From bbe11ba55eb272b53b644b10613c3731978fafdf Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Thu, 9 Feb 2023 22:18:35 +0100 Subject: [PATCH 001/494] Added kth roots to Permutation Added integer_partition_with_given_parts in partition.py (for use in kth roots computations). --- src/sage/combinat/partition.py | 65 ++++++++ src/sage/combinat/permutation.py | 271 +++++++++++++++++++++++++++++++ 2 files changed, 336 insertions(+) diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index cf1b0c2aee9..7f2b8e9e6a2 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -9016,6 +9016,71 @@ def number_of_partitions_length(n, k, algorithm='hybrid'): from sage.libs.gap.libgap import libgap return ZZ(libgap.NrPartitions(ZZ(n), ZZ(k))) +def integer_partitions_with_given_parts(n,parts,decreasing_order=True): + r""" + Return all partitions of n with parts in parts. + + INPUT: + + - n -- an integer + - parts -- an iterable of integers + + EXAMPLES:: + + sage: from sage.combinat.partition import integer_partitions_with_given_parts + sage: N = 5 + sage: Parts = [1, 2, 4] + sage: list(integer_partitions_with_given_parts(N, Parts)) + [[4, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] + + sage: N = 62 + sage: Parts = [11, 7, 56, 23] + sage: list(integer_partitions_with_given_parts(N, Parts)) + [[23, 11, 7, 7, 7, 7], [11, 11, 11, 11, 11, 7]] + + sage: N = 5 + sage: Parts = [3] + sage: list(integer_partitions_with_given_parts(N, Parts)) + [] + + TESTS:: + + sage: N = 1 + sage: Parts = [] + sage: list(integer_partitions_with_given_parts(N, Parts)) + [] + + sage: N = 0 + sage: Parts = [1] + sage: list(integer_partitions_with_given_parts(N, Parts)) + [] + + sage: list(integer_partitions_with_given_parts(-1,[1, 2, 4])) + [] + + sage: list(integer_partitions_with_given_parts(5,[-1])) + Traceback (most recent call last): + ... + ValueError: all parts must be positives (strictly) + """ + Parts = list(parts) + + if Parts and min(Parts) <= 0: + raise ValueError('all parts must be positives (strictly)') + + if decreasing_order: + Parts.sort(reverse=True) + front = [(n, [], 0)] + lp = len(Parts) + while len(front) != 0: + M, L, i = front.pop() + for j in range(i, lp): + new_M = M - Parts[j] + if new_M > 0: + front.insert(0,(new_M, L+[Parts[j]], j)) + elif new_M == 0: + yield Partition(L+[Parts[j]]) + ########## # trac 14225: Partitions() is frequently used, but only weakly cached. Hence, diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index e64650bde6e..4c57f194f78 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5270,6 +5270,277 @@ def shifted_shuffle(self, other): right_permutohedron_interval(self.shifted_concatenation(other, "left")) + def kth_roots(self,k=2): + r""" + Return all k-th roots of self (as a generator). + + A k-th root of the permutation self is a permutation Gamma such that Gamma^k == self. + + INPUT: + + - k -- optional integer (default 2), at least 1 + + EXAMPLES:: + + sage: Sigma = Permutations(5).identity() + sage: list(Sigma.kth_roots(3)) + [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] + + sage: Sigma = Permutation('(1,3)') + sage: list(Sigma.kth_roots()) + [] + + For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test its k-th power). + + .. SEEALSO:: + + * :meth:`has_kth_root` + * :meth:`number_of_kth_roots` + + TESTS: + + We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`):: + + sage: [len(list(Permutations(n).identity().kth_roots())) for n in range(2,8)] + [2, 4, 10, 26, 76, 232] + + sage: list(Permutation('(1)').kth_roots()) + [[1]] + + sage: list(Permutations(4).identity().kth_roots(-1)) + Traceback (most recent call last): + ... + ValueError: k must be at least 1 + """ + + from sage.combinat.partition import integer_partitions_with_given_parts + from sage.combinat.set_partition import SetPartitions + from sage.categories.cartesian_product import cartesian_product + from sage.arith.misc import divisors, gcd + + def merging_cycles(list_of_cycles): + """ + Generate all l-cycles such that its k-th power is the product of cycles in Cycles (which conctains gcd(l,k) cycles of lenght l/gcd(l,k)) + """ + lC = len(list_of_cycles) + lperm = len(list_of_cycles[0]) + l = lC*lperm + Perm = [0 for i in range(l)] + for j in range(lperm): + Perm[j*lC] = list_of_cycles[0][j] + for p in Permutations(lC-1): + for indexes in cartesian_product([range(lperm) for _ in range(lC-1)]): + new_Perm = list(Perm) + for i in range(lC-1): + for j in range(lperm): + new_Perm[(p[i] + (indexes[i]+j)*lC) %l] = list_of_cycles[i+1][j] + gamma = Permutation(tuple(new_Perm)) + yield gamma + + def rewind(L,k): + """ + Construct the list M such that M[(j*k)%(len(M))] == L[j]. + """ + M = [0 for _ in L] + m = len(M) + for j in range(m): + M[(j*k)%m] = L[j] + return M + + if k < 1: + raise ValueError('k must be at least 1') + + P = Permutations(self.size()) + + # Creating dict {length: cycles of this length in the cycle decomposition of Sigma} + Cycles = {} + for c in self.cycle_tuples(singletons=True): + lc = len(c) + if lc not in Cycles: + Cycles[lc] = [] + Cycles[lc].append(c) + + # for each length m, collects all product of cycles which k-th power gives the product prod(Cycles[l]) + Possibilities = {m: [] for m in Cycles} + for m in Cycles: + N = len(Cycles[m]) + parts = [x for x in divisors(k) if gcd(m*x,k) == x] + b = False + for X in integer_partitions_with_given_parts(N,parts): + for partition in SetPartitions(N,X): + b = True + poss = [P.identity()] + for pa in partition: + poss = [p*q for p in poss for q in merging_cycles([rewind(Cycles[m][i-1],k//len(pa)) for i in pa])] + Possibilities[m] += poss + if not b: + return + + #Product of Possibilities (i.e. final result) + for L in cartesian_product(Possibilities.values()): + yield P.prod(L) + + def has_kth_root(self,k=2): + r""" + Decide if ``self`` has a k-th roots. + + A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. + + INPUT: + + - k -- optional integer (default 2), at least 1 + + EXAMPLES:: + + sage: Sigma = Permutations(5).identity() + sage: Sigma.has_kth_root(3) + True + + sage: Sigma = Permutation('(1,3)') + sage: Sigma.has_kth_root() + False + + .. SEEALSO:: + + * :meth:`kth_roots` + * :meth:`number_of_kth_roots` + + TESTS: + + We compute the number of permutations that have square roots (i.e. squares in `S_n`, :oeis:`A003483`):: + + sage: [len([p for p in Permutations(n) if p.has_kth_root()]) for n in range(2,7)] + [1, 3, 12, 60, 270] + + sage: Permutation('(1)').has_kth_root() + True + + sage: Permutations(4).identity().has_kth_root(-1) + Traceback (most recent call last): + ... + ValueError: k must be at least 1 + """ + + from sage.arith.misc import divisors, gcd + + def has_integer_partitions_with_given_parts(N,Parts): + """ + Generate all lists L with sum(L) == N and L[i] in Parts. If decreasing_order, then L with be non-increasing. + """ + parts = list(Parts) + front = [(N,[],0)] + lp = len(parts) + while len(front) != 0: + M,L,i = front.pop() + for j in range(i,lp): + new_M = M - parts[j] + if new_M > 0: + front.insert(0,(new_M, L+[parts[j]], j)) + elif new_M == 0: + return True + return False + + if k < 1: + raise ValueError('k must be at least 1') + + P = Permutations(self.size()) + + # Creating dict {length: number of cycles of this length in the cycle decomposition of self} + Cycles = {} + for c in self.cycle_tuples(singletons=True): + lc = len(c) + if lc not in Cycles: + Cycles[lc] = 0 + Cycles[lc] += 1 + + # for each length m, check if the number of m-cycles can come from a k-th power (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l,k)) + for m in Cycles: + N = Cycles[m] + parts = [x for x in divisors(k) if gcd(m*x,k) == x] + if not has_integer_partitions_with_given_parts(N,parts): + return False + return True + + def number_of_kth_roots(self,k=2): + r""" + Return the number of k-th roots of ``self``. + + A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. + + INPUT: + + - k -- optional integer (default 2), at least 1 + + EXAMPLES:: + + sage: Sigma = Permutations(5).identity() + sage: Sigma.number_of_kth_roots(3) + 21 + + sage: Sigma = Permutation('(1,3)') + sage: Sigma.number_of_kth_roots() + 0 + + .. SEEALSO:: + + * :meth:`kth_roots` + * :meth:`has_kth_root` + + TESTS: + + We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`), then the number of cubic roots:: + + sage: [Permutations(n).identity().number_of_kth_roots() for n in range(2,10)] + [2, 4, 10, 26, 76, 232, 764, 2620] + + sage: [Permutations(n).identity().number_of_kth_roots(3) for n in range(2,10)] + [1, 3, 9, 21, 81, 351, 1233, 5769] + + sage: Permutation('(1)').number_of_kth_roots() + 1 + + sage: Permutations(4).identity().number_of_kth_roots(-1) + Traceback (most recent call last): + ... + ValueError: k must be at least 1 + """ + + from sage.combinat.partition import integer_partitions_with_given_parts + from sage.combinat.set_partition import SetPartitions + from sage.arith.misc import divisors, gcd + from sage.misc.misc_c import prod + + if k < 1: + raise ValueError('k must be at least 1') + + P = Permutations(self.size()) + + # Creating dict {length: number of cycles of this length in the cycle decomposition of Sigma} + Cycles = {} + for c in self.cycle_tuples(singletons=True): + lc = len(c) + if lc not in Cycles: + Cycles[lc] = 0 + Cycles[lc] += 1 + + # for each length m, count the number of products of cycles which k-th power gives the product prod(Cycles[l]) + Counts = {m: 0 for m in Cycles} + for m in Cycles: + N = Cycles[m] + parts = [x for x in divisors(k) if gcd(m*x,k) == x] + b = False + for partition in integer_partitions_with_given_parts(N,parts,decreasing_order=True): + b = True + count = SetPartitions(N,partition).cardinality() + for x in partition: + count *= factorial(x-1) * m**(x-1) + Counts[m] += count + if not b: + return 0 + + #Product of Possibilities (i.e. final result) + return prod(Counts.values()) + def _tableau_contribution(T): r""" Get the number of SYT of shape(``T``). From 2e77794b0fda2dd236c88e8924025559fdcaf09c Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Fri, 10 Feb 2023 14:10:48 +0100 Subject: [PATCH 002/494] Deleted integer_partitions_with_given_parts Was redundant. Added comas. --- src/sage/combinat/partition.py | 66 -------------------------------- src/sage/combinat/permutation.py | 66 ++++++++++++-------------------- 2 files changed, 25 insertions(+), 107 deletions(-) diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 7f2b8e9e6a2..d2d204f06d4 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -9016,72 +9016,6 @@ def number_of_partitions_length(n, k, algorithm='hybrid'): from sage.libs.gap.libgap import libgap return ZZ(libgap.NrPartitions(ZZ(n), ZZ(k))) -def integer_partitions_with_given_parts(n,parts,decreasing_order=True): - r""" - Return all partitions of n with parts in parts. - - INPUT: - - - n -- an integer - - parts -- an iterable of integers - - EXAMPLES:: - - sage: from sage.combinat.partition import integer_partitions_with_given_parts - sage: N = 5 - sage: Parts = [1, 2, 4] - sage: list(integer_partitions_with_given_parts(N, Parts)) - [[4, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] - - sage: N = 62 - sage: Parts = [11, 7, 56, 23] - sage: list(integer_partitions_with_given_parts(N, Parts)) - [[23, 11, 7, 7, 7, 7], [11, 11, 11, 11, 11, 7]] - - sage: N = 5 - sage: Parts = [3] - sage: list(integer_partitions_with_given_parts(N, Parts)) - [] - - TESTS:: - - sage: N = 1 - sage: Parts = [] - sage: list(integer_partitions_with_given_parts(N, Parts)) - [] - - sage: N = 0 - sage: Parts = [1] - sage: list(integer_partitions_with_given_parts(N, Parts)) - [] - - sage: list(integer_partitions_with_given_parts(-1,[1, 2, 4])) - [] - - sage: list(integer_partitions_with_given_parts(5,[-1])) - Traceback (most recent call last): - ... - ValueError: all parts must be positives (strictly) - """ - Parts = list(parts) - - if Parts and min(Parts) <= 0: - raise ValueError('all parts must be positives (strictly)') - - if decreasing_order: - Parts.sort(reverse=True) - front = [(n, [], 0)] - lp = len(Parts) - while len(front) != 0: - M, L, i = front.pop() - for j in range(i, lp): - new_M = M - Parts[j] - if new_M > 0: - front.insert(0,(new_M, L+[Parts[j]], j)) - elif new_M == 0: - yield Partition(L+[Parts[j]]) - - ########## # trac 14225: Partitions() is frequently used, but only weakly cached. Hence, # establish a strong reference to it. diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 4c57f194f78..c5a65098206 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5270,7 +5270,7 @@ def shifted_shuffle(self, other): right_permutohedron_interval(self.shifted_concatenation(other, "left")) - def kth_roots(self,k=2): + def kth_roots(self, k=2): r""" Return all k-th roots of self (as a generator). @@ -5286,7 +5286,7 @@ def kth_roots(self,k=2): sage: list(Sigma.kth_roots(3)) [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] - sage: Sigma = Permutation('(1,3)') + sage: Sigma = Permutation('(1, 3)') sage: list(Sigma.kth_roots()) [] @@ -5313,14 +5313,14 @@ def kth_roots(self,k=2): ValueError: k must be at least 1 """ - from sage.combinat.partition import integer_partitions_with_given_parts + from sage.combinat.partition import Partitions from sage.combinat.set_partition import SetPartitions from sage.categories.cartesian_product import cartesian_product from sage.arith.misc import divisors, gcd def merging_cycles(list_of_cycles): """ - Generate all l-cycles such that its k-th power is the product of cycles in Cycles (which conctains gcd(l,k) cycles of lenght l/gcd(l,k)) + Generate all l-cycles such that its k-th power is the product of cycles in Cycles (which conctains gcd(l, k) cycles of lenght l/gcd(l, k)) """ lC = len(list_of_cycles) lperm = len(list_of_cycles[0]) @@ -5329,15 +5329,15 @@ def merging_cycles(list_of_cycles): for j in range(lperm): Perm[j*lC] = list_of_cycles[0][j] for p in Permutations(lC-1): - for indexes in cartesian_product([range(lperm) for _ in range(lC-1)]): + for indices in cartesian_product([range(lperm) for _ in range(lC-1)]): new_Perm = list(Perm) for i in range(lC-1): for j in range(lperm): - new_Perm[(p[i] + (indexes[i]+j)*lC) %l] = list_of_cycles[i+1][j] + new_Perm[(p[i] + (indices[i]+j)*lC) %l] = list_of_cycles[i+1][j] gamma = Permutation(tuple(new_Perm)) yield gamma - def rewind(L,k): + def rewind(L, k): """ Construct the list M such that M[(j*k)%(len(M))] == L[j]. """ @@ -5364,14 +5364,14 @@ def rewind(L,k): Possibilities = {m: [] for m in Cycles} for m in Cycles: N = len(Cycles[m]) - parts = [x for x in divisors(k) if gcd(m*x,k) == x] + parts = [x for x in divisors(k) if gcd(m*x, k) == x] b = False - for X in integer_partitions_with_given_parts(N,parts): - for partition in SetPartitions(N,X): + for X in Partitions(N, parts_in=parts): + for partition in SetPartitions(N, X): b = True poss = [P.identity()] for pa in partition: - poss = [p*q for p in poss for q in merging_cycles([rewind(Cycles[m][i-1],k//len(pa)) for i in pa])] + poss = [p*q for p in poss for q in merging_cycles([rewind(Cycles[m][i-1], k//len(pa)) for i in pa])] Possibilities[m] += poss if not b: return @@ -5380,7 +5380,7 @@ def rewind(L,k): for L in cartesian_product(Possibilities.values()): yield P.prod(L) - def has_kth_root(self,k=2): + def has_kth_root(self, k=2): r""" Decide if ``self`` has a k-th roots. @@ -5396,7 +5396,7 @@ def has_kth_root(self,k=2): sage: Sigma.has_kth_root(3) True - sage: Sigma = Permutation('(1,3)') + sage: Sigma = Permutation('(1, 3)') sage: Sigma.has_kth_root() False @@ -5409,7 +5409,7 @@ def has_kth_root(self,k=2): We compute the number of permutations that have square roots (i.e. squares in `S_n`, :oeis:`A003483`):: - sage: [len([p for p in Permutations(n) if p.has_kth_root()]) for n in range(2,7)] + sage: [len([p for p in Permutations(n) if p.has_kth_root()]) for n in range(2, 7)] [1, 3, 12, 60, 270] sage: Permutation('(1)').has_kth_root() @@ -5421,25 +5421,9 @@ def has_kth_root(self,k=2): ValueError: k must be at least 1 """ + from sage.combinat.partition import Partitions from sage.arith.misc import divisors, gcd - def has_integer_partitions_with_given_parts(N,Parts): - """ - Generate all lists L with sum(L) == N and L[i] in Parts. If decreasing_order, then L with be non-increasing. - """ - parts = list(Parts) - front = [(N,[],0)] - lp = len(parts) - while len(front) != 0: - M,L,i = front.pop() - for j in range(i,lp): - new_M = M - parts[j] - if new_M > 0: - front.insert(0,(new_M, L+[parts[j]], j)) - elif new_M == 0: - return True - return False - if k < 1: raise ValueError('k must be at least 1') @@ -5456,12 +5440,12 @@ def has_integer_partitions_with_given_parts(N,Parts): # for each length m, check if the number of m-cycles can come from a k-th power (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l,k)) for m in Cycles: N = Cycles[m] - parts = [x for x in divisors(k) if gcd(m*x,k) == x] - if not has_integer_partitions_with_given_parts(N,parts): + parts = [x for x in divisors(k) if gcd(m*x, k) == x] + if (Partitions(N, parts_in=parts)): return False return True - def number_of_kth_roots(self,k=2): + def number_of_kth_roots(self, k=2): r""" Return the number of k-th roots of ``self``. @@ -5477,7 +5461,7 @@ def number_of_kth_roots(self,k=2): sage: Sigma.number_of_kth_roots(3) 21 - sage: Sigma = Permutation('(1,3)') + sage: Sigma = Permutation('(1, 3)') sage: Sigma.number_of_kth_roots() 0 @@ -5490,10 +5474,10 @@ def number_of_kth_roots(self,k=2): We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`), then the number of cubic roots:: - sage: [Permutations(n).identity().number_of_kth_roots() for n in range(2,10)] + sage: [Permutations(n).identity().number_of_kth_roots() for n in range(2, 10)] [2, 4, 10, 26, 76, 232, 764, 2620] - sage: [Permutations(n).identity().number_of_kth_roots(3) for n in range(2,10)] + sage: [Permutations(n).identity().number_of_kth_roots(3) for n in range(2, 10)] [1, 3, 9, 21, 81, 351, 1233, 5769] sage: Permutation('(1)').number_of_kth_roots() @@ -5505,7 +5489,7 @@ def number_of_kth_roots(self,k=2): ValueError: k must be at least 1 """ - from sage.combinat.partition import integer_partitions_with_given_parts + from sage.combinat.partition import Partitions from sage.combinat.set_partition import SetPartitions from sage.arith.misc import divisors, gcd from sage.misc.misc_c import prod @@ -5527,11 +5511,11 @@ def number_of_kth_roots(self,k=2): Counts = {m: 0 for m in Cycles} for m in Cycles: N = Cycles[m] - parts = [x for x in divisors(k) if gcd(m*x,k) == x] + parts = [x for x in divisors(k) if gcd(m*x, k) == x] b = False - for partition in integer_partitions_with_given_parts(N,parts,decreasing_order=True): + for partition in Partitions(N, parts_in=parts): b = True - count = SetPartitions(N,partition).cardinality() + count = SetPartitions(N, partition).cardinality() for x in partition: count *= factorial(x-1) * m**(x-1) Counts[m] += count From c9d180d00cedd084d4905dc740b1aecc1911d2b9 Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Fri, 10 Feb 2023 14:16:37 +0100 Subject: [PATCH 003/494] "len" was lacking --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index c5a65098206..75356444e85 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5441,7 +5441,7 @@ def has_kth_root(self, k=2): for m in Cycles: N = Cycles[m] parts = [x for x in divisors(k) if gcd(m*x, k) == x] - if (Partitions(N, parts_in=parts)): + if len(Partitions(N, parts_in=parts)): return False return True From fbd6c666d464f4a68706945b61c267fac0338f5c Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Fri, 10 Feb 2023 14:39:42 +0100 Subject: [PATCH 004/494] Improved doc: number roots depend only cyclic type --- src/sage/combinat/permutation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 75356444e85..217469d9bc8 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5275,6 +5275,8 @@ def kth_roots(self, k=2): Return all k-th roots of self (as a generator). A k-th root of the permutation self is a permutation Gamma such that Gamma^k == self. + + Note that the number of k-th roots only depend on the cyclic type of `self`. INPUT: @@ -5385,6 +5387,8 @@ def has_kth_root(self, k=2): Decide if ``self`` has a k-th roots. A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. + + Note that the number of k-th roots only depend on the cyclic type of `self`. INPUT: @@ -5441,7 +5445,7 @@ def has_kth_root(self, k=2): for m in Cycles: N = Cycles[m] parts = [x for x in divisors(k) if gcd(m*x, k) == x] - if len(Partitions(N, parts_in=parts)): + if not len(Partitions(N, parts_in=parts)): return False return True @@ -5450,7 +5454,9 @@ def number_of_kth_roots(self, k=2): Return the number of k-th roots of ``self``. A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. - + + Note that the number of k-th roots only depend on the cyclic type of `self`. + INPUT: - k -- optional integer (default 2), at least 1 From 6648bd9c598d57940c182e6da2d1634165e09581 Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Sun, 12 Feb 2023 11:31:45 +0100 Subject: [PATCH 005/494] Restore partition --- src/sage/combinat/partition.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index d2d204f06d4..cf1b0c2aee9 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -9016,6 +9016,7 @@ def number_of_partitions_length(n, k, algorithm='hybrid'): from sage.libs.gap.libgap import libgap return ZZ(libgap.NrPartitions(ZZ(n), ZZ(k))) + ########## # trac 14225: Partitions() is frequently used, but only weakly cached. Hence, # establish a strong reference to it. From 99973a53753e0fc80d9ebfbb128240ff57bd12e7 Mon Sep 17 00:00:00 2001 From: Germain Poullot Date: Sun, 12 Feb 2023 15:42:55 +0100 Subject: [PATCH 006/494] Change to nth_roots and improve code Change kth to nth Improve number_of_nth_roots (better way to iter and more readable) Idem for has_nth_root Minor improvements in nth_roots --- src/sage/combinat/permutation.py | 195 +++++++++++++++---------------- 1 file changed, 92 insertions(+), 103 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 217469d9bc8..24d8398b783 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5270,49 +5270,52 @@ def shifted_shuffle(self, other): right_permutohedron_interval(self.shifted_concatenation(other, "left")) - def kth_roots(self, k=2): + def nth_roots(self, n): r""" - Return all k-th roots of self (as a generator). + Return all n-th roots of ``self`` (as a generator). - A k-th root of the permutation self is a permutation Gamma such that Gamma^k == self. + A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of k-th roots only depend on the cyclic type of `self`. - - INPUT: - - - k -- optional integer (default 2), at least 1 + Note that the number of n-th roots only depend on the cyclic type of ``self``. EXAMPLES:: sage: Sigma = Permutations(5).identity() - sage: list(Sigma.kth_roots(3)) + sage: list(Sigma.nth_roots(3)) [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] sage: Sigma = Permutation('(1, 3)') - sage: list(Sigma.kth_roots()) + sage: list(Sigma.nth_roots(2)) [] - For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test its k-th power). + For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test their n-th power). .. SEEALSO:: - * :meth:`has_kth_root` - * :meth:`number_of_kth_roots` + * :meth:`has_nth_root` + * :meth:`number_of_nth_roots` TESTS: We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`):: - sage: [len(list(Permutations(n).identity().kth_roots())) for n in range(2,8)] + sage: [len(list(Permutations(n).identity().nth_roots(2))) for n in range(2,8)] [2, 4, 10, 26, 76, 232] - sage: list(Permutation('(1)').kth_roots()) + sage: list(Permutation('(1)').nth_roots(2)) [[1]] + + sage: list(Permutation('').nth_roots(2)) + [[]] + + sage: Sigma = Permutations(6).random_element() + sage: list(Sigma.nth_roots(1)) == [Sigma] + True - sage: list(Permutations(4).identity().kth_roots(-1)) + sage: list(Permutations(4).identity().nth_roots(-1)) Traceback (most recent call last): ... - ValueError: k must be at least 1 + ValueError: n must be at least 1 """ from sage.combinat.partition import Partitions @@ -5322,7 +5325,7 @@ def kth_roots(self, k=2): def merging_cycles(list_of_cycles): """ - Generate all l-cycles such that its k-th power is the product of cycles in Cycles (which conctains gcd(l, k) cycles of lenght l/gcd(l, k)) + Generate all l-cycles such that its n-th power is the product of cycles in Cycles (which conctains gcd(l, n) cycles of lenght l/gcd(l, n)) """ lC = len(list_of_cycles) lperm = len(list_of_cycles[0]) @@ -5339,18 +5342,18 @@ def merging_cycles(list_of_cycles): gamma = Permutation(tuple(new_Perm)) yield gamma - def rewind(L, k): + def rewind(L, n): """ - Construct the list M such that M[(j*k)%(len(M))] == L[j]. + Construct the list M such that M[(j*n)%(len(M))] == L[j]. """ M = [0 for _ in L] m = len(M) for j in range(m): - M[(j*k)%m] = L[j] + M[(j*n)%m] = L[j] return M - if k < 1: - raise ValueError('k must be at least 1') + if n < 1: + raise ValueError('n must be at least 1') P = Permutations(self.size()) @@ -5362,18 +5365,19 @@ def rewind(L, k): Cycles[lc] = [] Cycles[lc].append(c) - # for each length m, collects all product of cycles which k-th power gives the product prod(Cycles[l]) + # for each length m, collects all product of cycles which n-th power gives the product prod(Cycles[l]) Possibilities = {m: [] for m in Cycles} for m in Cycles: N = len(Cycles[m]) - parts = [x for x in divisors(k) if gcd(m*x, k) == x] + parts = [x for x in divisors(n) if gcd(m*x, n) == x] b = False for X in Partitions(N, parts_in=parts): for partition in SetPartitions(N, X): b = True poss = [P.identity()] for pa in partition: - poss = [p*q for p in poss for q in merging_cycles([rewind(Cycles[m][i-1], k//len(pa)) for i in pa])] + poss = [p*q for p in poss + for q in merging_cycles([rewind(Cycles[m][i-1], n//len(pa)) for i in pa])] Possibilities[m] += poss if not b: return @@ -5382,117 +5386,117 @@ def rewind(L, k): for L in cartesian_product(Possibilities.values()): yield P.prod(L) - def has_kth_root(self, k=2): + def has_nth_root(self, n): r""" - Decide if ``self`` has a k-th roots. + Decide if ``self`` has n-th roots. - A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. + A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of k-th roots only depend on the cyclic type of `self`. - - INPUT: - - - k -- optional integer (default 2), at least 1 + Note that the number of n-th roots only depend on the cyclic type of ``self``. EXAMPLES:: sage: Sigma = Permutations(5).identity() - sage: Sigma.has_kth_root(3) + sage: Sigma.has_nth_root(3) True sage: Sigma = Permutation('(1, 3)') - sage: Sigma.has_kth_root() + sage: Sigma.has_nth_root(2) False .. SEEALSO:: - * :meth:`kth_roots` - * :meth:`number_of_kth_roots` + * :meth:`nth_roots` + * :meth:`number_of_nth_roots` TESTS: We compute the number of permutations that have square roots (i.e. squares in `S_n`, :oeis:`A003483`):: - sage: [len([p for p in Permutations(n) if p.has_kth_root()]) for n in range(2, 7)] + sage: [len([p for p in Permutations(n) if p.has_nth_root(2)]) for n in range(2, 7)] [1, 3, 12, 60, 270] - sage: Permutation('(1)').has_kth_root() + sage: Permutation('(1)').has_nth_root(2) + True + + sage: Permutation('').has_nth_root(2) + True + + sage: Sigma = Permutations(6).random_element() + sage: Sigma.has_nth_root(1) True - sage: Permutations(4).identity().has_kth_root(-1) + sage: Permutations(4).identity().has_nth_root(-1) Traceback (most recent call last): ... - ValueError: k must be at least 1 + ValueError: n must be at least 1 """ from sage.combinat.partition import Partitions from sage.arith.misc import divisors, gcd + from sage.rings.integer import Integer - if k < 1: - raise ValueError('k must be at least 1') - - P = Permutations(self.size()) + if n < 1: + raise ValueError('n must be at least 1') - # Creating dict {length: number of cycles of this length in the cycle decomposition of self} - Cycles = {} - for c in self.cycle_tuples(singletons=True): - lc = len(c) - if lc not in Cycles: - Cycles[lc] = 0 - Cycles[lc] += 1 - - # for each length m, check if the number of m-cycles can come from a k-th power (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l,k)) - for m in Cycles: - N = Cycles[m] - parts = [x for x in divisors(k) if gcd(m*x, k) == x] - if not len(Partitions(N, parts_in=parts)): + Cycles = self.cycle_type().to_exp_dict() + + # for each length m, check if the number of m-cycles can come from a n-th power + # (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l, n)) + for m, N in Cycles.items(): + N = Integer(N) # I don't know why but ._findfirst doesn't work without + parts = [x for x in divisors(n) if gcd(m*x, n) == x] + if not Partitions(0, parts_in=[])._findfirst(N, parts): return False return True - def number_of_kth_roots(self, k=2): + def number_of_nth_roots(self, n): r""" - Return the number of k-th roots of ``self``. + Return the number of n-th roots of ``self``. - A k-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^k = self`. + A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of k-th roots only depend on the cyclic type of `self`. + Note that the number of n-th roots only depend on the cyclic type of ``self``. - INPUT: - - - k -- optional integer (default 2), at least 1 - EXAMPLES:: sage: Sigma = Permutations(5).identity() - sage: Sigma.number_of_kth_roots(3) + sage: Sigma.number_of_nth_roots(3) 21 sage: Sigma = Permutation('(1, 3)') - sage: Sigma.number_of_kth_roots() + sage: Sigma.number_of_nth_roots(2) 0 .. SEEALSO:: - * :meth:`kth_roots` - * :meth:`has_kth_root` + * :meth:`nth_roots` + * :meth:`has_nth_root` TESTS: We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`), then the number of cubic roots:: - sage: [Permutations(n).identity().number_of_kth_roots() for n in range(2, 10)] + sage: [Permutations(n).identity().number_of_nth_roots(2) for n in range(2, 10)] [2, 4, 10, 26, 76, 232, 764, 2620] - sage: [Permutations(n).identity().number_of_kth_roots(3) for n in range(2, 10)] + sage: [Permutations(n).identity().number_of_nth_roots(3) for n in range(2, 10)] [1, 3, 9, 21, 81, 351, 1233, 5769] - sage: Permutation('(1)').number_of_kth_roots() + sage: Permutation('(1)').number_of_nth_roots(2) + 1 + + sage: Permutation('').number_of_nth_roots(2) + 1 + + sage: Sigma = Permutations(6).random_element() + sage: Sigma.number_of_nth_roots(1) 1 - sage: Permutations(4).identity().number_of_kth_roots(-1) + sage: Permutations(4).identity().number_of_nth_roots(-1) Traceback (most recent call last): ... - ValueError: k must be at least 1 + ValueError: n must be at least 1 """ from sage.combinat.partition import Partitions @@ -5500,36 +5504,21 @@ def number_of_kth_roots(self, k=2): from sage.arith.misc import divisors, gcd from sage.misc.misc_c import prod - if k < 1: - raise ValueError('k must be at least 1') + if n < 1: + raise ValueError('n must be at least 1') - P = Permutations(self.size()) + Cycles = self.cycle_type().to_exp_dict() + Result = 1 + for m, N in Cycles.items(): + parts = [x for x in divisors(n) if gcd(m*x, n) == x] + Result *= sum(SetPartitions(N, pa).cardinality() * + prod(factorial(x-1) * m**(x-1) for x in pa) + for pa in Partitions(N, parts_in=parts)) - # Creating dict {length: number of cycles of this length in the cycle decomposition of Sigma} - Cycles = {} - for c in self.cycle_tuples(singletons=True): - lc = len(c) - if lc not in Cycles: - Cycles[lc] = 0 - Cycles[lc] += 1 + if not Result: + return 0 - # for each length m, count the number of products of cycles which k-th power gives the product prod(Cycles[l]) - Counts = {m: 0 for m in Cycles} - for m in Cycles: - N = Cycles[m] - parts = [x for x in divisors(k) if gcd(m*x, k) == x] - b = False - for partition in Partitions(N, parts_in=parts): - b = True - count = SetPartitions(N, partition).cardinality() - for x in partition: - count *= factorial(x-1) * m**(x-1) - Counts[m] += count - if not b: - return 0 - - #Product of Possibilities (i.e. final result) - return prod(Counts.values()) + return Result def _tableau_contribution(T): r""" From 459585fa48350f8d3c51b45bbd3f7926439859aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 18 Apr 2023 09:58:34 +0200 Subject: [PATCH 007/494] Update permutation.py remove some spaces in empty lines --- src/sage/combinat/permutation.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index e1a375da273..c3d15877515 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5477,28 +5477,28 @@ def has_nth_root(self, n): def number_of_nth_roots(self, n): r""" Return the number of n-th roots of ``self``. - + A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cyclic type of ``self``. EXAMPLES:: - + sage: Sigma = Permutations(5).identity() sage: Sigma.number_of_nth_roots(3) 21 - + sage: Sigma = Permutation('(1, 3)') sage: Sigma.number_of_nth_roots(2) 0 - + .. SEEALSO:: - + * :meth:`nth_roots` * :meth:`has_nth_root` - + TESTS: - + We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`), then the number of cubic roots:: sage: [Permutations(n).identity().number_of_nth_roots(2) for n in range(2, 10)] @@ -5522,7 +5522,6 @@ def number_of_nth_roots(self, n): ... ValueError: n must be at least 1 """ - from sage.combinat.partition import Partitions from sage.combinat.set_partition import SetPartitions from sage.arith.misc import divisors, gcd @@ -5530,7 +5529,7 @@ def number_of_nth_roots(self, n): if n < 1: raise ValueError('n must be at least 1') - + Cycles = self.cycle_type().to_exp_dict() Result = 1 for m, N in Cycles.items(): @@ -5538,10 +5537,10 @@ def number_of_nth_roots(self, n): Result *= sum(SetPartitions(N, pa).cardinality() * prod(factorial(x-1) * m**(x-1) for x in pa) for pa in Partitions(N, parts_in=parts)) - + if not Result: - return 0 - + return 0 + return Result def _tableau_contribution(T): From 500d520f9d297ecf9ad62008bf3d26289893bd94 Mon Sep 17 00:00:00 2001 From: ymusleh <44390016+ymusleh@users.noreply.github.com> Date: Wed, 9 Aug 2023 23:36:28 -0400 Subject: [PATCH 008/494] Resolve merge conflicts --- .../finite_drinfeld_module.py | 451 ++++++++++++++---- 1 file changed, 364 insertions(+), 87 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index e2115323fb8..7923a780d49 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -23,9 +23,14 @@ # ***************************************************************************** from sage.matrix.constructor import Matrix +from sage.matrix.matrix_space import MatrixSpace +from sage.matrix.special import companion_matrix from sage.modules.free_module_element import vector from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.function_field.drinfeld_modules.drinfeld_module import DrinfeldModule +from sage.functions.other import ceil, sqrt +from sage.functions.log import logb +from sage.misc.misc_c import prod class FiniteDrinfeldModule(DrinfeldModule): @@ -151,8 +156,76 @@ def __init__(self, gen, category): # added one to ensure that FiniteDrinfeldModule would always # have _frobenius_norm and _frobenius_trace attributes. super().__init__(gen, category) + self._base_degree_over_constants = self.base_over_constants_field().degree(self._Fq) self._frobenius_norm = None self._frobenius_trace = None + self._frobenius_charpoly = None + + def _frobenius_crystalline_matrix(self): + r""" + Return the matrix representing the Frobenius endomorphism on the + crystalline cohomology of the Drinfeld module. This is done up to + precision [K:Fq] + 1, which is enough to ensure the characteristic + polynomial can be recovered. + + For the formal construction of the crystalline cohomology, see + [Ang1997]_. It is a free module of rank r over the ring of Witt + vectors in `T - \mathfrak{p}`. + + EXAMPLES:: + + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(6) + sage: p_root = 2*z12^11 + 2*z12^10 + z12^9 + 3*z12^8 + z12^7 + 2*z12^5 + 2*z12^4 + 3*z12^3 + z12^2 + 2*z12 + sage: phi = DrinfeldModule(A, [p_root, z12^3, z12^5]) + sage: phi._frobenius_crystalline_matrix() + [...((z2 + 3) + z12 + (4*z2 + 1)*z12^2 + (z2 + 4)*z12^3 + (z2 + 4)*z12^4 + (2*z2 + 3)*z12^5)*T^3 + (2*z2 + 2*z2*z12 + (2*z2 + 3)*z12^2 + ... + (3*z2 + 4)*z12^3 + (2*z2 + 3)*z12^4 + 3*z2*z12^5] + + ALGORITHM: + + Compute the action of the Frobenius on an explicit basis for the + cohomology using a recurrence relation, and return the resulting + matrix. + """ + Fq = self._Fq + K = self.base_over_constants_field() + A = self.function_ring() + char, q = Fq.characteristic(), Fq.cardinality() + qdeg = logb(q, char) + r, n = self.rank(), self._base_degree_over_constants + nstar = ceil(sqrt(n)) + nquo, nrem = divmod(n, nstar) + drin_coeffs = self.coefficients(sparse=False) + poly_K = PolynomialRing(K, name=str(A.gen())) + matrix_poly_K = MatrixSpace(poly_K, r, r) + mu_coeffs = ((poly_K.gen() - drin_coeffs[0])**(n+1)) \ + .coefficients(sparse=False) + + def companion(order): + # + [1] is required to satisfy formatting for companion matrix + M = matrix_poly_K(companion_matrix([(drin_coeffs[i]/drin_coeffs[r]) + .frobenius(qdeg*order) + for i in range(r)] + [1], format='top')) + M[0, r-1] += poly_K.gen() / drin_coeffs[r].frobenius(qdeg*order) + return M + + companion_initial = prod([companion(i) for i in range(nrem, 0, -1)]) + companion_step = prod([companion(i) + for i in range(nstar + nrem, nrem, -1)]) + reduced_companions = [] + for k in range(nquo - 1, 0, -1): + M = Matrix(poly_K, r, r) + modulus = poly_K([c.frobenius(qdeg*(-k*nstar % n)) + for c in mu_coeffs]) + for i, row in enumerate(companion_step): + for j, entry in enumerate(row): + reduction = entry % modulus + M[i, j] = poly_K([c.frobenius(qdeg*(k*nstar)) + for c in reduction + .coefficients(sparse=False)]) + reduced_companions.append(M) + return (prod(reduced_companions) * companion_step * companion_initial) def frobenius_endomorphism(self): r""" @@ -183,46 +256,62 @@ def frobenius_endomorphism(self): deg = self.base_over_constants_field().degree_over() return self._Hom_(self, category=self.category())(t**deg) - def frobenius_charpoly(self, var='X'): + def frobenius_charpoly(self, var='X', algorithm='crystalline'): r""" Return the characteristic polynomial of the Frobenius - endomorphism if the rank is two. Raise a NotImplementedError - otherwise. + endomorphism. Let `\mathbb{F}_q` be the base field of the function ring. The - *characteristic polynomial `\chi` of the Frobenius endomorphism* + *characteristic polynomial* `\chi` *of the Frobenius endomorphism* is defined in [Gek1991]_. An important feature of this - polynomial is that it is a monic univariate polynomial with - coefficients in the function ring. As in our case the function + polynomial is that it is monic, univariate, and has coefficients + in the function ring. As in our case the function ring is a univariate polynomial ring, it is customary to see the characteristic polynomial of the Frobenius endomorphism as a bivariate polynomial. - Let `\chi = X^2 - A(T)X + B(T)` be the characteristic polynomial - of the Frobenius endomorphism, and let `t^n` be the Ore polynomial - that defines the Frobenius endomorphism of `\phi`; by - definition, `n` is the degree over of the base field over - `\mathbb{F}_q`. We have `\chi(t^n)(\phi(T)) = t^{2n} - \phi_A - t^n + \phi_B = 0`, with `\deg(A) \leq \frac{n}{2}` and `\deg(B) - = n`. + Let `\chi = X^r + \sum_{i=0}^{r-1} A_{i}(T)X^{i}` be the + characteristic polynomial of the Frobenius endomorphism, and + let `t^n` be the Ore polynomial that defines the Frobenius + endomorphism of `\phi`; by definition, `n` is the degree of `K` + over the base field `\mathbb{F}_q`. Then we have + + .. MATH:: + + \chi(t^n)(\phi(T)) + = t^{nr} + \sum_{i=1}^{r} \phi_{A_{i}}t^{n(i)} + = 0, + + with `\deg(A_i) \leq \frac{n(r-i)}{r}`. - Note that the *Frobenius trace* is defined as `A(T)` and the - *Frobenius norm* is defined as `B(T)`. + Note that the *Frobenius trace* is defined as `A_{r-1}(T)` and the + *Frobenius norm* is defined as `A_0(T)`. INPUT: - ``var`` (default: ``'X'``) -- the name of the second variable + - ``algorithm`` (default: ``'crystalline'``) -- the algorithm + used to compute the characteristic polynomial EXAMPLES:: + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(6) + sage: p_root = 2*z12^11 + 2*z12^10 + z12^9 + 3*z12^8 + z12^7 + 2*z12^5 + 2*z12^4 + 3*z12^3 + z12^2 + 2*z12 + sage: phi = DrinfeldModule(A, [p_root, z12^3, z12^5]) + sage: phi.frobenius_charpoly() + X^2 + ((4*z2 + 4)*T^3 + (z2 + 3)*T^2 + 3*T + 2*z2 + 3)*X + 3*z2*T^6 + (4*z2 + 3)*T^5 + (4*z2 + 4)*T^4 + 2*T^3 + (3*z2 + 3)*T^2 + (z2 + 2)*T + 4*z2 + + :: + sage: Fq = GF(343) sage: A. = Fq[] sage: K. = Fq.extension(2) sage: phi = DrinfeldModule(A, [1, 0, z6]) sage: chi = phi.frobenius_charpoly() sage: chi - X^2 + ((3*z3^2 + z3 + 4)*T + 4*z3^2 + 6*z3 + 3)*X - + (5*z3^2 + 2*z3)*T^2 + (4*z3^2 + 3*z3)*T + 5*z3^2 + 2*z3 + X^2 + ((3*z3^2 + z3 + 4)*T + 4*z3^2 + 6*z3 + 3)*X + (5*z3^2 + 2*z3)*T^2 + (4*z3^2 + 3*z3)*T + 5*z3^2 + 2*z3 :: @@ -232,51 +321,196 @@ def frobenius_charpoly(self, var='X'): :: - sage: trace = phi.frobenius_trace() - sage: trace - (4*z3^2 + 6*z3 + 3)*T + 3*z3^2 + z3 + 4 - sage: norm = phi.frobenius_norm() - sage: norm - (5*z3^2 + 2*z3)*T^2 + (4*z3^2 + 3*z3)*T + 5*z3^2 + 2*z3 + sage: phi.frobenius_charpoly(algorithm="NotImplemented") + Traceback (most recent call last): + NotImplementedError: algorithm "NotImplemented" not implemented + + ALGORITHM: + + By default, this method uses the so-called *crystalline* + algorithm which computes the characteristic polynomial of the + Frobenius acting on the crystalline cohomology of the Drinfeld + module. For further details, see [Ang1997]_. Currently, the only + alternative is to use the *Gekeler* approach based on solving + the linear system given by `t^{nr} + \sum_{i=0}^{r-1} + \phi_{A_{i}}t^{ni} = 0`. For more details, see [Gek2008]_. + """ + # Throw an error if the user asks for an unimplemented algorithm + # even if the char poly has already been computed + method_name = f'_frobenius_charpoly_{algorithm}' + if hasattr(self, method_name): + if self._frobenius_charpoly is not None: + return self._frobenius_charpoly + self._frobenius_charpoly = getattr(self, method_name)(var) + return self._frobenius_charpoly + raise NotImplementedError(f'algorithm \"{algorithm}\" not implemented') + + def _frobenius_charpoly_crystalline(self, var): + r""" + Return the characteristic polynomial of the Frobenius + endomorphism using Crystalline cohomology. + + The algorithm works for Drinfeld `\mathbb{F}_q[T]`-modules of + any rank. + + This method is private and should not be directly called. + Instead, use :meth:`frobenius_charpoly` with the option + `algorithm='crystalline'`. + + INPUT: + + - ``var`` -- the name of the second variable + + OUTPUT: a univariate polynomial with coefficients in the + function ring + + EXAMPLES:: + + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(6) + sage: p_root = 2*z12^11 + 2*z12^10 + z12^9 + 3*z12^8 + z12^7 + 2*z12^5 + 2*z12^4 + 3*z12^3 + z12^2 + 2*z12 + sage: phi = DrinfeldModule(A, [p_root, z12^3, z12^5]) + sage: phi.frobenius_charpoly(algorithm='crystalline') # indirect doctest + X^2 + ((4*z2 + 4)*T^3 + (z2 + 3)*T^2 + 3*T + 2*z2 + 3)*X + 3*z2*T^6 + (4*z2 + 3)*T^5 + (4*z2 + 4)*T^4 + 2*T^3 + (3*z2 + 3)*T^2 + (z2 + 2)*T + 4*z2 :: - sage: n = 2 # Degree of the base field over Fq - sage: trace.degree() <= n/2 - True - sage: norm.degree() == n - True + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(8) + sage: phi = DrinfeldModule(A, [z, 4, 1, z, z+1, 2, z+2, 1, 1, 3, 1]) + sage: phi.frobenius_charpoly(algorithm='crystalline') # indirect doctest + X^10 + X^9 + (3*T + z2 + 1)*X^8 + (4*T^2 + z2*T + 2*z2 + 1)*X^7 + ... + (4*z2 + 4)*T^4 + 4*z2*T^2 + (z2 + 2)*T + z2 + + :: + + sage: Fq = GF(27) + sage: A. = Fq[] + sage: K. = Fq.extension(10) + sage: phi = DrinfeldModule(A, [z, z^2 + z, 2, 1, z, z+1, 2, z+2, 0, 1, 1, z^2 + z]) + sage: phi.frobenius_charpoly(algorithm='crystalline') # indirect doctest + X^11 + (z3^2 + 2*z3)*X^10 + ((z3 + 1)*T + z3)*X^9 + ((2*z3^2 + z3 + 2)*T^2 + ... + (2*z3^2 + 2*z3 + 2)*T + z3^2 ALGORITHM: - We compute the Frobenius norm, and with it the Frobenius - trace. This gives the Frobenius characteristic polynomial. - See [MS2019]_, Section 4. + Compute the characteristic polynomial of the Frobenius endomorphism + acting on the crystalline cohomology of a Drinfeld module, which + is equal to that of the Frobenius endomorphism on the Drinfeld + module. A recurrence on elements of the cohomology allows us to + compute a matrix representation of the Frobenius endomorphism + efficiently using a companion matrix method. + """ + A = self.function_ring() + K = self.base_over_constants_field() + charpoly_coeffs_K = self._frobenius_crystalline_matrix() \ + .charpoly(var).coefficients(sparse=False) + + # The above line obtains the char poly with coefficients in K[T] + # This maps them into A = Fq[T] + def coeff_A(coeff): + return A([K(x).vector()[0] for x in coeff]) + + coeffs_A = [coeff_A(c) for c in charpoly_coeffs_K] + return PolynomialRing(A, name=var)(coeffs_A) + + def _frobenius_charpoly_gekeler(self, var): + r""" + Return the characteristic polynomial of the Frobenius + endomorphism using Gekeler's algorithm. + + The algorithm works for Drinfeld `\mathbb{F}_q[T]`-modules of + any rank, provided that the constant coefficient is a generator + of the base field. + + This method is private and should not be directly called. + Instead, use :meth:`frobenius_charpoly` with the option + `algorithm='gekeler'`. + + .. WARNING: + + This algorithm only works in the generic case when the + corresponding linear system is invertible. Notable cases + where this fails include Drinfeld modules whose minimal + polynomial is not equal to the characteristic polynomial, + and rank 2 Drinfeld modules where the degree 1 coefficient + of `\phi_T` is 0. In that case, an exception is raised. + + INPUT: + + - ``var`` -- the name of the second variable - See docstrings of methods :meth:`frobenius_norm` and - :meth:`frobenius_trace` for further details on the - computation of the norm and of the trace. + OUTPUT: a univariate polynomial with coefficients in the + function ring + + EXAMPLES:: + + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(6) + sage: phi = DrinfeldModule(A, [z, 4, 1, z]) + sage: phi.frobenius_charpoly(algorithm='gekeler') # indirect doctest + X^3 + ((z2 + 2)*T^2 + (z2 + 2)*T + 4*z2 + 4)*X^2 + ... + (3*z2 + 2)*T^2 + (3*z2 + 3)*T + 4 + + :: + + sage: Fq = GF(125) + sage: A. = Fq[] + sage: K. = Fq.extension(2) + sage: phi = DrinfeldModule(A, [z, 0, z]) + sage: phi.frobenius_charpoly(algorithm='gekeler') # indirect doctest + Traceback (most recent call last): + NotImplementedError: 'Gekeler' algorithm failed + + ALGORITHM: + + Construct a linear system based on the requirement that the + Frobenius satisfies a degree r polynomial with coefficients in + the function ring. This generalizes the procedure from + [Gek2008]_ for the rank 2 case. """ - self._check_rank_two() - A = self._function_ring # Fq[T] - S = PolynomialRing(A, name=var) # Fq[T][X] - # Does not work when Fq is not a prime field... - # chi = self._gen.reduced_charpoly() - # return -chi(A.gen(), S.gen()) - return S([self.frobenius_norm(), -self.frobenius_trace(), 1]) + K = self.base_over_constants_field() + A = self.function_ring() + r, n = self.rank(), self._base_degree_over_constants + # Compute constants that determine the block structure of the + # linear system. The system is prepared such that the solution + # vector has the form [a_0, a_1, ... a_{r-1}]^T with each a_i + # corresponding to a block of length (n*(r - i))//r + 1 + shifts = [(n*(r - i))//r + 1 for i in range(r)] + rows, cols = n*r + 1, sum(shifts) + block_shifts = [0] + for i in range(r-1): + block_shifts.append(block_shifts[-1] + shifts[i]) + # Compute the images \phi_T^i for i = 0 .. n. + gen_powers = [self(A.gen()**i).coefficients(sparse=False) + for i in range(0, n + 1)] + sys, vec = Matrix(K, rows, cols), vector(K, rows) + vec[rows - 1] = -1 + for j in range(r): + for k in range(shifts[j]): + for i in range(len(gen_powers[k])): + sys[i + n*j, block_shifts[j] + k] = gen_powers[k][i] + if sys.right_nullity() != 0: + raise NotImplementedError("'Gekeler' algorithm failed") + sol = list(sys.solve_right(vec)) + # The system is solved over L, but the coefficients should all be in Fq + # We project back into Fq here. + sol_Fq = [K(x).vector()[0] for x in sol] + char_poly = [] + for i in range(r): + char_poly.append([sol_Fq[block_shifts[i] + j] + for j in range(shifts[i])]) + return PolynomialRing(self._function_ring, name=var)(char_poly + [1]) def frobenius_norm(self): r""" - Return Frobenius norm of the Drinfeld module, if the rank is - two, raise a NotImplementedError otherwise. + Return the Frobenius norm of the Drinfeld module. - Let `\mathbb{F}_q[T]` be the function ring, write `\chi = X^2 - - A(T)X + B(T) \in \mathbb{F}_q[T][X]` for the characteristic - polynomial of the Frobenius endomorphism. The *Frobenius norm* - is defined as the polynomial `B(T) \in \mathbb{F}_q[T]`. - - Let `n` be the degree of the base field over `\mathbb{F}_q` Then the - Frobenius norm has degree `n`. + Let `C(X) = \sum_{i=0}^r a_iX^{i}` denote the characteristic + polynomial of the Frobenius endomorphism. The Frobenius norm + is `(-1)^r a_{0}`. This is an element of the regular function ring + and if `n` is the degree of the base field over `\mathbb{F}_q`, + then the Frobenius norm has degree `n`. EXAMPLES:: @@ -304,31 +538,24 @@ def frobenius_norm(self): The Frobenius norm is computed using the formula, by Gekeler, given in [MS2019]_, Section 4, Proposition 3. """ - self._check_rank_two() - L = self._base.over(self._Fq) - # Notations from Schost-Musleh: - if self._frobenius_norm is None: - n = L.degree_over(self._Fq) - d = self.characteristic().degree() - m = n // d - delta = self._gen[2] - norm = L(delta).norm() - char = self.characteristic() - self._frobenius_norm = ((-1)**n) * (char**m) / norm + if self._frobenius_norm is not None: + return self._frobenius_norm + K = self.base_over_constants_field() + n = K.degree(self._Fq) + char = self.characteristic() + norm = K(self.coefficients()[-1]).norm() + self._frobenius_norm = ((-1)**n)*(char**(n/char.degree())) / norm return self._frobenius_norm def frobenius_trace(self): r""" - Return Frobenius norm of the Drinfeld module, if the rank is - two; raise a NotImplementedError otherwise. + Return the Frobenius trace of the Drinfeld module. - Let `\mathbb{F}_q[T]` be the function ring, write `\chi = T^2 - - A(X)T + B(X) \in \mathbb{F}_q[T][X]` for the characteristic - polynomial of the Frobenius endomorphism. The *Frobenius trace* - is defined as the polynomial `A(T) \in \mathbb{F}_q[T]`. - - Let `n` be the degree over `\mathbb{F}_q` of the base codomain. - Then the Frobenius trace has degree at most `\frac{n}{2}`. + Let `C(X) = \sum_{i=0}^r a_iX^{i}` denote the characteristic + polynomial of the Frobenius endomorphism. The Frobenius trace + is `-a_{r-1}`. This is an element of the regular function ring + and if `n` is the degree of the base field over `\mathbb{F}_q`, + then the Frobenius trace has degree at most `\frac{n}{r}`. EXAMPLES:: @@ -353,24 +580,20 @@ def frobenius_trace(self): ALGORITHM: - Let `A(T)` denote the Frobenius trace and `B(T)` denote the - Frobenius norm. We begin by computing `B(T)`, see docstring - of method :meth:`frobenius_norm` for details. The - characteristic polynomial of the Frobenius yields `t^{2n} - - \phi_A t^n + \phi_B = 0`, where `t^n` is the Frobenius - endomorphism. As `\phi_B` is now known, we can compute - `\phi_A = (t^{2n} + \phi_B) / t^n`. We get `A(T)` by - inverting this quantity, using the method - :meth:`sage.rings.function_fields.drinfeld_module.drinfeld_module.DrinfeldModule.invert`, - see its docstring for details. + We extract the coefficient of `X^{r-1}` from the characteristic + polynomial if it has been previously computed, otherwise we compute + the trace of the matrix of the Frobenius acting on the crystalline + cohomology. """ - self._check_rank_two() - # Notations from Schost-Musleh: - if self._frobenius_trace is None: - n = self._base.over(self._Fq).degree_over(self._Fq) - B = self.frobenius_norm() - t = self.ore_polring().gen() - self._frobenius_trace = self.invert(t**n + (self(B) // t**n)) + K = self.base_over_constants_field() + A = self.function_ring() + if self._frobenius_trace is not None: + return self._frobenius_trace + if self._frobenius_charpoly is not None: + self._frobenius_trace = -self._frobenius_charpoly \ + .coefficients(sparse=False)[-2] + self._frobenius_trace = self._frobenius_crystalline_matrix().trace() + self._frobenius_trace = A([K(x).vector()[0] for x in self._frobenius_trace]) return self._frobenius_trace def invert(self, ore_pol): @@ -487,6 +710,60 @@ def invert(self, ore_pol): pass raise ValueError('input must be in the image of the Drinfeld module') + def is_isogenous(self, psi): + r""" + Return ``True`` when ``self`` is isogenous to the other + Drinfeld module. + + If the Drinfeld modules do not belong to the same category, an + exception is raised. + + EXAMPLES:: + + sage: Fq = GF(2) + sage: A. = Fq[] + sage: K. = Fq.extension(3) + sage: psi = DrinfeldModule(A, [z, z + 1, z^2 + z + 1]) + sage: phi = DrinfeldModule(A, [z, z^2 + z + 1, z^2 + z]) + sage: phi.is_isogenous(psi) + True + + :: + + sage: chi = DrinfeldModule(A, [z, z + 1, z^2 + z]) + sage: phi.is_isogenous(chi) + False + + :: + + sage: mu = DrinfeldModule(A, [z + 1, z^2 + z + 1, z^2 + z]) + sage: phi.is_isogenous(mu) + Traceback (most recent call last): + TypeError: Drinfeld modules are not in the same category + + :: + + sage: mu = 1 + sage: phi.is_isogenous(mu) + Traceback (most recent call last): + TypeError: input must be a Drinfeld module + + ALGORITHM: + + Two Drinfeld A-modules of equal characteristic are isogenous + if and only if: + + - they have the same rank + - the characteristic polynomial of the Frobenius endomorphism + for both Drinfeld modules are equal. + """ + if not isinstance(psi, DrinfeldModule): + raise TypeError("input must be a Drinfeld module") + if self.category() != psi.category(): + raise TypeError("Drinfeld modules are not in the same category") + return self.rank() == psi.rank() \ + and self.frobenius_charpoly() == psi.frobenius_charpoly() + def is_supersingular(self): r""" Return ``True`` if this Drinfeld module is supersingular. From 8121580ca9b700b8d496cd2079c463b302e6fb96 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 00:34:42 +0900 Subject: [PATCH 009/494] Rework sage live doc --- build/pkgs/jupyter_sphinx/checksums.ini | 6 +- build/pkgs/jupyter_sphinx/package-version.txt | 2 +- .../0001-Patch-for-sage-live-doc.patch | 75 +++ .../common/static/custom-jupyter-sphinx.css | 16 + src/doc/common/static/thebe-sage.js | 147 ------ .../common/themes/sage-classic/layout.html | 2 - .../themes/sage-classic/static/sage.css_t | 13 +- src/doc/en/tutorial/latex.rst | 370 ++++++++------ src/sage/env.py | 10 +- src/sage/plot/plot3d/plot3d.py | 465 +----------------- src/sage/repl/ipython_kernel/interact.py | 22 - src/sage/repl/rich_output/backend_ipython.py | 3 +- src/sage_docbuild/__main__.py | 5 + src/sage_docbuild/conf.py | 118 ++++- src/sage_docbuild/sphinxbuild.py | 4 +- 15 files changed, 458 insertions(+), 800 deletions(-) create mode 100644 build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch create mode 100644 src/doc/common/static/custom-jupyter-sphinx.css delete mode 100644 src/doc/common/static/thebe-sage.js diff --git a/build/pkgs/jupyter_sphinx/checksums.ini b/build/pkgs/jupyter_sphinx/checksums.ini index f53c5af453a..14f1bdf7594 100644 --- a/build/pkgs/jupyter_sphinx/checksums.ini +++ b/build/pkgs/jupyter_sphinx/checksums.ini @@ -1,5 +1,5 @@ tarball=jupyter_sphinx-VERSION.tar.gz -sha1=241f6dfcd3aae4f44f330e2ba76480011b382d3d -md5=e7ab370d9793be5b20bce5447ccbd45b -cksum=2021246952 +sha1=fb2abdd5e35da0886b12d45a6373c4dbcc24b244 +md5=130daa6be810976c9f8e30aa04011e50 +cksum=2882523000 upstream_url=https://pypi.io/packages/source/j/jupyter_sphinx/jupyter_sphinx-VERSION.tar.gz diff --git a/build/pkgs/jupyter_sphinx/package-version.txt b/build/pkgs/jupyter_sphinx/package-version.txt index d15723fbe8d..1d0ba9ea182 100644 --- a/build/pkgs/jupyter_sphinx/package-version.txt +++ b/build/pkgs/jupyter_sphinx/package-version.txt @@ -1 +1 @@ -0.3.2 +0.4.0 diff --git a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch new file mode 100644 index 00000000000..bfd767028db --- /dev/null +++ b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch @@ -0,0 +1,75 @@ +From 4d6c87f4144110d7f361f11ead41f1b6f602b20d Mon Sep 17 00:00:00 2001 +From: Kwankyu Lee +Date: Mon, 28 Aug 2023 00:18:59 +0900 +Subject: [PATCH] Patch for sage live doc + +--- + jupyter_sphinx/__init__.py | 8 +++++--- + jupyter_sphinx/execute.py | 11 +++++++++++ + 2 files changed, 16 insertions(+), 3 deletions(-) + +diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py +index 34af884..f5a7f44 100644 +--- a/jupyter_sphinx/__init__.py ++++ b/jupyter_sphinx/__init__.py +@@ -2,6 +2,7 @@ + + from pathlib import Path + ++import os + import docutils + import ipywidgets + from IPython.lib.lexers import IPython3Lexer, IPythonTracebackLexer +@@ -31,7 +32,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource + REQUIRE_URL_DEFAULT = ( + "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js" + ) +-THEBELAB_URL_DEFAULT = "https://unpkg.com/thebelab@^0.4.0" ++THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@latest/lib/index.js" + + logger = logging.getLogger(__name__) + +@@ -186,7 +187,7 @@ def setup(app): + app.add_config_value("jupyter_sphinx_embed_url", None, "html") + + # thebelab config, can be either a filename or a dict +- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html") ++ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env") + app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html") + + # linenos config +@@ -290,7 +291,8 @@ def setup(app): + app.add_lexer("ipythontb", IPythonTracebackLexer) + app.add_lexer("ipython3", IPython3Lexer) + +- app.connect("builder-inited", builder_inited) ++ if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': ++ app.connect("builder-inited", builder_inited) + app.connect("build-finished", build_finished) + + # add jupyter-sphinx and thebelab js and css +diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py +index 558a26b..bebb000 100644 +--- a/jupyter_sphinx/execute.py ++++ b/jupyter_sphinx/execute.py +@@ -152,6 +152,17 @@ class ExecuteJupyterCells(SphinxTransform): + kernel_name = default_kernel + file_name = next(default_names) + ++ # save time when jupyter notebook execution is not necessary ++ if not any(not "execute" in node or node["execute"] for node in nodes): ++ # mimics empty cell output for each node ++ for node in nodes: ++ source = node.children[0] ++ source.attributes["classes"].append("code_cell") ++ node.attributes["cm_language"] = 'sage' ++ node += CellOutputNode(classes=["cell_output"]) ++ apply_styling(node, thebe_config) ++ continue ++ + # Add empty placeholder cells for non-executed nodes so nodes + # and cells can be zipped and the provided input/output + # can be inserted later +-- +2.40.1 + diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css new file mode 100644 index 00000000000..e560cb370ba --- /dev/null +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -0,0 +1,16 @@ +div.jupyter_container { + margin: .5em 0; +} + +div.jupyter_container + div.jupyter_container { + margin: 0 0 0.5em 0; +} + +div.jupyter_container div.cell_input pre { + margin: .5em; +} + +div.jupyter_container div.cell_output div.output { + margin: .5em; +} + diff --git a/src/doc/common/static/thebe-sage.js b/src/doc/common/static/thebe-sage.js deleted file mode 100644 index 567e3488802..00000000000 --- a/src/doc/common/static/thebe-sage.js +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @overview - * This file aims at replacing the document's Sage code blocks by executable - * notebook cells. Users are presented a dedicated button in the top right - * corner. When they click on it, each code block is appended a "Run" button - * to execute the corresponding code. - * - * This is based on the Thebe library (https://github.com/oreillymedia/thebe/) - * installed in ${SAGE_ROOT}/local/share/thebe/thebe.js by Sage's thebe package. - */ - -$(function() { - - /** - * Build and return the Thebe instance that will communicate with the - * Jupyter notebook (or tmpnb server). - * - * This function categorizes the cells lines into "code" and "result" - * categories to refine the given cell selector and pass only the code - * lines to Thebe. - * - * @param {String} cellSelector - A jQuery selector that matches the cells - * @param {Object} thebeOptions - Thebe options, must not contain "selector" - */ - function setupThebeSage(cellSelector, thebeOptions) { - var lineClass = 'sage-cell-line', - codeClass = 'sage-code', - codeBlockClass = 'sage-code-block', - resultClass = 'sage-expected-result', - resultBlockClass = 'sage-expect-result-block'; - $(cellSelector).each(function() { - wrapEachCellLine(this, lineClass); - categorizeCellLines(this, lineClass, codeClass, resultClass); - wrapLineBlocks(this, lineClass, codeClass, codeBlockClass); - wrapLineBlocks(this, lineClass, resultClass, resultBlockClass); - $('.' + resultBlockClass, this).hide(); - sanitizeCode(this, codeClass); - }); - thebeOptions.selector = '.' + codeBlockClass; - return new Thebe(thebeOptions); - } - - /** - * Sanitize the code before executing. For now, transforms the code line - * into pure text, also stripping out the Sage prompts and continuation - * characters at line start, if any. - * - * @param {Element} cellNode - The DOM element of the cell - * @param {String} codeClass - The class name associated to code line - */ - function sanitizeCode(cellNode, codeClass) { - var rgx = /^(sage: )|(\.\.\.\.: )|(\.\.\. )/; - var codeLines = cellNode.getElementsByClassName(codeClass); - Array.prototype.forEach.call(codeLines, function(line) { - line.textContent = line.textContent.replace(rgx, ''); - }); - } - - /** - * Wrap consecutive lines of the same type in a given cell in line blocks. - * - * @param {Element} cellNode - The DOM element of the cell - * @param {String} lineClass - The class name that identifies all cell lines - * @param {String} specificClass - The class name that identifies the lines - * to be wrapped - * @param {String} blockClass - The class name to be given to the add - * wrapper blocks - */ - function wrapLineBlocks(cellNode, lineClass, specificClass, blockClass) { - var wrapper, - lines = cellNode.getElementsByClassName(lineClass); - Array.prototype.forEach.call(lines, function(line) { - if (line.classList.contains(specificClass)) { - if (! wrapper) { - wrapper = document.createElement('span'); - wrapper.classList.add(blockClass); - cellNode.insertBefore(wrapper, line); - } - wrapper.appendChild(line); - } else { - wrapper = null; - } - }); - } - - /** - * Add a class on each line of a cell to categorize them as code or result. - * - * @param {Element} cellNode - The DOM element of the cell to categorize the - * lines of - * @param {String} lineClass - A class name to identify each cell line - * @param {String} codeClass - A class name to be added on code lines - * @param {String} resultClass - A class name to be added on result lines - */ - function categorizeCellLines(cellNode, lineClass, codeClass, resultClass) { - var lines = cellNode.getElementsByClassName(lineClass); - var previousCategory; - Array.prototype.forEach.call(lines, function(line) { - var lineText = line.textContent; - if (lineText.startsWith('sage: ')) { - line.classList.add(codeClass); - previousCategory = 'code'; - return; - } - if (previousCategory === 'code' - && (lineText.startsWith('....: ') - || lineText.startsWith('... '))) { - line.classList.add(codeClass); - return; - } - line.classList.add(resultClass); - previousCategory = 'result'; - }); - } - - /** - * Add a (span) DOM element around each line of an executable cell - * - * @param {Element} cellNode - cell to wrap the lines of - * @param {String} lineClass - class attribute value for the added span tags - */ - function wrapEachCellLine(cellNode, lineClass) { - var html = ''; - cellNode.innerHTML.split('\n').forEach(function(htmlLine) { - html += '' + htmlLine + '\n'; - }); - cellNode.innerHTML = html; - } - - if (window.location.protocol.startsWith('http')) { - var cellSelector = "pre:contains('sage: ')"; - if ($(cellSelector).length > 0) { - $('') - .css({position: 'absolute', right: 0}) - .click(function() { - setupThebeSage(cellSelector, { - tmpnb_mode: false, - load_css: false, - url: window.location.origin, - kernel_name: "sagemath" - }); - $(this).attr('disabled', 'disabled'); - }) - .prependTo('div.body'); - } - } -}); diff --git a/src/doc/common/themes/sage-classic/layout.html b/src/doc/common/themes/sage-classic/layout.html index ab9a05261aa..1cea7f178a9 100644 --- a/src/doc/common/themes/sage-classic/layout.html +++ b/src/doc/common/themes/sage-classic/layout.html @@ -17,8 +17,6 @@ {% block extrahead %} - - {% endblock %} {%- block footer %} diff --git a/src/doc/common/themes/sage-classic/static/sage.css_t b/src/doc/common/themes/sage-classic/static/sage.css_t index 38b6159ec75..a0e96f4e1c4 100644 --- a/src/doc/common/themes/sage-classic/static/sage.css_t +++ b/src/doc/common/themes/sage-classic/static/sage.css_t @@ -373,10 +373,15 @@ dl.citation p { #thebelab-activate-button { position: fixed; - right: 10px; - bottom: 10px; + right: -100px; + top: 50%; + border-radius: 30px; + transition-property: right; + transition-duration: 300ms; + transition-timing-function: ease-out; } -.jupyter_cell .thebelab-input { - display: none; +#thebelab-activate-button:hover { + right: 5px; } + diff --git a/src/doc/en/tutorial/latex.rst b/src/doc/en/tutorial/latex.rst index aafaaea6ac5..a173afd75c5 100644 --- a/src/doc/en/tutorial/latex.rst +++ b/src/doc/en/tutorial/latex.rst @@ -1,71 +1,99 @@ -********************************* +*********************** Sage, LaTeX and Friends -********************************* +*********************** Sage and the LaTeX dialect of TeX have an intensely synergistic relationship. This section aims to introduce the variety of interactions, beginning with the most basic and proceeding to the more unusual. -Overview -======== - -It may be easiest to understand the various uses of LaTeX with a -brief overview of the mechanics of the three principal methods -employed by Sage. - - #. Every "object" in Sage is required to have a LaTeX representation. You - can access this representation by executing ``latex(foo)`` where - ``foo`` is some object in Sage. The output is a string that should - render a reasonably accurate representation of ``foo`` when used in - TeX's math-mode (for example, when enclosed between a pair of single - dollar signs). Some examples of this follow below. - - In this way, Sage can be used effectively for constructing portions of - a LaTeX document: create or compute an object in Sage, print ``latex()`` - of the object and cut/paste it into your document. - - #. The Jupyter notebook interface uses `MathJax `_ - to render mathematics cleanly in a web browser. You can start this - automatic rendering by executing ``%display latex`` (and stop by - executing ``%display plain``). - - MathJax is an open source JavaScript display engine for mathematics that - works in all modern browsers. It is able to render a large, but not - totally complete, subset of TeX. It has no support for things like - complicated tables, sectioning or document management, as it is oriented - towards accurately rendering "snippets" of TeX. Seemingly automatic - rendering of math in the notebook is provided by converting the - ``latex()`` representation of an object (as described above) into a form - of HTML palatable to MathJax. - - #. A system-wide installation of LaTeX can be employed. Sage includes - almost everything you need to build and use Sage, but a significant - exception is TeX itself. So in these situations you need to have - TeX installed, along with some associated conversion utilities, to - utilize the full power. - -Here we demonstrate some basic uses of the ``latex()`` function. :: +Basic Use +========= + +Every "object" in Sage is required to have a LaTeX representation. You can +access this representation by executing ``latex(foo)`` where ``foo`` is some +object in Sage. The output is a string that should render a reasonably +accurate representation of ``foo`` when used in TeX's math-mode (for example, +when enclosed between a pair of single dollar signs). Some examples of this +follow below. :: sage: var('z') z sage: latex(z^12) z^{12} - sage: latex(integrate(z^4, z)) - \frac{1}{5} \, z^{5} + sage: latex(sqrt(z^2 + 1/2)) + \sqrt{z^{2} + \frac{1}{2}} sage: latex('a string') \text{\texttt{a{ }string}} sage: latex(QQ) \Bold{Q} + sage: latex(ZZ['x']) + \Bold{Z}[x] sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]])) \left(\begin{array}{rrr} 2 & 4 & 6 \\ -1 & -1 & -1 \end{array}\right) -Basic MathJax functionality is largely automatic in the notebook, but we can -partially demonstrate this support with the ``MathJax`` class. The object of -this class converts a Sage object to its LaTeX representation and then wraps it -in HTML. :: +In this way, Sage can be used effectively for constructing portions of +a LaTeX document: create or compute an object in Sage, do ``latex(foo)`` +of the object ``foo`` and cut/paste the LaTeX string into your document. + +The command ``view(foo)`` will show the rendered LaTeX +representation of ``foo``. In the background, the command runs ``latex(foo)`` +and incorporates the LaTeX string into a simple LaTeX document, processes that +document with the system-wide TeX installation, and finally an appropriate +viewer will be called to display the output. + +In the Jupyter notebook, you can see the rendered LaTeX representation of the +output of the entered commands automatically. You can start this +automatic rendering by executing ``%display latex`` (and stop by executing +``%display plain``). + +.. ONLY:: html + + Thus, in the Jupyter notebook, you get + + .. JUPYTER-EXECUTE:: + + %display latex + var('z') + z^12 + + .. JUPYTER-EXECUTE:: + + sqrt(z^2 + 1/2) + + .. JUPYTER-EXECUTE:: + + 'a string' + + .. JUPYTER-EXECUTE:: + + QQ + + .. JUPYTER-EXECUTE:: + + ZZ['x'] + + .. JUPYTER-EXECUTE:: + + matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]) + + .. JUPYTER-EXECUTE:: + + %display plain + +The Jupyter notebook uses `MathJax `_ to render +mathematics cleanly in a web browser. MathJax is an open source JavaScript +display engine for mathematics that works in all modern browsers. It is able +to render a large, but not totally complete, subset of LaTeX. It has no +support for things like complicated tables, sectioning or document management, +as it is oriented towards accurately rendering math snippets of LaTeX. + +The automatic LaTeX rendering in the Jupyter notebook (with ``%display latex`` +on) is internally done via the :class:`sage.misc.html.MathJax` class. The +object of this class converts a Sage object through ``latex()`` to a form of +HTML palatable to MathJax and then wraps it in HTML. :: sage: from sage.misc.html import MathJax sage: mj = MathJax() @@ -73,28 +101,22 @@ in HTML. :: z sage: mj(z^12) \[z^{12}\] + sage: mj(sqrt(z^2 + 1/2)) + \[\sqrt{z^{2} + \frac{1}{2}}\] + sage: mj('a string') + \[\verb|a|\verb| |\verb|string|\] sage: mj(QQ) \[\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}\] sage: mj(ZZ['x']) \[\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]\] - sage: mj(integrate(z^4, z)) - \[\frac{1}{5} \, z^{5}\] - -Basic Use -========= + sage: mj(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]])) + \[\left(\begin{array}{rrr} + 2 & 4 & 6 \\ + -1 & -1 & -1 + \end{array}\right)\] -As indicated in the overview, the simplest way to exploit Sage's support of -LaTeX is to use the ``latex()`` function to create legitimate LaTeX code to -represent mathematical objects. These strings can then be incorporated into -standalone LaTeX documents. +This is useful to know if you need to understand the LaTeX rendering of a Sage object. -At the other extreme is the ``view()`` command. The command ``view(foo)`` will -create the LaTeX representation of ``foo``, incorporate this into a simple -LaTeX document, and then process that document with your system-wide TeX -installation. Finally, the appropriate viewer will be called to display the -output from the TeX command. Which version of TeX is used, and therefore the -nature of the output and associated viewer, can be customized (see -:ref:`sec-custom-processing`). .. _sec-custom-generation: @@ -152,30 +174,74 @@ done in written work. This is accomplished by redefining the \[\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}\] sage: latex.blackboard_bold(False) -It is possible to take advantage of the extensible nature of TeX by adding in -new macros and new packages. First, individual macros can be added so that -they are used when MathJax interprets a snippet of TeX in the notebook. :: +.. ONLY:: html + In the Jupyter notebook, + + .. JUPYTER-EXECUTE:: + + %display latex + QQ + + .. JUPYTER-EXECUTE:: + + latex.blackboard_bold(True) + QQ + + .. JUPYTER-EXECUTE:: + + latex.blackboard_bold(False) + %display plain + +It is possible to take advantage of the extensible nature of LaTeX by adding in +new macros. Individual macros can be added so that they are used when MathJax +interprets a LaTeX snippet. :: + + sage: latex.add_macro(r"\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}") sage: latex.extra_macros() - '' - sage: latex.add_macro("\\newcommand{\\foo}{bar}") - sage: latex.extra_macros() - '\\newcommand{\\foo}{bar}' + '\\newcommand{\\sqrt}[1]{(#1)^\\frac{1}{2}}' sage: var('x y') (x, y) - sage: latex(x+y) - x + y + sage: latex(sqrt(x+y)) + \sqrt{x + y} sage: from sage.misc.html import MathJax sage: mj = MathJax() - sage: mj(x+y) - \[\newcommand{\foo}{bar}x + y\] + sage: mj(sqrt(x + y)) + \[\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}\sqrt{x + y}\] + sage: latex.extra_macros('') + +.. ONLY:: html + + In the Jupyter notebook, -Additional macros added this way will also be used in the event that the -system-wide version of TeX is called on something larger than MathJax can -handle. The command ``latex_extra_preamble`` is used to build the preamble of -a complete LaTeX document, so the following illustrates how this is -accomplished. As usual note the need for the double-backslashes in the Python -strings. :: + .. JUPYTER-EXECUTE:: + + %display latex + var('x y') + sqrt(x + y) + + .. JUPYTER-EXECUTE:: + + latex.add_macro(r"\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}") + sqrt(x + y) + + .. JUPYTER-EXECUTE:: + + latex.extra_macros('') + %display plain + + +.. _sec-custom-processing: + +Customizing LaTeX Processing +============================ + +The system-wide TeX is called to process a complete LaTeX document, such as +when you ``view(foo)``, where ``foo`` is a complicated Sage object, too +complicated for ``MathJax`` to handle. The command ``latex_extra_preamble`` is +used to build the preamble of the complete LaTeX document, so the following +illustrates how this is accomplished. As usual note the need for the +double-backslashes in the Python strings. :: sage: latex.extra_macros('') sage: latex.extra_preamble('') @@ -229,38 +295,40 @@ package that presumably does not exist. :: sage: latex.extra_preamble() '\\usepackage{foo-bar-unchecked}' -.. _sec-custom-processing: +Which dialect of TeX is used, and therefore the nature of the output and +associated viewer, can also be customized. -Customizing LaTeX Processing -============================ +.. NOTE:: -It is also possible to control which variant of TeX is used for system-wide -invocations, thus also influencing the nature of the output. + Sage includes almost everything you need to build and use Sage, but a + significant exception is TeX itself. So in the following situations you + need to have a full TeX system installed, along with some associated + conversion utilities. Many versions of Linux have packages based on + TeXLive, for macOS there is MacTeX and for Windows there is MiKTeX. The ``latex.engine()`` command can be used to control if the system-wide -executables ``latex``, ``pdflatex`` or ``xelatex`` are employed for more -complicated LaTeX expressions. When ``view()`` is called and the engine is set -to ``latex``, a dvi file is produced and Sage will use a dvi viewer (like xdvi) -to display the result. In contrast, using ``view()`` when the engine is set to -``pdflatex`` will produce a PDF as the result and Sage will call your system's -utility for displaying PDF files (acrobat, okular, evince, etc.). - -For a concrete example of how complicated LaTeX expressions can be processed, -see the example in the next section (:ref:`sec-tkz-graph`) for using the LaTeX -``tkz-graph`` package to produce high-quality renderings of combinatorial -graphs. For other examples, there are some pre-packaged test cases. To use -these, it is necessary to import the ``sage.misc.latex.latex_examples`` object, -which is an instance of the ``sage.misc.latex.LatexExamples`` class, as -illustrated below. This class currently has examples of commutative diagrams, -combinatorial graphs, knot theory and pstricks, which respectively exercise the -following packages: xy, tkz-graph, xypic, pstricks. After the import, use -tab-completion on ``latex_examples`` to see the pre-packaged examples. Calling -each example will give you back some explanation about what is required to make -the example render properly. To actually see the examples, it is necessary to -use ``view()`` (once the preamble, engine, etc are all set properly). :: +executables ``latex``, ``pdflatex`` or ``xelatex`` are employed. When +``view()`` is called and the engine is set to ``latex``, a dvi file is produced +and Sage will use a dvi viewer (like xdvi) to display the result. In contrast, +using ``view()`` when the engine is set to ``pdflatex`` will produce a PDF as +the result and Sage will call your system's utility for displaying PDF files +(acrobat, okular, evince, etc.). + +For your exercises with these facilities, there are some pre-packaged examples. +To use these, it is necessary to import the ``sage.misc.latex.latex_examples`` +object, which is an instance of the :class:`sage.misc.latex.LatexExamples` +class, as illustrated below. This class currently has examples of commutative +diagrams, combinatorial graphs, knot theory and pstricks, which respectively +exercise the following packages: xy, tkz-graph, xypic, pstricks. After the +import, use tab-completion on ``latex_examples`` to see the pre-packaged +examples. Calling each example will give you back some explanation about what +is required to make the example render properly. To actually see the examples, +it is necessary to use ``view(foo)`` (once the preamble, engine, etc are all set +properly). :: sage: from sage.misc.latex import latex_examples - sage: latex_examples.diagram() + sage: foo = latex_examples.diagram() + sage: foo LaTeX example for testing display of a commutative diagram produced by xypic. @@ -269,63 +337,47 @@ use ``view()`` (once the preamble, engine, etc are all set properly). :: and try viewing again. You should get a picture (a part of the diagram arising from a filtered chain complex). -.. _sec-tkz-graph: - -An Example: Combinatorial Graphs with tkz-graph -=============================================== - -High-quality illustrations of combinatorial graphs (henceforth just "graphs") -are possible with the ``tkz-graph`` package. This package is built on top of -the ``tikz`` front-end to the ``pgf`` library. So all of these components need -to be part of a system-wide TeX installation, and it may be possible that these -components may not be at their most current versions as packaged in some TeX -implementations. So for best results, it could be necessary or advisable to -install these as part of your personal texmf tree. Creating, maintaining and -customizing a system-wide or personal TeX installation is beyond the scope of -this document, but it should be easy to find instructions. The necessary files -are listed in :ref:`sec-system-wide-tex`. - -Thus, to start we need to insure that the relevant packages are included by -adding them to the preamble of the eventual LaTeX document. The images of -graphs do not form properly when a dvi file is used as an intermediate format, -so it is best to set the latex engine to the ``pdflatex`` executable. At this -point a command like ``view(graphs.CompleteGraph(4))`` should produce a PDF -with an appropriate image of the complete graph `K_4`. +For an example of how complicated LaTeX expressions can be processed, let us see the +example of combinatorial graphs, that use ``tkz-graph`` LaTeX package. + +.. NOTE:: + + ``tkz-graph`` LaTeX package is built on top of the ``tikz`` front-end to + the ``pgf`` library. Rendering combinatorial graphs requires the ``pgf`` + library, and the files ``tkz-graph.sty`` and ``tkz-berge.sty``. It is + highly likely that they are already part of your system-wide TeX + installation. Even if not, it should be easy to find instructions to + install them. + +First, we ensure that the relevant packages are included by adding them to the +preamble of the LaTeX document. :: + + sage: latex.extra_preamble('\\usepackage{tikz}\n\\usepackage{tkz-graph}\n' + ....: '\\usepackage{tkz-berge}\n\\usetikzlibrary{arrows,shapes}') + +The images of graphs do not form properly when a dvi file is used as an +intermediate format, so it is best to set the latex engine to the ``pdflatex`` +executable:: + + sage: latex.engine('pdflatex') + +At this point a command like ``view(graphs.CompleteGraph(4))`` should produce a +PDF with an appropriate image of the complete graph `K_4`. + +Actually the preliminary steps could be omitted as the preamble is +automatically set up properly for graphs and ``pdflatex`` is the default LaTeX +engine in Sage. Try the command again after restarting Sage. Note that there is a variety of options to affect how a graph is rendered in -LaTeX via ``tkz-graph``, which is again outside the scope of this section, see -the section of the Reference manual titled "LaTeX Options for Graphs" for -instructions and details. - -.. _sec-system-wide-tex: - -A Fully Capable TeX Installation -================================ - -Many of the more advanced features of the integration of TeX with Sage requires -a system-wide installation of TeX. Many versions of Linux have base TeX -packages based on TeX Live, for macOS there is TeXShop and for Windows there is -MiKTeX. The ``convert`` utility is part of the `ImageMagick -`_ suite (which should be a package or an easy -download), and the three programs ``dvipng``, ``ps2pdf``, and ``dvips`` may be -included with your TeX distribution. The first two may also be obtained, -respectively, from http://sourceforge.net/projects/dvipng/ and as part of -`Ghostscript `_. - -Rendering combinatorial graphs requires a recent version of the PGF library, -the file ``tkz-graph.sty`` from https://www.ctan.org/pkg/tkz-graph, and the -files ``tkz-arith.sty`` and perhaps ``tkz-berge.sty`` from -https://www.ctan.org/pkg/tkz-berge. +LaTeX via ``tkz-graph``, which is outside the scope of this section. See the +section :ref:`sage.graphs.graph_latex` of the Reference Manual for instructions +and details. + SageTeX ======= -SageTeX is a program available to further integrate TeX and Sage. A concise -description of SageTeX is that it is a collection of TeX macros that allow a -LaTeX document to include instructions to have Sage compute various objects -and/or format objects using the ``latex()`` support built into Sage. So as an -intermediate step of compiling a LaTeX document, all of the computational and -LaTeX-formatting features of Sage can be handled automatically. As an example, -a mathematics examination can maintain a correct correspondence between -questions and answers by using SageTeX to have Sage compute one from the other. +SageTeX is a program available to further integrate TeX and Sage. It is a +collection of TeX macros that allow a LaTeX document to include instructions to +have Sage compute various objects and format objects using the ``latex()``. See :ref:`sec-sagetex` for more information. diff --git a/src/sage/env.py b/src/sage/env.py index f4899639a6d..b1fe9a89cd1 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -1,10 +1,6 @@ r""" Sage Runtime Environment -AUTHORS: - -- \R. Andrew Ohana (2012): Initial version. - Verify that importing ``sage.all`` works in Sage's Python without any ``SAGE_`` environment variables, and has the same ``SAGE_ROOT`` and ``SAGE_LOCAL`` (see also :trac:`29446`):: @@ -16,6 +12,11 @@ sage: out = check_output([sys.executable, "-c", cmd], env=env).decode().strip() # long time sage: out == repr((SAGE_ROOT, SAGE_LOCAL)) # long time True + +AUTHORS: + +- \R. Andrew Ohana (2012): initial version + """ # **************************************************************************** @@ -200,7 +201,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st POLYTOPE_DATA_DIR = var("POLYTOPE_DATA_DIR", join(SAGE_SHARE, "reflexive_polytopes")) GAP_LIB_DIR = var("GAP_LIB_DIR", join(SAGE_LOCAL, "lib", "gap")) GAP_SHARE_DIR = var("GAP_SHARE_DIR", join(SAGE_SHARE, "gap")) -THEBE_DIR = var("THEBE_DIR", join(SAGE_SHARE, "thebe")) COMBINATORIAL_DESIGN_DATA_DIR = var("COMBINATORIAL_DESIGN_DATA_DIR", join(SAGE_SHARE, "combinatorial_designs")) CREMONA_MINI_DATA_DIR = var("CREMONA_MINI_DATA_DIR", join(SAGE_SHARE, "cremona")) CREMONA_LARGE_DATA_DIR = var("CREMONA_LARGE_DATA_DIR", join(SAGE_SHARE, "cremona")) diff --git a/src/sage/plot/plot3d/plot3d.py b/src/sage/plot/plot3d/plot3d.py index 2d2bfb9e34d..898b6a2d8ed 100644 --- a/src/sage/plot/plot3d/plot3d.py +++ b/src/sage/plot/plot3d/plot3d.py @@ -10,17 +10,6 @@ sage: S = sphere((0, 0, 0), size=0.3, color='red', aspect_ratio=[1,1,1]) sage: show(W + S, figsize=8) -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x, y = var('x y') - W = plot3d(sin(pi*((x)^2 + (y)^2))/2, (x, -1, 1), (y, -1, 1), frame=False, color='purple', opacity=0.8) - S = sphere((0, 0, 0), size=0.3, color='red', aspect_ratio=[1,1,1]) - show(W + S, figsize=8) - .. PLOT:: x, y = var('x y') @@ -36,17 +25,6 @@ ....: color=rainbow(60, 'rgbtuple'), max_bend=.1, max_depth=15) sage: P.show() -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - def f(x,y): - return math.sin(y^2 + x^2)/math.sqrt(x^2 + y^2 + 0.0001) - P = plot3d(f, (-3, 3), (-3, 3), adaptive=True, color=rainbow(60, 'rgbtuple'), max_bend=.1, max_depth=15) - P.show() - .. PLOT:: def f(x,y): return math.sin(y**2 + x**2)/math.sqrt(x**2 + y**2 + 0.0001) @@ -63,20 +41,6 @@ def f(x,y): return math.sin(y**2 + x**2)/math.sqrt(x**2 + y**2 + 0.0001) sage: S = P + axes(6, color='black') sage: S.show() -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - def f(x,y): - return math.exp(x/5)*math.sin(y) - - P = plot3d(f, (-5, 5), (-5, 5), adaptive=True, color=['red', 'yellow']) - from sage.plot.plot3d.plot3d import axes - S = P + axes(6, color='black') - S.show() - .. PLOT:: def f(x,y): return math.exp(x/5)*math.sin(y) @@ -93,17 +57,6 @@ def f(x,y): return math.exp(x/5)*math.sin(y) sage: plot3d(x*x + y*y, (x, -4, 4), (y, -4, 4), color=(c, cm)) Graphics3d Object -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x, y = var('x y') - cm = colormaps.hsv - def c(x, y): return float((x + y + x*y)/15) % 1 - plot3d(x*x + y*y, (x, -4, 4), (y, -4, 4), color=(c, cm)) - .. PLOT:: x, y = var('x y') @@ -135,23 +88,6 @@ def c(x, y): return float((x + y + x*y)/15) % 1 sage: cape_man = P.scale(.2) + S.translate(1, 0, 0) sage: cape_man.show(aspect_ratio=[1, 1, 1]) -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - S = sphere(size=.5, color='yellow') - from sage.plot.plot3d.shapes import Cone - S += Cone(.5, .5, color='red').translate(0,0,.3) - S += sphere((.45, -.1, .15), size=.1, color='white') + sphere((.51,-.1,.17), size=.05, color='black') - S += sphere((.45, .1, .15), size=.1, color='white') + sphere((.51, .1,.17), size=.05, color='black') - S += sphere((.5, 0, -.2), size=.1, color='yellow') - def f(x,y): return math.exp(x/5)*math.cos(y) - P = plot3d(f, (-5, 5), (-5, 5), adaptive=True, color=['red','yellow'], max_depth=10) - cape_man = P.scale(.2) + S.translate(1, 0, 0) - cape_man.show(aspect_ratio=[1, 1, 1]) - .. PLOT:: S = sphere(size=.5, color='yellow') @@ -171,14 +107,6 @@ def f(x,y): return math.exp(x/5)*math.cos(y) sage: plot3d(pi, (-1,1), (-1,1)) Graphics3d Object -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - plot3d(pi, (-1,1), (-1,1)) - .. PLOT:: sphinx_plot(plot3d(pi, (-1,1), (-1,1))) @@ -577,16 +505,6 @@ class Spherical(_Coordinates): sage: plot3d(phi * theta, (theta, 0, pi), (phi, 0, 1), transformation=T) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, phi, theta = var('r phi theta') - T = Spherical('radius', ['azimuth', 'inclination']) - plot3d(phi * theta, (theta, 0, pi), (phi, 0, 1), transformation=T) - .. PLOT:: r, phi, theta = var('r phi theta') @@ -600,16 +518,6 @@ class Spherical(_Coordinates): sage: plot3d(3, (r,0,3), (theta, 0, 2*pi), transformation=S) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - S = Spherical('inclination', ['radius', 'azimuth']) - r, theta = var('r,theta') - plot3d(r-r+3, (r,0,3), (theta, 0, 2*pi), transformation=S) - .. PLOT:: S = Spherical('inclination', ['radius', 'azimuth']) @@ -666,16 +574,6 @@ class SphericalElevation(_Coordinates): sage: plot3d(phi * theta, (theta, 0, pi), (phi, 0, 1), transformation=T) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - T = SphericalElevation('radius', ['azimuth', 'elevation']) - r, theta, phi = var('r theta phi') - plot3d(phi * theta, (theta, 0, pi), (phi, 0, 1), transformation=T) - .. PLOT:: T = SphericalElevation('radius', ['azimuth', 'elevation']) @@ -688,24 +586,14 @@ class SphericalElevation(_Coordinates): sage: SE = SphericalElevation('elevation', ['radius', 'azimuth']) sage: r, theta = var('r,theta') - sage: plot3d(3, (r,0,3), (theta, 0, 2*pi), transformation=SE) + sage: plot3d(3, (r, 0, 3), (theta, 0, 2*pi), transformation=SE) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - SE = SphericalElevation('elevation', ['radius', 'azimuth']) - r, theta = var('r,theta') - plot3d(3+r-r, (r,0,3), (theta, 0, 2*pi), transformation=SE) - .. PLOT:: SE = SphericalElevation('elevation', ['radius', 'azimuth']) r, theta = var('r,theta') - sphinx_plot(plot3d(3+r-r, (r,0,3), (theta, 0, 2*pi), transformation=SE)) + sphinx_plot(plot3d(3 + r - r, (r,0,3), (theta, 0, 2*pi), transformation=SE)) Plot a sin curve wrapped around the equator:: @@ -715,24 +603,12 @@ class SphericalElevation(_Coordinates): sage: P1 + P2 Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, theta = var('r,theta') - SE = SphericalElevation('elevation', ['radius', 'azimuth']) - P1 = plot3d( (pi/12)*sin(8*theta), (r,0.99,1), (theta, 0, 2*pi), transformation=SE, plot_points=(10,200)) - P2 = sphere(center=(0,0,0), size=1, color='red', opacity=0.3) - P1 + P2 - .. PLOT:: r, theta = var('r,theta') SE = SphericalElevation('elevation', ['radius', 'azimuth']) - P1 = plot3d( (pi/12)*sin(8*theta), (r,0.99,1), (theta, 0, 2*pi), transformation=SE, plot_points=(10,200)) - P2 = sphere(center=(0,0,0), size=1, color='red', opacity=0.3) + P1 = plot3d( (pi/12)*sin(8*theta), (r, 0.99, 1), (theta, 0, 2*pi), transformation=SE, plot_points=(10,200)) + P2 = sphere(center=(0, 0, 0), size=1, color='red', opacity=0.3) sphinx_plot(P1 + P2) Now we graph several constant elevation functions alongside several constant @@ -753,23 +629,6 @@ class SphericalElevation(_Coordinates): ....: for a in angles] sage: show(sum(P1+P2), aspect_ratio=1) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, phi, theta = var('r phi theta') - SE = SphericalElevation('elevation', ['radius', 'azimuth']) - S = Spherical('inclination', ['radius', 'azimuth']) - angles = [pi/18, pi/12, pi/6] - P1=Graphics() - P2=Graphics() - for a in angles: - P1 += plot3d( a, (r,0,3), (theta, 0, 2*pi), transformation=SE, opacity=0.85, color='blue') - P2 += plot3d( a, (r,0,3), (theta, 0, 2*pi), transformation=S, opacity=0.85, color='red') - P1+P2 - .. PLOT:: r, phi, theta = var('r phi theta') @@ -834,16 +693,6 @@ class Cylindrical(_Coordinates): sage: plot3d(9-r^2, (r, 0, 3), (theta, 0, pi), transformation=T) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - T = Cylindrical('height', ['radius', 'azimuth']) - r, theta, z = var('r theta z') - plot3d(9-r**2, (r, 0, 3), (theta, 0, pi), transformation=T) - .. PLOT:: T = Cylindrical('height', ['radius', 'azimuth']) @@ -857,21 +706,11 @@ class Cylindrical(_Coordinates): sage: plot3d(3, (theta, 0, 2*pi), (z, -2, 2), transformation=S) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - S = Cylindrical('radius', ['azimuth', 'height']) - theta, z = var('theta, z') - plot3d(3, (theta, 0, 2*pi), (z, -2, 2), transformation=S) - .. PLOT:: S = Cylindrical('radius', ['azimuth', 'height']) theta, z = var('theta, z') - sphinx_plot(plot3d(3+z-z, (theta, 0, 2*pi), (z, -2, 2), transformation=S)) + sphinx_plot(plot3d(3 + z - z, (theta, 0, 2*pi), (z, -2, 2), transformation=S)) See also :func:`cylindrical_plot3d` for more examples of plotting in cylindrical coordinates. @@ -1006,14 +845,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(lambda x, y: x^2 + y^2, (-2,2), (-2,2)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2)) - .. PLOT:: sphinx_plot(plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2))) @@ -1023,14 +854,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(lambda x, y: x^2 + y^2, (-2,2), (-2,2), adaptive=True) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2), adaptive=True) - .. PLOT:: sphinx_plot(plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2), adaptive=True)) @@ -1040,14 +863,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(lambda x, y: x^2 + y^2, (-2,2), (-2,2), adaptive=True, initial_depth=5) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2), adaptive=True, initial_depth=5) - .. PLOT:: sphinx_plot(plot3d(lambda x, y: x**2 + y**2, (-2,2), (-2,2), adaptive=True, initial_depth=5)) @@ -1059,15 +874,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(x^2 + y^2, (x,-2,2), (y,-2,2)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - var('x y') - plot3d(x**2 + y**2, (x,-2,2), (y,-2,2)) - .. PLOT:: var('x y') @@ -1078,15 +884,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(sin(x*y), (x, -pi, pi), (y, -pi, pi)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - var('x y') - plot3d(sin(x*y), (x, -pi, pi), (y, -pi, pi)) - .. PLOT:: var('x y') @@ -1099,15 +896,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(sin(x^2 + y^2), (x,-5,5), (y,-5,5), plot_points=200) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - var('x y') - plot3d(sin(x^2 + y^2),(x,-5,5),(y,-5,5), plot_points=200) - .. PLOT:: var('x y') @@ -1118,15 +906,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(sin(x^2 + y^2), (x, -5, 5), (y, -5, 5), plot_points=[10, 100]) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - var('x y') - plot3d(sin(x^2 + y^2), (x, -5, 5), (y, -5, 5), plot_points=[10, 100]) - .. PLOT:: var('x y') @@ -1139,15 +918,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(sin(x - y)*y*cos(x), (x, -3, 3), (y, -3, 3), mesh=True) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - var('x,y') - plot3d(sin(x - y)*y*cos(x), (x, -3, 3), (y, -3, 3), mesh=True) - .. PLOT:: var('x y') @@ -1171,17 +941,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: P + Q Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x,y = var('x,y') - P = plot3d(x + y + sin(x*y), (x, -10, 10), (y, -10, 10), opacity=0.87, color='blue') - Q = plot3d(x - 2*y - cos(x*y),(x, -10, 10), (y, -10, 10), opacity=0.3, color='red') - P + Q - .. PLOT:: x,y = var('x,y') @@ -1197,17 +956,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: L + P + Q Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - L = plot3d(lambda x,y: 0, (-5,5), (-5,5), color="lightblue", opacity=0.8) - P = plot3d(lambda x,y: 4 - x^3 - y^2, (-2,2), (-2,2), color='green') - Q = plot3d(lambda x,y: x^3 + y^2 - 4, (-2,2), (-2,2), color='orange') - L + P + Q - .. PLOT:: L = plot3d(lambda x,y: 0, (-5,5), (-5,5), color="lightblue", opacity=0.8) @@ -1221,15 +969,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(sin(pi*(x^2 + y^2))/2, (x, -1, 1), (y, -1, 1)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x, y = var('x y') - plot3d(sin(pi*(x^2 + y^2))/2, (x, -1, 1), (y, -1, 1)) - .. PLOT:: x, y = var('x y') @@ -1241,15 +980,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(4*x*exp(-x^2 - y^2), (x, -2, 2), (y, -2, 2)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x, y = var('x y') - plot3d(4*x*exp(-x^2 - y^2), (x, -2, 2), (y, -2, 2)) - .. PLOT:: x, y = var('x y') @@ -1261,16 +991,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: trans = (r*cos(phi), r*sin(phi), z) sage: plot3d(cos(r), (r, 0, 17*pi/2), (phi, 0, 2*pi), transformation=trans, opacity=0.87).show(aspect_ratio=(1,1,2), frame=False) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, phi, z = var('r phi z') - trans = (r*cos(phi), r*sin(phi), z) - plot3d(cos(r), (r, 0, 17*pi/2), (phi, 0, 2*pi), transformation=trans, opacity=0.87).show(aspect_ratio=(1,1,2), frame=False) - .. PLOT:: r, phi, z = var('r phi z') @@ -1285,16 +1005,6 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): sage: plot3d(3, (theta, 0, pi/2), (z, 0, pi/2), transformation=cylindrical) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, theta, z = var('r theta z') - cylindrical(r, theta, z) = [r*cos(theta), r*sin(theta), z] - plot3d(3, (theta, 0, pi/2), (z, 0, pi/2), transformation=cylindrical) - .. PLOT:: r, theta, z = var('r theta z') @@ -1420,30 +1130,28 @@ def plot3d_adaptive(f, x_range, y_range, color="automatic", INPUT: - - ``f`` -- a symbolic function or a Python function of - 3 variables. + - ``f`` -- a symbolic function or a Python function of 3 variables - - ``x_range`` -- x range of values: 2-tuple (xmin, + - ``x_range`` -- x range of values: 2-tuple (xmin, xmax) or 3-tuple (x,xmin,xmax) - - ``y_range`` -- y range of values: 2-tuple (ymin, - ymax) or 3-tuple (y,ymin,ymax) + - ``y_range`` -- y range of values: 2-tuple (ymin, ymax) or 3-tuple + (y,ymin,ymax) - - ``grad_f`` -- gradient of f as a Python function + - ``grad_f`` -- gradient of f as a Python function - - ``color`` -- "automatic" - a rainbow of num_colors - colors + - ``color`` -- "automatic" - a rainbow of num_colors colors - - ``num_colors`` -- (default: 128) number of colors to - use with default color + - ``num_colors`` -- (default: 128) number of colors to use with default + color - - ``max_bend`` -- (default: 0.5) + - ``max_bend`` -- (default: 0.5) - - ``max_depth`` -- (default: 5) + - ``max_depth`` -- (default: 5) - - ``initial_depth`` -- (default: 4) + - ``initial_depth`` -- (default: 4) - - ``**kwds`` -- standard graphics parameters + - ``**kwds`` -- standard graphics parameters EXAMPLES: @@ -1454,16 +1162,6 @@ def plot3d_adaptive(f, x_range, y_range, color="automatic", sage: plot3d_adaptive(sin(x*y), (x, -pi, pi), (y, -pi, pi), initial_depth=5) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - from sage.plot.plot3d.plot3d import plot3d_adaptive - x, y = var('x,y') - plot3d_adaptive(sin(x*y), (x, -pi, pi), (y, -pi, pi), initial_depth=5) - .. PLOT:: from sage.plot.plot3d.plot3d import plot3d_adaptive @@ -1559,15 +1257,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: spherical_plot3d(2, (x, 0, 2*pi), (y, 0, pi)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x,y = var('x,y') - spherical_plot3d(2, (x, 0, 2*pi), (y, 0, pi)) - .. PLOT:: x, y = var('x,y') @@ -1581,18 +1270,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: ima = spherical_plot3d(abs(imag(Y)), (phi, 0, 2*pi), (theta, 0, pi), color='red', opacity=0.6) sage: (rea + ima).show(aspect_ratio=1) # long time (4s on sage.math, 2011) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - phi, theta = var('phi, theta') - Y = spherical_harmonic(2, 1, theta, phi) - rea = spherical_plot3d(abs(real(Y)), (phi, 0, 2*pi), (theta, 0, pi), color='blue', opacity=0.6) - ima = spherical_plot3d(abs(imag(Y)), (phi, 0, 2*pi), (theta, 0, pi), color='red', opacity=0.6) - (rea + ima).show(aspect_ratio=1) # long time (4s on sage.math, 2011) - .. PLOT:: phi, theta = var('phi, theta') @@ -1606,15 +1283,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: x,y = var('x,y') sage: spherical_plot3d(e^-y, (x, 0, 2*pi), (y, 0, pi), opacity=0.5).show(frame=False) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x,y = var('x,y') - spherical_plot3d(e^-y, (x, 0, 2*pi), (y, 0, pi), opacity=0.5).show(frame=False) - .. PLOT:: x, y = var('x,y') @@ -1626,15 +1294,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: spherical_plot3d((2 + cos(2*x))*(y + 1), (x, 0, 2*pi), (y, 0, pi), rgbcolor=(1, .1, .1)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x,y = var('x,y') - spherical_plot3d((2 + cos(2*x))*(y + 1), (x, 0, 2*pi), (y, 0, pi), rgbcolor=(1, .1, .1)) - .. PLOT:: x, y = var('x,y') @@ -1646,15 +1305,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: spherical_plot3d(1 + sin(5*x)/5, (x, 0, 2*pi), (y, 0, pi), rgbcolor=(1, 0.5, 0), plot_points=(80, 80), opacity=0.7) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x,y = var('x,y') - spherical_plot3d(1 + sin(5*x)/5, (x, 0, 2*pi), (y, 0, pi), rgbcolor=(1, 0.5, 0), plot_points=(80, 80), opacity=0.7) - .. PLOT:: x,y = var('x,y') @@ -1665,15 +1315,6 @@ def spherical_plot3d(f, urange, vrange, **kwds): sage: x, y = var('x,y') sage: spherical_plot3d(1 + 2*cos(2*y), (x, 0, 3*pi/2), (y, 0, pi)).show(aspect_ratio=(1, 1, 1)) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - x, y = var('x,y') - spherical_plot3d(1 + 2*cos(2*y), (x, 0, 3*pi/2), (y, 0, pi)).show(aspect_ratio=(1, 1, 1)) - .. PLOT:: x, y = var('x,y') @@ -1693,17 +1334,6 @@ def cylindrical_plot3d(f, urange, vrange, **kwds): sage: plot3d(f, urange, vrange, transformation=T) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - r, u, v = var('r,u,v') - f = u*v; urange = (u, 0, pi); vrange = (v, 0, pi) - T = (r*cos(u), r*sin(u), v, [u, v]) - plot3d(f, urange, vrange, transformation=T) - .. PLOT:: r, u, v = var('r,u,v') @@ -1737,15 +1367,6 @@ def cylindrical_plot3d(f, urange, vrange, **kwds): sage: cylindrical_plot3d(2, (theta, 0, 3*pi/2), (z, -2, 2)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - theta, z = var('theta,z') - cylindrical_plot3d(2, (theta, 0, 3*pi/2), (z, -2, 2)) - .. PLOT:: theta, z = var('theta,z') @@ -1758,16 +1379,7 @@ def cylindrical_plot3d(f, urange, vrange, **kwds): sage: cylindrical_plot3d(cosh(z), (theta, 0, 2*pi), (z, -2, 2)) Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - theta, z = var('theta,z') - cylindrical_plot3d(cosh(z), (theta, 0, 2*pi), (z, -2, 2)) - - .. PLOT:: + .. PLOT:: theta, z = var('theta,z') sphinx_plot(cylindrical_plot3d(cosh(z), (theta, 0, 2*pi), (z, -2, 2))) @@ -1776,22 +1388,12 @@ def cylindrical_plot3d(f, urange, vrange, **kwds): sage: cylindrical_plot3d(e^(-z^2)*(cos(4*theta) + 2) + 1, (theta, 0, 2*pi), (z, -2, 2), plot_points=[80, 80]).show(aspect_ratio=(1, 1, 1)) - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - theta, z = var('theta,z') - cylindrical_plot3d(e^(-z^2)*(cos(4*theta) + 2) + 1, (theta, 0, 2*pi), (z, -2, 2), plot_points=[80, 80]).show(aspect_ratio=(1, 1, 1)) - - .. PLOT:: + .. PLOT:: theta, z = var('theta,z') P = cylindrical_plot3d(e**(-z**2)*(cos(4*theta) + 2) + 1, (theta, 0, 2*pi), (z, -2, 2), plot_points=[80, 80]) P.aspect_ratio([1, 1, 1]) sphinx_plot(P) - """ return plot3d(f, urange, vrange, transformation=Cylindrical('radius', ['azimuth', 'height']), **kwds) @@ -1802,9 +1404,10 @@ def axes(scale=1, radius=None, **kwds): INPUT: - - ``scale`` -- (default: 1) The length of the axes (all three - will be the same). - - ``radius`` -- (default: .01) The radius of the axes as arrows. + - ``scale`` -- (default: 1) the length of the axes (all three will be the + same) + + - ``radius`` -- (default: .01) the radius of the axes as arrows EXAMPLES:: @@ -1812,16 +1415,7 @@ def axes(scale=1, radius=None, **kwds): sage: S = axes(6, color='black'); S Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - from sage.plot.plot3d.plot3d import axes - S = axes(6, color='black'); S - - .. PLOT:: + .. PLOT:: from sage.plot.plot3d.plot3d import axes S = axes(6, color='black') @@ -1832,16 +1426,7 @@ def axes(scale=1, radius=None, **kwds): sage: T = axes(2, .5); T Graphics3d Object - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - from sage.plot.plot3d.plot3d import axes - T = axes(2, .5); T - - .. PLOT:: + .. PLOT:: from sage.plot.plot3d.plot3d import axes T = axes(2, .5) diff --git a/src/sage/repl/ipython_kernel/interact.py b/src/sage/repl/ipython_kernel/interact.py index 0551c83480e..c9c3d627657 100644 --- a/src/sage/repl/ipython_kernel/interact.py +++ b/src/sage/repl/ipython_kernel/interact.py @@ -22,18 +22,6 @@ x: IntSlider(value=5, description='x', max=10) sage: f.widget.children (IntSlider(value=5, description='x', max=10), Output()) - -.. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - from sage.repl.ipython_kernel.interact import interact - @interact - def f(x=(0, 10)): - pass - """ # **************************************************************************** @@ -72,16 +60,6 @@ class sage_interactive(interactive): x: IntSlider(value=10, description='x') y: Text(value='hello', description='y') z: Dropdown(description='z', options=('one', 'two', 'three'), value=None) - - .. ONLY:: html - - .. JUPYTER-EXECUTE:: - :hide-code: - :hide-output: - - from sage.repl.ipython_kernel.interact import sage_interactive - def myfunc(x=10, y="hello", z=None): pass - sage_interactive(myfunc, x=(0,100), z=["one", "two", "three"]) """ def __init__(self, *args, **kwds): """ diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py index 86bdf342e3e..69e63b76d60 100644 --- a/src/sage/repl/rich_output/backend_ipython.py +++ b/src/sage/repl/rich_output/backend_ipython.py @@ -17,6 +17,7 @@ import os import sys +import html from IPython.display import publish_display_data from sage.repl.rich_output.backend_base import BackendBase from sage.repl.rich_output.output_catalog import * @@ -574,7 +575,7 @@ def displayhook(self, plain_text, rich_output): 'text/plain': plain_text.text.get_str(), }, {}) elif isinstance(rich_output, OutputSceneThreejs): - escaped_html = rich_output.html.get_str().replace('"', '"') + escaped_html = html.escape(rich_output.html.get_str()) iframe = IFRAME_TEMPLATE.format( escaped_html=escaped_html, width='100%', diff --git a/src/sage_docbuild/__main__.py b/src/sage_docbuild/__main__.py index 77919ec4000..0d15808a69c 100644 --- a/src/sage_docbuild/__main__.py +++ b/src/sage_docbuild/__main__.py @@ -294,6 +294,9 @@ def setup_parser(): standard.add_argument("--no-pdf-links", dest="no_pdf_links", action="store_true", help="do not include PDF links in DOCUMENT 'website'; FORMATs: html, json, pickle, web") + standard.add_argument("--live-doc", dest="live_doc", + action="store_true", + help="make Sage code blocks live for html FORMAT") standard.add_argument("--warn-links", dest="warn_links", action="store_true", help="issue a warning whenever a link is not properly resolved; equivalent to '--sphinx-opts -n' (sphinx option: nitpicky)") @@ -474,6 +477,8 @@ def excepthook(*exc_info): build_options.ALLSPHINXOPTS += "-n " if args.no_plot: os.environ['SAGE_SKIP_PLOT_DIRECTIVE'] = 'yes' + if args.live_doc: + os.environ['SAGE_LIVE_DOC'] = 'yes' if args.skip_tests: os.environ['SAGE_SKIP_TESTS_BLOCKS'] = 'True' if args.use_cdns: diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 0df2760c035..85efeadbbe4 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -27,10 +27,11 @@ import sage.version from sphinx import highlighting +from sphinx.transforms import SphinxTransform from IPython.lib.lexers import IPythonConsoleLexer, IPyLexer from sage.misc.sagedoc import extlinks -from sage.env import SAGE_DOC_SRC, SAGE_DOC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR +from sage.env import SAGE_DOC_SRC, SAGE_DOC, PPLPY_DOCS, MATHJAX_DIR from sage.misc.latex_macros import sage_mathjax_macros from sage.features import PythonModule @@ -54,17 +55,41 @@ jupyter_execute_default_kernel = 'sagemath' -jupyter_sphinx_thebelab_config = { - 'requestKernel': True, - 'binderOptions': { - 'repo': "sagemath/sage-binder-env", - }, - 'kernelOptions': { - 'name': "sagemath", - 'kernelName': "sagemath", - 'path': ".", - }, -} +if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': + + SAGE_JUPYTER_SERVER = os.environ.get('SAGE_JUPYTER_SERVER', 'binder') + if SAGE_JUPYTER_SERVER == 'binder': + jupyter_sphinx_thebelab_config = { + 'requestKernel': False, + 'binderOptions': { + 'repo': "sagemath/sage-binder-env", + }, + 'kernelOptions': { + 'name': "sagemath", + 'kernelName': "sagemath", + 'path': ".", + }, + 'selector': "div.live-code" + } + else: # local jupyter server + SAGE_JUPYTER_SERVER_TOKEN = os.environ.get('SAGE_JUPYTER_SERVER_TOKEN', 'secret') + jupyter_sphinx_thebelab_config = { + 'requestKernel': False, + 'kernelOptions': { + 'name': "sagemath", + 'kernelName': "sagemath", + 'path': ".", + 'serverSettings': { + 'baseUrl': SAGE_JUPYTER_SERVER, + 'token': SAGE_JUPYTER_SERVER_TOKEN + }, + }, + } + jupyter_sphinx_thebelab_config.update({ + 'codeMirrorConfig': { + 'lineNumbers': True, + } + }) # This code is executed before each ".. PLOT::" directive in the Sphinx # documentation. It defines a 'sphinx_plot' function that displays a Sage object @@ -310,6 +335,7 @@ def set_intersphinx_mappings(app, config): # or fully qualified paths (eg. https://...) html_css_files = [ 'custom-furo.css', + 'custom-jupyter-sphinx.css', ] # A list of paths that contain extra templates (or templates that overwrite # builtin/theme-specific templates). Relative paths are taken as relative @@ -348,8 +374,7 @@ def set_intersphinx_mappings(app, config): # conf.py read by Sphinx was the cause of subtle bugs in builders (see #30418 for # instance). Hence now html_common_static_path contains the common paths to static # files, and is combined to html_static_path in each conf.py file read by Sphinx. -html_common_static_path = [os.path.join(SAGE_DOC_SRC, 'common', 'static'), - THEBE_DIR, 'static'] +html_common_static_path = [os.path.join(SAGE_DOC_SRC, 'common', 'static'), 'static'] # Configure MathJax # https://docs.mathjax.org/en/latest/options/input/tex.html @@ -913,6 +938,69 @@ class will be properly documented inside its surrounding class. return skip +from jupyter_sphinx.ast import JupyterCellNode, CellInputNode + +class SagecodeTransform(SphinxTransform): + """ + Transform code blocks to live code blocks enabled by jupter-sphinx. + + Effectively a code block like:: + + EXAMPLE:: + + sage: 1 + 1 + 2 + + is transformed into:: + + EXAMPLE:: + + sage: 1 + 1 + 2 + + .. ONLY:: html + + .. JUPYTER-EXECUTE:: + :hide-code: + :hide-output: + :raises: + :stderr: + + 1 + 1 + + enabling live execution of the code. + """ + # lower than the priority of jupyer_sphinx.execute.ExecuteJupyterCells + default_priority = 170 + + def apply(self): + if self.app.builder.tags.has('html') or self.app.builder.tags.has('inventory'): + for node in self.document.traverse(nodes.literal_block): + if node.get('language') is None and node.astext().startswith('sage:'): + source = node.rawsource + lines = [] + for line in source.splitlines(): + newline = line.lstrip() + if newline.startswith('sage: ') or newline.startswith('....: '): + lines.append(newline[6:]) + cell_node = JupyterCellNode( + execute=False, + hide_code=True, + hide_output=True, + emphasize_lines=[], + raises=False, + stderr=True, + code_below=False, + classes=["jupyter_cell"]) + cell_input = CellInputNode(classes=['cell_input','live-code']) + cell_input += nodes.literal_block( + text='\n'.join(lines), + linenos=False, + linenostart=1) + cell_node += cell_input + + node.parent.insert(node.parent.index(node) + 1, cell_node) + # This replaces the setup() in sage.misc.sagedoc_conf def setup(app): app.connect('autodoc-process-docstring', process_docstring_cython) @@ -924,6 +1012,8 @@ def setup(app): app.connect('autodoc-process-docstring', skip_TESTS_block) app.connect('autodoc-skip-member', skip_member) app.add_transform(SagemathTransform) + if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': + app.add_transform(SagecodeTransform) # When building the standard docs, app.srcdir is set to SAGE_DOC_SRC + # 'LANGUAGE/DOCNAME'. diff --git a/src/sage_docbuild/sphinxbuild.py b/src/sage_docbuild/sphinxbuild.py index 94407cad5eb..5ae1d2e6b10 100644 --- a/src/sage_docbuild/sphinxbuild.py +++ b/src/sage_docbuild/sphinxbuild.py @@ -77,14 +77,14 @@ def _init_chatter(self): re.compile(r'^loading cross citations... done \([0-9]* citations\).'), re.compile('^Compiling a sub-document'), re.compile('^updating environment: 0 added, 0 changed, 0 removed'), + re.compile('^executing .*'), re.compile('^looking for now-outdated files... none found'), re.compile(r'^building \[.*\]: targets for 0 source files that are out of date'), re.compile(r'^building \[.*\]: targets for 0 po files that are out of date'), re.compile(r'^building \[.*\]: targets for 0 mo files that are out of date'), re.compile('^pickling environment... done'), re.compile('^dumping object inventory... done'), - # We still have "Build finished." - re.compile('^build succeeded.'), + re.compile('^build succeeded.'), # We still have "Build finished." re.compile('^checking consistency... done'), re.compile('^preparing documents... done'), re.compile('^copying extra files... done'), From 19c1c09791e499b3d3be8501276ebdf45c376fcc Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 08:29:58 +0900 Subject: [PATCH 010/494] Style activate button --- build/pkgs/jupyter_sphinx/package-version.txt | 2 +- src/doc/common/static/custom-jupyter-sphinx.css | 14 ++++++++++++++ .../common/themes/sage-classic/static/sage.css_t | 13 ++++--------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/build/pkgs/jupyter_sphinx/package-version.txt b/build/pkgs/jupyter_sphinx/package-version.txt index 1d0ba9ea182..8af2848288a 100644 --- a/build/pkgs/jupyter_sphinx/package-version.txt +++ b/build/pkgs/jupyter_sphinx/package-version.txt @@ -1 +1 @@ -0.4.0 +0.4.0.p0 diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index e560cb370ba..1da7fc7ac17 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -14,3 +14,17 @@ div.jupyter_container div.cell_output div.output { margin: .5em; } +#thebelab-activate-button { + position: fixed; + right: -100px; + top: 50%; + border-radius: 30px; + transition-property: right; + transition-duration: 300ms; + transition-timing-function: ease-out; +} + +#thebelab-activate-button:hover { + right: 5px; +} + diff --git a/src/doc/common/themes/sage-classic/static/sage.css_t b/src/doc/common/themes/sage-classic/static/sage.css_t index a0e96f4e1c4..38b6159ec75 100644 --- a/src/doc/common/themes/sage-classic/static/sage.css_t +++ b/src/doc/common/themes/sage-classic/static/sage.css_t @@ -373,15 +373,10 @@ dl.citation p { #thebelab-activate-button { position: fixed; - right: -100px; - top: 50%; - border-radius: 30px; - transition-property: right; - transition-duration: 300ms; - transition-timing-function: ease-out; + right: 10px; + bottom: 10px; } -#thebelab-activate-button:hover { - right: 5px; +.jupyter_cell .thebelab-input { + display: none; } - From 62928dbaa2214c1ed11a2e71bb77523c500a8f84 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 12:14:03 +0900 Subject: [PATCH 011/494] Fix activate button --- src/doc/common/static/custom-jupyter-sphinx.css | 7 ++++++- src/sage_docbuild/conf.py | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 1da7fc7ac17..63c1113e990 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -14,14 +14,19 @@ div.jupyter_container div.cell_output div.output { margin: .5em; } +.thebelab-button { + margin: 0.5rem 0 0.5rem 0.5rem; +} + #thebelab-activate-button { position: fixed; right: -100px; - top: 50%; + top: 45%; border-radius: 30px; transition-property: right; transition-duration: 300ms; transition-timing-function: ease-out; + z-index: 100; } #thebelab-activate-button:hover { diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 85efeadbbe4..39494a5a555 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -69,7 +69,7 @@ 'kernelName': "sagemath", 'path': ".", }, - 'selector': "div.live-code" + 'selector': "div.live-doc" } else: # local jupyter server SAGE_JUPYTER_SERVER_TOKEN = os.environ.get('SAGE_JUPYTER_SERVER_TOKEN', 'secret') @@ -84,6 +84,7 @@ 'token': SAGE_JUPYTER_SERVER_TOKEN }, }, + 'selector': "div.live-doc" } jupyter_sphinx_thebelab_config.update({ 'codeMirrorConfig': { @@ -992,7 +993,7 @@ def apply(self): stderr=True, code_below=False, classes=["jupyter_cell"]) - cell_input = CellInputNode(classes=['cell_input','live-code']) + cell_input = CellInputNode(classes=['cell_input','live-doc']) cell_input += nodes.literal_block( text='\n'.join(lines), linenos=False, From 6ae42f5f435b4080bbe0aab3563ee204db3565ca Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 12:23:17 +0900 Subject: [PATCH 012/494] Fix a typo --- src/sage_docbuild/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 39494a5a555..7d876905886 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -943,7 +943,7 @@ class will be properly documented inside its surrounding class. class SagecodeTransform(SphinxTransform): """ - Transform code blocks to live code blocks enabled by jupter-sphinx. + Transform a code block to a live code block enabled by jupyter-sphinx. Effectively a code block like:: From 12afe87d2e54e2636856df54b3c8c74676339eec Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 12:43:45 +0900 Subject: [PATCH 013/494] Fix the patch to jupyter-sphinx --- .../patches/0001-Patch-for-sage-live-doc.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch index bfd767028db..c86b4001caa 100644 --- a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch +++ b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch @@ -1,4 +1,4 @@ -From 4d6c87f4144110d7f361f11ead41f1b6f602b20d Mon Sep 17 00:00:00 2001 +From f95c7a7a393f0eef9989dddffc70a09ac0a14c35 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 00:18:59 +0900 Subject: [PATCH] Patch for sage live doc @@ -49,20 +49,20 @@ index 34af884..f5a7f44 100644 # add jupyter-sphinx and thebelab js and css diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py -index 558a26b..bebb000 100644 +index 558a26b..de44455 100644 --- a/jupyter_sphinx/execute.py +++ b/jupyter_sphinx/execute.py @@ -152,6 +152,17 @@ class ExecuteJupyterCells(SphinxTransform): kernel_name = default_kernel file_name = next(default_names) -+ # save time when jupyter notebook execution is not necessary ++ # Save time when jupyter notebook execution is not necessary + if not any(not "execute" in node or node["execute"] for node in nodes): + # mimics empty cell output for each node + for node in nodes: + source = node.children[0] + source.attributes["classes"].append("code_cell") -+ node.attributes["cm_language"] = 'sage' ++ node.attributes["cm_language"] = kernel_name + node += CellOutputNode(classes=["cell_output"]) + apply_styling(node, thebe_config) + continue From fd494e7aaaccfa2bbeff409c6b1bb831cb8ba25b Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 16:01:03 +0900 Subject: [PATCH 014/494] Adjust css styles of thebe elements --- .../common/static/custom-jupyter-sphinx.css | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 63c1113e990..f0412b4fe0e 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -3,7 +3,7 @@ div.jupyter_container { } div.jupyter_container + div.jupyter_container { - margin: 0 0 0.5em 0; + margin: 0 0 .5em 0; } div.jupyter_container div.cell_input pre { @@ -15,21 +15,27 @@ div.jupyter_container div.cell_output div.output { } .thebelab-button { - margin: 0.5rem 0 0.5rem 0.5rem; + margin: .5rem 0 .5rem .5rem; +} + +.thebelab-busy { + margin-left: .5rem; } #thebelab-activate-button { - position: fixed; - right: -100px; - top: 45%; - border-radius: 30px; - transition-property: right; - transition-duration: 300ms; - transition-timing-function: ease-out; - z-index: 100; + position: fixed; + right: -100px; + top: 45%; + border-radius: 30px; + transition-property: right; + transition-duration: 300ms; + transition-timing-function: ease-out; + z-index: 100; } #thebelab-activate-button:hover { - right: 5px; + right: 5px; } + + From fc84c30837c58b3123b3ab9b34143acd908eebd5 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 17:44:10 +0900 Subject: [PATCH 015/494] Showcase live doc on a-tour-of-sage --- .../common/static/custom-jupyter-sphinx.css | 17 +++-- src/doc/en/a_tour_of_sage/index.rst | 68 +++++++++---------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index f0412b4fe0e..5ab91226227 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -1,17 +1,26 @@ div.jupyter_container { - margin: .5em 0; + margin: .5rem 0; } div.jupyter_container + div.jupyter_container { - margin: 0 0 .5em 0; + margin: 0 0 .5rem 0; } div.jupyter_container div.cell_input pre { - margin: .5em; + margin: .5rem; } div.jupyter_container div.cell_output div.output { - margin: .5em; + margin: .5rem; +} + +.thebelab-cell .jp-OutputArea { + margin: 0 .5rem; +} + +.thebelab-cell .jp-OutputArea-output { + margin: .5rem 0; + overflow-x: auto; } .thebelab-button { diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index 15e9d2aae46..8053bfb7a85 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -1,38 +1,36 @@ .. _a-tour-of-sage: -========================= -Welcome to a Tour of Sage -========================= +=============== +Welcome to Sage +=============== -This is a tour of Sage that closely follows the tour of Mathematica -that is at the beginning of the Mathematica Book. +This is a short tour of Sage as a calculator, a very powerful one. - -Sage as a Calculator -==================== - -The Sage command line has a ``sage:`` prompt; you do not have to add -it. If you use the Sage notebook, then put everything after the -``sage:`` prompt in an input cell, and press shift-enter to compute the -corresponding output. +The Sage command line has a prompt "``sage:``". You do not have to add it. :: sage: 3 + 5 8 +If you use Sage on the Jupyter notebook, then put +everything after the ``sage:`` prompt in an input cell, and press shift-enter +to compute the corresponding output. + + + The caret symbol means "raise to a power". :: - sage: 57.1 ^ 100 + sage: 57.1^100 4.60904368661396e175 We compute the inverse of a :math:`2 \times 2` matrix in Sage. :: - sage: matrix([[1,2], [3,4]])^(-1) + sage: matrix([[1, 2], [3, 4]])^(-1) [ -2 1] [ 3/2 -1/2] @@ -40,16 +38,15 @@ Here we integrate a simple function. :: - sage: x = var('x') # create a symbolic variable - sage: integrate(sqrt(x)*sqrt(1+x), x) + sage: var('x') # create a symbolic variable + sage: integrate(sqrt(x) * sqrt(1 + x), x) 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) -This asks Sage to solve a quadratic equation. The symbol ``==`` -represents equality in Sage. +This asks Sage to solve a quadratic equation. The symbol ``==`` represents equality in Sage. :: - sage: a = var('a') + sage: var('a') sage: S = solve(x^2 + x == a, x); S [x == -1/2*sqrt(4*a + 1) - 1/2, x == 1/2*sqrt(4*a + 1) - 1/2] @@ -59,7 +56,7 @@ The result is a list of equalities. :: - sage: S[0].rhs() + sage: S[0].rhs() # right hand side of the equation -1/2*sqrt(4*a + 1) - 1/2 Naturally, Sage can plot various useful functions. @@ -71,15 +68,12 @@ Naturally, Sage can plot various useful functions. .. image:: sin_plot.* -Power Computing with Sage -========================= - -First we create a :math:`500 \times 500` matrix of random -numbers. +Sage is very powerful. To experience it, first we create a +:math:`500 \times 500` matrix of random numbers. :: - sage: m = random_matrix(RDF,500) + sage: m = random_matrix(RDF, 500) It takes Sage a few seconds to compute the eigenvalues of the matrix and plot them. @@ -88,7 +82,7 @@ matrix and plot them. :: - sage: e = m.eigenvalues() #about 2 seconds + sage: e = m.eigenvalues() # about 1 second sage: w = [(i, abs(e[i])) for i in range(len(e))] sage: show(points(w)) @@ -103,7 +97,7 @@ digits. sage: factorial(100) 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 - sage: n = factorial(1000000) #about 2.5 seconds + sage: n = factorial(1000000) # about 1 second This computes at least 100 digits of :math:`\pi`. @@ -128,6 +122,9 @@ This asks Sage to factor a polynomial in two variables. x^51*y^9 - x^48*y^12 + x^42*y^18 + x^39*y^21 - x^33*y^27 - x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 - x^12*y^48 - x^9*y^51 + x^3*y^57 + y^60) + +:: + sage: F.expand() x^99 + y^99 @@ -136,12 +133,9 @@ partition one hundred million as a sum of positive integers. :: - sage: z = Partitions(10^8).cardinality() #about 4.5 seconds - sage: str(z)[:40] - '1760517045946249141360373894679135204009' - -Accessing Algorithms in Sage -============================ + sage: z = Partitions(10^8).cardinality() # about .1 second + sage: z + 1760517045946249141360373894679135204009... -Whenever you use Sage you are accessing one of the world's largest -collections of open source computational algorithms. +Whenever you use Sage, you are accessing the world's most advanced open source computational +algorithms. From 5f4dcb1ba1d9c9f75220217ce565bde1cbb02410 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 17:57:46 +0900 Subject: [PATCH 016/494] More edits on a-tour-of-Sage --- src/doc/en/a_tour_of_sage/index.rst | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index 8053bfb7a85..a967570e48f 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -13,9 +13,9 @@ The Sage command line has a prompt "``sage:``". You do not have to add it. sage: 3 + 5 8 -If you use Sage on the Jupyter notebook, then put -everything after the ``sage:`` prompt in an input cell, and press shift-enter -to compute the corresponding output. +If you use Sage on the Jupyter notebook, then put everything after the +``sage:`` prompt in an input cell, and press shift-enter to compute the +corresponding output. @@ -59,7 +59,7 @@ The result is a list of equalities. sage: S[0].rhs() # right hand side of the equation -1/2*sqrt(4*a + 1) - 1/2 -Naturally, Sage can plot various useful functions. +Sage can plot various useful functions, of course. :: @@ -68,15 +68,14 @@ Naturally, Sage can plot various useful functions. .. image:: sin_plot.* -Sage is very powerful. To experience it, first we create a -:math:`500 \times 500` matrix of random numbers. +Sage is powerful. To experience it, first we create a :math:`500 \times 500` +matrix of random numbers. :: sage: m = random_matrix(RDF, 500) -It takes Sage a few seconds to compute the eigenvalues of the -matrix and plot them. +It takes Sage a second to compute the eigenvalues of the matrix and plot them. .. link @@ -89,15 +88,19 @@ matrix and plot them. .. image:: eigen_plot.* -Thanks to the GNU Multiprecision Library (GMP), Sage can handle -very large numbers, even numbers with millions or billions of +Sage can handle very large numbers, even numbers with millions or billions of digits. :: sage: factorial(100) 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 + +:: + sage: n = factorial(1000000) # about 1 second + sage: len(n.digits()) + 5565709 This computes at least 100 digits of :math:`\pi`. @@ -128,8 +131,8 @@ This asks Sage to factor a polynomial in two variables. sage: F.expand() x^99 + y^99 -Sage takes just under 5 seconds to compute the numbers of ways to -partition one hundred million as a sum of positive integers. +Sage takes less than 1 second to compute the numbers of ways to partition one +hundred million as a sum of positive integers. :: @@ -137,5 +140,5 @@ partition one hundred million as a sum of positive integers. sage: z 1760517045946249141360373894679135204009... -Whenever you use Sage, you are accessing the world's most advanced open source computational -algorithms. +Whenever you use Sage, you are accessing the world's most advanced open source +computational algorithms. From 8bb20a66573c438152f40d0db850d5a0c6dd144a Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 29 Aug 2023 20:13:48 +0900 Subject: [PATCH 017/494] Support furo dark mode --- .../static/custom-codemirror-monokai.css | 42 +++++++++++++++++++ .../common/static/custom-jupyter-sphinx.css | 28 +++++++++++++ .../common/static/jupyter-sphinx-helper.js | 38 +++++++++++++++++ src/sage_docbuild/conf.py | 6 +++ 4 files changed, 114 insertions(+) create mode 100644 src/doc/common/static/custom-codemirror-monokai.css create mode 100644 src/doc/common/static/jupyter-sphinx-helper.js diff --git a/src/doc/common/static/custom-codemirror-monokai.css b/src/doc/common/static/custom-codemirror-monokai.css new file mode 100644 index 00000000000..3489e3d61e5 --- /dev/null +++ b/src/doc/common/static/custom-codemirror-monokai.css @@ -0,0 +1,42 @@ +/* from https://codemirror.net/5/theme/monokai.css */ +/* Based on Sublime Text's Monokai theme */ + +.cm-s-monokai.CodeMirror { background: #272822; color: #f8f8f2; } +.cm-s-monokai div.CodeMirror-selected { background: #49483E; } +.cm-s-monokai .CodeMirror-line::selection, .cm-s-monokai .CodeMirror-line > span::selection, .cm-s-monokai .CodeMirror-line > span > span::selection { background: rgba(73, 72, 62, .99); } +.cm-s-monokai .CodeMirror-line::-moz-selection, .cm-s-monokai .CodeMirror-line > span::-moz-selection, .cm-s-monokai .CodeMirror-line > span > span::-moz-selection { background: rgba(73, 72, 62, .99); } +.cm-s-monokai .CodeMirror-gutters { background: #272822; border-right: 0px; } +.cm-s-monokai .CodeMirror-guttermarker { color: white; } +.cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; } +.cm-s-monokai .CodeMirror-linenumber { color: #d0d0d0; } +.cm-s-monokai .CodeMirror-cursor { border-left: 1px solid #f8f8f0; } + +.cm-s-monokai span.cm-comment { color: #75715e; } +.cm-s-monokai span.cm-atom { color: #ae81ff; } +.cm-s-monokai span.cm-number { color: #ae81ff; } + +.cm-s-monokai span.cm-comment.cm-attribute { color: #97b757; } +.cm-s-monokai span.cm-comment.cm-def { color: #bc9262; } +.cm-s-monokai span.cm-comment.cm-tag { color: #bc6283; } +.cm-s-monokai span.cm-comment.cm-type { color: #5998a6; } + +.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; } +.cm-s-monokai span.cm-keyword { color: #f92672; } +.cm-s-monokai span.cm-builtin { color: #66d9ef; } +.cm-s-monokai span.cm-string { color: #e6db74; } + +.cm-s-monokai span.cm-variable { color: #f8f8f2; } +.cm-s-monokai span.cm-variable-2 { color: #9effff; } +.cm-s-monokai span.cm-variable-3, .cm-s-monokai span.cm-type { color: #66d9ef; } +.cm-s-monokai span.cm-def { color: #fd971f; } +.cm-s-monokai span.cm-bracket { color: #f8f8f2; } +.cm-s-monokai span.cm-tag { color: #f92672; } +.cm-s-monokai span.cm-header { color: #ae81ff; } +.cm-s-monokai span.cm-link { color: #ae81ff; } +.cm-s-monokai span.cm-error { background: #f92672; color: #f8f8f0; } + +.cm-s-monokai .CodeMirror-activeline-background { background: #373831; } +.cm-s-monokai .CodeMirror-matchingbracket { + text-decoration: underline; + color: white !important; +} diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 5ab91226227..db56a42943e 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -46,5 +46,33 @@ div.jupyter_container div.cell_output div.output { right: 5px; } +body[data-theme="dark"] { + .jupyter_container { + color: white; + background-color: black; + } + + .thebelab-button { + color: #d0d0d0; + background-color: #383838; + } + + #thebelab-activate-button { + color: #d0d0d0; + background-color: #383838; + } + + .thebelab-cell .jp-OutputArea-output { + color: white; + background-color: black; + } + + .thebelab-cell .jp-OutputArea-output pre { + color: white; + background-color: black; + } +} + + diff --git a/src/doc/common/static/jupyter-sphinx-helper.js b/src/doc/common/static/jupyter-sphinx-helper.js new file mode 100644 index 00000000000..4d58e581423 --- /dev/null +++ b/src/doc/common/static/jupyter-sphinx-helper.js @@ -0,0 +1,38 @@ +// +// Change the editor theme of all CodeMirror cells according to the furo (dark) mode +// + +function changeTheme(editor, theme) { + if (theme === 'dark') { + editor.setOption('theme', 'monokai'); // the same with pygments dark style in conf.py + } + else { + editor.setOption('theme', 'default'); + } +} + +const body = document.body; +const observer1 = new MutationObserver((mutationsList) => { + for (let mutation of mutationsList) { + if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') { + const theme = body.dataset.theme; + const querySet = document.querySelectorAll('.CodeMirror'); + for (var i = 0; i < querySet.length; i++) { + changeTheme(querySet[i].CodeMirror, theme); + }}}}); +observer1.observe(body, { attributes: true }); + +// +// Change the editor theme of a new CodeMirror cell. +// + +const callback = function(mutationsList, observer) { + for(const mutation of mutationsList) { + if (mutation.type === 'childList') { + const theme = body.dataset.theme; + for (const addedNode of mutation.addedNodes) { + if (addedNode.classList && addedNode.classList.contains('CodeMirror')) { + changeTheme(addedNode.CodeMirror, theme); + }}}}}; +const observer2 = new MutationObserver(callback); +observer2.observe(document.getElementsByClassName("content")[0], { childList: true, subtree: true }); diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 7d876905886..9c135596f46 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -337,7 +337,13 @@ def set_intersphinx_mappings(app, config): html_css_files = [ 'custom-furo.css', 'custom-jupyter-sphinx.css', + 'custom-codemirror-monokai.css', ] + + html_js_files = [ + 'jupyter-sphinx-helper.js', + ] + # A list of paths that contain extra templates (or templates that overwrite # builtin/theme-specific templates). Relative paths are taken as relative # to the configuration directory. From 27977dc8c7319cac43d0ed6e4f8c1b61f9580bac Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 30 Aug 2023 10:50:20 +0900 Subject: [PATCH 018/494] Fine fixes --- src/doc/common/static/custom-jupyter-sphinx.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index db56a42943e..3fa1e5a9eff 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -19,7 +19,7 @@ div.jupyter_container div.cell_output div.output { } .thebelab-cell .jp-OutputArea-output { - margin: .5rem 0; + margin: 0 0 .5rem 0; overflow-x: auto; } @@ -33,9 +33,9 @@ div.jupyter_container div.cell_output div.output { #thebelab-activate-button { position: fixed; - right: -100px; - top: 45%; - border-radius: 30px; + right: -6.5rem; + top: calc(50% - 1.5em); + border-radius: 1em; transition-property: right; transition-duration: 300ms; transition-timing-function: ease-out; From 482d51fbf8e7d4e40137696c93ba1c5ff5750922 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 30 Aug 2023 11:08:19 +0900 Subject: [PATCH 019/494] Minor edits to the front of sage doc --- src/doc/en/a_tour_of_sage/index.rst | 7 +++---- src/doc/en/website/templates/index_furo.html | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index a967570e48f..062ca42742e 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -4,7 +4,7 @@ Welcome to Sage =============== -This is a short tour of Sage as a calculator, a very powerful one. +This is a short tour of Sage as a calculator. The Sage command line has a prompt "``sage:``". You do not have to add it. @@ -68,7 +68,7 @@ Sage can plot various useful functions, of course. .. image:: sin_plot.* -Sage is powerful. To experience it, first we create a :math:`500 \times 500` +Sage is a very powerful calculator. To experience it, first we create a :math:`500 \times 500` matrix of random numbers. :: @@ -140,5 +140,4 @@ hundred million as a sum of positive integers. sage: z 1760517045946249141360373894679135204009... -Whenever you use Sage, you are accessing the world's most advanced open source -computational algorithms. +Sage is the world's most advanced open source math software. diff --git a/src/doc/en/website/templates/index_furo.html b/src/doc/en/website/templates/index_furo.html index ae70b6ea4df..922068b9b52 100644 --- a/src/doc/en/website/templates/index_furo.html +++ b/src/doc/en/website/templates/index_furo.html @@ -49,9 +49,7 @@


- This is a tour of Sage that closely follows the tour of - Mathematica that is at the beginning of the Mathematica - Book. + A one page introduction to Sage as a handy calculator.

@@ -85,7 +83,7 @@


- This tutorial is the best way to become familiar with Sage + The best way to become familiar with Sage in only a few hours.

From fafce5c10c54e7eee9548afda307715ccca8b86e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 30 Aug 2023 11:59:27 +0900 Subject: [PATCH 020/494] Add more comments to renamed jupyter-sphinx-furo.js --- .../{jupyter-sphinx-helper.js => jupyter-sphinx-furo.js} | 8 ++------ src/sage_docbuild/conf.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) rename src/doc/common/static/{jupyter-sphinx-helper.js => jupyter-sphinx-furo.js} (89%) diff --git a/src/doc/common/static/jupyter-sphinx-helper.js b/src/doc/common/static/jupyter-sphinx-furo.js similarity index 89% rename from src/doc/common/static/jupyter-sphinx-helper.js rename to src/doc/common/static/jupyter-sphinx-furo.js index 4d58e581423..b4443a670f7 100644 --- a/src/doc/common/static/jupyter-sphinx-helper.js +++ b/src/doc/common/static/jupyter-sphinx-furo.js @@ -1,7 +1,4 @@ -// // Change the editor theme of all CodeMirror cells according to the furo (dark) mode -// - function changeTheme(editor, theme) { if (theme === 'dark') { editor.setOption('theme', 'monokai'); // the same with pygments dark style in conf.py @@ -11,6 +8,8 @@ function changeTheme(editor, theme) { } } +// Uses the theme data of the document.body element set by setTheme function +// defined in https://github.com/pradyunsg/furo/blob/main/src/furo/assets/scripts/furo.js const body = document.body; const observer1 = new MutationObserver((mutationsList) => { for (let mutation of mutationsList) { @@ -22,10 +21,7 @@ const observer1 = new MutationObserver((mutationsList) => { }}}}); observer1.observe(body, { attributes: true }); -// // Change the editor theme of a new CodeMirror cell. -// - const callback = function(mutationsList, observer) { for(const mutation of mutationsList) { if (mutation.type === 'childList') { diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 9c135596f46..cb5c8a22b40 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -341,7 +341,7 @@ def set_intersphinx_mappings(app, config): ] html_js_files = [ - 'jupyter-sphinx-helper.js', + 'jupyter-sphinx-furo.js', ] # A list of paths that contain extra templates (or templates that overwrite From 910e866c15da1a1edd91eb20f76b044127240285 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 1 Sep 2023 14:53:46 +0900 Subject: [PATCH 021/494] Activate live doc in github doc previews --- .github/workflows/doc-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index e12ad0a75fb..eb4f81f303c 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -83,6 +83,7 @@ jobs: run: | set -ex export SAGE_USE_CDNS=yes + export SAGE_LIVE_DOC=yes mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git From 5f8fb1ae88d09ed56168fa91df301e0ab8bc88f5 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 3 Sep 2023 19:42:06 +0900 Subject: [PATCH 022/494] Adjust button styles --- .../common/static/custom-jupyter-sphinx.css | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 3fa1e5a9eff..24b19868c4f 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -25,6 +25,12 @@ div.jupyter_container div.cell_output div.output { .thebelab-button { margin: .5rem 0 .5rem .5rem; + padding: 0 .5rem; + min-width: 2rem; +} + +.thebelab-button:active { + color: #0f0fff; } .thebelab-busy { @@ -33,9 +39,10 @@ div.jupyter_container div.cell_output div.output { #thebelab-activate-button { position: fixed; - right: -6.5rem; - top: calc(50% - 1.5em); - border-radius: 1em; + right: -5rem; + top: calc(50% - 1.5rem); + width: 6rem; + border-radius: 1rem; transition-property: right; transition-duration: 300ms; transition-timing-function: ease-out; @@ -43,7 +50,11 @@ div.jupyter_container div.cell_output div.output { } #thebelab-activate-button:hover { - right: 5px; + right: .5rem; +} + +#thebelab-activate-button:active { + color: #0f0fff; } body[data-theme="dark"] { @@ -57,11 +68,18 @@ body[data-theme="dark"] { background-color: #383838; } + .thebelab-button:active { + color: #368ce2; + } + #thebelab-activate-button { - color: #d0d0d0; background-color: #383838; } + #thebelab-activate-button:active { + color: #368ce2; + } + .thebelab-cell .jp-OutputArea-output { color: white; background-color: black; From b5ff41a555958d67f7fdf3d57446dff4385c2a36 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 4 Sep 2023 09:42:51 +0900 Subject: [PATCH 023/494] Minimize the patch on jupyter-sphinx --- .../0001-Patch-for-sage-live-doc.patch | 37 +++---------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch index c86b4001caa..046c8a4fd6a 100644 --- a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch +++ b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch @@ -1,26 +1,18 @@ -From f95c7a7a393f0eef9989dddffc70a09ac0a14c35 Mon Sep 17 00:00:00 2001 +From fa6e7b31ebd7f6dbf02e1e4c1056e4ef1389884e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 00:18:59 +0900 Subject: [PATCH] Patch for sage live doc --- - jupyter_sphinx/__init__.py | 8 +++++--- + jupyter_sphinx/__init__.py | 2 +- jupyter_sphinx/execute.py | 11 +++++++++++ - 2 files changed, 16 insertions(+), 3 deletions(-) + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py -index 34af884..f5a7f44 100644 +index 34af884..f2e17e0 100644 --- a/jupyter_sphinx/__init__.py +++ b/jupyter_sphinx/__init__.py -@@ -2,6 +2,7 @@ - - from pathlib import Path - -+import os - import docutils - import ipywidgets - from IPython.lib.lexers import IPython3Lexer, IPythonTracebackLexer -@@ -31,7 +32,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource +@@ -31,7 +31,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource REQUIRE_URL_DEFAULT = ( "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js" ) @@ -29,25 +21,6 @@ index 34af884..f5a7f44 100644 logger = logging.getLogger(__name__) -@@ -186,7 +187,7 @@ def setup(app): - app.add_config_value("jupyter_sphinx_embed_url", None, "html") - - # thebelab config, can be either a filename or a dict -- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html") -+ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env") - app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html") - - # linenos config -@@ -290,7 +291,8 @@ def setup(app): - app.add_lexer("ipythontb", IPythonTracebackLexer) - app.add_lexer("ipython3", IPython3Lexer) - -- app.connect("builder-inited", builder_inited) -+ if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': -+ app.connect("builder-inited", builder_inited) - app.connect("build-finished", build_finished) - - # add jupyter-sphinx and thebelab js and css diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py index 558a26b..de44455 100644 --- a/jupyter_sphinx/execute.py From 1ec45d6f62fdb5821e9a595a93501c480e16d43b Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 4 Sep 2023 09:45:38 +0900 Subject: [PATCH 024/494] Fix doctests --- src/doc/en/a_tour_of_sage/index.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index 062ca42742e..f0c9897268f 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -38,7 +38,7 @@ Here we integrate a simple function. :: - sage: var('x') # create a symbolic variable + sage: x = var('x') # create a symbolic variable sage: integrate(sqrt(x) * sqrt(1 + x), x) 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) @@ -46,7 +46,7 @@ This asks Sage to solve a quadratic equation. The symbol ``==`` represents equal :: - sage: var('a') + sage: a = var('a') sage: S = solve(x^2 + x == a, x); S [x == -1/2*sqrt(4*a + 1) - 1/2, x == 1/2*sqrt(4*a + 1) - 1/2] @@ -126,8 +126,6 @@ This asks Sage to factor a polynomial in two variables. x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 - x^12*y^48 - x^9*y^51 + x^3*y^57 + y^60) -:: - sage: F.expand() x^99 + y^99 From a5dd948b7488ae6c68735c894230ee3b90a8622f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 4 Sep 2023 10:40:35 +0900 Subject: [PATCH 025/494] Fix a doctest --- src/doc/en/a_tour_of_sage/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index f0c9897268f..2cbcf493bcb 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -125,7 +125,6 @@ This asks Sage to factor a polynomial in two variables. x^51*y^9 - x^48*y^12 + x^42*y^18 + x^39*y^21 - x^33*y^27 - x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 - x^12*y^48 - x^9*y^51 + x^3*y^57 + y^60) - sage: F.expand() x^99 + y^99 From da82502bb76e87f0869a97884f5ec35fac21a9d6 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 4 Sep 2023 13:49:57 +0900 Subject: [PATCH 026/494] Allow custom binder repo --- src/sage_docbuild/conf.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index cb5c8a22b40..c7953980973 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -56,13 +56,16 @@ jupyter_execute_default_kernel = 'sagemath' if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': - SAGE_JUPYTER_SERVER = os.environ.get('SAGE_JUPYTER_SERVER', 'binder') - if SAGE_JUPYTER_SERVER == 'binder': + if SAGE_JUPYTER_SERVER.startswith('binder'): + if SAGE_JUPYTER_SERVER == 'binder': # default binder repo + binder_repo = "sagemath/sage-binder-env" + else: # format "binder:sagemath/sage-binder-env" + binder_repo = SAGE_JUPYTER_SERVER[7:] jupyter_sphinx_thebelab_config = { 'requestKernel': False, 'binderOptions': { - 'repo': "sagemath/sage-binder-env", + 'repo': binder_repo, }, 'kernelOptions': { 'name': "sagemath", From 225446ffdd4ce03bd8bca1d4f0a28725998ff41e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 8 Sep 2023 10:37:37 +0900 Subject: [PATCH 027/494] %display latex is the default --- src/doc/common/static/jupyter-sphinx-furo.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/doc/common/static/jupyter-sphinx-furo.js b/src/doc/common/static/jupyter-sphinx-furo.js index b4443a670f7..842dde6052a 100644 --- a/src/doc/common/static/jupyter-sphinx-furo.js +++ b/src/doc/common/static/jupyter-sphinx-furo.js @@ -8,7 +8,7 @@ function changeTheme(editor, theme) { } } -// Uses the theme data of the document.body element set by setTheme function +// Use the theme data of the document.body element set by setTheme function // defined in https://github.com/pradyunsg/furo/blob/main/src/furo/assets/scripts/furo.js const body = document.body; const observer1 = new MutationObserver((mutationsList) => { @@ -32,3 +32,14 @@ const callback = function(mutationsList, observer) { }}}}}; const observer2 = new MutationObserver(callback); observer2.observe(document.getElementsByClassName("content")[0], { childList: true, subtree: true }); + + +// Run custom code once the kernel is ready +// https://thebe.readthedocs.io/en/stable/events.html +thebelab.on("status", function (evt, data) { + if (data.status === 'ready') { + const kernel = data.kernel; + kernel.requestExecute({code: "%display latex"}); + } +}); + From 612d396e7b898a3d2b2b3ea1ea9bf153088b506f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 8 Sep 2023 17:41:13 +0900 Subject: [PATCH 028/494] Use unofficial binder repo temporarily --- .github/workflows/doc-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index eb4f81f303c..abe38b8a159 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -84,6 +84,8 @@ jobs: set -ex export SAGE_USE_CDNS=yes export SAGE_LIVE_DOC=yes + # Remove the following line when the official sagemath/sage-binder-env repo is in good shape + export SAGE_JUPYTER_SERVER=binder:kwankyu/sage-binder-env mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git From 49dfc5633cc84f5e999f88d8cd34b2f5f5e80dbc Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 9 Sep 2023 09:17:31 +0900 Subject: [PATCH 029/494] Minor css tweak --- src/doc/common/static/custom-jupyter-sphinx.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 24b19868c4f..40495702c26 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -39,7 +39,7 @@ div.jupyter_container div.cell_output div.output { #thebelab-activate-button { position: fixed; - right: -5rem; + right: -5.1rem; top: calc(50% - 1.5rem); width: 6rem; border-radius: 1rem; @@ -50,7 +50,7 @@ div.jupyter_container div.cell_output div.output { } #thebelab-activate-button:hover { - right: .5rem; + right: .4rem; } #thebelab-activate-button:active { From 7102fe05e3744148b896904268f4b52d2bccd274 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 9 Sep 2023 17:22:14 +0900 Subject: [PATCH 030/494] Use the official thing --- .github/workflows/doc-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index abe38b8a159..eb4f81f303c 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -84,8 +84,6 @@ jobs: set -ex export SAGE_USE_CDNS=yes export SAGE_LIVE_DOC=yes - # Remove the following line when the official sagemath/sage-binder-env repo is in good shape - export SAGE_JUPYTER_SERVER=binder:kwankyu/sage-binder-env mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git From 561984f7ca2bef5e5ff27b3d093d87af9fc7690d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 11 Sep 2023 15:39:13 +0900 Subject: [PATCH 031/494] Use external urls --- src/sage/repl/ipython_kernel/kernel.py | 44 +++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/sage/repl/ipython_kernel/kernel.py b/src/sage/repl/ipython_kernel/kernel.py index 73681716aa2..9a1b652f812 100644 --- a/src/sage/repl/ipython_kernel/kernel.py +++ b/src/sage/repl/ipython_kernel/kernel.py @@ -83,54 +83,68 @@ def help_links(self): See the Jupyter documentation. - .. NOTE:: - - Urls starting with "kernelspecs" are prepended by the - browser with the appropriate path. - EXAMPLES:: sage: from sage.repl.ipython_kernel.kernel import SageKernel sage: sk = SageKernel.__new__(SageKernel) sage: sk.help_links [{'text': 'Sage Documentation', - 'url': 'kernelspecs/sagemath/doc/html/en/index.html'}, + 'url': 'https://doc.sagemath.org/html/en/index.html'}, ...] """ + # DEPRECATED: The URLs in the form 'kernelspecs/...' were used for + # classical Jupyter notebooks. For instance, + # + # 'kernelspecs/sagemath/doc/html/en/index.html' + # + # is constructed by kernel_url('doc/html/en/index.html'), but these + # URLs of local files don't work for JupyterLab. Hence all URLs here + # have been replaced with URLs of external documents. + from sage.repl.ipython_kernel.install import SageKernelSpec identifier = SageKernelSpec.identifier() def kernel_url(x): + # URLs starting with 'kernelspecs' are prepended by the + # browser with the appropriate path return 'kernelspecs/{0}/{1}'.format(identifier, x) return [ { 'text': 'Sage Documentation', - 'url': kernel_url('doc/html/en/index.html'), + 'url': "https://doc.sagemath.org/html/en/index.html", + }, + { + 'text': 'A Tour of Sage', + 'url': "https://doc.sagemath.org/html/en/a_tour_of_sage/index.html", }, { 'text': 'Tutorial', - 'url': kernel_url('doc/html/en/tutorial/index.html'), + 'url': "https://doc.sagemath.org/html/en/tutorial/index.html", }, { 'text': 'Thematic Tutorials', - 'url': kernel_url('doc/html/en/thematic_tutorials/index.html'), + 'url': "https://doc.sagemath.org/html/en/thematic_tutorials/index.html", }, { - 'text': 'FAQs', - 'url': kernel_url('doc/html/en/faq/index.html'), + 'text': 'PREP Tutorials', + 'url': "https://doc.sagemath.org/html/en/prep/index.html", }, { - 'text': 'PREP Tutorials', - 'url': kernel_url('doc/html/en/prep/index.html'), + 'text': 'Constructions', + 'url': "https://doc.sagemath.org/html/en/constructions/index.html", + }, + { + 'text': 'FAQ', + 'url': "https://doc.sagemath.org/html/en/faq/index.html", }, { 'text': 'Reference', - 'url': kernel_url('doc/html/en/reference/index.html'), + 'url': "https://doc.sagemath.org/html/en/reference/index.html", }, { 'text': "Developer's Guide", - 'url': kernel_url('doc/html/en/developer/index.html'), + 'url': "https://doc.sagemath.org/html/en/developer/index.html", }, { 'text': "Python", From 4247db01c15f783e89ec3c287ddff190026a7a2f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 11 Sep 2023 15:44:05 +0900 Subject: [PATCH 032/494] Minor edits --- src/sage/repl/ipython_kernel/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/repl/ipython_kernel/kernel.py b/src/sage/repl/ipython_kernel/kernel.py index 9a1b652f812..3e03ef71619 100644 --- a/src/sage/repl/ipython_kernel/kernel.py +++ b/src/sage/repl/ipython_kernel/kernel.py @@ -99,7 +99,7 @@ def help_links(self): # # is constructed by kernel_url('doc/html/en/index.html'), but these # URLs of local files don't work for JupyterLab. Hence all URLs here - # have been replaced with URLs of external documents. + # have been replaced with URLs of online documents. from sage.repl.ipython_kernel.install import SageKernelSpec identifier = SageKernelSpec.identifier() From 747f3c5f872751421ea4f99b356ca78db07f5250 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 13 Sep 2023 18:31:02 +0900 Subject: [PATCH 033/494] Edit installation doc --- src/doc/en/installation/index.rst | 16 +- src/doc/en/installation/source.rst | 244 ++++++++++++++++------------- 2 files changed, 142 insertions(+), 118 deletions(-) diff --git a/src/doc/en/installation/index.rst b/src/doc/en/installation/index.rst index 9baf654f457..437169a83a3 100644 --- a/src/doc/en/installation/index.rst +++ b/src/doc/en/installation/index.rst @@ -127,16 +127,18 @@ Linux In the cloud ============ -- `CoCalc `_: an online service that provides SageMath and +- `Sage Binder repo `_ provides a + Binder badge to launch JupyterLab computing environment with Sage. + +- `Sage Cell Server `_ is a free online service for + quick computations with Sage. + +- `CoCalc `_ is an online commercial service that provides Sage and many other tools. -- On any system that allows you to bring your own Docker images to run - in a container: Use the `Docker image sagemathinc/cocalc - `_ or :trac:`another Docker - image providing SageMath `. +- `Docker image sagemathinc/cocalc + `_ can be used on any system with Docker to run CoCalc locally. -- `Sage Cell Server `_: an online service for - elementary SageMath computations. More information: diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst index b156165778b..248b918da5f 100644 --- a/src/doc/en/installation/source.rst +++ b/src/doc/en/installation/source.rst @@ -1,9 +1,3 @@ -.. comment: - *************************************************************************** - If you alter this document, please change the last line: - **This page was last updated in MONTH YEAR (Sage X.Y).** - *************************************************************************** - .. HIGHLIGHT:: shell-session .. _sec-installation-from-sources: @@ -11,27 +5,23 @@ Install from Source Code ======================== -.. contents:: Table of contents - :depth: 2 - :class: this-will-duplicate-information-and-it-is-still-useful-here - -Some familiarity with the use of the Unix command line may be required to -build Sage from the :wikipedia:`source code `. - -Building Sage from the source code has the major advantage that your install -will be optimized for your particular computer and should therefore offer -better performance and compatibility than a binary install. +Building Sage from the :wikipedia:`source code ` has the major +advantage that your install will be optimized for your particular computer and +should therefore offer better performance and compatibility than a binary +install. -Moreover, it offers you full development capabilities: -you can change absolutely any part of Sage or the programs on which it depends, -and recompile the modified parts. +Moreover, it offers you full development capabilities: you can change +absolutely any part of Sage or the packages on which it depends, and recompile +the modified parts. See the file `README.md `_ in ``SAGE_ROOT`` for information on supported platforms and step-by-step instructions. -The following sections provide some additional details. Most users -will not need to read them. +The following sections provide some additional details. Most users will not +need to read them. Some familiarity with the use of the Unix command line may +be required to build Sage from the source code. + .. _section-prereqs: @@ -436,7 +426,6 @@ On other systems, check the documentation for your particular operating system. .. _section_conda_compilers: - Notes on using conda ^^^^^^^^^^^^^^^^^^^^ @@ -457,70 +446,12 @@ If you don't want conda to be used by sage, deactivate conda (for the current sh operating system, or its own compilers. -Additional software -------------------- - -Recommended programs -^^^^^^^^^^^^^^^^^^^^ - -The following programs are recommended. -They are not strictly required at build time or at run time, -but provide additional capabilities: - -- **dvipng**. -- **ffmpeg**. -- **ImageMagick**. -- **LaTeX**: highly recommended. - -It is highly recommended that you have -:wikipedia:`LaTeX ` -installed, but it is not required. -The most popular packaging is `TeX Live `_, -which can be installed following the directions on their web site. -On Linux systems you can alternatively install your distribution's -texlive packages:: - - $ sudo apt-get install texlive # debian - $ sudo yum install texlive # redhat - -or similar commands. In addition to the base TeX Live install, you may -need some optional TeX Live packages, for example -country-specific babel packages for the localized Sage -documentation. - -If you don't have either ImageMagick or ffmpeg, you won't be able to -view animations. -ffmpeg can produce animations in more different formats than ImageMagick, -and seems to be faster than ImageMagick when creating animated GIFs. -Either ImageMagick or dvipng is used for displaying some LaTeX output in the -Sage notebook. - -On Debian/Ubuntu, the following system packages are recommended. - -- ``texlive-generic-extra`` (to generate pdf documentation) - -- ``texlive-xetex`` (to convert Jupyter notebooks to pdf) - -- ``latexmk`` (to generate pdf documentation) - -- ``pandoc`` (to convert Jupyter notebooks to pdf) - -- ``dvipng`` (to render text with LaTeX in Matplotlib) - -- ``default-jdk`` (to run the Jmol 3D viewer from the console and generate images for 3D plots in the documentation) - -- ``ffmpeg`` (to produce animations) - -- ``libavdevice-dev`` (to produce animations) - Tcl/Tk ^^^^^^ -If you want to use `Tcl/Tk `_ libraries in Sage, -you need to install the Tcl/Tk and its development headers before building -Sage. -Sage's Python will then automatically recognize your system's install of -Tcl/Tk. +If you want to use `Tcl/Tk `_ libraries in Sage, you need +to install the Tcl/Tk and its development headers before building Sage. Sage's +Python will then automatically recognize your system's install of Tcl/Tk. On Linux systems, these are usually provided by the **tk** and **tk-dev** (or **tk-devel**) packages which can be installed using:: @@ -548,13 +479,11 @@ If does not raise an :class:`ImportError`, then it worked. -.. _build-from-source-step-by-step: -Step-by-step installation procedure ------------------------------------ +.. _build-from-source-step-by-step: -General procedure -^^^^^^^^^^^^^^^^^ +Installation steps +------------------ #. Follow the procedure in the file `README.md `_ in ``SAGE_ROOT``. @@ -936,23 +865,6 @@ Here are some of the more commonly used variables affecting the build process: Python-level profiling is always available; This option enables profiling in Cython modules. -- :envvar:`SAGE_SPKG_INSTALL_DOCS` - if set to ``yes``, then install - package-specific documentation to - :file:`$SAGE_ROOT/local/share/doc/PACKAGE_NAME/` when an spkg is - installed. - This option may not be supported by all spkgs. - Some spkgs might also assume that certain programs are available on the - system (for example, ``latex`` or ``pdflatex``). - -- :envvar:`SAGE_DOCBUILD_OPTS` - the value of this variable is passed as an - argument to ``sage --docbuild all html`` or ``sage --docbuild all pdf`` when - you run ``make``, ``make doc``, or ``make doc-pdf``. - For example, you can add ``--no-plot`` to this variable to avoid building - the graphics coming from the ``.. PLOT`` directive within the documentation, - or you can add ``--include-tests-blocks`` to include all "TESTS" blocks in the - reference manual. Run ``sage --docbuild help`` to see the full list - of options. - - :envvar:`SAGE_BUILD_DIR` - the default behavior is to build each spkg in a subdirectory of :file:`$SAGE_ROOT/local/var/tmp/sage/build/`; for example, build version 7.27.0 of @@ -1034,6 +946,66 @@ Here are some of the more commonly used variables affecting the build process: supports :envvar:`SAGE_SUDO`, into a root-owned installation hierarchy (:envvar:`SAGE_LOCAL`). +Environment variables for documentation build: + +- :envvar:`SAGE_DOCBUILD_OPTS` - the value of this variable is passed as an + argument to ``sage --docbuild all html`` or ``sage --docbuild all pdf`` when + you run ``make``, ``make doc``, or ``make doc-pdf``. For example, you can + add ``--no-plot`` to this variable to avoid building the graphics coming from + the ``.. PLOT`` directive within the documentation, or you can add + ``--include-tests-blocks`` to include all "TESTS" blocks in the reference + manual. Run ``sage --docbuild help`` to see the full list of options. + +- :envvar:`SAGE_SPKG_INSTALL_DOCS` - if set to ``yes``, then install + package-specific documentation to + :file:`$SAGE_ROOT/local/share/doc/PACKAGE_NAME/` when an spkg is installed. + This option may not be supported by all spkgs. Some spkgs might also assume + that certain programs are available on the system (for example, ``latex`` or + ``pdflatex``). + +- :envvar:`SAGE_USE_CDNS` -- if set to ``yes``, then build the documentation + using CDNs (Content Distribution Networks) for scripts necessary for HTML + documentation, such as `MathJax `_. + +- :envvar:`SAGE_LIVE_DOC` -- if set to ``yes``, then build live Sage + documentation. If the ``Make live`` button on any webpage of the live doc is + clicked, every example code gets a `CodeMirror `_ + code cell runnable via `Thebe `_. + Thebe is responsible in sending the code to the Sage computing environment + built by `Binder `_ and showing the output result. + The Sage computing environment can be specified to either a Binder repo or a + local Jupyter server. The environment variable :envvar:`SAGE_JUPYTER_SERVER` + is used for this purpose. + + :envvar:`SAGE_JUPYTER_SERVER` - set this to either ``binder``, + ``binder:repo`` with ``repo`` specifying a Binder repo or the URL to a local + Jupyter server. + + - ``binder`` refers to `Sage's official Binder repo + `_. This is assumed if the + environment variable :envvar:`SAGE_JUPYTER_SERVER` is not set. + + - ``binder:repo`` specifies a Binder repo with ``repo``, which is a GitHub + repository name, optionally added with a branch name with ``/`` separator. + + - If a local Jupyter server is used, then set the URL to + :envvar:`SAGE_JUPYTER_SERVER` and the secret token to environemt variable + :envvar:`SAGE_JUPYTER_SERVER_TOKEN`, which can be left unset if the + default token ``secret`` is used. For this case, run a local Jupyter + server by + + .. CODE-BLOCK:: bash + + ./sage --notebook=jupyterlab \ + --ServerApp.token='secret' \ + --ServerApp.allow_origin='null' \ + --ServerApp.disable_check_xsrf=true \ + --ServerApp.port=8889 \ + --ServerApp.open_browser=false + + before opening the Sage documentation webpage. + + Environment variables dealing with specific Sage packages: - :envvar:`SAGE_MATPLOTLIB_GUI` - if set to anything non-empty except ``no``, @@ -1045,14 +1017,14 @@ Environment variables dealing with specific Sage packages: support (which is disabled by default). See the file :file:`build/pkgs/pari/spkg-install` for more information. -- :envvar:`SAGE_TUNE_PARI`: If yes, enable PARI self-tuning. Note that +- :envvar:`SAGE_TUNE_PARI` - if yes, enable PARI self-tuning. Note that this can be time-consuming. If you set this variable to "yes", you will also see this: ``WARNING: Tuning PARI/GP is unreliable. You may find your build of PARI fails, or PARI/GP does not work properly once built. We recommend to build this package with SAGE_CHECK="yes".`` -- :envvar:`PARI_MAKEFLAGS`: The value of this variable is passed as an +- :envvar:`PARI_MAKEFLAGS` - The value of this variable is passed as an argument to the ``$MAKE`` command when compiling PARI. Some standard environment variables which are used by Sage: @@ -1094,7 +1066,7 @@ Some standard environment variables which are used by Sage: - :envvar:`OPENBLAS_CONFIGURE` - adds additional configuration flags for the OpenBLAS package that gets added to the make command. (see :trac:`23272`) -Variables dealing with doctesting: +Environment variables dealing with doctesting: - :envvar:`SAGE_TIMEOUT` - used for Sage's doctesting: the number of seconds to allow a doctest before timing it out. @@ -1105,7 +1077,7 @@ Variables dealing with doctesting: ``sage -t --long``. If this isn't set, the default is 1800 seconds (30 minutes). -- :envvar:`SAGE_TEST_GLOBAL_ITER`, :envvar:`SAGE_TEST_ITER`: these can +- :envvar:`SAGE_TEST_GLOBAL_ITER`, :envvar:`SAGE_TEST_ITER` - these can be used instead of passing the flags ``--global-iterations`` and ``--file-iterations``, respectively, to ``sage -t``. Indeed, these variables are only used if the flags are unset. Run ``sage -t -h`` @@ -1146,7 +1118,7 @@ see a list, execute ``sage.env.[TAB]`` while running Sage. *************************************************************************** -Installation in a Multiuser Environment +Installation in a multiuser environment --------------------------------------- This section addresses the question of how a system administrator can install @@ -1183,4 +1155,54 @@ a single copy of Sage in a multi-user computer network. $ sudo chown -R root SAGE_LOCAL -**This page was last updated in September 2022 (Sage 9.8).** +Additional software +------------------- + +The following programs are not strictly required at build time or at run time, +but provide additional capabilities to Sage. We highly recommend a Sage user to +install them. + +LaTeX +^^^^^ + +It is highly recommended that you have :wikipedia:`LaTeX ` installed, +but it is not required. The most popular packaging is `TeX Live +`_, which can be installed following the +directions on their web site. On Linux systems you can alternatively install +your distribution's texlive packages:: + + $ sudo apt-get install texlive # debian + $ sudo yum install texlive # redhat + +or similar commands. In addition to the base TeX Live install, you may +need some optional TeX Live packages, for example +country-specific Babel packages for the localized Sage +documentation. + +Additionally, the following system packages are recommended on Debian/Ubuntu: + +- ``texlive-generic-extra`` (to generate pdf documentation) + +- ``texlive-xetex`` (to convert Jupyter notebooks to pdf) + +- ``latexmk`` (to generate pdf documentation) + +- ``dvipng`` (to render text with LaTeX in Matplotlib) + +pandoc +^^^^^^ + +This is useful to convert Jupyter notebooks to pdf. + +ffmpeg, ImageMagick +^^^^^^^^^^^^^^^^^^^ + +If you don't have either ImageMagick or ffmpeg, you won't be able to view +animations. ffmpeg can produce animations in more different formats than +ImageMagick, and seems to be faster than ImageMagick when creating animated +GIFs. + +``libavdevice-dev`` is a component of ffmpeg to produce animations, and +recommended to install on Debian/Ubuntu. + + From 59ccc746945ed0f2600f4bad9e40ccc6721c90e6 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 13 Sep 2023 21:29:25 +0900 Subject: [PATCH 034/494] More edits of installation guide --- src/doc/en/installation/binary.rst | 2 +- src/doc/en/installation/index.rst | 3 +-- src/doc/en/installation/linux.rst | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/doc/en/installation/binary.rst b/src/doc/en/installation/binary.rst index 5fcce7d5943..4943245a845 100644 --- a/src/doc/en/installation/binary.rst +++ b/src/doc/en/installation/binary.rst @@ -1,6 +1,6 @@ .. _sec-installation-from-binaries: -Install from Pre-built Binaries +Install from Pre-Built Binaries =============================== Linux diff --git a/src/doc/en/installation/index.rst b/src/doc/en/installation/index.rst index 437169a83a3..50d0af27341 100644 --- a/src/doc/en/installation/index.rst +++ b/src/doc/en/installation/index.rst @@ -128,7 +128,7 @@ In the cloud ============ - `Sage Binder repo `_ provides a - Binder badge to launch JupyterLab computing environment with Sage. + Binder badge to launch JupyterLab environment with Sage. - `Sage Cell Server `_ is a free online service for quick computations with Sage. @@ -140,7 +140,6 @@ In the cloud `_ can be used on any system with Docker to run CoCalc locally. - More information: .. toctree:: diff --git a/src/doc/en/installation/linux.rst b/src/doc/en/installation/linux.rst index ec3b5e07ecf..2b2e7bafe2b 100644 --- a/src/doc/en/installation/linux.rst +++ b/src/doc/en/installation/linux.rst @@ -1,6 +1,6 @@ .. _sec-GNU-Linux: -Linux package managers +Linux Package Managers ====================== SageMath is available from various distributions and can be installed From 1061ab5ce0a2c9c2f04018ef65d765f185621b69 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 14 Sep 2023 20:24:29 +0900 Subject: [PATCH 035/494] Use binder repo sagemath/sage-binder-env/dev --- .github/workflows/doc-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index eb4f81f303c..5d7504685ec 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -84,6 +84,7 @@ jobs: set -ex export SAGE_USE_CDNS=yes export SAGE_LIVE_DOC=yes + export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env/dev mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git From d72bc2a0fbb08e5b3f4460adc45041fa93cc3255 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 15 Sep 2023 08:54:08 +0900 Subject: [PATCH 036/494] Fix thebe config error --- src/sage_docbuild/conf.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index c7953980973..1c070c99b43 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -58,15 +58,26 @@ if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': SAGE_JUPYTER_SERVER = os.environ.get('SAGE_JUPYTER_SERVER', 'binder') if SAGE_JUPYTER_SERVER.startswith('binder'): - if SAGE_JUPYTER_SERVER == 'binder': # default binder repo - binder_repo = "sagemath/sage-binder-env" - else: # format "binder:sagemath/sage-binder-env" + # format: "binder" or + # "binder:sagemath/sage-binder-env" or + # "binder:sagemath/sage-binder-env/dev" + if SAGE_JUPYTER_SERVER == 'binder': + binder_repo = "sagemath/sage-binder-env/master" + else: binder_repo = SAGE_JUPYTER_SERVER[7:] + s = binder_repo.split('/') + if len(s) > 2: + binder_options = { + 'repo': s[0] + '/' + s[1], + 'ref': s[2] + } + else: + binder_options = { + 'repo': binder_repo + } jupyter_sphinx_thebelab_config = { 'requestKernel': False, - 'binderOptions': { - 'repo': binder_repo, - }, + 'binderOptions': binder_options, 'kernelOptions': { 'name': "sagemath", 'kernelName': "sagemath", From f80b252c349075de303b481bb0eb8bf6d8bd435e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 15 Sep 2023 11:31:18 +0900 Subject: [PATCH 037/494] Binder repo branch part can have slashes --- src/sage_docbuild/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 1c070c99b43..9134a5abb9b 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -65,7 +65,7 @@ binder_repo = "sagemath/sage-binder-env/master" else: binder_repo = SAGE_JUPYTER_SERVER[7:] - s = binder_repo.split('/') + s = binder_repo.split('/', 2) if len(s) > 2: binder_options = { 'repo': s[0] + '/' + s[1], From f76c2cd0c8165942d23e5ef656f21912fd0ffe98 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 16:33:52 -0700 Subject: [PATCH 038/494] src/sage/rings/number_field/galois_group.py: Add file level # needs --- src/sage/rings/number_field/galois_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py index 07b58b7b2a2..6e159f9e3fa 100644 --- a/src/sage/rings/number_field/galois_group.py +++ b/src/sage/rings/number_field/galois_group.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.groups sage.rings.number_field """ Galois Groups of Number Fields From 682b174f737300ad32ee4bb95d583bc93439d376 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 16:52:06 -0700 Subject: [PATCH 039/494] sage.rings.number_field: Update # needs --- src/sage/rings/number_field/S_unit_solver.py | 13 +++++----- src/sage/rings/number_field/number_field.py | 10 ++++---- .../rings/number_field/number_field_base.pyx | 15 ++++++++---- .../number_field/number_field_element.pyx | 14 +++++------ .../number_field_element_quadratic.pyx | 1 + .../rings/number_field/number_field_ideal.py | 9 +++---- .../rings/number_field/number_field_rel.py | 24 +++++++++---------- .../rings/number_field/splitting_field.py | 6 ++--- 8 files changed, 50 insertions(+), 42 deletions(-) diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py index 92f7af1bf19..b7e40d9893d 100644 --- a/src/sage/rings/number_field/S_unit_solver.py +++ b/src/sage/rings/number_field/S_unit_solver.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field sage.rings.padics r""" Solve S-unit equation x + y = 1 @@ -104,7 +105,7 @@ def column_Log(SUK, iota, U, prec=106): sage: phi_complex = K.places()[1] sage: v_fin = S[0] sage: U = [phi_complex, v_fin] - sage: column_Log(SUK, xi^2, U) # abs tol 1e-29 + sage: column_Log(SUK, xi^2, U) # abs tol 1e-29 [1.464816384890812968648768625966, -2.197224577336219382790490473845] REFERENCES: @@ -787,10 +788,10 @@ def c11_func(SUK, v, A, prec=106): sage: phi_complex = K.places()[1] sage: A = K.roots_of_unity() - sage: c11_func(SUK, phi_real, A) # abs tol 1e-29 + sage: c11_func(SUK, phi_real, A) # abs tol 1e-29 3.255848343572896153455615423662 - sage: c11_func(SUK, phi_complex, A) # abs tol 1e-29 + sage: c11_func(SUK, phi_complex, A) # abs tol 1e-29 6.511696687145792306911230847323 REFERENCES: @@ -827,10 +828,10 @@ def c13_func(SUK, v, prec=106): sage: phi_real = K.places()[0] sage: phi_complex = K.places()[1] - sage: c13_func(SUK, phi_real) # abs tol 1e-29 + sage: c13_func(SUK, phi_real) # abs tol 1e-29 0.4257859134798034746197327286726 - sage: c13_func(SUK, phi_complex) # abs tol 1e-29 + sage: c13_func(SUK, phi_complex) # abs tol 1e-29 0.2128929567399017373098663643363 It is an error to input a finite place. :: @@ -968,7 +969,7 @@ def minimal_vector(A, y, prec=106): [ 1 1 -2] [ 6 1 -1] sage: y = vector([1, 2, 100]) - sage: minimal_vector(B, y) # random + sage: minimal_vector(B, y) # random 15/28 """ if A.is_singular(): diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index bc35e0ec0ed..abb58cadb8e 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -199,7 +199,7 @@ def is_NumberFieldHomsetCodomain(codomain): Caveat: Gap objects are not (yet) in :class:`Fields`, and therefore not accepted as number field homset codomains:: - sage: is_NumberFieldHomsetCodomain(gap.Rationals) + sage: is_NumberFieldHomsetCodomain(gap.Rationals) # needs sage.libs.gap False """ from sage.categories.fields import Fields @@ -400,7 +400,7 @@ def NumberField(polynomial, name=None, check=True, names=None, embedding=None, sage: K. = NumberField(x^3-2, embedding=CC.gen()-0.6) sage: CC(a) -0.629960524947436 + 1.09112363597172*I - sage: L = Qp(5) + sage: L = Qp(5) # needs sage.rings.padics sage: f = polygen(L)^3 - 2 sage: K. = NumberField(x^3-2, embedding=f.roots()[0][0]) sage: a + L(1) @@ -781,7 +781,7 @@ def NumberFieldTower(polynomials, names, check=True, embeddings=None, latex_name The Galois group is a product of 3 groups of order 2:: - sage: k.absolute_field(names='c').galois_group() + sage: k.absolute_field(names='c').galois_group() # needs sage.groups Galois group 8T3 (2[x]2[x]2) with order 8 of x^8 + 36*x^6 + 302*x^4 + 564*x^2 + 121 Repeatedly calling base_field allows us to descend the internally @@ -1237,7 +1237,7 @@ def create_object(self, version, key, **extra_args): TESTS:: - sage: CyclotomicField.create_object(None, (0, None, True)) + sage: CyclotomicField.create_object(None, (0, None, True)) # needs sage.libs.gap Universal Cyclotomic Field """ n, names, embedding = key @@ -1396,7 +1396,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField): This example was suggested on sage-nt; see :trac:`18942`:: - sage: G = DirichletGroup(80) + sage: G = DirichletGroup(80) # needs sage.modular sage: for chi in G: # long time ....: D = ModularSymbols(chi, 2, -1).cuspidal_subspace().new_subspace().decomposition() ....: for f in D: diff --git a/src/sage/rings/number_field/number_field_base.pyx b/src/sage/rings/number_field/number_field_base.pyx index 1d09825477a..222f8f108a7 100644 --- a/src/sage/rings/number_field/number_field_base.pyx +++ b/src/sage/rings/number_field/number_field_base.pyx @@ -186,11 +186,11 @@ cdef class NumberField(Field): EXAMPLES:: - sage: K. = NumberField(x^3+2) + sage: K. = NumberField(x^3 + 2) sage: K.is_absolute() True sage: y = polygen(K) - sage: L. = NumberField(y^2+1) + sage: L. = NumberField(y^2 + 1) sage: L.is_absolute() False sage: QQ.is_absolute() @@ -253,6 +253,7 @@ cdef class NumberField(Field): The Minkowski bound for `\QQ[i]` tells us that the class number is 1:: + sage: # needs sage.symbolic sage: K = QQ[I] sage: B = K.minkowski_bound(); B 4/pi @@ -261,6 +262,7 @@ cdef class NumberField(Field): We compute the Minkowski bound for `\QQ[\sqrt[3]{2}]`:: + sage: # needs sage.symbolic sage: K = QQ[2^(1/3)] sage: B = K.minkowski_bound(); B 16/3*sqrt(3)/pi @@ -272,6 +274,7 @@ cdef class NumberField(Field): We compute the Minkowski bound for `\QQ[\sqrt{10}]`, which has class number 2:: + sage: # needs sage.symbolic sage: K = QQ[sqrt(10)] sage: B = K.minkowski_bound(); B sqrt(10) @@ -282,7 +285,8 @@ cdef class NumberField(Field): We compute the Minkowski bound for `\QQ[\sqrt{2}+\sqrt{3}]`:: - sage: K. = NumberField([x^2-2, x^2-3]) + sage: # needs sage.symbolic + sage: K. = NumberField([x^2 - 2, x^2 - 3]) sage: L. = QQ[sqrt(2) + sqrt(3)] sage: B = K.minkowski_bound(); B 9/2 @@ -328,6 +332,7 @@ cdef class NumberField(Field): We compute both the Minkowski and Bach bounds for a quadratic field, where the Minkowski bound is much better:: + sage: # needs sage.symbolic sage: K = QQ[sqrt(5)] sage: K.minkowski_bound() 1/2*sqrt(5) @@ -341,6 +346,7 @@ cdef class NumberField(Field): We compute both the Minkowski and Bach bounds for a bigger degree field, where the Bach bound is much better:: + sage: # needs sage.symbolic sage: K = CyclotomicField(37) sage: K.minkowski_bound().n() 7.50857335698544e14 @@ -349,7 +355,7 @@ cdef class NumberField(Field): The bound of course also works for the rational numbers:: - sage: QQ.minkowski_bound() + sage: QQ.bach_bound() # needs sage.symbolic 1 """ ans = 12 * abs(self.discriminant()).log()**2 @@ -413,7 +419,6 @@ cdef class NumberField(Field): sage: K._get_embedding_approx(1).str(style='brackets') '[0.334734141943352687075098962473280 .. 0.334734141943352687075098962473287]' - sage: K._get_embedding_approx(2).prec() 212 sage: K._get_embedding_approx(1).prec() diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index fb37690f280..abfb10f9ef8 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -528,9 +528,9 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) - sage: (a**2 - a + 1)._gap_init_() + sage: (a**2 - a + 1)._gap_init_() # needs sage.libs.gap '\\$sage4^2 - \\$sage4 + 1' - sage: gap(_) + sage: gap(_) # needs sage.libs.gap a^2-a+1 sage: F = CyclotomicField(8) @@ -1662,12 +1662,12 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: L. = NumberField(X^4 + a + 2) sage: (a/4).is_norm(L) True - sage: (a/2).is_norm(L) + sage: (a/2).is_norm(L) # needs sage.groups Traceback (most recent call last): ... NotImplementedError: is_norm is not implemented unconditionally for norms from non-Galois number fields - sage: (a/2).is_norm(L, proof=False) + sage: (a/2).is_norm(L, proof=False) # needs sage.groups False sage: K. = NumberField(x^3 + x + 1) @@ -3093,13 +3093,13 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: c = a.galois_conjugates(K); c [a] sage: K. = NumberField(x^3 - 2) - sage: c = a.galois_conjugates(K.galois_closure('a1')); c + sage: c = a.galois_conjugates(K.galois_closure('a1')); c # needs sage.groups [1/18*a1^4, -1/36*a1^4 + 1/2*a1, -1/36*a1^4 - 1/2*a1] sage: c[0]^3 2 sage: parent(c[0]) Number Field in a1 with defining polynomial x^6 + 108 - sage: parent(c[0]).is_galois() + sage: parent(c[0]).is_galois() # needs sage.groups True There is only one Galois conjugate of `\sqrt[3]{2}` in @@ -4513,7 +4513,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: L. = K.extension(x^2 + 1) sage: K(7).residue_symbol(K.ideal(11),2) -1 - sage: K(7).residue_symbol(L.ideal(11),2) + sage: K(7).residue_symbol(L.ideal(11),2) # needs sage.libs.gap 1 Cubic Residue:: diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pyx b/src/sage/rings/number_field/number_field_element_quadratic.pyx index c32f6aadd10..f0a7d8ae078 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx @@ -1,3 +1,4 @@ +# sage.doctests: needs sage.rings.number_field # distutils: libraries = NTL_LIBRARIES # distutils: extra_compile_args = NTL_CFLAGS # distutils: include_dirs = NTL_INCDIR diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index 161ef40a842..de95aa69369 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -273,6 +273,7 @@ def _mul_(self, other): EXAMPLES:: + sage: # needs sage.symbolic sage: K.=QQ[i] sage: A = K.ideal([5, 2 + I]) sage: B = K.ideal([13, 5 + 12*I]) @@ -804,11 +805,11 @@ def gens_reduced(self, proof=None): sage: R. = QQ['x'] sage: L. = NumberField(x^10 - 10*x^8 - 20*x^7 + 165*x^6 - 12*x^5 - 760*x^3 + 2220*x^2 + 5280*x + 7744) sage: z_x = -96698852571685/2145672615243325696*b^9 + 2472249905907/195061146840302336*b^8 + 916693155514421/2145672615243325696*b^7 + 1348520950997779/2145672615243325696*b^6 - 82344497086595/12191321677518896*b^5 + 2627122040194919/536418153810831424*b^4 - 452199105143745/48765286710075584*b^3 + 4317002771457621/536418153810831424*b^2 + 2050725777454935/67052269226353928*b + 3711967683469209/3047830419379724 - sage: P = EllipticCurve(L, '57a1').lift_x(z_x) * 3 - sage: ideal = L.fractional_ideal(P[0], P[1]) - sage: ideal.is_principal(proof=False) + sage: P = EllipticCurve(L, '57a1').lift_x(z_x) * 3 # needs sage.schemes + sage: ideal = L.fractional_ideal(P[0], P[1]) # needs sage.schemes + sage: ideal.is_principal(proof=False) # needs sage.schemes True - sage: len(ideal.gens_reduced(proof=False)) + sage: len(ideal.gens_reduced(proof=False)) # needs sage.schemes 1 """ if len(self.gens()) <= 1: diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 1e8a6a17fe1..7f642cfcc7f 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -579,7 +579,7 @@ def galois_closure(self, names=None): sage: x = polygen(ZZ, 'x') sage: K. = NumberField([x^4 + 3, x^2 + 2]); K Number Field in a with defining polynomial x^4 + 3 over its base field - sage: K.galois_closure('c') + sage: K.galois_closure('c') # needs sage.groups Number Field in c with defining polynomial x^16 + 16*x^14 + 28*x^12 + 784*x^10 + 19846*x^8 - 595280*x^6 + 2744476*x^4 + 3212848*x^2 + 29953729 """ @@ -1234,7 +1234,7 @@ def is_galois_absolute(self): sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: y = polygen(K); L. = K.extension(y^2 - a) - sage: L.is_galois_absolute() + sage: L.is_galois_absolute() # needs sage.groups False """ @@ -1255,12 +1255,12 @@ def is_isomorphic_relative(self, other, base_isom=None): sage: R. = PolynomialRing(K) sage: m1 = 3*z9^4 - 4*z9^3 - 4*z9^2 + 3*z9 - 8 sage: L1 = K.extension(z^2 - m1, 'b1') - sage: G = K.galois_group(); gamma = G.gen() - sage: m2 = (gamma^2)(m1) - sage: L2 = K.extension(z^2 - m2, 'b2') - sage: L1.is_isomorphic_relative(L2) + sage: G = K.galois_group(); gamma = G.gen() # needs sage.groups + sage: m2 = (gamma^2)(m1) # needs sage.groups + sage: L2 = K.extension(z^2 - m2, 'b2') # needs sage.groups + sage: L1.is_isomorphic_relative(L2) # needs sage.groups False - sage: L1.is_isomorphic(L2) + sage: L1.is_isomorphic(L2) # needs sage.groups True sage: L3 = K.extension(z^4 - m1, 'b3') sage: L1.is_isomorphic_relative(L3) @@ -1276,12 +1276,12 @@ def is_isomorphic_relative(self, other, base_isom=None): sage: L1cyc = Kcyc.extension(zcyc^2 - m1cyc, 'b1cyc') sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi1) True - sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi1) + sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi1) # needs sage.groups False - sage: phi2 = K.hom([phi1((gamma^(-2))(z9))]) - sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi2) + sage: phi2 = K.hom([phi1((gamma^(-2))(z9))]) # needs sage.groups + sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi2) # needs sage.groups False - sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi2) + sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi2) # needs sage.groups True Omitting ``base_isom`` raises a :class:`ValueError` when the base fields are not identical:: @@ -1296,7 +1296,7 @@ def is_isomorphic_relative(self, other, base_isom=None): The parameter ``base_isom`` can also be used to check if the relative extensions are Galois conjugate:: - sage: for g in G: + sage: for g in G: # needs sage.groups ....: if L1.is_isomorphic_relative(L2, g.as_hom()): ....: print(g.as_hom()) Ring endomorphism of Number Field in z9 with defining polynomial x^6 + x^3 + 1 diff --git a/src/sage/rings/number_field/splitting_field.py b/src/sage/rings/number_field/splitting_field.py index 927ecb3b5fb..46c535d2a5e 100644 --- a/src/sage/rings/number_field/splitting_field.py +++ b/src/sage/rings/number_field/splitting_field.py @@ -283,8 +283,8 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No Some bigger examples:: sage: R. = PolynomialRing(QQ) - sage: pol15 = chebyshev_T(31, x) - 1 # 2^30*(x-1)*minpoly(cos(2*pi/31))^2 # needs sage.symbolic - sage: pol15.splitting_field('a') # needs sage.symbolic + sage: pol15 = chebyshev_T(31, x) - 1 # 2^30*(x-1)*minpoly(cos(2*pi/31))^2 + sage: pol15.splitting_field('a') Number Field in a with defining polynomial x^15 - x^14 - 14*x^13 + 13*x^12 + 78*x^11 - 66*x^10 - 220*x^9 + 165*x^8 + 330*x^7 - 210*x^6 - 252*x^5 + 126*x^4 + 84*x^3 - 28*x^2 - 8*x + 1 @@ -297,7 +297,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No computation, in particular for polynomials of degree >= 12 or for relative extensions:: - sage: pol15.splitting_field('a', degree_multiple=15) # needs sage.symbolic + sage: pol15.splitting_field('a', degree_multiple=15) Number Field in a with defining polynomial x^15 + x^14 - 14*x^13 - 13*x^12 + 78*x^11 + 66*x^10 - 220*x^9 - 165*x^8 + 330*x^7 + 210*x^6 - 252*x^5 - 126*x^4 + 84*x^3 + 28*x^2 - 8*x - 1 From b25e987717cb295e17941d41962868817004cf4c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 17:11:52 -0700 Subject: [PATCH 040/494] src/sage/rings/universal_cyclotomic_field.py: Update distribution, # needs --- src/sage/rings/universal_cyclotomic_field.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/universal_cyclotomic_field.py b/src/sage/rings/universal_cyclotomic_field.py index 8afd960006c..e60d59cd0db 100644 --- a/src/sage/rings/universal_cyclotomic_field.py +++ b/src/sage/rings/universal_cyclotomic_field.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap r""" Universal cyclotomic field @@ -576,7 +577,7 @@ def to_cyclotomic_field(self, R=None): [ E(3) E(4)] [ E(5) -E(3)^2] - sage: Matrix(CyclotomicField(60),M) # indirect doctest + sage: Matrix(CyclotomicField(60),M) # indirect doctest [zeta60^10 - 1 zeta60^15] [ zeta60^12 zeta60^10] @@ -699,7 +700,7 @@ def _eval_complex_(self, R): 2.41421356237310? sage: (1 + E(8) - E(8,3))._eval_complex_(CC) 2.41421356237309 - sage: (1 + E(8) - E(8,3))._eval_complex_(CDF) # abs tol 1e-14 + sage: (1 + E(8) - E(8,3))._eval_complex_(CDF) # abs tol 1e-14 2.414213562373095 """ if self._obj.IsRat(): @@ -1331,7 +1332,7 @@ def _first_ngens(self, n): This method is needed to make the following work:: - sage: UCF. = UniversalCyclotomicField() # indirect doctest + sage: UCF. = UniversalCyclotomicField() # indirect doctest """ if n == 1: return (self.gen,) From 7a652705d50d936533c4e87ca48f30291701ccae Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 17:23:19 -0700 Subject: [PATCH 041/494] src/sage/algebras: Add file-level tags; src/sage/rings/finite_rings: Add tags --- src/sage/rings/finite_rings/element_ntl_gf2e.pyx | 4 ++-- src/sage/rings/finite_rings/element_pari_ffelt.pyx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index 7c5ab521b7a..5ef38815663 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -1152,9 +1152,9 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): sage: k. = GF(2^16) sage: b._gap_init_() 'Z(65536)^1' - sage: k(gap('Z(2^16)^3+Z(2^16)^5')) + sage: k(gap('Z(2^16)^3+Z(2^16)^5')) # needs sage.libs.gap b^5 + b^3 - sage: k(libgap.Z(2^16)^3+libgap.Z(2^16)^5) + sage: k(libgap.Z(2^16)^3+libgap.Z(2^16)^5) # needs sage.libs.gap b^5 + b^3 """ F = self._parent diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 2d29f424e3b..30ad3075da6 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -202,22 +202,22 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): sage: F = FiniteField(2^3, 'a', impl='pari_ffelt') sage: a = F.multiplicative_generator(); a a - sage: b = gap(a^3); b + sage: b = gap(a^3); b # needs sage.libs.gap Z(2^3)^3 sage: F(b) a + 1 sage: a^3 a + 1 - sage: a = GF(13)(gap('0*Z(13)')); a + sage: a = GF(13)(gap('0*Z(13)')); a # needs sage.libs.gap 0 sage: a.parent() Finite Field of size 13 sage: F = FiniteField(2^4, 'a', impl='pari_ffelt') - sage: F(gap('Z(16)^3')) + sage: F(gap('Z(16)^3')) # needs sage.libs.gap a^3 - sage: F(gap('Z(16)^2')) + sage: F(gap('Z(16)^2')) # needs sage.libs.gap a^2 You can also call a finite extension field with a string From 9ead00bf4073e5496fd5ea46b5a46e51a7cc1cc0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 09:46:13 -0700 Subject: [PATCH 042/494] ./sage -fixdoctests --distribution sagemath-categories --only-tags src/sage/rings --- src/sage/rings/factorint.pyx | 9 +++++-- src/sage/rings/infinity.py | 2 +- src/sage/rings/integer.pyx | 18 ++++++------- src/sage/rings/morphism.pyx | 16 +++++++----- .../rings/polynomial/multi_polynomial.pyx | 4 +-- .../polynomial/multi_polynomial_sequence.py | 2 +- .../rings/polynomial/polynomial_element.pyx | 26 +++++++++---------- src/sage/rings/polynomial/polynomial_ring.py | 4 +-- .../polynomial/polynomial_ring_constructor.py | 4 +-- 9 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index d4df0e5ea05..cc14b6c6e2f 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -50,6 +50,8 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): EXAMPLES:: sage: from sage.rings.factorint import aurifeuillian + + sage: # needs sage.rings.real_interval_field sage: aurifeuillian(2, 2) [5, 13] sage: aurifeuillian(2, 2^5) @@ -58,6 +60,7 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): [1471, 2851] sage: aurifeuillian(15, 1) [19231, 142111] + sage: aurifeuillian(12, 3) Traceback (most recent call last): ... @@ -76,8 +79,6 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): There is no need to set `F`. It's only for increasing speed of :meth:`factor_aurifeuillian()`. """ - from sage.arith.misc import euler_phi - from sage.rings.real_mpfi import RealIntervalField if check: if not n.is_squarefree(): raise ValueError("n has to be square-free") @@ -85,6 +86,10 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): raise ValueError("n has to be greater than 1") if m < 1: raise ValueError("m has to be positive") + + from sage.arith.misc import euler_phi + from sage.rings.real_mpfi import RealIntervalField + x = m**2*n cdef Py_ssize_t y = euler_phi(2*n)//2 if F is None: diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index c5ab0b24f32..4f6916210e6 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -1857,7 +1857,7 @@ def test_signed_infinity(pos_inf): sage: from sage.rings.infinity import test_signed_infinity sage: test_signed_infinity(oo) sage: test_signed_infinity(float('+inf')) - sage: test_signed_infinity(RLF(oo)) + sage: test_signed_infinity(RLF(oo)) # needs sage.rings.real_interval_field sage: test_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field sage: test_signed_infinity(SR(oo)) # needs sage.symbolic """ diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 0ca24804524..bc0d7dfa3fb 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -1468,10 +1468,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: sage: n=3^100000 - sage: n.digits(base=10)[-1] # slightly slower than str + sage: n.digits(base=10)[-1] # slightly slower than str # needs sage.rings.real_interval_field 1 sage: n=10^10000 - sage: n.digits(base=10)[-1] # slightly faster than str + sage: n.digits(base=10)[-1] # slightly faster than str # needs sage.rings.real_interval_field 1 AUTHORS: @@ -1710,13 +1710,13 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: n.ndigits(2) 4 sage: n = 1000**1000000+1 - sage: n.ndigits() + sage: n.ndigits() # needs sage.rings.real_interval_field 3000001 sage: n = 1000**1000000-1 - sage: n.ndigits() + sage: n.ndigits() # needs sage.rings.real_interval_field 3000000 sage: n = 10**10000000-10**9999990 - sage: n.ndigits() + sage: n.ndigits() # needs sage.rings.real_interval_field 10000000 """ cdef Integer temp @@ -2524,9 +2524,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: Integer(125)._exact_log_mpfi_log(3) + sage: Integer(125)._exact_log_mpfi_log(3) # needs sage.rings.real_interval_field 4 - sage: Integer(5^150)._exact_log_mpfi_log(5) + sage: Integer(5^150)._exact_log_mpfi_log(5) # needs sage.rings.real_interval_field 150 """ cdef int i @@ -2636,7 +2636,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: Integer(178^1700+1).exact_log(178) 1700 sage: # we need to exercise the large base code path too - sage: Integer(1780^1700-1).exact_log(1780) + sage: Integer(1780^1700-1).exact_log(1780) # needs sage.rings.real_interval_field 1699 sage: # The following are very very fast. @@ -2783,7 +2783,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): For extremely large numbers, this works:: sage: x = 3^100000 - sage: log(x, 3) + sage: log(x, 3) # needs sage.rings.real_interval_field 100000 Also ``log(x)``, giving a symbolic output, diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 797445e78eb..186cce139de 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -80,7 +80,7 @@ From smaller to bigger doesn't make sense:: From bigger to small does:: - sage: f = RR.hom( RealField(15) ) # needs sage.rings.real_mpfr + sage: f = RR.hom(RealField(15)) # needs sage.rings.real_mpfr sage: f(2.5) 2.500 sage: f(RR.pi()) @@ -88,6 +88,7 @@ From bigger to small does:: Inclusion map from the reals to the complexes:: + sage: # needs sage.rings.real_mpfr sage: i = RR.hom([CC(1)]); i Ring morphism: From: Real Field with 53 bits of precision @@ -98,7 +99,7 @@ Inclusion map from the reals to the complexes:: A map from a multivariate polynomial ring to itself:: - sage: R. = PolynomialRing(QQ,3) + sage: R. = PolynomialRing(QQ, 3) sage: phi = R.hom([y, z, x^2]); phi Ring endomorphism of Multivariate Polynomial Ring in x, y, z over Rational Field Defn: x |--> y @@ -347,8 +348,9 @@ TESTS:: :: - sage: K. = CyclotomicField(7) # needs sage.rings.number_field - sage: c = K.hom([1/zeta7]) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(7) + sage: c = K.hom([1/zeta7]) sage: c == loads(dumps(c)) True @@ -365,7 +367,7 @@ compare equal:: sage: # needs sage.rings.finite_rings sage: k = GF(2) sage: R. = k[] - sage: F4. = R.quo(x^2+x+1) + sage: F4. = R.quo(x^2 + x + 1) sage: H = End(F4) sage: from sage.rings.morphism import * sage: phi1 = H.identity(); phi1 @@ -1588,7 +1590,7 @@ cdef class RingHomomorphism(RingMap): :: sage: R. = LaurentPolynomialRing(QQ) - sage: R.hom([y, x], R).inverse() + sage: R.hom([y, x], R).inverse() # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError @@ -2023,7 +2025,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): A multivariate quotient over a finite field:: sage: R. = GF(7)[] - sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) + sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) # needs sage.libs.singular sage: f1 = R.hom([a, b]) sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) sage: f1 == f2 diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index d0a430bbfd8..14f7de9f5a6 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -2086,7 +2086,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: r = x*y*z*t + 1 sage: p = r * (x - y + z - t + 1) sage: q = r * (x*z - y*t) - sage: gcd(p, q) + sage: gcd(p, q) # needs sage.libs.singular z*t*x*y + 1 sage: _.parent() Multivariate Polynomial Ring in x, y over @@ -2726,7 +2726,7 @@ cdef class MPolynomial(CommutativePolynomial): is not a subring of the real numbers, as the notion is not defined in this case:: - sage: Q. = CC[] + sage: Q. = CC[] # needs sage.rings.real_mpfr sage: q = z^2 + w^2 sage: q.is_lorentzian() Traceback (most recent call last): diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index 19c53c392b2..d4a7f5575ab 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -1125,7 +1125,7 @@ def reduced(self): sage: Sequence([2*x,y]).reduced() [x, y] - sage: P. = CC[] + sage: P. = CC[] # needs sage.rings.real_mpfr sage: Sequence([2*x,y]).reduced() [x, y] diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index c5a1129aecf..504d1bd8526 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -1364,15 +1364,15 @@ cdef class Polynomial(CommutativePolynomial): 0.2 sage: RR(a) 0.200000000000000 - sage: CC(a) + sage: CC(a) # needs sage.rings.real_mpfr 0.200000000000000 sage: RBF(a) # needs sage.libs.flint [0.2000000000000000 +/- 4.45e-17] sage: CBF(a) # needs sage.libs.flint [0.2000000000000000 +/- 4.45e-17] - sage: RIF(a) + sage: RIF(a) # needs sage.rings.real_interval_field 0.2000000000000000? - sage: CIF(a) + sage: CIF(a) # needs sage.rings.complex_interval_field 0.2000000000000000? sage: float(a) 0.2 @@ -4531,14 +4531,14 @@ cdef class Polynomial(CommutativePolynomial): sage: P. = PolynomialRing(ZZ) sage: R. = PolynomialRing(FractionField(P)) sage: p = (x - a) * (b*x + c) * (a*b*x + a*c) / (a + 2) - sage: factor(p) + sage: factor(p) # needs sage.libs.singular (a/(a + 2)) * (x - a) * (b*x + c)^2 Check that :trac:`24973` is fixed:: sage: x1 = ZZ['x'].gen() sage: x2 = ZZ['x']['x'].gen() - sage: (x1 - x2).factor() + sage: (x1 - x2).factor() # needs sage.libs.singular -x + x Check that :trac:`26421' is fixed:: @@ -4546,16 +4546,16 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = LaurentPolynomialRing(ZZ) sage: P. = R[] sage: p = x^4 + (-5 - 2*t)*x^3 + (-2 + 10*t)*x^2 + (10 + 4*t)*x - 20*t - sage: p.factor() + sage: p.factor() # needs sage.libs.singular (x - 5) * (x - 2*t) * (x^2 - 2) Check that :trac:`29266` is fixed: sage: f = t*x + t - sage: f.is_irreducible() + sage: f.is_irreducible() # needs sage.libs.singular True sage: f = 2*x + 4 - sage: f.is_irreducible() + sage: f.is_irreducible() # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError @@ -7790,7 +7790,7 @@ cdef class Polynomial(CommutativePolynomial): :: - sage: x = CC['x'].0 + sage: x = CC['x'].0 # needs sage.rings.real_mpfr sage: f = x^3 - 2 sage: f.roots() # needs numpy [(1.25992104989487, 1), @@ -8333,7 +8333,7 @@ cdef class Polynomial(CommutativePolynomial): Spurious crash with pari-2.5.5, see :trac:`16165`:: sage: f = (1+x+x^2)^3 - sage: f.roots(ring=CC) + sage: f.roots(ring=CC) # needs sage.rings.real_mpfr [(-0.500000000000000 - 0.866025403784439*I, 3), (-0.500000000000000 + 0.866025403784439*I, 3)] @@ -8341,7 +8341,7 @@ cdef class Polynomial(CommutativePolynomial): sage: polRing. = PolynomialRing(ZZ) sage: j = (x+1)^2 * (x-1)^7 * (x^2-x+1)^5 - sage: j.roots(CC) + sage: j.roots(CC) # needs sage.rings.real_mpfr [(-1.00000000000000, 2), (1.00000000000000, 7), (0.500000000000000 - 0.866025403784439*I, 5), @@ -8364,7 +8364,7 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = LaurentPolynomialRing(ZZ) sage: P. = R[] sage: p = x^4 + (-5 - 2*t)*x^3 + (-2 + 10*t)*x^2 + (10 + 4*t)*x - 20*t - sage: p.roots() + sage: p.roots() # needs sage.libs.singular [(5, 1), (2*t, 1)] Check that :trac:`31040` is fixed:: @@ -9196,7 +9196,7 @@ cdef class Polynomial(CommutativePolynomial): is not a subring of the real numbers, as the notion is not defined in this case:: - sage: Q. = CC[] + sage: Q. = CC[] # needs sage.rings.real_mpfr sage: q = y^2 sage: q.is_lorentzian() Traceback (most recent call last): diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index af37b6d9fd7..dd416bd84b0 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -1057,7 +1057,7 @@ def change_ring(self, R): EXAMPLES:: - sage: R. = RealIntervalField()[]; R + sage: R. = RealIntervalField()[]; R # needs sage.rings.real_interval_field Univariate Polynomial Ring in ZZZ over Real Interval Field with 53 bits of precision sage: R.change_ring(GF(19^2, 'b')) # needs sage.rings.finite_rings @@ -1160,7 +1160,7 @@ def characteristic(self): EXAMPLES:: - sage: R. = RealIntervalField()[]; R + sage: R. = RealIntervalField()[]; R # needs sage.rings.real_interval_field Univariate Polynomial Ring in ZZZ over Real Interval Field with 53 bits of precision sage: R.characteristic() 0 diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index ecccc51519e..ba1c3c47821 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -611,11 +611,11 @@ def PolynomialRing(base_ring, *args, **kwds): sage: R = PolynomialRing(GF(49), 'j', sparse=True); TestSuite(R).run(); type(R) # needs sage.rings.finite_rings - sage: P. = PolynomialRing(RealIntervalField(2)) + sage: P. = PolynomialRing(RealIntervalField(2)) # needs sage.rings.real_interval_field sage: TestSuite(P).run(skip=['_test_elements', '_test_elements_eq_transitive']) sage: Q. = PolynomialRing(P) sage: TestSuite(Q).run(skip=['_test_additive_associativity', '_test_associativity', '_test_distributivity', '_test_prod']) - sage: R. = PolynomialRing(RIF,2) + sage: R. = PolynomialRing(RIF,2) # needs sage.rings.real_interval_field sage: TestSuite(R).run(skip=['_test_elements', '_test_elements_eq_transitive']) """ if not ring.is_Ring(base_ring): From be756b6dfa659d9800c69de308040bff1aec0f8e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 10:43:49 -0700 Subject: [PATCH 043/494] sage.rings: Block tags, update # needs --- .../rings/finite_rings/finite_field_prime_modn.py | 6 +++--- src/sage/rings/finite_rings/integer_mod_ring.py | 8 ++++---- src/sage/rings/function_field/function_field.py | 12 +++++++----- src/sage/rings/polynomial/toy_variety.py | 2 +- src/sage/rings/power_series_ring_element.pyx | 4 ++-- src/sage/rings/ring.pyx | 2 +- src/sage/rings/sum_of_squares.pyx | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) 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 95c1803abf4..2c52681e822 100644 --- a/src/sage/rings/finite_rings/finite_field_prime_modn.py +++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py @@ -105,7 +105,7 @@ def _coerce_map_from_(self, S): sage: 12 % 7 5 - sage: ZZ.residue_field(7).hom(GF(7))(1) # See trac 11319 # needs sage.rings.finite_rings + sage: ZZ.residue_field(7).hom(GF(7))(1) # See trac 11319 1 sage: # needs sage.rings.finite_rings sage.rings.number_field @@ -120,12 +120,12 @@ def _coerce_map_from_(self, S): Check that :trac:`19573` is resolved:: - sage: Integers(9).hom(GF(3)) # needs sage.rings.finite_rings + sage: Integers(9).hom(GF(3)) Natural morphism: From: Ring of integers modulo 9 To: Finite Field of size 3 - sage: Integers(9).hom(GF(5)) # needs sage.rings.finite_rings + sage: Integers(9).hom(GF(5)) Traceback (most recent call last): ... TypeError: natural coercion morphism from Ring of integers modulo 9 to Finite Field of size 5 not defined diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index b615d3a8c1a..c4c84a26ed3 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -19,13 +19,13 @@ sage: s = GF(7) sage: r.has_coerce_map_from(s) False - sage: s.has_coerce_map_from(r) # needs sage.rings.finite_rings + sage: s.has_coerce_map_from(r) True - sage: s(1) + r(1) # needs sage.rings.finite_rings + sage: s(1) + r(1) 2 - sage: parent(s(1) + r(1)) # needs sage.rings.finite_rings + sage: parent(s(1) + r(1)) Finite Field of size 7 - sage: parent(r(1) + s(1)) # needs sage.rings.finite_rings + sage: parent(r(1) + s(1)) Finite Field of size 7 We list the elements of `\ZZ/3\ZZ`:: diff --git a/src/sage/rings/function_field/function_field.py b/src/sage/rings/function_field/function_field.py index 26975773a88..47056fffb5c 100644 --- a/src/sage/rings/function_field/function_field.py +++ b/src/sage/rings/function_field/function_field.py @@ -127,11 +127,13 @@ sage: TestSuite(J).run() sage: TestSuite(K).run(max_runs=256) # long time (10s) # needs sage.rings.number_field sage: TestSuite(L).run(max_runs=8) # long time (25s) # needs sage.rings.function_field sage.rings.number_field - sage: TestSuite(M).run(max_runs=8) # long time (35s) # needs sage.rings.finite_rings sage.rings.function_field - sage: TestSuite(N).run(max_runs=8, skip='_test_derivation') # long time (15s), needs sage.rings.finite_rings - sage: TestSuite(O).run() # needs sage.rings.function_field - sage: TestSuite(R).run() # needs sage.rings.finite_rings sage.rings.function_field - sage: TestSuite(S).run() # long time (4s) # needs sage.rings.finite_rings sage.rings.function_field + + sage: # needs sage.rings.finite_rings sage.rings.function_field + sage: TestSuite(M).run(max_runs=8) # long time (35s) + sage: TestSuite(N).run(max_runs=8, skip='_test_derivation') # long time (15s) + sage: TestSuite(O).run() + sage: TestSuite(R).run() + sage: TestSuite(S).run() # long time (4s) Global function fields ---------------------- diff --git a/src/sage/rings/polynomial/toy_variety.py b/src/sage/rings/polynomial/toy_variety.py index 5b51dc5eb00..6b0572e6010 100644 --- a/src/sage/rings/polynomial/toy_variety.py +++ b/src/sage/rings/polynomial/toy_variety.py @@ -164,7 +164,7 @@ def is_linearly_dependent(polys) -> bool: sage: p = x*B[0] sage: is_linearly_dependent(B + [p]) # needs sage.modules False - sage: is_linearly_dependent([]) # needs sage.modules + sage: is_linearly_dependent([]) False """ if not polys: diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index 2436db7af1d..4df2f330288 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -1339,8 +1339,8 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: sage: t = PowerSeriesRing(QQ, 't').gen() - sage: s = sum(factorial(k) * t**k for k in range(12)).O(12) # needs sage.rings.complex_double - sage: s.jacobi_continued_fraction() # needs sage.rings.complex_double + sage: s = sum(factorial(k) * t**k for k in range(12)).O(12) + sage: s.jacobi_continued_fraction() ((-1, -1), (-3, -4), (-5, -9), (-7, -16), (-9, -25)) Another example:: diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index 5273891a5b0..4fe45ed2c59 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -134,7 +134,7 @@ cdef class Ring(ParentWithGens): running ._test_zero_divisors() . . . pass sage: TestSuite(QQ['x','y']).run(skip='_test_elements') # needs sage.libs.singular sage: TestSuite(ZZ['x','y']).run(skip='_test_elements') # needs sage.libs.singular - sage: TestSuite(ZZ['x','y']['t']).run() # needs sage.libs.singular + sage: TestSuite(ZZ['x','y']['t']).run() Test against another bug fixed in :trac:`9944`:: diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index b8f719d4dac..c179f273f3b 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -166,7 +166,7 @@ def two_squares_pyx(uint32_t n): TESTS:: sage: s = lambda t: sum(i^2 for i in t) - sage: for ij in Subsets(Subsets(45000, 15).random_element(), 2): # needs sage.combinat + sage: for ij in Subsets(Subsets(45000, 15).random_element(), 2): ....: if s(two_squares_pyx(s(ij))) != s(ij): ....: print("hey") @@ -254,7 +254,7 @@ def three_squares_pyx(uint32_t n): TESTS:: sage: s = lambda t: sum(i^2 for i in t) - sage: for ijk in Subsets(Subsets(35000,15).random_element(),3): # needs sage.combinat + sage: for ijk in Subsets(Subsets(35000,15).random_element(),3): ....: if s(three_squares_pyx(s(ijk))) != s(ijk): ....: print("hey") """ From 14990f0c4d0be800799eb6a2f5638d44a08717b7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 10:57:09 -0700 Subject: [PATCH 044/494] sage.rings: More block tags, update # needs --- src/sage/rings/factorint.pyx | 3 ++- src/sage/rings/morphism.pyx | 7 ++++--- .../rings/polynomial/infinite_polynomial_element.py | 3 ++- src/sage/rings/polynomial/laurent_polynomial.pyx | 7 ++++--- src/sage/rings/polynomial/multi_polynomial.pyx | 9 +++++---- .../rings/polynomial/multi_polynomial_sequence.py | 12 +++++++++--- src/sage/rings/polynomial/polynomial_element.pyx | 12 +++++++----- src/sage/rings/polynomial/polynomial_ring.py | 6 ++++-- .../rings/polynomial/polynomial_ring_constructor.py | 2 +- 9 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index cc14b6c6e2f..95f91424164 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -51,7 +51,7 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): sage: from sage.rings.factorint import aurifeuillian - sage: # needs sage.rings.real_interval_field + sage: # needs sage.libs.pari sage.rings.real_interval_field sage: aurifeuillian(2, 2) [5, 13] sage: aurifeuillian(2, 2^5) @@ -61,6 +61,7 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): sage: aurifeuillian(15, 1) [19231, 142111] + sage: # needs sage.libs.pari sage: aurifeuillian(12, 3) Traceback (most recent call last): ... diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 186cce139de..96086030697 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -3249,13 +3249,14 @@ def _tensor_product_ring(B, A): EXAMPLES:: + sage: # needs sage.libs.singular sage: from sage.rings.morphism import _tensor_product_ring sage: R. = QQ[] - sage: S. = R.quotient(x^2 + y^2) # needs sage.libs.singular - sage: Q = _tensor_product_ring(S, R); Q # needs sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) + sage: Q = _tensor_product_ring(S, R); Q Quotient of Multivariate Polynomial Ring in u, v, x, y over Rational Field by the ideal (u^2 + v^2) - sage: Q.term_order() # needs sage.libs.singular + sage: Q.term_order() Block term order with blocks: (Degree reverse lexicographic term order of length 2, Degree reverse lexicographic term order of length 2) diff --git a/src/sage/rings/polynomial/infinite_polynomial_element.py b/src/sage/rings/polynomial/infinite_polynomial_element.py index fc8449b340e..338e8df1676 100644 --- a/src/sage/rings/polynomial/infinite_polynomial_element.py +++ b/src/sage/rings/polynomial/infinite_polynomial_element.py @@ -465,7 +465,8 @@ def subs(self, fixed=None, **kwargs): TESTS:: - sage: g.subs(fixed=x[0], x_1=N) # needs sage.modules + sage: # needs sage.modules + sage: g.subs(fixed=x[0], x_1=N) Traceback (most recent call last): ... ValueError: fixed must be a dict diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index cd79996eed7..6515cf17e1a 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -182,9 +182,10 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): Check that :trac:`22277` is fixed:: - sage: R. = LaurentPolynomialRing(QQ) # needs sage.modules - sage: a = 2*x^2 + 3*x^3 + 4*x^-1 # needs sage.modules - sage: a.change_ring(GF(3)) # needs sage.modules + sage: # needs sage.modules + sage: R. = LaurentPolynomialRing(QQ) + sage: a = 2*x^2 + 3*x^3 + 4*x^-1 + sage: a.change_ring(GF(3)) -x^2 + x^-1 """ return self._parent.change_ring(R)(self) diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index 14f7de9f5a6..736e794d3b4 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -1549,7 +1549,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: f = x^5*y + 3*x^2*y^2 - 2*x + y - 1 sage: f.discriminant(y) # needs sage.libs.singular x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - sage: f.polynomial(y).discriminant() + sage: f.polynomial(y).discriminant() # needs sage.libs.pari x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 sage: f.discriminant(y).parent() == f.polynomial(y).discriminant().parent() # needs sage.libs.singular False @@ -1790,10 +1790,11 @@ cdef class MPolynomial(CommutativePolynomial): :: - sage: R. = RR[] # needs sage.rings.real_mpfr - sage: f = a + b + RR('0.3'); f # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: R. = RR[] + sage: f = a + b + RR('0.3'); f a + b + 0.300000000000000 - sage: f.denominator() # needs sage.rings.real_mpfr + sage: f.denominator() 1.00000000000000 Check that the denominator is an element over the base whenever the base diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index d4a7f5575ab..8088eb3349c 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -637,6 +637,7 @@ def algebraic_dependence(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: S = Sequence([x, x*y]) sage: I = S.algebraic_dependence(); I @@ -644,22 +645,26 @@ def algebraic_dependence(self): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: S = Sequence([x, (x^2 + y^2 - 1)^2, x*y - 2]) sage: I = S.algebraic_dependence(); I - Ideal (16 + 32*T2 - 8*T0^2 + 24*T2^2 - 8*T0^2*T2 + 8*T2^3 + 9*T0^4 - 2*T0^2*T2^2 + T2^4 - T0^4*T1 + 8*T0^4*T2 - 2*T0^6 + 2*T0^4*T2^2 + T0^8) of Multivariate Polynomial Ring in T0, T1, T2 over Rational Field + Ideal (16 + 32*T2 - 8*T0^2 + 24*T2^2 - 8*T0^2*T2 + 8*T2^3 + 9*T0^4 - 2*T0^2*T2^2 + + T2^4 - T0^4*T1 + 8*T0^4*T2 - 2*T0^6 + 2*T0^4*T2^2 + T0^8) + of Multivariate Polynomial Ring in T0, T1, T2 over Rational Field sage: [F(S) for F in I.gens()] [0] :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(GF(7)) sage: S = Sequence([x, (x^2 + y^2 - 1)^2, x*y - 2]) - sage: I = S.algebraic_dependence(); I # needs sage.rings.finite_rings + sage: I = S.algebraic_dependence(); I Ideal (2 - 3*T2 - T0^2 + 3*T2^2 - T0^2*T2 + T2^3 + 2*T0^4 - 2*T0^2*T2^2 + T2^4 - T0^4*T1 + T0^4*T2 - 2*T0^6 + 2*T0^4*T2^2 + T0^8) of Multivariate Polynomial Ring in T0, T1, T2 over Finite Field of size 7 - sage: [F(S) for F in I.gens()] # needs sage.rings.finite_rings + sage: [F(S) for F in I.gens()] [0] .. NOTE:: @@ -1187,6 +1192,7 @@ def is_groebner(self, singular=singular): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(GF(127), 10) sage: I = sage.rings.ideal.Cyclic(R, 4) sage: I.basis.is_groebner() diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 504d1bd8526..31f06583b7b 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -8779,8 +8779,9 @@ cdef class Polynomial(CommutativePolynomial): TESTS:: - sage: x = polygen(RR) # needs sage.rings.real_mpfr - sage: (x^3 - 1).complex_roots()[0].parent() # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: x = polygen(RR) + sage: (x^3 - 1).complex_roots()[0].parent() Complex Field with 53 bits of precision sage: x = polygen(RDF) @@ -10094,9 +10095,10 @@ cdef class Polynomial(CommutativePolynomial): TESTS:: - sage: R. = RR[] # needs sage.rings.real_mpfr - sage: f = x^6 + x^2 + -x^4 -x^3 # needs sage.rings.real_mpfr - sage: f.norm(int(2)) # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: R. = RR[] + sage: f = x^6 + x^2 + -x^4 -x^3 + sage: f.norm(int(2)) 2.00000000000000 Check that :trac:`18600` is fixed:: diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index dd416bd84b0..420fa9b754b 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -2067,9 +2067,11 @@ def __init__(self, base_ring, name="x", sparse=False, implementation=None, Sparse Univariate Polynomial Ring in x over Rational Field sage: type(R.gen()) - sage: R = PRing(CC, 'x'); R # needs sage.rings.real_mpfr + + sage: # needs sage.rings.real_mpfr + sage: R = PRing(CC, 'x'); R Univariate Polynomial Ring in x over Complex Field with 53 bits of precision - sage: type(R.gen()) # needs sage.rings.real_mpfr + sage: type(R.gen()) Demonstrate that :trac:`8762` is fixed:: diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index ba1c3c47821..dcb47e2ab41 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -442,7 +442,7 @@ def PolynomialRing(base_ring, *args, **kwds): sage: S = PolynomialRing(GF(2), 'j'); TestSuite(S).run(); type(S) - sage: R = PolynomialRing(ZZ, 'x,y', implementation="generic"); TestSuite(R).run(skip=['_test_elements', '_test_elements_eq_transitive']); type(R) # needs sage.libs.singular + sage: R = PolynomialRing(ZZ, 'x,y', implementation="generic"); TestSuite(R).run(skip=['_test_elements', '_test_elements_eq_transitive']); type(R) sage: S = PolynomialRing(ZZ, 'x,y'); TestSuite(S).run(skip='_test_elements'); type(S) # needs sage.libs.singular From 571b0f711d2a143ef5cc9ac1af03b1c59a45a6f1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 12:47:55 -0700 Subject: [PATCH 045/494] sage.rings: Update # needs --- src/sage/rings/integer.pyx | 11 +-- src/sage/rings/morphism.pyx | 22 +++--- .../rings/polynomial/multi_polynomial.pyx | 2 +- src/sage/rings/polynomial/polydict.pyx | 2 + .../rings/polynomial/polynomial_element.pyx | 15 ++-- .../polynomial/polynomial_element_generic.py | 2 +- src/sage/rings/polynomial/polynomial_ring.py | 6 +- src/sage/rings/polynomial/toy_d_basis.py | 6 +- src/sage/rings/power_series_poly.pyx | 7 +- src/sage/rings/power_series_ring_element.pyx | 69 +++++++++++-------- 10 files changed, 84 insertions(+), 58 deletions(-) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index bc0d7dfa3fb..90d1df0a74b 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -14,7 +14,7 @@ Add 2 integers:: Add an integer and a real number:: - sage: a + 4.0 + sage: a + 4.0 # needs sage.rings.real_mpfr 7.00000000000000 Add an integer and a rational number:: @@ -24,7 +24,8 @@ Add an integer and a rational number:: Add an integer and a complex number:: - sage: b = ComplexField().0 + 1.5 # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: b = ComplexField().0 + 1.5 sage: loads((a + b).dumps()) == a + b True @@ -2139,7 +2140,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: 2^x # symbolic x # needs sage.symbolic 2^x - sage: 2^1.5 # real number + sage: 2^1.5 # real number # needs sage.rings.real_mpfr 2.82842712474619 sage: 2^float(1.5) # python float abs tol 3e-16 2.8284271247461903 @@ -6732,7 +6733,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): 128 sage: int(32) << 2 128 - sage: 1 << 2.5 + sage: 1 << 2.5 # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: unsupported operands for <<: 1, 2.5000... @@ -6765,7 +6766,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): 8 sage: int(32) >> 2 8 - sage: 1 >> 2.5 + sage: 1 >> 2.5 # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: unsupported operands for >>: 1, 2.5000... diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 96086030697..f6e88f8f180 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -45,8 +45,7 @@ Reduction to finite field:: Map from single variable polynomial ring:: sage: R. = ZZ[] - sage: phi = R.hom([2], GF(5)) - sage: phi + sage: phi = R.hom([2], GF(5)); phi Ring morphism: From: Univariate Polynomial Ring in x over Integer Ring To: Finite Field of size 5 @@ -56,12 +55,13 @@ Map from single variable polynomial ring:: Identity map on the real numbers:: + sage: # needs sage.rings.real_mpfr sage: f = RR.hom([RR(1)]); f Ring endomorphism of Real Field with 53 bits of precision Defn: 1.00000000000000 |--> 1.00000000000000 sage: f(2.5) 2.50000000000000 - sage: f = RR.hom( [2.0] ) + sage: f = RR.hom([2.0]) Traceback (most recent call last): ... ValueError: relations do not all (canonically) map to 0 @@ -113,8 +113,7 @@ An endomorphism of a quotient of a multi-variate polynomial ring:: sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: S. = quo(R, ideal(1 + y^2)) - sage: phi = S.hom([a^2, -b]) - sage: phi + sage: phi = S.hom([a^2, -b]); phi Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (y^2 + 1) Defn: a |--> a^2 @@ -166,13 +165,11 @@ We next compose the inclusion with reduction from the integers to ``GF(2)``:: sage: # needs sage.rings.finite_rings - sage: pi = ZZ.hom(k) - sage: pi + sage: pi = ZZ.hom(k); pi Natural morphism: From: Integer Ring To: Finite Field of size 2 - sage: f = i * pi - sage: f + sage: f = i * pi; f Composite map: From: Integer Ring To: Finite Field in a of size 2^2 @@ -1447,7 +1444,7 @@ cdef class RingHomomorphism(RingMap): x1^3 + 3*x1*x2 + x3, x1^4 + 6*x1^2*x2 + 3*x2^2 + 4*x1*x3 + x4, x1^5 + 10*x1^3*x2 + 15*x1*x2^2 + 10*x1^2*x3 + 10*x2*x3 + 5*x1*x4 + x5] - sage: all(p.is_homogeneous() for p in phi.im_gens()) + sage: all(p.is_homogeneous() for p in phi.im_gens()) # needs sage.libs.singular True sage: phi.inverse().im_gens()[:5] # needs sage.libs.singular [x1, @@ -2024,8 +2021,9 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): A multivariate quotient over a finite field:: + sage: # needs sage.libs.singular sage: R. = GF(7)[] - sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) # needs sage.libs.singular + sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) sage: f1 = R.hom([a, b]) sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) sage: f1 == f2 @@ -3268,7 +3266,7 @@ def _tensor_product_ring(B, A): Local orderings are not supported:: sage: R = PolynomialRing(QQ, 'x,y', order='negdeglex') - sage: _tensor_product_ring(R, R) + sage: _tensor_product_ring(R, R) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: term ordering must be global diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index 736e794d3b4..dee2a02e2c6 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -142,7 +142,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: ZZ(RR['x,y'](0)) # indirect doctest 0 - sage: ZZ(RR['x,y'](0.5)) + sage: ZZ(RR['x,y'](0.5)) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer diff --git a/src/sage/rings/polynomial/polydict.pyx b/src/sage/rings/polynomial/polydict.pyx index 0c847d125a4..4734acff8c2 100644 --- a/src/sage/rings/polynomial/polydict.pyx +++ b/src/sage/rings/polynomial/polydict.pyx @@ -879,6 +879,8 @@ cdef class PolyDict: sage: PolyDict({(1, 0): GF(4)(1)}).poly_repr(['x', 'y']) # needs sage.rings.finite_rings 'x' + + sage: # needs sage.modules sage: P. = LaurentPolynomialRing(GF(2), 2) sage: P.gens() (x, y) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 31f06583b7b..c0eb7e19f63 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -1362,7 +1362,7 @@ cdef class Polynomial(CommutativePolynomial): 0.2 sage: CDF(a) # needs sage.rings.complex_double 0.2 - sage: RR(a) + sage: RR(a) # needs sage.rings.real_mpfr 0.200000000000000 sage: CC(a) # needs sage.rings.real_mpfr 0.200000000000000 @@ -1383,11 +1383,11 @@ cdef class Polynomial(CommutativePolynomial): sage: b = AA['x'](AA(2/3).sqrt()) sage: AA(b) 0.8164965809277260? - sage: RR(b) + sage: RR(b) # needs sage.rings.real_mpfr 0.816496580927726 sage: RBF(b) # needs sage.libs.flint [0.816496580927726 +/- 2.44e-16] - sage: RIF(b) + sage: RIF(b) # needs sage.rings.real_interval_field 0.8164965809277260? sage: float(b) 0.816496580927726 @@ -1398,11 +1398,11 @@ cdef class Polynomial(CommutativePolynomial): 0.6324555320336758?*I sage: CDF(c) 0.6324555320336758*I - sage: CC(c) + sage: CC(c) # needs sage.rings.real_mpfr 0.632455532033676*I sage: CBF(c) # abs tol 1e-16 # needs sage.libs.flint [0.6324555320336759 +/- 3.38e-17]*I - sage: CIF(c) + sage: CIF(c) # needs sage.rings.complex_interval_field 0.6324555320336758?*I sage: complex(c) 0.6324555320336758j @@ -3117,6 +3117,7 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: S. = PolynomialRing(RR) sage: f = y^10 - 1.393493*y + 0.3 sage: f._mul_karatsuba(f,0) @@ -3642,6 +3643,7 @@ cdef class Polynomial(CommutativePolynomial): :: + sage: # needs sage.rings.real_mpfr sage: R. = RR[] sage: f = x + RR('0.3'); f x + 0.300000000000000 @@ -3730,6 +3732,7 @@ cdef class Polynomial(CommutativePolynomial): :: + sage: # needs sage.rings.real_mpfr sage: R. = RR[] sage: f = x + RR('0.3'); f x + 0.300000000000000 @@ -8386,6 +8389,7 @@ cdef class Polynomial(CommutativePolynomial): Check that :trac:`33979` is fixed:: + sage: # needs sage.libs.pari sage: n = randint(2, 10^6) sage: K = Integers(n) sage: R. = PolynomialRing(K) @@ -9436,6 +9440,7 @@ cdef class Polynomial(CommutativePolynomial): Over `\RR[z]`:: + sage: # needs sage.rings.real_mpfr sage: z = PowerSeriesRing(RR, 'z').gen() sage: P = PolynomialRing(RR, 'x') sage: x = P.gen() diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py index 1f447fc1287..8b656266625 100644 --- a/src/sage/rings/polynomial/polynomial_element_generic.py +++ b/src/sage/rings/polynomial/polynomial_element_generic.py @@ -777,7 +777,7 @@ def shift(self, n): x^1267650600228229401496703205386 - 5*x^10 sage: p.shift(-10) x^1267650600228229401496703205366 - sage: p.shift(1.5) + sage: p.shift(1.5) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 420fa9b754b..2878ed7f648 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -1160,7 +1160,8 @@ def characteristic(self): EXAMPLES:: - sage: R. = RealIntervalField()[]; R # needs sage.rings.real_interval_field + sage: # needs sage.rings.real_interval_field + sage: R. = RealIntervalField()[]; R Univariate Polynomial Ring in ZZZ over Real Interval Field with 53 bits of precision sage: R.characteristic() 0 @@ -1797,6 +1798,7 @@ def _roots_univariate_polynomial(self, p, ring=None, multiplicities=True, algori EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = QQ[] sage: S. = R[] sage: p = y^3 + (-x^2 - 3)*y^2 + (2*x^3 - x^2 + 3)*y - x^4 + 2*x^2 - 1 @@ -2165,6 +2167,7 @@ def divided_difference(self, points, full_table=False): Only return the divided-difference coefficients `F_{i,i}`. This example is taken from Example 1, page 121 of [BF2005]_:: + sage: # needs sage.rings.real_mpfr sage: points = [(1.0, 0.7651977), (1.3, 0.6200860), (1.6, 0.4554022), ....: (1.9, 0.2818186), (2.2, 0.1103623)] sage: R = PolynomialRing(RR, "x") @@ -2177,6 +2180,7 @@ def divided_difference(self, points, full_table=False): Now return the full divided-difference table:: + sage: # needs sage.rings.real_mpfr sage: points = [(1.0, 0.7651977), (1.3, 0.6200860), (1.6, 0.4554022), ....: (1.9, 0.2818186), (2.2, 0.1103623)] sage: R = PolynomialRing(RR, "x") diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 393eb0452b2..3734449a666 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -35,10 +35,10 @@ the corresponding computation over `\ZZ`:: sage: I = A.ideal([f, fx, fy]) - sage: gb = d_basis(I); gb + sage: gb = d_basis(I); gb # needs sage.libs.singular [x - 2020, y - 11313, 22627] - sage: gb[-1].factor() + sage: gb[-1].factor() # needs sage.libs.singular 11^3 * 17 This Groebner Basis gives a lot of information. First, the only @@ -212,7 +212,7 @@ def d_basis(F, strat=True): sage: fx = f.derivative(x) sage: fy = f.derivative(y) sage: I = A.ideal([f,fx,fy]) - sage: gb = d_basis(I); gb + sage: gb = d_basis(I); gb # needs sage.libs.singular [x - 2020, y - 11313, 22627] """ R = F.ring() diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index c7cd78db093..8b7dcd29697 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -501,6 +501,7 @@ cdef class PowerSeries_poly(PowerSeries): In the past this could die with EXC_BAD_ACCESS (:trac:`8029`):: + sage: # needs sage.rings.real_mpfr sage: A. = RR['x'] sage: B. = PowerSeriesRing(A) sage: 1. + O(t) @@ -1152,6 +1153,7 @@ cdef class PowerSeries_poly(PowerSeries): With real coefficients:: + sage: # needs sage.rings.real_mpfr sage: R. = RR[[]] sage: f = exp(2*z) sage: f.pade(3, 3) # abs tol 1e-10 @@ -1159,6 +1161,7 @@ cdef class PowerSeries_poly(PowerSeries): When precision is too low:: + sage: # needs sage.rings.real_mpfr sage: f = z + O(z**6) sage: f.pade(4, 4) Traceback (most recent call last): @@ -1168,13 +1171,13 @@ cdef class PowerSeries_poly(PowerSeries): Check that :trac:`21212` is fixed:: sage: QQx. = QQ[[]] - sage: (1+x+O(x^100)).pade(2,2) + sage: (1 + x + O(x^100)).pade(2,2) x + 1 Check for correct precision:: sage: QQx. = QQ[[]] - sage: (1+x+O(x^2)).pade(0,1) + sage: (1 + x + O(x^2)).pade(0,1) -1/(x - 1) """ if self.precision_absolute() < n + m + 1: diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index 4df2f330288..685240e21a4 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -1300,6 +1300,7 @@ cdef class PowerSeries(AlgebraElement): Tests other implementations:: + sage: # needs sage.libs.pari sage: R. = PowerSeriesRing(GF(11), implementation='pari') sage: f = q - q^3 + O(q^10) sage: f.map_coefficients(lambda c: c - 2) @@ -1504,26 +1505,26 @@ cdef class PowerSeries(AlgebraElement): def sqrt(self, prec=None, extend=False, all=False, name=None): r""" - Return a square root of self. + Return a square root of ``self``. INPUT: - - ``prec`` - integer (default: None): if not None and the series + - ``prec`` -- integer (default: ``None``): if not ``None`` and the series has infinite precision, truncates series at precision - prec. + ``prec``. - - ``extend`` - bool (default: False); if True, return a square + - ``extend`` -- bool (default: ``False``); if ``True``, return a square root in an extension ring, if necessary. Otherwise, raise - a ValueError if the square root is not in the base power series - ring. For example, if ``extend`` is True the square root of a + a :class:`ValueError` if the square root is not in the base power series + ring. For example, if ``extend`` is ``True``, the square root of a power series with odd degree leading coefficient is defined as an element of a formal extension ring. - - ``name`` - string; if ``extend`` is True, you must also specify the print + - ``name`` -- string; if ``extend`` is True, you must also specify the print name of the formal square root. - - ``all`` - bool (default: False); if True, return all square - roots of self, instead of just one. + - ``all`` -- bool (default: ``False``); if ``True``, return all square + roots of ``self``, instead of just one. ALGORITHM: Newton's method @@ -1536,20 +1537,22 @@ cdef class PowerSeries(AlgebraElement): sage: K. = PowerSeriesRing(QQ, 't', 5) sage: sqrt(t^2) t - sage: sqrt(1+t) + sage: sqrt(1 + t) 1 + 1/2*t - 1/8*t^2 + 1/16*t^3 - 5/128*t^4 + O(t^5) - sage: sqrt(4+t) + sage: sqrt(4 + t) 2 + 1/4*t - 1/64*t^2 + 1/512*t^3 - 5/16384*t^4 + O(t^5) - sage: u = sqrt(2+t, prec=2, extend=True, name = 'alpha'); u + sage: u = sqrt(2 + t, prec=2, extend=True, name = 'alpha'); u alpha sage: u^2 2 + t sage: u.parent() - Univariate Quotient Polynomial Ring in alpha over Power Series Ring in t over Rational Field with modulus x^2 - 2 - t + Univariate Quotient Polynomial Ring in alpha + over Power Series Ring in t over Rational Field + with modulus x^2 - 2 - t sage: K. = PowerSeriesRing(QQ, 't', 50) - sage: sqrt(1+2*t+t^2) + sage: sqrt(1 + 2*t + t^2) 1 + t - sage: sqrt(t^2 +2*t^4 + t^6) + sage: sqrt(t^2 + 2*t^4 + t^6) t + t^3 sage: sqrt(1 + t + t^2 + 7*t^3)^2 1 + t + t^2 + 7*t^3 + O(t^50) @@ -1560,7 +1563,8 @@ cdef class PowerSeries(AlgebraElement): :: - sage: K. = PowerSeriesRing(CDF, 5) # needs sage.rings.complex_double + sage: # needs sage.rings.complex_double + sage: K. = PowerSeriesRing(CDF, 5) sage: v = sqrt(-1 + t + t^3, all=True); v [1.0*I - 0.5*I*t - 0.125*I*t^2 - 0.5625*I*t^3 - 0.2890625*I*t^4 + O(t^5), -1.0*I + 0.5*I*t + 0.125*I*t^2 + 0.5625*I*t^3 + 0.2890625*I*t^4 + O(t^5)] @@ -1576,7 +1580,9 @@ cdef class PowerSeries(AlgebraElement): sage: s^2 2*t + t^3 + O(t^4) sage: parent(s) - Univariate Quotient Polynomial Ring in sqrtf over Power Series Ring in t over Rational Field with modulus x^2 - 2*t - t^3 + O(t^4) + Univariate Quotient Polynomial Ring in sqrtf + over Power Series Ring in t over Rational Field + with modulus x^2 - 2*t - t^3 + O(t^4) TESTS:: @@ -1685,7 +1691,7 @@ cdef class PowerSeries(AlgebraElement): def square_root(self): """ - Return the square root of self in this ring. If this cannot be done + Return the square root of ``self`` in this ring. If this cannot be done, then an error will be raised. This function succeeds if and only if @@ -1694,14 +1700,15 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: sage: K. = PowerSeriesRing(QQ, 't', 5) - sage: (1+t).square_root() + sage: (1 + t).square_root() 1 + 1/2*t - 1/8*t^2 + 1/16*t^3 - 5/128*t^4 + O(t^5) - sage: (2+t).square_root() + sage: (2 + t).square_root() Traceback (most recent call last): ... ValueError: Square root does not live in this ring. - sage: (2+t.change_ring(RR)).square_root() - 1.41421356237309 + 0.353553390593274*t - 0.0441941738241592*t^2 + 0.0110485434560398*t^3 - 0.00345266983001244*t^4 + O(t^5) + sage: (2 + t.change_ring(RR)).square_root() # needs sage.rings.real_mpfr + 1.41421356237309 + 0.353553390593274*t - 0.0441941738241592*t^2 + + 0.0110485434560398*t^3 - 0.00345266983001244*t^4 + O(t^5) sage: t.square_root() Traceback (most recent call last): ... @@ -1710,7 +1717,7 @@ cdef class PowerSeries(AlgebraElement): sage: f = (1+t)^20 sage: f.square_root() 1 + 10*t + 45*t^2 + 120*t^3 + 210*t^4 + O(t^5) - sage: f = 1+t + sage: f = 1 + t sage: f.square_root() Traceback (most recent call last): ... @@ -2476,7 +2483,8 @@ cdef class PowerSeries(AlgebraElement): Check that `\exp(t)` is, well, `\exp(t)`:: sage: (t + O(t^10)).exp() - 1 + t + 1/2*t^2 + 1/6*t^3 + 1/24*t^4 + 1/120*t^5 + 1/720*t^6 + 1/5040*t^7 + 1/40320*t^8 + 1/362880*t^9 + O(t^10) + 1 + t + 1/2*t^2 + 1/6*t^3 + 1/24*t^4 + 1/120*t^5 + 1/720*t^6 + + 1/5040*t^7 + 1/40320*t^8 + 1/362880*t^9 + O(t^10) Check that `\exp(\log(1+t))` is `1+t`:: @@ -2486,7 +2494,8 @@ cdef class PowerSeries(AlgebraElement): Check that `\exp(2t + t^2 - t^5)` is whatever it is:: sage: (2*t + t^2 - t^5 + O(t^10)).exp() - 1 + 2*t + 3*t^2 + 10/3*t^3 + 19/6*t^4 + 8/5*t^5 - 7/90*t^6 - 538/315*t^7 - 425/168*t^8 - 30629/11340*t^9 + O(t^10) + 1 + 2*t + 3*t^2 + 10/3*t^3 + 19/6*t^4 + 8/5*t^5 - 7/90*t^6 + - 538/315*t^7 - 425/168*t^8 - 30629/11340*t^9 + O(t^10) Check requesting lower precision:: @@ -2507,6 +2516,7 @@ cdef class PowerSeries(AlgebraElement): Handle nonzero constant term (fixes :trac:`4477`):: + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(RR) sage: (1 + x + x^2 + O(x^3)).exp() 2.71828182845905 + 2.71828182845905*x + 4.07742274268857*x^2 + O(x^3) @@ -2517,7 +2527,8 @@ cdef class PowerSeries(AlgebraElement): sage: (1 + x + O(x^2)).exp() # needs sage.symbolic Traceback (most recent call last): ... - ArithmeticError: exponential of constant term does not belong to coefficient ring (consider working in a larger ring) + ArithmeticError: exponential of constant term does not belong + to coefficient ring (consider working in a larger ring) :: @@ -2567,7 +2578,8 @@ cdef class PowerSeries(AlgebraElement): sage: R. = PowerSeriesRing(QQ, default_prec=10) sage: (1 + t + O(t^10)).log() - t - 1/2*t^2 + 1/3*t^3 - 1/4*t^4 + 1/5*t^5 - 1/6*t^6 + 1/7*t^7 - 1/8*t^8 + 1/9*t^9 + O(t^10) + t - 1/2*t^2 + 1/3*t^3 - 1/4*t^4 + 1/5*t^5 - 1/6*t^6 + 1/7*t^7 + - 1/8*t^8 + 1/9*t^9 + O(t^10) sage: t.exp().log() t + O(t^10) @@ -2580,8 +2592,9 @@ cdef class PowerSeries(AlgebraElement): ... ArithmeticError: constant term of power series is not 1 + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(RR) - sage: (2+t).log().exp() + sage: (2 + t).log().exp() 2.00000000000000 + 1.00000000000000*t + O(t^20) """ if prec is None: From 36f7707773278c33c5619b9e6f514a5f95bcf99e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 14:50:46 -0700 Subject: [PATCH 046/494] src/sage/rings/polynomial/polynomial_element.pyx: Update # needs --- .../rings/polynomial/polynomial_element.pyx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index c0eb7e19f63..700f89267ee 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -8336,7 +8336,7 @@ cdef class Polynomial(CommutativePolynomial): Spurious crash with pari-2.5.5, see :trac:`16165`:: sage: f = (1+x+x^2)^3 - sage: f.roots(ring=CC) # needs sage.rings.real_mpfr + sage: f.roots(ring=CC) # needs sage.libs.pari sage.rings.real_mpfr [(-0.500000000000000 - 0.866025403784439*I, 3), (-0.500000000000000 + 0.866025403784439*I, 3)] @@ -8344,7 +8344,7 @@ cdef class Polynomial(CommutativePolynomial): sage: polRing. = PolynomialRing(ZZ) sage: j = (x+1)^2 * (x-1)^7 * (x^2-x+1)^5 - sage: j.roots(CC) # needs sage.rings.real_mpfr + sage: j.roots(CC) # needs sage.libs.pari sage.rings.real_mpfr [(-1.00000000000000, 2), (1.00000000000000, 7), (0.500000000000000 - 0.866025403784439*I, 5), @@ -8740,20 +8740,20 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: sage: x = polygen(ZZ) - sage: (x^2 - x - 1).real_roots() # needs sage.rings.real_mpfr + sage: (x^2 - x - 1).real_roots() # needs sage.libs.pari sage.rings.real_mpfr [-0.618033988749895, 1.61803398874989] TESTS:: - sage: x = polygen(RealField(100)) # needs sage.rings.real_mpfr - sage: (x^2 - x - 1).real_roots()[0].parent() # needs sage.rings.real_mpfr + sage: x = polygen(RealField(100)) # needs sage.libs.pari sage.rings.real_mpfr + sage: (x^2 - x - 1).real_roots()[0].parent() # needs sage.libs.pari sage.rings.real_mpfr Real Field with 100 bits of precision sage: x = polygen(RDF) sage: (x^2 - x - 1).real_roots()[0].parent() # needs numpy Real Double Field - sage: x = polygen(ZZ,'x'); v = (x^2 - x - 1).real_roots() # needs sage.rings.real_mpfr - sage: v[0].parent() is RR # needs sage.rings.real_mpfr + sage: x = polygen(ZZ,'x'); v = (x^2 - x - 1).real_roots() # needs sage.libs.pari sage.rings.real_mpfr + sage: v[0].parent() is RR # needs sage.libs.pari sage.rings.real_mpfr True """ K = self.base_ring() @@ -8775,15 +8775,16 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: x = polygen(ZZ) - sage: (x^3 - 1).complex_roots() # note: low order bits slightly different on ppc. # needs sage.rings.real_mpfr + sage: (x^3 - 1).complex_roots() # note: low order bits slightly different on ppc. [1.00000000000000, -0.500000000000000 - 0.86602540378443...*I, -0.500000000000000 + 0.86602540378443...*I] TESTS:: - sage: # needs sage.rings.real_mpfr + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: x = polygen(RR) sage: (x^3 - 1).complex_roots()[0].parent() Complex Field with 53 bits of precision From 35c223227f6bf11f71d202685156f92cce1f0e0a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 15:31:22 -0700 Subject: [PATCH 047/494] Fix # needs for sagemath-pari --- src/sage/rings/factorint_pari.pyx | 1 + src/sage/rings/finite_rings/residue_field.pyx | 11 +++++----- .../rings/function_field/element_rational.pyx | 2 +- .../rings/polynomial/laurent_polynomial.pyx | 6 +++--- .../polynomial/multi_polynomial_sequence.py | 8 +++---- .../rings/polynomial/polynomial_element.pyx | 21 ++++++++++--------- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/sage/rings/factorint_pari.pyx b/src/sage/rings/factorint_pari.pyx index 8e5ed7c619e..862b7baa5b8 100644 --- a/src/sage/rings/factorint_pari.pyx +++ b/src/sage/rings/factorint_pari.pyx @@ -1,3 +1,4 @@ +# sage_setup: distribution = sagemath-pari # sage.doctest: needs sage.libs.pari r""" Integer factorization using PARI diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index b466ee5e2c1..c5973c6f1dc 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -1293,7 +1293,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): sage: # needs sage.rings.finite_rings sage: R. = GF(2)[]; P = R.ideal(t^7 + t^6 + t^5 + t^4 + 1) sage: k = P.residue_field(); f = k.coerce_map_from(R) - sage: f(t^10) + sage: f(t^10) # needs sage.modules tbar^6 + tbar^3 + tbar^2 """ self._K = K @@ -1482,7 +1482,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): sage: k. = P.residue_field(); f = k.coerce_map_from(R) sage: f.lift(a^2 + 5*a + 1) t^2 + 5*t + 1 - sage: f(f.lift(a^2 + 5*a + 1)) == a^2 + 5*a + 1 + sage: f(f.lift(a^2 + 5*a + 1)) == a^2 + 5*a + 1 # needs sage.modules True """ if self.domain() is ZZ: @@ -1780,12 +1780,11 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.modules sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^3 - 7) sage: P = K.ideal(29).factor()[1][0] - sage: k = ResidueField(P) - sage: k + sage: k = ResidueField(P); k Residue field of Fractional ideal (-a^2 - 2*a - 2) sage: OK = K.maximal_order() sage: c = OK(a) @@ -1799,7 +1798,7 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn sage: k(v) # indirect doctest 3 - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: R. = GF(2)[]; P = R.ideal(t + 1); k. = P.residue_field() sage: V = k.vector_space(map=False); v = V([1]) sage: k(v) diff --git a/src/sage/rings/function_field/element_rational.pyx b/src/sage/rings/function_field/element_rational.pyx index 0d306d6826e..a23532dacd3 100644 --- a/src/sage/rings/function_field/element_rational.pyx +++ b/src/sage/rings/function_field/element_rational.pyx @@ -390,7 +390,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): sage: f = (x+1)/(x-1) sage: f.is_nth_power(1) True - sage: f.is_nth_power(3) + sage: f.is_nth_power(3) # needs sage.modules False sage: (f^3).is_nth_power(3) True diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index 6515cf17e1a..8285d3a37db 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -260,9 +260,9 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): sage: f = x*a + a sage: f.map_coefficients(lambda a: a + 1) (a + 1) + (a + 1)*x - sage: R. = LaurentPolynomialRing(k, 2) - sage: f = x*a + 2*x^3*y*a + a - sage: f.map_coefficients(lambda a: a + 1) + sage: R. = LaurentPolynomialRing(k, 2) # needs sage.modules + sage: f = x*a + 2*x^3*y*a + a # needs sage.modules + sage: f.map_coefficients(lambda a: a + 1) # needs sage.modules (2*a + 1)*x^3*y + (a + 1)*x + a + 1 Examples with different base ring:: diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index 8088eb3349c..b52fb34f721 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -394,22 +394,22 @@ def __init__(self, parts, ring, immutable=False, cr=False, cr_str=None): EXAMPLES:: sage: P. = PolynomialRing(GF(127), 4) - sage: I = sage.rings.ideal.Katsura(P) # needs sage.rings.finite_rings + sage: I = sage.rings.ideal.Katsura(P) # needs sage.libs.singular - sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.rings.finite_rings + sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] If an ideal is provided, the generators are used.:: - sage: Sequence(I) # needs sage.rings.finite_rings + sage: Sequence(I) # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] If a list of polynomials is provided, the system has only one part.:: - sage: Sequence(I.gens(), I.ring()) # needs sage.rings.finite_rings + sage: Sequence(I.gens(), I.ring()) # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] """ diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 700f89267ee..5b85be6bc19 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6881,9 +6881,9 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = QQ[] sage: S. = R[] sage: f = x^2 + a; g = y^3 + a - sage: h = f.resultant(g); h # needs sage.libs.pari + sage: h = f.resultant(g); h # needs sage.libs.pari sage.modules y^3 - x^2 - sage: h.parent() is R # needs sage.libs.pari + sage: h.parent() is R # needs sage.libs.pari sage.modules True Check that :trac:`13672` is fixed:: @@ -7342,9 +7342,9 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.libs.singular sage: f = cyclotomic_polynomial(30) - sage: f.adams_operator(7)==f + sage: f.adams_operator(7) == f True sage: f.adams_operator(6) == cyclotomic_polynomial(5)**2 True @@ -7505,7 +7505,7 @@ cdef class Polynomial(CommutativePolynomial): -31 sage: d.parent() is QQ # needs sage.libs.pari True - sage: EllipticCurve([1, 1]).discriminant()/16 # needs sage.libs.pari + sage: EllipticCurve([1, 1]).discriminant()/16 # needs sage.libs.pari sage.schemes -31 :: @@ -7733,7 +7733,7 @@ cdef class Polynomial(CommutativePolynomial): sage: f = x^3 - 1 sage: f.roots() [(1, 1)] - sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc + sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc # needs sage.rings.real_mpfr [(1.00000000000000, 1), (-0.500000000000000 - 0.86602540378443...*I, 1), (-0.500000000000000 + 0.86602540378443...*I, 1)] @@ -8274,9 +8274,10 @@ cdef class Polynomial(CommutativePolynomial): TESTS:: - sage: K. = CyclotomicField(2) # needs sage.rings.number_field - sage: R. = K[] # needs sage.rings.number_field - sage: factor(x^3 - 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(2) + sage: R. = K[] + sage: factor(x^3 - 1) (x - 1) * (x^2 + x + 1) This shows that the issue from :trac:`6237` is fixed:: @@ -10834,7 +10835,7 @@ cdef class Polynomial(CommutativePolynomial): Some random tests:: - sage: for R in [QQ['x'], GF(4)['x']]: # needs sage.rings.finite_rings + sage: for R in [QQ['x'], GF(4)['x']]: # needs sage.modules sage.rings.finite_rings ....: for _ in range(30): ....: p = R.random_element(degree=randint(10,20)) ....: n = ZZ.random_element(2,20) From d7cf4a754982557a439b66ede881983f0fe86556 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 19:58:44 -0700 Subject: [PATCH 048/494] sage.rings: Update # needs --- src/sage/rings/factorint.pyx | 2 +- .../rings/finite_rings/element_pari_ffelt.pyx | 3 +++ src/sage/rings/finite_rings/integer_mod.pyx | 9 ++++---- .../rings/polynomial/multi_polynomial.pyx | 6 ++--- .../rings/polynomial/polynomial_element.pyx | 4 ++-- .../polynomial/polynomial_quotient_ring.py | 21 +++++++++--------- .../polynomial_quotient_ring_element.py | 22 +++++++++---------- src/sage/rings/polynomial/polynomial_ring.py | 7 +++--- src/sage/rings/power_series_pari.pyx | 8 ++++--- src/sage/rings/rational_field.py | 2 +- src/sage/rings/ring.pyx | 6 ++--- src/sage/rings/tests.py | 2 +- 12 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index 95f91424164..32116f9de0a 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -135,7 +135,7 @@ cpdef factor_aurifeuillian(n, check=True): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.rings.real_interval_field sage: from sage.rings.factorint import factor_aurifeuillian as fa sage: fa(2^6 + 1) [5, 13] diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 30ad3075da6..845df74b840 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -873,6 +873,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): TESTS:: + sage: # needs sage.modules sage: F. = GF(13^64, impl='pari_ffelt'); F Finite Field in a of size 13^64 sage: x = F.random_element() @@ -885,6 +886,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): sage: x.pth_power(-1)**13 == x True + sage: # needs sage.modules sage: F. = GF(127^16, impl='pari_ffelt'); F Finite Field in a of size 127^16 sage: x = F.random_element() @@ -1386,6 +1388,7 @@ def unpickle_FiniteFieldElement_pari_ffelt(parent, elem): """ EXAMPLES:: + sage: # needs sage.modules sage: k. = GF(2^20, impl='pari_ffelt') sage: e = k.random_element() sage: f = loads(dumps(e)) # indirect doctest diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index 38dd4569c7f..be1d9ca5322 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -656,7 +656,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.modules sage: r = Integers(125) sage: b = r.multiplicative_generator()^3 sage: a = b^17 @@ -825,10 +825,11 @@ cdef class IntegerMod_abstract(FiniteRingElement): EXAMPLES:: + sage: m = Mod(3, 1568) - sage: v = m.generalised_log(); v # needs sage.libs.pari + sage: v = m.generalised_log(); v # needs sage.libs.pari sage.modules [1, 3, 1] - sage: prod([Zmod(1568).unit_gens()[i] ** v[i] for i in [0..2]]) # needs sage.libs.pari + sage: prod([Zmod(1568).unit_gens()[i] ** v[i] for i in [0..2]]) # needs sage.libs.pari sage.modules 3 .. SEEALSO:: @@ -924,7 +925,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): 1 sage: a.polynomial() 1 - sage: type(a.polynomial()) # needs sage.rings.finite_rings + sage: type(a.polynomial()) # needs sage.libs.flint """ R = self.parent()[var] diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index dee2a02e2c6..bee78170e99 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -1549,9 +1549,9 @@ cdef class MPolynomial(CommutativePolynomial): sage: f = x^5*y + 3*x^2*y^2 - 2*x + y - 1 sage: f.discriminant(y) # needs sage.libs.singular x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - sage: f.polynomial(y).discriminant() # needs sage.libs.pari + sage: f.polynomial(y).discriminant() # needs sage.libs.pari sage.modules x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - sage: f.discriminant(y).parent() == f.polynomial(y).discriminant().parent() # needs sage.libs.singular + sage: f.discriminant(y).parent() == f.polynomial(y).discriminant().parent() # needs sage.libs.singular sage.modules False TESTS: @@ -1561,7 +1561,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: # needs sage.rings.number_field sage: R. = QQbar[] sage: f = x^5*y + 3*x^2*y^2 - 2*x + y - 1 - sage: f.discriminant(y) + sage: f.discriminant(y) # needs sage.libs.singular x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 AUTHOR: Miguel Marco diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 5b85be6bc19..d5873f3971c 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -2980,8 +2980,8 @@ cdef class Polynomial(CommutativePolynomial): sage: D = d0 + d1*y + d2*y^2 + d3*y^3 + d4*y^4 + d5*y^5 + d6*y^6 + d7*y^7 sage: F = D.subs({y: B}) sage: G = A.subs({y: F}) + C - sage: g = G.mod(y^8 + y) - sage: g.degree(y) + sage: g = G.mod(y^8 + y) # needs sage.libs.singular + sage: g.degree(y) # needs sage.libs.singular 7 """ return self % other diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index e372be888ee..894336def89 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1099,7 +1099,7 @@ def is_integral_domain(self, proof=True): sage: U.is_integral_domain() False sage: R2. = PolynomialRing(R) - sage: S2 = R2.quotient(z^2 - y^3) + sage: S2 = R2.quotient(z^2 - y^3) # needs sage.libs.singular sage: S2.is_integral_domain() # needs sage.libs.singular True sage: S3 = R2.quotient(z^2 - 2*y*z + y^2) @@ -1915,7 +1915,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: K. = FunctionField(l) sage: R. = K[] sage: F = t * x - sage: F.factor(proof=False) + sage: F.factor(proof=False) # needs sage.modules (x) * t """ @@ -1945,9 +1945,9 @@ def _factor_univariate_polynomial(self, f): sage: R. = M[] sage: R(y).factor() # indirect doctest y - sage: (T^2 + T + x).factor() # indirect doctest + sage: (T^2 + T + x).factor() # indirect doctest # needs sage.modules (T + y) * (T + y + 1) - sage: (y*T^2 + y*T + y*x).factor() # indirect doctest + sage: (y*T^2 + y*T + y*x).factor() # indirect doctest # needs sage.modules (y) * (T + y) * (T + y + 1) """ @@ -1988,7 +1988,7 @@ def _isomorphic_ring(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: K. = GF(4) sage: R. = K[] sage: L. = K.extension(b^2 + b + a); L @@ -1996,14 +1996,13 @@ def _isomorphic_ring(self): over Finite Field in a of size 2^2 with modulus b^2 + b + a sage: from_M, to_M, M = L._isomorphic_ring(); M Finite Field in z4 of size 2^4 - - sage: R. = L[] # needs sage.rings.finite_rings - sage: M. = L.extension(c^2 + b*c + b); M # needs sage.rings.finite_rings + sage: R. = L[] + sage: M. = L.extension(c^2 + b*c + b); M Univariate Quotient Polynomial Ring in c over Univariate Quotient Polynomial Ring in b over Finite Field in a of size 2^2 with modulus b^2 + b + a with modulus c^2 + b*c + b - sage: from_N, to_N, N = M._isomorphic_ring(); N # needs sage.rings.finite_rings + sage: from_N, to_N, N = M._isomorphic_ring(); N Finite Field in z8 of size 2^8 sage: R. = QQ[] @@ -2135,7 +2134,7 @@ def _test_isomorphic_ring(self, **options): TESTS:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: K. = GF(4) sage: R. = K[] sage: L. = K.extension(b^2 + b + a) @@ -2367,7 +2366,7 @@ def field_extension(self, names): Over a finite field, the corresponding field extension is not a number field:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: R. = GF(25, 'a')['x'] sage: S. = R.quo(x^3 + 2*x + 1) sage: F, g, h = S.field_extension('b') diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 4185f0d1455..56f1522a19b 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -592,7 +592,7 @@ def charpoly(self, var): sage: R. = PolynomialRing(QQ) sage: S. = R.quo(x^3 -389*x^2 + 2*x - 5) - sage: a.charpoly('X') + sage: a.charpoly('X') # needs sage.modules X^3 - 389*X^2 + 2*X - 5 """ return self.matrix().charpoly(var) @@ -606,9 +606,9 @@ def fcp(self, var='x'): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 -389*x^2 + 2*x - 5) - sage: a.fcp('x') + sage: a.fcp('x') # needs sage.modules x^3 - 389*x^2 + 2*x - 5 - sage: S(1).fcp('y') + sage: S(1).fcp('y') # needs sage.modules (y - 1)^3 """ return self.charpoly(var).factor() @@ -621,7 +621,7 @@ def lift(self): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: S. = R.quotient(x^3-2) + sage: S. = R.quotient(x^3 - 2) sage: b = a^2 - 3 sage: b a^2 - 3 @@ -661,7 +661,7 @@ def matrix(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 + 2*x - 5) - sage: a.matrix() + sage: a.matrix() # needs sage.modules [ 0 1 0] [ 0 0 1] [ 5 -2 0] @@ -699,9 +699,9 @@ def minpoly(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 + 2*x - 5) - sage: (a + 123).minpoly() + sage: (a + 123).minpoly() # needs sage.modules x^3 - 369*x^2 + 45389*x - 1861118 - sage: (a + 123).matrix().minpoly() + sage: (a + 123).matrix().minpoly() # needs sage.modules x^3 - 369*x^2 + 45389*x - 1861118 One useful application of this function is to compute a minimal @@ -711,10 +711,10 @@ def minpoly(self): sage: # needs sage.rings.finite_rings sage: F2. = GF((431,2), modulus=[1,0,1]) sage: F6. = F2.extension(3) - sage: (u + 1).minpoly() + sage: (u + 1).minpoly() # needs sage.modules x^6 + 425*x^5 + 19*x^4 + 125*x^3 + 189*x^2 + 239*x + 302 sage: ext = F6.over(F2) - sage: ext(u + 1).minpoly() # indirect doctest + sage: ext(u + 1).minpoly() # indirect doctest # needs sage.modules x^3 + (396*i + 428)*x^2 + (80*i + 39)*x + 9*i + 178 TESTS: @@ -750,7 +750,7 @@ def norm(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) - sage: a.norm() + sage: a.norm() # needs sage.modules 5 """ return self.matrix().determinant() @@ -763,7 +763,7 @@ def trace(self): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: S. = R.quotient(x^3 -389*x^2 + 2*x - 5) + sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) sage: a.trace() 389 """ diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 2878ed7f648..123db470a62 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -1057,10 +1057,11 @@ def change_ring(self, R): EXAMPLES:: - sage: R. = RealIntervalField()[]; R # needs sage.rings.real_interval_field + sage: # needs sage.rings.finite_rings sage.rings.real_interval_field + sage: R. = RealIntervalField()[]; R Univariate Polynomial Ring in ZZZ over Real Interval Field with 53 bits of precision - sage: R.change_ring(GF(19^2, 'b')) # needs sage.rings.finite_rings + sage: R.change_ring(GF(19^2, 'b')) Univariate Polynomial Ring in ZZZ over Finite Field in b of size 19^2 """ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -2591,7 +2592,7 @@ def irreducible_element(self, n, algorithm=None): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: f = GF(5^3, 'a')['x'].irreducible_element(2) sage: f.degree() 2 diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx index 94a6d1baacb..dc84fdbc162 100644 --- a/src/sage/rings/power_series_pari.pyx +++ b/src/sage/rings/power_series_pari.pyx @@ -9,7 +9,7 @@ PARI by passing the keyword ``implementation='pari'`` to the sage: R. = PowerSeriesRing(ZZ, implementation='pari'); R Power Series Ring in q over Integer Ring - sage: S. = PowerSeriesRing(CC, implementation='pari'); S + sage: S. = PowerSeriesRing(CC, implementation='pari'); S # needs sage.rings.real_mpfr Power Series Ring in t over Complex Field with 53 bits of precision Note that only the type of the elements depends on the implementation, @@ -19,9 +19,9 @@ not the type of the parents:: sage: type(q) - sage: type(S) + sage: type(S) # needs sage.rings.real_mpfr - sage: type(t) + sage: type(t) # needs sage.rings.real_mpfr If `k` is a finite field implemented using PARI, this is the default @@ -137,6 +137,7 @@ cdef class PowerSeries_pari(PowerSeries): TESTS:: + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(CC, implementation='pari') sage: TestSuite(q).run() sage: f = q - q^3 + O(q^10) @@ -664,6 +665,7 @@ cdef class PowerSeries_pari(PowerSeries): sage: f.list() [1, 0, 0, -5, 0, 1] + sage: # needs sage.rings.padics sage: S. = PowerSeriesRing(pAdicRing(5), implementation='pari') sage: (2 + u).list() [2 + O(5^20), 1 + O(5^20)] diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 104c5463bf5..2938796b655 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -1424,7 +1424,7 @@ def selmer_space(self, S, p, proof=None): sage: QS2gens # needs sage.rings.number_field [-1] - sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # needs sage.libs.pari + sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # needs sage.libs.pari sage.rings.number_field ....: for p in primes(3, 10)) True diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index 4fe45ed2c59..cf75edd4099 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -533,10 +533,10 @@ cdef class Ring(ParentWithGens): sage: S._ideal_class_(2) - sage: T. = S[] # needs sage.rings.finite_rings - sage: T._ideal_class_(5) # needs sage.rings.finite_rings + sage: T. = S[] # needs sage.libs.singular + sage: T._ideal_class_(5) # needs sage.libs.singular - sage: T._ideal_class_(1) # needs sage.rings.finite_rings + sage: T._ideal_class_(1) # needs sage.libs.singular Since :trac:`7797`, non-commutative rings have ideals as well:: diff --git a/src/sage/rings/tests.py b/src/sage/rings/tests.py index 13a205195d5..3eed7e1aa31 100644 --- a/src/sage/rings/tests.py +++ b/src/sage/rings/tests.py @@ -445,7 +445,7 @@ def test_karatsuba_multiplication(base_ring, maxdeg1, maxdeg2, sage: rings += [ZZ[I], ZZ[I, sqrt(2)]] # needs sage.rings.number_field sage.symbolic sage: rings += [GF(49, 'a')] # needs sage.rings.finite_rings sage: rings += [MatrixSpace(GF(17), 3)] # needs sage.modules - sage: for C in rings: + sage: for C in rings: # needs sage.modules ....: test_karatsuba_multiplication(C, 10, 10) Zero-tests over ``QQbar`` are currently very slow, so we test only very small examples:: From 5ffeedfbc411f2342774895217bddc67f2d7b771 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 01:01:30 -0700 Subject: [PATCH 049/494] sage.rings: Update # needs --- src/sage/rings/factorint.pyx | 3 +- src/sage/rings/finite_rings/element_base.pyx | 28 +++++++++++-------- .../finite_rings/residue_field_pari_ffelt.pyx | 8 +++--- src/sage/rings/morphism.pyx | 10 +++---- src/sage/rings/polynomial/flatten.py | 2 +- .../rings/polynomial/polynomial_element.pyx | 5 ++-- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index 32116f9de0a..7a441eabad6 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -154,7 +154,8 @@ cpdef factor_aurifeuillian(n, check=True): TESTS:: - sage: for n in [2,3,5,6,30,31,33]: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.rings.real_interval_field + sage: for n in [2,3,5,6,30,31,33]: ....: for m in [8,96,109201283]: ....: s = -1 if n % 4 == 1 else 1 ....: y = (m^2*n)^n + s diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index e9ab5b5d4ab..08f76c59927 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -268,6 +268,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: F,t = GF(random_prime(99)^randrange(2,99), 't').objgen() sage: a = F.random_element() sage: all(a[i] == a.polynomial()[i] for i in range(F.degree())) @@ -290,7 +291,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): EXAMPLES:: sage: x = polygen(GF(71)) - sage: F. = GF(71^7, modulus=x^7+x+1) + sage: F. = GF(71^7, modulus=x^7 + x + 1) sage: a = 3 + u + 3*u^2 + 3*u^3 + 7*u^4 sage: a.list() [3, 1, 3, 3, 7, 0, 0] @@ -308,6 +309,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: R. = GF(17)[] sage: F. = GF(17^60) sage: a = F.random_element() @@ -351,6 +353,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: F = GF(random_prime(333)^randrange(111,999),'t') sage: a = F.random_element() sage: list(a) == a.list() # implicit doctest @@ -358,6 +361,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): :: + sage: # needs sage.modules sage: F. = GF(17^60) sage: a = F.random_element() sage: a == sum(c*t^i for i,c in enumerate(a)) # implicit doctest @@ -365,7 +369,8 @@ cdef class FinitePolyExtElement(FiniteRingElement): :: - sage: F. = GF((2^127-1)^10, 't') + sage: # needs sage.modules + sage: F. = GF((2^127 - 1)^10, 't') sage: a = F.random_element() sage: a == sum(c*t^i for i,c in enumerate(a)) # implicit doctest True @@ -431,6 +436,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): EXAMPLES:: + sage: # needs sage.modules sage: k. = GF(2^4) sage: b = k.random_element() sage: vector(a*b) == a.matrix() * vector(b) @@ -557,18 +563,18 @@ cdef class FinitePolyExtElement(FiniteRingElement): def charpoly(self, var='x', algorithm='pari'): """ - Return the characteristic polynomial of self as a polynomial with given variable. + Return the characteristic polynomial of ``self`` as a polynomial with given variable. INPUT: - ``var`` -- string (default: 'x') - - ``algorithm`` -- string (default: 'pari') + - ``algorithm`` -- string (default: ``'pari'``) - - 'pari' -- use pari's charpoly + - ``'pari'`` -- use pari's charpoly - - 'matrix' -- return the charpoly computed from the matrix of - left multiplication by self + - ``'matrix'`` -- return the charpoly computed from the matrix of + left multiplication by ``self`` The result is not cached. @@ -578,10 +584,10 @@ cdef class FinitePolyExtElement(FiniteRingElement): sage: k. = FiniteField(19^2) sage: parent(a) Finite Field in a of size 19^2 - sage: b=a**20 - sage: p=FinitePolyExtElement.charpoly(b,"x", algorithm="pari") - sage: q=FinitePolyExtElement.charpoly(b,"x", algorithm="matrix") - sage: q == p + sage: b = a**20 + sage: p = FinitePolyExtElement.charpoly(b, "x", algorithm="pari") + sage: q = FinitePolyExtElement.charpoly(b, "x", algorithm="matrix") # needs sage.modules + sage: q == p # needs sage.modules True sage: p x^2 + 15*x + 4 diff --git a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx index 375b3b4cdfc..f21a3b8d9bb 100644 --- a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx @@ -110,15 +110,15 @@ class ResidueFiniteField_pari_ffelt(ResidueField_generic, FiniteField_pari_ffelt 7521*alpha + 4131 sage: ff(17/3) 6677 - sage: V = ff.vector_space(map=False); v = V([3,-2]) - sage: type(ff.convert_map_from(V)) + sage: V = ff.vector_space(map=False); v = V([3,-2]) # needs sage.modules + sage: type(ff.convert_map_from(V)) # needs sage.modules - sage: ff(v) # indirect doctest + sage: ff(v) # indirect doctest # needs sage.modules 10005*alpha + 3 sage: R. = GF(5)[]; P = R.ideal(4*t^12 + 3*t^11 + 4*t^10 + t^9 + t^8 + 3*t^7 + 2*t^6 + 3*t^4 + t^3 + 3*t^2 + 2) sage: k. = P.residue_field() - sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest + sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest # needs sage.modules 2*a^11 + a^10 + 4*a^8 + 3*a^7 + 2*a^6 + a^5 + 4*a^3 + 3*a^2 + 2*a + 1 """ try: diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index f6e88f8f180..17e63a269bc 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -81,9 +81,9 @@ From smaller to bigger doesn't make sense:: From bigger to small does:: sage: f = RR.hom(RealField(15)) # needs sage.rings.real_mpfr - sage: f(2.5) + sage: f(2.5) # needs sage.rings.real_mpfr 2.500 - sage: f(RR.pi()) + sage: f(RR.pi()) # needs sage.rings.real_mpfr 3.142 Inclusion map from the reals to the complexes:: @@ -1516,7 +1516,7 @@ cdef class RingHomomorphism(RingMap): sage: A. = GF(7^3) sage: R = A.polynomial_ring().quotient(A.polynomial()) sage: g = A.hom(R.gens(), R) - sage: (g.inverse() * g).is_identity() + sage: (g.inverse() * g).is_identity() # needs sage.libs.singular True sage: B., f = A.extension(3, map=True) sage: f.inverse() @@ -2039,7 +2039,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): TESTS:: - sage: loads(dumps(f2)) == f2 # needs sage.rings.finite_rings + sage: loads(dumps(f2)) == f2 # needs sage.libs.pari True This was fixed in :trac:`24277`:: @@ -2946,7 +2946,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage.rings.finite_rings sage: R. = PolynomialRing(GF(19), 3) sage: S. = R.quo(x^3 + y^3 + z^3) sage: phi = S.hom([b, c, a]) diff --git a/src/sage/rings/polynomial/flatten.py b/src/sage/rings/polynomial/flatten.py index cfc5f96179c..74783285396 100644 --- a/src/sage/rings/polynomial/flatten.py +++ b/src/sage/rings/polynomial/flatten.py @@ -382,7 +382,7 @@ def _call_(self, p): sage: rings = [ZZ['x']['y']['a,b,c']] sage: rings += [GF(4)['x','y']['a','b']] # needs sage.rings.finite_rings sage: rings += [AA['x']['a','b']['y'], QQbar['a1','a2']['t']['X','Y']] # needs sage.rings.number_field - sage: for R in rings: + sage: for R in rings: # needs sage.modules ....: f = FlatteningMorphism(R) ....: g = f.section() ....: for _ in range(10): diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index d5873f3971c..9a80e062c22 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6908,7 +6908,7 @@ cdef class Polynomial(CommutativePolynomial): sage: K. = FunctionField(QQ) sage: R. = K[] - sage: y.resultant(y + x) # needs sage.libs.pari + sage: y.resultant(y + x) # needs sage.libs.pari sage.modules x sage: # needs sage.libs.singular @@ -7793,7 +7793,8 @@ cdef class Polynomial(CommutativePolynomial): :: - sage: x = CC['x'].0 # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: x = CC['x'].0 sage: f = x^3 - 2 sage: f.roots() # needs numpy [(1.25992104989487, 1), From e91b7c6852abda67480cc8013a6bbc3c99a44857 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 21:51:56 -0700 Subject: [PATCH 050/494] src/sage/rings/number_field/number_field.py: Use lazy_import --- src/sage/rings/number_field/number_field.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index abb58cadb8e..5ac37e3f23f 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -127,7 +127,7 @@ from sage.misc.fast_methods import WithEqualityById from sage.misc.functional import is_odd, lift - +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.rings.infinity import Infinity from sage.categories.number_fields import NumberFields @@ -162,6 +162,10 @@ from sage.interfaces.abc import GapElement +lazy_import('sage.libs.gap.element', 'GapElement', as_='LibGapElement') +lazy_import('sage.rings.universal_cyclotomic_field', 'UniversalCyclotomicFieldElement') + + _NumberFields = NumberFields() @@ -11442,14 +11446,11 @@ def _element_constructor_(self, x, check=True): return NumberField_absolute._element_constructor_(self, x) elif isinstance(x, pari_gen): return NumberField_absolute._element_constructor_(self, x, check=check) - elif isinstance(x, (sage.libs.gap.element.GapElement, GapElement)): + elif isinstance(x, (LibGapElement, GapElement)): return self._coerce_from_gap(x) elif isinstance(x, str): return self._convert_from_str(x) - - # late import because of speed - from sage.rings.universal_cyclotomic_field import UniversalCyclotomicFieldElement - if isinstance(x, UniversalCyclotomicFieldElement): + elif isinstance(x, UniversalCyclotomicFieldElement): return x.to_cyclotomic_field(self) else: return self._convert_non_number_field_element(x) From ae8b9b2ba4a1084e75b2baf098fab8ac1baeebe6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 21:52:22 -0700 Subject: [PATCH 051/494] sage.rings: Update # needs --- .../polynomial/polynomial_quotient_ring.py | 9 ++++++--- .../polynomial_quotient_ring_element.py | 2 +- .../polynomial/polynomial_rational_flint.pyx | 17 ++++++++++++----- src/sage/rings/polynomial/toy_d_basis.py | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 894336def89..98fd9a34fd5 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1089,6 +1089,7 @@ def is_integral_domain(self, proof=True): EXAMPLES:: sage: R. = PolynomialRing(ZZ) + sage: S = R.quotient(z^2 - z) sage: S.is_integral_domain() False @@ -1098,12 +1099,14 @@ def is_integral_domain(self, proof=True): sage: U = R.quotient(-1) sage: U.is_integral_domain() False + + sage: # needs sage.libs.singular sage: R2. = PolynomialRing(R) - sage: S2 = R2.quotient(z^2 - y^3) # needs sage.libs.singular - sage: S2.is_integral_domain() # needs sage.libs.singular + sage: S2 = R2.quotient(z^2 - y^3) + sage: S2.is_integral_domain() True sage: S3 = R2.quotient(z^2 - 2*y*z + y^2) - sage: S3.is_integral_domain() # needs sage.libs.singular + sage: S3.is_integral_domain() False sage: R. = PolynomialRing(ZZ.quotient(4)) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 56f1522a19b..5d4b9f1883b 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -764,7 +764,7 @@ def trace(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) - sage: a.trace() + sage: a.trace() # needs sage.modules 389 """ return self.matrix().trace() diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index b888b31d214..f898eb701d6 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -344,7 +344,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: P. = PolynomialRing(QQ) sage: f = 3*x^2 + 2*x + 5 - sage: singular(f) + sage: singular(f) # needs sage.libs.singular 3*x^2+2*x+5 """ self._parent._singular_(singular).set_ring() # Expensive! @@ -486,7 +486,7 @@ cdef class Polynomial_rational_flint(Polynomial): True sage: (t/3)(RealBallField(100)(1)) [0.33333333333333333333333333333...] - sage: (t/3)(ComplexBallField(10)(1+i)) + sage: (t/3)(ComplexBallField(10)(1+i)) # needs sage.symbolic [0.33...] + [0.33...]*I """ cdef Polynomial_rational_flint f @@ -2097,6 +2097,7 @@ cdef class Polynomial_rational_flint(Polynomial): EXAMPLES:: + sage: # needs sage.libs.pari sage: R. = QQ[] sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(); G @@ -2113,6 +2114,7 @@ cdef class Polynomial_rational_flint(Polynomial): :: + sage: # needs sage.libs.pari sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(pari_group=True); G PARI group [24, -1, 5, "S4"] of degree 4 @@ -2130,6 +2132,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: f.galois_group(algorithm='kash') # optional - kash Transitive group number 5 of degree 4 + sage: # needs sage.libs.gap sage: f = x^4 - 17*x^3 - 2*x + 1 sage: f.galois_group(algorithm='gap') Transitive group number 5 of degree 4 @@ -2139,6 +2142,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: f = x^12 - 2*x^8 - x^7 + 2*x^6 + 4*x^4 - 2*x^3 - x^2 - x + 1 sage: f.galois_group(algorithm='gap') Transitive group number 183 of degree 12 + sage: f.galois_group(algorithm='magma') # optional - magma Transitive group number 5 of degree 4 @@ -2157,7 +2161,7 @@ cdef class Polynomial_rational_flint(Polynomial): are supported (see :trac:`20631`):: sage: R. = QQ[] - sage: (zeta^2 + zeta + 1).galois_group(pari_group=True) + sage: (zeta^2 + zeta + 1).galois_group(pari_group=True) # needs sage.libs.pari PARI group [2, -1, 1, "S2"] of degree 2 """ from sage.groups.pari_group import PariGroup @@ -2287,6 +2291,7 @@ cdef class Polynomial_rational_flint(Polynomial): EXAMPLES:: + sage: # needs sage.rings.padic sage: R. = QQ[] sage: f = x^3 - 2 sage: f.factor_padic(2) @@ -2307,6 +2312,7 @@ cdef class Polynomial_rational_flint(Polynomial): the same as first coercing to `\QQ_p` and then factoring (see also :trac:`15422`):: + sage: # needs sage.rings.padic sage: f = x^2 - 3^6 sage: f.factor_padic(3, 5) ((1 + O(3^5))*x + 3^3 + O(3^5)) * ((1 + O(3^5))*x + 2*3^3 + 2*3^4 + O(3^5)) @@ -2319,12 +2325,13 @@ cdef class Polynomial_rational_flint(Polynomial): A more difficult example:: sage: f = 100 * (5*x + 1)^2 * (x + 5)^2 - sage: f.factor_padic(5, 10) + sage: f.factor_padic(5, 10) # needs sage.rings.padic (4*5^4 + O(5^14)) * ((1 + O(5^9))*x + 5^-1 + O(5^9))^2 * ((1 + O(5^10))*x + 5 + O(5^10))^2 Try some bogus inputs:: + sage: # needs sage.rings.padic sage: f.factor_padic(3, -1) Traceback (most recent call last): ... @@ -2469,7 +2476,7 @@ cdef class Polynomial_rational_flint(Polynomial): -31 sage: d.parent() is QQ True - sage: EllipticCurve([1, 1]).discriminant() / 16 + sage: EllipticCurve([1, 1]).discriminant() / 16 # needs sage.schemes -31 :: diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 3734449a666..89bab98dbae 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -51,6 +51,7 @@ Another example. This one is from the Magma Handbook:: + sage: # needs sage.libs.singular sage: P. = PolynomialRing(IntegerRing(), 3, order='lex') sage: I = ideal(x^2 - 1, y^2 - 1, 2*x*y - z) sage: I = Ideal(d_basis(I)) From c719121f07ac2910d31a140a3f314a38ab94d410 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 5 Sep 2023 09:39:58 -0700 Subject: [PATCH 052/494] src/sage/rings/real_arb.pyx: Update # needs --- src/sage/rings/real_arb.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 17859068273..7bc5eaed61a 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -3950,7 +3950,7 @@ cdef class RealBall(RingElement): [0.69314718055995 +/- ...e-15] sage: RBF(1/3).polylog(1/2) [0.44210883528067 +/- 6.7...e-15] - sage: RBF(1/3).polylog(RLF(pi)) + sage: RBF(1/3).polylog(RLF(pi)) # needs sage.symbolic [0.34728895057225 +/- ...e-15] TESTS:: From 7e08b6f4e9eabcd07160eb80f961c5202b185f98 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:13:40 -0700 Subject: [PATCH 053/494] Add # needs --- src/sage/rings/derivation.py | 27 ++++++++++------------- src/sage/rings/polynomial/toy_d_basis.py | 1 + src/sage/rings/rational_field.py | 2 +- src/sage/rings/real_interval_absolute.pyx | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py index 26b6f2d5905..da55ada5432 100644 --- a/src/sage/rings/derivation.py +++ b/src/sage/rings/derivation.py @@ -1580,7 +1580,7 @@ def __init__(self, parent, arg=None): TESTS:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: from sage.rings.derivation import RingDerivationWithoutTwist_wrapper sage: R. = GF(5)[] sage: S = R.quo([x^5, y^5]) @@ -1588,8 +1588,7 @@ def __init__(self, parent, arg=None): sage: der = M.random_element() sage: isinstance(der, RingDerivationWithoutTwist_wrapper) True - - sage: TestSuite(der).run() # needs sage.rings.finite_rings + sage: TestSuite(der).run() """ if isinstance(arg, list) and len(arg) == 1 and isinstance(arg[0], RingDerivation): @@ -1620,7 +1619,7 @@ def _add_(self, other): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1637,7 +1636,7 @@ def _sub_(self, other): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1654,7 +1653,7 @@ def _neg_(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1670,7 +1669,7 @@ def _lmul_(self, factor): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1688,7 +1687,7 @@ def _rmul_(self, factor): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1707,21 +1706,19 @@ def list(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: M = S.derivation_module() sage: M.basis() Family (d/dx, d/dy) - - sage: S.derivation(x).list() # needs sage.rings.finite_rings + sage: S.derivation(x).list() [1, 0] - sage: S.derivation(y).list() # needs sage.rings.finite_rings + sage: S.derivation(y).list() [0, 1] - - sage: f = x*S.derivation(x) + y*S.derivation(y); f # needs sage.rings.finite_rings + sage: f = x*S.derivation(x) + y*S.derivation(y); f x*d/dx + y*d/dy - sage: f.list() # needs sage.rings.finite_rings + sage: f.list() [x, y] """ diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 89bab98dbae..25eca7a9fc2 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -62,6 +62,7 @@ To compute modulo 4, we can add the generator 4 to our basis.:: + sage: # needs sage.libs.singular sage: I = ideal(x^2 - 1, y^2 - 1, 2*x*y - z, 4) sage: gb = d_basis(I) sage: R = P.change_ring(IntegerModRing(4)) diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 2938796b655..7296d227097 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -808,7 +808,7 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): :: - sage: QQ.hilbert_symbol_negative_at_S([5, 7], 2) # needs sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([5, 7], 2) # needs sage.libs.pari sage.modules sage.rings.padics Traceback (most recent call last): ... ValueError: second argument must be a nonsquare with diff --git a/src/sage/rings/real_interval_absolute.pyx b/src/sage/rings/real_interval_absolute.pyx index 5caf4ac40f1..27b0238f2a8 100644 --- a/src/sage/rings/real_interval_absolute.pyx +++ b/src/sage/rings/real_interval_absolute.pyx @@ -173,7 +173,7 @@ cdef class RealIntervalAbsoluteField_class(Field): True sage: R.has_coerce_map_from(QQ) True - sage: R.has_coerce_map_from(Qp(5)) + sage: R.has_coerce_map_from(Qp(5)) # needs sage.rings.padics False sage: R(1/2) + 100 From bfd4c03ab9c166f4fee098dab9bf8a90fabd9c55 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:59:22 -0700 Subject: [PATCH 054/494] sage.rings: Update # needs --- src/sage/rings/morphism.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 17e63a269bc..5d55d18eb17 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -2353,7 +2353,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): A matrix ring over a multivariate quotient over a finite field:: - sage: # needs sage.modules + sage: # needs sage.libs.singular sage.modules sage: R. = GF(7)[] sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) sage: f1 = R.hom([a, b]) @@ -2367,7 +2367,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): TESTS:: - sage: f1M == loads(dumps(f1M)) # needs sage.modules + sage: f1M == loads(dumps(f1M)) # needs sage.libs.singular sage.modules True """ if not isinstance(other, RingHomomorphism_from_base): From ee95b2aba2aa388bda2b44c9243b1949b8621164 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 9 Sep 2023 16:51:53 -0700 Subject: [PATCH 055/494] sage.rings: Update # needs --- src/sage/rings/abc.pyx | 6 ++--- src/sage/rings/complex_arb.pyx | 2 +- src/sage/rings/complex_double.pyx | 4 ++-- src/sage/rings/complex_interval_field.py | 2 +- src/sage/rings/continued_fraction.py | 2 +- src/sage/rings/derivation.py | 2 +- src/sage/rings/finite_rings/element_base.pyx | 1 + .../rings/finite_rings/finite_field_base.pyx | 2 ++ src/sage/rings/finite_rings/residue_field.pyx | 3 +-- src/sage/rings/morphism.pyx | 23 ++++++++++--------- .../rings/number_field/number_field_base.pyx | 12 ++++++++++ 11 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/sage/rings/abc.pyx b/src/sage/rings/abc.pyx index 6ad9dd8d6f0..7dde9da52b8 100644 --- a/src/sage/rings/abc.pyx +++ b/src/sage/rings/abc.pyx @@ -66,13 +66,13 @@ class UniversalCyclotomicField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: K = UniversalCyclotomicField() # needs sage.rings.number_field - sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # needs sage.rings.number_field + sage: K = UniversalCyclotomicField() # needs sage.libs.gap + sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # needs sage.libs.gap True By design, there is a unique direct subclass:: - sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # needs sage.rings.number_field + sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # needs sage.libs.gap [] sage: len(sage.rings.abc.NumberField_cyclotomic.__subclasses__()) <= 1 diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index 198e5edb591..1e511848f59 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -4014,7 +4014,7 @@ cdef class ComplexBall(RingElement): [2.2882956833435e+50 +/- ...e+36], [1.2807602335816e+51 +/- ...e+37]) sage: ai, aip, bi, bip = CBF(1,2).airy() - sage: (ai * bip - bi * aip) * CBF(pi) + sage: (ai * bip - bi * aip) * CBF(pi) # needs sage.symbolic [1.0000000000000 +/- ...e-15] + [+/- ...e-16]*I """ diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index f2080959a54..10ea4c5ac84 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -820,11 +820,11 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: CDF(1.2) > CDF(i) + sage: CDF(1.2) > CDF(i) # needs sage.symbolic True sage: CDF(1) < CDF(2) True - sage: CDF(1 + i) > CDF(-1 - i) + sage: CDF(1 + i) > CDF(-1 - i) # needs sage.symbolic True :: diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index 9fedd3f4476..9d42f64074a 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -517,7 +517,7 @@ def _coerce_map_from_(self, S): Conversion via _complex_mpfi_ method map: From: Algebraic Real Field To: Complex Interval Field with 53 bits of precision - sage: CIF.coerce_map_from(UniversalCyclotomicField()) + sage: CIF.coerce_map_from(UniversalCyclotomicField()) # needs sage.libs.gap Conversion via _complex_mpfi_ method map: From: Universal Cyclotomic Field To: Complex Interval Field with 53 bits of precision diff --git a/src/sage/rings/continued_fraction.py b/src/sage/rings/continued_fraction.py index a3f877e423d..f73e1d3f90f 100644 --- a/src/sage/rings/continued_fraction.py +++ b/src/sage/rings/continued_fraction.py @@ -157,7 +157,7 @@ Nevertheless, the tail is preserved under invertible integer homographies:: - sage: # needs sage.rings.number_field + sage: # needs sage.modular sage.rings.number_field sage: apply_homography = lambda m,z: (m[0,0]*z + m[0,1]) / (m[1,0]*z + m[1,1]) sage: m1 = SL2Z([60,13,83,18]) sage: m2 = SL2Z([27,80,28,83]) diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py index da55ada5432..44182627cfc 100644 --- a/src/sage/rings/derivation.py +++ b/src/sage/rings/derivation.py @@ -1997,7 +1997,7 @@ def _call_(self, x): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: f = x^3*S.derivation(); f diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index 08f76c59927..458ea9d85cd 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -1004,6 +1004,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): Check that :trac:`26761` is fixed:: + sage: # needs sage.libs.gap sage: G32 = GU(3,2) sage: g1, g2 = G32.gens() sage: m1 = g1.matrix() diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index 7e2eed91153..2a1d4f913a9 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -4,6 +4,7 @@ Base class for finite fields TESTS:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field sage: F = K.factor(3)[0][0].residue_field() # needs sage.rings.number_field sage: loads(dumps(F)) == F # needs sage.rings.number_field @@ -1238,6 +1239,7 @@ cdef class FiniteField(Field): (0, 1) sage: # needs sage.modules + sage: x = polygen(ZZ) sage: F = GF(9, 't', modulus=x^2 + x - 1) sage: E = GF(81) sage: h = Hom(F,E).an_element() diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index c5973c6f1dc..f21911cbe43 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -89,7 +89,7 @@ Verify that :trac:`7475` is fixed:: Reducing a curve modulo a prime:: - sage: # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage.schemes sage: K. = NumberField(x^2 + 23) sage: OK = K.ring_of_integers() sage: E = EllipticCurve([0,0,0,K(1),K(5)]) @@ -99,7 +99,6 @@ Reducing a curve modulo a prime:: Elliptic Curve defined by y^2 = x^3 + x + 5 over Residue field of Fractional ideal (13, 1/2*s + 9/2) - sage: # needs sage.rings.finite_rings sage: R. = GF(11)[] sage: P = R.ideal(t^3 + t + 4) sage: ff. = R.residue_field(P) diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 5d55d18eb17..0fe0b4e86bb 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -985,13 +985,13 @@ cdef class RingHomomorphism(RingMap): sage: K. = NumberField(QQ['x']('x^2+2')) sage: f = K.hom([-a], K) sage: I = K.ideal([a + 1]) - sage: f.inverse_image(I) + sage: f.inverse_image(I) # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError: inverse image not implemented... - sage: f.inverse_image(K.ideal(0)).is_zero() + sage: f.inverse_image(K.ideal(0)).is_zero() # needs sage.libs.singular True - sage: f.inverse()(I) + sage: f.inverse()(I) # needs sage.rings.padics Fractional ideal (-a + 1) ALGORITHM: @@ -1033,7 +1033,7 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage.symbolic sage: R. = QQbar[] sage: f = R.hom([x, QQbar(i) * x + y^2], R) sage: I = R.ideal(y^3) @@ -1192,7 +1192,7 @@ cdef class RingHomomorphism(RingMap): :: sage: K. = QuadraticField(2) # needs sage.rings.number_field - sage: K.hom([-sqrt2], K).kernel().is_zero() # needs sage.rings.number_field + sage: K.hom([-sqrt2], K).kernel().is_zero() # needs sage.libs.singular sage.rings.number_field True :: @@ -1201,7 +1201,7 @@ cdef class RingHomomorphism(RingMap): sage: A. = QuadraticField(2) sage: B. = A.extension(A['b']('b^2-3')) sage: C. = B.absolute_field() - sage: A.hom([B(a)], C).kernel().is_zero() + sage: A.hom([B(a)], C).kernel().is_zero() # needs sage.libs.singular True sage: A.hom([a], B).kernel() Traceback (most recent call last): @@ -1459,11 +1459,12 @@ cdef class RingHomomorphism(RingMap): sage: K. = CyclotomicField(7) # needs sage.rings.number_field sage: c = K.hom([1/zeta7]) # needs sage.rings.number_field - sage: (c.inverse() * c).is_identity() # needs sage.rings.number_field + sage: (c.inverse() * c).is_identity() # needs sage.libs.singular sage.rings.number_field True + sage: F. = GF(7^3) # needs sage.rings.finite_rings sage: f = F.hom(t^7, F) # needs sage.rings.finite_rings - sage: (f.inverse() * f).is_identity() # needs sage.rings.finite_rings + sage: (f.inverse() * f).is_identity() # needs sage.libs.singular sage.rings.finite_rings True An isomorphism between the algebraic torus and the circle over a number @@ -1632,7 +1633,7 @@ cdef class RingHomomorphism(RingMap): sage: R. = GF(17)[] sage: f = R.hom([3*x, y + x^2 + x^3], R) - sage: (f * ~f).is_identity() # needs sage.rings.finite_rings + sage: (f * ~f).is_identity() # needs sage.libs.singular True """ return self.inverse() @@ -2921,7 +2922,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = PolynomialRing(GF(19), 3) sage: S. = R.quo(x^3 + y^3 + z^3) sage: phi = S.hom([b, c, a]) @@ -2946,7 +2947,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: # needs sage.libs.singular sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = PolynomialRing(GF(19), 3) sage: S. = R.quo(x^3 + y^3 + z^3) sage: phi = S.hom([b, c, a]) diff --git a/src/sage/rings/number_field/number_field_base.pyx b/src/sage/rings/number_field/number_field_base.pyx index 222f8f108a7..001cfaeb702 100644 --- a/src/sage/rings/number_field/number_field_base.pyx +++ b/src/sage/rings/number_field/number_field_base.pyx @@ -5,6 +5,7 @@ Base class for all number fields TESTS:: + sage: x = polygen(ZZ) sage: k = NumberField(x^2 + 1, 'i'); k == loads(dumps(k)) True """ @@ -19,6 +20,7 @@ def is_NumberField(x): EXAMPLES:: sage: from sage.rings.number_field.number_field_base import is_NumberField + sage: x = polygen(ZZ) sage: is_NumberField(NumberField(x^2 + 1, 'a')) doctest:...: DeprecationWarning: the function is_NumberField is deprecated; use isinstance(x, sage.rings.number_field.number_field_base.NumberField) instead @@ -74,6 +76,7 @@ cdef class NumberField(Field): Pushout is implemented for number field embedded in ``AA``:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 - 3, embedding=AA(3)**(1/2)) sage: L. = NumberField(x^2 - 2, embedding=AA(2)**(1/2)) sage: cm = sage.structure.element.get_coercion_model() @@ -151,6 +154,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ring_of_integers() Gaussian Integers in Number Field in a with defining polynomial x^2 + 1 @@ -163,6 +167,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^3 - 2,'a').OK() Maximal Order in Number Field in a with defining polynomial x^3 - 2 """ @@ -175,6 +180,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^3 - 2,'b').maximal_order() Maximal Order in Number Field in b with defining polynomial x^3 - 2 """ @@ -186,6 +192,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 2) sage: K.is_absolute() True @@ -205,6 +212,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^3 - 2, 'a').signature() (1, 1) """ @@ -216,6 +224,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^3 + 9, 'a').degree() 3 """ @@ -227,6 +236,7 @@ cdef class NumberField(Field): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^3 + 9, 'a').discriminant() -243 """ @@ -286,6 +296,7 @@ cdef class NumberField(Field): We compute the Minkowski bound for `\QQ[\sqrt{2}+\sqrt{3}]`:: sage: # needs sage.symbolic + sage: x = polygen(ZZ) sage: K. = NumberField([x^2 - 2, x^2 - 3]) sage: L. = QQ[sqrt(2) + sqrt(3)] sage: B = K.minkowski_bound(); B @@ -375,6 +386,7 @@ cdef class NumberField(Field): TESTS:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 - x^2 - x - 1, embedding=1) sage: K._get_embedding_approx(0) # indirect doctest 1.839286755214161? From 94a8772f51d9d90940e5483807d97a7f398ad111 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 16:39:34 -0700 Subject: [PATCH 056/494] sage.rings: Update # needs --- src/sage/rings/finite_rings/residue_field.pyx | 5 ++- src/sage/rings/infinity.py | 12 +++--- src/sage/rings/invariants/reconstruction.py | 2 +- .../polynomial_padic_capped_relative_dense.py | 18 ++++---- .../polynomial/polynomial_element_generic.py | 41 ++++++++----------- src/sage/rings/polynomial/real_roots.pyx | 1 + src/sage/rings/polynomial/toy_d_basis.py | 4 +- 7 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index f21911cbe43..1f704853e1c 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -99,11 +99,12 @@ Reducing a curve modulo a prime:: Elliptic Curve defined by y^2 = x^3 + x + 5 over Residue field of Fractional ideal (13, 1/2*s + 9/2) + sage: # needs sage.libs.pari sage.schemes sage: R. = GF(11)[] sage: P = R.ideal(t^3 + t + 4) sage: ff. = R.residue_field(P) - sage: E = EllipticCurve([0,0,0,R(1),R(t)]) # needs sage.schemes - sage: E.base_extend(ff) # needs sage.schemes + sage: E = EllipticCurve([0,0,0,R(1),R(t)]) + sage: E.base_extend(ff) Elliptic Curve defined by y^2 = x^3 + x + a over Residue field in a of Principal ideal (t^3 + t + 4) of Univariate Polynomial Ring in t over Finite Field of size 11 diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index 4f6916210e6..5bf588ecf39 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -1773,17 +1773,15 @@ def test_comparison(ring): EXAMPLES:: sage: from sage.rings.infinity import test_comparison - sage: rings = [ZZ, QQ, RR, RealField(200), RDF, RLF, RIF] # needs sage.rings.real_mpfr - sage: for R in rings: # needs sage.rings.real_mpfr + sage: rings = [ZZ, QQ, RDF] + sage: rings += [RR, RealField(200)] # needs sage.rings.real_mpfr + sage: rings += [RLF, RIF] # needs sage.rings.real_interval_field + sage: for R in rings: ....: print('testing {}'.format(R)) ....: test_comparison(R) testing Integer Ring testing Rational Field - testing Real Field with 53 bits of precision - testing Real Field with 200 bits of precision - testing Real Double Field - testing Real Lazy Field - testing Real Interval Field with 53 bits of precision + testing Real Double Field... sage: test_comparison(AA) # needs sage.rings.number_field Comparison with number fields does not work:: diff --git a/src/sage/rings/invariants/reconstruction.py b/src/sage/rings/invariants/reconstruction.py index 4619bf777f1..2fff473d090 100644 --- a/src/sage/rings/invariants/reconstruction.py +++ b/src/sage/rings/invariants/reconstruction.py @@ -86,7 +86,7 @@ def binary_cubic_coefficients_from_invariants(discriminant, invariant_choice='de sage: coeffs (0, 1, -1, 0) sage: R. = QQ[] - sage: R(coeffs).discriminant() + sage: R(coeffs).discriminant() # needs sage.libs.pari 1 The two non-equivalent cubics `x^3` and `x^2*z` with discriminant 0 can't diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py index 204ae5c54f4..d6ec7525fb4 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py @@ -21,9 +21,11 @@ import copy from sage.libs.pari.all import pari, pari_gen -from sage.libs.ntl.all import ZZX +from sage.misc.lazy_import import lazy_import from sage.rings.infinity import infinity +lazy_import('sage.libs.ntl.all', 'ZZX') + min = misc.min ZZ = sage.rings.integer_ring.ZZ PrecisionError = precision_error.PrecisionError @@ -1145,13 +1147,13 @@ def newton_polygon(self): sage: K = Qp(2, prec=5) sage: P. = K[] sage: f = x^4 + 2^3*x^3 + 2^13*x^2 + 2^21*x + 2^37 - sage: f.newton_polygon() + sage: f.newton_polygon() # needs sage.geometry.polyhedron Finite Newton polygon with 4 vertices: (0, 37), (1, 21), (3, 3), (4, 0) sage: K = Qp(5) sage: R. = K[] sage: f = 5 + 3*t + t^4 + 25*t^10 - sage: f.newton_polygon() + sage: f.newton_polygon() # needs sage.geometry.polyhedron Finite Newton polygon with 4 vertices: (0, 1), (1, 0), (4, 0), (10, 2) Here is an example where the computation fails because precision is @@ -1159,14 +1161,14 @@ def newton_polygon(self): sage: g = f + K(0,0)*t^4; g (5^2 + O(5^22))*t^10 + O(5^0)*t^4 + (3 + O(5^20))*t + 5 + O(5^21) - sage: g.newton_polygon() + sage: g.newton_polygon() # needs sage.geometry.polyhedron Traceback (most recent call last): ... PrecisionError: The coefficient of t^4 has not enough precision TESTS:: - sage: (5*f).newton_polygon() + sage: (5*f).newton_polygon() # needs sage.geometry.polyhedron Finite Newton polygon with 4 vertices: (0, 2), (1, 1), (4, 1), (10, 3) AUTHOR: @@ -1283,13 +1285,13 @@ def newton_slopes(self, repetition=True): sage: K = Qp(5) sage: R. = K[] sage: f = 5 + 3*t + t^4 + 25*t^10 - sage: f.newton_polygon() + sage: f.newton_polygon() # needs sage.geometry.polyhedron Finite Newton polygon with 4 vertices: (0, 1), (1, 0), (4, 0), (10, 2) - sage: f.newton_slopes() + sage: f.newton_slopes() # needs sage.geometry.polyhedron [1, 0, 0, 0, -1/3, -1/3, -1/3, -1/3, -1/3, -1/3] - sage: f.newton_slopes(repetition=False) + sage: f.newton_slopes(repetition=False) # needs sage.geometry.polyhedron [1, 0, -1/3] AUTHOR: diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py index 8b656266625..65c2d832b54 100644 --- a/src/sage/rings/polynomial/polynomial_element_generic.py +++ b/src/sage/rings/polynomial/polynomial_element_generic.py @@ -1155,7 +1155,7 @@ def newton_slopes(self, repetition=True): EXAMPLES:: - sage: # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics sage: K = Qp(5) sage: R. = K[] sage: f = 5 + 3*t + t^4 + 25*t^10 @@ -1163,8 +1163,7 @@ def newton_slopes(self, repetition=True): Finite Newton polygon with 4 vertices: (0, 1), (1, 0), (4, 0), (10, 2) sage: f.newton_slopes() [1, 0, 0, 0, -1/3, -1/3, -1/3, -1/3, -1/3, -1/3] - - sage: f.newton_slopes(repetition=False) # needs sage.rings.padics + sage: f.newton_slopes(repetition=False) [1, 0, -1/3] AUTHOR: @@ -1184,16 +1183,15 @@ def newton_polygon(self): EXAMPLES:: - sage: # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics sage: K = Qp(5) sage: R. = K[] sage: f = 5 + 3*t + t^4 + 25*t^10 sage: f.newton_polygon() Finite Newton polygon with 4 vertices: (0, 1), (1, 0), (4, 0), (10, 2) - - sage: g = f + K(0,0)*t^4; g # needs sage.rings.padics + sage: g = f + K(0,0)*t^4; g (5^2 + O(5^22))*t^10 + O(5^0)*t^4 + (3 + O(5^20))*t + 5 + O(5^21) - sage: g.newton_polygon() # needs sage.rings.padics + sage: g.newton_polygon() Traceback (most recent call last): ... PrecisionError: The coefficient of t^4 has not enough precision @@ -1354,7 +1352,7 @@ def factor_of_slope(self, slope=None): EXAMPLES:: - sage: # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics sage: K = Qp(5) sage: R. = K[] sage: K = Qp(5) @@ -1362,23 +1360,21 @@ def factor_of_slope(self, slope=None): sage: f = 5 + 3*t + t^4 + 25*t^10 sage: f.newton_slopes() [1, 0, 0, 0, -1/3, -1/3, -1/3, -1/3, -1/3, -1/3] - - sage: g = f.factor_of_slope(0) # needs sage.rings.padics - sage: g.newton_slopes() # needs sage.rings.padics + sage: g = f.factor_of_slope(0) + sage: g.newton_slopes() [0, 0, 0] - sage: (f % g).is_zero() # needs sage.rings.padics + sage: (f % g).is_zero() True - - sage: h = f.factor_of_slope() # needs sage.rings.padics - sage: h.newton_slopes() # needs sage.rings.padics + sage: h = f.factor_of_slope() + sage: h.newton_slopes() [1] - sage: (f % h).is_zero() # needs sage.rings.padics + sage: (f % h).is_zero() True If ``slope`` is not a slope of ``self``, the corresponding factor is `1`:: - sage: f.factor_of_slope(-1) # needs sage.rings.padics + sage: f.factor_of_slope(-1) # needs sage.geometry.polyhedron sage.rings.padics 1 + O(5^20) AUTHOR: @@ -1424,7 +1420,7 @@ def slope_factorization(self): EXAMPLES:: - sage: # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics sage: K = Qp(5) sage: R. = K[] sage: K = Qp(5) @@ -1432,11 +1428,10 @@ def slope_factorization(self): sage: f = 5 + 3*t + t^4 + 25*t^10 sage: f.newton_slopes() [1, 0, 0, 0, -1/3, -1/3, -1/3, -1/3, -1/3, -1/3] - - sage: F = f.slope_factorization() # needs sage.rings.padics - sage: F.prod() == f # needs sage.rings.padics + sage: F = f.slope_factorization() + sage: F.prod() == f True - sage: for (f,_) in F: # needs sage.rings.padics + sage: for (f,_) in F: ....: print(f.newton_slopes()) [-1/3, -1/3, -1/3, -1/3, -1/3, -1/3] [0, 0, 0] @@ -1502,7 +1497,7 @@ def _roots(self, secure, minval, hint): TESTS:: - sage: # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics sage: R = Zp(2) sage: S. = R[] sage: P = (x-1) * (x-2) * (x-4) * (x-8) * (x-16) diff --git a/src/sage/rings/polynomial/real_roots.pyx b/src/sage/rings/polynomial/real_roots.pyx index 4b5ebac6d8e..71481e8aba5 100644 --- a/src/sage/rings/polynomial/real_roots.pyx +++ b/src/sage/rings/polynomial/real_roots.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs numpy """ Isolate Real Roots of Real Polynomials diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 25eca7a9fc2..00209396614 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -82,7 +82,7 @@ sage: P. = PolynomialRing(IntegerRing(), 3, order='degneglex') sage: I = ideal(x^2 - 3*y, y^3 - x*y, z^3 - x, x^4 - y*z + 1) - sage: I.change_ring(P.change_ring(RationalField())).groebner_basis() + sage: I.change_ring(P.change_ring(RationalField())).groebner_basis() # needs sage.libs.singular [1] However, when we compute the Groebner basis of I (defined over `\ZZ`), we @@ -104,7 +104,7 @@ sage: I.change_ring(P.change_ring(GF(103))).groebner_basis() [z - 18, y + 8, x + 39] - sage: I.change_ring( P.change_ring(GF(27173681))).groebner_basis() # needs sage.libs.pari + sage: I.change_ring(P.change_ring(GF(27173681))).groebner_basis() # needs sage.rings.finite_rings [z + 10380032, y + 3186055, x - 536027] Of course, modulo any other prime the Groebner basis is trivial so From 0cb16f3526ae567413fa5361bf1339a78ebfd13e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 11 Sep 2023 20:36:17 -0700 Subject: [PATCH 057/494] ./sage -fixdoctests --long --fixed-point --distribution sagemath-flint --distribution sagemath-ntl --distribution sagemath-pari --distribution sagemath-categories --only-tags --probe sage.rings.function_field src/sage/rings/padics src/sage/rings/valuation src/sage/rings/polynomial/padics --- src/sage/rings/padics/CA_template.pxi | 28 +- src/sage/rings/padics/CR_template.pxi | 24 +- src/sage/rings/padics/FM_template.pxi | 19 +- .../padics/eisenstein_extension_generic.py | 62 ++-- src/sage/rings/padics/factory.py | 346 ++++++++++-------- src/sage/rings/padics/generic_nodes.py | 123 ++++--- src/sage/rings/padics/lattice_precision.py | 79 ++-- src/sage/rings/padics/local_generic.py | 181 +++++---- .../rings/padics/local_generic_element.pyx | 62 ++-- src/sage/rings/padics/misc.py | 8 +- src/sage/rings/padics/morphism.pyx | 1 + .../rings/padics/padic_ZZ_pX_CA_element.pyx | 207 ++++++----- .../rings/padics/padic_ZZ_pX_CR_element.pyx | 237 ++++++------ .../rings/padics/padic_ZZ_pX_FM_element.pyx | 156 ++++---- src/sage/rings/padics/padic_ZZ_pX_element.pyx | 63 ++-- src/sage/rings/padics/padic_base_generic.py | 14 +- src/sage/rings/padics/padic_base_leaves.py | 173 +++++---- .../padics/padic_capped_absolute_element.pyx | 14 +- .../padics/padic_capped_relative_element.pyx | 22 +- src/sage/rings/padics/padic_ext_element.pyx | 8 +- .../rings/padics/padic_extension_generic.py | 15 +- .../rings/padics/padic_extension_leaves.py | 110 +++--- .../rings/padics/padic_fixed_mod_element.pyx | 14 +- .../padics/padic_floating_point_element.pyx | 18 +- src/sage/rings/padics/padic_generic.py | 143 ++++---- .../rings/padics/padic_generic_element.pyx | 228 +++++++----- .../rings/padics/padic_lattice_element.py | 2 +- src/sage/rings/padics/padic_printing.pyx | 12 +- .../rings/padics/padic_template_element.pxi | 2 + src/sage/rings/padics/padic_valuation.py | 97 ++--- src/sage/rings/padics/pow_computer.pyx | 17 +- src/sage/rings/padics/pow_computer_ext.pyx | 112 +++--- .../rings/padics/pow_computer_relative.pyx | 26 +- .../rings/padics/relative_extension_leaves.py | 41 ++- .../rings/padics/relative_ramified_CA.pyx | 1 + .../rings/padics/relative_ramified_CR.pyx | 1 + .../rings/padics/relative_ramified_FM.pyx | 1 + .../rings/padics/relative_ramified_FP.pyx | 1 + src/sage/rings/padics/relaxed_template.pxi | 1 + src/sage/rings/padics/tests.py | 8 +- src/sage/rings/padics/tutorial.py | 6 +- .../padics/unramified_extension_generic.py | 53 +-- .../polynomial/padics/polynomial_padic.py | 73 ++-- .../polynomial_padic_capped_relative_dense.py | 1 + .../rings/valuation/augmented_valuation.py | 176 +++++---- .../rings/valuation/developing_valuation.py | 30 +- src/sage/rings/valuation/gauss_valuation.py | 35 +- .../rings/valuation/inductive_valuation.py | 88 +++-- src/sage/rings/valuation/limit_valuation.py | 79 ++-- src/sage/rings/valuation/mapped_valuation.py | 76 ++-- src/sage/rings/valuation/scaled_valuation.py | 4 +- src/sage/rings/valuation/valuation.py | 247 ++++++------- src/sage/rings/valuation/valuation_space.py | 7 +- src/sage/rings/valuation/value_group.py | 16 +- 54 files changed, 1965 insertions(+), 1603 deletions(-) diff --git a/src/sage/rings/padics/CA_template.pxi b/src/sage/rings/padics/CA_template.pxi index d821b5c1576..2dd1500cb75 100644 --- a/src/sage/rings/padics/CA_template.pxi +++ b/src/sage/rings/padics/CA_template.pxi @@ -100,13 +100,14 @@ cdef class CAElement(pAdicTemplateElement): TESTS:: - sage: R = ZpCA(5); R(6,5) * R(7,8) #indirect doctest + sage: R = ZpCA(5); R(6,5) * R(7,8) # indirect doctest 2 + 3*5 + 5^2 + O(5^5) + sage: # needs sage.libs.flint sage: R. = ZqCA(25) sage: S. = ZZ[] sage: W. = R.ext(x^2 - 5) - sage: w * (w+1) #indirect doctest + sage: w * (w+1) # indirect doctest w + w^2 + O(w^40) """ cdef type t = type(self) @@ -459,6 +460,8 @@ cdef class CAElement(pAdicTemplateElement): sage: R(1)^R(0) 1 + O(19^5) + + sage: # needs sage.libs.flint sage: S. = ZqCA(4) sage: S(1)^S(0) 1 + O(2^20) @@ -851,6 +854,7 @@ cdef class CAElement(pAdicTemplateElement): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCA(9) sage: (9*a)._cache_key() (..., ((), (), (0, 1)), 20) @@ -912,9 +916,10 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZZ[] sage: K. = ZqCA(25) - sage: W. = K.extension(x^3-5) + sage: W. = K.extension(x^3 - 5) sage: (1 + w + O(w^11))._polynomial_list() [1 + O(5^4), 1 + O(5^4)] sage: (1 + w + O(w^11))._polynomial_list(pad=True) @@ -951,6 +956,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(5^3) sage: a.polynomial() (1 + O(5^20))*x + O(5^20) @@ -1416,6 +1422,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); f @@ -1434,6 +1441,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); type(f) @@ -1449,6 +1457,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1477,6 +1486,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1527,6 +1537,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1549,6 +1560,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1578,6 +1590,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCA(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1606,6 +1619,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1621,6 +1635,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1637,6 +1652,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); f @@ -1650,6 +1666,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); type(f) @@ -1664,6 +1681,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -1699,6 +1717,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); a = K(a) @@ -1750,6 +1769,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -1778,6 +1798,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCA(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -1834,4 +1855,3 @@ def unpickle_cae_v2(cls, parent, value, absprec): cunpickle(ans.value, value, ans.prime_pow) ans.absprec = absprec return ans - diff --git a/src/sage/rings/padics/CR_template.pxi b/src/sage/rings/padics/CR_template.pxi index 863c612587c..94695bd9f81 100644 --- a/src/sage/rings/padics/CR_template.pxi +++ b/src/sage/rings/padics/CR_template.pxi @@ -183,9 +183,10 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: sage: R = Zp(5) - sage: R(6,5) * R(7,8) #indirect doctest + sage: R(6,5) * R(7,8) # indirect doctest 2 + 3*5 + 5^2 + O(5^5) + sage: # needs sage.libs.ntl sage: R. = ZqCR(25) sage: S. = ZZ[] sage: W. = R.ext(x^2 - 5) @@ -663,6 +664,8 @@ cdef class CRElement(pAdicTemplateElement): sage: R(1)^R(0) 1 + O(19^5) + + sage: # needs sage.libs.ntl sage: S. = ZqCR(4) sage: S(1)^S(0) 1 + O(2^20) @@ -1243,6 +1246,7 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: + sage: # needs sage.libs.ntl sage: K. = Qq(9) sage: (9*a)._cache_key() (..., ((0, 1),), 2, 20) @@ -1349,6 +1353,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(5^3) sage: a.polynomial() (1 + O(5^20))*x + O(5^20) @@ -2135,6 +2140,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); f @@ -2144,7 +2150,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): TESTS:: - sage: TestSuite(f).run() + sage: TestSuite(f).run() # needs sage.libs.flint """ def __init__(self, R, K): @@ -2153,6 +2159,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); type(f) @@ -2168,6 +2175,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2197,6 +2205,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2251,6 +2260,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2273,6 +2283,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2302,6 +2313,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCR(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2330,6 +2342,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2345,6 +2358,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -2361,6 +2375,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); f @@ -2374,6 +2389,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); type(f) @@ -2388,6 +2404,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -2417,6 +2434,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); a = K(a) @@ -2472,6 +2490,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCR(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -2500,6 +2519,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqCR(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) diff --git a/src/sage/rings/padics/FM_template.pxi b/src/sage/rings/padics/FM_template.pxi index 3bae827a08c..f62ba450530 100644 --- a/src/sage/rings/padics/FM_template.pxi +++ b/src/sage/rings/padics/FM_template.pxi @@ -711,9 +711,10 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZZ[] sage: K. = ZqFM(25) - sage: W. = K.extension(x^3-5) + sage: W. = K.extension(x^3 - 5) sage: (1 + w)._polynomial_list() [1, 1] sage: (1 + w)._polynomial_list(pad=True) @@ -738,6 +739,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(5^3) sage: a.polynomial() x @@ -1180,6 +1182,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); f @@ -1198,6 +1201,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); type(f) @@ -1213,6 +1217,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1240,6 +1245,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1287,6 +1293,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1305,6 +1312,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1333,6 +1341,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFM(9) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1361,6 +1370,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(9) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1376,6 +1386,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(9) sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1392,6 +1403,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = R.convert_map_from(K); f @@ -1405,6 +1417,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = R.convert_map_from(K); type(f) @@ -1419,6 +1432,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -1448,6 +1462,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = R.convert_map_from(K); a = K(a) @@ -1492,6 +1507,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFM(27) sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -1520,6 +1536,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFM(9) sage: K = R.fraction_field() sage: f = R.convert_map_from(K) diff --git a/src/sage/rings/padics/eisenstein_extension_generic.py b/src/sage/rings/padics/eisenstein_extension_generic.py index bf9a3d96158..2e3f702a0aa 100644 --- a/src/sage/rings/padics/eisenstein_extension_generic.py +++ b/src/sage/rings/padics/eisenstein_extension_generic.py @@ -31,8 +31,8 @@ def __init__(self, poly, prec, print_mode, names, element_class): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2+7) #indirect doctest + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2+7) #indirect doctest # needs sage.libs.ntl sage.rings.padics """ pAdicExtensionGeneric.__init__(self, poly, prec, print_mode, names, element_class) #self._precompute() @@ -46,13 +46,13 @@ def _extension_type(self): EXAMPLES:: - sage: K. = Qq(5^3) - sage: K._extension_type() + sage: K. = Qq(5^3) # needs sage.libs.ntl + sage: K._extension_type() # needs sage.libs.ntl 'Unramified' sage: x = polygen(ZZ, 'x') - sage: L. = Qp(5).extension(x^2 - 5) - sage: L._extension_type() + sage: L. = Qp(5).extension(x^2 - 5) # needs sage.libs.ntl + sage: L._extension_type() # needs sage.libs.ntl 'Eisenstein' """ return "Eisenstein" @@ -63,13 +63,13 @@ def absolute_e(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_e() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_e() # needs sage.libs.ntl 1 sage: x = polygen(ZZ, 'x') - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_e() + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_e() # needs sage.libs.ntl 2 """ return self.modulus().degree() * self.base_ring().absolute_e() @@ -84,9 +84,9 @@ def inertia_subring(self): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2 + 7) - sage: B.inertia_subring() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.inertia_subring() # needs sage.libs.ntl 7-adic Ring with capped relative precision 10 """ return self.ground_ring() @@ -106,9 +106,9 @@ def residue_class_field(self): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2 + 7) - sage: B.residue_class_field() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.residue_class_field() # needs sage.libs.ntl Finite Field of size 7 """ return self.ground_ring().residue_class_field() @@ -120,13 +120,13 @@ def residue_ring(self, n): EXAMPLES:: sage: S. = ZZ[] - sage: W. = Zp(5).extension(x^2 - 5) - sage: W.residue_ring(1) + sage: W. = Zp(5).extension(x^2 - 5) # needs sage.libs.ntl + sage: W.residue_ring(1) # needs sage.libs.ntl Ring of integers modulo 5 The following requires implementing more general Artinian rings:: - sage: W.residue_ring(2) + sage: W.residue_ring(2) # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError @@ -169,9 +169,9 @@ def gen(self, n=0): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2 + 7) - sage: B.gen() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.gen() # needs sage.libs.ntl t + O(t^21) """ if n != 0: @@ -186,9 +186,9 @@ def uniformizer_pow(self, n): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2 + 7) - sage: B.uniformizer_pow(5) + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.uniformizer_pow(5) # needs sage.libs.ntl t^5 + O(t^25) """ if n is infinity: @@ -204,9 +204,9 @@ def uniformizer(self): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2 + 7) - sage: B.uniformizer() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.uniformizer() # needs sage.libs.ntl t + O(t^21) """ return self.gen() @@ -219,9 +219,9 @@ def _uniformizer_print(self): EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2+7) - sage: B._uniformizer_print() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2+7) # needs sage.libs.ntl + sage: B._uniformizer_print() # needs sage.libs.ntl 't' """ return self.variable_name() diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index d8d7c7e3c3b..ce20f53b0cb 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -897,15 +897,15 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, is relative precision, which gives the number of known `p`-adic digits:: - sage: R. = Qq(25, 20, 'capped-rel', print_mode='series'); b = 25*a; b + sage: R. = Qq(25, 20, 'capped-rel', print_mode='series'); b = 25*a; b # needs sage.libs.ntl a*5^2 + O(5^22) - sage: b.precision_relative() + sage: b.precision_relative() # needs sage.libs.ntl 20 The second type of precision is absolute precision, which gives the power of `p` that this element is defined modulo:: - sage: b.precision_absolute() + sage: b.precision_absolute() # needs sage.libs.ntl 22 There are two types of unramified `p`-adic fields: capped relative @@ -919,11 +919,11 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, capped relative field, it truncates it to the precision cap of the field. :: - sage: R. = Qq(9, 5, 'capped-rel', print_mode='series'); b = (1+2*a)^4; b + sage: R. = Qq(9, 5, 'capped-rel', print_mode='series'); b = (1+2*a)^4; b # needs sage.libs.ntl 2 + (2*a + 2)*3 + (2*a + 1)*3^2 + O(3^5) - sage: c = R(3249); c + sage: c = R(3249); c # needs sage.libs.ntl 3^2 + 3^4 + 3^5 + 3^6 + O(3^7) - sage: b + c + sage: b + c # needs sage.libs.ntl 2 + (2*a + 2)*3 + (2*a + 2)*3^2 + 3^4 + O(3^5) In the floating point case, elements do not track their @@ -941,6 +941,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, The base ring can be `\ZZ`, `\QQ`, `\ZZ_p`, `\QQ_p`, `\GF{p}`. :: + sage: # needs sage.libs.ntl sage: P. = ZZ[] sage: R. = Qq(27, modulus = x^3 + 2*x + 1); R.modulus() (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) @@ -950,19 +951,20 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: T. = Qq(27, modulus = x^3 + 2*x + 1) sage: P. = Qp(3)[] sage: U. = Qq(27, modulus = x^3 + 2*x + 1) - sage: P. = GF(3)[] + sage: P. = GF(3)[] # needs sage.rings.finite_rings sage: V. = Qq(27, modulus = x^3 + 2*x + 1) Which form the modulus is given in has no effect on the unramified extension produced:: - sage: R == S, S == T, T == U, U == V + sage: R == S, S == T, T == U, U == V # needs sage.libs.ntl (True, True, True, False) unless the precision of the modulus differs. In the case of V, the modulus is only given to precision 1, so the resulting field has a precision cap of 1. :: + sage: # needs sage.libs.ntl sage: V.precision_cap() 1 sage: U.precision_cap() @@ -979,24 +981,24 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: x = var('x') # needs sage.symbolic sage: X. = Qq(27, modulus = x^3 + 2*x + 1); X.modulus() # needs sage.symbolic (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) - sage: X == R # needs sage.symbolic + sage: X == R # needs sage.libs.ntl sage.symbolic True By default, the polynomial chosen is the standard lift of the generator chosen for `\GF{q}`. :: - sage: GF(125, 'a').modulus() + sage: GF(125, 'a').modulus() # needs sage.rings.finite_rings x^3 + 3*x + 3 - sage: Y. = Qq(125); Y.modulus() + sage: Y. = Qq(125); Y.modulus() # needs sage.libs.ntl (1 + O(5^20))*x^3 + O(5^20)*x^2 + (3 + O(5^20))*x + 3 + O(5^20) However, you can choose another polynomial if desired (as long as the reduction to `\GF{p}[x]` is irreducible). :: sage: P. = ZZ[] - sage: Z. = Qq(125, modulus = x^3 + 3*x^2 + x + 1); Z.modulus() + sage: Z. = Qq(125, modulus = x^3 + 3*x^2 + x + 1); Z.modulus() # needs sage.libs.ntl (1 + O(5^20))*x^3 + (3 + O(5^20))*x^2 + (1 + O(5^20))*x + 1 + O(5^20) - sage: Y == Z + sage: Y == Z # needs sage.libs.ntl False PRINTING: @@ -1012,15 +1014,15 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, 1. **series**: elements are displayed as series in `p`. :: - sage: R. = Qq(9, 20, 'capped-rel', print_mode='series'); (1+2*a)^4 + sage: R. = Qq(9, 20, 'capped-rel', print_mode='series'); (1+2*a)^4 # needs sage.libs.ntl 2 + (2*a + 2)*3 + (2*a + 1)*3^2 + O(3^20) - sage: -3*(1+2*a)^4 + sage: -3*(1+2*a)^4 # needs sage.libs.ntl 3 + a*3^2 + 3^3 + (2*a + 2)*3^4 + (2*a + 2)*3^5 + (2*a + 2)*3^6 + (2*a + 2)*3^7 + (2*a + 2)*3^8 + (2*a + 2)*3^9 + (2*a + 2)*3^10 + (2*a + 2)*3^11 + (2*a + 2)*3^12 + (2*a + 2)*3^13 + (2*a + 2)*3^14 + (2*a + 2)*3^15 + (2*a + 2)*3^16 + (2*a + 2)*3^17 + (2*a + 2)*3^18 + (2*a + 2)*3^19 + (2*a + 2)*3^20 + O(3^21) - sage: ~(3*a+18) + sage: ~(3*a+18) # needs sage.libs.ntl (a + 2)*3^-1 + 1 + 2*3 + (a + 1)*3^2 + 3^3 + 2*3^4 + (a + 1)*3^5 + 3^6 + 2*3^7 + (a + 1)*3^8 + 3^9 + 2*3^10 + (a + 1)*3^11 + 3^12 + 2*3^13 + (a + 1)*3^14 + 3^15 + 2*3^16 + (a + 1)*3^17 + 3^18 + O(3^19) @@ -1028,24 +1030,25 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_pos* controls whether negatives can be used in the coefficients of powers of `p`. :: - sage: S. = Qq(9, print_mode='series', print_pos=False); (1+2*b)^4 + sage: S. = Qq(9, print_mode='series', print_pos=False); (1+2*b)^4 # needs sage.libs.ntl -1 - b*3 - 3^2 + (b + 1)*3^3 + O(3^20) - sage: -3*(1+2*b)^4 + sage: -3*(1+2*b)^4 # needs sage.libs.ntl 3 + b*3^2 + 3^3 + (-b - 1)*3^4 + O(3^21) *ram_name* controls how the prime is printed. :: - sage: T. = Qq(9, print_mode='series', ram_name='p'); 3*(1+2*d)^4 + sage: T. = Qq(9, print_mode='series', ram_name='p'); 3*(1+2*d)^4 # needs sage.libs.ntl 2*p + (2*d + 2)*p^2 + (2*d + 1)*p^3 + O(p^21) *print_max_ram_terms* limits the number of powers of `p` that appear. :: - sage: U. = Qq(9, print_mode='series', print_max_ram_terms=4); repr(-3*(1+2*e)^4) + sage: U. = Qq(9, print_mode='series', print_max_ram_terms=4); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + e*3^2 + 3^3 + (2*e + 2)*3^4 + ... + O(3^21)' *print_max_unram_terms* limits the number of terms that appear in a coefficient of a power of `p`. :: + sage: # needs sage.libs.ntl sage: V. = Qq(128, prec = 8, print_mode='series'); repr((1+f)^9) '(f^3 + 1) + (f^5 + f^4 + f^3 + f^2)*2 + (f^6 + f^5 + f^4 + f + 1)*2^2 + (f^5 + f^4 + f^2 + f + 1)*2^3 + (f^6 + f^5 + f^4 + f^3 + f^2 + f + 1)*2^4 + (f^5 + f^4)*2^5 + (f^6 + f^5 + f^4 + f^3 + f + 1)*2^6 + (f + 1)*2^7 + O(2^8)' sage: V. = Qq(128, prec = 8, print_mode='series', print_max_unram_terms = 3); repr((1+f)^9) @@ -1063,34 +1066,35 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` type and ``True`` for all other types. :: - sage: U. = Qq(9, 2, show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Qq(9, 2, show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + e*3^2' *print_sep* and *print_max_terse_terms* have no effect. Note that print options affect equality:: - sage: R == S, R == T, R == U, R == V, S == T, S == U, S == V, T == U, T == V, U == V + sage: R == S, R == T, R == U, R == V, S == T, S == U, S == V, T == U, T == V, U == V # needs sage.libs.ntl (False, False, False, False, False, False, False, False, False, False) 2. **val-unit**: elements are displayed as `p^k u`:: - sage: R. = Qq(9, 7, print_mode='val-unit'); b = (1+3*a)^9 - 1; b + sage: R. = Qq(9, 7, print_mode='val-unit'); b = (1+3*a)^9 - 1; b # needs sage.libs.ntl 3^3 * (15 + 64*a) + O(3^7) - sage: ~b + sage: ~b # needs sage.libs.ntl 3^-3 * (41 + a) + O(3) *print_pos* controls whether to use a balanced representation or not. :: - sage: S. = Qq(9, 7, print_mode='val-unit', print_pos=False) - sage: b = (1+3*a)^9 - 1; b + sage: S. = Qq(9, 7, print_mode='val-unit', print_pos=False) # needs sage.libs.ntl + sage: b = (1+3*a)^9 - 1; b # needs sage.libs.ntl 3^3 * (15 - 17*a) + O(3^7) - sage: ~b + sage: ~b # needs sage.libs.ntl 3^-3 * (-40 + a) + O(3) *ram_name* affects how the prime is printed. :: + sage: # needs sage.libs.ntl sage: A. = Qp(next_prime(10^6), print_mode='val-unit')[] sage: T. = Qq(next_prime(10^6)^3, 4, print_mode='val-unit', ram_name='p', ....: modulus=x^3+385831*x^2+106556*x+321036) @@ -1103,10 +1107,10 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_max_terse_terms* controls how many terms of the polynomial appear in the unit part. :: - sage: U. = Qq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) - sage: b = ~(17*(a^3-a+14)); b + sage: U. = Qq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) # needs sage.libs.ntl + sage: b = ~(17*(a^3-a+14)); b # needs sage.libs.ntl 17^-1 * (22110411 + 11317400*a + 20656972*a^2 + ...) + O(17^5) - sage: b*17*(a^3-a+14) + sage: b*17*(a^3-a+14) # needs sage.libs.ntl 1 + O(17^6) *show_prec* determines how the precision is printed. @@ -1115,7 +1119,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` type and ``True`` for all other types. :: - sage: U. = Qq(9, 2, print_mode='val-unit', show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Qq(9, 2, print_mode='val-unit', show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 * (1 + 3*e)' *print_sep*, *print_max_ram_terms* and *print_max_unram_terms* have no @@ -1123,44 +1127,44 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, Equality again depends on the printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) 3. **terse**: elements are displayed as a polynomial of degree less than the degree of the extension. :: - sage: R. = Qq(125, print_mode='terse') - sage: (a+5)^177 + sage: R. = Qq(125, print_mode='terse') # needs sage.libs.ntl + sage: (a+5)^177 # needs sage.libs.ntl 68210977979428 + 90313850704069*a + 73948093055069*a^2 + O(5^20) - sage: (a/5+1)^177 + sage: (a/5+1)^177 # needs sage.libs.ntl 68210977979428/5^177 + 90313850704069/5^177*a + 73948093055069/5^177*a^2 + O(5^-157) As of version 3.3, if coefficients of the polynomial are non-integral, they are always printed with an explicit power of `p` in the denominator. :: - sage: 5*a + a^2/25 + sage: 5*a + a^2/25 # needs sage.libs.ntl 5*a + 1/5^2*a^2 + O(5^18) *print_pos* controls whether to use a balanced representation or not. :: - sage: (a-5)^6 + sage: (a-5)^6 # needs sage.libs.ntl 22864 + 95367431627998*a + 8349*a^2 + O(5^20) - sage: S. = Qq(125, print_mode='terse', print_pos=False); b = (a-5)^6; b + sage: S. = Qq(125, print_mode='terse', print_pos=False); b = (a-5)^6; b # needs sage.libs.ntl 22864 - 12627*a + 8349*a^2 + O(5^20) - sage: (a - 1/5)^6 + sage: (a - 1/5)^6 # needs sage.libs.ntl -20624/5^6 + 18369/5^5*a + 1353/5^3*a^2 + O(5^14) *ram_name* affects how the prime is printed. :: - sage: T. = Qq(125, print_mode='terse', ram_name='p'); (a - 1/5)^6 + sage: T. = Qq(125, print_mode='terse', ram_name='p'); (a - 1/5)^6 # needs sage.libs.ntl 95367431620001/p^6 + 18369/p^5*a + 1353/p^3*a^2 + O(p^14) *print_max_terse_terms* controls how many terms of the polynomial are shown. :: - sage: U. = Qq(625, print_mode='terse', print_max_terse_terms=2); (a-1/5)^6 + sage: U. = Qq(625, print_mode='terse', print_max_terse_terms=2); (a-1/5)^6 # needs sage.libs.ntl 106251/5^6 + 49994/5^5*a + ... + O(5^14) *show_prec* determines how the precision is printed. @@ -1169,7 +1173,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` type and ``True`` for all other types. :: - sage: U. = Qq(9, 2, print_mode='terse', show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Qq(9, 2, print_mode='terse', show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + 9*e' *print_sep*, *print_max_ram_terms* and *print_max_unram_terms* have no @@ -1177,7 +1181,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, Equality again depends on the printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) 4. **digits**: This print mode is not available when the residue @@ -1189,30 +1193,31 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, 5. **bars**: elements are displayed in a similar fashion to series, but more compactly. :: - sage: R. = Qq(125); (a+5)^6 + sage: R. = Qq(125); (a+5)^6 # needs sage.libs.ntl (4*a^2 + 3*a + 4) + (3*a^2 + 2*a)*5 + (a^2 + a + 1)*5^2 + (3*a + 2)*5^3 + (3*a^2 + a + 3)*5^4 + (2*a^2 + 3*a + 2)*5^5 + O(5^20) - sage: R. = Qq(125, print_mode='bars', prec=8); repr((a+5)^6) + sage: R. = Qq(125, print_mode='bars', prec=8); repr((a+5)^6) # needs sage.libs.ntl '...[2, 3, 2]|[3, 1, 3]|[2, 3]|[1, 1, 1]|[0, 2, 3]|[4, 3, 4]' - sage: repr((a-5)^6) + sage: repr((a-5)^6) # needs sage.libs.ntl '...[0, 4]|[1, 4]|[2, 0, 2]|[1, 4, 3]|[2, 3, 1]|[4, 4, 3]|[2, 4, 4]|[4, 3, 4]' Note that elements with negative valuation are shown with a decimal point at valuation 0. :: - sage: repr((a+1/5)^6) + sage: repr((a+1/5)^6) # needs sage.libs.ntl '...[3]|[4, 1, 3]|.|[1, 2, 3]|[3, 3]|[0, 0, 3]|[0, 1]|[0, 1]|[1]' - sage: repr((a+1/5)^2) + sage: repr((a+1/5)^2) # needs sage.libs.ntl '...[0, 0, 1]|.|[0, 2]|[1]' If not enough precision is known, ``'?'`` is used instead. :: - sage: repr((a+R(1/5,relprec=3))^7) + sage: repr((a+R(1/5,relprec=3))^7) # needs sage.libs.ntl '...|.|?|?|?|?|[0, 1, 1]|[0, 2]|[1]' Note that it's not possible to read off the precision from the representation in this mode. :: + sage: # needs sage.libs.ntl sage: b = a + 3; repr(b) '...[3, 1]' sage: c = a + R(3, 4); repr(c) @@ -1224,28 +1229,29 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_pos* controls whether the digits can be negative. :: - sage: S. = Qq(125, print_mode='bars', print_pos=False); repr((a-5)^6) + sage: S. = Qq(125, print_mode='bars', print_pos=False); repr((a-5)^6) # needs sage.libs.ntl '...[1, -1, 1]|[2, 1, -2]|[2, 0, -2]|[-2, -1, 2]|[0, 0, -1]|[-2]|[-1, -2, -1]' - sage: repr((a-1/5)^6) + sage: repr((a-1/5)^6) # needs sage.libs.ntl '...[0, 1, 2]|[-1, 1, 1]|.|[-2, -1, -1]|[2, 2, 1]|[0, 0, -2]|[0, -1]|[0, -1]|[1]' *print_max_ram_terms* controls the maximum number of "digits" shown. Note that this puts a cap on the relative precision, not the absolute precision. :: - sage: T. = Qq(125, print_max_ram_terms=3, print_pos=False); (a-5)^6 + sage: T. = Qq(125, print_max_ram_terms=3, print_pos=False); (a-5)^6 # needs sage.libs.ntl (-a^2 - 2*a - 1) - 2*5 - a^2*5^2 + ... + O(5^20) - sage: 5*(a-5)^6 + 50 + sage: 5*(a-5)^6 + 50 # needs sage.libs.ntl (-a^2 - 2*a - 1)*5 - a^2*5^3 + (2*a^2 - a - 2)*5^4 + ... + O(5^21) *print_sep* controls the separating character (``'|'`` by default). :: - sage: U. = Qq(625, print_mode='bars', print_sep=''); b = (a+5)^6; repr(b) + sage: U. = Qq(625, print_mode='bars', print_sep=''); b = (a+5)^6; repr(b) # needs sage.libs.ntl '...[0, 1][4, 0, 2][3, 2, 2, 3][4, 2, 2, 4][0, 3][1, 1, 3][3, 1, 4, 1]' *print_max_unram_terms* controls how many terms are shown in each "digit":: + sage: # needs sage.libs.ntl sage: with local_print_mode(U, {'max_unram_terms': 3}): repr(b) '...[0, 1][4,..., 0, 2][3,..., 2, 3][4,..., 2, 4][0, 3][1,..., 1, 3][3,..., 4, 1]' sage: with local_print_mode(U, {'max_unram_terms': 2}): repr(b) @@ -1261,14 +1267,14 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` type and ``True`` for all other types. :: - sage: U. = Qq(9, 2, print_mode='bars', show_prec=True); repr(-3*(1+2*e)^4) + sage: U. = Qq(9, 2, print_mode='bars', show_prec=True); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '...[0, 1]|[1]|[]' *ram_name* and *print_max_terse_terms* have no effect. Equality depends on printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) EXAMPLES: @@ -1281,16 +1287,16 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: p = next_prime(2^123) sage: k = Qp(p) - sage: R. = k[] - sage: K = Qq([(p, 5)], modulus=x^5+x+4, names='a', ram_name='p', + sage: R. = k[] # needs sage.libs.ntl + sage: K = Qq([(p, 5)], modulus=x^5+x+4, names='a', ram_name='p', # needs sage.libs.ntl ....: print_pos=False, check=False) - sage: K.0^5 + sage: K.0^5 # needs sage.libs.ntl (-a - 4) + O(p^20) In tests on ``sage.math.washington.edu``, the creation of ``K`` as above took an average of 1.58ms, while:: - sage: K = Qq(p^5, modulus=x^5+x+4, names='a', ram_name='p', + sage: K = Qq(p^5, modulus=x^5+x+4, names='a', ram_name='p', # needs sage.libs.ntl ....: print_pos=False, check=True) took an average of 24.5ms. Of course, with smaller primes these @@ -1300,11 +1306,11 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, Check that :trac:`8162` is resolved:: - sage: R = Qq([(5,3)], names="alpha", check=False); R + sage: R = Qq([(5,3)], names="alpha", check=False); R # needs sage.libs.ntl 5-adic Unramified Extension Field in alpha defined by x^3 + 3*x + 3 - sage: Qq((5, 3), names="alpha") is R + sage: Qq((5, 3), names="alpha") is R # needs sage.libs.ntl True - sage: Qq(125.factor(), names="alpha") is R + sage: Qq(125.factor(), names="alpha") is R # needs sage.libs.ntl True Check that :trac:`18606` is resolved:: @@ -1312,8 +1318,8 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: x = QQ['x'].gen() sage: F = Qp(5,20) sage: K0 = F.extension(x^2-F(13),names = 'g') - sage: K1 = F.extension(x^2-13,names = 'g') - sage: K0 is K1 + sage: K1 = F.extension(x^2-13,names = 'g') # needs sage.libs.ntl + sage: K0 is K1 # needs sage.libs.ntl True """ if is_Element(q): @@ -1419,7 +1425,7 @@ def QqCR(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = QqCR(25, 40); R + sage: R. = QqCR(25, 40); R # needs sage.libs.ntl 5-adic Unramified Extension Field in a defined by x^2 + 4*x + 2 """ return Qq(q, prec, 'capped-rel', *args, **kwds) @@ -1434,7 +1440,7 @@ def QqFP(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = QqFP(25, 40); R + sage: R. = QqFP(25, 40); R # needs sage.libs.flint 5-adic Unramified Extension Field in a defined by x^2 + 4*x + 2 """ return Qq(q, prec, 'floating-point', *args, **kwds) @@ -1477,8 +1483,7 @@ def QpER(p, prec=None, halt=None, secure=False, *args, **kwds): EXAMPLES:: - sage: R = QpER(2) - sage: R + sage: R = QpER(2); R # needs sage.libs.flint 2-adic Field handled with relaxed arithmetics """ return Qp(p, (prec, halt, secure), 'relaxed', *args, **kwds) @@ -2113,15 +2118,15 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, is relative precision (default), which gives the number of known `p`-adic digits:: - sage: R. = Zq(25, 20, 'capped-rel', print_mode='series'); b = 25*a; b + sage: R. = Zq(25, 20, 'capped-rel', print_mode='series'); b = 25*a; b # needs sage.libs.ntl a*5^2 + O(5^22) - sage: b.precision_relative() + sage: b.precision_relative() # needs sage.libs.ntl 20 The second type of precision is absolute precision, which gives the power of `p` that this element is defined modulo:: - sage: b.precision_absolute() + sage: b.precision_absolute() # needs sage.libs.ntl 22 There are many types of `p`-adic rings: capped relative rings @@ -2137,43 +2142,45 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, capped relative field, it truncates it to the precision cap of the field. :: - sage: R. = Zq(9, 5, 'capped-rel', print_mode='series'); b = (1+2*a)^4; b + sage: R. = Zq(9, 5, 'capped-rel', print_mode='series'); b = (1+2*a)^4; b # needs sage.libs.ntl 2 + (2*a + 2)*3 + (2*a + 1)*3^2 + O(3^5) - sage: c = R(3249); c + sage: c = R(3249); c # needs sage.libs.ntl 3^2 + 3^4 + 3^5 + 3^6 + O(3^7) - sage: b + c + sage: b + c # needs sage.libs.ntl 2 + (2*a + 2)*3 + (2*a + 2)*3^2 + 3^4 + O(3^5) One can invert non-units: the result is in the fraction field. :: - sage: d = ~(3*b+c); d + sage: d = ~(3*b+c); d # needs sage.libs.ntl 2*3^-1 + (a + 1) + (a + 1)*3 + a*3^3 + O(3^4) - sage: d.parent() + sage: d.parent() # needs sage.libs.ntl 3-adic Unramified Extension Field in a defined by x^2 + 2*x + 2 The capped absolute case is the same as the capped relative case, except that the cap is on the absolute precision rather than the relative precision. :: + sage: # needs sage.libs.flint sage: R. = Zq(9, 5, 'capped-abs', print_mode='series'); b = 3*(1+2*a)^4; b 2*3 + (2*a + 2)*3^2 + (2*a + 1)*3^3 + O(3^5) - sage: c = R(3249); c + sage: c = R(3249); c # needs sage.libs.ntl 3^2 + 3^4 + O(3^5) - sage: b*c + sage: b*c # needs sage.libs.ntl 2*3^3 + (2*a + 2)*3^4 + O(3^5) - sage: b*c >> 1 + sage: b*c >> 1 # needs sage.libs.ntl 2*3^2 + (2*a + 2)*3^3 + O(3^4) The fixed modulus case is like the capped absolute, except that individual elements don't track their precision. :: + sage: # needs sage.libs.flint sage: R. = Zq(9, 5, 'fixed-mod', print_mode='series'); b = 3*(1+2*a)^4; b 2*3 + (2*a + 2)*3^2 + (2*a + 1)*3^3 - sage: c = R(3249); c + sage: c = R(3249); c # needs sage.libs.ntl 3^2 + 3^4 - sage: b*c + sage: b*c # needs sage.libs.ntl 2*3^3 + (2*a + 2)*3^4 - sage: b*c >> 1 + sage: b*c >> 1 # needs sage.libs.ntl 2*3^2 + (2*a + 2)*3^3 The floating point case is similar to the fixed modulus type @@ -2192,6 +2199,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, The base ring can be `\ZZ`, `\QQ`, `\ZZ_p`, `\GF{p}`, or anything that can be converted to `\ZZ_p`. :: + sage: # needs sage.libs.ntl sage: P. = ZZ[] sage: R. = Zq(27, modulus = x^3 + 2*x + 1); R.modulus() (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) @@ -2201,19 +2209,20 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: T. = Zq(27, modulus = x^3 + 2*x + 1) sage: P. = Qp(3)[] sage: U. = Zq(27, modulus = x^3 + 2*x + 1) - sage: P. = GF(3)[] + sage: P. = GF(3)[] # needs sage.rings.finite_rings sage: V. = Zq(27, modulus = x^3 + 2*x + 1) Which form the modulus is given in has no effect on the unramified extension produced:: - sage: R == S, R == T, T == U, U == V + sage: R == S, R == T, T == U, U == V # needs sage.libs.ntl (False, True, True, False) unless the modulus is different, or the precision of the modulus differs. In the case of ``V``, the modulus is only given to precision ``1``, so the resulting field has a precision cap of ``1``. :: + sage: # needs sage.libs.ntl sage: V.precision_cap() 1 sage: U.precision_cap() @@ -2230,24 +2239,24 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, sage: x = var('x') # needs sage.symbolic sage: X. = Zq(27, modulus = x^3 + 2*x + 1); X.modulus() # needs sage.symbolic (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) - sage: X == R # needs sage.symbolic + sage: X == R # needs sage.libs.ntl sage.symbolic True By default, the polynomial chosen is the standard lift of the generator chosen for `\GF{q}`. :: - sage: GF(125, 'a').modulus() + sage: GF(125, 'a').modulus() # needs sage.rings.finite_rings x^3 + 3*x + 3 - sage: Y. = Zq(125); Y.modulus() + sage: Y. = Zq(125); Y.modulus() # needs sage.libs.ntl (1 + O(5^20))*x^3 + O(5^20)*x^2 + (3 + O(5^20))*x + 3 + O(5^20) However, you can choose another polynomial if desired (as long as the reduction to `\GF{p}[x]` is irreducible). :: sage: P. = ZZ[] - sage: Z. = Zq(125, modulus = x^3 + 3*x^2 + x + 1); Z.modulus() + sage: Z. = Zq(125, modulus = x^3 + 3*x^2 + x + 1); Z.modulus() # needs sage.libs.ntl (1 + O(5^20))*x^3 + (3 + O(5^20))*x^2 + (1 + O(5^20))*x + 1 + O(5^20) - sage: Y == Z + sage: Y == Z # needs sage.libs.ntl False PRINTING: @@ -2263,37 +2272,44 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, 1. **series**: elements are displayed as series in `p`. :: + sage: # needs sage.libs.ntl sage: R. = Zq(9, 20, 'capped-rel', print_mode='series'); (1+2*a)^4 2 + (2*a + 2)*3 + (2*a + 1)*3^2 + O(3^20) sage: -3*(1+2*a)^4 - 3 + a*3^2 + 3^3 + (2*a + 2)*3^4 + (2*a + 2)*3^5 + (2*a + 2)*3^6 + (2*a + 2)*3^7 + (2*a + 2)*3^8 + (2*a + 2)*3^9 + (2*a + 2)*3^10 + (2*a + 2)*3^11 + (2*a + 2)*3^12 + (2*a + 2)*3^13 + (2*a + 2)*3^14 + (2*a + 2)*3^15 + (2*a + 2)*3^16 + (2*a + 2)*3^17 + (2*a + 2)*3^18 + (2*a + 2)*3^19 + (2*a + 2)*3^20 + O(3^21) + 3 + a*3^2 + 3^3 + (2*a + 2)*3^4 + (2*a + 2)*3^5 + (2*a + 2)*3^6 + (2*a + 2)*3^7 + + (2*a + 2)*3^8 + (2*a + 2)*3^9 + (2*a + 2)*3^10 + (2*a + 2)*3^11 + (2*a + 2)*3^12 + + (2*a + 2)*3^13 + (2*a + 2)*3^14 + (2*a + 2)*3^15 + (2*a + 2)*3^16 + + (2*a + 2)*3^17 + (2*a + 2)*3^18 + (2*a + 2)*3^19 + (2*a + 2)*3^20 + O(3^21) sage: b = ~(3*a+18); b - (a + 2)*3^-1 + 1 + 2*3 + (a + 1)*3^2 + 3^3 + 2*3^4 + (a + 1)*3^5 + 3^6 + 2*3^7 + (a + 1)*3^8 + 3^9 + 2*3^10 + (a + 1)*3^11 + 3^12 + 2*3^13 + (a + 1)*3^14 + 3^15 + 2*3^16 + (a + 1)*3^17 + 3^18 + O(3^19) + (a + 2)*3^-1 + 1 + 2*3 + (a + 1)*3^2 + 3^3 + 2*3^4 + (a + 1)*3^5 + 3^6 + 2*3^7 + + (a + 1)*3^8 + 3^9 + 2*3^10 + (a + 1)*3^11 + 3^12 + 2*3^13 + (a + 1)*3^14 + + 3^15 + 2*3^16 + (a + 1)*3^17 + 3^18 + O(3^19) sage: b.parent() is R.fraction_field() True *print_pos* controls whether negatives can be used in the coefficients of powers of `p`. :: - sage: S. = Zq(9, print_mode='series', print_pos=False); (1+2*b)^4 + sage: S. = Zq(9, print_mode='series', print_pos=False); (1+2*b)^4 # needs sage.libs.ntl -1 - b*3 - 3^2 + (b + 1)*3^3 + O(3^20) - sage: -3*(1+2*b)^4 + sage: -3*(1+2*b)^4 # needs sage.libs.ntl 3 + b*3^2 + 3^3 + (-b - 1)*3^4 + O(3^21) *ram_name* controls how the prime is printed. :: - sage: T. = Zq(9, print_mode='series', ram_name='p'); 3*(1+2*d)^4 + sage: T. = Zq(9, print_mode='series', ram_name='p'); 3*(1+2*d)^4 # needs sage.libs.ntl 2*p + (2*d + 2)*p^2 + (2*d + 1)*p^3 + O(p^21) *print_max_ram_terms* limits the number of powers of `p` that appear. :: - sage: U. = Zq(9, print_mode='series', print_max_ram_terms=4); repr(-3*(1+2*e)^4) + sage: U. = Zq(9, print_mode='series', print_max_ram_terms=4); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + e*3^2 + 3^3 + (2*e + 2)*3^4 + ... + O(3^21)' *print_max_unram_terms* limits the number of terms that appear in a coefficient of a power of `p`. :: + sage: # needs sage.libs.ntl sage: V. = Zq(128, prec = 8, print_mode='series'); repr((1+f)^9) '(f^3 + 1) + (f^5 + f^4 + f^3 + f^2)*2 + (f^6 + f^5 + f^4 + f + 1)*2^2 + (f^5 + f^4 + f^2 + f + 1)*2^3 + (f^6 + f^5 + f^4 + f^3 + f^2 + f + 1)*2^4 + (f^5 + f^4)*2^5 + (f^6 + f^5 + f^4 + f^3 + f + 1)*2^6 + (f + 1)*2^7 + O(2^8)' sage: V. = Zq(128, prec = 8, print_mode='series', print_max_unram_terms = 3); repr((1+f)^9) @@ -2311,33 +2327,34 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` and ``'fixed-mod'`` types and ``True`` for all other types. :: - sage: U. = Zq(9, 2, show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Zq(9, 2, show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + e*3^2' *print_sep* and *print_max_terse_terms* have no effect. Note that print options affect equality:: - sage: R == S, R == T, R == U, R == V, S == T, S == U, S == V, T == U, T == V, U == V + sage: R == S, R == T, R == U, R == V, S == T, S == U, S == V, T == U, T == V, U == V # needs sage.libs.ntl (False, False, False, False, False, False, False, False, False, False) 2. **val-unit**: elements are displayed as `p^k u`:: - sage: R. = Zq(9, 7, print_mode='val-unit'); b = (1+3*a)^9 - 1; b + sage: R. = Zq(9, 7, print_mode='val-unit'); b = (1+3*a)^9 - 1; b # needs sage.libs.ntl 3^3 * (15 + 64*a) + O(3^7) - sage: ~b + sage: ~b # needs sage.libs.ntl 3^-3 * (41 + a) + O(3) *print_pos* controls whether to use a balanced representation or not. :: - sage: S. = Zq(9, 7, print_mode='val-unit', print_pos=False); b = (1+3*a)^9 - 1; b + sage: S. = Zq(9, 7, print_mode='val-unit', print_pos=False); b = (1+3*a)^9 - 1; b # needs sage.libs.ntl 3^3 * (15 - 17*a) + O(3^7) - sage: ~b + sage: ~b # needs sage.libs.ntl 3^-3 * (-40 + a) + O(3) *ram_name* affects how the prime is printed. :: + sage: # needs sage.libs.ntl sage: A. = Zp(next_prime(10^6), print_mode='val-unit')[] sage: T. = Zq(next_prime(10^6)^3, 4, print_mode='val-unit', ram_name='p', ....: modulus=x^3+385831*x^2+106556*x+321036) @@ -2350,6 +2367,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_max_terse_terms* controls how many terms of the polynomial appear in the unit part. :: + sage: # needs sage.libs.ntl sage: U. = Zq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) sage: b = 17*(a^3-a+14)^6; b 17 * (12131797 + 12076378*a + 10809706*a^2 + ...) + O(17^7) @@ -2360,19 +2378,20 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` and ``'fixed-mod'`` types and ``True`` for all other types. :: - sage: U. = Zq(9, 2, print_mode='val-unit', show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Zq(9, 2, print_mode='val-unit', show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 * (1 + 3*e)' *print_sep*, *print_max_ram_terms* and *print_max_unram_terms* have no effect. Equality again depends on the printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) 3. **terse**: elements are displayed as a polynomial of degree less than the degree of the extension. :: + sage: # needs sage.libs.ntl sage: R. = Zq(125, print_mode='terse') sage: (a+5)^177 68210977979428 + 90313850704069*a + 73948093055069*a^2 + O(5^20) @@ -2387,12 +2406,14 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, non-integral, they are always printed with an explicit power of `p` in the denominator. :: + sage: # needs sage.libs.ntl sage: 5*a + a^2/25 5*a + 1/5^2*a^2 + O(5^18) *print_pos* controls whether to use a balanced representation or not. :: + sage: # needs sage.libs.ntl sage: (a-5)^6 22864 + 95367431627998*a + 8349*a^2 + O(5^20) sage: S. = Zq(125, print_mode='terse', print_pos=False); b = (a-5)^6; b @@ -2402,13 +2423,13 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, *ram_name* affects how the prime is printed. :: - sage: T. = Zq(125, print_mode='terse', ram_name='p'); (a - 1/5)^6 + sage: T. = Zq(125, print_mode='terse', ram_name='p'); (a - 1/5)^6 # needs sage.libs.ntl 95367431620001/p^6 + 18369/p^5*a + 1353/p^3*a^2 + O(p^14) *print_max_terse_terms* controls how many terms of the polynomial are shown. :: - sage: U. = Zq(625, print_mode='terse', print_max_terse_terms=2); (a-1/5)^6 + sage: U. = Zq(625, print_mode='terse', print_max_terse_terms=2); (a-1/5)^6 # needs sage.libs.ntl 106251/5^6 + 49994/5^5*a + ... + O(5^14) *show_prec* determines how the precision is printed. @@ -2417,7 +2438,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` and ``'fixed-mod'`` types and ``True`` for all other types. :: - sage: U. = Zq(9, 2, print_mode='terse', show_prec=False); repr(-3*(1+2*e)^4) + sage: U. = Zq(9, 2, print_mode='terse', show_prec=False); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '3 + 9*e' *print_sep*, *print_max_ram_terms* and *print_max_unram_terms* have no @@ -2425,7 +2446,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, Equality again depends on the printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) 4. **digits**: This print mode is not available when the residue @@ -2435,6 +2456,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, 5. **bars**: elements are displayed in a similar fashion to series, but more compactly. :: + sage: # needs sage.libs.ntl sage: R. = Zq(125); (a+5)^6 (4*a^2 + 3*a + 4) + (3*a^2 + 2*a)*5 + (a^2 + a + 1)*5^2 + (3*a + 2)*5^3 + (3*a^2 + a + 3)*5^4 + (2*a^2 + 3*a + 2)*5^5 + O(5^20) @@ -2446,6 +2468,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, Note that it's not possible to read off the precision from the representation in this mode. :: + sage: # needs sage.libs.ntl sage: b = a + 3; repr(b) '...[3, 1]' sage: c = a + R(3, 4); repr(c) @@ -2457,6 +2480,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_pos* controls whether the digits can be negative. :: + sage: # needs sage.libs.ntl sage: S. = Zq(125, print_mode='bars', print_pos=False); repr((a-5)^6) '...[1, -1, 1]|[2, 1, -2]|[2, 0, -2]|[-2, -1, 2]|[0, 0, -1]|[-2]|[-1, -2, -1]' sage: repr((a-1/5)^6) @@ -2466,6 +2490,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, Note that this puts a cap on the relative precision, not the absolute precision. :: + sage: # needs sage.libs.ntl sage: T. = Zq(125, print_max_ram_terms=3, print_pos=False); (a-5)^6 (-a^2 - 2*a - 1) - 2*5 - a^2*5^2 + ... + O(5^20) sage: 5*(a-5)^6 + 50 @@ -2475,12 +2500,13 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, *print_sep* controls the separating character (``'|'`` by default). :: - sage: U. = Zq(625, print_mode='bars', print_sep=''); b = (a+5)^6; repr(b) + sage: U. = Zq(625, print_mode='bars', print_sep=''); b = (a+5)^6; repr(b) # needs sage.libs.ntl '...[0, 1][4, 0, 2][3, 2, 2, 3][4, 2, 2, 4][0, 3][1, 1, 3][3, 1, 4, 1]' *print_max_unram_terms* controls how many terms are shown in each ``'digit'``:: + sage: # needs sage.libs.ntl sage: with local_print_mode(U, {'max_unram_terms': 3}): repr(b) '...[0, 1][4,..., 0, 2][3,..., 2, 3][4,..., 2, 4][0, 3][1,..., 1, 3][3,..., 4, 1]' sage: with local_print_mode(U, {'max_unram_terms': 2}): repr(b) @@ -2496,14 +2522,14 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, The default is ``False`` for the ``'floating-point'`` and ``'fixed-mod'`` types and ``True`` for all other types. :: - sage: U. = Zq(9, 2, print_mode='bars', show_prec='bigoh'); repr(-3*(1+2*e)^4) + sage: U. = Zq(9, 2, print_mode='bars', show_prec='bigoh'); repr(-3*(1+2*e)^4) # needs sage.libs.ntl '[0, 1]|[1]|[] + O(3^3)' *ram_name* and *print_max_terse_terms* have no effect. Equality depends on printing options:: - sage: R == S, R == T, R == U, S == T, S == U, T == U + sage: R == S, R == T, R == U, S == T, S == U, T == U # needs sage.libs.ntl (False, False, False, False, False, False) EXAMPLES: @@ -2514,6 +2540,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, have to factor. If you do so, you need to use names explicitly rather than the ``R.`` syntax. :: + sage: # needs sage.libs.ntl sage: p = next_prime(2^123) sage: k = Zp(p) sage: R. = k[] @@ -2525,7 +2552,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, In tests on sage.math, the creation of ``K`` as above took an average of 1.58ms, while:: - sage: K = Zq(p^5, modulus=x^5+x+4, names='a', ram_name='p', + sage: K = Zq(p^5, modulus=x^5+x+4, names='a', ram_name='p', # needs sage.libs.ntl ....: print_pos=False, check=True) took an average of 24.5ms. Of course, with smaller primes these @@ -2533,6 +2560,7 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, TESTS:: + sage: # needs sage.libs.ntl sage: R = Zq([(5,3)], names="alpha"); R 5-adic Unramified Extension Ring in alpha defined by x^3 + 3*x + 3 sage: Zq((5, 3), names="alpha") is R @@ -2664,7 +2692,7 @@ def ZqCR(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = ZqCR(25, 40); R + sage: R. = ZqCR(25, 40); R # needs sage.libs.ntl 5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2 """ return Zq(q, prec, 'capped-rel', *args, **kwds) @@ -2677,7 +2705,7 @@ def ZqCA(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = ZqCA(25, 40); R + sage: R. = ZqCA(25, 40); R # needs sage.libs.flint 5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2 """ return Zq(q, prec, 'capped-abs', *args, **kwds) @@ -2690,7 +2718,7 @@ def ZqFM(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = ZqFM(25, 40); R + sage: R. = ZqFM(25, 40); R # needs sage.libs.flint 5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2 """ return Zq(q, prec, 'fixed-mod', *args, **kwds) @@ -2704,7 +2732,7 @@ def ZqFP(q, prec=None, *args, **kwds): EXAMPLES:: - sage: R. = ZqFP(25, 40); R + sage: R. = ZqFP(25, 40); R # needs sage.libs.flint 5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2 """ return Zq(q, prec, 'floating-point', *args, **kwds) @@ -2902,7 +2930,7 @@ def ZpLC(p, prec=None, *args, **kwds): might be delayed. We can force it with the method :meth:`del_elements`:: sage: z = 0 - sage: prec # random output, could be 2 objects if the garbage collector is fast + sage: prec # random output, could be 2 objects if the garbage collector is fast Precision lattice on 3 objects sage: prec.del_elements() sage: prec @@ -2911,7 +2939,7 @@ def ZpLC(p, prec=None, *args, **kwds): The method :meth:`precision_lattice` returns (a matrix defining) the lattice that models the precision. Here we have:: - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [9765625 0] [ 0 3125] @@ -2923,7 +2951,7 @@ def ZpLC(p, prec=None, *args, **kwds): sage: x, y = 3*x+2*y, 2*(x-y) sage: prec.del_elements() - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [ 3125 48825000] [ 0 48828125] @@ -3025,44 +3053,42 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): Relaxed `p`-adic rings are created by the constructor :func:`ZpER`:: - sage: R = ZpER(5, print_mode="digits") - sage: R + sage: R = ZpER(5, print_mode="digits"); R # needs sage.libs.flint 5-adic Ring handled with relaxed arithmetics The precision is not capped in `R`:: - sage: R.precision_cap() + sage: R.precision_cap() # needs sage.libs.flint +Infinity However, a default precision is fixed. This is the precision at which the elements will be printed:: - sage: R.default_prec() + sage: R.default_prec() # needs sage.libs.flint 20 A default halting precision is also set. It is the default absolute precision at which the elements will be compared. By default, it is twice the default precision:: - sage: R.halting_prec() + sage: R.halting_prec() # needs sage.libs.flint 40 However, both the default precision and the halting precision can be customized at the creation of the parent as follows:: - sage: S = ZpER(5, prec=10, halt=100) - sage: S.default_prec() + sage: S = ZpER(5, prec=10, halt=100) # needs sage.libs.flint + sage: S.default_prec() # needs sage.libs.flint 10 - sage: S.halting_prec() + sage: S.halting_prec() # needs sage.libs.flint 100 One creates elements as usual:: - sage: a = R(17/42) - sage: a + sage: a = R(17/42); a # needs sage.libs.flint ...00244200244200244201 - sage: R.random_element() # random + sage: R.random_element() # random # needs sage.libs.flint ...21013213133412431402 Here we notice that 20 digits (that is the default precision) are printed. @@ -3071,22 +3097,23 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): This feature is reflected by the fact that, when we ask for the precision of `a`, the software answers `+\infty`:: - sage: a.precision_absolute() + sage: a.precision_absolute() # needs sage.libs.flint +Infinity Asking for more digits is achieved by the methods :meth:`at_precision_absolute` and :meth:`at_precision_relative`:: - sage: a.at_precision_absolute(30) + sage: a.at_precision_absolute(30) # needs sage.libs.flint ...?244200244200244200244200244201 As a shortcut, one can use the bracket operator:: - sage: a[:30] + sage: a[:30] # needs sage.libs.flint ...?244200244200244200244200244201 Of course, standard operations are supported:: + sage: # needs sage.libs.flint sage: b = R(42/17) sage: a + b ...03232011214322140002 @@ -3102,7 +3129,7 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): We observe again that only 20 digits are printed but, as before, more digits are available on demand:: - sage: sqrt(a)[:30] + sage: sqrt(a)[:30] # needs sage.libs.flint ...?142443342120042333114021142101 .. RUBRIC:: Equality tests @@ -3114,12 +3141,12 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): default), elements are compared at the current precision, or at the default halting precision if it is higher:: - sage: a == b + sage: a == b # needs sage.libs.flint False - sage: a == sqrt(a)^2 + sage: a == sqrt(a)^2 # needs sage.libs.flint True - sage: a == sqrt(a)^2 + 5^50 + sage: a == sqrt(a)^2 + 5^50 # needs sage.libs.flint True In the above example, the halting precision is `40`; it is the @@ -3129,6 +3156,7 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): Hence comparing two elements at different times can produce different results:: + sage: # needs sage.libs.flint sage: aa = sqrt(a)^2 + 5^50 sage: a == aa True @@ -3145,6 +3173,7 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): Indeed, in this case, if the equality cannot be decided, an error is raised:: + sage: # needs sage.libs.flint sage: S = ZpER(5, secure=True) sage: u = S.random_element() sage: uu = u + 5^50 @@ -3153,7 +3182,7 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): ... PrecisionError: unable to decide equality; try to bound precision - sage: u[:60] == uu + sage: u[:60] == uu # needs sage.libs.flint False .. RUBRIC:: Self-referent numbers @@ -3162,20 +3191,19 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): create (in some cases) self-referent numbers. Here is an example. We first declare a new variable as follows:: - sage: x = R.unknown() - sage: x + sage: x = R.unknown(); x # needs sage.libs.flint ...?.0 We then use the method :meth:`set` to define `x` by writing down an equation it satisfies:: - sage: x.set(1 + 5*x^2) + sage: x.set(1 + 5*x^2) # needs sage.libs.flint True The variable `x` now contains the unique solution of the equation `x = 1 + 5 x^2`:: - sage: x + sage: x # needs sage.libs.flint ...04222412141121000211 This works because the `n`-th digit of the right hand size of the @@ -3184,6 +3212,7 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): As a comparison, the following does not work:: + sage: # needs sage.libs.flint sage: y = R.unknown() sage: y.set(1 + 3*y^2) True @@ -3196,17 +3225,16 @@ def ZpER(p, prec=None, halt=None, secure=False, *args, **kwds): Self-referent definitions also work with systems of equations:: + sage: # needs sage.libs.flint sage: u = R.unknown() sage: v = R.unknown() sage: w = R.unknown() - sage: u.set(1 + 2*v + 3*w^2 + 5*u*v*w) True sage: v.set(2 + 4*w + sqrt(1 + 5*u + 10*v + 15*w)) True sage: w.set(3 + 25*(u*v + v*w + u*w)) True - sage: u ...31203130103131131433 sage: v @@ -3231,7 +3259,7 @@ class pAdicExtension_class(UniqueFactory): sage: R = Zp(5,3) sage: S. = ZZ[] - sage: W. = pAdicExtension(R, x^4 - 15) + sage: W. = pAdicExtension(R, x^4 - 15) # needs sage.libs.ntl sage.rings.padics sage: W 5-adic Eisenstein Extension Ring in w defined by x^4 - 15 sage: W.precision_cap() @@ -3252,7 +3280,7 @@ def create_key_and_extra_args(self, base, modulus, prec=None, print_mode=None, sage: R = Zp(5,3) sage: S. = ZZ[] - sage: pAdicExtension.create_key_and_extra_args(R, x^4-15,names='w') + sage: pAdicExtension.create_key_and_extra_args(R, x^4-15,names='w') # needs sage.libs.ntl (('e', 5-adic Ring with capped relative precision 3, x^4 - 15, @@ -3269,6 +3297,7 @@ def create_key_and_extra_args(self, base, modulus, prec=None, print_mode=None, 'NTL'), {'approx_modulus': (1 + O(5^3))*x^4 + O(5^4)*x^3 + O(5^4)*x^2 + O(5^4)*x + 2*5 + 4*5^2 + 4*5^3 + O(5^4)}) + sage: # needs sage.libs.ntl sage: A = Qp(3,5) sage: Po. = A[] sage: f = Po([3,0,-1]) @@ -3278,6 +3307,7 @@ def create_key_and_extra_args(self, base, modulus, prec=None, print_mode=None, sage: K.defining_polynomial() == f/f.leading_coefficient() True + sage: # needs sage.libs.ntl sage: g = Po([6,3,2]) sage: H. = A.ext(g) sage: 2*b^2+3*b+6 @@ -3396,8 +3426,8 @@ def create_object(self, version, key, approx_modulus=None, shift_seed=None): TESTS:: sage: R = Zp(5,3) - sage: S. = R[] - sage: pAdicExtension.create_object(version = (6,4,2), key = ('e', R, x^4 - 15, x^4 - 15, ('w', None, None, 'w'), 12, None, 'series', True, '|', (),-1,-1,-1,'NTL'), shift_seed = S(3 + O(5^3))) + sage: S. = R[] # needs sage.libs.ntl + sage: pAdicExtension.create_object(version = (6,4,2), key = ('e', R, x^4 - 15, x^4 - 15, ('w', None, None, 'w'), 12, None, 'series', True, '|', (),-1,-1,-1,'NTL'), shift_seed = S(3 + O(5^3))) # needs sage.libs.ntl 5-adic Eisenstein Extension Ring in w defined by x^4 - 15 """ polytype = key[0] @@ -3455,9 +3485,9 @@ def split(poly, prec): EXAMPLES:: sage: k = Qp(13) - sage: x = polygen(k) - sage: f = x^2 + 1 - sage: sage.rings.padics.factory.split(f, 10) + sage: x = polygen(k) # needs sage.libs.ntl + sage: f = x^2 + 1 # needs sage.libs.ntl + sage: sage.rings.padics.factory.split(f, 10) # needs sage.libs.ntl sage.rings.real_double Traceback (most recent call last): ... NotImplementedError: Extensions by general polynomials not yet supported. @@ -3468,9 +3498,9 @@ def split(poly, prec): This checks that :trac:`6186` is still fixed:: sage: k = Qp(13) - sage: x = polygen(k) - sage: f = x^2+1 - sage: L. = k.extension(f) + sage: x = polygen(k) # needs sage.libs.ntl + sage: f = x^2+1 # needs sage.libs.ntl + sage: L. = k.extension(f) # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError: Extensions by general polynomials not yet supported. Please use an unramified or Eisenstein polynomial. @@ -3485,10 +3515,10 @@ def truncate_to_prec(poly, R, absprec): EXAMPLES:: sage: R = Zp(5) - sage: S. = R[] + sage: S. = R[] # needs sage.libs.ntl sage: from sage.rings.padics.factory import truncate_to_prec - sage: f = x^4 + (3+O(5^6))*x^3 + O(5^4) - sage: truncate_to_prec(f, R, 5) + sage: f = x^4 + (3+O(5^6))*x^3 + O(5^4) # needs sage.libs.ntl + sage: truncate_to_prec(f, R, 5) # needs sage.libs.ntl (1 + O(5^5))*x^4 + (3 + O(5^5))*x^3 + O(5^5)*x^2 + O(5^5)*x + O(5^4) """ return R[poly.variable_name()]([R(a, absprec=absprec) for a in poly.list()]) # Is this quite right? We don't want flat necessarily... @@ -3519,6 +3549,7 @@ def is_eisenstein(poly): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(5) sage: S. = R[] sage: from sage.rings.padics.factory import is_eisenstein @@ -3547,6 +3578,7 @@ def is_unramified(poly): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(5) sage: S. = R[] sage: from sage.rings.padics.factory import is_unramified diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index 0832f317b4d..c9fec13a4cb 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -523,8 +523,8 @@ def label(self): with matrices:: sage: R = ZpLC(5, label='matrices') - sage: M = random_matrix(R, 4, 4) - sage: d = M.determinant() + sage: M = random_matrix(R, 4, 4) # needs sage.geometry.polyhedron + sage: d = M.determinant() # needs sage.geometry.polyhedron Now, if we want to do another unrelated computation, we can use a different label:: @@ -612,7 +612,7 @@ def convert_multiple(self, *elts): sage: x + y 2 + O(2^11) - sage: R.precision().diffused_digits([x,y]) + sage: R.precision().diffused_digits([x,y]) # needs sage.geometry.polyhedron 6 As a consequence, if we convert ``x`` and ``y`` separately, we @@ -627,17 +627,17 @@ def convert_multiple(self, *elts): sage: x2 + y2 2 + O(2^5) - sage: R2.precision().diffused_digits([x2,y2]) + sage: R2.precision().diffused_digits([x2,y2]) # needs sage.geometry.polyhedron 0 On the other hand, this issue disappears when we use multiple conversion:: - sage: x2,y2 = R2.convert_multiple(x,y) - sage: x2 + y2 + sage: x2,y2 = R2.convert_multiple(x,y) # needs sage.geometry.polyhedron + sage: x2 + y2 # needs sage.rings.padics 2 + O(2^11) - sage: R2.precision().diffused_digits([x2,y2]) + sage: R2.precision().diffused_digits([x2,y2]) # needs sage.geometry.polyhedron 6 """ p = self.prime() @@ -712,8 +712,8 @@ class pAdicRelaxedGeneric(pAdicGeneric): TESTS:: - sage: R = ZpER(17) # indirect doctest - sage: R._prec_type() + sage: R = ZpER(17) # indirect doctest # needs sage.libs.flint + sage: R._prec_type() # needs sage.libs.flint 'relaxed' """ def _get_element_class(self, name=None): @@ -727,16 +727,14 @@ def _get_element_class(self, name=None): TESTS:: + sage: # needs sage.libs.flint sage: R = ZpER(5) sage: R._get_element_class() - sage: R._get_element_class("add") - sage: R._get_element_class("unknown") - sage: R._get_element_class("foobar") Traceback (most recent call last): ... @@ -754,7 +752,7 @@ def _prec_type(self): EXAMPLES:: - sage: ZpER(5)._prec_type() + sage: ZpER(5)._prec_type() # needs sage.libs.flint 'relaxed' """ return 'relaxed' @@ -768,8 +766,8 @@ def is_relaxed(self): sage: R = Zp(5) sage: R.is_relaxed() False - sage: S = ZpER(5) - sage: S.is_relaxed() + sage: S = ZpER(5) # needs sage.libs.flint + sage: S.is_relaxed() # needs sage.libs.flint True """ return True @@ -783,6 +781,7 @@ def is_secure(self): EXAMPLES:: + sage: # needs sage.libs.flint sage: R = ZpER(5) sage: R.is_secure() False @@ -791,6 +790,7 @@ def is_secure(self): sage: x == y True + sage: # needs sage.libs.flint sage: S = ZpER(5, secure=True) sage: S.is_secure() True @@ -813,12 +813,12 @@ def default_prec(self): EXAMPLES:: + sage: # needs sage.libs.flint sage: R = ZpER(5, print_mode="digits") sage: R.default_prec() 20 sage: R(1/17) ...34024323104201213403 - sage: S = ZpER(5, prec=10, print_mode="digits") sage: S.default_prec() 10 @@ -838,8 +838,8 @@ def halting_prec(self): EXAMPLES:: - sage: R = ZpER(5, print_mode="digits") - sage: R.halting_prec() + sage: R = ZpER(5, print_mode="digits") # needs sage.libs.flint + sage: R.halting_prec() # needs sage.libs.flint 40 """ return self._halting_prec @@ -851,8 +851,8 @@ def precision_cap(self): EXAMPLES:: - sage: R = ZpER(5) - sage: R.precision_cap() + sage: R = ZpER(5) # needs sage.libs.flint + sage: R.precision_cap() # needs sage.libs.flint +Infinity """ return infinity @@ -863,6 +863,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: + sage: # needs sage.libs.flint sage: R = ZpER(5) sage: K = R.fraction_field() sage: K.has_coerce_map_from(R) # indirect doctest @@ -886,23 +887,20 @@ def _element_constructor_(self, x, prec=None): EXAMPLES:: + sage: # needs sage.libs.flint sage: R = ZpER(7, prec=5) - - sage: a = R(17/71) - sage: a + sage: a = R(17/71); a 3 + 3*7^2 + 4*7^3 + 4*7^4 + ... sage: a.precision_absolute() +Infinity - - sage: b = R(17/71, prec=10) - sage: b + sage: b = R(17/71, prec=10); b 3 + 3*7^2 + 4*7^3 + 4*7^4 + 2*7^5 + 7^6 + 5*7^8 + 5*7^9 + O(7^10) sage: b.precision_absolute() 10 TESTS:: - sage: R(1/7) + sage: R(1/7) # needs sage.libs.flint Traceback (most recent call last): ... ValueError: negative valuation @@ -913,7 +911,7 @@ def _element_constructor_(self, x, prec=None): sage: c = S(7^5) sage: c 7^5 + O(7^25) - sage: R(c) + sage: R(c) # needs sage.libs.flint 7^5 + O(7^25) """ parent = x.parent() @@ -963,10 +961,10 @@ def an_element(self, unbounded=False): EXAMPLES:: - sage: R = ZpER(7, prec=5) - sage: R.an_element() + sage: R = ZpER(7, prec=5) # needs sage.libs.flint + sage: R.an_element() # needs sage.libs.flint 7 + O(7^5) - sage: R.an_element(unbounded=True) + sage: R.an_element(unbounded=True) # needs sage.libs.flint 7 + ... """ p = self(self.prime()) @@ -982,8 +980,8 @@ def some_elements(self, unbounded=False): EXAMPLES:: - sage: R = ZpER(7, prec=5) - sage: R.some_elements() + sage: R = ZpER(7, prec=5) # needs sage.libs.flint + sage: R.some_elements() # needs sage.libs.flint [O(7^5), 1 + O(7^5), 7 + O(7^5), @@ -991,7 +989,7 @@ def some_elements(self, unbounded=False): 1 + 5*7 + 3*7^2 + 6*7^3 + O(7^5), 7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5)] - sage: R.some_elements(unbounded=True) + sage: R.some_elements(unbounded=True) # needs sage.libs.flint [0, 1 + ..., 7 + ..., @@ -1032,16 +1030,16 @@ def unknown(self, start_val=0, digits=None): EXAMPLES: - sage: R = ZpER(5, prec=10) + sage: R = ZpER(5, prec=10) # needs sage.libs.flint We declare a self-referent number:: - sage: a = R.unknown() + sage: a = R.unknown() # needs sage.libs.flint So far, we do not know anything on `a` (except that it has nonnegative valuation):: - sage: a + sage: a # needs sage.libs.flint O(5^0) We can now use the method :meth:`sage.rings.padics.relaxed_template.RelaxedElement_unknown.set` @@ -1049,17 +1047,18 @@ def unknown(self, start_val=0, digits=None): agree with the digits of `1 + 5 a`. Note that the factor `5` shifts the digits; the `n`-th digit of `a` is then defined by the previous ones:: - sage: a.set(1 + 5*a) + sage: a.set(1 + 5*a) # needs sage.libs.flint True After this, `a` contains the solution of the equation `a = 1 + 5 a`, that is `a = -1/4`:: - sage: a + sage: a # needs sage.libs.flint 1 + 5 + 5^2 + 5^3 + 5^4 + 5^5 + 5^6 + 5^7 + 5^8 + 5^9 + ... Here is another example with an equation of degree `2`:: + sage: # needs sage.libs.flint sage: b = R.unknown() sage: b.set(1 - 5*b^2) True @@ -1070,17 +1069,16 @@ def unknown(self, start_val=0, digits=None): Cross self-referent definitions are also allowed:: + sage: # needs sage.libs.flint sage: u = R.unknown() sage: v = R.unknown() sage: w = R.unknown() - sage: u.set(1 + 2*v + 3*w^2 + 5*u*v*w) True sage: v.set(2 + 4*w + sqrt(1 + 5*u + 10*v + 15*w)) True sage: w.set(3 + 25*(u*v + v*w + u*w)) True - sage: u 3 + 3*5 + 4*5^2 + 5^3 + 3*5^4 + 5^5 + 5^6 + 3*5^7 + 5^8 + 3*5^9 + ... sage: v @@ -1090,6 +1088,7 @@ def unknown(self, start_val=0, digits=None): TESTS:: + sage: # needs sage.libs.flint sage: a = R.unknown() sage: a.set(1 + 3*a) True @@ -1121,23 +1120,23 @@ def random_element(self, integral=False, prec=None): EXAMPLES:: - sage: R = ZpER(5, prec=10) + sage: R = ZpER(5, prec=10) # needs sage.libs.flint By default, this method returns a unbounded element:: - sage: a = R.random_element() - sage: a # random + sage: a = R.random_element() # needs sage.libs.flint + sage: a # random # needs sage.libs.flint 4 + 3*5 + 3*5^2 + 5^3 + 3*5^4 + 2*5^5 + 2*5^6 + 5^7 + 5^9 + ... - sage: a.precision_absolute() + sage: a.precision_absolute() # needs sage.libs.flint +Infinity The precision can be bounded by passing in a precision:: - sage: b = R.random_element(prec=15) - sage: b # random + sage: b = R.random_element(prec=15) # needs sage.libs.flint + sage: b # random # needs sage.libs.flint 2 + 3*5^2 + 5^3 + 3*5^4 + 5^5 + 3*5^6 + 3*5^8 + 3*5^9 + 4*5^10 + 5^11 + 4*5^12 + 5^13 + 2*5^14 + O(5^15) - sage: b.precision_absolute() + sage: b.precision_absolute() # needs sage.libs.flint 15 """ if integral or (not self.is_field()): @@ -1151,8 +1150,8 @@ def teichmuller(self, x): EXAMPLES:: - sage: R = ZpER(5, print_mode="digits") - sage: R.teichmuller(2) + sage: R = ZpER(5, print_mode="digits") # needs sage.libs.flint + sage: R.teichmuller(2) # needs sage.libs.flint ...40423140223032431212 """ x = self(x) @@ -1167,8 +1166,8 @@ def teichmuller_system(self): EXAMPLES:: - sage: R = ZpER(7, print_mode="digits") - sage: R.teichmuller_system() + sage: R = ZpER(7, print_mode="digits") # needs sage.libs.flint + sage: R.teichmuller_system() # needs sage.libs.flint [...00000000000000000001, ...16412125443426203642, ...16412125443426203643, @@ -1192,7 +1191,7 @@ def is_pAdicRing(R): DeprecationWarning: is_pAdicRing is deprecated; use isinstance(..., sage.rings.abc.pAdicRing) instead See https://github.com/sagemath/sage/issues/32750 for details. True - sage: is_pAdicRing(RR) + sage: is_pAdicRing(RR) # needs sage.rings.real_mpfr False """ from sage.misc.superseded import deprecation @@ -1255,19 +1254,21 @@ def _xgcd_univariate_polynomial(self, f, g): EXAMPLES:: - sage: R. = Zp(3,3)[] - sage: f = x + 1 - sage: f.xgcd(f^2) + sage: R. = Zp(3,3)[] # needs sage.libs.ntl + sage: f = x + 1 # needs sage.libs.ntl + sage: f.xgcd(f^2) # needs sage.libs.ntl ((1 + O(3^3))*x + 1 + O(3^3), 1 + O(3^3), 0) We check that :trac:`13439` has been fixed:: + sage: # needs sage.libs.ntl sage: R. = Zp(3,3)[] sage: f = 3*x + 7 sage: g = 5*x + 9 sage: f.xgcd(f*g) ((3 + O(3^4))*x + 1 + 2*3 + O(3^3), 1 + O(3^3), 0) + sage: # needs sage.libs.ntl sage: R. = Zp(3)[] sage: f = 357555295953*x + 257392844 sage: g = 225227399*x - 511940255230575 @@ -1280,6 +1281,7 @@ def _xgcd_univariate_polynomial(self, f, g): We check low precision computations:: + sage: # needs sage.libs.ntl sage: R. = Zp(3,1)[] sage: h = 3*x + 7 sage: i = 4*x + 9 @@ -1316,6 +1318,7 @@ def _gcd_univariate_polynomial(self, f, g): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(27) sage: K. = R[] sage: h = 3*x + a @@ -1426,8 +1429,8 @@ def construction(self, forbid_frac_field=False): The `secure` attribute for relaxed type is included in the functor:: - sage: R = ZpER(5, secure=True) - sage: R.construction() + sage: R = ZpER(5, secure=True) # needs sage.libs.flint + sage: R.construction() # needs sage.libs.flint (Completion[5, prec=(20, 40, True)], Integer Ring) """ from sage.categories.pushout import CompletionFunctor @@ -1604,8 +1607,8 @@ def construction(self, forbid_frac_field=False): The `secure` attribute for relaxed type is included in the functor:: - sage: K = QpER(5, secure=True) - sage: K.construction(forbid_frac_field=True) + sage: K = QpER(5, secure=True) # needs sage.libs.flint + sage: K.construction(forbid_frac_field=True) # needs sage.libs.flint (Completion[5, prec=(20, 40, True)], Rational Field) """ from sage.categories.pushout import FractionField, CompletionFunctor diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py index 9c76ff88362..43556ff4bc6 100644 --- a/src/sage/rings/padics/lattice_precision.py +++ b/src/sage/rings/padics/lattice_precision.py @@ -847,7 +847,7 @@ def _new_element(self, *args, **kwargs): sage: R = ZpLC(2) sage: x = R.random_element() sage: y = R.random_element() - sage: z = x*y # indirect doctest + sage: z = x*y # indirect doctest """ pass @@ -897,19 +897,19 @@ def del_elements(self, threshold=None): sage: x = R(1, 10) sage: prec Precision lattice on 1 object (label: del_elements) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: del x sage: prec Precision lattice on 1 object (label: del_elements) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: prec.del_elements() sage: prec Precision lattice on 0 objects (label: del_elements) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [] """ pass @@ -963,12 +963,12 @@ def precision_lattice(self, elements=None): sage: x = R(1, 10); y = R(1, 5) sage: u = x + y sage: v = x - y - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [ 1024 0 1024 1024] [ 0 32 32 1099511627744] [ 0 0 2097152 0] [ 0 0 0 1099511627776] - sage: prec.precision_lattice([u, v]) + sage: prec.precision_lattice([u, v]) # needs sage.geometry.polyhedron [ 32 2016] [ 0 2048] @@ -980,7 +980,7 @@ def precision_lattice(self, elements=None): sage: x = R(1, 10); y = R(1, 5) sage: u = x + y sage: v = x - y - sage: prec.precision_lattice([x,y,u,v]) + sage: prec.precision_lattice([x,y,u,v]) # needs sage.geometry.polyhedron Traceback (most recent call last): ... PrecisionError: the differential is not surjective @@ -1012,9 +1012,9 @@ def diffused_digits(self, elements=None): sage: u = x + y sage: v = x - y - sage: prec.diffused_digits([x, y]) + sage: prec.diffused_digits([x, y]) # needs sage.geometry.polyhedron 0 - sage: prec.diffused_digits([u, v]) + sage: prec.diffused_digits([u, v]) # needs sage.geometry.polyhedron 6 The elements `u` and `v` are known at absolute precision `O(2^5)`. @@ -1024,14 +1024,14 @@ def diffused_digits(self, elements=None): Here is another example with matrices:: - sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) - sage: N = M^10 + sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) # needs sage.modules + sage: N = M^10 # needs sage.modules The next syntax provides as easy way to select an interesting subset of variables (the selected subset consists of the four entries of the matrix ``N``):: - sage: prec.diffused_digits(N) + sage: prec.diffused_digits(N) # needs sage.geometry.polyhedron sage.modules 17 Note that, in some cases, the number of diffused digits can be @@ -1041,7 +1041,7 @@ def diffused_digits(self, elements=None): sage: prec = R.precision() sage: x = R(1, 10) sage: y = x - sage: prec.diffused_digits([x, y]) + sage: prec.diffused_digits([x, y]) # needs sage.geometry.polyhedron +Infinity """ try: @@ -1081,6 +1081,7 @@ def tracked_elements(self, values=True, dead=True): [WeakProxy#..., WeakProxy#...] + sage: # needs sage.rings.padics sage: u = x + y sage: v = x - y sage: prec.tracked_elements() @@ -1378,8 +1379,8 @@ def history(self, compact=True, separate_reduce=False, timings=True, output_type sage: R = ZpLC(3) sage: prec = R.precision() sage: prec.history_enable() - sage: M = random_matrix(R, 5) - sage: d = M.determinant() + sage: M = random_matrix(R, 5) # needs sage.geometry.polyhedron + sage: d = M.determinant() # needs sage.geometry.polyhedron sage: print(prec.history()) # somewhat random --- 0.004212s oooooooooooooooooooooooooooooooooooo @@ -1503,8 +1504,8 @@ def timings(self, action=None): sage: R = ZpLC(2, label='timings') sage: prec = R.precision() sage: prec.history_enable() - sage: M = random_matrix(R, 5, 5) - sage: N = M^10 + sage: M = random_matrix(R, 5, 5) # needs sage.geometry.polyhedron + sage: N = M^10 # needs sage.geometry.polyhedron sage: prec.timings() # somewhat random {'add': 1.0530245304107666, 'del': 0.24358701705932617, @@ -1808,19 +1809,19 @@ def del_elements(self, threshold=None): sage: x = R(1, 10) sage: prec Precision lattice on 1 object (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: del x sage: prec Precision lattice on 1 object (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: prec.del_elements() sage: prec Precision lattice on 0 objects (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [] """ n = len(self._elements) @@ -2076,27 +2077,27 @@ def precision_lattice(self, elements=None): sage: x = R(1, 10); y = R(1, 5) sage: u = x + y sage: v = x - y - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [ 1024 0 1024 1024] [ 0 32 32 1099511627744] [ 0 0 2097152 0] [ 0 0 0 1099511627776] - sage: prec.precision_lattice([u, v]) + sage: prec.precision_lattice([u, v]) # needs sage.geometry.polyhedron [ 32 2016] [ 0 2048] Here is another example with matrices:: - sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) - sage: N = M^10 - sage: prec.precision_lattice() + sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) # needs sage.modules + sage: N = M^10 # needs sage.modules + sage: prec.precision_lattice() # needs sage.geometry.polyhedron sage.modules 23 x 23 dense matrix over Integer Ring (use the '.str()' method to see the entries) The next syntax provides as easy way to select an interesting subset of variables (the selected subset consists of the four entries of the matrix ``N``):: - sage: prec.precision_lattice(N) + sage: prec.precision_lattice(N) # needs sage.modules [ 2048 512 28160 230400] [ 0 2048 14336 258048] [ 0 0 65536 65536] @@ -2104,7 +2105,7 @@ def precision_lattice(self, elements=None): We can give a list of matrices as well:: - sage: prec.precision_lattice([M, N]) + sage: prec.precision_lattice([M, N]) # needs sage.modules [ 32 0 0 0 226115584 96788480 52174848 82804736] [ 0 32 0 0 52174848 121765888 11829248 28516352] [ 0 0 32 0 96788480 42762240 121765888 199614464] @@ -2408,19 +2409,19 @@ def del_elements(self, threshold=None): sage: x = R(1, 10) sage: prec Precision module on 1 object (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: del x sage: prec Precision module on 1 object (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024] sage: prec.del_elements() sage: prec Precision module on 0 objects (label: delelts) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [] """ # We mark new collected elements for deletion @@ -2676,34 +2677,34 @@ def precision_lattice(self, elements=None): sage: R = ZpLF(2, label='preclattice') sage: prec = R.precision() sage: x = R(1, 10); y = R(1, 5) - sage: prec.precision_lattice() + sage: prec.precision_lattice() # needs sage.geometry.polyhedron [1024 0] [ 0 32] sage: u = x + y sage: v = x - y - sage: prec.precision_lattice([u, v]) + sage: prec.precision_lattice([u, v]) # needs sage.geometry.polyhedron [ 32 2016] [ 0 2048] If the precision module does not project to a lattice, an error is raised. :: - sage: prec.precision_lattice([x, y, u, v]) + sage: prec.precision_lattice([x, y, u, v]) # needs sage.geometry.polyhedron Traceback (most recent call last): ... PrecisionError: the differential is not surjective Here is another example with matrices:: - sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) - sage: N = M^10 + sage: M = matrix(R, 2, 2, [R(3, 5), R(7, 5), R(1, 5), R(11, 1)]) # needs sage.modules + sage: N = M^10 # needs sage.modules The next syntax provides as easy way to select an interesting subset of variables (the selected subset consists of the four entries of the matrix ``N``):: - sage: prec.precision_lattice(N) + sage: prec.precision_lattice(N) # needs sage.geometry.polyhedron sage.modules [ 2048 512 28160 230400] [ 0 2048 14336 258048] [ 0 0 65536 65536] @@ -2852,7 +2853,7 @@ def __repr__(self): sage: from sage.rings.padics.lattice_precision import pAdicLatticeElementWeakProxy sage: R = ZpLF(2, label='proxy_repr') sage: p = R(2) - sage: R.precision()._elements # indirect doctest + sage: R.precision()._elements # indirect doctest [WeakProxy#...] """ @@ -2869,8 +2870,8 @@ def list_of_padics(elements): sage: from sage.rings.padics.lattice_precision import list_of_padics sage: R = ZpLC(2) - sage: M = random_matrix(R, 2, 2) - sage: list_of_padics(M) + sage: M = random_matrix(R, 2, 2) # needs sage.geometry.polyhedron + sage: list_of_padics(M) # needs sage.geometry.polyhedron [WeakProxy#..., WeakProxy#..., WeakProxy#..., diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 5726055d2be..62b8868b012 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -36,15 +36,15 @@ def __init__(self, base, prec, names, element_class, category=None): EXAMPLES:: - sage: R = Zp(5) #indirect doctest + sage: R = Zp(5) # indirect doctest sage: R.precision_cap() 20 In :trac:`14084`, the category framework has been implemented for p-adic rings:: - sage: TestSuite(R).run() + sage: TestSuite(R).run() # needs sage.geometry.polyhedron sage: K = Qp(7) - sage: TestSuite(K).run() + sage: TestSuite(K).run() # needs sage.geometry.polyhedron TESTS:: @@ -228,7 +228,7 @@ def _latex_(self): EXAMPLES:: - sage: latex(Zq(27,names='a')) #indirect doctest + sage: latex(Zq(27,names='a')) #indirect doctest # needs sage.libs.ntl \Bold{Z}_{3^{3}} """ return self._repr_(do_latex=True) @@ -264,18 +264,18 @@ def change(self, **kwds): The following arguments have special behavior: - ``prec`` -- integer. If the precision is increased on an extension ring, - the precision on the base is increased as necessary (respecting ramification). - If the precision is decreased, the precision of the base is unchanged. + the precision on the base is increased as necessary (respecting ramification). + If the precision is decreased, the precision of the base is unchanged. - ``field`` -- bool. If ``True``, switch to a tower of fields via the fraction field. - If False, switch to a tower of rings of integers. + If False, switch to a tower of rings of integers. - ``q`` -- prime power. Replace the initial unramified extension of `\QQ_p` or `\ZZ_p` - with an unramified extension of residue cardinality `q`. - If the initial extension is ramified, add in an unramified extension. + with an unramified extension of residue cardinality `q`. + If the initial extension is ramified, add in an unramified extension. - ``base`` -- ring or field. Use a specific base ring instead of recursively - calling :meth:`change` down the tower. + calling :meth:`change` down the tower. See the :mod:`constructors ` for more details on the meaning of these arguments. @@ -310,6 +310,7 @@ def change(self, **kwds): Changing print mode to 'digits' works for Eisenstein extensions:: + sage: # needs sage.libs.ntl sage: S. = ZZ[] sage: W. = Zp(3).extension(x^4 + 9*x^2 + 3*x - 3) sage: W.print_mode() @@ -319,6 +320,7 @@ def change(self, **kwds): You can change extensions:: + sage: # needs sage.libs.flint sage: K. = QqFP(125, prec=4) sage: K.change(q=64) 2-adic Unramified Extension Field in a defined by x^6 + x^4 + x^3 + x + 1 @@ -351,6 +353,7 @@ def change(self, **kwds): Changing the prime works for extensions:: + sage: # needs sage.libs.ntl sage: x = polygen(ZZ) sage: R. = Zp(5).extension(x^2 + 2) sage: S = R.change(p=7) @@ -364,6 +367,7 @@ def change(self, **kwds): :: + sage: # needs sage.libs.ntl sage: R. = Zq(5^3) sage: S = R.change(prec=50) sage: S.defining_polynomial(exact=True) @@ -382,6 +386,7 @@ def change(self, **kwds): The `secure` attribute for relaxed type is copied:: + sage: # needs sage.libs.flint sage: R = ZpER(5, secure=True); R 5-adic Ring handled with relaxed arithmetics sage: K = R.change(field=True); K @@ -391,6 +396,7 @@ def change(self, **kwds): The `check=False` option works for relaxed type:: + sage: # needs sage.libs.flint sage: R = ZpER(5) ; R 5-adic Ring handled with relaxed arithmetics sage: K = R.change(field=True, check=False) ; K @@ -708,12 +714,13 @@ def absolute_degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_degree() # needs sage.libs.ntl 2 """ return self.absolute_e() * self.absolute_f() @@ -724,12 +731,13 @@ def relative_degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.relative_degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.relative_degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.relative_degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.relative_degree() # needs sage.libs.ntl 2 """ return self.absolute_degree() // self.base_ring().absolute_degree() @@ -742,12 +750,13 @@ def degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.degree() # needs sage.libs.ntl 2 """ if self.base_ring().absolute_degree() == 1: @@ -761,12 +770,13 @@ def absolute_e(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_e() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_e() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_e() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_e() # needs sage.libs.ntl 2 """ # Override this in subclasses (if appropriate) @@ -781,12 +791,13 @@ def absolute_ramification_index(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_ramification_index() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_ramification_index() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_ramification_index() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_ramification_index() # needs sage.libs.ntl 2 """ return self.absolute_e() @@ -797,12 +808,13 @@ def relative_e(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.relative_e() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.relative_e() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.relative_e() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.relative_e() # needs sage.libs.ntl 2 """ return self.absolute_e() // self.base_ring().absolute_e() @@ -813,12 +825,13 @@ def relative_ramification_index(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.relative_ramification_index() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.relative_ramification_index() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.relative_ramification_index() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.relative_ramification_index() # needs sage.libs.ntl 2 """ return self.relative_e() @@ -831,12 +844,13 @@ def e(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.e() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.e() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.e() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.e() # needs sage.libs.ntl 2 """ if self.base_ring().absolute_degree() == 1: @@ -852,12 +866,13 @@ def ramification_index(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.ramification_index() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.ramification_index() # needs sage.libs.ntl 1 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.ramification_index() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.ramification_index() # needs sage.libs.ntl 2 """ return self.e() @@ -869,12 +884,13 @@ def absolute_f(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_f() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_f() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_f() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_f() # needs sage.libs.ntl 1 """ # Override this in subclasses (if appropriate) @@ -890,12 +906,13 @@ def absolute_inertia_degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_inertia_degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_inertia_degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_inertia_degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_inertia_degree() # needs sage.libs.ntl 1 """ return self.absolute_f() @@ -906,12 +923,13 @@ def relative_f(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.relative_f() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.relative_f() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.relative_f() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.relative_f() # needs sage.libs.ntl 1 """ return self.absolute_f() // self.base_ring().absolute_f() @@ -922,12 +940,13 @@ def relative_inertia_degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.relative_inertia_degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.relative_inertia_degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.relative_inertia_degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.relative_inertia_degree() # needs sage.libs.ntl 1 """ return self.relative_f() @@ -940,12 +959,13 @@ def f(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.f() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.f() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.f() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.f() # needs sage.libs.ntl 1 """ if self.base_ring().absolute_degree() == 1: @@ -961,12 +981,13 @@ def inertia_degree(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.inertia_degree() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.inertia_degree() # needs sage.libs.ntl 5 - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.inertia_degree() + sage: R. = QQ[] + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.inertia_degree() # needs sage.libs.ntl 1 """ return self.f() @@ -1027,9 +1048,9 @@ def uniformiser(self): sage: R.uniformiser() 5 + O(5^21) sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2+7) - sage: B.uniformiser() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2+7) # needs sage.libs.ntl + sage: B.uniformiser() # needs sage.libs.ntl t + O(t^21) """ return self.uniformizer() @@ -1048,14 +1069,14 @@ def uniformiser_pow(self, n): def ext(self, *args, **kwds): r""" - Construct an extension of self. See :meth:`extension` for more details. + Construct an extension of ``self``. See :meth:`extension` for more details. EXAMPLES:: sage: A = Zp(7,10) - sage: S. = A[] - sage: B. = A.ext(x^2+7) - sage: B.uniformiser() + sage: S. = A[] # needs sage.libs.ntl + sage: B. = A.ext(x^2 + 7) # needs sage.libs.ntl + sage: B.uniformiser() # needs sage.libs.ntl t + O(t^21) """ return self.extension(*args, **kwds) @@ -1279,7 +1300,7 @@ def _matrix_smith_form(self, M, transformation, integral, exact): TESTS:: sage: A = ZpCR(5, prec=10) - sage: M = zero_matrix(A, 2) + sage: M = zero_matrix(A, 2) # needs sage.geometry.polyhedron sage: M.smith_form(transformation=False) # indirect doctest [0 0] [0 0] @@ -1468,7 +1489,7 @@ def _test_matrix_smith(self, **options): EXAMPLES:: - sage: ZpCA(5, 15)._test_matrix_smith() + sage: ZpCA(5, 15)._test_matrix_smith() # needs sage.geometry.polyhedron """ tester = self._tester(**options) @@ -1562,12 +1583,14 @@ def _matrix_determinant(self, M): O(5^70) O(5^80) + sage: # needs sage.geometry.polyhedron sage: A = random_matrix(Qp(5),4) sage: B = random_matrix(Qp(5),4) sage: (A*B).det() == A.det()*B.det() True sage: A.change_ring(QQ).det() == A.det() True + sage: matrix(Qp(37),[0]).determinant() 0 sage: matrix(Qp(37),[O(37)]).determinant() diff --git a/src/sage/rings/padics/local_generic_element.pyx b/src/sage/rings/padics/local_generic_element.pyx index 6c78114f395..0813de34811 100644 --- a/src/sage/rings/padics/local_generic_element.pyx +++ b/src/sage/rings/padics/local_generic_element.pyx @@ -127,40 +127,39 @@ cdef class LocalGenericElement(CommutativeRingElement): Over unramified extensions:: - sage: R = ZpCA(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) - sage: t.inverse_of_unit() - 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5) + sage: # needs sage.libs.ntl sage: R = ZpCR(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) sage: t.inverse_of_unit() 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5) + sage: R = QpCR(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) + sage: t.inverse_of_unit() + 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5) + sage: # needs sage.libs.flint + sage: R = ZpCA(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) + sage: t.inverse_of_unit() + 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5) sage: R = ZpFM(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) sage: t.inverse_of_unit() 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 - sage: R = ZpFP(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) sage: t.inverse_of_unit() 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 - sage: R = QpCR(3,5); S. = R[]; W. = R.extension( t^2 + 1 ) - sage: t.inverse_of_unit() - 2*t + 2*t*3 + 2*t*3^2 + 2*t*3^3 + 2*t*3^4 + O(3^5) Over Eisenstein extensions:: + sage: # needs sage.libs.ntl sage: R = ZpCA(3,5); S. = R[]; W. = R.extension( t^2 - 3 ) sage: (t - 1).inverse_of_unit() 2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10) - sage: R = ZpCR(3,5); S. = R[]; W. = R.extension( t^2 - 3 ) sage: (t - 1).inverse_of_unit() 2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10) - sage: R = ZpFM(3,5); S. = R[]; W. = R.extension( t^2 - 3 ) sage: (t - 1).inverse_of_unit() 2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 - sage: R = QpCR(3,5); S. = R[]; W. = R.extension( t^2 - 3 ) sage: (t - 1).inverse_of_unit() 2 + 2*t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10) @@ -301,9 +300,10 @@ cdef class LocalGenericElement(CommutativeRingElement): Test that slices also work over eisenstein extensions:: + sage: # needs sage.libs.ntl sage: F = Qp(5) sage: H. = F[] - sage: T. = F.extension(x^2-5) + sage: T. = F.extension(x^2 - 5) sage: a = T(3*t^-2 + 1 + 4*t + 2*t^2) sage: a.slice(0, 1) 1 + O(t) @@ -314,9 +314,10 @@ cdef class LocalGenericElement(CommutativeRingElement): Test that slices also work over unramified extensions:: + sage: # needs sage.libs.ntl sage: F = Qp(5) sage: H. = F[] - sage: T. = F.extension(x^2-2) + sage: T. = F.extension(x^2 - 2) sage: a = T(3*5^-1 + 1 + (3*t + 4)*5^2) sage: a.slice(0, 1) 1 + O(5) @@ -327,9 +328,10 @@ cdef class LocalGenericElement(CommutativeRingElement): Test that slices also work over 2-step extensions (unramified followed by eisenstein):: + sage: # needs sage.libs.ntl sage: F = Qp(5) sage: H. = F[] - sage: T. = F.extension(x^2-3) + sage: T. = F.extension(x^2 - 3) sage: D. = T[] sage: W. = T.extension((4*5^-2 + 2*5^-1 + 4 + (2*t + 2)*5 + 3*t*5^3 + 4*5^4 + 3*5^5 + (2*t + 2)*5^8 + (4*t + 3)*5^9 + 2*t*5^10 + (3*t + 3)*5^11 + (3*t + 1)*5^12 + (3*t + 2)*5^13 + 4*5^14 + (2*t + 4)*5^15 + (4*t + 1)*5^16 + (t + 1)*5^17 + O(5^18))*y^2 + (t + 2*t*5 + t*5^2 + 4*t*5^3 + (2*t + 4)*5^4 + (3*t + 4)*5^5 + (t + 1)*5^6 + t*5^7 + (2*t + 4)*5^8 + 3*5^9 + 2*5^10 + 5^12 + (4*t + 2)*5^13 + 5^14 + 5^15 + 3*t*5^16 + (t + 2)*5^17 + 4*5^18 + (3*t + 1)*5^19 + O(5^20))*y + (2*t + 2)*5^-1 + 3 + 5 + t*5^2 + (4*t + 2)*5^3 + (4*t + 1)*5^4 + (3*t + 4)*5^5 + (4*t + 4)*5^6 + (3*t + 2)*5^7 + (4*t + 4)*5^8 + 3*5^9 + (t + 3)*5^10 + (4*t + 3)*5^11 + 5^12 + (2*t + 2)*5^14 + 4*t*5^15 + (2*t + 2)*5^16 + (4*t + 4)*5^17 + O(5^18)) sage: a = W(3*w^-36 + (2*t + 2)*w^-23) @@ -351,8 +353,8 @@ cdef class LocalGenericElement(CommutativeRingElement): Verify that :trac:`30695` has been fixed:: - sage: F=Qp(3) - sage: a=F(0) + sage: F = Qp(3) + sage: a = F(0) sage: a.slice(0,None) 0 @@ -507,8 +509,9 @@ cdef class LocalGenericElement(CommutativeRingElement): Check that :trac:`23464` has been resolved:: - sage: R. = Qp(7).extension(x^3 - 7) - sage: (pi^93).add_bigoh(-10) + sage: x = polygen(QQ) + sage: R. = Qp(7).extension(x^3 - 7) # needs sage.libs.ntl + sage: (pi^93).add_bigoh(-10) # needs sage.libs.ntl sage.symbolic O(pi^-10) """ @@ -602,7 +605,7 @@ cdef class LocalGenericElement(CommutativeRingElement): False sage: K(1/9).is_padic_unit() False - sage: Qq(3^2,5,names='a')(3).is_padic_unit() + sage: Qq(3^2,5,names='a')(3).is_padic_unit() # needs sage.libs.ntl False """ return self.valuation() == 0 @@ -638,7 +641,7 @@ cdef class LocalGenericElement(CommutativeRingElement): True sage: R(3).is_unit() False - sage: Qp(5,5)(5).is_unit() # Note that 5 is invertible in `QQ_5`, even if it has positive valuation! + sage: Qp(5,5)(5).is_unit() # Note that 5 is invertible in `QQ_5`, even if it has positive valuation! True sage: Qp(5,5)(5).is_padic_unit() False @@ -669,7 +672,7 @@ cdef class LocalGenericElement(CommutativeRingElement): True sage: K(1/9).is_unit() True - sage: Qq(3^2,5,names='a')(3).is_unit() + sage: Qq(3^2,5,names='a')(3).is_unit() # needs sage.libs.ntl True sage: R(0,0).is_unit() False @@ -771,21 +774,22 @@ cdef class LocalGenericElement(CommutativeRingElement): sage: sqrt(R2(4)) 2 + O(2^20) - sage: R. = Zq(2^10, 10) - sage: u = 1 + 8*t - sage: sqrt(u) - 1 + t*2^2 + t^2*2^3 + t^2*2^4 + (t^4 + t^3 + t^2)*2^5 + (t^4 + t^2)*2^6 + (t^5 + t^2)*2^7 + (t^6 + t^5 + t^4 + t^2)*2^8 + O(2^9) + sage: R. = Zq(2^10, 10) # needs sage.libs.ntl + sage: u = 1 + 8*t # needs sage.libs.ntl + sage: sqrt(u) # needs sage.libs.ntl + 1 + t*2^2 + t^2*2^3 + t^2*2^4 + (t^4 + t^3 + t^2)*2^5 + (t^4 + t^2)*2^6 + + (t^5 + t^2)*2^7 + (t^6 + t^5 + t^4 + t^2)*2^8 + O(2^9) sage: R. = Zp(2).extension(x^3 - 2) sage: u = R(1 + a^4 + a^5 + a^7 + a^8, 10); u 1 + a^4 + a^5 + a^7 + a^8 + O(a^10) - sage: v = sqrt(u); v + sage: v = sqrt(u); v # needs sage.libs.ntl 1 + a^2 + a^4 + a^6 + O(a^7) However, observe that the precision increases to its original value when we recompute the square of the square root:: - sage: v^2 + sage: v^2 # needs sage.libs.ntl 1 + a^4 + a^5 + a^7 + a^8 + O(a^10) If the input does not have enough precision in order to determine if @@ -848,9 +852,9 @@ cdef class LocalGenericElement(CommutativeRingElement): EXAMPLES:: sage: Q7 = Qp(7) - sage: R. = Q7[] - sage: F. = Q7.ext(x^3+7*x+7) - sage: z.normalized_valuation() + sage: R. = Q7[] # needs sage.libs.ntl + sage: F. = Q7.ext(x^3+7*x+7) # needs sage.libs.ntl + sage: z.normalized_valuation() # needs sage.libs.ntl 1/3 """ F = self.parent() diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index b535dbb07c5..984482bc39c 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -91,21 +91,21 @@ def gauss_sum(a, p, f, prec=20, factored=False, algorithm='pari', parent=None): In this example, we verify that `g_3(0) = -1`:: sage: from sage.rings.padics.misc import gauss_sum - sage: -gauss_sum(0, 3, 1) # needs sage.rings.padics + sage: -gauss_sum(0, 3, 1) # needs sage.libs.ntl sage.rings.padics 1 + O(pi^40) Next, we verify that `g_5(a) g_5(-a) = 5 (-1)^a`:: sage: from sage.rings.padics.misc import gauss_sum - sage: gauss_sum(2,5,1)^2 - 5 # needs sage.rings.padics + sage: gauss_sum(2,5,1)^2 - 5 # needs sage.libs.ntl O(pi^84) - sage: gauss_sum(1,5,1)*gauss_sum(3,5,1) + 5 # needs sage.rings.padics + sage: gauss_sum(1,5,1)*gauss_sum(3,5,1) + 5 # needs sage.libs.ntl O(pi^84) Finally, we compute a non-trivial value:: sage: from sage.rings.padics.misc import gauss_sum - sage: gauss_sum(2,13,2) # needs sage.rings.padics + sage: gauss_sum(2,13,2) # needs sage.libs.ntl 6*pi^2 + 7*pi^14 + 11*pi^26 + 3*pi^62 + 6*pi^74 + 3*pi^86 + 5*pi^98 + pi^110 + 7*pi^134 + 9*pi^146 + 4*pi^158 + 6*pi^170 + 4*pi^194 + pi^206 + 6*pi^218 + 9*pi^230 + O(pi^242) diff --git a/src/sage/rings/padics/morphism.pyx b/src/sage/rings/padics/morphism.pyx index 73ae1d53471..f1423b12bd3 100644 --- a/src/sage/rings/padics/morphism.pyx +++ b/src/sage/rings/padics/morphism.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.ntl """ Frobenius endomorphisms on p-adic fields """ diff --git a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx index 979f9d54ba5..c5e66ed4002 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics r""" `p`-adic ``ZZ_pX`` CA Element @@ -73,13 +74,15 @@ An Eisenstein extension:: sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f); W 5-adic Eisenstein Extension Ring in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: z = (1+w)^5; z - 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) + 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: y = z >> 1; y - w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) + w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) sage: y.valuation() 4 sage: y.precision_relative() @@ -95,14 +98,17 @@ An Eisenstein extension:: An unramified extension:: + sage: # needs sage.libs.flint sage: g = x^3 + 3*x + 3 sage: A. = R.ext(g) sage: z = (1+a)^5; z - (2*a^2 + 4*a) + (3*a^2 + 3*a + 1)*5 + (4*a^2 + 3*a + 4)*5^2 + (4*a^2 + 4*a + 4)*5^3 + (4*a^2 + 4*a + 4)*5^4 + O(5^5) + (2*a^2 + 4*a) + (3*a^2 + 3*a + 1)*5 + (4*a^2 + 3*a + 4)*5^2 + + (4*a^2 + 4*a + 4)*5^3 + (4*a^2 + 4*a + 4)*5^4 + O(5^5) sage: z - 1 - 5*a - 10*a^2 - 10*a^3 - 5*a^4 - a^5 O(5^5) sage: y = z >> 1; y - (3*a^2 + 3*a + 1) + (4*a^2 + 3*a + 4)*5 + (4*a^2 + 4*a + 4)*5^2 + (4*a^2 + 4*a + 4)*5^3 + O(5^4) + (3*a^2 + 3*a + 1) + (4*a^2 + 3*a + 4)*5 + (4*a^2 + 4*a + 4)*5^2 + + (4*a^2 + 4*a + 4)*5^3 + O(5^4) sage: 1/a (3*a^2 + 4) + (a^2 + 4)*5 + (3*a^2 + 4)*5^2 + (a^2 + 4)*5^3 + (3*a^2 + 4)*5^4 + O(5^5) sage: FFA = A.residue_field() @@ -111,6 +117,7 @@ An unramified extension:: Different printing modes:: + sage: # needs sage.libs.flint sage: R = ZpCA(5, print_mode='digits'); S. = ZZ[]; f = x^5 + 75*x^3 - 15*x^2 + 125*x -5; W. = R.ext(f) sage: z = (1+w)^5; repr(z) '...4110403113210310442221311242000111011201102002023303214332011214403232013144001400444441030421100001' @@ -126,6 +133,7 @@ Different printing modes:: You can get at the underlying ntl representation:: + sage: # needs sage.libs.flint sage: z._ntl_rep() [6 95367431640505 25 95367431640560 5] sage: y._ntl_rep() @@ -215,10 +223,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = (1+w)^5; z # indirect doctest - 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) + sage: z = (1+w)^5; z # indirect doctest + 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: W(R(3,3)) 3 + O(w^15) sage: W(pari('3 + O(5^3)')) @@ -245,9 +254,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): Check that :trac:`13612` has been fixed:: + sage: # needs sage.libs.flint sage: R = ZpCA(3) sage: S. = R[] - sage: W. = R.extension(a^2+1) + sage: W. = R.extension(a^2 + 1) sage: W(W.residue_field().zero()) O(3) @@ -436,9 +446,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(0,6); z # indirect doctest + sage: z = W(0,6); z # indirect doctest O(w^6) sage: z.valuation() 6 @@ -460,10 +470,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = W(0) - sage: z._is_inexact_zero() #indirect doctest + sage: z._is_inexact_zero() # indirect doctest True sage: z = W(0,6) sage: z._is_inexact_zero() @@ -479,10 +489,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: F = W.fraction_field() - sage: z = F(1+w); z # indirect doctest + sage: z = F(1+w); z # indirect doctest 1 + w + O(w^25) sage: W.precision_cap() 25 @@ -502,9 +512,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, absprec = 13) # indirect doctest + sage: W(70, absprec = 13) # indirect doctest 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13) sage: W(70, absprec = 4) O(w^4) @@ -530,9 +540,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, relprec = 3) # indirect doctest + sage: W(70, relprec = 3) # indirect doctest 4*w^5 + 3*w^7 + O(w^8) sage: W(70, absprec = 4, relprec = 2) O(w^4) @@ -565,9 +575,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(70/3, 14); z # indirect doctest + sage: z = W(70/3, 14); z # indirect doctest 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + O(w^14) sage: z * 3 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + w^13 + O(w^14) @@ -595,9 +605,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(70/3, 14); z # indirect doctest + sage: z = W(70/3, 14); z # indirect doctest 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + O(w^14) sage: z * 3 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + w^13 + O(w^14) @@ -630,9 +640,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(QQ(4), 23) # indirect doctest + sage: W(QQ(4), 23) # indirect doctest 4 + O(w^23) """ cdef mpz_t tmp_m @@ -656,9 +666,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16]), absprec = 14); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16]), absprec = 14); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + 4*w^13 + O(w^14) sage: z._ntl_rep() [4 1 16] @@ -680,9 +690,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16]), relprec = 12); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16]), relprec = 12); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + O(w^12) sage: z._ntl_rep() [4 1 16] @@ -703,9 +713,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + O(w^10) sage: z._ntl_rep() [4 1 16] @@ -733,9 +743,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec = 8, relprec = 12); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec = 8, relprec = 12); z # indirect doctest 4 + w + w^2 + 3*w^7 + O(w^8) sage: z._ntl_rep() [4 1 16] @@ -785,9 +795,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, 13) # indirect doctest + sage: W(70, 13) # indirect doctest 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13) """ if absprec < 0: @@ -826,9 +836,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, relprec = 3) # indirect doctest + sage: W(70, relprec=3) # indirect doctest 4*w^5 + 3*w^7 + O(w^8) """ if absprec <= ordp + relprec: @@ -845,9 +855,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w^5 + 1 # indirect doctest + sage: w^5 + 1 # indirect doctest 1 + w^5 + O(w^25) """ cdef pAdicZZpXCAElement ans = pAdicZZpXCAElement.__new__(pAdicZZpXCAElement) @@ -868,7 +878,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = Qp(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - 1 sage: loads(dumps(z)) == z @@ -894,9 +904,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w == 1 # indirect doctest + sage: w == 1 # indirect doctest False sage: y = 1 + w + O(w^7) sage: z = 1 + w + w^10 + O(w^13) @@ -921,10 +931,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: y = ~z; y # indirect doctest + sage: y = ~z; y # indirect doctest 1 + 4*w^5 + 4*w^6 + 3*w^7 + w^8 + 2*w^10 + w^11 + w^12 + 2*w^14 + 3*w^16 + 3*w^17 + 4*w^18 + 4*w^19 + 2*w^20 + 2*w^21 + 4*w^22 + 3*w^23 + 3*w^24 + O(w^25) sage: y.parent() 5-adic Eisenstein Extension Field in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 @@ -942,11 +952,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5; z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: y = z.to_fraction_field(); y #indirect doctest + sage: y = z.to_fraction_field(); y #indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: y.parent() 5-adic Eisenstein Extension Field in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 @@ -970,12 +980,12 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 + O(w^25) sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) @@ -991,12 +1001,12 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 + O(w^25) sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) @@ -1022,10 +1032,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5,print_mode='digits') sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: for m in range(26): repr(z >> m) # indirect doctest + sage: for m in range(26): repr(z >> m) # indirect doctest '...4001400444441030421100001' '...400140044444103042110000' '...40014004444410304211000' @@ -1089,12 +1099,12 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z >> (6) # indirect doctest + sage: z >> (6) # indirect doctest 1 + 2*w + 4*w^2 + 3*w^4 + w^6 + 4*w^7 + 4*w^8 + 4*w^9 + 4*w^10 + 4*w^11 + 4*w^14 + w^15 + 4*w^18 + O(w^19) sage: z >> (-4) w^4 + w^9 + w^10 + 2*w^11 + 4*w^12 + 3*w^14 + w^16 + 4*w^17 + 4*w^18 + 4*w^19 + 4*w^20 + 4*w^21 + 4*w^24 + O(w^25) @@ -1118,11 +1128,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5; z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: -z # indirect doctest + sage: -z # indirect doctest 4 + 3*w^5 + 4*w^6 + w^7 + w^8 + w^9 + w^10 + w^11 + 2*w^12 + 4*w^13 + 4*w^15 + 3*w^16 + w^17 + 2*w^18 + 3*w^19 + 2*w^21 + 4*w^23 + 4*w^24 + O(w^25) sage: y = z + (-z); y O(w^25) @@ -1196,9 +1206,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (1 + w)^5 # indirect doctest + sage: (1 + w)^5 # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: (1 + w + O(w^19))^5 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + O(w^24) @@ -1385,9 +1395,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) - 69 # indirect doctest + sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) - 69 # indirect doctest 1 + O(w^13) sage: -69 + (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) 1 + O(w^13) @@ -1424,11 +1434,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a - b #indirect doctest + sage: a - b # indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) sage: W(218) 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) @@ -1466,11 +1476,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b #indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 + O(w^25) sage: a * 0 O(w^25) @@ -1519,9 +1529,9 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(14) / W(125) #indirect doctest + sage: W(14) / W(125) # indirect doctest 4*w^-15 + w^-13 + 3*w^-11 + 2*w^-10 + 3*w^-9 + 4*w^-8 + 4*w^-7 + 3*w^-6 + O(w^-5) sage: 1 / w w^-1 + O(w^23) @@ -1547,7 +1557,8 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): EXAMPLES:: - sage: ZZ(ZqCA(125,names='a')(-1)) #indirect doctest + sage: # needs sage.libs.flint + sage: ZZ(ZqCA(125,names='a')(-1)) # indirect doctest 95367431640624 sage: R = ZpCA(5); S. = ZZ[]; f = x^5 + 25*x^3 - 5; W. = R.ext(f) sage: ZZ(W(-1)) @@ -1580,7 +1591,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: b = W(45, 17); b 4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) @@ -1607,7 +1618,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: O(w^189).is_zero() True @@ -1651,10 +1662,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566); b = W(209) - sage: c = a + b; c._ntl_rep() # indirect doctest + sage: c = a + b; c._ntl_rep() # indirect doctest [775] """ if self.absprec == 0: @@ -1673,7 +1684,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566); b = W(209) sage: c = a + b; c._ntl_rep_abs() @@ -1697,7 +1708,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): EXAMPLES:: sage: R. = ZZ[] - sage: W. = ZpCA(5).extension(x^3-5) + sage: W. = ZpCA(5).extension(x^3 - 5) sage: (1 + w + O(w^11))._polynomial_list() [1 + O(5^4), 1 + O(5^4)] sage: (1 + w + O(w^11))._polynomial_list(pad=True) @@ -1753,10 +1764,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566) - sage: a._const_term_test() #indirect doctest + sage: a._const_term_test() #indirect doctest 566 """ return ZZ_pX_ConstTerm(self.value) @@ -1773,7 +1784,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(47); b = W(47 + 25) sage: a.is_equal_to(b) @@ -1806,11 +1817,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(345, 17); a 4*w^5 + 3*w^7 + w^9 + 3*w^10 + 2*w^11 + 4*w^12 + w^13 + 2*w^14 + 2*w^15 + O(w^17) - sage: b = a.lift_to_precision(19); b # indirect doctest + sage: b = a.lift_to_precision(19); b # indirect doctest 4*w^5 + 3*w^7 + w^9 + 3*w^10 + 2*w^11 + 4*w^12 + w^13 + 2*w^14 + 2*w^15 + w^17 + 2*w^18 + O(w^19) sage: c = a.lift_to_precision(24); c 4*w^5 + 3*w^7 + w^9 + 3*w^10 + 2*w^11 + 4*w^12 + w^13 + 2*w^14 + 2*w^15 + w^17 + 2*w^18 + 4*w^19 + 4*w^20 + 2*w^21 + 4*w^23 + O(w^24) @@ -1876,7 +1887,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) @@ -1887,6 +1898,8 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: w^10 - w^12 + 2*w^14 + w^15 + 2*w^16 + w^18 + O(w^19) w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) sage: g = x^3 + 3*x + 3 + + sage: # needs sage.libs.flint sage: A. = R.ext(g) sage: y = 75 + 45*a + 1200*a^2; y 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 + O(5^5) @@ -1957,10 +1970,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (3+w)^7 - sage: a.matrix_mod_pn() + sage: a.matrix_mod_pn() # needs sage.geometry.polyhedron [2757 333 1068 725 2510] [ 50 1507 483 318 725] [ 500 50 3007 2358 318] @@ -2047,7 +2060,10 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: E = a.teichmuller_expansion(); E 5-adic expansion of a + O(5^4) (teichmuller) sage: list(E) - [a + (2*a^3 + 2*a^2 + 3*a + 4)*5 + (4*a^3 + 3*a^2 + 3*a + 2)*5^2 + (4*a^2 + 2*a + 2)*5^3 + O(5^4), (3*a^3 + 3*a^2 + 2*a + 1) + (a^3 + 4*a^2 + 1)*5 + (a^2 + 4*a + 4)*5^2 + O(5^3), (4*a^3 + 2*a^2 + a + 1) + (2*a^3 + 2*a^2 + 2*a + 4)*5 + O(5^2), (a^3 + a^2 + a + 4) + O(5)] + [a + (2*a^3 + 2*a^2 + 3*a + 4)*5 + (4*a^3 + 3*a^2 + 3*a + 2)*5^2 + (4*a^2 + 2*a + 2)*5^3 + O(5^4), + (3*a^3 + 3*a^2 + 2*a + 1) + (a^3 + 4*a^2 + 1)*5 + (a^2 + 4*a + 4)*5^2 + O(5^3), + (4*a^3 + 2*a^2 + a + 1) + (2*a^3 + 2*a^2 + 2*a + 4)*5 + O(5^2), + (a^3 + a^2 + a + 4) + O(5)] sage: sum([c * 5^i for i, c in enumerate(E)]) a + O(5^4) sage: all(c^625 == c for c in E) @@ -2057,14 +2073,16 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: f = x^3 - 98*x + 7 sage: W. = ZpCA(7,3).ext(f) sage: b = (1+w)^5; L = b.teichmuller_expansion(); L - [1 + O(w^9), 5 + 5*w^3 + w^6 + 4*w^7 + O(w^8), 3 + 3*w^3 + O(w^7), 3 + 3*w^3 + O(w^6), O(w^5), 4 + 5*w^3 + O(w^4), 3 + O(w^3), 6 + O(w^2), 6 + O(w)] + [1 + O(w^9), 5 + 5*w^3 + w^6 + 4*w^7 + O(w^8), 3 + 3*w^3 + O(w^7), + 3 + 3*w^3 + O(w^6), O(w^5), 4 + 5*w^3 + O(w^4), 3 + O(w^3), 6 + O(w^2), 6 + O(w)] sage: sum([w^i*L[i] for i in range(9)]) == b True sage: all(L[i]^(7^3) == L[i] for i in range(9)) True sage: L = W(3).teichmuller_expansion(); L - [3 + 3*w^3 + w^7 + O(w^9), O(w^8), O(w^7), 4 + 5*w^3 + O(w^6), O(w^5), O(w^4), 3 + O(w^3), 6 + O(w^2)] + [3 + 3*w^3 + w^7 + O(w^9), O(w^8), O(w^7), 4 + 5*w^3 + O(w^6), O(w^5), + O(w^4), 3 + O(w^3), 6 + O(w^2)] sage: sum([w^i*L[i] for i in range(len(L))]) 3 + O(w^9) """ @@ -2120,12 +2138,13 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: S. = ZZ[] sage: f = x^5 + 33*x^3 - 121*x^2 - 77 sage: W. = R.ext(f) - sage: y = W.teichmuller(3, 19); y #indirect doctest + sage: y = W.teichmuller(3, 19); y # indirect doctest 3 + 9*w^10 + 3*w^13 + 3*w^15 + 9*w^16 + 3*w^17 + w^18 + O(w^19) - sage: y^11 == y True sage: g = x^3 + 9*x^2 + 7 + + sage: # needs sage.libs.flint sage: A. = R.ext(g) sage: b = A.teichmuller(1 + 2*a - a^2); b (10*a^2 + 2*a + 1) + (4*a^2 + 7)*11 + (5*a^2 + a + 3)*11^2 + (a^2 + 9*a + 6)*11^3 + (7*a^2 + 2*a + 3)*11^4 + O(11^5) @@ -2165,7 +2184,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -2192,7 +2211,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -2223,11 +2242,11 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) - sage: a.valuation() # indirect doctest + sage: a.valuation() # indirect doctest 10 sage: a.precision_absolute() 19 @@ -2260,7 +2279,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -2296,7 +2315,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) @@ -2307,6 +2326,8 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: w^10 - w^12 + 2*w^14 + w^15 + 2*w^16 + w^18 + O(w^19) w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) sage: g = x^3 + 3*x + 3 + + sage: # needs sage.libs.flint sage: A. = R.ext(g) sage: y = 75 + 45*a + 1200*a^2; y 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 + O(5^5) @@ -2328,7 +2349,7 @@ def make_ZZpXCAElement(parent, value, absprec, version): sage: from sage.rings.padics.padic_ZZ_pX_CA_element import make_ZZpXCAElement sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: make_ZZpXCAElement(W, ntl.ZZ_pX([3,2,4],5^3),13,0) 3 + 2*w + 4*w^2 + O(w^13) diff --git a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx index e3bd45e9037..f5e06abcba0 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics r""" `p`-adic ``ZZ_pX`` CR Element @@ -91,7 +92,7 @@ An Eisenstein extension:: sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f); W 5-adic Eisenstein Extension Ring in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: z = (1+w)^5; z @@ -251,9 +252,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = (1+w)^5; z # indirect doctest + sage: z = (1+w)^5; z # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: W(pari('3 + O(5^3)')) 3 + O(w^15) @@ -277,13 +278,13 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(3) sage: S. = R[] - sage: W. = R.extension(a^2+1) + sage: W. = R.extension(a^2 + 1) sage: W(W.residue_field().zero()) O(3) sage: K = Qp(3) sage: S. = K[] - sage: L. = K.extension(a^2+1) + sage: L. = K.extension(a^2 + 1) sage: L(L.residue_field().zero()) O(3) @@ -553,9 +554,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(0,6); z # indirect doctest + sage: z = W(0,6); z # indirect doctest O(w^6) sage: z.valuation() 6 @@ -589,9 +590,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = R(0); z # indirect doctest + sage: z = R(0); z # indirect doctest 0 sage: z.valuation() +Infinity @@ -605,7 +606,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(89, 3) sage: S. = R[] sage: W. = R.ext(x^34 - 2*89*x^5 + 89) - sage: z = R(0); z # indirect doctest + sage: z = R(0); z # indirect doctest 0 sage: z.valuation() +Infinity @@ -625,7 +626,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Qp(3,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = W(0) sage: z._is_exact_zero() @@ -660,7 +661,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(7,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = W(0) sage: z._is_inexact_zero() @@ -695,10 +696,10 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: F = W.fraction_field() - sage: z = F(1+w); z # indirect doctest + sage: z = F(1 + w); z # indirect doctest 1 + w + O(w^25) TESTS:: @@ -708,9 +709,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: f = x^51 - 34 sage: W. = R.ext(f) sage: F = W.fraction_field() - sage: z = F(1+w); z # indirect doctest + sage: z = F(1 + w); z # indirect doctest 1 + w + O(w^1530) - sage: z = F(w+w^2,relprec=0); z + sage: z = F(w + w^2, relprec=0); z O(w) """ self.ordp = ordp @@ -726,11 +727,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, relprec = 8) # indirect doctest + sage: W(70, relprec=8) # indirect doctest 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13) - sage: W(70, relprec = 0) + sage: W(70, relprec=0) O(w^5) TESTS:: @@ -739,9 +740,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: S. = R[] sage: f = x^169 - 13 sage: W. = R.ext(f) - sage: a = W(65, relprec = 8); a.valuation() # indirect doctest + sage: a = W(65, relprec=8); a.valuation() # indirect doctest 169 - sage: W(65, relprec = 0) + sage: W(65, relprec=0) O(w^169) """ if mpz_sgn(x) == 0: @@ -773,11 +774,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, 8) # indirect doctest + sage: W(70, 8) # indirect doctest 4*w^5 + 3*w^7 + O(w^8) - sage: W(70, absprec = 4) + sage: W(70, absprec=4) O(w^4) TESTS:: @@ -786,9 +787,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: S. = R[] sage: f = x^49 + 7*x^21 - 14 sage: W. = R.ext(f) - sage: W(70, 100) # indirect doctest + sage: W(70, 100) # indirect doctest 5*w^49 + 6*w^70 + 3*w^91 + O(w^100) - sage: W(70, absprec = 4) + sage: W(70, absprec=4) O(w^4) """ if mpz_sgn(x) == 0: @@ -822,9 +823,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(70/3, relprec = 9); z # indirect doctest + sage: z = W(70/3, relprec=9); z # indirect doctest 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + O(w^14) sage: z * 3 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + w^13 + O(w^14) @@ -835,7 +836,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): w^-10 + w^-8 + 4*w^-6 + w^-3 + 4*w^-2 + 3*w^-1 + 3 + 4*w + w^3 + 4*w^4 + w^5 + 4*w^6 + 2*w^7 + 3*w^8 + 4*w^9 + 3*w^10 + 4*w^11 + w^12 + O(w^15) sage: y * 700 3 + O(w^25) - sage: W(70/3, relprec = 0) + sage: W(70/3, relprec=0) O(w^5) sage: c = F(5^-1 + O(5^2)); c w^-5 + 3*w^-3 + 2*w^3 + 4*w^5 + 4*w^6 + 3*w^7 + w^9 + O(w^10) @@ -848,7 +849,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: S. = R[] sage: f = x^3 + 1331 * x^2 - 11 * x + 11 sage: W. = R.ext(f) - sage: z = W(77/3, relprec = 11); repr(z)[3:] + sage: z = W(77/3, relprec=11); repr(z)[3:] '304107A2555000' sage: repr(z*3)[3:] '56698765444000' @@ -884,9 +885,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(70/3, 14); z # indirect doctest + sage: z = W(70/3, 14); z # indirect doctest 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + O(w^14) sage: z * 3 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + w^13 + O(w^14) @@ -897,7 +898,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): w^-10 + w^-8 + 4*w^-6 + w^-3 + O(w^-2) sage: y * 700 3 + O(w^8) - sage: W(70/3, absprec = 4) + sage: W(70/3, absprec=4) O(w^4) """ if mpq_sgn(x) == 0: @@ -920,9 +921,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(7000/3, 23); z # indirect doctest + sage: z = W(7000/3, 23); z # indirect doctest 2*w^15 + 2*w^17 + 3*w^19 + w^22 + O(w^23) """ cdef long num_ordp, den_ordp @@ -947,9 +948,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(QQ(0), 23) # indirect doctest + sage: W(QQ(0), 23) # indirect doctest O(w^23) sage: W(QQ(0)) 0 @@ -980,17 +981,17 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16]), relprec = 14); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16]), relprec=14); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + 4*w^13 + O(w^14) sage: z._ntl_rep() [4 1 16] - sage: z = W(ntl.ZZX([5^40,5^42,3*5^41]), relprec = 14); z + sage: z = W(ntl.ZZX([5^40,5^42,3*5^41]), relprec=14); z w^200 + 4*w^207 + 4*w^209 + w^210 + 2*w^211 + 2*w^213 + O(w^214) sage: W(5)^40 + w*W(5)^42 + w^2 * W(3) * W(5)^41 w^200 + 4*w^207 + 4*w^209 + w^210 + 2*w^211 + 2*w^213 + 2*w^215 + w^217 + 2*w^218 + w^220 + w^221 + w^222 + 3*w^224 + O(w^225) - sage: z = W(ntl.ZZX([5^40,5^42,3*5^41]), relprec = 0); z + sage: z = W(ntl.ZZX([5^40,5^42,3*5^41]), relprec=0); z O(w^200) """ if ZZX_IsZero(poly): @@ -1018,9 +1019,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16]), 12); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16]), 12); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + O(w^12) sage: z._ntl_rep() [4 1 16] @@ -1052,9 +1053,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16]), 12); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16]), 12); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + O(w^12) """ cdef long i = 0 @@ -1099,15 +1100,15 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + O(w^10) sage: z._ntl_rep() [4 1 16] sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^44)); z w^200 + 4*w^207 + 4*w^209 + w^210 + 2*w^211 + 2*w^213 + 2*w^215 + w^217 + 2*w^218 + O(w^220) - sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^44), relprec = 0); z + sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^44), relprec=0); z O(w^200) """ cdef long ctx_prec = -1 @@ -1138,15 +1139,15 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec = 8, relprec = 12); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec=8, relprec=12); z # indirect doctest 4 + w + w^2 + 3*w^7 + O(w^8) sage: z._ntl_rep() [4 1 16] sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^50), 220); z w^200 + 4*w^207 + 4*w^209 + w^210 + 2*w^211 + 2*w^213 + 2*w^215 + w^217 + 2*w^218 + O(w^220) - sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^44), absprec = 77); z + sage: z = W(ntl.ZZ_pX([5^40,5^42,3*5^41], 5^44), absprec=77); z O(w^77) """ cdef long ctx_prec @@ -1172,9 +1173,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec = 8, relprec = 12); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec=8, relprec=12); z # indirect doctest 4 + w + w^2 + 3*w^7 + O(w^8) """ cdef long val = 0, index = 0 @@ -1193,9 +1194,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec = 8, relprec = 12); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2), absprec=8, relprec=12); z # indirect doctest 4 + w + w^2 + 3*w^7 + O(w^8) """ # We've set self.relprec to what is actually the absolute precision. @@ -1229,9 +1230,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, relprec = 8) # indirect doctest + sage: W(70, relprec=8) # indirect doctest 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13) """ if self.relprec == relprec: @@ -1271,9 +1272,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70, 8) # indirect doctest + sage: W(70, 8) # indirect doctest 4*w^5 + 3*w^7 + O(w^8) """ self.relprec = absprec - self.ordp @@ -1303,13 +1304,13 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1+w)^5 sage: y = z - 1 sage: y._ntl_rep_unnormalized() [5 3005 25 3060 5] - sage: y # indirect doctest + sage: y # indirect doctest w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: y._ntl_rep_unnormalized() [41 26 152 49 535] @@ -1370,11 +1371,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1+w)^5 sage: y = z - 1 - sage: y # indirect doctest + sage: y # indirect doctest w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) """ if self.relprec == 0: @@ -1408,9 +1409,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Qp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(3/25, relprec = 6); z + sage: z = W(3/25, relprec=6); z 3*w^-10 + 3*w^-8 + 2*w^-6 + O(w^-4) sage: z * 25 3 + O(w^6) @@ -1485,9 +1486,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Qp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w^5 + 1 # indirect doctest + sage: w^5 + 1 # indirect doctest 1 + w^5 + O(w^25) """ cdef pAdicZZpXCRElement ans = pAdicZZpXCRElement.__new__(pAdicZZpXCRElement) @@ -1511,7 +1512,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Qp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - 1 sage: loads(dumps(z)) == z @@ -1539,9 +1540,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Qp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w == 1 # indirect doctest + sage: w == 1 # indirect doctest False sage: y = 1 + w + O(w^7) sage: z = 1 + w + w^10 + O(w^13) @@ -1567,10 +1568,10 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: y = ~z; y # indirect doctest + sage: y = ~z; y # indirect doctest 1 + 4*w^5 + 4*w^6 + 3*w^7 + w^8 + 2*w^10 + w^11 + w^12 + 2*w^14 + 3*w^16 + 3*w^17 + 4*w^18 + 4*w^19 + 2*w^20 + 2*w^21 + 4*w^22 + 3*w^23 + 3*w^24 + O(w^25) sage: y.parent() 5-adic Eisenstein Extension Field in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 @@ -1606,12 +1607,12 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 + 4*w^25 + 3*w^27 + w^29 + 4*w^30 + 4*w^31 + 4*w^32 + 4*w^33 + 4*w^34 + 4*w^37 + w^38 + 4*w^41 + O(w^42) sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) @@ -1640,12 +1641,12 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 + 4*w^25 + 3*w^27 + w^29 + 4*w^30 + 4*w^31 + 4*w^32 + 4*w^33 + 4*w^34 + 4*w^37 + w^38 + 4*w^41 + O(w^42) sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + O(w^24) @@ -1674,10 +1675,10 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5,print_mode='digits') sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: for m in range(26): repr(z >> m) # indirect doctest + sage: for m in range(26): repr(z >> m) # indirect doctest '...4001400444441030421100001' '...400140044444103042110000' '...40014004444410304211000' @@ -1739,12 +1740,12 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: z >> (6) # indirect doctest + sage: z >> (6) # indirect doctest 1 + 2*w + 4*w^2 + 3*w^4 + w^6 + 4*w^7 + 4*w^8 + 4*w^9 + 4*w^10 + 4*w^11 + 4*w^14 + w^15 + 4*w^18 + O(w^19) sage: z >> (-4) w^4 + w^9 + w^10 + 2*w^11 + 4*w^12 + 3*w^14 + w^16 + 4*w^17 + 4*w^18 + 4*w^19 + 4*w^20 + 4*w^21 + 4*w^24 + w^25 + 4*w^28 + O(w^29) @@ -1775,11 +1776,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5; z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: -z # indirect doctest + sage: -z # indirect doctest 4 + 3*w^5 + 4*w^6 + w^7 + w^8 + w^9 + w^10 + w^11 + 2*w^12 + 4*w^13 + 4*w^15 + 3*w^16 + w^17 + 2*w^18 + 3*w^19 + 2*w^21 + 4*w^23 + 4*w^24 + O(w^25) sage: y = z + (-z); y O(w^25) @@ -1859,9 +1860,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (1 + w)^5 # indirect doctest + sage: (1 + w)^5 # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: (1 + w)^-5 1 + 4*w^5 + 4*w^6 + 3*w^7 + w^8 + 2*w^10 + w^11 + w^12 + 2*w^14 + 3*w^16 + 3*w^17 + 4*w^18 + 4*w^19 + 2*w^20 + 2*w^21 + 4*w^22 + 3*w^23 + 3*w^24 + O(w^25) @@ -1896,7 +1897,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: type(W(0)) @@ -1909,7 +1910,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: type(W(0)^0) == type(W(0)) True @@ -2056,9 +2057,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) - 69 # indirect doctest + sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) - 69 # indirect doctest 1 + O(w^13) sage: -69 + (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + O(w^13)) 1 + O(w^13) @@ -2173,11 +2174,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a - b #indirect doctest + sage: a - b #indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) sage: W(218) 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) @@ -2199,11 +2200,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b #indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 + O(w^25) sage: a * 0 0 @@ -2253,9 +2254,9 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(14) / W(125) #indirect doctest + sage: W(14) / W(125) # indirect doctest 4*w^-15 + w^-13 + 3*w^-11 + 2*w^-10 + 3*w^-9 + 4*w^-8 + 4*w^-7 + 3*w^-6 + 2*w^-5 + 4*w^-4 + 3*w^-3 + 2*w^-2 + 4*w^-1 + 2 + w^2 + w^4 + 4*w^5 + w^6 + w^7 + 3*w^9 + O(w^10) sage: 1 / w w^-1 + O(w^24) @@ -2283,7 +2284,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: b = W(45, 17); b 4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) @@ -2304,7 +2305,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): EXAMPLES:: - sage: ZZ(ZqCR(125,names='a')(-1)) #indirect doctest + sage: ZZ(ZqCR(125,names='a')(-1)) # indirect doctest 95367431640624 sage: R = Zp(5); S. = ZZ[]; f = x^5 + 25*x^3 - 5; W. = R.ext(f) sage: ZZ(W(-1)) @@ -2317,7 +2318,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): Traceback (most recent call last): ... ValueError: this element not well approximated by an integer - sage: ZZ(W(5)) # todo: this should be different... + sage: ZZ(W(5)) # todo: this should be different... 381469726562505 """ cdef Integer ans @@ -2350,7 +2351,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: O(w^189).is_zero() True @@ -2400,7 +2401,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566); b = W(209) sage: c = a + b; c._ntl_rep_unnormalized() @@ -2426,7 +2427,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566); b = W(209) sage: c = a + b; c._ntl_rep() @@ -2448,7 +2449,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566); b = W(209) sage: c = a + b; c._ntl_rep_abs() @@ -2517,7 +2518,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): EXAMPLES:: sage: R. = ZZ[] - sage: W. = Qp(5).extension(x^3-5) + sage: W. = Qp(5).extension(x^3 - 5) sage: (1 + w + O(w^11))._polynomial_list() [1 + O(5^4), 1 + O(5^4)] sage: (1 + w + O(w^11))._polynomial_list(pad=True) @@ -2530,7 +2531,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): [] sage: W(O(w^7))._polynomial_list(pad=True) [O(5^3), O(5^2), O(5^2)] - sage: T. = Qp(5).extension(x^2-5) + sage: T. = Qp(5).extension(x^2 - 5) sage: T(1/5)._polynomial_list() [5^-1 + O(5^19)] sage: T(a^-800)._polynomial_list() @@ -2587,10 +2588,10 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566) - sage: a._const_term_test() #indirect doctest + sage: a._const_term_test() # indirect doctest 566 """ return ZZ_pX_ConstTerm((self).unit) @@ -2606,7 +2607,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(47); b = W(47 + 25) sage: a.is_equal_to(b) @@ -2649,7 +2650,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(345, 17); a 4*w^5 + 3*w^7 + w^9 + 3*w^10 + 2*w^11 + 4*w^12 + w^13 + 2*w^14 + 2*w^15 + O(w^17) @@ -2748,7 +2749,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) @@ -2845,7 +2846,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (3+w)^7 sage: a.matrix_mod_pn() @@ -3091,7 +3092,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -3126,7 +3127,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -3158,11 +3159,11 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) - sage: a.valuation() # indirect doctest + sage: a.valuation() # indirect doctest 10 sage: a.precision_absolute() 19 @@ -3182,7 +3183,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75, 19); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + O(w^19) @@ -3201,7 +3202,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: z = (1+w)^5 sage: y = z - 1 - sage: t=y-y + sage: t = y - y sage: t.unit_part() O(w^0) """ @@ -3231,7 +3232,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) @@ -3263,11 +3264,11 @@ def make_ZZpXCRElement(parent, unit, ordp, relprec, version): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) - sage: loads(dumps(y)) #indirect doctest + sage: loads(dumps(y)) # indirect doctest w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) sage: from sage.rings.padics.padic_ZZ_pX_CR_element import make_ZZpXCRElement diff --git a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx index 9dec3affd53..bcc90685701 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics r""" `p`-adic ``ZZ_pX`` FM Element @@ -65,7 +66,7 @@ An Eisenstein extension:: sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f); W 5-adic Eisenstein Extension Ring in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: z = (1+w)^5; z @@ -83,6 +84,7 @@ An Eisenstein extension:: An unramified extension:: + sage: # needs sage.libs.flint sage: g = x^3 + 3*x + 3 sage: A. = R.ext(g) sage: z = (1+a)^5; z @@ -96,6 +98,7 @@ An unramified extension:: Different printing modes:: + sage: # needs sage.libs.flint sage: R = ZpFM(5, print_mode='digits'); S. = R[]; f = x^5 + 75*x^3 - 15*x^2 + 125*x -5; W. = R.ext(f) sage: z = (1+w)^5; repr(z) '...4110403113210310442221311242000111011201102002023303214332011214403232013144001400444441030421100001' @@ -173,9 +176,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = (1+w)^5; z # indirect doctest + sage: z = (1+w)^5; z # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 TESTS: @@ -187,9 +190,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): Check that :trac:`13612` has been fixed:: + sage: # needs sage.libs.flint sage: R = ZpFM(3) sage: S. = R[] - sage: W. = R.extension(a^2+1) + sage: W. = R.extension(a^2 + 1) sage: W(W.residue_field().zero()) 0 @@ -286,9 +290,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(70) # indirect doctest + sage: W(70) # indirect doctest 4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11 + w^13 + 3*w^16 + w^17 + w^18 + 4*w^20 + 4*w^21 + w^22 + 2*w^23 """ self.prime_pow.restore_top_context() @@ -310,9 +314,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(70/3); z # indirect doctest + sage: z = W(70/3); z # indirect doctest 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + 3*w^15 + 2*w^16 + 3*w^17 + w^18 + 3*w^19 + 3*w^20 + 2*w^21 + 2*w^22 + 3*w^23 + 4*w^24 sage: z * 3 @@ -344,9 +348,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + 4*w^13 + 3*w^14 + 2*w^15 + w^16 + 3*w^18 + 2*w^19 + 4*w^20 + 4*w^21 + 2*w^22 + 2*w^23 + 4*w^24 sage: z._ntl_rep() @@ -365,9 +369,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZX([4,1,16])); z # indirect doctest + sage: z = W(ntl.ZZX([4,1,16])); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + 2*w^11 + 4*w^13 + 3*w^14 + 2*w^15 + w^16 + 3*w^18 + 2*w^19 + 4*w^20 + 4*w^21 + 2*w^22 + 2*w^23 + 4*w^24 sage: z._ntl_rep() @@ -384,7 +388,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = W(0) sage: z._is_inexact_zero() @@ -404,10 +408,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - 1 - sage: loads(dumps(z)) == z #indirect doctest + sage: loads(dumps(z)) == z #indirect doctest True """ self.prime_pow.restore_top_context() @@ -424,9 +428,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w^5 + 1 # indirect doctest + sage: w^5 + 1 # indirect doctest 1 + w^5 """ self.prime_pow.restore_top_context() @@ -443,9 +447,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: w == 1 # indirect doctest + sage: w == 1 # indirect doctest False sage: y = 1 + w sage: z = 1 + w + w^27 @@ -480,10 +484,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: y = ~z; y # indirect doctest + sage: y = ~z; y # indirect doctest 1 + 4*w^5 + 4*w^6 + 3*w^7 + w^8 + 2*w^10 + w^11 + w^12 + 2*w^14 + 3*w^16 + 3*w^17 + 4*w^18 + 4*w^19 + 2*w^20 + 2*w^21 + 4*w^22 + 3*w^23 + 3*w^24 sage: y.parent() @@ -515,12 +519,12 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + 4*w^24 @@ -547,12 +551,12 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 - sage: z << 17 # indirect doctest + sage: z << 17 # indirect doctest w^17 + w^22 + w^23 + 2*w^24 sage: z << (-1) w^4 + w^5 + 2*w^6 + 4*w^7 + 3*w^9 + w^11 + 4*w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^19 + w^20 + 4*w^23 + 4*w^24 @@ -578,10 +582,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5,print_mode='digits') sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - sage: for m in range(26): '...' + repr(z >> m)[len(repr(z >> m)) - 25 + m:] # indirect doctest + sage: for m in range(26): '...' + repr(z >> m)[len(repr(z >> m)) - 25 + m:] # indirect doctest '...4001400444441030421100001' '...400140044444103042110000' '...40014004444410304211000' @@ -639,13 +643,13 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 sage: z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 - sage: z >> (6) # indirect doctest + sage: z >> (6) # indirect doctest 1 + 2*w + 4*w^2 + 3*w^4 + w^6 + 4*w^7 + 4*w^8 + 4*w^9 + 4*w^10 + 4*w^11 + 4*w^14 + w^15 + 4*w^18 + 4*w^19 + 2*w^20 + 3*w^21 + 2*w^22 + 3*w^24 sage: z >> (-4) @@ -668,12 +672,12 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5; z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 - sage: -z # indirect doctest + sage: -z # indirect doctest 4 + 3*w^5 + 4*w^6 + w^7 + w^8 + w^9 + w^10 + w^11 + 2*w^12 + 4*w^13 + 4*w^15 + 3*w^16 + w^17 + 2*w^18 + 3*w^19 + 2*w^21 + 4*w^23 + 4*w^24 sage: y = z + (-z); y @@ -693,9 +697,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (1 + w)^5 # indirect doctest + sage: (1 + w)^5 # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 sage: (1 + w)^-5 @@ -708,7 +712,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: type(W(0)) @@ -721,7 +725,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: type(W(0)^0) == type(W(0)) True @@ -759,9 +763,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11) - 69 # indirect doctest + sage: (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11) - 69 # indirect doctest 1 + 4*w^13 + 2*w^16 + 4*w^17 + 3*w^18 + 4*w^20 + 4*w^22 sage: -69 + (4*w^5 + 3*w^7 + w^9 + 2*w^10 + 2*w^11) 1 + 4*w^13 + 2*w^16 + 4*w^17 + 3*w^18 + 4*w^20 + 4*w^22 @@ -778,11 +782,11 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b #indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 sage: a * 0 @@ -802,11 +806,11 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a - b #indirect doctest + sage: a - b #indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 sage: W(218) @@ -827,9 +831,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(125) / W(14) #indirect doctest + sage: W(125) / W(14) #indirect doctest 4*w^15 + 4*w^17 + w^19 + w^20 + w^23 + 2*w^24 sage: 1 / W(14) == ~W(14) True @@ -867,7 +871,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: b = W(45); b 4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 @@ -892,7 +896,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: O(w^189).is_zero() True @@ -938,8 +942,8 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): EXAMPLES:: - sage: R=Zp(7,4,'fixed-mod') - sage: a = R(1+7+7^2) + sage: R = Zp(7,4,'fixed-mod') + sage: a = R(1 + 7 + 7^2) sage: a.add_bigoh(1) 1 """ @@ -975,7 +979,8 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): EXAMPLES:: - sage: ZZ(ZqFM(125,names='a')(-1)) #indirect doctest + sage: # needs sage.libs.flint + sage: ZZ(ZqFM(125,names='a')(-1)) # indirect doctest 95367431640624 sage: R = ZpFM(5); S. = ZZ[]; f = x^5 + 25*x^3 - 5; W. = R.ext(f) sage: ZZ(W(-1)) @@ -1015,10 +1020,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (3+w)^7 - sage: a.matrix_mod_pn() + sage: a.matrix_mod_pn() # needs sage.geometry.polyhedron [2757 333 1068 725 2510] [ 50 1507 483 318 725] [ 500 50 3007 2358 318] @@ -1082,7 +1087,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: ((1+2*w)^5).norm() 1 + 5^2 + O(5^5) @@ -1114,7 +1119,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 @@ -1148,7 +1153,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = 72 + 4*w^2; b = 17 + 9*w + w^3; c = a + b sage: c._ntl_rep() @@ -1173,7 +1178,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): EXAMPLES:: sage: R. = ZZ[] - sage: W. = ZpFM(5).extension(x^3-5) + sage: W. = ZpFM(5).extension(x^3 - 5) sage: (1 + w)._polynomial_list() [1, 1] sage: (1 + w + O(w^11))._polynomial_list(pad=True) @@ -1221,10 +1226,10 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566) - sage: a._const_term_test() #indirect doctest + sage: a._const_term_test() # indirect doctest 566 """ return ZZ_pX_ConstTerm(self.value) @@ -1241,7 +1246,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(47); b = W(47 + 25) sage: a.is_equal_to(b) @@ -1268,7 +1273,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: w.lift_to_precision(10000) w @@ -1314,7 +1319,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 @@ -1325,6 +1330,8 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: w^10 - w^12 + 2*w^14 + w^15 + 2*w^16 + w^18 + 2*w^19 + w^20 + w^21 - w^22 - w^23 + 2*w^24 w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 sage: g = x^3 + 3*x + 3 + + sage: # needs sage.libs.flint sage: A. = R.ext(g) sage: y = 75 + 45*a + 1200*a^2; y 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 @@ -1397,6 +1404,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFM(5^4,4) sage: E = a.teichmuller_expansion(); E 5-adic expansion of a (teichmuller) @@ -1488,13 +1496,15 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: y = W.teichmuller(3); y #indirect doctest + sage: y = W.teichmuller(3); y # indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + 3*w^15 + 2*w^16 + 3*w^17 + w^18 + 3*w^19 + 3*w^20 + 2*w^21 + 2*w^22 + 3*w^23 + 4*w^24 sage: y^5 == y True + + sage: # needs sage.libs.flint sage: g = x^3 + 3*x + 3 sage: A. = R.ext(g) sage: b = A.teichmuller(1 + 2*a - a^2); b @@ -1546,7 +1556,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + 3*w^19 + 2*w^21 + 3*w^22 + 3*w^23 @@ -1573,7 +1583,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + 3*w^19 + 2*w^21 + 3*w^22 + 3*w^23 @@ -1607,7 +1617,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + 3*w^19 + 2*w^21 + 3*w^22 + 3*w^23 @@ -1637,7 +1647,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(75); a 3*w^10 + 2*w^12 + w^14 + w^16 + w^17 + 3*w^18 + 3*w^19 + 2*w^21 + 3*w^22 + 3*w^23 @@ -1691,23 +1701,25 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 - sage: (y>>9).expansion() #indirect doctest + sage: (y>>9).expansion() #indirect doctest [0, 1, 0, 4, 0, 2, 1, 2, 4, 1, 0, 1, 2, 3, 1, 1, 4, 1, 2, 4, 1, 0, 0, 3] - sage: (y>>9).expansion(lift_mode='smallest') #indirect doctest + sage: (y>>9).expansion(lift_mode='smallest') #indirect doctest [0, 1, 0, -1, 0, 2, 1, 2, 0, 1, 2, 1, 1, -1, -1, 2, -2, 0, -2, -2, -2, 0, -2, -2, 2] sage: w^10 - w^12 + 2*w^14 + w^15 + 2*w^16 + w^18 + 2*w^19 + w^20 + w^21 - w^22 - w^23 + 2*w^24 w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 sage: g = x^3 + 3*x + 3 + + sage: # needs sage.libs.flint sage: A. = R.ext(g) sage: y = 75 + 45*a + 1200*a^2; y 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 - sage: list(y.expansion()) #indirect doctest + sage: list(y.expansion()) #indirect doctest [[], [0, 4], [3, 1, 3], [0, 0, 4], [0, 0, 1]] - sage: list(y.expansion(lift_mode='smallest')) #indirect doctest + sage: list(y.expansion(lift_mode='smallest')) #indirect doctest [[], [0, -1], [-2, 2, -2], [1], [0, 0, 2]] sage: 5*((-2*5 + 25) + (-1 + 2*5)*a + (-2*5 + 2*125)*a^2) 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 @@ -1724,10 +1736,10 @@ def make_ZZpXFMElement(parent, f): sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - 1 - sage: loads(dumps(z)) == z # indirect doctest + sage: loads(dumps(z)) == z # indirect doctest True """ return pAdicZZpXFMElement(parent, f) diff --git a/src/sage/rings/padics/padic_ZZ_pX_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_element.pyx index b0beaa85617..c49fa926d0f 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics r""" `p`-adic ``ZZ_pX Element`` @@ -60,7 +61,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: A = Zp(next_prime(50000),10) sage: S. = A[] - sage: B. = A.ext(x^2+next_prime(50000)) #indirect doctest + sage: B. = A.ext(x^2 + next_prime(50000)) # indirect doctest """ self.prime_pow = parent.prime_pow pAdicExtElement.__init__(self, parent) @@ -81,7 +82,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpFM(5,5) sage: S. = ZZ[] sage: W. = R.ext(x^5 + 25*x^3 - 15*x - 5) - sage: W([1,2,3,4]) #indirect doctest + sage: W([1,2,3,4]) # indirect doctest 1 + 2*w + 3*w^2 + 4*w^3 sage: W([5,10,15,20]) w^5 + 4*w^6 + w^7 + w^8 + 2*w^9 + 4*w^10 + 2*w^11 + 3*w^13 + 2*w^15 + w^16 + 2*w^17 + 2*w^18 + w^19 + 4*w^20 + w^21 + 4*w^22 + 4*w^23 + 2*w^24 @@ -113,7 +114,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = Zp(5,5) sage: S. = ZZ[] sage: W. = R.ext(x^5 + 25*x^3 - 15*x - 5) - sage: W([1,2,3,4]) #indirect doctest + sage: W([1,2,3,4]) # indirect doctest 1 + 2*w + 3*w^2 + 4*w^3 + O(w^25) sage: W([5,10,15,20], relprec=16) w^5 + 4*w^6 + w^7 + w^8 + 2*w^9 + 4*w^10 + 2*w^11 + 3*w^13 + 2*w^15 + w^16 + 2*w^17 + 2*w^18 + w^19 + 4*w^20 + O(w^21) @@ -145,7 +146,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: W. = R.ext(x^5 + 25*x^3 - 15*x - 5) sage: W([1,2,3,4]) 1 + 2*w + 3*w^2 + 4*w^3 + O(w^25) - sage: W([5,10,15,20], absprec=16) #indirect doctest + sage: W([5,10,15,20], absprec=16) # indirect doctest w^5 + 4*w^6 + w^7 + w^8 + 2*w^9 + 4*w^10 + 2*w^11 + 3*w^13 + 2*w^15 + O(w^16) """ @@ -180,12 +181,12 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: W. = R.ext(x^5 + 25*x^3 - 15*x - 5) sage: W([1,2,3,4]) 1 + 2*w + 3*w^2 + 4*w^3 + O(w^25) - sage: W([5,10,15,20], absprec=16) #indirect doctest + sage: W([5,10,15,20], absprec=16) # indirect doctest w^5 + 4*w^6 + w^7 + w^8 + 2*w^9 + 4*w^10 + 2*w^11 + 3*w^13 + 2*w^15 + O(w^16) - sage: T. = Qp(5).extension(x^2-5) + sage: T. = Qp(5).extension(x^2 - 5) sage: T([5^-2], absprec=-1) a^-4 + O(a^-1) - sage: G. = Qp(5).extension(x^2-5) + sage: G. = Qp(5).extension(x^2 - 5) sage: G(a^-41) g^-41 + O(g^-2) """ @@ -215,9 +216,9 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest + sage: z = W(ntl.ZZ_pX([4,1,16],5^2)); z # indirect doctest 4 + w + w^2 + 3*w^7 + w^9 + O(w^10) """ cdef ZZ_c leftover @@ -268,11 +269,11 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) - sage: y._ext_p_list(True) #indirect doctest + sage: y._ext_p_list(True) # indirect doctest [1, 0, 4, 0, 2, 1, 2, 4, 1] sage: y._ext_p_list(False) [1, 0, -1, 0, 2, 1, 2, 0, 1] @@ -374,7 +375,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: ((1+2*w)^5).norm() 1 + 5^2 + O(5^5) @@ -385,19 +386,19 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: ((1+2*w)^5).norm() + sage: ((1+2*w)^5).norm() # needs sage.geometry.polyhedron 1 + 5^2 + O(5^5) - sage: ((1+2*w)).norm()^5 + sage: ((1+2*w)).norm()^5 # needs sage.geometry.polyhedron 1 + 5^2 + O(5^5) sage: R = ZpFM(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: ((1+2*w)^5).norm() + sage: ((1+2*w)^5).norm() # needs sage.geometry.polyhedron 1 + 5^2 - sage: ((1+2*w)).norm()^5 + sage: ((1+2*w)).norm()^5 # needs sage.geometry.polyhedron 1 + 5^2 Check that :trac:`11586` has been resolved:: @@ -446,7 +447,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 @@ -461,27 +462,27 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpCA(5,5) sage: S. = ZZ[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 - sage: a.trace() + sage: a.trace() # needs sage.geometry.polyhedron 3*5 + 2*5^2 + 3*5^3 + 2*5^4 + O(5^5) - sage: a.trace() + b.trace() + sage: a.trace() + b.trace() # needs sage.geometry.polyhedron 4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5) - sage: (a+b).trace() + sage: (a+b).trace() # needs sage.geometry.polyhedron 4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5) sage: R = ZpFM(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 - sage: a.trace() + sage: a.trace() # needs sage.geometry.polyhedron 3*5 + 2*5^2 + 3*5^3 + 2*5^4 - sage: a.trace() + b.trace() + sage: a.trace() + b.trace() # needs sage.geometry.polyhedron 4*5 + 5^2 + 5^3 + 2*5^4 - sage: (a+b).trace() + sage: (a+b).trace() # needs sage.geometry.polyhedron 4*5 + 5^2 + 5^3 + 2*5^4 TESTS: @@ -519,7 +520,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): EXAMPLES:: - sage: QQ(Qq(125,names='a')(-1/5)) #indirect doctest + sage: QQ(Qq(125,names='a')(-1/5)) # indirect doctest -1/5 """ if self.valuation() < 0: @@ -536,7 +537,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: R = ZpCR(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: w._prime_pow() PowComputer_ext for 5, with polynomial [3120 125 3110 75 0 1] @@ -551,12 +552,12 @@ cdef class pAdicZZpXElement(pAdicExtElement): Check that :trac:`13647` has been fixed:: + sage: # needs sage.libs.flint sage: K = ZpCA(3) sage: R. = K[] sage: L. = K.extension(u^2 + 1) sage: L(R.gen()) u + O(3^20) - sage: K = ZpFM(3) sage: R. = K[] sage: L. = K.extension(u^2 + 1) @@ -821,7 +822,7 @@ def _test_get_val_prec(R, a): TESTS:: - sage: _test_get_val_prec(Zq(25,names='a',implementation="NTL"), 0) #indirect doctest + sage: _test_get_val_prec(Zq(25,names='a',implementation="NTL"), 0) # indirect doctest (340282366920938463463374607431768211457, 340282366920938463463374607431768211457, 2) sage: _test_get_val_prec(Zq(25,names='a',implementation="NTL"), ntl_ZZ(0)) (340282366920938463463374607431768211457, 340282366920938463463374607431768211457, 2) diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index 6fb5f464a7f..b049cb6ea4c 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -40,7 +40,7 @@ def __init__(self, p, prec, print_mode, names, element_class): TESTS:: - sage: R = Zp(5) #indirect doctest + sage: R = Zp(5) #indirect doctest """ if self.is_relaxed(): from sage.rings.padics.pow_computer_flint import PowComputer_flint @@ -92,21 +92,21 @@ def _repr_(self, do_latex=False): EXAMPLES:: - sage: K = Zp(17); K #indirect doctest + sage: K = Zp(17); K #indirect doctest 17-adic Ring with capped relative precision 20 sage: latex(K) \Bold{Z}_{17} - sage: K = ZpCA(17); K #indirect doctest + sage: K = ZpCA(17); K #indirect doctest 17-adic Ring with capped absolute precision 20 sage: latex(K) \Bold{Z}_{17} - sage: K = ZpFP(17); K #indirect doctest + sage: K = ZpFP(17); K #indirect doctest 17-adic Ring with floating precision 20 sage: latex(K) \Bold{Z}_{17} sage: K = ZpFM(7); K 7-adic Ring of fixed modulus 7^20 - sage: latex(K) #indirect doctest + sage: latex(K) #indirect doctest \Bold{Z}_{7} sage: K = ZpLF(2); K # indirect doctest doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. @@ -114,11 +114,11 @@ def _repr_(self, do_latex=False): 2-adic Ring with lattice-float precision sage: latex(K) \Bold{Z}_{2} - sage: K = Qp(17); K #indirect doctest + sage: K = Qp(17); K #indirect doctest 17-adic Field with capped relative precision 20 sage: latex(K) \Bold{Q}_{17} - sage: K = QpFP(17); K #indirect doctest + sage: K = QpFP(17); K #indirect doctest 17-adic Field with floating precision 20 sage: latex(K) \Bold{Q}_{17} diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py index 1c47b0083c2..32c3630a552 100644 --- a/src/sage/rings/padics/padic_base_leaves.py +++ b/src/sage/rings/padics/padic_base_leaves.py @@ -163,17 +163,17 @@ class names.:: sage: R = Qp(5, 15, print_mode='bars', print_sep='&') sage: repr(R(2777))[3:] '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2' - sage: TestSuite(R).run() + sage: TestSuite(R).run() # needs sage.geometry.polyhedron sage: R = Zp(5, 15, print_mode='bars', print_sep='&') sage: repr(R(2777))[3:] '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2' - sage: TestSuite(R).run() + sage: TestSuite(R).run() # needs sage.geometry.polyhedron sage: R = ZpCA(5, 15, print_mode='bars', print_sep='&') sage: repr(R(2777))[3:] '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2' - sage: TestSuite(R).run() + sage: TestSuite(R).run() # needs sage.geometry.polyhedron """ @@ -225,27 +225,28 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpCR(next_prime(10^60)) #indirect doctest + sage: R = ZpCR(next_prime(10^60)) #indirect doctest sage: type(R) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = ZpCR(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpCR(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^3)]) - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)]) sage: R = ZpCR(3, 2) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpCR(next_prime(10^60)) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^3)], max_runs = 2^5, skip='_test_log') # long time - sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time + ....: max_runs=2^5, skip='_test_log') + sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) # long time """ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement) @@ -256,7 +257,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = Zp(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 + O(17^20) sage: K.has_coerce_map_from(ZZ) True @@ -304,6 +305,7 @@ def _convert_map_from_(self, R): from sage.rings.padics.padic_generic import ResidueLiftingMap return ResidueLiftingMap._create_(R, self) + class pAdicRingCappedAbsolute(pAdicRingBaseGeneric, pAdicCappedAbsoluteRingGeneric): r""" An implementation of the `p`-adic integers with capped absolute precision. @@ -321,26 +323,27 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpCA(next_prime(10^60)) #indirect doctest + sage: R = ZpCA(next_prime(10^60)) #indirect doctest sage: type(R) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = ZpCA(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpCA(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^3)]) - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)]) sage: R = ZpCA(3, 2) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpCA(next_prime(10^60)) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^3)], max_runs = 2^5, skip='_test_log') # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time + ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement) @@ -352,7 +355,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = ZpCA(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 + O(17^20) sage: K.has_coerce_map_from(ZZ) True @@ -420,26 +423,27 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpFP(next_prime(10^60)) #indirect doctest + sage: R = ZpFP(next_prime(10^60)) #indirect doctest sage: type(R) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = ZpFP(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpFP(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^3)]) - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)]) sage: R = ZpFP(3, 2) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpFP(next_prime(10^60)) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^3)], max_runs = 2^5, skip='_test_log') # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time + ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement) @@ -451,7 +455,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = ZpFP(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 sage: K.has_coerce_map_from(ZZ) True @@ -513,27 +517,28 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpFM(next_prime(10^60)) #indirect doctest + sage: R = ZpFM(next_prime(10^60)) #indirect doctest sage: type(R) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = ZpFM(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpFM(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^3)]) - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)]) sage: R = ZpFM(3, 2) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = ZpFM(next_prime(10^60)) sage: TestSuite(R).run(skip='_test_log') - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^4)], max_runs = 2^6, skip='_test_log') # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^4)], # long time + ....: max_runs=2^6, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) Fraction fields work after :trac:`23510`:: @@ -553,7 +558,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = ZpFM(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 #indirect doctest 2 sage: K.has_coerce_map_from(ZZ) True @@ -607,8 +612,8 @@ class pAdicFieldCappedRelative(pAdicFieldBaseGeneric, pAdicCappedRelativeFieldGe EXAMPLES:: - sage: K = Qp(17, 1000000) #indirect doctest - sage: K = Qp(101) #indirect doctest + sage: K = Qp(17, 1000000) #indirect doctest + sage: K = Qp(101) #indirect doctest """ @@ -625,28 +630,33 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: K = Qp(next_prime(10^60)) # indirect doctest + sage: K = Qp(next_prime(10^60)) # indirect doctest sage: type(K) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = Qp(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = Qp(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time, needs sage.geometry.polyhedron + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = Qp(3, 2) - sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^9)], skip="_test_metric_function") # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^9)], # long time, needs sage.geometry.polyhedron + ....: skip="_test_metric_function") sage: R._test_metric_function(elements=[R.random_element() for i in range(3^3)]) sage: R = Qp(next_prime(10^60)) - sage: TestSuite(R).run(skip='_test_log') - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^3)], max_runs = 2^5, skip='_test_log') # long time + sage: TestSuite(R).run(skip='_test_log') # needs sage.geometry.polyhedron + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time, needs sage.geometry.polyhedron + ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement) @@ -658,7 +668,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = Qp(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 + O(17^20) sage: K.has_coerce_map_from(ZZ) True @@ -751,27 +761,28 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = QpFP(next_prime(10^60)) #indirect doctest + sage: R = QpFP(next_prime(10^60)) #indirect doctest sage: type(R) TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = QpFP(2) sage: TestSuite(R).run() - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^10)], max_runs = 2^12, skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time + ....: max_runs=2^12, skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = QpFP(3, 1) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^3)]) - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)]) sage: R = QpFP(3, 2) - sage: TestSuite(R).run(elements = [R.random_element() for i in range(3^6)], skip='_test_metric_function') # long time - sage: R._test_metric_function(elements = [R.random_element() for i in range(2^3)]) # long time - + sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time + ....: skip='_test_metric_function') + sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time sage: R = QpFP(next_prime(10^60)) sage: TestSuite(R).run(skip='_test_log') - sage: TestSuite(R).run(elements = [R.random_element() for i in range(2^3)], max_runs = 2^5, skip='_test_log') # long time + sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time + ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement) @@ -783,7 +794,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = QpFP(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 #indirect doctest 2 sage: K.has_coerce_map_from(ZZ) True @@ -857,14 +868,14 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric): EXAMPLES:: - sage: R = ZpLC(next_prime(10^60)) # indirect doctest + sage: R = ZpLC(next_prime(10^60)) # indirect doctest doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. See https://github.com/sagemath/sage/issues/23505 for details. sage: type(R) - sage: R = ZpLC(2, label='init') # indirect doctest + sage: R = ZpLC(2, label='init') # indirect doctest sage: R 2-adic Ring with lattice-cap precision (label: init) """ @@ -875,7 +886,7 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None): TESTS: sage: R = ZpLC(7, label='init') - sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time + sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time """ # We need to set the subtype first, so that # pAdicRingBaseGeneric.__init__ can work @@ -988,14 +999,14 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric): EXAMPLES:: - sage: R = QpLC(next_prime(10^60)) # indirect doctest + sage: R = QpLC(next_prime(10^60)) # indirect doctest doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. See https://github.com/sagemath/sage/issues/23505 for details. sage: type(R) - sage: R = QpLC(2,label='init') # indirect doctest + sage: R = QpLC(2,label='init') # indirect doctest sage: R 2-adic Field with lattice-cap precision (label: init) """ @@ -1006,7 +1017,7 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None): TESTS:: sage: R = QpLC(7, label='init') - sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time + sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time """ # We need to set the subtype first, so that # pAdicFieldBaseGeneric.__init__ can work @@ -1120,8 +1131,8 @@ class pAdicRingRelaxed(pAdicRelaxedGeneric, pAdicRingBaseGeneric): EXAMPLES:: - sage: R = ZpER(5) # indirect doctest - sage: type(R) + sage: R = ZpER(5) # indirect doctest # needs sage.libs.flint + sage: type(R) # needs sage.libs.flint """ def __init__(self, p, prec, print_mode, names): @@ -1130,6 +1141,7 @@ def __init__(self, p, prec, print_mode, names): TESTS:: + sage: # needs sage.libs.flint sage: R = ZpER(7) sage: TestSuite(R).run(skip=['_test_log', '_test_matrix_smith']) sage: R = ZpER(7, secure=True) @@ -1157,8 +1169,8 @@ class pAdicFieldRelaxed(pAdicRelaxedGeneric, pAdicFieldBaseGeneric): EXAMPLES:: - sage: R = QpER(5) # indirect doctest - sage: type(R) + sage: R = QpER(5) # indirect doctest # needs sage.libs.flint + sage: type(R) # needs sage.libs.flint """ def __init__(self, p, prec, print_mode, names): @@ -1167,6 +1179,7 @@ def __init__(self, p, prec, print_mode, names): TESTS:: + sage: # needs sage.libs.flint sage: K = QpER(7) sage: TestSuite(K).run(skip=['_test_log', '_test_matrix_smith']) sage: K = QpER(7, secure=True) diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pyx b/src/sage/rings/padics/padic_capped_absolute_element.pyx index 69d5b474f20..f869e6381a3 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pyx +++ b/src/sage/rings/padics/padic_capped_absolute_element.pyx @@ -103,7 +103,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): TESTS:: - sage: ZpCA(3,3)(1/4).lift() # indirect doctest + sage: ZpCA(3,3)(1/4).lift() # indirect doctest 7 """ cdef Integer ans = Integer.__new__(Integer) @@ -117,9 +117,9 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: sage: R = ZpCA(5) - sage: pari(R(1777)) #indirect doctest + sage: pari(R(1777)) #indirect doctest # needs sage.libs.pari 2 + 5^2 + 4*5^3 + 2*5^4 + O(5^20) - sage: pari(R(0,0)) + sage: pari(R(0,0)) # needs sage.libs.pari O(5^0) """ return self._to_gen() @@ -130,11 +130,11 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: - sage: R = ZpCA(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = ZpCA(5, 10); a = R(17); pari(a) #indirect doctest 2 + 3*5 + O(5^10) - sage: pari(R(0,5)) + sage: pari(R(0,5)) # needs sage.libs.pari O(5^5) - sage: pari(R(0,5)).debug() + sage: pari(R(0,5)).debug() # needs sage.libs.pari [&=...] PADIC(lg=5):... (precp=0,valp=5):... ... ... ... p : [&=...] INT(lg=3):... (+,lgefint=3):... ... p^l : [&=...] INT(lg=3):... (+,lgefint=3):... ... @@ -477,7 +477,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: - sage: R. = Zq(7^2,5) + sage: R. = Zq(7^2,5) # needs sage.libs.ntl sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_capped_relative_element.pyx b/src/sage/rings/padics/padic_capped_relative_element.pyx index f09708db2c7..c835e0ce785 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pyx +++ b/src/sage/rings/padics/padic_capped_relative_element.pyx @@ -126,16 +126,16 @@ cdef class pAdicCappedRelativeElement(CRElement): Construct from Pari objects:: sage: R = Zp(5) - sage: x = pari(123123) ; R(x) + sage: x = pari(123123) ; R(x) # needs sage.libs.pari 3 + 4*5 + 4*5^2 + 4*5^3 + 5^4 + 4*5^5 + 2*5^6 + 5^7 + O(5^20) sage: R(pari(R(5252))) 2 + 2*5^3 + 3*5^4 + 5^5 + O(5^20) sage: R = Zp(5,prec=5) sage: R(pari(-1)) 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5) - sage: pari(R(-1)) + sage: pari(R(-1)) # needs sage.libs.pari 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 sage: R(pari(R(0,5))) O(5^5) @@ -201,11 +201,11 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R = Zp(17, 10); a = ~R(14); pari(a) #indirect doctest + sage: R = Zp(17, 10); a = ~R(14); pari(a) #indirect doctest 11 + 3*17 + 17^2 + 6*17^3 + 13*17^4 + 15*17^5 + 10*17^6 + 3*17^7 + 17^8 + 6*17^9 + O(17^10) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 - sage: pari(R(0,5)) + sage: pari(R(0,5)) # needs sage.libs.pari O(17^5) """ return self._to_gen() @@ -216,13 +216,13 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R = Zp(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = Zp(5, 10); a = R(17); pari(a) #indirect doctest 2 + 3*5 + O(5^10) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 - sage: pari(R(0,5)) + sage: pari(R(0,5)) # needs sage.libs.pari O(5^5) - sage: pari(R(0,5)).debug() + sage: pari(R(0,5)).debug() # needs sage.libs.pari [&=...] PADIC(lg=5):... (precp=0,valp=5):... ... ... ... p : [&=...] INT(lg=3):... (+,lgefint=3):... ... p^l : [&=...] INT(lg=3):... (+,lgefint=3):... ... @@ -535,7 +535,7 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R. = Zq(7^2,5) + sage: R. = Zq(7^2,5) # needs sage.libs.ntl sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_ext_element.pyx b/src/sage/rings/padics/padic_ext_element.pyx index 94a7d93c727..10076df92e2 100644 --- a/src/sage/rings/padics/padic_ext_element.pyx +++ b/src/sage/rings/padics/padic_ext_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics r""" `p`-adic Extension Element @@ -280,7 +281,7 @@ cdef class pAdicExtElement(pAdicGenericElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566) sage: a._const_term_test() @@ -320,7 +321,7 @@ cdef class pAdicExtElement(pAdicGenericElement): sage: R = Zp(5,5) sage: S. = R[] - sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 + sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: y = W(775, 19); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + O(w^19) @@ -442,6 +443,7 @@ cdef class pAdicExtElement(pAdicGenericElement): Unramified case:: + sage: # needs sage.libs.flint sage: R = ZpCA(3,5) sage: S. = R[] sage: W. = R.extension(a^2 + 9*a + 1) @@ -466,6 +468,7 @@ cdef class pAdicExtElement(pAdicGenericElement): TESTS:: + sage: # needs sage.libs.flint sage: K = Qp(3,5) sage: S. = R[] sage: W. = R.extension(a^2 + 9*a + 1) @@ -474,6 +477,7 @@ cdef class pAdicExtElement(pAdicGenericElement): ... ValueError: element must have non-negative valuation in order to compute residue + sage: # needs sage.libs.flint sage: R = ZpFM(3,5) sage: S. = R[] sage: W. = R.extension(a^2 + 3) diff --git a/src/sage/rings/padics/padic_extension_generic.py b/src/sage/rings/padics/padic_extension_generic.py index 88027e19439..073e628042d 100644 --- a/src/sage/rings/padics/padic_extension_generic.py +++ b/src/sage/rings/padics/padic_extension_generic.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.ntl """ `p`-adic Extension Generic @@ -49,7 +50,7 @@ def __init__(self, poly, prec, print_mode, names, element_class): sage: R = Zp(5,5) sage: S. = R[] sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 - sage: W. = R.ext(f) #indirect doctest + sage: W. = R.ext(f) #indirect doctest """ #type checking done in factory self._given_poly = poly @@ -72,7 +73,7 @@ def _coerce_map_from_(self, R): sage: R = Zp(5); S. = ZZ[]; f = x^5 + 25*x - 5; W. = R.ext(f) sage: L = W.fraction_field() - sage: w + L(w) #indirect doctest + sage: w + L(w) #indirect doctest 2*w + O(w^101) sage: w + R(5,2) w + w^5 + O(w^10) @@ -141,7 +142,7 @@ def _repr_(self, do_latex=False): '\\Bold{Z}_{7^{3}}' sage: x = polygen(ZZ, 'x') sage: R2. = R.ext(x^2 + 7) - sage: R2 #indirect doctest + sage: R2 #indirect doctest 7-adic Eisenstein Extension Ring in t defined by x^2 + 7 sage: R2._latex_() '\\Bold{Z}_{7}[t]' @@ -155,7 +156,7 @@ def _repr_(self, do_latex=False): sage: K1._latex_() '\\Bold{Q}_{7^{3}}' sage: K2. = K.ext(x^2+7) - sage: K2 #indirect doctest + sage: K2 #indirect doctest 7-adic Eisenstein Extension Field in t defined by x^2 + 7 sage: K2._latex_() '\\Bold{Q}_{7}[t]' @@ -734,7 +735,7 @@ class MapFreeModuleToOneStep(pAdicModuleIsomorphism): sage: K. = Qq(125) sage: V, fr, to = K.free_module() - sage: TestSuite(fr).run(skip=['_test_nonzero_equal']) # skipped since Qq(125) doesn't have dimension() + sage: TestSuite(fr).run(skip=['_test_nonzero_equal']) # skipped since Qq(125) doesn't have dimension() """ def _call_(self, x): """ @@ -795,7 +796,7 @@ class MapFreeModuleToTwoStep(pAdicModuleIsomorphism): sage: R. = ZZ[] sage: L. = K.extension(x^2 - 5*x + 5) sage: V, fr, to = L.free_module(base=Qp(5)) - sage: TestSuite(fr).run(skip=['_test_nonzero_equal']) # skipped since L doesn't have dimension() + sage: TestSuite(fr).run(skip=['_test_nonzero_equal']) # skipped since L doesn't have dimension() """ def _call_(self, x): """ @@ -939,7 +940,7 @@ def _call_with_args(self, x, args=(), kwds={}): sage: S. = ZZ[] sage: W. = Zp(3).extension(x^4 + 9*x^2 + 3*x - 3) sage: z = W.random_element() - sage: r = repr(W.change(print_mode='digits')(z, absprec=8)) # indirect doctest + sage: r = repr(W.change(print_mode='digits')(z, absprec=8)) # indirect doctest sage: r[:3] == '...' True sage: all(l in ['0', '1', '2'] for l in r[3:]) diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index ed171e833e4..6e213230fd2 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -89,8 +89,8 @@ class UnramifiedExtensionRingCappedRelative(UnramifiedExtensionGeneric, pAdicCap """ TESTS:: - sage: R. = ZqCR(27,1000) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: R. = ZqCR(27,1000) # needs sage.libs.ntl + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.libs.ntl """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): r""" @@ -116,10 +116,10 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqCR(27,10000); R #indirect doctest + sage: R. = ZqCR(27,10000); R #indirect doctest # needs sage.libs.ntl 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 - sage: R. = ZqCR(next_prime(10^30)^3, 3); R.prime() + sage: R. = ZqCR(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl 1000000000000000000000000000057 """ self._shift_seed = None @@ -147,8 +147,8 @@ class UnramifiedExtensionFieldCappedRelative(UnramifiedExtensionGeneric, pAdicCa """ TESTS:: - sage: R. = QqCR(27,1000) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: R. = QqCR(27,1000) # needs sage.libs.ntl + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.libs.ntl """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): r""" @@ -174,10 +174,10 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = Qq(27,10000); R #indirect doctest + sage: R. = Qq(27,10000); R #indirect doctest # needs sage.libs.ntl 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 - sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() + sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl 1000000000000000000000000000057 """ # Currently doesn't support polynomials with non-integral coefficients @@ -209,12 +209,12 @@ def _coerce_map_from_(self, R): EXAMPLES:: - sage: R. = QqCR(27) - sage: R.coerce_map_from(ZqCR(27,names='a')) # indirect doctest + sage: R. = QqCR(27) # needs sage.libs.ntl + sage: R.coerce_map_from(ZqCR(27,names='a')) # indirect doctest # needs sage.libs.ntl Ring morphism: From: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 To: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 - sage: R.coerce_map_from(ZqCA(27,names='a')) # indirect doctest + sage: R.coerce_map_from(ZqCA(27,names='a')) # indirect doctest # needs sage.libs.ntl Ring morphism: From: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 To: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 @@ -233,8 +233,8 @@ class UnramifiedExtensionRingCappedAbsolute(UnramifiedExtensionGeneric, pAdicCap """ TESTS:: - sage: R. = ZqCA(27,1000) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: R. = ZqCA(27,1000) # needs sage.libs.flint + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.libs.flint """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): r""" @@ -260,10 +260,10 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqCA(27,10000); R #indirect doctest + sage: R. = ZqCA(27,10000); R #indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 - sage: R. = ZqCA(next_prime(10^30)^3, 3); R.prime() + sage: R. = ZqCA(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint 1000000000000000000000000000057 """ # Currently doesn't support polynomials with non-integral coefficients @@ -292,7 +292,7 @@ class UnramifiedExtensionRingFixedMod(UnramifiedExtensionGeneric, pAdicFixedModR """ TESTS:: - sage: R. = ZqFM(27,1000) + sage: R. = ZqFM(27,1000) # needs sage.libs.flint sage: TestSuite(R).run(skip='_test_log',max_runs=4) # long time """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): @@ -318,10 +318,10 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqFM(27,10000); R #indirect doctest + sage: R. = ZqFM(27,10000); R #indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 - sage: R. = ZqFM(next_prime(10^30)^3, 3); R.prime() + sage: R. = ZqFM(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint 1000000000000000000000000000057 """ self._shift_seed = None @@ -354,7 +354,7 @@ class UnramifiedExtensionRingFloatingPoint(UnramifiedExtensionGeneric, pAdicFloa """ TESTS:: - sage: R. = ZqFP(27,10000); R == loads(dumps(R)) + sage: R. = ZqFP(27,10000); R == loads(dumps(R)) # needs sage.libs.flint True """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): @@ -380,16 +380,16 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqFP(27,10000); R #indirect doctest + sage: R. = ZqFP(27,10000); R #indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 - sage: R. = ZqFP(next_prime(10^30)^3, 3); R.prime() + sage: R. = ZqFP(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint 1000000000000000000000000000057 TESTS: Check that :trac:`23228` has been resolved:: - sage: a % R.prime() + sage: a % R.prime() # needs sage.libs.flint a """ @@ -411,7 +411,7 @@ class UnramifiedExtensionFieldFloatingPoint(UnramifiedExtensionGeneric, pAdicFlo """ TESTS:: - sage: R. = QqFP(27,10000); R == loads(dumps(R)) + sage: R. = QqFP(27,10000); R == loads(dumps(R)) # needs sage.libs.flint True """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): @@ -437,9 +437,9 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = QqFP(27,10000); R #indirect doctest + sage: R. = QqFP(27,10000); R #indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 - sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() + sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl 1000000000000000000000000000057 """ # Currently doesn't support polynomials with non-integral coefficients @@ -463,8 +463,8 @@ def _coerce_map_from_(self, R): EXAMPLES:: - sage: R. = QqFP(27) - sage: R.coerce_map_from(ZqFP(27,names='a')) # indirect doctest + sage: R. = QqFP(27) # needs sage.libs.flint + sage: R.coerce_map_from(ZqFP(27,names='a')) # indirect doctest # needs sage.libs.flint Ring morphism: From: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 To: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 @@ -480,8 +480,8 @@ class EisensteinExtensionRingCappedRelative(EisensteinExtensionGeneric, pAdicCap TESTS:: sage: R = Zp(3, 1000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: W. = R.ext(f) # needs sage.libs.ntl sage.rings.padics + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.geometry.polyhedron """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='NTL'): r""" @@ -507,15 +507,15 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = Zp(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest + sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Ring in w defined by x^3 + 9*x - 3 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 30000 - sage: R.

= Zp(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p - sage: W. = R.ext(f); W.prime() + sage: R.

= Zp(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p # needs sage.libs.ntl + sage: W. = R.ext(f); W.prime() # needs sage.libs.ntl 1000000000000000000000000000057 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 9 """ unram_prec = (prec + poly.degree() - 1) // poly.degree() @@ -535,8 +535,8 @@ class EisensteinExtensionFieldCappedRelative(EisensteinExtensionGeneric, pAdicCa TESTS:: sage: R = Qp(3, 1000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: W. = R.ext(f) # needs sage.libs.ntl + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.geometry.polyhedron """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='NTL'): r""" @@ -562,15 +562,15 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = Qp(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest + sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Field in w defined by x^3 + 9*x - 3 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 30000 - sage: R.

= Qp(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p - sage: W. = R.ext(f); W.prime() + sage: R.

= Qp(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p # needs sage.libs.ntl + sage: W. = R.ext(f); W.prime() # needs sage.libs.ntl 1000000000000000000000000000057 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 9 """ # Currently doesn't support polynomials with non-integral coefficients @@ -591,8 +591,8 @@ class EisensteinExtensionRingCappedAbsolute(EisensteinExtensionGeneric, pAdicCap TESTS:: sage: R = ZpCA(3, 1000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: W. = R.ext(f) # needs sage.libs.ntl sage.rings.padics + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.geometry.polyhedron """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation): r""" @@ -618,15 +618,15 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = ZpCA(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W + sage: W. = R.ext(f); W # needs sage.libs.ntl 3-adic Eisenstein Extension Ring in w defined by x^3 + 9*x - 3 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 30000 sage: R.

= ZpCA(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p - sage: W. = R.ext(f); W.prime() + sage: W. = R.ext(f); W.prime() # needs sage.libs.ntl 1000000000000000000000000000057 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 9 """ unram_prec = (prec + poly.degree() - 1) // poly.degree() @@ -646,8 +646,8 @@ class EisensteinExtensionRingFixedMod(EisensteinExtensionGeneric, pAdicFixedModR TESTS:: sage: R = ZpFM(3, 1000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f) - sage: TestSuite(R).run(skip='_test_log',max_runs=4) + sage: W. = R.ext(f) # needs sage.libs.ntl sage.rings.padics + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # needs sage.geometry.polyhedron """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='NTL'): r""" @@ -673,15 +673,15 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = ZpFM(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest + sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Ring in w defined by x^3 + 9*x - 3 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 30000 sage: R.

= ZpFM(next_prime(10^30), 3, print_pos=False); S. = ZZ[]; f = x^3 + p^2*x - p - sage: W. = R.ext(f); W.prime() + sage: W. = R.ext(f); W.prime() # needs sage.libs.ntl 1000000000000000000000000000057 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 9 """ unram_prec = (prec + poly.degree() - 1) // poly.degree() @@ -702,8 +702,8 @@ def fraction_field(self): EXAMPLES:: sage: S. = ZZ[] - sage: R. = ZpFM(5).extension(x^2 - 5) - sage: R.fraction_field() + sage: R. = ZpFM(5).extension(x^2 - 5) # needs sage.libs.ntl + sage: R.fraction_field() # needs sage.libs.ntl Traceback (most recent call last): ... TypeError: This implementation of the p-adic ring diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pyx b/src/sage/rings/padics/padic_fixed_mod_element.pyx index 2e9e9a1ed3b..324c548f518 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pyx +++ b/src/sage/rings/padics/padic_fixed_mod_element.pyx @@ -169,7 +169,7 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: - sage: R = ZpFM(7,4); a = R(8); a.lift() # indirect doctest + sage: R = ZpFM(7,4); a = R(8); a.lift() # indirect doctest 8 """ cdef Integer ans = PY_NEW(Integer) @@ -183,7 +183,7 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: sage: R = ZpCA(5) - sage: pari(R(1777)) #indirect doctest + sage: pari(R(1777)) #indirect doctest # needs sage.libs.pari 2 + 5^2 + 4*5^3 + 2*5^4 + O(5^20) """ return self._to_gen() @@ -194,13 +194,13 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: - sage: R = ZpFM(5, 10); a = R(17); pari(a) # indirect doctest + sage: R = ZpFM(5, 10); a = R(17); pari(a) # indirect doctest 2 + 3*5 + O(5^10) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari O(5^10) - sage: pari(R(0,5)) + sage: pari(R(0,5)) # needs sage.libs.pari O(5^10) - sage: pari(R(0)).debug() + sage: pari(R(0)).debug() # needs sage.libs.pari [&=...] PADIC(lg=5):... (precp=0,valp=10):... ... ... ... p : [&=...] INT(lg=3):... (+,lgefint=3):... ... p^l : [&=...] INT(lg=3):... (+,lgefint=3):... ... @@ -542,7 +542,7 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: - sage: R. = Zq(7^2,5) + sage: R. = Zq(7^2,5) # needs sage.libs.ntl sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_floating_point_element.pyx b/src/sage/rings/padics/padic_floating_point_element.pyx index d6153a1f673..0d54e1cbfbd 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pyx +++ b/src/sage/rings/padics/padic_floating_point_element.pyx @@ -121,16 +121,16 @@ cdef class pAdicFloatingPointElement(FPElement): Construct from Pari objects:: sage: R = ZpFP(5) - sage: x = pari(123123) ; R(x) + sage: x = pari(123123) ; R(x) # needs sage.libs.pari 3 + 4*5 + 4*5^2 + 4*5^3 + 5^4 + 4*5^5 + 2*5^6 + 5^7 sage: R(pari(R(5252))) 2 + 2*5^3 + 3*5^4 + 5^5 sage: R = ZpFP(5,prec=5) sage: R(pari(-1)) 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 - sage: pari(R(-1)) + sage: pari(R(-1)) # needs sage.libs.pari 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 sage: R(pari(R(0,5))) 0 @@ -163,7 +163,7 @@ cdef class pAdicFloatingPointElement(FPElement): TESTS:: - sage: ZpFP(5)(0).lift() #indirect doctest + sage: ZpFP(5)(0).lift() #indirect doctest 0 sage: R = QpFP(5); R(0).lift() 0 @@ -196,9 +196,9 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R = ZpFP(17, 10); a = ~R(14); pari(a) #indirect doctest + sage: R = ZpFP(17, 10); a = ~R(14); pari(a) #indirect doctest 11 + 3*17 + 17^2 + 6*17^3 + 13*17^4 + 15*17^5 + 10*17^6 + 3*17^7 + 17^8 + 6*17^9 + O(17^10) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 """ return self._to_gen() @@ -209,9 +209,9 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R = ZpFP(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = ZpFP(5, 10); a = R(17); pari(a) #indirect doctest 2 + 3*5 + O(5^10) - sage: pari(R(0)) + sage: pari(R(0)) # needs sage.libs.pari 0 """ if very_pos_val(self.ordp): @@ -418,7 +418,7 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R. = Zq(7^2,5) + sage: R. = Zq(7^2,5) # needs sage.libs.ntl sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index a929ee60a75..7c562d77e03 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -141,7 +141,7 @@ def ngens(self): sage: Zp(5).ngens() 1 - sage: Zq(25,names='a').ngens() + sage: Zq(25,names='a').ngens() # needs sage.libs.ntl 1 """ return 1 @@ -154,9 +154,9 @@ def gens(self): sage: R = Zp(5); R.gens() [5 + O(5^21)] - sage: Zq(25,names='a').gens() + sage: Zq(25,names='a').gens() # needs sage.libs.ntl [a + O(5^20)] - sage: S. = ZZ[]; f = x^5 + 25*x -5; W. = R.ext(f); W.gens() + sage: S. = ZZ[]; f = x^5 + 25*x -5; W. = R.ext(f); W.gens() # needs sage.libs.ntl [w + O(w^101)] """ return [self.gen()] @@ -393,10 +393,10 @@ def fraction_field(self, print_mode=None): DeprecationWarning: Use the change method if you want to change print options in fraction_field() See https://github.com/sagemath/sage/issues/23227 for details. 3132 - sage: U. = Zq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) - sage: U.fraction_field() + sage: U. = Zq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) # needs sage.libs.ntl + sage: U.fraction_field() # needs sage.libs.ntl 17-adic Unramified Extension Field in a defined by x^4 + 7*x^2 + 10*x + 3 - sage: U.fraction_field({"pos":False}) == U.fraction_field() + sage: U.fraction_field({"pos":False}) == U.fraction_field() # needs sage.libs.ntl False TESTS:: @@ -453,10 +453,10 @@ def integer_ring(self, print_mode=None): DeprecationWarning: Use the change method if you want to change print options in integer_ring() See https://github.com/sagemath/sage/issues/23227 for details. 3132 - sage: U. = Qq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) - sage: U.integer_ring() + sage: U. = Qq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) # needs sage.libs.ntl + sage: U.integer_ring() # needs sage.libs.ntl 17-adic Unramified Extension Ring in a defined by x^4 + 7*x^2 + 10*x + 3 - sage: U.fraction_field({"print_mode":"terse"}) == U.fraction_field() + sage: U.fraction_field({"print_mode":"terse"}) == U.fraction_field() # needs sage.libs.ntl doctest:warning ... DeprecationWarning: Use the change method if you want to change print options in fraction_field() @@ -482,7 +482,7 @@ def integer_ring(self, print_mode=None): The `secure` attribute for relaxed type is preserved:: - sage: K = QpER(5, secure=True) + sage: K = QpER(5, secure=True) # needs sage.libs.flint sage: K.integer_ring().is_secure() True """ @@ -522,6 +522,8 @@ def teichmuller(self, x, prec=None): sage: R = Zp(5, 10, 'fixed-mod', 'series') sage: R.teichmuller(2) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + + sage: # needs sage.libs.ntl sage: R = Zp(5,5) sage: S. = R[] sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 @@ -542,6 +544,7 @@ def teichmuller(self, x, prec=None): We check that :trac:`23736` is resolved:: + sage: # needs sage.libs.ntl sage: R.teichmuller(GF(5)(2)) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + O(5^5) @@ -581,8 +584,8 @@ def teichmuller_system(self): Check that :trac:`20457` is fixed:: - sage: F. = Qq(5^2,6) - sage: F.teichmuller_system()[3] + sage: F. = Qq(5^2,6) # needs sage.libs.ntl + sage: F.teichmuller_system()[3] # needs sage.libs.ntl (2*a + 2) + (4*a + 1)*5 + 4*5^2 + (2*a + 1)*5^3 + (4*a + 1)*5^4 + (2*a + 3)*5^5 + O(5^6) .. NOTE:: @@ -621,14 +624,13 @@ def extension(self, modulus, prec=None, names=None, print_mode=None, implementat EXAMPLES:: + sage: # needs sage.libs.ntl sage: k = Qp(5) sage: R. = k[] - sage: l. = k.extension(x^2-5); l + sage: l. = k.extension(x^2 - 5); l 5-adic Eisenstein Extension Field in w defined by x^2 - 5 - sage: F = list(Qp(19)['x'](cyclotomic_polynomial(5)).factor())[0][0] - sage: L = Qp(19).extension(F, names='a') - sage: L + sage: L = Qp(19).extension(F, names='a'); L 19-adic Unramified Extension Field in a defined by x^2 + 8751674996211859573806383*x + 1 """ if isinstance(modulus, list): @@ -675,6 +677,7 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = ZZ[] sage: K. = Qq(25, modulus=x^2-2) sage: L. = Qq(625, modulus=x^4-2) @@ -687,7 +690,6 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): True sage: L._is_valid_homomorphism_(L, [-b]) True - sage: W. = K.extension(x^2 - 5) sage: cc = K.hom([-a]) sage: W._is_valid_homomorphism_(W, [w], base_map=cc) @@ -1102,12 +1104,12 @@ def _log_unit_part_p(self): O(3^5) sage: S. = ZZ[] - sage: W. = R.extension(x^3-3) - sage: W._log_unit_part_p() + sage: W. = R.extension(x^3-3) # needs sage.libs.ntl + sage: W._log_unit_part_p() # needs sage.libs.ntl O(pi^15) - sage: W. = R.extension(x^3-3*x-3) - sage: W._log_unit_part_p() + sage: W. = R.extension(x^3-3*x-3) # needs sage.libs.ntl + sage: W._log_unit_part_p() # needs sage.libs.ntl 2 + pi + 2*pi^2 + pi^4 + pi^5 + 2*pi^7 + 2*pi^8 + pi^9 + 2*pi^10 + pi^11 + pi^12 + 2*pi^14 + O(pi^15) """ return self(self.prime()).unit_part().log() @@ -1123,30 +1125,30 @@ def frobenius_endomorphism(self, n=1): EXAMPLES:: - sage: K. = Qq(3^5) - sage: Frob = K.frobenius_endomorphism(); Frob + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: Frob = K.frobenius_endomorphism(); Frob # needs sage.libs.ntl Frobenius endomorphism on 3-adic Unramified Extension ... lifting a |--> a^3 on the residue field - sage: Frob(a) == a.frobenius() + sage: Frob(a) == a.frobenius() # needs sage.libs.ntl True We can specify a power:: - sage: K.frobenius_endomorphism(2) + sage: K.frobenius_endomorphism(2) # needs sage.libs.ntl Frobenius endomorphism on 3-adic Unramified Extension ... lifting a |--> a^(3^2) on the residue field The result is simplified if possible:: - sage: K.frobenius_endomorphism(6) + sage: K.frobenius_endomorphism(6) # needs sage.libs.ntl Frobenius endomorphism on 3-adic Unramified Extension ... lifting a |--> a^3 on the residue field - sage: K.frobenius_endomorphism(5) + sage: K.frobenius_endomorphism(5) # needs sage.libs.ntl Identity endomorphism of 3-adic Unramified Extension ... Comparisons work:: - sage: K.frobenius_endomorphism(6) == Frob + sage: K.frobenius_endomorphism(6) == Frob # needs sage.libs.ntl True """ from .morphism import FrobeniusEndomorphism_padics @@ -1183,6 +1185,7 @@ def valuation(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(a^3 - 3) @@ -1196,9 +1199,9 @@ def valuation(self): The normalization is chosen such that the valuation restricts to the valuation on the base ring:: - sage: v(3) == K.valuation()(3) + sage: v(3) == K.valuation()(3) # needs sage.libs.ntl True - sage: v.restriction(K) == K.valuation() + sage: v.restriction(K) == K.valuation() # needs sage.libs.ntl True .. SEEALSO:: @@ -1229,10 +1232,11 @@ def _primitive_qth_root_of_unity(self, exponent): TESTS:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^3, 5) sage: S. = K[] sage: L. = K.extension(x^2 + 2*x + 2) - sage: zeta = L.primitive_root_of_unity(); zeta # indirect doctest + sage: zeta = L.primitive_root_of_unity(); zeta # indirect doctest a + a*pi + pi^2 + a*pi^4 + a*pi^5 + a^2*pi^8 + a^2*pi^9 + O(pi^10) sage: zeta.parent() is L True @@ -1312,10 +1316,10 @@ def primitive_root_of_unity(self, n=None, order=False): Now we consider an example with non trivial ``p``-th roots of unity:: + sage: # needs sage.libs.ntl sage: W = Zp(3, 2) sage: S. = W[] sage: R. = W.extension((x+1)^6 + (x+1)^3 + 1) - sage: zeta, order = R.primitive_root_of_unity(order=True) sage: zeta 2 + 2*pi + 2*pi^3 + 2*pi^7 + 2*pi^8 + 2*pi^9 + pi^11 + O(pi^12) @@ -1323,7 +1327,6 @@ def primitive_root_of_unity(self, n=None, order=False): 18 sage: zeta.multiplicative_order() 18 - sage: zeta, order = R.primitive_root_of_unity(24, order=True) sage: zeta 2 + pi^3 + 2*pi^7 + 2*pi^8 + 2*pi^10 + 2*pi^11 + O(pi^12) @@ -1397,10 +1400,10 @@ def roots_of_unity(self, n=None): In general, there might be more roots of unity (it happens when the ring has non trivial ``p``-th roots of unity):: + sage: # needs sage.libs.ntl sage: W. = Zq(3^2, 2) sage: S. = W[] sage: R. = W.extension((x+1)^2 + (x+1) + 1) - sage: roots = R.roots_of_unity(); roots [1 + O(pi^4), a + 2*a*pi + 2*a*pi^2 + a*pi^3 + O(pi^4), @@ -1416,6 +1419,7 @@ def roots_of_unity(self, n=None): We check that the logarithm of each root of unity vanishes:: + sage: # needs sage.libs.ntl sage: for root in roots: ....: if root.log() != 0: ....: raise ValueError @@ -1473,6 +1477,7 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur EXAMPLES:: + sage: # needs sage.libs.ntl sage: A = Zp(3, prec=10, print_mode='terse') sage: S. = A[] sage: P = x^2 - 7 @@ -1484,13 +1489,13 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur We compare with the result given by the method :meth:`sage.rings.padics.padic_generic_element.square_root`:: - sage: A(7).square_root(all=True) + sage: A(7).square_root(all=True) # needs sage.libs.ntl [30793 + O(3^10), 28256 + O(3^10)] Here is another example:: - sage: P = x * (x-1) * (x-2) * (x-3) * (x-4) - sage: P.roots(multiplicities=False) + sage: P = x * (x-1) * (x-2) * (x-3) * (x-4) # needs sage.libs.ntl + sage: P.roots(multiplicities=False) # needs sage.libs.ntl [39370 + O(3^10), 19684 + O(3^10), 2 + O(3^10), @@ -1500,7 +1505,7 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur The result is not quite what we expected. In fact, the roots are correct but the precision is not:: - sage: [ root.add_bigoh(9) for root in P.roots(multiplicities=False) ] + sage: [ root.add_bigoh(9) for root in P.roots(multiplicities=False) ] # needs sage.libs.ntl [4 + O(3^9), 1 + O(3^9), 2 + O(3^9), @@ -1512,7 +1517,7 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur If we are switching to ``"sage"`` then the precision on the result becomes correct (but the computation is much slower):: - sage: P.roots(multiplicities=False, algorithm="sage") + sage: P.roots(multiplicities=False, algorithm="sage") # needs sage.geometry.polyhedron sage.libs.ntl [0, 3 + O(3^11), 1 + O(3^9), @@ -1521,27 +1526,27 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur We check that the keyword ``secure`` works as explained above:: - sage: P = x^2 + O(3^10)*x + O(3^10) - sage: P.roots(algorithm="sage") + sage: P = x^2 + O(3^10)*x + O(3^10) # needs sage.libs.ntl + sage: P.roots(algorithm="sage") # needs sage.geometry.polyhedron sage.libs.ntl [(O(3^5), 2)] - sage: P.roots(algorithm="sage", secure=True) + sage: P.roots(algorithm="sage", secure=True) # needs sage.libs.ntl Traceback (most recent call last): ... PrecisionError: not enough precision to determine the number of roots An example over an extension:: - sage: B. = Zq(3^3, prec=10, print_mode='terse') - sage: P = B.modulus() + sage: B. = Zq(3^3, prec=10, print_mode='terse') # needs sage.libs.ntl + sage: P = B.modulus() # needs sage.libs.ntl We check that `P` has no root in `A`:: - sage: P.roots() + sage: P.roots() # needs sage.libs.ntl [] but that it has roots in `B`:: - sage: P.roots(B) + sage: P.roots(B) # needs sage.geometry.polyhedron sage.libs.ntl [(35149 + 57730*b + 41124*b^2 + O(3^10), 1), (23900 + 1318*b + 17925*b^2 + O(3^10), 1), (b + O(3^10), 1)] @@ -1549,21 +1554,21 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur We check further that the other roots are the conjugates of ``b`` under Frobenius:: - sage: b.frobenius() + sage: b.frobenius() # needs sage.libs.ntl 23900 + 1318*b + 17925*b^2 + O(3^10) - sage: b.frobenius().frobenius() + sage: b.frobenius().frobenius() # needs sage.libs.ntl 35149 + 57730*b + 41124*b^2 + O(3^10) Root finding works over ramified extensions also:: + sage: # needs sage.libs.ntl sage: E = x^3 - 3*x + 3*b sage: C. = B.extension(E) - sage: E.roots(C) + sage: E.roots(C) # needs sage.geometry.polyhedron [(pi + O(pi^30), 1)] - sage: S. = C[] sage: P = prod(x - (pi+i) for i in range(5)) - sage: P.roots() + sage: P.roots() # needs sage.geometry.polyhedron [(pi + O(pi^29), 1), (3 + pi + O(pi^29), 1), (1 + pi + O(pi^27), 1), @@ -1572,7 +1577,7 @@ def _roots_univariate_polynomial(self, P, ring, multiplicities, algorithm, secur TESTS:: - sage: S(0).roots() + sage: S(0).roots() # needs sage.libs.ntl Traceback (most recent call last): ... ArithmeticError: factorization of 0 is not defined @@ -1615,8 +1620,8 @@ class ResidueReductionMap(Morphism): EXAMPLES:: sage: from sage.rings.padics.padic_generic import ResidueReductionMap - sage: R. = Zq(125); k = R.residue_field() - sage: f = ResidueReductionMap._create_(R, k); f + sage: R. = Zq(125); k = R.residue_field() # needs sage.libs.ntl + sage: f = ResidueReductionMap._create_(R, k); f # needs sage.libs.ntl Reduction morphism: From: 5-adic Unramified Extension Ring in a defined by x^3 + 3*x + 3 To: Finite Field in a0 of size 5^3 @@ -1634,10 +1639,10 @@ def _create_(R, k): EXAMPLES:: - sage: f = Zmod(49).convert_map_from(Zp(7)) - sage: TestSuite(f).run() - sage: K. = Qq(125); k = K.residue_field(); f = k.convert_map_from(K) - sage: TestSuite(f).run() + sage: f = Zmod(49).convert_map_from(Zp(7)) # needs sage.rings.finite_rings + sage: TestSuite(f).run() # needs sage.rings.finite_rings + sage: K. = Qq(125); k = K.residue_field(); f = k.convert_map_from(K) # needs sage.libs.ntl + sage: TestSuite(f).run() # needs sage.rings.finite_rings """ if R.is_field(): from sage.categories.sets_with_partial_maps import SetsWithPartialMaps @@ -1667,7 +1672,7 @@ def is_surjective(self): EXAMPLES:: - sage: GF(7).convert_map_from(Qp(7)).is_surjective() + sage: GF(7).convert_map_from(Qp(7)).is_surjective() # needs sage.rings.finite_rings True """ return True @@ -1678,7 +1683,7 @@ def is_injective(self): EXAMPLES:: - sage: GF(5).convert_map_from(ZpCA(5)).is_injective() + sage: GF(5).convert_map_from(ZpCA(5)).is_injective() # needs sage.rings.finite_rings False """ return False @@ -1689,6 +1694,7 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(125); k = R.residue_field() sage: f = k.convert_map_from(R) sage: f(15) @@ -1696,7 +1702,7 @@ def _call_(self, x): sage: f(1/(1+a)) a0^2 + 4*a0 + 4 - sage: Zmod(121).convert_map_from(Qp(11))(3/11) + sage: Zmod(121).convert_map_from(Qp(11))(3/11) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: element must have non-negative valuation in order to compute residue @@ -1710,7 +1716,7 @@ def section(self): EXAMPLES:: - sage: GF(3).convert_map_from(Zp(3)).section() + sage: GF(3).convert_map_from(Zp(3)).section() # needs sage.rings.finite_rings Lifting morphism: From: Finite Field of size 3 To: 3-adic Ring with capped relative precision 20 @@ -1723,7 +1729,7 @@ def _repr_type(self): EXAMPLES:: - sage: GF(3).convert_map_from(Zp(3))._repr_type() + sage: GF(3).convert_map_from(Zp(3))._repr_type() # needs sage.rings.finite_rings 'Reduction' """ return "Reduction" @@ -1758,8 +1764,8 @@ class ResidueLiftingMap(Morphism): EXAMPLES:: sage: from sage.rings.padics.padic_generic import ResidueLiftingMap - sage: R. = Zq(125); k = R.residue_field() - sage: f = ResidueLiftingMap._create_(k, R); f + sage: R. = Zq(125); k = R.residue_field() # needs sage.libs.ntl + sage: f = ResidueLiftingMap._create_(k, R); f # needs sage.libs.ntl Lifting morphism: From: Finite Field in a0 of size 5^3 To: 5-adic Unramified Extension Ring in a defined by x^3 + 3*x + 3 @@ -1799,12 +1805,12 @@ def _call_(self, x): EXAMPLES:: - sage: R. = Zq(27); k = R.residue_field(); a0 = k.gen() - sage: f = R.convert_map_from(k); f + sage: R. = Zq(27); k = R.residue_field(); a0 = k.gen() # needs sage.libs.ntl + sage: f = R.convert_map_from(k); f # needs sage.libs.ntl Lifting morphism: From: Finite Field in a0 of size 3^3 To: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 - sage: f(a0 + 1) + sage: f(a0 + 1) # needs sage.libs.ntl (a + 1) + O(3) sage: Zp(3)(Zmod(81)(0)) @@ -1867,6 +1873,7 @@ def _richcmp_(self, other, op): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.rings.padics.padic_generic import ResidueLiftingMap sage: f = ResidueLiftingMap._create_(GF(3), Zp(3)) sage: g = ResidueLiftingMap._create_(GF(3), Zp(3)) diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index f68405dcc6f..26992261171 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -67,7 +67,7 @@ cdef class pAdicGenericElement(LocalGenericElement): :: sage: R = Zp(5); a = R(5, 6); b = R(5 + 5^6, 8) - sage: a == b #indirect doctest + sage: a == b #indirect doctest True :: @@ -329,7 +329,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: sage: R = ZpCA(5); a = R(129378); b = R(2398125) - sage: a // b #indirect doctest + sage: a // b #indirect doctest 1 + 2*5 + 2*5^3 + 4*5^4 + 5^6 + 5^7 + 5^8 + 4*5^9 + 2*5^10 + 4*5^11 + 4*5^12 + 2*5^13 + 3*5^14 + O(5^16) sage: a / b 4*5^-4 + 3*5^-3 + 2*5^-2 + 5^-1 + 3 + 3*5 + 4*5^2 + 2*5^4 + 2*5^6 + 4*5^7 + 5^9 + 5^10 + 5^11 + O(5^12) @@ -361,7 +361,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: sage: R = Zp(5, 5); a = R(77) - sage: a // 15 # indirect doctest + sage: a // 15 # indirect doctest 5 + O(5^4) """ return self.quo_rem(right, integral=True)[0] @@ -375,7 +375,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R = Zp(7,4,'capped-rel','series'); a = R(1/3); a 5 + 4*7 + 4*7^2 + 4*7^3 + O(7^4) - sage: a[0] #indirect doctest + sage: a[0] #indirect doctest doctest:warning ... DeprecationWarning: __getitem__ is changing to match the behavior of number fields. Please use expansion instead. @@ -435,8 +435,9 @@ cdef class pAdicGenericElement(LocalGenericElement): For extension elements, "zeros" match the behavior of ``list``:: + sage: # needs sage.libs.ntl sage: S. = Qq(125) - sage: a[-2] + sage: a[-2] # needs sage.rings.padics [] .. SEEALSO:: @@ -455,7 +456,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R = Zp(7,4,'capped-rel','series'); a = R(3); a 3 + O(7^4) - sage: ~a #indirect doctest + sage: ~a # indirect doctest 5 + 4*7 + 4*7^2 + 4*7^3 + O(7^4) .. NOTE:: @@ -555,14 +556,15 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: Zp(5,5)(1/3) # indirect doctest + sage: Zp(5,5)(1/3) # indirect doctest 2 + 3*5 + 5^2 + 3*5^3 + 5^4 + O(5^5) We check that :trac:`26479` is fixed:: + sage: # needs sage.libs.ntl sage: x = polygen(ZZ, 'x') sage: K. = Qp(2).extension(x^3 - 2) - sage: latex(pi) + sage: latex(pi) # needs sage.symbolic \pi + O(\pi^{61}) """ return self.parent()._printer.repr_gen(self, do_latex, mode=mode) @@ -695,10 +697,10 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: x = PowerSeriesRing(QQ, 'x', default_prec=82).gen() sage: AH = sum(x**(3**i)/(3**i) for i in range(5)).O(82).exp() sage: z = Zp(3)(33/7) - sage: ahz = AH(z); ahz + sage: ahz = AH(z); ahz # needs sage.libs.ntl 1 + 2*3 + 3^2 + 3^3 + 2*3^5 + 3^6 + 2*3^7 + 3^9 + 3^11 + 3^12 + 3^13 + 3^14 + 2*3^15 + 3^16 + 2*3^18 + 2*3^19 + O(3^20) - sage: ahz - z.artin_hasse_exp() + sage: ahz - z.artin_hasse_exp() # needs sage.libs.ntl O(3^20) Out of convergence domain:: @@ -772,9 +774,10 @@ cdef class pAdicGenericElement(LocalGenericElement): When `x^{p^i}/p^i` is not in the domain of convergence of the exponential for some nonnegative integer `i`, an error is raised:: + sage: # needs sage.libs.ntl sage: S. = W[] sage: R. = W.extension(x^2 + 3) - sage: pi.artin_hasse_exp(algorithm='direct') # indirect doctest + sage: pi.artin_hasse_exp(algorithm='direct') # indirect doctest # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: one factor of the Artin-Hasse exponential does not converge @@ -801,7 +804,7 @@ cdef class pAdicGenericElement(LocalGenericElement): 1 + 2^3 + 2^4 + 2^5 + 2^7 + O(2^8) sage: y1 == -y2 True - sage: y1 == x.artin_hasse_exp(algorithm='series') + sage: y1 == x.artin_hasse_exp(algorithm='series') # needs sage.symbolic True .. SEEALSO:: @@ -858,12 +861,13 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: sage: W = Zp(3,10) - sage: W(123456).artin_hasse_exp(algorithm='series') # indirect doctest + sage: W(123456).artin_hasse_exp(algorithm='series') # indirect doctest # needs sage.symbolic 1 + 3 + 2*3^3 + 2*3^4 + 3^5 + 2*3^6 + 2*3^7 + 3^8 + O(3^10) + sage: # needs sage.libs.ntl sage: S. = W[] sage: R. = W.extension(x^2 + 3) - sage: pi.artin_hasse_exp(algorithm='series') # indirect doctest + sage: pi.artin_hasse_exp(algorithm='series') # indirect doctest # needs sage.symbolic 1 + pi + 2*pi^2 + 2*pi^3 + 2*pi^4 + 2*pi^10 + 2*pi^11 + pi^13 + pi^18 + pi^19 + O(pi^20) .. SEEALSO:: @@ -911,9 +915,10 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: W(123456).artin_hasse_exp(algorithm='newton') # indirect doctest 1 + 3 + 2*3^3 + 2*3^4 + 3^5 + 2*3^6 + 2*3^7 + 3^8 + O(3^10) + sage: # needs sage.libs.ntl sage: S. = W[] sage: R. = W.extension(x^2 + 3) - sage: pi.artin_hasse_exp(algorithm='newton') # indirect doctest + sage: pi.artin_hasse_exp(algorithm='newton') # indirect doctest # needs sage.symbolic 1 + pi + 2*pi^2 + 2*pi^3 + 2*pi^4 + 2*pi^10 + 2*pi^11 + pi^13 + pi^18 + pi^19 + O(pi^20) .. SEEALSO:: @@ -978,25 +983,24 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: Zp(5,5)(1/3).minimal_polynomial('x') + sage: Zp(5,5)(1/3).minimal_polynomial('x') # needs sage.libs.ntl (1 + O(5^5))*x + 3 + 5 + 3*5^2 + 5^3 + 3*5^4 + O(5^5) - sage: Zp(5,5)(1/3).minimal_polynomial('foo') + sage: Zp(5,5)(1/3).minimal_polynomial('foo') # needs sage.libs.ntl (1 + O(5^5))*foo + 3 + 5 + 3*5^2 + 5^3 + 3*5^4 + O(5^5) :: + sage: # needs sage.libs.ntl sage: K. = QqCR(2^3,5) sage: S. = K[] sage: L. = K.extension(x^4 - 2*a) - - sage: pi.minimal_polynomial() + sage: pi.minimal_polynomial() # needs sage.symbolic (1 + O(2^5))*x^4 + a*2 + a*2^2 + a*2^3 + a*2^4 + a*2^5 + O(2^6) - sage: (pi^2).minimal_polynomial() + sage: (pi^2).minimal_polynomial() # needs sage.symbolic (1 + O(2^5))*x^2 + a*2 + a*2^2 + a*2^3 + a*2^4 + a*2^5 + O(2^6) - sage: (1/pi).minimal_polynomial() + sage: (1/pi).minimal_polynomial() # needs sage.symbolic (1 + O(2^5))*x^4 + (a^2 + 1)*2^-1 + O(2^4) - sage: elt = L.random_element() sage: P = elt.minimal_polynomial() # not tested, known bug (see :trac:`32111`) sage: P(elt) == 0 # not tested @@ -1053,26 +1057,26 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: Zp(5)(5).norm() + sage: Zp(5)(5).norm() # needs sage.libs.ntl 5 + O(5^21) :: + sage: # needs sage.libs.ntl sage: K. = QqCR(2^3,5) sage: S. = K[] sage: L. = K.extension(x^4 - 2*a) - - sage: pi.norm() # norm over K + sage: pi.norm() # norm over K # needs sage.symbolic a*2 + a*2^2 + a*2^3 + a*2^4 + a*2^5 + O(2^6) - sage: (pi^2).norm() + sage: (pi^2).norm() # needs sage.symbolic a^2*2^2 + O(2^7) - sage: pi.norm()^2 + sage: pi.norm()^2 # needs sage.symbolic a^2*2^2 + O(2^7) TESTS:: - sage: x = L.random_element() - sage: y = L.random_element() + sage: x = L.random_element() # needs sage.libs.ntl + sage: y = L.random_element() # needs sage.libs.ntl sage: (x*y).norm() == x.norm() * y.norm() # not tested, known bug (see :trac:`32085`) True @@ -1099,22 +1103,22 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: Zp(5,5)(5).trace() + sage: Zp(5,5)(5).trace() # needs sage.libs.ntl 5 + O(5^6) + sage: # needs sage.libs.ntl sage: K. = QqCR(2^3,7) sage: S. = K[] sage: L. = K.extension(x^4 - 4*a*x^3 + 2*a) - - sage: pi.trace() # trace over K + sage: pi.trace() # trace over K # needs sage.symbolic a*2^2 + O(2^8) - sage: (pi+1).trace() + sage: (pi+1).trace() # needs sage.symbolic (a + 1)*2^2 + O(2^7) TESTS:: - sage: x = L.random_element() - sage: y = L.random_element() + sage: x = L.random_element() # needs sage.libs.ntl + sage: y = L.random_element() # needs sage.libs.ntl sage: (x+y).trace() == x.trace() + y.trace() # not tested, known bug (see :trac:`32085`) True @@ -1371,8 +1375,8 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: p = next_prime(200) sage: F = Qp(p) - sage: l1 = [F(a/(p-1)).gamma(algorithm='pari') for a in range(p-1)] # long time - sage: l2 = [F(a/(p-1)).gamma(algorithm='sage') for a in range(p-1)] # long time + sage: l1 = [F(a/(p-1)).gamma(algorithm='pari') for a in range(p-1)] # long time + sage: l2 = [F(a/(p-1)).gamma(algorithm='sage') for a in range(p-1)] # long time sage: all(l1[i] == l2[i] for i in range(p-1)) # long time True @@ -1504,24 +1508,22 @@ cdef class pAdicGenericElement(LocalGenericElement): The implementation also works over extensions:: + sage: # needs sage.libs.ntl sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(a^3-3) sage: (a+3).gcd(3) 1 + O(a^60) - sage: R = Zp(3) sage: S. = R[] sage: S. = R.extension(a^3-3) sage: (a+3).gcd(3) a + O(a^61) - sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(a^2-2) sage: (a+3).gcd(3) 1 + O(3^20) - sage: R = Zp(3) sage: S. = R[] sage: S. = R.extension(a^2-2) @@ -1620,6 +1622,7 @@ cdef class pAdicGenericElement(LocalGenericElement): If only one element is zero, then the result depends on its precision:: + sage: # needs sage.rings.padics sage: R(9).xgcd(R(0,1)) (O(3), 0, 1 + O(3^20)) sage: R(9).xgcd(R(0,2)) @@ -1646,6 +1649,7 @@ cdef class pAdicGenericElement(LocalGenericElement): The implementation also works over extensions:: + sage: # needs sage.libs.ntl sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(a^3-3) @@ -1657,7 +1661,6 @@ cdef class pAdicGenericElement(LocalGenericElement): + 2*a^40 + 2*a^41 + 2*a^44 + 2*a^45 + 2*a^48 + 2*a^49 + 2*a^52 + 2*a^53 + 2*a^56 + 2*a^57 + O(a^59), 0) - sage: R = Zp(3) sage: S. = R[] sage: S. = R.extension(a^3-3) @@ -1669,7 +1672,6 @@ cdef class pAdicGenericElement(LocalGenericElement): + 2*a^41 + 2*a^42 + 2*a^45 + 2*a^46 + 2*a^49 + 2*a^50 + 2*a^53 + 2*a^54 + 2*a^57 + 2*a^58 + O(a^60), 0) - sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(a^2-2) @@ -1680,7 +1682,6 @@ cdef class pAdicGenericElement(LocalGenericElement): + (2*a + 2)*3^12 + a*3^13 + (2*a + 1)*3^14 + (a + 2)*3^16 + 3^17 + (2*a + 2)*3^18 + a*3^19 + O(3^20), 0) - sage: R = Zp(3) sage: S. = R[] sage: S. = R.extension(a^2-2) @@ -1933,6 +1934,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Over unramified extensions:: + sage: # needs sage.libs.ntl sage: L1. = Qq(5^3) sage: c = L1.teichmuller(a) sage: c.multiplicative_order() @@ -1942,6 +1944,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Over totally ramified extensions:: + sage: # needs sage.libs.ntl sage: x = polygen(ZZ, 'x') sage: L2. = Qp(5).extension(x^4 + 5*x^3 + 10*x^2 + 10*x + 5) sage: u = 1 + pi @@ -2071,8 +2074,8 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R(1/50).valuation() -2 - sage: K. = Qq(25) - sage: K(0).valuation() + sage: K. = Qq(25) # needs sage.libs.ntl + sage: K(0).valuation() # needs sage.libs.ntl +Infinity sage: R(1/50).valuation(5) @@ -2107,7 +2110,7 @@ cdef class pAdicGenericElement(LocalGenericElement): :: - sage: Zp(5)(5).valuation() #indirect doctest + sage: Zp(5)(5).valuation() #indirect doctest 1 """ raise NotImplementedError @@ -2182,9 +2185,10 @@ cdef class pAdicGenericElement(LocalGenericElement): :: + sage: # needs sage.libs.ntl sage: x = polygen(ZZ, 'x') sage: B. = A.extension(x^5 - 2) - sage: pi.is_prime() + sage: pi.is_prime() # needs sage.symbolic True sage: B(2).is_prime() False @@ -2239,7 +2243,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: sage: R = Zp(7,5) - sage: QQ(R(125)) # indirect doctest + sage: QQ(R(125)) # indirect doctest 125 """ try: @@ -2258,9 +2262,9 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: R. = Zq(125) - sage: K = R.exact_field() - sage: a._number_field_(K) + sage: R. = Zq(125) # needs sage.libs.ntl + sage: K = R.exact_field() # needs sage.libs.ntl + sage: a._number_field_(K) # needs sage.libs.ntl a """ Kbase = K.base_ring() @@ -2280,6 +2284,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = ZZ[] sage: K. = Qq(25, modulus=x^2-2) sage: L. = Qq(625, modulus=x^4-2) @@ -2293,12 +2298,13 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: psi(z*w) == psi(z) * psi(w) True + sage: # needs sage.libs.ntl sage: P. = K.extension(x^2 - 5) sage: cc = K.hom([-a]) sage: alpha = P.hom([pi], base_map=cc); alpha(a) + a O(pi^40) sage: zz = (1 + a*pi).log() - sage: ww = pi.exp() + sage: ww = pi.exp() # needs sage.symbolic sage: beta = P.hom([-pi], base_map=cc) sage: beta(ww*zz) == beta(ww)*beta(zz) True @@ -2641,16 +2647,17 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R = Zp(5,5) sage: S. = ZZ[] sage: f = x^4 + 15*x^2 + 625*x - 5 - sage: W. = R.ext(f) - sage: z = 1 + w^2 + 4*w^7; z + sage: W. = R.ext(f) # needs sage.libs.ntl + sage: z = 1 + w^2 + 4*w^7; z # needs sage.libs.ntl 1 + w^2 + 4*w^7 + O(w^20) - sage: z.log() + sage: z.log() # needs sage.libs.ntl w^2 + 2*w^4 + 3*w^6 + 4*w^7 + w^9 + 4*w^10 + 4*w^11 + 4*w^12 + 3*w^14 + w^15 + w^17 + 3*w^18 + 3*w^19 + O(w^20) In an extension, there will usually be a difference between specifying ``p_branch`` and ``pi_branch``:: + sage: # needs sage.libs.ntl sage: b = W(5) sage: b.log() Traceback (most recent call last): @@ -2677,11 +2684,12 @@ cdef class pAdicGenericElement(LocalGenericElement): Check that log is multiplicative:: - sage: y.log(p_branch=0) + z.log() - (y*z).log(p_branch=0) + sage: y.log(p_branch=0) + z.log() - (y*z).log(p_branch=0) # needs sage.libs.ntl O(w^20) Now an unramified example:: + sage: # needs sage.libs.ntl sage: g = x^3 + 3*x + 3 sage: A. = R.ext(g) sage: b = 1 + 5*(1 + a^2) + 5^3*(3 + 2*a) @@ -2691,6 +2699,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Check that log is multiplicative:: + sage: # needs sage.libs.ntl sage: c = 3 + 5^2*(2 + 4*a) sage: b.log() + c.log() - (b*c).log() O(5^5) @@ -2729,13 +2738,13 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R = ZpCA(3,10) sage: S. = R[] sage: f = x^3 - 3 - sage: W. = R.ext(f) - sage: w.log(p_branch=2) + sage: W. = R.ext(f) # needs sage.libs.ntl sage.rings.padics + sage: w.log(p_branch=2) # needs sage.libs.ntl sage.rings.padics Traceback (most recent call last): ... ValueError: logarithm is not integral, use change_frac=True to obtain a result in the fraction field - sage: w.log(p_branch=2, change_frac=True) + sage: w.log(p_branch=2, change_frac=True) # needs sage.libs.ntl sage.rings.padics 2*w^-3 + O(w^24) TESTS: @@ -2813,7 +2822,7 @@ cdef class pAdicGenericElement(LocalGenericElement): 7 + 3*7^2 + 4*7^3 + 3*7^4 sage: x.log(aprec = 7) 7 + 3*7^2 + 4*7^3 + 3*7^4 + 7^5 + 3*7^6 - sage: x.log() + sage: x.log() # needs sage.symbolic 7 + 3*7^2 + 4*7^3 + 3*7^4 + 7^5 + 3*7^6 + 7^7 + 3*7^8 + 4*7^9 Check that precision is computed correctly in highly ramified @@ -2822,11 +2831,14 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: S. = ZZ[] sage: K = Qp(5,5) sage: f = x^625 - 5*x - 5 + + sage: # needs sage.libs.ntl sage.rings.padics sage: W. = K.extension(f) sage: z = 1 - w^2 + O(w^11) sage: x = 1 - z sage: z.log().precision_absolute() -975 + sage: (x^5/5).precision_absolute() -570 sage: (x^25/25).precision_absolute() @@ -2834,9 +2846,10 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: (x^125/125).precision_absolute() -775 + sage: # needs sage.libs.ntl sage: z = 1 - w + O(w^2) sage: x = 1 - z - sage: z.log().precision_absolute() + sage: z.log().precision_absolute() # needs sage.rings.padics -1625 sage: (x^5/5).precision_absolute() -615 @@ -2847,7 +2860,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: (x^625/625).precision_absolute() -1250 - sage: z.log().precision_relative() + sage: z.log().precision_relative() # needs sage.libs.ntl sage.rings.padics 250 Performances:: @@ -2974,9 +2987,9 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: R. = Zq(7^2,5) - sage: x = R(7*w) - sage: x.exp(algorithm="generic") # indirect doctest + sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: x = R(7*w) # needs sage.libs.ntl + sage: x.exp(algorithm="generic") # indirect doctest # needs sage.libs.ntl 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) AUTHORS: @@ -3123,9 +3136,9 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: R. = Zq(7^2,5) - sage: x = R(7*w) - sage: x.exp(algorithm="newton") # indirect doctest + sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: x = R(7*w) # needs sage.libs.ntl + sage: x.exp(algorithm="newton") # indirect doctest # needs sage.libs.ntl 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) """ R = self.parent() @@ -3223,6 +3236,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Logarithms and exponentials in extension fields. First, in an Eisenstein extension:: + sage: # needs sage.libs.ntl sage: R = Zp(5,5) sage: S. = R[] sage: f = x^4 + 15*x^2 + 625*x - 5 @@ -3234,6 +3248,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Now an unramified example:: + sage: # needs sage.libs.ntl sage: R = Zp(5,5) sage: S. = R[] sage: g = x^3 + 3*x + 3 @@ -3270,6 +3285,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: a.log().exp() 1 + 13 + O(13^10) + sage: # needs sage.libs.ntl sage: R = ZpCA(5,5) sage: S. = R[] sage: f = x^4 + 15*x^2 + 625*x - 5 @@ -3287,6 +3303,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: a.log().exp() 1 + 13 + sage: # needs sage.libs.ntl sage: R = ZpFM(5,5) sage: S. = R[] sage: f = x^4 + 15*x^2 + 625*x - 5 @@ -3304,6 +3321,7 @@ cdef class pAdicGenericElement(LocalGenericElement): ... ValueError: Exponential does not converge for that input. + sage: # needs sage.libs.ntl sage: S. = Z2[] sage: W. = Z2.ext(x^3-2) sage: (w^2).exp() @@ -3436,12 +3454,13 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R2(4).square_root() 2 + O(2^20) - sage: R. = Zq(2^10, 10) - sage: u = 1 + 8*t - sage: u.square_root() + sage: R. = Zq(2^10, 10) # needs sage.libs.ntl + sage: u = 1 + 8*t # needs sage.libs.ntl + sage: u.square_root() # needs sage.libs.ntl 1 + t*2^2 + t^2*2^3 + t^2*2^4 + (t^4 + t^3 + t^2)*2^5 + (t^4 + t^2)*2^6 + (t^5 + t^2)*2^7 + (t^6 + t^5 + t^4 + t^2)*2^8 + O(2^9) + sage: # needs sage.libs.ntl sage: x = polygen(ZZ, 'x') sage: R. = Zp(2).extension(x^3 - 2) sage: u = R(1 + a^4 + a^5 + a^7 + a^8, 10); u @@ -3452,21 +3471,20 @@ cdef class pAdicGenericElement(LocalGenericElement): However, observe that the precision increases to its original value when we recompute the square of the square root:: - sage: v^2 + sage: v^2 # needs sage.libs.ntl 1 + a^4 + a^5 + a^7 + a^8 + O(a^10) If the input does not have enough precision in order to determine if the given element has a square root in the ground field, an error is raised:: + sage: # needs sage.libs.ntl sage: R(1, 6).square_root() Traceback (most recent call last): ... PrecisionError: not enough precision to be sure that this element has a square root - sage: R(1, 7).square_root() 1 + O(a^4) - sage: R(1+a^6, 7).square_root(extend=False) Traceback (most recent call last): ... @@ -3617,6 +3635,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Everything works over extensions as well:: + sage: # needs sage.libs.ntl sage: W. = Zq(5^3) sage: S. = W[] sage: R. = W.extension(x^7 - 5) @@ -3628,7 +3647,7 @@ cdef class pAdicGenericElement(LocalGenericElement): An error is raised if the given element is not an `n`-th power in the ring:: - sage: R(5).nth_root(11) + sage: R(5).nth_root(11) # needs sage.libs.ntl Traceback (most recent call last): ... ValueError: this element is not a nth power @@ -3636,6 +3655,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Similarly, when precision on the input is too small, an error is raised:: + sage: # needs sage.libs.ntl sage: x = R(1,6); x 1 + O(pi^6) sage: x.nth_root(5) @@ -3645,6 +3665,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Check that :trac:`30314` is fixed:: + sage: # needs sage.libs.ntl sage: K = Qp(29) sage: x = polygen(K) sage: L. = K.extension(x^2 - 29) @@ -3655,6 +3676,7 @@ cdef class pAdicGenericElement(LocalGenericElement): We check that it works over different fields:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^3) sage: S. = K[] sage: L. = K.extension(x^2 + 2*x + 2) @@ -3668,6 +3690,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: elt in (elt^56).nth_root(56, all=True) True + sage: # needs sage.libs.ntl sage: K. = Qq(3^2) sage: S. = K[] sage: Z = (1+x)^3 @@ -3683,25 +3706,27 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: elt in (elt^108).nth_root(108, all=True) True + sage: # needs sage.libs.flint sage: K. = ZqCA(3^2) - sage: S. = K[] + sage: S. = K[] # needs sage.libs.ntl sage: Z = (1+x)^3 + 3*x^2 sage: E = Z^2 + Z + 1 - sage: L. = K.extension(E) - sage: elt = L.random_element() - sage: elt in (elt^9).nth_root(9, all=True) + sage: L. = K.extension(E) # needs sage.libs.ntl + sage: elt = L.random_element() # needs sage.libs.ntl + sage: elt in (elt^9).nth_root(9, all=True) # needs sage.libs.ntl True - sage: elt = L.random_element() - sage: try: + sage: elt = L.random_element() # needs sage.libs.ntl + sage: try: # needs sage.libs.ntl sage.rings.real_double ....: assert elt in (elt^27).nth_root(27, all=True) ....: except sage.rings.padics.precision_error.PrecisionError: ....: pass - sage: elt = L.random_element() - sage: try: + sage: elt = L.random_element() # needs sage.libs.ntl + sage: try: # needs sage.libs.ntl sage.rings.real_double ....: assert elt in (elt^108).nth_root(108, all=True) ....: except sage.rings.padics.precision_error.PrecisionError: ....: pass + sage: # needs sage.libs.ntl sage: K. = Qq(3^2) sage: S. = K[] sage: Z = (1+x)^3 + 3*x^3 @@ -3847,6 +3872,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: [ R.teichmuller(x).nth_root(11) == R.teichmuller(x) for x in range(1,11) ] # indirect doctest [True, True, True, True, True, True, True, True, True, True] + sage: # needs sage.libs.ntl sage: W. = Zq(5^3) sage: S. = W[] sage: R. = W.extension(x^8 + 15*a*x - 5) @@ -3977,6 +4003,7 @@ cdef class pAdicGenericElement(LocalGenericElement): An unramified extension:: + sage: # needs sage.libs.ntl sage: R = Zp(5,5) sage: P. = PolynomialRing(R) sage: Z25. = R.ext(x^2 - 3) @@ -3987,6 +4014,7 @@ cdef class pAdicGenericElement(LocalGenericElement): A ramified extension:: + sage: # needs sage.libs.ntl sage: W. = R.ext(x^5 + 75*x^3 - 15*x^2 + 125*x - 5) sage: abs(w) 0.724779663677696 @@ -4012,15 +4040,16 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: a = Qp(5)(15); a.abs() 1/5 - sage: a.abs(53) + sage: a.abs(53) # needs sage.rings.real_mpfr 0.200000000000000 sage: Qp(7)(0).abs() 0 - sage: Qp(7)(0).abs(prec=20) + sage: Qp(7)(0).abs(prec=20) # needs sage.rings.real_mpfr 0.00000 An unramified extension:: + sage: # needs sage.libs.ntl sage: R = Zp(5,5) sage: P. = PolynomialRing(R) sage: Z25. = R.ext(x^2 - 3) @@ -4031,6 +4060,7 @@ cdef class pAdicGenericElement(LocalGenericElement): A ramified extension:: + sage: # needs sage.libs.ntl sage: W. = R.ext(x^5 + 75*x^3 - 15*x^2 + 125*x - 5) sage: w.abs() 0.724779663677696 @@ -4084,7 +4114,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: - sage: Qp(2)(-1)._polylog_res_1(6) == 0 + sage: Qp(2)(-1)._polylog_res_1(6) == 0 # needs sage.symbolic True sage: Qp(5)(1)._polylog_res_1(1) @@ -4169,25 +4199,25 @@ cdef class pAdicGenericElement(LocalGenericElement): The `n`-th polylogarithm of `-1` is `0` for even `n`:: - sage: Qp(13)(-1).polylog(6) == 0 + sage: Qp(13)(-1).polylog(6) == 0 # needs sage.rings.real_mpfr sage.symbolic True We can check some identities, for example those mentioned in [DCW2016]_:: sage: x = Qp(7, prec=30)(1/3) - sage: (x^2).polylog(4) - 8*x.polylog(4) - 8*(-x).polylog(4) == 0 + sage: (x^2).polylog(4) - 8*x.polylog(4) - 8*(-x).polylog(4) == 0 # needs sage.symbolic True :: sage: x = Qp(5, prec=30)(4) - sage: x.polylog(2) + (1/x).polylog(2) + x.log(0)**2/2 == 0 + sage: x.polylog(2) + (1/x).polylog(2) + x.log(0)**2/2 == 0 # needs sage.symbolic True :: sage: x = Qp(11, prec=30)(2) - sage: x.polylog(2) + (1-x).polylog(2) + x.log(0)**2*(1-x).log(0) == 0 + sage: x.polylog(2) + (1-x).polylog(2) + x.log(0)**2*(1-x).log(0) == 0 # needs sage.symbolic True `Li_1(z) = -\log(1-z)` for `|z| < 1`:: @@ -4197,14 +4227,14 @@ cdef class pAdicGenericElement(LocalGenericElement): The dilogarithm of 1 is zero:: - sage: Qp(5)(1).polylog(2) + sage: Qp(5)(1).polylog(2) # needs sage.rings.real_mpfr sage.symbolic O(5^20) The cubing relation holds for the trilogarithm at 1:: sage: K = Qp(7) sage: z = K.zeta(3) - sage: -8*K(1).polylog(3) == 9*(K(z).polylog(3) + K(z^2).polylog(3)) + sage: -8*K(1).polylog(3) == 9*(K(z).polylog(3) + K(z^2).polylog(3)) # needs sage.rings.padics sage.rings.real_mpfr sage.symbolic True The polylogarithm of 0 is 0:: @@ -4222,7 +4252,7 @@ cdef class pAdicGenericElement(LocalGenericElement): Check that :trac:`29222` is fixed:: sage: K = Qp(7) - sage: print(K(1 + 7^11).polylog(4)) + sage: print(K(1 + 7^11).polylog(4)) # needs sage.symbolic 6*7^14 + 3*7^15 + 7^16 + 7^17 + O(7^18) ALGORITHM: @@ -4365,7 +4395,7 @@ def _AHE_coefficients(p, N, prec): However, the result is *not* guaranteed to be correct beyond the requested precision:: - sage: L = _AHE_coefficients(2, 513, 1); L + sage: L = _AHE_coefficients(2, 513, 1); L # needs sage.symbolic [1, 1, 1, @@ -4380,13 +4410,13 @@ def _AHE_coefficients(p, N, prec): sage: S. = PowerSeriesRing(QQ, 513) sage: AH = exp(sum(x^(2^i) / 2^i for i in range(10))) sage: R = ZpFM(2, 1) - sage: [ R(c) for c in L ] == [ R(c) for c in AH.list() ] + sage: [ R(c) for c in L ] == [ R(c) for c in AH.list() ] # needs sage.rings.padics True But it is not modulo `2^{10}`:: sage: R = ZpFM(2, 10) - sage: [ R(c) for c in L ] == [ R(c) for c in AH.list() ] + sage: [ R(c) for c in L ] == [ R(c) for c in AH.list() ] # needs sage.rings.padics False """ @@ -4424,7 +4454,7 @@ def _polylog_c(n, p): EXAMPLES:: - sage: sage.rings.padics.padic_generic_element._polylog_c(1, 2) + sage: sage.rings.padics.padic_generic_element._polylog_c(1, 2) # needs sage.symbolic 4.52876637294490 """ return p/(p-1) - (n-1)/p.log().n() + (n-1)*(n*(p-1)/p.log().n()).log(p).n() + (2*p*(p-1)*n/p.log().n()).log(p).n() @@ -4446,7 +4476,7 @@ def _findprec(c_1, c_2, c_3, p): EXAMPLES:: - sage: sage.rings.padics.padic_generic_element._findprec(1, 1, 2, 2) + sage: sage.rings.padics.padic_generic_element._findprec(1, 1, 2, 2) # needs sage.rings.real_double sage.rings.real_mpfr sage.symbolic 5 sage: 5*1 - 5*log(1, 2) > 2 True @@ -4470,7 +4500,7 @@ def _compute_g(p, n, prec, terms): EXAMPLES:: - sage: sage.rings.padics.padic_generic_element._compute_g(7, 3, 3, 3)[0] + sage: sage.rings.padics.padic_generic_element._compute_g(7, 3, 3, 3)[0] # needs sage.libs.ntl sage.rings.real_double O(7^3)*v^2 + (1 + O(7^3))*v + O(7^3) """ from sage.rings.power_series_ring import PowerSeriesRing diff --git a/src/sage/rings/padics/padic_lattice_element.py b/src/sage/rings/padics/padic_lattice_element.py index a8d9e507b90..e2c80855b71 100644 --- a/src/sage/rings/padics/padic_lattice_element.py +++ b/src/sage/rings/padics/padic_lattice_element.py @@ -17,7 +17,7 @@ sage: R3 = QpLC(2) sage: R4 = QpLF(2) - sage: # long time + sage: # long time, needs sage.rings.padics sage: TestSuite(R1).run(skip=['_test_teichmuller', '_test_matrix_smith']) sage: TestSuite(R2).run(skip=['_test_teichmuller', '_test_matrix_smith']) sage: TestSuite(R3).run(skip=['_test_teichmuller', '_test_matrix_smith']) diff --git a/src/sage/rings/padics/padic_printing.pyx b/src/sage/rings/padics/padic_printing.pyx index 344a1e544a7..06b9f9057c3 100644 --- a/src/sage/rings/padics/padic_printing.pyx +++ b/src/sage/rings/padics/padic_printing.pyx @@ -211,7 +211,7 @@ class pAdicPrinterDefaults(SageObject): sage: padic_printing.max_unram_terms(2) sage: padic_printing.max_unram_terms() 2 - sage: Zq(5^6, 5, names='a')([1,2,3,-1])^17 + sage: Zq(5^6, 5, names='a')([1,2,3,-1])^17 # needs sage.libs.ntl (3*a^4 + ... + 3) + (a^5 + ... + a)*5 + (3*a^3 + ... + 2)*5^2 + (3*a^5 + ... + 2)*5^3 + (4*a^5 + ... + 4)*5^4 + O(5^5) sage: padic_printing.max_unram_terms(-1) @@ -236,7 +236,7 @@ class pAdicPrinterDefaults(SageObject): sage: padic_printing.max_poly_terms() 3 sage: padic_printing.mode('terse') - sage: Zq(7^5, 5, names='a')([2,3,4])^8 + sage: Zq(7^5, 5, names='a')([2,3,4])^8 # needs sage.libs.ntl 2570 + 15808*a + 9018*a^2 + ... + O(7^5) sage: padic_printing.max_poly_terms(-1) @@ -379,7 +379,7 @@ cdef class pAdicPrinter_class(SageObject): TESTS:: - sage: R = Qp(7, print_mode='bars', print_sep='&') #indirect doctest + sage: R = Qp(7, print_mode='bars', print_sep='&') #indirect doctest sage: R = Zp(5, print_mode='digits', print_max_terms=10) Traceback (most recent call last): @@ -614,7 +614,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: - sage: Zp(5)._printer #indirect doctest + sage: Zp(5)._printer #indirect doctest series printer for 5-adic Ring with capped relative precision 20 """ return "%s printer for %s"%(self._print_mode(), self.ring) @@ -830,7 +830,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: sage: P = Zp(17)._printer - sage: P._base_p_list(1298734,True) #indirect doctest + sage: P._base_p_list(1298734,True) #indirect doctest [2, 15, 5, 9, 15] sage: P._base_p_list(1298734,False) [2, -2, 6, -8, -1, 1] @@ -900,7 +900,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: - sage: R = Zp(7,4,'capped-rel','val-unit'); a = R(364); a #indirect doctest + sage: R = Zp(7,4,'capped-rel','val-unit'); a = R(364); a #indirect doctest 7 * 52 + O(7^5) sage: print(a.str('terse')) 364 + O(7^5) diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index 06cc00e73f0..0502f855aa6 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -97,6 +97,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): TESTS:: + sage: # needs sage.libs.ntl sage: QQq. = Qq(25,4) sage: FFp = Zp(5,5).residue_field() sage: QQq(FFp.zero()) @@ -517,6 +518,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): Check to see that :trac:`10292` is resolved:: + sage: # needs sage.schemes sage: E = EllipticCurve('37a') sage: R = E.padic_regulator(7) sage: len(R.expansion()) diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index b6ea2ea75ee..a46cee1f805 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -8,9 +8,9 @@ 2-adic valuation sage: QQ.valuation(3) 3-adic valuation - sage: CyclotomicField(5).valuation(5) + sage: CyclotomicField(5).valuation(5) # needs sage.rings.number_field 5-adic valuation - sage: GaussianIntegers().valuation(7) + sage: GaussianIntegers().valuation(7) # needs sage.rings.number_field 7-adic valuation sage: Zp(11).valuation() 11-adic valuation @@ -21,7 +21,7 @@ sage: v = ZZ.valuation(2) sage: R. = ZZ[] sage: f = x^5 + x^4 + x^3 + x^2 + x - 1 - sage: v.montes_factorization(f, required_precision=20) + sage: v.montes_factorization(f, required_precision=20) # needs sage.geometry.polyhedron (x + 676027) * (x^4 + 372550*x^3 + 464863*x^2 + 385052*x + 297869) AUTHORS: @@ -92,6 +92,7 @@ class PadicValuationFactory(UniqueFactory): quotient of a polynomial ring (since number field extensions always compute an absolute polynomial defining the extension which can be very costly):: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^2 + 1) sage: R. = K[] @@ -115,7 +116,7 @@ def create_key_and_extra_args(self, R, prime=None, approximants=None): EXAMPLES:: - sage: QQ.valuation(2) # indirect doctest + sage: QQ.valuation(2) # indirect doctest 2-adic valuation """ @@ -145,7 +146,7 @@ def create_key_for_integers(self, R, prime): EXAMPLES:: - sage: QQ.valuation(2) # indirect doctest + sage: QQ.valuation(2) # indirect doctest 2-adic valuation """ @@ -166,7 +167,7 @@ def create_key_for_local_ring(self, R, prime): EXAMPLES:: - sage: Qp(2).valuation() # indirect doctest + sage: Qp(2).valuation() # indirect doctest 2-adic valuation """ @@ -188,7 +189,7 @@ def create_key_and_extra_args_for_number_field(self, R, prime, approximants): EXAMPLES:: - sage: GaussianIntegers().valuation(2) # indirect doctest + sage: GaussianIntegers().valuation(2) # indirect doctest # needs sage.rings.number_field 2-adic valuation """ @@ -218,7 +219,7 @@ def create_key_and_extra_args_for_number_field_from_valuation(self, R, v, prime, EXAMPLES:: - sage: GaussianIntegers().valuation(ZZ.valuation(2)) # indirect doctest + sage: GaussianIntegers().valuation(ZZ.valuation(2)) # indirect doctest # needs sage.rings.number_field 2-adic valuation TESTS: @@ -227,10 +228,10 @@ def create_key_and_extra_args_for_number_field_from_valuation(self, R, v, prime, sage: R. = ZZ[] sage: S = R.quo(x^2 + 1) - sage: v = valuations.pAdicValuation(S, 2) + sage: v = valuations.pAdicValuation(S, 2) # needs sage.geometry.polyhedron sage: R. = QQ[] sage: S = R.quo(x^2 + 1) - sage: v = valuations.pAdicValuation(S, v) + sage: v = valuations.pAdicValuation(S, v) # needs sage.geometry.polyhedron """ K, L, G = self._normalize_number_field_data(R) @@ -282,13 +283,15 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): EXAMPLES:: - sage: GaussianIntegers().valuation(GaussianIntegers().number_field().fractional_ideal(2)) # indirect doctest + sage: # needs sage.rings.number_field + sage: GaussianIntegers().valuation(GaussianIntegers().number_field().fractional_ideal(2)) # indirect doctest 2-adic valuation TESTS: Verify that :trac:`28976` has been resolved:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^6 - 18*x^4 - 24*x^3 + 27*x^2 + 36*x - 6) sage: I = K.fractional_ideal((2, -7/44*a^5 + 19/44*a^4 + 87/44*a^3 - 87/44*a^2 - 5/2*a + 39/22)) @@ -301,6 +304,7 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): :: + sage: # needs sage.rings.number_field sage: K. = NumberField([x^2 - 2, x^2 + x + 1]) sage: K.valuation(2) 2-adic valuation @@ -448,9 +452,9 @@ class pAdicValuation_base(DiscreteValuation): TESTS:: - sage: TestSuite(ZZ.valuation(3)).run() # long time - sage: TestSuite(QQ.valuation(5)).run() # long time - sage: TestSuite(Zp(5).valuation()).run() # long time + sage: TestSuite(ZZ.valuation(3)).run() # long time # needs sage.geometry.polyhedron + sage: TestSuite(QQ.valuation(5)).run() # long time # needs sage.geometry.polyhedron + sage: TestSuite(Zp(5).valuation()).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent, p): @@ -473,7 +477,7 @@ def p(self): EXAMPLES:: - sage: GaussianIntegers().valuation(2).p() + sage: GaussianIntegers().valuation(2).p() # needs sage.rings.number_field 2 """ @@ -562,7 +566,7 @@ def is_unramified(self, G, include_steps=False, assume_squarefree=False): However, even if ``G`` factors, it might define an unramified extension:: - sage: v.is_unramified(x^2 + 2*x + 4) + sage: v.is_unramified(x^2 + 2*x + 4) # needs sage.geometry.polyhedron True """ @@ -626,11 +630,12 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: k = Qp(5,4) sage: v = k.valuation() sage: R. = k[] sage: G = x^2 + 1 - sage: v.is_totally_ramified(G) + sage: v.is_totally_ramified(G) # needs sage.geometry.polyhedron False sage: G = x + 1 sage: v.is_totally_ramified(G) @@ -639,9 +644,9 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False): sage: v.is_totally_ramified(G) False sage: G = x^2 + 5 - sage: v.is_totally_ramified(G) + sage: v.is_totally_ramified(G) # needs sage.geometry.polyhedron True - sage: v.is_totally_ramified(G, include_steps=True) + sage: v.is_totally_ramified(G, include_steps=True) # needs sage.geometry.polyhedron (True, [Gauss valuation induced by 5-adic valuation, [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x) = 1/2 ]]) We consider an extension as totally ramified if its ramification index @@ -659,7 +664,7 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False): sage: R = ZpFM(3, 20) sage: S. = R[] sage: f = x^9 + 9*x^2 + 3 - sage: R.valuation().is_totally_ramified(f) + sage: R.valuation().is_totally_ramified(f) # needs sage.geometry.polyhedron True """ @@ -734,11 +739,12 @@ def extensions(self, ring): EXAMPLES:: sage: v = ZZ.valuation(2) - sage: v.extensions(GaussianIntegers()) + sage: v.extensions(GaussianIntegers()) # needs sage.rings.number_field [2-adic valuation] TESTS:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: x = polygen(ZZ, 'x') sage: L. = QQ.extension(x^3 - 2) @@ -749,6 +755,7 @@ def extensions(self, ring): Check that we can extend to a field written as a quotient:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = QQ.extension(x^2 + 1) sage: R. = K[] @@ -759,6 +766,7 @@ def extensions(self, ring): A case where there was at some point an internal error in the approximants code:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: L. = NumberField(x^4 + 2*x^3 + 2*x^2 + 8) sage: QQ.valuation(2).extensions(L) @@ -767,6 +775,7 @@ def extensions(self, ring): A case where the extension was incorrect at some point:: + sage: # needs sage.rings.number_field sage: v = QQ.valuation(2) sage: L. = NumberField(x^2 + 2) sage: M. = L.extension(x^2 + 1) @@ -776,6 +785,7 @@ def extensions(self, ring): A case where the extensions could not be separated at some point:: + sage: # needs sage.rings.number_field sage: v = QQ.valuation(2) sage: R. = QQ[] sage: F = x^48 + 120*x^45 + 56*x^42 + 108*x^36 + 32*x^33 + 40*x^30 + 48*x^27 + 80*x^24 + 112*x^21 + 96*x^18 + 96*x^15 + 24*x^12 + 96*x^9 + 16*x^6 + 96*x^3 + 68 @@ -819,8 +829,8 @@ def restriction(self, ring): EXAMPLES:: - sage: v = GaussianIntegers().valuation(2) - sage: v.restriction(ZZ) + sage: v = GaussianIntegers().valuation(2) # needs sage.rings.number_field + sage: v.restriction(ZZ) # needs sage.rings.number_field 2-adic valuation """ @@ -839,8 +849,8 @@ def value_semigroup(self): EXAMPLES:: - sage: v = GaussianIntegers().valuation(2) - sage: v.value_semigroup() + sage: v = GaussianIntegers().valuation(2) # needs sage.rings.number_field + sage: v.value_semigroup() # needs sage.rings.number_field Additive Abelian Semigroup generated by 1/2 """ @@ -862,12 +872,12 @@ class pAdicValuation_padic(pAdicValuation_base): EXAMPLES:: - sage: v = Qp(2).valuation(); v #indirect doctest + sage: v = Qp(2).valuation(); v #indirect doctest 2-adic valuation TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent): @@ -952,6 +962,7 @@ def element_with_valuation(self, v): sage: v.element_with_valuation(3) 3^3 + O(3^23) + sage: # needs sage.libs.ntl sage: K = Qp(3) sage: R. = K[] sage: L. = K.extension(y^2 + 3*y + 3) @@ -986,9 +997,9 @@ def _call_(self, x): EXAMPLES:: sage: K = Qp(3) - sage: R. = K[] - sage: L. = K.extension(y^2 - 3) - sage: L.valuation()(3) + sage: R. = K[] # needs sage.libs.ntl + sage: L. = K.extension(y^2 - 3) # needs sage.libs.ntl + sage: L.valuation()(3) # needs sage.libs.ntl 1 """ @@ -1000,7 +1011,7 @@ def residue_ring(self): EXAMPLES:: - sage: Qq(9, names='a').valuation().residue_ring() + sage: Qq(9, names='a').valuation().residue_ring() # needs sage.libs.ntl Finite Field in a0 of size 3^2 """ @@ -1027,6 +1038,7 @@ def shift(self, x, s): sage: v.shift(R.one(), -1) O(2^19) + sage: # needs sage.libs.ntl sage.rings.padics sage: S. = R[] sage: S. = R.extension(y^3 - 2) sage: v = S.valuation() @@ -1089,7 +1101,7 @@ class pAdicValuation_int(pAdicValuation_base): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def _repr_(self): @@ -1343,7 +1355,7 @@ class pAdicFromLimitValuation(FiniteExtensionFromLimitValuation, pAdicValuation_ EXAMPLES:: - sage: v = GaussianIntegers().valuation(3); v + sage: v = GaussianIntegers().valuation(3); v # needs sage.rings.number_field 3-adic valuation TESTS:: @@ -1361,9 +1373,9 @@ def __init__(self, parent, approximant, G, approximants): r""" TESTS:: - sage: v = GaussianIntegers().valuation(3) + sage: v = GaussianIntegers().valuation(3) # needs sage.rings.number_field sage: from sage.rings.padics.padic_valuation import pAdicFromLimitValuation - sage: isinstance(v, pAdicFromLimitValuation) + sage: isinstance(v, pAdicFromLimitValuation) # needs sage.rings.number_field True """ @@ -1377,15 +1389,16 @@ def _to_base_domain(self, f): EXAMPLES:: - sage: v = GaussianIntegers().valuation(3) - sage: I = GaussianIntegers().fraction_field().gen() - sage: v._to_base_domain(I) + sage: v = GaussianIntegers().valuation(3) # needs sage.rings.number_field + sage: I = GaussianIntegers().fraction_field().gen() # needs sage.rings.number_field + sage: v._to_base_domain(I) # needs sage.rings.number_field x TESTS: Check that this also works for relative extensions:: + sage: # needs sage.rings.number_field sage: v = QQ.valuation(2) sage: x = polygen(ZZ, 'x') sage: L. = NumberField(x^2 + 2) @@ -1405,8 +1418,8 @@ def _from_base_domain(self, f): EXAMPLES:: - sage: v = GaussianIntegers().valuation(3) - sage: v._from_base_domain(v._base_valuation.domain().gen()) + sage: v = GaussianIntegers().valuation(3) # needs sage.rings.number_field + sage: v._from_base_domain(v._base_valuation.domain().gen()) # needs sage.rings.number_field I """ @@ -1418,8 +1431,8 @@ def extensions(self, ring): EXAMPLES:: - sage: v = GaussianIntegers().valuation(3) - sage: v.extensions(v.domain().fraction_field()) + sage: v = GaussianIntegers().valuation(3) # needs sage.rings.number_field + sage: v.extensions(v.domain().fraction_field()) # needs sage.rings.number_field [3-adic valuation] """ diff --git a/src/sage/rings/padics/pow_computer.pyx b/src/sage/rings/padics/pow_computer.pyx index 1c5bdf86897..ee5cd82d1f2 100644 --- a/src/sage/rings/padics/pow_computer.pyx +++ b/src/sage/rings/padics/pow_computer.pyx @@ -153,7 +153,7 @@ cdef class PowComputer_class(SageObject): EXAMPLES:: sage: PC = PowComputer(3, 5, 10) - sage: PC.pow_Integer_Integer(2) #indirect doctest + sage: PC.pow_Integer_Integer(2) # indirect doctest 9 """ cdef Integer ans = PY_NEW(Integer) @@ -175,6 +175,8 @@ cdef class PowComputer_class(SageObject): 1 sage: PC.pow_Integer_Integer(10) 59049 + + sage: # needs sage.libs.ntl sage: PC = PowComputer_ext_maker(3, 5, 10, 20, False, ntl.ZZ_pX([-3,0,1], 3^10), 'big','e',ntl.ZZ_pX([1],3^10)) sage: PC.pow_Integer_Integer(4) 81 @@ -227,7 +229,7 @@ cdef class PowComputer_class(SageObject): to that mpz_t. So if you try to use the results of two calls at once, things will break. :: - sage: PC._pow_mpz_t_tmp_demo(6, 8) # 244140625 on some architectures and 152587890625 on others: random + sage: PC._pow_mpz_t_tmp_demo(6, 8) # 244140625 on some architectures and 152587890625 on others: random 244140625 sage: 5^6*5^8 6103515625 @@ -266,6 +268,8 @@ cdef class PowComputer_class(SageObject): 1 sage: PC._pow_mpz_t_tmp_test(10) 59049 + + sage: # needs sage.libs.ntl sage: PC = PowComputer_ext_maker(3, 5, 10, 20, False, ntl.ZZ_pX([-3,0,1], 3^10), 'big','e',ntl.ZZ_pX([1],3^10)) sage: PC._pow_mpz_t_tmp_test(4) 81 @@ -288,7 +292,7 @@ cdef class PowComputer_class(SageObject): EXAMPLES:: sage: PC = PowComputer(3, 5, 10) - sage: PC._pow_mpz_t_top_test() #indirect doctest + sage: PC._pow_mpz_t_top_test() # indirect doctest 59049 """ raise NotImplementedError @@ -302,6 +306,8 @@ cdef class PowComputer_class(SageObject): sage: PC = PowComputer(3, 5, 10) sage: PC._pow_mpz_t_top_test() 59049 + + sage: # needs sage.libs.ntl sage: PC = PowComputer_ext_maker(3, 5, 10, 20, False, ntl.ZZ_pX([-3,0,1], 3^10), 'big','e',ntl.ZZ_pX([1],3^10)) sage: PC._pow_mpz_t_top_test() 59049 @@ -426,6 +432,7 @@ cdef class PowComputer_class(SageObject): else: return self.pow_Integer(mpz_get_ui(_n.value)) + cdef class PowComputer_base(PowComputer_class): def __cinit__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, poly=None, shift_seed=None): """ @@ -560,7 +567,7 @@ cdef class PowComputer_base(PowComputer_class): EXAMPLES:: sage: PC = PowComputer(3, 5, 10) - sage: PC._pow_mpz_t_top_test() #indirect doctest + sage: PC._pow_mpz_t_top_test() #indirect doctest 59049 """ return self.top_power @@ -604,7 +611,7 @@ cdef PowComputer_base PowComputer_c(Integer m, Integer cache_limit, Integer prec EXAMPLES:: - sage: PC = PowComputer(3, 5, 10) # indirect doctest + sage: PC = PowComputer(3, 5, 10) # indirect doctest sage: PC(4) 81 """ diff --git a/src/sage/rings/padics/pow_computer_ext.pyx b/src/sage/rings/padics/pow_computer_ext.pyx index 1626990a051..2a5b3361d3e 100644 --- a/src/sage/rings/padics/pow_computer_ext.pyx +++ b/src/sage/rings/padics/pow_computer_ext.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.padics """ PowComputer_ext @@ -89,7 +90,7 @@ cdef int ZZ_pX_Eis_init(PowComputer_ZZ_pX prime_pow, ntl_ZZ_pX shift_seed) excep EXAMPLES:: - sage: A = PowComputer_ext_maker(5, 10, 10, 40, False, ntl.ZZ_pX([-5,65,125,0,1],5^10), 'small','e',ntl.ZZ_pX([1,-13,-25],5^10)) # indirect doctest + sage: A = PowComputer_ext_maker(5, 10, 10, 40, False, ntl.ZZ_pX([-5,65,125,0,1],5^10), 'small','e',ntl.ZZ_pX([1,-13,-25],5^10)) # indirect doctest """ if prime_pow.deg <= 1: raise ValueError("Eisenstein extension must have degree at least 2") @@ -308,7 +309,7 @@ cdef int ZZ_pX_eis_shift_p(PowComputer_ZZ_pX self, ZZ_pX_c* x, ZZ_pX_c* a, long sage: R. = QQ[] sage: K = Qp(11,10) - sage: J. = K.extension(x^30-11) + sage: J. = K.extension(x^30 - 11) sage: M. = PowerSeriesRing(J) sage: S. = QQ[] sage: xr = O(a^152)*t + (8*a^2 + 10*a^32 + 7*a^62 + 10*a^92 + 7*a^122 + O(a^152))*t^2 + O(a^154)*t^3 + (2*a^4 + 10*a^64 + 2*a^124 + O(a^154))*t^4 + O(a^156)*t^5 + (5*a^6 + 2*a^96 + a^126 + O(a^156))*t^6 + O(a^158)*t^7 + (7*a^8 + 6*a^38 + 8*a^68 + 2*a^98 + 5*a^128 + O(a^158))*t^8 + O(a^160)*t^9 + (8*a^10 + 10*a^40 + a^70 + 5*a^130 + O(a^160))*t^10 + O(a^162)*t^11 + (9*a^12 + 7*a^42 + 8*a^72 + 6*a^102 + 9*a^132 + O(a^162))*t^12 + O(a^164)*t^13 + (2*a^14 + 5*a^44 + 3*a^74 + a^104 + 4*a^134 + O(a^164))*t^14 + O(a^166)*t^15 + (2*a^16 + 5*a^46 + 8*a^76 + 5*a^106 + 7*a^136 + O(a^166))*t^16 + O(a^168)*t^17 + (7*a^18 + 3*a^48 + 6*a^78 + 9*a^138 + O(a^168))*t^18 + O(a^172)*t^19 + (7*a^50 + 3*a^80 + 5*a^110 + 5*a^140 + 7*a^170 + O(a^172))*t^20 + O(a^172)*t^21 + (a^22 + a^52 + 3*a^82 + 3*a^112 + 2*a^142 + O(a^172))*t^22 + O(a^174)*t^23 + (4*a^24 + 7*a^54 + 9*a^84 + 4*a^114 + 7*a^144 + O(a^174))*t^24 + O(a^176)*t^25 + (3*a^26 + 8*a^56 + 8*a^116 + 5*a^146 + O(a^176))*t^26 + O(a^178)*t^27 + (2*a^28 + 2*a^58 + 6*a^88 + a^118 + 10*a^148 + O(a^178))*t^28 + O(a^180)*t^29 + (8*a^30 + 5*a^60 + 8*a^90 + 5*a^120 + 6*a^150 + O(a^180))*t^30 + O(a^184)*t^31 + (7*a^62 + 9*a^92 + 2*a^182 + O(a^184))*t^32 @@ -468,7 +469,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: - sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) #indirect doctest + sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) # indirect doctest """ PowComputer_class.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly, shift_seed) @@ -504,7 +505,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del PC # indirect doctest + sage: del PC # indirect doctest """ if (self)._initialized: self.cleanup_ext() @@ -516,7 +517,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC # indirect doctest + sage: PC # indirect doctest PowComputer_ext for 5, with polynomial [9765620 0 1] """ return "PowComputer_ext for %s, with polynomial %s"%(self.prime, self.polynomial()) @@ -548,7 +549,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del PC # indirect doctest + sage: del PC # indirect doctest """ Delete_ZZ_array(self.small_powers) mpz_clear(self.temp_m) @@ -574,7 +575,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._pow_mpz_t_tmp_test(4) #indirect doctest + sage: PC._pow_mpz_t_tmp_test(4) # indirect doctest 625 """ if n < 0: @@ -611,7 +612,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._pow_mpz_t_tmp_test(4) #indirect doctest + sage: PC._pow_mpz_t_tmp_test(4) # indirect doctest 625 """ if n < 0: @@ -685,7 +686,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 6, 6, 12, False, ntl.ZZ_pX([-5,0,1],5^6),'small', 'e',ntl.ZZ_pX([1],5^6)) - sage: PC._pow_mpz_t_top_test() #indirect doctest + sage: PC._pow_mpz_t_top_test() #indirect doctest 15625 """ ZZ_to_mpz(self.temp_m, &self.top_power) @@ -698,7 +699,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 6, 6, 12, False, ntl.ZZ_pX([-5,0,1],5^6),'small', 'e',ntl.ZZ_pX([1],5^6)) - sage: PC._pow_ZZ_top_test() #indirect doctest + sage: PC._pow_ZZ_top_test() # indirect doctest 15625 """ return &self.top_power @@ -770,7 +771,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_context_test(15) #indirect doctest + sage: PC._get_context_test(15) # indirect doctest NTL modulus 30517578125 """ cdef ntl_ZZ pn = ntl_ZZ.__new__(ntl_ZZ) @@ -806,7 +807,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_context_capdiv_test(30) #indirect doctest + sage: PC._get_context_capdiv_test(30) # indirect doctest NTL modulus 30517578125 """ return self.get_context(self.capdiv(n)) @@ -844,7 +845,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5, 0, 1], 5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC.speed_test(10, 10^6) # random + sage: PC.speed_test(10, 10^6) # random 0.0090679999999991878 """ cdef Py_ssize_t i, end, _n @@ -863,7 +864,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): TESTS:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_top_context_test() #indirect doctest + sage: PC._get_top_context_test() # indirect doctest NTL modulus 9765625 """ return self.get_context(self.prec_cap) @@ -887,7 +888,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_context_test(4) #indirect doctest + sage: PC._restore_context_test(4) # indirect doctest """ self.get_context(n).restore_c() @@ -910,7 +911,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_context_capdiv_test(4) #indirect doctest + sage: PC._restore_context_capdiv_test(4) # indirect doctest """ self.restore_context(self.capdiv(n)) @@ -921,7 +922,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_context_capdiv_test(8) #indirect doctest + sage: PC._restore_context_capdiv_test(8) #indirect doctest """ cdef Integer _n = Integer(n) self.restore_context_capdiv(mpz_get_si(_n.value)) @@ -957,7 +958,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): sage: A = PowComputer_ext_maker(5, 10, 1000, 2000, False, ntl.ZZ_pX([-5,0,1],5^1000), 'big', 'e',ntl.ZZ_pX([1],5^1000)) sage: a = ntl.ZZ_pX([4,2],5^2) sage: b = ntl.ZZ_pX([6,3],5^2) - sage: A._get_modulus_test(a, b, 2) # indirect doctest + sage: A._get_modulus_test(a, b, 2) # indirect doctest [4 24] """ # Exception will be ignored by Cython @@ -976,7 +977,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): [4 24] sage: a * b [24 24 6] - sage: mod(6 * 5 + 24, 25) + sage: mod(6 * 5 + 24, 25) # needs sage.rings.finite_rings 4 """ if self.pow_Integer(mpz_get_si(n.value)) != Integer(a.c.p): @@ -1008,7 +1009,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_top_modulus_test(a, b) #indirect doctest + sage: A._get_top_modulus_test(a, b) # indirect doctest [1783058 7785200] """ # Exception will be ignored by Cython @@ -1028,7 +1029,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): [1783058 7785200] sage: a*b [9560618 7785200 397613] - sage: mod(397613 * 5 + 9560618, 5^10) + sage: mod(397613 * 5 + 9560618, 5^10) # needs sage.rings.finite_rings 1783058 """ cdef ntl_ZZ_pX ans = a._new() @@ -1119,7 +1120,6 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): sage: W. = R.ext(f) sage: y = W.teichmuller(3,10); y 3 + 13*w^5 + 4*w^7 + 9*w^8 + 13*w^9 + O(w^10) - sage: y^17 == y True sage: g = x^3 + 9*x^2 + 1 @@ -1226,7 +1226,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): EXAMPLES:: - sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) #indirect doctest + sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) # indirect doctest sage: A PowComputer_ext for 5, with polynomial [9765620 0 1] """ @@ -1259,7 +1259,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_top_context_test() # indirect doctest + sage: PC._get_top_context_test() # indirect doctest NTL modulus 9765625 """ return self.c @@ -1271,7 +1271,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_top_context_test() #indirect doctest + sage: PC._restore_top_context_test() # indirect doctest """ self.c.restore_c() @@ -1284,7 +1284,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_top_modulus_test(a, b) #indirect doctest + sage: A._get_top_modulus_test(a, b) # indirect doctest [1783058 7785200] """ return &self.mod @@ -1300,7 +1300,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_modulus_test(a, b, 10) #indirect doctest + sage: A._get_modulus_test(a, b, 10) # indirect doctest [1783058 7785200] """ if n == self.prec_cap: @@ -1320,7 +1320,7 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): TESTS:: - sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) #indirect doctest + sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) # indirect doctest """ # The __new__ method for PowComputer_ZZ_pX_FM has already run, so we have access to self.mod self._ext_type = 'e' @@ -1420,7 +1420,7 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): TESTS:: sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ if self._initialized: self.cleanup_ZZ_pX_FM_Eis() @@ -1433,7 +1433,7 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): TESTS:: sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ Delete_ZZ_pX_Multiplier_array(self.low_shifter) Delete_ZZ_pX_Multiplier_array(self.high_shifter) @@ -1448,7 +1448,7 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): sage: from sage.rings.padics.pow_computer_ext import ZZ_pX_eis_shift_test sage: A = PowComputer_ext_maker(5, 3, 10, 40, False, ntl.ZZ_pX([-5,75,15,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1,-15,-3],5^10)) - sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) #indirect doctest + sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) # indirect doctest [1] sage: ZZ_pX_eis_shift_test(A, [0, 0, 1], 1, 5) [0 1] @@ -1547,7 +1547,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: - sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) # indirect doctest + sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) # indirect doctest sage: A PowComputer_ext for 5, with polynomial [9765620 0 1] """ @@ -1609,7 +1609,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ if self._initialized: self.cleanup_ZZ_pX_small() @@ -1621,7 +1621,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ Delete_ZZ_pX_Modulus_array(self.mod) @@ -1641,7 +1641,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: A._get_context_test(4) #indirect doctest + sage: A._get_context_test(4) # indirect doctest NTL modulus 625 """ if n < 0: @@ -1663,7 +1663,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: A._restore_context_test(4) #indirect doctest + sage: A._restore_context_test(4) # indirect doctest """ if n < 0: n = -n @@ -1679,7 +1679,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_top_context_test() # indirect doctest + sage: PC._get_top_context_test() # indirect doctest NTL modulus 9765625 """ return self.c[self.prec_cap] @@ -1691,7 +1691,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_top_context_test() #indirect doctest + sage: PC._restore_top_context_test() # indirect doctest """ (self.c[self.prec_cap]).restore_c() @@ -1732,7 +1732,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small','e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_top_modulus_test(a, b) #indirect doctest + sage: A._get_top_modulus_test(a, b) # indirect doctest [1783058 7785200] """ return &(self.mod[self.prec_cap]) @@ -1853,7 +1853,7 @@ cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): TESTS:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'small', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ if self._initialized: self.cleanup_ZZ_pX_small_Eis() @@ -1866,7 +1866,7 @@ cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): TESTS:: sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ Delete_ZZ_pX_array(self.low_shifter) Delete_ZZ_pX_array(self.high_shifter) @@ -1881,7 +1881,7 @@ cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): sage: from sage.rings.padics.pow_computer_ext import ZZ_pX_eis_shift_test sage: A = PowComputer_ext_maker(5, 10, 10, 40, False, ntl.ZZ_pX([-5,75,15,0,1],5^10), 'small', 'e',ntl.ZZ_pX([1,-15,-3],5^10)) - sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) #indirect doctest + sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) # indirect doctest [1] sage: ZZ_pX_eis_shift_test(A, [0, 0, 1], 1, 5) [0 1] @@ -1911,7 +1911,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: - sage: A = PowComputer_ext_maker(5, 6, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) # indirect doctest + sage: A = PowComputer_ext_maker(5, 6, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) # indirect doctest sage: A PowComputer_ext for 5, with polynomial [9765620 0 1] """ @@ -1976,7 +1976,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 6, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ if self._initialized: self.cleanup_ZZ_pX_big() @@ -1988,7 +1988,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 6, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ Delete_ZZ_pX_Modulus_array(self.modulus_list) @@ -2063,9 +2063,9 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: A = PowComputer_ext_maker(5, 6, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big') - sage: A._get_context_test(4) #indirect doctest + sage: A._get_context_test(4) # indirect doctest NTL modulus 625 - sage: A._get_context_test(8) #indirect doctest + sage: A._get_context_test(8) # indirect doctest NTL modulus 390625 """ if n == 0: @@ -2091,7 +2091,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) - sage: PC._get_top_context_test() # indirect doctest + sage: PC._get_top_context_test() # indirect doctest NTL modulus 9765625 """ return self.top_context @@ -2103,7 +2103,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_top_context_test() #indirect doctest + sage: PC._restore_top_context_test() #indirect doctest """ self.top_context.restore_c() @@ -2120,13 +2120,13 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([4,2],5^2) sage: b = ntl.ZZ_pX([6,3],5^2) - sage: A._get_modulus_test(a, b, 2) # indirect doctest + sage: A._get_modulus_test(a, b, 2) # indirect doctest [4 24] sage: a = ntl.ZZ_pX([4,2],5^6) sage: b = ntl.ZZ_pX([6,3],5^6) - sage: A._get_modulus_test(a, b, 6) # indirect doctest + sage: A._get_modulus_test(a, b, 6) # indirect doctest [54 24] - sage: A._get_modulus_test(a, b, 6) # indirect doctest + sage: A._get_modulus_test(a, b, 6) # indirect doctest [54 24] """ cdef ntl_ZZ_pX tmp @@ -2163,7 +2163,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_top_modulus_test(a, b) #indirect doctest + sage: A._get_top_modulus_test(a, b) #indirect doctest [1783058 7785200] """ return &self.top_mod @@ -2284,7 +2284,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): TESTS:: sage: A = PowComputer_ext_maker(5, 10, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ if self._initialized: self.cleanup_ZZ_pX_big_Eis() @@ -2297,7 +2297,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): TESTS:: sage: A = PowComputer_ext_maker(5, 3, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: del A # indirect doctest + sage: del A # indirect doctest """ Delete_ZZ_pX_array(self.low_shifter) Delete_ZZ_pX_array(self.high_shifter) @@ -2312,7 +2312,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): sage: from sage.rings.padics.pow_computer_ext import ZZ_pX_eis_shift_test sage: A = PowComputer_ext_maker(5, 10, 10, 40, False, ntl.ZZ_pX([-5,75,15,0,1],5^10), 'big', 'e',ntl.ZZ_pX([1,-15,-3],5^10)) - sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) #indirect doctest + sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) #indirect doctest [1] sage: ZZ_pX_eis_shift_test(A, [0, 0, 1], 1, 5) [0 1] diff --git a/src/sage/rings/padics/pow_computer_relative.pyx b/src/sage/rings/padics/pow_computer_relative.pyx index 2253281bd35..0785fd5ba8b 100644 --- a/src/sage/rings/padics/pow_computer_relative.pyx +++ b/src/sage/rings/padics/pow_computer_relative.pyx @@ -41,6 +41,7 @@ cdef class PowComputer_relative(PowComputer_class): EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[] @@ -52,7 +53,7 @@ cdef class PowComputer_relative(PowComputer_class): TESTS:: sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative - sage: isinstance(PC, PowComputer_relative) + sage: isinstance(PC, PowComputer_relative) # needs sage.libs.flint True """ @@ -60,6 +61,7 @@ cdef class PowComputer_relative(PowComputer_class): r""" TESTS:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[] @@ -75,12 +77,13 @@ cdef class PowComputer_relative(PowComputer_class): r""" TESTS:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[]; f = x^3 - 5*x - 5*a sage: RFP = R.change(field=False, show_prec=False, type='floating-point') sage: shift_seed = (-f[:3] // 5).change_ring(RFP) - sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest + sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest sage: TestSuite(PC).run() """ @@ -105,6 +108,7 @@ cdef class PowComputer_relative(PowComputer_class): r""" TESTS:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[] @@ -122,13 +126,14 @@ cdef class PowComputer_relative(PowComputer_class): TESTS:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[] sage: f = x^3 - 5*x - 5*a sage: RFP = R.change(field=False, show_prec=False, type='floating-point') sage: shift_seed = (-f[:3] // 5).change_ring(RFP) - sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest + sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest sage: loads(dumps(PC)) == PC True """ @@ -140,13 +145,14 @@ cdef class PowComputer_relative(PowComputer_class): EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25,print_pos=False,show_prec=False) sage: S. = R[] sage: f = x^3 + 5*x + 5*a sage: RFP = R.change(field=False, show_prec=False, type='floating-point') sage: shift_seed = (-f[:3] // 5).change_ring(RFP) - sage: PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest + sage: PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest Relative PowComputer for modulus x^3 + 5*x + a*5 """ @@ -167,12 +173,13 @@ cdef class PowComputer_relative(PowComputer_class): EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[]; f = x^3 - 5*x - 5*a sage: RFP = R.change(field=False, show_prec=False, type='floating-point') sage: shift_seed = (-f[:3] // 5).change_ring(RFP) - sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest + sage: PC = PowComputer_relative_maker(5, 20, 20, 60, False, f, shift_seed, 'fixed-mod') # indirect doctest sage: PC.polynomial() is f True @@ -188,6 +195,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_eis, PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[]; f = x^3 - 5*x - 5*a @@ -197,7 +205,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): TESTS:: - sage: isinstance(PC, PowComputer_relative_eis) + sage: isinstance(PC, PowComputer_relative_eis) # needs sage.libs.flint True """ @@ -205,6 +213,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): r""" TESTS:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25) sage: S. = R[]; f = x^3 - 5*x - 5*a @@ -234,6 +243,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25,3) sage: S. = R[]; f = x^3 - 5*x - 5*a @@ -281,6 +291,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(25, prec=3) sage: S. = R[]; f = x^3 - 5*x - 5*a sage: W. = R.ext(f) @@ -313,6 +324,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(25, prec=3) sage: S. = R[]; f = x^3 - 5*x - 5*a sage: W. = R.ext(f) @@ -346,6 +358,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(25, prec=3) sage: S. = R[]; f = x^3 - 5*x - 5*a sage: W. = R.ext(f) @@ -403,6 +416,7 @@ def PowComputer_relative_maker(prime, cache_limit, prec_cap, ram_prec_cap, in_fi EXAMPLES:: + sage: # needs sage.libs.flint sage: from sage.rings.padics.pow_computer_relative import PowComputer_relative_maker sage: R. = ZqFM(25, prec=2) sage: S. = R[] diff --git a/src/sage/rings/padics/relative_extension_leaves.py b/src/sage/rings/padics/relative_extension_leaves.py index a9f20adce21..0310f2b21c3 100644 --- a/src/sage/rings/padics/relative_extension_leaves.py +++ b/src/sage/rings/padics/relative_extension_leaves.py @@ -39,6 +39,7 @@ class pAdicRelativeBaseringInjection(Morphism): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(125) sage: R. = K[] sage: W. = K.extension(x^3 + 15*a*x - 5*(1+a^2)) @@ -53,6 +54,7 @@ def __init__(self, R, S): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(125) sage: R. = K[] sage: W. = K.extension(x^3 + 15*a*x - 5*(1+a^2)) @@ -72,11 +74,12 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(125,2) sage: R. = K[] sage: W. = K.extension(x^3 + 15*a*x - 5*(1+a^2)) sage: f = W.coerce_map_from(K) - sage: f(a+5) # indirect doctest + sage: f(a+5) # indirect doctest a + (4*a^2 + 4*a + 3)*w^3 + (a + 2)*w^4 + (2*a^2 + 4*a + 2)*w^5 + O(w^6) """ if x.is_zero(): @@ -91,13 +94,14 @@ def _call_with_args(self, x, args=(), kwds={}): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(125,2) sage: R. = K[] sage: W. = K.extension(x^3 + 15*a*x - 5*(1+a^2)) sage: f = W.coerce_map_from(K) sage: f(5*a,5) (4*a^2 + a + 3)*w^3 + (a^2 + 2*a)*w^4 + O(w^5) - sage: f(5*a,8,2) # indirect doctest + sage: f(5*a,8,2) # indirect doctest (4*a^2 + a + 3)*w^3 + (a^2 + 2*a)*w^4 + O(w^5) """ return self.codomain()([x], *args, **kwds) @@ -108,6 +112,7 @@ def section(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(125,2) sage: R. = K[] sage: W. = K.extension(x^3 + 15*a*x - 5*(1+a^2)) @@ -124,6 +129,7 @@ class pAdicRelativeBaseringSection(Morphism): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^10) sage: R. = K[] sage: W. = K.extension(x^4 + 2*a*x^2 - 16*x - 6) @@ -138,6 +144,7 @@ def __init__(self, S, R): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^10) sage: R. = K[] sage: W. = K.extension(x^4 + 2*a*x^2 - 16*x - 6*a) @@ -153,11 +160,12 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^10) sage: R. = K[] sage: W. = K.extension(x^4 + 2*a*x^2 - 16*x - 6*a) sage: f = K.convert_map_from(W) - sage: f(a + w - w) # indirect doctest + sage: f(a + w - w) # indirect doctest a + O(2^20) sage: f(w) Traceback (most recent call last): @@ -175,11 +183,12 @@ def _call_with_args(self, x, args=(), kwds={}): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K. = Qq(2^10) sage: R. = K[] sage: W. = K.extension(x^4 + 2*a*x^2 - 16*x - 6*a) sage: f = K.convert_map_from(W) - sage: f(a, 5) # indirect doctest + sage: f(a, 5) # indirect doctest a + O(2^5) """ return self.codomain()(self._call_(x), *args, **kwds) @@ -190,6 +199,7 @@ class RelativeRamifiedExtensionRingFixedMod(EisensteinExtensionGeneric, pAdicFix EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqFM(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -203,10 +213,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqFM(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() @@ -225,6 +236,7 @@ class RelativeRamifiedExtensionRingCappedAbsolute(EisensteinExtensionGeneric, pA EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqCA(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -238,10 +250,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqCA(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() @@ -260,6 +273,7 @@ class RelativeRamifiedExtensionRingCappedRelative(EisensteinExtensionGeneric, pA EXAMPLES:: + sage: # needs sage.libs.ntl sage: A. = ZqCR(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -273,10 +287,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.ntl sage: A. = ZqCR(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() @@ -295,6 +310,7 @@ class RelativeRamifiedExtensionFieldCappedRelative(EisensteinExtensionGeneric, p EXAMPLES:: + sage: # needs sage.libs.ntl sage: A. = QqCR(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -308,10 +324,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.ntl sage: A. = QqCR(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() @@ -332,6 +349,7 @@ class RelativeRamifiedExtensionRingFloatingPoint(EisensteinExtensionGeneric, pAd EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqFP(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -345,10 +363,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = ZqFP(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() @@ -367,6 +386,7 @@ class RelativeRamifiedExtensionFieldFloatingPoint(EisensteinExtensionGeneric, pA EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = QqFP(2^10) sage: R. = A[] sage: W. = A.extension(x^4 + 2*a*x^2 - 16*x - 6*a); W @@ -380,10 +400,11 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed, EXAMPLES:: + sage: # needs sage.libs.flint sage: A. = QqFP(5^4) sage: R. = A[] sage: W. = A.extension(x^3 - 25*(a+1)*x + 10*(a^2+2)) - sage: TestSuite(W).run(max_samples=16) # long time + sage: TestSuite(W).run(max_samples=16) # long time """ self._exact_modulus = exact_modulus unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree() diff --git a/src/sage/rings/padics/relative_ramified_CA.pyx b/src/sage/rings/padics/relative_ramified_CA.pyx index 0a2df891f87..42337d04979 100644 --- a/src/sage/rings/padics/relative_ramified_CA.pyx +++ b/src/sage/rings/padics/relative_ramified_CA.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint include "sage/libs/linkages/padics/Polynomial_ram.pxi" include "CA_template.pxi" diff --git a/src/sage/rings/padics/relative_ramified_CR.pyx b/src/sage/rings/padics/relative_ramified_CR.pyx index fa2defc6b34..5263c190966 100644 --- a/src/sage/rings/padics/relative_ramified_CR.pyx +++ b/src/sage/rings/padics/relative_ramified_CR.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.ntl include "sage/libs/linkages/padics/Polynomial_ram.pxi" include "CR_template.pxi" diff --git a/src/sage/rings/padics/relative_ramified_FM.pyx b/src/sage/rings/padics/relative_ramified_FM.pyx index 739da94f7c3..27d18035ccb 100644 --- a/src/sage/rings/padics/relative_ramified_FM.pyx +++ b/src/sage/rings/padics/relative_ramified_FM.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint include "sage/libs/linkages/padics/Polynomial_ram.pxi" include "FM_template.pxi" diff --git a/src/sage/rings/padics/relative_ramified_FP.pyx b/src/sage/rings/padics/relative_ramified_FP.pyx index 4fd227c4f4d..3cbae5e55d3 100644 --- a/src/sage/rings/padics/relative_ramified_FP.pyx +++ b/src/sage/rings/padics/relative_ramified_FP.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint include "sage/libs/linkages/padics/Polynomial_ram.pxi" include "FP_template.pxi" diff --git a/src/sage/rings/padics/relaxed_template.pxi b/src/sage/rings/padics/relaxed_template.pxi index a18ffb1cb03..0facf94380d 100644 --- a/src/sage/rings/padics/relaxed_template.pxi +++ b/src/sage/rings/padics/relaxed_template.pxi @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" Template for relaxed `p`-adic rings and fields. diff --git a/src/sage/rings/padics/tests.py b/src/sage/rings/padics/tests.py index 5574f931356..1d0e3f3c5d6 100644 --- a/src/sage/rings/padics/tests.py +++ b/src/sage/rings/padics/tests.py @@ -2,8 +2,8 @@ TESTS:: sage: R = Zp(5, prec=5, type='fixed-mod') - sage: a = random_matrix(R,5) - sage: a.determinant().parent() is R + sage: a = random_matrix(R,5) # needs sage.geometry.polyhedron + sage: a.determinant().parent() is R # needs sage.geometry.polyhedron True sage: K = Qp(3, 10,'capped-rel'); K.krull_dimension() 0 @@ -26,8 +26,8 @@ sage: a = Zp(5)(-3); loads(dumps(a)) == a True - sage: M = MatrixSpace(pAdicField(3,100),2) - sage: (M([1,0,0,90]) - (1+O(3^100)) * M(1)).left_kernel() + sage: M = MatrixSpace(pAdicField(3,100),2) # needs sage.geometry.polyhedron + sage: (M([1,0,0,90]) - (1+O(3^100)) * M(1)).left_kernel() # needs sage.geometry.polyhedron Vector space of degree 2 and dimension 1 over 3-adic Field with capped relative precision 100 Basis matrix: [1 + O(3^100) 0] diff --git a/src/sage/rings/padics/tutorial.py b/src/sage/rings/padics/tutorial.py index d281ae663a9..20ffeacf586 100644 --- a/src/sage/rings/padics/tutorial.py +++ b/src/sage/rings/padics/tutorial.py @@ -309,7 +309,7 @@ ``Zq`` also requires a name for the generator of the residue field. One can specify this name as follows:: - sage: R. = Zq(125, prec = 20); R + sage: R. = Zq(125, prec = 20); R # needs sage.libs.ntl 5-adic Unramified Extension Ring in c defined by x^3 + 3*x + 3 Eisenstein Extensions @@ -328,11 +328,11 @@ Finally, use the ``ext`` function on the ground field to create the desired extension.:: - sage: W. = R.ext(f) + sage: W. = R.ext(f) # needs sage.libs.ntl sage.rings.padics You can do arithmetic in this Eisenstein extension:: - sage: (1 + w)^7 + sage: (1 + w)^7 # needs sage.libs.ntl 1 + 2*w + w^2 + w^5 + 3*w^6 + 3*w^7 + 3*w^8 + w^9 + O(w^10) Note that the precision cap increased by a factor of 5, since the diff --git a/src/sage/rings/padics/unramified_extension_generic.py b/src/sage/rings/padics/unramified_extension_generic.py index b73b88ebc1c..c4f8612db69 100644 --- a/src/sage/rings/padics/unramified_extension_generic.py +++ b/src/sage/rings/padics/unramified_extension_generic.py @@ -44,7 +44,7 @@ def __init__(self, poly, prec, print_mode, names, element_class): EXAMPLES:: - sage: R. = Zq(27) #indirect doctest + sage: R. = Zq(27) #indirect doctest # needs sage.libs.ntl """ #base = poly.base_ring() #if base.is_field(): @@ -63,12 +63,12 @@ def _extension_type(self): EXAMPLES:: - sage: K. = Qq(5^3) - sage: K._extension_type() + sage: K. = Qq(5^3) # needs sage.libs.ntl + sage: K._extension_type() # needs sage.libs.ntl 'Unramified' sage: x = polygen(ZZ, 'x') - sage: L. = Qp(5).extension(x^2 - 5) + sage: L. = Qp(5).extension(x^2 - 5) # needs sage.libs.ntl sage: L._extension_type() 'Eisenstein' """ @@ -81,13 +81,13 @@ def absolute_f(self): EXAMPLES:: - sage: K. = Qq(3^5) - sage: K.absolute_f() + sage: K. = Qq(3^5) # needs sage.libs.ntl + sage: K.absolute_f() # needs sage.libs.ntl 5 sage: x = polygen(ZZ, 'x') - sage: L. = Qp(3).extension(x^2 - 3) - sage: L.absolute_f() + sage: L. = Qp(3).extension(x^2 - 3) # needs sage.libs.ntl + sage: L.absolute_f() # needs sage.libs.ntl 1 """ return self.modulus().degree() * self.base_ring().absolute_f() @@ -104,7 +104,7 @@ def residue_class_field(self): EXAMPLES:: - sage: R. = Zq(125); R.residue_class_field() + sage: R. = Zq(125); R.residue_class_field() # needs sage.libs.ntl Finite Field in a0 of size 5^3 """ #should eventually take advantage of finite field @@ -119,13 +119,13 @@ def residue_ring(self, n): EXAMPLES:: - sage: R. = Zq(125) - sage: R.residue_ring(1) + sage: R. = Zq(125) # needs sage.libs.ntl + sage: R.residue_ring(1) # needs sage.libs.ntl Finite Field in a0 of size 5^3 The following requires implementing more general Artinian rings:: - sage: R.residue_ring(2) + sage: R.residue_ring(2) # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError @@ -145,8 +145,8 @@ def discriminant(self, K=None): EXAMPLES:: - sage: R. = Zq(125) - sage: R.discriminant() + sage: R. = Zq(125) # needs sage.libs.ntl + sage: R.discriminant() # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError @@ -186,7 +186,7 @@ def is_galois(self, K=None): EXAMPLES:: - sage: R. = Zq(125); R.is_galois() + sage: R. = Zq(125); R.is_galois() # needs sage.libs.ntl True """ if K is None or K is self: @@ -203,7 +203,7 @@ def gen(self, n=0): EXAMPLES:: - sage: R. = Zq(125); R.gen() + sage: R. = Zq(125); R.gen() # needs sage.libs.ntl a + O(5^20) """ if n != 0: @@ -217,8 +217,8 @@ def _frob_gen(self, arithmetic=True): EXAMPLES:: - sage: R. = Zq(9) - sage: R._frob_gen() + sage: R. = Zq(9) # needs sage.libs.ntl + sage: R._frob_gen() # needs sage.libs.ntl (2*a + 1) + (2*a + 2)*3 + (2*a + 2)*3^2 + (2*a + 2)*3^3 + (2*a + 2)*3^4 + (2*a + 2)*3^5 + (2*a + 2)*3^6 + (2*a + 2)*3^7 + (2*a + 2)*3^8 + (2*a + 2)*3^9 + (2*a + 2)*3^10 + (2*a + 2)*3^11 + (2*a + 2)*3^12 + (2*a + 2)*3^13 + (2*a + 2)*3^14 + (2*a + 2)*3^15 + (2*a + 2)*3^16 + (2*a + 2)*3^17 + (2*a + 2)*3^18 + (2*a + 2)*3^19 + O(3^20) """ p = self.prime() @@ -239,8 +239,8 @@ def uniformizer_pow(self, n): EXAMPLES:: - sage: R. = ZqCR(125) - sage: R.uniformizer_pow(5) + sage: R. = ZqCR(125) # needs sage.libs.ntl + sage: R.uniformizer_pow(5) # needs sage.libs.ntl 5^5 + O(5^25) """ return self(self.prime_pow(n)) @@ -254,8 +254,8 @@ def uniformizer(self): EXAMPLES:: - sage: R. = ZqCR(125) - sage: R.uniformizer() + sage: R. = ZqCR(125) # needs sage.libs.ntl + sage: R.uniformizer() # needs sage.libs.ntl 5 + O(5^21) """ return self(self.ground_ring().uniformizer()) @@ -266,7 +266,7 @@ def _uniformizer_print(self): EXAMPLES:: - sage: R. = Zq(125); R._uniformizer_print() + sage: R. = Zq(125); R._uniformizer_print() # needs sage.libs.ntl '5' """ return self.ground_ring()._uniformizer_print() @@ -277,7 +277,7 @@ def _unram_print(self): EXAMPLES:: - sage: R. = Zq(125); R._unram_print() + sage: R. = Zq(125); R._unram_print() # needs sage.libs.ntl 'a' """ return self.variable_name() @@ -300,9 +300,9 @@ def has_pth_root(self): EXAMPLES:: - sage: R. = Zq(1024); R.has_pth_root() + sage: R. = Zq(1024); R.has_pth_root() # needs sage.libs.ntl True - sage: R. = Zq(17^5); R.has_pth_root() + sage: R. = Zq(17^5); R.has_pth_root() # needs sage.libs.ntl False """ return self.ground_ring().has_pth_root() @@ -323,6 +323,7 @@ def has_root_of_unity(self, n): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(37^8) sage: R.has_root_of_unity(144) True diff --git a/src/sage/rings/polynomial/padics/polynomial_padic.py b/src/sage/rings/polynomial/padics/polynomial_padic.py index b9c16923cc3..f19d6ccefa4 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic.py @@ -36,7 +36,7 @@ def _repr(self, name=None): r""" EXAMPLES:: - sage: R. = PolynomialRing(Zp(5, prec=5, type = 'capped-abs', print_mode = 'val-unit')) + sage: R. = PolynomialRing(Zp(5, prec=5, type='capped-abs', print_mode='val-unit')) sage: f = 24 + R(4/3)*w + w^4 sage: f._repr() '(1 + O(5^5))*w^4 + O(5^5)*w^3 + O(5^5)*w^2 + (1043 + O(5^5))*w + 24 + O(5^5)' @@ -45,6 +45,7 @@ def _repr(self, name=None): TESTS:: + sage: # needs sage.libs.ntl sage: k = Qp(5,10) sage: R. = k[] sage: f = R([k(0,-3), 0, k(0,-1)]); f @@ -97,6 +98,7 @@ def content(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: K = Zp(13,7) sage: R. = K[] sage: f = 13^7*t^3 + K(169,4)*t - 13^4 @@ -109,6 +111,7 @@ def content(self): sage: f.content() O(13^3) + sage: # needs sage.libs.ntl sage: P. = ZZ[] sage: f = x + 2 sage: f.content() @@ -125,6 +128,7 @@ def content(self): content is only defined up to multiplication with a unit. However, we return `\pi^k` where `k` is the minimal valuation of any coefficient:: + sage: # needs sage.libs.ntl sage: K = Qp(13,7) sage: R. = K[] sage: f = 13^7*t^3 + K(169,4)*t - 13^-4 @@ -152,7 +156,8 @@ def factor(self): EXAMPLES:: - sage: R. = PolynomialRing(Qp(3,3,print_mode='terse',print_pos=False)) + sage: # needs sage.libs.ntl + sage: R. = PolynomialRing(Qp(3, 3, print_mode='terse', print_pos=False)) sage: pol = t^8 - 1 sage: for p,e in pol.factor(): ....: print("{} {}".format(e, p)) @@ -161,9 +166,8 @@ def factor(self): 1 (1 + O(3^3))*t^2 + (5 + O(3^3))*t - 1 + O(3^3) 1 (1 + O(3^3))*t^2 + (-5 + O(3^3))*t - 1 + O(3^3) 1 (1 + O(3^3))*t^2 + O(3^3)*t + 1 + O(3^3) - sage: R. = PolynomialRing(Qp(5,6,print_mode='terse',print_pos=False)) - sage: pol = 100 * (5*t - 1) * (t - 5) - sage: pol + sage: R. = PolynomialRing(Qp(5, 6, print_mode='terse', print_pos=False)) + sage: pol = 100 * (5*t - 1) * (t - 5); pol (500 + O(5^9))*t^2 + (-2600 + O(5^8))*t + 500 + O(5^9) sage: pol.factor() (500 + O(5^9)) * ((1 + O(5^5))*t - 1/5 + O(5^5)) * ((1 + O(5^6))*t - 5 + O(5^6)) @@ -174,9 +178,9 @@ def factor(self): part is a `p`-adic unit and the power of `p` is considered to be a factor:: - sage: R. = PolynomialRing(Zp(5,6,print_mode='terse',print_pos=False)) - sage: pol = 100 * (5*t - 1) * (t - 5) - sage: pol + sage: # needs sage.libs.ntl + sage: R. = PolynomialRing(Zp(5, 6, print_mode='terse', print_pos=False)) + sage: pol = 100 * (5*t - 1) * (t - 5); pol (500 + O(5^9))*t^2 + (-2600 + O(5^8))*t + 500 + O(5^9) sage: pol.factor() (4 + O(5^6)) * (5 + O(5^7))^2 * ((1 + O(5^6))*t - 5 + O(5^6)) * ((5 + O(5^6))*t - 1 + O(5^6)) @@ -186,7 +190,7 @@ def factor(self): In the following example, the discriminant is zero, so the `p`-adic factorization is not well defined:: - sage: factor(t^2) + sage: factor(t^2) # needs sage.libs.ntl Traceback (most recent call last): ... PrecisionError: p-adic factorization not well-defined since @@ -194,36 +198,43 @@ def factor(self): An example of factoring a constant polynomial (see :trac:`26669`):: - sage: R. = Qp(5)[] - sage: R(2).factor() + sage: R. = Qp(5)[] # needs sage.libs.ntl + sage: R(2).factor() # needs sage.libs.ntl 2 + O(5^20) More examples over `\ZZ_p`:: - sage: R. = PolynomialRing(Zp(5, prec=6, type = 'capped-abs', print_mode = 'val-unit')) - sage: f = w^5-1 - sage: f.factor() - ((1 + O(5^6))*w + 3124 + O(5^6)) * ((1 + O(5^6))*w^4 + (12501 + O(5^6))*w^3 + (9376 + O(5^6))*w^2 + (6251 + O(5^6))*w + 3126 + O(5^6)) + sage: R. = PolynomialRing(Zp(5, prec=6, type='capped-abs', print_mode='val-unit')) + sage: f = w^5 - 1 + sage: f.factor() # needs sage.libs.ntl + ((1 + O(5^6))*w + 3124 + O(5^6)) + * ((1 + O(5^6))*w^4 + (12501 + O(5^6))*w^3 + (9376 + O(5^6))*w^2 + + (6251 + O(5^6))*w + 3126 + O(5^6)) See :trac:`4038`:: - sage: E = EllipticCurve('37a1') - sage: K =Qp(7,10) - sage: EK = E.base_extend(K) + sage: # needs sage.libs.ntl sage.schemes sage: E = EllipticCurve('37a1') sage: K = Qp(7,10) sage: EK = E.base_extend(K) sage: g = EK.division_polynomial_0(3) sage: g.factor() - (3 + O(7^10)) * ((1 + O(7^10))*x + 1 + 2*7 + 4*7^2 + 2*7^3 + 5*7^4 + 7^5 + 5*7^6 + 3*7^7 + 5*7^8 + 3*7^9 + O(7^10)) * ((1 + O(7^10))*x^3 + (6 + 4*7 + 2*7^2 + 4*7^3 + 7^4 + 5*7^5 + 7^6 + 3*7^7 + 7^8 + 3*7^9 + O(7^10))*x^2 + (6 + 3*7 + 5*7^2 + 2*7^4 + 7^5 + 7^6 + 2*7^8 + 3*7^9 + O(7^10))*x + 2 + 5*7 + 4*7^2 + 2*7^3 + 6*7^4 + 3*7^5 + 7^6 + 4*7^7 + O(7^10)) + (3 + O(7^10)) + * ((1 + O(7^10))*x + + 1 + 2*7 + 4*7^2 + 2*7^3 + 5*7^4 + 7^5 + 5*7^6 + 3*7^7 + 5*7^8 + 3*7^9 + O(7^10)) + * ((1 + O(7^10))*x^3 + + (6 + 4*7 + 2*7^2 + 4*7^3 + 7^4 + 5*7^5 + + 7^6 + 3*7^7 + 7^8 + 3*7^9 + O(7^10))*x^2 + + (6 + 3*7 + 5*7^2 + 2*7^4 + 7^5 + 7^6 + 2*7^8 + 3*7^9 + O(7^10))*x + + 2 + 5*7 + 4*7^2 + 2*7^3 + 6*7^4 + 3*7^5 + 7^6 + 4*7^7 + O(7^10)) TESTS: Check that :trac:`13293` is fixed:: - sage: R. = Qp(3)[] - sage: f = 1926*T^2 + 312*T + 387 - sage: f.factor() + sage: R. = Qp(3)[] # needs sage.libs.ntl + sage: f = 1926*T^2 + 312*T + 387 # needs sage.libs.ntl + sage: f.factor() # needs sage.libs.ntl (3^2 + 2*3^3 + 2*3^4 + 3^5 + 2*3^6 + O(3^22)) * ((1 + O(3^19))*T + 2*3^-1 + 3 + 3^2 + 2*3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^9 + 2*3^11 + 3^15 + 3^17 + O(3^19)) * ((1 + O(3^20))*T + 2*3 + 3^2 + 3^3 + 3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^14 + 2*3^15 + 2*3^17 + 2*3^18 + O(3^20)) Check that :trac:`24065` is fixed:: @@ -268,23 +279,23 @@ def root_field(self, names, check_irreducible=True, **kwds): EXAMPLES:: - sage: R. = Qp(3,5,print_mode='digits')[] - sage: f = x^2 - 3 - sage: f.root_field('x') + sage: R. = Qp(3,5,print_mode='digits')[] # needs sage.libs.ntl + sage: f = x^2 - 3 # needs sage.libs.ntl + sage: f.root_field('x') # needs sage.libs.ntl 3-adic Eisenstein Extension Field in x defined by x^2 - 3 :: - sage: R. = Qp(5,5,print_mode='digits')[] - sage: f = x^2 - 3 - sage: f.root_field('x', print_mode='bars') + sage: R. = Qp(5,5,print_mode='digits')[] # needs sage.libs.ntl + sage: f = x^2 - 3 # needs sage.libs.ntl + sage: f.root_field('x', print_mode='bars') # needs sage.libs.ntl 5-adic Unramified Extension Field in x defined by x^2 - 3 :: - sage: R. = Qp(11,5,print_mode='digits')[] - sage: f = x^2 - 3 - sage: f.root_field('x', print_mode='bars') + sage: R. = Qp(11,5,print_mode='digits')[] # needs sage.libs.ntl + sage: f = x^2 - 3 # needs sage.libs.ntl + sage: f.root_field('x', print_mode='bars') # needs sage.libs.ntl Traceback (most recent call last): ... ValueError: polynomial must be irreducible diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py index d6ec7525fb4..fced8551fcd 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.ntl """ p-adic Capped Relative Dense Polynomials """ diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 37fda19d7dc..26584408c2f 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage_setup: distribution = sagemath-pari r""" Augmented valuations on polynomial rings @@ -35,107 +35,110 @@ sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x, 1) - sage: TestSuite(w).run() # long time - + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage: w = v.augmentation(x, 2) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron Run the test suite for a valuation with a residual extension:: sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, 1) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron Run the test suite for an iterated residual extension starting from a non-prime residue field:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 40) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage: ww = w.augmentation(x^8 + 4*x^7 + 2*x^6 + 2*x^5 + x^4 + 2*x^3 + 4*(u + 1)*x^2 + 6*(u + 1)*x + 4 + 3*u, 10) sage: TestSuite(ww).run() # long time Run the test suite for an augmentation of a ramified augmentation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x, 3/4) - sage: TestSuite(w).run() # long time - + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage: ww = w.augmentation(x^4 + 8, 5) - sage: TestSuite(ww).run() # long time + sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite for a ramified augmentation of an unramified augmentation:: sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, 1) - sage: TestSuite(w).run() # long time - + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage: ww = w.augmentation(x^4 + 2*x^3 + 5*x^2 + 8*x + 3, 16/3) - sage: TestSuite(ww).run() # long time + sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite for a ramified augmentation of a ramified augmentation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 20) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) - sage: TestSuite(w).run() # long time - + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) - sage: TestSuite(ww).run() # long time + sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite for another augmentation with iterated residue field extensions:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron - sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) - sage: TestSuite(ww).run() # long time + sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) # needs sage.libs.ntl + sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite for a rather trivial pseudo-valuation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x, infinity) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron Run the test suite for an infinite valuation which extends the residue field:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, infinity) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron Run the test suite for an infinite valuation which extends a valuation which extends the residue field:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, infinity) - sage: TestSuite(ww).run() # long time + sage: ww = w.augmentation((x^2 + x + u)^2 + 2, infinity) # needs sage.libs.ntl + sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite if the polynomial ring is not over a field:: sage: R. = ZZ[] sage: v = GaussValuation(R, ZZ.valuation(2)) sage: w = v.augmentation(x, 1) - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron REFERENCES: @@ -174,7 +177,7 @@ class AugmentedValuationFactory(UniqueFactory): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = v.augmentation(x, 1) # indirect doctest + sage: w = v.augmentation(x, 1) # indirect doctest Note that trivial parts of the augmented valuation might be dropped, so you should not rely on ``_base_valuation`` to be the valuation you started @@ -202,7 +205,7 @@ def create_key(self, base_valuation, phi, mu, check=True): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = v.augmentation(x, 1) # indirect doctest + sage: w = v.augmentation(x, 1) # indirect doctest sage: ww = v.augmentation(x, 1) sage: w is ww True @@ -236,7 +239,7 @@ def create_object(self, version, key): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = v.augmentation(x^2 + x + 1, 1) # indirect doctest + sage: w = v.augmentation(x^2 + x + 1, 1) # indirect doctest """ base_valuation, phi, mu = key @@ -272,10 +275,11 @@ class AugmentedValuation_base(InductiveValuation): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(5) sage: R. = K[] sage: v = GaussValuation(R, K.valuation(2)) - sage: w = v.augmentation(x, 1/2); w # indirect doctest + sage: w = v.augmentation(x, 1/2); w # indirect doctest [ Gauss valuation induced by 2-adic valuation, v(x) = 1/2 ] sage: ww = w.augmentation(x^4 + 2*x^2 + 4*u, 3); ww [ Gauss valuation induced by 2-adic valuation, v(x) = 1/2, v(x^4 + 2*x^2 + 4*u) = 3 ] @@ -290,6 +294,7 @@ def __init__(self, parent, v, phi, mu): r""" TESTS:: + sage: # needs sage.libs.ntl sage: K. = Qq(4, 5) sage: R. = K[] sage: v = GaussValuation(R) @@ -298,8 +303,7 @@ def __init__(self, parent, v, phi, mu): sage: from sage.rings.valuation.augmented_valuation import AugmentedValuation_base sage: isinstance(w, AugmentedValuation_base) True - - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.numerical.mip """ InductiveValuation.__init__(self, parent, phi) @@ -327,11 +331,11 @@ def equivalence_unit(self, s, reciprocal=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1) - sage: w.equivalence_unit(0) 1 + O(2^5) sage: w.equivalence_unit(-4) @@ -341,21 +345,19 @@ def equivalence_unit(self, s, reciprocal=False): divide it. Therefore, its valuation is in the value group of the base valuation:: - sage: w = v.augmentation(x, 1/2) - - sage: w.equivalence_unit(3/2) + sage: w = v.augmentation(x, 1/2) # needs sage.libs.ntl + sage: w.equivalence_unit(3/2) # needs sage.libs.ntl Traceback (most recent call last): ... ValueError: 3/2 is not in the value semigroup of 2-adic valuation - sage: w.equivalence_unit(1) + sage: w.equivalence_unit(1) # needs sage.libs.ntl 2 + O(2^6) An equivalence unit might not be integral, even if ``s >= 0``:: - sage: w = v.augmentation(x, 3/4) - sage: ww = w.augmentation(x^4 + 8, 5) - - sage: ww.equivalence_unit(1/2) + sage: w = v.augmentation(x, 3/4) # needs sage.libs.ntl + sage: ww = w.augmentation(x^4 + 8, 5) # needs sage.libs.ntl + sage: ww.equivalence_unit(1/2) # needs sage.libs.ntl (2^-1 + O(2^4))*x^2 """ @@ -386,6 +388,7 @@ def element_with_valuation(self, s): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -403,7 +406,8 @@ def element_with_valuation(self, s): sage: w.element_with_valuation(1/3) Traceback (most recent call last): ... - ValueError: s must be in the value group of the valuation but 1/3 is not in Additive Abelian Group generated by 1/2. + ValueError: s must be in the value group of the valuation + but 1/3 is not in Additive Abelian Group generated by 1/2. """ if s not in self.value_group(): @@ -423,12 +427,14 @@ def _repr_(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) - sage: w # indirect doctest - [ Gauss valuation induced by 2-adic valuation, v((1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)) = 1/2 ] + sage: w # indirect doctest + [ Gauss valuation induced by 2-adic valuation, + v((1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)) = 1/2 ] """ vals = self.augmentation_chain() @@ -473,14 +479,13 @@ def psi(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: w.psi() x^2 + x + u0 - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: ww.psi() x + 1 @@ -499,14 +504,13 @@ def E(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1) sage: w.E() 1 - sage: w = v.augmentation(x, 1/2) sage: w.E() 2 @@ -524,14 +528,13 @@ def F(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1) sage: w.F() 2 - sage: w = v.augmentation(x, 1/2) sage: w.F() 1 @@ -548,8 +551,7 @@ def extensions(self, ring): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, 1) - - sage: w.extensions(GaussianIntegers().fraction_field()['x']) + sage: w.extensions(GaussianIntegers().fraction_field()['x']) # needs sage.rings.number_field [[ Gauss valuation induced by 2-adic valuation, v(x^2 + x + 1) = 1 ]] """ @@ -584,6 +586,7 @@ def restriction(self, ring): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = GaussianIntegers().fraction_field() sage: R. = K[] sage: v = GaussValuation(R, K.valuation(2)) @@ -645,13 +648,12 @@ def monic_integral_model(self, G): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, 1) - sage: w.monic_integral_model(5*x^2 + 1/2*x + 1/4) (Ring endomorphism of Univariate Polynomial Ring in x over Rational Field Defn: x |--> 1/2*x, Ring endomorphism of Univariate Polynomial Ring in x over Rational Field Defn: x |--> 2*x, - x^2 + 1/5*x + 1/5) + x^2 + 1/5*x + 1/5) """ return self._base_valuation.monic_integral_model(G) @@ -771,8 +773,9 @@ def _relative_size(self, f): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QQ.extension(u^2 + u+ 1) + sage: K. = QQ.extension(u^2 + u + 1) sage: S. = K[] sage: v = GaussValuation(S, K.valuation(2)) sage: w = v.augmentation(x^2 + x + u, 1/2) @@ -810,6 +813,7 @@ def change_domain(self, ring): We can change the domain of an augmented valuation even if there is no coercion between rings:: + sage: # needs sage.rings.number_field sage: R. = GaussianIntegers()[] sage: v = GaussValuation(R, GaussianIntegers().valuation(2)) sage: v = v.augmentation(x, 1) @@ -866,14 +870,14 @@ def residue_ring(self): Rational Field sage: w = v.augmentation(x^2 + x + 1, infinity) - sage: w.residue_ring() + sage: w.residue_ring() # needs sage.rings.number_field Number Field in u1 with defining polynomial x^2 + x + 1 An example with a non-trivial base valuation:: sage: v = GaussValuation(R, QQ.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, infinity) - sage: w.residue_ring() + sage: w.residue_ring() # needs sage.rings.finite_rings Finite Field in u1 of size 2^2 Since trivial extensions of finite fields are not implemented, the @@ -888,6 +892,7 @@ def residue_ring(self): We avoid clashes in generator names:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: v = K.valuation(x^2 + 2) sage: R. = K[] @@ -951,13 +956,14 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations 1 sage: w = v.augmentation(x^2 + x + 1, infinity) - sage: w.reduce(x) + sage: w.reduce(x) # needs sage.rings.number_field u1 TESTS: Cases with non-trivial base valuation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) @@ -965,7 +971,6 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations x sage: v.reduce(S(u)) u0 - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: w.reduce(S.one()) 1 @@ -973,14 +978,14 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations 0 sage: w.reduce(S(u)) u0 - sage: w.reduce(x) # this gives the generator of the residue field extension of w over v + sage: w.reduce(x) # this gives the generator of the residue field extension of w over v u1 sage: f = (x^2 + x + u)^2 / 2 sage: w.reduce(f) x sage: w.reduce(f + x + 1) x + u1 + 1 - + sage: # needs sage.libs.ntl sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: g = ((x^2 + x + u)^2 + 2)^3 / 2^5 sage: ww.reduce(g) @@ -1026,16 +1031,17 @@ def _residue_field_generator(self): 0 sage: w = v.augmentation(x^2 + x + 1, infinity) - sage: w._residue_field_generator() + sage: w._residue_field_generator() # needs sage.rings.number_field u1 A case with non-trivial base valuation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, infinity) - sage: w._residue_field_generator() + sage: w._residue_field_generator() # needs sage.rings.number_field u1 """ @@ -1073,22 +1079,24 @@ def lift(self, F): 1/2 sage: w = v.augmentation(x^2 + x + 1, infinity) - sage: w.lift(w.residue_ring().gen()) + sage: w.lift(w.residue_ring().gen()) # needs sage.rings.number_field x A case with non-trivial base valuation:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, infinity) - sage: w.lift(w.residue_ring().gen()) + sage: w.lift(w.residue_ring().gen()) # needs sage.rings.number_field (1 + O(2^10))*x TESTS: Verify that :trac:`30305` has been resolved:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(T^2 + T + 1) sage: R. = K[] @@ -1163,9 +1171,8 @@ def residue_ring(self): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = v.augmentation(x^2 + x + 1, 1) - sage: w.residue_ring() + sage: w.residue_ring() # needs sage.rings.finite_rings Univariate Polynomial Ring in x over Finite Field in u1 of size 2^2 Since trivial valuations of finite fields are not implemented, the @@ -1242,6 +1249,7 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) @@ -1249,7 +1257,6 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations x sage: v.reduce(S(u)) u0 - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: w.reduce(S.one()) 1 @@ -1257,14 +1264,13 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations 0 sage: w.reduce(S(u)) u0 - sage: w.reduce(x) # this gives the generator of the residue field extension of w over v + sage: w.reduce(x) # this gives the generator of the residue field extension of w over v u1 sage: f = (x^2 + x + u)^2 / 2 sage: w.reduce(f) x sage: w.reduce(f + x + 1) x + u1 + 1 - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: g = ((x^2 + x + u)^2 + 2)^3 / 2^5 sage: ww.reduce(g) @@ -1340,6 +1346,7 @@ def _residue_field_generator(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) @@ -1383,14 +1390,14 @@ def lift(self, F, report_coefficients=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: y = w.residue_ring().gen() sage: u1 = w.residue_ring().base().gen() - + sage: # needs sage.libs.ntl sage: w.lift(1) 1 + O(2^10) sage: w.lift(0) @@ -1401,11 +1408,9 @@ def lift(self, F, report_coefficients=False): True sage: w.reduce(w.lift(y + u1 + 1)) == y + u1 + 1 True - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: y = ww.residue_ring().gen() sage: u2 = ww.residue_ring().base().gen() - sage: ww.reduce(ww.lift(y)) == y True sage: ww.reduce(ww.lift(1)) == 1 @@ -1415,11 +1420,11 @@ def lift(self, F, report_coefficients=False): A more complicated example:: + sage: # needs sage.libs.ntl sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1) sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) sage: u = ww.residue_ring().base().gen() - sage: F = ww.residue_ring()(u); F u2 sage: f = ww.lift(F); f @@ -1494,10 +1499,10 @@ def lift_to_key(self, F, check=True): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 10) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: y = w.residue_ring().gen() sage: f = w.lift_to_key(y + 1); f @@ -1507,10 +1512,10 @@ def lift_to_key(self, F, check=True): A more complicated example:: + sage: # needs sage.libs.ntl sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1) sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) - sage: u = ww.residue_ring().base().gen() sage: y = ww.residue_ring().gen() sage: f = ww.lift_to_key(y^3+y+u) @@ -1616,6 +1621,7 @@ class FiniteAugmentedValuation(AugmentedValuation_base, FiniteInductiveValuation EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -1626,6 +1632,7 @@ def __init__(self, parent, v, phi, mu): r""" EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -1645,14 +1652,13 @@ def value_group(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: w.value_group() Additive Abelian Group generated by 1/2 - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: ww.value_group() Additive Abelian Group generated by 1/6 @@ -1666,14 +1672,13 @@ def value_semigroup(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: w.value_semigroup() Additive Abelian Semigroup generated by 1/2 - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: ww.value_semigroup() Additive Abelian Semigroup generated by 1/2, 5/3 @@ -1706,14 +1711,13 @@ def valuations(self, f, coefficients=None, call_error=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) - sage: w = v.augmentation(x^2 + x + u, 1/2) sage: list(w.valuations( x^2 + 1 )) [0, 1/2] - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3) sage: list(ww.valuations( ((x^2 + x + u)^2 + 2)^3 )) [+Infinity, +Infinity, +Infinity, 5] @@ -1774,6 +1778,7 @@ def simplify(self, f, error=None, force=False, effective_degree=None, size_heuri EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -1784,6 +1789,7 @@ def simplify(self, f, error=None, force=False, effective_degree=None, size_heuri Check that :trac:`25607` has been resolved, i.e., the coefficients in the following example are small::` + sage: # needs sage.libs.ntl sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^3 + 6) sage: R. = K[] @@ -1862,6 +1868,7 @@ def lower_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -1904,6 +1911,7 @@ def upper_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2009,6 +2017,7 @@ def value_group(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2026,6 +2035,7 @@ def value_semigroup(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2061,6 +2071,7 @@ def valuations(self, f, coefficients=None, call_error=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2104,6 +2115,7 @@ def simplify(self, f, error=None, force=False, effective_degree=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2131,6 +2143,7 @@ def lower_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -2150,6 +2163,7 @@ def upper_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) diff --git a/src/sage/rings/valuation/developing_valuation.py b/src/sage/rings/valuation/developing_valuation.py index 3cfaa1147c3..d7724642415 100644 --- a/src/sage/rings/valuation/developing_valuation.py +++ b/src/sage/rings/valuation/developing_valuation.py @@ -68,7 +68,7 @@ class DevelopingValuation(DiscretePseudoValuation): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent, phi): @@ -102,9 +102,9 @@ def phi(self): EXAMPLES:: sage: R = Zp(2,5) - sage: S. = R[] - sage: v = GaussValuation(S) - sage: v.phi() + sage: S. = R[] # needs sage.libs.ntl + sage: v = GaussValuation(S) # needs sage.libs.ntl + sage: v.phi() # needs sage.libs.ntl (1 + O(2^5))*x """ @@ -124,6 +124,7 @@ def effective_degree(self, f, valuations=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(2,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -156,6 +157,7 @@ def _pow(self, f, e, error, effective_degree): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(2,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -189,11 +191,12 @@ def coefficients(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Qp(2,5) sage: S. = R[] sage: v = GaussValuation(S) sage: f = x^2 + 2*x + 3 - sage: list(v.coefficients(f)) # note that these constants are in the polynomial ring + sage: list(v.coefficients(f)) # note that these constants are in the polynomial ring [1 + 2 + O(2^5), 2 + O(2^6), 1 + O(2^5)] sage: v = v.augmentation( x^2 + x + 1, 1) sage: list(v.coefficients(f)) @@ -239,17 +242,17 @@ def newton_polygon(self, f, valuations=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Qp(2,5) sage: S. = R[] sage: v = GaussValuation(S) sage: f = x^2 + 2*x + 3 - sage: v.newton_polygon(f) + sage: v.newton_polygon(f) # needs sage.geometry.polyhedron Finite Newton polygon with 2 vertices: (0, 0), (2, 0) - sage: v = v.augmentation( x^2 + x + 1, 1) - sage: v.newton_polygon(f) + sage: v.newton_polygon(f) # needs sage.geometry.polyhedron Finite Newton polygon with 2 vertices: (0, 0), (1, 1) - sage: v.newton_polygon( f * v.phi()^3 ) + sage: v.newton_polygon( f * v.phi()^3 ) # needs sage.geometry.polyhedron Finite Newton polygon with 2 vertices: (3, 3), (4, 4) """ @@ -270,6 +273,7 @@ def _call_(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Qp(2,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -277,6 +281,7 @@ def _call_(self, f): sage: v(f) 0 + sage: # needs sage.libs.ntl sage: v = v.augmentation( x^2 + x + 1, 1) sage: v(f) 0 @@ -315,6 +320,7 @@ def valuations(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Qp(2,5) sage: S. = R[] sage: v = GaussValuation(S, R.valuation()) @@ -331,9 +337,9 @@ def _test_effective_degree(self, **options): EXAMPLES:: sage: R = Zp(2,5) - sage: S. = R[] - sage: v = GaussValuation(S) - sage: v._test_effective_degree() + sage: S. = R[] # needs sage.libs.ntl + sage: v = GaussValuation(S) # needs sage.libs.ntl + sage: v._test_effective_degree() # needs sage.libs.ntl """ tester = self._tester(**options) S = tester.some_elements(self.domain().base_ring().some_elements()) diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py index fce282aa0c7..3fe783662cf 100644 --- a/src/sage/rings/valuation/gauss_valuation.py +++ b/src/sage/rings/valuation/gauss_valuation.py @@ -141,9 +141,9 @@ class GaussValuation_generic(NonFinalInductiveValuation): EXAMPLES:: sage: R = Zp(3,5) - sage: S. = R[] + sage: S. = R[] # needs sage.libs.ntl sage: v0 = R.valuation() - sage: v = GaussValuation(S, v0); v + sage: v = GaussValuation(S, v0); v # needs sage.libs.ntl Gauss valuation induced by 3-adic valuation sage: S. = QQ[] @@ -152,7 +152,7 @@ class GaussValuation_generic(NonFinalInductiveValuation): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent, v): @@ -295,9 +295,9 @@ def residue_ring(self): EXAMPLES:: - sage: S. = Qp(2,5)[] - sage: v = GaussValuation(S) - sage: v.residue_ring() + sage: S. = Qp(2,5)[] # needs sage.libs.ntl + sage: v = GaussValuation(S) # needs sage.libs.ntl + sage: v.residue_ring() # needs sage.libs.ntl Univariate Polynomial Ring in x over Finite Field of size 2 (using ...) """ @@ -329,6 +329,7 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations EXAMPLES:: + sage: # needs sage.libs.ntl sage: S. = Qp(2,5)[] sage: v = GaussValuation(S) sage: f = x^2 + 2*x + 16 @@ -339,8 +340,8 @@ def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations The reduction is only defined for integral elements:: - sage: f = x^2/2 - sage: v.reduce(f) + sage: f = x^2/2 # needs sage.libs.ntl + sage: v.reduce(f) # needs sage.libs.ntl Traceback (most recent call last): ... ValueError: reduction not defined for non-integral elements and (2^-1 + O(2^4))*x^2 is not integral over Gauss valuation induced by 2-adic valuation @@ -377,6 +378,7 @@ def lift(self, F): EXAMPLES:: + sage: # needs sage.libs.ntl sage: S. = Qp(3,5)[] sage: v = GaussValuation(S) sage: f = x^2 + 2*x + 16 @@ -449,6 +451,7 @@ def equivalence_unit(self, s, reciprocal=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: S. = Qp(3,5)[] sage: v = GaussValuation(S) sage: v.equivalence_unit(2) @@ -484,7 +487,7 @@ def E(self): EXAMPLES:: - sage: R. = Qq(4,5) + sage: R. = Qq(4,5) # needs sage.libs.ntl sage: S. = R[] sage: v = GaussValuation(S) sage: v.E() @@ -501,6 +504,7 @@ def F(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -539,7 +543,7 @@ def extensions(self, ring): sage: v = ZZ.valuation(2) sage: R. = ZZ[] sage: w = GaussValuation(R, v) - sage: w.extensions(GaussianIntegers()['x']) + sage: w.extensions(GaussianIntegers()['x']) # needs sage.rings.number_field [Gauss valuation induced by 2-adic valuation] """ @@ -576,6 +580,7 @@ def is_gauss_valuation(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -592,6 +597,7 @@ def augmentation_chain(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -624,9 +630,9 @@ def monic_integral_model(self, G): EXAMPLES:: - sage: R. = Qp(2, 5)[] - sage: v = GaussValuation(R) - sage: v.monic_integral_model(5*x^2 + 1/2*x + 1/4) + sage: R. = Qp(2, 5)[] # needs sage.libs.ntl + sage: v = GaussValuation(R) # needs sage.libs.ntl + sage: v.monic_integral_model(5*x^2 + 1/2*x + 1/4) # needs sage.libs.ntl (Ring endomorphism of Univariate Polynomial Ring in x over 2-adic Field with capped relative precision 5 Defn: (1 + O(2^5))*x |--> (2^-1 + O(2^4))*x, Ring endomorphism of Univariate Polynomial Ring in x over 2-adic Field with capped relative precision 5 @@ -755,6 +761,7 @@ def simplify(self, f, error=None, force=False, size_heuristic_bound=32, effectiv EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -787,6 +794,7 @@ def lower_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -815,6 +823,7 @@ def upper_bound(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) diff --git a/src/sage/rings/valuation/inductive_valuation.py b/src/sage/rings/valuation/inductive_valuation.py index 8cc999d5bbd..d06ff7a29a3 100644 --- a/src/sage/rings/valuation/inductive_valuation.py +++ b/src/sage/rings/valuation/inductive_valuation.py @@ -56,7 +56,7 @@ class InductiveValuation(DevelopingValuation): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def is_equivalence_unit(self, f, valuations=None): @@ -71,6 +71,7 @@ def is_equivalence_unit(self, f, valuations=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(2,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -116,6 +117,7 @@ def equivalence_reciprocal(self, f, coefficients=None, valuations=None, check=Tr EXAMPLES:: + sage: # needs sage.libs.ntl sage: R = Zp(3,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -127,6 +129,7 @@ def equivalence_reciprocal(self, f, coefficients=None, valuations=None, check=Tr In an extended valuation over an extension field:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -139,6 +142,7 @@ def equivalence_reciprocal(self, f, coefficients=None, valuations=None, check=Tr Extending the valuation once more:: + sage: # needs sage.libs.ntl sage: v = v.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) sage: h = v.equivalence_reciprocal(f); h (u + 1) + O(2^5) @@ -149,6 +153,7 @@ def equivalence_reciprocal(self, f, coefficients=None, valuations=None, check=Tr A case that caused problems at some point:: + sage: # needs sage.libs.ntl sage: K = Qp(2, 4) sage: R. = K[] sage: L. = K.extension(x^4 + 4*x^3 + 6*x^2 + 4*x + 2) @@ -239,6 +244,7 @@ def equivalence_unit(self, s, reciprocal=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: S. = Qp(3,5)[] sage: v = GaussValuation(S) sage: v.equivalence_unit(2) @@ -257,7 +263,8 @@ def equivalence_unit(self, s, reciprocal=False): sage: w.equivalence_unit(-1) Traceback (most recent call last): ... - ValueError: s must be in the value semigroup of this valuation but -1 is not in Additive Abelian Semigroup generated by 1 + ValueError: s must be in the value semigroup of this valuation + but -1 is not in Additive Abelian Semigroup generated by 1 """ @@ -269,6 +276,7 @@ def augmentation_chain(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -284,6 +292,7 @@ def is_gauss_valuation(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -300,6 +309,7 @@ def E(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -315,6 +325,7 @@ def F(self): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -339,7 +350,7 @@ def monic_integral_model(self, G): Defn: x |--> 1/2*x, Ring endomorphism of Univariate Polynomial Ring in x over Rational Field Defn: x |--> 2*x, - x^2 + 1/5*x + 1/5) + x^2 + 1/5*x + 1/5) """ @@ -363,7 +374,8 @@ def element_with_valuation(self, s): sage: v.element_with_valuation(-2) Traceback (most recent call last): ... - ValueError: s must be in the value semigroup of this valuation but -2 is not in Additive Abelian Semigroup generated by 1 + ValueError: s must be in the value semigroup of this valuation + but -2 is not in Additive Abelian Semigroup generated by 1 """ @@ -404,6 +416,7 @@ def _test_EF(self, **options): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -589,6 +602,7 @@ class NonFinalInductiveValuation(FiniteInductiveValuation, DiscreteValuation): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -599,6 +613,7 @@ def __init__(self, parent, phi): r""" TESTS:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -630,6 +645,7 @@ def augmentation(self, phi, mu, check=True): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -638,7 +654,11 @@ def augmentation(self, phi, mu, check=True): sage: v [ Gauss valuation induced by 2-adic valuation, v((1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)) = 1, - v((1 + O(2^5))*x^4 + (2^2 + O(2^6))*x^3 + (1 + (u + 1)*2 + O(2^5))*x^2 + ((u + 1)*2^2 + O(2^6))*x + (u + 1) + (u + 1)*2 + (u + 1)*2^2 + (u + 1)*2^3 + (u + 1)*2^4 + O(2^5)) = 3 ] + v((1 + O(2^5))*x^4 + + (2^2 + O(2^6))*x^3 + + (1 + (u + 1)*2 + O(2^5))*x^2 + + ((u + 1)*2^2 + O(2^6))*x + + (u + 1) + (u + 1)*2 + (u + 1)*2^2 + (u + 1)*2^3 + (u + 1)*2^4 + O(2^5)) = 3 ] TESTS: @@ -710,7 +730,7 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a sage: R. = QQ[] sage: v = QQ.valuation(2) sage: f = x^36 + 1160/81*x^31 + 9920/27*x^30 + 1040/81*x^26 + 52480/81*x^25 + 220160/81*x^24 - 5120/81*x^21 - 143360/81*x^20 - 573440/81*x^19 + 12451840/81*x^18 - 266240/567*x^16 - 20316160/567*x^15 - 198737920/189*x^14 - 1129840640/81*x^13 - 1907359744/27*x^12 + 8192/81*x^11 + 655360/81*x^10 + 5242880/21*x^9 + 2118123520/567*x^8 + 15460204544/567*x^7 + 6509559808/81*x^6 - 16777216/567*x^2 - 268435456/567*x - 1073741824/567 - sage: v.mac_lane_approximants(f) + sage: v.mac_lane_approximants(f) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x + 2056) = 23/2 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 11/9 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 2/5, v(x^5 + 4) = 7/2 ], @@ -721,7 +741,7 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a some linear key polynomials in the above example:: sage: v0 = GaussValuation(R, v) - sage: V1 = sorted(v0.mac_lane_step(f)); V1 + sage: V1 = sorted(v0.mac_lane_step(f)); V1 # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x) = 2/5 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 3/5 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 11/9 ], @@ -731,7 +751,7 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a step on each of these branches, note however, that a direct call to this method might produce some unexpected results:: - sage: V1[1].mac_lane_step(f) + sage: V1[1].mac_lane_step(f) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x) = 3/5, v(x^5 + 8) = 5 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 3/5, v(x^10 + 8*x^5 + 64) = 7 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 3 ], @@ -742,7 +762,7 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a greater than ``V1[1]``. To ignore such trivial augmentations, we can set ``allow_equivalent_key``:: - sage: V1[1].mac_lane_step(f, allow_equivalent_key=False) + sage: V1[1].mac_lane_step(f, allow_equivalent_key=False) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x) = 3/5, v(x^5 + 8) = 5 ], [ Gauss valuation induced by 2-adic valuation, v(x) = 3/5, v(x^10 + 8*x^5 + 64) = 7 ]] @@ -755,9 +775,9 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a sage: v1 = v0.augmentation(K._ring.gen(), 1/3) sage: mu0 = K.valuation(v1) sage: eta0 = GaussValuation(S, mu0) - sage: eta1 = eta0.mac_lane_step(F)[0] - sage: eta2 = eta1.mac_lane_step(F)[0] - sage: eta2 + sage: eta1 = eta0.mac_lane_step(F)[0] # needs sage.geometry.polyhedron + sage: eta2 = eta1.mac_lane_step(F)[0] # needs sage.geometry.polyhedron + sage: eta2 # needs sage.geometry.polyhedron [ Gauss valuation induced by Valuation on rational function field induced by [ Gauss valuation induced by 3-adic valuation, v(x) = 1/3 ], v(y + x) = 2/3 ] Check that :trac:`26066` has been resolved:: @@ -766,7 +786,7 @@ def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, a sage: v = QQ.valuation(2) sage: v = GaussValuation(R, v).augmentation(x+1, 1/2) sage: f = x^4 - 30*x^2 - 75 - sage: v.mac_lane_step(f) + sage: v.mac_lane_step(f) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 3/4 ]] """ @@ -931,16 +951,16 @@ def is_key(self, phi, explain=False, assume_equivalence_irreducible=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) sage: v.is_key(x) True - sage: v.is_key(2*x, explain = True) + sage: v.is_key(2*x, explain=True) (False, 'phi must be monic') - sage: v.is_key(x^2, explain = True) + sage: v.is_key(x^2, explain=True) (False, 'phi must be equivalence irreducible') - sage: w = v.augmentation(x, 1) sage: w.is_key(x + 1, explain = True) (False, 'phi must be minimal') @@ -980,6 +1000,7 @@ def is_minimal(self, f, assume_equivalence_irreducible=False): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4, 5) sage: S. = R[] sage: v = GaussValuation(S) @@ -991,6 +1012,7 @@ def is_minimal(self, f, assume_equivalence_irreducible=False): TESTS:: + sage: # needs sage.libs.ntl sage: K = Qp(2, 10) sage: R. = K[] sage: vp = K.valuation() @@ -1003,9 +1025,9 @@ def is_minimal(self, f, assume_equivalence_irreducible=False): Polynomials which are equivalent to the key polynomial are minimal if and only if they have the same degree as the key polynomial:: - sage: v2.is_minimal(x^4 + 2) + sage: v2.is_minimal(x^4 + 2) # needs sage.libs.ntl True - sage: v2.is_minimal(x^4 + 4) + sage: v2.is_minimal(x^4 + 4) # needs sage.libs.ntl False """ @@ -1129,6 +1151,7 @@ def is_equivalence_irreducible(self, f, coefficients=None, valuations=None): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) @@ -1199,6 +1222,7 @@ def equivalence_decomposition(self, f, assume_not_equivalence_unit=False, coeffi EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,10) sage: S. = R[] sage: v = GaussValuation(S) @@ -1217,26 +1241,26 @@ def equivalence_decomposition(self, f, assume_not_equivalence_unit=False, coeffi of a :class:`~sage.structure.factorization.Factorization`, leading to a unit non-minimal degree:: - sage: w = v.augmentation(x, 1) - sage: F = w.equivalence_decomposition(x^2+1); F + sage: w = v.augmentation(x, 1) # needs sage.libs.ntl + sage: F = w.equivalence_decomposition(x^2+1); F # needs sage.libs.ntl (1 + O(2^10))*x^2 + 1 + O(2^10) - sage: F.unit() + sage: F.unit() # needs sage.libs.ntl (1 + O(2^10))*x^2 + 1 + O(2^10) However, if the polynomial has a non-unit factor, then the unit might be replaced by a factor of lower degree:: - sage: f = x * (x^2 + 1) - sage: F = w.equivalence_decomposition(f); F + sage: f = x * (x^2 + 1) # needs sage.libs.ntl + sage: F = w.equivalence_decomposition(f); F # needs sage.libs.ntl (1 + O(2^10))*x - sage: F.unit() + sage: F.unit() # needs sage.libs.ntl 1 + O(2^10) Examples over an iterated unramified extension:: + sage: # needs sage.libs.ntl sage: v = v.augmentation(x^2 + x + u, 1) sage: v = v.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) - sage: v.equivalence_decomposition(x) (1 + O(2^10))*x sage: F = v.equivalence_decomposition( v.phi() ) @@ -1248,14 +1272,15 @@ def equivalence_decomposition(self, f, assume_not_equivalence_unit=False, coeffi TESTS:: + sage: # needs sage.geometry.polyhedron sage.rings.number_field sage: R. = QQ[] - sage: K1.=NumberField(x^3 - 2) - sage: K.=K1.galois_closure() - sage: R.=K[] + sage: K1. = NumberField(x^3 - 2) + sage: K. = K1.galois_closure() + sage: R. = K[] sage: vp = QQ.valuation(2) sage: vp = vp.extension(K) sage: v0 = GaussValuation(R, vp) - sage: G=x^36 + 36*x^35 + 630*x^34 + 7144*x^33 + 59055*x^32 + 379688*x^31 +1978792*x^30 + 8604440*x^29 + 31895428*x^28 + 102487784*x^27 + 289310720*x^26 + 725361352*x^25 + 1629938380*x^24 + 3307417800*x^23 + 6098786184*x^22+10273444280*x^21 + 15878121214*x^20 + 22596599536*x^19 + 29695703772*x^18 +36117601976*x^17 + 40722105266*x^16 + 42608585080*x^15 + 41395961848*x^14 +37344435656*x^13 + 31267160756*x^12 + 24271543640*x^11 + 17439809008*x^10 + 11571651608*x^9 + 7066815164*x^8 + 3953912472*x^7 + 2013737432*x^6 + 925014888*x^5 + 378067657*x^4 + 134716588*x^3 + 40441790*x^2 + 9532544*x + 1584151 + sage: G = x^36 + 36*x^35 + 630*x^34 + 7144*x^33 + 59055*x^32 + 379688*x^31 +1978792*x^30 + 8604440*x^29 + 31895428*x^28 + 102487784*x^27 + 289310720*x^26 + 725361352*x^25 + 1629938380*x^24 + 3307417800*x^23 + 6098786184*x^22+10273444280*x^21 + 15878121214*x^20 + 22596599536*x^19 + 29695703772*x^18 +36117601976*x^17 + 40722105266*x^16 + 42608585080*x^15 + 41395961848*x^14 +37344435656*x^13 + 31267160756*x^12 + 24271543640*x^11 + 17439809008*x^10 + 11571651608*x^9 + 7066815164*x^8 + 3953912472*x^7 + 2013737432*x^6 + 925014888*x^5 + 378067657*x^4 + 134716588*x^3 + 40441790*x^2 + 9532544*x + 1584151 sage: v1 = v0.mac_lane_step(G)[0] sage: V = v1.mac_lane_step(G) sage: v2 = V[0] @@ -1362,12 +1387,14 @@ def minimal_representative(self, f): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,10) sage: S. = R[] sage: v = GaussValuation(S) sage: v.minimal_representative(x + 2) (1 + O(2^10))*x + sage: # needs sage.libs.ntl sage: v = v.augmentation(x, 1) sage: v.minimal_representative(x + 2) (1 + O(2^10))*x + 2 + O(2^11) @@ -1440,6 +1467,7 @@ def lift_to_key(self, F): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(4,10) sage: S. = R[] sage: v = GaussValuation(S) @@ -1550,7 +1578,7 @@ def _test_lift_to_key(self, **options): sage: R. = QQ[] sage: v = GaussValuation(R, valuations.TrivialValuation(QQ)) - sage: v._test_lift_to_key() + sage: v._test_lift_to_key() # needs sage.rings.number_field """ tester = self._tester(**options) diff --git a/src/sage/rings/valuation/limit_valuation.py b/src/sage/rings/valuation/limit_valuation.py index 2820c7123a9..d19b3f0c24e 100644 --- a/src/sage/rings/valuation/limit_valuation.py +++ b/src/sage/rings/valuation/limit_valuation.py @@ -30,10 +30,10 @@ point has two extensions to ``L``. The valuations corresponding to these extensions can only be approximated:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(1) sage: w = v.extensions(L); w [[ (x - 1)-adic valuation, v(y + 1) = 1 ]-adic valuation, @@ -41,6 +41,7 @@ The same phenomenon can be observed for valuations on number fields:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -55,16 +56,17 @@ valuation without using a limit. This is done to improve performance as many computations already can be done correctly with an approximation:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(1/x) sage: w = v.extension(L); w Valuation at the infinite place sage: w._base_valuation._base_valuation._improve_approximation() sage: w._base_valuation._base_valuation._approximation - [ Gauss valuation induced by Valuation at the infinite place, v(y) = 1/2, v(y^2 - 1/x) = +Infinity ] + [ Gauss valuation induced by Valuation at the infinite place, + v(y) = 1/2, v(y^2 - 1/x) = +Infinity ] REFERENCES: @@ -119,7 +121,7 @@ def create_key(self, base_valuation, G): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = valuations.LimitValuation(v, x) # indirect doctest + sage: w = valuations.LimitValuation(v, x) # indirect doctest sage: v = v.augmentation(x, infinity) sage: u = valuations.LimitValuation(v, x) sage: u == w @@ -142,7 +144,7 @@ def create_object(self, version, key): sage: R. = QQ[] sage: v = GaussValuation(R, QQ.valuation(2)) - sage: w = valuations.LimitValuation(v, x^2 + 1) # indirect doctest + sage: w = valuations.LimitValuation(v, x^2 + 1) # indirect doctest """ base_valuation, G = key @@ -163,10 +165,10 @@ class LimitValuation_generic(DiscretePseudoValuation): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) sage: w._base_valuation @@ -175,15 +177,15 @@ class LimitValuation_generic(DiscretePseudoValuation): The currently used approximation can be found in the ``_approximation`` field:: - sage: w._base_valuation._approximation + sage: w._base_valuation._approximation # needs sage.rings.function_field [ Gauss valuation induced by (x)-adic valuation, v(y) = 1/2 ] TESTS:: sage: from sage.rings.valuation.limit_valuation import LimitValuation_generic - sage: isinstance(w._base_valuation, LimitValuation_generic) + sage: isinstance(w._base_valuation, LimitValuation_generic) # needs sage.rings.function_field True - sage: TestSuite(w._base_valuation).run() # long time + sage: TestSuite(w._base_valuation).run() # long time # needs sage.rings.function_field """ def __init__(self, parent, approximation): @@ -191,7 +193,7 @@ def __init__(self, parent, approximation): TESTS:: sage: R. = QQ[] - sage: K. = QQ.extension(x^2 + 1) + sage: K. = QQ.extension(x^2 + 1) # needs sage.rings.number_field sage: v = K.valuation(2) sage: from sage.rings.valuation.limit_valuation import LimitValuation_generic sage: isinstance(v._base_valuation, LimitValuation_generic) @@ -217,13 +219,13 @@ def reduce(self, f, check=True): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - (x - 1)) - sage: v = K.valuation(0) sage: w = v.extension(L) - sage: w.reduce(y) # indirect doctest + sage: w.reduce(y) # indirect doctest u1 """ @@ -238,13 +240,13 @@ def _call_(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) - sage: w(y) # indirect doctest + sage: w(y) # indirect doctest 1/2 """ @@ -259,6 +261,7 @@ def _improve_approximation_for_reduce(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - (x - 1337)) @@ -266,6 +269,7 @@ def _improve_approximation_for_reduce(self, f): For the unique extension over the place at 1337, the initial approximation is sufficient to compute the reduction of ``y``:: + sage: # needs sage.rings.function_field sage: v = K.valuation(1337) sage: w = v.extension(L) sage: u = w._base_valuation @@ -279,19 +283,21 @@ def _improve_approximation_for_reduce(self, f): However, at a place over 1341, the initial approximation is not sufficient for some values (note that 1341-1337 is a square):: + sage: # needs sage.rings.function_field sage: v = K.valuation(1341) sage: w = v.extensions(L)[1] sage: u = w._base_valuation sage: u._approximation [ Gauss valuation induced by (x - 1341)-adic valuation, v(y - 2) = 1 ] - sage: w.reduce((y - 2) / (x - 1341)) # indirect doctest + sage: w.reduce((y - 2) / (x - 1341)) # indirect doctest 1/4 sage: u._approximation [ Gauss valuation induced by (x - 1341)-adic valuation, v(y - 1/4*x + 1333/4) = 2 ] - sage: w.reduce((y - 1/4*x + 1333/4) / (x - 1341)^2) # indirect doctest + sage: w.reduce((y - 1/4*x + 1333/4) / (x - 1341)^2) # indirect doctest -1/64 sage: u._approximation - [ Gauss valuation induced by (x - 1341)-adic valuation, v(y + 1/64*x^2 - 1349/32*x + 1819609/64) = 3 ] + [ Gauss valuation induced by (x - 1341)-adic valuation, + v(y + 1/64*x^2 - 1349/32*x + 1819609/64) = 3 ] """ @@ -303,6 +309,7 @@ def _improve_approximation_for_call(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - (x - 23)) @@ -310,6 +317,7 @@ def _improve_approximation_for_call(self, f): For the unique extension over the place at 23, the initial approximation is sufficient to compute all valuations:: + sage: # needs sage.rings.function_field sage: v = K.valuation(23) sage: w = v.extension(L) sage: u = w._base_valuation @@ -325,7 +333,8 @@ def _improve_approximation_for_call(self, f): improvement step is faster in this case than checking whether the approximation is sufficient):: - sage: w(y) # indirect doctest + sage: # needs sage.rings.function_field + sage: w(y) # indirect doctest 1/2 sage: u._approximation [ Gauss valuation induced by (x - 23)-adic valuation, v(y) = 1/2, v(y^2 - x + 23) = +Infinity ] @@ -338,6 +347,7 @@ def _repr_(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -369,9 +379,9 @@ class MacLaneLimitValuation(LimitValuation_generic, InfiniteDiscretePseudoValuat EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = QQ.extension(x^2 + 1) - sage: v = K.valuation(2) sage: u = v._base_valuation; u [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 , … ] @@ -381,6 +391,7 @@ def __init__(self, parent, approximation, G): r""" TESTS:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = QQ.extension(x^2 + 1) sage: v = K.valuation(2) @@ -403,6 +414,7 @@ def extensions(self, ring): EXAMPLES:: + sage: # needs sage.rings.number_field sage: v = GaussianIntegers().valuation(2) sage: u = v._base_valuation sage: u.extensions(QQ['x']) @@ -429,16 +441,16 @@ def lift(self, F): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^4 - x^2 - 2*x - 1) - sage: v = K.valuation(1) sage: w = v.extensions(L)[1]; w [ (x - 1)-adic valuation, v(y^2 - 2) = 1 ]-adic valuation sage: s = w.reduce(y); s u1 - sage: w.lift(s) # indirect doctest + sage: w.lift(s) # indirect doctest y """ @@ -451,13 +463,13 @@ def uniformizer(self): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) - sage: w.uniformizer() # indirect doctest + sage: w.uniformizer() # indirect doctest y """ @@ -469,20 +481,18 @@ def _call_(self, f): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: K = QQ sage: R. = K[] sage: vK = K.valuation(2) sage: f = (x^2 + 7) * (x^2 + 9) sage: V = vK.mac_lane_approximants(f, require_incomparability=True) - sage: w = valuations.LimitValuation(V[0], f) sage: w((x^2 + 7) * (x + 3)) 3/2 - sage: w = valuations.LimitValuation(V[1], f) sage: w((x^2 + 7) * (x + 3)) +Infinity - sage: w = valuations.LimitValuation(V[2], f) sage: w((x^2 + 7) * (x + 3)) +Infinity @@ -500,6 +510,7 @@ def _improve_approximation(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -547,6 +558,7 @@ def _improve_approximation_for_call(self, f): approximation (perform one step of the Mac Lane algorithm) than to check for this:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -624,6 +636,7 @@ def _improve_approximation_for_reduce(self, f): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -653,6 +666,7 @@ def residue_ring(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -679,6 +693,7 @@ def _ge_(self, other): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: R. = QQ[] sage: F = (x^2 + 7) * (x^2 + 9) sage: G = (x^2 + 7) @@ -722,6 +737,7 @@ def restriction(self, ring): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -744,6 +760,7 @@ def _weakly_separating_element(self, other): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -756,6 +773,7 @@ def _weakly_separating_element(self, other): sage: u._base_valuation._weakly_separating_element(uu._base_valuation) # long time t + 2 + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: v = K.valuation(1/x) sage: R. = K[] @@ -765,7 +783,7 @@ def _weakly_separating_element(self, other): sage: w,ww = v.extensions(L) sage: v = K.valuation(1) sage: v = v.extension(L) - sage: u.separating_element([uu,ww,w,v]) # long time, random output + sage: u.separating_element([uu,ww,w,v]) # long time ((8*x^4 + 12*x^2 + 4)/(x^2 - x))*y + (8*x^4 + 8*x^2 + 1)/(x^3 - x^2) The underlying algorithm is quite naive and might not terminate in @@ -800,6 +818,7 @@ def value_semigroup(self): TESTS:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -817,6 +836,7 @@ def element_with_valuation(self, s): TESTS:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -842,6 +862,7 @@ def _relative_size(self, f): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -863,6 +884,7 @@ def simplify(self, f, error=None, force=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -892,6 +914,7 @@ def lower_bound(self, f): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -915,6 +938,7 @@ def upper_bound(self, f): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -939,6 +963,7 @@ def is_negative_pseudo_valuation(self): For a Mac Lane limit valuation, this is never the case, so this method always returns ``False``:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) diff --git a/src/sage/rings/valuation/mapped_valuation.py b/src/sage/rings/valuation/mapped_valuation.py index e2ec88ae306..c81e7c3182c 100644 --- a/src/sage/rings/valuation/mapped_valuation.py +++ b/src/sage/rings/valuation/mapped_valuation.py @@ -7,15 +7,16 @@ Extensions of valuations over finite field extensions `L=K[x]/(G)` are realized through an infinite valuation on `K[x]` which maps `G` to infinity:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) - sage: w = v.extension(L); w + sage: v = K.valuation(0) # needs sage.rings.function_field + sage: w = v.extension(L); w # needs sage.rings.function_field (x)-adic valuation - sage: w._base_valuation + sage: w._base_valuation # needs sage.rings.function_field [ Gauss valuation induced by (x)-adic valuation, v(y) = 1/2 , … ] AUTHORS: @@ -42,17 +43,17 @@ class MappedValuation_base(DiscretePseudoValuation): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L); w (x)-adic valuation TESTS:: - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.rings.function_field """ def __init__(self, parent, base_valuation): @@ -67,10 +68,10 @@ def __init__(self, parent, base_valuation): TESTS:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x^2 + 1) - sage: v = K.valuation(0) sage: w = v.extension(L); w (x)-adic valuation @@ -94,9 +95,9 @@ def _repr_(self): sage: K = QQ sage: R. = K[] - sage: L. = K.extension(t^2 + 1) + sage: L. = K.extension(t^2 + 1) # needs sage.rings.number_field sage: v = valuations.pAdicValuation(QQ, 2) - sage: v.extension(L) # indirect doctest + sage: v.extension(L) # indirect doctest # needs sage.rings.number_field 2-adic valuation """ @@ -109,9 +110,9 @@ def residue_ring(self): sage: K = QQ sage: R. = K[] - sage: L. = K.extension(t^2 + 1) + sage: L. = K.extension(t^2 + 1) # needs sage.rings.number_field sage: v = valuations.pAdicValuation(QQ, 2) - sage: v.extension(L).residue_ring() + sage: v.extension(L).residue_ring() # needs sage.rings.number_field Finite Field of size 2 """ @@ -125,9 +126,9 @@ def uniformizer(self): sage: K = QQ sage: R. = K[] - sage: L. = K.extension(t^2 + 1) + sage: L. = K.extension(t^2 + 1) # needs sage.rings.number_field sage: v = valuations.pAdicValuation(QQ, 2) - sage: v.extension(L).uniformizer() + sage: v.extension(L).uniformizer() # needs sage.rings.number_field t + 1 """ @@ -139,10 +140,10 @@ def _to_base_domain(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] sage: w._to_base_domain(y).parent() @@ -157,10 +158,10 @@ def _from_base_domain(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) sage: w._from_base_domain(w._base_valuation.domain().gen()).parent() @@ -175,13 +176,13 @@ def _call_(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) - sage: w(y) # indirect doctest + sage: w(y) # indirect doctest 1/2 """ @@ -193,10 +194,10 @@ def reduce(self, f): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - (x - 2)) - sage: v = K.valuation(0) sage: w = v.extension(L) sage: w.reduce(y) @@ -212,10 +213,10 @@ def lift(self, F): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(2) sage: w = v.extension(L) sage: w.lift(w.residue_field().gen()) @@ -239,24 +240,24 @@ def simplify(self, x, error=None, force=False): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] As :meth:`_relative_size` misses the bloated term ``x^32``, the following term does not get simplified:: - sage: w.simplify(y + x^32) + sage: w.simplify(y + x^32) # needs sage.rings.function_field y + x^32 In this case the simplification can be forced but this should not happen as a default as the recursive simplification can be quite costly:: - sage: w.simplify(y + x^32, force=True) + sage: w.simplify(y + x^32, force=True) # needs sage.rings.function_field y """ @@ -276,6 +277,7 @@ def _relative_size(self, x): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) @@ -285,7 +287,7 @@ def _relative_size(self, x): In this example, the method misses the size of the bloated term ``x^32``:: - sage: w._relative_size(y + x^32) + sage: w._relative_size(y + x^32) # needs sage.rings.function_field 1 """ @@ -298,10 +300,10 @@ def _to_base_residue_ring(self, F): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] sage: w._to_base_residue_ring(1) @@ -317,10 +319,10 @@ def _from_base_residue_ring(self, F): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] sage: w._from_base_residue_ring(1) @@ -335,6 +337,7 @@ def element_with_valuation(self, s): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -353,10 +356,10 @@ def _test_to_from_base_domain(self, **options): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] sage: w._test_to_from_base_domain() @@ -375,10 +378,10 @@ def _test_to_from_base_residue_ring(self, **options): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extensions(L)[0] sage: w._test_to_from_base_residue_ring() @@ -408,10 +411,10 @@ class FiniteExtensionFromInfiniteValuation(MappedValuation_base, DiscreteValuati EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L); w (x)-adic valuation @@ -421,16 +424,16 @@ def __init__(self, parent, base_valuation): r""" TESTS:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) - sage: v = K.valuation(0) sage: w = v.extension(L) sage: from sage.rings.valuation.mapped_valuation import FiniteExtensionFromInfiniteValuation sage: isinstance(w, FiniteExtensionFromInfiniteValuation) True - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time """ MappedValuation_base.__init__(self, parent, base_valuation) @@ -442,6 +445,7 @@ def _eq_(self, other): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -461,6 +465,7 @@ def restriction(self, ring): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -483,6 +488,7 @@ def _weakly_separating_element(self, other): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -512,6 +518,7 @@ def _relative_size(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -533,6 +540,7 @@ def simplify(self, x, error=None, force=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -559,6 +567,7 @@ def lower_bound(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -582,6 +591,7 @@ def upper_bound(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = QQ sage: R. = K[] sage: L. = K.extension(t^2 + 1) @@ -604,6 +614,7 @@ class FiniteExtensionFromLimitValuation(FiniteExtensionFromInfiniteValuation): EXAMPLES:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) @@ -614,8 +625,8 @@ class FiniteExtensionFromLimitValuation(FiniteExtensionFromInfiniteValuation): TESTS:: - sage: TestSuite(w[0]).run() # long time - sage: TestSuite(w[1]).run() # long time + sage: TestSuite(w[0]).run() # long time # needs sage.rings.function_field + sage: TestSuite(w[1]).run() # long time # needs sage.rings.function_field """ def __init__(self, parent, approximant, G, approximants): @@ -625,6 +636,7 @@ def __init__(self, parent, approximant, G, approximants): Note that this implementation is also used when the underlying limit is only taken over a finite sequence of valuations:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - x) @@ -650,7 +662,7 @@ def _repr_(self): EXAMPLES:: - sage: valuations.pAdicValuation(GaussianIntegers().fraction_field(), 2) # indirect doctest + sage: valuations.pAdicValuation(GaussianIntegers().fraction_field(), 2) # indirect doctest # needs sage.rings.number_field 2-adic valuation """ diff --git a/src/sage/rings/valuation/scaled_valuation.py b/src/sage/rings/valuation/scaled_valuation.py index 31e06ddb483..84249392e3a 100644 --- a/src/sage/rings/valuation/scaled_valuation.py +++ b/src/sage/rings/valuation/scaled_valuation.py @@ -98,7 +98,7 @@ class ScaledValuation_generic(DiscreteValuation): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent, base_valuation, s): @@ -208,7 +208,7 @@ def extensions(self, ring): EXAMPLES:: sage: v = 3*ZZ.valuation(5) - sage: v.extensions(GaussianIntegers().fraction_field()) + sage: v.extensions(GaussianIntegers().fraction_field()) # needs sage.rings.number_field [3 * [ 5-adic valuation, v(x + 2) = 1 ]-adic valuation, 3 * [ 5-adic valuation, v(x + 3) = 1 ]-adic valuation] diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index ec39b0d98ea..32b0df105d5 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -12,10 +12,9 @@ Discrete valuations can be created on a variety of rings:: - sage: # needs sage.rings.padics sage: ZZ.valuation(2) 2-adic valuation - sage: GaussianIntegers().valuation(3) + sage: GaussianIntegers().valuation(3) # needs sage.rings.number_field 3-adic valuation sage: QQ.valuation(5) 5-adic valuation @@ -24,6 +23,7 @@ :: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: K.valuation(x) (x)-adic valuation @@ -35,15 +35,15 @@ :: sage: R. = QQ[] - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: w = GaussValuation(R, v) # needs sage.rings.padics - sage: w.augmentation(x, 3) # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: w = GaussValuation(R, v) + sage: w.augmentation(x, 3) [ Gauss valuation induced by 2-adic valuation, v(x) = 3 ] We can also define discrete pseudo-valuations, i.e., discrete valuations that send more than just zero to infinity:: - sage: w.augmentation(x, infinity) # needs sage.rings.padics + sage: w.augmentation(x, infinity) [ Gauss valuation induced by 2-adic valuation, v(x) = +Infinity ] """ # **************************************************************************** @@ -77,7 +77,7 @@ class DiscretePseudoValuation(Morphism): TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time # needs sage.geometry.polyhedron """ def __init__(self, parent): @@ -85,7 +85,7 @@ def __init__(self, parent): TESTS:: sage: from sage.rings.valuation.valuation import DiscretePseudoValuation - sage: isinstance(ZZ.valuation(2), DiscretePseudoValuation) # needs sage.rings.padics + sage: isinstance(ZZ.valuation(2), DiscretePseudoValuation) True """ @@ -97,7 +97,6 @@ def is_equivalent(self, f, g): EXAMPLES:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: v.is_equivalent(2, 1) False @@ -126,8 +125,8 @@ def __hash__(self): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: hash(v) == hash(v) # indirect doctest # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: hash(v) == hash(v) # indirect doctest True """ @@ -147,8 +146,8 @@ def _hash_(self): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: hash(v) == hash(v) # indirect doctest # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: hash(v) == hash(v) # indirect doctest True """ @@ -169,7 +168,6 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: v == v True @@ -230,8 +228,8 @@ def _le_(self, other): EXAMPLES:: sage: v = valuations.TrivialValuation(QQ) - sage: w = QQ.valuation(2) # needs sage.rings.padics - sage: v <= w # needs sage.rings.padics + sage: w = QQ.valuation(2) + sage: v <= w True """ return other >= self @@ -247,8 +245,8 @@ def _ge_(self, other): EXAMPLES:: sage: v = valuations.TrivialValuation(QQ) - sage: w = QQ.valuation(2) # needs sage.rings.padics - sage: v >= w # needs sage.rings.padics + sage: w = QQ.valuation(2) + sage: v >= w False """ if self == other: @@ -272,7 +270,7 @@ def _test_valuation_inheritance(self, **options): EXAMPLES:: - sage: QQ.valuation(2)._test_valuation_inheritance() # needs sage.rings.padics + sage: QQ.valuation(2)._test_valuation_inheritance() """ tester = self._tester(**options) tester.assertNotEqual(isinstance(self, InfiniteDiscretePseudoValuation), @@ -286,18 +284,18 @@ class InfiniteDiscretePseudoValuation(DiscretePseudoValuation): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: v = QQ.valuation(2) sage: R. = QQ[] - sage: v = GaussValuation(R, v) # needs sage.rings.padics - sage: w = v.augmentation(x, infinity); w # indirect doctest # needs sage.rings.padics + sage: v = GaussValuation(R, v) + sage: w = v.augmentation(x, infinity); w # indirect doctest [ Gauss valuation induced by 2-adic valuation, v(x) = +Infinity ] TESTS:: sage: from sage.rings.valuation.valuation import InfiniteDiscretePseudoValuation - sage: isinstance(w, InfiniteDiscretePseudoValuation) # needs sage.rings.padics + sage: isinstance(w, InfiniteDiscretePseudoValuation) True - sage: TestSuite(w).run() # long time # needs sage.rings.padics + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage.rings.padics """ def is_discrete_valuation(self): @@ -306,7 +304,6 @@ def is_discrete_valuation(self): EXAMPLES:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: R. = QQ[] sage: v = GaussValuation(R, v) @@ -335,7 +332,7 @@ class NegativeInfiniteDiscretePseudoValuation(InfiniteDiscretePseudoValuation): TESTS:: - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time """ def is_negative_pseudo_valuation(self): @@ -364,18 +361,18 @@ class DiscreteValuation(DiscretePseudoValuation): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: v = QQ.valuation(2) sage: R. = QQ[] - sage: v = GaussValuation(R, v) # needs sage.rings.padics - sage: w = v.augmentation(x, 1337); w # indirect doctest # needs sage.rings.padics + sage: v = GaussValuation(R, v) + sage: w = v.augmentation(x, 1337); w # indirect doctest [ Gauss valuation induced by 2-adic valuation, v(x) = 1337 ] TESTS:: sage: from sage.rings.valuation.valuation import DiscreteValuation - sage: isinstance(w, DiscreteValuation) # needs sage.rings.padics + sage: isinstance(w, DiscreteValuation) True - sage: TestSuite(w).run() # long time # needs sage.rings.padics + sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron sage.rings.padics """ def is_discrete_valuation(self): @@ -436,12 +433,11 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru EXAMPLES:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: R. = QQ[] - sage: v.mac_lane_approximants(x^2 + 1) + sage: v.mac_lane_approximants(x^2 + 1) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ]] - sage: v.mac_lane_approximants(x^2 + 1, required_precision=infinity) + sage: v.mac_lane_approximants(x^2 + 1, required_precision=infinity) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2, v(x^2 + 1) = +Infinity ]] sage: v.mac_lane_approximants(x^2 + x + 1) @@ -451,13 +447,13 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru factor `x + 1` and an approximate factor `x + 1` (which is an approximation to `x - 1`):: - sage: v.mac_lane_approximants(x^2 - 1) # needs sage.rings.padics + sage: v.mac_lane_approximants(x^2 - 1) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = +Infinity ], [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ]] However, it needs to be squarefree:: - sage: v.mac_lane_approximants(x^2) # needs sage.rings.padics + sage: v.mac_lane_approximants(x^2) Traceback (most recent call last): ... ValueError: G must be squarefree @@ -466,26 +462,25 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Some difficult cases provided by Mark van Hoeij:: - sage: # needs sage.rings.finite_rings - sage: k = GF(2) - sage: K. = FunctionField(k) - sage: R. = K[] + sage: k = GF(2) # needs sage.rings.finite_rings + sage: K. = FunctionField(k) # needs sage.rings.function_field + sage: R. = K[] # needs sage.rings.function_field sage: F = y^21 + x*y^20 + (x^3 + x + 1)*y^18 + (x^3 + 1)*y^17 + (x^4 + x)*y^16 + (x^7 + x^6 + x^3 + x + 1)*y^15 + x^7*y^14 + (x^8 + x^7 + x^6 + x^4 + x^3 + 1)*y^13 + (x^9 + x^8 + x^4 + 1)*y^12 + (x^11 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2)*y^11 + (x^12 + x^9 + x^8 + x^7 + x^5 + x^3 + x + 1)*y^10 + (x^14 + x^13 + x^10 + x^9 + x^8 + x^7 + x^6 + x^3 + x^2 + 1)*y^9 + (x^13 + x^9 + x^8 + x^6 + x^4 + x^3 + x)*y^8 + (x^16 + x^15 + x^13 + x^12 + x^11 + x^7 + x^3 + x)*y^7 + (x^17 + x^16 + x^13 + x^9 + x^8 + x)*y^6 + (x^17 + x^16 + x^12 + x^7 + x^5 + x^2 + x + 1)*y^5 + (x^19 + x^16 + x^15 + x^12 + x^6 + x^5 + x^3 + 1)*y^4 + (x^18 + x^15 + x^12 + x^10 + x^9 + x^7 + x^4 + x)*y^3 + (x^22 + x^21 + x^20 + x^18 + x^13 + x^12 + x^9 + x^8 + x^7 + x^5 + x^4 + x^3)*y^2 + (x^23 + x^22 + x^20 + x^17 + x^15 + x^14 + x^12 + x^9)*y + x^25 + x^23 + x^19 + x^17 + x^15 + x^13 + x^11 + x^5 - sage: x = K._ring.gen() - sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed + sage: x = K._ring.gen() # needs sage.rings.function_field + sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.geometry.polyhedron [[ Gauss valuation induced by (x)-adic valuation, v(y + x + 1) = 3/2 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 1 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 4/3 ], [ Gauss valuation induced by (x)-adic valuation, v(y^15 + y^13 + y^12 + y^10 + y^9 + y^8 + y^4 + y^3 + y^2 + y + 1) = 1 ]] - sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x+1,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed + sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x+1,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.geometry.polyhedron [[ Gauss valuation induced by (x + 1)-adic valuation, v(y + x^2 + 1) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 3/4 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y^13 + y^12 + y^10 + y^7 + y^6 + y^3 + 1) = 1 ]] - sage: v0 = valuations.FunctionFieldValuation(K, GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x^3+x^2+1,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed + sage: v0 = valuations.FunctionFieldValuation(K, GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x^3+x^2+1,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.rings.function_field [[ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y + x^3 + x^2 + x) = 2, v(y^2 + (x^6 + x^4 + 1)*y + x^14 + x^10 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2 + x) = 5 ], [ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y^2 + (x^2 + x)*y + 1) = 1 ], [ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y^3 + (x + 1)*y^2 + (x + 1)*y + x^2 + x + 1) = 1 ], @@ -495,62 +490,58 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Cases with trivial residue field extensions:: - sage: # needs sage.rings.padics sage: K. = FunctionField(QQ) sage: S. = K[] sage: F = y^2 - x^2 - x^3 - 3 sage: v0 = GaussValuation(K._ring, QQ.valuation(3)) sage: v1 = v0.augmentation(K._ring.gen(),1/3) sage: mu0 = valuations.FunctionFieldValuation(K, v1) - sage: mu0.mac_lane_approximants(F) + sage: mu0.mac_lane_approximants(F) # needs sage.geometry.polyhedron [[ Gauss valuation induced by Valuation on rational function field induced by [ Gauss valuation induced by 3-adic valuation, v(x) = 1/3 ], v(y + 2*x) = 2/3 ], [ Gauss valuation induced by Valuation on rational function field induced by [ Gauss valuation induced by 3-adic valuation, v(x) = 1/3 ], v(y + x) = 2/3 ]] Over a complete base field:: - sage: k = Qp(2,10) # needs sage.rings.padics - sage: v = k.valuation() # needs sage.rings.padics - - sage: # needs sage.rings.padics + sage: # needs sage.libs.ntl + sage: k = Qp(2,10) + sage: v = k.valuation() sage: R. = k[] sage: G = x sage: v.mac_lane_approximants(G) [Gauss valuation induced by 2-adic valuation] sage: v.mac_lane_approximants(G, required_precision=infinity) [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = +Infinity ]] - - sage: G = x^2 + 1 # needs sage.rings.padics - sage: v.mac_lane_approximants(G) # needs sage.rings.padics + sage: G = x^2 + 1 + sage: v.mac_lane_approximants(G) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x + 1 + O(2^10)) = 1/2 ]] - sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x + 1 + O(2^10)) = 1/2, v((1 + O(2^10))*x^2 + 1 + O(2^10)) = +Infinity ]] - - sage: G = x^4 + 2*x^3 + 2*x^2 - 2*x + 2 # needs sage.rings.padics - sage: v.mac_lane_approximants(G) # needs sage.rings.padics + sage: G = x^4 + 2*x^3 + 2*x^2 - 2*x + 2 + sage: v.mac_lane_approximants(G) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = 1/4 ]] - sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = 1/4, v((1 + O(2^10))*x^4 + (2 + O(2^11))*x^3 + (2 + O(2^11))*x^2 + (2 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + 2^10 + O(2^11))*x + 2 + O(2^11)) = +Infinity ]] The factorization of primes in the Gaussian integers can be read off the Mac Lane approximants:: - sage: v0 = QQ.valuation(2) # needs sage.rings.padics + sage: v0 = QQ.valuation(2) sage: R. = QQ[] sage: G = x^2 + 1 - sage: v0.mac_lane_approximants(G) # needs sage.rings.padics + sage: v0.mac_lane_approximants(G) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ]] - sage: v0 = QQ.valuation(3) # needs sage.rings.padics - sage: v0.mac_lane_approximants(G) # needs sage.rings.padics + sage: v0 = QQ.valuation(3) + sage: v0.mac_lane_approximants(G) [[ Gauss valuation induced by 3-adic valuation, v(x^2 + 1) = +Infinity ]] - sage: v0 = QQ.valuation(5) # needs sage.rings.padics - sage: v0.mac_lane_approximants(G) # needs sage.rings.padics + sage: v0 = QQ.valuation(5) + sage: v0.mac_lane_approximants(G) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v(x + 2) = 1 ], [ Gauss valuation induced by 5-adic valuation, v(x + 3) = 1 ]] - sage: v0.mac_lane_approximants(G, required_precision=10) # needs sage.rings.padics + sage: v0.mac_lane_approximants(G, required_precision=10) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v(x + 3116/237) = 10 ], [ Gauss valuation induced by 5-adic valuation, v(x - 3116/237) = 10 ]] @@ -558,64 +549,61 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru `\QQ[x]/(x^2+1)`, 5 factors `-(x - 2)(x + 2)`, this behaviour can be read off the Mac Lane approximants:: - sage: # needs sage.rings.padics sage: k = Qp(5,4) sage: v = k.valuation() - sage: R. = k[] + sage: R. = k[] # needs sage.libs.ntl sage: G = x^2 + 1 - sage: v1,v2 = v.mac_lane_approximants(G); v1,v2 + sage: v1,v2 = v.mac_lane_approximants(G); v1,v2 # needs sage.geometry.polyhedron ([ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + O(5^4)) = 1 ], [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + O(5^4)) = 1 ]) - sage: w1, w2 = v.mac_lane_approximants(G, required_precision = 2); w1,w2 + sage: w1, w2 = v.mac_lane_approximants(G, required_precision = 2); w1,w2 # needs sage.geometry.polyhedron ([ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + 5 + O(5^4)) = 2 ], [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + 3*5 + O(5^4)) = 2 ]) Note how the latter give a better approximation to the factors of `x^2 + 1`:: - sage: v1.phi() * v2.phi() - G # needs sage.rings.padics + sage: v1.phi() * v2.phi() - G # needs sage.rings.padics O(5^4)*x^2 + (5 + O(5^4))*x + 5 + O(5^4) - sage: w1.phi() * w2.phi() - G # needs sage.rings.padics + sage: w1.phi() * w2.phi() - G # needs sage.rings.padics O(5^4)*x^2 + (5^2 + O(5^4))*x + 5^3 + O(5^4) In this example, the process stops with a factorization of `x^2 + 1`:: - sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) = +Infinity ], [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) = +Infinity ]] This obviously cannot happen over the rationals where we only get an approximate factorization:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(5) sage: R. = QQ[] sage: G = x^2 + 1 - sage: v.mac_lane_approximants(G) + sage: v.mac_lane_approximants(G) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 5-adic valuation, v(x + 2) = 1 ], [ Gauss valuation induced by 5-adic valuation, v(x + 3) = 1 ]] - sage: v.mac_lane_approximants(G, required_precision=5) + sage: v.mac_lane_approximants(G, required_precision=5) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 5-adic valuation, v(x + 79/3) = 5 ], [ Gauss valuation induced by 5-adic valuation, v(x - 79/3) = 5 ]] Initial versions ran into problems with the trivial residue field extensions in this case:: - sage: K = Qp(3, 20, print_mode='digits') # needs sage.rings.padics - sage: R. = K[] # needs sage.rings.padics + sage: K = Qp(3, 20, print_mode='digits') + sage: R. = K[] # needs sage.libs.ntl - sage: # needs sage.rings.padics - sage: alpha = T^3/4 - sage: G = 3^3*T^3*(alpha^4 - alpha)^2 - (4*alpha^3 - 1)^3 + sage: alpha = T^3/4 # needs sage.libs.ntl + sage: G = 3^3*T^3*(alpha^4 - alpha)^2 - (4*alpha^3 - 1)^3 # needs sage.libs.ntl sage: G = G/G.leading_coefficient() - sage: K.valuation().mac_lane_approximants(G) + sage: K.valuation().mac_lane_approximants(G) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 3-adic valuation, v(...1*T + ...2) = 1/9, v(...1*T^9 + ...20*T^8 + ...210*T^7 + ...20*T^6 + ...20*T^5 + ...10*T^4 + ...220*T^3 + ...20*T^2 + ...110*T + ...122) = 55/27 ]] A similar example:: sage: R. = QQ[] - sage: v = QQ.valuation(3) # needs sage.rings.padics - sage: G = (x^3 + 3)^3 - 81 # needs sage.rings.padics - sage: v.mac_lane_approximants(G) # needs sage.rings.padics + sage: v = QQ.valuation(3) + sage: G = (x^3 + 3)^3 - 81 + sage: v.mac_lane_approximants(G) # needs sage.geometry.polyhedron sage.rings.padics [[ Gauss valuation induced by 3-adic valuation, v(x) = 1/3, v(x^3 + 3*x + 3) = 13/9 ]] Another problematic case:: @@ -640,8 +628,8 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru An easy case that produced the wrong error at some point:: sage: R. = QQ[] - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: v.mac_lane_approximants(x^2 - 1/2) # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: v.mac_lane_approximants(x^2 - 1/2) Traceback (most recent call last): ... ValueError: G must be integral @@ -650,33 +638,30 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru :: - sage: # needs sage.rings.padics sage: R = ZpFM(3, 7, print_mode='terse') sage: S. = R[] sage: v = R.valuation() sage: f = x^4 + 234 - sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet + sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet # needs sage.geometry.polyhedron ....: assume_squarefree=True)) 2 :: - sage: # needs sage.rings.padics sage: R = ZpFM(2, 50, print_mode='terse') sage: S. = R[] sage: f = (x^32 + 16)*(x^32 + 16 + 2^16*x^2) + 2^34 sage: v = R.valuation() - sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet + sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet # needs sage.geometry.polyhedron ....: assume_squarefree=True)) 2 A case that triggered an assertion at some point:: - sage: # needs sage.rings.padics sage: v = QQ.valuation(3) sage: R. = QQ[] sage: f = x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 +17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116 - sage: v.mac_lane_approximants(f) + sage: v.mac_lane_approximants(f) # needs sage.geometry.polyhedron [[ Gauss valuation induced by 3-adic valuation, v(x) = 1/3, v(x^3 - 3) = 3/2, v(x^12 - 3*x^9 + 54*x^6 + 27/2*x^3 + 405/2) = 13/2, v(x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 + 17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116) = +Infinity ]] """ @@ -805,10 +790,10 @@ def _pow(self, x, e, error): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: v._pow(2, 2, error=4) # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: v._pow(2, 2, error=4) 4 - sage: v._pow(2, 1000, error=4) # needs sage.rings.padics + sage: v._pow(2, 1000, error=4) 0 """ @@ -838,33 +823,33 @@ def mac_lane_approximant(self, G, valuation, approximants=None): EXAMPLES:: - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: R. = QQ[] # needs sage.rings.padics - sage: G = x^2 + 1 # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: R. = QQ[] + sage: G = x^2 + 1 We can select an approximant by approximating it:: - sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] As long as this is the only matching approximant, the approximation can be very coarse:: - sage: w = GaussValuation(R, v) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] Or it can be very specific:: - sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2).augmentation(G, infinity) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2).augmentation(G, infinity) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] But it must be an approximation of an approximant:: - sage: w = GaussValuation(R, v).augmentation(x, 1/2) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x, 1/2) + sage: v.mac_lane_approximant(G, w) Traceback (most recent call last): ... ValueError: The valuation @@ -875,29 +860,29 @@ def mac_lane_approximant(self, G, valuation, approximants=None): The ``valuation`` must single out one approximant:: - sage: G = x^2 - 1 # needs sage.rings.padics - sage: w = GaussValuation(R, v) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: G = x^2 - 1 + sage: w = GaussValuation(R, v) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 2-adic valuation does not approximate a unique extension of 2-adic valuation with respect to x^2 - 1 - sage: w = GaussValuation(R, v).augmentation(x + 1, 1) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x + 1, 1) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ] does not approximate a unique extension of 2-adic valuation with respect to x^2 - 1 - sage: w = GaussValuation(R, v).augmentation(x + 1, 2) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x + 1, 2) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = +Infinity ] - sage: w = GaussValuation(R, v).augmentation(x + 3, 2) # needs sage.rings.padics - sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics + sage: w = GaussValuation(R, v).augmentation(x + 3, 2) + sage: v.mac_lane_approximant(G, w) # needs sage.geometry.polyhedron sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ] """ @@ -957,12 +942,12 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No EXAMPLES:: - sage: # needs sage.rings.padics + sage: # needs sage.libs.ntl sage: k = Qp(5,4) sage: v = k.valuation() sage: R. = k[] sage: G = x^2 + 1 - sage: v.montes_factorization(G) + sage: v.montes_factorization(G) # needs sage.geometry.polyhedron ((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) * ((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) @@ -970,13 +955,13 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No particular because the factors can not be represented there):: sage: R. = QQ[] - sage: v = QQ.valuation(2) # needs sage.rings.padics - sage: v.montes_factorization(x^6 - 1) # needs sage.rings.padics + sage: v = QQ.valuation(2) + sage: v.montes_factorization(x^6 - 1) # needs sage.geometry.polyhedron sage.rings.padics (x - 1) * (x + 1) * (x^2 - x + 1) * (x^2 + x + 1) sage: v.montes_factorization(x^7 - 1) # not tested # needs sage.rings.padics - sage: v.montes_factorization(x^7 - 1, required_precision=5) # needs sage.rings.padics + sage: v.montes_factorization(x^7 - 1, required_precision=5) # needs sage.geometry.polyhedron sage.rings.padics (x - 1) * (x^3 - 5*x^2 - 6*x - 1) * (x^3 + 6*x^2 + 5*x - 1) TESTS: @@ -986,7 +971,7 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No In this example, ``f`` factors as three factors of degree 50 over an unramified extension:: - sage: # needs sage.rings.padics + sage: # needs sage.libs.flint sage: R. = ZqFM(125) sage: S. = R[] sage: f = (x^6+2)^25 + 5 @@ -996,14 +981,14 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No In this case, ``f`` factors into degrees 1, 2, and 5 over a totally ramified extension:: - sage: # needs sage.rings.padics + sage: # needs sage.libs.ntl sage: R = Zp(5) sage: S. = R[] sage: R. = R.extension(w^3 + 5) sage: S. = R[] sage: f = (x^3 + 5)*(x^5 + w) + 625 sage: v = R.valuation() - sage: v.montes_factorization(f, assume_squarefree=True, required_precision=0) + sage: v.montes_factorization(f, assume_squarefree=True, required_precision=0) # needs sage.libs.flint ((1 + O(w^60))*x + 4*w + O(w^61)) * ((1 + O(w^60))*x^2 + (w + O(w^61))*x + w^2 + O(w^62)) * ((1 + O(w^60))*x^5 + w + O(w^61)) REFERENCES: @@ -1066,8 +1051,8 @@ class MacLaneApproximantNode(): TESTS:: - sage: v = ZZ.valuation(3) # needs sage.rings.padics - sage: v.extension(GaussianIntegers()) # indirect doctest # needs sage.rings.padics + sage: v = ZZ.valuation(3) + sage: v.extension(GaussianIntegers()) # indirect doctest # needs sage.rings.number_field sage.rings.padics 3-adic valuation """ @@ -1076,8 +1061,8 @@ def __init__(self, valuation, parent, ef, principal_part_bound, coefficients, va TESTS:: sage: from sage.rings.valuation.valuation import MacLaneApproximantNode - sage: node = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) # needs sage.rings.padics - sage: TestSuite(node).run() # needs sage.rings.padics + sage: node = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) + sage: TestSuite(node).run() """ self.valuation = valuation @@ -1094,7 +1079,6 @@ def __eq__(self, other): EXAMPLES:: - sage: # needs sage.rings.padics sage: from sage.rings.valuation.valuation import MacLaneApproximantNode sage: n = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) sage: m = MacLaneApproximantNode(QQ.valuation(3), None, 1, None, None, None) @@ -1114,7 +1098,6 @@ def __ne__(self, other): EXAMPLES:: - sage: # needs sage.rings.padics sage: from sage.rings.valuation.valuation import MacLaneApproximantNode sage: n = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) sage: m = MacLaneApproximantNode(QQ.valuation(3), None, 1, None, None, None) diff --git a/src/sage/rings/valuation/valuation_space.py b/src/sage/rings/valuation/valuation_space.py index be0e9192c7c..d2ea1e74d6e 100644 --- a/src/sage/rings/valuation/valuation_space.py +++ b/src/sage/rings/valuation/valuation_space.py @@ -510,8 +510,7 @@ def residue_ring(self): sage: valuations.TrivialValuation(ZZ).residue_ring() Integer Ring sage: GaussValuation(ZZ['x'], ZZ.valuation(2)).residue_ring() - Univariate Polynomial Ring in x over Finite Field of size 2 (using ...) - + Univariate Polynomial Ring in x over Finite Field of size 2... """ @@ -1336,7 +1335,7 @@ def _test_value_semigroup(self, **options): TESTS:: sage: v = QQ.valuation(5) - sage: v._test_value_semigroup() + sage: v._test_value_semigroup() # needs sage.geometry.polyhedron """ tester = self._tester(**options) @@ -1355,7 +1354,7 @@ def _test_element_with_valuation(self, **options): TESTS:: sage: v = QQ.valuation(5) - sage: v._test_element_with_valuation() + sage: v._test_element_with_valuation() # needs sage.geometry.polyhedron """ tester = self._tester(**options) diff --git a/src/sage/rings/valuation/value_group.py b/src/sage/rings/valuation/value_group.py index 57a6c1b2719..b39eec60bdd 100644 --- a/src/sage/rings/valuation/value_group.py +++ b/src/sage/rings/valuation/value_group.py @@ -136,9 +136,9 @@ class DiscreteValueGroup(UniqueRepresentation, Parent): TESTS:: - sage: TestSuite(D1).run() # long time - sage: TestSuite(D2).run() # long time - sage: TestSuite(D3).run() # long time + sage: TestSuite(D1).run() # long time + sage: TestSuite(D2).run() # long time + sage: TestSuite(D3).run() # long time """ @staticmethod @@ -431,9 +431,9 @@ class DiscreteValueSemigroup(UniqueRepresentation, Parent): TESTS:: - sage: TestSuite(D1).run() # long time - sage: TestSuite(D2).run() # long time - sage: TestSuite(D3).run() # long time + sage: TestSuite(D1).run() # long time + sage: TestSuite(D2).run() # long time # needs sage.geometry.polyhedron + sage: TestSuite(D3).run() # long time # needs sage.numerical.mip """ @staticmethod @@ -511,7 +511,7 @@ def _solve_linear_program(self, target): sage: from sage.rings.valuation.value_group import DiscreteValueSemigroup sage: D = DiscreteValueSemigroup([2,3,5]) - sage: D._solve_linear_program(12) + sage: D._solve_linear_program(12) # needs sage.numerical.mip {0: 1, 1: 0, 2: 2} sage: 1*2 + 0*3 + 2*5 12 @@ -670,7 +670,7 @@ def some_elements(self): EXAMPLES:: sage: from sage.rings.valuation.value_group import DiscreteValueSemigroup - sage: list(DiscreteValueSemigroup([-3/8,1/2]).some_elements()) + sage: list(DiscreteValueSemigroup([-3/8,1/2]).some_elements()) # needs sage.numerical.mip [0, -3/8, 1/2, ...] """ yield self(0) From 962347d6ddc523b5ef8594a4535c55ca7fd324f2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:07:04 -0700 Subject: [PATCH 058/494] sage.rings.polynomial: Update # needs --- src/sage/rings/polynomial/hilbert.pyx | 3 +++ src/sage/rings/polynomial/multi_polynomial.pyx | 11 ++++++----- src/sage/rings/polynomial/polynomial_element.pyx | 4 ++-- .../polynomial/polynomial_integer_dense_flint.pyx | 8 ++++---- .../rings/polynomial/polynomial_integer_dense_ntl.pyx | 6 +++--- src/sage/rings/polynomial/real_roots.pyx | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx index d2abf325fd8..444bb2044e7 100644 --- a/src/sage/rings/polynomial/hilbert.pyx +++ b/src/sage/rings/polynomial/hilbert.pyx @@ -440,6 +440,7 @@ def first_hilbert_series(I, grading=None, return_grading=False): EXAMPLES:: + sage: # needs sage.libs.singular sage: from sage.rings.polynomial.hilbert import first_hilbert_series sage: R = singular.ring(0,'(x,y,z)','dp') sage: I = singular.ideal(['x^2','y^2','z^2']) @@ -560,6 +561,7 @@ def hilbert_poincare_series(I, grading=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: from sage.rings.polynomial.hilbert import hilbert_poincare_series sage: R = PolynomialRing(QQ,'x',9) sage: I = [m.lm() @@ -571,6 +573,7 @@ def hilbert_poincare_series(I, grading=None): The following example is taken from :trac:`20145`:: + sage: # needs sage.libs.singular sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x) sage: from sage.rings.polynomial.hilbert import first_hilbert_series sage: I = P.ideal(M.minors(2)) diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index bee78170e99..c3fe1572098 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -1047,21 +1047,22 @@ cdef class MPolynomial(CommutativePolynomial): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # optional - magma, needs sage.rings.finite_rings sage: k. = GF(25); R. = k[] sage: f = y*x^2*b + x*(b+1) + 1 sage: magma = Magma() # so var names same below - sage: magma(f) # optional - magma + sage: magma(f) b*x^2*y + b^22*x + 1 - sage: f._magma_init_(magma) # optional - magma + sage: f._magma_init_(magma) '_sage_[...]!((_sage_[...]!(_sage_[...]))*_sage_[...]^2*_sage_[...]+(_sage_[...]!(_sage_[...] + 1))*_sage_[...]+(_sage_[...]!(1))*1)' A more complicated nested example:: + sage: # optional - magma sage: R. = QQ[]; S. = R[]; f = (2/3)*x^3*z + w^2 + 5 - sage: f._magma_init_(magma) # optional - magma + sage: f._magma_init_(magma) '_sage_[...]!((_sage_[...]!((1/1)*1))*_sage_[...]^2+(_sage_[...]!((2/3)*_sage_[...]^3))*_sage_[...]+(_sage_[...]!((5/1)*1))*1)' - sage: magma(f) # optional - magma + sage: magma(f) w^2 + 2/3*x^3*z + 5 """ R = magma(self.parent()) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 9a80e062c22..e93a7f09fd8 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -1585,7 +1585,7 @@ cdef class Polynomial(CommutativePolynomial): error the product may not always exactly equal the constant polynomial 1 and have extra terms with coefficients close to zero. :: - sage: # needs sage.modules + sage: # needs scipy sage.modules sage: R. = RDF[] sage: epsilon = RDF(1).ulp()*50 # Allow an error of up to 50 ulp sage: f = inverse_mod(x^2 + 1, x^5 + x + 1); f # abs tol 1e-14 @@ -2131,7 +2131,7 @@ cdef class Polynomial(CommutativePolynomial): Check root computation over large finite fields:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.m4ri sage.rings.finite_rings sage: K. = GF(2**50) sage: x = polygen(K) sage: (x**10+x+a).any_root() diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index 7bb023e8452..c92e18af51d 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -351,8 +351,8 @@ cdef class Polynomial_integer_dense_flint(Polynomial): 1 sage: p = x^3 - x^2 - x - 1 - sage: r = p.roots(RIF, multiplicities=False)[0] - sage: p._eval_mpfi_(r) + sage: r = p.roots(RIF, multiplicities=False)[0] # needs sage.libs.linbox + sage: p._eval_mpfi_(r) # needs sage.libs.linbox 0.?e-27 """ cdef RealIntervalFieldElement res = a._new() @@ -395,7 +395,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): True sage: (t^2+3)(RealBallField(100)(1/3)) [3.1111111111111111111111111111...] - sage: (t^2+3)(ComplexBallField(10)(i)) + sage: (t^2+3)(ComplexBallField(10)(i)) # needs sage.symbolic 2.00 """ cdef Polynomial_integer_dense_flint f @@ -1354,7 +1354,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sage: R. = PolynomialRing(ZZ) sage: f = 1 - x^2 - x^3 - x^4 + x^6 - sage: f.real_root_intervals() + sage: f.real_root_intervals() # needs sage.libs.linbox [((1/2, 3/4), 1), ((1, 3/2), 1)] """ diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx index 80a1726bb4e..e276f8073d2 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx @@ -312,8 +312,8 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): 1 sage: p = x^3 - x^2 - x - 1 - sage: r = p.roots(RIF, multiplicities=False)[0] - sage: p._eval_mpfi_(r) + sage: r = p.roots(RIF, multiplicities=False)[0] # needs sage.libs.linbox + sage: p._eval_mpfi_(r) # needs sage.libs.linbox 0.?e-27 """ cdef RealIntervalFieldElement res = a._new() @@ -795,7 +795,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): sage: R. = PolynomialRing(ZZ, implementation='NTL') sage: f = 1 - x^2 - x^3 - x^4 + x^6 - sage: f.real_root_intervals() + sage: f.real_root_intervals() # needs sage.libs.linbox [((1/2, 3/4), 1), ((1, 3/2), 1)] """ diff --git a/src/sage/rings/polynomial/real_roots.pyx b/src/sage/rings/polynomial/real_roots.pyx index 71481e8aba5..72554418fb6 100644 --- a/src/sage/rings/polynomial/real_roots.pyx +++ b/src/sage/rings/polynomial/real_roots.pyx @@ -1,4 +1,4 @@ -# sage.doctest: needs numpy +# sage.doctest: needs numpy sage.libs.linbox """ Isolate Real Roots of Real Polynomials From fb7fbab9893abe6a021be025036119157d292459 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:07:56 -0700 Subject: [PATCH 059/494] sage.rings.number_field: Update # needs --- src/sage/rings/number_field/bdd_height.py | 1 + src/sage/rings/number_field/morphism.py | 1 + src/sage/rings/number_field/number_field.py | 2 +- .../number_field/number_field_element.pyx | 34 +++++++++++-------- .../number_field_element_quadratic.pyx | 2 +- .../number_field/number_field_morphisms.pyx | 1 + .../rings/number_field/number_field_rel.py | 2 +- src/sage/rings/number_field/order.py | 1 + src/sage/rings/number_field/structure.py | 1 + src/sage/rings/number_field/unit_group.py | 1 + 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py index e467ee9df0e..ee2080c3bd7 100644 --- a/src/sage/rings/number_field/bdd_height.py +++ b/src/sage/rings/number_field/bdd_height.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron r""" Elements of bounded height in number fields diff --git a/src/sage/rings/number_field/morphism.py b/src/sage/rings/number_field/morphism.py index a979035a82a..245d107142b 100644 --- a/src/sage/rings/number_field/morphism.py +++ b/src/sage/rings/number_field/morphism.py @@ -114,6 +114,7 @@ def preimage(self, y): :: + sage: # needs sage.libs.linbox sage: F. = QuadraticField(23) sage: G. = F.extension(x^3 + 5) sage: f = F.embeddings(G)[0] diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 5ac37e3f23f..d31df96ea8f 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.linbox r""" Number Fields diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index abfb10f9ef8..842adcf236a 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -4,6 +4,7 @@ # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.libs.linbox """ Number field elements (implementation using NTL) @@ -526,13 +527,13 @@ cdef class NumberFieldElement(NumberFieldElement_base): EXAMPLES:: + sage: # needs sage.libs.gap sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) - sage: (a**2 - a + 1)._gap_init_() # needs sage.libs.gap + sage: (a**2 - a + 1)._gap_init_() '\\$sage4^2 - \\$sage4 + 1' - sage: gap(_) # needs sage.libs.gap + sage: gap(_) a^2-a+1 - sage: F = CyclotomicField(8) sage: F.gen() zeta8 @@ -581,15 +582,16 @@ cdef class NumberFieldElement(NumberFieldElement_base): EXAMPLES:: + sage: # needs sage.libs.gap sage: F = CyclotomicField(8) - sage: F.gen()._libgap_() # needs sage.libs.gap + sage: F.gen()._libgap_() E(8) - sage: libgap(F.gen()) # syntactic sugar # needs sage.libs.gap + sage: libgap(F.gen()) # syntactic sugar E(8) - sage: E8 = F.gen() # needs sage.libs.gap - sage: libgap(E8 + 3/2*E8^2 + 100*E8^7) # needs sage.libs.gap + sage: E8 = F.gen() + sage: libgap(E8 + 3/2*E8^2 + 100*E8^7) E(8)+3/2*E(8)^2-100*E(8)^3 - sage: type(_) # needs sage.libs.gap + sage: type(_) Check that :trac:`15276` is fixed:: @@ -620,15 +622,16 @@ cdef class NumberFieldElement(NumberFieldElement_base): TESTS: + sage: # needs sage.libs.pari sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 + 2) - sage: K.zero()._pari_polynomial('x') # needs sage.libs.pari + sage: K.zero()._pari_polynomial('x') 0 - sage: K.one()._pari_polynomial() # needs sage.libs.pari + sage: K.one()._pari_polynomial() 1 - sage: (a + 1)._pari_polynomial() # needs sage.libs.pari + sage: (a + 1)._pari_polynomial() y + 1 - sage: a._pari_polynomial('c') # needs sage.libs.pari + sage: a._pari_polynomial('c') c """ f = pari(self._coefficients()).Polrev() @@ -651,14 +654,15 @@ cdef class NumberFieldElement(NumberFieldElement_base): EXAMPLES:: + sage: # needs sage.libs.pari sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 + 2) - sage: K(1).__pari__() # needs sage.libs.pari + sage: K(1).__pari__() Mod(1, y^3 + 2) - sage: (a + 2).__pari__() # needs sage.libs.pari + sage: (a + 2).__pari__() Mod(y + 2, y^3 + 2) sage: L. = K.extension(x^2 + 2) - sage: (b + a).__pari__() # needs sage.libs.pari + sage: (b + a).__pari__() Mod(24/101*y^5 - 9/101*y^4 + 160/101*y^3 - 156/101*y^2 + 397/101*y + 364/101, y^6 + 6*y^4 - 4*y^3 + 12*y^2 + 24*y + 12) :: diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pyx b/src/sage/rings/number_field/number_field_element_quadratic.pyx index f0a7d8ae078..096932bd411 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx @@ -1,10 +1,10 @@ -# sage.doctests: needs sage.rings.number_field # distutils: libraries = NTL_LIBRARIES # distutils: extra_compile_args = NTL_CFLAGS # distutils: include_dirs = NTL_INCDIR # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA # distutils: language = c++ +# sage.doctest: needs sage.rings.number_field r""" Optimized Quadratic Number Field Elements diff --git a/src/sage/rings/number_field/number_field_morphisms.pyx b/src/sage/rings/number_field/number_field_morphisms.pyx index 862b32ffc02..2daeb86d9d1 100644 --- a/src/sage/rings/number_field/number_field_morphisms.pyx +++ b/src/sage/rings/number_field/number_field_morphisms.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Embeddings into ambient fields diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 7f642cfcc7f..e91e4e0162a 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -2252,7 +2252,7 @@ def places(self, all_complex=False, prec=None): sage: x = polygen(ZZ, 'x') sage: L. = NumberFieldTower([x^2 - 5, x^3 + x + 3]) - sage: L.places() + sage: L.places() # needs sage.libs.linbox [Relative number field morphism: From: Number Field in b with defining polynomial x^2 - 5 over its base field To: Real Field with 106 bits of precision diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index e789a97bc75..ea517a138e9 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.linbox """ Orders in Number Fields diff --git a/src/sage/rings/number_field/structure.py b/src/sage/rings/number_field/structure.py index ee699716638..64d7d688e35 100644 --- a/src/sage/rings/number_field/structure.py +++ b/src/sage/rings/number_field/structure.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Helper classes for structural embeddings and isomorphisms of number fields diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py index 5f9d5c0654c..63bd1f7cbfc 100644 --- a/src/sage/rings/number_field/unit_group.py +++ b/src/sage/rings/number_field/unit_group.py @@ -296,6 +296,7 @@ def __init__(self, number_field, proof=True, S=None): Conversion from unit group to a number field and back gives the right results (:trac:`25874`):: + sage: # needs sage.libs.linbox sage: K = QuadraticField(-3).composite_fields(QuadraticField(2))[0] sage: U = K.unit_group() sage: tuple(U(K(u)) for u in U.gens()) == U.gens() From e2fcede8abde6f551e153071b454683da9005f24 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:08:19 -0700 Subject: [PATCH 060/494] sage.rings.padics: Fix up import, update # needs --- src/sage/rings/padics/factory.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index ce20f53b0cb..ea9681919ea 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -3259,10 +3259,9 @@ class pAdicExtension_class(UniqueFactory): sage: R = Zp(5,3) sage: S. = ZZ[] - sage: W. = pAdicExtension(R, x^4 - 15) # needs sage.libs.ntl sage.rings.padics - sage: W + sage: W. = pAdicExtension(R, x^4 - 15); W # needs sage.libs.ntl 5-adic Eisenstein Extension Ring in w defined by x^4 - 15 - sage: W.precision_cap() + sage: W.precision_cap() # needs sage.libs.ntl 12 """ def create_key_and_extra_args(self, base, modulus, prec=None, print_mode=None, From bb87f795fe667a60c71addacb90d1fe412e10387 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:08:37 -0700 Subject: [PATCH 061/494] sage.rings: Update # needs --- src/sage/rings/finite_rings/residue_field_ntl_gf2e.pyx | 3 ++- src/sage/rings/morphism.pyx | 4 ++-- src/sage/rings/qqbar.py | 7 +++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/rings/finite_rings/residue_field_ntl_gf2e.pyx b/src/sage/rings/finite_rings/residue_field_ntl_gf2e.pyx index ed6af655258..5071bc87137 100644 --- a/src/sage/rings/finite_rings/residue_field_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/residue_field_ntl_gf2e.pyx @@ -85,7 +85,8 @@ class ResidueFiniteField_ntl_gf2e(ResidueField_generic, FiniteField_ntl_gf2e): sage: P = K.ideal(61).factor()[0][0] # needs sage.rings.number_field sage: k = K.residue_field(P) # needs sage.rings.number_field - sage: R. = GF(3)[]; P = R.ideal(t^4 - t^3 + t + 1); k. = P.residue_field(); type(k) + sage: R. = GF(3)[]; P = R.ideal(t^4 - t^3 + t + 1); k. = P.residue_field() + sage: type(k) # needs sage.libs.linbox sage: a^5 a^3 + 2*a^2 + a + 2 diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 0fe0b4e86bb..06925850790 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -1572,8 +1572,8 @@ cdef class RingHomomorphism(RingMap): Check that results are cached:: sage: R. = GF(823)[] - sage: f = R.hom([x, y+x^2], R) - sage: f.inverse() is f.inverse() # needs sage.rings.finite_rings + sage: f = R.hom([x, y + x^2], R) + sage: f.inverse() is f.inverse() # needs sage.libs.singular True Some subclasses of ring homomorphisms are not supported:: diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index ed3b1071b04..008c8a2a447 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.linbox r""" Field of Algebraic Numbers @@ -2078,7 +2078,7 @@ def _factor_univariate_polynomial(self, f): (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?) sage: QQbar._factor_univariate_polynomial(R(-1)) -1 - sage: QQbar._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(QQbar).division_polynomial(5)) + sage: QQbar._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(QQbar).division_polynomial(5)) # needs sage.schemes (5) * (x - 16) * (x - 5) * (x - 1.959674775249769?) * (x - 1.427050983124843? - 3.665468789467727?*I) * (x - 1.427050983124843? + 3.665468789467727?*I) * (x + 0.9549150281252629? - 0.8652998037182486?*I) * (x + 0.9549150281252629? + 0.8652998037182486?*I) * (x + 1.927050983124843? - 1.677599044300515?*I) * (x + 1.927050983124843? + 1.677599044300515?*I) * (x + 2.959674775249769?) * (x + 6.545084971874737? - 7.106423590645660?*I) * (x + 6.545084971874737? + 7.106423590645660?*I) """ @@ -8603,10 +8603,10 @@ def exactify(self): We lower the recursion limit for this test to allow a test in reasonable time:: + sage: # needs sage.combinat sage: import sys sage: old_recursion_limit = sys.getrecursionlimit() sage: sys.setrecursionlimit(1000) - sage: sys.getrecursionlimit() 1000 sage: s = SymmetricFunctions(QQ).schur() @@ -8615,7 +8615,6 @@ def exactify(self): 0 sage: sys.getrecursionlimit() 1000 - sage: sys.setrecursionlimit(old_recursion_limit) """ import sys From 613b0694fd642b58e84c80e34ad1d9aa3cf48d5c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 13:24:06 -0700 Subject: [PATCH 062/494] sage.rings.{padics,valuation}: Update # needs --- src/sage/rings/padics/CA_template.pxi | 2 +- src/sage/rings/padics/CR_template.pxi | 3 ++- src/sage/rings/padics/FM_template.pxi | 2 +- src/sage/rings/padics/FP_template.pxi | 25 ++++++++++++++++--- src/sage/rings/padics/lattice_precision.py | 1 - .../rings/padics/padic_template_element.pxi | 5 ++++ src/sage/rings/padics/padic_valuation.py | 4 +-- .../padics/unramified_extension_generic.py | 2 +- .../rings/valuation/augmented_valuation.py | 10 +++----- src/sage/rings/valuation/gauss_valuation.py | 3 ++- src/sage/rings/valuation/limit_valuation.py | 7 +++--- 11 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/sage/rings/padics/CA_template.pxi b/src/sage/rings/padics/CA_template.pxi index 2dd1500cb75..dbb1d34aab5 100644 --- a/src/sage/rings/padics/CA_template.pxi +++ b/src/sage/rings/padics/CA_template.pxi @@ -1432,7 +1432,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): TESTS:: - sage: TestSuite(f).run() + sage: TestSuite(f).run() # needs sage.libs.flint """ def __init__(self, R, K): diff --git a/src/sage/rings/padics/CR_template.pxi b/src/sage/rings/padics/CR_template.pxi index 94695bd9f81..ff3e5d6a7ff 100644 --- a/src/sage/rings/padics/CR_template.pxi +++ b/src/sage/rings/padics/CR_template.pxi @@ -1309,9 +1309,10 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = ZZ[] sage: K. = Qq(25) - sage: W. = K.extension(x^3-5) + sage: W. = K.extension(x^3 - 5) sage: (1 + w + O(w^11))._polynomial_list() [1 + O(5^4), 1 + O(5^4)] sage: (1 + w + O(w^11))._polynomial_list(pad=True) diff --git a/src/sage/rings/padics/FM_template.pxi b/src/sage/rings/padics/FM_template.pxi index f62ba450530..1825e0f19b9 100644 --- a/src/sage/rings/padics/FM_template.pxi +++ b/src/sage/rings/padics/FM_template.pxi @@ -1192,7 +1192,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): TESTS:: - sage: TestSuite(f).run() + sage: TestSuite(f).run() # needs sage.libs.flint """ def __init__(self, R, K): diff --git a/src/sage/rings/padics/FP_template.pxi b/src/sage/rings/padics/FP_template.pxi index d253d208410..754fe08d0cc 100644 --- a/src/sage/rings/padics/FP_template.pxi +++ b/src/sage/rings/padics/FP_template.pxi @@ -180,6 +180,7 @@ cdef class FPElement(pAdicTemplateElement): sage: R = ZpFP(5); R(6) * R(7) #indirect doctest 2 + 3*5 + 5^2 + sage: # needs sage.libs.flint sage: R. = ZqFP(25) sage: S. = ZZ[] sage: W. = R.ext(x^2 - 5) @@ -609,8 +610,9 @@ cdef class FPElement(pAdicTemplateElement): sage: R(1)^R(0) 1 - sage: S. = ZqFP(4) - sage: S(1)^S(0) + + sage: S. = ZqFP(4) # needs sage.libs.flint + sage: S(1)^S(0) # needs sage.libs.flint 1 """ cdef long dummyL @@ -1051,9 +1053,10 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZZ[] sage: K. = QqFP(5^3) - sage: W. = K.extension(x^3-5) + sage: W. = K.extension(x^3 - 5) sage: (1 + w)._polynomial_list() [1, 1] sage: (1 + w)._polynomial_list(pad=True) @@ -1082,6 +1085,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: + sage: # needs sage.libs.flint sage: K. = QqFP(5^3) sage: a.polynomial() x @@ -1801,6 +1805,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); f @@ -1810,7 +1815,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): TESTS:: - sage: TestSuite(f).run() + sage: TestSuite(f).run() # needs sage.libs.flint """ def __init__(self, R, K): @@ -1819,6 +1824,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R); type(f) @@ -1834,6 +1840,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1862,6 +1869,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1913,6 +1921,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1927,6 +1936,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1955,6 +1965,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFP(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) @@ -1983,6 +1994,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); f @@ -1996,6 +2008,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); type(f) @@ -2010,6 +2023,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -2038,6 +2052,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): EXAMPLES:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); a = K(a) @@ -2090,6 +2105,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFP(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) @@ -2118,6 +2134,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): TESTS:: + sage: # needs sage.libs.flint sage: R. = ZqFP(9, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py index 43556ff4bc6..51a510a4360 100644 --- a/src/sage/rings/padics/lattice_precision.py +++ b/src/sage/rings/padics/lattice_precision.py @@ -1092,7 +1092,6 @@ def tracked_elements(self, values=True, dead=True): WeakProxy#..., WeakProxy#..., WeakProxy#...] - sage: del x; del y sage: prec.tracked_elements() [None, None, 2 + O(2^5), O(2^5), None] diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index 0502f855aa6..17f41ff6e65 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -615,6 +615,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Qq(125) sage: b = a^2 + 5*a + 1 sage: b._ext_p_list(True) @@ -635,6 +636,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(125) sage: (5*a).unit_part() a + O(5^20) @@ -694,6 +696,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): EXAMPLES:: + sage: # needs sage.libs.ntl sage: R. = Zq(27, 4) sage: (3 + 3*a).residue() 0 @@ -702,6 +705,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): TESTS:: + sage: # needs sage.libs.ntl sage: a.residue(0) 0 sage: a.residue(2) @@ -717,6 +721,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): ... NotImplementedError: reduction modulo p^n with n>1 + sage: # needs sage.libs.flint sage: R. = ZqCA(27, 4) sage: (3 + 3*a).residue() 0 diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index a46cee1f805..a44abb23deb 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -1360,12 +1360,12 @@ class pAdicFromLimitValuation(FiniteExtensionFromLimitValuation, pAdicValuation_ TESTS:: - sage: TestSuite(v).run(skip='_test_shift') # long time + sage: TestSuite(v).run(skip='_test_shift') # long time # needs sage.rings.number_field The ``_test_shift`` test fails because the parent of the shift is incorrect, see :trac:`23971`:: - sage: v.shift(1, -1).parent() + sage: v.shift(1, -1).parent() # needs sage.rings.number_field Number Field in I with defining polynomial x^2 + 1 with I = 1*I """ diff --git a/src/sage/rings/padics/unramified_extension_generic.py b/src/sage/rings/padics/unramified_extension_generic.py index c4f8612db69..1c72ab1a4cd 100644 --- a/src/sage/rings/padics/unramified_extension_generic.py +++ b/src/sage/rings/padics/unramified_extension_generic.py @@ -69,7 +69,7 @@ def _extension_type(self): sage: x = polygen(ZZ, 'x') sage: L. = Qp(5).extension(x^2 - 5) # needs sage.libs.ntl - sage: L._extension_type() + sage: L._extension_type() # needs sage.libs.ntl 'Eisenstein' """ return "Unramified" diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 26584408c2f..21fbb67008f 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -55,8 +55,8 @@ sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron - - sage: ww = w.augmentation(x^8 + 4*x^7 + 2*x^6 + 2*x^5 + x^4 + 2*x^3 + 4*(u + 1)*x^2 + 6*(u + 1)*x + 4 + 3*u, 10) + sage: ww = w.augmentation(x^8 + 4*x^7 + 2*x^6 + 2*x^5 + x^4 + 2*x^3 + ....: + 4*(u + 1)*x^2 + 6*(u + 1)*x + 4 + 3*u, 10) sage: TestSuite(ww).run() # long time Run the test suite for an augmentation of a ramified augmentation:: @@ -98,8 +98,7 @@ sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1) sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron - - sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) # needs sage.libs.ntl + sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3) sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite for a rather trivial pseudo-valuation:: @@ -129,8 +128,7 @@ sage: v = GaussValuation(S) sage: w = v.augmentation(x^2 + x + u, 1/2) sage: TestSuite(w).run() # long time # needs sage.geometry.polyhedron - - sage: ww = w.augmentation((x^2 + x + u)^2 + 2, infinity) # needs sage.libs.ntl + sage: ww = w.augmentation((x^2 + x + u)^2 + 2, infinity) sage: TestSuite(ww).run() # long time # needs sage.numerical.mip Run the test suite if the polynomial ring is not over a field:: diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py index 3fe783662cf..759d2a4e03e 100644 --- a/src/sage/rings/valuation/gauss_valuation.py +++ b/src/sage/rings/valuation/gauss_valuation.py @@ -487,7 +487,8 @@ def E(self): EXAMPLES:: - sage: R. = Qq(4,5) # needs sage.libs.ntl + sage: # needs sage.libs.ntl + sage: R. = Qq(4,5) sage: S. = R[] sage: v = GaussValuation(S) sage: v.E() diff --git a/src/sage/rings/valuation/limit_valuation.py b/src/sage/rings/valuation/limit_valuation.py index d19b3f0c24e..96b2f93615f 100644 --- a/src/sage/rings/valuation/limit_valuation.py +++ b/src/sage/rings/valuation/limit_valuation.py @@ -192,8 +192,9 @@ def __init__(self, parent, approximation): r""" TESTS:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QQ.extension(x^2 + 1) # needs sage.rings.number_field + sage: K. = QQ.extension(x^2 + 1) sage: v = K.valuation(2) sage: from sage.rings.valuation.limit_valuation import LimitValuation_generic sage: isinstance(v._base_valuation, LimitValuation_generic) @@ -526,8 +527,8 @@ def _improve_approximation(self): This method has no effect, if the approximation is already an infinite valuation:: - sage: u._improve_approximation() - sage: u._approximation + sage: u._improve_approximation() # needs sage.rings.number_field + sage: u._approximation # needs sage.rings.number_field [ Gauss valuation induced by 2-adic valuation, v(t + 1) = 1/2, v(t^2 + 1) = +Infinity ] """ From 85e80335a2820982d193ac346bdc6ca5af862d7b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 13:28:18 -0700 Subject: [PATCH 063/494] sage.rings: Update # needs --- src/sage/rings/function_field/valuation.py | 7 +- src/sage/rings/morphism.pyx | 4 +- src/sage/rings/number_field/number_field.py | 9 +-- .../number_field/number_field_element.pyx | 2 +- .../polynomial/polynomial_complex_arb.pyx | 3 +- .../polynomial_quotient_ring_element.py | 2 +- .../polynomial/polynomial_rational_flint.pyx | 2 + src/sage/rings/qqbar.py | 68 ++++++++----------- 8 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/sage/rings/function_field/valuation.py b/src/sage/rings/function_field/valuation.py index e8afd1cb232..28e18411dd7 100644 --- a/src/sage/rings/function_field/valuation.py +++ b/src/sage/rings/function_field/valuation.py @@ -654,7 +654,7 @@ def _test_classical_residue_field(self, **options): sage: K. = FunctionField(QQ) sage: v = K.valuation(x^2 + 1) - sage: v._test_classical_residue_field() + sage: v._test_classical_residue_field() # needs sage.rings.number_field """ tester = self._tester(**options) @@ -774,7 +774,7 @@ def reduce(self, f): sage: K. = FunctionField(QQ) sage: v = K.valuation(x^2 + 1) - sage: v.reduce(x) + sage: v.reduce(x) # needs sage.rings.number_field u1 """ @@ -805,7 +805,7 @@ def _repr_(self): EXAMPLES:: sage: K. = FunctionField(QQ) - sage: K.valuation(x^2 + 1) # indirect doctest + sage: K.valuation(x^2 + 1) # indirect doctest (x^2 + 1)-adic valuation """ @@ -827,6 +827,7 @@ def extensions(self, L): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K. = FunctionField(QQ) sage: v = K.valuation(x^2 + 1) sage: L. = FunctionField(GaussianIntegers().fraction_field()) diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 06925850790..b157b6bdffe 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -1587,8 +1587,8 @@ cdef class RingHomomorphism(RingMap): :: - sage: R. = LaurentPolynomialRing(QQ) - sage: R.hom([y, x], R).inverse() # needs sage.libs.singular + sage: R. = LaurentPolynomialRing(QQ) # needs sage.modules + sage: R.hom([y, x], R).inverse() # needs sage.libs.singular sage.modules Traceback (most recent call last): ... NotImplementedError diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index d31df96ea8f..457a5c0fc39 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1787,7 +1787,7 @@ def _element_constructor_(self, x, check=True): Check that :trac:`30961` is fixed:: - sage: QQi = i.parent() + sage: QQi = i.parent() # needs sage.symbolic sage: x = SR.var('x') # needs sage.symbolic sage: QQi((x, x)) # needs sage.symbolic Traceback (most recent call last): @@ -9431,6 +9431,7 @@ def embeddings(self, K): We embed a cubic field in the complex numbers:: + sage: x = polygen(QQ, 'x') sage: K. = NumberField(x^3 - 2) sage: K.embeddings(CC) [ @@ -12818,12 +12819,12 @@ def _splitting_classes_gens_(K, m, d): sage: L = K.subfields(20)[0][0] sage: L.conductor() 101 - sage: _splitting_classes_gens_(L,101,20) + sage: _splitting_classes_gens_(L,101,20) # needs sage.libs.gap [95] sage: K = CyclotomicField(44) sage: L = K.subfields(4)[0][0] - sage: _splitting_classes_gens_(L,44,4) + sage: _splitting_classes_gens_(L,44,4) # needs sage.libs.gap [37] sage: K = CyclotomicField(44) @@ -12835,7 +12836,7 @@ def _splitting_classes_gens_(K, m, d): with zeta44_0 = 3.837971894457990? sage: L.conductor() 11 - sage: _splitting_classes_gens_(L,11,5) + sage: _splitting_classes_gens_(L,11,5) # needs sage.libs.gap [10] """ diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 842adcf236a..261ca29f4cb 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -551,7 +551,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): Check that :trac:`15276` is fixed:: - sage: for n in range(2,20): + sage: for n in range(2,20): # needs sage.libs.gap ....: K = CyclotomicField(n) ....: assert K(gap(K.gen())) == K.gen(), "n = {}".format(n) ....: assert K(gap(K.one())) == K.one(), "n = {}".format(n) diff --git a/src/sage/rings/polynomial/polynomial_complex_arb.pyx b/src/sage/rings/polynomial/polynomial_complex_arb.pyx index 57c1a52ede4..f26c7d8f52b 100644 --- a/src/sage/rings/polynomial/polynomial_complex_arb.pyx +++ b/src/sage/rings/polynomial/polynomial_complex_arb.pyx @@ -119,7 +119,7 @@ cdef class Polynomial_complex_arb(Polynomial): 2.000000000000000*x sage: Polynomial_complex_arb(Pol, (1,)) 1.000000000000000 - sage: Polynomial_complex_arb(Pol, (CBF(i), 1)) + sage: Polynomial_complex_arb(Pol, (CBF(i), 1)) # needs sage.symbolic x + I sage: Polynomial_complex_arb(Pol, polygen(QQ,'y')+2) x + 2.000000000000000 @@ -190,6 +190,7 @@ cdef class Polynomial_complex_arb(Polynomial): TESTS:: + sage: # needs sage.symbolic sage: Pol. = ComplexBallField(42)[] sage: pol = (x + i)/3 sage: pol2 = loads(dumps(pol)) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 5d4b9f1883b..57947c345bf 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -713,7 +713,7 @@ def minpoly(self): sage: F6. = F2.extension(3) sage: (u + 1).minpoly() # needs sage.modules x^6 + 425*x^5 + 19*x^4 + 125*x^3 + 189*x^2 + 239*x + 302 - sage: ext = F6.over(F2) + sage: ext = F6.over(F2) # needs sage.modules sage: ext(u + 1).minpoly() # indirect doctest # needs sage.modules x^3 + (396*i + 428)*x^2 + (80*i + 39)*x + 9*i + 178 diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index f898eb701d6..44cfa405633 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -2128,6 +2128,7 @@ cdef class Polynomial_rational_flint(Polynomial): :: + sage: R. = QQ[] sage: f = x^4 - 17*x^3 - 2*x + 1 sage: f.galois_group(algorithm='kash') # optional - kash Transitive group number 5 of degree 4 @@ -2324,6 +2325,7 @@ cdef class Polynomial_rational_flint(Polynomial): A more difficult example:: + sage: R. = QQ[] sage: f = 100 * (5*x + 1)^2 * (x + 5)^2 sage: f.factor_padic(5, 10) # needs sage.rings.padic (4*5^4 + O(5^14)) * ((1 + O(5^9))*x + 5^-1 + O(5^9))^2 diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 008c8a2a447..781567e0b9c 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -748,24 +748,21 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: R. = QQbar[] sage: A. = AA[] - sage: L = QQbar._factor_multivariate_polynomial(x^2-y^2) - sage: L + sage: # needs sage.libs.singular + sage: L = QQbar._factor_multivariate_polynomial(x^2 - y^2); L (x - y) * (x + y) - sage: L = QQbar._factor_multivariate_polynomial(x^2+y^2) - sage: L + sage: L = QQbar._factor_multivariate_polynomial(x^2 + y^2); L (x + (-1*I)*y) * (x + 1*I*y) sage: L.value() x^2 + y^2 - - sage: L = AA._factor_multivariate_polynomial(u^2-v^2) - sage: L + sage: L = AA._factor_multivariate_polynomial(u^2 - v^2); L (u - v) * (u + v) - sage: L = AA._factor_multivariate_polynomial(u^2+v^2) - sage: L + sage: L = AA._factor_multivariate_polynomial(u^2 + v^2); L u^2 + v^2 The test from Singular's ``absfact`` documentation:: + sage: # needs sage.libs.singular sage: p = (-7*x^2 + 2*x*y^2 + 6*x + y^4 + 14*y^2 + 47)*(5*x^2+y^2)^3*(x-y)^4 sage: F = QQbar._factor_multivariate_polynomial(p) sage: F @@ -775,7 +772,6 @@ def _factor_multivariate_polynomial(self, f, proof=True): * (y^2 + 3.828427124746190?*x + 8.414213562373095?) sage: F.value() == p True - sage: p = (-7*u^2 + 2*u*v^2 + 6*u + v^4 + 14*v^2 + 47)*(5*u^2+v^2)^3*(u-v)^4 sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -789,15 +785,13 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test requiring us to further extend a number field that was used to specify the polynomial:: - sage: # needs sage.symbolic + sage: # needs sage.libs.singular sage.symbolic sage: p = x^2 + QQbar(sqrt(2))*y^2 sage: F = QQbar._factor_multivariate_polynomial(p) sage: F (x + (-1.189207115002722?*I)*y) * (x + 1.189207115002722?*I*y) sage: F.value() == p True - - sage: # needs sage.symbolic sage: p = u^2 + AA(sqrt(2))*v^2 sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -808,15 +802,13 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test requiring a number field different from the number field used to specify the polynomial:: - sage: # needs sage.symbolic + sage: # needs sage.libs.singular sage.symbolic sage: p = QQbar(sqrt(2))*(x^2+y^2) sage: F = QQbar._factor_multivariate_polynomial(p) sage: F (1.414213562373095?) * (x + (-1*I)*y) * (x + 1*I*y) sage: F.value() == p True - - sage: # needs sage.symbolic sage: p = AA(sqrt(2))*(u^2+v^2) sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -827,19 +819,15 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where a factor introduces a number field that was already used to specify the polynomial:: - sage: # needs sage.symbolic + sage: # needs sage.libs.singular sage.symbolic sage: p = QQbar(sqrt(2))*(x^2-2*y^2)^2 - sage: F = QQbar._factor_multivariate_polynomial(p) - sage: F + sage: F = QQbar._factor_multivariate_polynomial(p); F (1.414213562373095?) * (x + (-1.414213562373095?)*y)^2 * (x + 1.414213562373095?*y)^2 sage: F.value() == p True - - sage: # needs sage.symbolic sage: p = AA(sqrt(2))*(u^2-2*v^2)^2 - sage: F = AA._factor_multivariate_polynomial(p) - sage: F + sage: F = AA._factor_multivariate_polynomial(p); F (1.414213562373095?) * (u - 1.414213562373095?*v)^2 * (u + 1.414213562373095?*v)^2 sage: F.value() == p @@ -847,19 +835,17 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where two factors produce the same factor in the norm:: - sage: # needs sage.symbolic + sage: # needs sage.libs.singular sage.symbolic sage: p = (x^2+QQbar(sqrt(2))*y^2)*(x^4-2*y^4) - sage: F = QQbar._factor_multivariate_polynomial(p) - sage: F + sage: F = QQbar._factor_multivariate_polynomial(p); F (x + (-1.189207115002722?)*y) * (x + 1.189207115002722?*y) * (x + (-1.189207115002722?*I)*y)^2 * (x + 1.189207115002722?*I*y)^2 sage: F.value() == p True - sage: # needs sage.symbolic + sage: # needs sage.libs.singular sage.symbolic sage: p = (u^2+AA(sqrt(2))*v^2)*(u^4-2*v^4) - sage: F = AA._factor_multivariate_polynomial(p) - sage: F + sage: F = AA._factor_multivariate_polynomial(p); F (u - 1.189207115002722?*v) * (u + 1.189207115002722?*v) * (u^2 + 1.414213562373095?*v^2)^2 sage: F.value() == p @@ -868,9 +854,9 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where the number field that expresses the result is a subfield of the number field that expressed the polynomial:: + sage: # needs sage.libs.singular sage: p = (x^2+QQbar(2)^(1/2)*y^2)*(x+QQbar(2)^(1/8)*y) - sage: F = QQbar._factor_multivariate_polynomial(p) - sage: F + sage: F = QQbar._factor_multivariate_polynomial(p); F (x + (-1.189207115002722?*I)*y) * (x + 1.189207115002722?*I*y) * (x + 1.090507732665258?*y) sage: F.value() == p @@ -879,14 +865,15 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where the polynomial variable names conflict with the number field generator:: + sage: # needs sage.libs.singular sage.symbolic sage: S. = QQbar[] - sage: p = a^2 + QQbar(sqrt(2))*b^2 # needs sage.symbolic - sage: F = QQbar._factor_multivariate_polynomial(p) # needs sage.symbolic - sage: F # needs sage.symbolic + sage: p = a^2 + QQbar(sqrt(2))*b^2 + sage: F = QQbar._factor_multivariate_polynomial(p); F (a + (-1.189207115002722?*I)*b) * (a + 1.189207115002722?*I*b) A test that led to :trac:`26898`:: + sage: # needs sage.libs.singular sage: R. = QQ[] sage: minpoly = 4*x^7 + 27 sage: NF. = NumberField(minpoly) @@ -896,6 +883,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): Test :trac:`29076`:: + sage: # needs sage.libs.singular sage: AA['x','y'](1).factor() # indirect doctest 1 @@ -1520,7 +1508,7 @@ def _factor_univariate_polynomial(self, f): (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?) sage: AA._factor_univariate_polynomial(12*x^2 + 4) (12) * (x^2 + 0.3333333333333334?) - sage: AA._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(AA).division_polynomial(5)) + sage: AA._factor_univariate_polynomial(EllipticCurve('11a1').change_ring(AA).division_polynomial(5)) # needs sage.schemes (5) * (x - 16.00000000000000?) * (x - 5.000000000000000?) * (x - 1.959674775249769?) * (x + 2.959674775249769?) * (x^2 - 2.854101966249685?*x + 15.47213595499958?) * (x^2 + 1.909830056250526?*x + 1.660606461254312?) * (x^2 + 3.854101966249685?*x + 6.527864045000421?) * (x^2 + 13.09016994374948?*x + 93.33939353874569?) """ @@ -1700,8 +1688,9 @@ def _coerce_map_from_(self, from_par): sage: QQbar.has_coerce_map_from(SR) # needs sage.symbolic False - sage: i + QQbar(2) + sage: i + QQbar(2) # needs sage.symbolic I + 2 + sage: K. = QuadraticField(-1, embedding=ComplexField(13)(0,-1)) sage: ii + QQbar(2) -I + 2 @@ -2807,15 +2796,16 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal Tests more complicated combinations:: + sage: # needs sage.libs.gap sage.symbolic sage: UCF = UniversalCyclotomicField() sage: E = UCF.gen(5) sage: L. = NumberField(x^2-189*x+16, embedding=200) sage: x = polygen(ZZ) - sage: my_nums = [-52*E - 136*E^2 - 136*E^3 - 52*E^4, # needs sage.symbolic + sage: my_nums = [-52*E - 136*E^2 - 136*E^3 - 52*E^4, ....: L.gen()._algebraic_(AA), ....: 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) # needs sage.symbolic - sage: res[0] # needs sage.symbolic + 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 = 93.32530798172420? """ From 3b8f49025078b18b4f5fc83b4cadc1370a46e166 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 16:54:10 -0700 Subject: [PATCH 064/494] sage.rings: Remove 'sage_setup: distribution' directives --- src/sage/rings/factorint_pari.pyx | 1 - src/sage/rings/valuation/augmented_valuation.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/sage/rings/factorint_pari.pyx b/src/sage/rings/factorint_pari.pyx index 862b7baa5b8..8e5ed7c619e 100644 --- a/src/sage/rings/factorint_pari.pyx +++ b/src/sage/rings/factorint_pari.pyx @@ -1,4 +1,3 @@ -# sage_setup: distribution = sagemath-pari # sage.doctest: needs sage.libs.pari r""" Integer factorization using PARI diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 21fbb67008f..0d873aa4943 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -1,4 +1,3 @@ -# sage_setup: distribution = sagemath-pari r""" Augmented valuations on polynomial rings From c1aabef24f4cb50019e3ae0b7bdc6fc94cb5c279 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 17:31:49 -0700 Subject: [PATCH 065/494] src/sage/rings/valuation/limit_valuation.py: Restore lost '# random' --- src/sage/rings/valuation/limit_valuation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/valuation/limit_valuation.py b/src/sage/rings/valuation/limit_valuation.py index 96b2f93615f..31caa6ebaca 100644 --- a/src/sage/rings/valuation/limit_valuation.py +++ b/src/sage/rings/valuation/limit_valuation.py @@ -769,9 +769,9 @@ def _weakly_separating_element(self, other): sage: w = v.extension(L) sage: v = QQ.valuation(5) sage: u,uu = v.extensions(L) - sage: w._base_valuation._weakly_separating_element(u._base_valuation) # long time + sage: w._base_valuation._weakly_separating_element(u._base_valuation) # long time 2 - sage: u._base_valuation._weakly_separating_element(uu._base_valuation) # long time + sage: u._base_valuation._weakly_separating_element(uu._base_valuation) # long time t + 2 sage: # needs sage.rings.function_field @@ -784,14 +784,14 @@ def _weakly_separating_element(self, other): sage: w,ww = v.extensions(L) sage: v = K.valuation(1) sage: v = v.extension(L) - sage: u.separating_element([uu,ww,w,v]) # long time + sage: u.separating_element([uu,ww,w,v]) # random output # long time ((8*x^4 + 12*x^2 + 4)/(x^2 - x))*y + (8*x^4 + 8*x^2 + 1)/(x^3 - x^2) The underlying algorithm is quite naive and might not terminate in reasonable time. In particular, the order of the arguments sometimes has a huge impact on the runtime:: - sage: u.separating_element([ww,w,v,uu]) # not tested, takes forever + sage: u.separating_element([ww,w,v,uu]) # not tested, takes forever """ from .scaled_valuation import ScaledValuation_generic From 34c9fff61628a008b3d16585ed66cc6e1515bfa3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 14 Sep 2023 10:26:33 -0700 Subject: [PATCH 066/494] src/sage/rings/polynomial/polynomial_ring_constructor.py: Fix # needs --- src/sage/rings/polynomial/polynomial_ring_constructor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index dcb47e2ab41..ba9b9453e76 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -611,11 +611,14 @@ def PolynomialRing(base_ring, *args, **kwds): sage: R = PolynomialRing(GF(49), 'j', sparse=True); TestSuite(R).run(); type(R) # needs sage.rings.finite_rings - sage: P. = PolynomialRing(RealIntervalField(2)) # needs sage.rings.real_interval_field + + sage: # needs sage.rings.real_interval_field + sage: P. = PolynomialRing(RealIntervalField(2)) sage: TestSuite(P).run(skip=['_test_elements', '_test_elements_eq_transitive']) sage: Q. = PolynomialRing(P) - sage: TestSuite(Q).run(skip=['_test_additive_associativity', '_test_associativity', '_test_distributivity', '_test_prod']) - sage: R. = PolynomialRing(RIF,2) # needs sage.rings.real_interval_field + sage: TestSuite(Q).run(skip=['_test_additive_associativity', '_test_associativity', + ....: '_test_distributivity', '_test_prod']) + sage: R. = PolynomialRing(RIF,2) sage: TestSuite(R).run(skip=['_test_elements', '_test_elements_eq_transitive']) """ if not ring.is_Ring(base_ring): From 5257002cb51479e19bd9d41b838f01427d8d8519 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 12:49:08 -0700 Subject: [PATCH 067/494] sage.schemes: Update # needs --- src/sage/schemes/projective/projective_point.py | 1 + src/sage/schemes/projective/projective_subscheme.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 53038b21efe..9769b7237c6 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -1074,6 +1074,7 @@ class SchemeMorphism_point_projective_field(SchemeMorphism_point_projective_ring EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: P = ProjectiveSpace(3, RR) sage: P(2, 3, 4, 5) (0.400000000000000 : 0.600000000000000 : 0.800000000000000 : 1.00000000000000) diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 8970637882d..9a465b36ea4 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -1432,6 +1432,7 @@ def global_height(self, prec=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: NF. = NumberField(x^2 - 5) sage: P. = ProjectiveSpace(NF, 2) @@ -1443,7 +1444,7 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([z^2 - 101*y^2 - 3*x*z]) - sage: X.global_height() # long time + sage: X.global_height() # long time 4.61512051684126 """ return self.Chow_form().global_height(prec) @@ -1465,19 +1466,20 @@ def local_height(self, v, prec=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: NF. = NumberField(x^2 - 5) sage: I = NF.ideal(3) sage: P. = ProjectiveSpace(NF, 2) sage: X = P.subscheme([3*x*y - 5*x*z, y^2]) - sage: X.local_height(I) + sage: X.local_height(I) # needs sage.libs.singular 0.000000000000000 :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([z^2 - 101*y^2 - 3*x*z]) - sage: X.local_height(2) + sage: X.local_height(2) # needs sage.libs.singular 0.000000000000000 """ return self.Chow_form().local_height(v, prec) @@ -1499,18 +1501,19 @@ def local_height_arch(self, i, prec=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: NF. = NumberField(x^2 - 5) sage: P. = ProjectiveSpace(NF, 2) sage: X = P.subscheme([x^2 + y*z, 3*x*y]) - sage: X.local_height_arch(1) + sage: X.local_height_arch(1) # needs sage.libs.singular 0.0000000000000000000000000000000 :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([z^2 - 101*y^2 - 3*x*z]) - sage: X.local_height_arch(1) + sage: X.local_height_arch(1) # needs sage.libs.singular 4.61512051684126 """ return self.Chow_form().local_height_arch(i, prec) \ No newline at end of file From 26bda85794341ee6de5916709f33c69f11aff22d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 15:31:22 -0700 Subject: [PATCH 068/494] Fix # needs for sagemath-pari --- src/sage/schemes/projective/projective_morphism.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 5ba47f00afa..4396f4c7765 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2082,18 +2082,18 @@ def reduce_base_field(self): sage: H2 = Hom(P, P2) sage: H3 = Hom(P2, P) sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) - sage: f.reduce_base_field() + sage: f.reduce_base_field() # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Finite Field in t2 of size 3^2 Defn: Defined on coordinates by sending (x : y) to (x^2 + t2*y^2 : y^2) sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) - sage: f2.reduce_base_field() + sage: f2.reduce_base_field() # needs sage.modules Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 3 To: Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 - y^2 : y^2 : -x*y) sage: f3 = H3([a^2 + t*b^2, c^2]) - sage: f3.reduce_base_field() + sage: f3.reduce_base_field() # needs sage.modules Scheme morphism: From: Projective Space of dimension 2 over Finite Field in t of size 3^4 To: Projective Space of dimension 1 over Finite Field in t of size 3^4 From 796265f2509acc932ba067fabc3d67a7df931fca Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 19:55:20 -0700 Subject: [PATCH 069/494] sage.schemes: Update # needs --- src/sage/schemes/affine/affine_space.py | 2 +- src/sage/schemes/generic/algebraic_scheme.py | 2 +- src/sage/schemes/generic/morphism.py | 2 +- src/sage/schemes/generic/scheme.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py index 927a065cf60..2680982c232 100644 --- a/src/sage/schemes/affine/affine_space.py +++ b/src/sage/schemes/affine/affine_space.py @@ -1149,7 +1149,7 @@ def curve(self, F): EXAMPLES:: sage: A. = AffineSpace(QQ, 3) - sage: A.curve([y - x^4, z - y^5]) # needs sage.libs.pari + sage: A.curve([y - x^4, z - y^5]) # needs sage.schemes Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z """ from sage.schemes.curves.constructor import Curve diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index 5d071f2bd49..01b7229f846 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -1296,7 +1296,7 @@ def is_irreducible(self): ....: x*y*z^2 - x*y*z*w - z*w^2 + w^3, ....: x^3*y*z*w - x*y^3*z - x^2*y*z*w - x^2*w^3 + y^2*w^2 + x*w^3 ....: ]) - sage: X.is_irreducible() # needs sage.rings.finite_rings + sage: X.is_irreducible() # needs sage.libs.singular False """ return self.defining_ideal().is_prime() diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index f42e8f4a680..7597d385b40 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -513,7 +513,7 @@ def base_ring(self): :: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(GF((17,2)), [1,2,3,4,5]) sage: P = E.random_point() sage: P.base_ring() diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py index fe55bca9117..da188ac63b3 100644 --- a/src/sage/schemes/generic/scheme.py +++ b/src/sage/schemes/generic/scheme.py @@ -684,7 +684,7 @@ def count_points(self, n): sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings - sage: X.count_points(2) # needs sage.rings.finite_rings + sage: X.count_points(2) # needs sage.libs.singular sage.rings.finite_rings [5, 17] """ F = self.base_ring() From 75b8262a338b9c13cf94542b9289be382bafcda3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 23:48:50 -0700 Subject: [PATCH 070/494] src/sage/dynamics/complex_dynamics/mandel_julia.py: Use lazy_import --- src/sage/dynamics/complex_dynamics/mandel_julia.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia.py b/src/sage/dynamics/complex_dynamics/mandel_julia.py index f387c84ccec..f3d6fbfa5a0 100644 --- a/src/sage/dynamics/complex_dynamics/mandel_julia.py +++ b/src/sage/dynamics/complex_dynamics/mandel_julia.py @@ -31,7 +31,6 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem from sage.dynamics.complex_dynamics.mandel_julia_helper import (fast_mandelbrot_plot, fast_external_ray, convert_to_pixels, @@ -56,6 +55,8 @@ from sage.rings.fraction_field import is_FractionField from sage.categories.function_fields import FunctionFields +lazy_import('sage.dynamics.arithmetic_dynamics.generic_ds', 'DynamicalSystem') + EPS = 0.00001 def mandelbrot_plot(f=None, **kwds): From 0284add97c3c9cf7af2c13577df1720498b6ccec Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 17:15:36 -0700 Subject: [PATCH 071/494] sage.schemes: Doctest cosmetics, update # needs --- .../hyperelliptic_curves/monsky_washnitzer.py | 317 ++++++++++-------- src/sage/schemes/plane_conics/con_field.py | 67 ++-- .../plane_conics/con_rational_field.py | 16 +- .../con_rational_function_field.py | 26 +- src/sage/schemes/product_projective/point.py | 2 +- .../schemes/projective/projective_morphism.py | 9 +- .../schemes/projective/projective_space.py | 2 +- .../projective/projective_subscheme.py | 4 +- 8 files changed, 238 insertions(+), 205 deletions(-) diff --git a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py index 321928f1464..c8683230212 100644 --- a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py +++ b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py @@ -84,7 +84,7 @@ class SpecialCubicQuotientRingElement(CommutativeAlgebraElement): """ - An element of a SpecialCubicQuotientRing. + An element of a :class:`SpecialCubicQuotientRing`. """ def __init__(self, parent, p0, p1, p2, check=True): """ @@ -93,7 +93,7 @@ def __init__(self, parent, p0, p1, p2, check=True): INPUT: - - ``parent`` -- a SpecialCubicQuotientRing + - ``parent`` -- a :class:`SpecialCubicQuotientRing` - ``p0, p1, p2`` -- coefficients; must be coercible into parent.poly_ring() @@ -306,7 +306,9 @@ def square(self): sage: f = R.create_element(1 + 2*t + 3*t^2, 4 + 7*t + 9*t^2, 3 + 5*t + 11*t^2) sage: f.square() - (73*T^5 + 16*T^4 + 38*T^3 + 39*T^2 + 70*T + 120) + (121*T^5 + 113*T^4 + 73*T^3 + 8*T^2 + 51*T + 61)*x + (18*T^4 + 60*T^3 + 22*T^2 + 108*T + 31)*x^2 + (73*T^5 + 16*T^4 + 38*T^3 + 39*T^2 + 70*T + 120) + + (121*T^5 + 113*T^4 + 73*T^3 + 8*T^2 + 51*T + 61)*x + + (18*T^4 + 60*T^3 + 22*T^2 + 108*T + 31)*x^2 """ return self * self @@ -323,7 +325,9 @@ def _mul_(self, other): sage: f = R.create_element(1 + 2*t + 3*t^2, 4 + 7*t + 9*t^2, 3 + 5*t + 11*t^2) sage: g = R.create_element(4 + 3*t + 7*t^2, 2 + 3*t + t^2, 8 + 4*t + 6*t^2) sage: f * g - (65*T^5 + 27*T^4 + 33*T^3 + 75*T^2 + 120*T + 57) + (66*T^5 + T^4 + 123*T^3 + 95*T^2 + 24*T + 50)*x + (45*T^4 + 75*T^3 + 37*T^2 + 2*T + 52)*x^2 + (65*T^5 + 27*T^4 + 33*T^3 + 75*T^2 + 120*T + 57) + + (66*T^5 + T^4 + 123*T^3 + 95*T^2 + 24*T + 50)*x + + (45*T^4 + 75*T^3 + 37*T^2 + 2*T + 52)*x^2 """ # Here we do Toom-Cook three-way multiplication, which reduces # the naive 9 polynomial multiplications to only 5 polynomial @@ -470,8 +474,8 @@ def __init__(self, Q, laurent_series=False): `Q(x) = x^3 + ax + b`, where `a`, `b` belong to a ring in which 2, 3 are invertible. - - ``laurent_series`` -- whether or not to allow - negative powers of `T` (default=False) + - ``laurent_series`` -- boolean (default: ``False``); whether or not to allow + negative powers of `T` EXAMPLES:: @@ -494,7 +498,8 @@ def __init__(self, Q, laurent_series=False): sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + 1) Traceback (most recent call last): ... - ArithmeticError: 2 and 3 must be invertible in the coefficient ring (=Ring of integers modulo 10) of Q + ArithmeticError: 2 and 3 must be invertible in the coefficient ring + (=Ring of integers modulo 10) of Q """ if not isinstance(Q, Polynomial): raise TypeError("Q (=%s) must be a polynomial" % Q) @@ -717,10 +722,10 @@ def helper_matrix(Q): def lift(x): r""" - Try to call x.lift(), presumably from the `p`-adics to ZZ. + Try to call ``x.lift()``, presumably from the `p`-adics to ``ZZ``. If this fails, it assumes the input is a power series, and tries to - lift it to a power series over QQ. + lift it to a power series over ``QQ``. This function is just a very kludgy solution to the problem of trying to make the reduction code (below) work over both Zp and @@ -728,14 +733,14 @@ def lift(x): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.schemes.hyperelliptic_curves.monsky_washnitzer import lift sage: l = lift(Qp(13)(131)); l 131 sage: l.parent() Integer Ring - - sage: x=PowerSeriesRing(Qp(17),'x').gen() - sage: l = lift(4+5*x+17*x**6); l + sage: x = PowerSeriesRing(Qp(17),'x').gen() + sage: l = lift(4 + 5*x + 17*x**6); l 4 + 5*t + 17*t^6 sage: l.parent() Power Series Ring in t over Rational Field @@ -1298,7 +1303,7 @@ def frobenius_expansion_by_series(Q, p, M): sage: from sage.schemes.hyperelliptic_curves.monsky_washnitzer import frobenius_expansion_by_series sage: R. = Integers(5^3)['x'] sage: Q = x^3 - x + R(1/4) - sage: frobenius_expansion_by_series(Q,5,3) + sage: frobenius_expansion_by_series(Q,5,3) # needs sage.libs.pari ((25*T^5 + 75*T^3 + 100*T^2 + 100*T + 100) + (5*T^6 + 80*T^5 + 100*T^3 + 25*T + 50)*x + (55*T^5 + 50*T^4 + 75*T^3 + 25*T^2 + 25*T + 25)*x^2, (5*T^8 + 15*T^7 + 95*T^6 + 10*T^5 + 25*T^4 + 25*T^3 + 100*T^2 + 50) @@ -1494,6 +1499,7 @@ def matrix_of_frobenius(Q, p, M, trace=None, compute_exact_forms=False): Here is an example that is particularly badly conditioned for using the trace trick:: + sage: # needs sage.libs.pari sage: p = 11 sage: prec = 3 sage: M = monsky_washnitzer.adjusted_prec(p, prec) @@ -1521,56 +1527,55 @@ def matrix_of_frobenius(Q, p, M, trace=None, compute_exact_forms=False): factors), so it is feasible to run on fairly large primes, or precision (or both?!?!):: + sage: # long time, needs sage.libs.pari sage: p = 10007 sage: prec = 2 sage: M = monsky_washnitzer.adjusted_prec(p, prec) sage: R. = PolynomialRing(Integers(p**M)) - sage: A = monsky_washnitzer.matrix_of_frobenius( # long time - ....: x^3 - x + R(1/4), p, M) - sage: B = A.change_ring(Integers(p**prec)); B # long time + sage: A = monsky_washnitzer.matrix_of_frobenius(x^3 - x + R(1/4), p, M) + sage: B = A.change_ring(Integers(p**prec)); B [74311982 57996908] [95877067 25828133] - sage: B.det() # long time + sage: B.det() 10007 - sage: B.trace() # long time + sage: B.trace() 66 - sage: EllipticCurve([-1, 1/4]).ap(10007) # long time + sage: EllipticCurve([-1, 1/4]).ap(10007) 66 :: + sage: # long time, needs sage.libs.pari sage: p = 5 sage: prec = 300 sage: M = monsky_washnitzer.adjusted_prec(p, prec) sage: R. = PolynomialRing(Integers(p**M)) - sage: A = monsky_washnitzer.matrix_of_frobenius( # long time - ....: x^3 - x + R(1/4), p, M) - sage: B = A.change_ring(Integers(p**prec)) # long time - sage: B.det() # long time + sage: A = monsky_washnitzer.matrix_of_frobenius(x^3 - x + R(1/4), p, M) + sage: B = A.change_ring(Integers(p**prec)) + sage: B.det() 5 - sage: -B.trace() # long time + sage: -B.trace() 2 - sage: EllipticCurve([-1, 1/4]).ap(5) # long time + sage: EllipticCurve([-1, 1/4]).ap(5) -2 Let us check consistency of the results for a range of precisions:: + sage: # long time, needs sage.libs.pari sage: p = 5 sage: max_prec = 60 sage: M = monsky_washnitzer.adjusted_prec(p, max_prec) sage: R. = PolynomialRing(Integers(p**M)) - sage: A = monsky_washnitzer.matrix_of_frobenius(x^3 - x + R(1/4), p, M) # long time - sage: A = A.change_ring(Integers(p**max_prec)) # long time - sage: result = [] # long time - sage: for prec in range(1, max_prec): # long time + sage: A = monsky_washnitzer.matrix_of_frobenius(x^3 - x + R(1/4), p, M) + sage: A = A.change_ring(Integers(p**max_prec)) + sage: result = [] + sage: for prec in range(1, max_prec): ....: M = monsky_washnitzer.adjusted_prec(p, prec) ....: R. = PolynomialRing(Integers(p^M),'x') - ....: B = monsky_washnitzer.matrix_of_frobenius( - ....: x^3 - x + R(1/4), p, M) + ....: B = monsky_washnitzer.matrix_of_frobenius(x^3 - x + R(1/4), p, M) ....: B = B.change_ring(Integers(p**prec)) - ....: result.append(B == A.change_ring( - ....: Integers(p**prec))) - sage: result == [True] * (max_prec - 1) # long time + ....: result.append(B == A.change_ring(Integers(p**prec))) + sage: result == [True] * (max_prec - 1) True The remaining examples discuss what happens when you take the @@ -1581,6 +1586,7 @@ def matrix_of_frobenius(Q, p, M, trace=None, compute_exact_forms=False): :: + sage: # needs sage.libs.pari sage: p = 11 sage: prec = 3 sage: M = monsky_washnitzer.adjusted_prec(p, prec) @@ -1589,9 +1595,9 @@ def matrix_of_frobenius(Q, p, M, trace=None, compute_exact_forms=False): sage: b = 8 - 6*t + 17*t^2 sage: R. = PolynomialRing(S) sage: Q = x**3 + a*x + b - sage: A = monsky_washnitzer.matrix_of_frobenius(Q, p, M) # long time - sage: B = A.change_ring(PowerSeriesRing(Integers(p**prec), 't', default_prec=4)) # long time - sage: B # long time + sage: A = monsky_washnitzer.matrix_of_frobenius(Q, p, M) # long time + sage: B = A.change_ring(PowerSeriesRing(Integers(p**prec), 't', # long time + ....: default_prec=4)); B [1144 + 264*t + 841*t^2 + 1025*t^3 + O(t^4) 176 + 1052*t + 216*t^2 + 523*t^3 + O(t^4)] [ 847 + 668*t + 81*t^2 + 424*t^3 + O(t^4) 185 + 341*t + 171*t^2 + 642*t^3 + O(t^4)] @@ -1786,6 +1792,7 @@ def matrix_of_frobenius_hyperelliptic(Q, p=None, prec=None, M=None): EXAMPLES:: + sage: # needs sage.rings.padics sage: p = 5 sage: prec = 3 sage: R. = QQ['x'] @@ -1854,10 +1861,10 @@ class SpecialHyperellipticQuotientElement(CommutativeAlgebraElement): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: MW = x.parent() - sage: MW(x+x**2+y-77) + sage: MW(x + x**2 + y - 77) -(77-y)*1 + x + x^2 """ def __init__(self, parent, val=0, offset=0, check=True): @@ -1867,10 +1874,10 @@ def __init__(self, parent, val=0, offset=0, check=True): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: MW = x.parent() - sage: elt = MW(x+x**2+y-77) + sage: elt = MW(x + x**2 + y - 77) sage: TestSuite(elt).run() """ CommutativeAlgebraElement.__init__(self, parent) @@ -1896,7 +1903,7 @@ def _richcmp_(self, other, op): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x == x True @@ -1912,12 +1919,13 @@ def change_ring(self, R): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: MW = x.parent() - sage: z = MW(x+x**2+y-77) - sage: z.change_ring(AA).parent() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 36*x + 1) over Algebraic Real Field + sage: z = MW(x + x**2 + y - 77) + sage: z.change_ring(AA).parent() # needs sage.rings.number_field + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 36*x + 1) + over Algebraic Real Field """ return self.parent().change_ring(R)(self) @@ -1928,10 +1936,10 @@ def __call__(self, *x): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: MW = x.parent() - sage: z = MW(x+x**2+y-77); z + sage: z = MW(x + x**2 + y - 77); z -(77-y)*1 + x + x^2 sage: z(66) 4345 + y @@ -1950,14 +1958,15 @@ def __invert__(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: MW = x.parent() - sage: z = y**(-1) # indirect doctest + sage: z = y**(-1) # indirect doctest sage: z.parent() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 36*x + 1) over Rational Field + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 36*x + 1) + over Rational Field - sage: z = (x+y)**(-1) # indirect doctest + sage: z = (x+y)**(-1) # indirect doctest Traceback (most recent call last): ... ZeroDivisionError: element not invertible @@ -1975,7 +1984,7 @@ def __bool__(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: bool(x) True @@ -1989,7 +1998,7 @@ def __eq__(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x == y # indirect doctest False @@ -2005,9 +2014,9 @@ def _add_(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: x+y + sage: x + y y*1 + x """ P = self.parent() @@ -2020,9 +2029,9 @@ def _sub_(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: y-x + sage: y - x y*1 - x """ P = self.parent() @@ -2035,7 +2044,7 @@ def _mul_(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-36*x+1) + sage: E = HyperellipticCurve(x^5 - 36*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: y*x y*x @@ -2066,9 +2075,9 @@ def _rmul_(self, c): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: x._rmul_(y) + sage: x._rmul_(y) # needs sage.rings.real_interval_field y*1*x """ P = self.parent() @@ -2088,7 +2097,7 @@ def _lmul_(self, c): sage: R. = QQ['x'] sage: E = HyperellipticCurve(x^5-3*x+1) sage: x,y = E.monsky_washnitzer_gens() - sage: x._lmul_(y) + sage: x._lmul_(y) # needs sage.rings.real_interval_field y*1*x """ P = self.parent() @@ -2106,7 +2115,7 @@ def __lshift__(self, k): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.__lshift__(3) y^3*x @@ -2122,7 +2131,7 @@ def __rshift__(self, k): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: y.__rshift__(3) (y^-2)*1 @@ -2138,9 +2147,9 @@ def truncate_neg(self, n): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y+7*x*2*y**4).truncate_neg(1) + sage: (x + 3*y + 7*x*2*y**4).truncate_neg(1) 3*y*1 + 14*y^4*x """ coeffs = self._f.list(copy=False) @@ -2154,9 +2163,9 @@ def _repr_(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y)._repr_() + sage: (x + 3*y)._repr_() '3*y*1 + x' """ x = PolynomialRing(QQ, 'x').gen(0) @@ -2170,9 +2179,9 @@ def _latex_(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y)._latex_() + sage: (x + 3*y)._latex_() '3y 1 + x' """ x = PolynomialRing(QQ, 'x').gen(0) @@ -2186,9 +2195,9 @@ def diff(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y).diff() + sage: (x + 3*y).diff() (-(9-2*y)*1 + 15*x^4) dx/2y """ # try: @@ -2216,9 +2225,9 @@ def extract_pow_y(self, k): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y+9*x*y).extract_pow_y(1) + sage: (x + 3*y + 9*x*y).extract_pow_y(1) [3, 9, 0, 0, 0] """ v = [a[k] for a in self._f.list()] @@ -2232,9 +2241,9 @@ def min_pow_y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y).min_pow_y() + sage: (x + 3*y).min_pow_y() 0 """ if self._f.degree() == -1: @@ -2248,9 +2257,9 @@ def max_pow_y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: (x+3*y).max_pow_y() + sage: (x + 3*y).max_pow_y() 1 """ if self._f.degree() == -1: @@ -2276,7 +2285,7 @@ def coeffs(self, R=None): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.coeffs() ([(0, 1, 0, 0, 0)], 0) @@ -2287,7 +2296,7 @@ def coeffs(self, R=None): x + 2*x^2 + 3*x^3 + 4*x^4 sage: a.coeffs() ([(0, 1, 2, 3, 4)], 0) - sage: a.coeffs(Qp(7)) + sage: a.coeffs(Qp(7)) # needs sage.rings.padics ([(0, 1 + O(7^20), 2 + O(7^20), 3 + O(7^20), 4 + O(7^20))], 0) sage: (a*y).coeffs() ([(0, 0, 0, 0, 0), (0, 1, 2, 3, 4)], 0) @@ -2304,7 +2313,8 @@ def coeffs(self, R=None): sage: a = x^20*y^-3 - x^11*y^2; a (y^-3-4*y^-1+6*y-4*y^3+y^5)*1 - (12*y^-3-36*y^-1+36*y+y^2-12*y^3-2*y^4+y^6)*x - + (54*y^-3-108*y^-1+54*y+6*y^2-6*y^4)*x^2 - (108*y^-3-108*y^-1+9*y^2)*x^3 + (81*y^-3)*x^4 + + (54*y^-3-108*y^-1+54*y+6*y^2-6*y^4)*x^2 - (108*y^-3-108*y^-1+9*y^2)*x^3 + + (81*y^-3)*x^4 sage: raw, offset = a.coeffs() sage: a.min_pow_y() -3 @@ -2321,7 +2331,8 @@ def coeffs(self, R=None): (0, 2, -6, 0, 0), (1, 0, 0, 0, 0), (0, -1, 0, 0, 0)] - sage: sum(c * x^i * y^(j+offset) for j, L in enumerate(raw) for i, c in enumerate(L)) == a + sage: sum(c * x^i * y^(j+offset) + ....: for j, L in enumerate(raw) for i, c in enumerate(L)) == a True Can also be used to construct elements:: @@ -2360,10 +2371,10 @@ def __init__(self, Q, R=None, invert_y=True): TESTS:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: from sage.schemes.hyperelliptic_curves.monsky_washnitzer import SpecialHyperellipticQuotientRing sage: HQR = SpecialHyperellipticQuotientRing(E) - sage: TestSuite(HQR).run() + sage: TestSuite(HQR).run() # needs sage.rings.real_interval_field Check that caching works:: @@ -2441,7 +2452,7 @@ def _repr_(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent() # indirect doctest SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 3*x + 1) over Rational Field @@ -2456,10 +2467,11 @@ def base_extend(self, R): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() - sage: x.parent().base_extend(UniversalCyclotomicField()) - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 3*x + 1) over Universal Cyclotomic Field + sage: x.parent().base_extend(UniversalCyclotomicField()) # needs sage.libs.gap + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 3*x + 1) + over Universal Cyclotomic Field sage: x.parent().base_extend(ZZ) Traceback (most recent call last): ... @@ -2476,10 +2488,11 @@ def change_ring(self, R): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().change_ring(ZZ) - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 3*x + 1) over Integer Ring + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 3*x + 1) + over Integer Ring """ return SpecialHyperellipticQuotientRing(self._Q.change_ring(R), R, is_LaurentSeriesRing(self._series_ring)) @@ -2491,7 +2504,7 @@ def _element_constructor_(self, val, offset=0, check=True): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent()(x^6) -(1-y^2)*x + 3*x^2 @@ -2513,7 +2526,7 @@ def one(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().one() 1 @@ -2528,7 +2541,7 @@ def zero(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().zero() 0 @@ -2542,7 +2555,7 @@ def gens(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().gens() (x, y*1) @@ -2556,7 +2569,7 @@ def x(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().x() x @@ -2570,7 +2583,7 @@ def y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().y() y*1 @@ -2584,7 +2597,7 @@ def monomial(self, i, j, b=None): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().monomial(4,5) y^5*x^4 @@ -2623,7 +2636,7 @@ def monomial_diff_coeffs(self, i, j): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().monomial_diff_coeffs(2,3) ((0, -15, 36, 0, 0), (0, 19, 0, 0, 0)) @@ -2656,7 +2669,7 @@ def monomial_diff_coeffs_matrices(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().monomial_diff_coeffs_matrices() ( @@ -2684,7 +2697,7 @@ def _precompute_monomial_diffs(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent()._precompute_monomial_diffs() [((-3, 0, 0, 0, 5), (0, 0, 0, 0, 0), (0, 0, 0, 0, 0)), @@ -2725,7 +2738,7 @@ def curve(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().curve() Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 3*x + 1 @@ -2739,7 +2752,7 @@ def degree(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().degree() 5 @@ -2753,7 +2766,7 @@ def prime(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().prime() is None True @@ -2767,7 +2780,7 @@ def monsky_washnitzer(self): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: type(x.parent().monsky_washnitzer()) @@ -2781,7 +2794,7 @@ def is_field(self, proof=True): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = E.monsky_washnitzer_gens() sage: x.parent().is_field() False @@ -2846,7 +2859,7 @@ def _add_(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x + 4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w + w @@ -2867,7 +2880,7 @@ def _sub_(self, other): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w-w @@ -2887,7 +2900,7 @@ def __neg__(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: -w @@ -2905,7 +2918,7 @@ def _lmul_(self, a): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w*x @@ -2927,7 +2940,7 @@ def _rmul_(self, a): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: x*w @@ -2949,7 +2962,7 @@ def coeff(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w @@ -2966,7 +2979,7 @@ def __bool__(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: not w @@ -2983,7 +2996,7 @@ def _repr_(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w @@ -3003,7 +3016,7 @@ def _latex_(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: latex(w) @@ -3030,7 +3043,7 @@ def _richcmp_(self, other, op): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: (y^-1).diff() == (y^-1).diff() True @@ -3053,7 +3066,7 @@ def extract_pow_y(self, k): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: A = y^5 - x*y^3 sage: A.extract_pow_y(5) @@ -3070,7 +3083,7 @@ def min_pow_y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: w = y^5 * C.invariant_differential() sage: w.min_pow_y() @@ -3088,7 +3101,7 @@ def max_pow_y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: w = y^5 * C.invariant_differential() sage: w.max_pow_y() @@ -3106,7 +3119,7 @@ def reduce_neg_y(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: (y^-1).diff().reduce_neg_y() ((y^-1)*1, 0 dx/2y) @@ -3142,7 +3155,7 @@ def reduce_neg_y_fast(self, even_degree_only=False): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: x, y = E.monsky_washnitzer_gens() sage: (y^-1).diff().reduce_neg_y_fast() ((y^-1)*1, 0 dx/2y) @@ -3206,7 +3219,7 @@ def reduce_neg_y_faster(self, even_degree_only=False): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-3*x+1) + sage: C = HyperellipticCurve(x^5 - 3*x + 1) sage: x,y = C.monsky_washnitzer_gens() sage: (y^-1).diff().reduce_neg_y() ((y^-1)*1, 0 dx/2y) @@ -3301,7 +3314,7 @@ def reduce_pos_y_fast(self, even_degree_only=False): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^3-4*x+4) + sage: E = HyperellipticCurve(x^3 - 4*x + 4) sage: x, y = E.monsky_washnitzer_gens() sage: y.diff().reduce_pos_y_fast() (y*1, 0 dx/2y) @@ -3370,7 +3383,7 @@ def reduce(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = (y*x).diff() sage: w.reduce() @@ -3380,7 +3393,8 @@ def reduce(self): sage: w.reduce() (1/5*y*1, 4/5*1 dx/2y) - sage: w = sum(QQ.random_element() * x^i * y^j for i in [0..4] for j in [-3..3]) * C.invariant_differential() + sage: w = sum(QQ.random_element() * x^i * y^j + ....: for i in [0..4] for j in [-3..3]) * C.invariant_differential() sage: f, a = w.reduce() sage: f.diff() + a - w 0 dx/2y @@ -3409,7 +3423,7 @@ def reduce_fast(self, even_degree_only=False): EXAMPLES:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^3-4*x+4) + sage: E = HyperellipticCurve(x^3 - 4*x + 4) sage: x, y = E.monsky_washnitzer_gens() sage: x.diff().reduce_fast() (x, (0, 0)) @@ -3447,7 +3461,7 @@ def coeffs(self, R=None): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: x,y = C.monsky_washnitzer_gens() sage: w = C.invariant_differential() sage: w.coeffs() @@ -3506,11 +3520,11 @@ def __init__(self, base_ring): TESTS:: sage: R. = QQ['x'] - sage: E = HyperellipticCurve(x^5-3*x+1) + sage: E = HyperellipticCurve(x^5 - 3*x + 1) sage: from sage.schemes.hyperelliptic_curves.monsky_washnitzer import SpecialHyperellipticQuotientRing, MonskyWashnitzerDifferentialRing sage: S = SpecialHyperellipticQuotientRing(E) sage: DR = MonskyWashnitzerDifferentialRing(S) - sage: TestSuite(DR).run() + sage: TestSuite(DR).run() # needs sage.rings.real_interval_field Check that caching works:: @@ -3526,7 +3540,7 @@ def invariant_differential(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.invariant_differential() 1 dx/2y @@ -3548,12 +3562,14 @@ def base_extend(self, R): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.base_ring() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 4*x + 4) over Rational Field - sage: MW.base_extend(Qp(5,5)).base_ring() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = (1 + O(5^5))*x^5 + (1 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5))*x + 4 + O(5^5)) + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 4*x + 4) + over Rational Field + sage: MW.base_extend(Qp(5,5)).base_ring() # needs sage.rings.padics + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = (1 + O(5^5))*x^5 + + (1 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5))*x + 4 + O(5^5)) over 5-adic Field with capped relative precision 5 """ return MonskyWashnitzerDifferentialRing(self.base_ring().base_extend(R)) @@ -3574,12 +3590,14 @@ def change_ring(self, R): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.base_ring() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 4*x + 4) over Rational Field - sage: MW.change_ring(Qp(5,5)).base_ring() - SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = (1 + O(5^5))*x^5 + (1 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5))*x + 4 + O(5^5)) + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = x^5 - 4*x + 4) + over Rational Field + sage: MW.change_ring(Qp(5,5)).base_ring() # needs sage.rings.padics + SpecialHyperellipticQuotientRing K[x,y,y^-1] / (y^2 = (1 + O(5^5))*x^5 + + (1 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5))*x + 4 + O(5^5)) over 5-adic Field with capped relative precision 5 """ return MonskyWashnitzerDifferentialRing(self.base_ring().change_ring(R)) @@ -3592,7 +3610,7 @@ def degree(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.Q() x^5 - 4*x + 4 @@ -3607,8 +3625,9 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.rings.padics sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: K = Qp(7,5) sage: CK = C.change_ring(K) sage: MW = CK.invariant_differential().parent() @@ -3625,7 +3644,7 @@ def Q(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.Q() x^5 - 4*x + 4 @@ -3641,7 +3660,7 @@ def x_to_p(self, p): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.x_to_p(3) x^3 @@ -3661,11 +3680,11 @@ def frob_Q(self, p): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.frob_Q(3) -(60-48*y^2+12*y^4-y^6)*1 + (192-96*y^2+12*y^4)*x - (192-48*y^2)*x^2 + 60*x^3 - sage: MW.Q()(MW.x_to_p(3)) + sage: MW.Q()(MW.x_to_p(3)) # needs sage.rings.real_interval_field -(60-48*y^2+12*y^4-y^6)*1 + (192-96*y^2+12*y^4)*x - (192-48*y^2)*x^2 + 60*x^3 sage: MW.frob_Q(11) is MW.frob_Q(11) True @@ -3696,11 +3715,11 @@ def frob_invariant_differential(self, prec, p): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: prec = 2 sage: p = 7 sage: MW = C.invariant_differential().parent() - sage: MW.frob_invariant_differential(prec,p) + sage: MW.frob_invariant_differential(prec, p) ((67894400*y^-20-81198880*y^-18+40140800*y^-16-10035200*y^-14+1254400*y^-12-62720*y^-10)*1 - (119503944*y^-20-116064242*y^-18+43753472*y^-16-7426048*y^-14+514304*y^-12-12544*y^-10+1568*y^-8-70*y^-6-7*y^-4)*x + (78905288*y^-20-61014016*y^-18+16859136*y^-16-2207744*y^-14+250880*y^-12-37632*y^-10+3136*y^-8-70*y^-6)*x^2 @@ -3766,11 +3785,11 @@ def frob_basis_elements(self, prec, p): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: prec = 1 sage: p = 5 sage: MW = C.invariant_differential().parent() - sage: MW.frob_basis_elements(prec,p) + sage: MW.frob_basis_elements(prec, p) [((92000*y^-14-74200*y^-12+32000*y^-10-8000*y^-8+1000*y^-6-50*y^-4)*1 - (194400*y^-14-153600*y^-12+57600*y^-10-9600*y^-8+600*y^-6)*x + (204800*y^-14-153600*y^-12+38400*y^-10-3200*y^-8)*x^2 @@ -3808,7 +3827,7 @@ def helper_matrix(self): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW.helper_matrix() [ 256/2101 320/2101 400/2101 500/2101 625/2101] @@ -3850,7 +3869,7 @@ def _element_constructor_(self, val=0, offset=0): EXAMPLES:: sage: R. = QQ['x'] - sage: C = HyperellipticCurve(x^5-4*x+4) + sage: C = HyperellipticCurve(x^5 - 4*x + 4) sage: MW = C.invariant_differential().parent() sage: MW(3) 3*1 dx/2y diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py index 9794790e1ae..97bd54408ac 100644 --- a/src/sage/schemes/plane_conics/con_field.py +++ b/src/sage/schemes/plane_conics/con_field.py @@ -103,7 +103,7 @@ def base_extend(self, S): sage: c = Conic([1, 1, 1]); c Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 - sage: c.has_rational_point() + sage: c.has_rational_point() # needs sage.libs.pari False sage: d = c.base_extend(QuadraticField(-1, 'i')); d # needs sage.rings.number_field Projective Conic Curve over Number Field in i @@ -142,7 +142,9 @@ def cache_point(self, p): (15/8 : 17/8 : 1) sage: c.rational_point() (15/8 : 17/8 : 1) - sage: c.cache_point(c.rational_point(read_cache = False)) + + sage: # needs sage.libs.pari + sage: c.cache_point(c.rational_point(read_cache=False)) sage: c.rational_point() (-1 : 1 : 0) """ @@ -270,10 +272,11 @@ def diagonal_matrix(self): :: - sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) # needs sage.rings.finite_rings - sage: c.is_smooth() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) + sage: c.is_smooth() True - sage: c.diagonal_matrix() # needs sage.rings.finite_rings + sage: c.diagonal_matrix() Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -385,17 +388,16 @@ def gens(self): sage: P. = QQ[] sage: c = Conic(x^2 + y^2 + z^2) - sage: c.gens() + sage: c.gens() # needs sage.libs.singular (xbar, ybar, zbar) - sage: c.defining_polynomial()(c.gens()) + sage: c.defining_polynomial()(c.gens()) # needs sage.libs.singular 0 The function ``gens()`` is required for the following construction: :: - sage: C. = Conic(GF(3), [1, 1, 1]) - sage: C + sage: C. = Conic(GF(3), [1, 1, 1]); C # needs sage.libs.singular Projective Conic Curve over Finite Field of size 3 defined by a^2 + b^2 + c^2 @@ -439,8 +441,8 @@ def has_rational_point(self, point=False, Conics over polynomial rings can be solved internally:: sage: R. = QQ[] - sage: C = Conic([-2,t^2+1,t^2-1]) - sage: C.has_rational_point() + sage: C = Conic([-2, t^2 + 1, t^2 - 1]) + sage: C.has_rational_point() # needs sage.libs.pari True And they can also be solved with Magma:: @@ -450,7 +452,7 @@ def has_rational_point(self, point=False, sage: C.has_rational_point(algorithm='magma', point=True) # optional - magma (True, (-t : 1 : 1)) - sage: D = Conic([t,1,t^2]) + sage: D = Conic([t, 1, t^2]) sage: D.has_rational_point(algorithm='magma') # optional - magma False @@ -603,10 +605,10 @@ def has_singular_point(self, point=False): (True, (a + 1 : 0 : 1)) sage: P. = GF(2)[] - sage: C = Conic(P, [t,t,1]); C # needs sage.libs.ntl + sage: C = Conic(P, [t,t,1]); C Projective Conic Curve over Fraction Field of Univariate Polynomial Ring - in t over Finite Field of size 2 (using GF2X) defined by t*x^2 + t*y^2 + z^2 - sage: C.has_singular_point(point=False) # needs sage.libs.ntl + in t over Finite Field of size 2... defined by t*x^2 + t*y^2 + z^2 + sage: C.has_singular_point(point=False) Traceback (most recent call last): ... NotImplementedError: Sorry, find singular point on conics not implemented @@ -656,7 +658,7 @@ def hom(self, x, Y=None): From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) - sage: h([-1, 1, 0]) + sage: h([-1, 1, 0]) # needs sage.libs.singular (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) @@ -667,7 +669,7 @@ def hom(self, x, Y=None): To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) - ``ValueError`` is raised if the wrong codomain ``Y`` is specified: + :class:`ValueError` is raised if the wrong codomain ``Y`` is specified: :: @@ -853,6 +855,7 @@ def parametrization(self, point=None, morphism=True): An example over a finite field :: + sage: # needs sage.libs.pari sage: c = Conic(GF(2), [1,1,1,1,1,0]) sage: f, g = c.parametrization(); f, g (Scheme morphism: @@ -870,7 +873,7 @@ def parametrization(self, point=None, morphism=True): Verfication of the example :: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.pari sage: h = g*f; h Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 2 @@ -892,7 +895,7 @@ def parametrization(self, point=None, morphism=True): The morphisms are mathematically defined in all points, but don't work completely in SageMath (see :trac:`31892`) :: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.pari sage: f, g = c.parametrization([0,0,1]) sage: g([0,1,1]) (1 : 0) @@ -905,6 +908,7 @@ def parametrization(self, point=None, morphism=True): An example with ``morphism = False`` :: + sage: # needs sage.libs.pari sage: R. = QQ[] sage: C = Curve(7*x^2 + 2*y*z + z^2) sage: (p, i) = C.parametrization(morphism=False); (p, i) @@ -914,8 +918,9 @@ def parametrization(self, point=None, morphism=True): sage: i[0](p) / i[1](p) x/y - A ``ValueError`` is raised if ``self`` has no rational point :: + A :class:`ValueError` is raised if ``self`` has no rational point :: + sage: # needs sage.libs.pari sage: C = Conic(x^2 + y^2 + 7*z^2) sage: C.parametrization() Traceback (most recent call last): @@ -923,8 +928,9 @@ def parametrization(self, point=None, morphism=True): ValueError: Conic Projective Conic Curve over Rational Field defined by x^2 + y^2 + 7*z^2 has no rational points over Rational Field! - A ``ValueError`` is raised if ``self`` is not smooth :: + A :class:`ValueError` is raised if ``self`` is not smooth :: + sage: # needs sage.libs.pari sage: C = Conic(x^2 + y^2) sage: C.parametrization() Traceback (most recent call last): @@ -983,7 +989,7 @@ def point(self, v, check=True): sage: c.rational_point() (15/8 : 17/8 : 1) sage: d = Conic([1, -1, 1]) - sage: d.rational_point() + sage: d.rational_point() # needs sage.libs.pari (-1 : 1 : 0) """ if is_Vector(v): @@ -1009,19 +1015,18 @@ def random_rational_point(self, *args1, **args2): are passed to ``random_element``. If the base field is a finite field, then the - output is uniformly distributed over the points of self. + output is uniformly distributed over the points of ``self``. EXAMPLES:: + sage: # needs sage.libs.pari sage: c = Conic(GF(2), [1,1,1,1,1,0]) sage: [c.random_rational_point() for i in range(10)] # random [(1 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 1 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1)] - sage: d = Conic(QQ, [1, 1, -1]) sage: d.random_rational_point(den_bound=1, num_bound=5) # random (-24/25 : 7/25 : 1) - sage: Conic(QQ, [1, 1, 1]).random_rational_point() Traceback (most recent call last): ... @@ -1055,10 +1060,11 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over `\QQ` :: sage: R. = QQ[] + + sage: # needs sage.libs.pari sage: C = Conic(7*x^2 + 2*y*z + z^2) sage: C.rational_point() (0 : 1 : 0) - sage: C = Conic(x^2 + 2*y^2 + z^2) sage: C.rational_point() Traceback (most recent call last): @@ -1090,7 +1096,7 @@ def rational_point(self, algorithm='default', read_cache=True): sage: D.rational_point(algorithm='rnfisnorm') # output is random # needs sage.rings.number_field (-3 : 4*i : 1) - sage: # needs sage.rings.number_field + sage: # needs sage.libs.pari sage.rings.number_field sage: L. = QuadraticField(2) sage: Conic(QQ, [1, 1, -3]).has_rational_point() False @@ -1117,7 +1123,7 @@ def rational_point(self, algorithm='default', read_cache=True): ....: read_cache=False) (-s : 1 : 1) - sage: # needs sage.rings.number_field + sage: # needs sage.libs.pari sage.rings.number_field sage: F = Conic([L.gen(), 30, -20]) sage: q = F.rational_point(algorithm='magma') # optional - magma sage: q # random # optional - magma @@ -1132,7 +1138,7 @@ def rational_point(self, algorithm='default', read_cache=True): sage: G = Conic([L.gen(), 30, -21]) sage: G.has_rational_point(algorithm='magma') # optional - magma False - sage: G.has_rational_point(read_cache=False) + sage: G.has_rational_point(read_cache=False) # needs sage.libs.pari False sage: G.has_rational_point(algorithm='local', ....: read_cache=False) @@ -1286,8 +1292,7 @@ def variable_names(self): :: - sage: C. = Conic(QQ, [1, 1, 1]) - sage: C + sage: C. = Conic(QQ, [1, 1, 1]); C # needs sage.libs.singular Projective Conic Curve over Rational Field defined by p^2 + q^2 + r^2 """ diff --git a/src/sage/schemes/plane_conics/con_rational_field.py b/src/sage/schemes/plane_conics/con_rational_field.py index 46de65132b5..6ecfb988562 100644 --- a/src/sage/schemes/plane_conics/con_rational_field.py +++ b/src/sage/schemes/plane_conics/con_rational_field.py @@ -115,6 +115,7 @@ def has_rational_point(self, point=False, obstruction=False, EXAMPLES:: + sage: # needs sage.libs.pari sage: C = Conic(QQ, [1, 2, -3]) sage: C.has_rational_point(point=True) (True, (1 : 1 : 1)) @@ -131,7 +132,7 @@ def has_rational_point(self, point=False, obstruction=False, ``algorithm = 'rnfisnorm'`` :: sage: C = Conic(QQ, [1, 113922743, -310146482690273725409]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.pari (True, (-76842858034579/5424 : -5316144401/5424 : 1)) sage: C.has_rational_point(algorithm='local', read_cache=False) True @@ -144,10 +145,11 @@ def has_rational_point(self, point=False, obstruction=False, Create a bunch of conics over `\QQ`, check if ``has_rational_point`` runs without errors and returns consistent answers for all algorithms. Check if all points returned are valid. :: + sage: # needs sage.libs.pari sage: l = Sequence(cartesian_product_iterator([[-1, 0, 1] for i in range(6)])) sage: c = [Conic(QQ, a) for a in l if a != [0,0,0] and a != (0,0,0,0,0,0)] sage: d = [] - sage: d = [[C] + [C.has_rational_point(algorithm=algorithm, read_cache=False, # long time: 7 seconds + sage: d = [[C] + [C.has_rational_point(algorithm=algorithm, read_cache=False, # long time (7 s) ....: obstruction=(algorithm != 'rnfisnorm'), ....: point=(algorithm != 'local')) ....: for algorithm in ['local', 'qfsolve', 'rnfisnorm']] @@ -214,6 +216,7 @@ def is_locally_solvable(self, p) -> bool: EXAMPLES:: + sage: # needs sage.libs.pari sage: C = Conic(QQ, [1,2,3]) sage: C.is_locally_solvable(-1) False @@ -272,6 +275,7 @@ def local_obstructions(self, finite=True, infinite=True, read_cache=True): EXAMPLES:: + sage: # needs sage.libs.pari sage: Conic(QQ, [1, 1, 1]).local_obstructions() [2, -1] sage: Conic(QQ, [1, 2, -3]).local_obstructions() @@ -330,6 +334,7 @@ def parametrization(self, point=None, morphism=True): EXAMPLES:: + sage: # needs sage.libs.pari sage: c = Conic([1,1,-1]) sage: c.parametrization() (Scheme morphism: @@ -345,6 +350,7 @@ def parametrization(self, point=None, morphism=True): An example with ``morphism = False`` :: + sage: # needs sage.libs.pari sage: R. = QQ[] sage: C = Curve(7*x^2 + 2*y*z + z^2) sage: (p, i) = C.parametrization(morphism=False); (p, i) @@ -354,8 +360,9 @@ def parametrization(self, point=None, morphism=True): sage: i[0](p) / i[1](p) x/y - A ``ValueError`` is raised if ``self`` has no rational point :: + A :class:`ValueError` is raised if ``self`` has no rational point :: + sage: # needs sage.libs.pari sage: C = Conic(x^2 + 2*y^2 + z^2) sage: C.parametrization() Traceback (most recent call last): @@ -363,8 +370,9 @@ def parametrization(self, point=None, morphism=True): ValueError: Conic Projective Conic Curve over Rational Field defined by x^2 + 2*y^2 + z^2 has no rational points over Rational Field! - A ``ValueError`` is raised if ``self`` is not smooth :: + A :class:`ValueError` is raised if ``self`` is not smooth :: + sage: # needs sage.libs.pari sage: C = Conic(x^2 + y^2) sage: C.parametrization() Traceback (most recent call last): diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py index 1b3f0ac412a..05d24e78a85 100644 --- a/src/sage/schemes/plane_conics/con_rational_function_field.py +++ b/src/sage/schemes/plane_conics/con_rational_function_field.py @@ -25,7 +25,7 @@ sage: K. = FractionField(QQ['t']) sage: C = Conic([1, -t, t]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (0 : 1 : 1)) """ @@ -128,37 +128,37 @@ def has_rational_point(self, point=False, algorithm='default', sage: K. = FractionField(PolynomialRing(QQ, 't')) sage: C = Conic(K, [t^2 - 2, 2*t^3, -2*t^3 - 13*t^2 - 2*t + 18]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (-3 : (t + 1)/t : 1)) sage: R. = FiniteField(23)[] sage: C = Conic([2, t^2 + 1, t^2 + 5]) - sage: C.has_rational_point() + sage: C.has_rational_point() # needs sage.libs.singular True - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (5*t : 8 : 1)) sage: # needs sage.rings.number_field sage: F. = QuadraticField(-1) sage: R. = F[] sage: C = Conic([1, i*t, -t^2 + 4]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (-t - 2*i : -2*i : 1)) It works on non-diagonal conics as well:: sage: K. = QQ[] sage: C = Conic([4, -4, 8, 1, -4, t + 4]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (1/2 : 1 : 0)) If no point exists output still depends on the argument ``point``:: sage: K. = QQ[] sage: C = Conic(K, [t^2, (t-1), -2*(t-1)]) - sage: C.has_rational_point() + sage: C.has_rational_point() # needs sage.libs.singular False - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (False, None) Due to limitations in Sage of algorithms we depend on, it is not @@ -171,7 +171,7 @@ def has_rational_point(self, point=False, algorithm='default', sage: b = 2*t2^2 + 2*t1*t2 - t1^2 sage: c = -3*t2^4 - 4*t1*t2^3 + 8*t1^2*t2^2 + 16*t1^3 - t2 - 48*t1^4 sage: C = Conic([a,b,c]) - sage: C.has_rational_point() + sage: C.has_rational_point() # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError: is_square() not implemented for elements of @@ -204,7 +204,7 @@ def has_rational_point(self, point=False, algorithm='default', sage: K. = PolynomialRing(GF(7)) sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2, ....: 5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5]) - sage: C.has_rational_point() + sage: C.has_rational_point() # needs sage.libs.singular Traceback (most recent call last): ... TypeError: self (=Scheme morphism: @@ -237,7 +237,7 @@ def has_rational_point(self, point=False, algorithm='default', sage: b = (1/2*t^2 + 1/3)/(-73*t^2 - 2*t + 11/4) sage: c = (6934/3*t^6 + 8798/3*t^5 - 947/18*t^4 + 3949/9*t^3 + 20983/18*t^2 + 28/3*t - 131/3)/(-2701/3*t^4 - 293/3*t^3 + 301/6*t^2 + 13/4*t - 11/16) sage: C = Conic([a,b,c]) - sage: C.has_rational_point(point=True) + sage: C.has_rational_point(point=True) # needs sage.libs.singular (True, (4*t + 4 : 2*t + 2 : 1)) A long time test:: @@ -247,7 +247,7 @@ def has_rational_point(self, point=False, algorithm='default', sage: b = (-3*t^3 + 8*t + 1/2)/(-1/3*t^3 + 3/2*t^2 + 1/12*t + 1/2) sage: c = (1232009/225*t^25 - 1015925057/8100*t^24 + 1035477411553/1458000*t^23 + 7901338091/30375*t^22 - 1421379260447/729000*t^21 + 266121260843/972000*t^20 + 80808723191/486000*t^19 - 516656082523/972000*t^18 + 21521589529/40500*t^17 + 4654758997/21600*t^16 - 20064038625227/9720000*t^15 - 173054270347/324000*t^14 + 536200870559/540000*t^13 - 12710739349/50625*t^12 - 197968226971/135000*t^11 - 134122025657/810000*t^10 + 22685316301/120000*t^9 - 2230847689/21600*t^8 - 70624099679/270000*t^7 - 4298763061/270000*t^6 - 41239/216000*t^5 - 13523/36000*t^4 + 493/36000*t^3 + 83/2400*t^2 + 1/300*t + 1/200)/(-27378/125*t^17 + 504387/500*t^16 - 97911/2000*t^15 + 1023531/4000*t^14 + 1874841/8000*t^13 + 865381/12000*t^12 + 15287/375*t^11 + 6039821/6000*t^10 + 599437/1500*t^9 + 18659/250*t^8 + 1218059/6000*t^7 + 2025127/3000*t^6 + 1222759/6000*t^5 + 38573/200*t^4 + 8323/125*t^3 + 15453/125*t^2 + 17031/500*t + 441/10) sage: C = Conic([a,b,c]) - sage: C.has_rational_point(point = True) # long time (4 seconds) + sage: C.has_rational_point(point=True) # long time (4 seconds) # needs sage.libs.singular (True, ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1)) """ @@ -475,7 +475,7 @@ def find_point(self, supports, roots, case, solution=0): sage: K. = FractionField(QQ['t']) sage: C = Conic(K, [t^2 - 2, 2*t^3, -2*t^3 - 13*t^2 - 2*t + 18]) - sage: C.has_rational_point(point=True) # indirect test + sage: C.has_rational_point(point=True) # indirect test # needs sage.libs.singular (True, (-3 : (t + 1)/t : 1)) Different solubility certificates give different points:: diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index d51d5d369bf..b9430804695 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -339,7 +339,7 @@ def dehomogenize(self, L): :: - sage: # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr sage.symbolic sage: PP. = ProductProjectiveSpaces([1, 2], CC) sage: X = PP.subscheme([a^2 + b^2]) sage: P = X([2, 2*i, -3, 6*i, 3 - 6*i]) diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 4396f4c7765..b3fd2aae646 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2310,7 +2310,7 @@ def __call__(self, x): TESTS:: - sage: # needs sage.schemes + sage: # needs sage.libs.pari sage.schemes sage: R. = QQ[] sage: C = Curve(7*x^2 + 2*y*z + z^2) sage: f, g = C.parametrization() @@ -2340,10 +2340,11 @@ def __eq__(self, other): """ EXAMPLES:: + sage: # needs sage.libs.pari sage.schemes sage: R. = QQ[] - sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic # needs sage.schemes - sage: f, g = C.parametrization() # needs sage.schemes - sage: f*g == C.identity_morphism() # needs sage.schemes + sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic + sage: f, g = C.parametrization() + sage: f*g == C.identity_morphism() True sage: # needs sage.schemes diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py index ecb34f8230a..79377dfcada 100644 --- a/src/sage/schemes/projective/projective_space.py +++ b/src/sage/schemes/projective/projective_space.py @@ -2247,7 +2247,7 @@ def line_through(self, p, q): sage: P3. = ProjectiveSpace(3, QQ) sage: p1 = P3(1, 2, 3, 4) sage: p2 = P3(4, 3, 2, 1) - sage: P3.line_through(p1, p2) # needs sage.schemes + sage: P3.line_through(p1, p2) # needs sage.libs.singular sage.schemes Projective Curve over Rational Field defined by -5/4*x0 + 5/2*x1 - 5/4*x2, -5/2*x0 + 15/4*x1 - 5/4*x3, -5/4*x0 + 15/4*x2 - 5/2*x3, -5/4*x1 + 5/2*x2 - 5/4*x3 diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 9a465b36ea4..b571d25e932 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -548,7 +548,7 @@ def nth_iterate(self, f, n): sage: P. = ProjectiveSpace(QQ, 3) sage: f = DynamicalSystem_projective([y^2, z^2, x^2, w^2]) # needs sage.schemes - sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) # needs sage.schemes + sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) # needs sage.libs.singular sage.schemes Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: y - z, @@ -559,7 +559,7 @@ def nth_iterate(self, f, n): sage: PS. = ProjectiveSpace(ZZ, 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.nth_iterate(f, -2) # needs sage.schemes + sage: X.nth_iterate(f, -2) # needs sage.libs.singular sage.schemes Traceback (most recent call last): ... TypeError: must be a forward orbit From d962ea518d4f60f7e38f716defcaa907172cb5bb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 5 Sep 2023 17:06:17 -0700 Subject: [PATCH 072/494] src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx: Docstring cosmetics, add # needs --- .../schemes/hyperelliptic_curves/hypellfrob.pyx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx b/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx index 50730d1081f..b4144780c1d 100644 --- a/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx +++ b/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx @@ -6,6 +6,7 @@ # distutils: extra_compile_args = NTL_CFLAGS # distutils: library_dirs = NTL_LIBDIR # distutils: extra_link_args = NTL_LIBEXTRA +# sage.doctest: needs sage.libs.ntl sage.modules sage.rings.padics r""" Frobenius on Monsky-Washnitzer cohomology of a hyperelliptic curve over a @@ -75,8 +76,8 @@ def interval_products(M0, M1, target): INPUT: - - M0, M1 -- matrices over `\ZZ/N\ZZ`, so that `M = M0 + M1*x` - - target -- a list of integers + - ``M0``, ``M1`` -- matrices over `\ZZ/N\ZZ`, so that `M = M0 + M1*x` + - ``target`` -- a list of integers ALGORITHM: @@ -173,10 +174,10 @@ def hypellfrob(p, N, Q): INPUT: - - p -- a prime - - Q -- a monic polynomial in `\ZZ[x]` of odd degree. - Must have no multiple roots mod p. - - N -- precision parameter; the output matrix will be correct modulo `p^N`. + - ``p`` -- a prime + - ``Q`` -- a monic polynomial in `\ZZ[x]` of odd degree. + Must have no multiple roots mod `p`. + - ``N`` -- precision parameter; the output matrix will be correct modulo `p^N`. PRECONDITIONS: From 420ca2b3b48ff4adf14afc5c77d1733ae173fe0e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:55:40 -0700 Subject: [PATCH 073/494] sage.schemes.projective: Add # needs --- .../schemes/projective/projective_morphism.py | 3 ++- .../schemes/projective/projective_subscheme.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index b3fd2aae646..bd110b059ed 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2340,8 +2340,9 @@ def __eq__(self, other): """ EXAMPLES:: - sage: # needs sage.libs.pari sage.schemes sage: R. = QQ[] + + sage: # needs sage.libs.pari sage.schemes sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic sage: f, g = C.parametrization() sage: f*g == C.identity_morphism() diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index b571d25e932..6370bef6ad2 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -469,10 +469,11 @@ def orbit(self, f, N): EXAMPLES:: + sage: # needs sage.libs.singular sage.schemes sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, # needs sage.schemes + sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, ....: (x-2*w)^2, x^2]) - sage: f.orbit(P.subscheme([x]), 5) # needs sage.schemes + sage: f.orbit(P.subscheme([x]), 5) [Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x, Closed subscheme of Projective Space of dimension 3 over Rational Field @@ -1039,9 +1040,10 @@ def degree(self): sage: X.degree() # needs sage.libs.singular 3 + sage: # needs sage.libs.singular sage.schemes sage: P. = ProjectiveSpace(QQ, 4) - sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) # needs sage.schemes - sage: C.degree() # needs sage.libs.singular sage.schemes + sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) + sage: C.degree() 63 """ P = self.defining_ideal().hilbert_polynomial() @@ -1157,10 +1159,11 @@ def multiplicity(self, P): :: + sage: # needs sage.libs.singular sage.schemes sage: P. = ProjectiveSpace(GF(29), 3) - sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) # needs sage.schemes + sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) sage: Q = P([3,0,0,1]) - sage: C.multiplicity(Q) # needs sage.libs.singular sage.schemes + sage: C.multiplicity(Q) 8 """ if self.base_ring() not in Fields(): From 1391f9163fdd5181932be200c5b3add0e1da5f63 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 14 May 2023 10:51:37 -0700 Subject: [PATCH 074/494] sage.dynamics: Doctest cosmetics --- .../arithmetic_dynamics/berkovich_ds.py | 90 +++++----- .../endPN_automorphism_group.py | 96 +++++------ .../endPN_minimal_model.py | 35 ++-- .../arithmetic_dynamics/generic_ds.py | 80 ++++----- .../product_projective_ds.py | 33 ++-- .../arithmetic_dynamics/projective_ds.py | 8 +- .../dynamics/arithmetic_dynamics/wehlerK3.py | 162 ++++++++++-------- 7 files changed, 263 insertions(+), 241 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index de956719603..19bc1fbc5e6 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -71,15 +71,18 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) sage: DynamicalSystem_Berkovich(f) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x : y) to - ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2 : (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) + ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2 + : (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) Or directly from polynomials:: sage: P. = ProjectiveSpace(Qp(3),1) sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2]) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) @@ -87,7 +90,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet sage: R. = Qp(3)[] sage: DynamicalSystem_Berkovich([x^2, y^2]) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) @@ -358,9 +362,9 @@ def as_scheme_dynamical_system(self): sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y]) sage: f.as_scheme_dynamical_system() - Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20 - Defn: Defined on coordinates by sending (x : y) to - (x^2 + y^2 : x*y) + Dynamical System of Projective Space of dimension 1 over + 3-adic Field with capped relative precision 20 + Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : x*y) """ return self._system @@ -399,7 +403,7 @@ def defining_polynomials(self): sage: g = DynamicalSystem_Berkovich(f) sage: g.defining_polynomials() ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2, - (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) + (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) """ return self._system._polys @@ -488,18 +492,16 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich): sage: H = End(P1) sage: DynamicalSystem_Berkovich(H([y, x])) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 - induced by the map - Defn: Defined on coordinates by sending (x : y) to - (y : x) + induced by the map + Defn: Defined on coordinates by sending (x : y) to (y : x) Or from polynomials:: sage: P. = ProjectiveSpace(Qp(3), 1) sage: DynamicalSystem_Berkovich([x^2+y^2, y^2]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 - induced by the map - Defn: Defined on coordinates by sending (x : y) to - (x^2 + y^2 : y^2) + induced by the map + Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) """ @staticmethod def __classcall_private__(cls, dynamical_system, domain=None): @@ -512,9 +514,8 @@ def __classcall_private__(cls, dynamical_system, domain=None): sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_projective sage: DynamicalSystem_Berkovich_projective([y, x]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 - induced by the map - Defn: Defined on coordinates by sending (x : y) to - (y : x) + induced by the map + Defn: Defined on coordinates by sending (x : y) to (y : x) """ if not isinstance(dynamical_system, DynamicalSystem): if not isinstance(dynamical_system, DynamicalSystem_projective): @@ -549,7 +550,8 @@ def __init__(self, dynamical_system, domain=None): sage: P. = ProjectiveSpace(Qp(3), 1) sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y]) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 + x*y + (2 + O(3^20))*y^2 : (2 + O(3^20))*x*y) """ @@ -570,9 +572,9 @@ def scale_by(self, t): sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_Berkovich([x^2, y^2]) sage: f.scale_by(x); f - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x : y) to - (x^3 : x*y^2) + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map + Defn: Defined on coordinates by sending (x : y) to (x^3 : x*y^2) :: @@ -601,9 +603,9 @@ def normalize_coordinates(self): sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2]) sage: f.normalize_coordinates(); f - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) Normalize_coordinates may sometimes fail over p-adic fields:: @@ -621,9 +623,9 @@ def normalize_coordinates(self): sage: B = Berkovich_Cp_Projective(P, 3) sage: g = DynamicalSystem_Berkovich([2*x^2, x*y], B) sage: g.normalize_coordinates(); g - Dynamical system of Projective Berkovich line over Cp(3), with base Rational Field induced by the map - Defn: Defined on coordinates by sending (x : y) to - (2*x : y) + Dynamical system of Projective Berkovich line over Cp(3), with base Rational Field + induced by the map + Defn: Defined on coordinates by sending (x : y) to (2*x : y) """ self._system.normalize_coordinates() @@ -655,7 +657,8 @@ def conjugate(self, M, adjugate=False, new_ideal=None): sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) sage: g = DynamicalSystem_Berkovich(f) sage: g.conjugate(Matrix([[1, 1], [0, 1]])) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 + (2 + O(3^20))*x*y : (2 + O(3^20))*y^2) @@ -748,7 +751,8 @@ def dehomogenize(self, n): sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) sage: g = DynamicalSystem_Berkovich(f) sage: g.dehomogenize(1) - Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map + Dynamical system of Affine Berkovich line over Cp(3) of precision 20 + induced by the map Defn: Defined on coordinates by sending (x) to ((x^2 + 1 + O(3^20))/(x + 1 + O(3^20))) """ @@ -766,8 +770,8 @@ def __call__(self, x, type_3_pole_check=True): - ``x`` -- a point of projective Berkovich space over ``Cp``. - - type_3_pole_check -- (default ``True``) A bool. WARNING: - changing the value of type_3_pole_check can lead to mathematically + - ``type_3_pole_check`` -- (default ``True``) A bool. WARNING: + changing the value of ``type_3_pole_check`` can lead to mathematically incorrect answers. Only set to ``False`` if there are NO poles of the dynamical system in the disk corresponding to the type III point ``x``. See Examples. @@ -969,8 +973,7 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich): sage: f = DynamicalSystem_affine([(x^2 + 1)/x]) sage: DynamicalSystem_Berkovich(f) Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x) to - ((x^2 + 1 + O(5^20))/x) + Defn: Defined on coordinates by sending (x) to ((x^2 + 1 + O(5^20))/x) Dynamical system can be created from a morphism:: @@ -978,8 +981,7 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich): sage: phi = H([x + 3]) sage: DynamicalSystem_Berkovich(phi) Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x) to - (x + 3 + O(5^20)) + Defn: Defined on coordinates by sending (x) to (x + 3 + O(5^20)) """ @staticmethod def __classcall_private__(cls, dynamical_system, domain=None): @@ -991,9 +993,9 @@ def __classcall_private__(cls, dynamical_system, domain=None): sage: A. = AffineSpace(Qp(3), 1) sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2)) - Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical system of Affine Berkovich line over Cp(3) of precision 20 + induced by the map + Defn: Defined on coordinates by sending (x) to (x^2) """ if not isinstance(dynamical_system, DynamicalSystem): if not isinstance(dynamical_system, DynamicalSystem_affine): @@ -1025,9 +1027,9 @@ def __init__(self, dynamical_system, domain): sage: A. = AffineSpace(Qp(3), 1) sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3)) - Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x) to - (x^3) + Dynamical system of Affine Berkovich line over Cp(3) of precision 20 + induced by the map + Defn: Defined on coordinates by sending (x) to (x^3) """ DynamicalSystem_Berkovich.__init__(self, dynamical_system, domain) @@ -1052,9 +1054,9 @@ def homogenize(self, n): sage: f = DynamicalSystem_affine(1/x) sage: f = DynamicalSystem_Berkovich(f) sage: f.homogenize(1) - Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map - Defn: Defined on coordinates by sending (x0 : x1) to - (x1 : x0) + Dynamical system of Projective Berkovich line over Cp(3) of precision 20 + induced by the map + Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0) """ new_system = self._system.homogenize(n) ideal = self.domain().ideal() diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py index e8e5ddba1c4..32ccb2a9a7b 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py @@ -43,24 +43,23 @@ def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False): r""" - - This function will compute the automorphism group for ``rational_function`` via the method of fixed points + Compute the automorphism group for ``rational_function`` via the method of fixed points ALGORITHM: - See Algorithm 3 in Faber-Manes-Viray [FMV]_. + See Algorithm 3 in Faber-Manes-Viray [FMV]_. INPUT: - - ``rational_function`` - Rational Function defined over `\ZZ` or `\QQ` + - ``rational_function`` -- Rational Function defined over `\ZZ` or `\QQ` - - ``return_functions`` - Boolean Value, True will return elements in the automorphism group - as linear fractional transformations. False will return elements as `PGL2` matrices + - ``return_functions`` -- Boolean value; ``True`` will return elements in the automorphism group + as linear fractional transformations. ``False`` will return elements as `PGL_2` matrices - - ``iso_type`` - Boolean - True will cause the classification of the finite automorphism + - ``iso_type`` -- Boolean; ``True`` will cause the classification of the finite automorphism group to also be returned - OUTPUT: a list of automorphisms that make up the Automorphism Group + OUTPUT: a list of automorphisms that make up the automorphism group of ``rational_function`` EXAMPLES:: @@ -69,7 +68,7 @@ def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, sage: rational_function = (z^2 - 2*z - 2)/(-2*z^2 - 2*z + 1) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints sage: automorphism_group_QQ_fixedpoints(rational_function, True) - [z, 1/z, -z - 1, -z/(z + 1), (-z - 1)/z, -1/(z + 1)] + [z, 1/z, -z - 1, -z/(z + 1), (-z - 1)/z, -1/(z + 1)] :: @@ -77,18 +76,18 @@ def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, sage: rational_function = (z^2 + 2*z)/(-2*z - 1) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints sage: automorphism_group_QQ_fixedpoints(rational_function) - [ + [ [1 0] [-1 -1] [-2 0] [0 2] [-1 -1] [ 0 -1] [0 1], [ 0 1], [ 2 2], [2 0], [ 1 0], [ 1 1] - ] + ] :: sage: F. = PolynomialRing(QQ) - sage: rational_function = (z^2 - 4*z -3)/(-3*z^2 - 2*z + 2) + sage: rational_function = (z^2 - 4*z - 3)/(-3*z^2 - 2*z + 2) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints sage: automorphism_group_QQ_fixedpoints(rational_function, True, True) - ([z, (-z - 1)/z, -1/(z + 1)], 'Cyclic of order 3') + ([z, (-z - 1)/z, -1/(z + 1)], 'Cyclic of order 3') """ if rational_function.parent().is_field(): @@ -304,7 +303,7 @@ def height_bound(polynomial): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: f = (z^3+2*z+6) + sage: f = z^3 + 2*z + 6 sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import height_bound sage: height_bound(f) 413526 @@ -345,7 +344,7 @@ def PGL_repn(rational_function): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: f = ((2*z-1)/(3-z)) + sage: f = (2*z-1)/(3-z) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import PGL_repn sage: PGL_repn(f) [-2 1] @@ -377,7 +376,7 @@ def PGL_order(A): EXAMPLES:: - sage: M = matrix([[0,2],[2,0]]) + sage: M = matrix([[0,2], [2,0]]) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import PGL_order sage: PGL_order(M) 2 @@ -418,7 +417,7 @@ def CRT_helper(automorphisms, moduli): EXAMPLES:: sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import CRT_helper - sage: CRT_helper([[matrix([[4,0],[0,1]]), matrix([[0,1],[1,0]])]],[5]) + sage: CRT_helper([[matrix([[4,0], [0,1]]), matrix([[0,1], [1,0]])]], [5]) ([ [4 0] [0 1] [0 1], [1 0] @@ -452,7 +451,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli): Given a list of automorphisms over various `Zmod(p^k)`, a list of the elements orders, an integer degree, and a list of the `p^k` values compute - a maximal list of automorphisms over `Zmod(M)`, such that for every `j` in `len(moduli)`, + a maximal list of automorphisms over `Zmod(M)`, such that for every `j` in ``len(moduli)``, each element reduces mod ``moduli[j]`` to one of the elements in ``automorphisms[j]`` that has order = ``degree`` @@ -462,7 +461,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli): - ``order_elts`` -- a list of lists of the orders of the elements of ``automorphisms`` - - ``degree`` - a positive integer + - ``degree`` -- a positive integer - ``moduli`` -- list of prime powers, i.e., `p^k` @@ -470,7 +469,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli): EXAMPLES:: - sage: aut = [[matrix([[1,0],[0,1]]), matrix([[0,1],[1,0]])]] + sage: aut = [[matrix([[1,0], [0,1]]), matrix([[0,1], [1,0]])]] sage: ords = [[1,2]] sage: degree = 2 sage: mods = [5] @@ -506,7 +505,7 @@ def valid_automorphisms(automorphisms_CRT, rational_function, ht_bound, M, - ``rational_function`` -- A one variable rational function - - ``ht_bound`` - a positive integer + - ``ht_bound`` -- a positive integer - ``M`` -- a positive integer, a product of prime powers @@ -519,7 +518,7 @@ def valid_automorphisms(automorphisms_CRT, rational_function, ht_bound, M, sage: R. = PolynomialRing(QQ) sage: F = z^2 sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import valid_automorphisms - sage: valid_automorphisms([matrix(GF(5),[[0,1],[1,0]])], F, 48, 5, True) + sage: valid_automorphisms([matrix(GF(5), [[0,1],[1,0]])], F, 48, 5, True) [1/z] """ z = rational_function.parent().gen(0) @@ -570,8 +569,8 @@ def remove_redundant_automorphisms(automorphisms, order_elts, moduli, integral_a EXAMPLES:: sage: auts = [[matrix([[1,0],[0,1]]), matrix([[6,0],[0,1]]), matrix([[0,1],[1,0]]), - ....: matrix([[6,1],[1,1]]), matrix([[1,1],[1,6]]), matrix([[0,6],[1,0]]), - ....: matrix([[1,6],[1,1]]), matrix([[6,6],[1,6]])]] + ....: matrix([[6,1],[1,1]]), matrix([[1,1],[1,6]]), matrix([[0,6],[1,0]]), + ....: matrix([[1,6],[1,1]]), matrix([[6,6],[1,6]])]] sage: ord_elts = [[1, 2, 2, 2, 2, 2, 4, 4]] sage: mods = [7] sage: R. = PolynomialRing(QQ) @@ -625,15 +624,15 @@ def automorphism_group_QQ_CRT(rational_function, prime_lower_bound=4, return_fun INPUT: - - ``rational_function`` - a rational function of a univariate polynomial ring over `\QQ` + - ``rational_function`` -- a rational function of a univariate polynomial ring over `\QQ` - - ``prime_lower_bound`` -- (default: 4) a positive integer - a lower bound for the primes to use for + - ``prime_lower_bound`` -- (default: 4) a positive integer; a lower bound for the primes to use for the Chinese Remainder Theorem step - - ``return_functions`` -- (default: True) boolean - True returns linear fractional transformations + - ``return_functions`` -- (default: ``True``) boolean; ``True`` returns linear fractional transformations False returns elements of `PGL(2,\QQ)` - - ``iso_type`` -- (default: False) boolean - True returns the isomorphism type of the automorphism group + - ``iso_type`` -- (default: ``False``) boolean; ``True`` returns the isomorphism type of the automorphism group OUTPUT: a complete list of automorphisms of ``rational_function`` @@ -839,11 +838,11 @@ def automorphism_group_FF(rational_function, absolute=False, iso_type=False, ret - ``rational_function`` -- a rational function defined over the fraction field of a polynomial ring in one variable with finite field coefficients - - ``absolute``-- (default: False) boolean - True returns the absolute automorphism group and a field of definition + - ``absolute``-- (default: ``False``) boolean; ``True`` returns the absolute automorphism group and a field of definition - - ``iso_type`` -- (default: False) boolean - True returns the isomorphism type of the automorphism group + - ``iso_type`` -- (default: ``False``) boolean; ``True`` returns the isomorphism type of the automorphism group - - ``return_functions`` -- (default: False) boolean, True returns linear fractional transformations + - ``return_functions`` -- (default: ``False``) boolean; ``True`` returns linear fractional transformations False returns elements of `PGL(2)` OUTPUT: a list of automorphisms of ``rational_function`` @@ -899,9 +898,9 @@ def automorphism_group_FF(rational_function, absolute=False, iso_type=False, ret def field_descent(sigma, y): r""" - Function for descending an element in a field E to a subfield F. + Function for descending an element in a field `E` to a subfield `F`. - Here F, E must be finite fields or number fields. This function determines + Here `F`, `E` must be finite fields or number fields. This function determines the unique image of subfield which is ``y`` by the embedding ``sigma`` if it exists. Otherwise returns ``None``. This functionality is necessary because Sage does not keep track of subfields. @@ -961,7 +960,7 @@ def rational_function_coefficient_descent(rational_function, sigma, poly_ring): Here `F`, `E` must be finite fields or number fields. It determines the unique rational function in fraction field of - ``poly_ring`` which is the image of ``rational_function`` by ``ssigma``, + ``poly_ring`` which is the image of ``rational_function`` by ``sigma``, if it exists, and otherwise returns ``None``. INPUT: @@ -1061,7 +1060,7 @@ def rational_function_reduce(rational_function): - ``rational_function`` -- rational function `= F/G` in univariate polynomial ring - OUTPUT: rational function -- `(F/gcd(F,G) ) / (G/gcd(F,G))` + OUTPUT: rational function -- `(F/\gcd(F,G)) / (G/\gcd(F,G))` EXAMPLES:: @@ -1157,7 +1156,7 @@ def automorphism_group_FF_alg2(rational_function): INPUT: - - ``rational_function``--a rational function defined over a finite field + - ``rational_function`` -- a rational function defined over a finite field OUTPUT: absolute automorphism group of ``rational_function`` and a ring of definition @@ -1272,9 +1271,9 @@ def order_p_automorphisms(rational_function, pre_image): INPUT: - - ``rational_function``--rational function defined over finite field `F` + - ``rational_function`` -- rational function defined over finite field `F` - - ``pre_image``--set of triples `[x, L, f]`, where `x` is an `F`-rational + - ``pre_image`` -- set of triples `[x, L, f]`, where `x` is an `F`-rational fixed point of ``rational_function``, `L` is the list of `F`-rational pre-images of `x` (excluding `x`), and `f` is the polynomial defining the full set of pre-images of `x` (again excluding `x` itself) @@ -1455,11 +1454,11 @@ def automorphisms_fixing_pair(rational_function, pair, quad): INPUT: - - ``rational_function``-- rational function defined over finite field `E` + - ``rational_function`` -- rational function defined over finite field `E` - - ``pair``-- a pair of points of `\mathbb{P}^1(E)` + - ``pair`` -- a pair of points of `\mathbb{P}^1(E)` - - ``quad``-- Boolean: an indicator if this is a quadratic pair of points + - ``quad`` -- Boolean: an indicator if this is a quadratic pair of points OUTPUT: set of automorphisms with order prime to characteristic defined over `E` that fix the pair, excluding the identity @@ -1535,14 +1534,14 @@ def automorphism_group_FF_alg3(rational_function): INPUT: - - ``rational_function``--a rational function defined over a finite field `F` + - ``rational_function`` -- a rational function defined over a finite field `F` OUTPUT: list of `F`-rational automorphisms of ``rational_function`` EXAMPLES:: sage: R. = PolynomialRing(GF(5^3,'t')) - sage: f = (3456*z^4) + sage: f = 3456*z^4 sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_FF_alg3 sage: automorphism_group_FF_alg3(f) [z, 1/z] @@ -1694,14 +1693,14 @@ def automorphism_group_FF_alg3(rational_function): def which_group(list_of_elements): r""" - Given a finite subgroup of `PGL2` determine its isomorphism class. + Given a finite subgroup of `PGL_2` determine its isomorphism class. This function makes heavy use of the classification of finite subgroups of `PGL(2,K)`. INPUT: - ``list_of_elements``-- a finite list of elements of `PGL(2,K)` - that we know a priori form a group + that we know a priori form a group OUTPUT: a string -- the isomorphism type of the group @@ -1844,9 +1843,10 @@ def conjugating_set_initializer(f, g): ``possible_targets`` tracks multiplier information:: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem([(8*x^7 - 35*x^4*y^3 - 35*x^4*z^3 - 7*x*y^6 - 140*x*y^3*z^3 \ - - 7*x*z^6), (-7*x^6*y - 35*x^3*y^4 - 140*x^3*y*z^3 + 8*y^7 - 35*y^4*z^3 \ - - 7*y*z^6), -7*x^6*z - 140*x^3*y^3*z - 35*x^3*z^4 - 7*y^6*z - 35*y^3*z^4 + 8*z^7]) + sage: f = DynamicalSystem([ + ....: 8*x^7 - 35*x^4*y^3 - 35*x^4*z^3 - 7*x*y^6 - 140*x*y^3*z^3 - 7*x*z^6, + ....: -7*x^6*y - 35*x^3*y^4 - 140*x^3*y*z^3 + 8*y^7 - 35*y^4*z^3 - 7*y*z^6, + ....: -7*x^6*z - 140*x^3*y^3*z - 35*x^3*z^4 - 7*y^6*z - 35*y^3*z^4 + 8*z^7]) sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import conjugating_set_initializer sage: source, possible_targets = conjugating_set_initializer(f, f) sage: P.is_linearly_independent(source, 3) diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py index 735e0800a6f..0a33b460a01 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py @@ -22,6 +22,9 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +from copy import copy + +from sage.arith.misc import gcd from sage.functions.hyperbolic import cosh from sage.matrix.constructor import matrix from sage.matrix.matrix_space import MatrixSpace @@ -33,9 +36,7 @@ from sage.rings.polynomial.binary_form_reduce import covariant_z0, epsinv from sage.rings.rational_field import QQ from sage.schemes.affine.affine_space import AffineSpace -from sage.symbolic.constants import e -from sage.arith.misc import gcd -from copy import copy + def bCheck(c, v, p, b): r""" @@ -89,7 +90,7 @@ def scale(c, v, p): - ``c`` -- an integer polynomial - - ``v`` -- an integer - the bound on the exponent from blift + - ``v`` -- an integer; the bound on the exponent from :func:`blift` - ``p`` -- a prime @@ -151,8 +152,8 @@ def blift(LF, Li, p, k, S=None, all_orbits=False): sage: R. = PolynomialRing(QQ) sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import blift - sage: blift([8*b^3 + 12*b^2 + 6*b + 1, 48*b^2 + 483*b + 117, 72*b + 1341,\ - ....: -24*b^2 + 411*b + 99, -144*b + 1233, -216*b], 2, 3, 2) + sage: blift([8*b^3 + 12*b^2 + 6*b + 1, 48*b^2 + 483*b + 117, 72*b + 1341, + ....: -24*b^2 + 411*b + 99, -144*b + 1233, -216*b], 2, 3, 2) [[True, 4]] """ @@ -244,8 +245,7 @@ def affine_minimal(vp, return_transformation=False, D=None, quick=False): sage: affine_minimal(vp, True) ( Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (X : Y) to - (X^2 + Y^2 : X*Y) + Defn: Defined on coordinates by sending (X : Y) to (X^2 + Y^2 : X*Y) , [3 0] [0 1] @@ -330,16 +330,16 @@ def affine_minimal(vp, return_transformation=False, D=None, quick=False): def Min(Fun, p, ubRes, conj, all_orbits=False): r""" - Local loop for Affine_minimal, where we check minimality at the prime p. + Local loop for :func:`affine_minimal`, where we check minimality at the prime `p`. - First we bound the possible k in our transformations A = zp^k + b. + First we bound the possible `k` in our transformations `A = zp^k + b`. See Theorems 3.3.2 and 3.3.3 in [Molnar]_. INPUT: - ``Fun`` -- a dynamical system on projective space - - ``p`` - a prime + - ``p`` -- a prime - ``ubRes`` -- integer, the upper bound needed for Th. 3.3.3 in [Molnar]_ @@ -357,7 +357,8 @@ def Min(Fun, p, ubRes, conj, all_orbits=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([149*x^2 + 39*x*y + y^2, -8*x^2 + 137*x*y + 33*y^2]) + sage: f = DynamicalSystem_projective([149*x^2 + 39*x*y + y^2, + ....: -8*x^2 + 137*x*y + 33*y^2]) sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import Min sage: Min(f, 3, -27000000, matrix(QQ,[[1, 0],[0, 1]])) [ @@ -941,6 +942,8 @@ def get_bound_dynamical(F, f, m=1, dynatomic=True, prec=53, emb=None): sage: get_bound_dynamical(f.dynatomic_polynomial(1), f) 35.5546923182219 """ + from sage.symbolic.constants import e + def coshdelta(z): #The cosh of the hyperbolic distance from z = t+uj to j return (z.norm() + 1)/(2*z.imag()) @@ -998,7 +1001,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith - ``dynatomic`` -- boolean. whether ``F`` is the periodic points or the formal periodic points of period ``m`` for ``f`` - - ``start_n`` - positive integer. the period used to start trying to + - ``start_n`` -- positive integer. the period used to start trying to create associate binary form ``F`` - ``prec``-- positive integer. precision to use in CC @@ -1010,7 +1013,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith properties of the map are utilized to choose how to compute minimal orbit representatives - - ``check_minimal`` -- (default: True), boolean, whether to check + - ``check_minimal`` -- (default: ``True``), boolean, whether to check if this map is a minimal model OUTPUT: pair [dynamical system, matrix] @@ -1020,7 +1023,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import smallest_dynamical sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem([50*x^2 + 795*x*y + 2120*y^2, 265*x^2 + 106*y^2]) - sage: smallest_dynamical(f) #long time + sage: smallest_dynamical(f) # long time [ Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to @@ -1030,6 +1033,8 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith [0 1] ] """ + from sage.symbolic.constants import e + def insert_item(pts, item, index): # binary insertion to maintain list of points left to consider N = len(pts) diff --git a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py index 25d8645ae86..9533e983ba6 100644 --- a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py @@ -78,14 +78,14 @@ class DynamicalSystem(SchemeMorphism_polynomial, EXAMPLES:: sage: A. = AffineSpace(QQ,1) - sage: f = DynamicalSystem_affine([x^2+1]) + sage: f = DynamicalSystem_affine([x^2 + 1]) sage: type(f) :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: type(f) @@ -96,8 +96,7 @@ class DynamicalSystem(SchemeMorphism_polynomial, sage: DynamicalSystem(H([y, x])) Dynamical System of Projective Space of dimension 1 over Complex Field with 53 bits of precision - Defn: Defined on coordinates by sending (x : y) to - (y : x) + Defn: Defined on coordinates by sending (x : y) to (y : x) :class:`DynamicalSystem` defaults to projective:: @@ -109,16 +108,14 @@ class DynamicalSystem(SchemeMorphism_polynomial, :: - sage: A. = AffineSpace(QQ, 2) - sage: DynamicalSystem([y, x], domain=A) - Dynamical System of Affine Space of dimension 2 over Rational Field - Defn: Defined on coordinates by sending (x, y) to - (y, x) - sage: H = End(A) - sage: DynamicalSystem(H([y, x])) - Dynamical System of Affine Space of dimension 2 over Rational Field - Defn: Defined on coordinates by sending (x, y) to - (y, x) + sage: A. = AffineSpace(QQ, 2) + sage: DynamicalSystem([y, x], domain=A) + Dynamical System of Affine Space of dimension 2 over Rational Field + Defn: Defined on coordinates by sending (x, y) to (y, x) + sage: H = End(A) + sage: DynamicalSystem(H([y, x])) + Dynamical System of Affine Space of dimension 2 over Rational Field + Defn: Defined on coordinates by sending (x, y) to (y, x) Note that ``domain`` is ignored if an endomorphism is passed in:: @@ -134,7 +131,8 @@ class DynamicalSystem(SchemeMorphism_polynomial, sage: P. = ProjectiveSpace(ZZ, 1) sage: DynamicalSystem([CC.0*x^2, 4/5*y^2]) - Dynamical System of Projective Space of dimension 1 over Complex Field with 53 bits of precision + Dynamical System of + Projective Space of dimension 1 over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y) to (1.00000000000000*I*x^2 : 0.800000000000000*y^2) sage: P. = ProjectiveSpace(GF(5), 1) @@ -179,7 +177,7 @@ def __init__(self, polys_or_rat_fncts, domain): sage: from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: isinstance(f, DynamicalSystem) True """ @@ -239,7 +237,7 @@ def as_scheme_morphism(self): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: type(f.as_scheme_morphism()) @@ -253,21 +251,21 @@ def as_scheme_morphism(self): :: sage: A. = AffineSpace(ZZ, 2) - sage: f = DynamicalSystem_affine([x^2-2, y^2]) + sage: f = DynamicalSystem_affine([x^2 - 2, y^2]) sage: type(f.as_scheme_morphism()) :: sage: A. = AffineSpace(QQ, 2) - sage: f = DynamicalSystem_affine([x^2-2, y^2]) + sage: f = DynamicalSystem_affine([x^2 - 2, y^2]) sage: type(f.as_scheme_morphism()) :: sage: A. = AffineSpace(GF(3), 2) - sage: f = DynamicalSystem_affine([x^2-2, y^2]) + sage: f = DynamicalSystem_affine([x^2 - 2, y^2]) sage: type(f.as_scheme_morphism()) """ @@ -295,8 +293,7 @@ def change_ring(self, R, check=True): sage: f = DynamicalSystem_projective([3*x^2, y^2]) sage: f.change_ring(GF(5)) Dynamical System of Projective Space of dimension 1 over Finite Field of size 5 - Defn: Defined on coordinates by sending (x : y) to - (-2*x^2 : y^2) + Defn: Defined on coordinates by sending (x : y) to (-2*x^2 : y^2) """ f = self.as_scheme_morphism() F = f.change_ring(R) @@ -325,11 +322,10 @@ def specialization(self, D=None, phi=None, homset=None): sage: R. = PolynomialRing(QQ) sage: P. = ProjectiveSpace(R, 1) - sage: f = DynamicalSystem_projective([x^2 + c*y^2,y^2], domain=P) + sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2], domain=P) sage: f.specialization({c:1}) Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 + y^2 : y^2) + Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) """ F = self.as_scheme_morphism().specialization(D, phi, homset) return F.as_dynamical_system() @@ -362,7 +358,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals EXAMPLES: - Note that the number of critical points is 2d-2, but (1:0) has multiplicity 2 in this case:: + Note that the number of critical points is `2d-2`, but `(1:0)` has multiplicity 2 in this case:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/3*x^3 + x*y^2, y^3], domain=P) @@ -392,10 +388,11 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals sage: f[0].derivative(x).univariate_polynomial().is_irreducible() True sage: f.field_of_definition_critical(return_embedding=True, names='b') - (Finite Field in b of size 3^6, Ring morphism: - From: Finite Field in a of size 3^2 - To: Finite Field in b of size 3^6 - Defn: a |--> 2*b^5 + 2*b^3 + b^2 + 2*b + 2) + (Finite Field in b of size 3^6, + Ring morphism: + From: Finite Field in a of size 3^2 + To: Finite Field in b of size 3^6 + Defn: a |--> 2*b^5 + 2*b^3 + b^2 + 2*b + 2) """ ds = copy(self) space = ds.domain().ambient_space() @@ -475,7 +472,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False, [(0 : 1), (1 : 0), (1 : 1)] sage: N. = f.field_of_definition_periodic(3); N Number Field in a with defining polynomial x^6 + x^5 + x^4 + x^3 + x^2 + x + 1 - sage: sorted(f.periodic_points(3,minimal=False, R=N), key=str) + sage: sorted(f.periodic_points(3, minimal=False, R=N), key=str) [(-a^5 - a^4 - a^3 - a^2 - a - 1 : 1), (0 : 1), (1 : 0), @@ -504,10 +501,11 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False, sage: (g-x).univariate_polynomial().factor() (x + 1) * (x + a + 1) * (x^2 + a*x + 1) sage: f.field_of_definition_periodic(2, return_embedding=True, names='b') - (Finite Field in b of size 2^4, Ring morphism: - From: Finite Field in a of size 2^2 - To: Finite Field in b of size 2^4 - Defn: a |--> b^2 + b) + (Finite Field in b of size 2^4, + Ring morphism: + From: Finite Field in a of size 2^2 + To: Finite Field in b of size 2^4 + Defn: a |--> b^2 + b) """ ds = copy(self) n = int(n) @@ -588,7 +586,8 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/3*x^2 + 2/3*x*y, x^2 - 2*y^2], domain=P) sage: N. = f.field_of_definition_preimage(P(1,1), 2, simplify_all=True); N - Number Field in a with defining polynomial x^8 - 4*x^7 - 128*x^6 + 398*x^5 + 3913*x^4 - 8494*x^3 - 26250*x^2 + 30564*x - 2916 + Number Field in a with defining polynomial + x^8 - 4*x^7 - 128*x^6 + 398*x^5 + 3913*x^4 - 8494*x^3 - 26250*x^2 + 30564*x - 2916 :: @@ -603,10 +602,11 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif sage: P. = ProjectiveSpace(G, 1) sage: f = DynamicalSystem([x^2 + 2*y^2, y^2], domain=P) sage: f.field_of_definition_preimage(P(2,1), 2, return_embedding=True, names='a') - (Finite Field in a of size 5^2, Ring morphism: - From: Finite Field of size 5 - To: Finite Field in a of size 5^2 - Defn: 1 |--> 1) + (Finite Field in a of size 5^2, + Ring morphism: + From: Finite Field of size 5 + To: Finite Field in a of size 5^2 + Defn: 1 |--> 1) """ ds = copy(self) n = int(n) diff --git a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py index caf82a3b00d..c1f3a41c15e 100644 --- a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py @@ -1,7 +1,7 @@ r""" Dynamical systems for products of projective spaces -This class builds on the prouct projective space class. +This class builds on the product projective space class. The main constructor functions are given by ``DynamicalSystem`` and ``DynamicalSystem_projective``. The constructors function can take either polynomials or a morphism from which to construct a dynamical system. @@ -47,19 +47,18 @@ class DynamicalSystem_product_projective(DynamicalSystem, INPUT: - - ``polys`` -- a list of ``n_1 + \cdots + n_r`` multi-homogeneous polynomials, all + - ``polys`` -- a list of `n_1 + \cdots + n_r` multi-homogeneous polynomials, all of which should have the same parent - ``domain`` -- a projective scheme embedded in - ``P^{n_1-1} \times \cdots \times P^{n_r-1}`` + `P^{n_1-1} \times \cdots \times P^{n_r-1}` EXAMPLES:: sage: T. = ProductProjectiveSpaces([2, 1], QQ) sage: DynamicalSystem_projective([x^2, y^2, z^2, w^2, u^2], domain=T) Dynamical System of Product of projective spaces P^2 x P^1 over Rational Field - Defn: Defined by sending (x : y : z , w : u) to - (x^2 : y^2 : z^2 , w^2 : u^2). + Defn: Defined by sending (x : y : z , w : u) to (x^2 : y^2 : z^2 , w^2 : u^2). """ def __init__(self, polys, domain): @@ -86,7 +85,7 @@ def _call_with_args(self, P, check=True): - ``P`` -- a point in the domain - - ``check`` -- Boolean - whether or not to perform the input checks + - ``check`` -- Boolean; whether or not to perform the input checks on the image point (Default: ``True``) OUTPUT: The image point in the codomain @@ -135,7 +134,8 @@ def nth_iterate(self, P, n, normalize=False): EXAMPLES:: sage: Z. = ProductProjectiveSpaces([1, 2], QQ) - sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], domain=Z) + sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], + ....: domain=Z) sage: P = Z([1, 1, 1, 1, 1]) sage: f.nth_iterate(P, 3) (1/1872 : 1 , 1 : 1 : 0) @@ -145,7 +145,7 @@ def nth_iterate(self, P, n, normalize=False): sage: Z. = ProductProjectiveSpaces([1, 1], ZZ) sage: f = DynamicalSystem_projective([a*b, b^2, x^3 - y^3, y^2*x], domain=Z) sage: P = Z([2, 6, 2, 4]) - sage: f.nth_iterate(P, 2, normalize = True) + sage: f.nth_iterate(P, 2, normalize=True) (1 : 3 , 407 : 112) """ if P.codomain() != self.domain(): @@ -194,10 +194,12 @@ def orbit(self, P, N, **kwds): EXAMPLES:: sage: Z. = ProductProjectiveSpaces([1, 2], QQ) - sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], domain=Z) + sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], + ....: domain=Z) sage: P = Z([1, 1, 1, 1, 1]) sage: f.orbit(P, 3) - [(1 : 1 , 1 : 1 : 1), (1/2 : 1 , 1 : 0 : 1), (1/12 : 1 , -1 : 1 : 0), (1/1872 : 1 , 1 : 1 : 0)] + [(1 : 1 , 1 : 1 : 1), (1/2 : 1 , 1 : 0 : 1), + (1/12 : 1 , -1 : 1 : 0), (1/1872 : 1 , 1 : 1 : 0)] :: @@ -205,7 +207,8 @@ def orbit(self, P, N, **kwds): sage: f = DynamicalSystem_projective([a*b, b^2, x^3 - y^3, y^2*x], domain=Z) sage: P = Z([2, 6, 2, 4]) sage: f.orbit(P, 3, normalize=True) - [(1 : 3 , 1 : 2), (1 : 3 , -7 : 4), (1 : 3 , 407 : 112), (1 : 3 , 66014215 : 5105408)] + [(1 : 3 , 1 : 2), (1 : 3 , -7 : 4), + (1 : 3 , 407 : 112), (1 : 3 , 66014215 : 5105408)] """ if P.codomain() != self.domain(): raise TypeError("point is not defined over domain of function") @@ -241,7 +244,7 @@ def orbit(self, P, N, **kwds): def nth_iterate_map(self, n): r""" - Return the nth iterate of this dynamical system. + Return the ``n``-th iterate of this dynamical system. ALGORITHM: @@ -301,21 +304,21 @@ def cyclegraph(self): EXAMPLES:: sage: P. = ProductProjectiveSpaces(GF(3), [1,1]) - sage: f = DynamicalSystem_projective([a^2,b^2,c^2,d^2], domain=P) + sage: f = DynamicalSystem_projective([a^2, b^2, c^2, d^2], domain=P) sage: f.cyclegraph() Looped digraph on 16 vertices :: sage: P. = ProductProjectiveSpaces(GF(5), [1,1]) - sage: f = DynamicalSystem_projective([a^2,b^2,c,d], domain=P) + sage: f = DynamicalSystem_projective([a^2, b^2, c, d], domain=P) sage: f.cyclegraph() Looped digraph on 36 vertices :: sage: P. = ProductProjectiveSpaces(GF(2), [1,2]) - sage: f = DynamicalSystem_projective([a^2,b^2,c,d,e], domain=P) + sage: f = DynamicalSystem_projective([a^2, b^2, c, d, e], domain=P) sage: f.cyclegraph() Looped digraph on 21 vertices diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 6520177f4a7..f4a67e5fdf9 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -58,7 +58,7 @@ class initialization directly. import sage.rings.abc from sage.arith.functions import lcm -from sage.arith.misc import binomial, gcd, is_prime, moebius, next_prime, primes +from sage.arith.misc import binomial, gcd, integer_ceil as ceil, is_prime, moebius, next_prime, primes from sage.calculus.functions import jacobian from sage.categories.fields import Fields from sage.categories.finite_fields import FiniteFields @@ -76,7 +76,6 @@ class initialization directly. from sage.dynamics.arithmetic_dynamics.projective_ds_helper import ( _fast_possible_periods, _all_periodic_points) -from sage.functions.other import ceil from sage.libs.pari.all import PariError from sage.matrix.constructor import matrix, identity_matrix from sage.misc.cachefunc import cached_method @@ -116,7 +115,6 @@ class initialization directly. from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model -from sage.symbolic.constants import e class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, @@ -6854,6 +6852,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): return [] if B is None: + from sage.symbolic.constants import e B = e ** self.height_difference_bound() p = points_modp[0][0].codomain().base_ring().characteristic() @@ -7250,6 +7249,9 @@ def all_periodic_points(self, **kwds): return list(periodic) while p in badprimes: p = next_prime(p + 1) + + from sage.symbolic.constants import e + B = e ** DS.height_difference_bound() f = DS.change_ring(GF(p)) all_points = f.possible_periods(True) # return the list of points and their periods. diff --git a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py index cc4078c017a..0d1672e15d0 100644 --- a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py +++ b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py @@ -61,7 +61,7 @@ def WehlerK3Surface(polys): EXAMPLES:: - sage: PP. = ProductProjectiveSpaces([2, 2],QQ) + sage: PP. = ProductProjectiveSpaces([2, 2], QQ) sage: L = x0*y0 + x1*y1 - x2*y2 sage: Q = x0*x1*y1^2 + x2^2*y0*y2 sage: WehlerK3Surface([L, Q]) @@ -159,7 +159,7 @@ def change_ring(self, R): r""" Changes the base ring on which the Wehler K3 Surface is defined. - INPUT: ``R`` - ring + INPUT: ``R`` -- ring OUTPUT: K3 Surface defined over input ring @@ -184,7 +184,7 @@ def _check_satisfies_equations(self, P): r""" Function checks to see if point ``P`` lies on the K3 Surface. - INPUT: ``P`` - point in `\mathbb{P}^2 \times \mathbb{P}^2` + INPUT: ``P`` -- point in `\mathbb{P}^2 \times \mathbb{P}^2` OUTPUT: AttributeError True if the point is not on the surface @@ -330,17 +330,17 @@ def Gpoly(self, component, k): Return the G polynomials `G^*_k`. They are defined as: - `G^*_k = \left(L^*_j\right)^2Q^*_{ii}-L^*_iL^*_jQ^*_{ij}+\left(L^*_i\right)^2Q^*_{jj}`\ + `G^*_k = \left(L^*_j\right)^2Q^*_{ii}-L^*_iL^*_jQ^*_{ij}+\left(L^*_i\right)^2Q^*_{jj}` where {i, j, k} is some permutation of (0, 1, 2) and * is either - x (Component = 1) or y (Component = 0). + x (``component=1``) or y (``component=0``). INPUT: - - ``component`` - Integer: 0 or 1 + - ``component`` -- Integer: 0 or 1 - - ``k`` - Integer: 0, 1 or 2 + - ``k`` -- Integer: 0, 1 or 2 - OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) + OUTPUT: polynomial in terms of either y (``component=0``) or x (``component=1``) EXAMPLES:: @@ -376,17 +376,17 @@ def Hpoly(self, component, i, j): This polynomial is defined by: `H^*_{ij} = 2L^*_iL^*_jQ^*_{kk}-L^*_iL^*_kQ^*_{jk} - L^*_jL^*_kQ^*_{ik}+\left(L^*_k\right)^2Q^*_{ij}` - where {i, j, k} is some permutation of (0, 1, 2) and * is either y (Component = 0) or x (Component = 1). + where {i, j, k} is some permutation of (0, 1, 2) and * is either y (``component=0``) or x (``component=1``). INPUT: - - ``component`` - Integer: 0 or 1 + - ``component`` -- Integer: 0 or 1 - - ``i`` - Integer: 0, 1 or 2 + - ``i`` -- Integer: 0, 1 or 2 - - ``j`` - Integer: 0, 1 or 2 + - ``j`` -- Integer: 0, 1 or 2 - OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) + OUTPUT: polynomial in terms of either y (``component=0``) or x (``component=1``) EXAMPLES:: @@ -464,7 +464,7 @@ def Qxa(self, a): Notation and definition from: [CS1996]_ - INPUT: ``a`` - Point in `\mathbb{P}^2` + INPUT: ``a`` -- Point in `\mathbb{P}^2` OUTPUT: A polynomial representing the fiber @@ -518,9 +518,9 @@ def Sxa(self, a): sage: X = WehlerK3Surface([Z, Y]) sage: T = PP(1, 1, 0, 1, 0, 0) sage: X.Sxa(T[0]) - Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: - y0 + y1, - 5*y0^2 + 7*y0*y1 + y1^2 + 11*y1*y2 + y2^2 + Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: + y0 + y1, + 5*y0^2 + 7*y0*y1 + y1^2 + 11*y1*y2 + y2^2 """ if a not in self.ambient_space()[0]: raise TypeError("point must be in projective space of dimension 2") @@ -537,7 +537,7 @@ def Lyb(self, b): Notation and definition from: [CS1996]_ - INPUT: ``b`` - Point in projective space + INPUT: ``b`` -- Point in projective space OUTPUT: A polynomial representing the fiber @@ -554,7 +554,7 @@ def Lyb(self, b): sage: X = WehlerK3Surface([Z, Y]) sage: T = PP(1, 1, 0, 1, 0, 0) sage: X.Lyb(T[1]) - x0 + x0 """ if b not in self.ambient_space()[1]: raise TypeError("point must be in projective space of dimension 2") @@ -627,9 +627,9 @@ def Syb(self, b): sage: X = WehlerK3Surface([Z, Y]) sage: T = PP(1, 1, 0, 1, 0, 0) sage: X.Syb(T[1]) - Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: - x0, - x0^2 + 3*x0*x1 + x1^2 + Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: + x0, + x0^2 + 3*x0*x1 + x1^2 """ if b not in self.ambient_space()[1]: @@ -649,23 +649,25 @@ def Ramification_poly(self, i): The roots of this polynomial will either be degenerate fibers or fixed points of the involutions `\sigma_x` or `\sigma_y` for more information, see [CS1996]_. - INPUT: ``i`` - Integer, either 0 (polynomial in y) or 1 (polynomial in x) + INPUT: ``i`` -- Integer, either 0 (polynomial in y) or 1 (polynomial in x) OUTPUT: Polynomial in the coordinate ring of the ambient space EXAMPLES:: sage: PP. = ProductProjectiveSpaces([2, 2], QQ) - sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1\ - - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ - - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 + sage: Z = (x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 + ....: - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + ....: + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + ....: + x0*x1*y2^2 + 3*x2^2*y2^2) sage: Y = x0*y0 + x1*y1 + x2*y2 sage: X = WehlerK3Surface([Z, Y]) sage: X.Ramification_poly(0) 8*y0^5*y1 - 24*y0^4*y1^2 + 48*y0^2*y1^4 - 16*y0*y1^5 + y1^6 + 84*y0^3*y1^2*y2 + 46*y0^2*y1^3*y2 - 20*y0*y1^4*y2 + 16*y1^5*y2 + 53*y0^4*y2^2 + 56*y0^3*y1*y2^2 - 32*y0^2*y1^2*y2^2 - 80*y0*y1^3*y2^2 - 92*y1^4*y2^2 - 12*y0^2*y1*y2^3 - - 168*y0*y1^2*y2^3 - 122*y1^3*y2^3 + 14*y0^2*y2^4 + 8*y0*y1*y2^4 - 112*y1^2*y2^4 + y2^6 + - 168*y0*y1^2*y2^3 - 122*y1^3*y2^3 + 14*y0^2*y2^4 + 8*y0*y1*y2^4 - 112*y1^2*y2^4 + + y2^6 """ return ((self._Lcoeff(i, 0))**2)*(self._Qcoeff(i, 1, 2))**2 + \ ((self._Lcoeff(i, 1))**2)*(self._Qcoeff(i, 0, 2)**2)+ \ @@ -755,7 +757,7 @@ def degenerate_fibers(self): The criteria for degeneracy by the common vanishing of the polynomials ``self.Gpoly(1, 0)``, ``self.Gpoly(1, 1)``, ``self.Gpoly(1, 2)``, - ``self.Hpoly(1, 0, 1)``,``self.Hpoly(1, 0, 2)``, + ``self.Hpoly(1, 0, 1)``, ``self.Hpoly(1, 0, 2)``, ``self.Hpoly(1, 1, 2)`` (for the first component), is from Proposition 1.4 in the following article: [CS1996]_. @@ -781,9 +783,10 @@ def degenerate_fibers(self): :: sage: PP. = ProductProjectiveSpaces([2, 2], QQ) - sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1\ - - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ - - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 + sage: Z = (x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 + ....: - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + ....: + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + ....: + x0*x1*y2^2 + 3*x2^2*y2^2) sage: Y = x0*y0 + x1*y1 + x2*y2 sage: X = WehlerK3Surface([Z, Y]) sage: X.degenerate_fibers() @@ -875,7 +878,7 @@ def degenerate_primes(self,check=True): Raises an error if the surface is degenerate. Works only for ``ZZ`` or ``QQ``. - INPUT: ``check`` -- (default: True) boolean, whether the primes are verified + INPUT: ``check`` -- (default: ``True``) boolean, whether the primes are verified ALGORITHM: @@ -1038,11 +1041,11 @@ def sigmaX(self, P, **kwds): INPUT: - - ``P`` - a point in `\mathbb{P}^2 \times \mathbb{P}^2` + - ``P`` -- a point in `\mathbb{P}^2 \times \mathbb{P}^2` kwds: - - ``check`` - (default: ``True``) boolean checks to see if point is on the surface + - ``check`` -- (default: ``True``) boolean checks to see if point is on the surface - ``normalize`` -- (default: ``True``) boolean normalizes the point @@ -1083,12 +1086,14 @@ def sigmaX(self, P, **kwds): sage: PP.=ProductProjectiveSpaces([2, 2], GF(3)) sage: l = x0*y0 + x1*y1 + x2*y2 - sage: q=-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 - \ - 190*x0*x1*y0*y1- 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + \ - 5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2- 2*x1^2*y1^2 + 2*x0*x2*y1^2 - \ - 4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + 3*x0*x2*y0*y2+ 6*x1*x2*y0*y2 - \ - 6*x0^2*y1*y2 - 4*x0*x1*y1*y2 - x1^2*y1*y2 + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 - \ - 9*x2^2*y1*y2 - x0^2*y2^2 - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + 13*x1*x2*y2^2 - x2^2*y2^2 + sage: q = (-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 + ....: - 190*x0*x1*y0*y1 - 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + ....: + 5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2 - 2*x1^2*y1^2 + ....: + 2*x0*x2*y1^2 - 4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + ....: + 3*x0*x2*y0*y2 + 6*x1*x2*y0*y2 - 6*x0^2*y1*y2 - 4*x0*x1*y1*y2 + ....: - x1^2*y1*y2 + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 - 9*x2^2*y1*y2 + ....: - x0^2*y2^2 - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + ....: + 13*x1*x2*y2^2 - x2^2*y2^2) sage: X = WehlerK3Surface([l, q]) sage: P = X([1, 0, 0, 0, 1, 1]) sage: X.sigmaX(X.sigmaX(P)) @@ -1268,12 +1273,12 @@ def sigmaX(self, P, **kwds): def sigmaY(self,P, **kwds): r""" - Function returns the involution on the Wehler K3 surfaces induced by the double covers. + Return the involution on the Wehler K3 surfaces induced by the double covers. - In particular,it fixes the projection to the second coordinate and swaps + In particular, it fixes the projection to the second coordinate and swaps the two points in the fiber, i.e. `(x,y) \to (x',y)`. Note that in the degenerate case, while we can split the fiber into two points, - it is not always possibleto distinguish them, using this algorithm. + it is not always possible to distinguish them, using this algorithm. ALGORITHM: @@ -1283,11 +1288,11 @@ def sigmaY(self,P, **kwds): INPUT: - - ``P`` - a point in `\mathbb{P}^2 \times \mathbb{P}^2` + - ``P`` -- a point in `\mathbb{P}^2 \times \mathbb{P}^2` kwds: - - ``check`` - (default: ``True``) boolean checks to see if point is on the surface + - ``check`` -- (default: ``True``) boolean checks to see if point is on the surface - ``normalize`` -- (default: ``True``) boolean normalizes the point @@ -1326,11 +1331,13 @@ def sigmaY(self,P, **kwds): sage: PP.=ProductProjectiveSpaces([2, 2], GF(3)) sage: l = x0*y0 + x1*y1 + x2*y2 - sage: q=-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 - 190*x0*x1*y0*y1 \ - - 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + 5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2 \ - - 2*x1^2*y1^2 + 2*x0*x2*y1^2 - 4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + 3*x0*x2*y0*y2 \ - + 6*x1*x2*y0*y2 - 6*x0^2*y1*y2 - 4*x0*x1*y1*y2 - x1^2*y1*y2 + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 \ - - 9*x2^2*y1*y2 - x0^2*y2^2 - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + 13*x1*x2*y2^2 - x2^2*y2^2 + sage: q = (-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 + ....: - 190*x0*x1*y0*y1 - 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + ....: + 5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2 - 2*x1^2*y1^2 + 2*x0*x2*y1^2 + ....: - 4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + 3*x0*x2*y0*y2 + ....: + 6*x1*x2*y0*y2 - 6*x0^2*y1*y2 - 4*x0*x1*y1*y2 - x1^2*y1*y2 + ....: + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 - 9*x2^2*y1*y2 - x0^2*y2^2 + ....: - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + 13*x1*x2*y2^2 - x2^2*y2^2) sage: X = WehlerK3Surface([l ,q]) sage: P = X([0, 1, 1, 1, 0, 0]) sage: X.sigmaY(X.sigmaY(P)) @@ -1521,7 +1528,7 @@ def phi(self, a, **kwds): kwds: - - ``check`` - (default: ``True``) boolean checks to see if point is on the surface + - ``check`` -- (default: ``True``) boolean checks to see if point is on the surface - ``normalize`` -- (default: ``True``) boolean normalizes the point @@ -1561,7 +1568,7 @@ def psi(self,a, **kwds): kwds: - - ``check`` - (default: ``True``) boolean checks to see if point is on the surface + - ``check`` -- (default: ``True``) boolean checks to see if point is on the surface - ``normalize`` -- (default: ``True``) boolean normalizes the point @@ -1604,8 +1611,8 @@ def lambda_plus(self, P, v, N, m, n, prec=100): - ``v`` -- non-negative integer. a place, use v = 0 for the Archimedean place - - ``m,n`` -- positive integers, We compute the local height for the divisor `E_{mn}^{+}`. - These must be indices of non-zero coordinates of the point ``P``. + - ``m``, ``n`` -- positive integers; we compute the local height for the divisor `E_{mn}^{+}`. + These must be indices of non-zero coordinates of the point ``P``. - ``prec`` -- (default: 100) float point or p-adic precision @@ -2004,9 +2011,12 @@ def fiber(self, p, component): sage: PP. = ProductProjectiveSpaces([2, 2], GF(7)) sage: L = x0*y0 + x1*y1 - 1*x2*y2 - sage: Q=(2*x0^2 + x2*x0 + (2*x1^2 + x2^2))*y0^2 + ((x0^2 + x1*x0 +(x1^2 + 2*x2*x1 + x2^2))*y1 + \ - (2*x1^2 + x2*x1 + x2^2)*y2)*y0 + ((2*x0^2+ (x1 + 2*x2)*x0 + (2*x1^2 + x2*x1))*y1^2 + ((2*x1 + 2*x2)*x0 + \ - (x1^2 +x2*x1 + 2*x2^2))*y2*y1 + (2*x0^2 + x1*x0 + (2*x1^2 + x2^2))*y2^2) + sage: Q = ((2*x0^2 + x2*x0 + (2*x1^2 + x2^2))*y0^2 + ....: + ((x0^2 + x1*x0 +(x1^2 + 2*x2*x1 + x2^2))*y1 + ....: + (2*x1^2 + x2*x1 + x2^2)*y2)*y0 + ....: + ((2*x0^2 + (x1 + 2*x2)*x0 + (2*x1^2 + x2*x1))*y1^2 + ....: + ((2*x1 + 2*x2)*x0 + (x1^2 + x2*x1 + 2*x2^2))*y2*y1 + ....: + (2*x0^2 + x1*x0 + (2*x1^2 + x2^2))*y2^2)) sage: W = WehlerK3Surface([L, Q]) sage: W.fiber([4, 0, 1], 0) [(0 : 1 : 0 , 4 : 0 : 1), (4 : 0 : 2 , 4 : 0 : 1)] @@ -2136,7 +2146,7 @@ def fiber(self, p, component): def nth_iterate_phi(self, P, n, **kwds): r""" - Computes the nth iterate for the phi function. + Computes the ``n``-th iterate for the phi function. INPUT: @@ -2158,7 +2168,7 @@ def nth_iterate_phi(self, P, n, **kwds): sage: PP. = ProductProjectiveSpaces([2, 2], QQ) sage: L = x0*y0 + x1*y1 + x2*y2 sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 - sage: W = WehlerK3Surface([L ,Q]) + sage: W = WehlerK3Surface([L, Q]) sage: T = W([-1, -1, 1, 1, 0, 1]) sage: W.nth_iterate_phi(T, 7) (-1 : 0 : 1 , 1 : -2 : 1) @@ -2201,7 +2211,7 @@ def nth_iterate_phi(self, P, n, **kwds): def nth_iterate_psi(self, P, n, **kwds): r""" - Computes the nth iterate for the psi function. + Computes the ``n``-th iterate for the psi function. INPUT: @@ -2262,9 +2272,9 @@ def orbit_phi(self, P, N, **kwds): INPUT: - - ``P`` - Point on the K3 surface + - ``P`` -- Point on the K3 surface - - ``N`` - a non-negative integer or list or tuple of two non-negative integers + - ``N`` -- a non-negative integer or list or tuple of two non-negative integers kwds: @@ -2321,13 +2331,13 @@ def orbit_psi(self, P, N, **kwds): INPUT: - - ``P`` - a point on the K3 surface + - ``P`` -- a point on the K3 surface - - ``N`` - a non-negative integer or list or tuple of two non-negative integers + - ``N`` -- a non-negative integer or list or tuple of two non-negative integers kwds: - - ``check`` - (default: ``True``) boolean, checks to see if point is on the surface + - ``check`` -- (default: ``True``) boolean, checks to see if point is on the surface - ``normalize`` -- (default: ``False``) boolean, normalizes the point @@ -2343,9 +2353,9 @@ def orbit_psi(self, P, N, **kwds): sage: Y = x0*y0 + x1*y1 + x2*y2 sage: X = WehlerK3Surface([Z, Y]) sage: T = X(0, 0, 1, 1, 0, 0) - sage: X.orbit_psi(T, 2, normalize = True) + sage: X.orbit_psi(T, 2, normalize=True) [(0 : 0 : 1 , 1 : 0 : 0), (0 : 0 : 1 , 0 : 1 : 0), (-1 : 0 : 1 , 1 : 1/9 : 1)] - sage: X.orbit_psi(T,[2,3], normalize = True) + sage: X.orbit_psi(T,[2,3], normalize=True) [(-1 : 0 : 1 , 1 : 1/9 : 1), (-12816/6659 : 55413/6659 : 1 , -117756062505511/54767410965117 : -23134047983794359/37466994368025041 : 1)] """ @@ -2371,11 +2381,11 @@ def orbit_psi(self, P, N, **kwds): def is_isomorphic(self, right): r""" - Checks to see if two K3 surfaces have the same defining ideal. + Check to see if two K3 surfaces have the same defining ideal. INPUT: - - ``right`` - the K3 surface to compare to the original + - ``right`` -- the K3 surface to compare to the original OUTPUT: Boolean @@ -2395,12 +2405,12 @@ def is_isomorphic(self, right): :: sage: R. = PolynomialRing(QQ, 6) - sage: L = x*u-y*v + sage: L = x*u - y*v sage: Q = x*y*v^2 + z^2*u*w sage: W1 = WehlerK3Surface([L, Q]) sage: PP. = ProductProjectiveSpaces([2, 2], QQ) sage: L = x0*y0 + x1*y1 + x2*y2 - sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 -x0*x1*y2^2 + sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 sage: W2 = WehlerK3Surface([L, Q]) sage: W1.is_isomorphic(W2) False @@ -2409,12 +2419,12 @@ def is_isomorphic(self, right): def is_symmetric_orbit(self,orbit): r""" - Checks to see if the orbit is symmetric (i.e. if one of the points on the + Check to see if the orbit is symmetric (i.e. if one of the points on the orbit is fixed by '\sigma_x' or '\sigma_y'). INPUT: - - ``orbit``- a periodic cycle of either psi or phi + - ``orbit`` -- a periodic cycle of either psi or phi OUTPUT: Boolean @@ -2463,20 +2473,20 @@ class WehlerK3Surface_field( WehlerK3Surface_ring): class WehlerK3Surface_finite_field( WehlerK3Surface_field): def cardinality( self): r""" - Counts the total number of points on the K3 surface. + Count the total number of points on the K3 surface. ALGORITHM: Enumerate points over `\mathbb{P}^2`, and then count the points on the fiber of each of those points. - OUTPUT: Integer - total number of points on the surface + OUTPUT: Integer -- total number of points on the surface EXAMPLES:: sage: PP. = ProductProjectiveSpaces([2, 2], GF(7)) sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ - 3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ + 3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ + x0*x1*y2^2 + 3*x2^2*y2^2 sage: Y = x0*y0 + x1*y1 + x2*y2 From 6e08d6f888ad58d54875d1722fde4d8ffd5b651e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 May 2023 13:20:30 -0700 Subject: [PATCH 075/494] Massive modularization fixes --- .../dynamics/arithmetic_dynamics/affine_ds.py | 35 ++++++++++--------- .../arithmetic_dynamics/projective_ds.py | 34 +++++++++--------- .../dynamics/cellular_automata/elementary.py | 6 ++-- src/sage/dynamics/cellular_automata/glca.py | 4 +-- 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py index e672314a9c0..68db00928eb 100644 --- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py @@ -188,8 +188,8 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space, :: - sage: x = var('x') - sage: DynamicalSystem_affine(x^2+1) + sage: x = var('x') # optional - sage.symbolic + sage: DynamicalSystem_affine(x^2 + 1) # optional - sage.symbolic Traceback (most recent call last): ... TypeError: symbolic ring cannot be the base ring @@ -397,10 +397,10 @@ def homogenize(self, n): :: - sage: R. = PolynomialRing(QQbar) - sage: A. = AffineSpace(R, 2) - sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2]) - sage: f.homogenize(2) + sage: R. = PolynomialRing(QQbar) # optional - sage.rings.number_field + sage: A. = AffineSpace(R, 2) # optional - sage.rings.number_field + sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2]) # optional - sage.rings.number_field sage.symbolic + sage: f.homogenize(2) # optional - sage.rings.number_field sage.symbolic Dynamical System of Projective Space of dimension 2 over Univariate Polynomial Ring in a over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -507,8 +507,8 @@ def dynatomic_polynomial(self, period): :: sage: A. = AffineSpace(CC,1) - sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) - sage: F.dynatomic_polynomial([1,1]) + sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) # optional - sage.symbolic + sage: F.dynatomic_polynomial([1,1]) # optional - sage.symbolic (0.125000000000000*x^4 + 0.366025403784439*x^2 + 1.50000000000000)/(0.500000000000000*x^2 - x + 1.73205080756888) TESTS:: @@ -957,19 +957,22 @@ def reduce_base_field(self): :: - sage: A. = AffineSpace(QQbar, 2) - sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, QQbar(sqrt(-1))*y^2]) - sage: f.reduce_base_field() - Dynamical System of Affine Space of dimension 2 over Number Field in a with defining polynomial y^4 - y^2 + 1 with a = -0.866025403784439? + 0.50000000000000000?*I + sage: A. = AffineSpace(QQbar, 2) # optional - sage.rings.number_field + sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, # optional - sage.rings.number_field sage.symbolic + ....: QQbar(sqrt(-1))*y^2]) + sage: f.reduce_base_field() # optional - sage.rings.number_field sage.symbolic + Dynamical System of Affine Space of dimension 2 over Number Field in a + with defining polynomial y^4 - y^2 + 1 + with a = -0.866025403784439? + 0.50000000000000000?*I Defn: Defined on coordinates by sending (x, y) to (x^2 + (a^3 - 2*a)*y^2, (a^3)*y^2) :: - sage: K. = CyclotomicField(5) - sage: A. = AffineSpace(K, 2) - sage: f = DynamicalSystem_affine([(3*x^2 + y) / (5*x), (y^2+1) / (x+y)]) - sage: f.reduce_base_field() + sage: K. = CyclotomicField(5) # optional - sage.rings.number_field + sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field + sage: f = DynamicalSystem_affine([(3*x^2 + y) / (5*x), (y^2+1) / (x+y)]) # optional - sage.rings.number_field + sage: f.reduce_base_field() # optional - sage.rings.number_field Dynamical System of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to ((3*x^2 + y)/(5*x), (5*y^2 + 5)/(5*x + 5*y)) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index f4a67e5fdf9..f7af65ec347 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -193,8 +193,8 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, Symbolic Ring elements are not allowed:: - sage: x,y = var('x,y') - sage: DynamicalSystem_projective([x^2, y^2]) + sage: x,y = var('x,y') # optional - sage.symbolic + sage: DynamicalSystem_projective([x^2, y^2]) # optional - sage.symbolic Traceback (most recent call last): ... ValueError: [x^2, y^2] must be elements of a polynomial ring @@ -294,7 +294,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None): :: - sage: DynamicalSystem_projective([exp(x), exp(y)]) + sage: DynamicalSystem_projective([exp(x), exp(y)]) # optional - sage.symbolic Traceback (most recent call last): ... ValueError: [e^x, e^y] must be elements of a polynomial ring @@ -501,8 +501,8 @@ def _number_field_from_algebraics(self): EXAMPLES:: sage: P. = ProjectiveSpace(QQbar,1) - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(2)) * y^2, y^2]) - sage: f._number_field_from_algebraics() + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(2)) * y^2, y^2]) # optional - sage.symbolic + sage: f._number_field_from_algebraics() # optional - sage.symbolic Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial y^2 - 2 with a = 1.414213562373095? Defn: Defined on coordinates by sending (x : y) to @@ -2763,7 +2763,7 @@ def nth_preimage_tree(self, Q, n, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: Q = P(0,1) - sage: f.nth_preimage_tree(Q, 2) + sage: f.nth_preimage_tree(Q, 2) # optional - sage.plot GraphPlot object for Digraph on 7 vertices :: @@ -2771,7 +2771,7 @@ def nth_preimage_tree(self, Q, n, **kwds): sage: P. = ProjectiveSpace(GF(3), 1) sage: f = DynamicalSystem_projective([x^2 + x*y + y^2, y^2]) sage: Q = P(0,1) - sage: f.nth_preimage_tree(Q, 2, return_points=True) + sage: f.nth_preimage_tree(Q, 2, return_points=True) # optional - sage.plot (GraphPlot object for Digraph on 4 vertices, [[(0 : 1)], [(1 : 1)], [(0 : 1), (2 : 1)]]) """ @@ -6076,20 +6076,20 @@ def reduced_form(self, **kwds): :: sage: P. = ProjectiveSpace(RR, 1) - sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) + sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) # optional - sage.symbolic sage: m = matrix(RR, 2, 2, [1,12,0,1]) - sage: f = f.conjugate(m) - sage: g, m = f.reduced_form(smallest_coeffs=False); m + sage: f = f.conjugate(m) # optional - sage.symbolic + sage: g, m = f.reduced_form(smallest_coeffs=False); m # optional - sage.symbolic [ 1 -12] [ 0 1] :: sage: P. = ProjectiveSpace(CC, 1) - sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) + sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) # optional - sage.symbolic sage: m = matrix(CC, 2, 2, [1,12,0,1]) - sage: f = f.conjugate(m) - sage: g, m = f.reduced_form(smallest_coeffs=False); m + sage: f = f.conjugate(m) # optional - sage.symbolic + sage: g, m = f.reduced_form(smallest_coeffs=False); m # optional - sage.symbolic [ 1 -12] [ 0 1] @@ -8710,11 +8710,11 @@ def reduce_base_field(self): :: sage: P. = ProjectiveSpace(QQbar, 2) - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, # optional - sage.symbolic ....: 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 = -0.5176380902050415? + sage: f.reduce_base_field() # optional - sage.symbolic + Dynamical System of Projective Space of dimension 2 over Number Field in a + with 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) diff --git a/src/sage/dynamics/cellular_automata/elementary.py b/src/sage/dynamics/cellular_automata/elementary.py index cd0915cdde7..3cf0cd19560 100644 --- a/src/sage/dynamics/cellular_automata/elementary.py +++ b/src/sage/dynamics/cellular_automata/elementary.py @@ -225,7 +225,7 @@ class ElementaryCellularAutomata(SageObject): sage: ECA = cellular_automata.Elementary(60, width=200) sage: ECA.evolve(200) - sage: ECA.plot() + sage: ECA.plot() # optional - sage.plot Graphics object consisting of 1 graphics primitive .. PLOT:: @@ -239,7 +239,7 @@ class ElementaryCellularAutomata(SageObject): sage: ECA = cellular_automata.Elementary(90, initial_state=[1]+[0]*254+[1], boundary=None) sage: ECA.evolve(256) - sage: ECA.plot() + sage: ECA.plot() # optional - sage.plot Graphics object consisting of 1 graphics primitive .. PLOT:: @@ -598,7 +598,7 @@ def plot(self, number=None): sage: ECA = cellular_automata.Elementary(110, width=256) sage: ECA.evolve(256) - sage: ECA.plot() + sage: ECA.plot() # optional - sage.plot Graphics object consisting of 1 graphics primitive """ if number is None: diff --git a/src/sage/dynamics/cellular_automata/glca.py b/src/sage/dynamics/cellular_automata/glca.py index 46b24619ac2..90b7a770548 100644 --- a/src/sage/dynamics/cellular_automata/glca.py +++ b/src/sage/dynamics/cellular_automata/glca.py @@ -67,7 +67,7 @@ class GraftalLaceCellularAutomata(SageObject): sage: G = cellular_automata.GraftalLace([2,0,3,3,6,0,2,7]) sage: G.evolve(20) - sage: G.plot() + sage: G.plot() # optional - sage.plot Graphics object consisting of 842 graphics primitives .. PLOT:: @@ -398,7 +398,7 @@ def plot(self, number=None): sage: G = cellular_automata.GraftalLace([5,1,2,5,4,5,5,0]) sage: G.evolve(20) - sage: G.plot() + sage: G.plot() # optional - sage.plot Graphics object consisting of 865 graphics primitives """ if number is None: From 230b7343dcfd1dcb4a6590f88625b31ecf174213 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 2 Jul 2023 19:24:56 -0700 Subject: [PATCH 076/494] sage.dynamics.arithmetic_dynamics: Modularization fixes for imports --- .../arithmetic_dynamics/berkovich_ds.py | 25 +++++++++++-------- .../endPN_automorphism_group.py | 4 ++- .../arithmetic_dynamics/generic_ds.py | 16 +++++++----- .../arithmetic_dynamics/projective_ds.py | 12 +++++---- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index 19bc1fbc5e6..539a27ea7b5 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -22,23 +22,26 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.structure.element import Element +from sage.categories.number_fields import NumberFields +from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem -from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass +from sage.dynamics.arithmetic_dynamics.projective_ds import DynamicalSystem_projective +from sage.matrix.constructor import Matrix from sage.misc.classcall_metaclass import typecall +from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass +from sage.misc.lazy_import import lazy_import +from sage.rings.infinity import Infinity +from sage.rings.integer_ring import ZZ +from sage.rings.rational_field import QQ +from sage.schemes.affine.affine_space import is_AffineSpace from sage.schemes.berkovich.berkovich_space import (Berkovich_Cp_Affine, Berkovich_Cp_Projective, is_Berkovich_Cp, Berkovich_Element_Cp_Affine) from sage.schemes.projective.projective_space import is_ProjectiveSpace -from sage.schemes.affine.affine_space import is_AffineSpace -from sage.rings.padics.padic_base_generic import pAdicBaseGeneric -from sage.dynamics.arithmetic_dynamics.projective_ds import DynamicalSystem_projective -from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine -from sage.categories.number_fields import NumberFields -from sage.rings.integer_ring import ZZ -from sage.rings.rational_field import QQ -from sage.rings.infinity import Infinity -from sage.matrix.constructor import Matrix +from sage.structure.element import Element + +lazy_import('sage.rings.padics.padic_base_generic', 'pAdicBaseGeneric') + class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMetaclass): r""" diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py index 32ccb2a9a7b..421ce1b433d 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py @@ -28,18 +28,20 @@ from sage.combinat.subset import Subsets from sage.matrix.constructor import matrix from sage.misc.functional import sqrt +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.parallel.use_fork import p_iter_fork from sage.rings.finite_rings.finite_field_constructor import GF from sage.rings.finite_rings.integer_mod_ring import Integers from sage.rings.integer_ring import ZZ -from sage.rings.number_field.number_field import NumberField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ from sage.sets.primes import Primes from sage.sets.set import Set from sage.structure.element import is_Matrix +lazy_import('sage.rings.number_field.number_field', 'NumberField') + def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False): r""" diff --git a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py index 9533e983ba6..a9a945124fd 100644 --- a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py @@ -27,17 +27,21 @@ class initialization directly. # http://www.gnu.org/licenses/ #***************************************************************************** +from copy import copy + from sage.categories.homset import End from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass -from sage.schemes.generic.morphism import SchemeMorphism_polynomial +from sage.misc.lazy_import import lazy_import +from sage.rings.finite_rings.finite_field_base import FiniteField +from sage.rings.rational_field import QQ from sage.schemes.affine.affine_space import is_AffineSpace from sage.schemes.affine.affine_subscheme import AlgebraicScheme_subscheme_affine -from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic -from sage.rings.finite_rings.finite_field_base import FiniteField -from sage.rings.qqbar import AlgebraicField_common from sage.schemes.berkovich.berkovich_space import is_Berkovich_Cp -from sage.rings.rational_field import QQ -from copy import copy +from sage.schemes.generic.morphism import SchemeMorphism_polynomial + +lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') +lazy_import('sage.rings.qqbar', 'AlgebraicField_common') + class DynamicalSystem(SchemeMorphism_polynomial, metaclass=InheritComparisonClasscallMetaclass): diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index f7af65ec347..797c33f1a03 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -76,16 +76,15 @@ class initialization directly. from sage.dynamics.arithmetic_dynamics.projective_ds_helper import ( _fast_possible_periods, _all_periodic_points) -from sage.libs.pari.all import PariError from sage.matrix.constructor import matrix, identity_matrix from sage.misc.cachefunc import cached_method from sage.misc.classcall_metaclass import typecall from sage.misc.functional import sqrt +from sage.misc.lazy_import import lazy_import from sage.misc.mrange import xmrange from sage.modules.free_module_element import vector from sage.parallel.ncpus import ncpus from sage.parallel.use_fork import p_iter_fork -from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic from sage.rings.complex_mpfr import ComplexField from sage.rings.finite_rings.finite_field_base import FiniteField from sage.rings.finite_rings.finite_field_constructor import GF @@ -97,12 +96,9 @@ class initialization directly. from sage.rings.integer_ring import ZZ from sage.rings.polynomial.flatten import FlatteningMorphism, UnflatteningMorphism from sage.rings.morphism import RingHomomorphism_im_gens -from sage.rings.number_field.number_field_ideal import NumberFieldFractionalIdeal -from sage.rings.padics.factory import Qp from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.polynomial.polynomial_ring import is_PolynomialRing -from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics from sage.rings.quotient_ring import QuotientRing_generic from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField @@ -116,6 +112,12 @@ class initialization directly. from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model +lazy_import('sage.libs.pari.all', 'PariError') +lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') +lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') +lazy_import('sage.rings.padics.factory', 'Qp') +lazy_import('sage.rings.qqbar', ['QQbar', 'number_field_elements_from_algebraics']) + class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, DynamicalSystem): From 0d6869a0e2258fb5e15079a61450370cf78677b4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 2 Jul 2023 21:59:51 -0700 Subject: [PATCH 077/494] Update # optional / # needs --- .../arithmetic_dynamics/berkovich_ds.py | 324 ++--- .../product_projective_ds.py | 6 +- .../arithmetic_dynamics/projective_ds.py | 1144 ++++++++--------- 3 files changed, 737 insertions(+), 737 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index 539a27ea7b5..eab3bcdac91 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -71,9 +71,9 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet We can easily create a dynamical system on Berkovich space using a dynamical system on projective space over `\QQ_p`:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) - sage: DynamicalSystem_Berkovich(f) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -82,8 +82,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Or directly from polynomials:: - sage: P. = ProjectiveSpace(Qp(3),1) - sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2]) + sage: P. = ProjectiveSpace(Qp(3),1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -91,8 +91,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet :class:`DynamicalSystem_Berkovich` defaults to projective:: - sage: R. = Qp(3)[] - sage: DynamicalSystem_Berkovich([x^2, y^2]) + sage: R. = Qp(3)[] # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -101,18 +101,18 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet To create an affine dynamical system on Berkovich space, pass an affine dynamical system to :class:`DynamicalSystem_Berkovich`:: - sage: A. = AffineSpace(Qp(3), 1) - sage: f = DynamicalSystem_affine(z^2 + 1) - sage: DynamicalSystem_Berkovich(f) + sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_affine(z^2 + 1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (z) to (z^2 + 1 + O(3^20)) ``domain`` can be used to specify the type of dynamical system:: - sage: A. = AffineSpace(Qp(3), 1) - sage: C = Berkovich_Cp_Affine(3) - sage: DynamicalSystem_Berkovich([z^2 + 1], C) + sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: C = Berkovich_Cp_Affine(3) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([z^2 + 1], C) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (z) to (z^2 + 1 + O(3^20)) @@ -120,11 +120,11 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet We can create dynamical systems which act on Berkovich spaces backed by number fields:: sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) - sage: ideal = A.prime_above(2) - sage: P. = ProjectiveSpace(A, 1) - sage: B = Berkovich_Cp_Projective(P, ideal) - sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], B) + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: ideal = A.prime_above(2) # needs sage.rings.padics + sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.padics + sage: B = Berkovich_Cp_Projective(P, ideal) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], B) # needs sage.rings.number_field sage.rings.padics Dynamical system of Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -134,10 +134,10 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet same dynamical system more efficiently:: sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) - sage: prime_ideal = A.prime_above(2) - sage: P. = ProjectiveSpace(A, 1) - sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], ideal=prime_ideal) + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: prime_ideal = A.prime_above(2) # needs sage.rings.padics + sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], ideal=prime_ideal) # needs sage.rings.number_field sage.rings.padics Dynamical system of Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -146,49 +146,49 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Creating a map on Berkovich space creates the Berkovich space it acts on:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([x^2, y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: B = g.domain(); B + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([x^2, y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: B = g.domain(); B # needs sage.rings.padics Projective Berkovich line over Cp(3) of precision 20 The image of type I point is the image of the center:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: F = DynamicalSystem_Berkovich([x^2, y^2]) - sage: B = F.domain() - sage: Q1 = B(2) - sage: F(Q1) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: F = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics + sage: B = F.domain() # needs sage.rings.padics + sage: Q1 = B(2) # needs sage.rings.padics + sage: F(Q1) # needs sage.rings.padics Type I point centered at (1 + 3 + O(3^20) : 1 + O(3^20)) For type II/III points with no poles in the corresponding disk, the image is the type II/III point corresponding to the image of the disk:: - sage: Q2 = B(0, 3) - sage: F(Q2) + sage: Q2 = B(0, 3) # needs sage.rings.padics + sage: F(Q2) # needs sage.rings.padics Type II point centered at (0 : 1 + O(3^20)) of radius 3^2 The image of any type II point can be computed:: - sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: G = DynamicalSystem_Berkovich(g) - sage: Q3 = B(0, 1) - sage: G(Q3) + sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.padics + sage: G = DynamicalSystem_Berkovich(g) # needs sage.rings.padics + sage: Q3 = B(0, 1) # needs sage.rings.padics + sage: G(Q3) # needs sage.rings.padics Type II point centered at (0 : 1 + O(3^20)) of radius 3^0 The image of type III points can be computed has long as the corresponding disk contains no poles of the dynamical system:: - sage: Q4 = B(1/9, 1.5) - sage: G(Q4) + sage: Q4 = B(1/9, 1.5) # needs sage.rings.padics + sage: G(Q4) # needs sage.rings.padics Type III point centered at (3^-2 + 3^2 + O(3^18) : 1 + O(3^20)) of radius 1.50000000000000 Sometimes, however, the poles are contained in an extension of `\QQ_p` that Sage does not support:: - sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) + sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) # needs sage.rings.padics sage: H(Q4) # not tested Traceback (most recent call last): ... @@ -203,13 +203,13 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet sage: B = Berkovich_Cp_Projective(P, 3) sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3], B) sage: Q4 = B(1/9, 1.5) - sage: H(Q4) + sage: H(Q4) # needs sage.rings.number_field Type III point centered at (81/14581 : 1) of radius 0.00205761316872428 Alternatively, if checking for poles in the disk has been done already, ``type_3_pole_check`` can be set to ``False``:: - sage: P. = ProjectiveSpace(Qp(3), 1) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) sage: B = H.domain() sage: Q4 = B(1/9, 1.5) @@ -229,9 +229,9 @@ def __classcall_private__(cls, dynamical_system, domain=None, ideal=None): EXAMPLES:: - sage: R. = Qp(3)[] - sage: f = DynamicalSystem_affine(t^2 - 3) - sage: DynamicalSystem_Berkovich(f) + sage: R. = Qp(3)[] # needs sage.rings.padics + sage: f = DynamicalSystem_affine(t^2 - 3) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending ((1 + O(3^20))*t) to ((1 + O(3^20))*t^2 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + @@ -289,10 +289,10 @@ def __init__(self, dynamical_system, domain): TESTS:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: isinstance(g, DynamicalSystem_Berkovich) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: isinstance(g, DynamicalSystem_Berkovich) # needs sage.rings.padics True """ self._system = dynamical_system @@ -304,15 +304,15 @@ def __eq__(self, other): EXAMPLES:: - sage: R. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) - sage: f == f + sage: R. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics + sage: f == f # needs sage.rings.padics True :: - sage: g = DynamicalSystem_Berkovich([x^3, x*y^2]) - sage: f == g + sage: g = DynamicalSystem_Berkovich([x^3, x*y^2]) # needs sage.rings.padics + sage: f == g # needs sage.rings.padics True """ if not isinstance(other, type(self)): @@ -325,15 +325,15 @@ def __neq__(self, other): EXAMPLES:: - sage: R. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) - sage: f != f + sage: R. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics + sage: f != f # needs sage.rings.padics False :: - sage: g = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) - sage: f != g + sage: g = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics + sage: f != g # needs sage.rings.padics True """ return not (self == other) @@ -346,10 +346,10 @@ def domain(self): EXAMPLES:: - sage: Q. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: g.domain() + sage: Q. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: g.domain() # needs sage.rings.padics Projective Berkovich line over Cp(3) of precision 20 """ return self._domain @@ -362,9 +362,9 @@ def as_scheme_dynamical_system(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y]) - sage: f.as_scheme_dynamical_system() + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y]) # needs sage.rings.padics + sage: f.as_scheme_dynamical_system() # needs sage.rings.padics Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20 Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : x*y) @@ -384,10 +384,10 @@ def __getitem__(self, i): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: g[0] + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: g[0] # needs sage.rings.padics x^2 + y^2 """ return self._system._polys[i] @@ -401,10 +401,10 @@ def defining_polynomials(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: g.defining_polynomials() + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: g.defining_polynomials() # needs sage.rings.padics ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2, (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) """ @@ -418,18 +418,18 @@ def base_ring(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) - sage: f.base_ring() + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics + sage: f.base_ring() # needs sage.rings.padics 3-adic Field with capped relative precision 20 :: sage: R. = QQ[] - sage: A. = NumberField(z^3 + 20) - sage: P. = ProjectiveSpace(A, 1) - sage: f = DynamicalSystem_Berkovich([x^2, x^2 + y^2], ideal=A.prime_above(2)) - sage: f.base_ring() + sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_Berkovich([x^2, x^2 + y^2], ideal=A.prime_above(2)) # needs sage.rings.number_field + sage: f.base_ring() # needs sage.rings.padics Number Field in a with defining polynomial z^3 + 20 """ return self.domain().base_ring() @@ -442,10 +442,10 @@ def _repr_(self): EXAMPLES:: - sage: Q. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) - sage: f = DynamicalSystem_Berkovich(f) - sage: f._repr_() + sage: Q. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: f._repr_() # needs sage.rings.padics 'Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map\n Defn: Defined on coordinates by sending (x : y) to\n ((3 + O(3^21))*x^2 : (2 + O(3^20))*y^2)' """ @@ -479,9 +479,9 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich): We can easily create a dynamical system on Berkovich space using a dynamical system on projective space over `\QQ_p`:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([1/2*x^2 + x*y + 3*y^2, 3*x^2 + 9*y^2]) - sage: DynamicalSystem_Berkovich(f) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([1/2*x^2 + x*y + 3*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -491,17 +491,17 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich): Or from a morphism:: - sage: P1. = ProjectiveSpace(Qp(3), 1) - sage: H = End(P1) - sage: DynamicalSystem_Berkovich(H([y, x])) + sage: P1. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: H = End(P1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(H([y, x])) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (y : x) Or from polynomials:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: DynamicalSystem_Berkovich([x^2+y^2, y^2]) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2+y^2, y^2]) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) @@ -513,9 +513,9 @@ def __classcall_private__(cls, dynamical_system, domain=None): EXAMPLES:: - sage: P1. = ProjectiveSpace(Qp(3), 1) + sage: P1. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_projective - sage: DynamicalSystem_Berkovich_projective([y, x]) + sage: DynamicalSystem_Berkovich_projective([y, x]) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (y : x) @@ -551,8 +551,8 @@ def __init__(self, dynamical_system, domain=None): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y]) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y]) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -572,9 +572,9 @@ def scale_by(self, t): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) - sage: f.scale_by(x); f + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics + sage: f.scale_by(x); f # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^3 : x*y^2) @@ -582,12 +582,12 @@ def scale_by(self, t): :: sage: Q. = QQ[] - sage: A. = NumberField(z^3 + 20) - sage: ideal = A.prime_above(3) - sage: P. = ProjectiveSpace(A, 1) - sage: B = Berkovich_Cp_Projective(P, ideal) - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, 2*x*y], B) - sage: f.scale_by(2); f + sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field + sage: ideal = A.prime_above(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field + sage: B = Berkovich_Cp_Projective(P, ideal) # needs sage.rings.number_field sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, 2*x*y], B) # needs sage.rings.number_field sage.rings.padics + sage: f.scale_by(2); f # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3), with base Number Field in a with defining polynomial z^3 + 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -603,9 +603,9 @@ def normalize_coordinates(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2]) - sage: f.normalize_coordinates(); f + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2]) # needs sage.rings.padics + sage: f.normalize_coordinates(); f # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) @@ -613,7 +613,7 @@ def normalize_coordinates(self): Normalize_coordinates may sometimes fail over p-adic fields:: - sage: g = DynamicalSystem_Berkovich([2*x^2, x*y]) + sage: g = DynamicalSystem_Berkovich([2*x^2, x*y]) # needs sage.rings.padics sage: g.normalize_coordinates() #not tested Traceback (most recent call last): ... @@ -656,10 +656,10 @@ def conjugate(self, M, adjugate=False, new_ideal=None): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: g.conjugate(Matrix([[1, 1], [0, 1]])) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: g.conjugate(Matrix([[1, 1], [0, 1]])) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -670,9 +670,9 @@ def conjugate(self, M, adjugate=False, new_ideal=None): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2], ideal=5) sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) - sage: conj = Matrix([[1, a], [0, 1]]) - sage: f.conjugate(conj) + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: conj = Matrix([[1, a], [0, 1]]) # needs sage.rings.number_field + sage: f.conjugate(conj) # needs sage.rings.number_field Dynamical system of Projective Berkovich line over Cp(5), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -682,10 +682,10 @@ def conjugate(self, M, adjugate=False, new_ideal=None): the base ring of ``M`` and of this dynamical system are not the same:: - sage: ideal = A.ideal(5).factor()[1][0]; ideal + sage: ideal = A.ideal(5).factor()[1][0]; ideal # needs sage.rings.number_field Fractional ideal (2*a + 1) - sage: g = f.conjugate(conj, new_ideal=ideal) - sage: g.domain().ideal() + sage: g = f.conjugate(conj, new_ideal=ideal) # needs sage.rings.number_field + sage: g.domain().ideal() # needs sage.rings.padics Fractional ideal (2*a + 1) """ if self.domain().is_padic_base(): @@ -718,18 +718,18 @@ def resultant(self, normalize=False): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) - sage: f.resultant() + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics + sage: f.resultant() # needs sage.rings.padics 1 + O(3^20) :: sage: R. = QQ[] - sage: A. = NumberField(z^3 + 20) - sage: P. = ProjectiveSpace(A, 1) - sage: f = DynamicalSystem_Berkovich([2*x^2, x^2 + y^2], ideal=A.prime_above(2)) - sage: f.resultant() + sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_Berkovich([2*x^2, x^2 + y^2], ideal=A.prime_above(2)) # needs sage.rings.number_field + sage: f.resultant() # needs sage.rings.padics 4 """ return self._system.resultant(normalize=normalize) @@ -750,10 +750,10 @@ def dehomogenize(self, n): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) - sage: g = DynamicalSystem_Berkovich(f) - sage: g.dehomogenize(1) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: g.dehomogenize(1) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to @@ -783,21 +783,21 @@ def __call__(self, x, type_3_pole_check=True): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: G = DynamicalSystem_Berkovich(g) - sage: B = G.domain() - sage: Q3 = B(0, 1) - sage: G(Q3) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.padics + sage: G = DynamicalSystem_Berkovich(g) # needs sage.rings.padics + sage: B = G.domain() # needs sage.rings.padics + sage: Q3 = B(0, 1) # needs sage.rings.padics + sage: G(Q3) # needs sage.rings.padics Type II point centered at (0 : 1 + O(3^20)) of radius 3^0 :: - sage: P. = ProjectiveSpace(Qp(3), 1) - sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) - sage: B = H.domain() - sage: Q4 = B(1/9, 1.5) - sage: H(Q4, False) + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) # needs sage.rings.padics + sage: B = H.domain() # needs sage.rings.padics + sage: Q4 = B(1/9, 1.5) # needs sage.rings.padics + sage: H(Q4, False) # needs sage.rings.padics Type III point centered at (3^4 + 3^10 + 2*3^11 + 2*3^13 + 2*3^14 + 2*3^15 + 3^17 + 2*3^18 + 2*3^19 + 3^20 + 3^21 + 3^22 + O(3^24) : 1 + O(3^20)) of radius 0.00205761316872428 @@ -972,17 +972,17 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich): induced by a dynamical system on `\QQ_p` or an extension of `\QQ_p`:: - sage: A. = AffineSpace(Qp(5), 1) - sage: f = DynamicalSystem_affine([(x^2 + 1)/x]) - sage: DynamicalSystem_Berkovich(f) + sage: A. = AffineSpace(Qp(5), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_affine([(x^2 + 1)/x]) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to ((x^2 + 1 + O(5^20))/x) Dynamical system can be created from a morphism:: - sage: H = End(A) - sage: phi = H([x + 3]) - sage: DynamicalSystem_Berkovich(phi) + sage: H = End(A) # needs sage.rings.padics + sage: phi = H([x + 3]) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich(phi) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x + 3 + O(5^20)) """ @@ -993,9 +993,9 @@ def __classcall_private__(cls, dynamical_system, domain=None): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) + sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine - sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2)) + sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2)) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x^2) @@ -1027,9 +1027,9 @@ def __init__(self, dynamical_system, domain): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) + sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine - sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3)) + sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3)) # needs sage.rings.padics Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x^3) @@ -1053,10 +1053,10 @@ def homogenize(self, n): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) - sage: f = DynamicalSystem_affine(1/x) - sage: f = DynamicalSystem_Berkovich(f) - sage: f.homogenize(1) + sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_affine(1/x) # needs sage.rings.padics + sage: f = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: f.homogenize(1) # needs sage.rings.padics Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0) @@ -1073,12 +1073,12 @@ def __call__(self, x): EXAMPLES:: - sage: P. = AffineSpace(Qp(3), 1) - sage: f = DynamicalSystem_affine(x^2) - sage: g = DynamicalSystem_Berkovich(f) - sage: B = g.domain() - sage: Q1 = B(2) - sage: g(Q1) + sage: P. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_affine(x^2) # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: B = g.domain() # needs sage.rings.padics + sage: Q1 = B(2) # needs sage.rings.padics + sage: g(Q1) # needs sage.rings.padics Type I point centered at 1 + 3 + O(3^20) """ if not isinstance(x, Berkovich_Element_Cp_Affine): diff --git a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py index c1f3a41c15e..25b9f3704d7 100644 --- a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py @@ -305,21 +305,21 @@ def cyclegraph(self): sage: P. = ProductProjectiveSpaces(GF(3), [1,1]) sage: f = DynamicalSystem_projective([a^2, b^2, c^2, d^2], domain=P) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 16 vertices :: sage: P. = ProductProjectiveSpaces(GF(5), [1,1]) sage: f = DynamicalSystem_projective([a^2, b^2, c, d], domain=P) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 36 vertices :: sage: P. = ProductProjectiveSpaces(GF(2), [1,2]) sage: f = DynamicalSystem_projective([a^2, b^2, c, d, e], domain=P) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 21 vertices .. TODO:: Dynamical systems for subschemes of product projective spaces needs work. diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 797c33f1a03..624463f5bfa 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -195,8 +195,8 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, Symbolic Ring elements are not allowed:: - sage: x,y = var('x,y') # optional - sage.symbolic - sage: DynamicalSystem_projective([x^2, y^2]) # optional - sage.symbolic + sage: x,y = var('x,y') # needs sage.symbolic + sage: DynamicalSystem_projective([x^2, y^2]) # needs sage.symbolic Traceback (most recent call last): ... ValueError: [x^2, y^2] must be elements of a polynomial ring @@ -225,8 +225,8 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, sage: P. = ProjectiveSpace(CC, 2) sage: X = P.subscheme([x - y]) - sage: u,v,w = X.coordinate_ring().gens() - sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X) + sage: u,v,w = X.coordinate_ring().gens() # needs sage.rings.function_field + sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X) # needs sage.rings.function_field Dynamical System of Closed subscheme of Projective Space of dimension 2 over Complex Field with 53 bits of precision defined by: x - y @@ -242,7 +242,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, x^2]) sage: X = P.subscheme(y - z) - sage: f(f(f(X))) + sage: f(f(f(X))) # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y - z @@ -251,7 +251,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, sage: P. = ProjectiveSpace(QQ, 3) sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f(P.subscheme([x, y, z])) + sage: f(P.subscheme([x, y, z])) # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w, @@ -268,11 +268,11 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, :: - sage: K. = QuadraticField(-7) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem([x^3 + v*x*y^2, y^3]) - sage: fbar = f.change_ring(QQbar) - sage: fbar.is_postcritically_finite() + sage: K. = QuadraticField(-7) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem([x^3 + v*x*y^2, y^3]) # needs sage.rings.number_field + sage: fbar = f.change_ring(QQbar) # needs sage.rings.number_field + sage: fbar.is_postcritically_finite() # needs sage.rings.number_field False """ @@ -296,7 +296,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None): :: - sage: DynamicalSystem_projective([exp(x), exp(y)]) # optional - sage.symbolic + sage: DynamicalSystem_projective([exp(x), exp(y)]) # needs sage.symbolic Traceback (most recent call last): ... ValueError: [e^x, e^y] must be elements of a polynomial ring @@ -502,9 +502,9 @@ def _number_field_from_algebraics(self): EXAMPLES:: - sage: P. = ProjectiveSpace(QQbar,1) - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(2)) * y^2, y^2]) # optional - sage.symbolic - sage: f._number_field_from_algebraics() # optional - sage.symbolic + sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(2)) * y^2, y^2]) # needs sage.rings.number_field sage.symbolic + sage: f._number_field_from_algebraics() # needs sage.rings.number_field sage.symbolic Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial y^2 - 2 with a = 1.414213562373095? Defn: Defined on coordinates by sending (x : y) to @@ -615,21 +615,21 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari x^2 + x*y + 2*y^2 :: sage: P. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: f.dynatomic_polynomial(4) + sage: f.dynatomic_polynomial(4) # needs sage.libs.pari 2*x^12 + 18*x^10*y^2 + 57*x^8*y^4 + 79*x^6*y^6 + 48*x^4*y^8 + 12*x^2*y^10 + y^12 :: sage: P. = ProjectiveSpace(CC,1) sage: f = DynamicalSystem_projective([x^2 + y^2, 3*x*y]) - sage: f.dynatomic_polynomial(3) + sage: f.dynatomic_polynomial(3) # needs sage.libs.pari 13.0000000000000*x^6 + 117.000000000000*x^4*y^2 + 78.0000000000000*x^2*y^4 + y^6 @@ -644,7 +644,7 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) - sage: f.dynatomic_polynomial([2,3]) + sage: f.dynatomic_polynomial([2,3]) # needs sage.libs.pari x^12 - 95/8*x^10*y^2 + 13799/256*x^8*y^4 - 119953/1024*x^6*y^6 + 8198847/65536*x^4*y^8 - 31492431/524288*x^2*y^10 + 172692729/16777216*y^12 @@ -653,14 +653,14 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.dynatomic_polynomial([1,2]) + sage: f.dynatomic_polynomial([1,2]) # needs sage.libs.pari x^2 - x*y :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 - y^3, 3*x*y^2]) - sage: f.dynatomic_polynomial([0,4])==f.dynatomic_polynomial(4) + sage: f.dynatomic_polynomial([0,4])==f.dynatomic_polynomial(4) # needs sage.libs.pari True :: @@ -674,9 +674,9 @@ def dynatomic_polynomial(self, period): :: - sage: P. = ProjectiveSpace(Qp(5),1) - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: P. = ProjectiveSpace(Qp(5),1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) # needs sage.rings.padics + sage: f.dynatomic_polynomial(2) # needs sage.rings.padics (x^4*y + (2 + O(5^20))*x^2*y^3 - x*y^4 + (2 + O(5^20))*y^5)/(x^2*y - x*y^2 + y^3) :: @@ -684,7 +684,7 @@ def dynatomic_polynomial(self, period): sage: L. = PolynomialRing(QQ) sage: P. = ProjectiveSpace(L,1) sage: f = DynamicalSystem_projective([x^2 + t*y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari x^2 + x*y + (t + 1)*y^2 :: @@ -692,17 +692,17 @@ def dynatomic_polynomial(self, period): sage: K. = PolynomialRing(ZZ) sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.dynatomic_polynomial([1, 2]) + sage: f.dynatomic_polynomial([1, 2]) # needs sage.libs.pari x^2 - x*y + (c + 1)*y^2 :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari x^2 + x*y + 2*y^2 sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^2 + X + 2) + sage: K. = NumberField(X^2 + X + 2) # needs sage.rings.number_field sage: PP = P.change_ring(K) sage: ff = f.change_ring(K) sage: p = PP((c, 1)) @@ -713,21 +713,21 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: f.dynatomic_polynomial([2, 2]) + sage: f.dynatomic_polynomial([2, 2]) # needs sage.libs.pari x^4 + 4*x^2*y^2 + y^4 sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^4 + 4*X^2 + 1) + sage: K. = NumberField(X^4 + 4*X^2 + 1) # needs sage.rings.number_field sage: PP = P.change_ring(K) sage: ff = f.change_ring(K) sage: p = PP((c, 1)) - sage: ff.nth_iterate(p, 4) == ff.nth_iterate(p, 2) + sage: ff.nth_iterate(p, 4) == ff.nth_iterate(p, 2) # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(CC, 1) sage: f = DynamicalSystem_projective([x^2 - CC.0/3*y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari (x^4*y + (-0.666666666666667*I)*x^2*y^3 - x*y^4 + (-0.111111111111111 - 0.333333333333333*I)*y^5)/(x^2*y - x*y^2 + (-0.333333333333333*I)*y^3) @@ -736,15 +736,15 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(CC, 1) sage: f = DynamicalSystem_projective([x^2 - CC.0/5*y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari x^2 + x*y + (1.00000000000000 - 0.200000000000000*I)*y^2 :: - sage: L. = PolynomialRing(QuadraticField(2).maximal_order()) + sage: L. = PolynomialRing(QuadraticField(2).maximal_order()) # needs sage.rings.number_field sage: P. = ProjectiveSpace(L.fraction_field(), 1) sage: f = DynamicalSystem_projective([x^2 + (t^2 + 1)*y^2, y^2]) - sage: f.dynatomic_polynomial(2) + sage: f.dynatomic_polynomial(2) # needs sage.libs.pari sage.rings.number_field x^2 + x*y + (t^2 + 2)*y^2 :: @@ -759,18 +759,18 @@ def dynatomic_polynomial(self, period): We check that the dynatomic polynomial has the right parent (see :trac:`18409`):: - sage: P. = ProjectiveSpace(QQbar,1) + sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - 1/3*y^2, y^2]) - sage: f.dynatomic_polynomial(2).parent() + sage: f.dynatomic_polynomial(2).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Algebraic Field :: - sage: T. = QuadraticField(33) + sage: T. = QuadraticField(33) # needs sage.rings.number_field sage: S. = PolynomialRing(T) sage: P. = ProjectiveSpace(FractionField(S),1) sage: f = DynamicalSystem_projective([t*x^2 - 1/t*y^2, y^2]) - sage: f.dynatomic_polynomial([1, 2]).parent() + sage: f.dynatomic_polynomial([1, 2]).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Fraction Field of Univariate Polynomial Ring in t over Number Field in v with defining polynomial x^2 - 33 with v = 5.744562646538029? @@ -786,7 +786,7 @@ def dynatomic_polynomial(self, period): sage: R. = QQ[] sage: P. = ProjectiveSpace(R,1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.dynatomic_polynomial([1,2]).parent() + sage: f.dynatomic_polynomial([1,2]).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in c over Rational Field @@ -795,7 +795,7 @@ def dynatomic_polynomial(self, period): sage: R. = QQ[] sage: P. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, (1)*y^2 + (1)*x*y]) - sage: f.dynatomic_polynomial([1,2]).parent() + sage: f.dynatomic_polynomial([1,2]).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Integer Ring :: @@ -816,7 +816,7 @@ def dynatomic_polynomial(self, period): sage: R. = QQ[] sage: P. = ProjectiveSpace(R,1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.dynatomic_polynomial([1,2]).parent() + sage: f.dynatomic_polynomial([1,2]).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in c over Rational Field @@ -825,13 +825,13 @@ def dynatomic_polynomial(self, period): sage: S. = FunctionField(CC) sage: P. = ProjectiveSpace(S,1) sage: f = DynamicalSystem_projective([t*x^2-1*y^2, t*y^2]) - sage: f.dynatomic_polynomial([1, 2]).parent() + sage: f.dynatomic_polynomial([1, 2]).parent() # needs sage.libs.pari Symbolic Ring :: sage: R. = PolynomialRing(QQ) - sage: S = R.quo(R.ideal(y^2-x+1)) + sage: S = R.quo(R.ideal(y^2 - x + 1)) sage: P. = ProjectiveSpace(FractionField(S),1) sage: f = DynamicalSystem_projective([u^2 + S(x^2)*v^2, v^2]) sage: dyn = f.dynatomic_polynomial([1,1]); dyn @@ -936,7 +936,7 @@ def nth_iterate_map(self, n, normalize=False): :: sage: P. = ProjectiveSpace(ZZ,2) - sage: f = DynamicalSystem_projective([x^2-y^2, x*y, z^2+x^2]) + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y, z^2 + x^2]) sage: f.nth_iterate_map(2) Dynamical System of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to @@ -948,7 +948,7 @@ def nth_iterate_map(self, n, normalize=False): sage: P. = ProjectiveSpace(QQ,2) sage: X = P.subscheme(x*z-y^2) sage: f = DynamicalSystem_projective([x^2, x*z, z^2], domain=X) - sage: f.nth_iterate_map(2) + sage: f.nth_iterate_map(2) # needs sage.rings.function_field Dynamical System of Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: -y^2 + x*z @@ -1179,11 +1179,11 @@ def arakelov_zhang_pairing(self, g, **kwds): EXAMPLES:: - sage: K. = CyclotomicField(3) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 + (2*k + 2)*y^2, y^2]) - sage: g = DynamicalSystem_projective([x^2, y^2]) - sage: pairingval = f.arakelov_zhang_pairing(g, n=5); pairingval + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + (2*k + 2)*y^2, y^2]) # needs sage.rings.number_field + sage: g = DynamicalSystem_projective([x^2, y^2]) # needs sage.rings.number_field + sage: pairingval = f.arakelov_zhang_pairing(g, n=5); pairingval # needs sage.rings.number_field 0.409598197761958 :: @@ -1191,12 +1191,12 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + 4*y^2, y^2]) sage: g = DynamicalSystem_projective([x^2, y^2]) - sage: pairingval = f.arakelov_zhang_pairing(g, n=6); pairingval + sage: pairingval = f.arakelov_zhang_pairing(g, n=6); pairingval # needs sage.rings.function_field 0.750178391443644 sage: # Compare to the exact value: - sage: dynheight = f.canonical_height(P(0, 1)); dynheight + sage: dynheight = f.canonical_height(P(0, 1)); dynheight # needs sage.libs.pari 0.75017839144364417318023000563 - sage: dynheight - pairingval + sage: dynheight - pairingval # needs sage.libs.pari sage.rings.function_field 0.000000000000000 Notice that if we set the noise_multiplier to 0, the accuracy is diminished:: @@ -1204,12 +1204,12 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + 4*y^2, y^2]) sage: g = DynamicalSystem_projective([x^2, y^2]) - sage: pairingval = f.arakelov_zhang_pairing(g, n=6, noise_multiplier=0) + sage: pairingval = f.arakelov_zhang_pairing(g, n=6, noise_multiplier=0) # needs sage.rings.function_field sage: pairingval 0.650660018921632 - sage: dynheight = f.canonical_height(P(0, 1)); dynheight + sage: dynheight = f.canonical_height(P(0, 1)); dynheight # needs sage.libs.pari 0.75017839144364417318023000563 - sage: pairingval - dynheight + sage: pairingval - dynheight # needs sage.libs.pari sage.rings.function_field -0.0995183725220122 We compute the example of Prop. 18(d) from Petsche, Szpiro and Tucker:: @@ -1217,29 +1217,29 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([y^2 - (y - x)^2, y^2]) sage: g = DynamicalSystem_projective([x^2, y^2]) - sage: f.arakelov_zhang_pairing(g) + sage: f.arakelov_zhang_pairing(g) # needs sage.rings.function_field 0.326954667248466 sage: # Correct value should be = 0.323067... - sage: f.arakelov_zhang_pairing(g, n=9) # long time + sage: f.arakelov_zhang_pairing(g, n=9) # long time # needs sage.rings.function_field 0.323091061918965 - sage: _ - 0.323067 # long time + sage: _ - 0.323067 # long time # needs sage.rings.function_field 0.0000240619189654789 Also from Prop. 18 of Petsche, Szpiro and Tucker, includes places of bad reduction:: sage: R. = PolynomialRing(ZZ) - sage: K. = NumberField(z^3 - 11) - sage: P. = ProjectiveSpace(K,1) - sage: a = 7/(b - 1) - sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) + sage: K. = NumberField(z^3 - 11) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: a = 7/(b - 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) # needs sage.rings.number_field sage: g = DynamicalSystem_projective([x^2, y^2]) If all archimedean absolute values of a have modulus > 2, then the pairing should be h(a).:: - sage: f.arakelov_zhang_pairing(g, n=6) # long time + sage: f.arakelov_zhang_pairing(g, n=6) # long time # needs sage.rings.number_field 1.93846423207664 - sage: _ - a.global_height() # long time + sage: _ - a.global_height() # long time # needs sage.rings.number_field -0.00744591697867292 """ n = kwds.pop('n', 5) @@ -1421,7 +1421,7 @@ def degree_sequence(self, iterates=2): sage: P2. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([Z^2, X*Y, Y^2]) - sage: f.degree_sequence(15) + sage: f.degree_sequence(15) # needs sage.rings.function_field [2, 3, 5, 8, 11, 17, 24, 31, 45, 56, 68, 91, 93, 184, 275] :: @@ -1429,21 +1429,21 @@ def degree_sequence(self, iterates=2): sage: F. = PolynomialRing(QQ) sage: P2. = ProjectiveSpace(F, 2) sage: f = DynamicalSystem_projective([Y*Z, X*Y, Y^2 + t*X*Z]) - sage: f.degree_sequence(5) + sage: f.degree_sequence(5) # needs sage.rings.function_field [2, 3, 5, 8, 13] :: sage: P2. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([X^2, Y^2, Z^2]) - sage: f.degree_sequence(10) + sage: f.degree_sequence(10) # needs sage.rings.function_field [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] :: sage: P2. = ProjectiveSpace(ZZ, 2) sage: f = DynamicalSystem_projective([X*Y, Y*Z+Z^2, Z^2]) - sage: f.degree_sequence(10) + sage: f.degree_sequence(10) # needs sage.rings.function_field [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] """ if int(iterates) < 1: @@ -1482,14 +1482,14 @@ def dynamical_degree(self, N=3, prec=53): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) - sage: f.dynamical_degree() + sage: f.dynamical_degree() # needs sage.rings.function_field 2.00000000000000 :: sage: P2. = ProjectiveSpace(ZZ, 2) sage: f = DynamicalSystem_projective([X*Y, Y*Z + Z^2, Z^2]) - sage: f.dynamical_degree(N=5, prec=100) + sage: f.dynamical_degree(N=5, prec=100) # needs sage.rings.function_field 1.4309690811052555010452244131 """ if int(N) < 1: @@ -1674,7 +1674,7 @@ def resultant(self, normalize=False): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, 6*y^2]) - sage: f.resultant() + sage: f.resultant() # needs sage.libs.pari 36 :: @@ -1682,7 +1682,7 @@ def resultant(self, normalize=False): sage: R. = PolynomialRing(GF(17)) sage: P. = ProjectiveSpace(R,1) sage: f = DynamicalSystem_projective([t*x^2 + t*y^2, 6*y^2]) - sage: f.resultant() + sage: f.resultant() # needs sage.libs.pari 2*t^2 :: @@ -1703,10 +1703,10 @@ def resultant(self, normalize=False): :: sage: R. = PolynomialRing(QQ) - sage: s = (t^3 + t + 1).roots(QQbar)[0][0] - sage: P. = ProjectiveSpace(QQbar, 1) - sage: f = DynamicalSystem_projective([s*x^3 - 13*y^3, y^3 - 15*y^3]) - sage: f.resultant() + sage: s = (t^3 + t + 1).roots(QQbar)[0][0] # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([s*x^3 - 13*y^3, y^3 - 15*y^3]) # needs sage.rings.number_field + sage: f.resultant() # needs sage.rings.number_field 871.6925062959149? """ if normalize: @@ -1767,7 +1767,7 @@ def primes_of_bad_reduction(self, check=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([1/3*x^2 + 1/2*y^2, y^2]) - sage: f.primes_of_bad_reduction() + sage: f.primes_of_bad_reduction() # needs sage.rings.function_field [2, 3] :: @@ -1775,16 +1775,16 @@ def primes_of_bad_reduction(self, check=True): sage: P. = ProjectiveSpace(QQ,3) sage: f = DynamicalSystem_projective([12*x*z - 7*y^2, 31*x^2 - y^2, ....: 26*z^2, 3*w^2 - z*w]) - sage: f.primes_of_bad_reduction() + sage: f.primes_of_bad_reduction() # needs sage.rings.function_field [2, 3, 7, 13, 31] A number field example:: sage: R. = QQ[] - sage: K. = NumberField(z^2 - 2) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2]) - sage: f.primes_of_bad_reduction() + sage: K. = NumberField(z^2 - 2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2]) # needs sage.rings.number_field + sage: f.primes_of_bad_reduction() # needs sage.rings.function_field sage.rings.number_field [Fractional ideal (a), Fractional ideal (3)] This is an example where ``check=False`` returns extra primes:: @@ -1793,9 +1793,9 @@ def primes_of_bad_reduction(self, check=True): sage: f = DynamicalSystem_projective([3*x*y^2 + 7*y^3 - 4*y^2*z + 5*z^3, ....: -5*x^3 + x^2*y + y^3 + 2*x^2*z, ....: -2*x^2*y + x*y^2 + y^3 - 4*y^2*z + x*z^2]) - sage: f.primes_of_bad_reduction(False) + sage: f.primes_of_bad_reduction(False) # needs sage.rings.function_field [2, 5, 37, 2239, 304432717] - sage: f.primes_of_bad_reduction() + sage: f.primes_of_bad_reduction() # needs sage.rings.function_field [5, 37, 2239, 304432717] """ if (not is_ProjectiveSpace(self.domain())) or (not is_ProjectiveSpace(self.codomain())): @@ -1891,10 +1891,10 @@ def conjugate(self, M, adjugate=False, normalize=False): :: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field sage: P. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([x^3 + y^3, y^3]) - sage: f.conjugate(matrix([[i,0], [0,-i]])) + sage: f.conjugate(matrix([[i,0], [0,-i]])) # needs sage.rings.number_field Dynamical System of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (-x^3 + y^3 : -y^3) @@ -1920,10 +1920,10 @@ def conjugate(self, M, adjugate=False, normalize=False): :: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([1/3*x^2 + 1/2*y^2, y^2]) - sage: f.conjugate(matrix([[i,0], [0,-i]])) + sage: f.conjugate(matrix([[i,0], [0,-i]])) # needs sage.rings.number_field Dynamical System of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -2028,14 +2028,14 @@ def green_function(self, P, v, **kwds): :: - sage: K. = QuadraticField(3) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([17*x^2 + 1/7*y^2, 17*w*x*y]) - sage: f.green_function(P.point([w, 2], False), K.places()[1]) + sage: K. = QuadraticField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([17*x^2 + 1/7*y^2, 17*w*x*y]) # needs sage.rings.number_field + sage: f.green_function(P.point([w, 2], False), K.places()[1]) # needs sage.rings.number_field 1.7236334013785676107373093775 - sage: f.green_function(P([2, 1]), K.ideal(7), N=7) + sage: f.green_function(P([2, 1]), K.ideal(7), N=7) # needs sage.rings.number_field 0.48647753726382832627633818586 - sage: f.green_function(P([w, 1]), K.ideal(17), error_bound=0.001) + sage: f.green_function(P([w, 1]), K.ideal(17), error_bound=0.001) # needs sage.rings.number_field -0.70813041039490996737374178059 :: @@ -2205,21 +2205,21 @@ def canonical_height(self, P, **kwds): sage: P. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, 2*x*y]); - sage: f.canonical_height(P.point([5,4]), error_bound=0.001) + sage: f.canonical_height(P.point([5,4]), error_bound=0.001) # needs sage.libs.pari 2.1970553519503404898926835324 - sage: f.canonical_height(P.point([2,1]), error_bound=0.001) + sage: f.canonical_height(P.point([2,1]), error_bound=0.001) # needs sage.libs.pari 1.0984430632822307984974382955 Notice that preperiodic points may not return exactly 0:: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^2 + X - 1) - sage: P. = ProjectiveSpace(K,1) + sage: K. = NumberField(X^2 + X - 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: Q = P.point([a,1]) - sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 + sage: Q = P.point([a,1]) # needs sage.rings.number_field + sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 # needs sage.rings.number_field 5.7364919788790160119266380480e-8 - sage: f.nth_iterate(Q, 2) == Q # but it is indeed preperiodic + sage: f.nth_iterate(Q, 2) == Q # but it is indeed preperiodic # needs sage.rings.number_field True :: @@ -2228,7 +2228,7 @@ def canonical_height(self, P, **kwds): sage: X = P.subscheme(x^2 - y^2); sage: f = DynamicalSystem_projective([x^2, y^2, 4*z^2], domain=X); sage: Q = X([4,4,1]) - sage: f.canonical_height(Q, badprimes=[2]) + sage: f.canonical_height(Q, badprimes=[2]) # needs sage.rings.function_field 0.0013538030870311431824555314882 :: @@ -2237,7 +2237,7 @@ def canonical_height(self, P, **kwds): sage: X = P.subscheme(x^2 - y^2); sage: f = DynamicalSystem_projective([x^2, y^2, 30*z^2], domain=X) sage: Q = X([4, 4, 1]) - sage: f.canonical_height(Q, badprimes=[2,3,5], prec=200) + sage: f.canonical_height(Q, badprimes=[2,3,5], prec=200) # needs sage.rings.function_field 2.7054056208276961889784303469356774912979228770208655455481 :: @@ -2245,7 +2245,7 @@ def canonical_height(self, P, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([1000*x^2 - 29*y^2, 1000*y^2]) sage: Q = P(-1/4, 1) - sage: f.canonical_height(Q, error_bound=0.01) + sage: f.canonical_height(Q, error_bound=0.01) # needs sage.libs.pari 3.7996079979254623065837411853 :: @@ -2257,14 +2257,14 @@ def canonical_height(self, P, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([RSA768*x^2 + y^2, x*y]) sage: Q = P(RSA768,1) - sage: f.canonical_height(Q, error_bound=0.00000000000000001) + sage: f.canonical_height(Q, error_bound=0.00000000000000001) # needs sage.libs.pari 931.18256422718241278672729195 :: - sage: P.=ProjectiveSpace(QQ, 1) + sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([2*(-2*x^3 + 3*(x^2*y)) + 3*y^3, 3*y^3]) - sage: f.canonical_height(P(1,0)) + sage: f.canonical_height(P(1,0)) # needs sage.libs.pari 0.00000000000000000000000000000 """ bad_primes = kwds.get("badprimes", None) @@ -2418,36 +2418,36 @@ def height_difference_bound(self, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: f.height_difference_bound() + sage: f.height_difference_bound() # needs sage.symbolic 1.38629436111989 sage: P. = ProjectiveSpace(ZZ, 2) sage: f = DynamicalSystem_projective([4*x^2 + 100*y^2, 210*x*y, 10000*z^2]) - sage: f.height_difference_bound() + sage: f.height_difference_bound() # needs sage.symbolic 10.3089526606443 A number field example:: sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2) - sage: P. = ProjectiveSpace(K, 2) - sage: f = DynamicalSystem_projective([1/(c+1)*x^2 + c*y^2, 210*x*y, 10000*z^2]) - sage: f.height_difference_bound() + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([1/(c+1)*x^2 + c*y^2, 210*x*y, 10000*z^2]) # needs sage.rings.number_field + sage: f.height_difference_bound() # needs sage.rings.number_field sage.symbolic 11.3683039374269 :: - sage: P. = ProjectiveSpace(QQbar, 2) - sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, + sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, # needs sage.rings.number_field sage.symbolic ....: QQbar(sqrt(3))*z^2]) - sage: f.height_difference_bound() + sage: f.height_difference_bound() # needs sage.rings.number_field sage.symbolic 2.89037175789616 :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([5*x^2 + 3*x*y , y^2 + 3*x^2]) - sage: f.height_difference_bound(prec=100) + sage: f.height_difference_bound(prec=100) # needs sage.symbolic 5.3375380797013179737224159274 """ FF = FractionField(self.domain().base_ring()) #lift will only work over fields, so coercing into FF @@ -2532,9 +2532,9 @@ def multiplier(self, P, n, check=True): :: - sage: P. = ProjectiveSpace(Qp(13),1) + sage: P. = ProjectiveSpace(Qp(13),1) # needs sage.rings.padics sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) - sage: f.multiplier(P(5,4), 3) + sage: f.multiplier(P(5,4), 3) # needs sage.rings.padics [6 + 8*13 + 13^2 + 8*13^3 + 13^4 + 8*13^5 + 13^6 + 8*13^7 + 13^8 + 8*13^9 + 13^10 + 8*13^11 + 13^12 + 8*13^13 + 13^14 + 8*13^15 + 13^16 + 8*13^17 + 13^18 + 8*13^19 + O(13^20)] @@ -2765,7 +2765,7 @@ def nth_preimage_tree(self, Q, n, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: Q = P(0,1) - sage: f.nth_preimage_tree(Q, 2) # optional - sage.plot + sage: f.nth_preimage_tree(Q, 2) # needs sage.plot GraphPlot object for Digraph on 7 vertices :: @@ -2773,7 +2773,7 @@ def nth_preimage_tree(self, Q, n, **kwds): sage: P. = ProjectiveSpace(GF(3), 1) sage: f = DynamicalSystem_projective([x^2 + x*y + y^2, y^2]) sage: Q = P(0,1) - sage: f.nth_preimage_tree(Q, 2, return_points=True) # optional - sage.plot + sage: f.nth_preimage_tree(Q, 2, return_points=True) # needs sage.plot (GraphPlot object for Digraph on 4 vertices, [[(0 : 1)], [(1 : 1)], [(0 : 1), (2 : 1)]]) """ @@ -2874,20 +2874,20 @@ def possible_periods(self, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) - sage: f.possible_periods(ncpus=1) + sage: f.possible_periods(ncpus=1) # needs sage.rings.function_field [1, 3] :: sage: PS. = ProjectiveSpace(1,QQ) sage: f = DynamicalSystem_projective([5*x^3 - 53*x*y^2 + 24*y^3, 24*y^3]) - sage: f.possible_periods(prime_bound=[1,5]) + sage: f.possible_periods(prime_bound=[1,5]) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: no primes of good reduction in that range - sage: f.possible_periods(prime_bound=[1,10]) + sage: f.possible_periods(prime_bound=[1,10]) # needs sage.rings.function_field [1, 4, 12] - sage: f.possible_periods(prime_bound=[1,20]) + sage: f.possible_periods(prime_bound=[1,20]) # needs sage.rings.function_field [1, 4] :: @@ -2895,7 +2895,7 @@ def possible_periods(self, **kwds): sage: P. = ProjectiveSpace(ZZ,2) sage: f = DynamicalSystem_projective([2*x^3 - 50*x*z^2 + 24*z^3, ....: 5*y^3 - 53*y*z^2 + 24*z^3, 24*z^3]) - sage: f.possible_periods(prime_bound=10) + sage: f.possible_periods(prime_bound=10) # needs sage.rings.function_field [1, 2, 6, 20, 42, 60, 140, 420] sage: f.possible_periods(prime_bound=20) # long time [1, 20] @@ -2974,7 +2974,7 @@ def _preperiodic_points_to_cyclegraph(self, preper): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: preper = [P(-2, 1), P(1, 0), P(0, 1), P(1, 1), P(2, 1), P(-1, 1)] - sage: f._preperiodic_points_to_cyclegraph(preper) + sage: f._preperiodic_points_to_cyclegraph(preper) # needs sage.graphs Looped digraph on 6 vertices """ V = [] @@ -3018,21 +3018,21 @@ def is_PGL_minimal(self, prime_list=None): sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([X^2 + 3*Y^2, X*Y]) - sage: f.is_PGL_minimal() + sage: f.is_PGL_minimal() # needs sage.rings.function_field True :: sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y]) - sage: f.is_PGL_minimal() + sage: f.is_PGL_minimal() # needs sage.rings.function_field False :: sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, y^2]) - sage: f.is_PGL_minimal() + sage: f.is_PGL_minimal() # needs sage.rings.function_field False """ if self.base_ring() != QQ and self.base_ring() != ZZ: @@ -3093,7 +3093,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([X^2 + 3*Y^2, X*Y]) - sage: f.minimal_model(return_transformation=True) + sage: f.minimal_model(return_transformation=True) # needs sage.rings.function_field ( Dynamical System of Projective Space of dimension 1 over Rational Field @@ -3111,7 +3111,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= ....: + 1146*X*Y^3 + 245/2*Y^4, ....: -12329/2*X^4 - 10506*X^3*Y - 6723*X^2*Y^2 ....: - 1914*X*Y^3 - 409/2*Y^4]) - sage: f.minimal_model(return_transformation=True) + sage: f.minimal_model(return_transformation=True) # needs sage.rings.function_field ( Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (X : Y) to @@ -3126,7 +3126,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y]) - sage: f.minimal_model() + sage: f.minimal_model() # needs sage.rings.function_field Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 + 12*x*y + 42*y^2 : 2*x*y) @@ -3135,7 +3135,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y + 42*y^2]) - sage: g,M = f.minimal_model(return_transformation=True, algorithm='BM') + sage: g,M = f.minimal_model(return_transformation=True, algorithm='BM') # needs sage.rings.function_field sage: f.conjugate(M) == g True @@ -3143,7 +3143,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([2*x^2, y^2]) - sage: f.minimal_model(return_transformation=True) + sage: f.minimal_model(return_transformation=True) # needs sage.rings.function_field ( Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to @@ -3151,7 +3151,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= [1 0] [0 2] ) - sage: f.minimal_model(prime_list=[3]) + sage: f.minimal_model(prime_list=[3]) # needs sage.rings.function_field Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (2*x^2 : y^2) @@ -3160,7 +3160,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([X + Y, X - 3*Y]) - sage: f.minimal_model() + sage: f.minimal_model() # needs sage.rings.function_field Traceback (most recent call last): ... NotImplementedError: minimality is only for degree 2 or higher @@ -3169,7 +3169,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([X^2 - Y^2, X^2 + X*Y]) - sage: f.minimal_model() + sage: f.minimal_model() # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: the function is not a morphism @@ -3178,7 +3178,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem([2*x^2, y^2]) - sage: f.minimal_model(algorithm='BM') + sage: f.minimal_model(algorithm='BM') # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: affine minimality is only considered for @@ -3188,7 +3188,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem([2*x^2, y^2]) - sage: f.minimal_model(prime_list=[0]) + sage: f.minimal_model(prime_list=[0]) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: prime_list contains 0 which is not prime @@ -3279,7 +3279,7 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([2*x^2, 3*y^2]) - sage: f.all_minimal_models() + sage: f.all_minimal_models() # needs sage.rings.function_field [Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)] @@ -3289,9 +3289,9 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, sage: P. = ProjectiveSpace(QQ, 1) sage: c = 2*3^6 sage: f = DynamicalSystem([x^3 - c^2*y^3, x*y^2]) - sage: len(f.all_minimal_models(algorithm='HS')) + sage: len(f.all_minimal_models(algorithm='HS')) # needs sage.rings.function_field 14 - sage: len(f.all_minimal_models(prime_list=[2], algorithm='HS')) + sage: len(f.all_minimal_models(prime_list=[2], algorithm='HS')) # needs sage.rings.function_field 2 :: @@ -3300,7 +3300,7 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, sage: f = DynamicalSystem([237568*x^3 + 1204224*x^2*y + 2032560*x*y^2 ....: + 1142289*y^3, -131072*x^3 - 663552*x^2*y - 1118464*x*y^2 ....: - 627664*y^3]) - sage: len(f.all_minimal_models(algorithm='BM')) + sage: len(f.all_minimal_models(algorithm='BM')) # needs sage.rings.function_field 2 TESTS:: @@ -3308,10 +3308,10 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, sage: P. = ProjectiveSpace(QQ, 1) sage: c = 2^2*5^2*11^3 sage: f = DynamicalSystem([x^3 - c^2*y^3, x*y^2]) - sage: MM = f.all_minimal_models(return_transformation=True, algorithm='BM') + sage: MM = f.all_minimal_models(return_transformation=True, algorithm='BM') # needs sage.rings.function_field sage: all(f.conjugate(m) == F for F, m in MM) True - sage: MM = f.all_minimal_models(return_transformation=True, algorithm='HS') + sage: MM = f.all_minimal_models(return_transformation=True, algorithm='HS') # needs sage.rings.function_field sage: all(f.conjugate(m) == F for F,m in MM) True @@ -3392,7 +3392,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: g = f.affine_preperiodic_model(0, 1); g + sage: g = f.affine_preperiodic_model(0, 1); g # needs sage.rings.function_field Dynamical System of Projective Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (-x^2 : -2*x^2 + 2*x*y - y^2 : 2*x^2 - 2*x*y + 2*y^2 + 2*y*z + z^2) @@ -3410,9 +3410,9 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): :: - sage: P. = ProjectiveSpace(GF(9), 2) + sage: P. = ProjectiveSpace(GF(9), 2) # needs sage.rings.finite_rings sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: f.affine_preperiodic_model(0, 1) + sage: f.affine_preperiodic_model(0, 1) # needs sage.rings.finite_rings sage.rings.function_field Dynamical System of Projective Space of dimension 2 over Finite Field in z2 of size 3^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -3433,10 +3433,10 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): :: - sage: K. = CyclotomicField(3) - sage: P. = ProjectiveSpace(K, 2) - sage: f = DynamicalSystem_projective([x^2 + k*x*y + y^2, z^2, y^2]) - sage: f.affine_preperiodic_model(1, 1) + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + k*x*y + y^2, z^2, y^2]) # needs sage.rings.number_field + sage: f.affine_preperiodic_model(1, 1) # needs sage.rings.function_field sage.rings.number_field Dynamical System of Projective Space of dimension 2 over Cyclotomic Field of order 3 and degree 2 Defn: Defined on coordinates by sending (x : y : z) to @@ -3446,7 +3446,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) + sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) # needs sage.rings.function_field sage: g == f.conjugate(mat) True @@ -3455,7 +3455,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(2*y - z) sage: f = DynamicalSystem_projective([x^2 + y^2, z^2 + y^2, z^2], domain=X) - sage: f.affine_preperiodic_model(0, 1) + sage: f.affine_preperiodic_model(0, 1) # needs sage.rings.function_field Dynamical System of Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 2*y - z Defn: Defined on coordinates by sending (x : y : z) to @@ -3465,7 +3465,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, x^2]) - sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) + sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) # needs sage.rings.function_field sage: f.conjugate(mat) == g True """ @@ -3604,14 +3604,14 @@ def automorphism_group(self, **kwds): sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) - sage: f.automorphism_group(return_functions=True) + sage: f.automorphism_group(return_functions=True) # needs sage.libs.pari [x, -x] :: sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + 5*x*y + 5*y^2, 5*x^2 + 5*x*y + y^2]) - sage: f.automorphism_group() + sage: f.automorphism_group() # needs sage.libs.pari [ [1 0] [0 2] [0 1], [2 0] @@ -3621,21 +3621,21 @@ def automorphism_group(self, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem([x^3, y^3, z^3]) - sage: len(f.automorphism_group()) + sage: len(f.automorphism_group()) # needs sage.rings.function_field 24 :: sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 2*x*y - 2*y^2, -2*x^2 - 2*x*y + y^2]) - sage: f.automorphism_group(return_functions=True) + sage: f.automorphism_group(return_functions=True) # needs sage.libs.pari [x, 1/x, -x - 1, -x/(x + 1), (-x - 1)/x, -1/(x + 1)] :: sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([3*x^2*y - y^3, x^3 - 3*x*y^2]) - sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, + sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, # needs sage.libs.pari ....: iso_type=True) sage: sorted(lst), label ([-1/x, 1/x, (-x - 1)/(x - 1), (-x + 1)/(x + 1), (x - 1)/(x + 1), @@ -3647,7 +3647,7 @@ def automorphism_group(self, **kwds): sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([1/z^3]) sage: F = f.homogenize(1) - sage: F.automorphism_group() + sage: F.automorphism_group() # needs sage.libs.pari [ [1 0] [0 2] [-1 0] [ 0 -2] [0 1], [2 0], [ 0 1], [ 2 0] @@ -3657,7 +3657,7 @@ def automorphism_group(self, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x**2 + x*z, y**2, z**2]) - sage: f.automorphism_group() + sage: f.automorphism_group() # needs sage.rings.function_field [ [1 0 0] [0 1 0] @@ -3666,10 +3666,10 @@ def automorphism_group(self, **kwds): :: - sage: K. = CyclotomicField(3) - sage: P. = ProjectiveSpace(K, 1) - sage: D6 = DynamicalSystem_projective([y^2, x^2]) - sage: sorted(D6.automorphism_group()) + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: D6 = DynamicalSystem_projective([y^2, x^2]) # needs sage.rings.number_field + sage: sorted(D6.automorphism_group()) # needs sage.rings.number_field [ [-w - 1 0] [ 0 -w - 1] [w 0] [0 w] [0 1] [1 0] [ 0 1], [ 1 0], [0 1], [1 0], [1 0], [0 1] @@ -3712,7 +3712,7 @@ def critical_subscheme(self): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) - sage: f.critical_subscheme() + sage: f.critical_subscheme() # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: 9*x^2*y^2 - 6*y^4 @@ -3722,7 +3722,7 @@ def critical_subscheme(self): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y]) - sage: f.critical_subscheme() + sage: f.critical_subscheme() # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: 4*x^2 + 2*y^2 @@ -3731,16 +3731,16 @@ def critical_subscheme(self): sage: P. = ProjectiveSpace(QQ,2) sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y, z^2]) - sage: f.critical_subscheme() + sage: f.critical_subscheme() # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 8*x^2*z + 4*y^2*z :: - sage: P. = ProjectiveSpace(GF(81), 3) - sage: g = DynamicalSystem_projective([x^3 + y^3, y^3 + z^3, z^3 + x^3, w^3]) - sage: g.critical_subscheme() + sage: P. = ProjectiveSpace(GF(81), 3) # needs sage.rings.finite_rings + sage: g = DynamicalSystem_projective([x^3 + y^3, y^3 + z^3, z^3 + x^3, w^3]) # needs sage.rings.finite_rings + sage: g.critical_subscheme() # needs sage.rings.finite_rings Closed subscheme of Projective Space of dimension 3 over Finite Field in z4 of size 3^4 defined by: 0 @@ -3749,7 +3749,7 @@ def critical_subscheme(self): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2, x*y]) - sage: f.critical_subscheme() + sage: f.critical_subscheme() # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: the function is not a morphism @@ -3781,9 +3781,9 @@ def critical_points(self, R=None): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) - sage: f.critical_points() + sage: f.critical_points() # needs sage.rings.function_field [(1 : 0)] - sage: K. = QuadraticField(6) + sage: K. = QuadraticField(6) # needs sage.rings.number_field sage: f.critical_points(K) [(-1/3*w : 1), (1/3*w : 1), (1 : 0)] @@ -3792,7 +3792,7 @@ def critical_points(self, R=None): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y]) - sage: f.critical_points(QQbar) + sage: f.critical_points(QQbar) # needs sage.rings.number_field [(-0.7071067811865475?*I : 1), (0.7071067811865475?*I : 1)] """ PS = self.domain() @@ -3838,28 +3838,28 @@ def ramification_type(self, R=None, stable=True): sage: P. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem_projective([x^4, y^4]) - sage: F.ramification_type() + sage: F.ramification_type() # needs sage.rings.number_field [[4], [4]] sage: P. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem_projective([x^3, 4*y^3 - 3*x^2*y]) - sage: F.ramification_type() + sage: F.ramification_type() # needs sage.rings.number_field [[2], [2], [3]] sage: P. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem_projective([(x + y)^4, 16*x*y*(x-y)^2]) - sage: F.ramification_type() + sage: F.ramification_type() # needs sage.rings.number_field [[2], [2, 2], [4]] sage: P. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem_projective([(x + y)*(x - y)^3, y*(2*x+y)^3]) - sage: F.ramification_type() + sage: F.ramification_type() # needs sage.rings.number_field [[3], [3], [3]] sage: F = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) - sage: F.ramification_type() + sage: F.ramification_type() # needs sage.rings.number_field [[2], [2], [3]] - sage: F.ramification_type(R=F.base_ring()) + sage: F.ramification_type(R=F.base_ring()) # needs sage.rings.function_field [[2], [3]] """ @@ -3910,20 +3910,20 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.is_postcritically_finite() + sage: f.is_postcritically_finite() # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3- y^3, y^3]) - sage: f.is_postcritically_finite() + sage: f = DynamicalSystem_projective([x^3 - y^3, y^3]) + sage: f.is_postcritically_finite() # needs sage.rings.number_field False :: sage: R. = QQ[] - sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) + sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) # needs sage.rings.number_field sage: PS. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) sage: f.is_postcritically_finite() # long time @@ -3934,15 +3934,15 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([6*x^2 + 16*x*y + 16*y^2, ....: -3*x^2 - 4*x*y - 4*y^2]) - sage: f.is_postcritically_finite() + sage: f.is_postcritically_finite() # needs sage.rings.number_field True :: - sage: K = UniversalCyclotomicField() - sage: P. = ProjectiveSpace(K,1) + sage: K = UniversalCyclotomicField() # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field sage: F = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) - sage: F.is_postcritically_finite() + sage: F.is_postcritically_finite() # needs sage.rings.number_field True :: @@ -3956,14 +3956,14 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^4 - x^2*y^2 + y^4, y^4]) - sage: f.is_postcritically_finite(use_algebraic_closure=False) + sage: f.is_postcritically_finite(use_algebraic_closure=False) # needs sage.rings.number_field False :: - sage: P. = ProjectiveSpace(QQbar,1) + sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^4 - x^2*y^2, y^4]) - sage: f.is_postcritically_finite() + sage: f.is_postcritically_finite() # needs sage.rings.number_field False """ #iteration of subschemes not yet implemented @@ -4009,52 +4009,52 @@ def is_dynamical_belyi_map(self): sage: P.=ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([-2*x^3 - 9*x^2*y - 12*x*y^2 - 6*y^3, y^3]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([5*x^7 - 7*x^6*y, -7*x*y^6 + 5*y^7]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field False :: - sage: F = QuadraticField(-7) - sage: P. = ProjectiveSpace(F, 1) + sage: F = QuadraticField(-7) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(F, 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([5*x^7 - 7*x^6*y, -7*x*y^6 + 5*y^7]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([2*x^3 + 3*x^2*y - 3*x*y^2 + 2*y^3, x^3 + y^3]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field False :: sage: R. = PolynomialRing(QQ) - sage: N. = NumberField(t^3 - 2) - sage: P. = ProjectiveSpace(N, 1) - sage: f=DynamicalSystem_projective([x^2 + c*y^2, x*y]) - sage: f.is_dynamical_belyi_map() + sage: N. = NumberField(t^3 - 2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(N, 1) # needs sage.rings.number_field + sage: f=DynamicalSystem_projective([x^2 + c*y^2, x*y]) # needs sage.rings.number_field + sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field False :: sage: P. = ProjectiveSpace(GF(7), 1) sage: f = DynamicalSystem_projective([x^3 + 6*y^3, y^3]) - sage: f.is_dynamical_belyi_map() + sage: f.is_dynamical_belyi_map() # needs sage.libs.pari False """ P = self.codomain() @@ -4098,24 +4098,24 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): EXAMPLES:: sage: R. = QQ[] - sage: K. = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) - sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) - sage: f.critical_point_portrait(check=False) # long time + sage: K. = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) # needs sage.rings.number_field + sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) # needs sage.rings.number_field + sage: f.critical_point_portrait(check=False) # long time # needs sage.graphs sage.rings.number_field Looped digraph on 6 vertices :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5]) - sage: f.critical_point_portrait(check=False) + sage: f.critical_point_portrait(check=False) # needs sage.graphs sage.rings.number_field Looped digraph on 5 vertices :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, y^2]) - sage: f.critical_point_portrait() + sage: f.critical_point_portrait() # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: map must be post-critically finite @@ -4123,11 +4123,11 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): :: sage: R. = QQ[] - sage: K. = NumberField(t^3 + 2*t^2 + t + 1) - sage: phi = K.embeddings(QQbar)[0] - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) - sage: f.change_ring(phi).critical_point_portrait() + sage: K. = NumberField(t^3 + 2*t^2 + t + 1) # needs sage.rings.number_field + sage: phi = K.embeddings(QQbar)[0] # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) # needs sage.rings.number_field + sage: f.change_ring(phi).critical_point_portrait() # needs sage.graphs sage.rings.number_field Looped digraph on 4 vertices :: @@ -4139,16 +4139,16 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): :: - sage: P. = ProjectiveSpace(QQbar,1) + sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([8*x^4 - 8*x^2*y^2 + y^4, y^4]) - sage: f.critical_point_portrait() #long time + sage: f.critical_point_portrait() # long time # needs sage.graphs sage.rings.number_field Looped digraph on 6 vertices :: sage: P. = ProjectiveSpace(GF(3),1) sage: f = DynamicalSystem_projective([x^2 + x*y - y^2, x*y]) - sage: f.critical_point_portrait(use_algebraic_closure=False) + sage: f.critical_point_portrait(use_algebraic_closure=False) # needs sage.libs.pari Looped digraph on 6 vertices sage: f.critical_point_portrait() #long time Looped digraph on 6 vertices @@ -4222,31 +4222,31 @@ def critical_height(self, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 + 7*y^3, 11*y^3]) - sage: f.critical_height() + sage: f.critical_height() # needs sage.rings.number_field 1.1989273321156851418802151128 :: - sage: K. = QuadraticField(2) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2 + w*y^2, y^2]) - sage: f.critical_height() + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + w*y^2, y^2]) # needs sage.rings.number_field + sage: f.critical_height() # needs sage.rings.number_field 0.16090842452312941163719755472 Postcritically finite maps have critical height 0:: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 - 3/4*x*y^2 + 3/4*y^3, y^3]) - sage: f.critical_height(error_bound=0.0001) + sage: f.critical_height(error_bound=0.0001) # needs sage.rings.number_field 0.00000000000000000000000000000 :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 + 3*x*y^2, y^3]) - sage: f.critical_height(use_algebraic_closure=False) + sage: f.critical_height(use_algebraic_closure=False) # needs sage.rings.number_field 0.000023477016733897112886491967991 - sage: f.critical_height() + sage: f.critical_height() # needs sage.rings.number_field 0.000023477016733897112886491967991 """ PS = self.codomain() @@ -4321,30 +4321,30 @@ def preperiodic_points(self, m, n, **kwds): EXAMPLES:: - sage: P. = ProjectiveSpace(QQbar, 1) - sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.preperiodic_points(0, 1) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) # needs sage.rings.number_field + sage: f.preperiodic_points(0, 1) # needs sage.rings.number_field [(-0.618033988749895? : 1), (1 : 0), (1.618033988749895? : 1)] :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) - sage: f.preperiodic_points(1, 3) + sage: f.preperiodic_points(1, 3) # needs sage.rings.function_field [(-5/4 : 1), (1/4 : 1), (7/4 : 1)] :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2 , z^2]) - sage: f.preperiodic_points(0, 2, formal=True) + sage: f.preperiodic_points(0, 2, formal=True) # needs sage.rings.function_field [(-1/2 : 1 : 0), (-1/2 : 1 : 1)] :: - sage: P. = ProjectiveSpace(QQbar, 1) - sage: f = DynamicalSystem_projective([x^2 - x*y + 2*y^2, x^2 - y^2]) - sage: f.preperiodic_points(1, 2, minimal=False) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - x*y + 2*y^2, x^2 - y^2]) # needs sage.rings.number_field + sage: f.preperiodic_points(1, 2, minimal=False) # needs sage.rings.function_field sage.rings.number_field [(-3.133185666641252? : 1), (-1 : 1), (-0.3478103847799310? - 1.028852254136693?*I : 1), @@ -4359,10 +4359,10 @@ def preperiodic_points(self, m, n, **kwds): :: sage: R. = QQ[] - sage: K. = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1) - sage: P. = ProjectiveSpace(K, 2) + sage: K. = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 + z^2, y^2 + x^2, z^2 + y^2]) - sage: sorted(f.preperiodic_points(0, 1), key=str) + sage: sorted(f.preperiodic_points(0, 1), key=str) # needs sage.rings.function_field sage.rings.number_field [(-2*s^5 + 4*s^4 - 5*s^3 + 3*s^2 - 4*s : -2*s^5 + 5*s^4 - 7*s^3 + 6*s^2 - 7*s + 3 : 1), (-s^5 + 3*s^4 - 4*s^3 + 4*s^2 - 4*s + 2 : -s^5 + 2*s^4 - 2*s^3 + s^2 - s : 1), (-s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 3*s + 1 : s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 4*s - 1 : 1), @@ -4382,13 +4382,13 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) - sage: f.preperiodic_points(0, 2, formal=True) + sage: f.preperiodic_points(0, 2, formal=True) # needs sage.libs.pari [(-1/2 : 1)] :: sage: P. = ProjectiveSpace(QQ, 1) - sage: K. = QuadraticField(5) + sage: K. = QuadraticField(5) # needs sage.rings.number_field sage: phi = QQ.embeddings(K)[0] sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: f.preperiodic_points(1, 1, R=phi) @@ -4400,14 +4400,14 @@ def preperiodic_points(self, m, n, **kwds): sage: X = P.subscheme(2*x - y) sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], ....: domain=X) - sage: f.preperiodic_points(1, 1) + sage: f.preperiodic_points(1, 1) # needs sage.rings.function_field [(-1/4 : -1/2 : 1), (1 : 2 : 1)] :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, z^2, y^2]) - sage: f.preperiodic_points(1, 1) + sage: f.preperiodic_points(1, 1) # needs sage.rings.function_field [(-3/2 : -1 : 1), (-3/2 : 1 : 1), (-1/2 : -1 : 1), (1/2 : -1 : 1), (1/2 : 1 : 1), (3/2 : -1 : 1)] @@ -4415,7 +4415,7 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(GF(5), 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: sorted(f.preperiodic_points(2, 1)) + sage: sorted(f.preperiodic_points(2, 1)) # needs sage.rings.function_field [(0 : 2 : 1), (0 : 3 : 1), (1 : 2 : 1), (1 : 3 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 2 : 1), (4 : 3 : 1)] @@ -4437,7 +4437,7 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: R. = QQ[] - sage: K. = NumberField(z^4 - z^2 - 1) + sage: K. = NumberField(z^4 - z^2 - 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: sorted(f.preperiodic_points(2, 1, R=K), key=str) [(-v : 1), (v : 1)] @@ -4446,7 +4446,7 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2, z^2]) - sage: f.preperiodic_points(0, 2, formal=True) + sage: f.preperiodic_points(0, 2, formal=True) # needs sage.rings.function_field [(-1/2 : 1 : 0), (-1/2 : 1 : 1)] :: @@ -4455,7 +4455,7 @@ def preperiodic_points(self, m, n, **kwds): sage: R. = PolynomialRing(S, 2) sage: P = ProjectiveSpace(R) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.preperiodic_points(1, 2, return_scheme=True) + sage: f.preperiodic_points(1, 2, return_scheme=True) # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 1 over Univariate Polynomial Ring in c over Rational Field defined by: x^2 - x*y + (c + 1)*y^2 @@ -4464,7 +4464,7 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, x*y, z^2]) - sage: f.preperiodic_points(2, 1, minimal=False) + sage: f.preperiodic_points(2, 1, minimal=False) # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: use return_scheme=True @@ -4486,14 +4486,14 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem([x^2 - z^2, y^2 - 21/16*z^2, z^2]) - sage: len(f.preperiodic_points(1, 2, minimal=True, formal=False)) == 16 + sage: len(f.preperiodic_points(1, 2, minimal=True, formal=False)) == 16 # needs sage.rings.function_field True :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2]) - sage: f.preperiodic_points(2, 2) + sage: f.preperiodic_points(2, 2) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: dynamical system is not a morphism, @@ -4662,18 +4662,18 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari EXAMPLES:: sage: set_verbose(None) - sage: P. = ProjectiveSpace(QQbar, 1) - sage: f = DynamicalSystem_projective([x^2 - x*y + y^2, x^2 - y^2 + x*y]) - sage: f.periodic_points(1) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - x*y + y^2, x^2 - y^2 + x*y]) # needs sage.rings.number_field + sage: f.periodic_points(1) # needs sage.rings.number_field [(-0.50000000000000000? - 0.866025403784439?*I : 1), (-0.50000000000000000? + 0.866025403784439?*I : 1), (1 : 1)] :: - sage: P. = ProjectiveSpace(QuadraticField(5,'t'), 2) - sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - z^2, z^2]) - sage: f.periodic_points(2) + sage: P. = ProjectiveSpace(QuadraticField(5,'t'), 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - z^2, z^2]) # needs sage.rings.number_field + sage: f.periodic_points(2) # needs sage.rings.number_field [(-5/4 : -1 : 1), (-5/4 : -1/2*t + 1/2 : 1), (-5/4 : 0 : 1), (-5/4 : 1/2*t + 1/2 : 1), (-3/4 : -1 : 1), (-3/4 : 0 : 1), (1/4 : -1 : 1), (1/4 : -1/2*t + 1/2 : 1), (1/4 : 0 : 1), @@ -4683,16 +4683,16 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2 , z^2]) - sage: f.periodic_points(2, formal=True) + sage: f.periodic_points(2, formal=True) # needs sage.rings.function_field [(-1/2 : 1 : 0), (-1/2 : 1 : 1)] :: sage: w = QQ['w'].0 - sage: K = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1,'s') - sage: P. = ProjectiveSpace(K, 2) + sage: K = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1,'s') # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 + z^2, y^2 + x^2, z^2 + y^2]) - sage: sorted(f.periodic_points(1), key=str) + sage: sorted(f.periodic_points(1), key=str) # needs sage.rings.function_field sage.rings.number_field [(-2*s^5 + 4*s^4 - 5*s^3 + 3*s^2 - 4*s : -2*s^5 + 5*s^4 - 7*s^3 + 6*s^2 - 7*s + 3 : 1), (-s^5 + 3*s^4 - 4*s^3 + 4*s^2 - 4*s + 2 : -s^5 + 2*s^4 - 2*s^3 + s^2 - s : 1), (-s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 3*s + 1 : s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 4*s - 1 : 1), @@ -4705,7 +4705,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - 2*z^2, z^2]) - sage: f.periodic_points(2, False) + sage: f.periodic_points(2, False) # needs sage.rings.function_field [(-5/4 : -1 : 1), (-5/4 : 2 : 1), (-3/4 : -1 : 1), (-3/4 : 2 : 1), (0 : 1 : 0), (1/4 : -1 : 1), (1/4 : 2 : 1), (1 : 0 : 0), (1 : 1 : 0), (7/4 : -1 : 1), (7/4 : 2 : 1)] @@ -4714,7 +4714,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - 2*z^2, z^2]) - sage: f.periodic_points(2) + sage: f.periodic_points(2) # needs sage.rings.function_field [(-5/4 : -1 : 1), (-5/4 : 2 : 1), (1/4 : -1 : 1), (1/4 : 2 : 1)] :: @@ -4722,7 +4722,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: set_verbose(None) sage: P. = ProjectiveSpace(ZZ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.periodic_points(2, R=QQbar, minimal=False) + sage: f.periodic_points(2, R=QQbar, minimal=False) # needs sage.rings.number_field [(-0.50000000000000000? - 1.322875655532296?*I : 1), (-0.50000000000000000? + 1.322875655532296?*I : 1), (0.50000000000000000? - 0.866025403784439?*I : 1), @@ -4733,23 +4733,23 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - 3/4*z^2, y^2 - 3/4*z^2, z^2]) - sage: f.periodic_points(2, formal=True) + sage: f.periodic_points(2, formal=True) # needs sage.rings.function_field [(-1/2 : -1/2 : 1), (-1/2 : 3/2 : 1), (3/2 : -1/2 : 1)] :: sage: P. = ProjectiveSpace(GF(307), 1) sage: f = DynamicalSystem_projective([x^10 + y^10, y^10]) - sage: f.periodic_points(16, minimal=True, algorithm='cyclegraph') + sage: f.periodic_points(16, minimal=True, algorithm='cyclegraph') # needs sage.graphs [(69 : 1), (185 : 1), (120 : 1), (136 : 1), (97 : 1), (183 : 1), (170 : 1), (105 : 1), (274 : 1), (275 : 1), (154 : 1), (156 : 1), (87 : 1), (95 : 1), (161 : 1), (128 : 1)] :: - sage: P. = ProjectiveSpace(GF(13^2, 't'), 1) + sage: P. = ProjectiveSpace(GF(13^2, 't'), 1) # needs sage.rings.finite_rings sage: f = DynamicalSystem_projective([x^3 + 3*y^3, x^2*y]) - sage: f.periodic_points(30, minimal=True, algorithm='cyclegraph') + sage: f.periodic_points(30, minimal=True, algorithm='cyclegraph') # needs sage.graphs sage.rings.finite_rings [(t + 3 : 1), (6*t + 6 : 1), (7*t + 1 : 1), (2*t + 8 : 1), (3*t + 4 : 1), (10*t + 12 : 1), (8*t + 10 : 1), (5*t + 11 : 1), (7*t + 4 : 1), (4*t + 8 : 1), (9*t + 1 : 1), (2*t + 2 : 1), @@ -4763,16 +4763,16 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([3*x^2 + 5*y^2, y^2]) - sage: f.periodic_points(2, R=GF(3), minimal=False) + sage: f.periodic_points(2, R=GF(3), minimal=False) # needs sage.rings.function_field [(2 : 1)] - sage: f.periodic_points(2, R=GF(7)) + sage: f.periodic_points(2, R=GF(7)) # needs sage.rings.function_field [] :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, x*y, z^2]) - sage: f.periodic_points(1) + sage: f.periodic_points(1) # needs sage.rings.function_field Traceback (most recent call last): ... TypeError: use return_scheme=True @@ -4780,19 +4780,19 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari :: sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 3) - sage: P. = ProjectiveSpace(K, 2) + sage: K. = NumberField(x^2 - x + 3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field sage: X = P.subscheme(2*x - y) sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], ....: domain=X) - sage: f.periodic_points(2) + sage: f.periodic_points(2) # needs sage.rings.function_field sage.rings.number_field [(-1/5*u - 1/5 : -2/5*u - 2/5 : 1), (1/5*u - 2/5 : 2/5*u - 4/5 : 1)] :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - y^2, x^2 - z^2, y^2 - z^2]) - sage: f.periodic_points(1) + sage: f.periodic_points(1) # needs sage.rings.function_field [(-1 : 0 : 1)] sage: f.periodic_points(1, return_scheme=True) Closed subscheme of Projective Space of dimension 2 over Rational Field @@ -4805,7 +4805,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P.=ProjectiveSpace(GF(3), 1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: f.periodic_points(2, R=GF(3^2,'t')) + sage: f.periodic_points(2, R=GF(3^2,'t')) # needs sage.rings.finite_rings [(t + 2 : 1), (2*t : 1)] :: @@ -4814,7 +4814,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: R. = PolynomialRing(S, 2) sage: P = ProjectiveSpace(R) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.periodic_points(2, return_scheme=True) + sage: f.periodic_points(2, return_scheme=True) # needs sage.rings.function_field Closed subscheme of Projective Space of dimension 1 over Univariate Polynomial Ring in c over Rational Field defined by: x^2 + x*y + (c + 1)*y^2 @@ -4831,7 +4831,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2]) - sage: f.periodic_points(2, minimal=True) + sage: f.periodic_points(2, minimal=True) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: dynamical system is not a morphism, cannot calculate minimal or formal periodic points @@ -5012,16 +5012,16 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) - sage: sorted(f.multiplier_spectra(2, type='point')) + sage: sorted(f.multiplier_spectra(2, type='point')) # needs sage.rings.number_field [0, 1, 1, 1, 9] - sage: sorted(f.multiplier_spectra(2, type='cycle')) + sage: sorted(f.multiplier_spectra(2, type='cycle')) # needs sage.rings.number_field [0, 1, 1, 9] :: sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, z^2, y^2]) - sage: f.multiplier_spectra(1) + sage: f.multiplier_spectra(1) # needs sage.rings.number_field [ [ 2 1 - 1.732050807568878?*I] [ 0 -2], @@ -5047,10 +5047,10 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: set_verbose(None) sage: z = QQ['z'].0 - sage: K. = NumberField(z^4 - 4*z^2 + 1,'z') - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 - w/4*y^2, y^2]) - sage: sorted(f.multiplier_spectra(2, formal=False, type='cycle')) + sage: K. = NumberField(z^4 - 4*z^2 + 1,'z') # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - w/4*y^2, y^2]) # needs sage.rings.number_field + sage: sorted(f.multiplier_spectra(2, formal=False, type='cycle')) # needs sage.rings.number_field [0, 0.0681483474218635? - 1.930649271699173?*I, 0.0681483474218635? + 1.930649271699173?*I, @@ -5064,7 +5064,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur ....: + 2317935971590902*x^4*y^6 - 15344764859590852*x^3*y^7 ....: + 2561851642765275*x^2*y^8 + 113578270285012470*x*y^9 ....: - 150049940203963800*y^10, 4608*y^10]) - sage: sorted(f.multiplier_spectra(1)) + sage: sorted(f.multiplier_spectra(1)) # needs sage.rings.number_field [-119820502365680843999, -7198147681176255644585/256, -3086380435599991/9, @@ -5081,22 +5081,22 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 7/4*y^2, y^2]) - sage: f.multiplier_spectra(3, formal=True, type='cycle') + sage: f.multiplier_spectra(3, formal=True, type='cycle') # needs sage.rings.number_field [1, 1] - sage: f.multiplier_spectra(3, formal=True, type='point') + sage: f.multiplier_spectra(3, formal=True, type='point') # needs sage.rings.number_field [1, 1, 1, 1, 1, 1] :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^4 + 3*y^4, 4*x^2*y^2]) - sage: f.multiplier_spectra(1, use_algebraic_closure=False) + sage: f.multiplier_spectra(1, use_algebraic_closure=False) # needs sage.rings.number_field [0, -1, 1/128*a^5 - 13/384*a^4 + 5/96*a^3 + 1/16*a^2 + 43/128*a + 303/128, -1/288*a^5 + 1/96*a^4 + 1/24*a^3 - 1/3*a^2 + 5/32*a - 115/32, -5/1152*a^5 + 3/128*a^4 - 3/32*a^3 + 13/48*a^2 - 63/128*a - 227/128] - sage: f.multiplier_spectra(1) + sage: f.multiplier_spectra(1) # needs sage.rings.number_field [0, -1, 1.951373035591442?, @@ -5107,16 +5107,16 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(GF(5), 1) sage: f = DynamicalSystem_projective([x^4 + 2*y^4, 4*x^2*y^2]) - sage: f.multiplier_spectra(1, use_algebraic_closure=False) + sage: f.multiplier_spectra(1, use_algebraic_closure=False) # needs sage.rings.finite_rings [0, 3*a + 3, 2*a + 1, 1, 1] sage: f.multiplier_spectra(1) [0, 2*z2 + 1, 3*z2 + 3, 1, 1] :: - sage: P. = ProjectiveSpace(QQbar, 1) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^5 + 3*y^5, 4*x^3*y^2]) - sage: f.multiplier_spectra(1) + sage: f.multiplier_spectra(1) # needs sage.rings.number_field [0, -4.106544657178796?, -7/4, @@ -5136,7 +5136,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: f.multiplier_spectra(1) + sage: f.multiplier_spectra(1) # needs sage.rings.number_field [1, 1, 1] :: @@ -5144,7 +5144,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: K = GF(3).algebraic_closure() sage: P. = ProjectiveSpace(K, 2) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, 4*x*y, z^2]) - sage: f.multiplier_spectra(1) + sage: f.multiplier_spectra(1) # needs sage.rings.number_field [ [0 0] [1 0] [1 0] [1 0] [2 0] [2 0] [2 0] [0 0], [0 0], [0 0], [0 0], [0 1], [0 1], [0 1] @@ -5153,7 +5153,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: sage: F. = GF(7) - sage: P.=ProjectiveSpace(F, 1) + sage: P. = ProjectiveSpace(F, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: sorted(f.multiplier_spectra(1)) [0, 3, 6] @@ -5162,16 +5162,16 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, z^2, y^2]) - sage: g = f.change_ring(QQbar) - sage: f.multiplier_spectra(1) == g.multiplier_spectra(1) # long time + sage: g = f.change_ring(QQbar) # needs sage.rings.number_field + sage: f.multiplier_spectra(1) == g.multiplier_spectra(1) # long time, needs sage.rings.number_field True :: - sage: K. = QuadraticField(5) - sage: P. = ProjectiveSpace(K, 2) - sage: f = DynamicalSystem_projective([x^2 + w*x*y + y^2, y^2, z^2]) - sage: f.multiplier_spectra(1) # long time + sage: K. = QuadraticField(5) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + w*x*y + y^2, y^2, z^2]) # needs sage.rings.number_field + sage: f.multiplier_spectra(1) # long time, needs sage.rings.number_field [ [1.000000000000000? - 1.572302755514847?*I 0] [1.000000000000000? - 1.572302755514847?*I 0.618033988749895? - 1.757887921270715?*I] @@ -5189,7 +5189,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, z^2, y^2]) - sage: f.multiplier_spectra(1, use_algebraic_closure=False) + sage: f.multiplier_spectra(1, use_algebraic_closure=False) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: failed to compute the full multiplier spectra. Try use_algebraic_closure=True @@ -5496,7 +5496,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + x*y + y^2, y^2 + x*y]) - sage: f.sigma_invariants(1) + sage: f.sigma_invariants(1) # needs sage.rings.number_field [3, 3, 1] If ``return_polynomial`` is ``True``, then following [Hutz2019]_ @@ -5513,7 +5513,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: w, t = poly.variables() sage: poly.specialization({w:0}).monic() t^3 - 2*t^2 + 8*t - sage: f.sigma_invariants(1) + sage: f.sigma_invariants(1) # needs sage.rings.number_field [2, 8, 0] For dynamical systems on `\mathbb{P}^N`, where `N > 1`, the full polynomial @@ -5556,35 +5556,35 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: set_verbose(None) sage: z = QQ['z'].0 - sage: K = NumberField(z^4 - 4*z^2 + 1, 'z') - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) - sage: f.sigma_invariants(2, formal=False, type='cycle') + sage: K = NumberField(z^4 - 4*z^2 + 1, 'z') # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=False, type='cycle') # needs sage.rings.number_field [13, 11, -25, 0] - sage: f.sigma_invariants(2, formal=False, type='point') + sage: f.sigma_invariants(2, formal=False, type='point') # needs sage.rings.number_field [12, -2, -36, 25, 0] check that infinity as part of a longer cycle is handled correctly:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([y^2, x^2]) - sage: f.sigma_invariants(2, type='cycle') + sage: f.sigma_invariants(2, type='cycle') # needs sage.rings.number_field [12, 48, 64, 0] - sage: f.sigma_invariants(2, type='point') + sage: f.sigma_invariants(2, type='point') # needs sage.rings.number_field [12, 48, 64, 0, 0] - sage: f.sigma_invariants(2, type='cycle', formal=True) + sage: f.sigma_invariants(2, type='cycle', formal=True) # needs sage.rings.number_field [0] - sage: f.sigma_invariants(2, type='point', formal=True) + sage: f.sigma_invariants(2, type='point', formal=True) # needs sage.rings.number_field [0, 0] :: - sage: K. = QuadraticField(3) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 - w*y^2, (1-w)*x*y]) - sage: f.sigma_invariants(2, formal=False, type='cycle') + sage: K. = QuadraticField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - w*y^2, (1-w)*x*y]) # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=False, type='cycle') # needs sage.rings.number_field [6*w + 21, 78*w + 159, 210*w + 367, 90*w + 156] - sage: f.sigma_invariants(2, formal=False, type='point') + sage: f.sigma_invariants(2, formal=False, type='point') # needs sage.rings.number_field [6*w + 24, 96*w + 222, 444*w + 844, 720*w + 1257, 270*w + 468] :: @@ -5592,7 +5592,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([512*x^5 - 378128*x^4*y + 76594292*x^3*y^2 ....: - 4570550136*x^2*y^3 - 2630045017*x*y^4 + 28193217129*y^5, 512*y^5]) - sage: f.sigma_invariants(1) + sage: f.sigma_invariants(1) # needs sage.rings.number_field [19575526074450617/1048576, -9078122048145044298567432325/2147483648, -2622661114909099878224381377917540931367/1099511627776, -2622661107937102104196133701280271632423/549755813888, @@ -5612,11 +5612,11 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: R. = QQ[] sage: Pc. = ProjectiveSpace(R, 1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.sigma_invariants(1) + sage: f.sigma_invariants(1) # needs sage.rings.number_field [2, 4*c, 0] - sage: f.sigma_invariants(2, formal=True, type='point') + sage: f.sigma_invariants(2, formal=True, type='point') # needs sage.rings.number_field [8*c + 8, 16*c^2 + 32*c + 16] - sage: f.sigma_invariants(2, formal=True, type='cycle') + sage: f.sigma_invariants(2, formal=True, type='cycle') # needs sage.rings.number_field [4*c + 4] :: @@ -5626,7 +5626,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: f = DynamicalSystem([x^2 + c*y^2, y^2]) sage: f.sigma_invariants(1, return_polynomial=True) w^3 + (-3)*w^2*t + 2*w^2 + 3*w*t^2 + (-4)*w*t + 4*c*w - t^3 + 2*t^2 + (-4*c)*t - sage: f.sigma_invariants(2, chow=True, formal=True, return_polynomial=True) + sage: f.sigma_invariants(2, chow=True, formal=True, return_polynomial=True) # needs sage.libs.pari w^2 + (-2)*w*t + (8*c + 8)*w + t^2 + (-8*c - 8)*t + 16*c^2 + 32*c + 16 :: @@ -5641,21 +5641,21 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([x^2 + 3*y^2, x*y]) - sage: f.sigma_invariants(1, deform = True, return_polynomial=True) + sage: f.sigma_invariants(1, deform=True, return_polynomial=True) # needs sage.rings.function_field w^3 - 3*w^2*t + 3*w^2 + 3*w*t^2 - 6*w*t + 3*w - t^3 + 3*t^2 - 3*t + 1 doubled fixed point:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) - sage: f.sigma_invariants(2, formal=True) + sage: f.sigma_invariants(2, formal=True) # needs sage.rings.number_field [2, 1] doubled 2 cycle:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) - sage: f.sigma_invariants(4, formal=False, type='cycle') + sage: f.sigma_invariants(4, formal=False, type='cycle') # needs sage.rings.number_field [170, 5195, 172700, 968615, 1439066, 638125, 0] TESTS:: @@ -5663,16 +5663,16 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: F. = FunctionField(GF(5)) sage: P. = ProjectiveSpace(F,1) sage: f = DynamicalSystem_projective([x^2 + (t/(t^2+1))*y^2, y^2], P) - sage: f.sigma_invariants(1) + sage: f.sigma_invariants(1) # needs sage.rings.number_field [2, 4*t/(t^2 + 1), 0] :: sage: R. = QQ[] - sage: N. = NumberField(w^2 + 1) - sage: P. = ProjectiveSpace(N, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: f.sigma_invariants(1, chow=True) == f.change_ring(QQ).sigma_invariants(1, chow=True) + sage: N. = NumberField(w^2 + 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(N, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.rings.number_field + sage: f.sigma_invariants(1, chow=True) == f.change_ring(QQ).sigma_invariants(1, chow=True) # needs sage.rings.number_field True :: @@ -6078,31 +6078,31 @@ def reduced_form(self, **kwds): :: sage: P. = ProjectiveSpace(RR, 1) - sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) # optional - sage.symbolic + sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) # needs sage.symbolic sage: m = matrix(RR, 2, 2, [1,12,0,1]) - sage: f = f.conjugate(m) # optional - sage.symbolic - sage: g, m = f.reduced_form(smallest_coeffs=False); m # optional - sage.symbolic + sage: f = f.conjugate(m) # needs sage.symbolic + sage: g, m = f.reduced_form(smallest_coeffs=False); m # needs sage.symbolic [ 1 -12] [ 0 1] :: sage: P. = ProjectiveSpace(CC, 1) - sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) # optional - sage.symbolic + sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) # needs sage.symbolic sage: m = matrix(CC, 2, 2, [1,12,0,1]) - sage: f = f.conjugate(m) # optional - sage.symbolic - sage: g, m = f.reduced_form(smallest_coeffs=False); m # optional - sage.symbolic + sage: f = f.conjugate(m) + sage: g, m = f.reduced_form(smallest_coeffs=False); m # needs sage.symbolic [ 1 -12] [ 0 1] :: - sage: K. = QuadraticField(2) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^3, w*y^3]) - sage: m = matrix(K, 2, 2, [1,12,0,1]) + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^3, w*y^3]) # needs sage.rings.number_field + sage: m = matrix(K, 2, 2, [1,12,0,1]) # needs sage.rings.number_field sage: f = f.conjugate(m) - sage: f.reduced_form(smallest_coeffs=False) + sage: f.reduced_form(smallest_coeffs=False) # needs sage.rings.number_field ( Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 2 with w = 1.414213562373095? @@ -6115,13 +6115,13 @@ def reduced_form(self, **kwds): :: sage: R. = QQ[] - sage: K. = NumberField(x^5 + x - 3, + sage: K. = NumberField(x^5 + x - 3, # needs sage.rings.number_field ....: embedding=(x^5 + x - 3).roots(ring=CC)[0][0]) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) - sage: m = matrix(K, 2, 2, [-12,1,1,0]) + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) # needs sage.rings.number_field + sage: m = matrix(K, 2, 2, [-12,1,1,0]) # needs sage.rings.number_field sage: f = f.conjugate(m) - sage: f.reduced_form(smallest_coeffs=False) + sage: f.reduced_form(smallest_coeffs=False) # needs sage.rings.number_field ( Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^5 + x - 3 with w = 1.132997565885066? @@ -6303,17 +6303,17 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) sage: Q = P(-1, 1) - sage: f._is_preperiodic(Q) + sage: f._is_preperiodic(Q) # needs sage.rings.function_field True Check that :trac:`23814` is fixed (works even if domain is not specified):: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^2 + X - 1) - sage: P. = ProjectiveSpace(K,1) + sage: K. = NumberField(X^2 + X - 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: Q = P.point([a,1]) - sage: Q.is_preperiodic(f) + sage: Q = P.point([a,1]) # needs sage.rings.number_field + sage: Q.is_preperiodic(f) # needs sage.rings.function_field sage.rings.number_field True :: @@ -6322,7 +6322,7 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): sage: X = P.subscheme(z) sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) sage: p = X((-1, 1, 0)) - sage: f._is_preperiodic(p, return_period=True) + sage: f._is_preperiodic(p, return_period=True) # needs sage.rings.function_field (0, 2) :: @@ -6331,7 +6331,7 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): sage: X = P.subscheme(x) sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) sage: p = X((0, 1, 0)) - sage: f._is_preperiodic(p, return_period=True) + sage: f._is_preperiodic(p, return_period=True) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: orbit of point leaves domain @@ -6339,12 +6339,12 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): :: sage: R. = QQ[] - sage: K. = NumberField(t^2 - t - 1) - sage: P. = ProjectiveSpace(K, 2) + sage: K. = NumberField(t^2 - t - 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field sage: X = P.subscheme(z) sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) - sage: p = X((-a + 1, 1, 0)) - sage: f._is_preperiodic(p) + sage: p = X((-a + 1, 1, 0)) # needs sage.rings.number_field + sage: f._is_preperiodic(p) # needs sage.rings.function_field sage.rings.number_field True """ codomain = self.codomain() @@ -6428,41 +6428,41 @@ def postcritical_set(self, check=True): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([x^3 - 3/2* x*y^2, y^3]) - sage: f.postcritical_set() + sage: f.postcritical_set() # needs sage.rings.number_field [(1/2*a : 1), (-1/2*a : 1), (1 : 0)] :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([3*x^3 - 9/2* x^2*y+y^3, y^3]) - sage: f.postcritical_set(check=False) + sage: f.postcritical_set(check=False) # needs sage.rings.number_field [(1 : 1), (-1/2 : 1), (1 : 0)] :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([-4*y^2, 9*x^2 - 12*x*y]) - sage: f.postcritical_set() + sage: f.postcritical_set() # needs sage.rings.number_field [(1 : 1), (4/3 : 1), (1 : 0), (0 : 1)] :: - sage: K. = QuadraticField(2) - sage: P. = ProjectiveSpace(K,1) + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field sage: f = DynamicalSystem([x^2 + (-2)*y^2, y^2]) - sage: m = matrix(K, 2, 2, [v, 1, 0, 1]) - sage: g = f.conjugate(m) - sage: g.postcritical_set() + sage: m = matrix(K, 2, 2, [v, 1, 0, 1]) # needs sage.rings.number_field + sage: g = f.conjugate(m) # needs sage.rings.number_field + sage: g.postcritical_set() # needs sage.rings.number_field [(-3/2*a : 1), (1/2*a : 1), (1 : 0)] :: - sage: F. = FiniteField(9) - sage: P. = ProjectiveSpace(F, 1) + sage: F. = FiniteField(9) # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(F, 1) # needs sage.rings.finite_rings sage: f = DynamicalSystem([x^2 + (-2)*y^2, y^2]) - sage: m = matrix(F, 2, 2, [z, 1, 0, 1]) - sage: g = f.conjugate(m) - sage: g.postcritical_set() + sage: m = matrix(F, 2, 2, [z, 1, 0, 1]) # needs sage.rings.finite_rings + sage: g = f.conjugate(m) # needs sage.rings.finite_rings + sage: g.postcritical_set() # needs sage.rings.finite_rings [(1 : 0), (0 : 1), (a + 2 : 1)] """ if not is_ProjectiveSpace(self.domain()): @@ -6822,7 +6822,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.lift_to_rational_periodic([[P(0,1).change_ring(GF(7)), 4]]) + sage: f.lift_to_rational_periodic([[P(0,1).change_ring(GF(7)), 4]]) # needs sage.symbolic [[(0 : 1), 2]] :: @@ -6837,7 +6837,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) - sage: f.lift_to_rational_periodic([[P(3,1).change_ring(GF(13)), 3]]) + sage: f.lift_to_rational_periodic([[P(3,1).change_ring(GF(13)), 3]]) # needs sage.symbolic [[(-1/4 : 1), 3]] :: @@ -7087,19 +7087,19 @@ def all_periodic_points(self, **kwds): :: sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 1) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) - sage: sorted(f.all_periodic_points()) + sage: K. = NumberField(x^2 - x + 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) # needs sage.rings.number_field + sage: sorted(f.all_periodic_points()) # needs sage.rings.function_field sage.rings.number_field [(-w + 1 : 1), (w : 1), (1 : 0)] :: sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 1) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2 + v^2, u*v]) - sage: f.all_periodic_points() + sage: K. = NumberField(x^2 - x + 1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([u^2 + v^2, u*v]) # needs sage.rings.number_field + sage: f.all_periodic_points() # needs sage.rings.function_field sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: rational periodic points for number fields @@ -7108,10 +7108,10 @@ def all_periodic_points(self, **kwds): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: K. = QuadraticField(5) - sage: phi = QQ.embeddings(K)[0] + sage: K. = QuadraticField(5) # needs sage.rings.number_field + sage: phi = QQ.embeddings(K)[0] # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: sorted(f.all_periodic_points(R=phi)) + sage: sorted(f.all_periodic_points(R=phi)) # needs sage.rings.number_field [(-1 : 1), (-1/2*v + 1/2 : 1), (0 : 1), (1 : 0), (1/2*v + 1/2 : 1)] :: @@ -7119,7 +7119,7 @@ def all_periodic_points(self, **kwds): sage: P. = ProjectiveSpace(QQ, 3) sage: f = DynamicalSystem_projective([x^2 - (3/4)*w^2, y^2 - 3/4*w^2, ....: z^2 - 3/4*w^2, w^2]) - sage: sorted(f.all_periodic_points(algorithm="dynatomic")) + sage: sorted(f.all_periodic_points(algorithm="dynatomic")) # needs sage.rings.function_field [(-1/2 : -1/2 : -1/2 : 1), (-1/2 : -1/2 : 3/2 : 1), (-1/2 : 3/2 : -1/2 : 1), @@ -7140,7 +7140,7 @@ def all_periodic_points(self, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) - sage: sorted(f.all_periodic_points(period_degree_bounds=[2,2])) + sage: sorted(f.all_periodic_points(period_degree_bounds=[2,2])) # needs sage.rings.function_field [(-1/2 : 1), (1 : 0), (3/2 : 1)] TESTS:: @@ -7293,7 +7293,7 @@ def all_rational_preimages(self, points): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) - sage: sorted(f.all_rational_preimages([P(-1,4)])) + sage: sorted(f.all_rational_preimages([P(-1,4)])) # needs sage.rings.function_field [(-7/4 : 1), (-5/4 : 1), (-3/4 : 1), (-1/4 : 1), (1/4 : 1), (3/4 : 1), (5/4 : 1), (7/4 : 1)] @@ -7304,7 +7304,7 @@ def all_rational_preimages(self, points): ....: + 45*y*z - 90*z^2, ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, ....: -90*z^2]) - sage: sorted(f.all_rational_preimages([P(-9,-4,1)])) + sage: sorted(f.all_rational_preimages([P(-9,-4,1)])) # needs sage.rings.function_field [(-9 : -4 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 1), (0 : 4 : 1), (1 : 0 : 1), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1)] @@ -7312,16 +7312,16 @@ def all_rational_preimages(self, points): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 + y^2, 2*x*y]) - sage: sorted(f.all_rational_preimages([P(17,15)])) + sage: sorted(f.all_rational_preimages([P(17,15)])) # needs sage.rings.function_field [(1/3 : 1), (3/5 : 1), (5/3 : 1), (3 : 1)] A number field example:: sage: z = QQ['z'].0 - sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64) - sage: P. = ProjectiveSpace(K,1) + sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) - sage: sorted(f.all_rational_preimages([P(16*w^2 - 29, 16)]), key=str) + sage: sorted(f.all_rational_preimages([P(16*w^2 - 29, 16)]), key=str) # needs sage.rings.number_field [(-w - 1/2 : 1), (-w : 1), (-w^2 + 21/16 : 1), @@ -7337,10 +7337,10 @@ def all_rational_preimages(self, points): :: - sage: K. = QuadraticField(3) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) - sage: f.all_rational_preimages(P(4)) + sage: K. = QuadraticField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) # needs sage.rings.number_field + sage: f.all_rational_preimages(P(4)) # needs sage.rings.function_field sage.rings.number_field [(-w : 1), (w : 1)] """ if self.domain().base_ring() not in NumberFields(): @@ -7419,14 +7419,14 @@ def all_preperiodic_points(self, **kwds): sage: PS. = ProjectiveSpace(1,QQ) sage: f = DynamicalSystem_projective([x^2 - y^2, 3*x*y]) - sage: sorted(f.all_preperiodic_points()) + sage: sorted(f.all_preperiodic_points()) # needs sage.rings.function_field [(-2 : 1), (-1 : 1), (-1/2 : 1), (0 : 1), (1/2 : 1), (1 : 0), (1 : 1), (2 : 1)] :: sage: PS. = ProjectiveSpace(1,QQ) sage: f = DynamicalSystem_projective([5*x^3 - 53*x*y^2 + 24*y^3, 24*y^3]) - sage: sorted(f.all_preperiodic_points(prime_bound=10)) + sage: sorted(f.all_preperiodic_points(prime_bound=10)) # needs sage.rings.function_field [(-1 : 1), (0 : 1), (1 : 0), (1 : 1), (3 : 1)] :: @@ -7442,10 +7442,10 @@ def all_preperiodic_points(self, **kwds): :: - sage: K. = QuadraticField(33) - sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2 - 71/48*y^2, y^2]) - sage: sorted(f.all_preperiodic_points()) # long time + sage: K. = QuadraticField(33) # needs sage.rings.number_field + sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - 71/48*y^2, y^2]) # needs sage.rings.number_field + sage: sorted(f.all_preperiodic_points()) # long time # needs sage.rings.number_field [(-1/12*w - 1 : 1), (-1/6*w - 1/4 : 1), (-1/12*w - 1/2 : 1), @@ -7580,14 +7580,14 @@ def rational_preperiodic_graph(self, **kwds): sage: PS. = ProjectiveSpace(1,QQ) sage: f = DynamicalSystem_projective([7*x^2 - 28*y^2, 24*x*y]) - sage: f.rational_preperiodic_graph() + sage: f.rational_preperiodic_graph() # needs sage.rings.function_field Looped digraph on 12 vertices :: sage: PS. = ProjectiveSpace(1,QQ) sage: f = DynamicalSystem_projective([-3/2*x^3 + 19/6*x*y^2, y^3]) - sage: f.rational_preperiodic_graph(prime_bound=[1,8]) + sage: f.rational_preperiodic_graph(prime_bound=[1,8]) # needs sage.rings.function_field Looped digraph on 12 vertices :: @@ -7601,10 +7601,10 @@ def rational_preperiodic_graph(self, **kwds): :: - sage: K. = QuadraticField(-3) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) - sage: f.rational_preperiodic_graph() # long time + sage: K. = QuadraticField(-3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) # needs sage.rings.number_field + sage: f.rational_preperiodic_graph() # long time # needs sage.rings.number_field Looped digraph on 5 vertices """ #input checking done in .rational_preperiodic_points() @@ -7634,11 +7634,11 @@ def connected_rational_component(self, P, n=0): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 + 1/4*x^2 - 41/16*x + 23/64) - sage: PS. = ProjectiveSpace(1,K) - sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) - sage: P = PS([w,1]) - sage: sorted(f.connected_rational_component(P), key=str) + sage: K. = NumberField(x^3 + 1/4*x^2 - 41/16*x + 23/64) # needs sage.rings.number_field + sage: PS. = ProjectiveSpace(1,K) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) # needs sage.rings.number_field + sage: P = PS([w,1]) # needs sage.rings.number_field + sage: sorted(f.connected_rational_component(P), key=str) # needs sage.rings.number_field [(-w - 1/2 : 1), (-w : 1), (-w^2 + 21/16 : 1), @@ -7657,7 +7657,7 @@ def connected_rational_component(self, P, n=0): sage: PS. = ProjectiveSpace(2,QQ) sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - 2*z^2, z^2]) sage: P = PS([17/16, 7/4, 1]) - sage: f.connected_rational_component(P, 3) + sage: f.connected_rational_component(P, 3) # needs sage.rings.function_field [(17/16 : 7/4 : 1), (-47/256 : 17/16 : 1), (-83807/65536 : -223/256 : 1), @@ -7765,9 +7765,9 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: m = matrix(QQbar, 2, 2, [-1, 3, 2, 1]) - sage: g = f.conjugate(m) - sage: f.conjugating_set(g) + sage: m = matrix(QQbar, 2, 2, [-1, 3, 2, 1]) # needs sage.rings.number_field + sage: g = f.conjugate(m) # needs sage.rings.number_field + sage: f.conjugating_set(g) # needs sage.rings.number_field [ [-1 3] [ 2 1] @@ -7777,17 +7777,17 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 3) sage: f = DynamicalSystem_projective([x^2, y^2, z^2, w^2]) - sage: len(f.conjugating_set(f, num_cpus=3)) + sage: len(f.conjugating_set(f, num_cpus=3)) # needs sage.rings.function_field 24 :: - sage: K. = QuadraticField(-1) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: m = matrix(K, 2, 2, [1, 1, 2, 1]) - sage: g = f.conjugate(m) - sage: sorted(f.conjugating_set(g)) + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.number_field + sage: m = matrix(K, 2, 2, [1, 1, 2, 1]) # needs sage.rings.number_field + sage: g = f.conjugate(m) # needs sage.rings.number_field + sage: sorted(f.conjugating_set(g)) # needs sage.rings.number_field [ [-1 -1] [1 1] [ 2 1], [2 1] @@ -7795,10 +7795,10 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: K. = QuadraticField(-1) - sage: P. = ProjectiveSpace(K, 1) - sage: D8 = DynamicalSystem_projective([y^3, x^3]) - sage: sorted(D8.conjugating_set(D8)) + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: D8 = DynamicalSystem_projective([y^3, x^3]) # needs sage.rings.number_field + sage: sorted(D8.conjugating_set(D8)) # needs sage.rings.number_field [ [-1 0] [-i 0] [ 0 -1] [ 0 -i] [0 i] [0 1] [i 0] [1 0] [ 0 1], [ 0 1], [ 1 0], [ 1 0], [1 0], [1 0], [0 1], [0 1] @@ -7808,7 +7808,7 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 1) sage: D8 = DynamicalSystem_projective([y^2, x^2]) - sage: D8.conjugating_set(D8) + sage: D8.conjugating_set(D8) # needs sage.rings.function_field Traceback (most recent call last): ... ValueError: no more rational preimages; @@ -7818,7 +7818,7 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(GF(7), 1) sage: D6 = DynamicalSystem_projective([y^2, x^2]) - sage: sorted(D6.conjugating_set(D6)) + sage: sorted(D6.conjugating_set(D6)) # needs sage.rings.function_field [ [0 1] [0 2] [0 4] [1 0] [2 0] [4 0] [1 0], [1 0], [1 0], [0 1], [0 1], [0 1] @@ -7828,7 +7828,7 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2 + x*z, y^2, z^2]) - sage: f.conjugating_set(f) + sage: f.conjugating_set(f) # needs sage.rings.function_field [ [1 0 0] [0 1 0] @@ -7847,11 +7847,11 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: P. = ProjectiveSpace(QQbar, 1) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([7*x + 12*y, 8*x]) sage: g = DynamicalSystem_projective([1645*x - 318*y, 8473*x - 1638*y]) - sage: m = f.conjugating_set(g)[0] - sage: f.conjugate(m) == g + sage: m = f.conjugating_set(g)[0] # needs sage.rings.number_field + sage: f.conjugate(m) == g # needs sage.rings.number_field True note that only one possible conjugation is returned:: @@ -7869,32 +7869,32 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: L. = CyclotomicField(8) - sage: P. = ProjectiveSpace(L, 2) + sage: L. = CyclotomicField(8) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(L, 2) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) - sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) + sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) # needs sage.rings.number_field sage: g = f.conjugate(m1) - sage: m = f.conjugating_set(g)[0] # long time - sage: f.conjugate(m) == g # long time + sage: m = f.conjugating_set(g)[0] # long time, needs sage.rings.number_field + sage: f.conjugate(m) == g # long time, needs sage.rings.number_field True TESTS: Make sure the caching problem is fixed, see #28070 :: - sage: K. = QuadraticField(-1) + sage: K. = QuadraticField(-1) # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: m = matrix(QQ, 2, 2, [-1, 3, 2, 1]) sage: g = f.conjugate(m) - sage: f.conjugating_set(g) + sage: f.conjugating_set(g) # needs sage.rings.function_field sage.rings.number_field [ [-1 3] [ 2 1] ] - sage: f = f.change_ring(K) - sage: g = g.change_ring(K) - sage: f.conjugating_set(g) + sage: f = f.change_ring(K) # needs sage.rings.number_field + sage: g = g.change_ring(K) # needs sage.rings.number_field + sage: f.conjugating_set(g) # needs sage.rings.function_field sage.rings.number_field [ [-1 3] [ 2 1] @@ -8010,27 +8010,27 @@ def is_conjugate(self, other, R=None, num_cpus=2): EXAMPLES:: - sage: K. = CyclotomicField(3) - sage: P. = ProjectiveSpace(K, 1) - sage: D8 = DynamicalSystem_projective([y^2, x^2]) - sage: D8.is_conjugate(D8) + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: D8 = DynamicalSystem_projective([y^2, x^2]) # needs sage.rings.number_field + sage: D8.is_conjugate(D8) # needs sage.rings.number_field True We can speed up computation by increasing ``num_cpus``:: sage: P. = ProjectiveSpace(QQ,3) sage: f = DynamicalSystem_projective([x^2, y^2, z^2, w^2]) - sage: f.is_conjugate(f, num_cpus=2) + sage: f.is_conjugate(f, num_cpus=2) # needs sage.rings.function_field True :: sage: set_verbose(None) - sage: P. = ProjectiveSpace(QQbar, 1) - sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) - sage: m = matrix(QQbar, 2, 2, [1, 1, 2, 1]) - sage: g = f.conjugate(m) - sage: f.is_conjugate(g) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) # needs sage.rings.number_field + sage: m = matrix(QQbar, 2, 2, [1, 1, 2, 1]) # needs sage.rings.number_field + sage: g = f.conjugate(m) # needs sage.rings.number_field + sage: f.is_conjugate(g) # needs sage.rings.number_field True :: @@ -8039,7 +8039,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): sage: f = DynamicalSystem_projective([x^3 + x*y^2, y^3]) sage: m = matrix(GF(5), 2, 2, [1, 3, 2, 9]) sage: g = f.conjugate(m) - sage: f.is_conjugate(g) + sage: f.is_conjugate(g) # needs sage.rings.number_field True :: @@ -8055,15 +8055,15 @@ def is_conjugate(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) sage: g = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: f.is_conjugate(g) + sage: f.is_conjugate(g) # needs sage.rings.number_field False :: - sage: P. = ProjectiveSpace(QQbar, 1) + sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([7*x + 12*y, 8*x]) sage: g = DynamicalSystem_projective([1645*x - 318*y, 8473*x - 1638*y]) - sage: f.is_conjugate(g) + sage: f.is_conjugate(g) # needs sage.rings.number_field True Conjugation is only checked over the base field by default:: @@ -8071,7 +8071,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([-3*y^2, 3*x^2]) sage: g = DynamicalSystem_projective([-x^2 - 2*x*y, 2*x*y + y^2]) - sage: f.is_conjugate(g), f.is_conjugate(g, R=QQbar) + sage: f.is_conjugate(g), f.is_conjugate(g, R=QQbar) # needs sage.rings.number_field (False, True) :: @@ -8105,16 +8105,16 @@ def is_conjugate(self, other, R=None, num_cpus=2): Make sure the caching problem is fixed, see #28070 :: - sage: K. = QuadraticField(5) + sage: K. = QuadraticField(5) # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: m = matrix(QQ, 2, 2, [-1, 3, 2, 1]) sage: g = f.conjugate(m) - sage: f.is_conjugate(g) + sage: f.is_conjugate(g) # needs sage.rings.number_field True - sage: f = f.change_ring(K) - sage: g = g.change_ring(K) - sage: f.is_conjugate(g) + sage: f = f.change_ring(K) # needs sage.rings.number_field + sage: g = g.change_ring(K) # needs sage.rings.number_field + sage: f.is_conjugate(g) # needs sage.rings.number_field True """ f = copy(self) @@ -8176,37 +8176,37 @@ def is_polynomial(self): EXAMPLES:: sage: R. = QQ[] - sage: K. = QuadraticField(7) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x**2 + 2*x*y - 5*y**2, 2*x*y]) - sage: f.is_polynomial() + sage: K. = QuadraticField(7) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x**2 + 2*x*y - 5*y**2, 2*x*y]) # needs sage.rings.number_field + sage: f.is_polynomial() # needs sage.rings.number_field False :: sage: R. = QQ[] - sage: K. = QuadraticField(7) - sage: P. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([x**2 - 7*x*y, 2*y**2]) - sage: m = matrix(K, 2, 2, [w, 1, 0, 1]) - sage: f = f.conjugate(m) - sage: f.is_polynomial() + sage: K. = QuadraticField(7) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x**2 - 7*x*y, 2*y**2]) # needs sage.rings.number_field + sage: m = matrix(K, 2, 2, [w, 1, 0, 1]) # needs sage.rings.number_field + sage: f = f.conjugate(m) # needs sage.rings.number_field + sage: f.is_polynomial() # needs sage.rings.number_field True :: - sage: K. = QuadraticField(4/27) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x**3 + w*y^3, x*y**2]) - sage: f.is_polynomial() + sage: K. = QuadraticField(4/27) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x**3 + w*y^3, x*y**2]) # needs sage.rings.number_field + sage: f.is_polynomial() # needs sage.rings.number_field False :: - sage: K = GF(3**2, prefix='w') - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x**2 + K.gen()*y**2, x*y]) - sage: f.is_polynomial() + sage: K = GF(3**2, prefix='w') # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x**2 + K.gen()*y**2, x*y]) # needs sage.rings.finite_rings + sage: f.is_polynomial() # needs sage.rings.finite_rings False :: @@ -8223,7 +8223,7 @@ def is_polynomial(self): sage: P. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem([x^2 + y^2, x*y]) sage: F2 = F.conjugate(matrix(QQ,2,2, [1,2,3,5])) - sage: F2.is_polynomial() + sage: F2.is_polynomial() # needs sage.libs.pari False """ if self.codomain().dimension_relative() != 1: @@ -8325,30 +8325,30 @@ def normal_form(self, return_conjugation=False): :: sage: R. = QQ[] - sage: K. = NumberField(x^2 - 5) - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2 + w*x*y, y^2]) - sage: g,m,psi = f.normal_form(return_conjugation = True);m + sage: K. = NumberField(x^2 - 5) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + w*x*y, y^2]) # needs sage.rings.number_field + sage: g,m,psi = f.normal_form(return_conjugation=True); m # needs sage.rings.number_field [ 1 -1/2*w] [ 0 1] - sage: f.change_ring(psi).conjugate(m) == g + sage: f.change_ring(psi).conjugate(m) == g # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([13*x^2 + 4*x*y + 3*y^2, 5*y^2]) - sage: f.normal_form() + sage: f.normal_form() # needs sage.libs.pari Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (5*x^2 + 9*y^2 : 5*y^2) :: - sage: K = GF(3^3, prefix='w') - sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) - sage: f.normal_form() + sage: K = GF(3^3, prefix='w') # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(K,1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) # needs sage.rings.finite_rings + sage: f.normal_form() # needs sage.rings.finite_rings Dynamical System of Projective Space of dimension 1 over Finite Field in w3 of size 3^3 Defn: Defined on coordinates by sending (x : y) to @@ -8358,7 +8358,7 @@ def normal_form(self, return_conjugation=False): sage: P. = ProjectiveSpace(GF(3),1) sage: f = DynamicalSystem_projective([2*x**3 + x**2*y, y**3]) - sage: g,m,psi = f.normal_form(return_conjugation=True); psi + sage: g,m,psi = f.normal_form(return_conjugation=True); psi # needs sage.rings.finite_rings Ring morphism: From: Finite Field of size 3 To: Finite Field in z2 of size 3^2 @@ -8530,9 +8530,9 @@ def potential_good_reduction(self, prime, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) - sage: prime = system.field_of_definition_periodic(1).prime_above(2) - sage: new_system = system.potential_good_reduction(prime)[1] - sage: new_system + sage: prime = system.field_of_definition_periodic(1).prime_above(2) # needs sage.rings.number_field + sage: new_system = system.potential_good_reduction(prime)[1] # needs sage.rings.number_field + sage: new_system # needs sage.rings.number_field Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -8540,44 +8540,44 @@ def potential_good_reduction(self, prime, return_conjugation=False): Note that this map has good reduction at 2:: - sage: new_system.resultant() + sage: new_system.resultant() # needs sage.rings.number_field 1 Using ``return_conjugation``, we can get the conjugation that achieves good reduction:: - sage: conj = system.potential_good_reduction(prime, True)[2]; conj + sage: conj = system.potential_good_reduction(prime, True)[2]; conj # needs sage.rings.number_field [-1/2*a 1/2] [ 0 1] We can check that this conjugation achieves good reduction:: - sage: system.conjugate(conj).resultant() + sage: system.conjugate(conj).resultant() # needs sage.rings.number_field 1 :: sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([3^4*x^3 + 3*x*y^2 + y^3, 3^6*y^3]) - sage: prime = system.field_of_definition_periodic(1).prime_above(3) - sage: system.potential_good_reduction(prime) + sage: prime = system.field_of_definition_periodic(1).prime_above(3) # needs sage.rings.number_field + sage: system.potential_good_reduction(prime) # needs sage.rings.number_field (False, None) :: sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([x^5 - x*y^4, 5*y^5]) - sage: prime = system.field_of_definition_periodic(1).prime_above(5) - sage: system.potential_good_reduction(prime) + sage: prime = system.field_of_definition_periodic(1).prime_above(5) # needs sage.rings.number_field + sage: system.potential_good_reduction(prime) # needs sage.rings.number_field (False, None) TESTS:: sage: P. = ProjectiveSpace(QQ, 1) sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) - sage: prime = A.prime_above(2) + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: prime = A.prime_above(2) # needs sage.rings.number_field sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) - sage: system.potential_good_reduction(prime) + sage: system.potential_good_reduction(prime) # needs sage.rings.number_field (True, Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial x^2 + 1 @@ -8596,18 +8596,18 @@ def potential_good_reduction(self, prime, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([x**5 - 11*y**5, x**4*y]) - sage: B, new_sys, conj = system.potential_good_reduction(11, True) - sage: system.conjugate(conj).resultant() == 1 + sage: B, new_sys, conj = system.potential_good_reduction(11, True) # needs sage.rings.number_field + sage: system.conjugate(conj).resultant() == 1 # needs sage.rings.number_field True - sage: system.conjugate(conj) == new_sys + sage: system.conjugate(conj) == new_sys # needs sage.rings.number_field True :: sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([3*x^2 + x*y + y^2, 9*y^2]) - sage: prime = system.field_of_definition_periodic(1).prime_above(3) - sage: system.potential_good_reduction(prime) + sage: prime = system.field_of_definition_periodic(1).prime_above(3) # needs sage.rings.number_field + sage: system.potential_good_reduction(prime) # needs sage.rings.number_field (False, None) """ @@ -8701,20 +8701,20 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(2^3) - sage: P. = ProjectiveSpace(K, 2) - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2+z*y]) - sage: f.reduce_base_field() + sage: K. = GF(2^3) # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2+z*y]) # needs sage.rings.finite_rings + sage: f.reduce_base_field() # needs sage.rings.finite_rings Dynamical System of Projective Space of dimension 2 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y : z) to (x^2 + y^2 : y^2 : y*z + z^2) :: - sage: P. = ProjectiveSpace(QQbar, 2) - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, # optional - sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, # needs sage.rings.number_field sage.symbolic ....: y^2, QQbar(sqrt(2))*z^2]) - sage: f.reduce_base_field() # optional - sage.symbolic + sage: f.reduce_base_field() # needs sage.rings.number_field sage.symbolic Dynamical System of Projective Space of dimension 2 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415? Defn: Defined on coordinates by sending (x : y : z) to @@ -8723,22 +8723,22 @@ def reduce_base_field(self): :: sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2, embedding=(x^3 - 2).roots(ring=CC)[0][0]) + sage: K. = NumberField(x^3 - 2, embedding=(x^3 - 2).roots(ring=CC)[0][0]) # needs sage.rings.number_field sage: R. = QQ[] - sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, + sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, # needs sage.rings.number_field ....: embedding=(x^6 + 9*x^4 - 4*x^3 ....: + 27*x^2 + 36*x + 31).roots(ring=CC)[0][0]) - sage: P. = ProjectiveSpace(L,1) - sage: f = DynamicalSystem([L(v)*x^2 + y^2, x*y]) - sage: f.reduce_base_field().base_ring().is_isomorphic(K) + sage: P. = ProjectiveSpace(L,1) # needs sage.rings.number_field + sage: f = DynamicalSystem([L(v)*x^2 + y^2, x*y]) # needs sage.rings.number_field + sage: f.reduce_base_field().base_ring().is_isomorphic(K) # needs sage.rings.number_field True :: - sage: K. = CyclotomicField(5) - sage: A. = ProjectiveSpace(K, 1) - sage: f = DynamicalSystem_projective([3*x^2 + y^2, x*y]) - sage: f.reduce_base_field() + sage: K. = CyclotomicField(5) # needs sage.rings.number_field + sage: A. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([3*x^2 + y^2, x*y]) # needs sage.rings.number_field + sage: f.reduce_base_field() # needs sage.rings.number_field Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (3*x^2 + y^2 : x*y) @@ -8773,7 +8773,7 @@ def is_newton(self, return_conjugation=False): sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([z - (z^2 + 1)/(2*z)]) sage: F = f.homogenize(1) - sage: F.is_newton(return_conjugation=True) + sage: F.is_newton(return_conjugation=True) # needs sage.rings.number_field ( [1 0] True, [0 1] @@ -8784,26 +8784,26 @@ def is_newton(self, return_conjugation=False): sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine([z^2 + 1]) sage: F = f.homogenize(1) - sage: F.is_newton() + sage: F.is_newton() # needs sage.rings.number_field False - sage: F.is_newton(return_conjugation=True) + sage: F.is_newton(return_conjugation=True) # needs sage.rings.number_field (False, None) :: sage: PP. = ProjectiveSpace(QQ, 1) sage: F = DynamicalSystem_projective([-4*x^3 - 3*x*y^2, -2*y^3]) - sage: F.is_newton(return_conjugation=True)[1] + sage: F.is_newton(return_conjugation=True)[1] # needs sage.rings.number_field [ 0 1] [-4*a 2*a] :: - sage: K. = CyclotomicField(2*4) - sage: A. = AffineSpace(K, 1) - sage: f = DynamicalSystem_affine(z-(z^3+zeta*z)/(3*z^2+zeta)) + sage: K. = CyclotomicField(2*4) # needs sage.rings.number_field + sage: A. = AffineSpace(K, 1) # needs sage.rings.number_field + sage: f = DynamicalSystem_affine(z-(z^3+zeta*z)/(3*z^2+zeta)) # needs sage.rings.number_field sage: F = f.homogenize(1) - sage: F.is_newton() + sage: F.is_newton() # needs sage.rings.number_field True """ if self.degree() == 1: @@ -8939,7 +8939,7 @@ def orbit_structure(self, P): sage: P. = ProjectiveSpace(GF(7),2) sage: X = P.subscheme(x^2 - y^2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) - sage: f.orbit_structure(X(1,1,2)) + sage: f.orbit_structure(X(1,1,2)) # needs sage.rings.function_field (0, 2) :: @@ -8951,10 +8951,10 @@ def orbit_structure(self, P): :: - sage: R. = GF(13^3) - sage: P. = ProjectiveSpace(R,1) + sage: R. = GF(13^3) # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(R,1) # needs sage.rings.finite_rings sage: f = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) - sage: f.orbit_structure(P(t, 4)) + sage: f.orbit_structure(P(t, 4)) # needs sage.rings.finite_rings (11, 6) """ orbit = [] @@ -8984,14 +8984,14 @@ def cyclegraph(self): sage: P. = ProjectiveSpace(GF(13),1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 14 vertices :: - sage: P. = ProjectiveSpace(GF(3^2,'t'),2) - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) - sage: f.cyclegraph() + sage: P. = ProjectiveSpace(GF(3^2,'t'),2) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) # needs sage.rings.finite_rings + sage: f.cyclegraph() # needs sage.graphs sage.rings.finite_rings Looped digraph on 91 vertices :: @@ -8999,14 +8999,14 @@ def cyclegraph(self): sage: P. = ProjectiveSpace(GF(7),2) sage: X = P.subscheme(x^2 - y^2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 15 vertices :: sage: P. = ProjectiveSpace(GF(3),2) sage: f = DynamicalSystem_projective([x*z - y^2, x^2 - y^2, y^2 - z^2]) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 13 vertices :: @@ -9014,7 +9014,7 @@ def cyclegraph(self): sage: P. = ProjectiveSpace(GF(3),2) sage: X = P.subscheme([x - y]) sage: f = DynamicalSystem_projective([x^2 - y^2, x^2 - y^2, y^2 - z^2], domain=X) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 4 vertices """ V = [] @@ -9068,15 +9068,15 @@ def possible_periods(self, return_points=False): EXAMPLES:: sage: P. = ProjectiveSpace(GF(23),1) - sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) - sage: f.possible_periods() + sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) + sage: f.possible_periods() # needs sage.libs.pari [1, 5, 11, 22, 110] :: sage: P. = ProjectiveSpace(GF(13),1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: sorted(f.possible_periods(True)) + sage: sorted(f.possible_periods(True)) # needs sage.libs.pari [[(0 : 1), 2], [(1 : 0), 1], [(3 : 1), 3], [(3 : 1), 36]] :: @@ -9084,7 +9084,7 @@ def possible_periods(self, return_points=False): sage: PS. = ProjectiveSpace(2,GF(7)) sage: f = DynamicalSystem_projective([-360*x^3 + 760*x*z^2, ....: y^3 - 604*y*z^2 + 240*z^3, 240*z^3]) - sage: f.possible_periods() + sage: f.possible_periods() # needs sage.libs.pari [1, 2, 4, 6, 12, 14, 28, 42, 84] .. TODO:: @@ -9138,9 +9138,9 @@ def automorphism_group(self, **kwds): EXAMPLES:: - sage: R. = ProjectiveSpace(GF(7^3,'t'),1) - sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) - sage: f.automorphism_group() + sage: R. = ProjectiveSpace(GF(7^3,'t'),1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) # needs sage.rings.finite_rings + sage: f.automorphism_group() # needs sage.rings.finite_rings [ [1 0] [6 0] [0 1], [0 1] @@ -9148,11 +9148,11 @@ def automorphism_group(self, **kwds): :: - sage: R. = ProjectiveSpace(GF(3^2,'t'),1) - sage: f = DynamicalSystem_projective([x^3, y^3]) - sage: lst, label = f.automorphism_group(return_functions=True, # long time + sage: R. = ProjectiveSpace(GF(3^2,'t'),1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^3, y^3]) # needs sage.rings.finite_rings + sage: lst, label = f.automorphism_group(return_functions=True, # long time, needs sage.rings.finite_rings ....: iso_type=True) - sage: sorted(lst, key=str), label # long time + sage: sorted(lst, key=str), label # long time # needs sage.rings.finite_rings ([(2*x + 1)/(x + 1), (2*x + 1)/x, (2*x + 2)/(x + 2), @@ -9181,16 +9181,16 @@ def automorphism_group(self, **kwds): :: - sage: R. = ProjectiveSpace(GF(2^5,'t'),1) - sage: f = DynamicalSystem_projective([x^5, y^5]) - sage: f.automorphism_group(return_functions=True, iso_type=True) + sage: R. = ProjectiveSpace(GF(2^5,'t'),1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^5, y^5]) # needs sage.rings.finite_rings + sage: f.automorphism_group(return_functions=True, iso_type=True) # needs sage.rings.finite_rings ([x, 1/x], 'Cyclic of order 2') :: - sage: R. = ProjectiveSpace(GF(3^4,'t'),1) - sage: f = DynamicalSystem_projective([x^2 + 25*x*y + y^2, x*y + 3*y^2]) - sage: f.automorphism_group(absolute=True) + sage: R. = ProjectiveSpace(GF(3^4,'t'),1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^2 + 25*x*y + y^2, x*y + 3*y^2]) # needs sage.rings.finite_rings + sage: f.automorphism_group(absolute=True) # needs sage.rings.finite_rings [Univariate Polynomial Ring in w over Finite Field in b of size 3^4, [ [1 0] @@ -9201,7 +9201,7 @@ def automorphism_group(self, **kwds): sage: R. = ProjectiveSpace(GF(5), 2) sage: f = DynamicalSystem_projective([x^3 + x*z^2, y^3 + y*z^2, z^3]) - sage: all([f.conjugate(m) == f for m in f.automorphism_group()]) + sage: all([f.conjugate(m) == f for m in f.automorphism_group()]) # needs sage.rings.function_field True """ absolute = kwds.get('absolute', False) @@ -9237,9 +9237,9 @@ def all_periodic_points(self, **kwds): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5^2),1) - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) - sage: f.all_periodic_points() + sage: P. = ProjectiveSpace(GF(5^2),1) # needs sage.rings.finite_rings + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.finite_rings + sage: f.all_periodic_points() # needs sage.rings.finite_rings [(1 : 0), (z2 + 2 : 1), (4*z2 + 3 : 1)] :: @@ -9257,9 +9257,9 @@ def all_periodic_points(self, **kwds): :: - sage: P.=ProjectiveSpace(GF(3), 1) + sage: P. = ProjectiveSpace(GF(3), 1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: f.all_periodic_points(R=GF(3^2, 't')) + sage: f.all_periodic_points(R=GF(3^2, 't')) # needs sage.rings.finite_rings [(1 : 0), (0 : 1), (2 : 1), (t : 1), (2*t + 1 : 1)] """ R = kwds.pop("R", None) From 565663ecd421239b1381bcfa3a546a53f8ac4f11 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 3 Jul 2023 22:17:43 -0700 Subject: [PATCH 078/494] Fix up imports --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 624463f5bfa..a8ca6fad6c1 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -112,12 +112,16 @@ class initialization directly. from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model -lazy_import('sage.libs.pari.all', 'PariError') lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') lazy_import('sage.rings.padics.factory', 'Qp') lazy_import('sage.rings.qqbar', ['QQbar', 'number_field_elements_from_algebraics']) +try: + from sage.libs.pari.all import PariError +except ImportError: + PariError = () + class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, DynamicalSystem): From 53e8a0037529aa67d800a1bd2fe8b4fa783b04e5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:12 -0700 Subject: [PATCH 079/494] src/sage/dynamics: sage -fixdoctests --only-tags --- .../dynamics/arithmetic_dynamics/affine_ds.py | 32 +-- .../arithmetic_dynamics/berkovich_ds.py | 138 ++++++----- .../arithmetic_dynamics/projective_ds.py | 226 ++++++++++-------- .../dynamics/cellular_automata/elementary.py | 6 +- src/sage/dynamics/cellular_automata/glca.py | 4 +- 5 files changed, 221 insertions(+), 185 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py index 68db00928eb..23cdb1a9b51 100644 --- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py @@ -188,8 +188,8 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space, :: - sage: x = var('x') # optional - sage.symbolic - sage: DynamicalSystem_affine(x^2 + 1) # optional - sage.symbolic + sage: x = var('x') # needs sage.symbolic + sage: DynamicalSystem_affine(x^2 + 1) # needs sage.symbolic Traceback (most recent call last): ... TypeError: symbolic ring cannot be the base ring @@ -397,10 +397,11 @@ def homogenize(self, n): :: - sage: R. = PolynomialRing(QQbar) # optional - sage.rings.number_field - sage: A. = AffineSpace(R, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.homogenize(2) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field + sage: R. = PolynomialRing(QQbar) + sage: A. = AffineSpace(R, 2) + sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2]) # needs sage.symbolic + sage: f.homogenize(2) # needs sage.symbolic Dynamical System of Projective Space of dimension 2 over Univariate Polynomial Ring in a over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -507,8 +508,8 @@ def dynatomic_polynomial(self, period): :: sage: A. = AffineSpace(CC,1) - sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) # optional - sage.symbolic - sage: F.dynatomic_polynomial([1,1]) # optional - sage.symbolic + sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) # needs sage.symbolic + sage: F.dynatomic_polynomial([1,1]) # needs sage.symbolic (0.125000000000000*x^4 + 0.366025403784439*x^2 + 1.50000000000000)/(0.500000000000000*x^2 - x + 1.73205080756888) TESTS:: @@ -957,10 +958,10 @@ def reduce_base_field(self): :: - sage: A. = AffineSpace(QQbar, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, # optional - sage.rings.number_field sage.symbolic + sage: A. = AffineSpace(QQbar, 2) # needs sage.rings.number_field + sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, # needs sage.rings.number_field sage.symbolic ....: QQbar(sqrt(-1))*y^2]) - sage: f.reduce_base_field() # optional - sage.rings.number_field sage.symbolic + sage: f.reduce_base_field() # needs sage.rings.number_field sage.symbolic Dynamical System of Affine Space of dimension 2 over Number Field in a with defining polynomial y^4 - y^2 + 1 with a = -0.866025403784439? + 0.50000000000000000?*I @@ -969,10 +970,11 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(5) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_affine([(3*x^2 + y) / (5*x), (y^2+1) / (x+y)]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(5) + sage: A. = AffineSpace(K, 2) + sage: f = DynamicalSystem_affine([(3*x^2 + y) / (5*x), (y^2+1) / (x+y)]) + sage: f.reduce_base_field() Dynamical System of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to ((3*x^2 + y)/(5*x), (5*y^2 + 5)/(5*x + 5*y)) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index eab3bcdac91..5bb5e01d488 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -146,19 +146,21 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Creating a map on Berkovich space creates the Berkovich space it acts on:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([x^2, y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: B = g.domain(); B # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([x^2, y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: B = g.domain(); B Projective Berkovich line over Cp(3) of precision 20 The image of type I point is the image of the center:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: F = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics - sage: B = F.domain() # needs sage.rings.padics - sage: Q1 = B(2) # needs sage.rings.padics - sage: F(Q1) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: F = DynamicalSystem_Berkovich([x^2, y^2]) + sage: B = F.domain() + sage: Q1 = B(2) + sage: F(Q1) Type I point centered at (1 + 3 + O(3^20) : 1 + O(3^20)) For type II/III points with no poles in the corresponding disk, @@ -171,10 +173,11 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet The image of any type II point can be computed:: - sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.padics - sage: G = DynamicalSystem_Berkovich(g) # needs sage.rings.padics - sage: Q3 = B(0, 1) # needs sage.rings.padics - sage: G(Q3) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) + sage: G = DynamicalSystem_Berkovich(g) + sage: Q3 = B(0, 1) + sage: G(Q3) Type II point centered at (0 : 1 + O(3^20)) of radius 3^0 The image of type III points can be computed has long as the @@ -289,10 +292,11 @@ def __init__(self, dynamical_system, domain): TESTS:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: isinstance(g, DynamicalSystem_Berkovich) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: isinstance(g, DynamicalSystem_Berkovich) True """ self._system = dynamical_system @@ -346,10 +350,11 @@ def domain(self): EXAMPLES:: - sage: Q. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: g.domain() # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: Q. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: g.domain() Projective Berkovich line over Cp(3) of precision 20 """ return self._domain @@ -384,10 +389,11 @@ def __getitem__(self, i): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: g[0] # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: g[0] x^2 + y^2 """ return self._system._polys[i] @@ -401,10 +407,11 @@ def defining_polynomials(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: g.defining_polynomials() # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: g.defining_polynomials() ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2, (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2) """ @@ -442,10 +449,11 @@ def _repr_(self): EXAMPLES:: - sage: Q. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: f._repr_() # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: Q. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) + sage: f = DynamicalSystem_Berkovich(f) + sage: f._repr_() 'Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map\n Defn: Defined on coordinates by sending (x : y) to\n ((3 + O(3^21))*x^2 : (2 + O(3^20))*y^2)' """ @@ -656,10 +664,11 @@ def conjugate(self, M, adjugate=False, new_ideal=None): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: g.conjugate(Matrix([[1, 1], [0, 1]])) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: g.conjugate(Matrix([[1, 1], [0, 1]])) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -750,10 +759,11 @@ def dehomogenize(self, n): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: g.dehomogenize(1) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) + sage: g = DynamicalSystem_Berkovich(f) + sage: g.dehomogenize(1) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to @@ -783,21 +793,23 @@ def __call__(self, x, type_3_pole_check=True): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.padics - sage: G = DynamicalSystem_Berkovich(g) # needs sage.rings.padics - sage: B = G.domain() # needs sage.rings.padics - sage: Q3 = B(0, 1) # needs sage.rings.padics - sage: G(Q3) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) + sage: G = DynamicalSystem_Berkovich(g) + sage: B = G.domain() + sage: Q3 = B(0, 1) + sage: G(Q3) Type II point centered at (0 : 1 + O(3^20)) of radius 3^0 :: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) # needs sage.rings.padics - sage: B = H.domain() # needs sage.rings.padics - sage: Q4 = B(1/9, 1.5) # needs sage.rings.padics - sage: H(Q4, False) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) + sage: B = H.domain() + sage: Q4 = B(1/9, 1.5) + sage: H(Q4, False) Type III point centered at (3^4 + 3^10 + 2*3^11 + 2*3^13 + 2*3^14 + 2*3^15 + 3^17 + 2*3^18 + 2*3^19 + 3^20 + 3^21 + 3^22 + O(3^24) : 1 + O(3^20)) of radius 0.00205761316872428 @@ -1053,10 +1065,11 @@ def homogenize(self, n): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_affine(1/x) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: f.homogenize(1) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) + sage: f = DynamicalSystem_affine(1/x) + sage: f = DynamicalSystem_Berkovich(f) + sage: f.homogenize(1) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0) @@ -1073,12 +1086,13 @@ def __call__(self, x): EXAMPLES:: - sage: P. = AffineSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_affine(x^2) # needs sage.rings.padics - sage: g = DynamicalSystem_Berkovich(f) # needs sage.rings.padics - sage: B = g.domain() # needs sage.rings.padics - sage: Q1 = B(2) # needs sage.rings.padics - sage: g(Q1) # needs sage.rings.padics + sage: # needs sage.rings.padics + sage: P. = AffineSpace(Qp(3), 1) + sage: f = DynamicalSystem_affine(x^2) + sage: g = DynamicalSystem_Berkovich(f) + sage: B = g.domain() + sage: Q1 = B(2) + sage: g(Q1) Type I point centered at 1 + 3 + O(3^20) """ if not isinstance(x, Berkovich_Element_Cp_Affine): diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index a8ca6fad6c1..30d7b3c229f 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -272,11 +272,12 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, :: - sage: K. = QuadraticField(-7) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem([x^3 + v*x*y^2, y^3]) # needs sage.rings.number_field - sage: fbar = f.change_ring(QQbar) # needs sage.rings.number_field - sage: fbar.is_postcritically_finite() # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-7) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem([x^3 + v*x*y^2, y^3]) + sage: fbar = f.change_ring(QQbar) + sage: fbar.is_postcritically_finite() False """ @@ -771,7 +772,7 @@ def dynatomic_polynomial(self, period): :: sage: T. = QuadraticField(33) # needs sage.rings.number_field - sage: S. = PolynomialRing(T) + sage: S. = PolynomialRing(T) # needs sage.rings.number_field sage: P. = ProjectiveSpace(FractionField(S),1) sage: f = DynamicalSystem_projective([t*x^2 - 1/t*y^2, y^2]) sage: f.dynatomic_polynomial([1, 2]).parent() # needs sage.libs.pari @@ -1183,11 +1184,12 @@ def arakelov_zhang_pairing(self, g, **kwds): EXAMPLES:: - sage: K. = CyclotomicField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + (2*k + 2)*y^2, y^2]) # needs sage.rings.number_field - sage: g = DynamicalSystem_projective([x^2, y^2]) # needs sage.rings.number_field - sage: pairingval = f.arakelov_zhang_pairing(g, n=5); pairingval # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 + (2*k + 2)*y^2, y^2]) + sage: g = DynamicalSystem_projective([x^2, y^2]) + sage: pairingval = f.arakelov_zhang_pairing(g, n=5); pairingval 0.409598197761958 :: @@ -1209,7 +1211,7 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: f = DynamicalSystem_projective([x^2 + 4*y^2, y^2]) sage: g = DynamicalSystem_projective([x^2, y^2]) sage: pairingval = f.arakelov_zhang_pairing(g, n=6, noise_multiplier=0) # needs sage.rings.function_field - sage: pairingval + sage: pairingval # needs sage.rings.number_field 0.650660018921632 sage: dynheight = f.canonical_height(P(0, 1)); dynheight # needs sage.libs.pari 0.75017839144364417318023000563 @@ -2032,14 +2034,15 @@ def green_function(self, P, v, **kwds): :: - sage: K. = QuadraticField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([17*x^2 + 1/7*y^2, 17*w*x*y]) # needs sage.rings.number_field - sage: f.green_function(P.point([w, 2], False), K.places()[1]) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([17*x^2 + 1/7*y^2, 17*w*x*y]) + sage: f.green_function(P.point([w, 2], False), K.places()[1]) 1.7236334013785676107373093775 - sage: f.green_function(P([2, 1]), K.ideal(7), N=7) # needs sage.rings.number_field + sage: f.green_function(P([2, 1]), K.ideal(7), N=7) 0.48647753726382832627633818586 - sage: f.green_function(P([w, 1]), K.ideal(17), error_bound=0.001) # needs sage.rings.number_field + sage: f.green_function(P([w, 1]), K.ideal(17), error_bound=0.001) -0.70813041039490996737374178059 :: @@ -3140,7 +3143,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: PS. = ProjectiveSpace(ZZ,1) sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y + 42*y^2]) sage: g,M = f.minimal_model(return_transformation=True, algorithm='BM') # needs sage.rings.function_field - sage: f.conjugate(M) == g + sage: f.conjugate(M) == g # needs sage.rings.function_field True :: @@ -3313,10 +3316,10 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, sage: c = 2^2*5^2*11^3 sage: f = DynamicalSystem([x^3 - c^2*y^3, x*y^2]) sage: MM = f.all_minimal_models(return_transformation=True, algorithm='BM') # needs sage.rings.function_field - sage: all(f.conjugate(m) == F for F, m in MM) + sage: all(f.conjugate(m) == F for F, m in MM) # needs sage.rings.function_field True sage: MM = f.all_minimal_models(return_transformation=True, algorithm='HS') # needs sage.rings.function_field - sage: all(f.conjugate(m) == F for F,m in MM) + sage: all(f.conjugate(m) == F for F,m in MM) # needs sage.rings.function_field True REFERENCES: @@ -3403,7 +3406,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): We can check that ``g`` has affine fixed points:: - sage: g.periodic_points(1) + sage: g.periodic_points(1) # needs sage.rings.function_field [(-1 : -1 : 1), (-1/2 : -1 : 1), (-1/2 : -1/2 : 1), @@ -3437,10 +3440,11 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): :: - sage: K. = CyclotomicField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + k*x*y + y^2, z^2, y^2]) # needs sage.rings.number_field - sage: f.affine_preperiodic_model(1, 1) # needs sage.rings.function_field sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 2) + sage: f = DynamicalSystem_projective([x^2 + k*x*y + y^2, z^2, y^2]) + sage: f.affine_preperiodic_model(1, 1) # needs sage.rings.function_field Dynamical System of Projective Space of dimension 2 over Cyclotomic Field of order 3 and degree 2 Defn: Defined on coordinates by sending (x : y : z) to @@ -3451,7 +3455,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) # needs sage.rings.function_field - sage: g == f.conjugate(mat) + sage: g == f.conjugate(mat) # needs sage.rings.function_field True :: @@ -3470,7 +3474,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, x^2]) sage: g, mat = f.affine_preperiodic_model(0, 1, return_conjugation=True) # needs sage.rings.function_field - sage: f.conjugate(mat) == g + sage: f.conjugate(mat) == g # needs sage.rings.function_field True """ n = ZZ(n) @@ -3641,7 +3645,7 @@ def automorphism_group(self, **kwds): sage: f = DynamicalSystem_projective([3*x^2*y - y^3, x^3 - 3*x*y^2]) sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, # needs sage.libs.pari ....: iso_type=True) - sage: sorted(lst), label + sage: sorted(lst), label # needs sage.libs.pari ([-1/x, 1/x, (-x - 1)/(x - 1), (-x + 1)/(x + 1), (x - 1)/(x + 1), (x + 1)/(x - 1), -x, x], 'Dihedral of order 8') @@ -3670,10 +3674,11 @@ def automorphism_group(self, **kwds): :: - sage: K. = CyclotomicField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: D6 = DynamicalSystem_projective([y^2, x^2]) # needs sage.rings.number_field - sage: sorted(D6.automorphism_group()) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: D6 = DynamicalSystem_projective([y^2, x^2]) + sage: sorted(D6.automorphism_group()) [ [-w - 1 0] [ 0 -w - 1] [w 0] [0 w] [0 1] [1 0] [ 0 1], [ 1 0], [0 1], [1 0], [1 0], [0 1] @@ -3788,7 +3793,7 @@ def critical_points(self, R=None): sage: f.critical_points() # needs sage.rings.function_field [(1 : 0)] sage: K. = QuadraticField(6) # needs sage.rings.number_field - sage: f.critical_points(K) + sage: f.critical_points(K) # needs sage.rings.number_field [(-1/3*w : 1), (1/3*w : 1), (1 : 0)] :: @@ -3928,8 +3933,8 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: R. = QQ[] sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) # needs sage.rings.number_field - sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) + sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) # needs sage.rings.number_field sage: f.is_postcritically_finite() # long time True @@ -4231,10 +4236,11 @@ def critical_height(self, **kwds): :: - sage: K. = QuadraticField(2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + w*y^2, y^2]) # needs sage.rings.number_field - sage: f.critical_height() # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^2 + w*y^2, y^2]) + sage: f.critical_height() 0.16090842452312941163719755472 Postcritically finite maps have critical height 0:: @@ -4393,7 +4399,7 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 1) sage: K. = QuadraticField(5) # needs sage.rings.number_field - sage: phi = QQ.embeddings(K)[0] + sage: phi = QQ.embeddings(K)[0] # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: f.preperiodic_points(1, 1, R=phi) [(-1/2*v - 1/2 : 1), (1/2*v - 1/2 : 1)] @@ -4443,7 +4449,7 @@ def preperiodic_points(self, m, n, **kwds): sage: R. = QQ[] sage: K. = NumberField(z^4 - z^2 - 1) # needs sage.rings.number_field sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: sorted(f.preperiodic_points(2, 1, R=K), key=str) + sage: sorted(f.preperiodic_points(2, 1, R=K), key=str) # needs sage.rings.number_field [(-v : 1), (v : 1)] :: @@ -5172,10 +5178,11 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: - sage: K. = QuadraticField(5) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + w*x*y + y^2, y^2, z^2]) # needs sage.rings.number_field - sage: f.multiplier_spectra(1) # long time, needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: P. = ProjectiveSpace(K, 2) + sage: f = DynamicalSystem_projective([x^2 + w*x*y + y^2, y^2, z^2]) + sage: f.multiplier_spectra(1) # long time [ [1.000000000000000? - 1.572302755514847?*I 0] [1.000000000000000? - 1.572302755514847?*I 0.618033988749895? - 1.757887921270715?*I] @@ -5583,12 +5590,13 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', :: - sage: K. = QuadraticField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - w*y^2, (1-w)*x*y]) # needs sage.rings.number_field - sage: f.sigma_invariants(2, formal=False, type='cycle') # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 - w*y^2, (1-w)*x*y]) + sage: f.sigma_invariants(2, formal=False, type='cycle') [6*w + 21, 78*w + 159, 210*w + 367, 90*w + 156] - sage: f.sigma_invariants(2, formal=False, type='point') # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=False, type='point') [6*w + 24, 96*w + 222, 444*w + 844, 720*w + 1257, 270*w + 468] :: @@ -7341,10 +7349,11 @@ def all_rational_preimages(self, points): :: - sage: K. = QuadraticField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) # needs sage.rings.number_field - sage: f.all_rational_preimages(P(4)) # needs sage.rings.function_field sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) + sage: f.all_rational_preimages(P(4)) # needs sage.rings.function_field [(-w : 1), (w : 1)] """ if self.domain().base_ring() not in NumberFields(): @@ -7446,10 +7455,11 @@ def all_preperiodic_points(self, **kwds): :: - sage: K. = QuadraticField(33) # needs sage.rings.number_field - sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - 71/48*y^2, y^2]) # needs sage.rings.number_field - sage: sorted(f.all_preperiodic_points()) # long time # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(33) + sage: PS. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^2 - 71/48*y^2, y^2]) + sage: sorted(f.all_preperiodic_points()) # long time [(-1/12*w - 1 : 1), (-1/6*w - 1/4 : 1), (-1/12*w - 1/2 : 1), @@ -7605,10 +7615,11 @@ def rational_preperiodic_graph(self, **kwds): :: - sage: K. = QuadraticField(-3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) # needs sage.rings.number_field - sage: f.rational_preperiodic_graph() # long time # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) + sage: f.rational_preperiodic_graph() # long time Looped digraph on 5 vertices """ #input checking done in .rational_preperiodic_points() @@ -7786,12 +7797,13 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: K. = QuadraticField(-1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.number_field - sage: m = matrix(K, 2, 2, [1, 1, 2, 1]) # needs sage.rings.number_field - sage: g = f.conjugate(m) # needs sage.rings.number_field - sage: sorted(f.conjugating_set(g)) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) + sage: m = matrix(K, 2, 2, [1, 1, 2, 1]) + sage: g = f.conjugate(m) + sage: sorted(f.conjugating_set(g)) [ [-1 -1] [1 1] [ 2 1], [2 1] @@ -7799,10 +7811,11 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: K. = QuadraticField(-1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: D8 = DynamicalSystem_projective([y^3, x^3]) # needs sage.rings.number_field - sage: sorted(D8.conjugating_set(D8)) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: P. = ProjectiveSpace(K, 1) + sage: D8 = DynamicalSystem_projective([y^3, x^3]) + sage: sorted(D8.conjugating_set(D8)) [ [-1 0] [-i 0] [ 0 -1] [ 0 -i] [0 i] [0 1] [i 0] [1 0] [ 0 1], [ 0 1], [ 1 0], [ 1 0], [1 0], [1 0], [0 1], [0 1] @@ -7878,8 +7891,8 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) # needs sage.rings.number_field sage: g = f.conjugate(m1) - sage: m = f.conjugating_set(g)[0] # long time, needs sage.rings.number_field - sage: f.conjugate(m) == g # long time, needs sage.rings.number_field + sage: m = f.conjugating_set(g)[0] # long time # needs sage.rings.number_field + sage: f.conjugate(m) == g # long time # needs sage.rings.number_field True TESTS: @@ -8014,10 +8027,11 @@ def is_conjugate(self, other, R=None, num_cpus=2): EXAMPLES:: - sage: K. = CyclotomicField(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: D8 = DynamicalSystem_projective([y^2, x^2]) # needs sage.rings.number_field - sage: D8.is_conjugate(D8) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: D8 = DynamicalSystem_projective([y^2, x^2]) + sage: D8.is_conjugate(D8) True We can speed up computation by increasing ``num_cpus``:: @@ -8199,18 +8213,20 @@ def is_polynomial(self): :: - sage: K. = QuadraticField(4/27) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x**3 + w*y^3, x*y**2]) # needs sage.rings.number_field - sage: f.is_polynomial() # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(4/27) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x**3 + w*y^3, x*y**2]) + sage: f.is_polynomial() False :: - sage: K = GF(3**2, prefix='w') # needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x**2 + K.gen()*y**2, x*y]) # needs sage.rings.finite_rings - sage: f.is_polynomial() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3**2, prefix='w') + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x**2 + K.gen()*y**2, x*y]) + sage: f.is_polynomial() False :: @@ -8349,10 +8365,11 @@ def normal_form(self, return_conjugation=False): :: - sage: K = GF(3^3, prefix='w') # needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) # needs sage.rings.finite_rings - sage: f.normal_form() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3^3, prefix='w') + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) + sage: f.normal_form() Dynamical System of Projective Space of dimension 1 over Finite Field in w3 of size 3^3 Defn: Defined on coordinates by sending (x : y) to @@ -8705,10 +8722,11 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(2^3) # needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2+z*y]) # needs sage.rings.finite_rings - sage: f.reduce_base_field() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(2^3) + sage: P. = ProjectiveSpace(K, 2) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2+z*y]) + sage: f.reduce_base_field() Dynamical System of Projective Space of dimension 2 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y : z) to (x^2 + y^2 : y^2 : y*z + z^2) @@ -8739,10 +8757,11 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(5) # needs sage.rings.number_field - sage: A. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([3*x^2 + y^2, x*y]) # needs sage.rings.number_field - sage: f.reduce_base_field() # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(5) + sage: A. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([3*x^2 + y^2, x*y]) + sage: f.reduce_base_field() Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (3*x^2 + y^2 : x*y) @@ -9152,11 +9171,12 @@ def automorphism_group(self, **kwds): :: - sage: R. = ProjectiveSpace(GF(3^2,'t'),1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^3, y^3]) # needs sage.rings.finite_rings - sage: lst, label = f.automorphism_group(return_functions=True, # long time, needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = ProjectiveSpace(GF(3^2,'t'),1) + sage: f = DynamicalSystem_projective([x^3, y^3]) + sage: lst, label = f.automorphism_group(return_functions=True, # long time ....: iso_type=True) - sage: sorted(lst, key=str), label # long time # needs sage.rings.finite_rings + sage: sorted(lst, key=str), label # long time ([(2*x + 1)/(x + 1), (2*x + 1)/x, (2*x + 2)/(x + 2), diff --git a/src/sage/dynamics/cellular_automata/elementary.py b/src/sage/dynamics/cellular_automata/elementary.py index 3cf0cd19560..26e68c37b01 100644 --- a/src/sage/dynamics/cellular_automata/elementary.py +++ b/src/sage/dynamics/cellular_automata/elementary.py @@ -225,7 +225,7 @@ class ElementaryCellularAutomata(SageObject): sage: ECA = cellular_automata.Elementary(60, width=200) sage: ECA.evolve(200) - sage: ECA.plot() # optional - sage.plot + sage: ECA.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive .. PLOT:: @@ -239,7 +239,7 @@ class ElementaryCellularAutomata(SageObject): sage: ECA = cellular_automata.Elementary(90, initial_state=[1]+[0]*254+[1], boundary=None) sage: ECA.evolve(256) - sage: ECA.plot() # optional - sage.plot + sage: ECA.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive .. PLOT:: @@ -598,7 +598,7 @@ def plot(self, number=None): sage: ECA = cellular_automata.Elementary(110, width=256) sage: ECA.evolve(256) - sage: ECA.plot() # optional - sage.plot + sage: ECA.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive """ if number is None: diff --git a/src/sage/dynamics/cellular_automata/glca.py b/src/sage/dynamics/cellular_automata/glca.py index 90b7a770548..6b062f2a441 100644 --- a/src/sage/dynamics/cellular_automata/glca.py +++ b/src/sage/dynamics/cellular_automata/glca.py @@ -67,7 +67,7 @@ class GraftalLaceCellularAutomata(SageObject): sage: G = cellular_automata.GraftalLace([2,0,3,3,6,0,2,7]) sage: G.evolve(20) - sage: G.plot() # optional - sage.plot + sage: G.plot() # needs sage.plot Graphics object consisting of 842 graphics primitives .. PLOT:: @@ -398,7 +398,7 @@ def plot(self, number=None): sage: G = cellular_automata.GraftalLace([5,1,2,5,4,5,5,0]) sage: G.evolve(20) - sage: G.plot() # optional - sage.plot + sage: G.plot() # needs sage.plot Graphics object consisting of 865 graphics primitives """ if number is None: From d41ca2a675ebf7d7829bfc864c20fda864512431 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 18 Aug 2023 13:55:19 -0700 Subject: [PATCH 080/494] src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx: Add # needs --- src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx index 9ee71e4f4bf..43ce0effd58 100644 --- a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx +++ b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx @@ -1,4 +1,5 @@ # cython: binding=True +# sage.doctest: needs sage.plot r""" Mandelbrot and Julia sets (Cython helper) From a7ad632d90e49a3bd6af15cd20e0b11c7a451676 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:56:22 -0700 Subject: [PATCH 081/494] sage.dynamics: Add # needs --- .../dynamics/arithmetic_dynamics/affine_ds.py | 53 +- .../dynamical_semigroup.py | 454 +++++++++--------- .../arithmetic_dynamics/generic_ds.py | 16 +- .../dynamics/arithmetic_dynamics/wehlerK3.py | 27 +- 4 files changed, 288 insertions(+), 262 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py index 23cdb1a9b51..6938068bbc6 100644 --- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py @@ -162,8 +162,9 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space, If you pass in quotient ring elements, they are reduced:: + sage: # needs sage.libs.singular sage: A. = AffineSpace(QQ, 3) - sage: X = A.subscheme([x-y]) + sage: X = A.subscheme([x - y]) sage: u,v,w = X.coordinate_ring().gens() sage: DynamicalSystem_affine([u, v, u+v], domain=X) Dynamical System of Closed subscheme of Affine Space of dimension 3 @@ -174,9 +175,10 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space, :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: A. = AffineSpace(R, 3) - sage: X = A.subscheme(x^2-y^2) + sage: X = A.subscheme(x^2 - y^2) sage: H = End(X) sage: f = H([x^2/(t*y), t*y^2, x*z]) sage: DynamicalSystem_affine(f) @@ -454,7 +456,7 @@ def dynatomic_polynomial(self, period): sage: A. = AffineSpace(ZZ, 1) sage: f = DynamicalSystem_affine([(x^2+1)/x]) - sage: f.dynatomic_polynomial(4) + sage: f.dynatomic_polynomial(4) # needs sage.libs.pari 2*x^12 + 18*x^10 + 57*x^8 + 79*x^6 + 48*x^4 + 12*x^2 + 1 :: @@ -771,7 +773,7 @@ def multiplier(self, P, n, check=True): sage: P. = AffineSpace(CC, 1) sage: f = DynamicalSystem_affine([x^2 + 1/2]) - sage: f.multiplier(P([0.5 + 0.5*I]), 1) + sage: f.multiplier(P([0.5 + 0.5*I]), 1) # needs sage.symbolic [1.00000000000000 + 1.00000000000000*I] :: @@ -785,7 +787,7 @@ def multiplier(self, P, n, check=True): :: sage: P. = AffineSpace(QQ, 2) - sage: X = P.subscheme([x^2-y^2]) + sage: X = P.subscheme([x^2 - y^2]) sage: f = DynamicalSystem_affine([x^2, y^2], domain=X) sage: f.multiplier(X([1, 1]), 1) [2 0] @@ -824,7 +826,7 @@ def conjugate(self, M): EXAMPLES:: sage: A. = AffineSpace(QQ, 1) - sage: f = DynamicalSystem_affine([t^2+1]) + sage: f = DynamicalSystem_affine([t^2 + 1]) sage: f.conjugate(matrix([[1,2], [0,1]])) Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (t) to @@ -833,18 +835,20 @@ def conjugate(self, M): :: sage: A. = AffineSpace(ZZ,2) - sage: f = DynamicalSystem_affine([x^3+y^3,y^2]) + sage: f = DynamicalSystem_affine([x^3 + y^3, y^2]) sage: f.conjugate(matrix([[1,2,3], [0,1,2], [0,0,1]])) Dynamical System of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to - (x^3 + 6*x^2*y + 12*x*y^2 + 9*y^3 + 9*x^2 + 36*x*y + 40*y^2 + 27*x + 58*y + 28, y^2 + 4*y + 2) + (x^3 + 6*x^2*y + 12*x*y^2 + 9*y^3 + + 9*x^2 + 36*x*y + 40*y^2 + 27*x + 58*y + 28, y^2 + 4*y + 2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2+1) + sage: K. = NumberField(x^2 + 1) sage: A. = AffineSpace(ZZ,1) - sage: f = DynamicalSystem_affine([x^3+2*x^2+3]) + sage: f = DynamicalSystem_affine([x^3 + 2*x^2 + 3]) sage: f.conjugate(matrix([[i,i], [0,-i]])) Dynamical System of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x) to @@ -861,6 +865,7 @@ def degree(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QuadraticField(7) sage: A. = AffineSpace(R, 3) sage: f = DynamicalSystem_affine([x^2 + y^5 + c, x^11, z^19]) @@ -912,9 +917,10 @@ def weil_restriction(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(5) sage: A. = AffineSpace(K, 2) - sage: f = DynamicalSystem_affine([x^2-y^2, y^2]) + sage: f = DynamicalSystem_affine([x^2 - y^2, y^2]) sage: f.weil_restriction() Dynamical System of Affine Space of dimension 4 over Rational Field Defn: Defined on coordinates by sending (z0, z1, z2, z3) to @@ -922,6 +928,7 @@ def weil_restriction(self): :: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(5) sage: PS. = AffineSpace(K, 2) sage: f = DynamicalSystem_affine([x, y]) @@ -941,13 +948,14 @@ def reduce_base_field(self): The base field of the map could be strictly larger than the field where all of the coefficients are defined. This function reduces the base field to the minimal possible. This can be done when - the base ring is a number field, QQbar, a finite field, or algebraic + the base ring is a number field, ``QQbar``, a finite field, or algebraic closure of a finite field. OUTPUT: A dynamical system EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2) sage: A. = AffineSpace(K, 2) sage: f = DynamicalSystem_affine([x^2 + 3*y^2, 3*y^2]) @@ -958,10 +966,11 @@ def reduce_base_field(self): :: - sage: A. = AffineSpace(QQbar, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, # needs sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: A. = AffineSpace(QQbar, 2) + sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, ....: QQbar(sqrt(-1))*y^2]) - sage: f.reduce_base_field() # needs sage.rings.number_field sage.symbolic + sage: f.reduce_base_field() Dynamical System of Affine Space of dimension 2 over Number Field in a with defining polynomial y^4 - y^2 + 1 with a = -0.866025403784439? + 0.50000000000000000?*I @@ -1006,6 +1015,7 @@ def orbit_structure(self, P): :: + sage: # needs sage.rings.finite_rings sage: A. = AffineSpace(GF(49, 't'), 3) sage: f = DynamicalSystem_affine([x^2 - z, x - y + z, y^2 - x^2]) sage: f.orbit_structure(A(1, 1, 2)) @@ -1033,23 +1043,24 @@ def cyclegraph(self): EXAMPLES:: sage: P. = AffineSpace(GF(5), 2) - sage: f = DynamicalSystem_affine([x^2-y, x*y+1]) - sage: f.cyclegraph() + sage: f = DynamicalSystem_affine([x^2 - y, x*y + 1]) + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 25 vertices :: + sage: # needs sage.rings.finite_rings sage: P. = AffineSpace(GF(3^3, 't'), 1) - sage: f = DynamicalSystem_affine([x^2-1]) - sage: f.cyclegraph() + sage: f = DynamicalSystem_affine([x^2 - 1]) + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 27 vertices :: sage: P. = AffineSpace(GF(7), 2) - sage: X = P.subscheme(x-y) + sage: X = P.subscheme(x - y) sage: f = DynamicalSystem_affine([x^2, y^2], domain=X) - sage: f.cyclegraph() + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 7 vertices """ V = [] diff --git a/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py b/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py index 5b324ddbd9a..ebb8702a7db 100644 --- a/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py +++ b/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py @@ -51,13 +51,12 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: P. = ProjectiveSpace(QQ, 1) sage: DynamicalSemigroup(([x, y], [x^2, y^2])) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) :: @@ -65,23 +64,22 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem([x, y], P) sage: g = DynamicalSystem([x^2, y^2], P) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) :: sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem_affine(x, A) sage: DynamicalSemigroup(f) - Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 1 dynamical system: - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x) + Dynamical semigroup over Affine Space of dimension 1 over Rational Field + defined by 1 dynamical system: + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x) :: @@ -89,13 +87,12 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem(x, A) sage: g = DynamicalSystem(x^2, A) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x) - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical semigroup over Affine Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x) + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x^2) :: @@ -104,32 +101,32 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem_projective([x, y], X) sage: g = DynamicalSystem_projective([x^2, y^2], X) sage: DynamicalSemigroup_projective([f, g]) - Dynamical semigroup over Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: - x - y defined by 2 dynamical systems: - Dynamical System of Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: - x - y - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: - x - y - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) - - If a dynamical semigroup is built from dynamical systems with different base rings, all systems will be coerced - to the largest base ring:: + Dynamical semigroup over Closed subscheme of Projective Space of dimension 1 + over Rational Field defined by: x - y + defined by 2 dynamical systems: + Dynamical System of Closed subscheme of Projective Space of dimension 1 + over Rational Field defined by: x - y + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Closed subscheme of Projective Space of dimension 1 + over Rational Field defined by: x - y + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) + + If a dynamical semigroup is built from dynamical systems with different base rings, + all systems will be coerced to the largest base ring:: sage: P. = ProjectiveSpace(QQ, 1) sage: Q. = ProjectiveSpace(RR, 1) sage: f = DynamicalSystem([x, y], P) sage: g = DynamicalSystem([z^2, w^2], Q) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Real Field with 53 bits of precision defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 + over Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 + over Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) :: @@ -138,17 +135,19 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem(x, A) sage: g = DynamicalSystem(y^2, B) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Affine Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x) to - (x) - Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical semigroup over Affine Space of dimension 1 over + Real Field with 53 bits of precision defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over + Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x) to (x) + Dynamical System of Affine Space of dimension 1 over + Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x) to (x^2) If a dynamical semigroup is built from dynamical systems over number fields, a composite number field is created and all systems will be coerced to it. This composite number field contains all of the initial number fields:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(r^2 - 2) sage: P. = ProjectiveSpace(QQ, 1) @@ -156,16 +155,18 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem([x, y], P) sage: g = DynamicalSystem([z^2, w^2], Q) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2 defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2 - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2 - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Number Field in k with defining polynomial r^2 - 2 defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Number Field in k with defining polynomial r^2 - 2 + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over + Number Field in k with defining polynomial r^2 - 2 + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(r^2 - 2) sage: L. = NumberField(r^2 - 3) @@ -174,16 +175,19 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem([x, y], P) sage: g = DynamicalSystem([z^2, w^2], Q) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(r^2 - 2) sage: L. = NumberField(r^2 - 3) @@ -192,102 +196,107 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): sage: f = DynamicalSystem(x, P) sage: g = DynamicalSystem(y^2, Q) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 - Defn: Defined on coordinates by sending (x) to - (x) - Dynamical System of Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical semigroup over Affine Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + Defn: Defined on coordinates by sending (x) to (x) + Dynamical System of Affine Space of dimension 1 over + Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 + Defn: Defined on coordinates by sending (x) to (x^2) A dynamical semigroup may contain dynamical systems over function fields:: - sage: R. = QQ[] - sage: P. = ProjectiveSpace(R, 1) - sage: f = DynamicalSystem([r * x, y], P) - sage: g = DynamicalSystem([x, r * y], P) - sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (r*x : y) - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : r*y) + sage: R. = QQ[] + sage: P. = ProjectiveSpace(R, 1) + sage: f = DynamicalSystem([r * x, y], P) + sage: g = DynamicalSystem([x, r * y], P) + sage: DynamicalSemigroup((f, g)) + Dynamical semigroup over Projective Space of dimension 1 over Univariate + Polynomial Ring in r over Rational Field defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (r*x : y) + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : r*y) - :: + :: - sage: R. = QQ[] - sage: P. = ProjectiveSpace(R, 1) - sage: f = DynamicalSystem([r * x, y], P) - sage: g = DynamicalSystem([x, y], P) - sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (r*x : y) - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) + sage: R. = QQ[] + sage: P. = ProjectiveSpace(R, 1) + sage: f = DynamicalSystem([r * x, y], P) + sage: g = DynamicalSystem([x, y], P) + sage: DynamicalSemigroup((f, g)) + Dynamical semigroup over Projective Space of dimension 1 over Univariate + Polynomial Ring in r over Rational Field defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (r*x : y) + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) - :: + :: - sage: R. = QQ[] - sage: P. = ProjectiveSpace(R, 1) - sage: f = DynamicalSystem([r * x, y], P) - sage: g = DynamicalSystem([s * x, y], P) - sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (r*x : y) - Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (s*x : y) + sage: R. = QQ[] + sage: P. = ProjectiveSpace(R, 1) + sage: f = DynamicalSystem([r * x, y], P) + sage: g = DynamicalSystem([s * x, y], P) + sage: DynamicalSemigroup((f, g)) + Dynamical semigroup over Projective Space of dimension 1 over Multivariate + Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Multivariate Polynomial Ring in r, s over Rational Field + Defn: Defined on coordinates by sending (x : y) to (r*x : y) + Dynamical System of Projective Space of dimension 1 over + Multivariate Polynomial Ring in r, s over Rational Field + Defn: Defined on coordinates by sending (x : y) to (s*x : y) - :: + :: - sage: R. = QQ[] - sage: P. = ProjectiveSpace(R, 1) - sage: f = DynamicalSystem([r * x, s * y], P) - sage: g = DynamicalSystem([s * x, r * y], P) - sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (r*x : s*y) - Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (s*x : r*y) + sage: R. = QQ[] + sage: P. = ProjectiveSpace(R, 1) + sage: f = DynamicalSystem([r * x, s * y], P) + sage: g = DynamicalSystem([s * x, r * y], P) + sage: DynamicalSemigroup((f, g)) + Dynamical semigroup over Projective Space of dimension 1 over + Multivariate Polynomial Ring in r, s over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Multivariate Polynomial Ring in r, s over Rational Field + Defn: Defined on coordinates by sending (x : y) to (r*x : s*y) + Dynamical System of Projective Space of dimension 1 over + Multivariate Polynomial Ring in r, s over Rational Field + Defn: Defined on coordinates by sending (x : y) to (s*x : r*y) A dynamical semigroup may contain dynamical systems over finite fields:: sage: F = FiniteField(5) sage: P. = ProjectiveSpace(F, 1) sage: DynamicalSemigroup(([x, y], [x^2, y^2])) - Dynamical semigroup over Projective Space of dimension 1 over Finite Field of size 5 defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Finite Field of size 5 - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Finite Field of size 5 - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Finite Field of size 5 defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Finite Field of size 5 + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over Finite Field of size 5 + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) - If a dynamical semigroup is built from dynamical systems over both projective and affine spaces, all systems - will be homogenized to dynamical systems over projective space:: + If a dynamical semigroup is built from dynamical systems over both projective and + affine spaces, all systems will be homogenized to dynamical systems over projective space:: sage: P. = ProjectiveSpace(QQ, 1) sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem([x, y], P) sage: g = DynamicalSystem(z^2, A) sage: DynamicalSemigroup((f, g)) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) TESTS:: @@ -299,6 +308,7 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(r^2 - 2) sage: P. = ProjectiveSpace(RR, 1) @@ -443,13 +453,14 @@ def change_ring(self, new_ring): sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSemigroup(([x, y], [x^2, y^2])) sage: f.change_ring(RR) - Dynamical semigroup over Projective Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Real Field with 53 bits of precision defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over + Real Field with 53 bits of precision + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) """ new_systems = [] for ds in self.defining_systems(): @@ -516,11 +527,9 @@ def defining_systems(self): sage: f = DynamicalSemigroup(([x, y], [x^2, y^2])) sage: f.defining_systems() (Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y), + Defn: Defined on coordinates by sending (x : y) to (x : y), Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2)) + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)) """ return tuple(self._dynamical_systems) @@ -760,13 +769,12 @@ def specialization(self, assignments): sage: g = DynamicalSystem([x, r * y], P) sage: d = DynamicalSemigroup((f, g)) sage: d.specialization({r:2}) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (2*x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : 2*y) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (2*x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : 2*y) :: @@ -776,13 +784,12 @@ def specialization(self, assignments): sage: g = DynamicalSystem([x, y], P) sage: d = DynamicalSemigroup((f, g)) sage: d.specialization({r:2}) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (2*x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (2*x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) :: @@ -792,13 +799,12 @@ def specialization(self, assignments): sage: g = DynamicalSystem([s * x, y], P) sage: d = DynamicalSemigroup((f, g)) sage: d.specialization({r:2, s:3}) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (2*x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (3*x : y) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (2*x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (3*x : y) :: @@ -808,13 +814,15 @@ def specialization(self, assignments): sage: g = DynamicalSystem([s * x, r * y], P) sage: d = DynamicalSemigroup((f, g)) sage: d.specialization({s:3}) - Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (r*x : 3*y) - Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (3*x : r*y) + Dynamical semigroup over Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (r*x : 3*y) + Dynamical System of Projective Space of dimension 1 over + Univariate Polynomial Ring in r over Rational Field + Defn: Defined on coordinates by sending (x : y) to (3*x : r*y) """ specialized_systems = [] for ds in self.defining_systems(): @@ -1222,13 +1230,12 @@ class DynamicalSemigroup_projective(DynamicalSemigroup): sage: P. = ProjectiveSpace(QQ, 1) sage: DynamicalSemigroup_projective(([x, y], [x^2, y^2])) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x : y) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^2 : y^2) + Dynamical semigroup over Projective Space of dimension 1 over + Rational Field defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x : y) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) """ @staticmethod @@ -1282,13 +1289,12 @@ def dehomogenize(self, n): sage: g = DynamicalSystem([x^2, y^2], P) sage: d = DynamicalSemigroup((f, g)) sage: d.dehomogenize(0) - Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (y) to - (y) - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (y) to - (y^2) + Dynamical semigroup over Affine Space of dimension 1 over + Rational Field defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (y) to (y) + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (y) to (y^2) :: @@ -1297,13 +1303,12 @@ def dehomogenize(self, n): sage: g = DynamicalSystem([x^2, y^2], P) sage: d = DynamicalSemigroup((f, g)) sage: d.dehomogenize(1) - Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x) - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical semigroup over Affine Space of dimension 1 over + Rational Field defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x) + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x^2) TESTS:: @@ -1317,8 +1322,8 @@ def dehomogenize(self, n): ValueError: Scheme morphism: From: Affine Space of dimension 1 over Rational Field To: Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (1/x) is not a `DynamicalSystem_affine` object + Defn: Defined on coordinates by sending (x) to (1/x) + is not a `DynamicalSystem_affine` object """ new_systems = [] for ds in self.defining_systems(): @@ -1354,13 +1359,12 @@ class DynamicalSemigroup_affine(DynamicalSemigroup): sage: f = DynamicalSystem(x, A) sage: g = DynamicalSystem(x^2, A) sage: DynamicalSemigroup_affine((f, g)) - Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x) - Dynamical System of Affine Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x) to - (x^2) + Dynamical semigroup over Affine Space of dimension 1 over + Rational Field defined by 2 dynamical systems: + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x) + Dynamical System of Affine Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x) to (x^2) """ @staticmethod @@ -1411,13 +1415,12 @@ def homogenize(self, n): sage: g = DynamicalSystem(x^2, A) sage: d = DynamicalSemigroup((f, g)) sage: d.homogenize(1) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x0 : x1) to - (x0 + x1 : x1) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x0 : x1) to - (x0^2 : x1^2) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x0 : x1) to (x0 + x1 : x1) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x0 : x1) to (x0^2 : x1^2) :: @@ -1426,13 +1429,12 @@ def homogenize(self, n): sage: g = DynamicalSystem(x^2, A) sage: d = DynamicalSemigroup((f, g)) sage: d.homogenize((1, 0)) - Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems: - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x0 : x1) to - (x1 : x0 + x1) - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x0 : x1) to - (x1^2 : x0^2) + Dynamical semigroup over Projective Space of dimension 1 over Rational Field + defined by 2 dynamical systems: + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0 + x1) + Dynamical System of Projective Space of dimension 1 over Rational Field + Defn: Defined on coordinates by sending (x0 : x1) to (x1^2 : x0^2) """ new_systems = [] for ds in self.defining_systems(): @@ -1466,11 +1468,9 @@ def _standardize_domains_of_(systems): sage: g = DynamicalSystem(x^2, B) sage: sage.dynamics.arithmetic_dynamics.dynamical_semigroup._standardize_domains_of_([f, g]) [Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x) to - (x), + Defn: Defined on coordinates by sending (x) to (x), Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision - Defn: Defined on coordinates by sending (x) to - (x^2)] + Defn: Defined on coordinates by sending (x) to (x^2)] """ identical_domains = True for ds in systems: diff --git a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py index a9a945124fd..9d6e877d424 100644 --- a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py @@ -139,6 +139,8 @@ class DynamicalSystem(SchemeMorphism_polynomial, Projective Space of dimension 1 over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y) to (1.00000000000000*I*x^2 : 0.800000000000000*y^2) + + sage: # needs sage.rings.finite_rings sage: P. = ProjectiveSpace(GF(5), 1) sage: K. = GF(25) sage: DynamicalSystem([GF(5)(3)*x^2, K(t)*y^2]) @@ -364,6 +366,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals Note that the number of critical points is `2d-2`, but `(1:0)` has multiplicity 2 in this case:: + sage: # needs sage.libs.singular sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/3*x^3 + x*y^2, y^3], domain=P) sage: f.critical_points() @@ -376,6 +379,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals :: + sage: # needs sage.libs.singular sage.rings.number_field sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem([z^4 + 2*z^2 + 2], domain=A) sage: K. = f.field_of_definition_critical(); K @@ -383,6 +387,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals :: + sage: # needs sage.libs.singular sage.rings.finite_rings sage: G. = GF(9) sage: R. = G[] sage: R.irreducible_element(3, algorithm='first_lexicographic') @@ -470,6 +475,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False, EXAMPLES:: + sage: # needs sage.libs.singular sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([x^2, y^2], domain=P) sage: f.periodic_points(3, minimal=False) @@ -489,6 +495,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False, :: + sage: # needs sage.libs.singular sage.rings.number_field sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem([(z^2 + 1)/(2*z + 1)], domain=A) sage: K. = f.field_of_definition_periodic(2); K @@ -498,6 +505,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False, :: + sage: # needs sage.rings.finite_rings sage: G. = GF(4) sage: A. = AffineSpace(G, 1) sage: f = DynamicalSystem([x^2 + (a+1)*x + 1], domain=A) @@ -589,7 +597,8 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/3*x^2 + 2/3*x*y, x^2 - 2*y^2], domain=P) - sage: N. = f.field_of_definition_preimage(P(1,1), 2, simplify_all=True); N + sage: N. = f.field_of_definition_preimage(P(1,1), 2, # needs sage.rings.number_field + ....: simplify_all=True); N Number Field in a with defining polynomial x^8 - 4*x^7 - 128*x^6 + 398*x^5 + 3913*x^4 - 8494*x^3 - 26250*x^2 + 30564*x - 2916 @@ -597,7 +606,7 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif sage: A. = AffineSpace(QQ, 1) sage: f = DynamicalSystem([z^2], domain=A) - sage: K. = f.field_of_definition_preimage(A(1), 3); K + sage: K. = f.field_of_definition_preimage(A(1), 3); K # needs sage.rings.number_field Number Field in a with defining polynomial z^4 + 1 :: @@ -605,7 +614,8 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif sage: G = GF(5) sage: P. = ProjectiveSpace(G, 1) sage: f = DynamicalSystem([x^2 + 2*y^2, y^2], domain=P) - sage: f.field_of_definition_preimage(P(2,1), 2, return_embedding=True, names='a') + sage: f.field_of_definition_preimage(P(2,1), 2, return_embedding=True, # needs sage.rings.number_field + ....: names='a') (Finite Field in a of size 5^2, Ring morphism: From: Finite Field of size 5 diff --git a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py index 0d1672e15d0..72676c1ad2a 100644 --- a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py +++ b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py @@ -25,25 +25,30 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.calculus.functions import jacobian -from sage.categories.fields import Fields +from copy import copy + +import sage.rings.abc + from sage.categories.commutative_rings import CommutativeRings +from sage.categories.fields import Fields from sage.categories.number_fields import NumberFields -from sage.misc.functional import sqrt from sage.misc.cachefunc import cached_method +from sage.misc.functional import sqrt +from sage.misc.lazy_import import lazy_import from sage.misc.mrange import xmrange from sage.rings.finite_rings.finite_field_constructor import GF from sage.rings.fraction_field import FractionField from sage.rings.integer_ring import ZZ -from sage.rings.number_field.order import is_NumberFieldOrder -from sage.rings.padics.factory import Qp from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme -from sage.schemes.product_projective.subscheme import AlgebraicScheme_subscheme_product_projective from sage.schemes.product_projective.space import ProductProjectiveSpaces -from copy import copy +from sage.schemes.product_projective.subscheme import AlgebraicScheme_subscheme_product_projective + +lazy_import("sage.calculus.functions", "jacobian") +lazy_import('sage.rings.padics.factory', 'Qp') + _NumberFields = NumberFields() _Fields = Fields() @@ -908,11 +913,11 @@ def degenerate_primes(self,check=True): [2, 3, 5, 11, 23, 47, 48747691, 111301831] """ PP = self.ambient_space() - if PP.base_ring() in _NumberFields or is_NumberFieldOrder(PP.base_ring()): - if PP.base_ring() != ZZ and PP.base_ring() != QQ: + if PP.base_ring() != ZZ and PP.base_ring() != QQ: + if PP.base_ring() in _NumberFields or isinstance(PP.base_ring(), sage.rings.abc.Order): raise NotImplementedError("must be ZZ or QQ") - else: - raise TypeError("must be over a number field") + else: + raise TypeError("must be over a number field") if self.is_degenerate(): raise TypeError("surface is degenerate at all primes") RR = PP.coordinate_ring() From a0379b53a069bfcdb5debf8e39c9ecf31c21ce37 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 9 Sep 2023 12:35:52 -0700 Subject: [PATCH 082/494] sage.schemes: Update # needs --- src/sage/schemes/generic/algebraic_scheme.py | 30 +++++++++++-------- .../schemes/projective/projective_morphism.py | 16 +++++----- .../projective/projective_rational_point.py | 2 +- src/sage/schemes/toric/chow_group.py | 8 ++--- src/sage/schemes/toric/divisor.py | 8 ++--- src/sage/schemes/toric/toric_subscheme.py | 20 +++++++++---- src/sage/schemes/toric/variety.py | 12 ++++---- 7 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index 01b7229f846..b5eb3d4ed32 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -278,9 +278,10 @@ def is_projective(self): projective spaces. This is why this method returns ``False`` for toric varieties:: - sage: PP. = toric_varieties.P(3) # needs sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron sage.graphs + sage: PP. = toric_varieties.P(3) sage: V = PP.subscheme(x^3 + y^3 + z^3 + w^3) - sage: V.is_projective() # needs sage.geometry.polyhedron + sage: V.is_projective() False """ return self.ambient_space().is_projective() @@ -386,9 +387,11 @@ def embedding_morphism(self): defined by: x^2 + y^2 - 1 To: Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (x, y) - sage: P1xP1. = toric_varieties.P1xP1() # needs sage.geometry.polyhedron - sage: P1 = P1xP1.subscheme(x - y) # needs sage.geometry.polyhedron sage.libs.singular - sage: P1.embedding_morphism() # needs sage.geometry.polyhedron sage.libs.singular + +i sage: # needs sage.graphs sage.geometry.polyhedron sage.libs.singular + sage: P1xP1. = toric_varieties.P1xP1() + sage: P1 = P1xP1.subscheme(x - y) + sage: P1.embedding_morphism() Scheme morphism: From: Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: x - y @@ -427,18 +430,18 @@ def embedding_morphism(self): A couple more examples:: - sage: # needs sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron sage.graphs sage.libs.singular sage: patch1 = P1xP1.affine_patch(1); patch1 2-d affine toric variety - sage: patch1.embedding_morphism() # needs sage.libs.singular + sage: patch1.embedding_morphism() Scheme morphism: From: 2-d affine toric variety To: 2-d CPR-Fano toric variety covered by 4 affine patches Defn: Defined on coordinates by sending [y : u] to [1 : y : u : 1] - sage: subpatch = P1.affine_patch(1); subpatch # needs sage.libs.singular + sage: subpatch = P1.affine_patch(1); subpatch Closed subscheme of 2-d affine toric variety defined by: -y + 1 - sage: subpatch.embedding_morphism() # needs sage.libs.singular + sage: subpatch.embedding_morphism() Scheme morphism: From: Closed subscheme of 2-d affine toric variety defined by: -y + 1 To: Closed subscheme of 2-d CPR-Fano toric variety covered @@ -543,7 +546,7 @@ def _homset(self, *args, **kwds): EXAMPLES:: - sage: # needs sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron sage.graphs sage: P1. = toric_varieties.P1() sage: type(P1.Hom(P1)) @@ -553,9 +556,10 @@ def _homset(self, *args, **kwds): :: - sage: P1xP1 = toric_varieties.P1xP1() # needs sage.geometry.polyhedron - sage: P1 = toric_varieties.P1() # needs sage.geometry.polyhedron - sage: P1xP1._homset(P1xP1, P1) # needs sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron sage.graphs + sage: P1xP1 = toric_varieties.P1xP1() + sage: P1 = toric_varieties.P1() + sage: P1xP1._homset(P1xP1, P1) Set of morphisms From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 1-d CPR-Fano toric variety covered by 2 affine patches diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index bd110b059ed..d4bd02eba78 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -1366,7 +1366,7 @@ def global_height(self, prec=None): :: - sage: # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage.symbolic sage: P. = ProjectiveSpace(QQbar, 1) sage: P2. = ProjectiveSpace(QQbar, 2) sage: H = Hom(P, P2) @@ -2082,18 +2082,18 @@ def reduce_base_field(self): sage: H2 = Hom(P, P2) sage: H3 = Hom(P2, P) sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) - sage: f.reduce_base_field() # needs sage.modules + sage: f.reduce_base_field() # needs sage.libs.singular sage.modules Scheme endomorphism of Projective Space of dimension 1 over Finite Field in t2 of size 3^2 Defn: Defined on coordinates by sending (x : y) to (x^2 + t2*y^2 : y^2) sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) - sage: f2.reduce_base_field() # needs sage.modules + sage: f2.reduce_base_field() # needs sage.libs.singular sage.modules Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 3 To: Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 - y^2 : y^2 : -x*y) sage: f3 = H3([a^2 + t*b^2, c^2]) - sage: f3.reduce_base_field() # needs sage.modules + sage: f3.reduce_base_field() # needs sage.libs.singular sage.modules Scheme morphism: From: Projective Space of dimension 2 over Finite Field in t of size 3^4 To: Projective Space of dimension 1 over Finite Field in t of size 3^4 @@ -2106,7 +2106,7 @@ def reduce_base_field(self): sage: P. = ProjectiveSpace(K, 1) sage: H = End(P) sage: f = H([x^2 + 2*y^2, y^2]) - sage: f.reduce_base_field() + sage: f.reduce_base_field() # needs sage.libs.singular Scheme endomorphism of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 + 2*y^2 : y^2) @@ -2118,13 +2118,13 @@ def reduce_base_field(self): sage: P. = ProjectiveSpace(L, 1) sage: H = End(P) sage: f = H([(L.gen(2))*x^2 + L.gen(4)*y^2, x*y]) - sage: f.reduce_base_field() + sage: f.reduce_base_field() # needs sage.libs.singular Scheme endomorphism of Projective Space of dimension 1 over Finite Field in z4 of size 5^4 Defn: Defined on coordinates by sending (x : y) to ((z4^3 + z4^2 + z4 - 2)*x^2 + z4*y^2 : x*y) sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) - sage: f.reduce_base_field() + sage: f.reduce_base_field() # needs sage.libs.singular Dynamical System of Projective Space of dimension 1 over Finite Field in z6 of size 5^6 Defn: Defined on coordinates by sending (x : y) to @@ -2138,7 +2138,7 @@ def reduce_base_field(self): sage: P. = ProjectiveSpace(F, 1) sage: H = Hom(P, P) sage: f = H([x^2 + y^2, y^2]) - sage: f.reduce_base_field() + sage: f.reduce_base_field() # needs sage.libs.singular Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) diff --git a/src/sage/schemes/projective/projective_rational_point.py b/src/sage/schemes/projective/projective_rational_point.py index 31dc0703b5a..bd66a798cce 100644 --- a/src/sage/schemes/projective/projective_rational_point.py +++ b/src/sage/schemes/projective/projective_rational_point.py @@ -191,7 +191,7 @@ def enum_projective_number_field(X, **kwds): sage: K = NumberField(u^3 - 5, 'v') sage: P. = ProjectiveSpace(K, 2) sage: X = P.subscheme([x - y]) - sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) + sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) # needs sage.symbolic [(0 : 0 : 1), (1 : 1 : 0), (-1 : -1 : 1), (1 : 1 : 1)] :: diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py index ae3d245c744..dac091a4f6f 100644 --- a/src/sage/schemes/toric/chow_group.py +++ b/src/sage/schemes/toric/chow_group.py @@ -317,7 +317,7 @@ def count_points(self): sage: aD = a.intersection_with_divisor(D) sage: aD.count_points() 1 - sage: P2.integrate( aD.cohomology_class() ) + sage: P2.integrate(aD.cohomology_class()) # needs sage.libs.singular 1 For toric varieties with at most orbifold singularities, the @@ -333,7 +333,7 @@ def count_points(self): V(y) sage: Dt.Chow_cycle(QQ).intersection_with_divisor(Dy).count_points() 1/2 - sage: P1xP1_Z2.integrate( Dt.cohomology_class() * Dy.cohomology_class() ) + sage: P1xP1_Z2.integrate(Dt.cohomology_class() * Dy.cohomology_class()) # needs sage.libs.singular 1/2 """ return sum(self.project_to_degree(0).lift()) @@ -476,6 +476,7 @@ def cohomology_class(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: dP6 = toric_varieties.dP6() sage: cone = dP6.fan().cone_containing(2,3) sage: HH = dP6.cohomology_ring() @@ -491,6 +492,7 @@ def cohomology_class(self): singularities, where we can also use the isomorphism with the rational cohomology ring:: + sage: # needs sage.libs.singular sage: WP4 = toric_varieties.P4_11169() sage: A = WP4.Chow_group() sage: HH = WP4.cohomology_ring() @@ -499,13 +501,11 @@ def cohomology_class(self): ( 0 | -1 | 0 | 0 | 0 ) sage: HH(cone3d) [3*z4^3] - sage: D = -WP4.K() # the anticanonical divisor sage: A(D) ( 0 | 0 | 0 | -18 | 0 ) sage: HH(D) [18*z4] - sage: WP4.integrate( A(cone3d).cohomology_class() * D.cohomology_class() ) 1 sage: WP4.integrate( HH(cone3d) * D.cohomology_class() ) diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index 3fbdae4cdb5..fb0bdbbfd17 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -818,7 +818,7 @@ def cohomology_class(self): sage: dP6 = toric_varieties.dP6() sage: D = dP6.divisor(dP6.fan().ray(0)) - sage: D.cohomology_class() + sage: D.cohomology_class() # needs sage.libs.singular [y + v - w] """ divisor = vector(self) @@ -841,9 +841,9 @@ def Chern_character(self): sage: D5 = dP6.divisor(dP6.fan().cone_containing( N(-1,-1) )) sage: D6 = dP6.divisor(dP6.fan().cone_containing( N(0,-1) )) sage: D = -D3 + 2*D5 - D6 - sage: D.Chern_character() + sage: D.Chern_character() # needs sage.libs.singular [5*w^2 + y - 2*v + w + 1] - sage: dP6.integrate( D.ch() * dP6.Td() ) + sage: dP6.integrate(D.ch() * dP6.Td()) # needs sage.libs.singular -4 """ return self.cohomology_class().exp() @@ -1531,7 +1531,7 @@ def cohomology(self, weight=None, deg=None, dim=False): 2: Vector space of dimension 0 over Rational Field} sage: D.cohomology( weight=M(0,0), deg=1 ) Vector space of dimension 1 over Rational Field - sage: dP6.integrate( D.ch() * dP6.Td() ) + sage: dP6.integrate(D.ch() * dP6.Td()) # needs sage.libs.singular -4 Note the different output options:: diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py index acdfd05d0d1..cc5b0e3158a 100644 --- a/src/sage/schemes/toric/toric_subscheme.py +++ b/src/sage/schemes/toric/toric_subscheme.py @@ -123,8 +123,8 @@ def _morphism(self, *args, **kwds): Defn: Defined on coordinates by sending [s : t : x : y] to [s : s : x : y] - sage: sbar, tbar, xbar, ybar = P1.coordinate_ring().gens() - sage: P1._morphism(H, [sbar, sbar, xbar, ybar]) + sage: sbar, tbar, xbar, ybar = P1.coordinate_ring().gens() # needs sage.libs.singular + sage: P1._morphism(H, [sbar, sbar, xbar, ybar]) # needs sage.libs.singular Scheme morphism: From: Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: @@ -425,6 +425,7 @@ def neighborhood(self, point): EXAMPLES:: + sage: # needs sage.libs.singular sage: P. = toric_varieties.P2() sage: S = P.subscheme(x + 2*y + 3*z) sage: s = S.point([0,-3,2]); s @@ -445,6 +446,7 @@ def neighborhood(self, point): A more complicated example:: + sage: # needs sage.libs.singular sage: dP6. = toric_varieties.dP6() sage: twoP1 = dP6.subscheme(x0*x3) sage: patch = twoP1.neighborhood([0,1,2, 3,4,5]); patch @@ -496,6 +498,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P1xP1 = toric_varieties.P1xP1() sage: P1xP1.inject_variables() Defining s, t, x, y @@ -531,6 +534,7 @@ def is_smooth(self, point=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = toric_varieties.P2() sage: cuspidal_curve = P2.subscheme([y^2*z - x^3]) sage: cuspidal_curve @@ -545,11 +549,12 @@ def is_smooth(self, point=None): Any sufficiently generic cubic hypersurface is smooth:: - sage: P2.subscheme([y^2*z-x^3+z^3+1/10*x*y*z]).is_smooth() + sage: P2.subscheme([y^2*z-x^3+z^3+1/10*x*y*z]).is_smooth() # needs sage.libs.singular True A more complicated example:: + sage: # needs sage.libs.singular sage: dP6. = toric_varieties.dP6() sage: disjointP1s = dP6.subscheme(x0*x3) sage: disjointP1s.is_smooth() @@ -560,6 +565,7 @@ def is_smooth(self, point=None): A smooth hypersurface in a compact singular toric variety:: + sage: # needs sage.libs.singular sage: lp = LatticePolytope([(1,0,0), (1,1,0), (1,1,1), (1,0,1), (-2,-1,-1)], ....: lattice=ToricLattice(3)) sage: X. = CPRFanoToricVariety(Delta_polar=lp) @@ -703,6 +709,7 @@ def is_schon(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = toric_varieties.P2() sage: X = P2.subscheme([(x-y)^2*(x+y) + x*y*z + z^3]) sage: X.is_smooth() @@ -791,6 +798,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P1xP1. = toric_varieties.P1xP1() sage: P1 = P1xP1.subscheme(s0 - s1) sage: P1.dimension() @@ -799,11 +807,11 @@ def dimension(self): A more complicated example where the ambient toric variety is not smooth:: + sage: # needs sage.libs.singular sage: X. = toric_varieties.A2_Z2() sage: X.is_smooth() False - sage: Y = X.subscheme([x*y, x^2]) - sage: Y + sage: Y = X.subscheme([x*y, x^2]); Y Closed subscheme of 2-d affine toric variety defined by: x*y, x^2 @@ -836,6 +844,7 @@ def is_smooth(self, point=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: A2. = toric_varieties.A2() sage: cuspidal_curve = A2.subscheme([y^2 - x^3]) sage: cuspidal_curve @@ -856,6 +865,7 @@ def is_smooth(self, point=None): A more complicated example where the ambient toric variety is not smooth:: + sage: # needs sage.libs.singular sage: X. = toric_varieties.A2_Z2() # 2-d affine space mod Z/2 sage: X.is_smooth() False diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index 82d2ec7769a..558900f5119 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -852,6 +852,7 @@ def _homset(self, *args, **kwds): Defn: Defined on coordinates by sending [s : t : x : y] to [s : s : x : y] + sage: # needs sage.libs.singular sage: hom_set = P1.Hom(P1) sage: sbar, tbar, xbar, ybar = P1.coordinate_ring().gens() sage: hom_set([sbar,sbar,xbar,ybar]) @@ -1921,7 +1922,7 @@ def cohomology_ring(self): Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field sage: X.variable_names() ('x', 'u', 'y', 'v', 'z', 'w') - sage: X.cohomology_ring().gens() + sage: X.cohomology_ring().gens() # needs sage.libs.singular ([y + v - w], [-y + z + w], [y], [v], [z], [w]) TESTS: @@ -1960,6 +1961,7 @@ def cohomology_basis(self, d=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: X = toric_varieties.dP8() sage: X.cohomology_basis() (([1],), ([z], [y]), ([y*z],)) @@ -2004,11 +2006,11 @@ def volume_class(self): EXAMPLES:: sage: P2 = toric_varieties.P2() - sage: P2.volume_class() + sage: P2.volume_class() # needs sage.libs.singular [z^2] sage: A2_Z2 = toric_varieties.A2_Z2() - sage: A2_Z2.volume_class() + sage: A2_Z2.volume_class() # needs sage.libs.singular Traceback (most recent call last): ... ValueError: volume class does not exist @@ -2032,11 +2034,11 @@ def volume_class(self): V(t) sage: Dy = P1xP1_Z2.divisor(3); Dy V(y) - sage: P1xP1_Z2.volume_class() + sage: P1xP1_Z2.volume_class() # needs sage.libs.singular [2*t*y] sage: HH = P1xP1_Z2.cohomology_ring() - sage: HH(Dt) * HH(Dy) == 1/2 * P1xP1_Z2.volume_class() + sage: HH(Dt) * HH(Dy) == 1/2 * P1xP1_Z2.volume_class() # needs sage.libs.singular True The fractional coefficients are also necessary to match the From 92489a44198e99ffba44100b741060476010fb1c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 16:40:55 -0700 Subject: [PATCH 083/494] sage.schemes: Update # needs --- src/sage/schemes/generic/homset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 5db57860f7d..904a30d4e59 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -737,11 +737,11 @@ def cardinality(self): EXAMPLES:: - sage: toric_varieties.P2().point_set().cardinality() # needs sage.geometry.polyhedron + sage: toric_varieties.P2().point_set().cardinality() # needs sage.geometry.polyhedron sage.graphs +Infinity - sage: P2 = toric_varieties.P2(base_ring=GF(3)) # needs sage.geometry.polyhedron - sage: P2.point_set().cardinality() # needs sage.geometry.polyhedron + sage: P2 = toric_varieties.P2(base_ring=GF(3)) # needs sage.geometry.polyhedron sage.graphs + sage: P2.point_set().cardinality() # needs sage.geometry.polyhedron sage.graphs 13 """ if hasattr(self, 'is_finite') and not self.is_finite(): @@ -761,8 +761,8 @@ def list(self): EXAMPLES:: - sage: P1 = toric_varieties.P1(base_ring=GF(3)) # needs sage.geometry.polyhedron - sage: P1.point_set().list() # needs sage.geometry.polyhedron + sage: P1 = toric_varieties.P1(base_ring=GF(3)) # needs sage.geometry.polyhedron sage.graphs + sage: P1.point_set().list() # needs sage.geometry.polyhedron sage.graphs ([0 : 1], [1 : 0], [1 : 1], [1 : 2]) """ return tuple(self) From c3b7079814764031361de34744ce521f4b1dd4cd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:09:33 -0700 Subject: [PATCH 084/494] sage.schemes: Update # needs --- src/sage/schemes/generic/algebraic_scheme.py | 2 +- src/sage/schemes/projective/projective_morphism.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index b5eb3d4ed32..b84d5626584 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -388,7 +388,7 @@ def embedding_morphism(self): To: Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (x, y) -i sage: # needs sage.graphs sage.geometry.polyhedron sage.libs.singular + sage: # needs sage.graphs sage.geometry.polyhedron sage.libs.singular sage: P1xP1. = toric_varieties.P1xP1() sage: P1 = P1xP1.subscheme(x - y) sage: P1.embedding_morphism() diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index d4bd02eba78..c4c3c96299c 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2123,8 +2123,8 @@ def reduce_base_field(self): over Finite Field in z4 of size 5^4 Defn: Defined on coordinates by sending (x : y) to ((z4^3 + z4^2 + z4 - 2)*x^2 + z4*y^2 : x*y) - sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) - sage: f.reduce_base_field() # needs sage.libs.singular + sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) # needs sage.schemes + sage: f.reduce_base_field() # needs sage.libs.singular sage.schemes Dynamical System of Projective Space of dimension 1 over Finite Field in z6 of size 5^6 Defn: Defined on coordinates by sending (x : y) to From d8141b23c17a2efa9507baec615a574fab8d2a4f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 13:28:19 -0700 Subject: [PATCH 085/494] sage.schemes: Update # needs --- src/sage/schemes/toric/divisor.py | 6 +-- src/sage/schemes/toric/fano_variety.py | 2 +- src/sage/schemes/toric/homset.py | 2 + src/sage/schemes/toric/points.py | 6 +-- src/sage/schemes/toric/toric_subscheme.py | 1 + src/sage/schemes/toric/variety.py | 54 ++++++++++++------- .../schemes/toric/weierstrass_covering.py | 10 ++-- 7 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index fb0bdbbfd17..c928cec4a7a 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -1063,7 +1063,7 @@ def polyhedron(self): (A vertex at (0, 0),) sage: D.is_nef() False - sage: dP7.integrate( D.ch() * dP7.Td() ) + sage: dP7.integrate(D.ch() * dP7.Td()) # needs sage.libs.singular 1 sage: P_antiK = (-dP7.K()).polyhedron(); P_antiK A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices @@ -1267,7 +1267,7 @@ def Kodaira_map(self, names='z'): sage: P1. = toric_varieties.P1() sage: D = -P1.K() - sage: D.Kodaira_map() + sage: D.Kodaira_map() # needs fpylll Scheme morphism: From: 1-d CPR-Fano toric variety covered by 2 affine patches To: Closed subscheme of Projective Space of dimension 2 @@ -1276,7 +1276,7 @@ def Kodaira_map(self, names='z'): sage: dP6 = toric_varieties.dP6() sage: D = -dP6.K() - sage: D.Kodaira_map(names='x') + sage: D.Kodaira_map(names='x') # needs fpylll Scheme morphism: From: 2-d CPR-Fano toric variety covered by 6 affine patches To: Closed subscheme of Projective Space of dimension 6 diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py index a1405c966ec..b7f2c2ab6ac 100644 --- a/src/sage/schemes/toric/fano_variety.py +++ b/src/sage/schemes/toric/fano_variety.py @@ -1518,7 +1518,7 @@ def cohomology_class(self): covered by 8 affine patches defined by: a2*z0^2*z1 + a5*z0*z1*z3 + a1*z1*z3^2 + a3*z0^2*z4 + a4*z0*z3*z4 + a0*z3^2*z4, b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5 + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2 - sage: CI.cohomology_class() + sage: CI.cohomology_class() # needs sage.libs.singular [2*z3*z4 + 4*z3*z5 + 2*z4*z5] """ X = self.ambient_space() diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py index bd535edf932..e02d0b92078 100644 --- a/src/sage/schemes/toric/homset.py +++ b/src/sage/schemes/toric/homset.py @@ -621,6 +621,7 @@ def __iter__(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = toric_varieties.P2(base_ring=GF(5)) sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) sage: list(cubic.point_set()) @@ -641,6 +642,7 @@ def cardinality(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = toric_varieties.P2(base_ring=GF(5)) sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) sage: list(cubic.point_set()) diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py index f9563bd0acc..4a40aa82ef7 100644 --- a/src/sage/schemes/toric/points.py +++ b/src/sage/schemes/toric/points.py @@ -1007,7 +1007,7 @@ def cardinality(self): sage: X. = ToricVariety(fan, base_ring=GF(7)) sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w) sage: point_set = Y.point_set() - sage: list(point_set) + sage: list(point_set) # needs fpylll [[0 : 1 : 3], [1 : 0 : 3], [1 : 3 : 0], @@ -1015,8 +1015,8 @@ def cardinality(self): [1 : 1 : 4], [1 : 3 : 2], [1 : 3 : 5]] - sage: ffe = point_set._enumerator() - sage: ffe.cardinality() + sage: ffe = point_set._enumerator() # needs fpylll + sage: ffe.cardinality() # needs fpylll 7 """ n = 0 diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py index cc5b0e3158a..770e459335e 100644 --- a/src/sage/schemes/toric/toric_subscheme.py +++ b/src/sage/schemes/toric/toric_subscheme.py @@ -270,6 +270,7 @@ def affine_algebraic_patch(self, cone=None, names=None): Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: z0^3 + z1^3 + 1 + sage: # needs fpylll sage: cone = Cone([(0,1), (2,1)]) sage: A2Z2. = AffineToricVariety(cone) sage: A2Z2.affine_algebraic_patch() diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index 558900f5119..01064ffbc95 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -66,7 +66,7 @@ sage: C2 = AffineToricVariety(quadrant, base_field=CC) sage: C2.base_ring() Complex Field with 53 bits of precision - sage: C2(1,2+i) + sage: C2(1, 2+i) # needs sage.symbolic [1.00000000000000 : 2.00000000000000 + 1.00000000000000*I] or even :: @@ -1083,7 +1083,7 @@ def coordinate_ring(self): sage: R = toric_varieties.A1().coordinate_ring(); R Multivariate Polynomial Ring in z over Rational Field - sage: type(R) + sage: type(R) # needs sage.libs.singular <... 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular'> """ if "_coordinate_ring" not in self.__dict__: @@ -1931,6 +1931,7 @@ def cohomology_ring(self): potentially troublesome on unpickling, see :trac:`15050` and :trac:`15149` :: + sage: # needs sage.libs.singular sage: variety = toric_varieties.P(1) sage: a = [variety.cohomology_ring(), variety.cohomology_basis(), variety.volume_class()] sage: b = [variety.Todd_class(), variety.Chern_class(), variety.Chern_character(), variety.Kaehler_cone(), variety.Mori_cone()] @@ -2077,6 +2078,7 @@ def integrate(self, cohomology_class): EXAMPLES:: + sage: # needs sage.libs.singular sage: dP6 = toric_varieties.dP6() sage: HH = dP6.cohomology_ring() sage: D = [ HH(c) for c in dP6.fan(dim=1) ] @@ -2098,6 +2100,7 @@ def integrate(self, cohomology_class): If the toric variety is an orbifold, the intersection numbers are usually fractional:: + sage: # needs sage.libs.singular sage: P2_123 = toric_varieties.P2_123() sage: HH = P2_123.cohomology_ring() sage: D = [ HH(c) for c in P2_123.fan(dim=1) ] @@ -2159,6 +2162,7 @@ def Chern_class(self, deg=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: X = toric_varieties.dP6() sage: X.Chern_class() [-6*w^2 + y + 2*v + 2*z + w + 1] @@ -2204,6 +2208,7 @@ def Chern_character(self, deg=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: dP6 = toric_varieties.dP6() sage: dP6.Chern_character() [3*w^2 + y + 2*v + 2*z + w + 2] @@ -2243,6 +2248,7 @@ def Todd_class(self, deg=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: dP6 = toric_varieties.dP6() sage: dP6.Todd_class() [-w^2 + 1/2*y + v + z + 1/2*w + 1] @@ -2289,6 +2295,7 @@ def Euler_number(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P1xP1 = toric_varieties.P1xP1() sage: P1xP1.Euler_number() 4 @@ -2320,7 +2327,7 @@ def K(self): sage: HH = dP6.cohomology_ring() sage: dP6.K() -V(x) - V(u) - V(y) - V(v) - V(z) - V(w) - sage: dP6.integrate( HH(dP6.K())^2 ) + sage: dP6.integrate( HH(dP6.K())^2 ) # needs sage.libs.singular 6 """ from sage.schemes.toric.divisor import ToricDivisor @@ -2479,18 +2486,18 @@ def _semigroup_ring(self, cone=None, names=None): EXAMPLES:: sage: A2Z2 = Cone([(0,1), (2,1)]) - sage: AffineToricVariety(A2Z2)._semigroup_ring() + sage: AffineToricVariety(A2Z2)._semigroup_ring() # needs fpylll (Multivariate Polynomial Ring in z0, z1, z2 over Rational Field, Ideal (-z0*z1 + z2^2) of Multivariate Polynomial Ring in z0, z1, z2 over Rational Field, 2-d cone in 2-d lattice M) sage: P2 = toric_varieties.P2() sage: cone = P2.fan().generating_cone(0) - sage: P2._semigroup_ring(cone) + sage: P2._semigroup_ring(cone) # needs fpylll (Multivariate Polynomial Ring in z0, z1 over Rational Field, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Rational Field, 2-d cone in 2-d lattice M) - sage: P2.change_ring(GF(101))._semigroup_ring(cone) + sage: P2.change_ring(GF(101))._semigroup_ring(cone) # needs fpylll (Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, 2-d cone in 2-d lattice M) @@ -2560,7 +2567,7 @@ def Spec(self, cone=None, names=None): A more interesting example:: sage: A2Z2 = Cone([(0,1), (2,1)]) - sage: AffineToricVariety(A2Z2).Spec(names='u,v,t') + sage: AffineToricVariety(A2Z2).Spec(names='u,v,t') # needs fpylll Spectrum of Quotient of Multivariate Polynomial Ring in u, v, t over Rational Field by the ideal (-u*v + t^2) """ @@ -2594,10 +2601,10 @@ def affine_algebraic_patch(self, cone=None, names=None): sage: cone = Cone([(0,1), (2,1)]) sage: A2Z2 = AffineToricVariety(cone) - sage: A2Z2.affine_algebraic_patch() + sage: A2Z2.affine_algebraic_patch() # needs fpylll Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -z0*z1 + z2^2 - sage: A2Z2.affine_algebraic_patch(Cone([(0,1)]), names='x, y, t') + sage: A2Z2.affine_algebraic_patch(Cone([(0,1)]), names='x, y, t') # needs fpylll Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: 1 """ @@ -3085,7 +3092,7 @@ def __init__(self, variety): True sage: TDiv.scheme().cohomology_ring() is X2.cohomology_ring() # this is where it gets tricky True - sage: TDiv.gen(0).Chern_character() * X2.cohomology_ring().one() + sage: TDiv.gen(0).Chern_character() * X2.cohomology_ring().one() # needs sage.libs.singular [1] """ self._variety = variety @@ -3147,6 +3154,7 @@ def _element_constructor_(self,x): EXAMPLES:: + sage: # needs sage.libs.singular sage: dP6 = toric_varieties.dP6() sage: H = dP6.cohomology_ring() sage: cone = dP6.fan().cone_containing(2,3); cone @@ -3164,6 +3172,7 @@ def _element_constructor_(self,x): coefficient is a multiple depending on the orbifold singularity. See also [CLS2011]_, Lemma 12.5.2:: + sage: # needs sage.libs.singular sage: P2_123 = toric_varieties.P2_123() sage: HH = P2_123.cohomology_ring() sage: HH(Cone([(1,0)])) * HH(Cone([(-2,-3)])) @@ -3179,6 +3188,7 @@ def _element_constructor_(self,x): Numbers will be converted into the ring:: + sage: # needs sage.libs.singular sage: P2 = toric_varieties.P2() sage: H = P2.cohomology_ring() sage: H._element_constructor_(1) @@ -3222,6 +3232,7 @@ def __call__(self, x, coerce=True): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2 = toric_varieties.P2() sage: H = P2.cohomology_ring() sage: H(1) @@ -3245,7 +3256,7 @@ def gens(self): EXAMPLES:: sage: P2 = toric_varieties.P2() - sage: P2.cohomology_ring().gens() + sage: P2.cohomology_ring().gens() # needs sage.libs.singular ([z], [z], [z]) """ if "_gens" not in self.__dict__: @@ -3270,7 +3281,7 @@ def gen(self, i): EXAMPLES:: sage: P2 = toric_varieties.P2() - sage: P2.cohomology_ring().gen(2) + sage: P2.cohomology_ring().gen(2) # needs sage.libs.singular [z] """ return CohomologyClass(self, self._polynomial_ring.gen(i)) @@ -3295,9 +3306,9 @@ def is_CohomologyClass(x): sage: P2 = toric_varieties.P2() sage: HH = P2.cohomology_ring() sage: from sage.schemes.toric.variety import is_CohomologyClass - sage: is_CohomologyClass( HH.one() ) + sage: is_CohomologyClass( HH.one() ) # needs sage.libs.singular True - sage: is_CohomologyClass( HH(P2.fan(1)[0]) ) + sage: is_CohomologyClass( HH(P2.fan(1)[0]) ) # needs sage.libs.singular True sage: is_CohomologyClass('z') False @@ -3319,6 +3330,7 @@ class CohomologyClass(QuotientRingElement): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2 = toric_varieties.P2() sage: P2.cohomology_ring().gen(0) [z] @@ -3348,7 +3360,7 @@ def __init__(self, cohomology_ring, representative): sage: P2 = toric_varieties.P2() sage: H = P2.cohomology_ring() sage: from sage.schemes.toric.variety import CohomologyClass - sage: CohomologyClass(H, H.defining_ideal().ring().zero() ) + sage: CohomologyClass(H, H.defining_ideal().ring().zero() ) # needs sage.libs.singular [0] """ assert representative in cohomology_ring.defining_ideal().ring(), \ @@ -3365,7 +3377,7 @@ def _repr_(self): EXAMPLES:: - sage: toric_varieties.P2().cohomology_ring().gen(0)._repr_() + sage: toric_varieties.P2().cohomology_ring().gen(0)._repr_() # needs sage.libs.singular '[z]' """ return '[' + super()._repr_() + ']' @@ -3380,8 +3392,8 @@ def _latex_(self): EXAMPLES:: - sage: cohomology_class = toric_varieties.P2().cohomology_ring().gen(0)^2/2 - sage: cohomology_class._latex_() + sage: cohomology_class = toric_varieties.P2().cohomology_ring().gen(0)^2/2 # needs sage.libs.singular + sage: cohomology_class._latex_() # needs sage.libs.singular '\\left[ \\frac{1}{2} z^{2} \\right]' """ return r'\left[ %s \right]' % latex(self.lift()) @@ -3399,9 +3411,9 @@ def deg(self): EXAMPLES:: sage: P2 = toric_varieties.P2() - sage: P2.cohomology_ring().gen(0).deg() + sage: P2.cohomology_ring().gen(0).deg() # needs sage.libs.singular 1 - sage: P2.cohomology_ring().zero().deg() + sage: P2.cohomology_ring().zero().deg() # needs sage.libs.singular -1 """ return self.lift().degree() @@ -3424,6 +3436,7 @@ def part_of_degree(self, d): EXAMPLES:: + sage: # needs sage.libs.singular sage: P1xP1 = toric_varieties.P1xP1() sage: t = P1xP1.cohomology_ring().gen(0) sage: y = P1xP1.cohomology_ring().gen(2) @@ -3460,6 +3473,7 @@ def exp(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2 = toric_varieties.P2() sage: H_class = P2.cohomology_ring().gen(0) sage: H_class diff --git a/src/sage/schemes/toric/weierstrass_covering.py b/src/sage/schemes/toric/weierstrass_covering.py index 13e3c24b2c1..cc9caeeae4d 100644 --- a/src/sage/schemes/toric/weierstrass_covering.py +++ b/src/sage/schemes/toric/weierstrass_covering.py @@ -351,7 +351,7 @@ def WeierstrassMap_P1xP1(polynomial, variables=None): sage: f, g = WeierstrassForm_P1xP1(biquadric, [x0, x1, y0, y1]); (f,g) (-625/48*a^4 + 25/3*a^2 - 16/3, 15625/864*a^6 - 625/36*a^4 - 100/9*a^2 + 128/27) sage: X, Y, Z = WeierstrassMap_P1xP1(biquadric, [x0, x1, y0, y1]) - sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(biquadric)) + sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(biquadric)) # needs sage.libs.singular 0 sage: R = PolynomialRing(QQ, 'x,y,s,t', order='lex') @@ -361,7 +361,7 @@ def WeierstrassMap_P1xP1(polynomial, variables=None): ....: + t^2*(7*x^2+8*x*y+9*y^2)) sage: X, Y, Z = WeierstrassMap_P1xP1(equation, [x,y,s,t]) sage: f, g = WeierstrassForm_P1xP1(equation, variables=[x,y,s,t]) - sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) + sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular 0 sage: R = PolynomialRing(QQ, 'x,s', order='lex') @@ -370,7 +370,7 @@ def WeierstrassMap_P1xP1(polynomial, variables=None): sage: equation = s^2*(x^2+2*x+3) + s*(4*x^2+5*x+6) + (7*x^2+8*x+9) sage: X, Y, Z = WeierstrassMap_P1xP1(equation) sage: f, g = WeierstrassForm_P1xP1(equation) - sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) + sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular 0 """ x, y, s, t = _check_polynomial_P1xP1(polynomial, variables) @@ -425,7 +425,7 @@ def WeierstrassMap_P2_112(polynomial, variables=None): sage: equation = y^2 + a0*x^4 + 4*a1*x^3 + 6*a2*x^2 + 4*a3*x + a4 sage: X, Y, Z = WeierstrassMap_P2_112(equation, [x,y]) sage: f, g = WeierstrassForm_P2_112(equation, variables=[x,y]) - sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) + sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular 0 Another example, this time in homogeneous coordinates:: @@ -441,7 +441,7 @@ def WeierstrassMap_P2_112(polynomial, variables=None): sage: WeierstrassForm_P2_112(C_eqn, [x,y,z,t]) (-97/48, 17/864) sage: X, Y, Z = WeierstrassMap_P2_112(C_eqn, [x,y,z,t]) - sage: (-Y^2 + X^3 - 97/48*X*Z^4 + 17/864*Z^6).reduce(C.defining_ideal()) + sage: (-Y^2 + X^3 - 97/48*X*Z^4 + 17/864*Z^6).reduce(C.defining_ideal()) # needs sage.libs.singular 0 """ x, y, z, t = _check_polynomial_P2_112(polynomial, variables) From 3fbf53132bd2a020ad5053856cae2b87d45af813 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 17 Sep 2023 07:03:35 +0900 Subject: [PATCH 086/494] Edit doc --- src/doc/en/installation/source.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst index 248b918da5f..b16fd8e7295 100644 --- a/src/doc/en/installation/source.rst +++ b/src/doc/en/installation/source.rst @@ -988,11 +988,12 @@ Environment variables for documentation build: - ``binder:repo`` specifies a Binder repo with ``repo``, which is a GitHub repository name, optionally added with a branch name with ``/`` separator. - - If a local Jupyter server is used, then set the URL to - :envvar:`SAGE_JUPYTER_SERVER` and the secret token to environemt variable - :envvar:`SAGE_JUPYTER_SERVER_TOKEN`, which can be left unset if the - default token ``secret`` is used. For this case, run a local Jupyter - server by + - To use a local Jupyter server instead of Binder, then set the URL to + :envvar:`SAGE_JUPYTER_SERVER` and the secret token to environment variable + :envvar:`SAGE_JUPYTER_SERVER_TOKEN`, which can be left unset if the default + token ``secret`` is used. If the live doc was built with + ``SAGE_JUPYTER_SERVER=http://localhost:8889``, run a local Jupyter server + by .. CODE-BLOCK:: bash From f50782649d4b26011f844208de791fa0c26a46ac Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 18 Sep 2023 08:06:03 +0200 Subject: [PATCH 087/494] sync_labels_fixes_part2 initial --- .github/sync_labels.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index 799b4985c5d..42724f9fa12 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -329,6 +329,8 @@ def get_review_decision(self): else: # To separate a not supplied value from not cached (see https://github.com/sagemath/sage/pull/36177#issuecomment-1704022893 ff) self._review_decision = ReviewDecision.unclear + info('No review decision for %s' % self._issue) + return None info('Review decision for %s: %s' % (self._issue, self._review_decision.value)) return self._review_decision @@ -539,7 +541,7 @@ def approve(self): r""" Approve the PR by the actor. """ - self.review('--approve', '%s approved this PR' % self._actor) + self.review('--approve', '@%s approved this PR' % self._actor) info('PR %s approved by %s' % (self._issue, self._actor)) def request_changes(self): From 15f6f2e0df3f48f93ee6f112f3e26afcb88f9bc5 Mon Sep 17 00:00:00 2001 From: Sebastian Oehms <47305845+soehms@users.noreply.github.com> Date: Thu, 21 Sep 2023 19:54:18 +0200 Subject: [PATCH 088/494] Fix method on_label_removal (#10) * fix_on_label_removal initial * fix_on_label_removal state -> status * fix bug in actor valid * once again * rewrite authors in actor_valid * syntax * replace warning by hint --- .github/sync_labels.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index 42724f9fa12..4bdb10e7d05 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -108,6 +108,7 @@ def __init__(self, url, actor): self._url = url self._actor = actor self._warning_prefix = 'Label Sync Warning:' + self._hint_prefix = 'Label Sync Hint:' self._labels = None self._author = None self._draft = None @@ -262,10 +263,15 @@ def clean_warnings(self): created_at = c['created_at'] if login.startswith('github-actions'): debug('github-actions comment %s created at %s on issue %s found' % (comment_id, created_at, issue)) + prefix = None if body.startswith(self._warning_prefix): + prefix = self._warning_prefix + if body.startswith(self._hint_prefix): + prefix = self._hint_prefix + if prefix: created = datetime.strptime(created_at, datetime_format) lifetime = today - created - debug('github-actions %s %s is %s old' % (self._warning_prefix, comment_id, lifetime)) + debug('github-actions %s %s is %s old' % (prefix, comment_id, lifetime)) if lifetime > warning_lifetime: try: self.rest_api('%s/%s' % (path_args, comment_id), method='DELETE') @@ -494,8 +500,15 @@ def actor_valid(self): return False coms = self.get_commits() - authors = sum(com['authors'] for com in coms) - authors = [auth for auth in authors if not auth['login'] in (self._actor, 'github-actions')] + authors = [] + for com in coms: + for author in com['authors']: + login = author['login'] + if not login in authors: + if not login in (self._actor, 'github-actions'): + debug('PR %s has recent commit by %s' % (self._issue, login)) + authors.append(login) + if not authors: info('PR %s can\'t be approved by the author %s since no other person commited to it' % (self._issue, self._actor)) return False @@ -571,6 +584,12 @@ def add_warning(self, text): """ self.add_comment('%s %s' % (self._warning_prefix, text)) + def add_hint(self, text): + r""" + Perform a system call to ``gh`` to add a hint to an issue or PR. + """ + self.add_comment('%s %s' % (self._hint_prefix, text)) + def add_label(self, label): r""" Add the given label to the issue or PR. @@ -624,11 +643,10 @@ def reject_label_removal(self, item): a corresponding other one. """ if type(item) == State: - sel_list = 'state' + sel_list = 'status' else: sel_list = 'priority' - self.add_warning('Label *%s* can not be removed. Please add the %s-label which should replace it' % (item.value, sel_list)) - self.add_label(item.value) + self.add_hint('You don\'t need to remove %s labels any more. You\'d better just add the label which replaces it' % sel_list) return # ------------------------------------------------------------------------- @@ -715,6 +733,10 @@ def on_label_removal(self, label): return item = sel_list(label) + + if len(self.active_partners(item)) > 0: + return + if sel_list is State: if self.is_pull_request(): if item != State.needs_info: From 3538edec2b86e5c29d50f9c0c63dadce71f01a37 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 13:23:11 -0700 Subject: [PATCH 089/494] projective_morphism.py, projective_ds.py: Test for QQbar using sage.rings.abc --- .../dynamics/arithmetic_dynamics/projective_ds.py | 15 +++++++-------- .../schemes/projective/projective_morphism.py | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 30d7b3c229f..00675082bff 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -115,7 +115,6 @@ class initialization directly. lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') lazy_import('sage.rings.padics.factory', 'Qp') -lazy_import('sage.rings.qqbar', ['QQbar', 'number_field_elements_from_algebraics']) try: from sage.libs.pari.all import PariError @@ -1274,7 +1273,7 @@ def arakelov_zhang_pairing(self, g, **kwds): if not self.is_endomorphism(): raise TypeError("Self must be an endomorphism.") - if R not in NumberFields() and R is not QQbar: + if R not in NumberFields() and not isinstance(R, sage.rings.abc.AlgebraicField) raise NotImplementedError("Only implemented for number fields.") f_iterate_map = self.nth_iterate_map(n) @@ -2280,7 +2279,7 @@ def canonical_height(self, P, **kwds): K = FractionField(self.codomain().base_ring()) if K not in NumberFields(): - if K is not QQbar: + if not isinstance(K, sage.rings.abc.AlgebraicField): raise NotImplementedError("must be over a number field or a number field order or QQbar") else: #since this an absolute height, we can compute the height of a QQbar point @@ -2794,7 +2793,7 @@ def nth_preimage_tree(self, Q, n, **kwds): if self.domain().dimension_relative() > 1: raise NotImplementedError("only implemented for dimension 1") base_ring = self.base_ring() - if base_ring is QQbar: + if isinstance(base_ring, sage.rings.abc.AlgebraicField): if numerical: raise ValueError("can't solve numerically over QQbar, no embedding into CC") fbar = self @@ -4605,7 +4604,7 @@ def preperiodic_points(self, m, n, **kwds): if return_scheme: # this includes the indeterminacy locus points! return X if X.dimension() <= 0: - if R in NumberFields() or R is QQbar or R in FiniteFields(): + if R in NumberFields() or isinstance(R, sage.rings.abc.AlgebraicField) or R in FiniteFields(): Z = f.base_indeterminacy_locus() points = [dom(Q) for Q in X.rational_points()] good_points = [] @@ -4951,7 +4950,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari if return_scheme: # this includes the indeterminacy locus points! return X if X.change_ring(FF).dimension() <= 0: - if R in NumberFields() or R is QQbar or R in FiniteFields(): + if R in NumberFields() or isinstance(R, sage.rings.abc.AlgebraicField) or R in FiniteFields(): Z = f.base_indeterminacy_locus() points = [dom(Q) for Q in X.rational_points()] good_points = [] @@ -5220,7 +5219,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur # if we are already using an algebraic closure, we move the # map into a finite extension and set use_algebraic_closure to True # in order to get a scheme defined over a finite extension - if K is QQbar or isinstance(K, AlgebraicClosureFiniteField_generic): + if isinstance(K, sage.rings.abc.AlgebraicField) or isinstance(K, AlgebraicClosureFiniteField_generic): f = self.reduce_base_field() K = f.base_ring() use_algebraic_closure = True @@ -8142,7 +8141,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): else: f = self.change_ring(R) g = other.change_ring(R) - if not (R in NumberFields() or R is QQbar or R in FiniteFields()): + if not (R in NumberFields() or isinstance(R, sage.rings.abc.AlgebraicField) or R in FiniteFields()): raise NotImplementedError("ring must be a number field or finite field") try: f.normalize_coordinates() diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index c4c3c96299c..697a108b770 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -66,6 +66,7 @@ from sage.misc.misc_c import prod from sage.misc.cachefunc import cached_method from sage.misc.lazy_attribute import lazy_attribute +from sage.misc.lazy_import import lazy_import from sage.ext.fast_callable import fast_callable from sage.calculus.functions import jacobian import sage.rings.abc @@ -77,7 +78,6 @@ from sage.rings.integer_ring import ZZ from sage.rings.number_field.order import is_NumberFieldOrder from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics from sage.rings.quotient_ring import QuotientRing_generic from sage.rings.rational_field import QQ from sage.modules.free_module_element import vector @@ -88,6 +88,8 @@ from sage.categories.homset import Hom, End from sage.categories.fields import Fields +lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') + _NumberFields = NumberFields() _FiniteFields = FiniteFields() _Fields = Fields() @@ -1404,7 +1406,7 @@ def global_height(self, prec=None): K = self.domain().base_ring() if K in _NumberFields or is_NumberFieldOrder(K): f = self - elif K is QQbar: + elif isinstance(K, sage.rings.abc.AlgebraicField): f = self._number_field_from_algebraics() else: raise TypeError("Must be over a Numberfield or a Numberfield Order or QQbar") @@ -2144,7 +2146,7 @@ def reduce_base_field(self): (x^2 + y^2 : y^2) """ K = self.base_ring() - if K in NumberFields() or K is QQbar: + if K in NumberFields() or isinstance(K, sage.rings.abc.AlgebraicField): return self._number_field_from_algebraics() if K in FiniteFields(): #find the degree of the extension containing the coefficients From 3e7447625abcb9512c0bd7e3e2c52a2a59990134 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 4 Jun 2023 23:28:24 -0700 Subject: [PATCH 090/494] sage.schemes: Modularization fixes --- src/sage/schemes/generic/homset.py | 21 ++++++++++--------- .../schemes/product_projective/morphism.py | 9 ++++---- src/sage/schemes/product_projective/point.py | 7 ++++--- .../product_projective/rational_point.py | 5 +++-- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 904a30d4e59..60e840619ac 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -36,6 +36,7 @@ # ***************************************************************************** from sage.categories.homset import HomsetWithBase +from sage.misc.lazy_import import lazy_import from sage.structure.factory import UniqueFactory from sage.structure.parent import Set_generic @@ -49,6 +50,11 @@ SchemeMorphism_structure_map, SchemeMorphism_spec ) +lazy_import('sage.schemes.affine.affine_space', 'AffineSpace_generic', as_='AffineSpace') +lazy_import('sage.schemes.generic.algebraic_scheme', 'AlgebraicScheme_subscheme') +lazy_import('sage.schemes.product_projective.space', 'ProductProjectiveSpaces_ring', as_='ProductProjectiveSpaces') +lazy_import('sage.schemes.projective.projective_space', 'ProjectiveSpace_ring', as_='ProjectiveSpace') + def is_SchemeHomset(H): r""" @@ -568,9 +574,8 @@ def _coerce_map_from_(self, other): # and the base rings are coercible if isinstance(other, CommutativeRing): try: - from sage.schemes.affine.affine_space import is_AffineSpace - if is_AffineSpace(target.ambient_space())\ - and target.ambient_space().dimension_relative() == 1: + if (isinstance(target.ambient_space(), AffineSpace) + and target.ambient_space().dimension_relative() == 1): return target.base_ring().has_coerce_map_from(other) else: return False @@ -578,7 +583,6 @@ def _coerce_map_from_(self, other): return False elif isinstance(other, SchemeHomset_points): #we are converting between scheme points - from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme source = other.codomain() if isinstance(target, AlgebraicScheme_subscheme): #subscheme coerce when there is containment @@ -592,9 +596,6 @@ def _coerce_map_from_(self, other): #if the target is an ambient space, we can coerce if the base rings coerce #and they are the same type: affine, projective, etc and have the same #variable names - from sage.schemes.projective.projective_space import is_ProjectiveSpace - from sage.schemes.affine.affine_space import is_AffineSpace - from sage.schemes.product_projective.space import is_ProductProjectiveSpaces try: ta = target.ambient_space() sa = source.ambient_space() @@ -602,15 +603,15 @@ def _coerce_map_from_(self, other): return False #for projective and affine varieties, we check dimension #and matching variable names - if (is_ProjectiveSpace(ta) and is_ProjectiveSpace(sa))\ - or (is_AffineSpace(ta) and is_AffineSpace(sa)): + if ((isinstance(ta, ProjectiveSpace) and isinstance(sa, ProjectiveSpace)) + or (isinstance(ta, AffineSpace) and isinstance(sa, AffineSpace))): if (ta.variable_names() == sa.variable_names()): return self.domain().coordinate_ring().has_coerce_map_from(other.domain().coordinate_ring()) else: return False #for products of projective spaces, we check dimension of #components and matching variable names - elif (is_ProductProjectiveSpaces(ta) and is_ProductProjectiveSpaces(sa)): + elif isinstance(ta, ProductProjectiveSpaces) and isinstance(sa, ProductProjectiveSpaces): if (ta.dimension_relative_components() == sa.dimension_relative_components()) \ and (ta.variable_names() == sa.variable_names()): return self.domain().coordinate_ring().has_coerce_map_from(other.domain().coordinate_ring()) diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index 74b424022a2..3524dbdb508 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -19,12 +19,13 @@ # the License, or (at your option) any later version. # https://www.gnu.org/licenses/ # **************************************************************************** + +import sage.rings.abc + from sage.schemes.generic.morphism import SchemeMorphism_polynomial from sage.categories.fields import Fields from sage.categories.number_fields import NumberFields -from sage.rings.number_field.order import is_NumberFieldOrder from sage.rings.fraction_field import FractionField -from sage.rings.qqbar import QQbar _Fields = Fields() @@ -460,14 +461,14 @@ def global_height(self, prec=None): 2.56494935746154 """ K = self.domain().base_ring() - if K in NumberFields() or is_NumberFieldOrder(K): + if K in NumberFields() or K == ZZ or isinstance(K, sage.rings.abc.Order): H = 0 for i in range(self.domain().ambient_space().ngens()): C = self[i].coefficients() h = max(c.global_height(prec=prec) for c in C) H = max(H, h) return H - elif K == QQbar: + elif isinstance(K, sage.rings.abc.AlgebraicField): raise NotImplementedError("not implemented for QQbar") else: raise TypeError("Must be over a Numberfield or a Numberfield Order or QQbar") diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index b9430804695..34e6804910b 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -21,11 +21,12 @@ # https://www.gnu.org/licenses/ # **************************************************************************** from copy import copy + +import sage.rings.abc + from sage.categories.integral_domains import IntegralDomains from sage.categories.number_fields import NumberFields from sage.rings.fraction_field import FractionField -from sage.rings.number_field.order import is_NumberFieldOrder -from sage.rings.qqbar import QQbar from sage.schemes.generic.morphism import SchemeMorphism from sage.schemes.generic.morphism import SchemeMorphism_point from sage.structure.sequence import Sequence @@ -466,7 +467,7 @@ def global_height(self, prec=None): 0.536479304144700 """ K = self.codomain().base_ring() - if K not in NumberFields() and not is_NumberFieldOrder(K) and K != QQbar: + if K not in NumberFields() and K != ZZ and not isinstance(K, (sage.rings.abc.Order, sage.rings.abc.AlgebraicField)): raise TypeError("must be over a number field or a number field order or QQbar") n = self.codomain().ambient_space().num_components() diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py index 5375ffb4535..e31e31c00a6 100644 --- a/src/sage/schemes/product_projective/rational_point.py +++ b/src/sage/schemes/product_projective/rational_point.py @@ -61,11 +61,12 @@ from sage.misc.misc_c import prod from sage.arith.misc import next_prime, previous_prime, crt from sage.rings.integer_ring import ZZ -from sage.rings.real_mpfr import RR from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.parallel.ncpus import ncpus from sage.parallel.use_fork import p_iter_fork -from sage.matrix.constructor import matrix + +lazy_import('sage.matrix.constructor', 'matrix') +lazy_import('sage.rings.real_mpfr', 'RR') def enum_product_projective_rational_field(X, B): From 23fecb1665fffd9555db4b69104d7673c5de52cd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 27 Mar 2023 14:38:08 -0700 Subject: [PATCH 091/494] sage.schemes: Modularization fixes for imports --- src/sage/schemes/affine/affine_morphism.py | 11 ++++--- src/sage/schemes/affine/affine_point.py | 9 +++--- src/sage/schemes/affine/affine_space.py | 8 +++-- src/sage/schemes/generic/algebraic_scheme.py | 11 ++++--- .../schemes/projective/projective_morphism.py | 32 +++++++++++-------- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index 1fc3f207464..33536eda52f 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -48,6 +48,8 @@ import sys +import sage.rings.abc + from sage.calculus.functions import jacobian from sage.categories.homset import Hom, End @@ -68,10 +70,7 @@ from sage.schemes.generic.morphism import SchemeMorphism_polynomial -from sage.ext.fast_callable import fast_callable - from sage.categories.number_fields import NumberFields -from sage.rings.number_field.order import is_NumberFieldOrder _NumberFields = NumberFields() _Fields = Fields() @@ -361,6 +360,8 @@ def _fastpolys(self): 1), ('load_arg', ...), ('ipow', 1), 'mul', 'add', ('load_const', 1), 'add', 'return']] """ + from sage.ext.fast_callable import fast_callable + polys = self._polys R = self.domain().ambient_space().coordinate_ring() @@ -800,7 +801,7 @@ def local_height(self, v, prec=None): 1.09861228866811 """ K = FractionField(self.domain().base_ring()) - if K not in _NumberFields or is_NumberFieldOrder(K): + if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): raise TypeError("must be over a number field or a number field order") return max([K(c).local_height(v, prec=prec) for f in self for c in f.coefficients()]) @@ -848,7 +849,7 @@ def local_height_arch(self, i, prec=None): 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) - if K not in _NumberFields or is_NumberFieldOrder(K): + if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): raise TypeError("must be over a number field or a number field order") if K == QQ: diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index a665ba6881a..dabcaa134f9 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -31,9 +31,7 @@ from sage.categories.number_fields import NumberFields from sage.rings.integer_ring import ZZ -from sage.rings.number_field.order import is_NumberFieldOrder -from sage.rings.real_mpfr import RealField -from sage.schemes.generic.morphism import (SchemeMorphism_point, SchemeMorphism, is_SchemeMorphism) +from sage.schemes.generic.morphism import SchemeMorphism_point, SchemeMorphism, is_SchemeMorphism from sage.structure.sequence import Sequence _NumberFields = NumberFields() @@ -206,13 +204,14 @@ def global_height(self, prec=None): P-adic heights. """ if self.domain().base_ring() == ZZ: + from sage.rings.real_mpfr import RealField if prec is None: R = RealField() else: R = RealField(prec) H = max([self[i].abs() for i in range(self.codomain().ambient_space().dimension_relative())]) - return R(max(H, 1)).log() - if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(self.domain().base_ring()): + return R(max(H,1)).log() + if self.domain().base_ring() in _NumberFields or isinstance(self.domain().base_ring(), sage.rings.abc.Order): return max([self[i].global_height(prec) for i in range(self.codomain().ambient_space().dimension_relative())]) else: raise NotImplementedError("must be over a number field or a number field Order") diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py index 2680982c232..f4483fd0f78 100644 --- a/src/sage/schemes/affine/affine_space.py +++ b/src/sage/schemes/affine/affine_space.py @@ -10,7 +10,6 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.functions.orthogonal_polys import chebyshev_T, chebyshev_U from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -23,7 +22,6 @@ from sage.categories.number_fields import NumberFields from sage.misc.latex import latex from sage.misc.mrange import cartesian_product_iterator -from sage.matrix.constructor import matrix from sage.structure.category_object import normalize_names from sage.schemes.generic.scheme import AffineScheme from sage.schemes.generic.ambient_space import AmbientSpace @@ -938,9 +936,13 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): if self.dimension_relative() != 1: raise TypeError("affine space must be of dimension 1") n = ZZ(n) - if (n < 0): + if n < 0: raise ValueError("first parameter 'n' must be a non-negative integer") + from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine + from sage.functions.orthogonal_polys import chebyshev_T, chebyshev_U + from sage.matrix.constructor import matrix + if kind == 'first': if monic and self.base().characteristic() != 2: f = DynamicalSystem_affine([chebyshev_T(n, self.gen(0))], domain=self) diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index b84d5626584..56b0bbf0852 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -118,10 +118,8 @@ from sage.rings.ideal import is_Ideal from sage.rings.integer_ring import ZZ -from sage.rings.qqbar import QQbar from sage.rings.rational_field import is_RationalField from sage.rings.finite_rings.finite_field_base import FiniteField -from sage.rings.number_field.order import is_NumberFieldOrder from sage.misc.latex import latex from sage.misc.misc import is_iterator @@ -129,8 +127,6 @@ from sage.structure.all import Sequence from sage.structure.richcmp import richcmp, richcmp_method -from sage.calculus.functions import jacobian - from sage.arith.functions import lcm from sage.arith.misc import gcd @@ -1125,7 +1121,9 @@ def normalize_defining_polynomials(self): """ BR = self.base_ring() - if BR == QQbar or BR in NumberFields() or is_NumberFieldOrder(BR): + if (BR == ZZ + or isinstance(BR, (sage.rings.abc.AlgebraicField, sage.rings.abc.Order)) + or BR in NumberFields()): normalized_polys = [] initial_polys = list(self.__polys) @@ -1334,6 +1332,9 @@ def Jacobian_matrix(self): l = self.defining_polynomials() if len(l) == 0: return sage.matrix.constructor.Matrix(R, 0) + + from sage.calculus.functions import jacobian + return jacobian(l, R.gens()) def Jacobian(self): diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 697a108b770..4a1a7f19b35 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -62,34 +62,24 @@ import sys from sage.arith.misc import GCD as gcd from sage.arith.functions import lcm -from sage.interfaces.singular import singular from sage.misc.misc_c import prod from sage.misc.cachefunc import cached_method from sage.misc.lazy_attribute import lazy_attribute -from sage.misc.lazy_import import lazy_import -from sage.ext.fast_callable import fast_callable -from sage.calculus.functions import jacobian import sage.rings.abc from sage.rings.integer import Integer from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic from sage.rings.finite_rings.finite_field_base import FiniteField -from sage.rings.finite_rings.finite_field_constructor import GF from sage.rings.fraction_field import FractionField from sage.rings.integer_ring import ZZ -from sage.rings.number_field.order import is_NumberFieldOrder from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.quotient_ring import QuotientRing_generic from sage.rings.rational_field import QQ -from sage.modules.free_module_element import vector -from sage.matrix.constructor import matrix from sage.schemes.generic.morphism import SchemeMorphism_polynomial from sage.categories.finite_fields import FiniteFields from sage.categories.number_fields import NumberFields from sage.categories.homset import Hom, End from sage.categories.fields import Fields -lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') - _NumberFields = NumberFields() _FiniteFields = FiniteFields() _Fields = Fields() @@ -432,6 +422,8 @@ def _fastpolys(self): [[('load_const', 0), ('load_const', 1), ('load_arg', ...), ('ipow', 2), 'mul', 'add', ('load_const', 1), ('load_arg', ...), ('ipow', 2), 'mul', 'add', 'return'], [('load_const', 0), ('load_const', 1), ('load_arg', 1), ('ipow', 2), 'mul', 'add', 'return']] """ + from sage.ext.fast_callable import fast_callable + polys = self._polys fastpolys = [] @@ -629,6 +621,7 @@ def _matrix_times_polymap_(self, mat, h): """ from sage.modules.free_module_element import vector from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem + if not mat.is_square(): raise ValueError("matrix must be square") if mat.ncols() != self.codomain().ngens(): @@ -1404,7 +1397,7 @@ def global_height(self, prec=None): 6.43775164973640 """ K = self.domain().base_ring() - if K in _NumberFields or is_NumberFieldOrder(K): + if K in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order): f = self elif isinstance(K, sage.rings.abc.AlgebraicField): f = self._number_field_from_algebraics() @@ -1474,7 +1467,7 @@ def local_height(self, v, prec=None): 1.09861228866811 """ K = FractionField(self.domain().base_ring()) - if K not in _NumberFields or is_NumberFieldOrder(K): + if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): raise TypeError("must be over a number field or a number field order") return max([K(c).local_height(v, prec=prec) for f in self for c in f.coefficients()]) @@ -1522,7 +1515,7 @@ def local_height_arch(self, i, prec=None): 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) - if K not in _NumberFields or is_NumberFieldOrder(K): + if not (K not in _NumberFields or isinstance(K, sage.rings.abc.Order)): raise TypeError("must be over a number field or a number field order") if K == QQ: return max([K(c).local_height_arch(prec=prec) for f in self for c in f.coefficients()]) @@ -1561,6 +1554,8 @@ def wronskian_ideal(self): Ideal (4*x*y, 2*x^2 + 4*y^2, -2*y^2) of Multivariate Polynomial Ring in x, y over Rational Field """ + from sage.calculus.functions import jacobian + dom = self.domain() from sage.schemes.projective.projective_space import is_ProjectiveSpace if not (is_ProjectiveSpace(dom) and is_ProjectiveSpace(self.codomain())): @@ -1801,7 +1796,9 @@ def _number_field_from_algebraics(self): Defn: Defined on coordinates by sending (x : y) to ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3) """ + from sage.rings.qqbar import number_field_elements_from_algebraics from sage.schemes.projective.projective_space import is_ProjectiveSpace + if not (is_ProjectiveSpace(self.domain()) and is_ProjectiveSpace(self.domain())): raise NotImplementedError("not implemented for subschemes") @@ -1811,7 +1808,7 @@ def _number_field_from_algebraics(self): if K_pre is QQ: if K_pre is self.base_ring(): return self - elif self.base_ring() != QQbar and K_pre.is_isomorphic(self.base_ring()): + elif not isinstance(self.base_ring(), sage.rings.abc.AlgebraicField) and K_pre.is_isomorphic(self.base_ring()): return self # Issue 23808: The field K_pre returned above does not have its embedding set to be phi # and phi is forgotten, so we redefine K_pre to be a field K with phi as the specified @@ -2153,6 +2150,8 @@ def reduce_base_field(self): c = [v for g in self for v in g.coefficients()] d = lcm([a.minpoly().degree() for a in c]) if d == 1: + from sage.rings.finite_rings.finite_field_constructor import GF + return self.change_ring(GF(K.characteristic())) if d == K.degree(): return self @@ -2372,6 +2371,8 @@ def __eq__(self, other): e = Y.projective_embedding(0) return (e * self) == (e * other) + from sage.matrix.constructor import matrix + R = self.domain().coordinate_ring() mat = matrix([self.defining_polynomials(), other.defining_polynomials()]) return all(R(minor).is_zero() for minor in mat.minors(2)) @@ -2479,6 +2480,7 @@ def representatives(self): raise ValueError("domain is not an irreducible scheme") # prepare homogeneous coordinate ring of X in Singular + from sage.interfaces.singular import singular from sage.rings.polynomial.term_order import TermOrder T = TermOrder('degrevlex') T._singular_ringorder_column = 1 # (c,dp) in Singular @@ -2778,6 +2780,8 @@ def projective_degrees(self): G = self.graph() I = G.defining_ideal() # a bihomogeneous ideal + from sage.modules.free_module_element import vector + degrees = xn * [vector([1, 0])] + yn * [vector([0, 1])] res = I.graded_free_resolution(degrees=degrees, algorithm='shreyer') kpoly = res.K_polynomial() From 67b279f76eb5a8355a45a328ad3cd1eac98e9c6d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 13:46:09 -0700 Subject: [PATCH 092/494] sage.schemes, sage.dynamics.arithmetic_dynamics: Modularization fixes --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 5 +++-- src/sage/schemes/curves/affine_curve.py | 10 ++++++++-- src/sage/schemes/generic/algebraic_scheme.py | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 00675082bff..9bbd1723571 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -1273,7 +1273,7 @@ def arakelov_zhang_pairing(self, g, **kwds): if not self.is_endomorphism(): raise TypeError("Self must be an endomorphism.") - if R not in NumberFields() and not isinstance(R, sage.rings.abc.AlgebraicField) + if R not in NumberFields() and not isinstance(R, sage.rings.abc.AlgebraicField): raise NotImplementedError("Only implemented for number fields.") f_iterate_map = self.nth_iterate_map(n) @@ -2458,7 +2458,7 @@ def height_difference_bound(self, prec=None): """ FF = FractionField(self.domain().base_ring()) #lift will only work over fields, so coercing into FF if FF not in NumberFields(): - if FF == QQbar: + if isinstance(FF, sage.rings.abc.AlgebraicField): #since this is absolute height, we can choose any number field over which the #function is defined. f = self._number_field_from_algebraics() @@ -8841,6 +8841,7 @@ def is_newton(self, return_conjugation=False): return False, None else: return False + from sage.rings.qqbar import QQbar Fbar = self.change_ring(QQbar) Pbar = Fbar.domain() fixed = Fbar.periodic_points(1) diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index 326c0d86e77..ce8c0ff0655 100644 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -125,6 +125,8 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +import sage.rings.abc + from sage.misc.lazy_attribute import lazy_attribute from sage.misc.cachefunc import cached_method @@ -139,10 +141,11 @@ from sage.matrix.constructor import matrix +from sage.misc.lazy_import import lazy_import + from sage.rings.polynomial.multi_polynomial_element import degree_lowest_rational_function from sage.rings.number_field.number_field import NumberField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.qqbar import number_field_elements_from_algebraics, QQbar from sage.rings.rational_field import is_RationalField from sage.rings.infinity import infinity @@ -162,6 +165,8 @@ from .closed_point import IntegralAffineCurveClosedPoint +lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') + class AffineCurve(Curve_generic, AlgebraicScheme_subscheme_affine): """ @@ -671,7 +676,7 @@ def tangents(self, P, factor=True): T = sum([binomial(r, i)*deriv[i]*(vars[0])**i*(vars[1])**(r-i) for i in range(r+1)]) if not factor: return [T(coords)] - if self.base_ring() == QQbar: + if isinstance(self.base_ring(), sage.rings.abc.AlgebraicField): fact = [] # first add tangents corresponding to vars[0], vars[1] if they divide T t = min([e[0] for e in T.exponents()]) @@ -1534,6 +1539,7 @@ def resolution_of_singularities(self, extend=False): def extension(self): F = self.base_ring() + from sage.rings.qqbar import QQbar pts = self.change_ring(F.embeddings(QQbar)[0]).rational_points() L = [t for pt in pts for t in pt] K = number_field_elements_from_algebraics(L)[0] diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index 56b0bbf0852..e030371f70e 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -113,6 +113,7 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +import sage.rings.abc from sage.categories.number_fields import NumberFields From dce871a116a41e25ef60b7eeecb9b850c9616dde Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 13 May 2023 18:54:18 -0700 Subject: [PATCH 093/494] sage.{rings,schemes}: Simplify some tests for number fields --- .../rings/polynomial/multi_polynomial_element.py | 4 ++-- src/sage/rings/polynomial/polynomial_element.pyx | 13 +++++-------- src/sage/schemes/affine/affine_morphism.py | 4 ++-- src/sage/schemes/projective/projective_morphism.py | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 0c510df8d59..d4e2b115e39 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -1150,7 +1150,7 @@ def local_height(self, v, prec=None): prec = 53 K = FractionField(self.base_ring()) - if not (K in NumberFields() or isinstance(K, (sage.rings.abc.Order, IntegerRing_class))): + if K not in NumberFields(): raise TypeError("must be over a Numberfield or a Numberfield order") return max([K(c).local_height(v, prec=prec) for c in self.coefficients()]) @@ -1199,7 +1199,7 @@ def local_height_arch(self, i, prec=None): prec = 53 K = FractionField(self.base_ring()) - if not (K in NumberFields() or isinstance(K, (sage.rings.abc.Order, IntegerRing_class))): + if K not in NumberFields(): return TypeError("must be over a Numberfield or a Numberfield Order") if K == QQ: diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index c5a1129aecf..ec88e323c02 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -5448,15 +5448,12 @@ cdef class Polynomial(CommutativePolynomial): if self.degree() <= 1: return R.fraction_field() - from sage.rings.number_field.number_field import is_NumberField, NumberField - if is_IntegerRing(R): from sage.rings.number_field.number_field import NumberField return NumberField(self, names) from sage.rings.number_field.number_field_base import NumberField as NumberField_base - - if sage.rings.rational_field.is_RationalField(R) or isinstance(R, NumberField_base): + if isinstance(R, NumberField_base): from sage.rings.number_field.number_field import NumberField return NumberField(self, names) @@ -6022,14 +6019,14 @@ cdef class Polynomial(CommutativePolynomial): K = self.base_ring() if K in NumberFields() or isinstance(K, sage.rings.abc.Order) or is_IntegerRing(K): from sage.schemes.projective.projective_space import ProjectiveSpace - P = ProjectiveSpace(K, self.number_of_terms()-1) + P = ProjectiveSpace(K, self.number_of_terms() - 1) return P.point(self.coefficients()).global_height(prec=prec) elif isinstance(K, sage.rings.abc.AlgebraicField): from sage.rings.qqbar import number_field_elements_from_algebraics from sage.schemes.projective.projective_space import ProjectiveSpace K_pre, P, phi = number_field_elements_from_algebraics(self.coefficients()) - Pr = ProjectiveSpace(K_pre, len(P)-1) + Pr = ProjectiveSpace(K_pre, len(P) - 1) return Pr.point(P).global_height(prec=prec) raise TypeError("Must be over a Numberfield or a Numberfield Order.") @@ -6078,7 +6075,7 @@ cdef class Polynomial(CommutativePolynomial): prec = 53 K = FractionField(self.base_ring()) - if not (K in NumberFields() or isinstance(K, sage.rings.abc.Order) or is_IntegerRing(K)): + if K not in NumberFields(): raise TypeError("must be over a Numberfield or a Numberfield order") return max([K(c).local_height(v, prec=prec) for c in self.coefficients()]) @@ -6127,7 +6124,7 @@ cdef class Polynomial(CommutativePolynomial): prec = 53 K = FractionField(self.base_ring()) - if not (K in NumberFields() or isinstance(K, sage.rings.abc.Order) or is_IntegerRing(K)): + if K not in NumberFields(): return TypeError("must be over a Numberfield or a Numberfield Order") if K == QQ: diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index 33536eda52f..7e855f78921 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -801,7 +801,7 @@ def local_height(self, v, prec=None): 1.09861228866811 """ K = FractionField(self.domain().base_ring()) - if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): + if K not in _NumberFields: raise TypeError("must be over a number field or a number field order") return max([K(c).local_height(v, prec=prec) for f in self for c in f.coefficients()]) @@ -849,7 +849,7 @@ def local_height_arch(self, i, prec=None): 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) - if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): + if K not in _NumberFields: raise TypeError("must be over a number field or a number field order") if K == QQ: diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 4a1a7f19b35..8de12ccf4a5 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -1467,7 +1467,7 @@ def local_height(self, v, prec=None): 1.09861228866811 """ K = FractionField(self.domain().base_ring()) - if not (K not in _NumberFields or K == ZZ or isinstance(K, sage.rings.abc.Order)): + if K not in _NumberFields: raise TypeError("must be over a number field or a number field order") return max([K(c).local_height(v, prec=prec) for f in self for c in f.coefficients()]) @@ -1515,7 +1515,7 @@ def local_height_arch(self, i, prec=None): 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) - if not (K not in _NumberFields or isinstance(K, sage.rings.abc.Order)): + if K not in _NumberFields: raise TypeError("must be over a number field or a number field order") if K == QQ: return max([K(c).local_height_arch(prec=prec) for f in self for c in f.coefficients()]) From d78e78a109aef34241469ae34c3e23dac42e4889 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 14:21:29 -0700 Subject: [PATCH 094/494] sage.schemes, sage.dynamics.arithmetic_dynamics: Modularization fixes --- .../dynamics/arithmetic_dynamics/projective_ds.py | 14 +++++++++----- src/sage/schemes/product_projective/morphism.py | 4 +++- src/sage/schemes/product_projective/point.py | 1 + .../schemes/product_projective/rational_point.py | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 9bbd1723571..d75972f812d 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -115,6 +115,7 @@ class initialization directly. lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') lazy_import('sage.rings.padics.factory', 'Qp') +lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') try: from sage.libs.pari.all import PariError @@ -763,15 +764,17 @@ def dynatomic_polynomial(self, period): We check that the dynatomic polynomial has the right parent (see :trac:`18409`):: - sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar,1) sage: f = DynamicalSystem_projective([x^2 - 1/3*y^2, y^2]) sage: f.dynatomic_polynomial(2).parent() # needs sage.libs.pari Multivariate Polynomial Ring in x, y over Algebraic Field :: - sage: T. = QuadraticField(33) # needs sage.rings.number_field - sage: S. = PolynomialRing(T) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: T. = QuadraticField(33) + sage: S. = PolynomialRing(T) sage: P. = ProjectiveSpace(FractionField(S),1) sage: f = DynamicalSystem_projective([t*x^2 - 1/t*y^2, y^2]) sage: f.dynatomic_polynomial([1, 2]).parent() # needs sage.libs.pari @@ -4396,9 +4399,10 @@ def preperiodic_points(self, m, n, **kwds): :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) - sage: K. = QuadraticField(5) # needs sage.rings.number_field - sage: phi = QQ.embeddings(K)[0] # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: phi = QQ.embeddings(K)[0] sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: f.preperiodic_points(1, 1, R=phi) [(-1/2*v - 1/2 : 1), (1/2*v - 1/2 : 1)] diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index 3524dbdb508..d5b1974164b 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -22,10 +22,12 @@ import sage.rings.abc -from sage.schemes.generic.morphism import SchemeMorphism_polynomial from sage.categories.fields import Fields from sage.categories.number_fields import NumberFields from sage.rings.fraction_field import FractionField +from sage.rings.integer_ring import ZZ +from sage.schemes.generic.morphism import SchemeMorphism_polynomial + _Fields = Fields() diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index 34e6804910b..70cc344806f 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -27,6 +27,7 @@ from sage.categories.integral_domains import IntegralDomains from sage.categories.number_fields import NumberFields from sage.rings.fraction_field import FractionField +from sage.rings.integer_ring import ZZ from sage.schemes.generic.morphism import SchemeMorphism from sage.schemes.generic.morphism import SchemeMorphism_point from sage.structure.sequence import Sequence diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py index e31e31c00a6..c9a2cf6b25f 100644 --- a/src/sage/schemes/product_projective/rational_point.py +++ b/src/sage/schemes/product_projective/rational_point.py @@ -57,6 +57,7 @@ from sage.schemes.generic.scheme import is_Scheme from sage.schemes.product_projective.space import is_ProductProjectiveSpaces +from sage.misc.lazy_import import lazy_import from sage.misc.mrange import xmrange from sage.misc.misc_c import prod from sage.arith.misc import next_prime, previous_prime, crt From b39df390e89ea0172b1d80a645fea924fae926eb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 17:40:37 -0700 Subject: [PATCH 095/494] sage.schemes: Update # needs --- .../schemes/projective/projective_subscheme.py | 4 ++-- src/sage/schemes/toric/toric_subscheme.py | 2 +- src/sage/schemes/toric/variety.py | 14 +++++++------- src/sage/schemes/toric/weierstrass_higher.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 6370bef6ad2..d31bfd5a2a7 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -1440,14 +1440,14 @@ def global_height(self, prec=None): sage: NF. = NumberField(x^2 - 5) sage: P. = ProjectiveSpace(NF, 2) sage: X = P.subscheme([x^2 + y*z, 2*y*z, 3*x*y]) - sage: X.global_height() + sage: X.global_height() # needs sage.libs.singular 0.000000000000000 :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([z^2 - 101*y^2 - 3*x*z]) - sage: X.global_height() # long time + sage: X.global_height() # long time # needs sage.libs.singular 4.61512051684126 """ return self.Chow_form().global_height(prec) diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py index 770e459335e..6b3645d0e4a 100644 --- a/src/sage/schemes/toric/toric_subscheme.py +++ b/src/sage/schemes/toric/toric_subscheme.py @@ -270,7 +270,7 @@ def affine_algebraic_patch(self, cone=None, names=None): Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: z0^3 + z1^3 + 1 - sage: # needs fpylll + sage: # needs fpylll sage.libs.singular sage: cone = Cone([(0,1), (2,1)]) sage: A2Z2. = AffineToricVariety(cone) sage: A2Z2.affine_algebraic_patch() diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index 01064ffbc95..44e33505d44 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -232,7 +232,7 @@ (False, True) sage: HH = P4_11133.cohomology_ring(); HH Rational cohomology ring of a 4-d CPR-Fano toric variety covered by 5 affine patches - sage: P4_11133.cohomology_basis() + sage: P4_11133.cohomology_basis() # needs sage.libs.singular (([1],), ([z4],), ([z4^2],), ([z4^3],), ([z4^4],)) Every cone defines a torus orbit closure, and hence a (co)homology class:: @@ -2486,18 +2486,18 @@ def _semigroup_ring(self, cone=None, names=None): EXAMPLES:: sage: A2Z2 = Cone([(0,1), (2,1)]) - sage: AffineToricVariety(A2Z2)._semigroup_ring() # needs fpylll + sage: AffineToricVariety(A2Z2)._semigroup_ring() # needs fpylll sage.libs.singular (Multivariate Polynomial Ring in z0, z1, z2 over Rational Field, Ideal (-z0*z1 + z2^2) of Multivariate Polynomial Ring in z0, z1, z2 over Rational Field, 2-d cone in 2-d lattice M) sage: P2 = toric_varieties.P2() sage: cone = P2.fan().generating_cone(0) - sage: P2._semigroup_ring(cone) # needs fpylll + sage: P2._semigroup_ring(cone) # needs fpylll sage.libs.singular (Multivariate Polynomial Ring in z0, z1 over Rational Field, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Rational Field, 2-d cone in 2-d lattice M) - sage: P2.change_ring(GF(101))._semigroup_ring(cone) # needs fpylll + sage: P2.change_ring(GF(101))._semigroup_ring(cone) # needs fpylll sage.libs.singular (Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, 2-d cone in 2-d lattice M) @@ -2567,7 +2567,7 @@ def Spec(self, cone=None, names=None): A more interesting example:: sage: A2Z2 = Cone([(0,1), (2,1)]) - sage: AffineToricVariety(A2Z2).Spec(names='u,v,t') # needs fpylll + sage: AffineToricVariety(A2Z2).Spec(names='u,v,t') # needs fpylll sage.libs.singular Spectrum of Quotient of Multivariate Polynomial Ring in u, v, t over Rational Field by the ideal (-u*v + t^2) """ @@ -2601,10 +2601,10 @@ def affine_algebraic_patch(self, cone=None, names=None): sage: cone = Cone([(0,1), (2,1)]) sage: A2Z2 = AffineToricVariety(cone) - sage: A2Z2.affine_algebraic_patch() # needs fpylll + sage: A2Z2.affine_algebraic_patch() # needs fpylll sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -z0*z1 + z2^2 - sage: A2Z2.affine_algebraic_patch(Cone([(0,1)]), names='x, y, t') # needs fpylll + sage: A2Z2.affine_algebraic_patch(Cone([(0,1)]), names='x, y, t') # needs fpylll sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: 1 """ diff --git a/src/sage/schemes/toric/weierstrass_higher.py b/src/sage/schemes/toric/weierstrass_higher.py index 2a83234e6ca..6e2cc57e59d 100644 --- a/src/sage/schemes/toric/weierstrass_higher.py +++ b/src/sage/schemes/toric/weierstrass_higher.py @@ -258,7 +258,7 @@ def WeierstrassMap_P3(quadratic1, quadratic2, variables=None): (-1/4, 0) sage: ideal = R.ideal(quadratic1, quadratic2) - sage: (-Y^2 + X^3 + a*X*Z^4 + b*Z^6).reduce(ideal) + sage: (-Y^2 + X^3 + a*X*Z^4 + b*Z^6).reduce(ideal) # needs sage.libs.singular 0 TESTS:: From a1195b05abb92292d39f9d2982c9b25d3b1a41eb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 19:49:10 -0700 Subject: [PATCH 096/494] sage.schemes: Update # needs --- src/sage/schemes/affine/affine_homset.py | 2 +- src/sage/schemes/affine/affine_morphism.py | 4 ++-- src/sage/schemes/affine/affine_subscheme.py | 6 +++--- src/sage/schemes/generic/algebraic_scheme.py | 4 ++-- src/sage/schemes/generic/morphism.py | 8 ++++---- src/sage/schemes/projective/projective_homset.py | 2 +- src/sage/schemes/projective/projective_point.py | 4 ++-- src/sage/schemes/toric/divisor.py | 4 ++-- src/sage/schemes/toric/ideal.py | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py index 52ea3f83c85..b6570bd6f6d 100644 --- a/src/sage/schemes/affine/affine_homset.py +++ b/src/sage/schemes/affine/affine_homset.py @@ -393,7 +393,7 @@ def numerical_points(self, F=None, **kwds): EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field sage: K. = QuadraticField(3) sage: A. = AffineSpace(K, 2) sage: X = A.subscheme([x^3 - v^2*y, y - v*x^2 + 3]) diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index 7e855f78921..dd9eb7cf844 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -1069,7 +1069,7 @@ def weil_restriction(self): sage: A. = AffineSpace(K, 2) sage: H = End(A) sage: f = H([x^2 - y^2, y^2]) - sage: f.weil_restriction() + sage: f.weil_restriction() # needs sage.libs.singular Scheme endomorphism of Affine Space of dimension 4 over Rational Field Defn: Defined on coordinates by sending (z0, z1, z2, z3) to (z0^2 + 5*z1^2 - z2^2 - 5*z3^2, 2*z0*z1 - 2*z2*z3, z2^2 + 5*z3^2, 2*z2*z3) @@ -1084,7 +1084,7 @@ def weil_restriction(self): sage: F = f.weil_restriction() sage: P = PS(2, 1) sage: Q = P.weil_restriction() - sage: f(P).weil_restriction() == F(Q) + sage: f(P).weil_restriction() == F(Q) # needs sage.libs.singular True """ if any(isinstance(f, FractionFieldElement) for f in self): diff --git a/src/sage/schemes/affine/affine_subscheme.py b/src/sage/schemes/affine/affine_subscheme.py index ed125a60193..e55f4512a15 100644 --- a/src/sage/schemes/affine/affine_subscheme.py +++ b/src/sage/schemes/affine/affine_subscheme.py @@ -374,7 +374,7 @@ def intersection_multiplicity(self, X, P): ....: -7*b^5 + 21*b^4 - 28*b^3 + 21*b^2 - 21*b + 14, ....: -b^5 + 2*b^4 - 3*b^3 + 2*b^2 - 2*b, ....: 0]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular 3 :: @@ -470,10 +470,10 @@ def multiplicity(self, P): sage: A. = AffineSpace(K, 5) sage: X = A.subscheme([y^7 - x^2*z^5 + z^3*t^8 - x^2*y^4*z - t^8]) sage: Q1 = A([1,1,0,1,-1]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = A([0,0,0,-a,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 7 Check that :trac:`27479` is fixed:: diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index e030371f70e..0648ad2a9f4 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -1282,7 +1282,7 @@ def is_irreducible(self): sage: K = QuadraticField(-3) sage: P. = ProjectiveSpace(K, 5) sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) - sage: X.is_irreducible() + sage: X.is_irreducible() # needs sage.libs.singular True :: @@ -1775,7 +1775,7 @@ def rational_points(self, **kwds): sage: K. = NumberField(u^2 + 3) sage: A. = ProjectiveSpace(K, 1) sage: X = A.subscheme(x^2 - y^2) - sage: X.rational_points(bound=3) + sage: X.rational_points(bound=3) # needs sage.libs.singular [(-1 : 1), (1 : 1)] One can enumerate points up to a given bound on a projective scheme diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 7597d385b40..4405268fed6 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -1349,8 +1349,8 @@ def change_ring(self, R, check=True): sage: K2. = NumberField(t**4 - 2) sage: P. = ProjectiveSpace(QQ, 1) sage: phi = K.embeddings(K2)[0] - sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) - sage: f.change_ring(phi) + sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) # needs sage.schemes + sage: f.change_ring(phi) # needs sage.schemes Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial t^4 - 2 Defn: Defined on coordinates by sending (x : y) to (x^2 + 3*y^2 : y^2) @@ -1364,8 +1364,8 @@ def change_ring(self, R, check=True): sage: K2. = NumberField(t^8 - 2) sage: P. = ProjectiveSpace(K, 1) sage: phi = K1.embeddings(K2)[0] - sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) - sage: f.change_ring(phi) + sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) # needs sage.schemes + sage: f.change_ring(phi) # needs sage.schemes Traceback (most recent call last): ... ValueError: no canonical coercion of base ring of morphism to domain of embedding diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index e1031e71fcf..2a61c1dd17c 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -581,7 +581,7 @@ class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_f The bug reported at :trac:`1785` is fixed:: - sage: # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage.schemes sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + x - (3^3-3)) sage: E = EllipticCurve('37a') diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 9769b7237c6..e22e0a858b1 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -728,8 +728,8 @@ def global_height(self, prec=None): :: sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field - sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # needs sage.rings.number_field - sage: Q.global_height() # needs sage.rings.number_field + sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # needs sage.rings.number_field sage.symbolic + sage: Q.global_height() # needs sage.rings.number_field sage.symbolic 0.549306144334055 :: diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index c928cec4a7a..796d667c518 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -1267,7 +1267,7 @@ def Kodaira_map(self, names='z'): sage: P1. = toric_varieties.P1() sage: D = -P1.K() - sage: D.Kodaira_map() # needs fpylll + sage: D.Kodaira_map() # needs fpylll sage.libs.singular Scheme morphism: From: 1-d CPR-Fano toric variety covered by 2 affine patches To: Closed subscheme of Projective Space of dimension 2 @@ -1276,7 +1276,7 @@ def Kodaira_map(self, names='z'): sage: dP6 = toric_varieties.dP6() sage: D = -dP6.K() - sage: D.Kodaira_map(names='x') # needs fpylll + sage: D.Kodaira_map(names='x') # needs fpylll sage.libs.singular Scheme morphism: From: 2-d CPR-Fano toric variety covered by 6 affine patches To: Closed subscheme of Projective Space of dimension 6 diff --git a/src/sage/schemes/toric/ideal.py b/src/sage/schemes/toric/ideal.py index bf9eb94e331..6d611719c14 100644 --- a/src/sage/schemes/toric/ideal.py +++ b/src/sage/schemes/toric/ideal.py @@ -1,4 +1,4 @@ -# sage.doctest: needs sage.geometry.polyhedron sage.graphs +# sage.doctest: needs sage.geometry.polyhedron sage.graphs sage.libs.singular r""" Toric ideals From d05991b31c4008dbf039ed36f66a218f3229fd35 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 11:14:32 -0700 Subject: [PATCH 097/494] sage.rings.{padics,valuations}: Update # needs --- src/sage/rings/padics/padic_template_element.pxi | 1 + src/sage/rings/valuation/valuation.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index 17f41ff6e65..63369090da5 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -728,6 +728,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): sage: (a + 1).residue() a0 + 1 + sage: # needs sage.libs.ntl sage: R. = Qq(27, 4) sage: (3 + 3*a).residue() 0 diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index 32b0df105d5..a095595dc3d 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -462,24 +462,25 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Some difficult cases provided by Mark van Hoeij:: - sage: k = GF(2) # needs sage.rings.finite_rings - sage: K. = FunctionField(k) # needs sage.rings.function_field - sage: R. = K[] # needs sage.rings.function_field + sage: # needs sage.rings.finite_rings sage.rings.function_field + sage: k = GF(2) + sage: K. = FunctionField(k) + sage: R. = K[] sage: F = y^21 + x*y^20 + (x^3 + x + 1)*y^18 + (x^3 + 1)*y^17 + (x^4 + x)*y^16 + (x^7 + x^6 + x^3 + x + 1)*y^15 + x^7*y^14 + (x^8 + x^7 + x^6 + x^4 + x^3 + 1)*y^13 + (x^9 + x^8 + x^4 + 1)*y^12 + (x^11 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2)*y^11 + (x^12 + x^9 + x^8 + x^7 + x^5 + x^3 + x + 1)*y^10 + (x^14 + x^13 + x^10 + x^9 + x^8 + x^7 + x^6 + x^3 + x^2 + 1)*y^9 + (x^13 + x^9 + x^8 + x^6 + x^4 + x^3 + x)*y^8 + (x^16 + x^15 + x^13 + x^12 + x^11 + x^7 + x^3 + x)*y^7 + (x^17 + x^16 + x^13 + x^9 + x^8 + x)*y^6 + (x^17 + x^16 + x^12 + x^7 + x^5 + x^2 + x + 1)*y^5 + (x^19 + x^16 + x^15 + x^12 + x^6 + x^5 + x^3 + 1)*y^4 + (x^18 + x^15 + x^12 + x^10 + x^9 + x^7 + x^4 + x)*y^3 + (x^22 + x^21 + x^20 + x^18 + x^13 + x^12 + x^9 + x^8 + x^7 + x^5 + x^4 + x^3)*y^2 + (x^23 + x^22 + x^20 + x^17 + x^15 + x^14 + x^12 + x^9)*y + x^25 + x^23 + x^19 + x^17 + x^15 + x^13 + x^11 + x^5 - sage: x = K._ring.gen() # needs sage.rings.function_field - sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: x = K._ring.gen() + sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x,1)) sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.geometry.polyhedron [[ Gauss valuation induced by (x)-adic valuation, v(y + x + 1) = 3/2 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 1 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 4/3 ], [ Gauss valuation induced by (x)-adic valuation, v(y^15 + y^13 + y^12 + y^10 + y^9 + y^8 + y^4 + y^3 + y^2 + y + 1) = 1 ]] - sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x+1,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x+1,1)) sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.geometry.polyhedron [[ Gauss valuation induced by (x + 1)-adic valuation, v(y + x^2 + 1) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 3/4 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y^13 + y^12 + y^10 + y^7 + y^6 + y^3 + 1) = 1 ]] - sage: v0 = valuations.FunctionFieldValuation(K, GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x^3+x^2+1,1)) # needs sage.rings.finite_rings sage.rings.function_field + sage: v0 = valuations.FunctionFieldValuation(K, GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x^3+x^2+1,1)) sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed # needs sage.rings.function_field [[ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y + x^3 + x^2 + x) = 2, v(y^2 + (x^6 + x^4 + 1)*y + x^14 + x^10 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2 + x) = 5 ], [ Gauss valuation induced by (x^3 + x^2 + 1)-adic valuation, v(y^2 + (x^2 + x)*y + 1) = 1 ], From adc3087e70e224bf520c2790d591e07ca91a8869 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 19:49:01 -0700 Subject: [PATCH 098/494] sage.rings.valuation: Update # needs --- src/sage/rings/valuation/augmented_valuation.py | 3 +-- src/sage/rings/valuation/inductive_valuation.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 0d873aa4943..0e15d004013 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -588,8 +588,7 @@ def restriction(self, ring): sage: R. = K[] sage: v = GaussValuation(R, K.valuation(2)) sage: w = v.augmentation(x^2 + x + 1, 1) - - sage: w.restriction(QQ['x']) + sage: w.restriction(QQ['x']) # needs sage.lins.singular [ Gauss valuation induced by 2-adic valuation, v(x^2 + x + 1) = 1 ] """ if ring.is_subring(self.domain()): diff --git a/src/sage/rings/valuation/inductive_valuation.py b/src/sage/rings/valuation/inductive_valuation.py index d06ff7a29a3..f547f1bee96 100644 --- a/src/sage/rings/valuation/inductive_valuation.py +++ b/src/sage/rings/valuation/inductive_valuation.py @@ -1272,7 +1272,7 @@ def equivalence_decomposition(self, f, assume_not_equivalence_unit=False, coeffi TESTS:: - sage: # needs sage.geometry.polyhedron sage.rings.number_field + sage: # needs sage.geometry.polyhedron sage.groups sage.rings.number_field sage: R. = QQ[] sage: K1. = NumberField(x^3 - 2) sage: K. = K1.galois_closure() From 4e97c428f3cc65563470ad175b75b6eef4ba862d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 16:17:03 -0700 Subject: [PATCH 099/494] sage.features.sagemath: Split UCF from sage.rings.number_field, add some join feature deps --- src/sage/features/sagemath.py | 37 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py index ac3922552e4..4516d20929e 100644 --- a/src/sage/features/sagemath.py +++ b/src/sage/features/sagemath.py @@ -389,7 +389,19 @@ def __init__(self): """ JoinFeature.__init__(self, 'sage.libs.gap', [PythonModule('sage.libs.gap.libgap'), - PythonModule('sage.interfaces.gap')]) + PythonModule('sage.interfaces.gap'), + PythonModule('sage.groups.matrix_gps.finitely_generated_gap'), + PythonModule('sage.groups.matrix_gps.group_element_gap'), + PythonModule('sage.groups.matrix_gps.heisenberg'), + PythonModule('sage.groups.matrix_gps.isometries'), + PythonModule('sage.groups.matrix_gps.linear_gap'), + PythonModule('sage.groups.matrix_gps.matrix_group_gap'), + PythonModule('sage.groups.matrix_gps.named_group_gap'), + PythonModule('sage.groups.matrix_gps.orthogonal_gap'), + PythonModule('sage.groups.matrix_gps.symplectic_gap'), + PythonModule('sage.groups.matrix_gps.unitary_gap'), + PythonModule('sage.matrix.matrix_gap'), + PythonModule('sage.rings.universal_cyclotomic_field')]) class sage__libs__linbox(JoinFeature): @@ -397,8 +409,8 @@ class sage__libs__linbox(JoinFeature): A :class:`sage.features.Feature` describing the presence of :mod:`sage.libs.linbox` and other modules depending on Givaro, FFLAS-FFPACK, LinBox. - In addition to the modularization purposes that this tag serves, - it also provides attribution to the upstream project. + In addition to the modularization purposes that this tag serves, it also provides attribution + to the upstream project. TESTS:: @@ -415,7 +427,9 @@ def __init__(self): True """ JoinFeature.__init__(self, 'sage.libs.linbox', - [PythonModule('sage.rings.finite_rings.element_givaro')], + [PythonModule('sage.rings.finite_rings.element_givaro'), + PythonModule('sage.matrix.matrix_modn_dense_float'), + PythonModule('sage.matrix.matrix_modn_dense_double')], spkg='sagemath_linbox', type='standard') @@ -442,7 +456,8 @@ def __init__(self): True """ JoinFeature.__init__(self, 'sage.libs.m4ri', - [PythonModule('sage.matrix.matrix_gf2e_dense')], + [PythonModule('sage.matrix.matrix_gf2e_dense'), + PythonModule('sage.matrix.matrix_mod2_dense')], spkg='sagemath_m4ri', type='standard') @@ -708,7 +723,8 @@ def __init__(self): """ JoinFeature.__init__(self, 'sage.rings.finite_rings', [PythonModule('sage.rings.finite_rings.element_pari_ffelt'), - PythonModule('sage.rings.algebraic_closure_finite_field')], + PythonModule('sage.rings.algebraic_closure_finite_field'), + sage__libs__pari()], type='standard') @@ -784,8 +800,8 @@ class sage__rings__number_field(JoinFeature): sage: CC(zeta) 0.913545457642601 + 0.406736643075800*I - Doctests that make use of the algebraic field ``QQbar``, the algebraic real field ``AA``, - or the universal cyclotomic field should be marked likewise:: + Doctests that make use of the algebraic field ``QQbar`` or the algebraic real field ``AA`` + should be marked likewise:: sage: # needs sage.rings.number_field sage: AA(-1)^(1/3) @@ -793,7 +809,10 @@ class sage__rings__number_field(JoinFeature): sage: QQbar(-1)^(1/3) 0.500000000000000? + 0.866025403784439?*I - sage: # needs sage.rings.number_field + Use of the universal cyclotomic field should be marked + ``# needs sage.libs.gap sage.rings.number_field``. + + sage: # needs sage.libs.gap sage.rings.number_field sage: UCF = UniversalCyclotomicField(); UCF Universal Cyclotomic Field sage: E = UCF.gen From 3df2d39622b4b8b86c955a5ea0365bfc1e49b608 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 24 Sep 2023 21:47:18 -0700 Subject: [PATCH 100/494] Mark uses of UCF as # needs sage.libs.gap sage.rings.number_field --- src/sage/rings/abc.pyx | 6 +++--- src/sage/rings/complex_interval_field.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/abc.pyx b/src/sage/rings/abc.pyx index 7dde9da52b8..028cade2bba 100644 --- a/src/sage/rings/abc.pyx +++ b/src/sage/rings/abc.pyx @@ -66,13 +66,13 @@ class UniversalCyclotomicField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: K = UniversalCyclotomicField() # needs sage.libs.gap - sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # needs sage.libs.gap + sage: K = UniversalCyclotomicField() # needs sage.libs.gap sage.rings.number_field + sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # needs sage.libs.gap sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # needs sage.libs.gap + sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # needs sage.libs.gap sage.rings.number_field [] sage: len(sage.rings.abc.NumberField_cyclotomic.__subclasses__()) <= 1 diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index 20e5335a0b4..7903ab42bae 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -484,19 +484,19 @@ def _coerce_map_from_(self, S): Coercion map: From: Set of Python objects of class 'int' To: Complex Interval Field with 53 bits of precision - sage: CIF.coerce_map_from(GaussianIntegers()) + sage: CIF.coerce_map_from(GaussianIntegers()) # needs sage.rings.number_field Conversion via _complex_mpfi_ method map: From: Gaussian Integers in Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Complex Interval Field with 53 bits of precision - sage: CIF.coerce_map_from(QQbar) + sage: CIF.coerce_map_from(QQbar) # needs sage.rings.number_field Conversion via _complex_mpfi_ method map: From: Algebraic Field To: Complex Interval Field with 53 bits of precision - sage: CIF.coerce_map_from(AA) + sage: CIF.coerce_map_from(AA) # needs sage.rings.number_field Conversion via _complex_mpfi_ method map: From: Algebraic Real Field To: Complex Interval Field with 53 bits of precision - sage: CIF.coerce_map_from(UniversalCyclotomicField()) # needs sage.libs.gap + sage: CIF.coerce_map_from(UniversalCyclotomicField()) # needs sage.libs.gap sage.rings.number_field Conversion via _complex_mpfi_ method map: From: Universal Cyclotomic Field To: Complex Interval Field with 53 bits of precision @@ -532,9 +532,9 @@ def _repr_(self): EXAMPLES:: - sage: ComplexIntervalField() # indirect doctest + sage: ComplexIntervalField() # indirect doctest Complex Interval Field with 53 bits of precision - sage: ComplexIntervalField(100) # indirect doctest + sage: ComplexIntervalField(100) # indirect doctest Complex Interval Field with 100 bits of precision """ return "Complex Interval Field with %s bits of precision" % self._prec From e38afeb967ae884fb8609ce35191a72e8ad0ade9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 1 Oct 2023 09:52:26 -0700 Subject: [PATCH 101/494] src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py: Use file and block tags --- .../arithmetic_dynamics/berkovich_ds.py | 222 +++++++++--------- 1 file changed, 108 insertions(+), 114 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index 5bb5e01d488..8f356067367 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Dynamical systems on Berkovich space over `\CC_p`. @@ -71,9 +72,9 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet We can easily create a dynamical system on Berkovich space using a dynamical system on projective space over `\QQ_p`:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) + sage: DynamicalSystem_Berkovich(f) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -82,8 +83,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Or directly from polynomials:: - sage: P. = ProjectiveSpace(Qp(3),1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3),1) + sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -91,8 +92,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet :class:`DynamicalSystem_Berkovich` defaults to projective:: - sage: R. = Qp(3)[] # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics + sage: R. = Qp(3)[] + sage: DynamicalSystem_Berkovich([x^2, y^2]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -101,30 +102,31 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet To create an affine dynamical system on Berkovich space, pass an affine dynamical system to :class:`DynamicalSystem_Berkovich`:: - sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_affine(z^2 + 1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) + sage: f = DynamicalSystem_affine(z^2 + 1) + sage: DynamicalSystem_Berkovich(f) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (z) to (z^2 + 1 + O(3^20)) ``domain`` can be used to specify the type of dynamical system:: - sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics - sage: C = Berkovich_Cp_Affine(3) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([z^2 + 1], C) # needs sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) + sage: C = Berkovich_Cp_Affine(3) + sage: DynamicalSystem_Berkovich([z^2 + 1], C) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (z) to (z^2 + 1 + O(3^20)) We can create dynamical systems which act on Berkovich spaces backed by number fields:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field - sage: ideal = A.prime_above(2) # needs sage.rings.padics - sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.padics - sage: B = Berkovich_Cp_Projective(P, ideal) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], B) # needs sage.rings.number_field sage.rings.padics + sage: A. = NumberField(z^2 + 1) + sage: ideal = A.prime_above(2) + sage: P. = ProjectiveSpace(A, 1) + sage: B = Berkovich_Cp_Projective(P, ideal) + sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], B) Dynamical system of Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -133,11 +135,12 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet We can use the optional parameter ``ideal`` to create the same dynamical system more efficiently:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field - sage: prime_ideal = A.prime_above(2) # needs sage.rings.padics - sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], ideal=prime_ideal) # needs sage.rings.number_field sage.rings.padics + sage: A. = NumberField(z^2 + 1) + sage: prime_ideal = A.prime_above(2) + sage: P. = ProjectiveSpace(A, 1) + sage: DynamicalSystem_Berkovich([x^2 + y^2, 2*a*x*y], ideal=prime_ideal) Dynamical system of Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -146,7 +149,6 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Creating a map on Berkovich space creates the Berkovich space it acts on:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([x^2, y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -155,7 +157,6 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet The image of type I point is the image of the center:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: F = DynamicalSystem_Berkovich([x^2, y^2]) sage: B = F.domain() @@ -167,13 +168,12 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet the image is the type II/III point corresponding to the image of the disk:: - sage: Q2 = B(0, 3) # needs sage.rings.padics - sage: F(Q2) # needs sage.rings.padics + sage: Q2 = B(0, 3) + sage: F(Q2) Type II point centered at (0 : 1 + O(3^20)) of radius 3^2 The image of any type II point can be computed:: - sage: # needs sage.rings.padics sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) sage: G = DynamicalSystem_Berkovich(g) sage: Q3 = B(0, 1) @@ -183,15 +183,15 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet The image of type III points can be computed has long as the corresponding disk contains no poles of the dynamical system:: - sage: Q4 = B(1/9, 1.5) # needs sage.rings.padics - sage: G(Q4) # needs sage.rings.padics + sage: Q4 = B(1/9, 1.5) + sage: G(Q4) Type III point centered at (3^-2 + 3^2 + O(3^18) : 1 + O(3^20)) of radius 1.50000000000000 Sometimes, however, the poles are contained in an extension of `\QQ_p` that Sage does not support:: - sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) # needs sage.rings.padics + sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) sage: H(Q4) # not tested Traceback (most recent call last): ... @@ -212,7 +212,7 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet Alternatively, if checking for poles in the disk has been done already, ``type_3_pole_check`` can be set to ``False``:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) sage: B = H.domain() sage: Q4 = B(1/9, 1.5) @@ -232,9 +232,9 @@ def __classcall_private__(cls, dynamical_system, domain=None, ideal=None): EXAMPLES:: - sage: R. = Qp(3)[] # needs sage.rings.padics - sage: f = DynamicalSystem_affine(t^2 - 3) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: R. = Qp(3)[] + sage: f = DynamicalSystem_affine(t^2 - 3) + sage: DynamicalSystem_Berkovich(f) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending ((1 + O(3^20))*t) to ((1 + O(3^20))*t^2 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + @@ -292,7 +292,6 @@ def __init__(self, dynamical_system, domain): TESTS:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -308,15 +307,15 @@ def __eq__(self, other): EXAMPLES:: - sage: R. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics - sage: f == f # needs sage.rings.padics + sage: R. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) + sage: f == f True :: - sage: g = DynamicalSystem_Berkovich([x^3, x*y^2]) # needs sage.rings.padics - sage: f == g # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich([x^3, x*y^2]) + sage: f == g True """ if not isinstance(other, type(self)): @@ -329,15 +328,15 @@ def __neq__(self, other): EXAMPLES:: - sage: R. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics - sage: f != f # needs sage.rings.padics + sage: R. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) + sage: f != f False :: - sage: g = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics - sage: f != g # needs sage.rings.padics + sage: g = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) + sage: f != g True """ return not (self == other) @@ -350,7 +349,6 @@ def domain(self): EXAMPLES:: - sage: # needs sage.rings.padics sage: Q. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -367,9 +365,9 @@ def as_scheme_dynamical_system(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y]) # needs sage.rings.padics - sage: f.as_scheme_dynamical_system() # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y]) + sage: f.as_scheme_dynamical_system() Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20 Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : x*y) @@ -389,7 +387,6 @@ def __getitem__(self, i): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -407,7 +404,6 @@ def defining_polynomials(self): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -425,18 +421,19 @@ def base_ring(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics - sage: f.base_ring() # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) + sage: f.base_ring() 3-adic Field with capped relative precision 20 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_Berkovich([x^2, x^2 + y^2], ideal=A.prime_above(2)) # needs sage.rings.number_field - sage: f.base_ring() # needs sage.rings.padics + sage: A. = NumberField(z^3 + 20) + sage: P. = ProjectiveSpace(A, 1) + sage: f = DynamicalSystem_Berkovich([x^2, x^2 + y^2], ideal=A.prime_above(2)) + sage: f.base_ring() Number Field in a with defining polynomial z^3 + 20 """ return self.domain().base_ring() @@ -449,7 +446,6 @@ def _repr_(self): EXAMPLES:: - sage: # needs sage.rings.padics sage: Q. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([3*x^2, 2*y^2]) sage: f = DynamicalSystem_Berkovich(f) @@ -487,9 +483,9 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich): We can easily create a dynamical system on Berkovich space using a dynamical system on projective space over `\QQ_p`:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_projective([1/2*x^2 + x*y + 3*y^2, 3*x^2 + 9*y^2]) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_projective([1/2*x^2 + x*y + 3*y^2, 3*x^2 + 9*y^2]) + sage: DynamicalSystem_Berkovich(f) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -499,17 +495,17 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich): Or from a morphism:: - sage: P1. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: H = End(P1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(H([y, x])) # needs sage.rings.padics + sage: P1. = ProjectiveSpace(Qp(3), 1) + sage: H = End(P1) + sage: DynamicalSystem_Berkovich(H([y, x])) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (y : x) Or from polynomials:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2+y^2, y^2]) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: DynamicalSystem_Berkovich([x^2+y^2, y^2]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) @@ -521,9 +517,9 @@ def __classcall_private__(cls, dynamical_system, domain=None): EXAMPLES:: - sage: P1. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: P1. = ProjectiveSpace(Qp(3), 1) sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_projective - sage: DynamicalSystem_Berkovich_projective([y, x]) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich_projective([y, x]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (y : x) @@ -559,8 +555,8 @@ def __init__(self, dynamical_system, domain=None): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y]) # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y]) Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -580,22 +576,23 @@ def scale_by(self, t): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2, y^2]) # needs sage.rings.padics - sage: f.scale_by(x); f # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2, y^2]) + sage: f.scale_by(x); f Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^3 : x*y^2) :: + sage: # needs sage.rings.number_field sage: Q. = QQ[] - sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field - sage: ideal = A.prime_above(3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field - sage: B = Berkovich_Cp_Projective(P, ideal) # needs sage.rings.number_field sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, 2*x*y], B) # needs sage.rings.number_field sage.rings.padics - sage: f.scale_by(2); f # needs sage.rings.padics + sage: A. = NumberField(z^3 + 20) + sage: ideal = A.prime_above(3) + sage: P. = ProjectiveSpace(A, 1) + sage: B = Berkovich_Cp_Projective(P, ideal) + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, 2*x*y], B) + sage: f.scale_by(2); f Dynamical system of Projective Berkovich line over Cp(3), with base Number Field in a with defining polynomial z^3 + 20 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -611,9 +608,9 @@ def normalize_coordinates(self): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2]) # needs sage.rings.padics - sage: f.normalize_coordinates(); f # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2]) + sage: f.normalize_coordinates(); f Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2) @@ -621,8 +618,8 @@ def normalize_coordinates(self): Normalize_coordinates may sometimes fail over p-adic fields:: - sage: g = DynamicalSystem_Berkovich([2*x^2, x*y]) # needs sage.rings.padics - sage: g.normalize_coordinates() #not tested + sage: g = DynamicalSystem_Berkovich([2*x^2, x*y]) + sage: g.normalize_coordinates() # not tested Traceback (most recent call last): ... TypeError: unable to coerce since the denominator is not 1 @@ -664,7 +661,6 @@ def conjugate(self, M, adjugate=False, new_ideal=None): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -676,12 +672,13 @@ def conjugate(self, M, adjugate=False, new_ideal=None): :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2], ideal=5) sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field - sage: conj = Matrix([[1, a], [0, 1]]) # needs sage.rings.number_field - sage: f.conjugate(conj) # needs sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: conj = Matrix([[1, a], [0, 1]]) + sage: f.conjugate(conj) Dynamical system of Projective Berkovich line over Cp(5), with base Number Field in a with defining polynomial z^2 + 1 induced by the map Defn: Defined on coordinates by sending (x : y) to @@ -691,10 +688,11 @@ def conjugate(self, M, adjugate=False, new_ideal=None): the base ring of ``M`` and of this dynamical system are not the same:: - sage: ideal = A.ideal(5).factor()[1][0]; ideal # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: ideal = A.ideal(5).factor()[1][0]; ideal Fractional ideal (2*a + 1) - sage: g = f.conjugate(conj, new_ideal=ideal) # needs sage.rings.number_field - sage: g.domain().ideal() # needs sage.rings.padics + sage: g = f.conjugate(conj, new_ideal=ideal) + sage: g.domain().ideal() Fractional ideal (2*a + 1) """ if self.domain().is_padic_base(): @@ -727,18 +725,19 @@ def resultant(self, normalize=False): EXAMPLES:: - sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) # needs sage.rings.padics - sage: f.resultant() # needs sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) + sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2]) + sage: f.resultant() 1 + O(3^20) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^3 + 20) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(A, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_Berkovich([2*x^2, x^2 + y^2], ideal=A.prime_above(2)) # needs sage.rings.number_field - sage: f.resultant() # needs sage.rings.padics + sage: A. = NumberField(z^3 + 20) + sage: P. = ProjectiveSpace(A, 1) + sage: f = DynamicalSystem_Berkovich([2*x^2, x^2 + y^2], ideal=A.prime_above(2)) + sage: f.resultant() 4 """ return self._system.resultant(normalize=normalize) @@ -759,7 +758,6 @@ def dehomogenize(self, n): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2]) sage: g = DynamicalSystem_Berkovich(f) @@ -793,7 +791,6 @@ def __call__(self, x, type_3_pole_check=True): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: g = DynamicalSystem_projective([x^2 + y^2, x*y]) sage: G = DynamicalSystem_Berkovich(g) @@ -804,7 +801,6 @@ def __call__(self, x, type_3_pole_check=True): :: - sage: # needs sage.rings.padics sage: P. = ProjectiveSpace(Qp(3), 1) sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3]) sage: B = H.domain() @@ -984,17 +980,17 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich): induced by a dynamical system on `\QQ_p` or an extension of `\QQ_p`:: - sage: A. = AffineSpace(Qp(5), 1) # needs sage.rings.padics - sage: f = DynamicalSystem_affine([(x^2 + 1)/x]) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(f) # needs sage.rings.padics + sage: A. = AffineSpace(Qp(5), 1) + sage: f = DynamicalSystem_affine([(x^2 + 1)/x]) + sage: DynamicalSystem_Berkovich(f) Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to ((x^2 + 1 + O(5^20))/x) Dynamical system can be created from a morphism:: - sage: H = End(A) # needs sage.rings.padics - sage: phi = H([x + 3]) # needs sage.rings.padics - sage: DynamicalSystem_Berkovich(phi) # needs sage.rings.padics + sage: H = End(A) + sage: phi = H([x + 3]) + sage: DynamicalSystem_Berkovich(phi) Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x + 3 + O(5^20)) """ @@ -1005,9 +1001,9 @@ def __classcall_private__(cls, dynamical_system, domain=None): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine - sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2)) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2)) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x^2) @@ -1039,9 +1035,9 @@ def __init__(self, dynamical_system, domain): EXAMPLES:: - sage: A. = AffineSpace(Qp(3), 1) # needs sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine - sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3)) # needs sage.rings.padics + sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3)) Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map Defn: Defined on coordinates by sending (x) to (x^3) @@ -1065,7 +1061,6 @@ def homogenize(self, n): EXAMPLES:: - sage: # needs sage.rings.padics sage: A. = AffineSpace(Qp(3), 1) sage: f = DynamicalSystem_affine(1/x) sage: f = DynamicalSystem_Berkovich(f) @@ -1086,7 +1081,6 @@ def __call__(self, x): EXAMPLES:: - sage: # needs sage.rings.padics sage: P. = AffineSpace(Qp(3), 1) sage: f = DynamicalSystem_affine(x^2) sage: g = DynamicalSystem_Berkovich(f) From 8443583acd1f37329d4c81b6cd5d40b6509ed72f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 1 Oct 2023 10:24:12 -0700 Subject: [PATCH 102/494] src/sage/dynamics/arithmetic_dynamics/projective_ds.py: Many more block tags --- .../arithmetic_dynamics/projective_ds.py | 580 ++++++++++-------- 1 file changed, 325 insertions(+), 255 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index d75972f812d..6625f1bd92b 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -1230,16 +1230,17 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: # Correct value should be = 0.323067... sage: f.arakelov_zhang_pairing(g, n=9) # long time # needs sage.rings.function_field 0.323091061918965 - sage: _ - 0.323067 # long time # needs sage.rings.function_field + sage: _ - 0.323067 # long time # needs sage.rings.function_field 0.0000240619189654789 Also from Prop. 18 of Petsche, Szpiro and Tucker, includes places of bad reduction:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(ZZ) - sage: K. = NumberField(z^3 - 11) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: a = 7/(b - 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) # needs sage.rings.number_field + sage: K. = NumberField(z^3 - 11) + sage: P. = ProjectiveSpace(K,1) + sage: a = 7/(b - 1) + sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) sage: g = DynamicalSystem_projective([x^2, y^2]) If all archimedean absolute values of a have modulus > 2, @@ -1247,7 +1248,7 @@ def arakelov_zhang_pairing(self, g, **kwds): sage: f.arakelov_zhang_pairing(g, n=6) # long time # needs sage.rings.number_field 1.93846423207664 - sage: _ - a.global_height() # long time # needs sage.rings.number_field + sage: _ - a.global_height() # long time # needs sage.rings.number_field -0.00744591697867292 """ n = kwds.pop('n', 5) @@ -1710,11 +1711,12 @@ def resultant(self, normalize=False): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: s = (t^3 + t + 1).roots(QQbar)[0][0] # needs sage.rings.number_field - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([s*x^3 - 13*y^3, y^3 - 15*y^3]) # needs sage.rings.number_field - sage: f.resultant() # needs sage.rings.number_field + sage: s = (t^3 + t + 1).roots(QQbar)[0][0] + sage: P. = ProjectiveSpace(QQbar, 1) + sage: f = DynamicalSystem_projective([s*x^3 - 13*y^3, y^3 - 15*y^3]) + sage: f.resultant() 871.6925062959149? """ if normalize: @@ -1788,11 +1790,12 @@ def primes_of_bad_reduction(self, check=True): A number field example:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(z^2 - 2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2]) # needs sage.rings.number_field - sage: f.primes_of_bad_reduction() # needs sage.rings.function_field sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2]) + sage: f.primes_of_bad_reduction() # needs sage.rings.function_field [Fractional ideal (a), Fractional ideal (3)] This is an example where ``check=False`` returns extra primes:: @@ -2221,14 +2224,15 @@ def canonical_height(self, P, **kwds): Notice that preperiodic points may not return exactly 0:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^2 + X - 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: K. = NumberField(X^2 + X - 1) + sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: Q = P.point([a,1]) # needs sage.rings.number_field - sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 # needs sage.rings.number_field + sage: Q = P.point([a,1]) + sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 5.7364919788790160119266380480e-8 - sage: f.nth_iterate(Q, 2) == Q # but it is indeed preperiodic # needs sage.rings.number_field + sage: f.nth_iterate(Q, 2) == Q # but it is indeed preperiodic True :: @@ -2437,19 +2441,21 @@ def height_difference_bound(self, prec=None): A number field example:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([1/(c+1)*x^2 + c*y^2, 210*x*y, 10000*z^2]) # needs sage.rings.number_field - sage: f.height_difference_bound() # needs sage.rings.number_field sage.symbolic + sage: K. = NumberField(x^3 - 2) + sage: P. = ProjectiveSpace(K, 2) + sage: f = DynamicalSystem_projective([1/(c+1)*x^2 + c*y^2, 210*x*y, 10000*z^2]) + sage: f.height_difference_bound() # needs sage.symbolic 11.3683039374269 :: - sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, # needs sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, ....: QQbar(sqrt(3))*z^2]) - sage: f.height_difference_bound() # needs sage.rings.number_field sage.symbolic + sage: f.height_difference_bound() 2.89037175789616 :: @@ -3314,14 +3320,15 @@ def all_minimal_models(self, return_transformation=False, prime_list=None, TESTS:: + sage: # needs sage.rings.function_field sage: P. = ProjectiveSpace(QQ, 1) sage: c = 2^2*5^2*11^3 sage: f = DynamicalSystem([x^3 - c^2*y^3, x*y^2]) - sage: MM = f.all_minimal_models(return_transformation=True, algorithm='BM') # needs sage.rings.function_field - sage: all(f.conjugate(m) == F for F, m in MM) # needs sage.rings.function_field + sage: MM = f.all_minimal_models(return_transformation=True, algorithm='BM') + sage: all(f.conjugate(m) == F for F, m in MM) True - sage: MM = f.all_minimal_models(return_transformation=True, algorithm='HS') # needs sage.rings.function_field - sage: all(f.conjugate(m) == F for F,m in MM) # needs sage.rings.function_field + sage: MM = f.all_minimal_models(return_transformation=True, algorithm='HS') + sage: all(f.conjugate(m) == F for F,m in MM) True REFERENCES: @@ -3419,9 +3426,10 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): :: - sage: P. = ProjectiveSpace(GF(9), 2) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(9), 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: f.affine_preperiodic_model(0, 1) # needs sage.rings.finite_rings sage.rings.function_field + sage: f.affine_preperiodic_model(0, 1) # needs sage.rings.function_field Dynamical System of Projective Space of dimension 2 over Finite Field in z2 of size 3^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -3645,7 +3653,8 @@ def automorphism_group(self, **kwds): sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([3*x^2*y - y^3, x^3 - 3*x*y^2]) - sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, # needs sage.libs.pari + sage: lst, label = f.automorphism_group(algorithm='CRT', # needs sage.libs.pari + ....: return_functions=True, ....: iso_type=True) sage: sorted(lst), label # needs sage.libs.pari ([-1/x, 1/x, (-x - 1)/(x - 1), (-x + 1)/(x + 1), (x - 1)/(x + 1), @@ -3749,9 +3758,10 @@ def critical_subscheme(self): :: - sage: P. = ProjectiveSpace(GF(81), 3) # needs sage.rings.finite_rings - sage: g = DynamicalSystem_projective([x^3 + y^3, y^3 + z^3, z^3 + x^3, w^3]) # needs sage.rings.finite_rings - sage: g.critical_subscheme() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(81), 3) + sage: g = DynamicalSystem_projective([x^3 + y^3, y^3 + z^3, z^3 + x^3, w^3]) + sage: g.critical_subscheme() Closed subscheme of Projective Space of dimension 3 over Finite Field in z4 of size 3^4 defined by: 0 @@ -3933,11 +3943,12 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) # needs sage.rings.number_field - sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) # needs sage.rings.number_field - sage: f.is_postcritically_finite() # long time + sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) + sage: PS. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) + sage: f.is_postcritically_finite() # long time True :: @@ -3950,10 +3961,11 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): :: - sage: K = UniversalCyclotomicField() # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field + sage: K = UniversalCyclotomicField() + sage: P. = ProjectiveSpace(K,1) sage: F = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) - sage: F.is_postcritically_finite() # needs sage.rings.number_field + sage: F.is_postcritically_finite() True :: @@ -3972,9 +3984,10 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): :: - sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar,1) sage: f = DynamicalSystem_projective([x^4 - x^2*y^2, y^4]) - sage: f.is_postcritically_finite() # needs sage.rings.number_field + sage: f.is_postcritically_finite() False """ #iteration of subschemes not yet implemented @@ -4018,7 +4031,7 @@ def is_dynamical_belyi_map(self): EXAMPLES:: - sage: P.=ProjectiveSpace(QQ, 1) + sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([-2*x^3 - 9*x^2*y - 12*x*y^2 - 6*y^3, y^3]) sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field True @@ -4039,26 +4052,29 @@ def is_dynamical_belyi_map(self): :: - sage: F = QuadraticField(-7) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(F, 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F = QuadraticField(-7) + sage: P. = ProjectiveSpace(F, 1) sage: f = DynamicalSystem_projective([5*x^7 - 7*x^6*y, -7*x*y^6 + 5*y^7]) - sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field + sage: f.is_dynamical_belyi_map() True :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([2*x^3 + 3*x^2*y - 3*x*y^2 + 2*y^3, x^3 + y^3]) + sage: f = DynamicalSystem_projective([2*x^3 + 3*x^2*y - 3*x*y^2 + 2*y^3, + ....: x^3 + y^3]) sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field False :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: N. = NumberField(t^3 - 2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(N, 1) # needs sage.rings.number_field - sage: f=DynamicalSystem_projective([x^2 + c*y^2, x*y]) # needs sage.rings.number_field - sage: f.is_dynamical_belyi_map() # needs sage.rings.number_field + sage: N. = NumberField(t^3 - 2) + sage: P. = ProjectiveSpace(N, 1) + sage: f=DynamicalSystem_projective([x^2 + c*y^2, x*y]) + sage: f.is_dynamical_belyi_map() False :: @@ -4108,11 +4124,12 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) # needs sage.rings.number_field - sage: PS. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) # needs sage.rings.number_field - sage: f.critical_point_portrait(check=False) # long time # needs sage.graphs sage.rings.number_field + sage: K. = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) + sage: PS. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) + sage: f.critical_point_portrait(check=False) # long time # needs sage.graphs Looped digraph on 6 vertices :: @@ -4133,12 +4150,13 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(t^3 + 2*t^2 + t + 1) # needs sage.rings.number_field - sage: phi = K.embeddings(QQbar)[0] # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) # needs sage.rings.number_field - sage: f.change_ring(phi).critical_point_portrait() # needs sage.graphs sage.rings.number_field + sage: K. = NumberField(t^3 + 2*t^2 + t + 1) + sage: phi = K.embeddings(QQbar)[0] + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) + sage: f.change_ring(phi).critical_point_portrait() # needs sage.graphs Looped digraph on 4 vertices :: @@ -4150,9 +4168,10 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): :: - sage: P. = ProjectiveSpace(QQbar,1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar,1) sage: f = DynamicalSystem_projective([8*x^4 - 8*x^2*y^2 + y^4, y^4]) - sage: f.critical_point_portrait() # long time # needs sage.graphs sage.rings.number_field + sage: f.critical_point_portrait() # long time # needs sage.graphs Looped digraph on 6 vertices :: @@ -4354,9 +4373,10 @@ def preperiodic_points(self, m, n, **kwds): :: - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - x*y + 2*y^2, x^2 - y^2]) # needs sage.rings.number_field - sage: f.preperiodic_points(1, 2, minimal=False) # needs sage.rings.function_field sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: f = DynamicalSystem_projective([x^2 - x*y + 2*y^2, x^2 - y^2]) + sage: f.preperiodic_points(1, 2, minimal=False) # needs sage.rings.function_field [(-3.133185666641252? : 1), (-1 : 1), (-0.3478103847799310? - 1.028852254136693?*I : 1), @@ -4370,11 +4390,12 @@ def preperiodic_points(self, m, n, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: K. = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1) + sage: P. = ProjectiveSpace(K, 2) sage: f = DynamicalSystem_projective([x^2 + z^2, y^2 + x^2, z^2 + y^2]) - sage: sorted(f.preperiodic_points(0, 1), key=str) # needs sage.rings.function_field sage.rings.number_field + sage: sorted(f.preperiodic_points(0, 1), key=str) # needs sage.rings.function_field [(-2*s^5 + 4*s^4 - 5*s^3 + 3*s^2 - 4*s : -2*s^5 + 5*s^4 - 7*s^3 + 6*s^2 - 7*s + 3 : 1), (-s^5 + 3*s^4 - 4*s^3 + 4*s^2 - 4*s + 2 : -s^5 + 2*s^4 - 2*s^3 + s^2 - s : 1), (-s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 3*s + 1 : s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 4*s - 1 : 1), @@ -4674,19 +4695,21 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari EXAMPLES:: + sage: # needs sage.rings.number_field sage: set_verbose(None) - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - x*y + y^2, x^2 - y^2 + x*y]) # needs sage.rings.number_field - sage: f.periodic_points(1) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: f = DynamicalSystem_projective([x^2 - x*y + y^2, x^2 - y^2 + x*y]) + sage: f.periodic_points(1) [(-0.50000000000000000? - 0.866025403784439?*I : 1), (-0.50000000000000000? + 0.866025403784439?*I : 1), (1 : 1)] :: - sage: P. = ProjectiveSpace(QuadraticField(5,'t'), 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - z^2, z^2]) # needs sage.rings.number_field - sage: f.periodic_points(2) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QuadraticField(5,'t'), 2) + sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - z^2, z^2]) + sage: f.periodic_points(2) [(-5/4 : -1 : 1), (-5/4 : -1/2*t + 1/2 : 1), (-5/4 : 0 : 1), (-5/4 : 1/2*t + 1/2 : 1), (-3/4 : -1 : 1), (-3/4 : 0 : 1), (1/4 : -1 : 1), (1/4 : -1/2*t + 1/2 : 1), (1/4 : 0 : 1), @@ -4701,11 +4724,12 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari :: + sage: # needs sage.rings.number_field sage: w = QQ['w'].0 - sage: K = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1,'s') # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: K = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1,'s') + sage: P. = ProjectiveSpace(K, 2) sage: f = DynamicalSystem_projective([x^2 + z^2, y^2 + x^2, z^2 + y^2]) - sage: sorted(f.periodic_points(1), key=str) # needs sage.rings.function_field sage.rings.number_field + sage: sorted(f.periodic_points(1), key=str) # needs sage.rings.function_field [(-2*s^5 + 4*s^4 - 5*s^3 + 3*s^2 - 4*s : -2*s^5 + 5*s^4 - 7*s^3 + 6*s^2 - 7*s + 3 : 1), (-s^5 + 3*s^4 - 4*s^3 + 4*s^2 - 4*s + 2 : -s^5 + 2*s^4 - 2*s^3 + s^2 - s : 1), (-s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 3*s + 1 : s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 4*s - 1 : 1), @@ -4760,9 +4784,10 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari :: - sage: P. = ProjectiveSpace(GF(13^2, 't'), 1) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13^2, 't'), 1) sage: f = DynamicalSystem_projective([x^3 + 3*y^3, x^2*y]) - sage: f.periodic_points(30, minimal=True, algorithm='cyclegraph') # needs sage.graphs sage.rings.finite_rings + sage: f.periodic_points(30, minimal=True, algorithm='cyclegraph') # needs sage.graphs [(t + 3 : 1), (6*t + 6 : 1), (7*t + 1 : 1), (2*t + 8 : 1), (3*t + 4 : 1), (10*t + 12 : 1), (8*t + 10 : 1), (5*t + 11 : 1), (7*t + 4 : 1), (4*t + 8 : 1), (9*t + 1 : 1), (2*t + 2 : 1), @@ -4792,13 +4817,14 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 3) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x + 3) + sage: P. = ProjectiveSpace(K, 2) sage: X = P.subscheme(2*x - y) sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], ....: domain=X) - sage: f.periodic_points(2) # needs sage.rings.function_field sage.rings.number_field + sage: f.periodic_points(2) # needs sage.rings.function_field [(-1/5*u - 1/5 : -2/5*u - 2/5 : 1), (1/5*u - 2/5 : 2/5*u - 4/5 : 1)] :: @@ -4836,8 +4862,9 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: P. = ProjectiveSpace(ZZ, 2) sage: f = DynamicalSystem([x^2 - 2*y^2, y^2, z^2]) - sage: X = f.periodic_points(2, minimal=False, formal=True, return_scheme=True) # long time - sage: len(X.defining_polynomials()) # long time + sage: X = f.periodic_points(2, minimal=False, formal=True, # long time + ....: return_scheme=True) + sage: len(X.defining_polynomials()) # long time 19 TESTS:: @@ -5058,12 +5085,13 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: + sage: # needs sage.rings.number_field sage: set_verbose(None) sage: z = QQ['z'].0 - sage: K. = NumberField(z^4 - 4*z^2 + 1,'z') # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - w/4*y^2, y^2]) # needs sage.rings.number_field - sage: sorted(f.multiplier_spectra(2, formal=False, type='cycle')) # needs sage.rings.number_field + sage: K. = NumberField(z^4 - 4*z^2 + 1,'z') + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 - w/4*y^2, y^2]) + sage: sorted(f.multiplier_spectra(2, formal=False, type='cycle')) [0, 0.0681483474218635? - 1.930649271699173?*I, 0.0681483474218635? + 1.930649271699173?*I, @@ -5127,9 +5155,10 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) sage: f = DynamicalSystem_projective([x^5 + 3*y^5, 4*x^3*y^2]) - sage: f.multiplier_spectra(1) # needs sage.rings.number_field + sage: f.multiplier_spectra(1) [0, -4.106544657178796?, -7/4, @@ -5568,27 +5597,29 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', :: + sage: # needs sage.rings.number_field sage: set_verbose(None) sage: z = QQ['z'].0 - sage: K = NumberField(z^4 - 4*z^2 + 1, 'z') # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) # needs sage.rings.number_field - sage: f.sigma_invariants(2, formal=False, type='cycle') # needs sage.rings.number_field + sage: K = NumberField(z^4 - 4*z^2 + 1, 'z') + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) + sage: f.sigma_invariants(2, formal=False, type='cycle') [13, 11, -25, 0] - sage: f.sigma_invariants(2, formal=False, type='point') # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=False, type='point') [12, -2, -36, 25, 0] check that infinity as part of a longer cycle is handled correctly:: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([y^2, x^2]) - sage: f.sigma_invariants(2, type='cycle') # needs sage.rings.number_field + sage: f.sigma_invariants(2, type='cycle') [12, 48, 64, 0] - sage: f.sigma_invariants(2, type='point') # needs sage.rings.number_field + sage: f.sigma_invariants(2, type='point') [12, 48, 64, 0, 0] - sage: f.sigma_invariants(2, type='cycle', formal=True) # needs sage.rings.number_field + sage: f.sigma_invariants(2, type='cycle', formal=True) [0] - sage: f.sigma_invariants(2, type='point', formal=True) # needs sage.rings.number_field + sage: f.sigma_invariants(2, type='point', formal=True) [0, 0] :: @@ -5624,14 +5655,15 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: Pc. = ProjectiveSpace(R, 1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) - sage: f.sigma_invariants(1) # needs sage.rings.number_field + sage: f.sigma_invariants(1) [2, 4*c, 0] - sage: f.sigma_invariants(2, formal=True, type='point') # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=True, type='point') [8*c + 8, 16*c^2 + 32*c + 16] - sage: f.sigma_invariants(2, formal=True, type='cycle') # needs sage.rings.number_field + sage: f.sigma_invariants(2, formal=True, type='cycle') [4*c + 4] :: @@ -5641,7 +5673,8 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: f = DynamicalSystem([x^2 + c*y^2, y^2]) sage: f.sigma_invariants(1, return_polynomial=True) w^3 + (-3)*w^2*t + 2*w^2 + 3*w*t^2 + (-4)*w*t + 4*c*w - t^3 + 2*t^2 + (-4*c)*t - sage: f.sigma_invariants(2, chow=True, formal=True, return_polynomial=True) # needs sage.libs.pari + sage: f.sigma_invariants(2, chow=True, formal=True, # needs sage.libs.pari + ....: return_polynomial=True) w^2 + (-2)*w*t + (8*c + 8)*w + t^2 + (-8*c - 8)*t + 16*c^2 + 32*c + 16 :: @@ -5683,11 +5716,12 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: N. = NumberField(w^2 + 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(N, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.rings.number_field - sage: f.sigma_invariants(1, chow=True) == f.change_ring(QQ).sigma_invariants(1, chow=True) # needs sage.rings.number_field + sage: N. = NumberField(w^2 + 1) + sage: P. = ProjectiveSpace(N, 2) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f.sigma_invariants(1, chow=True) == f.change_ring(QQ).sigma_invariants(1, chow=True) True :: @@ -6092,36 +6126,39 @@ def reduced_form(self, **kwds): :: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: P. = ProjectiveSpace(RR, 1) - sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) # needs sage.symbolic + sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) sage: m = matrix(RR, 2, 2, [1,12,0,1]) - sage: f = f.conjugate(m) # needs sage.symbolic - sage: g, m = f.reduced_form(smallest_coeffs=False); m # needs sage.symbolic + sage: f = f.conjugate(m) + sage: g, m = f.reduced_form(smallest_coeffs=False); m [ 1 -12] [ 0 1] :: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: P. = ProjectiveSpace(CC, 1) - sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) # needs sage.symbolic + sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) sage: m = matrix(CC, 2, 2, [1,12,0,1]) sage: f = f.conjugate(m) - sage: g, m = f.reduced_form(smallest_coeffs=False); m # needs sage.symbolic + sage: g, m = f.reduced_form(smallest_coeffs=False); m [ 1 -12] [ 0 1] :: - sage: K. = QuadraticField(2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^3, w*y^3]) # needs sage.rings.number_field - sage: m = matrix(K, 2, 2, [1,12,0,1]) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^3, w*y^3]) + sage: m = matrix(K, 2, 2, [1,12,0,1]) sage: f = f.conjugate(m) - sage: f.reduced_form(smallest_coeffs=False) # needs sage.rings.number_field + sage: f.reduced_form(smallest_coeffs=False) ( Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 2 with w = 1.414213562373095? - Defn: Defined on coordinates by sending (x : y) to (x^3 : w*y^3) , + Defn: Defined on coordinates by sending (x : y) to (x^3 : w*y^3) , [ 1 -12] [ 0 1] @@ -6129,14 +6166,15 @@ def reduced_form(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 + x - 3, # needs sage.rings.number_field + sage: K. = NumberField(x^5 + x - 3, ....: embedding=(x^5 + x - 3).roots(ring=CC)[0][0]) - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) # needs sage.rings.number_field - sage: m = matrix(K, 2, 2, [-12,1,1,0]) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) + sage: m = matrix(K, 2, 2, [-12,1,1,0]) sage: f = f.conjugate(m) - sage: f.reduced_form(smallest_coeffs=False) # needs sage.rings.number_field + sage: f.reduced_form(smallest_coeffs=False) ( Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^5 + x - 3 with w = 1.132997565885066? @@ -6323,12 +6361,13 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): Check that :trac:`23814` is fixed (works even if domain is not specified):: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(X^2 + X - 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: K. = NumberField(X^2 + X - 1) + sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: Q = P.point([a,1]) # needs sage.rings.number_field - sage: Q.is_preperiodic(f) # needs sage.rings.function_field sage.rings.number_field + sage: Q = P.point([a,1]) + sage: Q.is_preperiodic(f) # needs sage.rings.function_field True :: @@ -6353,13 +6392,14 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(t^2 - t - 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: K. = NumberField(t^2 - t - 1) + sage: P. = ProjectiveSpace(K, 2) sage: X = P.subscheme(z) sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) - sage: p = X((-a + 1, 1, 0)) # needs sage.rings.number_field - sage: f._is_preperiodic(p) # needs sage.rings.function_field sage.rings.number_field + sage: p = X((-a + 1, 1, 0)) + sage: f._is_preperiodic(p) # needs sage.rings.function_field True """ codomain = self.codomain() @@ -6462,22 +6502,24 @@ def postcritical_set(self, check=True): :: - sage: K. = QuadraticField(2) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem([x^2 + (-2)*y^2, y^2]) - sage: m = matrix(K, 2, 2, [v, 1, 0, 1]) # needs sage.rings.number_field - sage: g = f.conjugate(m) # needs sage.rings.number_field - sage: g.postcritical_set() # needs sage.rings.number_field + sage: m = matrix(K, 2, 2, [v, 1, 0, 1]) + sage: g = f.conjugate(m) + sage: g.postcritical_set() [(-3/2*a : 1), (1/2*a : 1), (1 : 0)] :: - sage: F. = FiniteField(9) # needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 1) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = FiniteField(9) + sage: P. = ProjectiveSpace(F, 1) sage: f = DynamicalSystem([x^2 + (-2)*y^2, y^2]) - sage: m = matrix(F, 2, 2, [z, 1, 0, 1]) # needs sage.rings.finite_rings - sage: g = f.conjugate(m) # needs sage.rings.finite_rings - sage: g.postcritical_set() # needs sage.rings.finite_rings + sage: m = matrix(F, 2, 2, [z, 1, 0, 1]) + sage: g = f.conjugate(m) + sage: g.postcritical_set() [(1 : 0), (0 : 1), (a + 2 : 1)] """ if not is_ProjectiveSpace(self.domain()): @@ -6539,7 +6581,8 @@ def is_chebyshev(self): sage: L. = CyclotomicField(4) sage: M = Matrix([[0,i],[-i,0]]) sage: F.conjugate(M) - Dynamical System of Projective Space of dimension 1 over Cyclotomic Field of order 4 and degree 2 + Dynamical System of Projective Space of dimension 1 over + Cyclotomic Field of order 4 and degree 2 Defn: Defined on coordinates by sending (x : y) to ((-i)*x^2 : (-i)*x^2 + (2*i)*y^2) sage: F.is_chebyshev() @@ -6650,7 +6693,7 @@ def is_Lattes(self): r""" Check if ``self`` is a Lattes map - OUTPUT: True if ``self`` is Lattes, False otherwise + OUTPUT: ``True`` if ``self`` is Lattes, ``False`` otherwise EXAMPLES:: @@ -6699,7 +6742,8 @@ def is_Lattes(self): sage: L. = CyclotomicField(4) sage: M = Matrix([[i, 0], [0, -i]]) sage: f.conjugate(M) - Dynamical System of Projective Space of dimension 1 over Cyclotomic Field of order 4 and degree 2 + Dynamical System of Projective Space of dimension 1 over + Cyclotomic Field of order 4 and degree 2 Defn: Defined on coordinates by sending (x : y) to ((-1/4*i)*x^4 + (-4*i)*x*y^3 : (-i)*x^3*y + (2*i)*y^4) sage: f.is_Lattes() @@ -6840,9 +6884,8 @@ def lift_to_rational_periodic(self, points_modp, B=None): sage: f.lift_to_rational_periodic([[P(0,1).change_ring(GF(7)), 4]]) # needs sage.symbolic [[(0 : 1), 2]] - :: + There may be multiple points in the lift. :: - There may be multiple points in the lift. sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([-5*x^2 + 4*y^2, 4*x*y]) sage: f.lift_to_rational_periodic([[P(1,0).change_ring(GF(3)), 1]]) # long time @@ -6862,7 +6905,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): ....: + 14*x*z + 45*y*z - 90*z^2, ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, ....: -90*z^2]) - sage: f.lift_to_rational_periodic([[P(14,19,1).change_ring(GF(23)), 9]]) # long time + sage: f.lift_to_rational_periodic([[P(14,19,1).change_ring(GF(23)), 9]]) # long time [[(-9 : -4 : 1), 9]] """ if not points_modp: @@ -7101,20 +7144,22 @@ def all_periodic_points(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) # needs sage.rings.number_field - sage: sorted(f.all_periodic_points()) # needs sage.rings.function_field sage.rings.number_field + sage: K. = NumberField(x^2 - x + 1) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) + sage: sorted(f.all_periodic_points()) # needs sage.rings.function_field [(-w + 1 : 1), (w : 1), (1 : 0)] :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - x + 1) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([u^2 + v^2, u*v]) # needs sage.rings.number_field - sage: f.all_periodic_points() # needs sage.rings.function_field sage.rings.number_field + sage: K. = NumberField(x^2 - x + 1) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([u^2 + v^2, u*v]) + sage: f.all_periodic_points() # needs sage.rings.function_field Traceback (most recent call last): ... NotImplementedError: rational periodic points for number fields @@ -7122,11 +7167,12 @@ def all_periodic_points(self, **kwds): :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) - sage: K. = QuadraticField(5) # needs sage.rings.number_field - sage: phi = QQ.embeddings(K)[0] # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: phi = QQ.embeddings(K)[0] sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) - sage: sorted(f.all_periodic_points(R=phi)) # needs sage.rings.number_field + sage: sorted(f.all_periodic_points(R=phi)) [(-1 : 1), (-1/2*v + 1/2 : 1), (0 : 1), (1 : 0), (1/2*v + 1/2 : 1)] :: @@ -7332,11 +7378,12 @@ def all_rational_preimages(self, points): A number field example:: + sage: # needs sage.rings.number_field sage: z = QQ['z'].0 - sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field + sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64) + sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) - sage: sorted(f.all_rational_preimages([P(16*w^2 - 29, 16)]), key=str) # needs sage.rings.number_field + sage: sorted(f.all_rational_preimages([P(16*w^2 - 29, 16)]), key=str) [(-w - 1/2 : 1), (-w : 1), (-w^2 + 21/16 : 1), @@ -7651,12 +7698,13 @@ def connected_rational_component(self, P, n=0): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 + 1/4*x^2 - 41/16*x + 23/64) # needs sage.rings.number_field - sage: PS. = ProjectiveSpace(1,K) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) # needs sage.rings.number_field - sage: P = PS([w,1]) # needs sage.rings.number_field - sage: sorted(f.connected_rational_component(P), key=str) # needs sage.rings.number_field + sage: K. = NumberField(x^3 + 1/4*x^2 - 41/16*x + 23/64) + sage: PS. = ProjectiveSpace(1,K) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) + sage: P = PS([w,1]) + sage: sorted(f.connected_rational_component(P), key=str) [(-w - 1/2 : 1), (-w : 1), (-w^2 + 21/16 : 1), @@ -7781,11 +7829,12 @@ def conjugating_set(self, other, R=None, num_cpus=2): EXAMPLES:: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) - sage: m = matrix(QQbar, 2, 2, [-1, 3, 2, 1]) # needs sage.rings.number_field - sage: g = f.conjugate(m) # needs sage.rings.number_field - sage: f.conjugating_set(g) # needs sage.rings.number_field + sage: m = matrix(QQbar, 2, 2, [-1, 3, 2, 1]) + sage: g = f.conjugate(m) + sage: f.conjugating_set(g) [ [-1 3] [ 2 1] @@ -7867,11 +7916,12 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) sage: f = DynamicalSystem_projective([7*x + 12*y, 8*x]) sage: g = DynamicalSystem_projective([1645*x - 318*y, 8473*x - 1638*y]) - sage: m = f.conjugating_set(g)[0] # needs sage.rings.number_field - sage: f.conjugate(m) == g # needs sage.rings.number_field + sage: m = f.conjugating_set(g)[0] + sage: f.conjugate(m) == g True note that only one possible conjugation is returned:: @@ -7889,32 +7939,34 @@ def conjugating_set(self, other, R=None, num_cpus=2): :: - sage: L. = CyclotomicField(8) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(L, 2) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = CyclotomicField(8) + sage: P. = ProjectiveSpace(L, 2) sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) - sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) # needs sage.rings.number_field + sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) sage: g = f.conjugate(m1) - sage: m = f.conjugating_set(g)[0] # long time # needs sage.rings.number_field - sage: f.conjugate(m) == g # long time # needs sage.rings.number_field + sage: m = f.conjugating_set(g)[0] # long time + sage: f.conjugate(m) == g # long time True TESTS: Make sure the caching problem is fixed, see #28070 :: - sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: m = matrix(QQ, 2, 2, [-1, 3, 2, 1]) sage: g = f.conjugate(m) - sage: f.conjugating_set(g) # needs sage.rings.function_field sage.rings.number_field + sage: f.conjugating_set(g) # needs sage.rings.function_field [ [-1 3] [ 2 1] ] - sage: f = f.change_ring(K) # needs sage.rings.number_field - sage: g = g.change_ring(K) # needs sage.rings.number_field - sage: f.conjugating_set(g) # needs sage.rings.function_field sage.rings.number_field + sage: f = f.change_ring(K) + sage: g = g.change_ring(K) + sage: f.conjugating_set(g) # needs sage.rings.function_field [ [-1 3] [ 2 1] @@ -8046,12 +8098,13 @@ def is_conjugate(self, other, R=None, num_cpus=2): :: + sage: # needs sage.rings.number_field sage: set_verbose(None) - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) # needs sage.rings.number_field - sage: m = matrix(QQbar, 2, 2, [1, 1, 2, 1]) # needs sage.rings.number_field - sage: g = f.conjugate(m) # needs sage.rings.number_field - sage: f.is_conjugate(g) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) + sage: m = matrix(QQbar, 2, 2, [1, 1, 2, 1]) + sage: g = f.conjugate(m) + sage: f.is_conjugate(g) True :: @@ -8081,10 +8134,11 @@ def is_conjugate(self, other, R=None, num_cpus=2): :: - sage: P. = ProjectiveSpace(QQbar, 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) sage: f = DynamicalSystem_projective([7*x + 12*y, 8*x]) sage: g = DynamicalSystem_projective([1645*x - 318*y, 8473*x - 1638*y]) - sage: f.is_conjugate(g) # needs sage.rings.number_field + sage: f.is_conjugate(g) True Conjugation is only checked over the base field by default:: @@ -8126,16 +8180,17 @@ def is_conjugate(self, other, R=None, num_cpus=2): Make sure the caching problem is fixed, see #28070 :: - sage: K. = QuadraticField(5) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: m = matrix(QQ, 2, 2, [-1, 3, 2, 1]) sage: g = f.conjugate(m) - sage: f.is_conjugate(g) # needs sage.rings.number_field + sage: f.is_conjugate(g) True - sage: f = f.change_ring(K) # needs sage.rings.number_field - sage: g = g.change_ring(K) # needs sage.rings.number_field - sage: f.is_conjugate(g) # needs sage.rings.number_field + sage: f = f.change_ring(K) + sage: g = g.change_ring(K) + sage: f.is_conjugate(g) True """ f = copy(self) @@ -8196,22 +8251,24 @@ def is_polynomial(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QuadraticField(7) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x**2 + 2*x*y - 5*y**2, 2*x*y]) # needs sage.rings.number_field - sage: f.is_polynomial() # needs sage.rings.number_field + sage: K. = QuadraticField(7) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x**2 + 2*x*y - 5*y**2, 2*x*y]) + sage: f.is_polynomial() False :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QuadraticField(7) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x**2 - 7*x*y, 2*y**2]) # needs sage.rings.number_field - sage: m = matrix(K, 2, 2, [w, 1, 0, 1]) # needs sage.rings.number_field - sage: f = f.conjugate(m) # needs sage.rings.number_field - sage: f.is_polynomial() # needs sage.rings.number_field + sage: K. = QuadraticField(7) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x**2 - 7*x*y, 2*y**2]) + sage: m = matrix(K, 2, 2, [w, 1, 0, 1]) + sage: f = f.conjugate(m) + sage: f.is_polynomial() True :: @@ -8347,14 +8404,15 @@ def normal_form(self, return_conjugation=False): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - 5) # needs sage.rings.number_field - sage: P. = ProjectiveSpace(K,1) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + w*x*y, y^2]) # needs sage.rings.number_field - sage: g,m,psi = f.normal_form(return_conjugation=True); m # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 5) + sage: P. = ProjectiveSpace(K,1) + sage: f = DynamicalSystem_projective([x^2 + w*x*y, y^2]) + sage: g,m,psi = f.normal_form(return_conjugation=True); m [ 1 -1/2*w] [ 0 1] - sage: f.change_ring(psi).conjugate(m) == g # needs sage.rings.number_field + sage: f.change_ring(psi).conjugate(m) == g True :: @@ -8552,11 +8610,12 @@ def potential_good_reduction(self, prime, return_conjugation=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) - sage: prime = system.field_of_definition_periodic(1).prime_above(2) # needs sage.rings.number_field - sage: new_system = system.potential_good_reduction(prime)[1] # needs sage.rings.number_field - sage: new_system # needs sage.rings.number_field + sage: prime = system.field_of_definition_periodic(1).prime_above(2) + sage: new_system = system.potential_good_reduction(prime)[1] + sage: new_system Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -8596,12 +8655,13 @@ def potential_good_reduction(self, prime, return_conjugation=False): TESTS:: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field - sage: prime = A.prime_above(2) # needs sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: prime = A.prime_above(2) sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) - sage: system.potential_good_reduction(prime) # needs sage.rings.number_field + sage: system.potential_good_reduction(prime) (True, Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial x^2 + 1 @@ -8618,12 +8678,13 @@ def potential_good_reduction(self, prime, return_conjugation=False): :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: system = DynamicalSystem_projective([x**5 - 11*y**5, x**4*y]) - sage: B, new_sys, conj = system.potential_good_reduction(11, True) # needs sage.rings.number_field - sage: system.conjugate(conj).resultant() == 1 # needs sage.rings.number_field + sage: B, new_sys, conj = system.potential_good_reduction(11, True) + sage: system.conjugate(conj).resultant() == 1 True - sage: system.conjugate(conj) == new_sys # needs sage.rings.number_field + sage: system.conjugate(conj) == new_sys True :: @@ -8736,10 +8797,11 @@ def reduce_base_field(self): :: - sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, # needs sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, ....: y^2, QQbar(sqrt(2))*z^2]) - sage: f.reduce_base_field() # needs sage.rings.number_field sage.symbolic + 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 = -0.5176380902050415? Defn: Defined on coordinates by sending (x : y : z) to @@ -8747,15 +8809,16 @@ def reduce_base_field(self): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2, embedding=(x^3 - 2).roots(ring=CC)[0][0]) # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2, embedding=(x^3 - 2).roots(ring=CC)[0][0]) sage: R. = QQ[] - sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, # needs sage.rings.number_field + sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, ....: embedding=(x^6 + 9*x^4 - 4*x^3 ....: + 27*x^2 + 36*x + 31).roots(ring=CC)[0][0]) - sage: P. = ProjectiveSpace(L,1) # needs sage.rings.number_field - sage: f = DynamicalSystem([L(v)*x^2 + y^2, x*y]) # needs sage.rings.number_field - sage: f.reduce_base_field().base_ring().is_isomorphic(K) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(L,1) + sage: f = DynamicalSystem([L(v)*x^2 + y^2, x*y]) + sage: f.reduce_base_field().base_ring().is_isomorphic(K) True :: @@ -8825,11 +8888,12 @@ def is_newton(self, return_conjugation=False): :: - sage: K. = CyclotomicField(2*4) # needs sage.rings.number_field - sage: A. = AffineSpace(K, 1) # needs sage.rings.number_field - sage: f = DynamicalSystem_affine(z-(z^3+zeta*z)/(3*z^2+zeta)) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(2*4) + sage: A. = AffineSpace(K, 1) + sage: f = DynamicalSystem_affine(z-(z^3+zeta*z)/(3*z^2+zeta)) sage: F = f.homogenize(1) - sage: F.is_newton() # needs sage.rings.number_field + sage: F.is_newton() True """ if self.degree() == 1: @@ -8978,10 +9042,11 @@ def orbit_structure(self, P): :: - sage: R. = GF(13^3) # needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(R,1) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(13^3) + sage: P. = ProjectiveSpace(R,1) sage: f = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) - sage: f.orbit_structure(P(t, 4)) # needs sage.rings.finite_rings + sage: f.orbit_structure(P(t, 4)) (11, 6) """ orbit = [] @@ -9016,6 +9081,7 @@ def cyclegraph(self): :: + sage: needs sage.rings.finite_rings sage: P. = ProjectiveSpace(GF(3^2,'t'),2) # needs sage.rings.finite_rings sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) # needs sage.rings.finite_rings sage: f.cyclegraph() # needs sage.graphs sage.rings.finite_rings @@ -9165,9 +9231,10 @@ def automorphism_group(self, **kwds): EXAMPLES:: - sage: R. = ProjectiveSpace(GF(7^3,'t'),1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) # needs sage.rings.finite_rings - sage: f.automorphism_group() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = ProjectiveSpace(GF(7^3,'t'),1) + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) + sage: f.automorphism_group() [ [1 0] [6 0] [0 1], [0 1] @@ -9180,7 +9247,7 @@ def automorphism_group(self, **kwds): sage: f = DynamicalSystem_projective([x^3, y^3]) sage: lst, label = f.automorphism_group(return_functions=True, # long time ....: iso_type=True) - sage: sorted(lst, key=str), label # long time + sage: sorted(lst, key=str), label # long time ([(2*x + 1)/(x + 1), (2*x + 1)/x, (2*x + 2)/(x + 2), @@ -9209,16 +9276,18 @@ def automorphism_group(self, **kwds): :: - sage: R. = ProjectiveSpace(GF(2^5,'t'),1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^5, y^5]) # needs sage.rings.finite_rings - sage: f.automorphism_group(return_functions=True, iso_type=True) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = ProjectiveSpace(GF(2^5,'t'),1) + sage: f = DynamicalSystem_projective([x^5, y^5]) + sage: f.automorphism_group(return_functions=True, iso_type=True) ([x, 1/x], 'Cyclic of order 2') :: - sage: R. = ProjectiveSpace(GF(3^4,'t'),1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^2 + 25*x*y + y^2, x*y + 3*y^2]) # needs sage.rings.finite_rings - sage: f.automorphism_group(absolute=True) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = ProjectiveSpace(GF(3^4,'t'),1) + sage: f = DynamicalSystem_projective([x^2 + 25*x*y + y^2, x*y + 3*y^2]) + sage: f.automorphism_group(absolute=True) [Univariate Polynomial Ring in w over Finite Field in b of size 3^4, [ [1 0] @@ -9265,9 +9334,10 @@ def all_periodic_points(self, **kwds): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5^2),1) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) # needs sage.rings.finite_rings - sage: f.all_periodic_points() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5^2),1) + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) + sage: f.all_periodic_points() [(1 : 0), (z2 + 2 : 1), (4*z2 + 3 : 1)] :: @@ -9276,12 +9346,12 @@ def all_periodic_points(self, **kwds): sage: f = DynamicalSystem_projective([x^2 + y^2 + z^2, x*y + x*z, z^2]) sage: f.all_periodic_points() [(1 : 0 : 0), - (0 : 0 : 1), - (1 : 0 : 1), - (2 : 1 : 1), - (1 : 4 : 1), - (3 : 0 : 1), - (0 : 3 : 1)] + (0 : 0 : 1), + (1 : 0 : 1), + (2 : 1 : 1), + (1 : 4 : 1), + (3 : 0 : 1), + (0 : 3 : 1)] :: From 869d776fa9bf616f319e987a86be87083eed1303 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 1 Oct 2023 10:32:46 -0700 Subject: [PATCH 103/494] src/sage/dynamics/arithmetic_dynamics/wehlerK3.py: update error messages, docstring cosmetics --- .../dynamics/arithmetic_dynamics/wehlerK3.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py index 72676c1ad2a..97d77991e34 100644 --- a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py +++ b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py @@ -336,8 +336,8 @@ def Gpoly(self, component, k): They are defined as: `G^*_k = \left(L^*_j\right)^2Q^*_{ii}-L^*_iL^*_jQ^*_{ij}+\left(L^*_i\right)^2Q^*_{jj}` - where {i, j, k} is some permutation of (0, 1, 2) and * is either - x (``component=1``) or y (``component=0``). + where `(i, j, k)` is some permutation of `(0, 1, 2)` and `*` is either + `x` (``component=1``) or `y` (``component=0``). INPUT: @@ -345,7 +345,7 @@ def Gpoly(self, component, k): - ``k`` -- Integer: 0, 1 or 2 - OUTPUT: polynomial in terms of either y (``component=0``) or x (``component=1``) + OUTPUT: polynomial in terms of either `y` (``component=0``) or `x` (``component=1``) EXAMPLES:: @@ -875,11 +875,11 @@ def degenerate_fibers(self): return [xFibers,yFibers] @cached_method - def degenerate_primes(self,check=True): + def degenerate_primes(self, check=True): r""" - Determine which primes `p` self has degenerate fibers over `GF(p)`. + Determine which primes `p` self has degenerate fibers over `\GF{p}`. - If check is False, then may return primes that do not have degenerate fibers. + If ``check`` is ``False``, then may return primes that do not have degenerate fibers. Raises an error if the surface is degenerate. Works only for ``ZZ`` or ``QQ``. @@ -888,15 +888,15 @@ def degenerate_primes(self,check=True): ALGORITHM: `p` is a prime of bad reduction if and only if the defining - polynomials of self plus the G and H polynomials have a common + polynomials of ``self`` plus the G and H polynomials have a common zero. Or stated another way, `p` is a prime of bad reduction if and only if the radical of the ideal defined by the defining - polynomials of self plus the G and H polynomials is not + polynomials of ``self`` plus the G and H polynomials is not `(x_0,x_1,\ldots,x_N)`. This happens if and only if some power of each `x_i` is not in the ideal defined by the - defining polynomials of self (with G and H). This last condition + defining polynomials of ``self`` (with G and H). This last condition is what is checked. The lcm of the coefficients of the monomials `x_i` in - a groebner basis is computed. This may return extra primes. + a Groebner basis is computed. This may return extra primes. OUTPUT: List of primes. @@ -915,9 +915,9 @@ def degenerate_primes(self,check=True): PP = self.ambient_space() if PP.base_ring() != ZZ and PP.base_ring() != QQ: if PP.base_ring() in _NumberFields or isinstance(PP.base_ring(), sage.rings.abc.Order): - raise NotImplementedError("must be ZZ or QQ") + raise NotImplementedError("only implemented for ZZ and QQ") else: - raise TypeError("must be over a number field") + raise TypeError("must be over a number field or number field order") if self.is_degenerate(): raise TypeError("surface is degenerate at all primes") RR = PP.coordinate_ring() From 1b873b9ec91c4f6422cd8173f0222be4163b5e24 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 1 Oct 2023 10:38:39 -0700 Subject: [PATCH 104/494] src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py: Docstring cosmetics --- .../hyperelliptic_curves/monsky_washnitzer.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py index c8683230212..f8c8f847350 100644 --- a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py +++ b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py @@ -684,11 +684,11 @@ def transpose_list(input): def helper_matrix(Q): - """ + r""" Compute the (constant) matrix used to calculate the linear combinations of the `d(x^i y^j)` needed to eliminate the - negative powers of `y` in the cohomology (i.e. in - reduce_negative()). + negative powers of `y` in the cohomology (i.e., in + :func:`reduce_negative`). INPUT: @@ -722,14 +722,14 @@ def helper_matrix(Q): def lift(x): r""" - Try to call ``x.lift()``, presumably from the `p`-adics to ``ZZ``. + Try to call ``x.lift()``, presumably from the `p`-adics to `\ZZ`. If this fails, it assumes the input is a power series, and tries to - lift it to a power series over ``QQ``. + lift it to a power series over `\QQ`. This function is just a very kludgy solution to the problem of - trying to make the reduction code (below) work over both Zp and - Zp[[t]]. + trying to make the reduction code (below) work over both `\ZZ_p` and + `\ZZ_p[[t]]`. EXAMPLES:: @@ -763,7 +763,7 @@ def reduce_negative(Q, p, coeffs, offset, exact_form=None): - ``Q`` -- cubic polynomial - ``coeffs`` -- list of length 3 lists. The - `i^{th}` list [a, b, c] represents + `i`-th list ``[a, b, c]`` represents `y^{2(i - offset)} (a + bx + cx^2) dx/y`. - ``offset`` -- nonnegative integer @@ -866,7 +866,7 @@ def reduce_positive(Q, p, coeffs, offset, exact_form=None): - ``Q`` -- cubic polynomial - ``coeffs`` -- list of length 3 lists. The - `i^{th}` list [a, b, c] represents + `i`-th list [a, b, c] represents `y^{2(i - offset)} (a + bx + cx^2) dx/y`. - ``offset`` -- nonnegative integer @@ -960,7 +960,7 @@ def reduce_zero(Q, coeffs, offset, exact_form=None): - ``Q`` -- cubic polynomial - ``coeffs`` -- list of length 3 lists. The - `i^{th}` list [a, b, c] represents + `i`-th list [a, b, c] represents `y^{2(i - offset)} (a + bx + cx^2) dx/y`. - ``offset`` -- nonnegative integer @@ -1012,7 +1012,7 @@ def reduce_all(Q, p, coeffs, offset, compute_exact_form=False): - ``Q`` -- cubic polynomial - ``coeffs`` -- list of length 3 lists. The - `i^{th}` list [a, b, c] represents + `i`-th list [a, b, c] represents `y^{2(i - offset)} (a + bx + cx^2) dx/y`. - ``offset`` -- nonnegative integer @@ -1088,7 +1088,7 @@ def frobenius_expansion_by_newton(Q, p, M): coefficient ring of `Q`.) `F_0` and `F_1` are computed in the - SpecialCubicQuotientRing associated to `Q`, so all powers + :class:`SpecialCubicQuotientRing` associated to `Q`, so all powers of `x^j` for `j \geq 3` are reduced to powers of `T`. @@ -1106,7 +1106,7 @@ def frobenius_expansion_by_newton(Q, p, M): OUTPUT: - ``F0, F1`` -- elements of - SpecialCubicQuotientRing(Q), as described above + ``SpecialCubicQuotientRing(Q)``, as described above - ``r`` -- non-negative integer, as described above @@ -1261,7 +1261,7 @@ def frobenius_expansion_by_series(Q, p, M): and `R` is the coefficient ring of `Q`.) `F_0` and `F_1` are computed in the - SpecialCubicQuotientRing associated to `Q`, so all powers + :class:`SpecialCubicQuotientRing` associated to `Q`, so all powers of `x^j` for `j \geq 3` are reduced to powers of `T`. @@ -1294,7 +1294,7 @@ def frobenius_expansion_by_series(Q, p, M): OUTPUT: - ``F0, F1`` -- elements of - SpecialCubicQuotientRing(Q), as described above + ``SpecialCubicQuotientRing(Q)``, as described above - ``r`` -- non-negative integer, as described above From ba0a3d7d2b6c0b22359748ed844ea9a9aee3fd07 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 1 Oct 2023 15:29:30 -0700 Subject: [PATCH 105/494] src/sage/dynamics/arithmetic_dynamics/projective_ds.py: Fixup --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 6625f1bd92b..f087ce16649 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -9081,10 +9081,10 @@ def cyclegraph(self): :: - sage: needs sage.rings.finite_rings - sage: P. = ProjectiveSpace(GF(3^2,'t'),2) # needs sage.rings.finite_rings - sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) # needs sage.rings.finite_rings - sage: f.cyclegraph() # needs sage.graphs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(3^2,'t'),2) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) + sage: f.cyclegraph() # needs sage.graphs Looped digraph on 91 vertices :: From 478c8f8772d97b75be472c78d82899a70e6990d4 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 4 Oct 2023 19:42:14 +0200 Subject: [PATCH 106/494] prepare for a specific bot account (secrets.SYNC_LABELS_BOT_TOKEN) --- .github/workflows/sync_labels.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync_labels.yml b/.github/workflows/sync_labels.yml index f9378d1fe9d..56fe526eb8e 100644 --- a/.github/workflows/sync_labels.yml +++ b/.github/workflows/sync_labels.yml @@ -29,6 +29,15 @@ jobs: with: files: .github/sync_labels.py + # Set special sync_labels bot token + - name: Get Tocken + run: | + TOKEN="${{ secrets.SYNC_LABELS_BOT_TOKEN }}" + if [ -z "$TOKEN" ]; then + TOKEN="${{ secrets.GITHUB_TOKEN }}" + fi + echo "TOKEN=$TOKEN" >> $GITHUB_ENV + # Perform synchronization - name: Call script for synchronization if: github.event.schedule == '' @@ -36,7 +45,7 @@ jobs: chmod a+x .github/sync_labels.py .github/sync_labels.py $ACTION $ISSUE_URL $PR_URL $ACTOR "$LABEL" "$REV_STATE" $LOG_LEVEL env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ env.TOKEN }} ACTION: ${{ github.event.action }} ISSUE_URL: ${{ github.event.issue.html_url }} PR_URL: ${{ github.event.pull_request.html_url }} @@ -52,6 +61,6 @@ jobs: chmod a+x .github/sync_labels.py .github/sync_labels.py $REPO_URL $LOG_LEVEL env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ env.TOKEN }} REPO_URL: ${{ github.event.repository.html_url }} LOG_LEVEL: ${{ vars.SYNC_LABELS_LOG_LEVEL }} # variable from repository settings, values can be "--debug", "--info" or "--warning" From c21421f4fc4d50fb44210bf2fc71f80c73368155 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 4 Oct 2023 20:16:20 +0900 Subject: [PATCH 107/494] Show kernel status --- src/doc/common/static/jupyter-sphinx-furo.js | 50 +++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/doc/common/static/jupyter-sphinx-furo.js b/src/doc/common/static/jupyter-sphinx-furo.js index 842dde6052a..7175c63bed5 100644 --- a/src/doc/common/static/jupyter-sphinx-furo.js +++ b/src/doc/common/static/jupyter-sphinx-furo.js @@ -34,10 +34,56 @@ const observer2 = new MutationObserver(callback); observer2.observe(document.getElementsByClassName("content")[0], { childList: true, subtree: true }); -// Run custom code once the kernel is ready +// Listen to the kernel status changes // https://thebe.readthedocs.io/en/stable/events.html thebelab.on("status", function (evt, data) { - if (data.status === 'ready') { + if (data.status === 'building') { + const elements = document.querySelectorAll('.thebelab-cell'); + elements.forEach(element => { + element.style.filter = 'opacity(50%)'; + }); + const element = document.getElementById("thebelab-activate-button"); + element.innerHTML = "Building"; + element.style.right = '.4rem'; + } + else if (data.status === 'built') { + const elements = document.querySelectorAll('.thebelab-cell'); + elements.forEach(element => { + element.style.filter = 'opacity(60%)'; + }); + const element = document.getElementById("thebelab-activate-button"); + element.innerHTML = "Built"; + element.style.right = '.4rem'; + } + else if (data.status === 'launching') { + const elements = document.querySelectorAll('.thebelab-cell'); + elements.forEach(element => { + element.style.filter = 'opacity(70%)'; + }); + const element = document.getElementById("thebelab-activate-button"); + element.innerHTML = "Launching"; + element.style.right = '.4rem'; + } + else if (data.status === 'failed') { + const elements = document.querySelectorAll('.thebelab-cell'); + elements.forEach(element => { + element.style.filter = 'opacity(50%)'; + }); + const element = document.getElementById("thebelab-activate-button"); + element.innerHTML = 'Failed: ' + data.message; + element.style.right = '.4rem'; + element.style.width = 'auto'; + element.style.color = 'red'; + } + else if (data.status === 'ready') { + const elements = document.querySelectorAll('.thebelab-cell'); + elements.forEach(element => { + element.style.filter = 'opacity(100%)'; + }); + const element = document.getElementById("thebelab-activate-button"); + element.innerHTML = "Ready"; + element.style.right = null; + // Run custom code when the kernel is ready const kernel = data.kernel; kernel.requestExecute({code: "%display latex"}); } From 3ddaaddfd6e4946be65473dff358e3f788bfe9b6 Mon Sep 17 00:00:00 2001 From: ymusleh Date: Sat, 7 Oct 2023 11:38:49 -0400 Subject: [PATCH 108/494] Use in_base() method to project to base field --- .../drinfeld_modules/finite_drinfeld_module.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 7923a780d49..b4311196b6e 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -403,15 +403,13 @@ def _frobenius_charpoly_crystalline(self, var): """ A = self.function_ring() K = self.base_over_constants_field() - charpoly_coeffs_K = self._frobenius_crystalline_matrix() \ - .charpoly(var).coefficients(sparse=False) + charpoly_K = self._frobenius_crystalline_matrix() \ + .charpoly(var).coefficients(sparse=False) # The above line obtains the char poly with coefficients in K[T] # This maps them into A = Fq[T] - def coeff_A(coeff): - return A([K(x).vector()[0] for x in coeff]) - coeffs_A = [coeff_A(c) for c in charpoly_coeffs_K] + coeffs_A = [A([x.in_base() for x in coeff]) for coeff in charpoly_K] return PolynomialRing(A, name=var)(coeffs_A) def _frobenius_charpoly_gekeler(self, var): @@ -495,7 +493,7 @@ def _frobenius_charpoly_gekeler(self, var): sol = list(sys.solve_right(vec)) # The system is solved over L, but the coefficients should all be in Fq # We project back into Fq here. - sol_Fq = [K(x).vector()[0] for x in sol] + sol_Fq = [x.in_base() for x in sol] char_poly = [] for i in range(r): char_poly.append([sol_Fq[block_shifts[i] + j] @@ -593,7 +591,7 @@ def frobenius_trace(self): self._frobenius_trace = -self._frobenius_charpoly \ .coefficients(sparse=False)[-2] self._frobenius_trace = self._frobenius_crystalline_matrix().trace() - self._frobenius_trace = A([K(x).vector()[0] for x in self._frobenius_trace]) + self._frobenius_trace = A([x.in_base() for x in self._frobenius_trace]) return self._frobenius_trace def invert(self, ore_pol): From 517657d5996254afa3f844077cc054e5a2d3e3d9 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Fri, 17 Mar 2023 11:20:43 +0000 Subject: [PATCH 109/494] update pari to 2.15.3, drop patch --- build/pkgs/pari/checksums.ini | 6 +++--- build/pkgs/pari/package-version.txt | 2 +- build/pkgs/pari/patches/bug2441.patch | 14 -------------- 3 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 build/pkgs/pari/patches/bug2441.patch diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini index d72e5246cf7..fdd2b48bdea 100644 --- a/build/pkgs/pari/checksums.ini +++ b/build/pkgs/pari/checksums.ini @@ -1,5 +1,5 @@ tarball=pari-VERSION.tar.gz -sha1=498e3cd0b7ded8be3fa1cba1125ca5213ed39453 -md5=562a6e973ca3980dc6c1eb2c4f252e92 -cksum=4081416981 +sha1=8a98276cb785c4d07b3f2481b82dd0895f5f6b9b +md5=23ff1ac381bc633cbd138d57a9929595 +cksum=1624634749 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 c06afc0ba5f..6480dd5ed87 100644 --- a/build/pkgs/pari/package-version.txt +++ b/build/pkgs/pari/package-version.txt @@ -1 +1 @@ -2.15.2.p1 +2.15.3 diff --git a/build/pkgs/pari/patches/bug2441.patch b/build/pkgs/pari/patches/bug2441.patch deleted file mode 100644 index 01047180d19..00000000000 --- a/build/pkgs/pari/patches/bug2441.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/src/basemath/ellsea.c b/src/basemath/ellsea.c -index a6871fa6a7..05f148eadd 100644 ---- a/src/basemath/ellsea.c -+++ b/src/basemath/ellsea.c -@@ -852,7 +852,8 @@ find_isogenous_from_Atkin(GEN a4, GEN a6, ulong ell, struct meqn *MEQN, GEN g, G - GEN a4t, a6t, h; - a4a6t(&a4t, &a6t, ell, E4t, E6t, T, p); - h = find_kernel(a4, a6, ell, a4t, a6t, pp1, T, p, pp, e); -- if (h) return gerepilecopy(ltop, mkvec3(a4t, a6t, h)); -+ if (h && signe(Fq_elldivpolmod(a4, a6, ell, h, T, pp))==0) -+ return gerepilecopy(ltop, mkvec3(a4t, a6t, h)); - } - } - pari_err_BUG("find_isogenous_from_Atkin, kernel not found"); From 374e7e92bea2ac7fb65835869734281d8249713e Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Mon, 20 Mar 2023 16:30:51 +0000 Subject: [PATCH 110/494] fix integer factoring regression from #35219 --- ...ime-numbers-to-use-in-Z_factor_limit.patch | 189 ++++++++++++++++++ src/sage/arith/misc.py | 5 + 2 files changed, 194 insertions(+) create mode 100644 build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch diff --git a/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch b/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch new file mode 100644 index 00000000000..873140b9ecd --- /dev/null +++ b/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch @@ -0,0 +1,189 @@ +From ea6992e38d651643982fd88777d5d5a186b0f54e Mon Sep 17 00:00:00 2001 +From: Bill Allombert +Date: Wed, 16 Nov 2022 13:33:21 +0100 +Subject: [PATCH] Keep product of prime numbers to use in Z_factor_limit + +--- + src/basemath/ifactor1.c | 67 ++++++++++++++++++++++++++++++++--------- + src/headers/paridecl.h | 2 ++ + src/language/forprime.c | 26 +++++++++++++++- + 3 files changed, 80 insertions(+), 15 deletions(-) + +diff --git a/src/basemath/ifactor1.c b/src/basemath/ifactor1.c +index 4478fc416..5dd04c966 100644 +--- a/src/basemath/ifactor1.c ++++ b/src/basemath/ifactor1.c +@@ -3652,29 +3652,68 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) + av = avma; affii(shifti(n,-i), n); set_avma(av); + } + if (is_pm1(n)) return aux_end(M,n,nb); +- /* trial division */ + maxp = maxprime(); +- av = avma; u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; +- /* first pass: known to fit in private prime table */ +- while ((p = u_forprime_next_fast(&T))) ++ if (lim >= maxprimelim()>>2) + { +- pari_sp av3 = avma; +- int stop; +- long k = Z_lvalrem_stop(&n, p, &stop); +- if (k) ++ GEN nr, NR; ++ /* fast trial division */ ++ av = avma; ++ NR = nr = gcdii(prodprimes(),n); ++ u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; ++ /* first pass: known to fit in private prime table */ ++ while ((p = u_forprime_next_fast(&T))) + { +- affii(n, N); n = N; set_avma(av3); +- STOREu(&nb, p, k); ++ pari_sp av3 = avma; ++ int stop; ++ long k; ++ if (!dvdiu(nr, p)) continue; ++ nr = diviuexact(nr, p); ++ affii(nr, NR); nr = NR; set_avma(av3); ++ k = Z_lvalrem_stop(&n, p, &stop); ++ if (k) ++ { ++ affii(n, N); n = N; set_avma(av3); ++ STOREu(&nb, p, k); ++ } ++ if (is_pm1(n)) ++ { ++ stackdummy(av, av2); ++ return aux_end(M,n,nb); ++ } ++ if (is_pm1(nr)) break; + } +- if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) +- { stop = ifac_isprime(n); nb0 = nb; } +- if (stop) ++ if (ifac_isprime(n)) + { +- if (!is_pm1(n)) STOREi(&nb, n, 1); ++ STOREi(&nb, n, 1); + stackdummy(av, av2); + return aux_end(M,n,nb); + } + } ++ else ++ { ++ /* trial division */ ++ av = avma; u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; ++ /* first pass: known to fit in private prime table */ ++ while ((p = u_forprime_next_fast(&T))) ++ { ++ pari_sp av3 = avma; ++ int stop; ++ long k = Z_lvalrem_stop(&n, p, &stop); ++ if (k) ++ { ++ affii(n, N); n = N; set_avma(av3); ++ STOREu(&nb, p, k); ++ } ++ if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) ++ { stop = ifac_isprime(n); nb0 = nb; } ++ if (stop) ++ { ++ if (!is_pm1(n)) STOREi(&nb, n, 1); ++ stackdummy(av, av2); ++ return aux_end(M,n,nb); ++ } ++ } ++ } + stackdummy(av, av2); + if (lim > maxp) + { /* second pass, usually empty: outside private prime table */ +diff --git a/src/headers/paridecl.h b/src/headers/paridecl.h +index be375c67d..1d5041e7f 100644 +--- a/src/headers/paridecl.h ++++ b/src/headers/paridecl.h +@@ -3565,7 +3565,9 @@ ulong init_primepointer_lt(ulong a, byteptr *pd); + ulong maxprime(void); + ulong maxprimeN(void); + void maxprime_check(ulong c); ++ulong maxprimelim(void); + void pari_init_primes(ulong maxprime); ++GEN prodprimes(void); + ulong u_forprime_next(forprime_t *T); + int u_forprime_init(forprime_t *T, ulong a, ulong b); + void u_forprime_restrict(forprime_t *T, ulong c); +diff --git a/src/language/forprime.c b/src/language/forprime.c +index 22be44726..1059900df 100644 +--- a/src/language/forprime.c ++++ b/src/language/forprime.c +@@ -22,7 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + /**********************************************************************/ + + static ulong _maxprime = 0; ++static ulong _maxprimelim = 0; + static ulong diffptrlen; ++static GEN _prodprimes; + + /* Building/Rebuilding the diffptr table. The actual work is done by the + * following two subroutines; the user entry point is the function +@@ -352,6 +354,18 @@ sieve_chunk(byteptr known_primes, ulong s, byteptr data, ulong n) + } + } + ++static void ++set_prodprimes(void) ++{ ++ pari_sp av = avma; ++ GEN p = zv_prod_Z(primes_zv(diffptrlen-1)); ++ long i, l = lgefint(p); ++ _prodprimes = (GEN) pari_malloc(l*sizeof(long)); ++ for (i = 0; i < l; i++) ++ _prodprimes[i] = p[i]; ++ set_avma(av); ++} ++ + /* assume maxnum <= 436273289 < 2^29 */ + static void + initprimes0(ulong maxnum, long *lenp, ulong *lastp, byteptr p1) +@@ -426,7 +440,11 @@ initprimes0(ulong maxnum, long *lenp, ulong *lastp, byteptr p1) + ulong + maxprime(void) { return diffptr ? _maxprime : 0; } + ulong ++maxprimelim(void) { return diffptr ? _maxprimelim : 0; } ++ulong + maxprimeN(void) { return diffptr ? diffptrlen-1: 0; } ++GEN ++prodprimes(void) { return diffptr ? _prodprimes: NULL; } + + void + maxprime_check(ulong c) { if (_maxprime < c) pari_err_MAXPRIME(c); } +@@ -445,6 +463,7 @@ initprimes(ulong maxnum, long *lenp, ulong *lastp) + maxnum = 436273289; + t = (byteptr)pari_malloc((size_t) (1.09 * maxnum/log((double)maxnum)) + 146); + initprimes0(maxnum, lenp, lastp, t); ++ _maxprimelim = maxnum; + return (byteptr)pari_realloc(t, *lenp); + } + +@@ -457,6 +476,7 @@ initprimetable(ulong maxnum) + diffptrlen = minss(diffptrlen, len); + _maxprime = minss(_maxprime,last); /*Protect against ^C*/ + diffptr = p; diffptrlen = len; _maxprime = last; ++ set_prodprimes(); + if (old) free(old); + } + +@@ -770,7 +790,11 @@ pari_init_primes(ulong maxprime) + void + pari_close_primes(void) + { +- pari_free(diffptr); ++ if (diffptr) ++ { ++ pari_free(diffptr); ++ pari_free(_prodprimes); ++ } + pari_free(pari_sieve_modular.sieve); + } + +-- +2.30.2 + diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index d18e83309e5..264f2c4e031 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2688,6 +2688,11 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): Traceback (most recent call last): ... TypeError: unable to factor 'xyz' + + test that :issue:`35219` is fixed:: + + sage: len(factor(2^2203-1,proof=false)) + 1 """ try: m = n.factor From 2400ee1a85d0490dbd14e4d31e6d8f8bb255ce84 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sun, 26 Mar 2023 17:56:34 +0100 Subject: [PATCH 111/494] capitalise "test" --- src/sage/arith/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 264f2c4e031..aa0174580a1 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2689,7 +2689,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): ... TypeError: unable to factor 'xyz' - test that :issue:`35219` is fixed:: + Test that :issue:`35219` is fixed:: sage: len(factor(2^2203-1,proof=false)) 1 From 0dde0f9239376d0365692120eb08a7bb3eca2ab0 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 28 Mar 2023 11:18:37 +0100 Subject: [PATCH 112/494] increase gp's initial stacksize to 3*10^6 in a long test --- src/sage/interfaces/gp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/interfaces/gp.py b/src/sage/interfaces/gp.py index 49b1a8a06fb..e5c77833cca 100644 --- a/src/sage/interfaces/gp.py +++ b/src/sage/interfaces/gp.py @@ -615,7 +615,7 @@ def _next_var_name(self): The vector of results is correctly resized when the stack has to be enlarged during this operation:: - sage: g = Gp(stacksize=10^4,init_list_length=12000) # long time + sage: g = Gp(stacksize=3*10^6,init_list_length=12000) # long time sage: for n in [1..13000]: # long time ....: a = g(n) sage: g('length(sage)') # long time From c1a87a280537c4ac3b9478449a0806bf49ab4628 Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Tue, 4 Apr 2023 16:12:45 +0800 Subject: [PATCH 113/494] replace patch for PARI bug #2469 --- ...ime-numbers-to-use-in-Z_factor_limit.patch | 189 ------------------ build/pkgs/pari/patches/bug2469.patch | 40 ++++ 2 files changed, 40 insertions(+), 189 deletions(-) delete mode 100644 build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch create mode 100644 build/pkgs/pari/patches/bug2469.patch diff --git a/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch b/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch deleted file mode 100644 index 873140b9ecd..00000000000 --- a/build/pkgs/pari/patches/Keep-product-of-prime-numbers-to-use-in-Z_factor_limit.patch +++ /dev/null @@ -1,189 +0,0 @@ -From ea6992e38d651643982fd88777d5d5a186b0f54e Mon Sep 17 00:00:00 2001 -From: Bill Allombert -Date: Wed, 16 Nov 2022 13:33:21 +0100 -Subject: [PATCH] Keep product of prime numbers to use in Z_factor_limit - ---- - src/basemath/ifactor1.c | 67 ++++++++++++++++++++++++++++++++--------- - src/headers/paridecl.h | 2 ++ - src/language/forprime.c | 26 +++++++++++++++- - 3 files changed, 80 insertions(+), 15 deletions(-) - -diff --git a/src/basemath/ifactor1.c b/src/basemath/ifactor1.c -index 4478fc416..5dd04c966 100644 ---- a/src/basemath/ifactor1.c -+++ b/src/basemath/ifactor1.c -@@ -3652,29 +3652,68 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) - av = avma; affii(shifti(n,-i), n); set_avma(av); - } - if (is_pm1(n)) return aux_end(M,n,nb); -- /* trial division */ - maxp = maxprime(); -- av = avma; u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; -- /* first pass: known to fit in private prime table */ -- while ((p = u_forprime_next_fast(&T))) -+ if (lim >= maxprimelim()>>2) - { -- pari_sp av3 = avma; -- int stop; -- long k = Z_lvalrem_stop(&n, p, &stop); -- if (k) -+ GEN nr, NR; -+ /* fast trial division */ -+ av = avma; -+ NR = nr = gcdii(prodprimes(),n); -+ u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; -+ /* first pass: known to fit in private prime table */ -+ while ((p = u_forprime_next_fast(&T))) - { -- affii(n, N); n = N; set_avma(av3); -- STOREu(&nb, p, k); -+ pari_sp av3 = avma; -+ int stop; -+ long k; -+ if (!dvdiu(nr, p)) continue; -+ nr = diviuexact(nr, p); -+ affii(nr, NR); nr = NR; set_avma(av3); -+ k = Z_lvalrem_stop(&n, p, &stop); -+ if (k) -+ { -+ affii(n, N); n = N; set_avma(av3); -+ STOREu(&nb, p, k); -+ } -+ if (is_pm1(n)) -+ { -+ stackdummy(av, av2); -+ return aux_end(M,n,nb); -+ } -+ if (is_pm1(nr)) break; - } -- if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) -- { stop = ifac_isprime(n); nb0 = nb; } -- if (stop) -+ if (ifac_isprime(n)) - { -- if (!is_pm1(n)) STOREi(&nb, n, 1); -+ STOREi(&nb, n, 1); - stackdummy(av, av2); - return aux_end(M,n,nb); - } - } -+ else -+ { -+ /* trial division */ -+ av = avma; u_forprime_init(&T, 3, minss(lim, maxp)); av2 = avma; -+ /* first pass: known to fit in private prime table */ -+ while ((p = u_forprime_next_fast(&T))) -+ { -+ pari_sp av3 = avma; -+ int stop; -+ long k = Z_lvalrem_stop(&n, p, &stop); -+ if (k) -+ { -+ affii(n, N); n = N; set_avma(av3); -+ STOREu(&nb, p, k); -+ } -+ if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) -+ { stop = ifac_isprime(n); nb0 = nb; } -+ if (stop) -+ { -+ if (!is_pm1(n)) STOREi(&nb, n, 1); -+ stackdummy(av, av2); -+ return aux_end(M,n,nb); -+ } -+ } -+ } - stackdummy(av, av2); - if (lim > maxp) - { /* second pass, usually empty: outside private prime table */ -diff --git a/src/headers/paridecl.h b/src/headers/paridecl.h -index be375c67d..1d5041e7f 100644 ---- a/src/headers/paridecl.h -+++ b/src/headers/paridecl.h -@@ -3565,7 +3565,9 @@ ulong init_primepointer_lt(ulong a, byteptr *pd); - ulong maxprime(void); - ulong maxprimeN(void); - void maxprime_check(ulong c); -+ulong maxprimelim(void); - void pari_init_primes(ulong maxprime); -+GEN prodprimes(void); - ulong u_forprime_next(forprime_t *T); - int u_forprime_init(forprime_t *T, ulong a, ulong b); - void u_forprime_restrict(forprime_t *T, ulong c); -diff --git a/src/language/forprime.c b/src/language/forprime.c -index 22be44726..1059900df 100644 ---- a/src/language/forprime.c -+++ b/src/language/forprime.c -@@ -22,7 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - /**********************************************************************/ - - static ulong _maxprime = 0; -+static ulong _maxprimelim = 0; - static ulong diffptrlen; -+static GEN _prodprimes; - - /* Building/Rebuilding the diffptr table. The actual work is done by the - * following two subroutines; the user entry point is the function -@@ -352,6 +354,18 @@ sieve_chunk(byteptr known_primes, ulong s, byteptr data, ulong n) - } - } - -+static void -+set_prodprimes(void) -+{ -+ pari_sp av = avma; -+ GEN p = zv_prod_Z(primes_zv(diffptrlen-1)); -+ long i, l = lgefint(p); -+ _prodprimes = (GEN) pari_malloc(l*sizeof(long)); -+ for (i = 0; i < l; i++) -+ _prodprimes[i] = p[i]; -+ set_avma(av); -+} -+ - /* assume maxnum <= 436273289 < 2^29 */ - static void - initprimes0(ulong maxnum, long *lenp, ulong *lastp, byteptr p1) -@@ -426,7 +440,11 @@ initprimes0(ulong maxnum, long *lenp, ulong *lastp, byteptr p1) - ulong - maxprime(void) { return diffptr ? _maxprime : 0; } - ulong -+maxprimelim(void) { return diffptr ? _maxprimelim : 0; } -+ulong - maxprimeN(void) { return diffptr ? diffptrlen-1: 0; } -+GEN -+prodprimes(void) { return diffptr ? _prodprimes: NULL; } - - void - maxprime_check(ulong c) { if (_maxprime < c) pari_err_MAXPRIME(c); } -@@ -445,6 +463,7 @@ initprimes(ulong maxnum, long *lenp, ulong *lastp) - maxnum = 436273289; - t = (byteptr)pari_malloc((size_t) (1.09 * maxnum/log((double)maxnum)) + 146); - initprimes0(maxnum, lenp, lastp, t); -+ _maxprimelim = maxnum; - return (byteptr)pari_realloc(t, *lenp); - } - -@@ -457,6 +476,7 @@ initprimetable(ulong maxnum) - diffptrlen = minss(diffptrlen, len); - _maxprime = minss(_maxprime,last); /*Protect against ^C*/ - diffptr = p; diffptrlen = len; _maxprime = last; -+ set_prodprimes(); - if (old) free(old); - } - -@@ -770,7 +790,11 @@ pari_init_primes(ulong maxprime) - void - pari_close_primes(void) - { -- pari_free(diffptr); -+ if (diffptr) -+ { -+ pari_free(diffptr); -+ pari_free(_prodprimes); -+ } - pari_free(pari_sieve_modular.sieve); - } - --- -2.30.2 - diff --git a/build/pkgs/pari/patches/bug2469.patch b/build/pkgs/pari/patches/bug2469.patch new file mode 100644 index 00000000000..347310e1d6b --- /dev/null +++ b/build/pkgs/pari/patches/bug2469.patch @@ -0,0 +1,40 @@ +diff --git a/src/basemath/ifactor1.c b/src/basemath/ifactor1.c +index 526ac5c1b3..5fb4454353 100644 +--- a/src/basemath/ifactor1.c ++++ b/src/basemath/ifactor1.c +@@ -3595,7 +3595,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) + { + GEN M, N; + pari_sp av; +- long nb = 0, nb0 = 0, i; ++ long nb = 0, nb0 = -1, i; + ulong lim; + forprime_t T; + +@@ -3666,7 +3666,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) + affii(n, N); n = N; set_avma(av3); + STOREu(&nb, p, k); + } +- if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) ++ if (!stop && p == 16381 && bit_accuracy(lgefint(n)) < 2048) + { stop = ifac_isprime(n); nb0 = nb; } + if (stop) + { +@@ -3706,15 +3706,14 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) + long k; + av = avma; + k = isanypower_nosmalldiv(n, &x); +- if (k > 1) affii(x, n); ++ if (k > 1) { affii(x, n); nb0 = -1; } + if (pU) + { + GEN F; + if (abscmpiu(n, lim) <= 0 + || cmpii(n, sqru(lim)) <= 0 + || (all >= (1<<14) +- && (nb > nb0 || k > 1) +- && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) ++ && nb > nb0 && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) + { set_avma(av); STOREi(&nb, n, k); return aux_end(M,n, nb); } + set_avma(av); F = aux_end(M, NULL, nb); /* don't destroy n */ + *pU = mkvec2(icopy(n), utoipos(k)); /* composite cofactor */ From d2f8fffada512916e07d5fd3caf1a2db186c5fbe Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Tue, 4 Apr 2023 16:35:01 +0800 Subject: [PATCH 114/494] adjust patch to PARI version 2.15.3 --- build/pkgs/pari/patches/bug2469.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build/pkgs/pari/patches/bug2469.patch b/build/pkgs/pari/patches/bug2469.patch index 347310e1d6b..9e7d91d9c21 100644 --- a/build/pkgs/pari/patches/bug2469.patch +++ b/build/pkgs/pari/patches/bug2469.patch @@ -31,10 +31,9 @@ index 526ac5c1b3..5fb4454353 100644 GEN F; if (abscmpiu(n, lim) <= 0 || cmpii(n, sqru(lim)) <= 0 - || (all >= (1<<14) -- && (nb > nb0 || k > 1) +- || ((nb > nb0 || k > 1) - && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) -+ && nb > nb0 && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) ++ || (nb > nb0 && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) { set_avma(av); STOREi(&nb, n, k); return aux_end(M,n, nb); } set_avma(av); F = aux_end(M, NULL, nb); /* don't destroy n */ *pU = mkvec2(icopy(n), utoipos(k)); /* composite cofactor */ From f5c12426e507aa37649a7c43f1d2469d6167a77a Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Tue, 4 Apr 2023 15:31:12 +0800 Subject: [PATCH 115/494] add patch for PARI bug #2466 --- build/pkgs/pari/patches/bug2466.patch | 25 +++++++++++++++++++++++++ src/sage/rings/number_field/order.py | 8 ++++++++ 2 files changed, 33 insertions(+) create mode 100644 build/pkgs/pari/patches/bug2466.patch diff --git a/build/pkgs/pari/patches/bug2466.patch b/build/pkgs/pari/patches/bug2466.patch new file mode 100644 index 00000000000..569baa288ff --- /dev/null +++ b/build/pkgs/pari/patches/bug2466.patch @@ -0,0 +1,25 @@ +From 7ca0c2eae87def89fa7253c60e4791a8ef26629d Mon Sep 17 00:00:00 2001 +From: Bill Allombert +Date: Mon, 3 Apr 2023 15:30:26 +0200 +Subject: [PATCH] quadunitindex(8461,2)->1 instead of 3 [#2466] + +--- + src/basemath/quad.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basemath/quad.c b/src/basemath/quad.c +index 021a404b00..7ed554c2f3 100644 +--- a/src/basemath/quad.c ++++ b/src/basemath/quad.c +@@ -359,7 +359,7 @@ quadunit_mod(GEN D, GEN N) + GEN M = shifti(mulii(q, N), 1); + quadunit_uvmod(D, d, M, &u, &v); + u = diviiexact(u, q); +- v = diviiexact(v, q); u = shifti(u,-1); ++ v = modii(diviiexact(v, q), N); u = shifti(u,-1); + } + return deg1pol_shallow(v, u, 0); + } +-- +2.40.0 + diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index e789a97bc75..f0b24b74630 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -1083,6 +1083,14 @@ def class_number(self, proof=None): NotImplementedError: computation of class numbers of non-maximal orders not in quadratic fields is not implemented + TESTS: + + Test for PARI bug #2466:: + + sage: x = polygen(ZZ) + sage: R. = EquationOrder(x^2 - 8461) + sage: R.class_number() + 3 """ if not self.is_maximal(): K = self.number_field() From 53c9bee1bf055f7e45fe4b72e0b5cfd9f423251c Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Tue, 11 Apr 2023 14:54:49 +0800 Subject: [PATCH 116/494] make sure patches are applied if needed --- build/pkgs/pari/package-version.txt | 2 +- build/pkgs/pari/spkg-configure.m4 | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt index 6480dd5ed87..3b8576204e0 100644 --- a/build/pkgs/pari/package-version.txt +++ b/build/pkgs/pari/package-version.txt @@ -1 +1 @@ -2.15.3 +2.15.3.p1 diff --git a/build/pkgs/pari/spkg-configure.m4 b/build/pkgs/pari/spkg-configure.m4 index e1a022a26ab..1404defc518 100644 --- a/build/pkgs/pari/spkg-configure.m4 +++ b/build/pkgs/pari/spkg-configure.m4 @@ -67,6 +67,25 @@ SAGE_SPKG_CONFIGURE([pari], [ AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.]) sage_spkg_install_pari=yes fi + + AC_MSG_CHECKING([whether factor() bug 2469 of pari 2.15.3 is fixed]) + result=`echo "f=factor(2^2203-1); print(\"ok\")" | timeout 1 $GP -qf` + if test x"$result" = xok; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no; cannot use system pari/GP with known bug]) + sage_spkg_install_pari=yes + fi + + AC_MSG_CHECKING([whether qfbclassno() bug 2466 of pari 2.15.3 is fixed]) + result=`echo "qfbclassno(33844)" | $GP -qf` + if test x"$result" = x3; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no; cannot use system pari/GP with known bug]) + sage_spkg_install_pari=yes + fi + fi dnl end GP test if test x$sage_spkg_install_pari = xno; then dnl main PARI test From 79667bfcb3c7d909567ce007c2a9e10c917cab7b Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 10 Oct 2023 12:54:05 +0100 Subject: [PATCH 117/494] bump to 2.15.4, patches dropped --- build/pkgs/pari/checksums.ini | 6 ++--- build/pkgs/pari/package-version.txt | 2 +- build/pkgs/pari/patches/bug2466.patch | 25 ----------------- build/pkgs/pari/patches/bug2469.patch | 39 --------------------------- 4 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 build/pkgs/pari/patches/bug2466.patch delete mode 100644 build/pkgs/pari/patches/bug2469.patch diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini index fdd2b48bdea..b6fc05baa1a 100644 --- a/build/pkgs/pari/checksums.ini +++ b/build/pkgs/pari/checksums.ini @@ -1,5 +1,5 @@ tarball=pari-VERSION.tar.gz -sha1=8a98276cb785c4d07b3f2481b82dd0895f5f6b9b -md5=23ff1ac381bc633cbd138d57a9929595 -cksum=1624634749 +sha1=ae962671b5bf86849d2021113dfb5b2f59331a10 +md5=4ab5c81d93f4bccb94e483b8b48fc336 +cksum=598072677 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 3b8576204e0..86fbeafcc20 100644 --- a/build/pkgs/pari/package-version.txt +++ b/build/pkgs/pari/package-version.txt @@ -1 +1 @@ -2.15.3.p1 +2.15.4 diff --git a/build/pkgs/pari/patches/bug2466.patch b/build/pkgs/pari/patches/bug2466.patch deleted file mode 100644 index 569baa288ff..00000000000 --- a/build/pkgs/pari/patches/bug2466.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 7ca0c2eae87def89fa7253c60e4791a8ef26629d Mon Sep 17 00:00:00 2001 -From: Bill Allombert -Date: Mon, 3 Apr 2023 15:30:26 +0200 -Subject: [PATCH] quadunitindex(8461,2)->1 instead of 3 [#2466] - ---- - src/basemath/quad.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/basemath/quad.c b/src/basemath/quad.c -index 021a404b00..7ed554c2f3 100644 ---- a/src/basemath/quad.c -+++ b/src/basemath/quad.c -@@ -359,7 +359,7 @@ quadunit_mod(GEN D, GEN N) - GEN M = shifti(mulii(q, N), 1); - quadunit_uvmod(D, d, M, &u, &v); - u = diviiexact(u, q); -- v = diviiexact(v, q); u = shifti(u,-1); -+ v = modii(diviiexact(v, q), N); u = shifti(u,-1); - } - return deg1pol_shallow(v, u, 0); - } --- -2.40.0 - diff --git a/build/pkgs/pari/patches/bug2469.patch b/build/pkgs/pari/patches/bug2469.patch deleted file mode 100644 index 9e7d91d9c21..00000000000 --- a/build/pkgs/pari/patches/bug2469.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/src/basemath/ifactor1.c b/src/basemath/ifactor1.c -index 526ac5c1b3..5fb4454353 100644 ---- a/src/basemath/ifactor1.c -+++ b/src/basemath/ifactor1.c -@@ -3595,7 +3595,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) - { - GEN M, N; - pari_sp av; -- long nb = 0, nb0 = 0, i; -+ long nb = 0, nb0 = -1, i; - ulong lim; - forprime_t T; - -@@ -3666,7 +3666,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) - affii(n, N); n = N; set_avma(av3); - STOREu(&nb, p, k); - } -- if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) -+ if (!stop && p == 16381 && bit_accuracy(lgefint(n)) < 2048) - { stop = ifac_isprime(n); nb0 = nb; } - if (stop) - { -@@ -3706,15 +3706,14 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) - long k; - av = avma; - k = isanypower_nosmalldiv(n, &x); -- if (k > 1) affii(x, n); -+ if (k > 1) { affii(x, n); nb0 = -1; } - if (pU) - { - GEN F; - if (abscmpiu(n, lim) <= 0 - || cmpii(n, sqru(lim)) <= 0 -- || ((nb > nb0 || k > 1) -- && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) -+ || (nb > nb0 && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) - { set_avma(av); STOREi(&nb, n, k); return aux_end(M,n, nb); } - set_avma(av); F = aux_end(M, NULL, nb); /* don't destroy n */ - *pU = mkvec2(icopy(n), utoipos(k)); /* composite cofactor */ From 33d50c9506c46c0b7cee6bf66ade8e9813cc768d Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 12 Oct 2023 01:08:19 +0000 Subject: [PATCH 118/494] Exclude Cython 3.0.3 --- build/pkgs/cython/distros/conda.txt | 4 +++- build/pkgs/cython/install-requires.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/pkgs/cython/distros/conda.txt b/build/pkgs/cython/distros/conda.txt index f6629e02456..19a32cd69b5 100644 --- a/build/pkgs/cython/distros/conda.txt +++ b/build/pkgs/cython/distros/conda.txt @@ -1 +1,3 @@ -cython +cython>=3.0,!=3.0.3,<4.0 + +# Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748 diff --git a/build/pkgs/cython/install-requires.txt b/build/pkgs/cython/install-requires.txt index 3693d637891..74073ecb57f 100644 --- a/build/pkgs/cython/install-requires.txt +++ b/build/pkgs/cython/install-requires.txt @@ -1 +1,3 @@ -cython >=3.0, <4.0 +cython >=3.0, != 3.0.3, <4.0 + +# Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748 From 8145739bb4efb4a04c4a070e1d782c812cfae3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 15 Oct 2023 09:37:35 +0200 Subject: [PATCH 119/494] using ruff for UP004, UP008, UP028 --- src/sage/algebras/free_algebra_quotient.py | 2 +- src/sage/categories/enumerated_sets.py | 6 ++---- src/sage/categories/finite_enumerated_sets.py | 3 +-- src/sage/categories/posets.py | 3 +-- src/sage/coding/guruswami_sudan/interpolation.py | 3 +-- src/sage/combinat/abstract_tree.py | 3 +-- src/sage/combinat/alternating_sign_matrix.py | 3 +-- .../combinat/cluster_algebra_quiver/cluster_seed.py | 3 +-- src/sage/combinat/colored_permutations.py | 4 ++-- src/sage/combinat/combinat.py | 6 ++---- src/sage/combinat/designs/design_catalog.py | 2 +- src/sage/combinat/finite_state_machine.py | 6 ++---- src/sage/combinat/free_module.py | 4 ++-- src/sage/combinat/integer_matrices.py | 2 +- src/sage/combinat/integer_vector_weighted.py | 2 +- src/sage/combinat/k_tableau.py | 6 ++---- src/sage/combinat/lr_tableau.py | 4 ++-- src/sage/combinat/plane_partition.py | 2 +- src/sage/combinat/posets/posets.py | 4 ++-- src/sage/combinat/recognizable_series.py | 6 +++--- src/sage/combinat/regular_sequence.py | 4 ++-- src/sage/combinat/ribbon_shaped_tableau.py | 4 ++-- .../combinat/rigged_configurations/kleber_tree.py | 12 +++++------- .../combinat/rigged_configurations/kr_tableaux.py | 2 +- .../combinat/rigged_configurations/rc_crystal.py | 2 +- .../combinat/rigged_configurations/rc_infinity.py | 6 +++--- .../rigged_configurations/rigged_configurations.py | 8 ++++---- .../tensor_product_kr_tableaux.py | 7 +++---- src/sage/combinat/root_system/type_relabel.py | 2 +- src/sage/combinat/species/cycle_species.py | 2 +- src/sage/combinat/species/linear_order_species.py | 2 +- src/sage/combinat/species/partition_species.py | 2 +- src/sage/combinat/species/permutation_species.py | 2 +- src/sage/combinat/species/set_species.py | 2 +- src/sage/combinat/species/subset_species.py | 2 +- src/sage/combinat/tableau.py | 3 +-- src/sage/combinat/words/abstract_word.py | 6 ++---- src/sage/combinat/words/word_generators.py | 3 +-- src/sage/combinat/words/words.py | 3 +-- src/sage/cpython/_py2_random.py | 10 +++++----- src/sage/data_structures/mutable_poset.py | 13 +++++-------- src/sage/databases/stein_watkins.py | 3 +-- src/sage/doctest/forker.py | 2 +- src/sage/features/join_feature.py | 4 ++-- src/sage/functions/orthogonal_polys.py | 6 +++--- src/sage/functions/piecewise.py | 3 +-- src/sage/geometry/polyhedral_complex.py | 6 ++---- src/sage/geometry/polyhedron/base0.py | 6 ++---- src/sage/geometry/polyhedron/generating_function.py | 4 ++-- src/sage/geometry/polyhedron/plot.py | 3 +-- src/sage/geometry/triangulation/element.py | 3 +-- .../geometry/triangulation/point_configuration.py | 9 +++------ src/sage/graphs/generic_graph.py | 3 +-- src/sage/graphs/graph.py | 3 +-- src/sage/graphs/graph_generators.py | 6 ++---- src/sage/homology/chain_complex.py | 4 ++-- src/sage/homology/koszul_complex.py | 2 +- src/sage/interfaces/polymake.py | 4 ++-- src/sage/interfaces/r.py | 2 +- src/sage/interfaces/singular.py | 2 +- src/sage/matrix/compute_J_ideal.py | 2 +- src/sage/matrix/matrix_space.py | 3 +-- src/sage/misc/bindable_class.py | 2 +- src/sage/modules/free_module.py | 2 +- src/sage/rings/number_field/class_group.py | 3 +-- src/sage/rings/padics/padic_extension_generic.py | 2 +- src/sage/rings/padics/padic_extension_leaves.py | 2 +- src/sage/rings/padics/padic_valuation.py | 2 +- src/sage/schemes/projective/projective_morphism.py | 2 +- src/sage/schemes/projective/projective_subscheme.py | 2 +- src/sage/sets/family.py | 3 +-- src/sage/sets/set.py | 6 ++---- src/sage/tensor/modules/finite_rank_free_module.py | 2 +- src/sage/tensor/modules/free_module_basis.py | 2 +- src/sage/topology/simplicial_complex.py | 3 +-- 75 files changed, 119 insertions(+), 165 deletions(-) diff --git a/src/sage/algebras/free_algebra_quotient.py b/src/sage/algebras/free_algebra_quotient.py index 81c7f5ad91e..b19884335c4 100644 --- a/src/sage/algebras/free_algebra_quotient.py +++ b/src/sage/algebras/free_algebra_quotient.py @@ -65,7 +65,7 @@ from sage.structure.unique_representation import UniqueRepresentation -class FreeAlgebraQuotient(UniqueRepresentation, Algebra, object): +class FreeAlgebraQuotient(UniqueRepresentation, Algebra): @staticmethod def __classcall__(cls, A, mons, mats, names): """ diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py index b0ea05d0563..8ae3270491c 100644 --- a/src/sage/categories/enumerated_sets.py +++ b/src/sage/categories/enumerated_sets.py @@ -313,8 +313,7 @@ def iterator_range(self, start=None, stop=None, step=None): if stop is None: if start is None: if step is None: - for x in self: - yield x + yield from self return start = 0 elif start < 0: @@ -793,8 +792,7 @@ def _iterator_from_list(self): sage: [next(it), next(it), next(it)] [1, 2, 3] """ - for x in self.tuple(): - yield x + yield from self.tuple() def _iterator_from_next(self): """ diff --git a/src/sage/categories/finite_enumerated_sets.py b/src/sage/categories/finite_enumerated_sets.py index 8a3c0e42ca5..4ca87850b7a 100644 --- a/src/sage/categories/finite_enumerated_sets.py +++ b/src/sage/categories/finite_enumerated_sets.py @@ -446,8 +446,7 @@ def iterator_range(self, start=None, stop=None, step=None): for j in range(stop): yield next(it) return - for x in self: - yield x + yield from self return if L is None: L = self.tuple() diff --git a/src/sage/categories/posets.py b/src/sage/categories/posets.py index 5cad3c70f73..98d1be6049d 100644 --- a/src/sage/categories/posets.py +++ b/src/sage/categories/posets.py @@ -150,8 +150,7 @@ def __iter__(self): from sage.combinat.posets.posets import FinitePosets_n n = 0 while True: - for P in FinitePosets_n(n): - yield P + yield from FinitePosets_n(n) n += 1 Finite = LazyImport('sage.categories.finite_posets', 'FinitePosets') diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py index 8625bae5b49..eea537a115a 100644 --- a/src/sage/coding/guruswami_sudan/interpolation.py +++ b/src/sage/coding/guruswami_sudan/interpolation.py @@ -46,8 +46,7 @@ def _flatten_once(lstlst): [1, 2, 3, 4, 5, 6] """ for lst in lstlst: - for e in lst: - yield e + yield from lst #************************************************************* # Linear algebraic Interpolation algorithm, helper functions diff --git a/src/sage/combinat/abstract_tree.py b/src/sage/combinat/abstract_tree.py index 1dd26c41222..ee797d990fa 100644 --- a/src/sage/combinat/abstract_tree.py +++ b/src/sage/combinat/abstract_tree.py @@ -779,8 +779,7 @@ def paths_at_depth(self, depth, path=[]): yield tuple(path) else: for i in range(len(self)): - for p in self[i].paths_at_depth(depth - 1, path + [i]): - yield p + yield from self[i].paths_at_depth(depth - 1, path + [i]) def node_number_at_depth(self, depth): r""" diff --git a/src/sage/combinat/alternating_sign_matrix.py b/src/sage/combinat/alternating_sign_matrix.py index ee34e183a70..e4eec5eedaf 100644 --- a/src/sage/combinat/alternating_sign_matrix.py +++ b/src/sage/combinat/alternating_sign_matrix.py @@ -1908,8 +1908,7 @@ def __iter__(self): [[1, 2, 3], [2, 3], [2]], [[1, 2, 3], [2, 3], [3]]] """ - for z in self._iterator_rec(self.n): - yield z + yield from self._iterator_rec(self.n) def _next_column_iterator(previous_column, height, i=None): diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index 514acb43636..58fa26437fa 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -3878,8 +3878,7 @@ def b_matrix_class_iter(self, depth=infinity, up_to_equivalence=True): ] """ Q = self.quiver() - for M in Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix'): - yield M + yield from Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix') def b_matrix_class(self, depth=infinity, up_to_equivalence=True): r""" diff --git a/src/sage/combinat/colored_permutations.py b/src/sage/combinat/colored_permutations.py index d97624a218d..ff9a67e3083 100644 --- a/src/sage/combinat/colored_permutations.py +++ b/src/sage/combinat/colored_permutations.py @@ -1557,7 +1557,7 @@ def _coerce_map_from_(self, C): [1 if v == 0 else -1 for v in x._colors], x._perm) - return super(SignedPermutations, self)._coerce_map_from_(C) + return super()._coerce_map_from_(C) def long_element(self, index_set=None): """ @@ -1587,7 +1587,7 @@ def long_element(self, index_set=None): True """ if index_set is not None: - return super(SignedPermutations, self).long_element() + return super().long_element() return self.element_class(self, [-ZZ.one()] * self._n, self._P.one()) def conjugacy_class_representative(self, nu): diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 4b763bb5af8..4c182f7c0da 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -1938,8 +1938,7 @@ def __iterator_from_list(self) -> Iterator: sage: list(C) # indirect doctest [1, 2, 3] """ - for x in self.list(): - yield x + yield from self.list() def __iter__(self): """ @@ -2574,8 +2573,7 @@ def __iter__(self) -> Iterator: raise NotImplementedError i = 0 while True: - for c in finite(i): - yield c + yield from finite(i) i += 1 diff --git a/src/sage/combinat/designs/design_catalog.py b/src/sage/combinat/designs/design_catalog.py index 26b899cb93d..8bf7f14fd0b 100644 --- a/src/sage/combinat/designs/design_catalog.py +++ b/src/sage/combinat/designs/design_catalog.py @@ -118,4 +118,4 @@ 'OAMainFunctions', as_='orthogonal_arrays') lazy_import('sage.combinat.designs.gen_quadrangles_with_spread', - ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) \ No newline at end of file + ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index acd0adb2718..0d51f7c3774 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -5406,8 +5406,7 @@ def _iter_transitions_all_(self): [('1', '2'), ('2', '2')] """ for state in self.iter_states(): - for t in state.transitions: - yield t + yield from state.transitions def initial_states(self): """ @@ -6461,8 +6460,7 @@ def _iter_process_simple_(self, iterator): "here." % (len(branch.outputs),)) - for o in branch.outputs[0]: - yield o + yield from branch.outputs[0] branch.outputs[0] = [] # Reset output so that in the next round # (of "for current in iterator") only new diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 2dce68651a2..14711e8713e 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -328,7 +328,7 @@ def __classcall_private__(cls, base_ring, basis_keys=None, category=None, latex_names = tuple(latex_names) keywords['latex_names'] = latex_names - return super(CombinatorialFreeModule, cls).__classcall__(cls, + return super().__classcall__(cls, base_ring, basis_keys, category=category, prefix=prefix, names=names, **keywords) @@ -1674,7 +1674,7 @@ def _coerce_map_from_(self, R): [vector_map[i](M.monomial(x[i])) for i, M in enumerate(modules)]), codomain=self) - return super(CombinatorialFreeModule_Tensor, self)._coerce_map_from_(R) + return super()._coerce_map_from_(R) class CartesianProductWithFlattening(): diff --git a/src/sage/combinat/integer_matrices.py b/src/sage/combinat/integer_matrices.py index 8d737c64349..238d0ef4091 100644 --- a/src/sage/combinat/integer_matrices.py +++ b/src/sage/combinat/integer_matrices.py @@ -77,7 +77,7 @@ def __classcall__(cls, row_sums, column_sums): from sage.combinat.composition import Composition row_sums = Composition(row_sums) column_sums = Composition(column_sums) - return super(IntegerMatrices, cls).__classcall__(cls, row_sums, column_sums) + return super().__classcall__(cls, row_sums, column_sums) def __init__(self, row_sums, column_sums): r""" diff --git a/src/sage/combinat/integer_vector_weighted.py b/src/sage/combinat/integer_vector_weighted.py index bd2198f29da..c7700671c61 100644 --- a/src/sage/combinat/integer_vector_weighted.py +++ b/src/sage/combinat/integer_vector_weighted.py @@ -101,7 +101,7 @@ def __classcall_private__(cls, n=None, weight=None): if n is None: return WeightedIntegerVectors_all(weight) - return super(WeightedIntegerVectors, cls).__classcall__(cls, n, weight) + return super().__classcall__(cls, n, weight) def __init__(self, n, weight): """ diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py index 530f621ca31..0e4bbc41758 100644 --- a/src/sage/combinat/k_tableau.py +++ b/src/sage/combinat/k_tableau.py @@ -4104,8 +4104,7 @@ def __iter__(self): yield self([[None]*(row) for row in self._inner_shape]) else: for unT in StrongTableaux.standard_unmarked_iterator( self.k, size, self._outer_shape, self._inner_shape ): - for T in StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight ): - yield T + yield from StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight ) @classmethod def standard_unmarked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ): @@ -4410,8 +4409,7 @@ def standard_marked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ): [[]] """ for T in cls.standard_unmarked_iterator( k, size, outer_shape, inner_shape ): - for TT in cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) ): - yield TT + yield from cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) ) @classmethod def cells_head_dictionary( cls, T ): diff --git a/src/sage/combinat/lr_tableau.py b/src/sage/combinat/lr_tableau.py index c19effc2173..a94f576a134 100644 --- a/src/sage/combinat/lr_tableau.py +++ b/src/sage/combinat/lr_tableau.py @@ -174,7 +174,7 @@ def __classcall_private__(cls, shape, weight): weight = tuple(Partition(a) for a in weight) if shape.size() != sum(a.size() for a in weight): raise ValueError("the sizes of shapes and sequence of weights do not match") - return super(LittlewoodRichardsonTableaux, cls).__classcall__(cls, shape, weight) + return super().__classcall__(cls, shape, weight) def __init__(self, shape, weight): r""" @@ -193,7 +193,7 @@ def __init__(self, shape, weight): self._shape = shape self._weight = weight self._heights = [a.length() for a in self._weight] - super(LittlewoodRichardsonTableaux, self).__init__(category=FiniteEnumeratedSets()) + super().__init__(category=FiniteEnumeratedSets()) def _repr_(self): """ diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index 14d284b77c6..d18177aac00 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -1748,7 +1748,7 @@ def __init__(self, n): sage: TestSuite(PP).run() """ - super(PlanePartitions_n, self).__init__(category=FiniteEnumeratedSets()) + super().__init__(category=FiniteEnumeratedSets()) self._n = n def _repr_(self) -> str: diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py index d3c46a1daf7..e223795099f 100644 --- a/src/sage/combinat/posets/posets.py +++ b/src/sage/combinat/posets/posets.py @@ -1319,7 +1319,7 @@ def __call__(self, element): """ if self._is_facade and element in self._element_to_vertex_dict: return element - return super(FinitePoset, self).__call__(element) + return super().__call__(element) def hasse_diagram(self): r""" @@ -8994,7 +8994,7 @@ def cardinality(self, from_iterator=False): if not from_iterator and self._n < len(known_values): return Integer(known_values[self._n]) else: - return super(FinitePosets_n, self).cardinality() + return super().cardinality() # For backward compatibility of pickles of the former Posets() diff --git a/src/sage/combinat/recognizable_series.py b/src/sage/combinat/recognizable_series.py index 698dd959619..173e061276b 100644 --- a/src/sage/combinat/recognizable_series.py +++ b/src/sage/combinat/recognizable_series.py @@ -455,7 +455,7 @@ def __init__(self, parent, mu, left, right): sage: S.mu[0] is M0, S.mu[1] is M1, S.left is L, S.right is R (True, True, True, True) """ - super(RecognizableSeries, self).__init__(parent=parent) + super().__init__(parent=parent) from copy import copy from sage.matrix.constructor import Matrix @@ -1660,7 +1660,7 @@ def __classcall__(cls, *args, **kwds): sage: Rec1 is Rec2 is Rec3 True """ - return super(RecognizableSeriesSpace, cls).__classcall__( + return super().__classcall__( cls, *cls.__normalize__(*args, **kwds)) @classmethod @@ -1782,7 +1782,7 @@ def __init__(self, coefficient_ring, indices, category, minimize_results): """ self._indices_ = indices self._minimize_results_ = minimize_results - super(RecognizableSeriesSpace, self).__init__( + super().__init__( category=category, base=coefficient_ring) def __reduce__(self): diff --git a/src/sage/combinat/regular_sequence.py b/src/sage/combinat/regular_sequence.py index a10ceb7cf17..c585e51e194 100644 --- a/src/sage/combinat/regular_sequence.py +++ b/src/sage/combinat/regular_sequence.py @@ -1510,7 +1510,7 @@ def some_elements(self): """ return iter(element.regenerated() for element - in super(RegularSequenceRing, self).some_elements( + in super().some_elements( allow_degenerated_sequence=True)) def _element_constructor_(self, *args, **kwds): @@ -1537,7 +1537,7 @@ def _element_constructor_(self, *args, **kwds): 2-regular sequence 1, 3, 6, 9, 12, 18, 18, 27, 24, 36, ... """ allow_degenerated_sequence = kwds.pop('allow_degenerated_sequence', False) - element = super(RegularSequenceRing, self)._element_constructor_(*args, **kwds) + element = super()._element_constructor_(*args, **kwds) if not allow_degenerated_sequence: element._error_if_degenerated_() return element diff --git a/src/sage/combinat/ribbon_shaped_tableau.py b/src/sage/combinat/ribbon_shaped_tableau.py index a5bfc841e7b..4115a6a13aa 100644 --- a/src/sage/combinat/ribbon_shaped_tableau.py +++ b/src/sage/combinat/ribbon_shaped_tableau.py @@ -191,7 +191,7 @@ class based on input. # return RibbonShapedTableaux_shape(Partition(shape)) # Otherwise arg0 takes the place of the category in pickling - return super(RibbonShapedTableaux, cls).__classcall__(cls, **kwds) + return super().__classcall__(cls, **kwds) def __init__(self, category=None): """ @@ -262,7 +262,7 @@ class based on input. return StandardRibbonShapedTableaux_shape(Partition(shape)) # Otherwise arg0 takes the place of the category in pickling - return super(StandardRibbonShapedTableaux, cls).__classcall__(cls, **kwds) + return super().__classcall__(cls, **kwds) def __init__(self, category=None): """ diff --git a/src/sage/combinat/rigged_configurations/kleber_tree.py b/src/sage/combinat/rigged_configurations/kleber_tree.py index 2403ad7ab05..b4a57e365f6 100644 --- a/src/sage/combinat/rigged_configurations/kleber_tree.py +++ b/src/sage/combinat/rigged_configurations/kleber_tree.py @@ -609,7 +609,7 @@ def __classcall_private__(cls, cartan_type, B, classical=None): classical = cartan_type.classical() else: classical = CartanType(classical) - return super(KleberTree, cls).__classcall__(cls, cartan_type, B, classical) + return super().__classcall__(cls, cartan_type, B, classical) def __init__(self, cartan_type, B, classical_ct): r""" @@ -811,8 +811,7 @@ def _children_iter(self, node): # tradeoff occurs between the methods. However, this may grow as # the _children_iter_vector is further optimized. if node != self.root and prod(val+1 for val in node.up_root.coefficients()) < 1000: - for x in self._children_iter_vector(node): - yield x + yield from self._children_iter_vector(node) return n = self._classical_ct.rank() @@ -985,8 +984,7 @@ def _depth_first_iter(self, cur): yield cur for child in cur.children: - for x in self._depth_first_iter(child): - yield x + yield from self._depth_first_iter(child) __iter__ = breadth_first_iter @@ -1160,7 +1158,7 @@ def __classcall_private__(cls, cartan_type, B): return KleberTreeTypeA2Even(cartan_type, B) if cartan_type.classical().is_simply_laced(): raise ValueError("use KleberTree for simply-laced types") - return super(VirtualKleberTree, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): """ @@ -1354,7 +1352,7 @@ def __classcall_private__(cls, cartan_type, B): cartan_type = CartanType(cartan_type) # Standardize B input into a tuple of tuples B = tuple(map(tuple, B)) - return super(KleberTreeTypeA2Even, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): """ diff --git a/src/sage/combinat/rigged_configurations/kr_tableaux.py b/src/sage/combinat/rigged_configurations/kr_tableaux.py index 3addee9e2e5..8bdc1d275b9 100644 --- a/src/sage/combinat/rigged_configurations/kr_tableaux.py +++ b/src/sage/combinat/rigged_configurations/kr_tableaux.py @@ -554,7 +554,7 @@ def tensor(self, *crystals, **options): elif isinstance(B, KirillovReshetikhinTableaux): dims.append([B._r, B._s]) return TensorProductOfKirillovReshetikhinTableaux(ct, dims) - return super(KirillovReshetikhinTableaux, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) @lazy_attribute def _tableau_height(self): diff --git a/src/sage/combinat/rigged_configurations/rc_crystal.py b/src/sage/combinat/rigged_configurations/rc_crystal.py index 647d3c6eb0d..13bc6a86cfa 100644 --- a/src/sage/combinat/rigged_configurations/rc_crystal.py +++ b/src/sage/combinat/rigged_configurations/rc_crystal.py @@ -153,7 +153,7 @@ def __classcall_private__(cls, cartan_type, wt=None, WLR=None): if isinstance(cartan_type, CartanTypeFolded): return CrystalOfNonSimplyLacedRC(cartan_type, wt, WLR) - return super(CrystalOfRiggedConfigurations, cls).__classcall__(cls, wt, WLR=WLR) + return super().__classcall__(cls, wt, WLR=WLR) def __init__(self, wt, WLR): r""" diff --git a/src/sage/combinat/rigged_configurations/rc_infinity.py b/src/sage/combinat/rigged_configurations/rc_infinity.py index e592f9b3656..d633f50abca 100644 --- a/src/sage/combinat/rigged_configurations/rc_infinity.py +++ b/src/sage/combinat/rigged_configurations/rc_infinity.py @@ -147,7 +147,7 @@ def __classcall_private__(cls, cartan_type): return InfinityCrystalOfNonSimplyLacedRC(cartan_type) cartan_type = CartanType(cartan_type) - return super(InfinityCrystalOfRiggedConfigurations, cls).__classcall__(cls, cartan_type) + return super().__classcall__(cls, cartan_type) def __init__(self, cartan_type): r""" @@ -241,7 +241,7 @@ def _coerce_map_from_(self, P): and self.cartan_type().is_simply_laced()): from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism return FromTableauIsomorphism(Hom(P, self)) - return super(InfinityCrystalOfRiggedConfigurations, self)._coerce_map_from_(P) + return super()._coerce_map_from_(P) def _calc_vacancy_number(self, partitions, a, i, **options): r""" @@ -358,7 +358,7 @@ def _coerce_map_from_(self, P): if isinstance(P, InfinityCrystalOfTableaux): from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism return FromTableauIsomorphism(Hom(P, self)) - return super(InfinityCrystalOfNonSimplyLacedRC, self)._coerce_map_from_(P) + return super()._coerce_map_from_(P) def _calc_vacancy_number(self, partitions, a, i): r""" diff --git a/src/sage/combinat/rigged_configurations/rigged_configurations.py b/src/sage/combinat/rigged_configurations/rigged_configurations.py index b822a668612..2d558322721 100644 --- a/src/sage/combinat/rigged_configurations/rigged_configurations.py +++ b/src/sage/combinat/rigged_configurations/rigged_configurations.py @@ -358,7 +358,7 @@ def __classcall_private__(cls, cartan_type, B): if not cartan_type.classical().is_simply_laced(): return RCNonSimplyLaced(cartan_type, B) - return super(RiggedConfigurations, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): r""" @@ -476,7 +476,7 @@ def _repr_option(self, key): """ if key == 'element_ascii_art': return self.options.element_ascii_art - return super(RiggedConfigurations, self)._repr_option(key) + return super()._repr_option(key) def __iter__(self): """ @@ -1062,7 +1062,7 @@ def tensor(self, *crystals, **options): for B in crystals: dims += B.dims return RiggedConfigurations(ct, dims) - return super(RiggedConfigurations, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) Element = KRRCSimplyLacedElement @@ -1093,7 +1093,7 @@ def __classcall_private__(cls, cartan_type, B): # Standardize B input into a tuple of tuples B = tuple(map(tuple, B)) - return super(RCNonSimplyLaced, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, dims): """ diff --git a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py index 3314986004f..a2ccd72e902 100644 --- a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py +++ b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py @@ -133,8 +133,7 @@ def __iter__(self): if self._cache is None: self._cache = tuple([x.to_tensor_product_of_kirillov_reshetikhin_tableaux() for x in self.tp_krt.rigged_configurations().module_generators]) - for x in self._cache: - yield x + yield from self._cache def __repr__(self): """ @@ -296,7 +295,7 @@ def __classcall_private__(cls, cartan_type, B): # Standardize B input into a tuple of tuples B = tuple(tuple(dim) for dim in B) - return super(TensorProductOfKirillovReshetikhinTableaux, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): r""" @@ -493,7 +492,7 @@ def tensor(self, *crystals, **options): elif isinstance(B, KirillovReshetikhinTableaux): dims.append([B._r, B._s]) return TensorProductOfKirillovReshetikhinTableaux(ct, dims) - return super(TensorProductOfKirillovReshetikhinTableaux, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) TensorProductOfKirillovReshetikhinTableaux.Element = TensorProductOfKirillovReshetikhinTableauxElement diff --git a/src/sage/combinat/root_system/type_relabel.py b/src/sage/combinat/root_system/type_relabel.py index 142ddeffa45..965ab598cfb 100644 --- a/src/sage/combinat/root_system/type_relabel.py +++ b/src/sage/combinat/root_system/type_relabel.py @@ -55,7 +55,7 @@ def __classcall__(cls, type, relabelling): return type relabelling = FiniteFamily(relabelling) # Hack to emulate a frozendict which would be hashable!!!! - return super(CartanType, cls).__classcall__(cls, type, relabelling) + return super().__classcall__(cls, type, relabelling) def __init__(self, type, relabelling): """ diff --git a/src/sage/combinat/species/cycle_species.py b/src/sage/combinat/species/cycle_species.py index 335223143ed..ed442e75ba9 100644 --- a/src/sage/combinat/species/cycle_species.py +++ b/src/sage/combinat/species/cycle_species.py @@ -113,7 +113,7 @@ def __classcall__(cls, *args, **kwds): sage: C = species.CycleSpecies(); C Cyclic permutation species """ - return super(CycleSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/linear_order_species.py b/src/sage/combinat/species/linear_order_species.py index a62fde28fb5..6203442ec8f 100644 --- a/src/sage/combinat/species/linear_order_species.py +++ b/src/sage/combinat/species/linear_order_species.py @@ -77,7 +77,7 @@ def __classcall__(cls, *args, **kwds): sage: L = species.LinearOrderSpecies(); L Linear order species """ - return super(LinearOrderSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/partition_species.py b/src/sage/combinat/species/partition_species.py index 3ed00b45ca4..f9044db7c73 100644 --- a/src/sage/combinat/species/partition_species.py +++ b/src/sage/combinat/species/partition_species.py @@ -142,7 +142,7 @@ def __classcall__(cls, *args, **kwds): sage: P = species.PartitionSpecies(); P Partition species """ - return super(PartitionSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/permutation_species.py b/src/sage/combinat/species/permutation_species.py index 4549e0354ff..64534c9e8bb 100644 --- a/src/sage/combinat/species/permutation_species.py +++ b/src/sage/combinat/species/permutation_species.py @@ -115,7 +115,7 @@ def __classcall__(cls, *args, **kwds): sage: P = species.PermutationSpecies(); P Permutation species """ - return super(PermutationSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/set_species.py b/src/sage/combinat/species/set_species.py index c4942dc653d..daa7d7e5835 100644 --- a/src/sage/combinat/species/set_species.py +++ b/src/sage/combinat/species/set_species.py @@ -91,7 +91,7 @@ def __classcall__(cls, *args, **kwds): sage: E = species.SetSpecies(); E Set species """ - return super(SetSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/subset_species.py b/src/sage/combinat/species/subset_species.py index 2bd89885533..81156e5183d 100644 --- a/src/sage/combinat/species/subset_species.py +++ b/src/sage/combinat/species/subset_species.py @@ -134,7 +134,7 @@ def __classcall__(cls, *args, **kwds): sage: S = species.SubsetSpecies(); S Subset species """ - return super(SubsetSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 2103cb810a7..f7e58a15c20 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -9440,8 +9440,7 @@ def __iter__(self): for (r, c) in growth_choice: new_tab[r][c] = growth_num list_of_partial_inc_tabs.append(Tableau(new_tab)) - for inctab in list_of_inc_tabs: - yield inctab + yield from list_of_inc_tabs class IncreasingTableaux_size_weight(IncreasingTableaux): diff --git a/src/sage/combinat/words/abstract_word.py b/src/sage/combinat/words/abstract_word.py index 77174089f78..610dba1437a 100644 --- a/src/sage/combinat/words/abstract_word.py +++ b/src/sage/combinat/words/abstract_word.py @@ -900,8 +900,7 @@ def _iterated_right_palindromic_closure_iterator(self, f=None): w = (w*par([letter])).palindromic_closure(f=f) length_after = w.length() d = length_after - length_before - for a in w[-d:]: - yield a + yield from w[-d:] def _iterated_right_palindromic_closure_recursive_iterator(self, f=None): r""" @@ -991,8 +990,7 @@ def _iterated_right_palindromic_closure_recursive_iterator(self, f=None): else: to_append = ipcw[lengths[pos]:] ipcw += to_append - for a in to_append: - yield a + yield from to_append def iterated_right_palindromic_closure(self, f=None, algorithm='recursive'): r""" diff --git a/src/sage/combinat/words/word_generators.py b/src/sage/combinat/words/word_generators.py index 06141373c85..d7093ae997c 100644 --- a/src/sage/combinat/words/word_generators.py +++ b/src/sage/combinat/words/word_generators.py @@ -1651,8 +1651,7 @@ def _s_adic_iterator(self, sequence, letters): if not precedent_letter == m(a)[0]: raise ValueError("the hypothesis of the algorithm used is not satisfied; the image of the %s-th letter (=%s) under the %s-th morphism (=%s) should start with the %s-th letter (=%s)" % (i+1,a,i+1,m,i,precedent_letter)) w = p(m(a)[1:]) - for b in w: - yield b + yield from w p = p * m precedent_letter = a diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py index 900ab9c8508..63d6f1f0d05 100644 --- a/src/sage/combinat/words/words.py +++ b/src/sage/combinat/words/words.py @@ -960,8 +960,7 @@ def __iter__(self): word: 444 """ for l in itertools.count(): - for w in self.iterate_by_length(l): - yield w + yield from self.iterate_by_length(l) def __contains__(self, x): """ diff --git a/src/sage/cpython/_py2_random.py b/src/sage/cpython/_py2_random.py index 1cd9532fee4..3ba96ccbbd1 100644 --- a/src/sage/cpython/_py2_random.py +++ b/src/sage/cpython/_py2_random.py @@ -92,19 +92,19 @@ def seed(self, a=None): import time a = int(time.time() * 256) # use fractional seconds - super(Random, self).seed(a) + super().seed(a) self.gauss_next = None def getstate(self): """Return internal state; can be passed to setstate() later.""" - return self.VERSION, super(Random, self).getstate(), self.gauss_next + return self.VERSION, super().getstate(), self.gauss_next def setstate(self, state): """Restore internal state from object returned by getstate().""" version = state[0] if version == 3: version, internalstate, self.gauss_next = state - super(Random, self).setstate(internalstate) + super().setstate(internalstate) elif version == 2: version, internalstate, self.gauss_next = state # In version 2, the state was saved as signed ints, which causes @@ -115,7 +115,7 @@ def setstate(self, state): internalstate = tuple( int(x) % (2**32) for x in internalstate ) except ValueError as e: raise TypeError(e) - super(Random, self).setstate(internalstate) + super().setstate(internalstate) else: raise ValueError("state with version %s passed to " "Random.setstate() of version %s" % @@ -131,7 +131,7 @@ def jumpahead(self, n): # we use hashing to create a large n for the shuffle. s = repr(n) + repr(self.getstate()) n = int(_hashlib.new('sha512', s).hexdigest(), 16) - super(Random, self).jumpahead(n) + super().jumpahead(n) ## ---- Methods below this point do not need to be overridden when ## ---- subclassing for the purpose of using a different core generator. diff --git a/src/sage/data_structures/mutable_poset.py b/src/sage/data_structures/mutable_poset.py index 44d086fa920..97bfcf1cd52 100644 --- a/src/sage/data_structures/mutable_poset.py +++ b/src/sage/data_structures/mutable_poset.py @@ -947,9 +947,8 @@ def _iter_depth_first_visit_(self, marked, if key is not None: S = sorted(S, key=key) for shell in S: - for e in shell._iter_depth_first_visit_(marked, reverse, - key, condition): - yield e + yield from shell._iter_depth_first_visit_(marked, reverse, + key, condition) def iter_depth_first(self, reverse=False, key=None, condition=None): r""" @@ -1072,9 +1071,8 @@ def _iter_topological_visit_(self, marked, if key is not None and len(S) > 1: S = sorted(S, key=key) for shell in S: - for e in shell._iter_topological_visit_(marked, reverse, - key, condition): - yield e + yield from shell._iter_topological_visit_(marked, reverse, + key, condition) yield self def iter_topological(self, reverse=False, key=None, condition=None): @@ -1768,8 +1766,7 @@ def shells(self, include_special=False): """ if include_special: yield self.null - for e in self._shells_.values(): - yield e + yield from self._shells_.values() if include_special: yield self.oo diff --git a/src/sage/databases/stein_watkins.py b/src/sage/databases/stein_watkins.py index 167fa3a195b..6abf39426dd 100644 --- a/src/sage/databases/stein_watkins.py +++ b/src/sage/databases/stein_watkins.py @@ -158,8 +158,7 @@ def __len__(self): def __iter__(self): try: - for E in self.curves: - yield E + yield from self.curves except AttributeError: return diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index b5521868dd5..6c3b0b225ac 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -503,7 +503,7 @@ def getvalue(self): TestResults = namedtuple('TestResults', 'failed attempted') -class SageDocTestRunner(doctest.DocTestRunner, object): +class SageDocTestRunner(doctest.DocTestRunner): def __init__(self, *args, **kwds): """ A customized version of DocTestRunner that tracks dependencies diff --git a/src/sage/features/join_feature.py b/src/sage/features/join_feature.py index 802cb433ba3..6360eec1576 100644 --- a/src/sage/features/join_feature.py +++ b/src/sage/features/join_feature.py @@ -148,7 +148,7 @@ def hide(self): """ for f in self._features: f.hide() - super(JoinFeature, self).hide() + super().hide() def unhide(self): r""" @@ -172,4 +172,4 @@ def unhide(self): """ for f in self._features: f.unhide() - super(JoinFeature, self).unhide() + super().unhide() diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 7a9322973ad..f4e0dc1bdbf 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -454,7 +454,7 @@ def __init__(self, name, nargs=2, latex_name=None, conversions=None): self._maxima_name = conversions['maxima'] except KeyError: pass - super(OrthogonalFunction, self).__init__(name=name, nargs=nargs, + super().__init__(name=name, nargs=nargs, latex_name=latex_name, conversions=conversions) @@ -529,7 +529,7 @@ def __call__(self, *args, **kwds): kwds['hold'] = True return _maxima(self._eval_(*args, **kwds))._sage_() - return super(OrthogonalFunction, self).__call__(*args, **kwds) + return super().__call__(*args, **kwds) class ChebyshevFunction(OrthogonalFunction): @@ -575,7 +575,7 @@ def __call__(self, n, *args, **kwds): except Exception: pass - return super(ChebyshevFunction, self).__call__(n, *args, **kwds) + return super().__call__(n, *args, **kwds) def _eval_(self, n, x): """ diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index ff3851a1776..4e8588ad05c 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -473,8 +473,7 @@ def items(self, parameters, variable): support is {0}, function is sin(x) support is (0, 2), function is cos(x) """ - for pair in parameters: - yield pair + yield from parameters def __call__(self, parameters, variable, value=None, **kwds): """ diff --git a/src/sage/geometry/polyhedral_complex.py b/src/sage/geometry/polyhedral_complex.py index 2e20e508057..d6e3b075656 100644 --- a/src/sage/geometry/polyhedral_complex.py +++ b/src/sage/geometry/polyhedral_complex.py @@ -415,8 +415,7 @@ def cell_iterator(self, increasing=True): dim_index = reversed(dim_index) for d in dim_index: if d in cells: - for c in cells[d]: - yield c + yield from cells[d] def _n_cells_sorted(self, n, subcomplex=None): """ @@ -543,8 +542,7 @@ def maximal_cell_iterator(self, increasing=False): dim_index = reversed(dim_index) for d in dim_index: if d in maximal_cells: - for c in maximal_cells[d]: - yield c + yield from maximal_cells[d] def n_maximal_cells(self, n): r""" diff --git a/src/sage/geometry/polyhedron/base0.py b/src/sage/geometry/polyhedron/base0.py index 556eefc5148..4b31a8eb6ed 100644 --- a/src/sage/geometry/polyhedron/base0.py +++ b/src/sage/geometry/polyhedron/base0.py @@ -753,8 +753,7 @@ def Hrep_generator(self): sage: next(p.Hrep_generator()) An inequality (-1, 0, 0) x + 1 >= 0 """ - for H in self.Hrepresentation(): - yield H + yield from self.Hrepresentation() @cached_method def n_Hrepresentation(self): @@ -843,8 +842,7 @@ def Vrep_generator(self): sage: next(vg) A vertex at (1, 1, 1) """ - for V in self.Vrepresentation(): - yield V + yield from self.Vrepresentation() def inequality_generator(self): """ diff --git a/src/sage/geometry/polyhedron/generating_function.py b/src/sage/geometry/polyhedron/generating_function.py index 2c6cfccf200..7a33bd528b9 100644 --- a/src/sage/geometry/polyhedron/generating_function.py +++ b/src/sage/geometry/polyhedron/generating_function.py @@ -772,7 +772,7 @@ def decode_factor(factor): return _simplify_(numerator, terms) -class _TransformHrepresentation(object): +class _TransformHrepresentation: r""" An abstract base class for transformations of the Hrepresentation of a polyhedron together with its @@ -1428,7 +1428,7 @@ def __init__(self, inequalities, equations, B, mod): <..._TransformMod object at 0x...> """ self.mod = mod - super(_TransformMod, self).__init__(inequalities, equations, B) + super().__init__(inequalities, equations, B) def _transform_(self): r""" diff --git a/src/sage/geometry/polyhedron/plot.py b/src/sage/geometry/polyhedron/plot.py index b6bb235b711..03628f60e22 100644 --- a/src/sage/geometry/polyhedron/plot.py +++ b/src/sage/geometry/polyhedron/plot.py @@ -843,8 +843,7 @@ def defining_equation(): # corresponding to a polygon if polyhedron.dim() < 3: yield next(polyhedron.equation_generator()) else: - for ineq in polyhedron.inequality_generator(): - yield ineq + yield from polyhedron.inequality_generator() faces = [] face_inequalities = [] diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index 16b55ab7cac..e8c8d7e1a51 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -336,8 +336,7 @@ def __iter__(self): ... StopIteration """ - for p in self._triangulation: - yield p + yield from self._triangulation def __getitem__(self, i): """ diff --git a/src/sage/geometry/triangulation/point_configuration.py b/src/sage/geometry/triangulation/point_configuration.py index 14afe670c16..68ac3119945 100644 --- a/src/sage/geometry/triangulation/point_configuration.py +++ b/src/sage/geometry/triangulation/point_configuration.py @@ -501,8 +501,7 @@ def __iter__(self): sage: [p.point(i) for i in range(p.n_points())] [P(1, 1), P(2, 2), P(3, 3)] """ - for p in self.points(): - yield p + yield from self.points() def _repr_(self): r""" @@ -719,8 +718,7 @@ def _TOPCOM_triangulations(self, verbose=True): if self._regular is False: command += ' --nonregular' - for t in self._TOPCOM_communicate(command, verbose): - yield t + yield from self._TOPCOM_communicate(command, verbose) def _TOPCOM_triangulate(self, verbose=True): r""" @@ -988,8 +986,7 @@ def triangulations(self, verbose=False): sage: p.set_engine('internal') """ if self._use_TOPCOM: - for triangulation in self._TOPCOM_triangulations(verbose): - yield triangulation + yield from self._TOPCOM_triangulations(verbose) else: if not self._connected: raise ValueError('Need TOPCOM to find disconnected triangulations.') diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..1782d08dbda 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -11431,8 +11431,7 @@ def neighbor_iterator(self, vertex, closed=False): if not self.has_edge(vertex, vertex): yield vertex - for u in self._backend.iterator_nbrs(vertex): - yield u + yield from self._backend.iterator_nbrs(vertex) def vertices(self, sort=False, key=None, degree=None, vertex_property=None): r""" diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 718dbdad745..60ab129f1c2 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -9039,8 +9039,7 @@ def rec(G): # For each unlabeled matching, we yield all its possible labelings for m in rec(G): - for pm in itertools.product(*[edges[frozenset(e)] for e in m]): - yield pm + yield from itertools.product(*[edges[frozenset(e)] for e in m]) @doc_index("Leftovers") def has_perfect_matching(self, algorithm="Edmonds", solver=None, verbose=0, diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py index e45371bc6d9..ce213b738c3 100644 --- a/src/sage/graphs/graph_generators.py +++ b/src/sage/graphs/graph_generators.py @@ -1521,8 +1521,7 @@ def fullerenes(self, order, ipr=False): sp.stdout.reconfigure(newline='') - for G in graphs._read_planar_code(sp.stdout): - yield(G) + yield from graphs._read_planar_code(sp.stdout) def fusenes(self, hexagon_count, benzenoids=False): r""" @@ -1797,8 +1796,7 @@ def plantri_gen(self, options=""): sp.stdout.reconfigure(newline='') try: - for G in graphs._read_planar_code(sp.stdout): - yield(G) + yield from graphs._read_planar_code(sp.stdout) except AssertionError: raise AttributeError("invalid options '{}'".format(options)) diff --git a/src/sage/homology/chain_complex.py b/src/sage/homology/chain_complex.py index 7a56cf3fc4b..16f2a78c7db 100644 --- a/src/sage/homology/chain_complex.py +++ b/src/sage/homology/chain_complex.py @@ -353,7 +353,7 @@ def __init__(self, parent, vectors, check=True): and v.base_ring() is parent.base_ring() for v in vectors.values()) self._vec = vectors - super(Chain_class, self).__init__(parent) + super().__init__(parent) def vector(self, degree): """ @@ -688,7 +688,7 @@ def __init__(self, grading_group, degree_of_differential, base_ring, differentia from sage.categories.chain_complexes import ChainComplexes category = ChainComplexes(base_ring) - super(ChainComplex_class, self).__init__(base=base_ring, category=category) + super().__init__(base=base_ring, category=category) Element = Chain_class diff --git a/src/sage/homology/koszul_complex.py b/src/sage/homology/koszul_complex.py index a8b050e09bc..22a1ceb5d80 100644 --- a/src/sage/homology/koszul_complex.py +++ b/src/sage/homology/koszul_complex.py @@ -115,7 +115,7 @@ def __classcall_private__(cls, R=None, elements=None): R = elements[0].parent() elif R is None: # elements is not None R = elements[0].parent() - return super(KoszulComplex, cls).__classcall__(cls, R, tuple(elements)) + return super().__classcall__(cls, R, tuple(elements)) def __init__(self, R, elements): """ diff --git a/src/sage/interfaces/polymake.py b/src/sage/interfaces/polymake.py index c857d14daf9..9161ebd5377 100644 --- a/src/sage/interfaces/polymake.py +++ b/src/sage/interfaces/polymake.py @@ -341,7 +341,7 @@ def to_str(x): except NotImplementedError: pass - return super(PolymakeAbstract, self)._coerce_impl(x, use_special=use_special) + return super()._coerce_impl(x, use_special=use_special) def console(self): """ @@ -1587,7 +1587,7 @@ def str_to_base_ring(s): from sage.geometry.polyhedron.backend_polymake import Polyhedron_polymake return Polyhedron_polymake._from_polymake_polytope(None, self) else: - return super(PolymakeElement, self)._sage_() + return super()._sage_() def _sage_doc_(self): """ diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py index 068e65a2096..bdf50dbfed9 100644 --- a/src/sage/interfaces/r.py +++ b/src/sage/interfaces/r.py @@ -560,7 +560,7 @@ def _coerce_impl(self, x, use_special=True): # cannot be used as input if isinstance(x, bool): return self('TRUE' if x else 'FALSE') - return super(R, self)._coerce_impl(x, use_special=use_special) + return super()._coerce_impl(x, use_special=use_special) def set_seed(self, seed=None): """ diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index f4e5c6a9158..331d698d3ab 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -1398,7 +1398,7 @@ def _repr_(self): """ - s = super(SingularElement, self)._repr_() + s = super()._repr_() if self._name in s: if self.get_custom_name() is None and self.type() == 'matrix': s = self.parent().eval('pmat(%s,20)' % (self.name())) diff --git a/src/sage/matrix/compute_J_ideal.py b/src/sage/matrix/compute_J_ideal.py index 3055f283a78..1983e16c0f5 100644 --- a/src/sage/matrix/compute_J_ideal.py +++ b/src/sage/matrix/compute_J_ideal.py @@ -334,7 +334,7 @@ def __init__(self, B): """ from sage.rings.polynomial.polynomial_ring import polygen - super(ComputeMinimalPolynomials, self).__init__() + super().__init__() if not B.is_square(): raise TypeError("square matrix required") diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index c307f4c28e4..279eba44511 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -2355,8 +2355,7 @@ def some_elements(self): ) """ yield self.an_element() - for g in self.gens(): - yield g + yield from self.gens() def _magma_init_(self, magma): r""" diff --git a/src/sage/misc/bindable_class.py b/src/sage/misc/bindable_class.py index 86d04bc8770..9213db6008e 100644 --- a/src/sage/misc/bindable_class.py +++ b/src/sage/misc/bindable_class.py @@ -213,7 +213,7 @@ class BoundClass(functools.partial): __doc__ = None # See warning above def __init__(self, *args): - super(BoundClass, self).__init__() + super().__init__() self.__doc__ = self.func.__doc__ def __repr__(self): diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index 8f584a211ef..5a65b4260f0 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -5387,7 +5387,7 @@ def _coerce_map_from_(self, M): if (self.base_ring().has_coerce_map_from(M.base_ring()) and self.rank() == M.degree()): return True - return super(FreeModule_ambient, self)._coerce_map_from_(M) + return super()._coerce_map_from_(M) def _dense_module(self): """ diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 2bae4dd2df0..93f22993eb3 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -591,8 +591,7 @@ def _iter_inner(self, i0, k): return gk = self.gen(k) for _ in range(self._gens_orders[k]): - for J in self._iter_inner(i0, k + 1): - yield J + yield from self._iter_inner(i0, k + 1) i0 = i0 * gk return diff --git a/src/sage/rings/padics/padic_extension_generic.py b/src/sage/rings/padics/padic_extension_generic.py index dc80e998bcd..59264f4f0f4 100644 --- a/src/sage/rings/padics/padic_extension_generic.py +++ b/src/sage/rings/padics/padic_extension_generic.py @@ -632,7 +632,7 @@ def free_module(self, base=None, basis=None, map=True): from_V = MapFreeModuleToTwoStep to_V = MapTwoStepToFreeModule elif base is self: - return super(pAdicExtensionGeneric, self).free_module(base=base, basis=basis, map=map) + return super().free_module(base=base, basis=basis, map=map) else: raise NotImplementedError FromV = Hom(V, self) diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index bf5599f7c59..44156a85075 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -483,7 +483,7 @@ def _coerce_map_from_(self, R): from sage.rings.padics.qadic_flint_FP import pAdicCoercion_FP_frac_field return pAdicCoercion_FP_frac_field(R, self) - return super(UnramifiedExtensionFieldFloatingPoint, self)._coerce_map_from_(R) + return super()._coerce_map_from_(R) class EisensteinExtensionRingCappedRelative(EisensteinExtensionGeneric, pAdicCappedRelativeRingGeneric): """ diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index 90e9d205ac5..ec85d00c3f2 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -1428,7 +1428,7 @@ def extensions(self, ring): G = ring.relative_polynomial() approximant = self._base_valuation.change_domain(G.parent())._initial_approximation return [pAdicValuation(ring, approximant)] - return super(pAdicFromLimitValuation, self).extensions(ring) + return super().extensions(ring) def _fraction_field(ring): r""" diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index c0f3fb20fdf..1bc872ad93b 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2325,7 +2325,7 @@ def __call__(self, x): reprs = self.representatives() except NotImplementedError: # Singular does not support the base field try: - return super(SchemeMorphism_polynomial_projective_subscheme_field, self).__call__(x) + return super().__call__(x) except ValueError: raise ValueError('cannot apply the morphism to this point') diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 8970637882d..0ccfbcd65b9 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -1513,4 +1513,4 @@ def local_height_arch(self, i, prec=None): sage: X.local_height_arch(1) 4.61512051684126 """ - return self.Chow_form().local_height_arch(i, prec) \ No newline at end of file + return self.Chow_form().local_height_arch(i, prec) diff --git a/src/sage/sets/family.py b/src/sage/sets/family.py index 6c007a96835..f3c3d0a7556 100644 --- a/src/sage/sets/family.py +++ b/src/sage/sets/family.py @@ -1508,8 +1508,7 @@ def __iter__(self): sage: [i for i in f] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] """ - for i in self.enumset: - yield i + yield from self.enumset def __getitem__(self, i): """ diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py index a6a746e9aca..2ac71e73dbf 100644 --- a/src/sage/sets/set.py +++ b/src/sage/sets/set.py @@ -1467,10 +1467,8 @@ def __iter__(self): sage: [x for x in Set(GF(3)).union(Set(GF(2)))] [0, 1, 2, 0, 1] """ - for x in self._X: - yield x - for y in self._Y: - yield y + yield from self._X + yield from self._Y def __contains__(self, x): """ diff --git a/src/sage/tensor/modules/finite_rank_free_module.py b/src/sage/tensor/modules/finite_rank_free_module.py index d868c50b109..d8d8686eeae 100644 --- a/src/sage/tensor/modules/finite_rank_free_module.py +++ b/src/sage/tensor/modules/finite_rank_free_module.py @@ -1210,7 +1210,7 @@ def __classcall_private__(cls, ring, rank, name=None, latex_name=None, start_ind category = Modules(ring).FiniteDimensional().or_subcategory(category) if latex_name is None: latex_name = name - return super(FiniteRankFreeModule, cls).__classcall__( + return super().__classcall__( cls, ring, rank, name, latex_name, start_index, output_formatter, category, ambient) def __init__( diff --git a/src/sage/tensor/modules/free_module_basis.py b/src/sage/tensor/modules/free_module_basis.py index 7fb776621b9..e44276a4317 100644 --- a/src/sage/tensor/modules/free_module_basis.py +++ b/src/sage/tensor/modules/free_module_basis.py @@ -700,7 +700,7 @@ def __classcall_private__(cls, fmodule, symbol, latex_symbol=None, symbol_dual = tuple(symbol_dual) if isinstance(latex_symbol_dual, list): latex_symbol_dual = tuple(latex_symbol_dual) - return super(FreeModuleBasis, cls).__classcall__(cls, fmodule, symbol, + return super().__classcall__(cls, fmodule, symbol, latex_symbol=latex_symbol, indices=indices, latex_indices=latex_indices, diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index e3b8f9a853c..8ca615e3488 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1394,8 +1394,7 @@ def face_iterator(self, increasing=True): if not increasing: dim_index = reversed(dim_index) for i in dim_index: - for F in Fs[i]: - yield F + yield from Fs[i] cells = faces From 233dd9dfe90b8e7eb0728e77e7aab6d4e89590d2 Mon Sep 17 00:00:00 2001 From: ymusleh Date: Sun, 15 Oct 2023 20:29:21 -0400 Subject: [PATCH 120/494] removed 'gekeler' algorithm --- .../finite_drinfeld_module.py | 93 +------------------ 1 file changed, 1 insertion(+), 92 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 7b18d2bc1d2..6e09538aa91 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -330,10 +330,7 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): By default, this method uses the so-called *crystalline* algorithm which computes the characteristic polynomial of the Frobenius acting on the crystalline cohomology of the Drinfeld - module. For further details, see [Ang1997]_. Currently, the only - alternative is to use the *Gekeler* approach based on solving - the linear system given by `t^{nr} + \sum_{i=0}^{r-1} - \phi_{A_{i}}t^{ni} = 0`. For more details, see [Gek2008]_. + module. For further details, see [Ang1997]_. """ # Throw an error if the user asks for an unimplemented algorithm # even if the char poly has already been computed @@ -412,94 +409,6 @@ def _frobenius_charpoly_crystalline(self, var): coeffs_A = [A([x.in_base() for x in coeff]) for coeff in charpoly_K] return PolynomialRing(A, name=var)(coeffs_A) - def _frobenius_charpoly_gekeler(self, var): - r""" - Return the characteristic polynomial of the Frobenius - endomorphism using Gekeler's algorithm. - - The algorithm works for Drinfeld `\mathbb{F}_q[T]`-modules of - any rank, provided that the constant coefficient is a generator - of the base field. - - This method is private and should not be directly called. - Instead, use :meth:`frobenius_charpoly` with the option - `algorithm='gekeler'`. - - .. WARNING: - - This algorithm only works in the generic case when the - corresponding linear system is invertible. Notable cases - where this fails include Drinfeld modules whose minimal - polynomial is not equal to the characteristic polynomial, - and rank 2 Drinfeld modules where the degree 1 coefficient - of `\phi_T` is 0. In that case, an exception is raised. - - INPUT: - - - ``var`` -- the name of the second variable - - OUTPUT: a univariate polynomial with coefficients in the - function ring - - EXAMPLES:: - - sage: Fq = GF(25) - sage: A. = Fq[] - sage: K. = Fq.extension(6) - sage: phi = DrinfeldModule(A, [z, 4, 1, z]) - sage: phi.frobenius_charpoly(algorithm='gekeler') # indirect doctest - X^3 + ((z2 + 2)*T^2 + (z2 + 2)*T + 4*z2 + 4)*X^2 + ... + (3*z2 + 2)*T^2 + (3*z2 + 3)*T + 4 - - :: - - sage: Fq = GF(125) - sage: A. = Fq[] - sage: K. = Fq.extension(2) - sage: phi = DrinfeldModule(A, [z, 0, z]) - sage: phi.frobenius_charpoly(algorithm='gekeler') # indirect doctest - Traceback (most recent call last): - NotImplementedError: 'Gekeler' algorithm failed - - ALGORITHM: - - Construct a linear system based on the requirement that the - Frobenius satisfies a degree r polynomial with coefficients in - the function ring. This generalizes the procedure from - [Gek2008]_ for the rank 2 case. - """ - K = self.base_over_constants_field() - A = self.function_ring() - r, n = self.rank(), self._base_degree_over_constants - # Compute constants that determine the block structure of the - # linear system. The system is prepared such that the solution - # vector has the form [a_0, a_1, ... a_{r-1}]^T with each a_i - # corresponding to a block of length (n*(r - i))//r + 1 - shifts = [(n*(r - i))//r + 1 for i in range(r)] - rows, cols = n*r + 1, sum(shifts) - block_shifts = [0] - for i in range(r-1): - block_shifts.append(block_shifts[-1] + shifts[i]) - # Compute the images \phi_T^i for i = 0 .. n. - gen_powers = [self(A.gen()**i).coefficients(sparse=False) - for i in range(0, n + 1)] - sys, vec = Matrix(K, rows, cols), vector(K, rows) - vec[rows - 1] = -1 - for j in range(r): - for k in range(shifts[j]): - for i in range(len(gen_powers[k])): - sys[i + n*j, block_shifts[j] + k] = gen_powers[k][i] - if sys.right_nullity() != 0: - raise NotImplementedError("'Gekeler' algorithm failed") - sol = list(sys.solve_right(vec)) - # The system is solved over L, but the coefficients should all be in Fq - # We project back into Fq here. - sol_Fq = [x.in_base() for x in sol] - char_poly = [] - for i in range(r): - char_poly.append([sol_Fq[block_shifts[i] + j] - for j in range(shifts[i])]) - return PolynomialRing(self._function_ring, name=var)(char_poly + [1]) - def frobenius_norm(self): r""" Return the Frobenius norm of the Drinfeld module. From 64f02f2a839d71e97e386b3ecfb7c89cf0229be4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 16 Oct 2023 01:40:53 +0000 Subject: [PATCH 121/494] Run incremental linux ci only when packages changed --- .github/workflows/ci-linux-incremental.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-linux-incremental.yml b/.github/workflows/ci-linux-incremental.yml index a4aa9ae99c7..5dbc25e0627 100644 --- a/.github/workflows/ci-linux-incremental.yml +++ b/.github/workflows/ci-linux-incremental.yml @@ -18,12 +18,11 @@ name: CI Linux incremental on: pull_request: types: - # Defaults - - opened - - synchronize - - reopened # When a CI label is added - labeled + paths: + - 'build/pkgs/**' + - 'pkgs/**' workflow_dispatch: concurrency: From d5b28635d8eb86e5354903ae73a476413f8785c0 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 10 Oct 2023 22:28:00 +0100 Subject: [PATCH 122/494] upgrade cypari2 to 2.1.4 use github URL for the tarball, for the time being --- build/pkgs/cypari/checksums.ini | 8 ++--- build/pkgs/cypari/package-version.txt | 2 +- .../pkgs/cypari/patches/cython3-legacy.patch | 32 ------------------- 3 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 build/pkgs/cypari/patches/cython3-legacy.patch diff --git a/build/pkgs/cypari/checksums.ini b/build/pkgs/cypari/checksums.ini index 998c8a5e962..3f87b3fabb8 100644 --- a/build/pkgs/cypari/checksums.ini +++ b/build/pkgs/cypari/checksums.ini @@ -1,5 +1,5 @@ tarball=cypari2-VERSION.tar.gz -sha1=7208fd9d0b636ca7704d3b7d1167bc7c9af2637c -md5=605b157123bd8a498d53572e8096bb8c -cksum=2809951255 -upstream_url=https://pypi.io/packages/source/c/cypari2/cypari2-VERSION.tar.gz +sha1=0af00b66e3f1b77e932ad9cade6e4e9dc6f21eaa +md5=34c919aedb0a470c8b4e4b0c0ec788e3 +cksum=2760761148 +upstream_url=https://github.com/sagemath/cypari2/releases/download/VERSION/cypari2-VERSION.tar.gz diff --git a/build/pkgs/cypari/package-version.txt b/build/pkgs/cypari/package-version.txt index ac2cdeba013..7d2ed7c7020 100644 --- a/build/pkgs/cypari/package-version.txt +++ b/build/pkgs/cypari/package-version.txt @@ -1 +1 @@ -2.1.3 +2.1.4 diff --git a/build/pkgs/cypari/patches/cython3-legacy.patch b/build/pkgs/cypari/patches/cython3-legacy.patch deleted file mode 100644 index 41392fe80d7..00000000000 --- a/build/pkgs/cypari/patches/cython3-legacy.patch +++ /dev/null @@ -1,32 +0,0 @@ -commit 8ef356a4eb936c37f55a5c501f3a955e6740c0c5 -Author: Gonzalo Tornaría -Date: Wed Jul 19 19:45:23 2023 -0300 - - cython3 support using legacy directives - -diff --git a/cypari2/gen.pyx b/cypari2/gen.pyx -index 247b1ad..75050a0 100644 ---- a/cypari2/gen.pyx -+++ b/cypari2/gen.pyx -@@ -329,7 +329,7 @@ cdef class Gen(Gen_base): - >>> pari = Pari() - >>> L = pari("vector(10,i,i^2)") - >>> L.__iter__() -- -+ <...generator object at ...> - >>> [x for x in L] - [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] - >>> list(L) -diff --git a/setup.py b/setup.py -index 2188711..455337f 100755 ---- a/setup.py -+++ b/setup.py -@@ -36,6 +36,8 @@ class build_ext(_build_ext): - "binding": True, - "cdivision": True, - "language_level": 2, -+ "legacy_implicit_noexcept": True, -+ "c_api_binop_methods": True, - } - - _build_ext.finalize_options(self) From 56be2357d9779dd3c7eef60739bb78d9c85221dd Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 17 Oct 2023 14:31:51 +0800 Subject: [PATCH 123/494] Revert changes to pr trigger --- .github/workflows/ci-linux-incremental.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-linux-incremental.yml b/.github/workflows/ci-linux-incremental.yml index 5dbc25e0627..7887597845c 100644 --- a/.github/workflows/ci-linux-incremental.yml +++ b/.github/workflows/ci-linux-incremental.yml @@ -18,6 +18,10 @@ name: CI Linux incremental on: pull_request: types: + # Defaults + - opened + - synchronize + - reopened # When a CI label is added - labeled paths: From 8015a0a63887d1141005c3bb8f054fedc7648421 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 10:27:34 -0700 Subject: [PATCH 124/494] .github/workflows/doc-build.yml: Repair display of changed output files after mathjax CDN change --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 355e07ab78e..31a6e9aecc7 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -79,7 +79,7 @@ jobs: if [ ! -f worktree-image/.gitignore ]; then cp .gitignore worktree-image/; fi (cd worktree-image && git add -A && git commit --quiet --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset --quiet old && git add -N . && git status) # Keep track of changes to built HTML - new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") + new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /;s,/sage/local/share/mathjax/mathjax/tex-chtml.js,https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js,;'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") - name: Download upstream artifact uses: actions/download-artifact@v3 From 457b6a8868354d92675c5d714e0a8dba82f48df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 18 Oct 2023 14:51:33 +0200 Subject: [PATCH 125/494] some details in pyx files in combinat --- src/sage/combinat/combinat_cython.pyx | 11 +++-- src/sage/combinat/debruijn_sequence.pyx | 31 +++++++------- src/sage/combinat/degree_sequences.pyx | 40 ++++++++++--------- src/sage/combinat/designs/designs_pyx.pyx | 6 +++ .../designs/gen_quadrangles_with_spread.pyx | 2 + .../orthogonal_arrays_find_recursive.pyx | 3 ++ src/sage/combinat/expnums.pyx | 1 + src/sage/combinat/fast_vector_partitions.pyx | 7 +++- src/sage/combinat/matrices/dancing_links.pyx | 6 +-- src/sage/combinat/partitions.pyx | 14 ++++--- .../combinat/posets/hasse_cython_flint.pyx | 4 +- .../posets/linear_extension_iterator.pyx | 11 +++-- src/sage/combinat/root_system/braid_orbit.pyx | 14 +++---- .../root_system/reflection_group_c.pyx | 29 ++++++++------ .../root_system/reflection_group_element.pyx | 33 +++++++-------- src/sage/combinat/set_partition_iterator.pyx | 3 ++ src/sage/combinat/subword_complex_c.pyx | 2 +- src/sage/combinat/words/word_char.pyx | 18 ++++----- src/sage/combinat/words/word_datatypes.pyx | 12 +++--- 19 files changed, 142 insertions(+), 105 deletions(-) diff --git a/src/sage/combinat/combinat_cython.pyx b/src/sage/combinat/combinat_cython.pyx index c0905491ac2..95ce7a6af96 100644 --- a/src/sage/combinat/combinat_cython.pyx +++ b/src/sage/combinat/combinat_cython.pyx @@ -134,6 +134,7 @@ cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k): mpz_clear(t) mpz_clear(u) + def _stirling_number2(n, k): """ Python wrapper of mpz_stirling_s2. @@ -148,8 +149,9 @@ def _stirling_number2(n, k): mpz_stirling_s2(s.value, n, k) return s + ##################################################################### -## Lyndon word iterator +# Lyndon word iterator def lyndon_word_iterator(Py_ssize_t n, Py_ssize_t k): r""" @@ -204,7 +206,8 @@ def lyndon_word_iterator(Py_ssize_t n, Py_ssize_t k): while a[i] == n - 1: i -= 1 -## Perfect matchings iterator + +# Perfect matchings iterator def perfect_matchings_iterator(Py_ssize_t n): r""" @@ -276,6 +279,7 @@ def perfect_matchings_iterator(Py_ssize_t n): sig_free(e) sig_free(f) + cdef list convert(Py_ssize_t* f, Py_ssize_t n): """ Convert a list ``f`` representing a fixed-point free involution @@ -288,8 +292,9 @@ cdef list convert(Py_ssize_t* f, Py_ssize_t n): ret.append((i, f[i])) return ret + ##################################################################### -## Set partition composition +# Set partition composition def set_partition_composition(tuple sp1, tuple sp2): r""" diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx index d98a3e66c87..d3709cf4fd2 100644 --- a/src/sage/combinat/debruijn_sequence.pyx +++ b/src/sage/combinat/debruijn_sequence.pyx @@ -57,15 +57,16 @@ AUTHOR: """ -#******************************************************************************* +# ****************************************************************************** # Copyright (C) 2011 Eviatar Bach # # Distributed under the terms of the GNU General Public License (GPL) -# http://www.gnu.org/licenses/ -#******************************************************************************* +# https://www.gnu.org/licenses/ +# ****************************************************************************** from sage.data_structures.bitset_base cimport * + def debruijn_sequence(int k, int n): """ The generating function for De Bruijn sequences. This avoids the object @@ -93,6 +94,7 @@ def debruijn_sequence(int k, int n): gen(1, 1, k, n) return sequence + cdef gen(int t, int p, k, n): """ The internal generation function. This should not be accessed by the @@ -183,6 +185,7 @@ def is_debruijn_sequence(seq, k, n): return answer + from sage.categories.finite_sets import FiniteSets from sage.structure.unique_representation import UniqueRepresentation from sage.structure.parent import Parent @@ -190,6 +193,7 @@ from sage.structure.parent import Parent from sage.rings.integer cimport Integer from sage.rings.integer_ring import ZZ + class DeBruijnSequences(UniqueRepresentation, Parent): """ Represents the De Bruijn sequences of given parameters `k` and `n`. @@ -256,35 +260,32 @@ class DeBruijnSequences(UniqueRepresentation, Parent): """ Constructor. - Checks the consistency of the given arguments. + This checks the consistency of the given arguments. TESTS: - Setting ``n`` orr ``k`` to anything under 1 will return a ValueError: - - :: + Setting ``n`` orr ``k`` to anything under 1 will return + a :class:`ValueError`:: sage: DeBruijnSequences(3, 0).an_element() Traceback (most recent call last): ... - ValueError: k and n cannot be under 1. + ValueError: k and n cannot be under 1 Setting ``n`` or ``k`` to any type except an integer will return a - TypeError: - - :: + :class:`TypeError`:: sage: DeBruijnSequences(2.5, 3).an_element() Traceback (most recent call last): ... - TypeError: k and n must be integers. + TypeError: k and n must be integers """ Parent.__init__(self, category=FiniteSets()) if n < 1 or k < 1: - raise ValueError('k and n cannot be under 1.') + raise ValueError('k and n cannot be under 1') if (not isinstance(n, (Integer, int)) or - not isinstance(k, (Integer,int))): - raise TypeError('k and n must be integers.') + not isinstance(k, (Integer, int))): + raise TypeError('k and n must be integers') self.k = k self.n = n diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx index 0ccc2377f2c..68ca4167230 100644 --- a/src/sage/combinat/degree_sequences.pyx +++ b/src/sage/combinat/degree_sequences.pyx @@ -57,9 +57,9 @@ An integer sequence need not necessarily be a degree sequence. Indeed, in a degree sequence of length `n` no integer can be larger than `n-1` -- the degree of a vertex is at most `n-1` -- and the sum of them is at most `n(n-1)`. -Degree sequences are completely characterized by a result from Erdos and Gallai: +Degree sequences are completely characterized by a result from Erdős and Gallai: -**Erdos and Gallai:** *The sequence of integers* `d_1 \geq \cdots \geq d_n` +**Erdős and Gallai:** *The sequence of integers* `d_1 \geq \cdots \geq d_n` *is a degree sequence if and only if* `\sum_i d_i` is even and `\forall i` .. MATH:: @@ -281,6 +281,7 @@ from cysignals.signals cimport sig_on, sig_off cdef unsigned char * seq cdef list sequences + class DegreeSequences: def __init__(self, n): @@ -352,13 +353,13 @@ class DegreeSequences: # Partial represents the left side of Erdos and Gallai's inequality, # i.e. the sum of the i first integers. cdef int partial = 0 - cdef int i,d,dd, right + cdef int i, d, dd, right # Temporary variable to ensure that the sequence is indeed # non-increasing - cdef int prev = n-1 + cdef int prev = n - 1 - for i,d in enumerate(seq): + for i, d in enumerate(seq): # Non-increasing ? if d > prev: @@ -372,7 +373,7 @@ class DegreeSequences: # Evaluating the right hand side right = i*(i+1) for dd in seq[i+1:]: - right += min(dd,i+1) + right += min(dd, i+1) # Comparing the two if partial > right: @@ -404,7 +405,7 @@ class DegreeSequences: sage: all(seq in DS for seq in DS) True """ - return iter( init(self._n) ) + yield from init(self._n) def __dealloc__(): """ @@ -412,6 +413,7 @@ class DegreeSequences: """ sig_free(seq) + cdef init(int n): """ Initializes the memory and starts the enumeration algorithm. @@ -432,7 +434,7 @@ cdef init(int n): N = n sequences = [] - enum(1,0) + enum(1, 0) sig_free(seq) return sequences @@ -467,7 +469,7 @@ cdef void enum(int k, int M): - ``k`` -- depth of the partial degree sequence - ``M`` -- value of a maximum element in the partial degree sequence """ - cdef int i,j + cdef int i, j global seq cdef int taken = 0 cdef int current_box @@ -491,21 +493,21 @@ cdef void enum(int k, int M): if M == 0: seq[0] += 1 - enum(k+1, M) + enum(k + 1, M) seq[0] -= 1 # We need not automatically increase the degree at each step. In this case, # we have no other choice but to link the new vertex of degree M to vertices # of degree M-1, which will become vertices of degree M too. - elif seq[M-1] >= M: + elif seq[M - 1] >= M: - seq[M] += M+1 - seq[M-1] -= M + seq[M] += M + 1 + seq[M - 1] -= M - enum(k+1, M) + enum(k + 1, M) - seq[M] -= M+1 - seq[M-1] += M + seq[M] -= M + 1 + seq[M - 1] += M ############################################### # Creating vertices of Vertices of degree > M # @@ -542,13 +544,13 @@ cdef void enum(int k, int M): seq[current_box] -= i seq[current_box+1] += i - for max(0,((M+1)-taken-i)) <= j <= n_previous_box: + for max(0, ((M+1)-taken-i)) <= j <= n_previous_box: seq[current_box-1] -= j seq[current_box] += j new_vertex = taken + i + j seq[new_vertex] += 1 - enum(k+1,new_vertex) + enum(k+1, new_vertex) seq[new_vertex] -= 1 seq[current_box-1] += j @@ -566,7 +568,7 @@ cdef void enum(int k, int M): # Now current_box = 0. All the vertices of nonzero degree are taken, we just # want to know how many vertices of degree 0 will be neighbors of the new # vertex. - for max(0,((M+1)-taken)) <= i <= seq[0]: + for max(0, ((M+1)-taken)) <= i <= seq[0]: seq[1] += i seq[0] -= i diff --git a/src/sage/combinat/designs/designs_pyx.pyx b/src/sage/combinat/designs/designs_pyx.pyx index 4b6638634f6..59b73431a18 100644 --- a/src/sage/combinat/designs/designs_pyx.pyx +++ b/src/sage/combinat/designs/designs_pyx.pyx @@ -15,6 +15,7 @@ from cysignals.memory cimport sig_malloc, sig_calloc, sig_realloc, sig_free from sage.misc.unknown import Unknown + def is_covering_array(array, strength=None, levels=None, verbose=False, parameters=False): r""" Check if the input is a covering array with given strength. @@ -349,6 +350,7 @@ def is_orthogonal_array(OA, int k, int n, int t=2, verbose=False, terminology="O bitset_free(seen) return True + def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=False): r""" Checks that input is a Group Divisible Design on `\{0,...,v-1\}` @@ -588,6 +590,7 @@ def is_pairwise_balanced_design(blocks,v,K=None,lambd=1,verbose=False): lambd=lambd, verbose=verbose) + def is_projective_plane(blocks, verbose=False): r""" Test whether the blocks form a projective plane on `\{0,...,v-1\}` @@ -661,6 +664,7 @@ def is_projective_plane(blocks, verbose=False): lambd=1, verbose=verbose) + def is_difference_matrix(M,G,k,lmbda=1,verbose=False): r""" Test if `M` is a `(G,k,\lambda)`-difference matrix. @@ -725,6 +729,7 @@ def is_difference_matrix(M,G,k,lmbda=1,verbose=False): """ return is_quasi_difference_matrix(M,G,k,lmbda=lmbda,mu=lmbda,u=0,verbose=verbose) + def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False): r""" Test if the matrix is a `(G,k;\lambda,\mu;u)`-quasi-difference matrix @@ -938,6 +943,7 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False): sig_free(M_c) return True + # Cached information for OA constructions (see .pxd file for more info) _OA_cache = sig_malloc(2*sizeof(cache_entry)) diff --git a/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx b/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx index 26da661f3cd..72baf1a5d28 100644 --- a/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx +++ b/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx @@ -123,6 +123,7 @@ def generalised_quadrangle_with_spread(const int s, const int t, raise RuntimeError( f"Sage can't build a GQ of order ({s}, {t}) with a spread") + def is_GQ_with_spread(GQ, S, s=None, t=None): r""" Check if GQ is a generalised quadrangle of order `(s,t)` and @@ -233,6 +234,7 @@ def dual_GQ_ovoid(GQ, O): D = IncidenceStructure(newBlocks) return (D, S) + def generalised_quadrangle_hermitian_with_ovoid(const int q): r""" Construct the generalised quadrangle `H(3,q^2)` with an ovoid. diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 066eecb9197..196a0d4a194 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -51,6 +51,7 @@ from .orthogonal_arrays import orthogonal_array from sage.rings.integer cimport smallInteger from sage.arith.misc import prime_powers + @cached_function def find_recursive_construction(k, n): r""" @@ -114,6 +115,7 @@ def find_recursive_construction(k, n): return res return False + cpdef find_product_decomposition(int k,int n): r""" Find `n_1n_2=n` to obtain an `OA(k,n)` by the product construction. @@ -880,6 +882,7 @@ def int_as_sum(int value, list S, int k_max): return None + cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n): r""" Find `rm+x_1+...+x_c=n` such that the Brouwer-van Rees constructions yields a `OA(k,n)`. diff --git a/src/sage/combinat/expnums.pyx b/src/sage/combinat/expnums.pyx index bff30b763d7..216850b43f1 100644 --- a/src/sage/combinat/expnums.pyx +++ b/src/sage/combinat/expnums.pyx @@ -117,6 +117,7 @@ def expnums(int n, int aa): # return bell[1]; # end); + def expnums2(n, aa): r""" A vanilla python (but compiled via Cython) implementation of diff --git a/src/sage/combinat/fast_vector_partitions.pyx b/src/sage/combinat/fast_vector_partitions.pyx index 2a1e093104b..fe937b75ee7 100644 --- a/src/sage/combinat/fast_vector_partitions.pyx +++ b/src/sage/combinat/fast_vector_partitions.pyx @@ -126,19 +126,20 @@ def recursive_within_from_to(list m, list s, list e, bint useS, bint useE): if len(m) == 1: # We use this style of Cython code for now in order to get this to convert # to an optimized pure C for loop. See Cython github issue #532. - #for x in range(start, end - 1, -1): + # for x in range(start, end - 1, -1): for x from start >= x >= end by 1: yield [x] # we know the answer for singletons else: # We use this style of Cython code for now in order to get this to convert # to an optimized pure C for loop. See Cython github issue #532. - #for x in range(start, end - 1, -1): + # for x in range(start, end - 1, -1): for x from start >= x >= end by 1: useSS = useS and x == s[0] useEE = useE and x == e[0] for o in recursive_within_from_to(m[1:], s[1:], e[1:], useSS, useEE): yield [x] + o + def within_from_to(list m, list s, list e): r""" Iterate over a lexicographically ordered list of lists ``v`` satisfying @@ -229,6 +230,7 @@ def within_from_to(list m, list s, list e): return yield from recursive_within_from_to(m, ss, e, True, True) + cdef inline list vector_sub(list a, list b): """ Return ``a - b`` considered as vectors. @@ -241,6 +243,7 @@ cdef inline list vector_sub(list a, list b): ret.append(( a[i]) - ( b[i])) return ret + def recursive_vector_partitions(list v, list vL): r""" Iterate over a lexicographically ordered list of lists, each list diff --git a/src/sage/combinat/matrices/dancing_links.pyx b/src/sage/combinat/matrices/dancing_links.pyx index df6cb7915f8..f0ecfeacd17 100644 --- a/src/sage/combinat/matrices/dancing_links.pyx +++ b/src/sage/combinat/matrices/dancing_links.pyx @@ -67,7 +67,7 @@ There is also a method ``reinitialize`` to reinitialize the algorithm:: sage: x.get_solution() [0, 1] """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2008 Carlo Hamalainen # Copyright (C) 2015-2018 Sébastien Labbé # @@ -75,8 +75,8 @@ There is also a method ``reinitialize`` to reinitialize the algorithm:: # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from cpython.object cimport PyObject_RichCompare from libcpp.vector cimport vector diff --git a/src/sage/combinat/partitions.pyx b/src/sage/combinat/partitions.pyx index c26ccdb3ddb..c461797067c 100644 --- a/src/sage/combinat/partitions.pyx +++ b/src/sage/combinat/partitions.pyx @@ -8,7 +8,7 @@ AUTHOR: that does all the actual heavy lifting. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 William Stein # Copyright (C) 2007 Jonathan Bober # @@ -16,8 +16,9 @@ AUTHOR: # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** + def ZS1_iterator(int n): """ @@ -82,9 +83,10 @@ def ZS1_iterator(int n): if t > 1: h += 1 x[h] = t - #yield [x[i] for i in range(m+1)] + # yield [x[i] for i in range(m+1)] yield x[:m+1] - #free(x) + # free(x) + def ZS1_iterator_nk(int n, int k): """ @@ -176,4 +178,4 @@ def ZS1_iterator_nk(int n, int k): h += 1 x[m] = t yield x[:m+1] - #free(x) + # free(x) diff --git a/src/sage/combinat/posets/hasse_cython_flint.pyx b/src/sage/combinat/posets/hasse_cython_flint.pyx index fcbe29faaf6..5d2c5b967ae 100644 --- a/src/sage/combinat/posets/hasse_cython_flint.pyx +++ b/src/sage/combinat/posets/hasse_cython_flint.pyx @@ -61,7 +61,7 @@ cpdef Matrix_integer_dense moebius_matrix_fast(list positions): for i in range(n): pos_lens[i] = len(positions[i]) pos_array[i] = sig_malloc(pos_lens[i]*sizeof(int)) - for jind,j in enumerate(positions[i]): + for jind, j in enumerate(positions[i]): pos_array[i][jind] = j for i in range(n - 1, -1, -1): @@ -120,7 +120,7 @@ cpdef Matrix_integer_dense coxeter_matrix_fast(list positions): for i in range(n): pos_lens[i] = len(positions[i]) pos_array[i] = sig_malloc(pos_lens[i]*sizeof(int)) - for jind,j in enumerate(positions[i]): + for jind, j in enumerate(positions[i]): pos_array[i][jind] = j for i in range(n - 1, -1, -1): diff --git a/src/sage/combinat/posets/linear_extension_iterator.pyx b/src/sage/combinat/posets/linear_extension_iterator.pyx index 5eb101b32e2..69a84cb46f0 100644 --- a/src/sage/combinat/posets/linear_extension_iterator.pyx +++ b/src/sage/combinat/posets/linear_extension_iterator.pyx @@ -5,6 +5,8 @@ Fast linear extension iterator cimport cython from copy import copy + + def _linear_extension_prepare(D): r""" The preprocessing routine in Figure 7 of "Generating Linear @@ -27,9 +29,8 @@ def _linear_extension_prepare(D): sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })._hasse_diagram sage: _linear_extension_prepare(D) ([0, 1, 2, 3, 4], [1, 3], [2, 4]) - """ - dag_copy = copy(D) # this copy is destroyed during preparation + dag_copy = copy(D) # this copy is destroyed during preparation le = [] a = [] b = [] @@ -57,6 +58,7 @@ def _linear_extension_prepare(D): return (le, a, b) + @cython.wraparound(False) @cython.boundscheck(False) cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py_ssize_t i): @@ -81,6 +83,7 @@ cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py _b[i] = a _a[i] = b + @cython.wraparound(False) @cython.boundscheck(False) cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i): @@ -109,6 +112,7 @@ cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i y = _le[yindex] return y != _b[i] and _D.are_incomparable(x, y) + @cython.wraparound(False) @cython.boundscheck(False) cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i): @@ -136,6 +140,7 @@ cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i y = _le[yindex] return _D.are_incomparable(x, y) + @cython.wraparound(False) @cython.boundscheck(False) def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssize_t i): @@ -276,7 +281,7 @@ def linear_extension_iterator(D): """ _le, _a, _b = _linear_extension_prepare(D) _max_pair = len(_a) - 1 - _is_plus = [True] # this is modified by _linear_extension_switch + _is_plus = [True] # this is modified by _linear_extension_switch yield _le[:] for e in _linear_extension_gen(D, _le, _a, _b, _is_plus, _max_pair): diff --git a/src/sage/combinat/root_system/braid_orbit.pyx b/src/sage/combinat/root_system/braid_orbit.pyx index d95bc388f83..5c605de8253 100644 --- a/src/sage/combinat/root_system/braid_orbit.pyx +++ b/src/sage/combinat/root_system/braid_orbit.pyx @@ -1,4 +1,4 @@ -#cython: wraparound=False, boundscheck=False +# cython: wraparound=False, boundscheck=False """ Braid Orbit @@ -48,11 +48,11 @@ cpdef set BraidOrbit(list word, list rels): cdef list rel l = len(word) - cdef set words = set( [tuple(word)] ) - cdef list test_words = [ tuple(word) ] + cdef set words = {tuple(word)} + cdef list test_words = [tuple(word)] - rels = rels + [ [b,a] for a,b in rels ] - rels = [ [tuple(a), tuple(b), len(a)] for a,b in rels ] + rels = rels + [[b, a] for a, b in rels] + rels = [[tuple(a), tuple(b), len(a)] for a, b in rels] loop_ind = 0 list_len = 1 @@ -101,8 +101,8 @@ cpdef bint is_fully_commutative(list word, list rels): cdef list rel l = len(word) - cdef set words = set( [tuple(word)] ) - cdef list test_words = [ tuple(word) ] + cdef set words = {tuple(word)} + cdef list test_words = [tuple(word)] rels = rels + [[b, a] for a, b in rels] rels = [[tuple(a), tuple(b), len(a)] for a, b in rels] diff --git a/src/sage/combinat/root_system/reflection_group_c.pyx b/src/sage/combinat/root_system/reflection_group_c.pyx index 247e9a62c02..6ad4f30212e 100644 --- a/src/sage/combinat/root_system/reflection_group_c.pyx +++ b/src/sage/combinat/root_system/reflection_group_c.pyx @@ -1,4 +1,4 @@ -#cython: wraparound=False, boundscheck=False +# cython: wraparound=False, boundscheck=False r""" This contains a few time-critical auxiliary cython functions for finite complex or real reflection groups. @@ -51,7 +51,7 @@ cdef class Iterator(): for i in range(n): si = S[i] noncom_i = [] - for j in range(i+1,n): + for j in range(i+1, n): sj = S[j] if si._mul_(sj) == sj._mul_(si): pass @@ -87,7 +87,7 @@ cdef class Iterator(): raise ValueError('the algorithm (="%s") must be either "depth", "breadth", or "parabolic"') self.algorithm = algorithm -# self.noncom = self.noncom_letters() + # self.noncom = self.noncom_letters() cdef list succ(self, PermutationGroupElement u, int first): cdef PermutationGroupElement si @@ -95,18 +95,18 @@ cdef class Iterator(): cdef list successors = [] cdef tuple S = self.S cdef int N = self.N -# cdef list nc = self.noncom[first] + # cdef list nc = self.noncom[first] for i in range(first): si = (S[i]) if self.test(u, si, i): - successors.append((_new_mul_(si,u), i)) - for i in range(first+1,self.n): -# for i in nc: + successors.append((_new_mul_(si, u), i)) + for i in range(first+1, self.n): + # for i in nc: if u.perm[i] < N: si = (S[i]) if self.test(u, si, i): - successors.append((_new_mul_(si,u), i)) + successors.append((_new_mul_(si, u), i)) return successors cdef list succ_words(self, PermutationGroupElement u, list word, int first): @@ -120,7 +120,7 @@ cdef class Iterator(): for i in range(first): si = (S[i]) if self.test(u, si, i): - u1 = (_new_mul_(si,u)) + u1 = (_new_mul_(si, u)) # try to use word+[i] and the reversed word_new = [i] + word u1._reduced_word = word_new @@ -129,7 +129,7 @@ cdef class Iterator(): if u.perm[i] < N: si = (S[i]) if self.test(u, si, i): - u1 = (_new_mul_(si,u)) + u1 = (_new_mul_(si, u)) word_new = [i] + word u1._reduced_word = word_new successors.append((u1, word_new, i)) @@ -375,6 +375,7 @@ cdef class Iterator(): for v in coset_reps: yield _new_mul_(w, v) + def iterator_tracking_words(W): r""" Return an iterator through the elements of ``self`` together @@ -417,7 +418,7 @@ def iterator_tracking_words(W): cdef list index_list = list(range(len(S))) cdef list level_set_cur = [(W.one(), [])] - cdef set level_set_old = set([ W.one() ]) + cdef set level_set_old = {W.one()} cdef list word cdef PermutationGroupElement x, y @@ -432,6 +433,7 @@ def iterator_tracking_words(W): level_set_new.append((y, word+[i])) level_set_cur = level_set_new + cdef inline bint has_left_descent(PermutationGroupElement w, int i, int N): return w.perm[i] >= N @@ -501,7 +503,7 @@ cpdef PermutationGroupElement reduce_in_coset(PermutationGroupElement w, tuple S w = _new_mul_(w, si) cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_small, - bint right): + bint right): cdef tuple S = tuple(W.simple_reflections()) cdef int N = W.number_of_reflections() cdef set totest = set([W.one()]) @@ -515,7 +517,7 @@ cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_sm S, parabolic_small, N, right) for i in parabolic_big]) res.update(totest) - totest = new.difference(res)#[ w for w in new if w not in res ] + totest = new.difference(res) # [w for w in new if w not in res] return list(res) cdef parabolic_recursive(PermutationGroupElement x, list v, f): @@ -558,6 +560,7 @@ def parabolic_iteration_application(W, f): parabolic_recursive(W.one(), coset_reps, f) + cpdef list reduced_word_c(W, PermutationGroupElement w): r""" Computes a reduced word for the element ``w`` in the diff --git a/src/sage/combinat/root_system/reflection_group_element.pyx b/src/sage/combinat/root_system/reflection_group_element.pyx index 8f5a61ff0a2..e8c05283167 100644 --- a/src/sage/combinat/root_system/reflection_group_element.pyx +++ b/src/sage/combinat/root_system/reflection_group_element.pyx @@ -115,7 +115,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): gens = [W.simple_reflection(j) for j in W._index_set] return _gap_factorization(self, gens) - #@cached_in_parent_method + # @cached_in_parent_method def reduced_word_in_reflections(self): r""" Return a word in the reflections to obtain ``self``. @@ -180,7 +180,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): """ return ZZ(len(self.reduced_word())) - #@cached_in_parent_method + # @cached_in_parent_method def to_matrix(self, on_space="primal"): r""" Return ``self`` as a matrix acting on the underlying vector @@ -481,7 +481,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): W = self._parent return PermutationGroupElement(self, W) - #@cached_in_parent_method + # @cached_in_parent_method def fix_space(self): r""" Return the fix space of ``self``. @@ -531,7 +531,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): I = identity_matrix(QQ, self._parent.rank()) return (self.to_matrix() - I).right_kernel() - #@cached_in_parent_method + # @cached_in_parent_method def reflection_eigenvalues(self, is_class_representative=False): r""" Return the reflection eigenvalues of ``self``. @@ -578,7 +578,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): """ return self._parent.reflection_eigenvalues(self, is_class_representative=is_class_representative) - #@cached_in_parent_method + # @cached_in_parent_method def galois_conjugates(self): r""" Return all Galois conjugates of ``self``. @@ -683,8 +683,8 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): """ rk = self._parent.rank() M = self.to_matrix().list() - m = lcm([x.conductor() if hasattr(x,"conductor") else 1 for x in M]) - cdef list M_gals = [x.galois_conjugates(m) if hasattr(x,"galois_conjugates") else [x] for x in M] + m = lcm([x.conductor() if hasattr(x, "conductor") else 1 for x in M]) + cdef list M_gals = [x.galois_conjugates(m) if hasattr(x, "galois_conjugates") else [x] for x in M] cdef list conjugates = [] cdef int i for i in range(len(M_gals[0])): @@ -808,10 +808,10 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): False """ if not isinstance(positive, bool): - raise TypeError("%s is not a boolean"%(bool)) + raise TypeError("%s is not a boolean" % (bool)) if i not in self._parent.index_set(): - raise ValueError("the given index %s is not in the index set"%i) + raise ValueError("the given index %s is not in the index set" % i) negative = not positive @@ -1049,9 +1049,8 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): (1, 1) -> (0, -1) """ if self_on_left: - return self.action(vec,side="left") - else: - return self.action(vec,side="right") + return self.action(vec, side="left") + return self.action(vec, side="right") cpdef action_on_root_indices(self, i, side="right"): """ @@ -1177,11 +1176,12 @@ def _gap_factorization(w, gens): """ from sage.interfaces.gap3 import gap3 - gap3.execute('W := GroupWithGenerators(%s)'%str(gens)) + gap3.execute('W := GroupWithGenerators(%s)' % str(gens)) gap3.execute(_gap_factorization_code) - fac = gap3('MinimalWord(W,%s)'%str(w)).sage() + fac = gap3('MinimalWord(W,%s)' % str(w)).sage() return [i-1 for i in fac] + _gap_factorization_code = r""" # MinimalWord(G,w) # given a permutation group G find some expression of minimal length in the @@ -1232,6 +1232,7 @@ MinimalWord:=function(G,w) od; end;""" + def _gap_return(S, coerce_obj='self'): r""" Return the string ``S`` after a few modifications are done. @@ -1245,6 +1246,6 @@ def _gap_return(S, coerce_obj='self'): sage: _gap_return("[ (), (1,4)(2,3)(5,6), (1,6,2)(3,5,4) ]") # optional - gap3 "[self('()',check=False),self('(1,4)(2,3)(5,6)',check=False),self('(1,6,2)(3,5,4)',check=False)]" """ - S = S.replace(' ','').replace('\n','') - S = S.replace(',(','\',check=False),%s(\'('%coerce_obj).replace('[','[%s(\''%coerce_obj).replace(']','\',check=False)]') + S = S.replace(' ', '').replace('\n', '') + S = S.replace(',(', '\',check=False),%s(\'(' % coerce_obj).replace('[', '[%s(\'' % coerce_obj).replace(']', '\',check=False)]') return S diff --git a/src/sage/combinat/set_partition_iterator.pyx b/src/sage/combinat/set_partition_iterator.pyx index fff6a71fefe..a0868e743cc 100644 --- a/src/sage/combinat/set_partition_iterator.pyx +++ b/src/sage/combinat/set_partition_iterator.pyx @@ -20,6 +20,7 @@ cdef list from_word(list w, list base_set): sp[b].append(x) return sp + @cython.wraparound(False) @cython.boundscheck(False) def set_partition_iterator(base_set): @@ -74,6 +75,7 @@ def set_partition_iterator(base_set): # H3: increase a_{n-1} a[last] += 1 + @cython.wraparound(False) @cython.boundscheck(False) def _set_partition_block_gen(Py_ssize_t n, Py_ssize_t k, list a): @@ -108,6 +110,7 @@ def _set_partition_block_gen(Py_ssize_t n, Py_ssize_t k, list a): yield P a[n-1] = n-1 + @cython.wraparound(False) @cython.boundscheck(False) def set_partition_iterator_blocks(base_set, Py_ssize_t k): diff --git a/src/sage/combinat/subword_complex_c.pyx b/src/sage/combinat/subword_complex_c.pyx index 66da5184356..3e60bcce303 100644 --- a/src/sage/combinat/subword_complex_c.pyx +++ b/src/sage/combinat/subword_complex_c.pyx @@ -57,7 +57,7 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices, if j != i: t = R[min(r, r_minus)] for k in range(min(i, j) + 1, max(i, j) + 1): - extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k],side="left") + extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k], side="left") return j cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1): diff --git a/src/sage/combinat/words/word_char.pyx b/src/sage/combinat/words/word_char.pyx index 433aae3f4db..faa9049db2f 100644 --- a/src/sage/combinat/words/word_char.pyx +++ b/src/sage/combinat/words/word_char.pyx @@ -1,15 +1,15 @@ r""" Fast word datatype using an array of unsigned char """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2014 Vincent Delecroix <20100.delecroix@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from cysignals.memory cimport check_allocarray, sig_free from cysignals.signals cimport sig_on, sig_off @@ -98,7 +98,7 @@ cdef class WordDatatype_char(WordDatatype): if data: self._set_data(data) - @cython.boundscheck(False) # assume that indexing will not cause any IndexErrors + @cython.boundscheck(False) # assume that indexing will not cause any IndexErrors @cython.wraparound(False) # not check not correctly handle negative indices cdef _set_data(self, data): r""" @@ -196,7 +196,7 @@ cdef class WordDatatype_char(WordDatatype): [1, 3, 2] """ cdef bitset_t seen - bitset_init(seen, 256) # allocation + initialization to 0 + bitset_init(seen, 256) # allocation + initialization to 0 cdef size_t i cdef list res = [] @@ -217,7 +217,7 @@ cdef class WordDatatype_char(WordDatatype): cdef type t = type(self) cdef WordDatatype_char other = t.__new__(t) other._data = data - other._master = master # can be None + other._master = master # can be None other._is_slice = 0 if master is None else 1 other._length = length other._parent = self._parent @@ -367,9 +367,9 @@ cdef class WordDatatype_char(WordDatatype): if isinstance(key, slice): # here the key is a slice PySlice_GetIndicesEx(key, - self._length, - &start, &stop, &step, - &slicelength) + self._length, + &start, &stop, &step, + &slicelength) if slicelength == 0: return self._new_c(NULL, 0, None) if step == 1: diff --git a/src/sage/combinat/words/word_datatypes.pyx b/src/sage/combinat/words/word_datatypes.pyx index 57c8079aad6..a25f09d5368 100644 --- a/src/sage/combinat/words/word_datatypes.pyx +++ b/src/sage/combinat/words/word_datatypes.pyx @@ -1,7 +1,7 @@ r""" Datatypes for finite words """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2009 Franco Saliola # Vincent Delecroix <20100.delecroix@gmail.com> # @@ -9,8 +9,8 @@ Datatypes for finite words # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from cpython.object cimport Py_EQ, Py_NE from itertools import islice @@ -20,10 +20,10 @@ cdef class WordDatatype(): r""" The generic WordDatatype class. - Any word datatype must contain two attributes (at least):: + Any word datatype must contain two attributes (at least): - - _parent - - _hash + - ``_parent`` + - ``_hash`` They are automatically defined here and it's not necessary (and forbidden) to define them anywhere else. From 7e5a6d8ea6688d397f946f83994c29d8f50c4f01 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 18 Oct 2023 20:02:22 -0700 Subject: [PATCH 126/494] .github/workflows/doc-build.yml: Do not duplicate the URL configured in sage_docbuild.conf --- .github/workflows/doc-build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index d27fab6d3d3..8ace5b09151 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -79,7 +79,15 @@ jobs: if [ ! -f worktree-image/.gitignore ]; then cp .gitignore worktree-image/; fi (cd worktree-image && git add -A && git commit --quiet --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset --quiet old && git add -N . && git status) # Keep track of changes to built HTML - new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /;s,/sage/local/share/mathjax/mathjax/tex-chtml.js,https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js,;'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") + new_version=$(cat src/VERSION.txt) + mathjax_path_from=$(SAGE_USE_CDNS=no ./sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") + mathjax_path_to=$(SAGE_USE_CDNS=yes ./sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") + (cd /sage/local/share/doc/sage/html/en && \ + find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /;s,'$mathjax_path_from,$mathjax_path_to,';'; \ + git init && \ + (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \ + (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \ + git add -A && git commit --quiet -m "old") - name: Download upstream artifact uses: actions/download-artifact@v3 From 6d7bcf92dbfea7b94a202fc173c12ef8a2b913af Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 18 Oct 2023 20:22:04 -0700 Subject: [PATCH 127/494] .github/workflows/doc-build.yml: Do not duplicate the URL configured in sage_docbuild.conf (fixup) --- .github/workflows/doc-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 5a3f69f1f2a..bb0655433f5 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -56,11 +56,11 @@ jobs: git config --global --add safe.directory $(pwd) git config --global user.email "ci-sage@example.com" git config --global user.name "Build & Test workflow" + mathjax_path_from=$(SAGE_USE_CDNS=no /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") .ci/retrofit-worktree.sh worktree-image /sage # Keep track of changes to built HTML new_version=$(cat src/VERSION.txt) - mathjax_path_from=$(SAGE_USE_CDNS=no ./sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") - mathjax_path_to=$(SAGE_USE_CDNS=yes ./sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") + mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /;s,'$mathjax_path_from,$mathjax_path_to,';'; \ git init && \ From 76c854969df957a56add5426361abf4cb7aadc61 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 18 Oct 2023 20:34:47 -0700 Subject: [PATCH 128/494] .github/workflows/doc-build.yml: Use make sagemath_doc_html-build-deps, make sagemath_doc_html-no-deps --- .github/workflows/doc-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index bb0655433f5..6588eac882d 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -85,7 +85,7 @@ jobs: id: incremental run: | # Now re-bootstrap and build. The build is incremental because we were careful with the timestamps. - ./bootstrap && make build + ./bootstrap && make sagemath_doc_html-build-deps working-directory: ./worktree-image env: MAKE: make -j2 --output-sync=recurse @@ -96,7 +96,7 @@ jobs: if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success' run: | set -ex - make sagelib-clean && git clean -fx src/sage && ./config.status && make build + make sagelib-clean && git clean -fx src/sage && ./config.status && make sagemath_doc_html-build-deps working-directory: ./worktree-image env: MAKE: make -j2 --output-sync=recurse @@ -113,7 +113,7 @@ jobs: mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git - ./config.status && make doc-html + ./config.status && make sagemath_doc_html-no-deps working-directory: ./worktree-image env: MAKE: make -j2 --output-sync=recurse From cd1a3ec7683dd64cb95d4efa167a69a4a85bd7b7 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 16:10:30 +0900 Subject: [PATCH 129/494] Remove lambdas from arguments --- src/sage/calculus/transforms/dft.py | 3 ++- src/sage/combinat/finite_state_machine.py | 3 ++- src/sage/combinat/root_system/type_A.py | 8 ++++++-- src/sage/combinat/root_system/type_A_affine.py | 8 ++++++-- .../combinat/root_system/type_A_infinity.py | 4 +++- src/sage/combinat/root_system/type_B.py | 8 ++++++-- src/sage/combinat/root_system/type_BC_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_B_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_C.py | 8 ++++++-- src/sage/combinat/root_system/type_C_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_D.py | 8 ++++++-- src/sage/combinat/root_system/type_D_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_E.py | 8 ++++++-- src/sage/combinat/root_system/type_E_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_F.py | 8 ++++++-- src/sage/combinat/root_system/type_F_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_G.py | 8 ++++++-- src/sage/combinat/root_system/type_G_affine.py | 8 ++++++-- src/sage/combinat/root_system/type_dual.py | 8 ++++++-- src/sage/combinat/root_system/type_marked.py | 8 ++++++-- src/sage/combinat/root_system/type_reducible.py | 8 ++++++-- src/sage/combinat/root_system/type_relabel.py | 8 ++++++-- src/sage/combinat/root_system/type_super_A.py | 8 ++++++-- src/sage/graphs/digraph_generators.py | 6 ++++-- src/sage/graphs/graph_generators.py | 5 ++++- src/sage/misc/sageinspect.py | 17 +++++++++++++---- 26 files changed, 148 insertions(+), 50 deletions(-) diff --git a/src/sage/calculus/transforms/dft.py b/src/sage/calculus/transforms/dft.py index b413bc0ea81..c3cc0671503 100644 --- a/src/sage/calculus/transforms/dft.py +++ b/src/sage/calculus/transforms/dft.py @@ -277,7 +277,7 @@ def plot(self): S = self.list() return line([[RR(I[i]), RR(S[i])] for i in range(len(I) - 1)]) - def dft(self, chi=lambda x: x): + def dft(self, chi=None): r""" A discrete Fourier transform "over `\QQ`" using exact `N`-th roots of unity. @@ -340,6 +340,7 @@ def dft(self, chi=lambda x: x): implemented Group (permutation, matrix), call .characters() and test if the index list is the set of conjugacy classes. """ + chi = (lambda x: x) if chi is None else chi J = self.index_object() # index set of length N N = len(J) S = self.list() diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index acd0adb2718..8397cd239cd 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -949,7 +949,7 @@ from sage.structure.sage_object import SageObject -def full_group_by(l, key=lambda x: x): +def full_group_by(l, key=None): """ Group iterable ``l`` by values of ``key``. @@ -1003,6 +1003,7 @@ def full_group_by(l, key=lambda x: x): Here, the result ``r`` has been sorted in order to guarantee a consistent order for the doctest suite. """ + key = (lambda x: x) if key is None else key elements = defaultdict(list) original_keys = {} for item in l: diff --git a/src/sage/combinat/root_system/type_A.py b/src/sage/combinat/root_system/type_A.py index 96bcec25f39..48d1474c1f4 100644 --- a/src/sage/combinat/root_system/type_A.py +++ b/src/sage/combinat/root_system/type_A.py @@ -277,7 +277,7 @@ def dynkin_diagram(self): g.add_edge(i, i+1) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -297,6 +297,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$1$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n > 1: @@ -306,7 +308,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): return ret + "".join(node((i-1)*node_dist, 0, label(i)) for i in self.index_set()) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the Dynkin diagram. @@ -332,6 +334,8 @@ def ascii_art(self, label=lambda i: i, node=None): n = self.n if n == 0: return "" + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node ret = "---".join(node(label(i)) for i in range(1,n+1)) + "\n" diff --git a/src/sage/combinat/root_system/type_A_affine.py b/src/sage/combinat/root_system/type_A_affine.py index f10d15c7f0e..5fe7bab2883 100644 --- a/src/sage/combinat/root_system/type_A_affine.py +++ b/src/sage/combinat/root_system/type_A_affine.py @@ -111,7 +111,7 @@ def dynkin_diagram(self): g.add_edge(0, n) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -128,6 +128,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (3.0 cm, 1.2 cm) circle (.25cm) node[anchor=south east]{$0$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 1: @@ -148,7 +150,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): ret += node(mid, 1.2, label(0), 'anchor=south east') return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -178,6 +180,8 @@ def ascii_art(self, label=lambda i: i, node=None): O<=>O 2 3 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n diff --git a/src/sage/combinat/root_system/type_A_infinity.py b/src/sage/combinat/root_system/type_A_infinity.py index c3a2c603266..9e0f4711ccd 100644 --- a/src/sage/combinat/root_system/type_A_infinity.py +++ b/src/sage/combinat/root_system/type_A_infinity.py @@ -86,7 +86,7 @@ def _latex_(self): """ return 'A_{{{}}}'.format(self.n._latex_()) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -100,6 +100,8 @@ def ascii_art(self, label=lambda i: i, node=None): 0 1 2 3 4 5 6 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node diff --git a/src/sage/combinat/root_system/type_B.py b/src/sage/combinat/root_system/type_B.py index 67794141adc..8e9cb6e75a5 100644 --- a/src/sage/combinat/root_system/type_B.py +++ b/src/sage/combinat/root_system/type_B.py @@ -245,7 +245,7 @@ def dynkin_diagram(self): g.set_edge_label(n-1, n, 2) return g - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the Dynkin diagram. @@ -261,6 +261,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O---O=>=O 3 4 5 6 7 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n @@ -271,7 +273,7 @@ def ascii_art(self, label=lambda i: i, node=None): ret += "".join("{!s:4}".format(label(i)) for i in range(1, n + 1)) return ret - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -307,6 +309,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= - :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram` - :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram` """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 1: diff --git a/src/sage/combinat/root_system/type_BC_affine.py b/src/sage/combinat/root_system/type_BC_affine.py index bbc261902fb..740dfa2e5f3 100644 --- a/src/sage/combinat/root_system/type_BC_affine.py +++ b/src/sage/combinat/root_system/type_BC_affine.py @@ -138,7 +138,7 @@ def _latex_(self): else: return "BC_{%s}^{(2)}" % self.n - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -180,6 +180,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 1: @@ -206,7 +208,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += "}\n" + node(0, 0, label(0)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return a ascii art representation of the extended Dynkin diagram. @@ -227,6 +229,8 @@ def ascii_art(self, label=lambda i: i, node=None): O=<=O 2 3 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n diff --git a/src/sage/combinat/root_system/type_B_affine.py b/src/sage/combinat/root_system/type_B_affine.py index 6cfe46255ae..047144f02d6 100644 --- a/src/sage/combinat/root_system/type_B_affine.py +++ b/src/sage/combinat/root_system/type_B_affine.py @@ -96,7 +96,7 @@ def dynkin_diagram(self): g.add_edge(0,2) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -130,6 +130,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 1: @@ -155,7 +157,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += node(i*node_dist, 0, label(i+1)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -184,6 +186,8 @@ def ascii_art(self, label=lambda i: i, node=None): """ n = self.n from .cartan_type import CartanType + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node if n == 1: diff --git a/src/sage/combinat/root_system/type_C.py b/src/sage/combinat/root_system/type_C.py index 57669883bea..8c7ebce3359 100644 --- a/src/sage/combinat/root_system/type_C.py +++ b/src/sage/combinat/root_system/type_C.py @@ -232,7 +232,7 @@ def dynkin_diagram(self): """ return self.dual().dynkin_diagram().dual() - def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -268,9 +268,11 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual= - :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram` - :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram` """ + if label is None: + label = lambda i: i return self.dual()._latex_dynkin_diagram(label=label, node=node, node_dist=node_dist, dual=not dual) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return a ascii art representation of the extended Dynkin diagram. @@ -289,6 +291,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O---O=<=O 3 4 5 6 7 """ + if label is None: + label = lambda i: i return self.dual().ascii_art(label=label, node=node).replace("=>=", "=<=") def _default_folded_cartan_type(self): diff --git a/src/sage/combinat/root_system/type_C_affine.py b/src/sage/combinat/root_system/type_C_affine.py index 72843b4d0a9..adaf5c77562 100644 --- a/src/sage/combinat/root_system/type_C_affine.py +++ b/src/sage/combinat/root_system/type_C_affine.py @@ -76,7 +76,7 @@ def dynkin_diagram(self): g.add_edge(0,1,2) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -117,6 +117,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 1: @@ -134,7 +136,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += "}\n" + node(0, 0, label(0)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return a ascii art representation of the extended Dynkin diagram. @@ -156,6 +158,8 @@ def ascii_art(self, label=lambda i: i, node=None): O<=>O 0 1 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n diff --git a/src/sage/combinat/root_system/type_D.py b/src/sage/combinat/root_system/type_D.py index 28d4cd29cb2..5f1469e48a8 100644 --- a/src/sage/combinat/root_system/type_D.py +++ b/src/sage/combinat/root_system/type_D.py @@ -272,7 +272,7 @@ def dynkin_diagram(self): g.add_edge(n-2, n) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -288,6 +288,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (4 cm, -0.7 cm) circle (.25cm) node[right=3pt]{$3$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n == 2: @@ -305,7 +307,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): ret += node(rt_most, -0.7, label(self.n-1), 'right=3pt') return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return a ascii art representation of the extended Dynkin diagram. @@ -336,6 +338,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O---O---O 3 4 5 6 7 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n diff --git a/src/sage/combinat/root_system/type_D_affine.py b/src/sage/combinat/root_system/type_D_affine.py index 3ea86f32438..f77204e4a01 100644 --- a/src/sage/combinat/root_system/type_D_affine.py +++ b/src/sage/combinat/root_system/type_D_affine.py @@ -111,7 +111,7 @@ def dynkin_diagram(self): g.add_edge(0,2) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -130,6 +130,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (4 cm, -0.7 cm) circle (.25cm) node[right=3pt]{$3$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node n = self.n @@ -152,7 +154,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += node(rt_most, -0.7, label(n-1), "right=3pt") return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -182,6 +184,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O 5 3 4 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node n = self.n diff --git a/src/sage/combinat/root_system/type_E.py b/src/sage/combinat/root_system/type_E.py index 478c628a5e9..5771d6d948f 100644 --- a/src/sage/combinat/root_system/type_E.py +++ b/src/sage/combinat/root_system/type_E.py @@ -573,7 +573,7 @@ def dynkin_diagram(self): g.add_edge(i, i+1) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -591,6 +591,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (4 cm, 2 cm) circle (.25cm) node[right=3pt]{$2$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % ((self.n-2)*node_dist) @@ -601,7 +603,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): ret += node(2*node_dist, node_dist, label(2), 'right=3pt') return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return a ascii art representation of the extended Dynkin diagram. @@ -626,6 +628,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O---O---O---O---O 2 4 5 6 7 8 9 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node labels = [label(i) for i in [1,3,4,5,6] + list(range(7, self.n+1))] # We exclude 2 because of the special case diff --git a/src/sage/combinat/root_system/type_E_affine.py b/src/sage/combinat/root_system/type_E_affine.py index ac64cbfbdde..3268d0603e5 100644 --- a/src/sage/combinat/root_system/type_E_affine.py +++ b/src/sage/combinat/root_system/type_E_affine.py @@ -132,7 +132,7 @@ def dynkin_diagram(self): raise ValueError("Invalid Cartan Type for Type E affine") return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -152,6 +152,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): """ n = self.n + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node @@ -181,7 +183,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): ret += node(2*node_dist, node_dist, label(2), "right=3pt") return ret - def ascii_art(self, label=lambda x: x, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -210,6 +212,8 @@ def ascii_art(self, label=lambda x: x, node=None): -2 0 1 2 3 4 5 -3 """ n = self.n + if label is None: + label = lambda x: x if node is None: node = self._ascii_art_node if n == 6: diff --git a/src/sage/combinat/root_system/type_F.py b/src/sage/combinat/root_system/type_F.py index ac33d97fbee..524dd1f7c35 100644 --- a/src/sage/combinat/root_system/type_F.py +++ b/src/sage/combinat/root_system/type_F.py @@ -290,7 +290,7 @@ def dynkin_diagram(self): g.set_edge_label(2,3,2) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -308,6 +308,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % node_dist @@ -322,7 +324,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += node(i*node_dist, 0, label(i+1)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the extended Dynkin diagram. @@ -335,6 +337,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O=>=O---O -1 0 1 2 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node ret = "{}---{}=>={}---{}\n".format(node(label(1)), node(label(2)), diff --git a/src/sage/combinat/root_system/type_F_affine.py b/src/sage/combinat/root_system/type_F_affine.py index 403c5b6e8ad..3d2dc8350ee 100644 --- a/src/sage/combinat/root_system/type_F_affine.py +++ b/src/sage/combinat/root_system/type_F_affine.py @@ -72,7 +72,7 @@ def dynkin_diagram(self): g.add_edge(0, 1) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -95,6 +95,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % node_dist @@ -103,7 +105,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += "}\n" + node(0, 0, label(0)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Returns a ascii art representation of the extended Dynkin diagram @@ -113,6 +115,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O=>=O---O 2 3 4 5 6 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node ret = "{}---{}---{}=>={}---{}\n".format(node(label(0)), node(label(1)), diff --git a/src/sage/combinat/root_system/type_G.py b/src/sage/combinat/root_system/type_G.py index 15da57bc11c..21dae3effa7 100644 --- a/src/sage/combinat/root_system/type_G.py +++ b/src/sage/combinat/root_system/type_G.py @@ -200,7 +200,7 @@ def dynkin_diagram(self): g.set_edge_label(2,1,3) return g - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -215,6 +215,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= \draw[fill=white] (2 cm, 0 cm) circle (.25cm) node[below=4pt]{$2$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node ret = "\\draw (0,0) -- (%s cm,0);\n" % node_dist @@ -228,7 +230,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual= ret += node(node_dist, 0, label(2)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the Dynkin diagram. @@ -239,6 +241,8 @@ def ascii_art(self, label=lambda i: i, node=None): O=<=O 3 4 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node ret = " 3\n{}=<={}\n".format(node(label(1)), node(label(2))) diff --git a/src/sage/combinat/root_system/type_G_affine.py b/src/sage/combinat/root_system/type_G_affine.py index 2cb1487dfd8..582f7d9ed03 100644 --- a/src/sage/combinat/root_system/type_G_affine.py +++ b/src/sage/combinat/root_system/type_G_affine.py @@ -70,7 +70,7 @@ def dynkin_diagram(self): g.add_edge(0, 2) return g - def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=False): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False): r""" Return a latex representation of the Dynkin diagram. @@ -89,6 +89,8 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual= \draw[fill=white] (4 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$}; """ + if label is None: + label = lambda x: x if node is None: node = self._latex_draw_node ret = "\\draw (%s cm,0) -- (%s cm,0);\n" % (node_dist, node_dist*2.0) @@ -98,7 +100,7 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual= ret += node(2*node_dist, 0, label(0)) return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Returns an ascii art representation of the Dynkin diagram @@ -109,6 +111,8 @@ def ascii_art(self, label=lambda i: i, node=None): O=<=O---O 3 4 2 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node ret = " 3\n{}=<={}---{}".format(node(label(1)), node(label(2)), node(label(0))) diff --git a/src/sage/combinat/root_system/type_dual.py b/src/sage/combinat/root_system/type_dual.py index c2ea5d978d3..22c4fb809d4 100644 --- a/src/sage/combinat/root_system/type_dual.py +++ b/src/sage/combinat/root_system/type_dual.py @@ -209,7 +209,7 @@ def __reduce__(self): """ return (attrcall("dual"), (self._type,)) - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" EXAMPLES:: @@ -229,11 +229,13 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): } \draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node return self._type._latex_dynkin_diagram(label, node, node_dist, dual=True) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of this Cartan type @@ -261,6 +263,8 @@ def ascii_art(self, label=lambda i: i, node=None): O=>=O---O---O=>=O 0 1 2 3 4 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node res = self._type.ascii_art(label, node) diff --git a/src/sage/combinat/root_system/type_marked.py b/src/sage/combinat/root_system/type_marked.py index 5d80ca1052a..3f76189bbc9 100644 --- a/src/sage/combinat/root_system/type_marked.py +++ b/src/sage/combinat/root_system/type_marked.py @@ -278,7 +278,7 @@ def _latex_draw_mark(self, x, y, color='black', thickness='thin'): ret += "\\draw[shift={{({}, {})}}, {}, {}] (0.25cm, -0.25cm) -- (-0.25cm, 0.25cm);\n".format(x, y, color, thickness) return ret - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=label, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -296,11 +296,13 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$}; """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node return self._type._latex_dynkin_diagram(label, node, node_dist) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of this Cartan type. @@ -320,6 +322,8 @@ def ascii_art(self, label=lambda i: i, node=None): X---O---X=>=O---O 0 1 2 3 4 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node return self._type.ascii_art(label, node) diff --git a/src/sage/combinat/root_system/type_reducible.py b/src/sage/combinat/root_system/type_reducible.py index 0f84b3f3b90..46cdccd2ab4 100644 --- a/src/sage/combinat/root_system/type_reducible.py +++ b/src/sage/combinat/root_system/type_reducible.py @@ -308,7 +308,7 @@ def dynkin_diagram(self): g.add_edge(relabelling[i,e1], relabelling[i,e2], label=l) return g - def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -332,6 +332,8 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2): \draw[fill=white] (2 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$}; } """ + if label is None: + label = lambda x: x types = self.component_types() relabelling = self._index_relabelling ret = "{\n" @@ -341,7 +343,7 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2): ret += "}" return ret - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of this reducible Cartan type. @@ -367,6 +369,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O=<=O 11 12 13 """ + if label is None: + label = lambda i: i types = self.component_types() relabelling = self._index_relabelling return "\n".join(types[i].ascii_art(lambda x: label(relabelling[i,x]), node) diff --git a/src/sage/combinat/root_system/type_relabel.py b/src/sage/combinat/root_system/type_relabel.py index 142ddeffa45..1cc633dc16c 100644 --- a/src/sage/combinat/root_system/type_relabel.py +++ b/src/sage/combinat/root_system/type_relabel.py @@ -271,7 +271,7 @@ def _latex_(self): ret += " \\text{ relabelled by } " + latex(self._relabelling) return ret - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -285,9 +285,11 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$2$}; """ + if label is None: + label = lambda i: i return self._type._latex_dynkin_diagram(lambda i: label(self._relabelling[i]), node, node_dist) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of this Cartan type. @@ -307,6 +309,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O=>=O---O 4 3 2 1 0 """ + if label is None: + label = lambda i: i if node is None: node = self._ascii_art_node return self._type.ascii_art(lambda i: label(self._relabelling[i]), node) diff --git a/src/sage/combinat/root_system/type_super_A.py b/src/sage/combinat/root_system/type_super_A.py index dedc56b9011..c2717a572ff 100644 --- a/src/sage/combinat/root_system/type_super_A.py +++ b/src/sage/combinat/root_system/type_super_A.py @@ -737,7 +737,7 @@ def _latex_draw_node(self, x, y, label, position="below=4pt"): x+.17, y-.17, x-.17, y+.17) return ret - def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. @@ -775,6 +775,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): \draw[-,thick] (0.17 cm, 0.17 cm) -- (-0.17 cm, -0.17 cm); \draw[-,thick] (0.17 cm, -0.17 cm) -- (-0.17 cm, 0.17 cm); """ + if label is None: + label = lambda i: i if node is None: node = self._latex_draw_node if self.n + self.m > 1: @@ -784,7 +786,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2): return ret + "".join(node((self.m+i)*node_dist, 0, label(i)) for i in self.index_set()) - def ascii_art(self, label=lambda i: i, node=None): + def ascii_art(self, label=None, node=None): """ Return an ascii art representation of the Dynkin diagram. @@ -812,6 +814,8 @@ def ascii_art(self, label=lambda i: i, node=None): O---O---O---O---O---X -5 -4 -3 -2 -1 0 """ + if label is None: + label = lambda i: i if node is None: node = lambda i: 'O' ret = "---".join(node(label(i)) for i in range(1,self.m+1)) diff --git a/src/sage/graphs/digraph_generators.py b/src/sage/graphs/digraph_generators.py index ec2f608e28c..2b29e0e73ef 100644 --- a/src/sage/graphs/digraph_generators.py +++ b/src/sage/graphs/digraph_generators.py @@ -1331,7 +1331,7 @@ def RandomDirectedAcyclicGraph(self, n, p, weight_max=None): return D - def RandomDirectedGN(self, n, kernel=lambda x: x, seed=None): + def RandomDirectedGN(self, n, kernel=None, seed=None): r""" Return a random growing network (GN) digraph with `n` vertices. @@ -1346,7 +1346,7 @@ def RandomDirectedGN(self, n, kernel=lambda x: x, seed=None): - ``n`` -- integer; number of vertices - - ``kernel`` -- the attachment kernel + - ``kernel`` -- the attachment kernel (default: identity function) - ``seed`` -- a ``random.Random`` seed or a Python ``int`` for the random number generator (default: ``None``) @@ -1365,6 +1365,8 @@ def RandomDirectedGN(self, n, kernel=lambda x: x, seed=None): True sage: D.show() # long time """ + if kernel is None: + kernel = lambda x: x if seed is None: seed = int(current_randstate().long_seed() % sys.maxsize) import networkx diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py index e45371bc6d9..e7347c4a2c4 100644 --- a/src/sage/graphs/graph_generators.py +++ b/src/sage/graphs/graph_generators.py @@ -1192,7 +1192,7 @@ def nauty_genbg(self, options="", debug=False): G = BipartiteGraph(s[:-1], format='graph6', partition=partition) yield G - def cospectral_graphs(self, vertices, matrix_function=lambda g: g.adjacency_matrix(), graphs=None): + def cospectral_graphs(self, vertices, matrix_function=None, graphs=None): r""" Find all sets of graphs on ``vertices`` vertices (with possible restrictions) which are cospectral with respect to a @@ -1288,6 +1288,9 @@ def cospectral_graphs(self, vertices, matrix_function=lambda g: g.adjacency_matr ....: == g[0][1].laplacian_matrix(normalized=True).charpoly()) True """ + if matrix_function is None: + matrix_function = lambda g: g.adjacency_matrix() + from sage.graphs.graph_generators import graphs as graph_gen if graphs is None: graph_list = graph_gen(vertices, property=lambda _: True) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index f0545be7d81..63cdb3115eb 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1810,10 +1810,10 @@ def formatannotation(annotation, base_module=None): def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults=None, annotations={}, formatarg=str, - formatvarargs=lambda name: '*' + name, - formatvarkw=lambda name: '**' + name, - formatvalue=lambda value: '=' + repr(value), - formatreturns=lambda text: ' -> ' + text, + formatvarargs=None, + formatvarkw=None, + formatvalue=None, + formatreturns=None, formatannotation=formatannotation): """ Format an argument spec from the values returned by getfullargspec. @@ -1843,6 +1843,15 @@ def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, sage: sage_formatargspec(args, defaults=defaults) '(a, b, c=3)' """ + if formatvarargs is None: + formatvarargs = lambda name: '*' + name + if formatvarkw is None: + formatvarkw = lambda name: '**' + name + if formatvalue is None: + formatvalue = lambda value: '=' + repr(value) + if formatreturns is None: + formatreturns = lambda text: ' -> ' + text + def formatargandannotation(arg): result = formatarg(arg) if arg in annotations: From 83bfcdb48856a9259f74c53f7fd32be27462c616 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 19 Oct 2023 11:03:58 +0000 Subject: [PATCH 130/494] Loosen version requirement on fpylll and align its conda version --- build/pkgs/fpylll/distros/conda.txt | 2 +- build/pkgs/fpylll/install-requires.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/fpylll/distros/conda.txt b/build/pkgs/fpylll/distros/conda.txt index 8a3e3a7ecd0..aa483930c7a 100644 --- a/build/pkgs/fpylll/distros/conda.txt +++ b/build/pkgs/fpylll/distros/conda.txt @@ -1 +1 @@ -fpylll +fpylll>=0.5.9 diff --git a/build/pkgs/fpylll/install-requires.txt b/build/pkgs/fpylll/install-requires.txt index c97d0c2c71e..e040e7daa1e 100644 --- a/build/pkgs/fpylll/install-requires.txt +++ b/build/pkgs/fpylll/install-requires.txt @@ -1 +1 @@ -fpylll >=0.5.9, <=0.5.9 +fpylll >=0.5.9 From 31f4fa60755087e9ae62d0ee4ef490caf7c2bfe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 19 Oct 2023 13:31:16 +0200 Subject: [PATCH 131/494] suggested details --- src/sage/combinat/debruijn_sequence.pyx | 2 +- src/sage/combinat/degree_sequences.pyx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx index d3709cf4fd2..02e224283c2 100644 --- a/src/sage/combinat/debruijn_sequence.pyx +++ b/src/sage/combinat/debruijn_sequence.pyx @@ -264,7 +264,7 @@ class DeBruijnSequences(UniqueRepresentation, Parent): TESTS: - Setting ``n`` orr ``k`` to anything under 1 will return + Setting ``n`` or ``k`` to anything under 1 will return a :class:`ValueError`:: sage: DeBruijnSequences(3, 0).an_element() diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx index 68ca4167230..63d41b9e5d4 100644 --- a/src/sage/combinat/degree_sequences.pyx +++ b/src/sage/combinat/degree_sequences.pyx @@ -308,16 +308,16 @@ class DegreeSequences: sage: DegreeSequences(-1) Traceback (most recent call last): ... - ValueError: The input parameter must be >= 0. + ValueError: the input parameter must be >= 0 """ if n < 0: - raise ValueError("The input parameter must be >= 0.") + raise ValueError("the input parameter must be >= 0") self._n = n def __contains__(self, seq): """ - Checks whether a given integer sequence is the degree sequence - of a graph on `n` elements + Check whether a given integer sequence is the degree sequence + of a graph on `n` elements. EXAMPLES:: @@ -343,7 +343,7 @@ class DegreeSequences: [[0]] """ cdef int n = self._n - if len(seq)!=n: + if len(seq) != n: return False # Is the sum even ? @@ -371,9 +371,9 @@ class DegreeSequences: partial += d # Evaluating the right hand side - right = i*(i+1) - for dd in seq[i+1:]: - right += min(dd, i+1) + right = i * (i + 1) + for dd in seq[i + 1:]: + right += min(dd, i + 1) # Comparing the two if partial > right: From 0baa6dee9e859128e947b823a3d49cf969b9488d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 21:59:43 +0900 Subject: [PATCH 132/494] Improve doc-build.yml --- .github/workflows/doc-build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 6588eac882d..53c6cbe9bdb 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -62,7 +62,9 @@ jobs: new_version=$(cat src/VERSION.txt) mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") (cd /sage/local/share/doc/sage/html/en && \ - find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /;s,'$mathjax_path_from,$mathjax_path_to,';'; \ + find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '$new_version' /' \ + -e 's_'"$mathjax_path_from"'_'"$mathjax_path_to"'_' \ + -e '\__ d' && \ git init && \ (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \ (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \ @@ -125,12 +127,16 @@ jobs: run: | set -ex mkdir -p ./docs + (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') # Create changelog echo '## Preview of CHANGES.html' + (cd /sage/local/share/doc/sage/html/en && \ + find . -name "*.html" | xargs sed -i -e '\__ d' ) (cd /sage/local/share/doc/sage/html/en && git diff --name-only) | tee ./docs/CHANGES.txt (cd /sage/local/share/doc/sage/html/en && git diff; rm -rf .git) > ./docs/html.diff echo '## Preview of html.diff'; head -n 400 ./docs/html.diff (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html + (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them From c1d67045bbb14dd2033ce233ded2a7571c40e88c Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 22:24:56 +0900 Subject: [PATCH 133/494] Add back comma --- src/sage/calculus/transforms/dft.py | 3 ++- src/sage/combinat/finite_state_machine.py | 3 ++- src/sage/combinat/root_system/type_A_affine.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sage/calculus/transforms/dft.py b/src/sage/calculus/transforms/dft.py index c3cc0671503..1b165fa6503 100644 --- a/src/sage/calculus/transforms/dft.py +++ b/src/sage/calculus/transforms/dft.py @@ -340,7 +340,8 @@ def dft(self, chi=None): implemented Group (permutation, matrix), call .characters() and test if the index list is the set of conjugacy classes. """ - chi = (lambda x: x) if chi is None else chi + if chi is None: + chi = lambda x: x J = self.index_object() # index set of length N N = len(J) S = self.list() diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 8397cd239cd..045a5de379c 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -1003,7 +1003,8 @@ def full_group_by(l, key=None): Here, the result ``r`` has been sorted in order to guarantee a consistent order for the doctest suite. """ - key = (lambda x: x) if key is None else key + if key is None: + key = lambda x: x elements = defaultdict(list) original_keys = {} for item in l: diff --git a/src/sage/combinat/root_system/type_A_affine.py b/src/sage/combinat/root_system/type_A_affine.py index 5fe7bab2883..57ed18afd01 100644 --- a/src/sage/combinat/root_system/type_A_affine.py +++ b/src/sage/combinat/root_system/type_A_affine.py @@ -111,7 +111,7 @@ def dynkin_diagram(self): g.add_edge(0, n) return g - def _latex_dynkin_diagram(self, label=None node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. From 3af722eb5adb2e50ab3732adbfbc8a141e80e44b Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:36 +0200 Subject: [PATCH 134/494] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 533e7ac54c7..495365af6eb 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ below](#sagemath-docker-images)) or other virtualization solutions. If your Mac uses the Apple Silicon (M1, M2, arm64) architecture: -- If you set up your Mac by transfering files from an older Mac, make sure +- If you set up your Mac by transferring files from an older Mac, make sure that the directory ``/usr/local`` does not contain an old copy of Homebrew (or other software) for the x86_64 architecture that you may have copied over. Note that Homebrew for the M1 is installed in ``/opt/homebrew``, not From ac154e5241e0125ded5ed7d459b3e01518d62e08 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:39 +0200 Subject: [PATCH 135/494] Update faq-contribute.rst --- src/doc/it/faq/faq-contribute.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/it/faq/faq-contribute.rst b/src/doc/it/faq/faq-contribute.rst index 0acda9b03da..63c67a8e264 100644 --- a/src/doc/it/faq/faq-contribute.rst +++ b/src/doc/it/faq/faq-contribute.rst @@ -21,7 +21,7 @@ Voglio contribuire a Sage. Da dove inizio? Dai un'occhiata alla `guida ufficiale per lo sviluppo `_ di Sage. Come minimo, la lettura del primo capitolo è richiesta per ogni -svilluppatore di Sage. Inoltre sii molto attento alle +sviluppatore di Sage. Inoltre sii molto attento alle `linee guida per trac `_. Puoi entrare nella lista email `sage-devel `_. @@ -29,7 +29,7 @@ Mentre inizi a conoscere la comunità prendi una copia del codice sorgente di Sa e familiarizza con `git `_, un software per il controllo versione. -Il migiol mode per diventare familiare con il processo di sviluppo di Sage +Il miglior modo per diventare familiare con il processo di sviluppo di Sage è quello di scegliere un ticket dal `server trac `_ ed esaminare i cambiamenti proposti in quel ticket. @@ -70,11 +70,11 @@ di Steven F. Lott è adatto a chiunque sia già a suo agio nel programmare. Se desideri, puoi iniziare a imparare Python usando Sage. Tuttavia, è utile sapere cosa è semplice Python e quando Sage sta usando la -sua "magia". Ci sono molte cose che funzionano in Phyton, ma non in Sage e +sua "magia". Ci sono molte cose che funzionano in Python, ma non in Sage e vice versa. Per di più anche quando la sintassi è identica, molti concetti di programmazione sono spiegati più dettagliatamente in risorse focalizzate su Python piuttosto che in risorse centrate su Sage; in quest'ultime, -la prioirità viene data alla matematica. +la priorità viene data alla matematica. Non sono un programmatore. C'è qualche altro modo in cui posso aiutare? """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -158,7 +158,7 @@ Consulta anche la Guida dello Sviluppo Sage, specialmente il capitolo `Convenzioni per scrivere codice sorgente in Sage `_. -Ho inviato al server trac una correzione molte settimane fa. Perchè la state ignorando? +Ho inviato al server trac una correzione molte settimane fa. Perché la state ignorando? """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Non stiamo cercando di ignorare la tua correzione. @@ -190,7 +190,7 @@ Se la tua correzione non ha la possibilità di essere aggiunta nell'albero dei sorgenti di Sage, non la ignoreremo ma semplicemente chiuderemo il ticket relativo con una spiegazione sul perché non possiamo includerla. -Come e quando posso ricordardare alla comunità di Sage una correzione a cui tengo? +Come e quando posso ricordare alla comunità di Sage una correzione a cui tengo? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Ti suggeriamo di fare uno sforzo ulteriore sul come ricordare alla comunità di @@ -221,7 +221,7 @@ preparser di Sage) e la necessità di importare quello che ti serve. primalità e la fattorizzazione. - Dovresti anche notare che ``2 / 3`` non significa più ``Integer(2) / Integer(3)`` che restituisce ``2/3``, ma invece - ``int(2) / int(3)``, e pertanto restituisce ``0`` poichè la divisione è + ``int(2) / int(3)``, e pertanto restituisce ``0`` poiché la divisione è intera e trascura il resto. Se stai lavorando con i tipi ``Integer`` ma in realtà hai bisogno di eseguire una divisione intera puoi usare ``Integer(2) // Integer(3)``. From 1ebf0976da02a20b9761c09842ca9d4236850747 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:43 +0200 Subject: [PATCH 136/494] Update faq-general.rst --- src/doc/it/faq/faq-general.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/it/faq/faq-general.rst b/src/doc/it/faq/faq-general.rst index 39ae0070bf9..85ea1c1ad38 100644 --- a/src/doc/it/faq/faq-general.rst +++ b/src/doc/it/faq/faq-general.rst @@ -13,13 +13,13 @@ La missione fissata per Sage è di essere un'alternativa open-source a Magma, Maple, Mathematica e Matlab. I predecessori di Sage, noti come HECKE e Manin, furono creati perché William Stein ebbe bisogno di scriverli come parte della sua ricerca sulla Teoria dei Numeri. Iniziato da William nel 2005 quando era -all'università di Harvard, Sage combina alcuni fra i miglori software open-source -per la matematica in un'unica intefaccia comune. +all'università di Harvard, Sage combina alcuni fra i migliori software open-source +per la matematica in un'unica interfaccia comune. Da allora Sage viene utilizzato non solo da ricercatori nel campo della Teoria dei Numeri, ma da ricercatori in tutte le scienze matematiche. Sage si avvale ed estende le funzionalità di molti dei pacchetti inglobati. -Anche dal principio, quando Sage veiniva usato principalmente per la Teoria dei +Anche dal principio, quando Sage veniva usato principalmente per la Teoria dei Numeri, includeva: `Givaro `_, `GMP `_, @@ -30,7 +30,7 @@ professori universitari, ricercatori di tutto il mondo usano Sage perché voglio un pacchetto open-source comprensivo per la matematica che offra calcolo sia simbolico che numerico. Perlopiù le persone sono contente di quanto offre Sage. -Com'é comune nell'ambito del software open-source (FOSS), spesso ci sono persone +Come é comune nell'ambito del software open-source (FOSS), spesso ci sono persone che individuano casi in cui Sage non dispone delle funzionalità richiesta da loro. Quindi si immergono nel codice sorgente di Sage per estenderlo per il loro scopo, o ancora per esporre delle funzionalità dei pacchetti inglobati in Sage in modo @@ -73,7 +73,7 @@ all'opera gratuita di una grande squadra internazionale di studenti, insegnanti, professori universitari, ricercatori, ingegneri informatici e persone che lavorano in vari ambiti della matematica, delle scienze, dell'ingegneria, dello sviluppo software e a tutti i livelli della scuola. Lo sviluppo di Sage ha potuto -usufruire di fondi asegnati da numerose istituzioni e ha potuto includere sia +usufruire di fondi assegnati da numerose istituzioni e ha potuto includere sia componenti preesistenti che in corso di sviluppo da parte di numerosi autori. Una lista di coloro che hanno dato un contributo diretto è reperibile al link @@ -144,7 +144,7 @@ ed in particolare nella seguente citazione:: I computer non sono una minaccia per i matematici più di quanto i robot da cucina lo siano per i cuochi. Poiché la matematica diviene sempre più complessa - mentre il ritmo delle nostre vite accellera, dobbiamo delegare il più possibile + mentre il ritmo delle nostre vite accelera, dobbiamo delegare il più possibile alle macchine. Ed intendo sia il lavoro in campo numerico che in quello simbolico. Alcune persone possono andare avanti senza lavastoviglie, ma penso che le dimostrazioni vengano fuori molto più pulite quando il lavoro di @@ -153,7 +153,7 @@ ed in particolare nella seguente citazione:: Questo porta con sè parecchie questioni. Non sono un esperto ma penso che abbiamo bisogno di uno standard a livello di calcolo simbolico per rendere le manipolazioni al computer più facili da documentare e verificare. Con tutto il - rispetto per il libero mercato, forse in questo non dobbiam essere dipendenti + rispetto per il libero mercato, forse in questo non dobbiamo essere dipendenti da un software commerciale. Un progetto open-source potrebbe, forse, trovare risposte migliori a problemi ovvi come la disponibilità, i bug, la compatibilità all'indietro, l'indipendenza dalla piattaforma, le librerie From e80d1eb897eb34617ae52ce0e6d06ad67b0312ee Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:46 +0200 Subject: [PATCH 137/494] Update faq-usage.rst --- src/doc/it/faq/faq-usage.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/doc/it/faq/faq-usage.rst b/src/doc/it/faq/faq-usage.rst index 13a2e0b7e5a..a13048eb71d 100644 --- a/src/doc/it/faq/faq-usage.rst +++ b/src/doc/it/faq/faq-usage.rst @@ -31,7 +31,7 @@ vai al link http://www.sagemath.org/download-source.html per scaricare l'archivio TAR di qualunque rilascio di Sage. Le sessioni di lavoro Notebook di Sage sono eseguite all'interno di -un browser web. Puoi lancianer il Notebook di sage attraverso il +un browser web. Puoi lanciare il Notebook di sage attraverso il seguente comando purché ``sage`` sia nella variabile ``PATH`` .. CODE-BLOCK:: shell-session @@ -45,7 +45,7 @@ Quali sono i prerequisiti di Sage? La maggior parte delle dipendenze sono incluse all'interno di Sage. Nella maggior parte dei casi puoi scaricare il binario precompilato ed usarlo senza dover installare alcun pacchetto dipendente. Se usi -Windows avrai bisogno di intallare +Windows avrai bisogno di installare `VirtualBox `_, che puoi scaricare dal link http://www.virtualbox.org/wiki/Downloads. Dopo aver installato VirtualBox devi scaricare una distribuzione di @@ -68,7 +68,7 @@ questi prerequisiti come segue:: sudo apt-get install build-essential m4 Se hai un sistema multiprocessore puoi scegliere una -copilazione parallela di Sage. Il comando :: +compilazione parallela di Sage. Il comando :: export MAKE='make -j8' @@ -87,7 +87,7 @@ Tcl/Tk. Su Ubuntu lancia, da riga di comando:: sudo apt-get install tk8.5-dev -o qualcosa di simile. Poi reinstalla l'iterprete Python di Sage con:: +o qualcosa di simile. Poi reinstalla l'interprete Python di Sage con:: sage -f python @@ -128,7 +128,7 @@ Puoi poi lanciare tale script Sage in questo modo:: sage /path/to/my/script.sage -Questo si occuperà di caricare le variabili d'ambiente necesssarie +Questo si occuperà di caricare le variabili d'ambiente necessarie ed eseguire gli import di default al posto tuo. @@ -189,7 +189,7 @@ o qualunque fallimento nei doctest. Le funzionalità di base di Sage dovrebbero risultare facili da imparare quanto le basi di Python. Molti tutorial sono disponibili in rete per aiutarti ad imparare Sage. Per trarre il massimo da Sage -ti consigliamo di impararare qualche elemento del linguaggio Python. +ti consigliamo di imparare qualche elemento del linguaggio Python. Segue una lista, incompleta, di risorse su Python. Altre risorse possono essere trovate cercando sul web. @@ -270,7 +270,7 @@ successiva nell'elenco. Questa funzionalità ti permette di recuperare dalla "history" tante righe consecutive quante vuoi. Ma Sage non ha una funzionalità simile: la riga di comando `IPython `_ utilizza la libreria "readline" -(via pyreadline), che evidentemente non supporta questa funzionalit. +(via pyreadline), che evidentemente non supporta questa funzionalità. Magma ha una sua propria libreria personalizzata simile alla "readline" che invece supporta questa funzionalità. (Dal momento che moltissime persone hanno richiesto questa @@ -292,7 +292,7 @@ anello base, come puoi vedere facendo:: sage: preparse("stats.uniform(0,15).ppf([0.5,0.7])") "stats.uniform(Integer(0),Integer(15)).ppf([RealNumber('0.5'),RealNumber('0.7')])" -Sfortunamente il supporto che NumPy fornisce a questi tipi avanzati di +Sfortunatamente il supporto che NumPy fornisce a questi tipi avanzati di Sage, quali ``Integer`` o ``RealNumber`` (numeri reali di precisione arbitraria), non è del 100%. Per risolvere ridefinisci ``Integer`` e/o ``RealNumber`` per cambiare @@ -475,7 +475,7 @@ La visualizzazione 3D in tempo reale per Sage dalla versione 6.4 in avanti usa il pacchetto `Jmol/JSmol `_. Dalla linea di comando viene utilizzata l'applicazione Java Jmol, mentre per la visualizzazione dal browser viene usato puro javascript -oppura una Java applet. In genere nei browser è usato javascript puro +oppure una Java applet. In genere nei browser è usato javascript puro per evitare problemi con quei browser che non supportano i plugin per le applet Java (ad esempio Chrome). In ogni worksheet su browser c'è una casella da spuntare prima di generare una vista tridimensionale @@ -548,7 +548,7 @@ Per saperne di più digita quanto segue al prompt di Sage :: sage.rings.finite_field_givaro.FiniteField_givaro. -Poi premi TAB, ed usa ``??`` per avere più informationi su ogni +Poi premi TAB, ed usa ``??`` per avere più informazioni su ogni funzione. Ad esempio:: sage.rings.finite_field_givaro.FiniteField_givaro.one?? @@ -698,10 +698,10 @@ accessibili tramite la linea di comando IPython con il comando ``??``:: Source: ... -Tuttabia gli oggetti che sono construiti in Python o IPython sono +Tuttavia gli oggetti che sono costruiti in Python o IPython sono compilati e non verranno visualizzati. Ci sono molte funzioni in Sage -construite come funzioni simboliche, i.e. possono essere usate come +costruite come funzioni simboliche, i.e. possono essere usate come parte di espressioni simboliche senza dover essere calcolate. Il loro codice sorgente potrebbe non essere accessibile dalla linea di -comando, sopratutto per le funzioni elementaru, poiché sono scritte +comando, sopratutto per le funzioni elementari, poiché sono scritte in C++ (per ragioni di efficienza). From 053a3010f8d93e7b6682a7006f971414550c5f7e Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:51 +0200 Subject: [PATCH 138/494] Update introduction.rst --- src/doc/it/tutorial/introduction.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/it/tutorial/introduction.rst b/src/doc/it/tutorial/introduction.rst index 7e388e04dfc..856aa26d484 100644 --- a/src/doc/it/tutorial/introduction.rst +++ b/src/doc/it/tutorial/introduction.rst @@ -66,7 +66,7 @@ Qui vengono fatti solamente due commenti. #. Il file di download di Sage arrive con le "batterie incluse". In altre parole, nonostante Sage usi Python, IPython, PARI, GAP, Singular, Maxima, NTL, GMP e così via, non è necessario installarli - separatemente siccome sono incluse con la distribuzione di Sage. + separatamente siccome sono incluse con la distribuzione di Sage. Comunque, per usare certe feature di \sage, ad es. Macaulay o KASH, bisogna installare il pacchetto opzionale Sage che interessa o almeno avere i programmi in questioni gia installati sul proprio computer. @@ -76,7 +76,7 @@ Qui vengono fatti solamente due commenti. #. Le versioni binarie precompilate di Sage (che si trovano sul sito web di Sage) possono essere più facili e più veloci da installare invece che la - versione da codice sorgente. Basta solo spachettare il file e eseguire "sage". + versione da codice sorgente. Basta solo spacchettare il file e eseguire "sage". Modi di usare Sage ================== @@ -100,7 +100,7 @@ Obiettivi di lungo periodo per Sage =================================== - **Utile**: il pubblico per Sage il quale sage è stato pensato sono gli - studentu di matematica (dalla scuola superiore all'università), gli insegnanti + studenti di matematica (dalla scuola superiore all'università), gli insegnanti e i ricercatori in matematica. Lo scopo è di fornire software che possa essere usato per esplorare e sperimentare le costruzioni matematiche in algebra, geometria, teoria dei numeri, calcolo, calcolo numerico, ecc. Sage aiuta a @@ -111,11 +111,11 @@ Obiettivi di lungo periodo per Sage operazioni. - **Libero e open source:** il codice sorgente deve essere liberamente disponibile - e leggibile, così che gli utenti posssano capire cosa stia facendo veramente il + e leggibile, così che gli utenti possano capire cosa stia facendo veramente il sistema e possano estenderlo più facilmente. Così come i matematici acquisiscono - una comprensione più profonda di un teorema leggendo attentamete o almeno scorrendo + una comprensione più profonda di un teorema leggendo attentamente o almeno scorrendo velocemente la dimostrazione, le persone che fanno calcoli dovrebbero essere capaci - di capire come funzionano i calcoli leggengo il codice sorgente documentato. Se + di capire come funzionano i calcoli leggendo il codice sorgente documentato. Se si usa Sage per fare calcoli in un articolo che si pubblica, si può essere rassicurati dal fatto che i lettori avranno sempre libero accesso a Sage e a tutto il suo codice sorgente ed è persino concesso di archiviare la versione di Sage che si è utilizzata. From 64d9a1f363815e9a207cbd4af24cd190aadc6746 Mon Sep 17 00:00:00 2001 From: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:37:55 +0200 Subject: [PATCH 139/494] Update tour_algebra.rst --- src/doc/it/tutorial/tour_algebra.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/it/tutorial/tour_algebra.rst b/src/doc/it/tutorial/tour_algebra.rst index cde427d3090..4c301d7b1b2 100644 --- a/src/doc/it/tutorial/tour_algebra.rst +++ b/src/doc/it/tutorial/tour_algebra.rst @@ -71,7 +71,7 @@ l'argomento è il numero di bit di precisione.) Differenziazione, Integrazione, etc. ------------------------------------ -Sage è in grado di differenziae ed integrare molte funzioni. Per +Sage è in grado di differenziare ed integrare molte funzioni. Per esempio, per differenziare :math:`\sin(u)` rispetto a :math:`u`, si procede come nelle righe seguenti: @@ -379,7 +379,7 @@ e "Funzioni speciali", rispettivamente) del manuale di Sage. 0.167089499251049 A questo punto, Sage ha soltanto incorporato queste funzioni per l'uso numerico. -Per l'uso simbolico, si usi direttamente l'intefaccia di Maxima, come +Per l'uso simbolico, si usi direttamente l'interfaccia di Maxima, come nell'esempio seguente:: sage: maxima.eval("f:bessel_y(v, w)") From db5613a6f122506bebc75b9b9b3829f1fef34581 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 22:41:10 +0900 Subject: [PATCH 140/494] Minor error --- src/sage/combinat/root_system/type_marked.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/root_system/type_marked.py b/src/sage/combinat/root_system/type_marked.py index 3f76189bbc9..a9ca7d15a35 100644 --- a/src/sage/combinat/root_system/type_marked.py +++ b/src/sage/combinat/root_system/type_marked.py @@ -278,7 +278,7 @@ def _latex_draw_mark(self, x, y, color='black', thickness='thin'): ret += "\\draw[shift={{({}, {})}}, {}, {}] (0.25cm, -0.25cm) -- (-0.25cm, 0.25cm);\n".format(x, y, color, thickness) return ret - def _latex_dynkin_diagram(self, label=label, node=None, node_dist=2): + def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2): r""" Return a latex representation of the Dynkin diagram. From 07b17c6d84f4aeab78c5ee44e76954503d1742b5 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 23:08:49 +0900 Subject: [PATCH 141/494] Compare with the old doc --- .github/workflows/doc-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 53c6cbe9bdb..24a03bb2b69 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -132,8 +132,8 @@ jobs: echo '## Preview of CHANGES.html' (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i -e '\__ d' ) - (cd /sage/local/share/doc/sage/html/en && git diff --name-only) | tee ./docs/CHANGES.txt - (cd /sage/local/share/doc/sage/html/en && git diff; rm -rf .git) > ./docs/html.diff + (cd /sage/local/share/doc/sage/html/en && git diff HEAD^ --name-only) | tee ./docs/CHANGES.txt + (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/html.diff echo '## Preview of html.diff'; head -n 400 ./docs/html.diff (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) From 5a7d593270cd9767a5d5d52c30ae74bcd800015f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 19 Oct 2023 23:44:05 +0900 Subject: [PATCH 142/494] Put on cosmetics --- .github/workflows/doc-build.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 24a03bb2b69..d30380b84e8 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -56,15 +56,19 @@ jobs: git config --global --add safe.directory $(pwd) git config --global user.email "ci-sage@example.com" git config --global user.name "Build & Test workflow" + # mathjax path in old doc mathjax_path_from=$(SAGE_USE_CDNS=no /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") .ci/retrofit-worktree.sh worktree-image /sage - # Keep track of changes to built HTML - new_version=$(cat src/VERSION.txt) + # mathjax path in new doc mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") + new_version=$(cat src/VERSION.txt) + # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '$new_version' /' \ -e 's_'"$mathjax_path_from"'_'"$mathjax_path_to"'_' \ - -e '\__ d' && \ + -e '\__ d') + # Create git repo from old doc + (cd /sage/local/share/doc/sage/html/en && \ git init && \ (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \ (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \ @@ -130,10 +134,22 @@ jobs: (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') # Create changelog echo '## Preview of CHANGES.html' + # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ - find . -name "*.html" | xargs sed -i -e '\__ d' ) + find . -name "*.html" | xargs sed -i -e '\__ d') (cd /sage/local/share/doc/sage/html/en && git diff HEAD^ --name-only) | tee ./docs/CHANGES.txt - (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/html.diff + # Create diff + echo '' > ./docs/html.diff + echo '' >> ./docs/html.diff + echo '' >> ./docs/html.diff + echo '' >> ./docs/html.diff + echo '' >> ./docs/html.diff + echo '' >> ./docs/html.diff + echo '

' >> ./docs/html.diff
+          (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) >> ./docs/html.diff
+          echo '
' >> ./docs/html.diff + echo '' >> ./docs/html.diff + # Preview of changes echo '## Preview of html.diff'; head -n 400 ./docs/html.diff (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) From 5be55e816cb9978088d27d5a369f6074f6a01695 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 00:32:16 +0900 Subject: [PATCH 143/494] diff.html not html.diff --- .github/workflows/doc-build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index d30380b84e8..411f66ee215 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -139,19 +139,19 @@ jobs: find . -name "*.html" | xargs sed -i -e '\__ d') (cd /sage/local/share/doc/sage/html/en && git diff HEAD^ --name-only) | tee ./docs/CHANGES.txt # Create diff - echo '' > ./docs/html.diff - echo '' >> ./docs/html.diff - echo '' >> ./docs/html.diff - echo '' >> ./docs/html.diff - echo '' >> ./docs/html.diff - echo '' >> ./docs/html.diff - echo '

' >> ./docs/html.diff
-          (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) >> ./docs/html.diff
-          echo '
' >> ./docs/html.diff - echo '' >> ./docs/html.diff + echo '' > ./docs/diff.html + echo '' >> ./docs/diff.html + echo '' >> ./docs/diff.html + echo '' >> ./docs/diff.html + echo '' >> ./docs/diff.html + echo '' >> ./docs/diff.html + echo '
' >> ./docs/diff.html
+          (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) >> ./docs/diff.html
+          echo '
' >> ./docs/diff.html + echo '' >> ./docs/diff.html # Preview of changes - echo '## Preview of html.diff'; head -n 400 ./docs/html.diff - (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html + echo '## Preview of diff.html'; head -n 400 ./docs/diff.html + (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder From d00862b0d12bbd1beffe78b93291728c4ea61cdb Mon Sep 17 00:00:00 2001 From: Sebastian Oehms <47305845+soehms@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:52:42 +0200 Subject: [PATCH 144/494] Approve without body (#11) * approve_without_body initial * add missing positional arg * nochmal * issue 2 * Introduce SYNC_LABELS_BOT_TOKEN and fix issue 1 * Fix in gh_cmd because of mark_as_ready * Ignore trigger of bot * Ignore actor's reviews on needs review * dismiss_bot_reviews and refrain from removing labels * fix broken call of review_by_actor * add get_review_requests * consistent use of state versus status * add full stops in comments --- .github/sync_labels.py | 504 +++++++++++++++++++++++++++-------------- 1 file changed, 334 insertions(+), 170 deletions(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index 4bdb10e7d05..97ddf039a16 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -25,6 +25,7 @@ from subprocess import check_output, CalledProcessError datetime_format = '%Y-%m-%dT%H:%M:%SZ' +default_bot = 'github-actions' class Action(Enum): @@ -42,21 +43,41 @@ class Action(Enum): converted_to_draft = 'converted_to_draft' submitted = 'submitted' -class RevState(Enum): +class AuthorAssociation(Enum): r""" - Enum for GitHub event ``review_state``. + Enum for GitHub ``authorAssociation``. """ - commented = 'commented' - approved = 'approved' - changes_requested = 'changes_requested' + def is_valid(self): + r""" + Return whether ``self`` has valid permissions. + """ + c = self.__class__ + return self in [c.collaborator, c.member, c.owner] + + collaborator = 'COLLABORATOR' # Author has been invited to collaborate on the repository. + contributor = 'CONTRIBUTOR' # Author has previously committed to the repository. + first_timer = 'FIRST_TIMER' # Author has not previously committed to GitHub. + first_time_contributor = 'FIRST_TIME_CONTRIBUTOR' # Author has not previously committed to the repository. + mannequin = 'MANNEQUIN' # Author is a placeholder for an unclaimed user. + member = 'MEMBER' # Author is a member of the organization that owns the repository. + none = 'NONE' # Author has no association with the repository. + owner = 'OWNER' # Author is the owner of the repository. -class ReviewDecision(Enum): +class RevState(Enum): r""" - Enum for ``gh pr view`` results for ``reviewDecision``. + Enum for GitHub event ``review_state``. """ + def is_proper(self): + r""" + Return whether ``self`` is a proper review state. + """ + c = self.__class__ + return self in [c.changes_requested, c.approved] + + commented = 'COMMENTED' changes_requested = 'CHANGES_REQUESTED' approved = 'APPROVED' - unclear = 'UNCLEAR' + dismissed = 'DISMISSED' class Priority(Enum): r""" @@ -68,9 +89,9 @@ class Priority(Enum): minor = 'p: minor /4' trivial = 'p: trivial /5' -class State(Enum): +class Status(Enum): r""" - Enum for state labels. + Enum for status labels. """ positive_review = 's: positive review' needs_work = 's: needs work' @@ -90,7 +111,7 @@ def selection_list(label): r""" Return the selection list to which ``label`` belongs to. """ - for sel_list in [Priority, State, Resolution]: + for sel_list in [Priority, Status, Resolution]: for item in sel_list: if label == item.value: return sel_list @@ -115,16 +136,25 @@ def __init__(self, url, actor): self._open = None self._review_decision = None self._reviews = None + self._reviews_from_rest_api = None + self._review_requests = None self._commits = None self._commit_date = None + self._bot_login = None + + s = url.split('/') + self._owner = s[3] + self._repo = s[4] + self._number = os.path.basename(url) - number = os.path.basename(url) self._pr = True - self._issue = 'pull request #%s' % number + self._issue = 'pull request #%s' % self._number if url.rfind('issue') != -1: - self._issue = 'issue #%s' % number + self._issue = 'issue #%s' % self._number self._pr = False info('Create label handler for %s and actor %s' % (self._issue, self._actor)) + + self.bot_login() self.clean_warnings() # ------------------------------------------------------------------------- @@ -199,6 +229,30 @@ def is_draft(self): info('Issue %s is draft %s' % (self._issue, self._draft)) return self._draft + def bot_login(self): + r""" + Return the login name of the bot. + """ + if self._bot_login: + return self._bot_login + cmd = 'gh auth status' + from subprocess import run + capt = run(cmd, shell=True, capture_output=True) + l = str(capt.stderr).split() + if not 'as' in l: + l = str(capt.stdout).split() + self._bot_login = l[l.index('as')+1] + if self._bot_login.endswith('[bot]'): + self._bot_login = self._bot_login.split('[bot]')[0] + info('Bot is %s' % self._bot_login) + return self._bot_login + + def is_this_bot(self, login): + r""" + Check whether login is the bot itself. + """ + return login.startswith(self.bot_login()) + def is_auth_team_member(self, login): r""" Return ``True`` if the user with given login belongs to an authorized @@ -225,9 +279,43 @@ def verify_membership(team): def actor_authorized(self): r""" - Return ``True`` if the actor belongs to an authorized team. + Return ``True`` if the actor has sufficient permissions. + """ + if self.is_this_bot(default_bot): + # since the default bot is not a member of the SageMath + # organization it cannot test membership for private members. + # Therefore, we check here for public organization membership. + rev = self.get_latest_review() + if not rev: + return False + + if rev['author']['login'] == self._actor: + ass = rev['authorAssociation'] + info('Actor %s has association %s' % (self._actor, ass)) + return AuthorAssociation(ass).is_valid() + info('Actor %s did not create latest review' % self._actor) + return False + else: + return self.is_auth_team_member(self._actor) + + def query_multi_pages(self, path_args, since=None): + r""" + Query data from REST api from multiple pages. """ - return self.is_auth_team_member(self._actor) + per_page = 100 + if since: + query = '-f per_page=%s -f page={} -f since=%s' % (per_page, since.strftime(datetime_format)) + else: + query = '-f per_page=%s -f page={}' % per_page + page = 1 + results = [] + while True: + results_page = self.rest_api(path_args, query=query.format(page)) + results += results_page + if len(results_page) < per_page: + break + page += 1 + return results def clean_warnings(self): r""" @@ -236,22 +324,10 @@ def clean_warnings(self): """ warning_lifetime = timedelta(minutes=5) time_frame = timedelta(minutes=730) # timedelta to search for comments including 10 minutes overlap with cron-cycle - per_page = 100 today = datetime.today() since = today - time_frame - query = '-F per_page=%s -F page={} -f since=%s' % (per_page, since.strftime(datetime_format)) - s = self._url.split('/') - owner = s[3] - repo = s[4] - path_args = '/repos/%s/%s/issues/comments' % (owner, repo) - page = 1 - comments = [] - while True: - comments_page = self.rest_api(path_args, query=query.format(page)) - comments += comments_page - if len(comments_page) < per_page: - break - page += 1 + path_args = '/repos/%s/%s/issues/comments' % (self._owner, self._repo) + comments = self.query_multi_pages(path_args, since=since) info('Cleaning warning comments since %s (total found %s)' % (since, len(comments))) @@ -261,8 +337,8 @@ def clean_warnings(self): comment_id = c['id'] issue = c['issue_url'].split('/').pop() created_at = c['created_at'] - if login.startswith('github-actions'): - debug('github-actions comment %s created at %s on issue %s found' % (comment_id, created_at, issue)) + if self.is_this_bot(login): + debug('%s comment %s created at %s on issue %s found' % (self.bot_login(), comment_id, created_at, issue)) prefix = None if body.startswith(self._warning_prefix): prefix = self._warning_prefix @@ -271,7 +347,7 @@ def clean_warnings(self): if prefix: created = datetime.strptime(created_at, datetime_format) lifetime = today - created - debug('github-actions %s %s is %s old' % (prefix, comment_id, lifetime)) + debug('%s %s %s is %s old' % (self.bot_login(), prefix, comment_id, lifetime)) if lifetime > warning_lifetime: try: self.rest_api('%s/%s' % (path_args, comment_id), method='DELETE') @@ -317,28 +393,18 @@ def get_commits(self): info('Commits until %s for %s: %s' % (self._commit_date, self._issue, self._commits)) return self._commits - def get_review_decision(self): + def get_review_requests(self): r""" - Return the reviewDecision of the PR. + Return the list of review request of the PR. """ if not self.is_pull_request(): return None - if self._review_decision is not None: - if self._review_decision == ReviewDecision.unclear: - return None - return self._review_decision + if self._review_requests is None: + self._review_requests = self.view('reviewRequests') + debug('Review requests for %s: %s' % (self._issue, self._review_requests)) - data = self.view('reviewDecision') - if data: - self._review_decision = ReviewDecision(data) - else: - # To separate a not supplied value from not cached (see https://github.com/sagemath/sage/pull/36177#issuecomment-1704022893 ff) - self._review_decision = ReviewDecision.unclear - info('No review decision for %s' % self._issue) - return None - info('Review decision for %s: %s' % (self._issue, self._review_decision.value)) - return self._review_decision + return self._review_requests def get_reviews(self, complete=False): r""" @@ -366,6 +432,28 @@ def get_reviews(self, complete=False): info('Proper reviews after %s for %s: %s' % (date, self._issue, proper_new_revs)) return proper_new_revs + def get_latest_review(self, complete=False): + r""" + Return the latest review of the PR. Per default only those proper reviews + are considered which have been submitted after the most recent commit. Use + keyword ``complete`` to get the latest of all. + """ + revs = self.get_reviews(complete=complete) + if not revs: + return + res = revs[0] + max_date = res['submittedAt'] + for rev in revs: + cur_date = rev['submittedAt'] + if cur_date > max_date: + max_date = cur_date + res = rev + fill_in = '' + if not complete: + fill_in = ' proper' + info('PR %s had latest%s review at %s: %s' % (self._issue, fill_in, max_date, res)) + return res + def active_partners(self, item): r""" Return the list of other labels from the selection list @@ -377,47 +465,60 @@ def active_partners(self, item): return partners # ------------------------------------------------------------------------- - # methods to validate the issue state + # methods to validate the issue status # ------------------------------------------------------------------------- - def review_comment_to_state(self): + def review_comment_to_status(self): r""" - Return a State label if the most recent review comment + Return a status label if the most recent review comment starts with its value. """ - revs = self.get_reviews(complete=True) - date = max(rev['submittedAt'] for rev in revs) - - for rev in revs: - if rev['submittedAt'] == date: - for stat in State: - body = rev['body'] - if body.startswith(stat.value): - return stat - return None - - def needs_work_valid(self): + rev = self.get_latest_review(complete=True) + ass = AuthorAssociation(rev['authorAssociation']) + for status in Status: + body = rev['body'] + if body.startswith(status.value): + info('Latest review comment contains status label %s' % status) + return status, ass + return None, ass + + def review_by_actor(self): r""" - Return ``True`` if the PR needs work. This is the case if - there are reviews more recent than any commit and the review - decision requests changes or if there is any review reqesting - changes. + Return ``True`` if the actor authored the latest review directly or indirectly. """ - revs = self.get_reviews() - if not revs: + rev = self.get_latest_review() + if not rev: # no proper review since most recent commit. return False + answer = False + auth = rev['author']['login'] + if self._actor == auth: + answer = True + if self.is_this_bot(auth): + if rev['body'].find(self._actor) > 0: + answer = True + if answer: + node_id = rev['id'] + info('Ignore actor\'s review %s' % node_id) + self.dismiss_bot_reviews('@%s reverted decision.' % self._actor, node_id=node_id) + return answer + + def check_review_decision(self, rev_decision): + r""" + Return ``True`` if the latest proper review of the PR has the + given decision. + """ + rev = self.get_latest_review() + if not rev: + # no proper review since most recent commit. + return False + return rev['state'] == rev_decision.value - ch_req = ReviewDecision.changes_requested - rev_dec = self.get_review_decision() - if rev_dec: - if rev_dec == ch_req: - info('PR %s needs work (by decision)' % self._issue) - return True - else: - info('PR %s doesn\'t need work (by decision)' % self._issue) - return False - - if any(rev['state'] == ch_req.value for rev in revs): + def needs_work_valid(self): + r""" + Return ``True`` if the PR needs work. This is the case if + the latest proper review request changes. + """ + if self.check_review_decision(RevState.changes_requested): info('PR %s needs work' % self._issue) return True info('PR %s doesn\'t need work' % self._issue) @@ -425,27 +526,10 @@ def needs_work_valid(self): def positive_review_valid(self): r""" - Return ``True`` if the PR has positive review. This is the - case if there are reviews more recent than any commit and the - review decision is approved or if there is any approved review - but no changes requesting one. + Return ``True`` if the PR is positively reviewed. This is the case if + the latest proper review is approved. """ - revs = self.get_reviews() - if not revs: - # no proper review since most recent commit. - return False - - appr = ReviewDecision.approved - rev_dec = self.get_review_decision() - if rev_dec: - if rev_dec == appr: - info('PR %s has positve review (by decision)' % self._issue) - return True - else: - info('PR %s doesn\'t have positve review (by decision)' % self._issue) - return False - - if all(rev['state'] == appr.value for rev in revs): + if self.check_review_decision(RevState.approved): info('PR %s has positve review' % self._issue) return True info('PR %s doesn\'t have positve review' % self._issue) @@ -459,6 +543,10 @@ def needs_review_valid(self): if self.is_draft(): return False + if self.review_by_actor(): + info('PR %s needs review (because of actor review)' % self._issue) + return True + if self.needs_work_valid(): info('PR %s already under review (needs work)' % self._issue) return False @@ -475,13 +563,12 @@ def approve_allowed(self): Return if the actor has permission to approve this PR. """ revs = self.get_reviews() - revs = [rev for rev in revs if rev['author']['login'] != self._actor] - ch_req = ReviewDecision.changes_requested + revs = [rev for rev in revs if not self.review_by_actor()] + ch_req = RevState.changes_requested if any(rev['state'] == ch_req.value for rev in revs): info('PR %s can\'t be approved by %s since others reqest changes' % (self._issue, self._actor)) return False - - return self.actor_valid() + return True def actor_valid(self): r""" @@ -494,7 +581,7 @@ def actor_valid(self): return True revs = self.get_reviews() - revs = [rev for rev in revs if rev['author']['login'] != 'github-actions'] + revs = [rev for rev in revs if not self.is_this_bot(rev['author']['login'])] if not revs: info('PR %s can\'t be approved by the author %s since no other person reviewed it' % (self._issue, self._actor)) return False @@ -502,10 +589,10 @@ def actor_valid(self): coms = self.get_commits() authors = [] for com in coms: - for author in com['authors']: - login = author['login'] + for auth in com['authors']: + login = auth['login'] if not login in authors: - if not login in (self._actor, 'github-actions'): + if not self.is_this_bot(login) and login != author: debug('PR %s has recent commit by %s' % (self._issue, login)) authors.append(login) @@ -513,7 +600,7 @@ def actor_valid(self): info('PR %s can\'t be approved by the author %s since no other person commited to it' % (self._issue, self._actor)) return False - info('PR %s can be approved by the author %s as co-author' % (self._issue, self._actor)) + info('PR %s can be approved by the author %s as co-author' % (self._issue, author)) return True # ------------------------------------------------------------------------- @@ -526,7 +613,10 @@ def gh_cmd(self, cmd, arg, option): issue = 'issue' if self._pr: issue = 'pr' - cmd_str = 'gh %s %s %s %s "%s"' % (issue, cmd, self._url, option, arg) + if arg: + cmd_str = 'gh %s %s %s %s "%s"' % (issue, cmd, self._url, option, arg) + else: + cmd_str = 'gh %s %s %s %s' % (issue, cmd, self._url, option) debug('Execute command: %s' % cmd_str) ex_code = os.system(cmd_str) if ex_code: @@ -544,26 +634,70 @@ def mark_as_ready(self): """ self.gh_cmd('ready', '', '') - def review(self, arg, text): + def review(self, arg, text=None): r""" Perform a system call to ``gh`` to review a PR. """ - self.gh_cmd('review', arg, '-b \"%s\"' % text) + if text: + self.gh_cmd('review', arg, '-b \"%s\"' % text) + else: + self.gh_cmd('review', arg, '') def approve(self): r""" Approve the PR by the actor. """ - self.review('--approve', '@%s approved this PR' % self._actor) + self.review('--approve') info('PR %s approved by %s' % (self._issue, self._actor)) def request_changes(self): r""" Request changes for this PR by the actor. """ - self.review('--request-changes', '%s requested changes for this PR' % self._actor) + self.review('--request-changes', '@%s requested changes for this PR' % self._actor) info('Changes requested for PR %s by %s' % (self._issue, self._actor)) + def dismiss_bot_reviews(self, message, node_id=None, state=None, actor=None): + r""" + Dismiss all reviews of the bot matching the given features (``node_id``, ...). + """ + path_args = '/repos/%s/%s/pulls/%s/reviews' % (self._owner, self._repo, self._number) + if not self._reviews_from_rest_api: + # since the reviews queried with `gh pr view` don't contain the id + # we need to obtain them form REST api. + self._reviews_from_rest_api = self.query_multi_pages(path_args) + reviews = self._reviews_from_rest_api + + options = '-f message=\"%s\" -f event=\"DISMISS\"' % message + for rev in reviews: + rev_login = rev['user']['login'] + rev_id = rev['id'] + rev_node_id = rev['node_id'] + rev_state = RevState(rev['state']) + + if not self.is_this_bot(rev_login): + continue + if not rev_state.is_proper(): + continue + + debug('Bot review with node_id %s has id %s' % (rev_node_id, rev_id)) + if node_id: + if rev_node_id != node_id: + continue + if state: + if rev_state != state: + continue + if actor: + if not rev['body'].find(actor): + continue + path_args_dismiss = '%s/%s/dismissals' % (path_args, rev_id) + try: + self.rest_api(path_args_dismiss, method='PUT', query=options) + info('Review %s (node_id %s, state %s) on PR %s dismissed' % (rev_id, rev_node_id, rev_state, self._issue)) + except CalledProcessError: + # the comment may have been deleted by a bot running in parallel + info('Review %s (node_id %s, state %s) on PR %s cannot be dismissed' % (rev_id, rev_node_id, rev_state, self._issue)) + def review_comment(self, text): r""" Add a review comment. @@ -625,28 +759,35 @@ def remove_label(self, label): def reject_label_addition(self, item): r""" - Post a comment that the given label can not be added and select - a corresponding other one. + Post a comment that the given label can not be added and remove + it again. + """ + if item is Status.positive_review: + self.add_warning('Label *%s* cannot be added by the author of the PR.' % item.value) + self.remove_label(item.value) + return + + def warning_about_label_addition(self, item): + r""" + Post a comment that the given label my be incorrect. """ if not self.is_pull_request(): - self.add_warning('Label *%s* can not be added to an issue. Please use it on the corresponding PR' % item.value) - elif item is State.needs_review: - self.add_warning('Label *%s* can not be added, since there are unresolved reviews' % item.value) + self.add_warning('Label *%s* is not suitable for an issue. Please use it on the corresponding PR.' % item.value) + elif item is Status.needs_review: + self.add_warning('Label *%s* may be incorrect, since there are unresolved reviews.' % item.value) else: - self.add_warning('Label *%s* can not be added. Please use the GitHub review functionality' % item.value) - self.remove_label(item.value) + self.add_warning('Label *%s* does not match the state of GitHub\'s review system.' % item.value) return - def reject_label_removal(self, item): + def hint_about_label_removal(self, item): r""" - Post a comment that the given label can not be removed and select - a corresponding other one. + Post a comment that the given label must not be removed any more. """ - if type(item) == State: + if type(item) == Status: sel_list = 'status' else: sel_list = 'priority' - self.add_hint('You don\'t need to remove %s labels any more. You\'d better just add the label which replaces it' % sel_list) + self.add_hint('You don\'t need to remove %s labels any more. You\'d better just add the label which replaces it.' % sel_list) return # ------------------------------------------------------------------------- @@ -655,7 +796,7 @@ def reject_label_removal(self, item): def on_label_add(self, label): r""" Check if the given label belongs to a selection list. If so, remove - all other labels of that list. In case of a state label reviews are + all other labels of that list. In case of a status label reviews are booked accordingly. """ sel_list = selection_list(label) @@ -675,13 +816,13 @@ def on_label_add(self, label): warning('Label %s of %s not found!' % (label, self._issue)) return - if sel_list is State: + if sel_list is Status: if not self.is_pull_request(): - if item != State.needs_info: - self.reject_label_addition(item) + if item != Status.needs_info: + self.warning_about_label_addition(item) return - if item == State.needs_review: + if item == Status.needs_review: if self.needs_review_valid(): # here we come for example after a sequence: # needs review -> needs info -> needs review @@ -689,10 +830,10 @@ def on_label_add(self, label): elif self.is_draft(): self.mark_as_ready() else: - self.reject_label_addition(item) + self.warning_about_label_addition(item) return - if item == State.needs_work: + if item == Status.needs_work: if self.needs_work_valid(): # here we come for example after a sequence: # needs work -> needs info -> needs work @@ -700,18 +841,21 @@ def on_label_add(self, label): elif not self.is_draft(): self.request_changes() else: - self.reject_label_addition(item) + self.warning_about_label_addition(item) return - if item == State.positive_review: + if item == Status.positive_review: if self.positive_review_valid(): # here we come for example after a sequence: # positive review -> needs info -> positive review pass + elif not self.actor_valid(): + self.reject_label_addition(item) + return elif self.approve_allowed(): self.approve() else: - self.reject_label_addition(item) + self.warning_about_label_addition(item) return if sel_list is Resolution: @@ -723,10 +867,9 @@ def on_label_add(self, label): def on_label_removal(self, label): r""" - Check if the given label belongs to a selection list. If so, the - removement is rejected and a comment is posted to instead add a - replacement for ``label`` from the list. Exceptions are State labels - on issues and State.needs_info on a PR. + Check if the given label belongs to a selection list. If so, a comment + is posted to instead add a replacement for ``label`` from the list. + Exceptions are status labels on issues and Status.needs_info on a PR. """ sel_list = selection_list(label) if not sel_list: @@ -737,12 +880,12 @@ def on_label_removal(self, label): if len(self.active_partners(item)) > 0: return - if sel_list is State: + if sel_list is Status: if self.is_pull_request(): - if item != State.needs_info: - self.reject_label_removal(item) + if item != Status.needs_info: + self.hint_about_label_removal(item) elif sel_list is Priority: - self.reject_label_removal(item) + self.hint_about_label_removal(item) return def on_review_comment(self): @@ -753,10 +896,21 @@ def on_review_comment(self): have permission to add labels (i.e. aren't a member of the Triage team). """ - rev_state = self.review_comment_to_state() - if rev_state in (State.needs_info, State.needs_review): - self.select_label(rev_state) - self.run(Action.labeled, label=rev_state.value) + status, ass = self.review_comment_to_status() + if ass is AuthorAssociation.owner: + if status is Status.positive_review: + # allow the repository owner to approve his own PR for testing + # the bot + info('Owner approves PR %s for testing the bot' % self._issue) + self.dismiss_bot_reviews('@%s approved the PR.' % self._actor, state=RevState.changes_requested, actor=self._actor) + self.approve() + elif ass.is_valid() or ass is Author.Assoziation.contributor: + if status in (Status.needs_info, Status.needs_review): + # allow contributors who are not Triage members to set + # these labels + info('Simulate label addition of %s for %s' % (label, self._issue)) + self.select_label(status) + self.run(Action.labeled, label=status.value) def remove_all_labels_of_sel_list(self, sel_list): r""" @@ -771,12 +925,16 @@ def run(self, action, label=None, rev_state=None): """ self.reset_view() # this is just needed for run_tests + if self.is_this_bot(self._actor): + info('Trigger %s of the bot %s is ignored' % (action, self._actor)) + return + if action is Action.opened and self.is_pull_request(): if not self.is_draft(): - self.add_default_label(State.needs_review) + self.add_default_label(Status.needs_review) if action in (Action.closed, Action.reopened, Action.converted_to_draft): - self.remove_all_labels_of_sel_list(State) + self.remove_all_labels_of_sel_list(Status) if action is Action.labeled: self.on_label_add(label) @@ -785,21 +943,27 @@ def run(self, action, label=None, rev_state=None): self.on_label_removal(label) if action in (Action.ready_for_review, Action.synchronize): + self.dismiss_bot_reviews('New changes ready for review.') if self.needs_review_valid(): - self.select_label(State.needs_review) + self.select_label(Status.needs_review) if action is Action.review_requested: - self.select_label(State.needs_review) + self.select_label(Status.needs_review) if action is Action.submitted: - rev_state = RevState(rev_state) + rev_state = RevState(rev_state.upper()) if rev_state is RevState.approved: - if self.actor_authorized() and self.positive_review_valid(): - self.select_label(State.positive_review) + self.dismiss_bot_reviews('@%s approved the PR.' % self._actor, state=RevState.changes_requested, actor=self._actor) + rev_req = self.get_review_requests() + if rev_req: + info('Waiting on pending review requests: %s' % rev_req) + elif self.actor_authorized() and self.positive_review_valid(): + self.select_label(Status.positive_review) if rev_state is RevState.changes_requested: + self.dismiss_bot_reviews('@%s requested changes.' % self._actor, state=RevState.approved) if self.needs_work_valid(): - self.select_label(State.needs_work) + self.select_label(Status.needs_work) if rev_state is RevState.commented: self.on_review_comment() @@ -818,12 +982,12 @@ def run_tests(self): for action in Action: self.add_comment('Test action %s' % action.value) if action in (Action.labeled, Action.unlabeled): - for stat in State: + for status in Status: if action is Action.labeled: - self.add_label(stat.value) + self.add_label(status.value) else: - self.remove_label(stat.value) - self.run(action, label=stat.value) + self.remove_label(status.value) + self.run(action, label=status.value) for prio in Priority: if action is Action.labeled: self.add_label(prio.value) @@ -835,17 +999,17 @@ def run_tests(self): self.add_label(res.value) self.run(action, label=prio.value) elif action == Action.submitted and self.is_pull_request(): - for rev_stat in RevState: - if rev_stat is RevState.approved: + for rev_state in RevState: + if rev_state is RevState.approved: self.approve() - self.run(action, rev_state=rev_stat.value) - elif rev_stat is RevState.changes_requested: + self.run(action, rev_state=rev_state.value) + elif rev_state is RevState.changes_requested: self.request_changes() - self.run(action, rev_state=rev_stat.value) - elif rev_stat is RevState.commented: - for stat in State: - self.review_comment(stat.value) - self.run(action, rev_state=rev_stat.value) + self.run(action, rev_state=rev_state.value) + elif rev_state is RevState.commented: + for status in Status: + self.review_comment(status.value) + self.run(action, rev_state=rev_state.value) elif self.is_pull_request(): self.run(action) From 46b86927a718a2d011762b35090787fcc55fb49e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 02:02:12 +0900 Subject: [PATCH 145/494] Sanitize text for html --- .github/workflows/doc-build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 411f66ee215..6ab3b23db7f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -146,12 +146,13 @@ jobs: echo '' >> ./docs/diff.html echo '' >> ./docs/diff.html echo '

' >> ./docs/diff.html
-          (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) >> ./docs/diff.html
+          (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt
+          sed 's/\&/\&/g; s//\>/g' ./docs/diff.txt >> ./docs/diff.html
           echo '
' >> ./docs/diff.html echo '' >> ./docs/diff.html # Preview of changes echo '## Preview of diff.html'; head -n 400 ./docs/diff.html - (echo '

HTML diff'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html + (echo '

diff.html diff.txt'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder From 5d8ddcf3c33db4ac70b36b46c8ebe9fe37dbea6d Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Thu, 19 Oct 2023 13:24:13 -0700 Subject: [PATCH 146/494] Fix func_persist: do not use the (now removed) inspect.formatargspec, but instead use inspect.signature. --- src/sage/misc/func_persist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/misc/func_persist.py b/src/sage/misc/func_persist.py index 12dd35d1f88..cf020479440 100644 --- a/src/sage/misc/func_persist.py +++ b/src/sage/misc/func_persist.py @@ -45,7 +45,6 @@ def bern(n): from . import persist - class func_persist: r""" Put ``@func_persist`` right before your function @@ -57,7 +56,7 @@ def __init__(self, f, dir='func_persist'): os.makedirs(dir, exist_ok=True) self.__doc__ = '%s%s%s' % ( f.__name__, - inspect.formatargspec(*inspect.getargs(f.__code__)), + inspect.signature(f), f.__doc__) def __call__(self, *args, **kwds): From b3df3d6e25a2e53f8b879e8ea4ab87a9a892ff1b Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 12:44:22 +0900 Subject: [PATCH 147/494] Reformat CHANGES.html --- .github/workflows/doc-build.yml | 41 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 6ab3b23db7f..bb72125e83f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -132,27 +132,38 @@ jobs: set -ex mkdir -p ./docs (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') - # Create changelog echo '## Preview of CHANGES.html' # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i -e '\__ d') - (cd /sage/local/share/doc/sage/html/en && git diff HEAD^ --name-only) | tee ./docs/CHANGES.txt - # Create diff - echo '' > ./docs/diff.html - echo '' >> ./docs/diff.html - echo '' >> ./docs/diff.html - echo '' >> ./docs/diff.html - echo '' >> ./docs/diff.html - echo '' >> ./docs/diff.html - echo '

' >> ./docs/diff.html
+          # Create CHANGES.html
+          echo '' > ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
+          echo '' >> ./docs/CHANGES.html
           (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt
-          sed 's/\&/\&/g; s//\>/g' ./docs/diff.txt >> ./docs/diff.html
-          echo '
' >> ./docs/diff.html - echo '' >> ./docs/diff.html + python -c "import re, html + with open('./docs/diff.txt ', 'r') as f: + diff_text = f.read() + diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) + out_blocks = [] + for block in diff_blocks: + match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) + if match: + path = match.group(1) + out_blocks.append(f'

{path}

\n
\n' + html.escape(block).strip() + '\n
') + output_text = '\n'.join(out_blocks) + + with open('./docs/diff.html' ', 'w') as f: + f.write(output_text)" + cat .docs/diff.html >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + echo '' >>./docs/CHANGES.html # Preview of changes - echo '## Preview of diff.html'; head -n 400 ./docs/diff.html - (echo '

diff.html diff.txt'; sed -E 's,(.*),

\1,' ./docs/CHANGES.txt) > ./docs/CHANGES.html + echo '## Preview of diff.txt'; head -n 400 ./docs/diff.txt (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder From ce5595b7303b4d3c69b92074583a2f1c84a5b5f8 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 14:29:31 +0900 Subject: [PATCH 148/494] Use sage python --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index bb72125e83f..3f8c03c1338 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -145,7 +145,7 @@ jobs: echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt - python -c "import re, html + /sage/sage -python -c "import re, html with open('./docs/diff.txt ', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) From 5de3957bb83859472609e5059188ba25877d9bc0 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 15:29:43 +0900 Subject: [PATCH 149/494] Use here document for python script --- .github/workflows/doc-build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 3f8c03c1338..72019f3be85 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -145,7 +145,8 @@ jobs: echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt - /sage/sage -python -c "import re, html + /sage/sage -python - << EOF + import re, html with open('./docs/diff.txt ', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) @@ -158,7 +159,8 @@ jobs: output_text = '\n'.join(out_blocks) with open('./docs/diff.html' ', 'w') as f: - f.write(output_text)" + f.write(output_text) + EOF cat .docs/diff.html >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html echo '' >>./docs/CHANGES.html From 2c04ca0e5f53150996503020aecf2fd4bd39634c Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 16:17:49 +0900 Subject: [PATCH 150/494] Fix an error --- .github/workflows/doc-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 72019f3be85..c2ad6d15797 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -147,7 +147,7 @@ jobs: (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF import re, html - with open('./docs/diff.txt ', 'r') as f: + with open('./docs/diff.txt', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) out_blocks = [] @@ -157,11 +157,10 @@ jobs: path = match.group(1) out_blocks.append(f'

{path}

\n
\n' + html.escape(block).strip() + '\n
') output_text = '\n'.join(out_blocks) - - with open('./docs/diff.html' ', 'w') as f: + with open('./docs/diff.html', 'w') as f: f.write(output_text) EOF - cat .docs/diff.html >> ./docs/CHANGES.html + cat ./docs/diff.html >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html echo '' >>./docs/CHANGES.html # Preview of changes From b5b49e29af04993920aca6b08b1ba117d2967d04 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 20:57:19 +0900 Subject: [PATCH 151/494] Use diffsite --- .github/workflows/doc-build.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index c2ad6d15797..ead31bd0978 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -142,6 +142,25 @@ jobs: echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html + cat >> ./docs/CHANGES.html << EOF + + EOF echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt @@ -155,7 +174,7 @@ jobs: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: path = match.group(1) - out_blocks.append(f'

{path}

\n
\n' + html.escape(block).strip() + '\n
') + out_blocks.append(f'

{path}

\n
\n' + html.escape(block).strip() + '\n
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: f.write(output_text) From 6522884bf44dbb07c439a7ef683686f43bc432d1 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 20 Oct 2023 22:54:49 +0900 Subject: [PATCH 152/494] Fix urls --- .github/workflows/doc-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index ead31bd0978..cc53309e186 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -151,10 +151,10 @@ jobs: diffParagraphs.forEach(paragraph => { const rootURL = window.location.origin; const docAnchor = paragraph.querySelector('a'); - const path = docAnchor.href; + const path = docAnchor.textContent; // .href doesn't work const anchor = document.createElement('a'); anchor.href = diffSite + '?url1=' + rootURL + path + '&url2=' + baseDocURL + path; - anchor.textContent = 'compare with the base doc'; + anchor.textContent = 'compare with the base'; anchor.setAttribute('target', '_blank'); paragraph.appendChild(anchor); }); @@ -174,7 +174,7 @@ jobs: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: path = match.group(1) - out_blocks.append(f'

{path}

\n
\n' + html.escape(block).strip() + '\n
') + out_blocks.append(f'

{path} 

\n
\n' + html.escape(block).strip() + '\n
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: f.write(output_text) From 15381f7c1cc899cf99dc49deedf162abc14cb085 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 21 Oct 2023 00:03:45 +0900 Subject: [PATCH 153/494] Minor tweak --- .github/workflows/doc-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index cc53309e186..1e099b06998 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -149,7 +149,7 @@ jobs: const baseDocURL = 'https://sagemath-tobias.netlify.app/' const diffParagraphs = document.querySelectorAll('p.diff'); diffParagraphs.forEach(paragraph => { - const rootURL = window.location.origin; + const rootURL = window.location.origin + '/'; const docAnchor = paragraph.querySelector('a'); const path = docAnchor.textContent; // .href doesn't work const anchor = document.createElement('a'); @@ -174,7 +174,7 @@ jobs: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: path = match.group(1) - out_blocks.append(f'

{path} 

\n
\n' + html.escape(block).strip() + '\n
') + out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: f.write(output_text) From 228cb67fcf43291bbb79ddd3d679fdcf57d05df1 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 21 Oct 2023 00:07:48 +0900 Subject: [PATCH 154/494] Change delimiters --- .github/workflows/doc-build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 1e099b06998..889633cc0ba 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -64,9 +64,9 @@ jobs: new_version=$(cat src/VERSION.txt) # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ - find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '$new_version' /' \ - -e 's_'"$mathjax_path_from"'_'"$mathjax_path_to"'_' \ - -e '\__ d') + find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \ + -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \ + -e '\;; d') # Create git repo from old doc (cd /sage/local/share/doc/sage/html/en && \ git init && \ @@ -135,7 +135,7 @@ jobs: echo '## Preview of CHANGES.html' # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ - find . -name "*.html" | xargs sed -i -e '\__ d') + find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html echo '' > ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html From 382e7c030d766b7905355073d5bc05091c936fab Mon Sep 17 00:00:00 2001 From: Dave Witte Morris Date: Fri, 20 Oct 2023 16:34:05 -0600 Subject: [PATCH 155/494] #36490 fix varchenko_matrix --- .../hyperplane_arrangement/arrangement.py | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/sage/geometry/hyperplane_arrangement/arrangement.py b/src/sage/geometry/hyperplane_arrangement/arrangement.py index 7174a80ece5..c25e0733a43 100644 --- a/src/sage/geometry/hyperplane_arrangement/arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/arrangement.py @@ -287,7 +287,7 @@ False sage: a.sign_vector((1,1,1)) (-1, 1, -1, 1, -1, 1) - sage: a.varchenko_matrix() + sage: a.varchenko_matrix()[:6, :6] [ 1 h2 h2*h4 h2*h3 h2*h3*h4 h2*h3*h4*h5] [ h2 1 h4 h3 h3*h4 h3*h4*h5] [ h2*h4 h4 1 h3*h4 h3 h3*h5] @@ -3157,11 +3157,24 @@ def varchenko_matrix(self, names='h'): sage: a = hyperplane_arrangements.coordinate(3) sage: v = a.varchenko_matrix(); v - [ 1 h2 h1] - [ h2 1 h1*h2] - [ h1 h1*h2 1] + [ 1 h2 h1 h1*h2 h0*h1*h2 h0*h1 h0*h2 h0] + [ h2 1 h1*h2 h1 h0*h1 h0*h1*h2 h0 h0*h2] + [ h1 h1*h2 1 h2 h0*h2 h0 h0*h1*h2 h0*h1] + [ h1*h2 h1 h2 1 h0 h0*h2 h0*h1 h0*h1*h2] + [h0*h1*h2 h0*h1 h0*h2 h0 1 h2 h1 h1*h2] + [ h0*h1 h0*h1*h2 h0 h0*h2 h2 1 h1*h2 h1] + [ h0*h2 h0 h0*h1*h2 h0*h1 h1 h1*h2 1 h2] + [ h0 h0*h2 h0*h1 h0*h1*h2 h1*h2 h1 h2 1] sage: factor(det(v)) - (h2 - 1) * (h2 + 1) * (h1 - 1) * (h1 + 1) + (h2 - 1)^4 * (h2 + 1)^4 * (h1 - 1)^4 * (h1 + 1)^4 * (h0 - 1)^4 * (h0 + 1)^4 + + TESTS: + + Verify that :issue:`36490` is fixed:: + + sage: hyperplane_arrangements.coordinate(1).varchenko_matrix() + [1 h] + [h 1] """ from sage.matrix.constructor import identity_matrix from sage.misc.misc_c import prod @@ -3169,9 +3182,10 @@ def varchenko_matrix(self, names='h'): R = PolynomialRing(QQ, names, k) h = R.gens() region = self.regions() - v = identity_matrix(R, k, k) - for i in range(k): - for j in range(i+1, k): + n = len(region) + v = identity_matrix(R, n, n) + for i in range(n): + for j in range(i+1, n): t = prod(h[p] for p in range(k) if self.is_separating_hyperplane(region[i], region[j], self[p])) v[i, j] = v[j, i] = t From 3013bd5545b5d7a7a0960a98adfd24bc6a8245fd Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 21 Oct 2023 07:54:21 +0900 Subject: [PATCH 156/494] Remove another spurious diff --- src/sage/rings/polynomial/groebner_fan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/groebner_fan.py b/src/sage/rings/polynomial/groebner_fan.py index 7e067a3a087..eb8928d09b5 100644 --- a/src/sage/rings/polynomial/groebner_fan.py +++ b/src/sage/rings/polynomial/groebner_fan.py @@ -1234,7 +1234,7 @@ def homogeneity_space(self): return h def render(self, file=None, larger=False, shift=0, rgbcolor=(0, 0, 0), - polyfill=max_degree, scale_colors=True): + polyfill=True, scale_colors=True): """ Render a Groebner fan as sage graphics or save as an xfig file. @@ -1295,6 +1295,8 @@ def render(self, file=None, larger=False, shift=0, rgbcolor=(0, 0, 0), ... NotImplementedError """ + if polyfill is True: + polyfill = max_degree S = self.__ring if S.ngens() < 3: print("For 2-D fan rendering the polynomial ring must have 3 variables (or more, which are ignored).") From c81d50f54b116349ab32c0ca11324574bedf9896 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 21 Oct 2023 12:54:59 +0900 Subject: [PATCH 157/494] Remove preview --- .github/workflows/doc-build.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 889633cc0ba..5eb3998feee 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -66,7 +66,7 @@ jobs: (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \ -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \ - -e '\;; d') + -e '\;; d') # Create git repo from old doc (cd /sage/local/share/doc/sage/html/en && \ git init && \ @@ -132,10 +132,9 @@ jobs: set -ex mkdir -p ./docs (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') - echo '## Preview of CHANGES.html' # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ - find . -name "*.html" | xargs sed -i -e '\;; d') + find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html echo '' > ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html @@ -182,8 +181,7 @@ jobs: cat ./docs/diff.html >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html echo '' >>./docs/CHANGES.html - # Preview of changes - echo '## Preview of diff.txt'; head -n 400 ./docs/diff.txt + rm ./docs/diff.txt ./docs/diff.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder From dd2044f99e3727d5e55c10acc235b434294fa8c2 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Sat, 21 Oct 2023 11:14:08 +0200 Subject: [PATCH 158/494] improve cycle basis for multigraphs --- src/sage/graphs/generic_graph.py | 42 +++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..c2eab5ebf2e 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -5150,13 +5150,13 @@ def cycle_basis(self, output='vertex'): sage: G = Graph([(0, 2, 'a'), (0, 2, 'b'), (0, 1, 'c'), (1, 2, 'd')], ....: multiedges=True) sage: G.cycle_basis() # needs networkx - [[0, 2], [2, 1, 0]] + [[2, 0], [2, 0, 1]] sage: G.cycle_basis(output='edge') # needs networkx - [[(0, 2, 'b'), (2, 0, 'a')], [(2, 1, 'd'), (1, 0, 'c'), (0, 2, 'a')]] + [[(0, 2, 'b'), (2, 0, 'a')], [(1, 2, 'd'), (2, 0, 'a'), (0, 1, 'c')]] sage: H = Graph([(1, 2), (2, 3), (2, 3), (3, 4), (1, 4), ....: (1, 4), (4, 5), (5, 6), (4, 6), (6, 7)], multiedges=True) sage: H.cycle_basis() # needs networkx - [[1, 4], [2, 3], [4, 3, 2, 1], [6, 5, 4]] + [[4, 1], [3, 2], [4, 1, 2, 3], [6, 4, 5]] Disconnected graph:: @@ -5168,14 +5168,14 @@ def cycle_basis(self, output='vertex'): ('Really ?', 'Wuuhuu', None), ('Wuuhuu', 'Hey', None)], [(0, 2, 'a'), (2, 0, 'b')], - [(0, 2, 'b'), (1, 0, 'c'), (2, 1, 'd')]] + [(0, 1, 'c'), (1, 2, 'd'), (2, 0, 'b')]] Graph that allows multiple edges but does not contain any:: sage: G = graphs.CycleGraph(3) sage: G.allow_multiple_edges(True) sage: G.cycle_basis() # needs networkx - [[2, 1, 0]] + [[2, 0, 1]] Not yet implemented for directed graphs:: @@ -5192,11 +5192,11 @@ def cycle_basis(self, output='vertex'): sage: G = Graph([(1, 2, 'a'), (2, 3, 'b'), (2, 3, 'c'), ....: (3, 4, 'd'), (3, 4, 'e'), (4, 1, 'f')], multiedges=True) sage: G.cycle_basis() # needs networkx - [[2, 3], [4, 3, 2, 1], [4, 3, 2, 1]] + [[3, 2], [4, 1, 2, 3], [4, 1, 2, 3]] sage: G.cycle_basis(output='edge') # needs networkx [[(2, 3, 'c'), (3, 2, 'b')], - [(4, 3, 'd'), (3, 2, 'b'), (2, 1, 'a'), (1, 4, 'f')], - [(4, 3, 'e'), (3, 2, 'b'), (2, 1, 'a'), (1, 4, 'f')]] + [(3, 4, 'd'), (4, 1, 'f'), (1, 2, 'a'), (2, 3, 'b')], + [(3, 4, 'e'), (4, 1, 'f'), (1, 2, 'a'), (2, 3, 'b')]] """ if output not in ['vertex', 'edge']: raise ValueError('output must be either vertex or edge') @@ -5211,14 +5211,32 @@ def cycle_basis(self, output='vertex'): []) from sage.graphs.graph import Graph + from itertools import pairwise T = Graph(self.min_spanning_tree(), multiedges=True, format='list_of_edges') H = self.copy() H.delete_edges(T.edge_iterator()) + root = next(T.vertex_iterator()) + rank = dict(T.breadth_first_search(root, report_distance=True)) + parent = {v: u for u, v in T.breadth_first_search(root, edges=True)} L = [] for e in H.edge_iterator(): - T.add_edge(e) - L.append(T.is_tree(certificate=True, output=output)[1]) - T.delete_edge(e) + # Search for the nearest common ancestor of e[0] and e[1] in T + P = [e[0]] + Q = [e[1]] + while P[-1] != Q[-1]: + # If rank[P[-1]] > rank[Q[-1]], we extend the path P. + # If rank[P[-1]] < rank[Q[-1]], we extend the path Q. + # In case of equality, we extend both paths. + diff = rank[P[-1]] - rank[Q[-1]] + if diff >= 0: + P.append(parent[P[-1]]) + if diff <= 0: + Q.append(parent[Q[-1]]) + + cycle = Q + P[-2::-1] + if output == 'edge': + cycle = [e] + [(x, y, T.edge_label(x, y)[0]) for x, y in pairwise(cycle)] + L.append(cycle) return L # second case: there are no multiple edges @@ -5289,7 +5307,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa TESTS:: sage: g = Graph([(0, 1, 1), (1, 2, 'a')]) - sage: g.min_spanning_tree(by_weight=True) + sage: g.minimum_cycle_basis(by_weight=True) Traceback (most recent call last): ... ValueError: the weight function cannot find the weight of (1, 2, 'a') From fe5d82813434e7d7f9f33891da884d1533615933 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 7 Oct 2023 11:24:07 -0700 Subject: [PATCH 159/494] Conditionalize pbori documentation --- src/doc/en/reference/polynomial_rings/index.rst | 8 +++++--- src/sage_docbuild/conf.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/doc/en/reference/polynomial_rings/index.rst b/src/doc/en/reference/polynomial_rings/index.rst index b03fa4279ca..f03428e3595 100644 --- a/src/doc/en/reference/polynomial_rings/index.rst +++ b/src/doc/en/reference/polynomial_rings/index.rst @@ -65,9 +65,11 @@ Infinite Polynomial Rings Boolean Polynomials ------------------- -.. toctree:: - :maxdepth: 1 +.. only:: feature_sage_rings_polynomial_pbori + + .. toctree:: + :maxdepth: 1 - sage/rings/polynomial/pbori/pbori + sage/rings/polynomial/pbori/pbori .. include:: ../footer.txt diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 5eca4ed29b0..0e3e857441d 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -33,6 +33,7 @@ from sage.env import SAGE_DOC_SRC, SAGE_DOC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR from sage.misc.latex_macros import sage_mathjax_macros from sage.features import PythonModule +from sage.features.all import all_features # General configuration # --------------------- @@ -940,3 +941,18 @@ def setup(app): app.connect('missing-reference', find_sage_dangling_links) app.connect('builder-inited', nitpick_patch_config) app.connect('html-page-context', add_page_context) + + +# Conditional content +# https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#tags +# https://www.sphinx-doc.org/en/master/usage/configuration.html#conf-tags +# https://github.com/readthedocs/readthedocs.org/issues/4603#issuecomment-1411594800 +# Workaround to allow importing this file from other confs +if 'tags' not in locals(): + class Tags(set): + has = set.__contains__ + tags = Tags() + + +for feature in all_features(): + tags.add('feature_' + feature.name.replace('.', '_')) From eec76cd5097dbc21df96de0ef99a6aa41160c14f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 7 Oct 2023 15:45:18 -0700 Subject: [PATCH 160/494] src/doc/en/developer: Document how to conditionalize portions of the manual --- .../en/developer/packaging_sage_library.rst | 11 ++++++++ src/doc/en/developer/sage_manuals.rst | 26 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst index abda71bbed8..af1da6c674c 100644 --- a/src/doc/en/developer/packaging_sage_library.rst +++ b/src/doc/en/developer/packaging_sage_library.rst @@ -472,6 +472,17 @@ requiring all of Sage to be present. mechanism mentioned above can also be used for this. +Dependencies of the Sage documentation +-------------------------------------- + +The documentation will not be modularized. + +However, some parts of the Sage reference manual may depend on functionality +provided by optional packages. These portions of the reference manual +should be conditionalized using the Sphinx directive ``.. only ::``, +as explained in :ref:`section-documentation-conditional`. + + Version constraints of dependencies ----------------------------------- diff --git a/src/doc/en/developer/sage_manuals.rst b/src/doc/en/developer/sage_manuals.rst index 30e8114175d..ec037f2ca9d 100644 --- a/src/doc/en/developer/sage_manuals.rst +++ b/src/doc/en/developer/sage_manuals.rst @@ -166,6 +166,32 @@ procedure is different: * Add your file to the index contained in ``SAGE_ROOT/src/doc/en/reference/combinat/module_list.rst``. +.. _section-documentation-conditional: + +Making portions of the reference manual conditional on optional features +======================================================================== + +For every dynamically detectable feature such as :class:`graphviz +<~sage.features.graphviz.Graphviz>` or :class:`sage.symbolic +` (see :mod:`sage.features`), +Sage defines a Sphinx tag that can be used with the `Sphinx +directive ".. only::" +`_. +Because Sphinx tags have to use Python identifier syntax, Sage uses +the format ``feature_``, followed by the feature name where dots are +replaced by underscores. Hence, conditionalizing on the features of +the previous examples would look as follows: + +.. CODE-BLOCK:: rest + + .. only:: feature_graphviz + +and: + +.. CODE-BLOCK:: rest + + .. only:: feature_sage_symbolic + .. _section-building-manuals: Building the manuals From c5b566d228d17b807e3f40cd409fdcb75728201a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 9 Oct 2023 08:34:03 -0700 Subject: [PATCH 161/494] Use uppercase .. ONLY:: --- src/doc/en/developer/sage_manuals.rst | 6 +++--- src/doc/en/reference/polynomial_rings/index.rst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/en/developer/sage_manuals.rst b/src/doc/en/developer/sage_manuals.rst index ec037f2ca9d..578419384c7 100644 --- a/src/doc/en/developer/sage_manuals.rst +++ b/src/doc/en/developer/sage_manuals.rst @@ -175,7 +175,7 @@ For every dynamically detectable feature such as :class:`graphviz <~sage.features.graphviz.Graphviz>` or :class:`sage.symbolic ` (see :mod:`sage.features`), Sage defines a Sphinx tag that can be used with the `Sphinx -directive ".. only::" +directive ".. ONLY::" `_. Because Sphinx tags have to use Python identifier syntax, Sage uses the format ``feature_``, followed by the feature name where dots are @@ -184,13 +184,13 @@ the previous examples would look as follows: .. CODE-BLOCK:: rest - .. only:: feature_graphviz + .. ONLY:: feature_graphviz and: .. CODE-BLOCK:: rest - .. only:: feature_sage_symbolic + .. ONLY:: feature_sage_symbolic .. _section-building-manuals: diff --git a/src/doc/en/reference/polynomial_rings/index.rst b/src/doc/en/reference/polynomial_rings/index.rst index f03428e3595..0035c50021f 100644 --- a/src/doc/en/reference/polynomial_rings/index.rst +++ b/src/doc/en/reference/polynomial_rings/index.rst @@ -65,7 +65,7 @@ Infinite Polynomial Rings Boolean Polynomials ------------------- -.. only:: feature_sage_rings_polynomial_pbori +.. ONLY:: feature_sage_rings_polynomial_pbori .. toctree:: :maxdepth: 1 From e2f56fdfcd6da3ea34aa6cc799bdd935d096dbec Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 16 Oct 2023 20:17:18 -0700 Subject: [PATCH 162/494] src/doc/en/developer/packaging_sage_library.rst: Use all-caps ONLY --- src/doc/en/developer/packaging_sage_library.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst index af1da6c674c..d8cd687ab79 100644 --- a/src/doc/en/developer/packaging_sage_library.rst +++ b/src/doc/en/developer/packaging_sage_library.rst @@ -479,7 +479,7 @@ The documentation will not be modularized. However, some parts of the Sage reference manual may depend on functionality provided by optional packages. These portions of the reference manual -should be conditionalized using the Sphinx directive ``.. only ::``, +should be conditionalized using the Sphinx directive ``.. ONLY ::``, as explained in :ref:`section-documentation-conditional`. From 4abc647ed9afc4abe195992d0eac3e70ca2a0338 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 11:23:46 -0700 Subject: [PATCH 163/494] src/doc/en/developer/packaging_sage_library.rst: No space between ONLY and :: --- src/doc/en/developer/packaging_sage_library.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst index d8cd687ab79..3b8ebbadf36 100644 --- a/src/doc/en/developer/packaging_sage_library.rst +++ b/src/doc/en/developer/packaging_sage_library.rst @@ -479,7 +479,7 @@ The documentation will not be modularized. However, some parts of the Sage reference manual may depend on functionality provided by optional packages. These portions of the reference manual -should be conditionalized using the Sphinx directive ``.. ONLY ::``, +should be conditionalized using the Sphinx directive ``.. ONLY::``, as explained in :ref:`section-documentation-conditional`. From b3d66dff5bf44e0b96015d73774dbc32aa8b9411 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 13:39:59 -0700 Subject: [PATCH 164/494] .ci/retrofit-worktree.sh: Set git config globally --- .ci/retrofit-worktree.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/retrofit-worktree.sh b/.ci/retrofit-worktree.sh index f926e59059e..b9c880a839f 100755 --- a/.ci/retrofit-worktree.sh +++ b/.ci/retrofit-worktree.sh @@ -12,6 +12,10 @@ export GIT_AUTHOR_EMAIL="ci-sage@example.com" export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" +# Set globally for other parts of the workflow +git config --global user.name "$GIT_AUTHOR_NAME" +git config --global user.email "$GIT_AUTHOR_EMAIL" + set -ex # If actions/checkout downloaded our source tree using the GitHub REST API From e69774b1b9040d083a24800cf6c0233632f271d0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 13:59:11 -0700 Subject: [PATCH 165/494] .github/workflows/lint.yml: Do not install what tox will install --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index afd0406341c..7626f1327dc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,7 +33,7 @@ jobs: python-version: 3.9 - name: Install dependencies - run: pip install tox pycodestyle relint + run: pip install tox - name: Code style check with pycodestyle run: tox -e pycodestyle-minimal From d60aa74c197e6f907bcd718b637d7e68f3512109 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 14:02:16 -0700 Subject: [PATCH 166/494] lint.yml: Always run all 3 linters --- .github/workflows/lint.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7626f1327dc..41560674b49 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,13 +33,17 @@ jobs: python-version: 3.9 - name: Install dependencies + id: deps run: pip install tox - name: Code style check with pycodestyle + if: always() && steps.deps.outcome == 'success' run: tox -e pycodestyle-minimal - name: Code style check with relint + if: always() && steps.deps.outcome == 'success' run: tox -e relint -- src/sage/ - name: Validate docstring markup as RST + if: always() && steps.deps.outcome == 'success' run: tox -e rst From 210d0c5aa0a48df50ee032e5db82f40bba4bf9a6 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 22 Oct 2023 11:17:27 +0000 Subject: [PATCH 167/494] Remove conda patchelf distro --- build/pkgs/patchelf/distros/conda.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 build/pkgs/patchelf/distros/conda.txt diff --git a/build/pkgs/patchelf/distros/conda.txt b/build/pkgs/patchelf/distros/conda.txt deleted file mode 100644 index fca4680084f..00000000000 --- a/build/pkgs/patchelf/distros/conda.txt +++ /dev/null @@ -1 +0,0 @@ -patchelf From 14a70ed0723d403c838d1215c13b93c0f63698ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Sun, 22 Oct 2023 18:45:46 -0300 Subject: [PATCH 168/494] Support launching notebook 7 --- src/bin/sage-notebook | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook index 2e8b12e1a1c..801b0a6a6a3 100755 --- a/src/bin/sage-notebook +++ b/src/bin/sage-notebook @@ -29,7 +29,12 @@ class NotebookJupyter(): def __init__(self, argv): self.print_banner() try: - from notebook.notebookapp import main + try: + # notebook 6 + from notebook.notebookapp import main + except ImportError: + # notebook 7 + from notebook.app import main except ImportError: import traceback traceback.print_exc() From aaf8cac231a227b048c49d53c67d2147b56bf50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Sun, 22 Oct 2023 14:03:37 -0300 Subject: [PATCH 169/494] Fix 'nogil' should appear at the end warnings --- .../combinatorial_polyhedron/face_iterator.pxd | 6 +++--- .../combinatorial_polyhedron/face_iterator.pyx | 10 +++++----- .../face_list_data_structure.pxd | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd index 1dd74505306..e2ad70a6d7c 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd @@ -94,6 +94,6 @@ cdef int parallel_f_vector(iter_t* structures, size_t num_threads, size_t parall # Nogil definitions of crucial functions. -cdef int next_dimension(iter_t structure, size_t parallelization_depth=?) nogil except -1 -cdef int next_face_loop(iter_t structure) nogil except -1 -cdef size_t n_atom_rep(iter_t structure) nogil except -1 +cdef int next_dimension(iter_t structure, size_t parallelization_depth=?) except -1 nogil +cdef int next_face_loop(iter_t structure) except -1 nogil +cdef size_t n_atom_rep(iter_t structure) except -1 nogil diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index f03f0f832ff..d34fe192e8a 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -1923,7 +1923,7 @@ cdef class FaceIterator_geom(FaceIterator_base): # Nogil definitions of crucial functions. -cdef inline int next_dimension(iter_t structure, size_t parallelization_depth=0) nogil except -1: +cdef inline int next_dimension(iter_t structure, size_t parallelization_depth=0) except -1 nogil: r""" See :meth:`FaceIterator.next_dimension`. @@ -1937,7 +1937,7 @@ cdef inline int next_dimension(iter_t structure, size_t parallelization_depth=0) structure._index += 1 return structure.current_dimension -cdef inline int next_face_loop(iter_t structure) nogil except -1: +cdef inline int next_face_loop(iter_t structure) except -1 nogil: r""" See :meth:`FaceIterator.next_face_loop`. """ @@ -2023,7 +2023,7 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1: structure.first_time[structure.current_dimension] = True return 0 -cdef inline size_t n_atom_rep(iter_t structure) nogil except -1: +cdef inline size_t n_atom_rep(iter_t structure) except -1 nogil: r""" See :meth:`FaceIterator.n_atom_rep`. """ @@ -2114,7 +2114,7 @@ cdef int parallel_f_vector(iter_t* structures, size_t num_threads, size_t parall f_vector[j] += parallel_structs[i].f_vector[j] cdef int _parallel_f_vector(iter_t structure, size_t parallelization_depth, - parallel_f_t parallel_struct, size_t job_id) nogil except -1: + parallel_f_t parallel_struct, size_t job_id) except -1 nogil: """ Set up a job and then visit all faces. """ @@ -2129,7 +2129,7 @@ cdef int _parallel_f_vector(iter_t structure, size_t parallelization_depth, cdef inline int prepare_face_iterator_for_partial_job( iter_t structure, size_t parallelization_depth, - parallel_f_t parallel_struct, size_t job_id) nogil except -1: + parallel_f_t parallel_struct, size_t job_id) except -1 nogil: """ Set ``structure`` according to ``job_id``. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd index 79b319e1982..2cade890839 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd @@ -106,7 +106,7 @@ cdef inline int face_list_shallow_copy(face_list_t dst, face_list_t src) except for i in range(src.n_faces): dst.faces[i][0] = src.faces[i][0] -cdef inline int add_face_shallow(face_list_t faces, face_t face) nogil except -1: +cdef inline int add_face_shallow(face_list_t faces, face_t face) except -1 nogil: """ Add a face to faces. """ @@ -246,7 +246,7 @@ cdef inline bint is_not_maximal_fused(face_list_t faces, size_t j, algorithm_var # Arithmetic ############################################################################# -cdef inline int face_list_intersection_fused(face_list_t dest, face_list_t A, face_t b, algorithm_variant algorithm) nogil except -1: +cdef inline int face_list_intersection_fused(face_list_t dest, face_list_t A, face_t b, algorithm_variant algorithm) except -1 nogil: """ Set ``dest`` to be the intersection of each face of ``A`` with ``b``. """ @@ -267,7 +267,7 @@ cdef inline int face_list_intersection_fused(face_list_t dest, face_list_t A, fa cdef inline size_t get_next_level_fused( face_list_t faces, face_list_t new_faces, - face_list_t visited_all, algorithm_variant algorithm) nogil except -1: + face_list_t visited_all, algorithm_variant algorithm) except -1 nogil: """ Set ``new_faces`` to be the facets of ``faces.faces[face.n_faces-1]`` that are not contained in a face of ``visited_all``. @@ -337,7 +337,7 @@ cdef inline size_t get_next_level_fused( cdef inline size_t get_next_level( face_list_t faces, face_list_t new_faces, - face_list_t visited_all) nogil except -1: + face_list_t visited_all) except -1 nogil: cdef size_t output if faces.polyhedron_is_simple: From d7495e201f4b608c43f25348987f75aa6bde2d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Sun, 22 Oct 2023 19:42:58 -0300 Subject: [PATCH 170/494] Fix implicit noexcept warnings (automatic) This was generated as follows: - cythonize sagemath and save all "Implicit noexcept" warnings - sort -u and parse to produce a list of unique filename + line number - pipe the list to the following snippet: while read file line; do sed "$file" -ne "$line"p | grep -q -e noexcept -e '<.*>' || sed -i "$file" -e "$line"'s/\(\( \+\(with \|no\)gil *\)\?[:,]\?\( *#.*\)\?\)$/ noexcept\1/' done --- .../algebras/clifford_algebra_element.pxd | 4 +- .../algebras/clifford_algebra_element.pyx | 14 +- .../algebras/exterior_algebra_groebner.pxd | 28 +- .../algebras/exterior_algebra_groebner.pyx | 40 +-- .../finite_dimensional_algebra_element.pxd | 2 +- .../finite_dimensional_algebra_element.pyx | 14 +- .../fast_parallel_fmats_methods.pxd | 8 +- .../fast_parallel_fmats_methods.pyx | 26 +- .../fast_parallel_fusion_ring_braid_repn.pxd | 4 +- .../fast_parallel_fusion_ring_braid_repn.pyx | 16 +- .../algebras/fusion_rings/poly_tup_engine.pxd | 34 +- .../algebras/fusion_rings/poly_tup_engine.pyx | 44 +-- .../algebras/fusion_rings/shm_managers.pxd | 8 +- .../algebras/fusion_rings/shm_managers.pyx | 8 +- .../free_algebra_element_letterplace.pxd | 4 +- .../free_algebra_element_letterplace.pyx | 14 +- .../letterplace/free_algebra_letterplace.pxd | 4 +- .../letterplace/free_algebra_letterplace.pyx | 8 +- .../lie_algebras/lie_algebra_element.pxd | 40 +-- .../lie_algebras/lie_algebra_element.pyx | 56 ++-- src/sage/algebras/octonion_algebra.pxd | 12 +- src/sage/algebras/octonion_algebra.pyx | 30 +- .../quatalg/quaternion_algebra_element.pxd | 14 +- .../quatalg/quaternion_algebra_element.pyx | 58 ++-- src/sage/arith/functions.pxd | 4 +- src/sage/arith/functions.pyx | 4 +- src/sage/arith/long.pxd | 6 +- src/sage/arith/multi_modular.pxd | 8 +- src/sage/arith/multi_modular.pyx | 8 +- src/sage/arith/power.pxd | 10 +- src/sage/arith/power.pyx | 6 +- src/sage/calculus/integration.pyx | 8 +- src/sage/calculus/interpolation.pxd | 4 +- src/sage/calculus/interpolation.pyx | 4 +- src/sage/calculus/ode.pxd | 4 +- src/sage/calculus/ode.pyx | 14 +- src/sage/calculus/riemann.pyx | 26 +- src/sage/categories/action.pxd | 6 +- src/sage/categories/action.pyx | 18 +- src/sage/categories/category_cy_helper.pxd | 8 +- src/sage/categories/category_cy_helper.pyx | 14 +- .../categories/examples/semigroups_cython.pyx | 4 +- src/sage/categories/map.pxd | 10 +- src/sage/categories/map.pyx | 22 +- src/sage/categories/morphism.pxd | 2 +- src/sage/categories/morphism.pyx | 22 +- src/sage/coding/ag_code_decoders.pyx | 12 +- src/sage/coding/binary_code.pxd | 78 ++--- src/sage/coding/binary_code.pyx | 80 ++--- src/sage/coding/codecan/codecan.pxd | 36 +- src/sage/coding/codecan/codecan.pyx | 48 +-- src/sage/combinat/combinat_cython.pxd | 4 +- src/sage/combinat/combinat_cython.pyx | 6 +- src/sage/combinat/crystals/letters.pxd | 90 ++--- src/sage/combinat/crystals/letters.pyx | 98 +++--- src/sage/combinat/crystals/pbw_datum.pxd | 6 +- src/sage/combinat/crystals/pbw_datum.pyx | 6 +- src/sage/combinat/crystals/spins.pxd | 18 +- src/sage/combinat/crystals/spins.pyx | 20 +- .../crystals/tensor_product_element.pxd | 8 +- .../crystals/tensor_product_element.pyx | 8 +- src/sage/combinat/debruijn_sequence.pyx | 2 +- src/sage/combinat/degree_sequences.pyx | 6 +- src/sage/combinat/designs/designs_pyx.pxd | 2 +- src/sage/combinat/designs/designs_pyx.pyx | 6 +- .../orthogonal_arrays_find_recursive.pyx | 26 +- .../combinat/designs/subhypergraph_search.pyx | 22 +- .../combinat/enumeration_mod_permgroup.pxd | 12 +- .../combinat/enumeration_mod_permgroup.pyx | 12 +- src/sage/combinat/fast_vector_partitions.pyx | 4 +- src/sage/combinat/permutation_cython.pxd | 16 +- src/sage/combinat/permutation_cython.pyx | 16 +- .../combinat/posets/hasse_cython_flint.pyx | 4 +- .../posets/linear_extension_iterator.pyx | 6 +- .../rigged_partition.pxd | 6 +- .../rigged_partition.pyx | 6 +- src/sage/combinat/root_system/braid_orbit.pyx | 6 +- .../root_system/reflection_group_c.pyx | 24 +- .../root_system/reflection_group_element.pxd | 12 +- .../root_system/reflection_group_element.pyx | 16 +- src/sage/combinat/set_partition_iterator.pyx | 2 +- src/sage/combinat/subword_complex_c.pyx | 4 +- src/sage/combinat/words/word_char.pyx | 6 +- src/sage/combinat/words/word_datatypes.pyx | 4 +- src/sage/cpython/getattr.pxd | 2 +- src/sage/cpython/getattr.pyx | 4 +- src/sage/cpython/string.pxd | 6 +- src/sage/cpython/type.pxd | 2 +- src/sage/cpython/type.pyx | 2 +- src/sage/cpython/wrapperdescr.pxd | 2 +- src/sage/cpython/wrapperdescr.pyx | 2 +- src/sage/crypto/boolean_function.pxd | 4 +- src/sage/crypto/boolean_function.pyx | 8 +- src/sage/crypto/sbox.pyx | 14 +- src/sage/data_structures/binary_matrix.pxd | 18 +- src/sage/data_structures/binary_search.pxd | 4 +- src/sage/data_structures/binary_search.pyx | 4 +- src/sage/data_structures/bitset.pxd | 40 +-- src/sage/data_structures/bitset.pyx | 42 +-- src/sage/data_structures/bitset_base.pxd | 122 +++---- src/sage/data_structures/bitset_base.pyx | 12 +- src/sage/data_structures/blas_dict.pxd | 20 +- src/sage/data_structures/blas_dict.pyx | 20 +- .../bounded_integer_sequences.pxd | 24 +- .../bounded_integer_sequences.pyx | 24 +- .../projective_ds_helper.pyx | 12 +- .../complex_dynamics/mandel_julia_helper.pyx | 16 +- src/sage/ext/fast_callable.pyx | 10 +- src/sage/ext/memory.pyx | 8 +- src/sage/ext/memory_allocator.pxd | 2 +- src/sage/ext/stdsage.pxd | 6 +- src/sage/functions/prime_pi.pyx | 2 +- src/sage/geometry/integral_points.pxi | 46 +-- .../combinatorial_polyhedron/base.pxd | 44 +-- .../combinatorial_polyhedron/base.pyx | 44 +-- .../combinatorial_face.pxd | 2 +- .../combinatorial_face.pyx | 2 +- .../face_data_structure.pxd | 40 +-- .../face_iterator.pxd | 2 +- .../face_iterator.pyx | 4 +- .../face_list_data_structure.pxd | 20 +- .../face_list_data_structure.pyx | 4 +- .../list_of_faces.pxd | 20 +- .../list_of_faces.pyx | 14 +- .../polyhedron_face_lattice.pxd | 12 +- .../polyhedron_face_lattice.pyx | 12 +- src/sage/geometry/toric_lattice_element.pyx | 4 +- src/sage/geometry/triangulation/base.pyx | 40 +-- src/sage/graphs/asteroidal_triples.pyx | 2 +- src/sage/graphs/base/boost_graph.pyx | 46 +-- src/sage/graphs/base/c_graph.pxd | 44 +-- src/sage/graphs/base/c_graph.pyx | 50 +-- src/sage/graphs/base/dense_graph.pxd | 2 +- src/sage/graphs/base/dense_graph.pyx | 4 +- src/sage/graphs/base/sparse_graph.pxd | 22 +- src/sage/graphs/base/sparse_graph.pyx | 20 +- src/sage/graphs/base/static_dense_graph.pxd | 2 +- src/sage/graphs/base/static_dense_graph.pyx | 2 +- .../graphs/base/static_sparse_backend.pxd | 2 +- .../graphs/base/static_sparse_backend.pyx | 14 +- src/sage/graphs/base/static_sparse_graph.pxd | 14 +- src/sage/graphs/base/static_sparse_graph.pyx | 20 +- src/sage/graphs/centrality.pyx | 8 +- src/sage/graphs/connectivity.pxd | 42 +-- src/sage/graphs/connectivity.pyx | 48 +-- src/sage/graphs/convexity_properties.pxd | 12 +- src/sage/graphs/convexity_properties.pyx | 12 +- src/sage/graphs/distances_all_pairs.pxd | 4 +- src/sage/graphs/distances_all_pairs.pyx | 22 +- src/sage/graphs/edge_connectivity.pyx | 34 +- src/sage/graphs/generic_graph_pyx.pxd | 4 +- src/sage/graphs/generic_graph_pyx.pyx | 10 +- src/sage/graphs/genus.pyx | 20 +- src/sage/graphs/graph_coloring.pyx | 8 +- .../graphs/graph_decompositions/bandwidth.pyx | 4 +- .../clique_separators.pyx | 2 +- .../graphs/graph_decompositions/cutwidth.pyx | 2 +- .../graph_decompositions/fast_digraph.pxd | 6 +- .../graph_decompositions/fast_digraph.pyx | 6 +- .../graphs/graph_decompositions/rankwidth.pxd | 2 +- .../graphs/graph_decompositions/rankwidth.pyx | 10 +- .../tree_decomposition.pxd | 2 +- .../tree_decomposition.pyx | 2 +- .../vertex_separation.pxd | 2 +- .../vertex_separation.pyx | 12 +- src/sage/graphs/hyperbolicity.pyx | 16 +- src/sage/graphs/independent_sets.pyx | 2 +- src/sage/graphs/matchpoly.pyx | 2 +- src/sage/graphs/strongly_regular_db.pyx | 8 +- src/sage/graphs/traversals.pxd | 2 +- src/sage/graphs/traversals.pyx | 6 +- src/sage/graphs/trees.pxd | 4 +- src/sage/graphs/trees.pyx | 4 +- src/sage/graphs/weakly_chordal.pyx | 6 +- src/sage/groups/libgap_wrapper.pxd | 4 +- src/sage/groups/libgap_wrapper.pyx | 8 +- src/sage/groups/matrix_gps/group_element.pxd | 8 +- src/sage/groups/matrix_gps/group_element.pyx | 10 +- .../groups/matrix_gps/group_element_gap.pxd | 4 +- .../groups/matrix_gps/group_element_gap.pyx | 6 +- .../automorphism_group_canonical_label.pxd | 14 +- .../automorphism_group_canonical_label.pyx | 24 +- .../partn_ref/canonical_augmentation.pxd | 44 +-- .../partn_ref/canonical_augmentation.pyx | 24 +- .../perm_gps/partn_ref/data_structures.pxd | 118 +++---- .../perm_gps/partn_ref/data_structures.pyx | 68 ++-- .../perm_gps/partn_ref/double_coset.pxd | 12 +- .../perm_gps/partn_ref/double_coset.pyx | 16 +- .../perm_gps/partn_ref/refinement_binary.pxd | 8 +- .../perm_gps/partn_ref/refinement_binary.pyx | 18 +- .../perm_gps/partn_ref/refinement_graphs.pyx | 44 +-- .../perm_gps/partn_ref/refinement_lists.pxd | 6 +- .../perm_gps/partn_ref/refinement_lists.pyx | 6 +- .../partn_ref/refinement_matrices.pxd | 6 +- .../partn_ref/refinement_matrices.pyx | 6 +- .../perm_gps/partn_ref/refinement_python.pyx | 6 +- .../perm_gps/partn_ref/refinement_sets.pxd | 32 +- .../perm_gps/partn_ref/refinement_sets.pyx | 36 +- .../partn_ref2/refinement_generic.pxd | 48 +-- .../partn_ref2/refinement_generic.pyx | 48 +-- .../groups/perm_gps/permgroup_element.pxd | 32 +- .../groups/perm_gps/permgroup_element.pyx | 40 +-- .../semimonomial_transformation.pxd | 4 +- .../semimonomial_transformation.pyx | 6 +- src/sage/interacts/library_cython.pyx | 6 +- src/sage/lfunctions/zero_sums.pyx | 6 +- src/sage/libs/ecl.pyx | 26 +- src/sage/libs/eclib/mat.pxd | 2 +- src/sage/libs/eclib/mat.pyx | 4 +- src/sage/libs/eclib/mwrank.pyx | 4 +- src/sage/libs/flint/fmpq_poly.pxd | 2 +- src/sage/libs/flint/fmpz_factor.pxd | 2 +- src/sage/libs/flint/fmpz_factor.pyx | 2 +- src/sage/libs/flint/nmod_poly_linkage.pxi | 12 +- src/sage/libs/gap/element.pxd | 54 +-- src/sage/libs/gap/element.pyx | 74 ++--- src/sage/libs/gap/util.pxd | 12 +- src/sage/libs/gap/util.pyx | 16 +- src/sage/libs/glpk/error.pyx | 4 +- src/sage/libs/gmp/binop.pxd | 6 +- src/sage/libs/gmp/pylong.pxd | 6 +- src/sage/libs/gmp/pylong.pyx | 8 +- src/sage/libs/gmp/randomize.pxd | 12 +- src/sage/libs/lcalc/lcalc_Lfunction.pxd | 14 +- src/sage/libs/lcalc/lcalc_Lfunction.pyx | 68 ++-- src/sage/libs/linbox/conversion.pxd | 12 +- .../libs/linbox/linbox_flint_interface.pxd | 10 +- .../libs/linbox/linbox_flint_interface.pyx | 16 +- .../libs/linkages/padics/Polynomial_ram.pxi | 6 +- .../linkages/padics/Polynomial_shared.pxi | 2 +- .../libs/linkages/padics/fmpz_poly_unram.pxi | 12 +- src/sage/libs/linkages/padics/mpz.pxi | 8 +- .../libs/linkages/padics/relaxed/flint.pxi | 74 ++--- src/sage/libs/mpmath/ext_impl.pxd | 104 +++--- src/sage/libs/mpmath/ext_impl.pyx | 158 ++++----- src/sage/libs/mpmath/ext_main.pyx | 12 +- src/sage/libs/mpmath/utils.pxd | 2 +- src/sage/libs/mpmath/utils.pyx | 12 +- src/sage/libs/ntl/conversion.pxd | 8 +- src/sage/libs/ntl/convert.pxd | 6 +- src/sage/libs/ntl/convert.pyx | 2 +- src/sage/libs/ntl/misc.pxi | 4 +- src/sage/libs/ntl/ntl_GF2E.pxd | 2 +- src/sage/libs/ntl/ntl_GF2E.pyx | 2 +- src/sage/libs/ntl/ntl_GF2EContext.pxd | 2 +- src/sage/libs/ntl/ntl_GF2EContext.pyx | 2 +- src/sage/libs/ntl/ntl_GF2EX.pxd | 4 +- src/sage/libs/ntl/ntl_GF2EX.pyx | 4 +- src/sage/libs/ntl/ntl_GF2X_linkage.pxi | 10 +- src/sage/libs/ntl/ntl_ZZ.pxd | 4 +- src/sage/libs/ntl/ntl_ZZ.pyx | 6 +- src/sage/libs/ntl/ntl_ZZX.pxd | 4 +- src/sage/libs/ntl/ntl_ZZX.pyx | 14 +- src/sage/libs/ntl/ntl_ZZ_p.pxd | 6 +- src/sage/libs/ntl/ntl_ZZ_p.pyx | 6 +- src/sage/libs/ntl/ntl_ZZ_pContext.pxd | 4 +- src/sage/libs/ntl/ntl_ZZ_pContext.pyx | 4 +- src/sage/libs/ntl/ntl_ZZ_pE.pxd | 6 +- src/sage/libs/ntl/ntl_ZZ_pE.pyx | 6 +- src/sage/libs/ntl/ntl_ZZ_pEContext.pxd | 2 +- src/sage/libs/ntl/ntl_ZZ_pEContext.pyx | 2 +- src/sage/libs/ntl/ntl_ZZ_pEX.pxd | 2 +- src/sage/libs/ntl/ntl_ZZ_pEX.pyx | 2 +- src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi | 10 +- src/sage/libs/ntl/ntl_ZZ_pX.pxd | 6 +- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 10 +- src/sage/libs/ntl/ntl_lzz_p.pxd | 2 +- src/sage/libs/ntl/ntl_lzz_p.pyx | 2 +- src/sage/libs/ntl/ntl_lzz_pContext.pxd | 2 +- src/sage/libs/ntl/ntl_lzz_pContext.pyx | 2 +- src/sage/libs/ntl/ntl_lzz_pX.pxd | 2 +- src/sage/libs/ntl/ntl_lzz_pX.pyx | 2 +- src/sage/libs/ntl/ntl_mat_GF2.pxd | 4 +- src/sage/libs/ntl/ntl_mat_GF2.pyx | 4 +- src/sage/libs/ntl/ntl_mat_GF2E.pxd | 4 +- src/sage/libs/ntl/ntl_mat_GF2E.pyx | 4 +- src/sage/libs/ntl/ntl_mat_ZZ.pyx | 8 +- src/sage/libs/pari/convert_flint.pxd | 16 +- src/sage/libs/pari/convert_flint.pyx | 16 +- src/sage/libs/pari/convert_gmp.pxd | 18 +- src/sage/libs/pari/convert_gmp.pyx | 18 +- src/sage/libs/pari/convert_sage.pxd | 18 +- src/sage/libs/pari/convert_sage.pyx | 20 +- .../libs/pari/convert_sage_complex_double.pxd | 16 +- .../libs/pari/convert_sage_complex_double.pyx | 16 +- .../libs/pari/convert_sage_real_double.pxd | 2 +- .../libs/pari/convert_sage_real_double.pyx | 2 +- src/sage/libs/pari/misc.pxd | 2 +- src/sage/libs/pari/misc.pyx | 2 +- src/sage/libs/singular/function.pxd | 28 +- src/sage/libs/singular/function.pyx | 52 +-- src/sage/libs/singular/groebner_strategy.pxd | 4 +- src/sage/libs/singular/groebner_strategy.pyx | 4 +- src/sage/libs/singular/polynomial.pxd | 22 +- src/sage/libs/singular/polynomial.pyx | 22 +- src/sage/libs/singular/ring.pxd | 4 +- src/sage/libs/singular/ring.pyx | 8 +- src/sage/libs/singular/singular.pxd | 42 +-- src/sage/libs/singular/singular.pyx | 52 +-- src/sage/libs/symmetrica/sb.pxi | 2 +- src/sage/libs/symmetrica/symmetrica.pxi | 80 ++--- src/sage/matrix/action.pyx | 12 +- src/sage/matrix/args.pxd | 14 +- src/sage/matrix/args.pyx | 10 +- src/sage/matrix/matrix0.pxd | 46 +-- src/sage/matrix/matrix0.pyx | 58 ++-- src/sage/matrix/matrix1.pxd | 6 +- src/sage/matrix/matrix1.pyx | 6 +- src/sage/matrix/matrix2.pxd | 12 +- src/sage/matrix/matrix2.pyx | 12 +- src/sage/matrix/matrix_cdv.pxd | 2 +- src/sage/matrix/matrix_cdv.pyx | 2 +- src/sage/matrix/matrix_complex_ball_dense.pxd | 8 +- src/sage/matrix/matrix_complex_ball_dense.pyx | 30 +- src/sage/matrix/matrix_cyclo_dense.pxd | 2 +- src/sage/matrix/matrix_cyclo_dense.pyx | 16 +- src/sage/matrix/matrix_dense.pxd | 2 +- src/sage/matrix/matrix_dense.pyx | 8 +- src/sage/matrix/matrix_double_dense.pyx | 10 +- src/sage/matrix/matrix_gap.pxd | 4 +- src/sage/matrix/matrix_gap.pyx | 16 +- src/sage/matrix/matrix_generic_dense.pxd | 2 +- src/sage/matrix/matrix_generic_dense.pyx | 10 +- src/sage/matrix/matrix_generic_sparse.pyx | 6 +- src/sage/matrix/matrix_gf2e_dense.pxd | 6 +- src/sage/matrix/matrix_gf2e_dense.pyx | 32 +- src/sage/matrix/matrix_integer_dense.pxd | 24 +- src/sage/matrix/matrix_integer_dense.pyx | 54 +-- src/sage/matrix/matrix_integer_sparse.pxd | 2 +- src/sage/matrix/matrix_integer_sparse.pyx | 14 +- src/sage/matrix/matrix_mod2_dense.pxd | 6 +- src/sage/matrix/matrix_mod2_dense.pyx | 36 +- src/sage/matrix/matrix_modn_dense_double.pyx | 6 +- src/sage/matrix/matrix_modn_dense_float.pyx | 6 +- .../matrix/matrix_modn_dense_template.pxi | 52 +-- .../matrix_modn_dense_template_header.pxi | 6 +- src/sage/matrix/matrix_modn_sparse.pxd | 2 +- src/sage/matrix/matrix_modn_sparse.pyx | 10 +- src/sage/matrix/matrix_numpy_dense.pxd | 2 +- src/sage/matrix/matrix_numpy_dense.pyx | 6 +- src/sage/matrix/matrix_rational_dense.pxd | 12 +- src/sage/matrix/matrix_rational_dense.pyx | 34 +- src/sage/matrix/matrix_rational_sparse.pyx | 6 +- src/sage/matrix/matrix_real_double_dense.pxd | 4 +- src/sage/matrix/matrix_real_double_dense.pyx | 4 +- src/sage/matrix/matrix_sparse.pyx | 16 +- src/sage/matrix/matrix_window.pxd | 38 +-- src/sage/matrix/matrix_window.pyx | 38 +-- src/sage/matrix/strassen.pyx | 6 +- src/sage/matroids/basis_exchange_matroid.pxd | 152 ++++----- src/sage/matroids/basis_exchange_matroid.pyx | 134 ++++---- src/sage/matroids/basis_matroid.pxd | 60 ++-- src/sage/matroids/basis_matroid.pyx | 52 +-- .../matroids/circuit_closures_matroid.pxd | 16 +- .../matroids/circuit_closures_matroid.pyx | 16 +- src/sage/matroids/extension.pxd | 10 +- src/sage/matroids/extension.pyx | 10 +- src/sage/matroids/lean_matrix.pxd | 90 ++--- src/sage/matroids/lean_matrix.pyx | 212 ++++++------ src/sage/matroids/linear_matroid.pxd | 224 ++++++------- src/sage/matroids/linear_matroid.pyx | 240 +++++++------- src/sage/matroids/matroid.pxd | 310 +++++++++--------- src/sage/matroids/matroid.pyx | 292 ++++++++--------- src/sage/matroids/set_system.pxd | 40 +-- src/sage/matroids/set_system.pyx | 40 +-- src/sage/matroids/union_matroid.pxd | 12 +- src/sage/matroids/union_matroid.pyx | 12 +- src/sage/misc/allocator.pxd | 4 +- src/sage/misc/allocator.pyx | 6 +- src/sage/misc/binary_tree.pyx | 20 +- src/sage/misc/c3.pyx | 2 +- src/sage/misc/c3_controlled.pxd | 2 +- src/sage/misc/c3_controlled.pyx | 4 +- src/sage/misc/cachefunc.pxd | 10 +- src/sage/misc/cachefunc.pyx | 18 +- src/sage/misc/citation.pyx | 2 +- src/sage/misc/fast_methods.pxd | 2 +- src/sage/misc/function_mangling.pxd | 2 +- src/sage/misc/function_mangling.pyx | 2 +- src/sage/misc/lazy_import.pyx | 14 +- src/sage/misc/lazy_list.pxd | 4 +- src/sage/misc/lazy_list.pyx | 4 +- src/sage/misc/lazy_string.pxd | 4 +- src/sage/misc/lazy_string.pyx | 4 +- src/sage/misc/misc_c.pxd | 2 +- src/sage/misc/misc_c.pyx | 8 +- src/sage/misc/nested_class.pyx | 2 +- src/sage/misc/parser.pyx | 46 +-- src/sage/misc/persist.pyx | 2 +- src/sage/misc/randstate.pxd | 16 +- src/sage/misc/randstate.pyx | 20 +- src/sage/misc/sage_ostools.pyx | 2 +- src/sage/misc/search.pxd | 2 +- src/sage/misc/search.pyx | 2 +- .../modular/arithgroup/arithgroup_element.pyx | 4 +- src/sage/modular/arithgroup/farey_symbol.pyx | 10 +- src/sage/modular/hypergeometric_misc.pxd | 2 +- src/sage/modular/hypergeometric_misc.pyx | 2 +- .../modular/modform/eis_series_cython.pyx | 4 +- .../modform/l_series_gross_zagier_coeffs.pyx | 2 +- src/sage/modular/modsym/heilbronn.pyx | 10 +- src/sage/modular/modsym/manin_symbol.pyx | 2 +- src/sage/modular/modsym/p1list.pxd | 4 +- src/sage/modular/modsym/p1list.pyx | 4 +- src/sage/modular/pollack_stevens/dist.pxd | 18 +- src/sage/modular/pollack_stevens/dist.pyx | 34 +- src/sage/modules/finite_submodule_iter.pxd | 2 +- src/sage/modules/finite_submodule_iter.pyx | 2 +- src/sage/modules/free_module_element.pxd | 8 +- src/sage/modules/free_module_element.pyx | 54 +-- src/sage/modules/module.pyx | 2 +- src/sage/modules/vector_double_dense.pyx | 12 +- src/sage/modules/vector_integer_dense.pxd | 2 +- src/sage/modules/vector_integer_dense.pyx | 22 +- src/sage/modules/vector_integer_sparse.pxd | 12 +- src/sage/modules/vector_integer_sparse.pyx | 12 +- src/sage/modules/vector_mod2_dense.pxd | 4 +- src/sage/modules/vector_mod2_dense.pyx | 26 +- src/sage/modules/vector_modn_dense.pxd | 4 +- src/sage/modules/vector_modn_dense.pyx | 24 +- src/sage/modules/vector_modn_sparse.pxd | 10 +- src/sage/modules/vector_modn_sparse.pyx | 10 +- src/sage/modules/vector_numpy_dense.pxd | 4 +- src/sage/modules/vector_numpy_dense.pyx | 10 +- src/sage/modules/vector_rational_dense.pxd | 2 +- src/sage/modules/vector_rational_dense.pyx | 24 +- src/sage/modules/vector_rational_sparse.pxd | 12 +- src/sage/modules/vector_rational_sparse.pyx | 12 +- .../modules/with_basis/indexed_element.pxd | 8 +- .../modules/with_basis/indexed_element.pyx | 16 +- .../monoids/free_abelian_monoid_element.pxd | 2 +- .../monoids/free_abelian_monoid_element.pyx | 2 +- .../numerical/backends/cvxopt_backend.pyx | 50 +-- .../numerical/backends/cvxopt_sdp_backend.pyx | 12 +- src/sage/numerical/backends/cvxpy_backend.pxd | 2 +- src/sage/numerical/backends/cvxpy_backend.pyx | 48 +-- .../numerical/backends/generic_backend.pxd | 84 ++--- .../numerical/backends/generic_backend.pyx | 84 ++--- .../backends/generic_sdp_backend.pxd | 40 +-- .../backends/generic_sdp_backend.pyx | 40 +-- src/sage/numerical/backends/glpk_backend.pxd | 16 +- src/sage/numerical/backends/glpk_backend.pyx | 88 ++--- .../numerical/backends/glpk_exact_backend.pxd | 2 +- .../numerical/backends/glpk_exact_backend.pyx | 2 +- .../numerical/backends/glpk_graph_backend.pxd | 42 +-- .../numerical/backends/glpk_graph_backend.pyx | 42 +-- .../backends/interactivelp_backend.pxd | 4 +- .../backends/interactivelp_backend.pyx | 66 ++-- .../numerical/backends/matrix_sdp_backend.pyx | 26 +- src/sage/numerical/backends/ppl_backend.pyx | 54 +-- src/sage/numerical/backends/scip_backend.pxd | 6 +- src/sage/numerical/backends/scip_backend.pyx | 66 ++-- src/sage/numerical/linear_functions.pxd | 22 +- src/sage/numerical/linear_functions.pyx | 28 +- src/sage/numerical/linear_tensor_element.pxd | 2 +- src/sage/numerical/linear_tensor_element.pyx | 8 +- src/sage/numerical/mip.pxd | 10 +- src/sage/numerical/mip.pyx | 10 +- src/sage/numerical/sdp.pxd | 16 +- src/sage/numerical/sdp.pyx | 16 +- src/sage/plot/complex_plot.pyx | 10 +- src/sage/plot/plot3d/implicit_surface.pyx | 28 +- src/sage/plot/plot3d/index_face_set.pyx | 18 +- src/sage/plot/plot3d/parametric_surface.pyx | 2 +- src/sage/plot/plot3d/point_c.pxi | 38 +-- src/sage/plot/plot3d/transform.pxd | 10 +- src/sage/plot/plot3d/transform.pyx | 10 +- src/sage/quadratic_forms/count_local_2.pyx | 4 +- .../quadratic_form__evaluate.pyx | 4 +- src/sage/quivers/algebra_elements.pxd | 20 +- src/sage/quivers/algebra_elements.pxi | 34 +- src/sage/quivers/algebra_elements.pyx | 32 +- src/sage/quivers/paths.pxd | 8 +- src/sage/quivers/paths.pyx | 10 +- src/sage/rings/complex_arb.pxd | 18 +- src/sage/rings/complex_arb.pyx | 32 +- src/sage/rings/complex_conversion.pxd | 2 +- src/sage/rings/complex_conversion.pyx | 2 +- src/sage/rings/complex_double.pxd | 10 +- src/sage/rings/complex_double.pyx | 32 +- src/sage/rings/complex_interval.pxd | 4 +- src/sage/rings/complex_interval.pyx | 10 +- src/sage/rings/complex_mpc.pxd | 10 +- src/sage/rings/complex_mpc.pyx | 40 +-- src/sage/rings/complex_mpfr.pxd | 10 +- src/sage/rings/complex_mpfr.pyx | 30 +- src/sage/rings/convert/mpfi.pyx | 2 +- src/sage/rings/factorint.pyx | 6 +- src/sage/rings/fast_arith.pxd | 2 +- src/sage/rings/fast_arith.pyx | 2 +- src/sage/rings/finite_rings/element_base.pxd | 2 +- src/sage/rings/finite_rings/element_base.pyx | 2 +- .../rings/finite_rings/element_givaro.pxd | 18 +- .../rings/finite_rings/element_givaro.pyx | 32 +- .../rings/finite_rings/element_ntl_gf2e.pxd | 4 +- .../rings/finite_rings/element_ntl_gf2e.pyx | 22 +- .../rings/finite_rings/element_pari_ffelt.pxd | 4 +- .../rings/finite_rings/element_pari_ffelt.pyx | 14 +- .../rings/finite_rings/finite_field_base.pyx | 4 +- .../rings/finite_rings/hom_finite_field.pxd | 4 +- .../rings/finite_rings/hom_finite_field.pyx | 12 +- .../finite_rings/hom_finite_field_givaro.pxd | 4 +- .../finite_rings/hom_finite_field_givaro.pyx | 6 +- .../finite_rings/hom_prime_finite_field.pyx | 6 +- src/sage/rings/finite_rings/integer_mod.pxd | 40 +-- src/sage/rings/finite_rings/integer_mod.pyx | 130 ++++---- src/sage/rings/finite_rings/residue_field.pyx | 18 +- src/sage/rings/fraction_field_FpT.pxd | 18 +- src/sage/rings/fraction_field_FpT.pyx | 72 ++-- src/sage/rings/fraction_field_element.pyx | 14 +- src/sage/rings/function_field/element.pxd | 6 +- src/sage/rings/function_field/element.pyx | 6 +- .../rings/function_field/element_polymod.pyx | 18 +- .../rings/function_field/element_rational.pyx | 16 +- src/sage/rings/integer.pxd | 42 +-- src/sage/rings/integer.pyx | 74 ++--- src/sage/rings/integer_fake.pxd | 2 +- src/sage/rings/integer_ring.pyx | 4 +- .../rings/laurent_series_ring_element.pxd | 6 +- .../rings/laurent_series_ring_element.pyx | 16 +- src/sage/rings/morphism.pyx | 52 +-- .../rings/number_field/number_field_base.pxd | 2 +- .../rings/number_field/number_field_base.pyx | 2 +- .../number_field/number_field_element.pxd | 26 +- .../number_field/number_field_element.pyx | 40 +-- .../number_field_element_quadratic.pxd | 14 +- .../number_field_element_quadratic.pyx | 52 +-- .../number_field/number_field_morphisms.pyx | 20 +- src/sage/rings/number_field/totallyreal.pyx | 2 +- .../rings/number_field/totallyreal_data.pxd | 14 +- .../rings/number_field/totallyreal_data.pyx | 14 +- src/sage/rings/padics/CA_template.pxi | 60 ++-- src/sage/rings/padics/CA_template_header.pxi | 2 +- src/sage/rings/padics/CR_template.pxi | 72 ++-- src/sage/rings/padics/CR_template_header.pxi | 4 +- src/sage/rings/padics/FM_template.pxi | 60 ++-- src/sage/rings/padics/FM_template_header.pxi | 2 +- src/sage/rings/padics/FP_template.pxi | 80 ++--- src/sage/rings/padics/FP_template_header.pxi | 4 +- .../rings/padics/local_generic_element.pyx | 4 +- src/sage/rings/padics/morphism.pxd | 2 +- src/sage/rings/padics/morphism.pyx | 8 +- .../rings/padics/padic_ZZ_pX_CA_element.pxd | 16 +- .../rings/padics/padic_ZZ_pX_CA_element.pyx | 32 +- .../rings/padics/padic_ZZ_pX_CR_element.pxd | 16 +- .../rings/padics/padic_ZZ_pX_CR_element.pyx | 32 +- .../rings/padics/padic_ZZ_pX_FM_element.pxd | 8 +- .../rings/padics/padic_ZZ_pX_FM_element.pyx | 26 +- src/sage/rings/padics/padic_ZZ_pX_element.pyx | 8 +- .../padics/padic_capped_absolute_element.pxd | 4 +- .../padics/padic_capped_absolute_element.pyx | 4 +- .../padics/padic_capped_relative_element.pxd | 4 +- .../padics/padic_capped_relative_element.pyx | 4 +- src/sage/rings/padics/padic_ext_element.pxd | 6 +- src/sage/rings/padics/padic_ext_element.pyx | 6 +- .../rings/padics/padic_fixed_mod_element.pxd | 4 +- .../rings/padics/padic_fixed_mod_element.pyx | 4 +- .../padics/padic_floating_point_element.pxd | 4 +- .../padics/padic_floating_point_element.pyx | 4 +- .../rings/padics/padic_generic_element.pxd | 12 +- .../rings/padics/padic_generic_element.pyx | 20 +- src/sage/rings/padics/padic_printing.pxd | 26 +- src/sage/rings/padics/padic_printing.pyx | 26 +- .../rings/padics/padic_template_element.pxi | 14 +- .../padics/padic_template_element_header.pxi | 10 +- src/sage/rings/padics/pow_computer.pxd | 4 +- src/sage/rings/padics/pow_computer.pyx | 8 +- src/sage/rings/padics/pow_computer_ext.pxd | 34 +- src/sage/rings/padics/pow_computer_ext.pyx | 66 ++-- src/sage/rings/padics/pow_computer_flint.pxd | 8 +- src/sage/rings/padics/pow_computer_flint.pyx | 10 +- .../rings/padics/pow_computer_relative.pxd | 4 +- .../rings/padics/pow_computer_relative.pyx | 4 +- src/sage/rings/padics/relaxed_template.pxi | 116 +++---- .../rings/padics/relaxed_template_header.pxi | 32 +- .../rings/polynomial/evaluation_flint.pxd | 4 +- .../rings/polynomial/evaluation_flint.pyx | 4 +- src/sage/rings/polynomial/evaluation_ntl.pxd | 4 +- src/sage/rings/polynomial/evaluation_ntl.pyx | 4 +- src/sage/rings/polynomial/hilbert.pyx | 16 +- .../rings/polynomial/laurent_polynomial.pxd | 14 +- .../rings/polynomial/laurent_polynomial.pyx | 32 +- .../polynomial/laurent_polynomial_mpair.pxd | 10 +- .../polynomial/laurent_polynomial_mpair.pyx | 30 +- .../rings/polynomial/multi_polynomial.pxd | 4 +- .../rings/polynomial/multi_polynomial.pyx | 6 +- .../multi_polynomial_ideal_libsingular.pxd | 2 +- .../multi_polynomial_ideal_libsingular.pyx | 2 +- .../multi_polynomial_libsingular.pxd | 18 +- .../multi_polynomial_libsingular.pyx | 32 +- .../polynomial/multi_polynomial_ring_base.pxd | 2 +- .../polynomial/multi_polynomial_ring_base.pyx | 2 +- .../polynomial/ore_polynomial_element.pxd | 44 +-- .../polynomial/ore_polynomial_element.pyx | 68 ++-- src/sage/rings/polynomial/pbori/pbori.pxd | 8 +- src/sage/rings/polynomial/pbori/pbori.pyx | 66 ++-- src/sage/rings/polynomial/plural.pxd | 16 +- src/sage/rings/polynomial/plural.pyx | 28 +- src/sage/rings/polynomial/polydict.pxd | 44 +-- src/sage/rings/polynomial/polydict.pyx | 46 +-- .../rings/polynomial/polynomial_compiled.pxd | 14 +- .../rings/polynomial/polynomial_compiled.pyx | 28 +- .../polynomial/polynomial_complex_arb.pxd | 2 +- .../polynomial/polynomial_complex_arb.pyx | 30 +- .../rings/polynomial/polynomial_element.pxd | 56 ++-- .../rings/polynomial/polynomial_element.pyx | 96 +++--- src/sage/rings/polynomial/polynomial_gf2x.pyx | 4 +- .../polynomial_integer_dense_flint.pxd | 6 +- .../polynomial_integer_dense_flint.pyx | 30 +- .../polynomial_integer_dense_ntl.pxd | 2 +- .../polynomial_integer_dense_ntl.pyx | 18 +- .../polynomial/polynomial_modn_dense_ntl.pxd | 8 +- .../polynomial/polynomial_modn_dense_ntl.pyx | 58 ++-- .../polynomial/polynomial_rational_flint.pxd | 8 +- .../polynomial/polynomial_rational_flint.pyx | 32 +- .../polynomial/polynomial_real_mpfr_dense.pyx | 20 +- .../polynomial_ring_homomorphism.pyx | 4 +- .../rings/polynomial/polynomial_template.pxi | 20 +- .../polynomial/polynomial_template_header.pxi | 2 +- .../polynomial/polynomial_zmod_flint.pxd | 6 +- .../polynomial/polynomial_zmod_flint.pyx | 14 +- .../rings/polynomial/polynomial_zz_pex.pyx | 10 +- src/sage/rings/polynomial/real_roots.pxd | 14 +- src/sage/rings/polynomial/real_roots.pyx | 24 +- .../polynomial/skew_polynomial_element.pxd | 10 +- .../polynomial/skew_polynomial_element.pyx | 20 +- .../skew_polynomial_finite_field.pxd | 10 +- .../skew_polynomial_finite_field.pyx | 8 +- .../skew_polynomial_finite_order.pxd | 4 +- .../skew_polynomial_finite_order.pyx | 4 +- .../polynomial/weil/weil_polynomials.pyx | 4 +- src/sage/rings/power_series_mpoly.pyx | 10 +- src/sage/rings/power_series_pari.pyx | 14 +- src/sage/rings/power_series_poly.pyx | 14 +- src/sage/rings/power_series_ring_element.pxd | 4 +- src/sage/rings/power_series_ring_element.pyx | 10 +- .../rings/puiseux_series_ring_element.pyx | 14 +- src/sage/rings/rational.pxd | 18 +- src/sage/rings/rational.pyx | 54 +-- src/sage/rings/real_arb.pxd | 12 +- src/sage/rings/real_arb.pyx | 20 +- src/sage/rings/real_double.pxd | 12 +- src/sage/rings/real_double.pyx | 26 +- src/sage/rings/real_double_element_gsl.pxd | 6 +- src/sage/rings/real_double_element_gsl.pyx | 10 +- src/sage/rings/real_interval_absolute.pyx | 44 +-- src/sage/rings/real_lazy.pxd | 16 +- src/sage/rings/real_lazy.pyx | 46 +-- src/sage/rings/real_mpfi.pxd | 10 +- src/sage/rings/real_mpfi.pyx | 24 +- src/sage/rings/real_mpfr.pxd | 18 +- src/sage/rings/real_mpfr.pyx | 34 +- src/sage/rings/ring_extension.pxd | 14 +- src/sage/rings/ring_extension.pyx | 22 +- src/sage/rings/ring_extension_conversion.pxd | 18 +- src/sage/rings/ring_extension_conversion.pyx | 18 +- src/sage/rings/ring_extension_element.pxd | 10 +- src/sage/rings/ring_extension_element.pyx | 22 +- src/sage/rings/ring_extension_morphism.pxd | 4 +- src/sage/rings/ring_extension_morphism.pyx | 20 +- .../rings/semirings/tropical_semiring.pyx | 14 +- src/sage/rings/sum_of_squares.pxd | 2 +- src/sage/rings/sum_of_squares.pyx | 4 +- src/sage/rings/tate_algebra_element.pxd | 44 +-- src/sage/rings/tate_algebra_element.pyx | 58 ++-- src/sage/rings/tate_algebra_ideal.pxd | 6 +- src/sage/rings/tate_algebra_ideal.pyx | 6 +- .../elliptic_curves/descent_two_isogeny.pyx | 22 +- .../schemes/elliptic_curves/mod_sym_num.pyx | 8 +- .../elliptic_curves/period_lattice_region.pyx | 4 +- src/sage/schemes/toric/divisor_class.pyx | 4 +- src/sage/sets/finite_set_map_cy.pxd | 28 +- src/sage/sets/finite_set_map_cy.pyx | 36 +- src/sage/sets/pythonclass.pxd | 2 +- src/sage/sets/pythonclass.pyx | 2 +- src/sage/sets/recursively_enumerated_set.pxd | 12 +- src/sage/sets/recursively_enumerated_set.pyx | 12 +- src/sage/stats/hmm/chmm.pyx | 20 +- src/sage/stats/hmm/distributions.pxd | 8 +- src/sage/stats/hmm/distributions.pyx | 10 +- src/sage/stats/hmm/hmm.pxd | 2 +- src/sage/stats/hmm/hmm.pyx | 14 +- src/sage/stats/hmm/util.pxd | 6 +- src/sage/stats/hmm/util.pyx | 6 +- src/sage/stats/intlist.pxd | 4 +- src/sage/stats/intlist.pyx | 6 +- src/sage/stats/time_series.pxd | 4 +- src/sage/stats/time_series.pyx | 6 +- src/sage/structure/category_object.pxd | 6 +- src/sage/structure/category_object.pyx | 6 +- src/sage/structure/coerce.pxd | 32 +- src/sage/structure/coerce.pyx | 32 +- src/sage/structure/coerce_actions.pyx | 20 +- src/sage/structure/coerce_dict.pxd | 8 +- src/sage/structure/coerce_dict.pyx | 26 +- src/sage/structure/coerce_maps.pxd | 2 +- src/sage/structure/coerce_maps.pyx | 48 +-- src/sage/structure/element.pxd | 100 +++--- src/sage/structure/element.pyx | 100 +++--- src/sage/structure/element_wrapper.pxd | 4 +- src/sage/structure/element_wrapper.pyx | 4 +- src/sage/structure/factory.pyx | 8 +- src/sage/structure/list_clone.pxd | 46 +-- src/sage/structure/list_clone.pyx | 50 +-- src/sage/structure/list_clone_demo.pyx | 10 +- src/sage/structure/list_clone_timings_cy.pyx | 8 +- src/sage/structure/mutability.pxd | 8 +- src/sage/structure/mutability.pyx | 8 +- src/sage/structure/parent.pxd | 42 +-- src/sage/structure/parent.pyx | 50 +-- src/sage/structure/parent_base.pyx | 4 +- src/sage/structure/parent_gens.pyx | 2 +- src/sage/structure/parent_old.pxd | 10 +- src/sage/structure/parent_old.pyx | 16 +- src/sage/structure/richcmp.pxd | 12 +- src/sage/structure/richcmp.pyx | 4 +- src/sage/symbolic/comparison_impl.pxi | 8 +- src/sage/symbolic/expression.pxd | 12 +- src/sage/symbolic/expression.pyx | 56 ++-- src/sage/symbolic/function.pxd | 12 +- src/sage/symbolic/function.pyx | 12 +- src/sage/symbolic/pynac_function_impl.pxi | 6 +- src/sage/symbolic/pynac_impl.pxi | 180 +++++----- src/sage/symbolic/ring.pyx | 6 +- src/sage/symbolic/substitution_map_impl.pxi | 6 +- src/sage/tests/stl_vector.pyx | 2 +- 726 files changed, 7045 insertions(+), 7045 deletions(-) diff --git a/src/sage/algebras/clifford_algebra_element.pxd b/src/sage/algebras/clifford_algebra_element.pxd index 14d5a7a625c..be08e06f922 100644 --- a/src/sage/algebras/clifford_algebra_element.pxd +++ b/src/sage/algebras/clifford_algebra_element.pxd @@ -5,8 +5,8 @@ from sage.modules.with_basis.indexed_element cimport IndexedFreeModuleElement from sage.data_structures.bitset cimport FrozenBitset cdef class CliffordAlgebraElement(IndexedFreeModuleElement): - cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) - cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) + cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept + cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept cdef class ExteriorAlgebraElement(CliffordAlgebraElement): pass diff --git a/src/sage/algebras/clifford_algebra_element.pyx b/src/sage/algebras/clifford_algebra_element.pyx index 046ee44c8e9..0a1a4adb681 100644 --- a/src/sage/algebras/clifford_algebra_element.pyx +++ b/src/sage/algebras/clifford_algebra_element.pyx @@ -64,7 +64,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement): """ return repr_from_monomials(self.list(), self._parent._latex_term, True) - cdef _mul_(self, other): + cdef _mul_(self, other) noexcept: """ Return ``self`` multiplied by ``other``. @@ -175,7 +175,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement): return self.__class__(self.parent(), d) - cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff): + cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept: r""" Multiply ``self * term`` with the ``term`` having support ``supp`` and coefficient ``coeff``. @@ -223,7 +223,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement): return type(self)(self._parent, {supp: coeff}) * self - cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff): + cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept: r""" Multiply ``term * self`` with the ``term`` having support ``supp`` and coefficient ``coeff``. @@ -399,7 +399,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement): """ An element of an exterior algebra. """ - cdef _mul_(self, other): + cdef _mul_(self, other) noexcept: """ Return ``self`` multiplied by ``other``. @@ -519,7 +519,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement): return self.__class__(P, d) - cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff): + cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept: r""" Multiply ``self * term`` with the ``term`` having support ``supp`` and coefficient ``coeff``. @@ -609,7 +609,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement): del d[k] return type(self)(self._parent, d) - cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff): + cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept: r""" Multiply ``term * self`` with the ``term`` having support ``supp`` and coefficient ``coeff``. @@ -938,7 +938,7 @@ cdef class CohomologyRAAGElement(CliffordAlgebraElement): :class:`~sage.groups.raag.CohomologyRAAG` """ - cdef _mul_(self, other): + cdef _mul_(self, other) noexcept: """ Return ``self`` multiplied by ``other``. diff --git a/src/sage/algebras/exterior_algebra_groebner.pxd b/src/sage/algebras/exterior_algebra_groebner.pxd index 28cea102be7..bf5ee24ea22 100644 --- a/src/sage/algebras/exterior_algebra_groebner.pxd +++ b/src/sage/algebras/exterior_algebra_groebner.pxd @@ -7,8 +7,8 @@ from sage.algebras.clifford_algebra_element cimport CliffordAlgebraElement from sage.structure.parent cimport Parent from sage.structure.element cimport MonoidElement -cdef long degree(FrozenBitset X) -cdef CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp) +cdef long degree(FrozenBitset X) noexcept +cdef CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp) noexcept cdef class GBElement: cdef CliffordAlgebraElement elt @@ -24,25 +24,25 @@ cdef class GroebnerStrategy: cdef Integer rank cdef public tuple groebner_basis - cdef inline GBElement build_elt(self, CliffordAlgebraElement f) - cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t) - cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f) - cdef inline bint build_S_poly(self, GBElement f, GBElement g) + cdef inline GBElement build_elt(self, CliffordAlgebraElement f) noexcept + cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t) noexcept + cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f) noexcept + cdef inline bint build_S_poly(self, GBElement f, GBElement g) noexcept - cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f) - cdef inline partial_S_poly_left(self, GBElement f, GBElement g) - cdef inline partial_S_poly_right(self, GBElement f, GBElement g) - cdef set preprocessing(self, list P, list G) - cdef list reduction(self, list P, list G) + cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f) noexcept + cdef inline partial_S_poly_left(self, GBElement f, GBElement g) noexcept + cdef inline partial_S_poly_right(self, GBElement f, GBElement g) noexcept + cdef set preprocessing(self, list P, list G) noexcept + cdef list reduction(self, list P, list G) noexcept - cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f) + cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f) noexcept cdef bint reduce_single(self, CliffordAlgebraElement f, CliffordAlgebraElement g) except -1 cdef int reduced_gb(self, list G) except -1 # These are the methods that determine the ordering of the monomials. # These must be implemented in subclasses. Declare them as "inline" there. - cdef Integer bitset_to_int(self, FrozenBitset X) - cdef FrozenBitset int_to_bitset(self, Integer n) + cdef Integer bitset_to_int(self, FrozenBitset X) noexcept + cdef FrozenBitset int_to_bitset(self, Integer n) noexcept cdef class GroebnerStrategyNegLex(GroebnerStrategy): pass diff --git a/src/sage/algebras/exterior_algebra_groebner.pyx b/src/sage/algebras/exterior_algebra_groebner.pyx index ba46a5f38b4..376eb454082 100644 --- a/src/sage/algebras/exterior_algebra_groebner.pyx +++ b/src/sage/algebras/exterior_algebra_groebner.pyx @@ -29,14 +29,14 @@ from sage.structure.richcmp cimport richcmp, rich_to_bool from sage.data_structures.blas_dict cimport iaxpy from copy import copy -cdef inline long degree(FrozenBitset X): +cdef inline long degree(FrozenBitset X) noexcept: """ Compute the degree of ``X``. """ return bitset_len(X._bitset) -cdef inline CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp): +cdef inline CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp) noexcept: """ Helper function for the fastest way to build a monomial. """ @@ -129,14 +129,14 @@ cdef class GroebnerStrategy: else: self.side = 2 - cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f): + cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f) noexcept: """ Return the leading support of the exterior algebra element ``f``. """ cdef dict mc = f._monomial_coefficients return self.int_to_bitset(max(self.bitset_to_int(k) for k in mc)) - cdef inline partial_S_poly_left(self, GBElement f, GBElement g): + cdef inline partial_S_poly_left(self, GBElement f, GBElement g) noexcept: r""" Compute one half of the `S`-polynomial for ``f`` and ``g``. @@ -153,7 +153,7 @@ cdef class GroebnerStrategy: ret.elt._monomial_coefficients[k] *= inv return ret - cdef inline partial_S_poly_right(self, GBElement f, GBElement g): + cdef inline partial_S_poly_right(self, GBElement f, GBElement g) noexcept: r""" Compute one half of the `S`-polynomial for ``f`` and ``g``. @@ -170,7 +170,7 @@ cdef class GroebnerStrategy: ret.elt._monomial_coefficients[k] *= inv return ret - cdef inline GBElement build_elt(self, CliffordAlgebraElement f): + cdef inline GBElement build_elt(self, CliffordAlgebraElement f) noexcept: """ Convert ``f`` into a ``GBElement``. """ @@ -180,7 +180,7 @@ cdef class GroebnerStrategy: cdef Integer r = max(self.bitset_to_int(k) for k in mc) return GBElement(f, self.int_to_bitset(r), r) - cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t): + cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t) noexcept: """ Return the GBElement corresponding to ``f * t``. @@ -192,7 +192,7 @@ cdef class GroebnerStrategy: cdef FrozenBitset ls = f.ls._union(t) return GBElement( ret, ls, self.bitset_to_int(ls)) - cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f): + cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f) noexcept: """ Return the GBElement corresponding to ``t * f``. @@ -204,7 +204,7 @@ cdef class GroebnerStrategy: cdef FrozenBitset ls = f.ls._union(t) return GBElement( ret, ls, self.bitset_to_int(ls)) - cdef inline bint build_S_poly(self, GBElement f, GBElement g): + cdef inline bint build_S_poly(self, GBElement f, GBElement g) noexcept: r""" Check to see if we should build the `S`-polynomial. @@ -219,7 +219,7 @@ cdef class GroebnerStrategy: return ( f.ls.intersection(g.ls)).isempty() - cdef inline set preprocessing(self, list P, list G): + cdef inline set preprocessing(self, list P, list G) noexcept: """ Perform the preprocessing step. """ @@ -265,7 +265,7 @@ cdef class GroebnerStrategy: break return L - cdef inline list reduction(self, list P, list G): + cdef inline list reduction(self, list P, list G) noexcept: """ Perform the reduction of ``P`` mod ``G`` in ``E``. """ @@ -450,7 +450,7 @@ cdef class GroebnerStrategy: cdef list G = [self.build_elt(f) for f in self.groebner_basis] self.reduced_gb(G) - cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f): + cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f) noexcept: """ Reduce ``f`` modulo the ideal with Gröbner basis ``G``. @@ -515,10 +515,10 @@ cdef class GroebnerStrategy: iaxpy(-coeff, gp._monomial_coefficients, f._monomial_coefficients) return was_reduced - cdef Integer bitset_to_int(self, FrozenBitset X): + cdef Integer bitset_to_int(self, FrozenBitset X) noexcept: raise NotImplementedError - cdef FrozenBitset int_to_bitset(self, Integer n): + cdef FrozenBitset int_to_bitset(self, Integer n) noexcept: raise NotImplementedError def sorted_monomials(self, as_dict=False): @@ -597,7 +597,7 @@ cdef class GroebnerStrategyNegLex(GroebnerStrategy): """ Gröbner basis strategy implementing neglex ordering. """ - cdef inline Integer bitset_to_int(self, FrozenBitset X): + cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept: """ Convert ``X`` to an :class:`Integer`. """ @@ -608,7 +608,7 @@ cdef class GroebnerStrategyNegLex(GroebnerStrategy): elt = bitset_next(X._bitset, elt + 1) return ret - cdef inline FrozenBitset int_to_bitset(self, Integer n): + cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept: """ Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`. """ @@ -628,7 +628,7 @@ cdef class GroebnerStrategyDegRevLex(GroebnerStrategy): """ Gröbner basis strategy implementing degree revlex ordering. """ - cdef inline Integer bitset_to_int(self, FrozenBitset X): + cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept: """ Convert ``X`` to an :class:`Integer`. """ @@ -647,7 +647,7 @@ cdef class GroebnerStrategyDegRevLex(GroebnerStrategy): elt = bitset_next(X._bitset, elt + 1) return Integer(sum(n.binomial(i) for i in range(deg+1)) - t - 1) - cdef inline FrozenBitset int_to_bitset(self, Integer n): + cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept: """ Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`. """ @@ -669,7 +669,7 @@ cdef class GroebnerStrategyDegLex(GroebnerStrategy): """ Gröbner basis strategy implementing degree lex ordering. """ - cdef inline Integer bitset_to_int(self, FrozenBitset X): + cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept: """ Convert ``X`` to an :class:`Integer`. """ @@ -688,7 +688,7 @@ cdef class GroebnerStrategyDegLex(GroebnerStrategy): elt = bitset_next(X._bitset, elt + 1) return Integer(sum(n.binomial(i) for i in range(deg+1)) - t - 1) - cdef inline FrozenBitset int_to_bitset(self, Integer n): + cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept: """ Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`. """ diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd index c13b8dbab07..dd5f85be9fb 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd @@ -6,4 +6,4 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): cdef Matrix __matrix cdef FiniteDimensionalAlgebraElement __inverse -cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat) +cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat) noexcept diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx index 1fc0977ce10..e4901439e19 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx @@ -20,7 +20,7 @@ from sage.rings.integer import Integer from cpython.object cimport PyObject_RichCompare as richcmp -cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat): +cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat) noexcept: """ Helper for unpickling of finite dimensional algebra elements. @@ -341,7 +341,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): return self._vector.ncols() # (Rich) comparison - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ EXAMPLES:: @@ -373,7 +373,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ return richcmp(self._vector, right._vector, op) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ EXAMPLES:: @@ -383,7 +383,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ return self._parent.element_class(self._parent, self._vector + other._vector) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ EXAMPLES:: @@ -393,7 +393,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ return self._parent.element_class(self._parent, self._vector - other._vector) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ EXAMPLES:: @@ -403,7 +403,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ return self._parent.element_class(self._parent, self._vector * (other)._matrix) - cpdef _lmul_(self, Element other): + cpdef _lmul_(self, Element other) noexcept: """ TESTS:: @@ -417,7 +417,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): .format(self.parent(), other.parent())) return self._parent.element_class(self._parent, self._vector * other) - cpdef _rmul_(self, Element other): + cpdef _rmul_(self, Element other) noexcept: """ TESTS:: diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd index e0908ab5884..19e98aa137d 100644 --- a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd +++ b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd @@ -1,4 +1,4 @@ -cdef _fmat(fvars, Nk_ij, one, a, b, c, d, x, y) -cpdef _backward_subs(factory, bint flatten=*) -cpdef executor(tuple params) -cpdef _solve_for_linear_terms(factory, list eqns=*) +cdef _fmat(fvars, Nk_ij, one, a, b, c, d, x, y) noexcept +cpdef _backward_subs(factory, bint flatten=*) noexcept +cpdef executor(tuple params) noexcept +cpdef _solve_for_linear_terms(factory, list eqns=*) noexcept diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx index a9b7eb50fab..b79370c7f2c 100644 --- a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx +++ b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx @@ -32,7 +32,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing # Fast class methods # ########################## -cpdef _solve_for_linear_terms(factory, list eqns=None): +cpdef _solve_for_linear_terms(factory, list eqns=None) noexcept: r""" Solve for a linear term occurring in a two-term equation, and for variables appearing in univariate single-term equations. @@ -107,7 +107,7 @@ cpdef _solve_for_linear_terms(factory, list eqns=None): # assert _unflatten_coeffs(factory._field, factory.test_fvars[s]) == fvars[s], "OG value {}, Shared: {}".format(factory.test_fvars[s], fvars[s]) return linear_terms_exist -cpdef _backward_subs(factory, bint flatten=True): +cpdef _backward_subs(factory, bint flatten=True) noexcept: r""" Perform backward substitution on ``self.ideal_basis``, traversing variables in reverse lexicographical order. @@ -171,7 +171,7 @@ cpdef _backward_subs(factory, bint flatten=True): fvars[sextuple] = res -cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y): +cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y) noexcept: """ Cython version of fmat class method. Using cdef for fastest dispatch """ @@ -214,7 +214,7 @@ cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y): # Mappers # ############### -cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple): +cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple) noexcept: """ Given an FMatrix factory and a sextuple, return a hexagon equation as a polynomial object. @@ -232,7 +232,7 @@ cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple): @cython.wraparound(False) @cython.nonecheck(False) @cython.cdivision(True) -cdef get_reduced_hexagons(factory, tuple mp_params): +cdef get_reduced_hexagons(factory, tuple mp_params) noexcept: """ Set up and reduce the hexagon equations corresponding to this worker. """ @@ -282,7 +282,7 @@ cdef get_reduced_hexagons(factory, tuple mp_params): return collect_eqns(worker_results) -cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, tuple nonuple, bint prune=False): +cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, tuple nonuple, bint prune=False) noexcept: r""" Given an FMatrix factory and a nonuple, return a pentagon equation as a polynomial object. @@ -301,7 +301,7 @@ cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, t @cython.wraparound(False) @cython.nonecheck(False) @cython.cdivision(True) -cdef get_reduced_pentagons(factory, tuple mp_params): +cdef get_reduced_pentagons(factory, tuple mp_params) noexcept: r""" Set up and reduce the pentagon equations corresponding to this worker. """ @@ -349,7 +349,7 @@ cdef get_reduced_pentagons(factory, tuple mp_params): worker_results.append(red) return collect_eqns(worker_results) -cdef list update_reduce(factory, list eqns): +cdef list update_reduce(factory, list eqns) noexcept: r""" Substitute known values, known squares, and reduce. """ @@ -381,7 +381,7 @@ cdef list update_reduce(factory, list eqns): res.append(red) return collect_eqns(res) -cdef list compute_gb(factory, tuple args): +cdef list compute_gb(factory, tuple args) noexcept: r""" Compute the reduced Groebner basis for given equations iterable. """ @@ -425,7 +425,7 @@ cdef list compute_gb(factory, tuple args): # Reducers # ################ -cdef inline list collect_eqns(list eqns): +cdef inline list collect_eqns(list eqns) noexcept: r""" Helper function for returning processed results back to parent process. @@ -450,7 +450,7 @@ cdef dict mappers = { "pent_verify": pent_verify } -cpdef executor(tuple params): +cpdef executor(tuple params) noexcept: r""" Execute a function defined in this module (``sage.algebras.fusion_rings.fast_parallel_fmats_methods``) in a worker @@ -497,7 +497,7 @@ cpdef executor(tuple params): # Verification # #################### -cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, float tol=5e-8): +cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, float tol=5e-8) noexcept: r""" Check the pentagon equation corresponding to the given nonuple. """ @@ -516,7 +516,7 @@ cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, f @cython.wraparound(False) @cython.nonecheck(False) @cython.cdivision(True) -cdef pent_verify(factory, tuple mp_params): +cdef pent_verify(factory, tuple mp_params) noexcept: r""" Generate all the pentagon equations assigned to this process, and reduce them. diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd index a992f0339a4..9fde1f0c5e8 100644 --- a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd +++ b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd @@ -1,2 +1,2 @@ -cpdef _unflatten_entries(factory, list entries) -cpdef executor(tuple params) +cpdef _unflatten_entries(factory, list entries) noexcept +cpdef executor(tuple params) noexcept diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx index 8fc054f50cd..9ba832c5124 100644 --- a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx +++ b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx @@ -18,7 +18,7 @@ from sage.rings.qqbar import QQbar # Mappers # ############### -cdef mid_sig_ij(fusion_ring, row, col, a, b): +cdef mid_sig_ij(fusion_ring, row, col, a, b) noexcept: r""" Compute the (xi, yi), (xj, yj) entry of generator braiding the middle two strands in the tree b -> xi # yi -> (a # a) # (a # a), which results in @@ -48,7 +48,7 @@ cdef mid_sig_ij(fusion_ring, row, col, a, b): entry += f1 * f2 * r * f3 * f4 return entry -cdef odd_one_out_ij(fusion_ring, xi, xj, a, b): +cdef odd_one_out_ij(fusion_ring, xi, xj, a, b) noexcept: r""" Compute the `xi`, `xj` entry of the braid generator on the two right-most strands, corresponding to the tree b -> (xi # a) -> (a # a) # a, which @@ -76,7 +76,7 @@ cdef odd_one_out_ij(fusion_ring, xi, xj, a, b): cdef odd_one_out_ij_cache = dict() cdef mid_sig_ij_cache = dict() -cdef cached_mid_sig_ij(fusion_ring, row, col, a, b): +cdef cached_mid_sig_ij(fusion_ring, row, col, a, b) noexcept: r""" Cached version of :meth:`mid_sig_ij`. """ @@ -86,7 +86,7 @@ cdef cached_mid_sig_ij(fusion_ring, row, col, a, b): mid_sig_ij_cache[row, col, a, b] = entry return entry -cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b): +cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b) noexcept: r""" Cached version of :meth:`odd_one_out_ij`. """ @@ -99,7 +99,7 @@ cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b): @cython.nonecheck(False) @cython.cdivision(True) -cdef sig_2k(fusion_ring, tuple args): +cdef sig_2k(fusion_ring, tuple args) noexcept: r""" Compute entries of the `2k`-th braid generator """ @@ -179,7 +179,7 @@ cdef sig_2k(fusion_ring, tuple args): @cython.nonecheck(False) @cython.cdivision(True) -cdef odd_one_out(fusion_ring, tuple args): +cdef odd_one_out(fusion_ring, tuple args) noexcept: r""" Compute entries of the rightmost braid generator, in case we have an odd number of strands. @@ -263,7 +263,7 @@ cdef dict mappers = { "odd_one_out": odd_one_out } -cpdef executor(tuple params): +cpdef executor(tuple params) noexcept: r""" Execute a function registered in this module's ``mappers`` in a worker process, and supply the ``FusionRing`` parameter by @@ -305,7 +305,7 @@ cpdef executor(tuple params): # Pickling circumvention helpers # ###################################### -cpdef _unflatten_entries(fusion_ring, list entries): +cpdef _unflatten_entries(fusion_ring, list entries) noexcept: r""" Restore cyclotomic coefficient object from its tuple of rational coefficients representation. diff --git a/src/sage/algebras/fusion_rings/poly_tup_engine.pxd b/src/sage/algebras/fusion_rings/poly_tup_engine.pxd index a4ddf9b92ae..ac2c5041de9 100644 --- a/src/sage/algebras/fusion_rings/poly_tup_engine.pxd +++ b/src/sage/algebras/fusion_rings/poly_tup_engine.pxd @@ -3,21 +3,21 @@ from sage.rings.number_field.number_field_element cimport NumberFieldElement_abs from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular, MPolynomialRing_libsingular from sage.rings.polynomial.polydict cimport ETuple -cpdef tuple poly_to_tup(MPolynomial_libsingular poly) -cpdef MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent) -cpdef tuple resize(tuple eq_tup, dict idx_map, int nvars) -cpdef list get_variables_degrees(list eqns, int nvars) -cpdef list variables(tuple eq_tup) -cpdef constant_coeff(tuple eq_tup, field) -cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map) +cpdef tuple poly_to_tup(MPolynomial_libsingular poly) noexcept +cpdef MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent) noexcept +cpdef tuple resize(tuple eq_tup, dict idx_map, int nvars) noexcept +cpdef list get_variables_degrees(list eqns, int nvars) noexcept +cpdef list variables(tuple eq_tup) noexcept +cpdef constant_coeff(tuple eq_tup, field) noexcept +cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map) noexcept # cpdef bint tup_fixes_sq(tuple eq_tup) -cdef bint tup_fixes_sq(tuple eq_tup) -cdef dict subs_squares(dict eq_dict, KSHandler known_sq) -cpdef dict compute_known_powers(max_degs, dict val_dict, one) -cdef dict subs(tuple poly_tup, dict known_powers, one) -cpdef tup_to_univ_poly(tuple eq_tup, univ_poly_ring) -cpdef tuple poly_tup_sortkey(tuple eq_tup) -cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one) -cdef tuple _flatten_coeffs(tuple eq_tup) -cpdef tuple _unflatten_coeffs(field, tuple eq_tup) -cdef int has_appropriate_linear_term(tuple eq_tup) +cdef bint tup_fixes_sq(tuple eq_tup) noexcept +cdef dict subs_squares(dict eq_dict, KSHandler known_sq) noexcept +cpdef dict compute_known_powers(max_degs, dict val_dict, one) noexcept +cdef dict subs(tuple poly_tup, dict known_powers, one) noexcept +cpdef tup_to_univ_poly(tuple eq_tup, univ_poly_ring) noexcept +cpdef tuple poly_tup_sortkey(tuple eq_tup) noexcept +cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one) noexcept +cdef tuple _flatten_coeffs(tuple eq_tup) noexcept +cpdef tuple _unflatten_coeffs(field, tuple eq_tup) noexcept +cdef int has_appropriate_linear_term(tuple eq_tup) noexcept diff --git a/src/sage/algebras/fusion_rings/poly_tup_engine.pyx b/src/sage/algebras/fusion_rings/poly_tup_engine.pyx index 67176402134..5c3f54df9a6 100644 --- a/src/sage/algebras/fusion_rings/poly_tup_engine.pyx +++ b/src/sage/algebras/fusion_rings/poly_tup_engine.pyx @@ -12,7 +12,7 @@ Arithmetic Engine for Polynomials as Tuples # API # ########### -cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly): +cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly) noexcept: r""" Convert a polynomial object into the internal representation as tuple of ``(ETuple exp, NumberFieldElement coeff)`` pairs. @@ -28,7 +28,7 @@ cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly): """ return tuple(poly.dict().items()) -cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent): +cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent) noexcept: r""" Return a polynomial object from its tuple of pairs representation. @@ -74,7 +74,7 @@ cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_ """ return parent._element_constructor_(dict(eq_tup), check=False) -cdef inline tuple _flatten_coeffs(tuple eq_tup): +cdef inline tuple _flatten_coeffs(tuple eq_tup) noexcept: r""" Flatten cyclotomic coefficients to a representation as a tuple of rational coefficients. @@ -88,7 +88,7 @@ cdef inline tuple _flatten_coeffs(tuple eq_tup): flat.append((exp, tuple(cyc_coeff._coefficients()))) return tuple(flat) -cpdef tuple _unflatten_coeffs(field, tuple eq_tup): +cpdef tuple _unflatten_coeffs(field, tuple eq_tup) noexcept: r""" Restore cyclotomic coefficient object from its tuple of rational coefficients representation. @@ -118,7 +118,7 @@ cpdef tuple _unflatten_coeffs(field, tuple eq_tup): # Useful private predicates # ################################# -cdef inline int has_appropriate_linear_term(tuple eq_tup): +cdef inline int has_appropriate_linear_term(tuple eq_tup) noexcept: r""" Determine whether the given tuple of pairs (of length 2) contains an *appropriate* linear term. @@ -149,7 +149,7 @@ cdef inline int has_appropriate_linear_term(tuple eq_tup): # "Change rings" # ###################### -cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring): +cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring) noexcept: r""" Given a tuple of pairs representing a univariate polynomial and a univariate polynomial ring, return a univariate polynomial object. @@ -177,7 +177,7 @@ cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring): cdef NumberFieldElement_absolute c return univ_poly_ring({exp._data[1] if exp._nonzero else 0: c for exp, c in eq_tup}) -cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars): +cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars) noexcept: r""" Return a tuple representing a polynomial in a ring with ``len(sorted_vars)`` generators. @@ -218,7 +218,7 @@ cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars): # Convenience methods # ########################### -cdef inline ETuple degrees(tuple poly_tup): +cdef inline ETuple degrees(tuple poly_tup) noexcept: r""" Return the maximal degree of each variable in the polynomial. """ @@ -232,7 +232,7 @@ cdef inline ETuple degrees(tuple poly_tup): max_degs = max_degs.emax( ( poly_tup[i])[0]) return max_degs -cpdef list get_variables_degrees(list eqns, int nvars): +cpdef list get_variables_degrees(list eqns, int nvars) noexcept: r""" Find maximum degrees for each variable in equations. @@ -257,7 +257,7 @@ cpdef list get_variables_degrees(list eqns, int nvars): dense[max_deg._data[2*i]] = max_deg._data[2*i+1] return dense -cpdef list variables(tuple eq_tup): +cpdef list variables(tuple eq_tup) noexcept: """ Return indices of all variables appearing in eq_tup @@ -277,7 +277,7 @@ cpdef list variables(tuple eq_tup): """ return degrees(eq_tup).nonzero_positions() -cpdef constant_coeff(tuple eq_tup, field): +cpdef constant_coeff(tuple eq_tup, field) noexcept: r""" Return the constant coefficient of the polynomial represented by given tuple. @@ -300,7 +300,7 @@ cpdef constant_coeff(tuple eq_tup, field): return coeff return field.zero() -cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map): +cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map) noexcept: """ Apply ``coeff_map`` to coefficients. @@ -320,7 +320,7 @@ cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map): return tuple(new_tup) # cpdef inline bint tup_fixes_sq(tuple eq_tup): -cdef inline bint tup_fixes_sq(tuple eq_tup): +cdef inline bint tup_fixes_sq(tuple eq_tup) noexcept: r""" Determine if given equation fixes the square of a variable. @@ -342,7 +342,7 @@ cdef inline bint tup_fixes_sq(tuple eq_tup): # Simplification # ###################### -cdef dict subs_squares(dict eq_dict, KSHandler known_sq): +cdef dict subs_squares(dict eq_dict, KSHandler known_sq) noexcept: r""" Substitute for known squares into a given polynomial. @@ -379,7 +379,7 @@ cdef dict subs_squares(dict eq_dict, KSHandler known_sq): subbed[exp] = coeff return subbed -cdef dict remove_gcf(dict eq_dict, ETuple nonz): +cdef dict remove_gcf(dict eq_dict, ETuple nonz) noexcept: r""" Return a dictionary of ``(ETuple, coeff)`` pairs describing the polynomial ``eq / GCF(eq)``. @@ -399,7 +399,7 @@ cdef dict remove_gcf(dict eq_dict, ETuple nonz): ret[exp.esub(common_powers)] = c return ret -cdef tuple to_monic(dict eq_dict, one): +cdef tuple to_monic(dict eq_dict, one) noexcept: """ Return tuple of pairs ``(ETuple, coeff)`` describing the monic polynomial associated to ``eq_dict``. @@ -422,7 +422,7 @@ cdef tuple to_monic(dict eq_dict, one): ret.append((ord_monoms[n-2-i], inv_lc * eq_dict[ord_monoms[n-2-i]])) return tuple(ret) -cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one): +cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one) noexcept: """ Return a tuple describing a monic polynomial with no known nonzero gcf and no known squares. @@ -437,7 +437,7 @@ cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, Numbe # Substitution # #################### -cpdef dict compute_known_powers(max_degs, dict val_dict, one): +cpdef dict compute_known_powers(max_degs, dict val_dict, one) noexcept: """ Pre-compute powers of known values for efficiency when preparing to substitute into a list of polynomials. @@ -482,7 +482,7 @@ cpdef dict compute_known_powers(max_degs, dict val_dict, one): known_powers[var_idx][power+1] = tup_mul(known_powers[var_idx][power], val_dict[var_idx]) return known_powers -cdef dict subs(tuple poly_tup, dict known_powers, one): +cdef dict subs(tuple poly_tup, dict known_powers, one) noexcept: """ Substitute given variables into a polynomial tuple. """ @@ -505,7 +505,7 @@ cdef dict subs(tuple poly_tup, dict known_powers, one): subbed[shifted_exp] = coeff * c return subbed -cdef tuple tup_mul(tuple p1, tuple p2): +cdef tuple tup_mul(tuple p1, tuple p2) noexcept: r""" Multiplication of two polynomial tuples using schoolbook multiplication. """ @@ -524,7 +524,7 @@ cdef tuple tup_mul(tuple p1, tuple p2): # Sorting # ############### -cdef tuple monom_sortkey(ETuple exp): +cdef tuple monom_sortkey(ETuple exp) noexcept: r""" Produce a sortkey for a monomial exponent with respect to degree reversed lexicographic ordering. @@ -535,7 +535,7 @@ cdef tuple monom_sortkey(ETuple exp): cdef ETuple rev = exp.reversed().emul(-1) return (deg, rev) -cpdef tuple poly_tup_sortkey(tuple eq_tup): +cpdef tuple poly_tup_sortkey(tuple eq_tup) noexcept: r""" Return the sortkey of a polynomial represented as a tuple of ``(ETuple, coeff)`` pairs with respect to the degree diff --git a/src/sage/algebras/fusion_rings/shm_managers.pxd b/src/sage/algebras/fusion_rings/shm_managers.pxd index 8f4967d6d0a..f1e2ed74714 100644 --- a/src/sage/algebras/fusion_rings/shm_managers.pxd +++ b/src/sage/algebras/fusion_rings/shm_managers.pxd @@ -8,10 +8,10 @@ cdef class KSHandler: cdef NumberField field cdef public object shm - cdef bint contains(self, int idx) - cdef NumberFieldElement_absolute get(self, int idx) - cdef setitem(self, int idx, rhs) - cpdef update(self, list eqns) + cdef bint contains(self, int idx) noexcept + cdef NumberFieldElement_absolute get(self, int idx) noexcept + cdef setitem(self, int idx, rhs) noexcept + cpdef update(self, list eqns) noexcept cdef class FvarsHandler: cdef dict sext_to_idx, obj_cache diff --git a/src/sage/algebras/fusion_rings/shm_managers.pyx b/src/sage/algebras/fusion_rings/shm_managers.pyx index bbb364e91dd..dcfa274b5ea 100644 --- a/src/sage/algebras/fusion_rings/shm_managers.pyx +++ b/src/sage/algebras/fusion_rings/shm_managers.pyx @@ -144,7 +144,7 @@ cdef class KSHandler: @cython.nonecheck(False) @cython.wraparound(False) @cython.boundscheck(False) - cdef NumberFieldElement_absolute get(self, int idx): + cdef NumberFieldElement_absolute get(self, int idx) noexcept: r""" Retrieve the known square corresponding to the given index, if it exists. @@ -175,7 +175,7 @@ cdef class KSHandler: self.obj_cache[idx] = cyc_coeff return cyc_coeff - cpdef update(self, list eqns): + cpdef update(self, list eqns) noexcept: r""" Update ```self``'s ``shared_memory``-backed dictionary of known squares. Keys are variable indices and corresponding values @@ -242,7 +242,7 @@ cdef class KSHandler: @cython.nonecheck(False) @cython.wraparound(False) @cython.infer_types(False) - cdef setitem(self, int idx, rhs): + cdef setitem(self, int idx, rhs) noexcept: """ Create an entry corresponding to the given index. @@ -269,7 +269,7 @@ cdef class KSHandler: nums[i] = num denoms[i] = denom - cdef bint contains(self, int idx): + cdef bint contains(self, int idx) noexcept: r""" Determine whether ``self`` contains entry corresponding to given ``idx``. diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd index d22fe4e9a40..ddd77e94be7 100644 --- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd +++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd @@ -13,5 +13,5 @@ from sage.algebras.letterplace.free_algebra_letterplace cimport FreeAlgebra_lett cdef class FreeAlgebraElement_letterplace(AlgebraElement): cdef MPolynomial_libsingular _poly - cpdef _add_(self, other) - cpdef _mul_(self, other) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx index 9029a8b07a5..8e48f0530d9 100644 --- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx @@ -441,7 +441,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): return True return False - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Implement comparisons, using the Cython richcmp convention. @@ -458,7 +458,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): ################################ # Arithmetic - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ TESTS:: @@ -474,7 +474,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): return FreeAlgebraElement_letterplace(self._parent, -self._poly, check=False) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Addition, under the side condition that either one summand is zero, or both summands have the same degree. @@ -508,7 +508,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): self._poly + right._poly, check=False) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ Difference, under the side condition that either one summand is zero or both have the same weighted degree. @@ -548,7 +548,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): self._poly - right._poly, check=False) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Multiplication from the right with an element of the base ring. @@ -563,7 +563,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): self._poly._lmul_(right), check=False) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ Multiplication from the left with an element of the base ring. @@ -578,7 +578,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement): self._poly._rmul_(left), check=False) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Product of two free algebra elements in letterplace implementation. diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd index 47a7275aba0..a726262546b 100644 --- a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd +++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd @@ -29,6 +29,6 @@ cdef class FreeAlgebra_letterplace(Algebra): cdef int _ngens cdef int _nb_slackvars cdef object __monoid - cdef str exponents_to_string(self, E) - cdef str exponents_to_latex(self, E) + cdef str exponents_to_string(self, E) noexcept + cdef str exponents_to_latex(self, E) noexcept cdef tuple _degrees diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx index 53f0dfdea6d..ddf3e5c2f09 100644 --- a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx @@ -137,7 +137,7 @@ freeAlgebra = singular_function("freeAlgebra") ##################### # Auxiliary functions -cdef MPolynomialRing_libsingular make_letterplace_ring(base_ring, blocks): +cdef MPolynomialRing_libsingular make_letterplace_ring(base_ring, blocks) noexcept: """ Create a polynomial ring in block order. @@ -563,7 +563,7 @@ cdef class FreeAlgebra_letterplace(Algebra): return self.__monoid # Auxiliar methods - cdef str exponents_to_string(self, E): + cdef str exponents_to_string(self, E) noexcept: """ This auxiliary method is used for the string representation of elements of this free algebra. @@ -605,7 +605,7 @@ cdef class FreeAlgebra_letterplace(Algebra): return '*'.join(out) # Auxiliar methods - cdef str exponents_to_latex(self, E): + cdef str exponents_to_latex(self, E) noexcept: r""" This auxiliary method is used for the representation of elements of this free algebra as a latex string. @@ -689,7 +689,7 @@ cdef class FreeAlgebra_letterplace(Algebra): ########################### # Coercion - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ A ring ``R`` coerces into self, if diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pxd b/src/sage/algebras/lie_algebras/lie_algebra_element.pxd index fdae38396b9..9005eae72fd 100644 --- a/src/sage/algebras/lie_algebras/lie_algebra_element.pxd +++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pxd @@ -4,24 +4,24 @@ from sage.structure.sage_object cimport SageObject from sage.modules.with_basis.indexed_element cimport IndexedFreeModuleElement cdef class LieAlgebraElement(IndexedFreeModuleElement): - cpdef lift(self) + cpdef lift(self) noexcept cdef class LieAlgebraElementWrapper(ElementWrapper): - cpdef _add_(self, right) - cpdef _sub_(self, right) + cpdef _add_(self, right) noexcept + cpdef _sub_(self, right) noexcept cdef class LieAlgebraMatrixWrapper(LieAlgebraElementWrapper): pass cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper): cdef dict _monomial_coefficients - cpdef dict monomial_coefficients(self, bint copy=*) + cpdef dict monomial_coefficients(self, bint copy=*) noexcept cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper): - cpdef bracket(self, right) - cpdef _bracket_(self, right) - cpdef to_vector(self, bint sparse=*) - cpdef dict monomial_coefficients(self, bint copy=*) + cpdef bracket(self, right) noexcept + cpdef _bracket_(self, right) noexcept + cpdef to_vector(self, bint sparse=*) noexcept + cpdef dict monomial_coefficients(self, bint copy=*) noexcept # cpdef lift(self) cdef class UntwistedAffineLieAlgebraElement(Element): @@ -30,23 +30,23 @@ cdef class UntwistedAffineLieAlgebraElement(Element): cdef _d_coeff cdef long _hash - cpdef _add_(self, other) - cpdef _sub_(self, other) - cpdef _neg_(self) + cpdef _add_(self, other) noexcept + cpdef _sub_(self, other) noexcept + cpdef _neg_(self) noexcept - cpdef dict t_dict(self) - cpdef c_coefficient(self) - cpdef d_coefficient(self) + cpdef dict t_dict(self) noexcept + cpdef c_coefficient(self) noexcept + cpdef d_coefficient(self) noexcept - cpdef bracket(self, y) - cpdef _bracket_(self, y) - cpdef canonical_derivation(self) - cpdef monomial_coefficients(self, bint copy=*) + cpdef bracket(self, y) noexcept + cpdef _bracket_(self, y) noexcept + cpdef canonical_derivation(self) noexcept + cpdef monomial_coefficients(self, bint copy=*) noexcept cdef class LieObject(SageObject): cdef tuple _word cdef public tuple _index_word - cpdef tuple to_word(self) + cpdef tuple to_word(self) noexcept cdef class LieGenerator(LieObject): cdef public str _name @@ -56,7 +56,7 @@ cdef class LieBracket(LieObject): cdef public LieObject _right cdef long _hash - cpdef lift(self, dict UEA_gens_dict) + cpdef lift(self, dict UEA_gens_dict) noexcept cdef class GradedLieBracket(LieBracket): cdef public _grade diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx index ec8dafeec66..ed9680a0af5 100644 --- a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx +++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx @@ -124,7 +124,7 @@ cdef class LieAlgebraElement(IndexedFreeModuleElement): return codomain.sum(base_map(c) * t._im_gens_(codomain, im_gens, names) for t, c in self._monomial_coefficients.items()) - cpdef lift(self): + cpdef lift(self) noexcept: """ Lift ``self`` to the universal enveloping algebra. @@ -275,7 +275,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper): """ return bool(self.value) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add ``self`` and ``rhs``. @@ -288,7 +288,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper): """ return type(self)(self._parent, self.value + right.value) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract ``self`` and ``rhs``. @@ -376,7 +376,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper): """ return self * (~x) - cpdef _acted_upon_(self, scalar, bint self_on_left): + cpdef _acted_upon_(self, scalar, bint self_on_left) noexcept: """ Return the action of a scalar on ``self``. @@ -572,7 +572,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper): """ return self._parent.module()(self.value.to_vector(sparse=sparse)) - cpdef dict monomial_coefficients(self, bint copy=True): + cpdef dict monomial_coefficients(self, bint copy=True) noexcept: r""" Return a dictionary whose keys are indices of basis elements in the support of ``self`` and whose values are the @@ -605,7 +605,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper): return dict(self._monomial_coefficients) return self._monomial_coefficients - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add ``self`` and ``rhs``. @@ -631,7 +631,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper): ret._monomial_coefficients = mc return ret - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract ``self`` and ``rhs``. @@ -657,7 +657,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper): ret._monomial_coefficients = mc return ret - cpdef _acted_upon_(self, scalar, bint self_on_left): + cpdef _acted_upon_(self, scalar, bint self_on_left) noexcept: """ Return the action of a scalar on ``self``. @@ -757,7 +757,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper): scalar_mult='·', strip_one=True)) - cpdef bracket(self, right): + cpdef bracket(self, right) noexcept: """ Return the Lie bracket ``[self, right]``. @@ -777,7 +777,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper): # We need this method because the LieAlgebra.bracket method (from the # category) calls this, where we are guaranteed to have the same parent. - cpdef _bracket_(self, right): + cpdef _bracket_(self, right) noexcept: """ Return the Lie bracket ``[self, right]``. @@ -832,7 +832,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper): if v != zero: yield (I[i], v) - cpdef to_vector(self, bint sparse=False): + cpdef to_vector(self, bint sparse=False) noexcept: """ Return ``self`` as a vector. @@ -865,7 +865,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper): gens = UEA.gens() return UEA.sum(c * gens[i] for i, c in self.value.items()) - cpdef dict monomial_coefficients(self, bint copy=True): + cpdef dict monomial_coefficients(self, bint copy=True) noexcept: """ Return the monomial coefficients of ``self`` as a dictionary. @@ -1072,7 +1072,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): lambda t: "t" + unicode_superscript(t), unicode_art('⋅'), unicode_art('⊗')) - cpdef dict t_dict(self): + cpdef dict t_dict(self) noexcept: r""" Return the ``dict``, whose keys are powers of `t` and values are elements of the classical Lie algebra, of ``self``. @@ -1088,7 +1088,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): """ return self._t_dict.copy() - cpdef c_coefficient(self): + cpdef c_coefficient(self) noexcept: r""" Return the coefficient of `c` of ``self``. @@ -1101,7 +1101,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): """ return self._c_coeff - cpdef d_coefficient(self): + cpdef d_coefficient(self) noexcept: r""" Return the coefficient of `d` of ``self``. @@ -1114,7 +1114,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): """ return self._d_coeff - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Return the rich comparison of ``self`` with ``other``. @@ -1177,7 +1177,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): """ return bool(self._t_dict) or bool(self._c_coeff) or bool(self._d_coeff) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Add ``self`` and ``other``. @@ -1193,7 +1193,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): self._c_coeff + rt._c_coeff, self._d_coeff + rt._d_coeff) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ Subtract ``self`` and ``other``. @@ -1217,7 +1217,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): self._c_coeff - rt._c_coeff, self._d_coeff - rt._d_coeff) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Negate ``self``. @@ -1232,7 +1232,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): return type(self)(self._parent, negate(self._t_dict), -self._c_coeff, -self._d_coeff) - cpdef _acted_upon_(self, x, bint self_on_left): + cpdef _acted_upon_(self, x, bint self_on_left) noexcept: """ Return ``self`` acted upon by ``x``. @@ -1250,7 +1250,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): x * self._c_coeff, x * self._d_coeff) - cpdef monomial_coefficients(self, bint copy=True): + cpdef monomial_coefficients(self, bint copy=True) noexcept: """ Return the monomial coefficients of ``self``. @@ -1280,7 +1280,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): d['d'] = self._d_coeff return d - cpdef bracket(self, right): + cpdef bracket(self, right) noexcept: """ Return the Lie bracket ``[self, right]``. @@ -1303,7 +1303,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): self, right = coercion_model.canonical_coercion(self, right) return self._bracket_(right) - cpdef _bracket_(self, y): + cpdef _bracket_(self, y) noexcept: """ Return the Lie bracket ``[self, y]``. @@ -1371,7 +1371,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element): return type(self)(self._parent, d, c, self._parent.base_ring().zero()) - cpdef canonical_derivation(self): + cpdef canonical_derivation(self) noexcept: r""" Return the canonical derivation `d` applied to ``self``. @@ -1511,7 +1511,7 @@ cdef class LieObject(SageObject): """ Abstract base class for :class:`LieGenerator` and :class:`LieBracket`. """ - cpdef tuple to_word(self): + cpdef tuple to_word(self) noexcept: """ Return the word ("flattening") of ``self``. @@ -1645,7 +1645,7 @@ cdef class LieGenerator(LieObject): """ return im_gens[names.index(self._name)] - cpdef tuple to_word(self): + cpdef tuple to_word(self) noexcept: """ Return the word ("flattening") of ``self``. @@ -1831,7 +1831,7 @@ cdef class LieBracket(LieObject): return codomain.bracket(self._left._im_gens_(codomain, im_gens, names), self._right._im_gens_(codomain, im_gens, names)) - cpdef lift(self, dict UEA_gens_dict): + cpdef lift(self, dict UEA_gens_dict) noexcept: """ Lift ``self`` to the universal enveloping algebra. @@ -1860,7 +1860,7 @@ cdef class LieBracket(LieObject): return l*r - r*l - cpdef tuple to_word(self): + cpdef tuple to_word(self) noexcept: """ Return the word ("flattening") of ``self``. diff --git a/src/sage/algebras/octonion_algebra.pxd b/src/sage/algebras/octonion_algebra.pxd index 78500729bdc..459e8ea3070 100644 --- a/src/sage/algebras/octonion_algebra.pxd +++ b/src/sage/algebras/octonion_algebra.pxd @@ -8,12 +8,12 @@ from sage.modules.free_module_element cimport FreeModuleElement cdef class Octonion_generic(AlgebraElement): cdef FreeModuleElement vec - cpdef Octonion_generic conjugate(self) - cpdef quadratic_form(self) - cpdef norm(self) - cpdef abs(self) - cpdef real_part(self) - cpdef Octonion_generic imag_part(self) + cpdef Octonion_generic conjugate(self) noexcept + cpdef quadratic_form(self) noexcept + cpdef norm(self) noexcept + cpdef abs(self) noexcept + cpdef real_part(self) noexcept + cpdef Octonion_generic imag_part(self) noexcept cdef class Octonion(Octonion_generic): pass diff --git a/src/sage/algebras/octonion_algebra.pyx b/src/sage/algebras/octonion_algebra.pyx index 18101c48f66..aef4f54aa9d 100644 --- a/src/sage/algebras/octonion_algebra.pyx +++ b/src/sage/algebras/octonion_algebra.pyx @@ -116,7 +116,7 @@ cdef class Octonion_generic(AlgebraElement): """ return (self.__class__, (self._parent, self.vec)) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare ``self`` to ``other`` with type ``op``. @@ -147,7 +147,7 @@ cdef class Octonion_generic(AlgebraElement): """ return hash(self.vec) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: r""" Return ``self`` plus ``other``. @@ -161,7 +161,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.__class__(self._parent, self.vec + ( other).vec) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: r""" Return ``self`` minus ``other``. @@ -191,7 +191,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.__class__(self._parent, -self.vec) - cpdef _lmul_(self, Element other): + cpdef _lmul_(self, Element other) noexcept: r""" Return ``self * other`` for a scalar ``other``. @@ -205,7 +205,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.__class__(self._parent, self.vec * other) - cpdef _rmul_(self, Element other): + cpdef _rmul_(self, Element other) noexcept: r""" Return ``self * other`` for a scalar ``other``. @@ -219,7 +219,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.__class__(self._parent, other * self.vec) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return ``self`` multiplied by ``other``. @@ -267,7 +267,7 @@ cdef class Octonion_generic(AlgebraElement): ret[k] += cl * cr * coeff return self.__class__(P, P._module(ret)) - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Return ``self`` divided by ``other``. @@ -356,7 +356,7 @@ cdef class Octonion_generic(AlgebraElement): raise ZeroDivisionError return self.quadratic_form().inverse_of_unit() * self.conjugate() - cpdef Octonion_generic conjugate(self): + cpdef Octonion_generic conjugate(self) noexcept: r""" Return the conjugate of ``self``. @@ -372,7 +372,7 @@ cdef class Octonion_generic(AlgebraElement): v.set_unsafe(0, -v.get_unsafe(0)) return self.__class__(self._parent, v) - cpdef quadratic_form(self): + cpdef quadratic_form(self) noexcept: r""" Return the quadratic form of ``self``. @@ -395,7 +395,7 @@ cdef class Octonion_generic(AlgebraElement): ret += -( table[i])[i][1] * self.vec.get_unsafe(i) ** 2 return ret - cpdef norm(self): + cpdef norm(self) noexcept: r""" Return the norm of ``self``. @@ -423,7 +423,7 @@ cdef class Octonion_generic(AlgebraElement): """ return sqrt(self.quadratic_form()) - cpdef abs(self): + cpdef abs(self) noexcept: r""" Return the absolute value of ``self``. @@ -446,7 +446,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.norm() - cpdef real_part(self): + cpdef real_part(self) noexcept: r""" Return the real part of ``self``. @@ -466,7 +466,7 @@ cdef class Octonion_generic(AlgebraElement): """ return self.vec.get_unsafe(0) - cpdef Octonion_generic imag_part(self): + cpdef Octonion_generic imag_part(self) noexcept: r""" Return the imginary part of ``self``. @@ -542,7 +542,7 @@ cdef class Octonion(Octonion_generic): This is an element of the octonion algebra with parameters `a = b = c = -1`, which is a classical octonion number. """ - cpdef quadratic_form(self): + cpdef quadratic_form(self) noexcept: r""" Return the quadratic form of ``self``. @@ -561,7 +561,7 @@ cdef class Octonion(Octonion_generic): """ return self.vec * self.vec - cpdef norm(self): + cpdef norm(self) noexcept: r""" Return the norm of ``self``. diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pxd b/src/sage/algebras/quatalg/quaternion_algebra_element.pxd index 243cae8e222..5a4f811443a 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra_element.pxd +++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pxd @@ -7,11 +7,11 @@ from sage.structure.element cimport AlgebraElement, RingElement, ModuleElement, from sage.categories.morphism cimport Morphism cdef class QuaternionAlgebraElement_abstract(AlgebraElement): - cpdef bint is_constant(self) - cdef _do_print(self, x, y, z, w) - cpdef conjugate(self) - cpdef reduced_norm(self) - cpdef reduced_trace(self) + cpdef bint is_constant(self) noexcept + cdef _do_print(self, x, y, z, w) noexcept + cpdef conjugate(self) noexcept + cpdef reduced_norm(self) noexcept + cpdef reduced_trace(self) noexcept cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract): cdef object x, y, z, w @@ -21,8 +21,8 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract): cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstract): cdef fmpz_poly_t x, y, z, w, a, b, modulus cdef mpz_t d - cdef inline canonicalize(self) + cdef inline canonicalize(self) noexcept cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abstract): cdef mpz_t x, y, z, w, a, b, d - cdef inline canonicalize(self) + cdef inline canonicalize(self) noexcept diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx index 723c284989e..a1dd86a224c 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx +++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx @@ -53,7 +53,7 @@ from sage.libs.flint.ntl_interface cimport * cdef mpz_t T1, T2, t3, t4, t5, t6, t7, t8, s1, s2, U1, U2 cdef fmpz_poly_t fT1, fT2, ft3, ft4, ft5, ft6, ft7, ft8, fs1, fs2, fU1, fU2 -cdef _clear_globals(): +cdef _clear_globals() noexcept: """ Clear all global variables allocated for optimization of quaternion algebra arithmetic. @@ -90,7 +90,7 @@ cdef _clear_globals(): fmpz_poly_clear(fU1) fmpz_poly_clear(fU2) -cdef _init_globals(): +cdef _init_globals() noexcept: """ Initialize all global variables allocated for optimization of quaternion algebra arithmetic, and register a hook to eventually @@ -137,7 +137,7 @@ cdef _init_globals(): # Initialize module-scope global C variables. _init_globals() -cdef to_quaternion(R, x): +cdef to_quaternion(R, x) noexcept: """ Internal function used implicitly by quaternion algebra creation. @@ -161,7 +161,7 @@ cdef to_quaternion(R, x): else: return R(x), R(0), R(0), R(0) -cdef inline print_coeff(y, i, bint atomic): +cdef inline print_coeff(y, i, bint atomic) noexcept: """ Internal function used implicitly by all quaternion algebra printing. @@ -219,7 +219,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): h = ((h+34125L)*51125L) ^ hash(x) return h - cpdef bint is_constant(self): + cpdef bint is_constant(self) noexcept: """ Return True if this quaternion is constant, i.e., has no i, j, or k term. @@ -335,7 +335,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return self[0] or self[1] or self[2] or self[3] - cdef _do_print(self, x, y, z, w): + cdef _do_print(self, x, y, z, w) noexcept: """ Used internally by the print function. @@ -384,7 +384,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return self._do_print(self[0], self[1], self[2], self[3]) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Comparing elements. @@ -412,7 +412,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): return res return rich_to_bool(op, 0) - cpdef conjugate(self): + cpdef conjugate(self) noexcept: """ Return the conjugate of the quaternion: if `\\theta = x + yi + zj + wk`, return `x - yi - zj - wk`; that is, return theta.reduced_trace() - theta. @@ -436,7 +436,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return self.__class__(self._parent, (self[0], -self[1], -self[2], -self[3]), check=False) - cpdef reduced_trace(self): + cpdef reduced_trace(self) noexcept: """ Return the reduced trace of self: if `\\theta = x + yi + zj + wk`, then `\\theta` has reduced trace `2x`. @@ -451,7 +451,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return 2*self[0] - cpdef reduced_norm(self): + cpdef reduced_norm(self) noexcept: """ Return the reduced norm of self: if `\\theta = x + yi + zj + wk`, then `\\theta` has reduced norm `x^2 - ay^2 - bz^2 + @@ -508,7 +508,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return ~self.reduced_norm() * self.conjugate() - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ Return left*self, where left is in the base ring. @@ -523,7 +523,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return self.__class__(self._parent, (left*self[0], left*self[1], left*self[2], left*self[3]), check=False) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Return self*right, where right is in the base ring. @@ -538,7 +538,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement): """ return self.__class__(self._parent, (self[0]*right, self[1]*right, self[2]*right, self[3]*right), check=False) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Return quotient of self by right. @@ -769,7 +769,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract): return (unpickle_QuaternionAlgebraElement_generic_v0, (self._parent, (self.x, self.y, self.z, self.w))) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Return the sum of self and _right. @@ -785,7 +785,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract): # TODO -- make this, etc. use __new__ return QuaternionAlgebraElement_generic(self._parent, (self.x + right.x, self.y + right.y, self.z + right.z, self.w + right.w), check=False) - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Return the difference of self and _right. @@ -800,7 +800,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract): cdef QuaternionAlgebraElement_generic right = _right return QuaternionAlgebraElement_generic(self._parent, (self.x - right.x, self.y - right.y, self.z - right.z, self.w - right.w), check=False) - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ Return the product of self and _right. @@ -928,7 +928,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst return x raise TypeError - cpdef bint is_constant(self): + cpdef bint is_constant(self) noexcept: """ Return True if this quaternion is constant, i.e., has no i, j, or k term. @@ -964,7 +964,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst """ return bool(mpz_sgn(self.x) or mpz_sgn(self.y) or mpz_sgn(self.z) or mpz_sgn(self.w)) - cpdef _richcmp_(self, _right, int op): + cpdef _richcmp_(self, _right, int op) noexcept: """ Compare two quaternions. @@ -1125,7 +1125,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst return (unpickle_QuaternionAlgebraElement_rational_field_v0, (self._parent, (self[0], self[1], self[2], self[3]))) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ EXAMPLES:: @@ -1181,7 +1181,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst mpz_set(result.b, self.b) return result - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ EXAMPLES:: @@ -1222,7 +1222,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst mpz_set(result.b, self.b) return result - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ EXAMPLES:: @@ -1335,7 +1335,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst return result - cpdef reduced_norm(self): + cpdef reduced_norm(self) noexcept: """ Return the reduced norm of ``self``. @@ -1376,7 +1376,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst return result - cpdef conjugate(self): + cpdef conjugate(self) noexcept: """ Return the conjugate of this quaternion. @@ -1407,7 +1407,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst return result - cpdef reduced_trace(self): + cpdef reduced_trace(self) noexcept: """ Return the reduced trace of ``self``. @@ -1431,7 +1431,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst mpq_canonicalize(result.value) return result - cdef inline canonicalize(self): + cdef inline canonicalize(self) noexcept: """ Put the representation of this quaternion element into smallest form. For `a = (1/d)(x + yi + zj + wk)` we @@ -1785,7 +1785,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra return (unpickle_QuaternionAlgebraElement_number_field_v0, (self._parent, (self[0], self[1], self[2], self[3]))) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Add self and _right: @@ -1857,7 +1857,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra return result - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Subtract _right from self. @@ -1906,7 +1906,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra return result - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ Multiply self and _right. @@ -2052,7 +2052,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra return result - cdef inline canonicalize(self): + cdef inline canonicalize(self) noexcept: """ Put the representation of this quaternion element into smallest form. For a = `(1/d)(x + yi + zj + wk)` we diff --git a/src/sage/arith/functions.pxd b/src/sage/arith/functions.pxd index 9ddfc38b38b..58ad13a30b7 100644 --- a/src/sage/arith/functions.pxd +++ b/src/sage/arith/functions.pxd @@ -1,3 +1,3 @@ -cpdef LCM_list(v) +cpdef LCM_list(v) noexcept -cdef LCM_generic(itr, ret) +cdef LCM_generic(itr, ret) noexcept diff --git a/src/sage/arith/functions.pyx b/src/sage/arith/functions.pyx index db49367b7f4..040a11ff0d6 100644 --- a/src/sage/arith/functions.pyx +++ b/src/sage/arith/functions.pyx @@ -124,7 +124,7 @@ def lcm(a, b=None): raise TypeError(f"unable to find lcm of {a!r} and {b!r}") -cpdef LCM_list(v): +cpdef LCM_list(v) noexcept: """ Return the LCM of an iterable ``v``. @@ -206,7 +206,7 @@ cpdef LCM_list(v): return z -cdef LCM_generic(itr, ret): +cdef LCM_generic(itr, ret) noexcept: """ Return the least common multiple of the element ``ret`` and the elements in the iterable ``itr``. diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd index 3ea70cef571..ce6a70bc215 100644 --- a/src/sage/arith/long.pxd +++ b/src/sage/arith/long.pxd @@ -217,12 +217,12 @@ cdef inline bint integer_check_long(x, long* value, int* err) except -1: return 0 -cdef inline long dig(const digit* D, int n): +cdef inline long dig(const digit* D, int n) noexcept: # Convenient helper function for integer_check_long_py() return (D[n]) << (n * PyLong_SHIFT) -cdef inline bint integer_check_long_py(x, long* value, int* err): +cdef inline bint integer_check_long_py(x, long* value, int* err) noexcept: """ Return whether ``x`` is a python object of type ``int``. @@ -381,7 +381,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err): return 1 -cdef inline bint is_small_python_int(obj): +cdef inline bint is_small_python_int(obj) noexcept: """ Test whether Python object is a small Python integer. diff --git a/src/sage/arith/multi_modular.pxd b/src/sage/arith/multi_modular.pxd index ca43eb3e23f..62534fce43c 100644 --- a/src/sage/arith/multi_modular.pxd +++ b/src/sage/arith/multi_modular.pxd @@ -13,11 +13,11 @@ cdef class MultiModularBasis_base(): cdef unsigned long _num_primes cdef mod_int _new_random_prime(self, set known_primes) except 1 - cdef mod_int last_prime(self) - cdef _realloc_to_new_count(self, new_count) + cdef mod_int last_prime(self) noexcept + cdef _realloc_to_new_count(self, new_count) noexcept cdef int _extend_moduli_to_height_c(self, mpz_t height) except -1 - cdef void _refresh_products(self, int start) - cdef void _refresh_prod(self) + cdef void _refresh_products(self, int start) noexcept + cdef void _refresh_prod(self) noexcept cdef void _refresh_precomputations(self, int start) except * cdef int min_moduli_count(self, mpz_t height) except -1 diff --git a/src/sage/arith/multi_modular.pyx b/src/sage/arith/multi_modular.pyx index a656742bd50..44a6059c6f1 100644 --- a/src/sage/arith/multi_modular.pyx +++ b/src/sage/arith/multi_modular.pyx @@ -101,7 +101,7 @@ cdef class MultiModularBasis_base(): mpz_init(self.product) mpz_init(self.half_product) - cdef _realloc_to_new_count(self, new_count): + cdef _realloc_to_new_count(self, new_count) noexcept: self.moduli = check_reallocarray(self.moduli, new_count, sizeof(mod_int)) self.partial_products = check_reallocarray(self.partial_products, new_count, sizeof(mpz_t)) self.C = check_reallocarray(self.C, new_count, sizeof(mod_int)) @@ -445,7 +445,7 @@ cdef class MultiModularBasis_base(): """ self._extend_moduli_to_count(self.n + count) - cdef void _refresh_products(self, int start): + cdef void _refresh_products(self, int start) noexcept: r""" Compute and store `\prod_j=1^{i-1} m_j` for i > start. """ @@ -460,7 +460,7 @@ cdef class MultiModularBasis_base(): mpz_clear(z) self._refresh_prod() - cdef void _refresh_prod(self): + cdef void _refresh_prod(self) noexcept: # record the product and half product for balancing the lifts. mpz_set(self.product, self.partial_products[self.n-1]) mpz_fdiv_q_ui(self.half_product, self.product, 2) @@ -492,7 +492,7 @@ cdef class MultiModularBasis_base(): return count - cdef mod_int last_prime(self): + cdef mod_int last_prime(self) noexcept: return self.moduli[self.n-1] cdef int mpz_reduce_tail(self, mpz_t z, mod_int* b, int offset, int len) except -1: diff --git a/src/sage/arith/power.pxd b/src/sage/arith/power.pxd index 7651245d2eb..33f043e9551 100644 --- a/src/sage/arith/power.pxd +++ b/src/sage/arith/power.pxd @@ -7,12 +7,12 @@ ctypedef fused ulong_or_object: object -cpdef generic_power(a, n) -cdef generic_power_long(a, long n) -cdef generic_power_pos(a, ulong_or_object n) # n > 0 +cpdef generic_power(a, n) noexcept +cdef generic_power_long(a, long n) noexcept +cdef generic_power_pos(a, ulong_or_object n) noexcept # n > 0 -cdef inline invert(a): +cdef inline invert(a) noexcept: """ Return ``a^(-1)``. """ @@ -21,7 +21,7 @@ cdef inline invert(a): return PyNumber_TrueDivide(type(a)(1), a) -cdef inline one(a): +cdef inline one(a) noexcept: """ Return ``a^0``. """ diff --git a/src/sage/arith/power.pyx b/src/sage/arith/power.pyx index acd5f885e85..65090f23c23 100644 --- a/src/sage/arith/power.pyx +++ b/src/sage/arith/power.pyx @@ -20,7 +20,7 @@ from cysignals.signals cimport sig_check from .long cimport integer_check_long -cpdef generic_power(a, n): +cpdef generic_power(a, n) noexcept: """ Return `a^n`. @@ -88,7 +88,7 @@ cpdef generic_power(a, n): return generic_power_pos(a, n) -cdef generic_power_long(a, long n): +cdef generic_power_long(a, long n) noexcept: """ As ``generic_power`` but where ``n`` is a C long. """ @@ -102,7 +102,7 @@ cdef generic_power_long(a, long n): return generic_power_pos(a, u) -cdef generic_power_pos(a, ulong_or_object n): +cdef generic_power_pos(a, ulong_or_object n) noexcept: """ Return `a^n` where `n > 0`. """ diff --git a/src/sage/calculus/integration.pyx b/src/sage/calculus/integration.pyx index 19b2dc2e4c8..621241436ae 100644 --- a/src/sage/calculus/integration.pyx +++ b/src/sage/calculus/integration.pyx @@ -43,10 +43,10 @@ cdef class PyFunctionWrapper: cdef list lx cdef class compiled_integrand: - cdef int c_f(self, double t): # void *params): + cdef int c_f(self, double t) noexcept: # void *params): return 0 -cdef double c_f(double t, void *params): +cdef double c_f(double t, void *params) noexcept: cdef double value cdef PyFunctionWrapper wrapper wrapper = params @@ -401,7 +401,7 @@ def numerical_integral(func, a, b=None, return result, abs_err -cdef double c_monte_carlo_f(double *t, size_t dim, void *params): +cdef double c_monte_carlo_f(double *t, size_t dim, void *params) noexcept: cdef double value cdef PyFunctionWrapper wrapper wrapper = params @@ -421,7 +421,7 @@ cdef double c_monte_carlo_f(double *t, size_t dim, void *params): return value -cdef double c_monte_carlo_ff(double *x, size_t dim, void *params): +cdef double c_monte_carlo_ff(double *x, size_t dim, void *params) noexcept: cdef double result ( params).call_c(x, &result) return result diff --git a/src/sage/calculus/interpolation.pxd b/src/sage/calculus/interpolation.pxd index 9d60459a03b..2d729228149 100644 --- a/src/sage/calculus/interpolation.pxd +++ b/src/sage/calculus/interpolation.pxd @@ -8,5 +8,5 @@ cdef class Spline: cdef int started cdef object v - cdef start_interp(self) - cdef stop_interp(self) + cdef start_interp(self) noexcept + cdef stop_interp(self) noexcept diff --git a/src/sage/calculus/interpolation.pyx b/src/sage/calculus/interpolation.pyx index 83bc83d1797..59f9fcc8e7a 100644 --- a/src/sage/calculus/interpolation.pyx +++ b/src/sage/calculus/interpolation.pyx @@ -243,7 +243,7 @@ cdef class Spline: """ return str(self.v) - cdef start_interp(self): + cdef start_interp(self) noexcept: if self.started: sig_free(self.x) sig_free(self.y) @@ -271,7 +271,7 @@ cdef class Spline: gsl_spline_init (self.spline, self.x, self.y, n) self.started = 1 - cdef stop_interp(self): + cdef stop_interp(self) noexcept: if not self.started: return sig_free(self.x) diff --git a/src/sage/calculus/ode.pxd b/src/sage/calculus/ode.pxd index e517fe0c401..2de37b91764 100644 --- a/src/sage/calculus/ode.pxd +++ b/src/sage/calculus/ode.pxd @@ -1,4 +1,4 @@ cdef class ode_system: - cdef int c_j(self,double , double *, double *,double *) + cdef int c_j(self,double , double *, double *,double *) noexcept - cdef int c_f(self,double t, double* , double* ) + cdef int c_f(self,double t, double* , double* ) noexcept diff --git a/src/sage/calculus/ode.pyx b/src/sage/calculus/ode.pyx index f1004b9b438..32ccfab5dfc 100644 --- a/src/sage/calculus/ode.pyx +++ b/src/sage/calculus/ode.pyx @@ -33,31 +33,31 @@ cdef class PyFunctionWrapper: cdef object the_parameters cdef int y_n - cdef set_yn(self,x): + cdef set_yn(self,x) noexcept: self.y_n = x cdef class ode_system: - cdef int c_j(self,double t, double *y, double *dfdy,double *dfdt): #void *params): + cdef int c_j(self,double t, double *y, double *dfdy,double *dfdt) noexcept: #void *params): return 0 - cdef int c_f(self,double t, double* y, double* dydt): #void *params): + cdef int c_f(self,double t, double* y, double* dydt) noexcept: #void *params): return 0 -cdef int c_jac_compiled(double t, double *y, double *dfdy,double *dfdt, void * params): +cdef int c_jac_compiled(double t, double *y, double *dfdy,double *dfdt, void * params) noexcept: cdef int status cdef ode_system wrapper wrapper = params status = wrapper.c_j(t,y,dfdy,dfdt) #Could add parameters return status -cdef int c_f_compiled(double t, double *y, double *dydt, void *params): +cdef int c_f_compiled(double t, double *y, double *dydt, void *params) noexcept: cdef int status cdef ode_system wrapper wrapper = params status = wrapper.c_f(t,y,dydt) #Could add parameters return status -cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params): +cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params) noexcept: cdef int i cdef int j cdef int y_n @@ -84,7 +84,7 @@ cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params): except Exception: return -1 -cdef int c_f(double t,double* y, double* dydt,void *params): +cdef int c_f(double t,double* y, double* dydt,void *params) noexcept: cdef int i cdef int y_n cdef int param_n diff --git a/src/sage/calculus/riemann.pyx b/src/sage/calculus/riemann.pyx index a4f9545bffb..0b80a29da70 100644 --- a/src/sage/calculus/riemann.pyx +++ b/src/sage/calculus/riemann.pyx @@ -291,7 +291,7 @@ cdef class Riemann_Map: """ return "A Riemann or Ahlfors mapping of a figure to the unit circle." - cdef _generate_theta_array(self): + cdef _generate_theta_array(self) noexcept: """ Generates the essential data for the Riemann map, primarily the Szegő kernel and boundary correspondence. @@ -515,7 +515,7 @@ cdef class Riemann_Map: return np.column_stack( [self.tk2, self.theta_array[boundary]]).tolist() - cdef _generate_interior_mapper(self): + cdef _generate_interior_mapper(self) noexcept: """ Generates the data necessary to use the :meth:`riemann_map` function. As much setup as possible is done here to minimize the computation @@ -568,7 +568,7 @@ cdef class Riemann_Map: cdef np.ndarray[double complex, ndim=1] pq = self.cps[:,list(range(N))+[0]].flatten() self.pre_q_vector = pq - cpdef riemann_map(self, COMPLEX_T pt): + cpdef riemann_map(self, COMPLEX_T pt) noexcept: """ Return the Riemann mapping of a point. @@ -619,7 +619,7 @@ cdef class Riemann_Map: self.pre_q_vector - pt1) return -np.dot(self.p_vector, q_vector) - cdef _generate_inverse_mapper(self): + cdef _generate_inverse_mapper(self) noexcept: """ Generates the data necessary to use the :meth:`inverse_riemann_map` function. As much setup as possible is @@ -656,7 +656,7 @@ cdef class Riemann_Map: for i in range(N): self.cosalpha[k, i] = cos(-theta_array[k, i]) - cpdef inverse_riemann_map(self, COMPLEX_T pt): + cpdef inverse_riemann_map(self, COMPLEX_T pt) noexcept: """ Return the inverse Riemann mapping of a point. @@ -764,7 +764,7 @@ cdef class Riemann_Map: pointsize=thickness) return sum(plots) - cpdef compute_on_grid(self, plot_range, int x_points): + cpdef compute_on_grid(self, plot_range, int x_points) noexcept: """ Compute the Riemann map on a grid of points. @@ -1060,7 +1060,7 @@ cdef class Riemann_Map: (ymin, ymax),options)) return g -cdef comp_pt(clist, loop=True): +cdef comp_pt(clist, loop=True) noexcept: """ Utility function to convert the list of complex numbers ``xderivs = get_derivatives(z_values, xstep, ystep)[0]`` to the plottable @@ -1090,7 +1090,7 @@ cdef comp_pt(clist, loop=True): return list2 cpdef get_derivatives(np.ndarray[COMPLEX_T, ndim=2] z_values, FLOAT_T xstep, - FLOAT_T ystep): + FLOAT_T ystep) noexcept: """ Computes the r*e^(I*theta) form of derivatives from the grid of points. The derivatives are computed using quick-and-dirty taylor expansion and @@ -1146,7 +1146,7 @@ cpdef get_derivatives(np.ndarray[COMPLEX_T, ndim=2] z_values, FLOAT_T xstep, cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values, np.ndarray[FLOAT_T, ndim = 2] dr, np.ndarray[FLOAT_T, ndim = 2] dtheta, - spokes, circles, rgbcolor, thickness, withcolor, min_mag): + spokes, circles, rgbcolor, thickness, withcolor, min_mag) noexcept: """ Converts a grid of complex numbers into a matrix containing rgb data for the Riemann spiderweb plot. @@ -1263,7 +1263,7 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values, return rgb -cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values): +cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values) noexcept: r""" Convert from a (Numpy) array of complex numbers to its corresponding matrix of RGB values. For internal use of :meth:`~Riemann_Map.plot_colored` @@ -1368,7 +1368,7 @@ cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values): sig_off() return rgb -cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon): +cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon) noexcept: """ Provides an exact (for n = infinity) Riemann boundary correspondence for the ellipse with axes 1 + epsilon and 1 - epsilon. The @@ -1417,7 +1417,7 @@ cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon): return result -cpdef cauchy_kernel(t, args): +cpdef cauchy_kernel(t, args) noexcept: """ Intermediate function for the integration in :meth:`~Riemann_Map.analytic_interior`. @@ -1463,7 +1463,7 @@ cpdef cauchy_kernel(t, args): return None -cpdef analytic_interior(COMPLEX_T z, int n, FLOAT_T epsilon): +cpdef analytic_interior(COMPLEX_T z, int n, FLOAT_T epsilon) noexcept: """ Provides a nearly exact computation of the Riemann Map of an interior point of the ellipse with axes 1 + epsilon and 1 - epsilon. It is diff --git a/src/sage/categories/action.pxd b/src/sage/categories/action.pxd index 0c9e322d455..444fcc1f38f 100644 --- a/src/sage/categories/action.pxd +++ b/src/sage/categories/action.pxd @@ -8,10 +8,10 @@ cdef class Action(Functor): cdef readonly op cdef readonly bint _is_left cdef US - cdef underlying_set(self) + cdef underlying_set(self) noexcept - cdef _act_convert(self, g, x) - cpdef _act_(self, g, x) + cdef _act_convert(self, g, x) noexcept + cpdef _act_(self, g, x) noexcept cdef class InverseAction(Action): diff --git a/src/sage/categories/action.pyx b/src/sage/categories/action.pyx index b3244f766d4..46effeecc42 100644 --- a/src/sage/categories/action.pyx +++ b/src/sage/categories/action.pyx @@ -66,7 +66,7 @@ from . import homset from weakref import ref -cdef inline category(x): +cdef inline category(x) noexcept: try: return x.category() except AttributeError: @@ -178,7 +178,7 @@ cdef class Action(Functor): else: raise TypeError("actions should be called with 1 or 2 arguments") - cdef _act_convert(self, g, x): + cdef _act_convert(self, g, x) noexcept: """ Let ``g`` act on ``x`` under this action, converting ``g`` and ``x`` to the correct parents first. @@ -190,7 +190,7 @@ cdef class Action(Functor): x = U(x) return self._act_(g, x) - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: """ Let ``g`` act on ``x`` under this action. @@ -251,7 +251,7 @@ cdef class Action(Functor): def actor(self): return self.G - cdef underlying_set(self): + cdef underlying_set(self) noexcept: """ The set on which the actor acts (it is not necessarily the codomain of the action). @@ -410,7 +410,7 @@ cdef class InverseAction(Action): """ return (type(self), (self._action,)) - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: if self.S_precomposition is not None: x = self.S_precomposition(x) return self._action._act_(~g, x) @@ -498,7 +498,7 @@ cdef class PrecomposedAction(Action): """ return (type(self), (self._action, self.G_precomposition, self.S_precomposition)) - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: if self.G_precomposition is not None: g = self.G_precomposition._call_(g) if self.S_precomposition is not None: @@ -569,7 +569,7 @@ cdef class ActionEndomorphism(Morphism): self._action = action self._g = g - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for pickling and copying. @@ -591,7 +591,7 @@ cdef class ActionEndomorphism(Morphism): slots['_g'] = self._g return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for pickling and copying. @@ -612,7 +612,7 @@ cdef class ActionEndomorphism(Morphism): self._g = _slots['_g'] Morphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: return self._action._act_(self._g, x) def _repr_(self): diff --git a/src/sage/categories/category_cy_helper.pxd b/src/sage/categories/category_cy_helper.pxd index f50ce4e8226..c7bf3759712 100644 --- a/src/sage/categories/category_cy_helper.pxd +++ b/src/sage/categories/category_cy_helper.pxd @@ -1,7 +1,7 @@ -cpdef tuple _sort_uniq(categories) +cpdef tuple _sort_uniq(categories) noexcept cdef class AxiomContainer(dict): pass -cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms) +cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms) noexcept from sage.misc.classcall_metaclass cimport ClasscallMetaclass -cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory) -cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms) +cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory) noexcept +cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms) noexcept diff --git a/src/sage/categories/category_cy_helper.pyx b/src/sage/categories/category_cy_helper.pyx index 1d0c5a2ad41..6ed38f4d00e 100644 --- a/src/sage/categories/category_cy_helper.pyx +++ b/src/sage/categories/category_cy_helper.pyx @@ -21,7 +21,7 @@ AUTHOR: ####################################### # Sorting -cpdef inline tuple category_sort_key(object category): +cpdef inline tuple category_sort_key(object category) noexcept: """ Return ``category._cmp_key``. @@ -38,7 +38,7 @@ cpdef inline tuple category_sort_key(object category): """ return category._cmp_key -cpdef tuple _sort_uniq(categories): +cpdef tuple _sort_uniq(categories) noexcept: """ Return the categories after sorting them and removing redundant categories. @@ -72,7 +72,7 @@ cpdef tuple _sort_uniq(categories): result.append(category) return tuple(result) -cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory): +cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory) noexcept: """ Return the tuple of categories in ``categories``, while flattening join categories. @@ -108,7 +108,7 @@ cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory): ############################################# # Join -cdef bint is_supercategory_of_done(new_cat, dict done): +cdef bint is_supercategory_of_done(new_cat, dict done) noexcept: # This is a helper function. It replaces the closure # any(cat.is_subcategory(new_cat) for cat in done) for cat in done: @@ -116,7 +116,7 @@ cdef bint is_supercategory_of_done(new_cat, dict done): return True return False -cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms): +cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms) noexcept: """ Helper for :meth:`~sage.categories.category.Category.join`. @@ -267,7 +267,7 @@ cdef class AxiomContainer(dict): return self -cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom): +cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom) noexcept: """ Helper function: Return the rank of an axiom. @@ -286,7 +286,7 @@ cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom): return (all_axioms)[axiom] -cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms): +cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms) noexcept: r""" Canonicalize a set of axioms. diff --git a/src/sage/categories/examples/semigroups_cython.pyx b/src/sage/categories/examples/semigroups_cython.pyx index b456c2868f8..2b7b76c00e3 100644 --- a/src/sage/categories/examples/semigroups_cython.pyx +++ b/src/sage/categories/examples/semigroups_cython.pyx @@ -85,7 +85,7 @@ cdef class LeftZeroSemigroupElement(Element): """ return LeftZeroSemigroupElement, (self._parent, self._value) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ EXAMPLES:: @@ -100,7 +100,7 @@ cdef class LeftZeroSemigroupElement(Element): right = (other)._value return PyObject_RichCompare(left, right, op) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ EXAMPLES:: diff --git a/src/sage/categories/map.pxd b/src/sage/categories/map.pxd index 0467b872353..98c74d862e4 100644 --- a/src/sage/categories/map.pxd +++ b/src/sage/categories/map.pxd @@ -8,12 +8,12 @@ cdef class Map(Element): # a rough measure of the cost of using this morphism in the coercion system. # 10 by default, 100 if a DefaultCoercionMorphism, 10000 if inexact. - cdef _update_slots(self, dict) - cdef dict _extra_slots(self) + cdef _update_slots(self, dict) noexcept + cdef dict _extra_slots(self) noexcept # these methods require x is an element of domain, and returns an element with parent codomain - cpdef Element _call_(self, x) - cpdef Element _call_with_args(self, x, args=*, kwds=*) + cpdef Element _call_(self, x) noexcept + cpdef Element _call_with_args(self, x, args=*, kwds=*) noexcept cdef public domain # will be either a weakref or a constant map cdef public codomain # will be a constant map @@ -23,7 +23,7 @@ cdef class Map(Element): cdef public _repr_type_str cdef public bint _is_coercion - cpdef _pow_int(self, n) + cpdef _pow_int(self, n) noexcept cdef class Section(Map): diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx index 45c30ae6c31..8f09e3aa00d 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -389,7 +389,7 @@ cdef class Map(Element): self.domain = ConstantFunction(D) self._parent = homset.Hom(D, C, self._category_for) - cdef _update_slots(self, dict slots): + cdef _update_slots(self, dict slots) noexcept: """ Set various attributes of this map to implement unpickling. @@ -451,7 +451,7 @@ cdef class Map(Element): """ self._update_slots(_slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Return a dict with attributes to pickle and copy this map. """ @@ -816,7 +816,7 @@ cdef class Map(Element): return self._call_(x) return self._call_with_args(x, args, kwds) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Call method with a single argument, not implemented in the base class. @@ -831,7 +831,7 @@ cdef class Map(Element): """ raise NotImplementedError(type(self)) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ Call method with multiple arguments, not implemented in the base class. @@ -1222,7 +1222,7 @@ cdef class Map(Element): """ raise NotImplementedError(type(self)) - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ TESTS:: @@ -1368,7 +1368,7 @@ cdef class Section(Map): Map.__init__(self, Hom(map.codomain(), map.domain(), SetsWithPartialMaps())) self._inverse = map # TODO: Use this attribute somewhere! - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for pickling and copying. @@ -1387,7 +1387,7 @@ cdef class Section(Map): slots['_inverse'] = self._inverse return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for pickling and copying. @@ -1576,7 +1576,7 @@ cdef class FormalCompositeMap(Map): """ return FormalCompositeMap(self.parent(), [f.__copy__() for f in self.__list]) - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Used in pickling and copying. @@ -1595,7 +1595,7 @@ cdef class FormalCompositeMap(Map): self.__list = _slots['__list'] Map._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Used in pickling and copying. @@ -1708,7 +1708,7 @@ cdef class FormalCompositeMap(Map): """ return self.__list[i] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Call with a single argument @@ -1726,7 +1726,7 @@ cdef class FormalCompositeMap(Map): x = f._call_(x) return x - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ Additional arguments are only passed to the last applied map. diff --git a/src/sage/categories/morphism.pxd b/src/sage/categories/morphism.pxd index fce5487d829..1a941b62b33 100644 --- a/src/sage/categories/morphism.pxd +++ b/src/sage/categories/morphism.pxd @@ -7,4 +7,4 @@ cdef class Morphism(Map): cdef class SetMorphism(Morphism): cdef object _function - cpdef bint _eq_c_impl(left, Element right) + cpdef bint _eq_c_impl(left, Element right) noexcept diff --git a/src/sage/categories/morphism.pyx b/src/sage/categories/morphism.pyx index 571f90a7330..32fcd565e34 100644 --- a/src/sage/categories/morphism.pyx +++ b/src/sage/categories/morphism.pyx @@ -344,7 +344,7 @@ cdef class Morphism(Map): definition = repr(self) return hash((domain, codomain, definition)) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Generic comparison function for morphisms. @@ -453,7 +453,7 @@ cdef class FormalCoercionMorphism(Morphism): def _repr_type(self): return "Coercion" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: return self._codomain.coerce(x) cdef class CallMorphism(Morphism): @@ -461,7 +461,7 @@ cdef class CallMorphism(Morphism): def _repr_type(self): return "Call" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: return self._codomain(x) cdef class IdentityMorphism(Morphism): @@ -475,10 +475,10 @@ cdef class IdentityMorphism(Morphism): def _repr_type(self): return "Identity" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: return x - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: if not args and not kwds: return x cdef Parent C = self._codomain @@ -499,7 +499,7 @@ cdef class IdentityMorphism(Morphism): else: return left - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: return self def __invert__(self): @@ -586,7 +586,7 @@ cdef class SetMorphism(Morphism): Morphism.__init__(self, parent) self._function = function - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ INPUT: @@ -607,7 +607,7 @@ cdef class SetMorphism(Morphism): """ return self._function(x) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ Extra arguments are passed to the defining function. @@ -629,7 +629,7 @@ cdef class SetMorphism(Morphism): except Exception: raise TypeError("Underlying map %s does not accept additional arguments" % type(self._function)) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ INPUT: @@ -651,7 +651,7 @@ cdef class SetMorphism(Morphism): slots['_function'] = self._function return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ INPUT: @@ -680,7 +680,7 @@ cdef class SetMorphism(Morphism): self._function = _slots['_function'] Map._update_slots(self, _slots) - cpdef bint _eq_c_impl(self, Element other): + cpdef bint _eq_c_impl(self, Element other) noexcept: """ Equality test diff --git a/src/sage/coding/ag_code_decoders.pyx b/src/sage/coding/ag_code_decoders.pyx index ccd6c8c6912..162c7210fc5 100644 --- a/src/sage/coding/ag_code_decoders.pyx +++ b/src/sage/coding/ag_code_decoders.pyx @@ -1318,7 +1318,7 @@ class DifferentialAGCodeUniqueDecoder(Decoder): return self._encode(self._decode(received_vector, **kwargs)) -cdef inline int pos_mod(int a, int b): +cdef inline int pos_mod(int a, int b) noexcept: """ Return ``a % b`` such that the result is positive. @@ -1384,7 +1384,7 @@ cdef class Decoder_K(): message_index = self.message_index return vector(sum([message[i]*code_basis[i] for i in range(len(message_index))])) - cdef inline int _degree(self, Polynomial f): + cdef inline int _degree(self, Polynomial f) noexcept: """ Return the degree of polynomial ``f`` @@ -1395,7 +1395,7 @@ cdef class Decoder_K(): else: return f.degree() - cdef void _exponents(self, int s, int *sk, int *si): + cdef void _exponents(self, int s, int *sk, int *si) noexcept: """ Compute the exponents of the monomial with weighted degree ``s``. @@ -1414,7 +1414,7 @@ cdef class Decoder_K(): @cython.wraparound(False) @cython.boundscheck(False) - cdef void _substitution(self, FreeModuleElement vec, w, int k, Py_ssize_t i): + cdef void _substitution(self, FreeModuleElement vec, w, int k, Py_ssize_t i) noexcept: r""" Substitute ``z`` with ``(z + w*phi_s)``. @@ -1740,7 +1740,7 @@ cdef class Decoder_K(): @cython.wraparound(False) @cython.boundscheck(False) - cdef inline int _next(self, int s): + cdef inline int _next(self, int s) noexcept: """ Return the next value after ``s`` in dRbar(dWbar). """ @@ -1757,7 +1757,7 @@ cdef class Decoder_K(): @cython.wraparound(False) @cython.boundscheck(False) - cdef inline void _get_eta_basis(self, list basis, list vecs, int s0, mon_func): + cdef inline void _get_eta_basis(self, list basis, list vecs, int s0, mon_func) noexcept: """ Compute a basis of J and h-functions via FGLM algorithm. diff --git a/src/sage/coding/binary_code.pxd b/src/sage/coding/binary_code.pxd index 4ae828dcd2b..38be220c731 100644 --- a/src/sage/coding/binary_code.pxd +++ b/src/sage/coding/binary_code.pxd @@ -1,4 +1,4 @@ -cdef int *hamming_weights() +cdef int *hamming_weights() noexcept ctypedef unsigned int codeword @@ -18,20 +18,20 @@ cdef class BinaryCode: cdef int radix cdef int nwords - cdef int is_one(self, int, int) - cdef int is_automorphism(self, int *, int *) - cpdef int put_in_std_form(self) - cdef void _apply_permutation_to_basis(self, object labeling) - cdef void _update_words_from_basis(self) + cdef int is_one(self, int, int) noexcept + cdef int is_automorphism(self, int *, int *) noexcept + cpdef int put_in_std_form(self) noexcept + cdef void _apply_permutation_to_basis(self, object labeling) noexcept + cdef void _update_words_from_basis(self) noexcept -cdef WordPermutation *create_word_perm(object) -cdef WordPermutation *create_array_word_perm(int *, int, int) -cdef WordPermutation *create_id_word_perm(int) -cdef WordPermutation *create_comp_word_perm(WordPermutation *, WordPermutation *) -cdef WordPermutation *create_inv_word_perm(WordPermutation *) -cdef int dealloc_word_perm(WordPermutation *) -cdef codeword permute_word_by_wp(WordPermutation *, codeword) -cdef codeword *expand_to_ortho_basis(BinaryCode, int) +cdef WordPermutation *create_word_perm(object) noexcept +cdef WordPermutation *create_array_word_perm(int *, int, int) noexcept +cdef WordPermutation *create_id_word_perm(int) noexcept +cdef WordPermutation *create_comp_word_perm(WordPermutation *, WordPermutation *) noexcept +cdef WordPermutation *create_inv_word_perm(WordPermutation *) noexcept +cdef int dealloc_word_perm(WordPermutation *) noexcept +cdef codeword permute_word_by_wp(WordPermutation *, codeword) noexcept +cdef codeword *expand_to_ortho_basis(BinaryCode, int) noexcept cdef class OrbitPartition: cdef int nwords @@ -45,11 +45,11 @@ cdef class OrbitPartition: cdef int *col_min_cell_rep cdef int *col_size - cdef int wd_find(self, int) - cdef void wd_union(self, int, int) - cdef int col_find(self, int) - cdef void col_union(self, int, int) - cdef int merge_perm(self, int *, int *) + cdef int wd_find(self, int) noexcept + cdef void wd_union(self, int, int) noexcept + cdef int col_find(self, int) noexcept + cdef void col_union(self, int, int) noexcept + cdef int merge_perm(self, int *, int *) noexcept cdef class PartitionStack: cdef int *wd_ents @@ -69,24 +69,24 @@ cdef class PartitionStack: cdef int *wd_counts # These are just for scratch space... cdef int *wd_output # - cdef int is_discrete(self, int) - cdef int num_cells(self, int) - cdef int sat_225(self, int) - cdef void new_min_cell_reps(self, int, unsigned int *, int) - cdef void fixed_vertices(self, int, unsigned int *, unsigned int *, int) - cdef int new_first_smallest_nontrivial(self, int, unsigned int *, int) - cdef void col_percolate(self, int, int) - cdef void wd_percolate(self, int, int) - cdef int split_vertex(self, int, int) - cdef int col_degree(self, BinaryCode, int, int, int) - cdef int wd_degree(self, BinaryCode, int, int, int, int *) - cdef int sort_cols(self, int, int) - cdef int sort_wds(self, int, int) - cdef int refine(self, int, int *, int, BinaryCode, int *) - cdef void clear(self, int) - cpdef int cmp(self, PartitionStack, BinaryCode) - cdef int find_basis(self, int *) - cdef void get_permutation(self, PartitionStack, int *, int *) + cdef int is_discrete(self, int) noexcept + cdef int num_cells(self, int) noexcept + cdef int sat_225(self, int) noexcept + cdef void new_min_cell_reps(self, int, unsigned int *, int) noexcept + cdef void fixed_vertices(self, int, unsigned int *, unsigned int *, int) noexcept + cdef int new_first_smallest_nontrivial(self, int, unsigned int *, int) noexcept + cdef void col_percolate(self, int, int) noexcept + cdef void wd_percolate(self, int, int) noexcept + cdef int split_vertex(self, int, int) noexcept + cdef int col_degree(self, BinaryCode, int, int, int) noexcept + cdef int wd_degree(self, BinaryCode, int, int, int, int *) noexcept + cdef int sort_cols(self, int, int) noexcept + cdef int sort_wds(self, int, int) noexcept + cdef int refine(self, int, int *, int, BinaryCode, int *) noexcept + cdef void clear(self, int) noexcept + cpdef int cmp(self, PartitionStack, BinaryCode) noexcept + cdef int find_basis(self, int *) noexcept + cdef void get_permutation(self, PartitionStack, int *, int *) noexcept cdef class BinaryCodeClassifier: cdef int *ham_wts @@ -113,6 +113,6 @@ cdef class BinaryCodeClassifier: cdef int Phi_size - cdef void record_automorphism(self, int *, int) - cdef void aut_gp_and_can_label(self, BinaryCode, int) + cdef void record_automorphism(self, int *, int) noexcept + cdef void aut_gp_and_can_label(self, BinaryCode, int) noexcept diff --git a/src/sage/coding/binary_code.pyx b/src/sage/coding/binary_code.pyx index fba66d7c690..6779708bfda 100644 --- a/src/sage/coding/binary_code.pyx +++ b/src/sage/coding/binary_code.pyx @@ -57,7 +57,7 @@ WORD_SIZE = sizeof(codeword) << 3 cdef enum: chunk_size = 8 -cdef inline int min(int a, int b): +cdef inline int min(int a, int b) noexcept: if a > b: return b else: @@ -67,7 +67,7 @@ cdef inline int min(int a, int b): ## functions come without an underscore, and the def'd equivalents, which are ## essentially only for doctesting and debugging, have underscores. -cdef int *hamming_weights(): +cdef int *hamming_weights() noexcept: cdef int *ham_wts cdef int i ham_wts = sig_malloc( 65536 * sizeof(int) ) @@ -279,7 +279,7 @@ def test_word_perms(t_limit=5.0): dealloc_word_perm(i) sig_free(arr) -cdef WordPermutation *create_word_perm(object list_perm): +cdef WordPermutation *create_word_perm(object list_perm) noexcept: r""" Create a word permutation from a Python list permutation L, i.e. such that `i \mapsto L[i]`. @@ -330,7 +330,7 @@ cdef WordPermutation *create_word_perm(object list_perm): image ^= images_i[1 << j] return word_perm -cdef WordPermutation *create_array_word_perm(int *array, int start, int degree): +cdef WordPermutation *create_array_word_perm(int *array, int start, int degree) noexcept: """ Create a word permutation of a given degree from a C array, starting at start. """ @@ -379,7 +379,7 @@ cdef WordPermutation *create_array_word_perm(int *array, int start, int degree): image ^= images_i[1 << j] return word_perm -cdef WordPermutation *create_id_word_perm(int degree): +cdef WordPermutation *create_id_word_perm(int degree) noexcept: """ Create the identity word permutation of degree degree. """ @@ -427,7 +427,7 @@ cdef WordPermutation *create_id_word_perm(int degree): image ^= images_i[1 << j] return word_perm -cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation *h): +cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation *h) noexcept: r""" Create the composition of word permutations `g \circ h`. """ @@ -478,7 +478,7 @@ cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation image ^= images_i[1 << j] return word_perm -cdef WordPermutation *create_inv_word_perm(WordPermutation *g): +cdef WordPermutation *create_inv_word_perm(WordPermutation *g) noexcept: r""" Create the inverse `g^{-1}` of the word permutation of `g`. """ @@ -496,7 +496,7 @@ cdef WordPermutation *create_inv_word_perm(WordPermutation *g): sig_free(array) return w -cdef int dealloc_word_perm(WordPermutation *wp): +cdef int dealloc_word_perm(WordPermutation *wp) noexcept: """ Free the memory used by a word permutation. """ @@ -506,7 +506,7 @@ cdef int dealloc_word_perm(WordPermutation *wp): sig_free(wp.images) sig_free(wp) -cdef codeword permute_word_by_wp(WordPermutation *wp, codeword word): +cdef codeword permute_word_by_wp(WordPermutation *wp, codeword word) noexcept: """ Return the codeword obtained by applying the permutation wp to word. """ @@ -574,7 +574,7 @@ def test_expand_to_ortho_basis(B=None): print(''.join(reversed(Integer(output[i]).binary().zfill(C.ncols)))) sig_free(output) -cdef codeword *expand_to_ortho_basis(BinaryCode B, int n): +cdef codeword *expand_to_ortho_basis(BinaryCode B, int n) noexcept: r""" INPUT: @@ -1073,7 +1073,7 @@ cdef class BinaryCode: """ return self.is_one(word, col) != 0 - cdef int is_one(self, int word, int column): + cdef int is_one(self, int word, int column) noexcept: return (self.words[word] & ( 1 << column)) >> column def _is_automorphism(self, col_gamma, word_gamma): @@ -1121,7 +1121,7 @@ cdef class BinaryCode: sig_free(_word_gamma) return result - cdef int is_automorphism(self, int *col_gamma, int *word_gamma): + cdef int is_automorphism(self, int *col_gamma, int *word_gamma) noexcept: cdef int i, j, self_nwords = self.nwords, self_ncols = self.ncols i = 1 while i < self_nwords: @@ -1180,7 +1180,7 @@ cdef class BinaryCode: self._apply_permutation_to_basis(labeling) self._update_words_from_basis() - cdef void _apply_permutation_to_basis(self, object labeling): + cdef void _apply_permutation_to_basis(self, object labeling) noexcept: cdef WordPermutation *wp cdef int i wp = create_word_perm(labeling) @@ -1188,7 +1188,7 @@ cdef class BinaryCode: self.basis[i] = permute_word_by_wp(wp, self.basis[i]) dealloc_word_perm(wp) - cdef void _update_words_from_basis(self): + cdef void _update_words_from_basis(self) noexcept: cdef codeword word cdef int j, parity, combination word = 0 @@ -1206,7 +1206,7 @@ cdef class BinaryCode: combination ^= (1 << j) word ^= self.basis[j] - cpdef int put_in_std_form(self): + cpdef int put_in_std_form(self) noexcept: """ Put the code in binary form, which is defined by an identity matrix on the left, augmented by a matrix of data. @@ -1386,7 +1386,7 @@ cdef class OrbitPartition: """ return self.wd_find(word) - cdef int wd_find(self, int word): + cdef int wd_find(self, int word) noexcept: if self.wd_parent[word] == word: return word else: @@ -1421,7 +1421,7 @@ cdef class OrbitPartition: """ self.wd_union(x, y) - cdef void wd_union(self, int x, int y): + cdef void wd_union(self, int x, int y) noexcept: cdef int x_root, y_root x_root = self.wd_find(x) y_root = self.wd_find(y) @@ -1460,7 +1460,7 @@ cdef class OrbitPartition: """ return self.col_find(col) - cdef int col_find(self, int col): + cdef int col_find(self, int col) noexcept: if self.col_parent[col] == col: return col else: @@ -1495,7 +1495,7 @@ cdef class OrbitPartition: """ self.col_union(x, y) - cdef void col_union(self, int x, int y): + cdef void col_union(self, int x, int y) noexcept: cdef int x_root, y_root x_root = self.col_find(x) y_root = self.col_find(y) @@ -1558,7 +1558,7 @@ cdef class OrbitPartition: sig_free(_wd_gamma) return result - cdef int merge_perm(self, int *col_gamma, int *wd_gamma): + cdef int merge_perm(self, int *col_gamma, int *wd_gamma) noexcept: cdef int i, gamma_i_root cdef int j, gamma_j_root, return_value = 0 cdef int *self_wd_parent = self.wd_parent @@ -1906,7 +1906,7 @@ cdef class PartitionStack: """ return self.is_discrete(k) - cdef int is_discrete(self, int k): + cdef int is_discrete(self, int k) noexcept: cdef int i, self_ncols = self.ncols, self_nwords = self.nwords cdef int *self_col_lvls = self.col_lvls cdef int *self_wd_lvls = self.wd_lvls @@ -1942,7 +1942,7 @@ cdef class PartitionStack: """ return self.num_cells(k) - cdef int num_cells(self, int k): + cdef int num_cells(self, int k) noexcept: cdef int i, j = 0 cdef int *self_wd_lvls = self.wd_lvls cdef int *self_col_lvls = self.col_lvls @@ -1982,7 +1982,7 @@ cdef class PartitionStack: """ return self.sat_225(k) - cdef int sat_225(self, int k): + cdef int sat_225(self, int k) noexcept: cdef int i, n = self.nwords + self.ncols, in_cell = 0 cdef int nontrivial_cells = 0, total_cells = self.num_cells(k) cdef int *self_wd_lvls = self.wd_lvls @@ -2049,7 +2049,7 @@ cdef class PartitionStack: # reps += (1 << i) # return reps # - cdef void new_min_cell_reps(self, int k, unsigned int *Omega, int start): + cdef void new_min_cell_reps(self, int k, unsigned int *Omega, int start) noexcept: cdef int i, j cdef int *self_col_lvls = self.col_lvls cdef int *self_wd_lvls = self.wd_lvls @@ -2109,7 +2109,7 @@ cdef class PartitionStack: # fixed += (1 << i) # return fixed & mcrs # - cdef void fixed_vertices(self, int k, unsigned int *Phi, unsigned int *Omega, int start): + cdef void fixed_vertices(self, int k, unsigned int *Phi, unsigned int *Omega, int start) noexcept: cdef int i, j, length, ell, fixed = 0 cdef int radix = self.radix, nwords = self.nwords, ncols = self.ncols cdef int *self_col_lvls = self.col_lvls @@ -2184,7 +2184,7 @@ cdef class PartitionStack: # cell = (~0 << location) ^ (~0 << j+1) # <------- self.radix -----> # return cell # [0]*(radix-j-1) + [1]*(j-location+1) + [0]*location # - cdef int new_first_smallest_nontrivial(self, int k, unsigned int *W, int start): + cdef int new_first_smallest_nontrivial(self, int k, unsigned int *W, int start) noexcept: cdef int ell cdef int i = 0, j = 0, location = 0, min = self.ncols, nwords = self.nwords cdef int min_is_col = 1, radix = self.radix @@ -2296,7 +2296,7 @@ cdef class PartitionStack: """ self.col_percolate(start, end) - cdef void col_percolate(self, int start, int end): + cdef void col_percolate(self, int start, int end) noexcept: cdef int i, temp cdef int *self_col_ents = self.col_ents for i from end >= i > start: @@ -2331,7 +2331,7 @@ cdef class PartitionStack: """ self.wd_percolate(start, end) - cdef void wd_percolate(self, int start, int end): + cdef void wd_percolate(self, int start, int end) noexcept: cdef int i, temp cdef int *self_wd_ents = self.wd_ents for i from end >= i > start: @@ -2430,7 +2430,7 @@ cdef class PartitionStack: """ return self.split_vertex(v, k) - cdef int split_vertex(self, int v, int k): + cdef int split_vertex(self, int v, int k) noexcept: cdef int i = 0, j, flag = self.flag cdef int *ents cdef int *lvls @@ -2496,7 +2496,7 @@ cdef class PartitionStack: """ return self.col_degree(C, col, wd_ptr, k) - cdef int col_degree(self, BinaryCode CG, int col, int wd_ptr, int k): + cdef int col_degree(self, BinaryCode CG, int col, int wd_ptr, int k) noexcept: cdef int i = 0 cdef int *self_wd_lvls = self.wd_lvls cdef int *self_wd_ents = self.wd_ents @@ -2540,7 +2540,7 @@ cdef class PartitionStack: sig_free(ham_wts) return result - cdef int wd_degree(self, BinaryCode CG, int wd, int col_ptr, int k, int *ham_wts): + cdef int wd_degree(self, BinaryCode CG, int wd, int col_ptr, int k, int *ham_wts) noexcept: cdef int *self_col_lvls = self.col_lvls cdef int *self_col_ents = self.col_ents @@ -2580,7 +2580,7 @@ cdef class PartitionStack: self.col_degs[i] = degrees[i] return self.sort_cols(start, k) - cdef int sort_cols(self, int start, int k): + cdef int sort_cols(self, int start, int k) noexcept: cdef int i, j, max, max_location, self_ncols = self.ncols cdef int self_nwords = self.nwords, ii cdef int *self_col_counts = self.col_counts @@ -2650,7 +2650,7 @@ cdef class PartitionStack: self.wd_degs[i] = degrees[i] return self.sort_wds(start, k) - cdef int sort_wds(self, int start, int k): + cdef int sort_wds(self, int start, int k) noexcept: cdef int i, j, max, max_location, self_nwords = self.nwords cdef int ii, self_ncols = self.ncols cdef int *self_wd_counts = self.wd_counts @@ -2755,7 +2755,7 @@ cdef class PartitionStack: sig_free(ham_wts) return result - cdef int refine(self, int k, int *alpha, int alpha_length, BinaryCode CG, int *ham_wts): + cdef int refine(self, int k, int *alpha, int alpha_length, BinaryCode CG, int *ham_wts) noexcept: cdef int q, r, s, t, flag = self.flag, self_ncols = self.ncols cdef int t_w, self_nwords = self.nwords, invariant = 0, i, j, m = 0 cdef int *self_wd_degs = self.wd_degs @@ -2858,7 +2858,7 @@ cdef class PartitionStack: """ self.clear(k) - cdef void clear(self, int k): + cdef void clear(self, int k) noexcept: cdef int i, j = 0, nwords = self.nwords, ncols = self.ncols cdef int *wd_lvls = self.wd_lvls cdef int *col_lvls = self.col_lvls @@ -2876,7 +2876,7 @@ cdef class PartitionStack: self.col_percolate(j, i) j = i + 1 - cpdef int cmp(self, PartitionStack other, BinaryCode CG): + cpdef int cmp(self, PartitionStack other, BinaryCode CG) noexcept: """ EXAMPLES:: @@ -2996,7 +2996,7 @@ cdef class PartitionStack: self.find_basis(ham_wts) sig_free(ham_wts) - cdef int find_basis(self, int *ham_wts): + cdef int find_basis(self, int *ham_wts) noexcept: cdef int i = 0, j, k, nwords = self.nwords, weight, basis_elts = 0, nrows = self.nrows cdef int *self_wd_ents = self.wd_ents if self.basis_locations is NULL: @@ -3072,7 +3072,7 @@ cdef class PartitionStack: sig_free(col_g) return word_l, col_l - cdef void get_permutation(self, PartitionStack other, int *word_gamma, int *col_gamma): + cdef void get_permutation(self, PartitionStack other, int *word_gamma, int *col_gamma) noexcept: cdef int i cdef int *self_wd_ents = self.wd_ents cdef int *other_wd_ents = other.wd_ents @@ -3159,7 +3159,7 @@ cdef class BinaryCodeClassifier: sig_free(self.labeling) sig_free(self.base) - cdef void record_automorphism(self, int *gamma, int ncols): + cdef void record_automorphism(self, int *gamma, int ncols) noexcept: cdef int i, j if self.aut_gp_index + ncols > self.aut_gens_size: self.aut_gens_size *= 2 @@ -3337,7 +3337,7 @@ cdef class BinaryCodeClassifier: aut_gp_size = self.aut_gp_size return py_aut_gp_gens, py_labeling, aut_gp_size, base - cdef void aut_gp_and_can_label(self, BinaryCode C, int verbosity): + cdef void aut_gp_and_can_label(self, BinaryCode C, int verbosity) noexcept: # declare variables: cdef int i, j, ii, jj, iii, jjj, iiii # local variables diff --git a/src/sage/coding/codecan/codecan.pxd b/src/sage/coding/codecan/codecan.pxd index dd72f6bb798..b76608d68e3 100644 --- a/src/sage/coding/codecan/codecan.pxd +++ b/src/sage/coding/codecan/codecan.pxd @@ -14,23 +14,23 @@ cdef class InnerGroup: cdef SemimonomialTransformation transporter cdef bint compute_transporter - cdef inline int get_rep(self, int pos) - cdef inline int join_rows(self, int rep1, int rep2) + cdef inline int get_rep(self, int pos) noexcept + cdef inline int join_rows(self, int rep1, int rep2) noexcept - cdef InnerGroup _new_c(self) - cdef void copy_from(self, InnerGroup other) - cdef bint has_semilinear_action(self) - cdef minimize_by_row_mult(self, FreeModuleElement v) + cdef InnerGroup _new_c(self) noexcept + cdef void copy_from(self, InnerGroup other) noexcept + cdef bint has_semilinear_action(self) noexcept + cdef minimize_by_row_mult(self, FreeModuleElement v) noexcept cdef minimize_matrix_col(self, object m, int pos, list fixed_minimized_cols, - bint *group_changed) - cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos) - cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow) + bint *group_changed) noexcept + cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos) noexcept + cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow) noexcept - cdef SemimonomialTransformation get_transporter(self) + cdef SemimonomialTransformation get_transporter(self) noexcept - cdef bint has_semilinear_action(self) - cpdef int get_frob_pow(self) - cpdef column_blocks(self, mat) + cdef bint has_semilinear_action(self) noexcept + cpdef int get_frob_pow(self) noexcept + cpdef column_blocks(self, mat) noexcept cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): cdef int _k, _q @@ -53,10 +53,10 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): cdef list _autom_group_generators # specialized refine methods, called in refine - cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition) - cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition) - cdef bint _hyp_refine(self, bint *changed_partition) + cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept + cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept + cdef bint _hyp_refine(self, bint *changed_partition) noexcept # some additional methods - cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type) - cdef _init_point_hyperplane_incidence(self) + cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type) noexcept + cdef _init_point_hyperplane_incidence(self) noexcept diff --git a/src/sage/coding/codecan/codecan.pyx b/src/sage/coding/codecan/codecan.pyx index b0709155b57..4276fffda68 100644 --- a/src/sage/coding/codecan/codecan.pyx +++ b/src/sage/coding/codecan/codecan.pyx @@ -190,20 +190,20 @@ cdef class InnerGroup: """ OP_dealloc(self.row_partition) - cdef int get_rep(self, int pos): + cdef int get_rep(self, int pos) noexcept: """ Get the index of the cell of ``self.row_partition`` containing ``pos``. """ return OP_find(self.row_partition, pos) - cdef bint has_semilinear_action(self): + cdef bint has_semilinear_action(self) noexcept: """ Returns ``True`` iff the field automorphism group component of ``self`` is non-trivial. """ return (self.frob_pow > 0) - cdef int join_rows(self, int rep1, int rep2): + cdef int join_rows(self, int rep1, int rep2) noexcept: """ Join the cells with unique representatives ``rep1`` and ``rep2`` of ``self.row_partition``. @@ -212,7 +212,7 @@ cdef class InnerGroup: OP_join(self.row_partition, rep1, rep2) return self.get_rep(rep1) - cdef void copy_from(self, InnerGroup other): + cdef void copy_from(self, InnerGroup other) noexcept: """ Copy the group ``other`` to ``self``. """ @@ -221,7 +221,7 @@ cdef class InnerGroup: self.permutational_only = other.permutational_only OP_copy_from_to(other.row_partition, self.row_partition) - cdef minimize_by_row_mult(self, FreeModuleElement w): + cdef minimize_by_row_mult(self, FreeModuleElement w) noexcept: r""" We suppose `v \in \GF{q}^k` and the entries `v_i = 0` for all ``i >= self.rank``. @@ -249,7 +249,7 @@ cdef class InnerGroup: return d, v cdef minimize_matrix_col(self, object m, int pos, list fixed_minimized_cols, - bint *group_changed): + bint *group_changed) noexcept: r""" Minimize the column at position ``pos`` of the matrix ``m`` by the action of ``self``. ``m`` should have no zero column. ``self`` is set to @@ -330,7 +330,7 @@ cdef class InnerGroup: self.rank += 1 return m - cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos): + cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos) noexcept: r""" Minimize the column at position ``pos`` of the matrix ``m`` by the action of ``self``. We know that there is some nonzero entry of this @@ -347,7 +347,7 @@ cdef class InnerGroup: if pivot != self.rank: m.swap_rows(self.rank, pivot) - cdef InnerGroup _new_c(self): + cdef InnerGroup _new_c(self) noexcept: r""" Make a new copy of ``self``. """ @@ -358,7 +358,7 @@ cdef class InnerGroup: res.permutational_only = self.permutational_only return res - cdef SemimonomialTransformation get_transporter(self): + cdef SemimonomialTransformation get_transporter(self) noexcept: r""" Return the group element we have applied. Should only be called if we passed an element in @@ -380,7 +380,7 @@ cdef class InnerGroup: "with rank = %s, frobenius power = %s and partition =%s" % (self.rank, self.frob_pow, OP_string(self.row_partition)) - cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow): + cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow) noexcept: r""" Minimize the vector ``v \in \GF{q}^k`` by the action of the field automorphism component of ``self``. @@ -417,7 +417,7 @@ cdef class InnerGroup: stab_pow[0] = 0 break # for - cpdef int get_frob_pow(self): + cpdef int get_frob_pow(self) noexcept: r""" Return the power of the Frobenius automorphism which generates the corresponding component of ``self``. @@ -431,7 +431,7 @@ cdef class InnerGroup: """ return self.frob_pow - cpdef column_blocks(self, mat): + cpdef column_blocks(self, mat) noexcept: r""" Let ``mat`` be a matrix which is stabilized by ``self`` having no zero columns. We know that for each column of ``mat`` there is a uniquely @@ -646,7 +646,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._autom_group_generators.append(transp_inv * x * self._transporter) self._inner_group_stabilizer_order *= Integer(F.degree() / remaining_inner_group.get_frob_pow()) - cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type): + cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type) noexcept: """ Apply ``trans`` to ``self._root_matrix`` and minimize this matrix column by column under the inner minimization. The action is @@ -738,7 +738,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): """ return self._inner_group_stabilizer_order - cdef _init_point_hyperplane_incidence(self): + cdef _init_point_hyperplane_incidence(self) noexcept: r""" Compute a set of codewords `W` of `C` (generated by self) which is compatible with the group action, i.e. if we start with some other code `(g,\pi)C` @@ -811,7 +811,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._hyp_refine_vals = _BestValStore(self._hyp_part.degree) - cdef bint _minimization_allowed_on_col(self, int pos): + cdef bint _minimization_allowed_on_col(self, int pos) noexcept: r""" Decide if we are allowed to perform the inner minimization on position ``pos`` which is supposed to be a singleton. For linear codes over finite @@ -819,7 +819,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): """ return True - cdef bint _inner_min_(self, int pos, bint *inner_group_changed): + cdef bint _inner_min_(self, int pos, bint *inner_group_changed) noexcept: r""" Minimize the node by the action of the inner group on the ``pos``-th position. Sets ``inner_group_changed`` to ``True`` if and only if the inner group @@ -850,7 +850,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): return True cdef bint _refine(self, bint *part_changed, - bint inner_group_changed, bint first_step): + bint inner_group_changed, bint first_step) noexcept: """ Refine the partition ``self.part``. Set ``part_changed`` to ``True`` if and only if ``self.part`` was refined. @@ -900,7 +900,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): return True - cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition): + cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept: """ Refine the partition ``self.part`` by computing the orbit (respectively the hash of a canonical form) of each column vector under the inner group. @@ -953,7 +953,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): return self._one_refinement(best_vals, 0, self._n, inner_stab_changed, changed_partition, "supp_refine") - cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition): + cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept: """ Refine the partition ``self.part`` by counting (colored) neighbours in the point-hyperplane graph. @@ -999,7 +999,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._part.depth -= 1 return ret_val - cdef bint _hyp_refine(self, bint *changed_partition): + cdef bint _hyp_refine(self, bint *changed_partition) noexcept: """ Refine the partition of the hyperplanes by counting (colored) neighbours in the point-hyperplane graph. @@ -1045,7 +1045,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._hyp_part.depth -= 1 return ret_val[0] - cdef tuple _store_state_(self): + cdef tuple _store_state_(self) noexcept: r""" Store the current state of the node to a tuple, such that it can be restored by :meth:`_restore_state_`. @@ -1054,7 +1054,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._nr_of_point_refine_calls, self._nr_of_hyp_refine_calls, self._hyp_part.depth) - cdef void _restore_state_(self, tuple act_state): + cdef void _restore_state_(self, tuple act_state) noexcept: r""" The inverse of :meth:`_store_state_`. """ @@ -1064,13 +1064,13 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._nr_of_hyp_refine_calls = act_state[3] self._hyp_part.depth = act_state[4] - cdef void _store_best_(self): + cdef void _store_best_(self) noexcept: """ Store this node as the actual best candidate for the canonical form. """ self._best_candidate = copy(self._matrix) - cdef void _latex_act_node(self, str comment="", int printlvl=0): + cdef void _latex_act_node(self, str comment="", int printlvl=0) noexcept: """ Print the actual status as latex (tikz) commands to ``self._latex_debug_string``. Only needed if one wants to visualize diff --git a/src/sage/combinat/combinat_cython.pxd b/src/sage/combinat/combinat_cython.pxd index 40cae00a781..dfafe45f589 100644 --- a/src/sage/combinat/combinat_cython.pxd +++ b/src/sage/combinat/combinat_cython.pxd @@ -1,5 +1,5 @@ from sage.libs.gmp.all cimport mpz_t -cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k) +cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k) noexcept -cdef list convert(Py_ssize_t* f, Py_ssize_t n) +cdef list convert(Py_ssize_t* f, Py_ssize_t n) noexcept diff --git a/src/sage/combinat/combinat_cython.pyx b/src/sage/combinat/combinat_cython.pyx index c0905491ac2..654a10726f3 100644 --- a/src/sage/combinat/combinat_cython.pyx +++ b/src/sage/combinat/combinat_cython.pyx @@ -28,7 +28,7 @@ set_partition_iterator_blocks = LazyImport('sage.combinat.set_partition_iterator linear_extension_iterator = LazyImport('sage.combinat.posets.linear_extension_iterator', 'linear_extension_iterator', deprecation=35741) -cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity): +cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity) noexcept: """ Set s = s + t*u * (-1)^parity """ @@ -38,7 +38,7 @@ cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity): mpz_addmul(s, t, u) -cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k): +cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k) noexcept: """ Set s = S(n,k) where S(n,k) denotes a Stirling number of the second kind. @@ -276,7 +276,7 @@ def perfect_matchings_iterator(Py_ssize_t n): sig_free(e) sig_free(f) -cdef list convert(Py_ssize_t* f, Py_ssize_t n): +cdef list convert(Py_ssize_t* f, Py_ssize_t n) noexcept: """ Convert a list ``f`` representing a fixed-point free involution to a set partition. diff --git a/src/sage/combinat/crystals/letters.pxd b/src/sage/combinat/crystals/letters.pxd index 4b9598127cd..e473a02dc24 100644 --- a/src/sage/combinat/crystals/letters.pxd +++ b/src/sage/combinat/crystals/letters.pxd @@ -5,74 +5,74 @@ cdef class Letter(Element): cdef class EmptyLetter(Element): cdef readonly str value - cpdef e(self, int i) - cpdef f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef e(self, int i) noexcept + cpdef f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_A_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_B_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_C_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_D_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_G_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class LetterTuple(Element): cdef readonly tuple value - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Crystal_of_letters_type_E6_element(LetterTuple): - cpdef LetterTuple e(self, int i) - cpdef LetterTuple f(self, int i) + cpdef LetterTuple e(self, int i) noexcept + cpdef LetterTuple f(self, int i) noexcept cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): - cpdef LetterTuple lift(self) - cpdef LetterTuple retract(self, LetterTuple p) - cpdef LetterTuple e(self, int i) - cpdef LetterTuple f(self, int i) + cpdef LetterTuple lift(self) noexcept + cpdef LetterTuple retract(self, LetterTuple p) noexcept + cpdef LetterTuple e(self, int i) noexcept + cpdef LetterTuple f(self, int i) noexcept cdef class Crystal_of_letters_type_E7_element(LetterTuple): - cpdef LetterTuple e(self, int i) - cpdef LetterTuple f(self, int i) + cpdef LetterTuple e(self, int i) noexcept + cpdef LetterTuple f(self, int i) noexcept cdef class BKKLetter(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept cdef class QueerLetter_element(Letter): - cpdef Letter e(self, int i) - cpdef Letter f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Letter e(self, int i) noexcept + cpdef Letter f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class LetterWrapped(Element): cdef readonly Element value - cpdef tuple _to_tuple(self) - cpdef LetterWrapped e(self, int i) - cpdef LetterWrapped f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef tuple _to_tuple(self) noexcept + cpdef LetterWrapped e(self, int i) noexcept + cpdef LetterWrapped f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx index d204a979563..cf8d25587d8 100644 --- a/src/sage/combinat/crystals/letters.pyx +++ b/src/sage/combinat/crystals/letters.pyx @@ -464,7 +464,7 @@ cdef class Letter(Element): """ return self.value - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Return ``True`` if ``left`` compares with ``right`` based on ``op``. @@ -585,7 +585,7 @@ cdef class EmptyLetter(Element): """ return hash(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Return ``True`` if ``left`` compares with ``right`` based on ``op``. @@ -625,7 +625,7 @@ cdef class EmptyLetter(Element): """ return self._parent.weight_lattice_realization().zero() - cpdef e(self, int i): + cpdef e(self, int i) noexcept: """ Return `e_i` of ``self`` which is ``None``. @@ -636,7 +636,7 @@ cdef class EmptyLetter(Element): """ return None - cpdef f(self, int i): + cpdef f(self, int i) noexcept: """ Return `f_i` of ``self`` which is ``None``. @@ -647,7 +647,7 @@ cdef class EmptyLetter(Element): """ return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -659,7 +659,7 @@ cdef class EmptyLetter(Element): """ return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -711,7 +711,7 @@ cdef class Crystal_of_letters_type_A_element(Letter): """ return self._parent.weight_lattice_realization().monomial(self.value-1) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -726,7 +726,7 @@ cdef class Crystal_of_letters_type_A_element(Letter): else: return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -741,7 +741,7 @@ cdef class Crystal_of_letters_type_A_element(Letter): else: return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -755,7 +755,7 @@ cdef class Crystal_of_letters_type_A_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -804,7 +804,7 @@ cdef class Crystal_of_letters_type_B_element(Letter): else: return self._parent.weight_lattice_realization()(0) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -833,7 +833,7 @@ cdef class Crystal_of_letters_type_B_element(Letter): else: return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the actions of `f_i` on ``self``. @@ -862,7 +862,7 @@ cdef class Crystal_of_letters_type_B_element(Letter): else: return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -883,7 +883,7 @@ cdef class Crystal_of_letters_type_B_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -942,7 +942,7 @@ cdef class Crystal_of_letters_type_C_element(Letter): else: return self._parent.weight_lattice_realization()(0) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -965,7 +965,7 @@ cdef class Crystal_of_letters_type_C_element(Letter): else: return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -983,7 +983,7 @@ cdef class Crystal_of_letters_type_C_element(Letter): else: return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -997,7 +997,7 @@ cdef class Crystal_of_letters_type_C_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -1049,7 +1049,7 @@ cdef class Crystal_of_letters_type_D_element(Letter): else: return self._parent.weight_lattice_realization()(0) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -1082,7 +1082,7 @@ cdef class Crystal_of_letters_type_D_element(Letter): else: return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -1113,7 +1113,7 @@ cdef class Crystal_of_letters_type_D_element(Letter): else: return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -1130,7 +1130,7 @@ cdef class Crystal_of_letters_type_D_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -1188,7 +1188,7 @@ cdef class Crystal_of_letters_type_G_element(Letter): else: raise RuntimeError("G2 crystal of letters element %d not valid" % self.value) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -1222,7 +1222,7 @@ cdef class Crystal_of_letters_type_G_element(Letter): else: return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -1256,7 +1256,7 @@ cdef class Crystal_of_letters_type_G_element(Letter): else: return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -1276,7 +1276,7 @@ cdef class Crystal_of_letters_type_G_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -1358,7 +1358,7 @@ cdef class LetterTuple(Element): """ return hash(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Check comparison between ``left`` and ``right`` based on ``op`` @@ -1438,7 +1438,7 @@ cdef class LetterTuple(Element): ret+= repr(v) return ret + "\\right)" - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -1454,7 +1454,7 @@ cdef class LetterTuple(Element): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -1555,7 +1555,7 @@ cdef class Crystal_of_letters_type_E6_element(LetterTuple): R = self._parent.weight_lattice_realization().fundamental_weights() return sum(Integer(i).sign() * R[abs(i)] for i in self.value) - cpdef LetterTuple e(self, int i): + cpdef LetterTuple e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -1643,7 +1643,7 @@ cdef class Crystal_of_letters_type_E6_element(LetterTuple): else: return None - cpdef LetterTuple f(self, int i): + cpdef LetterTuple f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -1774,7 +1774,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): return l[self._parent.list().index(self)] return repr(self.value) - cpdef LetterTuple lift(self): + cpdef LetterTuple lift(self) noexcept: """ Lift an element of ``self`` to the crystal of letters ``crystals.Letters(['E',6])`` by taking its inverse weight. @@ -1791,7 +1791,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): # tuple from a list return self._parent._ambient(tuple([-i for i in self.value])) - cpdef LetterTuple retract(self, LetterTuple p): + cpdef LetterTuple retract(self, LetterTuple p) noexcept: """ Retract element ``p``, which is an element in ``crystals.Letters(['E',6])`` to an element in @@ -1814,7 +1814,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): # tuple from a list return self._parent._element_constructor_(tuple([-i for i in p.value])) - cpdef LetterTuple e(self, int i): + cpdef LetterTuple e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -1826,7 +1826,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): """ return self.retract(self.lift().f(i)) - cpdef LetterTuple f(self, int i): + cpdef LetterTuple f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -1956,7 +1956,7 @@ cdef class Crystal_of_letters_type_E7_element(LetterTuple): R = self._parent.weight_lattice_realization().fundamental_weights() return sum(Integer(i).sign() * R[abs(i)] for i in self.value) - cpdef LetterTuple e(self, int i): + cpdef LetterTuple e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -2138,7 +2138,7 @@ cdef class Crystal_of_letters_type_E7_element(LetterTuple): else: return None - cpdef LetterTuple f(self, int i): + cpdef LetterTuple f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -2395,7 +2395,7 @@ cdef class BKKLetter(Letter): ret = "\\underline{{{}}}".format(ret) return ret - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -2435,7 +2435,7 @@ cdef class BKKLetter(Letter): return self._parent._element_constructor_(-1) return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -2715,7 +2715,7 @@ cdef class QueerLetter_element(Letter): """ return self._parent.weight_lattice_realization().monomial(self.value-1) - cpdef Letter e(self, int i): + cpdef Letter e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -2731,7 +2731,7 @@ cdef class QueerLetter_element(Letter): return self._parent._element_constructor_(self.value-1) return None - cpdef Letter f(self, int i): + cpdef Letter f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -2747,7 +2747,7 @@ cdef class QueerLetter_element(Letter): return self._parent._element_constructor_(self.value+1) return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -2761,7 +2761,7 @@ cdef class QueerLetter_element(Letter): return 1 return 0 - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -2823,7 +2823,7 @@ cdef class LetterWrapped(Element): """ return hash(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Check comparison between ``left`` and ``right`` based on ``op`` @@ -2854,7 +2854,7 @@ cdef class LetterWrapped(Element): return self.value == x.value or x._parent.lt_elements(x, self) return False - cpdef tuple _to_tuple(self): + cpdef tuple _to_tuple(self) noexcept: r""" Return a tuple encoding the `\varepsilon_i` and `\varphi_i` values of ``elt``. @@ -2923,7 +2923,7 @@ cdef class LetterWrapped(Element): ret+= repr(v) return ret + "\\right)" - cpdef LetterWrapped e(self, int i): + cpdef LetterWrapped e(self, int i) noexcept: r""" Return `e_i` of ``self``. @@ -2939,7 +2939,7 @@ cdef class LetterWrapped(Element): return None return type(self)(self._parent, ret) - cpdef LetterWrapped f(self, int i): + cpdef LetterWrapped f(self, int i) noexcept: r""" Return `f_i` of ``self``. @@ -2955,7 +2955,7 @@ cdef class LetterWrapped(Element): return None return type(self)(self._parent, ret) - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -2969,7 +2969,7 @@ cdef class LetterWrapped(Element): """ return self.value.epsilon(i) - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. diff --git a/src/sage/combinat/crystals/pbw_datum.pxd b/src/sage/combinat/crystals/pbw_datum.pxd index 9c3aab083df..ecfbf60b842 100644 --- a/src/sage/combinat/crystals/pbw_datum.pxd +++ b/src/sage/combinat/crystals/pbw_datum.pxd @@ -1,3 +1,3 @@ -cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum) -cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum) -cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type) +cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum) noexcept +cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum) noexcept +cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type) noexcept diff --git a/src/sage/combinat/crystals/pbw_datum.pyx b/src/sage/combinat/crystals/pbw_datum.pyx index 2adcb09d902..a81732cdc73 100644 --- a/src/sage/combinat/crystals/pbw_datum.pyx +++ b/src/sage/combinat/crystals/pbw_datum.pyx @@ -282,7 +282,7 @@ class PBWData(): # UniqueRepresentation? # enhanced_braid_chain is an ugly data structure. @cython.boundscheck(False) @cython.wraparound(False) -cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum): +cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum) noexcept: """ Return the Lusztig datum obtained by applying tropical Plücker relations along ``enhanced_braid_chain`` starting with @@ -330,7 +330,7 @@ cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig # The tropical Plücker relations @cython.boundscheck(False) @cython.wraparound(False) -cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum): +cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum) noexcept: r""" Apply the tropical Plücker relation of type ``a`` to ``lusztig_datum``. @@ -403,7 +403,7 @@ cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum): # TODO: Move to PBW_data? @cython.boundscheck(False) @cython.wraparound(False) -cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type): +cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type) noexcept: r""" Return a list of tuples that records the data of the long words in ``braid_move_chain`` plus the data of the intervals where the braid moves diff --git a/src/sage/combinat/crystals/spins.pxd b/src/sage/combinat/crystals/spins.pxd index a486aaa2518..a98f1702508 100644 --- a/src/sage/combinat/crystals/spins.pxd +++ b/src/sage/combinat/crystals/spins.pxd @@ -5,16 +5,16 @@ cdef class Spin(Element): cdef int _n cdef long _hash - cdef Spin _new_c(self, bint* value) + cdef Spin _new_c(self, bint* value) noexcept cdef class Spin_crystal_type_B_element(Spin): - cpdef Spin e(self, int i) - cpdef Spin f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Spin e(self, int i) noexcept + cpdef Spin f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept cdef class Spin_crystal_type_D_element(Spin): - cpdef Spin e(self, int i) - cpdef Spin f(self, int i) - cpdef int epsilon(self, int i) - cpdef int phi(self, int i) + cpdef Spin e(self, int i) noexcept + cpdef Spin f(self, int i) noexcept + cpdef int epsilon(self, int i) noexcept + cpdef int phi(self, int i) noexcept diff --git a/src/sage/combinat/crystals/spins.pyx b/src/sage/combinat/crystals/spins.pyx index 7548b7b695e..97e8157afd5 100644 --- a/src/sage/combinat/crystals/spins.pyx +++ b/src/sage/combinat/crystals/spins.pyx @@ -297,7 +297,7 @@ cdef class Spin(Element): self._value[i] = (val[i] != 1) Element.__init__(self, parent) - cdef Spin _new_c(self, bint* value): + cdef Spin _new_c(self, bint* value) noexcept: r""" Fast creation of a spin element. """ @@ -349,7 +349,7 @@ cdef class Spin(Element): tup = tuple([-1 if self._value[i] else 1 for i in range(self._n)]) return (self._parent, (tup,)) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Return ``True`` if ``left`` compares with ``right`` based on ``op``. @@ -534,7 +534,7 @@ cdef class Spin_crystal_type_B_element(Spin): r""" Type B spin representation crystal element """ - cpdef Spin e(self, int i): + cpdef Spin e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -567,7 +567,7 @@ cdef class Spin_crystal_type_B_element(Spin): return self._new_c(ret) return None - cpdef Spin f(self, int i): + cpdef Spin f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -600,7 +600,7 @@ cdef class Spin_crystal_type_B_element(Spin): return self._new_c(ret) return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -617,7 +617,7 @@ cdef class Spin_crystal_type_B_element(Spin): return self._value[i-1] return self._value[i-1] and not self._value[i] - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. @@ -638,7 +638,7 @@ cdef class Spin_crystal_type_D_element(Spin): r""" Type D spin representation crystal element """ - cpdef Spin e(self, int i): + cpdef Spin e(self, int i) noexcept: r""" Return the action of `e_i` on ``self``. @@ -679,7 +679,7 @@ cdef class Spin_crystal_type_D_element(Spin): return self._new_c(ret) return None - cpdef Spin f(self, int i): + cpdef Spin f(self, int i) noexcept: r""" Return the action of `f_i` on ``self``. @@ -720,7 +720,7 @@ cdef class Spin_crystal_type_D_element(Spin): return self._new_c(ret) return None - cpdef int epsilon(self, int i): + cpdef int epsilon(self, int i) noexcept: r""" Return `\varepsilon_i` of ``self``. @@ -737,7 +737,7 @@ cdef class Spin_crystal_type_D_element(Spin): return self._value[i-1] and self._value[i-2] return self._value[i-1] and not self._value[i] - cpdef int phi(self, int i): + cpdef int phi(self, int i) noexcept: r""" Return `\varphi_i` of ``self``. diff --git a/src/sage/combinat/crystals/tensor_product_element.pxd b/src/sage/combinat/crystals/tensor_product_element.pxd index aae31eb7a03..c1af4e1cb20 100644 --- a/src/sage/combinat/crystals/tensor_product_element.pxd +++ b/src/sage/combinat/crystals/tensor_product_element.pxd @@ -1,14 +1,14 @@ from sage.structure.list_clone cimport ClonableArray cdef class ImmutableListWithParent(ClonableArray): - cpdef _set_index(self, k, value) + cpdef _set_index(self, k, value) noexcept cdef class TensorProductOfCrystalsElement(ImmutableListWithParent): pass cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement): - cpdef position_of_last_unmatched_minus(self, i) - cpdef position_of_first_unmatched_plus(self, i) + cpdef position_of_last_unmatched_minus(self, i) noexcept + cpdef position_of_first_unmatched_plus(self, i) noexcept cdef class CrystalOfTableauxElement(TensorProductOfRegularCrystalsElement): pass @@ -31,4 +31,4 @@ cdef class TensorProductOfQueerSuperCrystalsElement(TensorProductOfRegularCrysta cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrystalsElement): cdef list _row_lengths -cdef Py_ssize_t count_leading(list row, letter) +cdef Py_ssize_t count_leading(list row, letter) noexcept diff --git a/src/sage/combinat/crystals/tensor_product_element.pyx b/src/sage/combinat/crystals/tensor_product_element.pyx index bafdb5e175a..abc5a743a4e 100644 --- a/src/sage/combinat/crystals/tensor_product_element.pyx +++ b/src/sage/combinat/crystals/tensor_product_element.pyx @@ -73,7 +73,7 @@ cdef class ImmutableListWithParent(ClonableArray): self._is_immutable = True self._hash = 0 - cpdef _set_index(self, k, value): + cpdef _set_index(self, k, value) noexcept: r""" Return a sibling of ``self`` obtained by setting the `k^{th}` entry of self to value. @@ -573,7 +573,7 @@ cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement) height = height - minus + plus return height - cpdef position_of_last_unmatched_minus(self, i): + cpdef position_of_last_unmatched_minus(self, i) noexcept: """ Return the position of the last unmatched `-` or ``None`` if there is no unmatched `-`. @@ -599,7 +599,7 @@ cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement) height = height - minus + plus return unmatched_minus - cpdef position_of_first_unmatched_plus(self, i): + cpdef position_of_first_unmatched_plus(self, i) noexcept: """ Return the position of the first unmatched `+` or ``None`` if there is no unmatched `+`. @@ -1858,7 +1858,7 @@ cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrysta ret -= L(1).weight() # From the 1 on the bottom row return ret -cdef Py_ssize_t count_leading(list row, letter): +cdef Py_ssize_t count_leading(list row, letter) noexcept: cdef Py_ssize_t i for i in range(len(row)-1,-1,-1): if row[i] != letter: diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx index d98a3e66c87..ada46bf23d0 100644 --- a/src/sage/combinat/debruijn_sequence.pyx +++ b/src/sage/combinat/debruijn_sequence.pyx @@ -93,7 +93,7 @@ def debruijn_sequence(int k, int n): gen(1, 1, k, n) return sequence -cdef gen(int t, int p, k, n): +cdef gen(int t, int p, k, n) noexcept: """ The internal generation function. This should not be accessed by the user. diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx index 0ccc2377f2c..5c6ed548e01 100644 --- a/src/sage/combinat/degree_sequences.pyx +++ b/src/sage/combinat/degree_sequences.pyx @@ -412,7 +412,7 @@ class DegreeSequences: """ sig_free(seq) -cdef init(int n): +cdef init(int n) noexcept: """ Initializes the memory and starts the enumeration algorithm. """ @@ -436,7 +436,7 @@ cdef init(int n): sig_free(seq) return sequences -cdef inline add_seq(): +cdef inline add_seq() noexcept: """ This function is called whenever a sequence is found. @@ -457,7 +457,7 @@ cdef inline add_seq(): sequences.append(s) -cdef void enum(int k, int M): +cdef void enum(int k, int M) noexcept: r""" Main function; for an explanation of the algorithm please refer to the :mod:`sage.combinat.degree_sequences` documentation. diff --git a/src/sage/combinat/designs/designs_pyx.pxd b/src/sage/combinat/designs/designs_pyx.pxd index 345a41f2945..8ff6bee5bd4 100644 --- a/src/sage/combinat/designs/designs_pyx.pxd +++ b/src/sage/combinat/designs/designs_pyx.pxd @@ -17,4 +17,4 @@ cdef struct cache_entry: cdef cache_entry * _OA_cache cdef int _OA_cache_size -cpdef _OA_cache_get(int k, int n) +cpdef _OA_cache_get(int k, int n) noexcept diff --git a/src/sage/combinat/designs/designs_pyx.pyx b/src/sage/combinat/designs/designs_pyx.pyx index 4b6638634f6..5102754cab6 100644 --- a/src/sage/combinat/designs/designs_pyx.pyx +++ b/src/sage/combinat/designs/designs_pyx.pyx @@ -948,7 +948,7 @@ _OA_cache[0].max_true = -1 _OA_cache[1].max_true = -1 _OA_cache_size = 2 -cpdef _OA_cache_set(int k,int n,truth_value): +cpdef _OA_cache_set(int k,int n,truth_value) noexcept: r""" Sets a value in the OA cache of existence results @@ -983,7 +983,7 @@ cpdef _OA_cache_set(int k,int n,truth_value): else: _OA_cache[n].min_false = k if k<_OA_cache[n].min_false else _OA_cache[n].min_false -cpdef _OA_cache_get(int k,int n): +cpdef _OA_cache_get(int k,int n) noexcept: r""" Gets a value from the OA cache of existence results @@ -1002,7 +1002,7 @@ cpdef _OA_cache_get(int k,int n): return None -cpdef _OA_cache_construction_available(int k,int n): +cpdef _OA_cache_construction_available(int k,int n) noexcept: r""" Tests if a construction is implemented using the cache's information diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 066eecb9197..bb23eaec8d4 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -114,7 +114,7 @@ def find_recursive_construction(k, n): return res return False -cpdef find_product_decomposition(int k,int n): +cpdef find_product_decomposition(int k,int n) noexcept: r""" Find `n_1n_2=n` to obtain an `OA(k,n)` by the product construction. @@ -155,7 +155,7 @@ cpdef find_product_decomposition(int k,int n): return wilson_construction, (None,k,n1,n2,(),False) return False -cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n): +cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n) noexcept: r""" Find `rm+u=n` to obtain an `OA(k,n)` by Wilson's construction with one truncated column. @@ -206,7 +206,7 @@ cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n): return False -cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n): +cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n) noexcept: r""" Find `rm+r_1+r_2=n` to obtain an `OA(k,n)` by Wilson's construction with two truncated columns. @@ -268,7 +268,7 @@ cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n): return wilson_construction, (None,k,r,m,(r1,r2),False) return False -cpdef find_construction_3_3(int k,int n): +cpdef find_construction_3_3(int k,int n) noexcept: r""" Find a decomposition for construction 3.3 from [AC07]_ @@ -307,7 +307,7 @@ cpdef find_construction_3_3(int k,int n): from .orthogonal_arrays_build_recursive import construction_3_3 return construction_3_3, (k,nn,mm,i) -cpdef find_construction_3_4(int k,int n): +cpdef find_construction_3_4(int k,int n) noexcept: r""" Find a decomposition for construction 3.4 from [AC07]_ @@ -350,7 +350,7 @@ cpdef find_construction_3_4(int k,int n): from .orthogonal_arrays_build_recursive import construction_3_4 return construction_3_4, (k,nn,mm,r,s) -cpdef find_construction_3_5(int k,int n): +cpdef find_construction_3_5(int k,int n) noexcept: r""" Find a decomposition for construction 3.5 from [AC07]_ @@ -400,7 +400,7 @@ cpdef find_construction_3_5(int k,int n): from .orthogonal_arrays_build_recursive import construction_3_5 return construction_3_5, (k,nn,mm,r,s,t) -cpdef find_construction_3_6(int k,int n): +cpdef find_construction_3_6(int k,int n) noexcept: r""" Find a decomposition for construction 3.6 from [AC07]_ @@ -441,7 +441,7 @@ cpdef find_construction_3_6(int k,int n): from .orthogonal_arrays_build_recursive import construction_3_6 return construction_3_6, (k,nn,mm,i) -cpdef find_q_x(int k,int n): +cpdef find_q_x(int k,int n) noexcept: r""" Find integers `q,x` such that the `q-x` construction yields an `OA(k,n)`. @@ -494,7 +494,7 @@ cpdef find_q_x(int k,int n): return construction_q_x, (k,q,x) return False -cpdef find_thwart_lemma_3_5(int k,int N): +cpdef find_thwart_lemma_3_5(int k,int N) noexcept: r""" Find the values on which Lemma 3.5 from [Thwarts]_ applies. @@ -615,7 +615,7 @@ cpdef find_thwart_lemma_3_5(int k,int N): return False -cpdef find_thwart_lemma_4_1(int k,int n): +cpdef find_thwart_lemma_4_1(int k,int n) noexcept: r""" Find a decomposition for Lemma 4.1 from [Thwarts]_. @@ -664,7 +664,7 @@ cpdef find_thwart_lemma_4_1(int k,int n): return False -cpdef find_three_factor_product(int k,int n): +cpdef find_three_factor_product(int k,int n) noexcept: r""" Find `n_1n_2n_3=n` to obtain an `OA(k,n)` by the three-factor product from [DukesLing14]_ @@ -709,7 +709,7 @@ cpdef find_three_factor_product(int k,int n): return False -cpdef find_brouwer_separable_design(int k,int n): +cpdef find_brouwer_separable_design(int k,int n) noexcept: r""" Find `t(q^2+q+1)+x=n` to obtain an `OA(k,n)` by Brouwer's separable design construction. @@ -880,7 +880,7 @@ def int_as_sum(int value, list S, int k_max): return None -cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n): +cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept: r""" Find `rm+x_1+...+x_c=n` such that the Brouwer-van Rees constructions yields a `OA(k,n)`. diff --git a/src/sage/combinat/designs/subhypergraph_search.pyx b/src/sage/combinat/designs/subhypergraph_search.pyx index ace387a4bf2..267ff3b2fe0 100644 --- a/src/sage/combinat/designs/subhypergraph_search.pyx +++ b/src/sage/combinat/designs/subhypergraph_search.pyx @@ -129,13 +129,13 @@ ctypedef struct hypergraph: uint64_t * set_space int * names -cdef inline int bs_get(uint64_t * bitset, int index): +cdef inline int bs_get(uint64_t * bitset, int index) noexcept: r""" Return a bit of a bitset """ return (bitset[index/64]>>(index%64))&1 -cdef inline void bs_set(uint64_t * bitset, int index, int bit): +cdef inline void bs_set(uint64_t * bitset, int index, int bit) noexcept: r""" Set a bit of a bitset. @@ -145,7 +145,7 @@ cdef inline void bs_set(uint64_t * bitset, int index, int bit): bitset[index/64] &= ~(( 1)< bit)<=c` sets of size `k` containing `S` in h1. This @@ -295,7 +295,7 @@ cdef int is_subhypergraph_admissible(hypergraph h1,hypergraph * h2_trace,int n,h return 1 -cdef int cmp_128_bits(void * a, void * b) nogil: +cdef int cmp_128_bits(void * a, void * b) noexcept nogil: r""" Lexicographic order on 128-bits words """ @@ -308,7 +308,7 @@ cdef int cmp_128_bits(void * a, void * b) nogil: else: return -1 -cdef int is_induced_admissible64(hypergraph h1,hypergraph * h2_induced,int n,hypergraph tmp1): +cdef int is_induced_admissible64(hypergraph h1,hypergraph * h2_induced,int n,hypergraph tmp1) noexcept: r""" Test if the hypergraph induced in h1 by 0,...,n-1 is equal to the hypergraph induced in h2 by 0,...,n-1. diff --git a/src/sage/combinat/enumeration_mod_permgroup.pxd b/src/sage/combinat/enumeration_mod_permgroup.pxd index 2f457429ccf..6d73f402321 100644 --- a/src/sage/combinat/enumeration_mod_permgroup.pxd +++ b/src/sage/combinat/enumeration_mod_permgroup.pxd @@ -1,9 +1,9 @@ from sage.structure.list_clone cimport ClonableIntArray -cpdef list all_children(ClonableIntArray v, int max_part) -cpdef int lex_cmp_partial(ClonableIntArray t1, ClonableIntArray t2, int step) -cpdef int lex_cmp(ClonableIntArray t1, ClonableIntArray t2) +cpdef list all_children(ClonableIntArray v, int max_part) noexcept +cpdef int lex_cmp_partial(ClonableIntArray t1, ClonableIntArray t2, int step) noexcept +cpdef int lex_cmp(ClonableIntArray t1, ClonableIntArray t2) noexcept cpdef bint is_canonical(list sgs, ClonableIntArray v) except -1 -cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v) -cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part) -cpdef set orbit(list sgs, ClonableIntArray v) +cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v) noexcept +cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part) noexcept +cpdef set orbit(list sgs, ClonableIntArray v) noexcept diff --git a/src/sage/combinat/enumeration_mod_permgroup.pyx b/src/sage/combinat/enumeration_mod_permgroup.pyx index 3e0b891165f..0da6b2d2638 100644 --- a/src/sage/combinat/enumeration_mod_permgroup.pyx +++ b/src/sage/combinat/enumeration_mod_permgroup.pyx @@ -12,7 +12,7 @@ Tools for enumeration modulo the action of a permutation group from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement -cpdef list all_children(ClonableIntArray v, int max_part): +cpdef list all_children(ClonableIntArray v, int max_part) noexcept: r""" Returns all the children of an integer vector (:class:`~sage.structure.list_clone.ClonableIntArray`) ``v`` in the tree of enumeration by lexicographic order. The children of @@ -56,7 +56,7 @@ cpdef list all_children(ClonableIntArray v, int max_part): all_children.append(child) return all_children -cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step): +cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step) noexcept: r""" Partial comparison of the two lists according the lexicographic order. It compares the ``step``-th first entries. @@ -85,7 +85,7 @@ cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step): return -1 return 0 -cpdef int lex_cmp(ClonableIntArray v1, ClonableIntArray v2): +cpdef int lex_cmp(ClonableIntArray v1, ClonableIntArray v2) noexcept: """ Lexicographic comparison of :class:`~sage.structure.list_clone.ClonableIntArray`. @@ -183,7 +183,7 @@ cpdef bint is_canonical(list sgs, ClonableIntArray v) except -1: return True -cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v): +cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v) noexcept: r""" Returns the maximal vector for the lexicographic order living in the orbit of `v` under the action of the permutation group whose @@ -229,7 +229,7 @@ cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIn representative = max(to_analyse) return representative -cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part): +cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part) noexcept: r""" Returns the canonical children of the integer vector ``v``. This function computes all children of the integer vector ``v`` via the @@ -250,7 +250,7 @@ cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part): cdef ClonableIntArray child return [child for child in all_children(v, max_part) if is_canonical(sgs, child)] -cpdef set orbit(list sgs, ClonableIntArray v): +cpdef set orbit(list sgs, ClonableIntArray v) noexcept: r""" Returns the orbit of the integer vector ``v`` under the action of the permutation group whose strong generating system is ``sgs``. diff --git a/src/sage/combinat/fast_vector_partitions.pyx b/src/sage/combinat/fast_vector_partitions.pyx index 2a1e093104b..579d43710ab 100644 --- a/src/sage/combinat/fast_vector_partitions.pyx +++ b/src/sage/combinat/fast_vector_partitions.pyx @@ -30,7 +30,7 @@ AUTHORS: # # To understand the code below, consult the ALGORITHM. -cdef list vector_halve(list v): +cdef list vector_halve(list v) noexcept: r""" Return the vector halfway (lexicographically) between ``v`` and zero. @@ -229,7 +229,7 @@ def within_from_to(list m, list s, list e): return yield from recursive_within_from_to(m, ss, e, True, True) -cdef inline list vector_sub(list a, list b): +cdef inline list vector_sub(list a, list b) noexcept: """ Return ``a - b`` considered as vectors. diff --git a/src/sage/combinat/permutation_cython.pxd b/src/sage/combinat/permutation_cython.pxd index 9f19d942604..9744b2f549e 100644 --- a/src/sage/combinat/permutation_cython.pxd +++ b/src/sage/combinat/permutation_cython.pxd @@ -1,11 +1,11 @@ from cpython.array cimport array -cdef void reset_swap(int n, int *c, int *o) -cdef int next_swap(int n, int *c, int *o) -cpdef bint next_perm(array l) -cpdef map_to_list(array l, tuple values, int n) -cpdef list left_action_same_n(list l, list r) -cpdef list right_action_same_n(list l, list r) -cpdef list left_action_product(list l, list r) -cpdef list right_action_product(list l, list r) +cdef void reset_swap(int n, int *c, int *o) noexcept +cdef int next_swap(int n, int *c, int *o) noexcept +cpdef bint next_perm(array l) noexcept +cpdef map_to_list(array l, tuple values, int n) noexcept +cpdef list left_action_same_n(list l, list r) noexcept +cpdef list right_action_same_n(list l, list r) noexcept +cpdef list left_action_product(list l, list r) noexcept +cpdef list right_action_product(list l, list r) noexcept diff --git a/src/sage/combinat/permutation_cython.pyx b/src/sage/combinat/permutation_cython.pyx index 1a0b02ac734..17010476cd9 100644 --- a/src/sage/combinat/permutation_cython.pyx +++ b/src/sage/combinat/permutation_cython.pyx @@ -54,7 +54,7 @@ from cysignals.memory cimport check_allocarray, sig_free # ########################################################## -cdef void reset_swap(int n, int *c, int *o): +cdef void reset_swap(int n, int *c, int *o) noexcept: """ Reset the plain_swapper to the initial state. """ @@ -63,7 +63,7 @@ cdef void reset_swap(int n, int *c, int *o): c[i] = -1 o[i] = 1 -cdef int next_swap(int n, int *c, int *o): +cdef int next_swap(int n, int *c, int *o) noexcept: """ Here's the translation of Algorithm P. We've modified it to @@ -174,7 +174,7 @@ def permutation_iterator_transposition_list(int n): @cython.wraparound(False) @cython.boundscheck(False) -cpdef bint next_perm(array l): +cpdef bint next_perm(array l) noexcept: """ Obtain the next permutation under lex order of ``l`` by mutating ``l``. @@ -255,7 +255,7 @@ cpdef bint next_perm(array l): @cython.boundscheck(False) -cpdef map_to_list(array l, tuple values, int n): +cpdef map_to_list(array l, tuple values, int n) noexcept: """ Build a list by mapping the array ``l`` using ``values``. @@ -291,7 +291,7 @@ cpdef map_to_list(array l, tuple values, int n): ##################################################################### ## Multiplication functions for permutations -cpdef list left_action_same_n(list S, list lp): +cpdef list left_action_same_n(list S, list lp) noexcept: r""" Return the permutation obtained by composing a permutation ``S`` with a permutation ``lp`` in such an order that ``lp`` @@ -318,7 +318,7 @@ cpdef list left_action_same_n(list S, list lp): ret.append(S[i-1]) return ret -cpdef list right_action_same_n(list S, list rp): +cpdef list right_action_same_n(list S, list rp) noexcept: """ Return the permutation obtained by composing a permutation ``S`` with a permutation ``rp`` in such an order that ``S`` is @@ -345,7 +345,7 @@ cpdef list right_action_same_n(list S, list rp): ret.append(rp[i-1]) return ret -cpdef list left_action_product(list S, list lp): +cpdef list left_action_product(list S, list lp) noexcept: r""" Return the permutation obtained by composing a permutation ``S`` with a permutation ``lp`` in such an order that ``lp`` is @@ -379,7 +379,7 @@ cpdef list left_action_product(list S, list lp): lp.append(i) return left_action_same_n(S, lp) -cpdef list right_action_product(list S, list rp): +cpdef list right_action_product(list S, list rp) noexcept: """ Return the permutation obtained by composing a permutation ``S`` with a permutation ``rp`` in such an order that ``S`` is diff --git a/src/sage/combinat/posets/hasse_cython_flint.pyx b/src/sage/combinat/posets/hasse_cython_flint.pyx index fcbe29faaf6..97b0efb89fb 100644 --- a/src/sage/combinat/posets/hasse_cython_flint.pyx +++ b/src/sage/combinat/posets/hasse_cython_flint.pyx @@ -22,7 +22,7 @@ from sage.matrix.matrix_space import MatrixSpace from sage.rings.integer_ring import ZZ -cpdef Matrix_integer_dense moebius_matrix_fast(list positions): +cpdef Matrix_integer_dense moebius_matrix_fast(list positions) noexcept: """ Compute the Möbius matrix of a poset by a specific triangular inversion. @@ -81,7 +81,7 @@ cpdef Matrix_integer_dense moebius_matrix_fast(list positions): return A -cpdef Matrix_integer_dense coxeter_matrix_fast(list positions): +cpdef Matrix_integer_dense coxeter_matrix_fast(list positions) noexcept: """ Compute the Coxeter matrix of a poset by a specific algorithm. diff --git a/src/sage/combinat/posets/linear_extension_iterator.pyx b/src/sage/combinat/posets/linear_extension_iterator.pyx index 5eb101b32e2..44e76739392 100644 --- a/src/sage/combinat/posets/linear_extension_iterator.pyx +++ b/src/sage/combinat/posets/linear_extension_iterator.pyx @@ -59,7 +59,7 @@ def _linear_extension_prepare(D): @cython.wraparound(False) @cython.boundscheck(False) -cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py_ssize_t i): +cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py_ssize_t i) noexcept: """ This implements the ``Switch`` procedure described on page 7 of "Generating Linear Extensions Fast" by Pruesse and Ruskey. @@ -83,7 +83,7 @@ cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py @cython.wraparound(False) @cython.boundscheck(False) -cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i): +cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i) noexcept: """ Return ``True`` if and only if ``_a[i]`` is incomparable with the element to its right in ``_le`` and the element to the right is @@ -111,7 +111,7 @@ cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i @cython.wraparound(False) @cython.boundscheck(False) -cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i): +cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i) noexcept: """ Return True if and only if ``_b[i]`` is incomparable with the elements to its right in ``_le``. diff --git a/src/sage/combinat/rigged_configurations/rigged_partition.pxd b/src/sage/combinat/rigged_configurations/rigged_partition.pxd index e99258f33b2..9b333b4fdc6 100644 --- a/src/sage/combinat/rigged_configurations/rigged_partition.pxd +++ b/src/sage/combinat/rigged_configurations/rigged_partition.pxd @@ -6,9 +6,9 @@ cdef class RiggedPartition(SageObject): cdef public list rigging cdef long _hash - cpdef get_num_cells_to_column(self, int end_column, t=*) - cpdef insert_cell(self, int max_width) - cpdef remove_cell(self, row, int num_cells=*) + cpdef get_num_cells_to_column(self, int end_column, t=*) noexcept + cpdef insert_cell(self, int max_width) noexcept + cpdef remove_cell(self, row, int num_cells=*) noexcept cdef class RiggedPartitionTypeB(RiggedPartition): pass diff --git a/src/sage/combinat/rigged_configurations/rigged_partition.pyx b/src/sage/combinat/rigged_configurations/rigged_partition.pyx index 694b3dd5977..5b30b15608f 100644 --- a/src/sage/combinat/rigged_configurations/rigged_partition.pyx +++ b/src/sage/combinat/rigged_configurations/rigged_partition.pyx @@ -354,7 +354,7 @@ cdef class RiggedPartition(SageObject): # Should we move these functions to the CP -> RC bijections? - cpdef get_num_cells_to_column(self, int end_column, t=1): + cpdef get_num_cells_to_column(self, int end_column, t=1) noexcept: r""" Get the number of cells in all columns before the ``end_column``. @@ -394,7 +394,7 @@ cdef class RiggedPartition(SageObject): return sum_cells - cpdef insert_cell(self, int max_width): + cpdef insert_cell(self, int max_width) noexcept: r""" Insert a cell given at a singular value as long as its less than the specified width. @@ -446,7 +446,7 @@ cdef class RiggedPartition(SageObject): self.rigging[max_pos] = None # State that we've changed this row return self._list[max_pos] - 1 - cpdef remove_cell(self, row, int num_cells=1): + cpdef remove_cell(self, row, int num_cells=1) noexcept: r""" Removes a cell at the specified ``row``. diff --git a/src/sage/combinat/root_system/braid_orbit.pyx b/src/sage/combinat/root_system/braid_orbit.pyx index d95bc388f83..d95e224c1cd 100644 --- a/src/sage/combinat/root_system/braid_orbit.pyx +++ b/src/sage/combinat/root_system/braid_orbit.pyx @@ -7,7 +7,7 @@ Cython function to compute the orbit of the braid moves on a reduced word. from cysignals.signals cimport sig_check -cpdef set BraidOrbit(list word, list rels): +cpdef set BraidOrbit(list word, list rels) noexcept: r""" Return the orbit of ``word`` by all replacements given by ``rels``. @@ -74,7 +74,7 @@ cpdef set BraidOrbit(list word, list rels): return words -cpdef bint is_fully_commutative(list word, list rels): +cpdef bint is_fully_commutative(list word, list rels) noexcept: r""" Check if the braid orbit of ``word`` is using a braid relation. @@ -129,7 +129,7 @@ cpdef bint is_fully_commutative(list word, list rels): return True -cdef inline bint pattern_match(tuple L, int i, tuple X, int l): +cdef inline bint pattern_match(tuple L, int i, tuple X, int l) noexcept: r""" Return ``True`` if ``L[i:i+l] == X``. diff --git a/src/sage/combinat/root_system/reflection_group_c.pyx b/src/sage/combinat/root_system/reflection_group_c.pyx index 247e9a62c02..8786b80ab87 100644 --- a/src/sage/combinat/root_system/reflection_group_c.pyx +++ b/src/sage/combinat/root_system/reflection_group_c.pyx @@ -31,7 +31,7 @@ cdef class Iterator(): cdef list noncom cdef list order - cdef list noncom_letters(self): + cdef list noncom_letters(self) noexcept: """ Return a list ``L`` of lists such that ... @@ -89,7 +89,7 @@ cdef class Iterator(): # self.noncom = self.noncom_letters() - cdef list succ(self, PermutationGroupElement u, int first): + cdef list succ(self, PermutationGroupElement u, int first) noexcept: cdef PermutationGroupElement si cdef int i cdef list successors = [] @@ -109,7 +109,7 @@ cdef class Iterator(): successors.append((_new_mul_(si,u), i)) return successors - cdef list succ_words(self, PermutationGroupElement u, list word, int first): + cdef list succ_words(self, PermutationGroupElement u, list word, int first) noexcept: cdef PermutationGroupElement u1, si cdef int i cdef list successors = [] @@ -135,7 +135,7 @@ cdef class Iterator(): successors.append((u1, word_new, i)) return successors - cdef inline bint test(self, PermutationGroupElement u, PermutationGroupElement si, int i): + cdef inline bint test(self, PermutationGroupElement u, PermutationGroupElement si, int i) noexcept: cdef int j cdef int N = self.N cdef int* siperm = si.perm @@ -432,10 +432,10 @@ def iterator_tracking_words(W): level_set_new.append((y, word+[i])) level_set_cur = level_set_new -cdef inline bint has_left_descent(PermutationGroupElement w, int i, int N): +cdef inline bint has_left_descent(PermutationGroupElement w, int i, int N) noexcept: return w.perm[i] >= N -cdef int first_descent(PermutationGroupElement w, int n, int N, bint left): +cdef int first_descent(PermutationGroupElement w, int n, int N, bint left) noexcept: cdef int i if not left: w = ~w @@ -445,7 +445,7 @@ cdef int first_descent(PermutationGroupElement w, int n, int N, bint left): return -1 cdef int first_descent_in_parabolic(PermutationGroupElement w, list parabolic, - int N, bint left): + int N, bint left) noexcept: cdef int i if not left: w = ~w @@ -457,7 +457,7 @@ cdef int first_descent_in_parabolic(PermutationGroupElement w, list parabolic, cpdef PermutationGroupElement reduce_in_coset(PermutationGroupElement w, tuple S, - list parabolic, int N, bint right): + list parabolic, int N, bint right) noexcept: r""" Return the minimal length coset representative of ``w`` of the parabolic subgroup indexed by ``parabolic`` (with indices `\{0, \ldots, n\}`). @@ -501,7 +501,7 @@ cpdef PermutationGroupElement reduce_in_coset(PermutationGroupElement w, tuple S w = _new_mul_(w, si) cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_small, - bint right): + bint right) noexcept: cdef tuple S = tuple(W.simple_reflections()) cdef int N = W.number_of_reflections() cdef set totest = set([W.one()]) @@ -518,7 +518,7 @@ cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_sm totest = new.difference(res)#[ w for w in new if w not in res ] return list(res) -cdef parabolic_recursive(PermutationGroupElement x, list v, f): +cdef parabolic_recursive(PermutationGroupElement x, list v, f) noexcept: if not v: f(x) else: @@ -558,7 +558,7 @@ def parabolic_iteration_application(W, f): parabolic_recursive(W.one(), coset_reps, f) -cpdef list reduced_word_c(W, PermutationGroupElement w): +cpdef list reduced_word_c(W, PermutationGroupElement w) noexcept: r""" Computes a reduced word for the element ``w`` in the reflection group ``W`` in the positions ``range(n)``. @@ -584,7 +584,7 @@ cpdef list reduced_word_c(W, PermutationGroupElement w): word.append(fdes) return word -cdef PermutationGroupElement _new_mul_(PermutationGroupElement left, PermutationGroupElement right): +cdef PermutationGroupElement _new_mul_(PermutationGroupElement left, PermutationGroupElement right) noexcept: """ Multiply two :class:`PermutationGroupElement` directly without the coercion framework. diff --git a/src/sage/combinat/root_system/reflection_group_element.pxd b/src/sage/combinat/root_system/reflection_group_element.pxd index 04e98fc3fb2..194688e25b6 100644 --- a/src/sage/combinat/root_system/reflection_group_element.pxd +++ b/src/sage/combinat/root_system/reflection_group_element.pxd @@ -1,11 +1,11 @@ from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement cdef class ComplexReflectionGroupElement(PermutationGroupElement): - cpdef action(self, vec, on_space=*) - cpdef action_on_root_indices(self, i) + cpdef action(self, vec, on_space=*) noexcept + cpdef action_on_root_indices(self, i) noexcept cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): - cpdef bint has_left_descent(self, i) - cpdef bint has_descent(self, i, side=*, positive=*) - cpdef action(self, vec, side=*, on_space=*) - cpdef action_on_root_indices(self, i, side=*) + cpdef bint has_left_descent(self, i) noexcept + cpdef bint has_descent(self, i, side=*, positive=*) noexcept + cpdef action(self, vec, side=*, on_space=*) noexcept + cpdef action_on_root_indices(self, i, side=*) noexcept diff --git a/src/sage/combinat/root_system/reflection_group_element.pyx b/src/sage/combinat/root_system/reflection_group_element.pyx index 8f5a61ff0a2..9754d6655b0 100644 --- a/src/sage/combinat/root_system/reflection_group_element.pyx +++ b/src/sage/combinat/root_system/reflection_group_element.pyx @@ -347,7 +347,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): mat.set_immutable() return mat - cpdef action(self, vec, on_space="primal"): + cpdef action(self, vec, on_space="primal") noexcept: r""" Return the image of ``vec`` under the action of ``self``. @@ -372,7 +372,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): mat = self.matrix(on_space=on_space) return vec * mat - cpdef _act_on_(self, vec, bint self_on_left): + cpdef _act_on_(self, vec, bint self_on_left) noexcept: r""" Defines the action of ``self`` as a linear transformation on the vector space, in the basis given by the simple @@ -396,7 +396,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement): return (~self).action(vec) return self.action(vec) - cpdef action_on_root_indices(self, i): + cpdef action_on_root_indices(self, i) noexcept: """ Return the right action on the set of roots. @@ -763,7 +763,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): """ return ZZ(len(self._reduced_word)) - cpdef bint has_left_descent(self, i): + cpdef bint has_left_descent(self, i) noexcept: r""" Return whether ``i`` is a left descent of ``self``. @@ -784,7 +784,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): # we also check == because 0-based indexing return self.perm[W._index_set_inverse[i]] >= W.number_of_reflections() - cpdef bint has_descent(self, i, side="left", positive=False): + cpdef bint has_descent(self, i, side="left", positive=False) noexcept: r""" Return whether ``i`` is a descent (or ascent) of ``self``. @@ -957,7 +957,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): matrix = to_matrix - cpdef action(self, vec, side="right", on_space="primal"): + cpdef action(self, vec, side="right", on_space="primal") noexcept: r""" Return the image of ``vec`` under the action of ``self``. @@ -1020,7 +1020,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): else: raise ValueError('on_space must be "primal" or "dual"') - cpdef _act_on_(self, vec, bint self_on_left): + cpdef _act_on_(self, vec, bint self_on_left) noexcept: r""" Give the action of ``self`` as a linear transformation on the vector space, in the basis given by the simple roots. @@ -1053,7 +1053,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement): else: return self.action(vec,side="right") - cpdef action_on_root_indices(self, i, side="right"): + cpdef action_on_root_indices(self, i, side="right") noexcept: """ Return the action on the set of roots. diff --git a/src/sage/combinat/set_partition_iterator.pyx b/src/sage/combinat/set_partition_iterator.pyx index fff6a71fefe..310b3d23017 100644 --- a/src/sage/combinat/set_partition_iterator.pyx +++ b/src/sage/combinat/set_partition_iterator.pyx @@ -7,7 +7,7 @@ cimport cython @cython.wraparound(False) @cython.boundscheck(False) -cdef list from_word(list w, list base_set): +cdef list from_word(list w, list base_set) noexcept: cdef list sp = [] cdef Py_ssize_t i cdef Py_ssize_t b diff --git a/src/sage/combinat/subword_complex_c.pyx b/src/sage/combinat/subword_complex_c.pyx index 66da5184356..b70b63ac64b 100644 --- a/src/sage/combinat/subword_complex_c.pyx +++ b/src/sage/combinat/subword_complex_c.pyx @@ -1,7 +1,7 @@ # sage.doctest: needs sage.modules cpdef int _flip_c(W, set positions, list extended_root_conf_indices, - int i, side="both"): + int i, side="both") noexcept: r""" Flip a facet. @@ -60,7 +60,7 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices, extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k],side="left") return j -cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1): +cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1) noexcept: r""" Return the list of facets of the subword complex associated to the word `Q` and the element `w` in a Coxeter group `W`. diff --git a/src/sage/combinat/words/word_char.pyx b/src/sage/combinat/words/word_char.pyx index 433aae3f4db..6735dbb0ad3 100644 --- a/src/sage/combinat/words/word_char.pyx +++ b/src/sage/combinat/words/word_char.pyx @@ -100,7 +100,7 @@ cdef class WordDatatype_char(WordDatatype): @cython.boundscheck(False) # assume that indexing will not cause any IndexErrors @cython.wraparound(False) # not check not correctly handle negative indices - cdef _set_data(self, data): + cdef _set_data(self, data) noexcept: r""" set the attribute ._data and ._length from the sequence data (usually data is a word, a tuple or a list) @@ -209,7 +209,7 @@ cdef class WordDatatype_char(WordDatatype): bitset_free(seen) return res - cdef _new_c(self, unsigned char * data, size_t length, WordDatatype_char master): + cdef _new_c(self, unsigned char * data, size_t length, WordDatatype_char master) noexcept: r""" TO DISCUSS: in Integer (sage.rings.integer) this method is actually an external function. But we might want to have several possible inheritance. @@ -425,7 +425,7 @@ cdef class WordDatatype_char(WordDatatype): """ return reversed_word_iterator(self) - cdef _concatenate(self, WordDatatype_char other): + cdef _concatenate(self, WordDatatype_char other) noexcept: cdef unsigned char * data data = check_allocarray(self._length + other._length, sizeof(unsigned char)) diff --git a/src/sage/combinat/words/word_datatypes.pyx b/src/sage/combinat/words/word_datatypes.pyx index 57c8079aad6..4e2540f0397 100644 --- a/src/sage/combinat/words/word_datatypes.pyx +++ b/src/sage/combinat/words/word_datatypes.pyx @@ -419,7 +419,7 @@ cdef class WordDatatype_str(WordDatatype): else: return a in self._data - cpdef _has_factor_naive(self, w): + cpdef _has_factor_naive(self, w) noexcept: r""" A naive test for testing whether the word contains ``w`` as a factor. @@ -449,7 +449,7 @@ cdef class WordDatatype_str(WordDatatype): return w in self._data raise ValueError - cpdef find(self, sub, start=0, end=None): + cpdef find(self, sub, start=0, end=None) noexcept: r""" Returns the index of the first occurrence of sub in self, such that sub is contained within self[start:end]. diff --git a/src/sage/cpython/getattr.pxd b/src/sage/cpython/getattr.pxd index e0987cfa4c5..299509a00dc 100644 --- a/src/sage/cpython/getattr.pxd +++ b/src/sage/cpython/getattr.pxd @@ -5,4 +5,4 @@ cdef class AttributeErrorMessage: cdef public cls cdef public name -cpdef getattr_from_other_class(self, cls, name) +cpdef getattr_from_other_class(self, cls, name) noexcept diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx index 1f49e5230c3..3a06167ea99 100644 --- a/src/sage/cpython/getattr.pyx +++ b/src/sage/cpython/getattr.pyx @@ -111,7 +111,7 @@ cdef class AttributeErrorMessage: cdef AttributeErrorMessage dummy_error_message = AttributeErrorMessage() -cpdef raw_getattr(obj, name): +cpdef raw_getattr(obj, name) noexcept: """ Like ``getattr(obj, name)`` but without invoking the binding behavior of descriptors under normal attribute access. @@ -227,7 +227,7 @@ cpdef raw_getattr(obj, name): raise AttributeError(dummy_error_message) -cpdef getattr_from_other_class(self, cls, name): +cpdef getattr_from_other_class(self, cls, name) noexcept: """ Emulate ``getattr(self, name)``, as if ``self`` was an instance of ``cls``. diff --git a/src/sage/cpython/string.pxd b/src/sage/cpython/string.pxd index 1fde0aec0de..dbf1c91c08b 100644 --- a/src/sage/cpython/string.pxd +++ b/src/sage/cpython/string.pxd @@ -13,7 +13,7 @@ cdef extern from "string_impl.h": bytes _str_to_bytes(s, encoding, errors) -cdef inline str char_to_str(const char* c, encoding=None, errors=None): +cdef inline str char_to_str(const char* c, encoding=None, errors=None) noexcept: r""" Convert a C string to a Python ``str``. """ @@ -23,7 +23,7 @@ cdef inline str char_to_str(const char* c, encoding=None, errors=None): return _cstr_to_str(c, encoding, errors) -cpdef inline str bytes_to_str(b, encoding=None, errors=None): +cpdef inline str bytes_to_str(b, encoding=None, errors=None) noexcept: r""" Convert ``bytes`` to ``str``. @@ -49,7 +49,7 @@ cpdef inline str bytes_to_str(b, encoding=None, errors=None): return _cstr_to_str(b, encoding, errors) -cpdef inline bytes str_to_bytes(s, encoding=None, errors=None): +cpdef inline bytes str_to_bytes(s, encoding=None, errors=None) noexcept: r""" Convert ``str`` or ``unicode`` to ``bytes``. diff --git a/src/sage/cpython/type.pxd b/src/sage/cpython/type.pxd index adb13dce6aa..f3f80c7a6c6 100644 --- a/src/sage/cpython/type.pxd +++ b/src/sage/cpython/type.pxd @@ -1 +1 @@ -cpdef bint can_assign_class(obj) +cpdef bint can_assign_class(obj) noexcept diff --git a/src/sage/cpython/type.pyx b/src/sage/cpython/type.pyx index 8106c99f6ab..f9dcabc5df4 100644 --- a/src/sage/cpython/type.pyx +++ b/src/sage/cpython/type.pyx @@ -12,7 +12,7 @@ except ImportError: pass -cpdef bint can_assign_class(obj): +cpdef bint can_assign_class(obj) noexcept: """ Can we assign ``obj.__class__``? diff --git a/src/sage/cpython/wrapperdescr.pxd b/src/sage/cpython/wrapperdescr.pxd index b6775860710..2260c062f1f 100644 --- a/src/sage/cpython/wrapperdescr.pxd +++ b/src/sage/cpython/wrapperdescr.pxd @@ -24,7 +24,7 @@ cdef extern from *: PyDescr_NewWrapper(PyTypeObject* cls, wrapperbase* wrapper, void* wrapped) -cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds) +cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds) noexcept cdef inline wrapperbase* get_slotdef(wrapper_descriptor slotwrapper) except NULL: diff --git a/src/sage/cpython/wrapperdescr.pyx b/src/sage/cpython/wrapperdescr.pyx index 66c79ca38e2..108ca690b8d 100644 --- a/src/sage/cpython/wrapperdescr.pyx +++ b/src/sage/cpython/wrapperdescr.pyx @@ -87,7 +87,7 @@ def wrapperdescr_call(slotwrapper, self, *args, **kwds): return wrapperdescr_fastcall(slotwrapper, self, args, kwds) -cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds): +cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds) noexcept: # Cython implementation of wrapperdescr_call cdef wrapperbase* slotdef = slotwrapper.d_base diff --git a/src/sage/crypto/boolean_function.pxd b/src/sage/crypto/boolean_function.pxd index 8a97eb875aa..d9fd1017fcd 100644 --- a/src/sage/crypto/boolean_function.pxd +++ b/src/sage/crypto/boolean_function.pxd @@ -1,4 +1,4 @@ -cdef inline unsigned int hamming_weight(unsigned int x): +cdef inline unsigned int hamming_weight(unsigned int x) noexcept: # valid for 32bits x -= (x>>1) & 0x55555555UL # 0-2 in 2 bits x = ((x>>2) & 0x33333333UL) + (x & 0x33333333UL) # 0-4 in 4 bits @@ -6,4 +6,4 @@ cdef inline unsigned int hamming_weight(unsigned int x): x *= 0x01010101UL return x>>24 -cdef walsh_hadamard(long *f, int ldn) +cdef walsh_hadamard(long *f, int ldn) noexcept diff --git a/src/sage/crypto/boolean_function.pyx b/src/sage/crypto/boolean_function.pyx index fa99fab5ea3..6190129278f 100644 --- a/src/sage/crypto/boolean_function.pyx +++ b/src/sage/crypto/boolean_function.pyx @@ -51,7 +51,7 @@ except ImportError: # walsh_hadamard transform, reed_muller transform, and a lot # more, see 'Matters computational' available on www.jjj.de. -cdef walsh_hadamard(long *f, int ldn): +cdef walsh_hadamard(long *f, int ldn) noexcept: r""" The Walsh Hadamard transform is an orthogonal transform equivalent to a multidimensional discrete Fourier transform of size 2x2x...x2. @@ -84,7 +84,7 @@ cdef walsh_hadamard(long *f, int ldn): t1 += 1 t2 += 1 -cdef long yellow_code(unsigned long a): +cdef long yellow_code(unsigned long a) noexcept: """ The yellow-code is just a Reed Muller transform applied to a word. @@ -109,7 +109,7 @@ cdef long yellow_code(unsigned long a): m ^= (m<1) << (n % GMP_LIMB_BITS) -cdef inline mp_limb_t limb_one_zero_bit(mp_bitcnt_t n): +cdef inline mp_limb_t limb_one_zero_bit(mp_bitcnt_t n) noexcept: """ Return a limb with all bits set, except for bit n. """ return ~((1) << (n % GMP_LIMB_BITS)) -cdef inline mp_limb_t limb_lower_bits_down(mp_bitcnt_t n): +cdef inline mp_limb_t limb_lower_bits_down(mp_bitcnt_t n) noexcept: """ Return a limb with the lower n bits set, where n is interpreted in [0 .. GMP_LIMB_BITS-1]. """ return ((1) << (n % GMP_LIMB_BITS)) - 1 -cdef inline mp_limb_t limb_lower_bits_up(mp_bitcnt_t n): +cdef inline mp_limb_t limb_lower_bits_up(mp_bitcnt_t n) noexcept: """ Return a limb with the lower n bits set, where n is interpreted in [1 .. GMP_LIMB_BITS]. @@ -184,7 +184,7 @@ cdef inline bint bitset_init(fused_bitset_t bits, mp_bitcnt_t size) except -1: bits.non_zero_chunks_are_initialized = False bits.non_zero_chunks = check_allocarray((bits.limbs*LIMB_SIZE) // ALIGNMENT, sizeof(mp_bitcnt_t)) -cdef inline bint bitset_check_alignment(fused_bitset_t bits): +cdef inline bint bitset_check_alignment(fused_bitset_t bits) noexcept: """ Return whether the bitset is aligned correctly. """ @@ -215,7 +215,7 @@ cdef inline int bitset_realloc(bitset_t bits, mp_bitcnt_t size) except -1: # Zero removed bits bitset_fix(bits) -cdef inline void bitset_free(fused_bitset_t bits): +cdef inline void bitset_free(fused_bitset_t bits) noexcept: """ Deallocate the memory in bits. """ @@ -225,7 +225,7 @@ cdef inline void bitset_free(fused_bitset_t bits): sig_free(bits.mem) sig_free(bits.non_zero_chunks) -cdef inline void bitset_clear(fused_bitset_t bits): +cdef inline void bitset_clear(fused_bitset_t bits) noexcept: """ Remove all elements from the set. """ @@ -233,7 +233,7 @@ cdef inline void bitset_clear(fused_bitset_t bits): if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_zero(fused_bitset_t bits): +cdef inline void bitset_zero(fused_bitset_t bits) noexcept: """ Remove all elements from the set. @@ -243,7 +243,7 @@ cdef inline void bitset_zero(fused_bitset_t bits): if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src): +cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src) noexcept: """ Copy the bitset src over to the bitset dst, overwriting dst. @@ -253,7 +253,7 @@ cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src): if fused_bitset_t is sparse_bitset_t: dst.non_zero_chunks_are_initialized = False -cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src): +cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src) noexcept: """ Copy the bitset src over to the bitset dst, overwriting dst. @@ -266,13 +266,13 @@ cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src): if fused_bitset_t is sparse_bitset_t: dst.non_zero_chunks_are_initialized = False -cdef inline void bitset_fix(fused_bitset_t bits): +cdef inline void bitset_fix(fused_bitset_t bits) noexcept: """ Clear upper bits in upper limb which should be zero. """ bits.bits[bits.limbs - 1] &= limb_lower_bits_up(bits.size) -cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) nogil: +cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) noexcept nogil: """ Set the non zero chunks of ``bits``. """ @@ -283,7 +283,7 @@ cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) nogil: # Bitset Comparison ############################################################################# -cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n): +cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n) noexcept: """ Return ``True`` iff the first n bits of *b1 and *b2 agree. """ @@ -298,7 +298,7 @@ cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n): cdef mp_limb_t b2h = b2[nlimbs] return (b1h ^ b2h) & mask == 0 -cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n, mp_bitcnt_t offset): +cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n, mp_bitcnt_t offset) noexcept: """ Return ``True`` iff the first n bits of *b1 and the bits ranging from offset to offset+n of *b2 agree. @@ -329,14 +329,14 @@ cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t tmp_limb |= (b2[preinc(i2)] << neg_bit_offset) return (b1h ^ tmp_limb) & mask == 0 -cdef inline bint bitset_isempty(fused_bitset_t bits) nogil: +cdef inline bint bitset_isempty(fused_bitset_t bits) noexcept nogil: """ Test whether bits is empty. Return True (i.e., 1) if the set is empty, False (i.e., 0) otherwise. """ return _bitset_isempty(bits.bits, bits.limbs) -cdef inline bint bitset_is_zero(fused_bitset_t bits): +cdef inline bint bitset_is_zero(fused_bitset_t bits) noexcept: """ Test whether bits is empty (i.e., zero). Return True (1) if the set is empty, False (0) otherwise. @@ -345,7 +345,7 @@ cdef inline bint bitset_is_zero(fused_bitset_t bits): """ return bitset_isempty(bits) -cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b): +cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b) noexcept: """ Compare bitset a and b. Return True (i.e., 1) if the sets are equal, and False (i.e., 0) otherwise. @@ -354,7 +354,7 @@ cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b): """ return _bitset_cmp(a.bits, b.bits, b.limbs, EQUAL) -cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b): +cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b) noexcept: """ Compare bitsets a and b. Return 0 if the two sets are identical, and consistently return -1 or 1 for two sets that are @@ -364,7 +364,7 @@ cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b): """ return mpn_cmp(a.bits, b.bits, b.limbs) -cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b): +cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b) noexcept: """ Compare bitsets ``a`` and ``b`` using lexicographical ordering. @@ -393,7 +393,7 @@ cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b): else: return -1 -cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Test whether a is a subset of b (i.e., every element in a is also in b). @@ -405,7 +405,7 @@ cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) nogil: else: return _bitset_cmp(a.bits, b.bits, a.limbs, SUBSET) -cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Test whether a is a superset of b (i.e., every element in b is also in a). @@ -414,7 +414,7 @@ cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) nogil: """ return bitset_issubset(b, a) -cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b): +cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b) noexcept: """ Tests whether ``a`` and ``b`` have an empty intersection. @@ -430,14 +430,14 @@ cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b): # Bitset Bit Manipulation ############################################################################# -cdef inline bint bitset_in(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline bint bitset_in(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Check if n is in bits. Return True (i.e., 1) if n is in the set, False (i.e., 0) otherwise. """ return (bits.bits[n >> index_shift] >> (n % GMP_LIMB_BITS)) & 1 -cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Check if n is in bits. Return True (i.e., 1) if n is in the set, False (i.e., 0) otherwise. @@ -446,7 +446,7 @@ cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n): """ return bitset_in(bits, n) -cdef inline bint bitset_not_in(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline bint bitset_not_in(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Check if n is not in bits. Return True (i.e., 1) if n is not in the set, False (i.e., 0) otherwise. @@ -463,7 +463,7 @@ cdef inline bint bitset_remove(fused_bitset_t bits, mp_bitcnt_t n) except -1: if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Remove n from bits. """ @@ -471,7 +471,7 @@ cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n): if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Remove n from bits. @@ -479,7 +479,7 @@ cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n): """ bitset_discard(bits, n) -cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Add n to bits. """ @@ -487,7 +487,7 @@ cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n): if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Add n to bits. @@ -495,14 +495,14 @@ cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n): """ bitset_add(bits, n) -cdef inline void bitset_set_to(bitset_t bits, mp_bitcnt_t n, bint b): +cdef inline void bitset_set_to(bitset_t bits, mp_bitcnt_t n, bint b) noexcept: """ If b is True, add n to bits. If b is False, remove n from bits. """ bitset_unset(bits, n) bits.bits[n >> index_shift] |= (b) << (n % GMP_LIMB_BITS) -cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ If n is in bits, remove n from bits. If n is not in bits, add n to bits. @@ -511,7 +511,7 @@ cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n): if fused_bitset_t is sparse_bitset_t: bits.non_zero_chunks_are_initialized = False -cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n): +cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n) noexcept: """ Set exactly the first n bits. """ @@ -530,7 +530,7 @@ cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n): # Bitset Searching ############################################################################# -cdef inline long bitset_first(fused_bitset_t a): +cdef inline long bitset_first(fused_bitset_t a) noexcept: """ Calculate the index of the first element in the set. If the set is empty, returns -1. @@ -541,7 +541,7 @@ cdef inline long bitset_first(fused_bitset_t a): return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i]) return -1 -cdef inline long bitset_first_in_complement(fused_bitset_t a): +cdef inline long bitset_first_in_complement(fused_bitset_t a) noexcept: """ Calculate the index of the first element not in the set. If the set is full, returns -1. @@ -567,7 +567,7 @@ cdef inline long bitset_pop(fused_bitset_t a) except -1: bitset_discard(a, i) return i -cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b): +cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b) noexcept: """ Calculate the index of the first difference between a and b. If a and b are equal, then return -1. @@ -580,7 +580,7 @@ cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b): return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i] ^ b.bits[i]) return -1 -cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n): +cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n) noexcept: """ Calculate the index of the next element in the set, starting at (and including) n. Return -1 if there are no elements from n @@ -598,7 +598,7 @@ cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n): return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i]) return -1 -cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_t n): +cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_t n) noexcept: """ Calculate the index of the next element that differs between a and b, starting at (and including) n. Return -1 if there are no @@ -618,13 +618,13 @@ cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_ return (i << index_shift) | _bitset_first_in_limb(a.bits[i] ^ b.bits[i]) return -1 -cdef inline long bitset_len(fused_bitset_t bits) nogil: +cdef inline long bitset_len(fused_bitset_t bits) noexcept nogil: """ Calculate the number of items in the set (i.e., the number of nonzero bits). """ return _bitset_len(bits.bits, bits.limbs) -cdef inline long bitset_hash(fused_bitset_t bits): +cdef inline long bitset_hash(fused_bitset_t bits) noexcept: """ Calculate a (very naive) hash function. @@ -641,7 +641,7 @@ cdef inline long bitset_hash(fused_bitset_t bits): # Bitset Arithmetic ############################################################################# -cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a): +cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a) noexcept: """ Set r to be the complement of a, overwriting r. @@ -652,7 +652,7 @@ cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a): if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a): +cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a) noexcept: """ Set r to be the complement of a, overwriting r. @@ -664,7 +664,7 @@ cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a): if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Set r to the intersection of a and b, overwriting r. @@ -674,7 +674,7 @@ cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_b if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Set r to the intersection of a and b, overwriting r. @@ -685,7 +685,7 @@ cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a, r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, AND) r.non_zero_chunks_are_initialized = True -cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the intersection of a and b, overwriting r. @@ -695,7 +695,7 @@ cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b """ bitset_intersection(r, a, b) -cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Set r to the union of a and b, overwriting r. @@ -706,7 +706,7 @@ cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil: +cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil: """ Set r to the union of a and b, overwriting r. @@ -718,7 +718,7 @@ cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_ r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, OR) r.non_zero_chunks_are_initialized = True -cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the union of a and b, overwriting r. @@ -729,7 +729,7 @@ cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) """ bitset_union(r, a, b) -cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the difference of a and b (i.e., things in a that are not in b), overwriting r. @@ -741,7 +741,7 @@ cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bit if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the difference of a and b (i.e., things in a that are not in b), overwriting r. @@ -754,7 +754,7 @@ cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, f r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, ANDNOT) r.non_zero_chunks_are_initialized = True -cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the symmetric difference of a and b, overwriting r. @@ -765,7 +765,7 @@ cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a, if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the symmetric difference of a and b, overwriting r. @@ -777,7 +777,7 @@ cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bit r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, XOR) r.non_zero_chunks_are_initialized = True -cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b): +cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept: """ Set r to the symmetric difference of a and b, overwriting r. @@ -788,7 +788,7 @@ cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b """ bitset_symmetric_difference(r, a, b) -cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n): +cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n) noexcept: """ Shift the bitset ``a`` right by ``n`` bits and store the result in ``r``. @@ -831,7 +831,7 @@ cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n if fused_bitset_t is sparse_bitset_t: r.non_zero_chunks_are_initialized = False -cdef inline void bitset_lshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n): +cdef inline void bitset_lshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n) noexcept: """ Shift the bitset ``a`` left by ``n`` bits and store the result in ``r``. @@ -898,25 +898,25 @@ cdef inline int bitset_map(fused_bitset_t r, fused_bitset_t a, m) except -1: # Hamming Weights ############################################################################# -cdef inline long bitset_hamming_weight(fused_bitset_t a): +cdef inline long bitset_hamming_weight(fused_bitset_t a) noexcept: return bitset_len(a) ############################################################################# # Bitset Conversion ############################################################################# -cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=*, char one=*) +cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=*, char one=*) noexcept cdef int bitset_from_char(bitset_t bits, char* s, char zero=*, char one=*) except -1 cdef int bitset_from_str(bitset_t bits, object s, char zero=*, char one=*) except -1 -cdef bitset_string(fused_bitset_t bits) +cdef bitset_string(fused_bitset_t bits) noexcept -cdef bitset_bytes(fused_bitset_t bits) +cdef bitset_bytes(fused_bitset_t bits) noexcept -cdef list bitset_list(fused_bitset_t bits) +cdef list bitset_list(fused_bitset_t bits) noexcept -cdef bitset_pickle(bitset_t bs) +cdef bitset_pickle(bitset_t bs) noexcept -cdef bitset_unpickle(bitset_t bs, tuple input) +cdef bitset_unpickle(bitset_t bs, tuple input) noexcept diff --git a/src/sage/data_structures/bitset_base.pyx b/src/sage/data_structures/bitset_base.pyx index 6a527a8ebfe..616e3b1ab04 100644 --- a/src/sage/data_structures/bitset_base.pyx +++ b/src/sage/data_structures/bitset_base.pyx @@ -11,7 +11,7 @@ Few functions from ``bitset_base.pxd`` that are not inlined. # http://www.gnu.org/licenses/ #***************************************************************************** -cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=c'0', char one=c'1'): +cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=c'0', char one=c'1') noexcept: """ Return a string representation of the bitset in s, using zero for the character representing the items not in the bitset and one for @@ -47,13 +47,13 @@ cdef int bitset_from_str(bitset_t bits, object s, char zero=c'0', char one=c'1') cdef bytes b = str_to_bytes(s) return bitset_from_char(bits, b, zero, one) -cdef bitset_string(fused_bitset_t bits): +cdef bitset_string(fused_bitset_t bits) noexcept: """ Return a python string representing the bitset. """ return bytes_to_str(bitset_bytes(bits)) -cdef bitset_bytes(fused_bitset_t bits): +cdef bitset_bytes(fused_bitset_t bits) noexcept: """ Return a python bytes string representing the bitset. @@ -66,7 +66,7 @@ cdef bitset_bytes(fused_bitset_t bits): sig_free(s) return py_s -cdef list bitset_list(fused_bitset_t bits): +cdef list bitset_list(fused_bitset_t bits) noexcept: """ Return a list of elements in the bitset. """ @@ -77,7 +77,7 @@ cdef list bitset_list(fused_bitset_t bits): elt = bitset_next(bits, elt + 1) return elts -cdef bitset_pickle(bitset_t bs): +cdef bitset_pickle(bitset_t bs) noexcept: """ Convert ``bs`` to a reasonably compact Python structure. @@ -91,7 +91,7 @@ cdef bitset_pickle(bitset_t bs): data.append(bs.bits[i]) return (version, bs.size, bs.limbs, sizeof(unsigned long), tuple(data)) -cdef bitset_unpickle(bitset_t bs, tuple input): +cdef bitset_unpickle(bitset_t bs, tuple input) noexcept: """ Convert the data into a bitset. diff --git a/src/sage/data_structures/blas_dict.pxd b/src/sage/data_structures/blas_dict.pxd index 7464c0daba8..3def4f5a950 100644 --- a/src/sage/data_structures/blas_dict.pxd +++ b/src/sage/data_structures/blas_dict.pxd @@ -1,11 +1,11 @@ cpdef int iaxpy(a, dict X, dict Y, bint remove_zeros=*, bint factor_on_left=*) except -1 -cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=*) -cpdef dict negate(dict D) -cpdef dict scal(a, dict D, bint factor_on_left=*) -cpdef dict add(dict D, dict D2) -cpdef dict sum(dict_iter) -cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=*) -cpdef dict sum_of_monomials(monomials, scalar) -cpdef dict sum_of_terms(index_coeff_pairs) -cdef dict remove_zeros(dict D) -cpdef dict convert_remove_zeroes(dict D, R) +cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=*) noexcept +cpdef dict negate(dict D) noexcept +cpdef dict scal(a, dict D, bint factor_on_left=*) noexcept +cpdef dict add(dict D, dict D2) noexcept +cpdef dict sum(dict_iter) noexcept +cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=*) noexcept +cpdef dict sum_of_monomials(monomials, scalar) noexcept +cpdef dict sum_of_terms(index_coeff_pairs) noexcept +cdef dict remove_zeros(dict D) noexcept +cpdef dict convert_remove_zeroes(dict D, R) noexcept diff --git a/src/sage/data_structures/blas_dict.pyx b/src/sage/data_structures/blas_dict.pyx index c13cab2aab9..c624aa6a2d5 100644 --- a/src/sage/data_structures/blas_dict.pyx +++ b/src/sage/data_structures/blas_dict.pyx @@ -143,7 +143,7 @@ cpdef int iaxpy(a, dict X, dict Y, bint remove_zeros=True, bint factor_on_left=T del Y[key] return 0 -cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True): +cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True) noexcept: """ Return `a X + Y`. @@ -203,7 +203,7 @@ cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True): iaxpy(a, X, Y, True, factor_on_left) return Y -cpdef dict negate(dict D): +cpdef dict negate(dict D) noexcept: r""" Return a dictionary representing the vector `-X`. @@ -220,7 +220,7 @@ cpdef dict negate(dict D): """ return { key: -value for key, value in D.iteritems() } -cpdef dict scal(a, dict D, bint factor_on_left=True): +cpdef dict scal(a, dict D, bint factor_on_left=True) noexcept: r""" Return a dictionary representing the vector `a*X`. @@ -242,7 +242,7 @@ cpdef dict scal(a, dict D, bint factor_on_left=True): # So for now we just delegate to axpy. return axpy(a, D, {}, factor_on_left=factor_on_left) -cpdef dict add(dict D, dict D2): +cpdef dict add(dict D, dict D2) noexcept: r""" Return the pointwise addition of dictionaries ``D`` and ``D2``. @@ -269,7 +269,7 @@ cpdef dict add(dict D, dict D2): D, D2 = D2, D return axpy(1, D2, D) -cpdef dict sum(dict_iter): +cpdef dict sum(dict_iter) noexcept: r""" Return the pointwise addition of dictionaries with coefficients. @@ -310,7 +310,7 @@ cpdef dict sum(dict_iter): return remove_zeros(result) -cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True): +cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True) noexcept: r""" Return the pointwise addition of dictionaries with coefficients. @@ -355,7 +355,7 @@ cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True): return remove_zeros(result) -cpdef dict sum_of_monomials(monomials, scalar): +cpdef dict sum_of_monomials(monomials, scalar) noexcept: r""" Return the pointwise addition of ``monomials``. @@ -383,7 +383,7 @@ cpdef dict sum_of_monomials(monomials, scalar): result[m] = scalar return remove_zeros(result) -cpdef dict sum_of_terms(index_coeff_pairs): +cpdef dict sum_of_terms(index_coeff_pairs) noexcept: r""" Return the linear combination of a monomial scaled by a coefficient. @@ -411,7 +411,7 @@ cpdef dict sum_of_terms(index_coeff_pairs): result[index] = coeff return remove_zeros(result) -cdef dict remove_zeros(dict D): +cdef dict remove_zeros(dict D) noexcept: """ Remove all keys whose value is zero from ``D``. """ @@ -422,7 +422,7 @@ cdef dict remove_zeros(dict D): del D[index] return D -cpdef dict convert_remove_zeroes(dict D, R): +cpdef dict convert_remove_zeroes(dict D, R) noexcept: """ Remove all keys whose value is zero from ``D`` after coercing into the ring ``R``. diff --git a/src/sage/data_structures/bounded_integer_sequences.pxd b/src/sage/data_structures/bounded_integer_sequences.pxd index b4466741034..44267b4fb46 100644 --- a/src/sage/data_structures/bounded_integer_sequences.pxd +++ b/src/sage/data_structures/bounded_integer_sequences.pxd @@ -34,28 +34,28 @@ ctypedef struct biseq_s: ctypedef biseq_s biseq_t[1] cdef bint biseq_init(biseq_t R, mp_size_t l, mp_bitcnt_t itemsize) except -1 -cdef void biseq_dealloc(biseq_t S) +cdef void biseq_dealloc(biseq_t S) noexcept cdef bint biseq_init_copy(biseq_t R, biseq_t S) except -1 -cdef tuple biseq_pickle(biseq_t S) +cdef tuple biseq_pickle(biseq_t S) noexcept cdef bint biseq_unpickle(biseq_t R, tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) except -1 cdef bint biseq_init_list(biseq_t R, list data, size_t bound) except -1 -cdef Py_hash_t biseq_hash(biseq_t S) -cdef bint biseq_richcmp(biseq_t S1, biseq_t S2, int op) +cdef Py_hash_t biseq_hash(biseq_t S) noexcept +cdef bint biseq_richcmp(biseq_t S1, biseq_t S2, int op) noexcept cdef bint biseq_init_concat(biseq_t R, biseq_t S1, biseq_t S2) except -1 cdef bint biseq_startswith(biseq_t S1, biseq_t S2) except -1 cdef mp_size_t biseq_contains(biseq_t S1, biseq_t S2, mp_size_t start) except -2 cdef mp_size_t biseq_startswith_tail(biseq_t S1, biseq_t S2, mp_size_t start) except -2 cdef mp_size_t biseq_index(biseq_t S, size_t item, mp_size_t start) except -2 -cdef size_t biseq_getitem(biseq_t S, mp_size_t index) -cdef biseq_getitem_py(biseq_t S, mp_size_t index) -cdef void biseq_inititem(biseq_t S, mp_size_t index, size_t item) -cdef void biseq_clearitem(biseq_t S, mp_size_t index) +cdef size_t biseq_getitem(biseq_t S, mp_size_t index) noexcept +cdef biseq_getitem_py(biseq_t S, mp_size_t index) noexcept +cdef void biseq_inititem(biseq_t S, mp_size_t index, size_t item) noexcept +cdef void biseq_clearitem(biseq_t S, mp_size_t index) noexcept cdef bint biseq_init_slice(biseq_t R, biseq_t S, mp_size_t start, mp_size_t stop, mp_size_t step) except -1 cdef class BoundedIntegerSequence: cdef biseq_t data - cpdef bint startswith(self, BoundedIntegerSequence other) - cpdef list list(self) - cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other) + cpdef bint startswith(self, BoundedIntegerSequence other) noexcept + cpdef list list(self) noexcept + cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other) noexcept -cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) +cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) noexcept diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx b/src/sage/data_structures/bounded_integer_sequences.pyx index 907f9b4298a..7e6513ec1b0 100644 --- a/src/sage/data_structures/bounded_integer_sequences.pyx +++ b/src/sage/data_structures/bounded_integer_sequences.pyx @@ -142,7 +142,7 @@ cdef bint biseq_init(biseq_t R, mp_size_t l, mp_bitcnt_t itemsize) except -1: R.itembitsize = itemsize R.mask_item = limb_lower_bits_up(itemsize) -cdef inline void biseq_dealloc(biseq_t S): +cdef inline void biseq_dealloc(biseq_t S) noexcept: """ Deallocate the memory used by ``S``. """ @@ -161,7 +161,7 @@ cdef bint biseq_init_copy(biseq_t R, biseq_t S) except -1: # Pickling # -cdef tuple biseq_pickle(biseq_t S): +cdef tuple biseq_pickle(biseq_t S) noexcept: return (bitset_pickle(S.data), S.itembitsize, S.length) cdef bint biseq_unpickle(biseq_t R, tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) except -1: @@ -199,10 +199,10 @@ cdef bint biseq_init_list(biseq_t R, list data, size_t bound) except -1: biseq_inititem(R, index, item_c) index += 1 -cdef inline Py_hash_t biseq_hash(biseq_t S): +cdef inline Py_hash_t biseq_hash(biseq_t S) noexcept: return S.itembitsize*(1073807360)+bitset_hash(S.data) -cdef inline bint biseq_richcmp(biseq_t S1, biseq_t S2, int op): +cdef inline bint biseq_richcmp(biseq_t S1, biseq_t S2, int op) noexcept: if S1.itembitsize != S2.itembitsize: return richcmp_not_equal(S1.itembitsize, S2.itembitsize, op) if S1.length != S2.length: @@ -271,7 +271,7 @@ cdef mp_size_t biseq_index(biseq_t S, size_t item, mp_size_t start) except -2: return -1 -cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index): +cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index) noexcept: """ Get item ``S[index]``, without checking margins. @@ -288,7 +288,7 @@ cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index): out |= (S.data.bits[limb_index+1]) << (GMP_LIMB_BITS - bit_index) return out & S.mask_item -cdef biseq_getitem_py(biseq_t S, mp_size_t index): +cdef biseq_getitem_py(biseq_t S, mp_size_t index) noexcept: """ Get item ``S[index]`` as a Python ``int``, without checking margins. @@ -297,7 +297,7 @@ cdef biseq_getitem_py(biseq_t S, mp_size_t index): cdef size_t out = biseq_getitem(S, index) return PyLong_FromSize_t(out) -cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item): +cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item) noexcept: """ Set ``S[index] = item``, without checking margins. @@ -314,7 +314,7 @@ cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item): # Our item is stored using 2 limbs, add the part from the upper limb S.data.bits[limb_index+1] |= (item >> (GMP_LIMB_BITS - bit_index)) -cdef inline void biseq_clearitem(biseq_t S, mp_size_t index): +cdef inline void biseq_clearitem(biseq_t S, mp_size_t index) noexcept: """ Set ``S[index] = 0``, without checking margins. @@ -1041,7 +1041,7 @@ cdef class BoundedIntegerSequence: return False return biseq_contains(self.data, right.data, 0) >= 0 - cpdef list list(self): + cpdef list list(self) noexcept: """ Converts this bounded integer sequence to a list @@ -1067,7 +1067,7 @@ cdef class BoundedIntegerSequence: cdef mp_size_t i return [biseq_getitem_py(self.data, i) for i in range(self.data.length)] - cpdef bint startswith(self, BoundedIntegerSequence other): + cpdef bint startswith(self, BoundedIntegerSequence other) noexcept: """ Tells whether ``self`` starts with a given bounded integer sequence @@ -1236,7 +1236,7 @@ cdef class BoundedIntegerSequence: biseq_init_concat(out.data, myself.data, right.data) return out - cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other): + cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other) noexcept: """ Return ``self``'s maximal trailing sub-sequence that ``other`` starts with. @@ -1355,7 +1355,7 @@ cdef class BoundedIntegerSequence: return 0 return h -cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length): +cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) noexcept: """ Helper function for unpickling of :class:`BoundedIntegerSequence`. diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx index f8fb37d5cf4..9b0009629de 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx @@ -24,7 +24,7 @@ from sage.rings.finite_rings.finite_field_constructor import GF from sage.combinat.subset import subsets -cpdef _fast_possible_periods(self, return_points=False): +cpdef _fast_possible_periods(self, return_points=False) noexcept: r""" Return the list of possible minimal periods of a periodic point over `\QQ` and (optionally) a point in each cycle. @@ -177,7 +177,7 @@ def _enum_points(int prime, int dimension): yield _get_point_from_hash(value, prime, dimension) current_range = current_range * prime -cpdef int _hash(list Point, int prime): +cpdef int _hash(list Point, int prime) noexcept: """ Hash point given as list to unique number. @@ -198,7 +198,7 @@ cpdef int _hash(list Point, int prime): return hash_q -cpdef list _get_point_from_hash(int value, int prime, int dimension): +cpdef list _get_point_from_hash(int value, int prime, int dimension) noexcept: """ Hash unique number to point as a list. @@ -217,7 +217,7 @@ cpdef list _get_point_from_hash(int value, int prime, int dimension): return P -cdef inline int _mod_inv(int num, int prime): +cdef inline int _mod_inv(int num, int prime) noexcept: """ Find the inverse of the number modulo the given prime. """ @@ -240,7 +240,7 @@ cdef inline int _mod_inv(int num, int prime): else: return y -cpdef _normalize_coordinates(list point, int prime, int len_points): +cpdef _normalize_coordinates(list point, int prime, int len_points) noexcept: """ Normalize the coordinates of the point for the given prime. @@ -269,7 +269,7 @@ cpdef _normalize_coordinates(list point, int prime, int len_points): for coefficient in range(len_points): point[coefficient] = (point[coefficient] * mod_inverse) % prime -cpdef _all_periodic_points(self): +cpdef _all_periodic_points(self) noexcept: """ Find all periodic points over a finite field. diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx index 9ee71e4f4bf..dd352fdca31 100644 --- a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx +++ b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx @@ -60,7 +60,7 @@ def _color_to_RGB(color): cpdef fast_mandelbrot_plot(double x_center, double y_center, double image_width, long max_iteration, long pixel_count, - long level_sep, long color_num, base_color): + long level_sep, long color_num, base_color) noexcept: r""" Plots the Mandelbrot set in the complex plane for the map `Q_c(z) = z^2 + c`. @@ -178,7 +178,7 @@ cpdef fast_mandelbrot_plot(double x_center, double y_center, cpdef fast_external_ray(double theta, long D=30, long S=10, long R=100, - long pixel_count=500, double image_width=4, long prec=300): + long pixel_count=500, double image_width=4, long prec=300) noexcept: r""" Return a list of points that approximate the external ray for a given angle. @@ -289,7 +289,7 @@ cpdef fast_external_ray(double theta, long D=30, long S=10, long R=100, return c_list cpdef convert_to_pixels(point_list, double x_0, double y_0, double width, - long number_of_pixels): + long number_of_pixels) noexcept: r""" Converts cartesian coordinates to pixels within a specified window. @@ -333,7 +333,7 @@ cpdef convert_to_pixels(point_list, double x_0, double y_0, double width, pixel_list.append((x_pixel, y_pixel)) return pixel_list -cpdef get_line(start, end): +cpdef get_line(start, end) noexcept: r""" Produces a list of pixel coordinates approximating a line from a starting point to an ending point using the Bresenham's Line Algorithm. @@ -420,7 +420,7 @@ cpdef get_line(start, end): cpdef fast_julia_plot(double c_real, double c_imag, double x_center=0, double y_center=0, double image_width=4, long max_iteration=500, long pixel_count=500, long level_sep=2, - long color_num=40, base_color=[50, 50, 50]): + long color_num=40, base_color=[50, 50, 50]) noexcept: r""" Plots the Julia set for a given `c` value in the complex plane for the map `Q_c(z) = z^2 + c`. @@ -539,7 +539,7 @@ cpdef fast_julia_plot(double c_real, double c_imag, cpdef julia_helper(double c_real, double c_imag, double x_center=0, double y_center=0, double image_width=4, long max_iteration=500, long pixel_count=500, long level_sep=2, long color_num=40, - base_color=[50, 50, 50], point_color=[255, 0, 0]): + base_color=[50, 50, 50], point_color=[255, 0, 0]) noexcept: r""" Helper function that returns the image of a Julia set for a given `c` value side by side with the Mandelbrot set with a point denoting @@ -630,7 +630,7 @@ cpdef julia_helper(double c_real, double c_imag, double x_center=0, cpdef polynomial_mandelbrot(f, parameter=None, double x_center=0, double y_center=0, image_width=4, int max_iteration=50, int pixel_count=500, - int level_sep=1, int color_num=30, base_color=Color('red')): + int level_sep=1, int color_num=30, base_color=Color('red')) noexcept: r""" Plots the Mandelbrot set in the complex plane for a family of polynomial maps. @@ -933,7 +933,7 @@ cpdef polynomial_mandelbrot(f, parameter=None, double x_center=0, cpdef general_julia(f, double x_center=0, double y_center=0, image_width=4, int max_iteration=50, int pixel_count=500, int level_sep=1, int color_num=30, - base_color=[50,50,50]): + base_color=[50,50,50]) noexcept: r""" Plots Julia sets for general polynomials. diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx index baf2e7c6d6e..bad30e0e605 100644 --- a/src/sage/ext/fast_callable.pyx +++ b/src/sage/ext/fast_callable.pyx @@ -1577,7 +1577,7 @@ cdef class ExpressionChoice(Expression): repr(self._cond), repr(self._iffalse)) -cpdef _expression_binop_helper(s, o, op): +cpdef _expression_binop_helper(s, o, op) noexcept: r""" Make an Expression for (s op o). Either s or o (or both) must already be an expression. @@ -1713,7 +1713,7 @@ class IntegerPowerFunction(): return x**self.exponent cdef dict builtin_functions = None -cpdef dict get_builtin_functions(): +cpdef dict get_builtin_functions() noexcept: r""" To handle ExpressionCall, we need to map from Sage and Python functions to opcode names. @@ -1767,7 +1767,7 @@ cpdef dict get_builtin_functions(): cdef class InstructionStream # forward declaration -cpdef generate_code(Expression expr, InstructionStream stream): +cpdef generate_code(Expression expr, InstructionStream stream) noexcept: r""" Generate code from an Expression tree; write the result into an InstructionStream. @@ -2142,7 +2142,7 @@ cdef class InstructionStream: """ self.instr('load_arg', n) - cpdef bint has_instr(self, opname): + cpdef bint has_instr(self, opname) noexcept: r""" Check whether this InstructionStream knows how to generate code for a given instruction. @@ -2191,7 +2191,7 @@ cdef class InstructionStream: """ self.instr0(opname, args) - cdef instr0(self, opname, tuple args): + cdef instr0(self, opname, tuple args) noexcept: """ Cdef version of instr. (Can't cpdef because of star args.) """ diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx index 1e93581a370..e7961348cb8 100644 --- a/src/sage/ext/memory.pyx +++ b/src/sage/ext/memory.pyx @@ -42,7 +42,7 @@ cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython -cdef void alloc_error(size_t size) nogil: +cdef void alloc_error(size_t size) noexcept nogil: """ Jump back to ``sig_on()``, raising a :class:`MemoryError`. """ @@ -51,7 +51,7 @@ cdef void alloc_error(size_t size) nogil: sig_error() -cdef void* sage_sig_malloc(size_t size) nogil: +cdef void* sage_sig_malloc(size_t size) noexcept nogil: """ ``malloc()`` function for the MPIR/GMP library. @@ -63,7 +63,7 @@ cdef void* sage_sig_malloc(size_t size) nogil: return p -cdef void* sage_sig_realloc(void *ptr, size_t old_size, size_t new_size) nogil: +cdef void* sage_sig_realloc(void *ptr, size_t old_size, size_t new_size) noexcept nogil: """ ``realloc()`` function for the MPIR/GMP library. @@ -75,7 +75,7 @@ cdef void* sage_sig_realloc(void *ptr, size_t old_size, size_t new_size) nogil: return p -cdef void sage_sig_free(void *ptr, size_t size) nogil: +cdef void sage_sig_free(void *ptr, size_t size) noexcept nogil: """ ``free()`` function for the MPIR/GMP library. """ diff --git a/src/sage/ext/memory_allocator.pxd b/src/sage/ext/memory_allocator.pxd index f96253345f6..5fc54a1cd27 100644 --- a/src/sage/ext/memory_allocator.pxd +++ b/src/sage/ext/memory_allocator.pxd @@ -6,7 +6,7 @@ cdef extern from *: int unlikely(int) nogil # defined by Cython -cdef inline void* align(void* ptr, size_t alignment): +cdef inline void* align(void* ptr, size_t alignment) noexcept: """ Round up ``ptr`` to the nearest multiple of ``alignment``, which must be a power of 2 diff --git a/src/sage/ext/stdsage.pxd b/src/sage/ext/stdsage.pxd index e2bf7434f35..7249fbf84d8 100644 --- a/src/sage/ext/stdsage.pxd +++ b/src/sage/ext/stdsage.pxd @@ -13,7 +13,7 @@ Standard C helper code for Cython modules from cpython.object cimport Py_TYPE, PyTypeObject, PyObject -cdef inline PY_NEW(type t): +cdef inline PY_NEW(type t) noexcept: """ Return ``t.__new__(t)``. This works even for types like :class:`Integer` where we change ``tp_new`` at runtime (Cython @@ -22,7 +22,7 @@ cdef inline PY_NEW(type t): return (t).tp_new(t, NULL, NULL) -cdef inline void PY_SET_TP_NEW(type dst, type src): +cdef inline void PY_SET_TP_NEW(type dst, type src) noexcept: """ Manually set ``dst.__new__`` to ``src.__new__``. This is used to speed up Cython's boilerplate object construction code by skipping @@ -31,7 +31,7 @@ cdef inline void PY_SET_TP_NEW(type dst, type src): (dst).tp_new = (src).tp_new -cdef inline bint HAS_DICTIONARY(obj): +cdef inline bint HAS_DICTIONARY(obj) noexcept: """ Test whether the given object has a Python dictionary. """ diff --git a/src/sage/functions/prime_pi.pyx b/src/sage/functions/prime_pi.pyx index 141e538cf74..2f64469c731 100644 --- a/src/sage/functions/prime_pi.pyx +++ b/src/sage/functions/prime_pi.pyx @@ -210,7 +210,7 @@ cdef class PrimePi(BuiltinFunction): prime_pi = PrimePi() -cpdef Integer legendre_phi(x, a): +cpdef Integer legendre_phi(x, a) noexcept: r""" Legendre's formula, also known as the partial sieve function, is a useful combinatorial function for computing the prime counting function (the diff --git a/src/sage/geometry/integral_points.pxi b/src/sage/geometry/integral_points.pxi index 037efb41da8..3ea46051b47 100644 --- a/src/sage/geometry/integral_points.pxi +++ b/src/sage/geometry/integral_points.pxi @@ -70,7 +70,7 @@ from sage.modules.free_module import FreeModule # existing lattice point and then copy it! -cpdef tuple parallelotope_points(spanning_points, lattice): +cpdef tuple parallelotope_points(spanning_points, lattice) noexcept: r""" Return integral points in the parallelotope starting at the origin and spanned by the ``spanning_points``. @@ -143,7 +143,7 @@ cpdef tuple parallelotope_points(spanning_points, lattice): return points -cpdef tuple ray_matrix_normal_form(R): +cpdef tuple ray_matrix_normal_form(R) noexcept: r""" Compute the Smith normal form of the ray matrix for :func:`parallelotope_points`. @@ -179,7 +179,7 @@ cpdef tuple ray_matrix_normal_form(R): # The optimized version avoids constructing new matrices, vectors, and lattice points cpdef tuple loop_over_parallelotope_points(e, d, MatrixClass VDinv, MatrixClass R, lattice, - A=None, b=None): + A=None, b=None) noexcept: r""" The inner loop of :func:`parallelotope_points`. @@ -244,7 +244,7 @@ cpdef tuple loop_over_parallelotope_points(e, d, MatrixClass VDinv, ############################################################################## -cpdef tuple simplex_points(vertices): +cpdef tuple simplex_points(vertices) noexcept: r""" Return the integral points in a lattice simplex. @@ -329,7 +329,7 @@ cpdef tuple simplex_points(vertices): return points -cdef translate_points(v_list, VectorClass delta): +cdef translate_points(v_list, VectorClass delta) noexcept: r""" Add ``delta`` to each vector in ``v_list``. """ @@ -348,7 +348,7 @@ cdef translate_points(v_list, VectorClass delta): cpdef rectangular_box_points(list box_min, list box_max, polyhedron=None, count_only=False, - return_saturated=False): + return_saturated=False) noexcept: r""" Return the integral points in the lattice bounding box that are also contained in the given polyhedron. @@ -583,7 +583,7 @@ cpdef rectangular_box_points(list box_min, list box_max, return tuple(points) -cdef list perm_action(list p, list lst): +cdef list perm_action(list p, list lst) noexcept: """ Return the action of a permutation ``p`` of `(0, ..., n-1)` on a list of length `n`. @@ -592,7 +592,7 @@ cdef list perm_action(list p, list lst): cdef loop_over_rectangular_box_points(list box_min, list box_max, InequalityCollection inequalities, - int d, bint count_only): + int d, bint count_only) noexcept: """ The inner loop of :func:`rectangular_box_points`. @@ -666,7 +666,7 @@ cdef loop_over_rectangular_box_points(list box_min, list box_max, cdef loop_over_rectangular_box_points_saturated(list box_min, list box_max, InequalityCollection inequalities, - int d): + int d) noexcept: """ The analog of :func:`rectangular_box_points` except that it keeps track of which inequalities are saturated. @@ -790,7 +790,7 @@ cdef class Inequality_generic: s += ') x + ' + str(self.b) + ' >= 0' return s - cdef prepare_next_to_inner_loop(self, p): + cdef prepare_next_to_inner_loop(self, p) noexcept: """ In :class:`Inequality_int` this method is used to peel of the next-to-inner loop. @@ -799,7 +799,7 @@ cdef class Inequality_generic: """ pass - cdef prepare_inner_loop(self, p): + cdef prepare_inner_loop(self, p) noexcept: """ Peel off the inner loop. @@ -956,7 +956,7 @@ cdef class Inequality_int: s += ') x + ' + str(self.b) + ' >= 0' return s - cdef prepare_next_to_inner_loop(Inequality_int self, p): + cdef prepare_next_to_inner_loop(Inequality_int self, p) noexcept: """ Peel off the next-to-inner loop. @@ -967,7 +967,7 @@ cdef class Inequality_int: for j in range(2, self.dim): self.cache_next += self.A[j] * p[j] - cdef prepare_inner_loop(Inequality_int self, p): + cdef prepare_inner_loop(Inequality_int self, p) noexcept: """ Peel off the inner loop. @@ -979,10 +979,10 @@ cdef class Inequality_int: else: self.cache = self.cache_next - cdef bint is_not_satisfied(Inequality_int self, int inner_loop_variable): + cdef bint is_not_satisfied(Inequality_int self, int inner_loop_variable) noexcept: return inner_loop_variable * self.coeff + self.cache < 0 - cdef bint is_equality(Inequality_int self, int inner_loop_variable): + cdef bint is_equality(Inequality_int self, int inner_loop_variable) noexcept: return inner_loop_variable * self.coeff + self.cache == 0 @@ -1054,7 +1054,7 @@ cdef class InequalityCollection: s += str(ineq) + '\n' return s.strip() - cpdef tuple _make_A_b(self, Hrep_obj, list permutation): + cpdef tuple _make_A_b(self, Hrep_obj, list permutation) noexcept: r""" Return the coefficients and constant of the H-representation object. @@ -1124,7 +1124,7 @@ cdef class InequalityCollection: raise TypeError('Cannot extract Hrepresentation data from polyhedron.') cdef _cinit_from_PPL(self, list max_abs_coordinates, list permutation, - polyhedron): + polyhedron) noexcept: """ Initialize the inequalities from a PPL C_Polyhedron @@ -1173,7 +1173,7 @@ cdef class InequalityCollection: self.ineqs_generic.append(H) cdef _cinit_from_Polyhedron(self, list max_abs_coordinates, - list permutation, polyhedron): + list permutation, polyhedron) noexcept: """ Initialize the inequalities from a Sage Polyhedron @@ -1225,7 +1225,7 @@ cdef class InequalityCollection: H = Inequality_generic(A, b, Hrep_obj.index()) self.ineqs_generic.append(H) - cpdef prepare_next_to_inner_loop(self, p): + cpdef prepare_next_to_inner_loop(self, p) noexcept: r""" Peel off the next-to-inner loop. @@ -1263,7 +1263,7 @@ cdef class InequalityCollection: for ineq in self.ineqs_generic: (ineq).prepare_next_to_inner_loop(p) - cpdef prepare_inner_loop(self, p): + cpdef prepare_inner_loop(self, p) noexcept: r""" Peel off the inner loop. @@ -1302,7 +1302,7 @@ cdef class InequalityCollection: for ineq in self.ineqs_generic: (ineq).prepare_inner_loop(p) - cpdef swap_ineq_to_front(self, int i): + cpdef swap_ineq_to_front(self, int i) noexcept: r""" Swap the ``i``-th entry of the list to the front of the list of inequalities. @@ -1377,7 +1377,7 @@ cdef class InequalityCollection: return False return True - cpdef frozenset satisfied_as_equalities(self, inner_loop_variable): + cpdef frozenset satisfied_as_equalities(self, inner_loop_variable) noexcept: """ Return the inequalities (by their index) that are satisfied as equalities. @@ -1423,7 +1423,7 @@ cdef class InequalityCollection: -cpdef print_cache(InequalityCollection inequality_collection): +cpdef print_cache(InequalityCollection inequality_collection) noexcept: r""" Print the cached values in :class:`Inequality_int` (for debugging/doctesting only). diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd index 030c9defa45..85a020df78a 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd @@ -30,34 +30,34 @@ cdef class CombinatorialPolyhedron(SageObject): cdef ListOfPairs _face_lattice_incidences # stores incidences in Hasse diagram labeled indices of the faces cdef PolyhedronFaceLattice _all_faces # class to generate Hasse diagram incidences - cdef tuple Vrep(self) - cdef tuple facet_names(self) - cdef tuple equations(self) - cdef tuple equalities(self) - cdef unsigned int n_Vrepresentation(self) - cdef unsigned int n_Hrepresentation(self) - cdef bint is_bounded(self) - cdef ListOfFaces bitrep_facets(self) - cdef ListOfFaces bitrep_Vrep(self) - cdef tuple far_face_tuple(self) + cdef tuple Vrep(self) noexcept + cdef tuple facet_names(self) noexcept + cdef tuple equations(self) noexcept + cdef tuple equalities(self) noexcept + cdef unsigned int n_Vrepresentation(self) noexcept + cdef unsigned int n_Hrepresentation(self) noexcept + cdef bint is_bounded(self) noexcept + cdef ListOfFaces bitrep_facets(self) noexcept + cdef ListOfFaces bitrep_Vrep(self) noexcept + cdef tuple far_face_tuple(self) noexcept cdef int _algorithm_to_dual(self, algorithm) except -2 # Methods to initialize the combinatorial polyhedron. - cdef _init_from_polyhedron(self, data) - cdef _init_from_lattice_polytope(self, data) - cdef _init_from_cone(self, data) - cdef _init_facet_names(self, facets) - cdef _init_from_incidence_matrix(self, data) - cdef _init_from_list_of_facets(self, data) - cdef _init_from_ListOfFaces(self, ListOfFaces facets, ListOfFaces Vrep) - cdef _initialize_far_face(self) - cdef _init_as_trivial_polyhedron(self, int dimension) + cdef _init_from_polyhedron(self, data) noexcept + cdef _init_from_lattice_polytope(self, data) noexcept + cdef _init_from_cone(self, data) noexcept + cdef _init_facet_names(self, facets) noexcept + cdef _init_from_incidence_matrix(self, data) noexcept + cdef _init_from_list_of_facets(self, data) noexcept + cdef _init_from_ListOfFaces(self, ListOfFaces facets, ListOfFaces Vrep) noexcept + cdef _initialize_far_face(self) noexcept + cdef _init_as_trivial_polyhedron(self, int dimension) noexcept # Methods to obtain a different combinatorial polyhedron. - cpdef CombinatorialPolyhedron dual(self) - cpdef CombinatorialPolyhedron pyramid(self, new_vertex=*, new_facet=*) + cpdef CombinatorialPolyhedron dual(self) noexcept + cpdef CombinatorialPolyhedron pyramid(self, new_vertex=*, new_facet=*) noexcept - cdef FaceIterator _face_iter(self, bint dual, int dimension) + cdef FaceIterator _face_iter(self, bint dual, int dimension) noexcept cdef int _compute_f_vector(self, size_t num_threads, size_t parallelization_depth, int dual) except -1 cdef int _persist_f_vector(self, size_t* input_f_vector, bint input_is_reversed) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index 5a07abb2408..8282fbbd1ca 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -398,7 +398,7 @@ cdef class CombinatorialPolyhedron(SageObject): else: self._init_from_list_of_facets(data) - cdef _init_from_polyhedron(self, data): + cdef _init_from_polyhedron(self, data) noexcept: r''' Initialize from :class:`~sage.geometry.polyhedron.parent.Polyhedron_base`. ''' @@ -415,7 +415,7 @@ cdef class CombinatorialPolyhedron(SageObject): return self._init_from_incidence_matrix(data.incidence_matrix()) - cdef _init_from_lattice_polytope(self, data): + cdef _init_from_lattice_polytope(self, data) noexcept: r''' Initialize from :class:`~sage.geometry.lattice_polytope.LatticePolytopeClass`. ''' @@ -425,7 +425,7 @@ cdef class CombinatorialPolyhedron(SageObject): self._dimension = data.dimension() return self._init_from_incidence_matrix(data.incidence_matrix()) - cdef _init_from_cone(self, data): + cdef _init_from_cone(self, data) noexcept: r''' Initialize from :class:`~sage.geometry.cone.ConvexRationalPolyhedralCone`. ''' @@ -440,7 +440,7 @@ cdef class CombinatorialPolyhedron(SageObject): + [[ZZ.one() for _ in range(len(data.facet_normals()))]]) return self._init_from_incidence_matrix(incidence_matrix) - cdef _init_facet_names(self, facets): + cdef _init_facet_names(self, facets) noexcept: ''' Store facet names and compute equations. ''' @@ -461,7 +461,7 @@ cdef class CombinatorialPolyhedron(SageObject): else: self._facet_names = None - cdef _init_from_incidence_matrix(self, data): + cdef _init_from_incidence_matrix(self, data) noexcept: """ Initialize from an incidence matrix. """ @@ -498,7 +498,7 @@ cdef class CombinatorialPolyhedron(SageObject): self._initialize_far_face() - cdef _init_from_list_of_facets(self, data): + cdef _init_from_list_of_facets(self, data) noexcept: """ Initialize from a list of facets. @@ -543,7 +543,7 @@ cdef class CombinatorialPolyhedron(SageObject): self._initialize_far_face() - cdef _init_from_ListOfFaces(self, ListOfFaces facets, ListOfFaces Vrep): + cdef _init_from_ListOfFaces(self, ListOfFaces facets, ListOfFaces Vrep) noexcept: """ Initialize self from two ``ListOfFaces``. """ @@ -556,7 +556,7 @@ cdef class CombinatorialPolyhedron(SageObject): self._initialize_far_face() - cdef _initialize_far_face(self): + cdef _initialize_far_face(self) noexcept: """ Initialize far_face if unbounded. """ @@ -564,7 +564,7 @@ cdef class CombinatorialPolyhedron(SageObject): face_init(self._far_face, self.bitrep_facets().n_atoms(), self._n_facets) Vrep_list_to_bit_rep(tuple(self._far_face_tuple), self._far_face) - cdef _init_as_trivial_polyhedron(self, int dimension): + cdef _init_as_trivial_polyhedron(self, int dimension) noexcept: """ Initialize polyhedron equal to its affine hull. """ @@ -2805,7 +2805,7 @@ cdef class CombinatorialPolyhedron(SageObject): face_iter = face_generator - cdef FaceIterator _face_iter(self, bint dual, int dimension): + cdef FaceIterator _face_iter(self, bint dual, int dimension) noexcept: r""" A method to obtain the FaceIterator as Cython object. @@ -3255,13 +3255,13 @@ cdef class CombinatorialPolyhedron(SageObject): tester.assertTrue(all(j in f.ambient_V_indices() for f in b)) tester.assertTrue(all(i in f.ambient_H_indices() for f in b)) - cdef tuple Vrep(self): + cdef tuple Vrep(self) noexcept: r""" Return the names of the Vrepresentation, if they exist. Else return ``None``. """ return self._Vrep - cdef tuple facet_names(self): + cdef tuple facet_names(self) noexcept: r""" Return the names Hrepresentatives, which are facets. @@ -3269,7 +3269,7 @@ cdef class CombinatorialPolyhedron(SageObject): """ return self._facet_names - cdef tuple equations(self): + cdef tuple equations(self) noexcept: r""" Return the names of the equations. @@ -3277,18 +3277,18 @@ cdef class CombinatorialPolyhedron(SageObject): """ return self._equations - cdef tuple equalities(self): + cdef tuple equalities(self) noexcept: from sage.misc.superseded import deprecation deprecation(31834, "the method equalities of CombinatorialPolyhedron is deprecated; use equations", 3) return self.equations() - cdef unsigned int n_Vrepresentation(self): + cdef unsigned int n_Vrepresentation(self) noexcept: r""" Return the number of elements in the Vrepresentation. """ return self._n_Vrepresentation - cdef unsigned int n_Hrepresentation(self): + cdef unsigned int n_Hrepresentation(self) noexcept: r""" Return the number of elements in the Hrepresentation. """ @@ -3315,25 +3315,25 @@ cdef class CombinatorialPolyhedron(SageObject): """ return self.is_bounded() - cdef bint is_bounded(self): + cdef bint is_bounded(self) noexcept: r""" Return whether the polyhedron is bounded. """ return self._bounded - cdef ListOfFaces bitrep_facets(self): + cdef ListOfFaces bitrep_facets(self) noexcept: r""" Return the facets in bit representation. """ return self._bitrep_facets - cdef ListOfFaces bitrep_Vrep(self): + cdef ListOfFaces bitrep_Vrep(self) noexcept: r""" Return the Vrepresentations in bit representation. """ return self._bitrep_Vrep - cdef tuple far_face_tuple(self): + cdef tuple far_face_tuple(self) noexcept: r""" Return the far face as it was given on initialization. """ @@ -3357,7 +3357,7 @@ cdef class CombinatorialPolyhedron(SageObject): # Methods to obtain a different combinatorial polyhedron. - cpdef CombinatorialPolyhedron dual(self): + cpdef CombinatorialPolyhedron dual(self) noexcept: r""" Return the dual/polar of self. @@ -3400,7 +3400,7 @@ cdef class CombinatorialPolyhedron(SageObject): polar = dual - cpdef CombinatorialPolyhedron pyramid(self, new_vertex=None, new_facet=None): + cpdef CombinatorialPolyhedron pyramid(self, new_vertex=None, new_facet=None) noexcept: r""" Return the pyramid of ``self``. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd index 9193a5417a9..2169fe539f6 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd @@ -31,7 +31,7 @@ cdef class CombinatorialFace(SageObject): # If ``dual == 0``, then coatoms are facets, atoms vertices and vice versa. cdef ListOfFaces atoms, coatoms - cpdef dimension(self) + cpdef dimension(self) noexcept cdef size_t n_atom_rep(self) except -1 cdef size_t set_coatom_rep(self) except -1 cdef size_t set_atom_rep(self) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx index bf01025707f..541927c6c11 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx @@ -497,7 +497,7 @@ cdef class CombinatorialFace(SageObject): else: raise NotImplementedError("is_subface only implemented for faces of the same polyhedron") - cpdef dimension(self): + cpdef dimension(self) noexcept: r""" Return the dimension of the face. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd index f37bcd36085..3ed71a664e1 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd @@ -43,27 +43,27 @@ cdef inline bint face_init(face_t face, mp_bitcnt_t n_atoms, mp_bitcnt_t n_coato bitset_init(face.atoms, n_atoms) bitset_init(face.coatoms, n_coatoms) -cdef inline void face_free(face_t face): +cdef inline void face_free(face_t face) noexcept: """ Free ``face``. """ bitset_free(face.atoms) bitset_free(face.coatoms) -cdef inline bint face_check_alignment(face_t face): +cdef inline bint face_check_alignment(face_t face) noexcept: """ Return whether the data is correctly aligned. """ return bitset_check_alignment(face.atoms) -cdef inline void face_clear(face_t face): +cdef inline void face_clear(face_t face) noexcept: """ Remove all atoms and coatoms from face. """ bitset_clear(face.atoms) bitset_clear(face.coatoms) -cdef inline void face_copy(face_t dst, face_t src): +cdef inline void face_copy(face_t dst, face_t src) noexcept: """ Copy src to dst overwriting dst. @@ -77,20 +77,20 @@ cdef inline void face_copy(face_t dst, face_t src): # Face Comparison ############################################################################# -cdef inline bint face_isempty(face_t face) nogil: +cdef inline bint face_isempty(face_t face) noexcept nogil: """ Return whether ``face`` contains no coatoms. """ return bitset_isempty(face.atoms) -cdef inline int face_cmp(face_t a, face_t b): +cdef inline int face_cmp(face_t a, face_t b) noexcept: """ Return ``0`` if the faces are equal and consistently ``-1`` and ``1`` if not. """ return bitset_cmp(a.atoms, b.atoms) -cdef inline bint face_issubset_fused(face_t a, face_t b, algorithm_variant algorithm) nogil: +cdef inline bint face_issubset_fused(face_t a, face_t b, algorithm_variant algorithm) noexcept nogil: """ Return whether ``a`` is a subface of ``b``. """ @@ -99,20 +99,20 @@ cdef inline bint face_issubset_fused(face_t a, face_t b, algorithm_variant algor else: return bitset_issuperset(a.coatoms, b.coatoms) -cdef inline bint face_issubset(face_t a, face_t b) nogil: +cdef inline bint face_issubset(face_t a, face_t b) noexcept nogil: return face_issubset_fused(a, b, 0) ############################################################################# # Face Bit Manipulation ############################################################################# -cdef inline bint face_atom_in(face_t face, mp_bitcnt_t n): +cdef inline bint face_atom_in(face_t face, mp_bitcnt_t n) noexcept: """ Return whether ``n`` is an atom of ``face``. """ return bitset_in(face.atoms, n) -cdef inline void face_add_atom(face_t face, mp_bitcnt_t n): +cdef inline void face_add_atom(face_t face, mp_bitcnt_t n) noexcept: """ Add atom `n` to the face. """ @@ -126,20 +126,20 @@ cdef inline int face_add_atom_safe(face_t face, mp_bitcnt_t n) except -1: raise KeyError(n) bitset_add(face.atoms, n) -cdef inline void face_discard_atom(face_t face, mp_bitcnt_t n): +cdef inline void face_discard_atom(face_t face, mp_bitcnt_t n) noexcept: """ Discard atom `n` of the face. """ bitset_discard(face.atoms, n) -cdef inline void facet_set_coatom(face_t face, mp_bitcnt_t n): +cdef inline void facet_set_coatom(face_t face, mp_bitcnt_t n) noexcept: """ Set the facet to be coatom ``n``. """ bitset_clear(face.coatoms) bitset_add(face.coatoms, n) -cdef inline void face_set_first_n_atoms(face_t face, mp_bitcnt_t n): +cdef inline void face_set_first_n_atoms(face_t face, mp_bitcnt_t n) noexcept: """ Set exactly the first ``n`` atoms. """ @@ -150,7 +150,7 @@ cdef inline void face_set_first_n_atoms(face_t face, mp_bitcnt_t n): # Face Searching ############################################################################# -cdef inline long face_next_atom(face_t face, mp_bitcnt_t n): +cdef inline long face_next_atom(face_t face, mp_bitcnt_t n) noexcept: """ Return the index of the next atom in ``face`` with index >= ``n``. @@ -158,7 +158,7 @@ cdef inline long face_next_atom(face_t face, mp_bitcnt_t n): """ return bitset_next(face.atoms, n) -cdef inline long face_first_missing_atom(face_t face): +cdef inline long face_first_missing_atom(face_t face) noexcept: """ Return the index of the first atom not in ``face``. @@ -166,7 +166,7 @@ cdef inline long face_first_missing_atom(face_t face): """ return bitset_first_in_complement(face.atoms) -cdef inline long face_len_atoms(face_t face) nogil: +cdef inline long face_len_atoms(face_t face) noexcept nogil: """ Calculate the number of atoms in the face. """ @@ -177,7 +177,7 @@ cdef inline long face_len_atoms(face_t face) nogil: # Arithmetic ############################################################################# -cdef inline void face_intersection_fused(face_t dest, face_t A, face_t B, algorithm_variant algorithm) nogil: +cdef inline void face_intersection_fused(face_t dest, face_t A, face_t B, algorithm_variant algorithm) noexcept nogil: """ Set ``dest`` to the intersection of ``A`` and ``B``. """ @@ -188,7 +188,7 @@ cdef inline void face_intersection_fused(face_t dest, face_t A, face_t B, algori bitset_intersection(dest.atoms, A.atoms, B.atoms) bitset_union(dest.coatoms, A.coatoms, B.coatoms) -cdef inline void face_intersection(face_t dest, face_t A, face_t B) nogil: +cdef inline void face_intersection(face_t dest, face_t A, face_t B) noexcept nogil: face_intersection_fused(dest, A, B, 0) @@ -196,11 +196,11 @@ cdef inline void face_intersection(face_t dest, face_t A, face_t B) nogil: # Miscellaneous ############################################################################# -cdef inline void swap_faces(face_t a, face_t b) nogil: +cdef inline void swap_faces(face_t a, face_t b) noexcept nogil: cdef face_t tmp tmp[0] = a[0] a[0] = b[0] b[0] = tmp[0] -cdef inline bint faces_are_identical(face_t a, face_t b) nogil: +cdef inline bint faces_are_identical(face_t a, face_t b) noexcept nogil: return a.atoms.limbs == b.atoms.limbs diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd index e2ad70a6d7c..f148c81f7a9 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd @@ -70,7 +70,7 @@ cdef class FaceIterator_base(SageObject): # If ``dual == 0``, then coatoms are facets, atoms vertices and vice versa. cdef ListOfFaces atoms, coatoms, coatoms_coatom_rep - cdef inline CombinatorialFace next_face(self) + cdef inline CombinatorialFace next_face(self) noexcept cdef inline int next_dimension(self) except -1 cdef inline int next_face_loop(self) except -1 cdef size_t n_atom_rep(self) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index d34fe192e8a..d35033fc855 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -1201,7 +1201,7 @@ cdef class FaceIterator_base(SageObject): # for the dimension. By this time the current dimension has changed. self.structure.highest_dimension = self.structure.current_dimension - 1 - cdef inline CombinatorialFace next_face(self): + cdef inline CombinatorialFace next_face(self) noexcept: r""" Set attribute ``face`` to the next face and return it as :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace`. @@ -2258,7 +2258,7 @@ cdef inline int prepare_face_iterator_for_partial_job( return 1 -cdef inline size_t get_digit(size_t job_id, size_t pos, size_t padto, size_t base) nogil: +cdef inline size_t get_digit(size_t job_id, size_t pos, size_t padto, size_t base) noexcept nogil: """ Get the digit ``pos`` of ``job_id`` with base ``base`` padding the number of digits to ``pad_to``. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd index 2cade890839..105cc81b9a4 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd @@ -56,7 +56,7 @@ cdef inline int face_list_shallow_init(face_list_t faces, size_t n_faces, size_t faces.is_not_new_face = check_allocarray(n_faces, sizeof(bint)) faces.polyhedron_is_simple = False -cdef inline void face_list_free(face_list_t faces): +cdef inline void face_list_free(face_list_t faces) noexcept: """ Free faces. """ @@ -66,7 +66,7 @@ cdef inline void face_list_free(face_list_t faces): face_free(faces.faces[i]) face_list_shallow_free(faces) -cdef inline void face_list_shallow_free(face_list_t faces): +cdef inline void face_list_shallow_free(face_list_t faces) noexcept: """ Free a shallow list of faces. """ @@ -124,7 +124,7 @@ cdef inline int add_face_deep(face_list_t faces, face_t face) except -1: face_copy(faces.faces[faces.n_faces], face) faces.n_faces += 1 -cdef inline void face_list_delete_faces_by_array(face_list_t faces, bint *delete): +cdef inline void face_list_delete_faces_by_array(face_list_t faces, bint *delete) noexcept: r""" Remove face ``i`` if and only if ``delete[i]`` decreasing ``faces.n_faces``. @@ -144,7 +144,7 @@ cdef inline void face_list_delete_faces_by_array(face_list_t faces, bint *delete faces.n_faces = n_newfaces faces.total_n_faces = n_newfaces -cdef inline void face_list_delete_faces_by_face(face_list_t faces, face_t face): +cdef inline void face_list_delete_faces_by_face(face_list_t faces, face_t face) noexcept: r""" Remove all faces such that the ``i``-th bit in ``face`` is not set descreasing ``faces.n_faces``. @@ -170,9 +170,9 @@ cdef inline void face_list_delete_faces_by_face(face_list_t faces, face_t face): # Face Comparison ############################################################################# -cdef void sort_faces_list(face_list_t faces) +cdef void sort_faces_list(face_list_t faces) noexcept -cdef inline size_t find_face(face_t face, face_list_t faces): +cdef inline size_t find_face(face_t face, face_list_t faces) noexcept: r""" Return the index of ``face`` in ``faces``. @@ -211,7 +211,7 @@ cdef inline size_t find_face(face_t face, face_list_t faces): else: return -1 -cdef inline bint is_contained_in_one_fused(face_t face, face_list_t faces, algorithm_variant algorithm) nogil: +cdef inline bint is_contained_in_one_fused(face_t face, face_list_t faces, algorithm_variant algorithm) noexcept nogil: """ Return whether ``face`` is contained in one of ``faces``. """ @@ -221,7 +221,7 @@ cdef inline bint is_contained_in_one_fused(face_t face, face_list_t faces, algor return True return False -cdef inline bint is_not_maximal_fused(face_list_t faces, size_t j, algorithm_variant algorithm, bint* is_not_new_face) nogil: +cdef inline bint is_not_maximal_fused(face_list_t faces, size_t j, algorithm_variant algorithm, bint* is_not_new_face) noexcept nogil: """ Return whether face ``j`` is not maximal in ``faces``. """ @@ -346,7 +346,7 @@ cdef inline size_t get_next_level( output = get_next_level_fused(faces, new_faces, visited_all, 0) return output -cdef inline size_t bit_rep_to_coatom_rep(face_t face, face_list_t coatoms, size_t *output): +cdef inline size_t bit_rep_to_coatom_rep(face_t face, face_list_t coatoms, size_t *output) noexcept: """ Write the coatom-representation of face in output. Return length. ``face_length`` is the length of ``face`` and ``coatoms[i]`` @@ -361,7 +361,7 @@ cdef inline size_t bit_rep_to_coatom_rep(face_t face, face_list_t coatoms, size_ count_length += 1 return count_length -cdef inline bint face_list_check_alignment(face_list_t faces): +cdef inline bint face_list_check_alignment(face_list_t faces) noexcept: """ Return whether all faces in ``faces`` are aligned correctly. """ diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx index ec9c23d090d..3f33aec8ec6 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx @@ -11,7 +11,7 @@ Sorting of a list of faces. # https://www.gnu.org/licenses/ #**************************************************************************** -cdef void sort_faces_list(face_list_t faces): +cdef void sort_faces_list(face_list_t faces) noexcept: r""" Sorts faces in place. """ @@ -23,7 +23,7 @@ cdef void sort_faces_list(face_list_t faces): # Sort the faces using merge sort. _sort_faces_loop(faces.faces, faces.faces, extra_mem, faces.n_faces) -cdef void _sort_faces_loop(face_t* inp, face_t* out, face_t* extra_mem, size_t n_faces): +cdef void _sort_faces_loop(face_t* inp, face_t* out, face_t* extra_mem, size_t n_faces) noexcept: """ This is merge sort. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd index d16065979eb..d50c8f85539 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd @@ -7,23 +7,23 @@ cdef class ListOfFaces: # It will be of "type" ``uint64_t[n_faces][face_length]`` cdef face_list_t data - cpdef ListOfFaces __copy__(self) + cpdef ListOfFaces __copy__(self) noexcept cpdef int compute_dimension(self) except -2 - cdef inline size_t n_faces(self): + cdef inline size_t n_faces(self) noexcept: return self.data.n_faces - cdef inline size_t n_atoms(self): + cdef inline size_t n_atoms(self) noexcept: return self.data.n_atoms - cdef inline size_t n_coatoms(self): + cdef inline size_t n_coatoms(self) noexcept: return self.data.n_coatoms - cpdef ListOfFaces pyramid(self) + cpdef ListOfFaces pyramid(self) noexcept - cdef ListOfFaces delete_atoms_unsafe(self, bint* delete, face_t face) # not in place - cdef void delete_faces_unsafe(self, bint* delete, face_t face) # in place + cdef ListOfFaces delete_atoms_unsafe(self, bint* delete, face_t face) noexcept # not in place + cdef void delete_faces_unsafe(self, bint* delete, face_t face) noexcept # in place - cdef void get_not_inclusion_maximal_unsafe(self, bint *not_inclusion_maximal) - cdef void get_faces_all_set_unsafe(self, bint *all_set) + cdef void get_not_inclusion_maximal_unsafe(self, bint *not_inclusion_maximal) noexcept + cdef void get_faces_all_set_unsafe(self, bint *all_set) noexcept -cdef tuple face_as_combinatorial_polyhedron(ListOfFaces facets, ListOfFaces Vrep, face_t face, bint dual) +cdef tuple face_as_combinatorial_polyhedron(ListOfFaces facets, ListOfFaces Vrep, face_t face, bint dual) noexcept diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx index dffa76036fa..9b5f3dd4ada 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx @@ -178,7 +178,7 @@ cdef class ListOfFaces: """ assert face_list_check_alignment(self.data) - cpdef ListOfFaces __copy__(self): + cpdef ListOfFaces __copy__(self) noexcept: r""" Return a copy of self. @@ -303,7 +303,7 @@ cdef class ListOfFaces: # by calculating dimension of one of its faces. return new_faces.compute_dimension() + 1 - cpdef ListOfFaces pyramid(self): + cpdef ListOfFaces pyramid(self) noexcept: r""" Return the list of faces of the pyramid. @@ -381,7 +381,7 @@ cdef class ListOfFaces: return copy - cdef ListOfFaces delete_atoms_unsafe(self, bint *delete, face_t face): + cdef ListOfFaces delete_atoms_unsafe(self, bint *delete, face_t face) noexcept: r""" Return a copy of ``self`` where bits in ``delete`` have been removed/contracted. @@ -421,7 +421,7 @@ cdef class ListOfFaces: return output - cdef void delete_faces_unsafe(self, bint *delete, face_t face): + cdef void delete_faces_unsafe(self, bint *delete, face_t face) noexcept: r""" Deletes face ``i`` if and only if ``delete[i]``. @@ -439,7 +439,7 @@ cdef class ListOfFaces: else: face_list_delete_faces_by_face(self.data, face) - cdef void get_not_inclusion_maximal_unsafe(self, bint *not_inclusion_maximal): + cdef void get_not_inclusion_maximal_unsafe(self, bint *not_inclusion_maximal) noexcept: r""" Get all faces that are not inclusion maximal. @@ -458,7 +458,7 @@ cdef class ListOfFaces: for i in range(self.n_faces()): not_inclusion_maximal[i] = is_not_maximal_fused(self.data, i, 0, not_inclusion_maximal) - cdef void get_faces_all_set_unsafe(self, bint *all_set): + cdef void get_faces_all_set_unsafe(self, bint *all_set) noexcept: r""" Get the faces that have all ``bits`` set. @@ -518,7 +518,7 @@ cdef class ListOfFaces: M.set_immutable() return M -cdef tuple face_as_combinatorial_polyhedron(ListOfFaces facets, ListOfFaces Vrep, face_t face, bint dual): +cdef tuple face_as_combinatorial_polyhedron(ListOfFaces facets, ListOfFaces Vrep, face_t face, bint dual) noexcept: r""" Obtain facets and Vrepresentation of ``face`` as new combinatorial polyhedron. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd index 4e7987b0d7a..438dc8de6f7 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd @@ -40,11 +40,11 @@ cdef class PolyhedronFaceLattice: cdef int _sort(self) except -1 cdef inline size_t find_face(self, int dimension, face_t face) except -2 - cpdef CombinatorialFace get_face(self, int dimension, size_t index) + cpdef CombinatorialFace get_face(self, int dimension, size_t index) noexcept cdef size_t set_coatom_rep(self, int dimension, size_t index) except -1 cdef size_t set_atom_rep(self, int dimension, size_t index) except -1 - cdef void incidence_init(self, int dimension_one, int dimension_two) - cdef inline bint next_incidence(self, size_t *one, size_t *two) - cdef inline bint next_incidence_loop(self, size_t *one, size_t *two) - cdef inline bint next_trivial_incidence(self, size_t *one, size_t *two) - cdef inline bint next_trivial_incidence2(self, size_t *one, size_t *two) + cdef void incidence_init(self, int dimension_one, int dimension_two) noexcept + cdef inline bint next_incidence(self, size_t *one, size_t *two) noexcept + cdef inline bint next_incidence_loop(self, size_t *one, size_t *two) noexcept + cdef inline bint next_trivial_incidence(self, size_t *one, size_t *two) noexcept + cdef inline bint next_trivial_incidence2(self, size_t *one, size_t *two) noexcept diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx index be6ffbda794..9f5a98c7ece 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx @@ -315,7 +315,7 @@ cdef class PolyhedronFaceLattice: return find_face(face, self.faces[dimension+1]) - cpdef CombinatorialFace get_face(self, int dimension, size_t index): + cpdef CombinatorialFace get_face(self, int dimension, size_t index) noexcept: r""" Return the face of dimension ``dimension`` and index ``index``. @@ -401,7 +401,7 @@ cdef class PolyhedronFaceLattice: cdef face_t face = self.faces[dimension+1].faces[index] return bit_rep_to_Vrep_list(face, self.atom_rep) - cdef void incidence_init(self, int dimension_one, int dimension_two): + cdef void incidence_init(self, int dimension_one, int dimension_two) noexcept: r""" Initialize the :class:`PolyhedronFaceLattice` to give incidences between ``dimension_one`` and ``dimension_two``. @@ -454,7 +454,7 @@ cdef class PolyhedronFaceLattice: self.incidence_counter_two = 0 self.is_incidence_initialized = 1 - cdef inline bint next_incidence(self, size_t *one, size_t *two): + cdef inline bint next_incidence(self, size_t *one, size_t *two) noexcept: r""" Set ``one[0]`` and ``two[0]`` to be the next incidence. Return ``True`` unless there are no more incidences, then return `0`. @@ -484,7 +484,7 @@ cdef class PolyhedronFaceLattice: return result - cdef inline bint next_incidence_loop(self, size_t *one, size_t *two): + cdef inline bint next_incidence_loop(self, size_t *one, size_t *two) noexcept: r""" Set ``one[0]`` and ``two[0]`` to be the next incidence. Return ``True`` on success and ``False`` otherwise. @@ -534,7 +534,7 @@ cdef class PolyhedronFaceLattice: if self.is_incidence_initialized == 0: return 0 - cdef inline bint next_trivial_incidence(self, size_t *one, size_t *two): + cdef inline bint next_trivial_incidence(self, size_t *one, size_t *two) noexcept: r""" Handling the case where ``dimension_one`` is dimension of polyhedron. @@ -551,7 +551,7 @@ cdef class PolyhedronFaceLattice: return (two[0] < self.f_vector[self.incidence_dim_two + 1]) - cdef inline bint next_trivial_incidence2(self, size_t *one, size_t *two): + cdef inline bint next_trivial_incidence2(self, size_t *one, size_t *two) noexcept: r""" Handling the case where ``dimension_two`` is `-1`. diff --git a/src/sage/geometry/toric_lattice_element.pyx b/src/sage/geometry/toric_lattice_element.pyx index 40897c019f5..bc736243642 100644 --- a/src/sage/geometry/toric_lattice_element.pyx +++ b/src/sage/geometry/toric_lattice_element.pyx @@ -223,7 +223,7 @@ cdef class ToricLatticeElement(Vector_integer_dense): """ return Vector_integer_dense.__hash__(self) - cpdef _act_on_(self, other, bint self_on_left): + cpdef _act_on_(self, other, bint self_on_left) noexcept: """ Act on ``other``. @@ -298,7 +298,7 @@ cdef class ToricLatticeElement(Vector_integer_dense): # We need to override this function to prohibit default behaviour. # It seems to be called when right is in the same lattice as self, which # is wrong from our point of view. - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: """ Raise a ``TypeError`` exception. diff --git a/src/sage/geometry/triangulation/base.pyx b/src/sage/geometry/triangulation/base.pyx index d66186db098..cbb1673d0f2 100644 --- a/src/sage/geometry/triangulation/base.pyx +++ b/src/sage/geometry/triangulation/base.pyx @@ -109,7 +109,7 @@ cdef class Point(SageObject): """ return hash(self._point_configuration) ^ (self._index) - cpdef point_configuration(self): + cpdef point_configuration(self) noexcept: r""" Return the point configuration to which the point belongs. @@ -158,7 +158,7 @@ cdef class Point(SageObject): """ return len(self._affine) - cpdef index(self): + cpdef index(self) noexcept: """ Return the index of the point in the point configuration. @@ -172,7 +172,7 @@ cdef class Point(SageObject): """ return self._index - cpdef projective(self): + cpdef projective(self) noexcept: r""" Return the projective coordinates of the point in the ambient space. @@ -198,7 +198,7 @@ cdef class Point(SageObject): """ return self._projective - cpdef affine(self): + cpdef affine(self) noexcept: r""" Return the affine coordinates of the point in the ambient space. @@ -224,7 +224,7 @@ cdef class Point(SageObject): """ return self._affine - cpdef reduced_affine(self): + cpdef reduced_affine(self) noexcept: r""" Return the affine coordinates of the point on the hyperplane spanned by the point configuration. @@ -251,7 +251,7 @@ cdef class Point(SageObject): """ return self._reduced_affine - cpdef reduced_projective(self): + cpdef reduced_projective(self) noexcept: r""" Return the projective coordinates of the point on the hyperplane spanned by the point configuration. @@ -278,7 +278,7 @@ cdef class Point(SageObject): """ return tuple(self._reduced_affine)+(1,) - cpdef reduced_affine_vector(self): + cpdef reduced_affine_vector(self) noexcept: """ Return the affine coordinates of the point on the hyperplane spanned by the point configuration. @@ -305,7 +305,7 @@ cdef class Point(SageObject): """ return self._reduced_affine_vector - cpdef reduced_projective_vector(self): + cpdef reduced_projective_vector(self) noexcept: """ Return the affine coordinates of the point on the hyperplane spanned by the point configuration. @@ -334,7 +334,7 @@ cdef class Point(SageObject): """ return self._reduced_projective_vector - cpdef _repr_(self): + cpdef _repr_(self) noexcept: """ Return a string representation of the point. @@ -396,7 +396,7 @@ cdef class PointConfiguration_base(Parent): cdef bint _is_affine cdef object _reduced_affine_vector_space, _reduced_projective_vector_space - cdef _init_points(self, tuple projective_points): + cdef _init_points(self, tuple projective_points) noexcept: """ Internal method to determine coordinates of points. @@ -466,7 +466,7 @@ cdef class PointConfiguration_base(Parent): """ return hash_by_id( self) - cpdef reduced_affine_vector_space(self): + cpdef reduced_affine_vector_space(self) noexcept: """ Return the vector space that contains the affine points. @@ -486,7 +486,7 @@ cdef class PointConfiguration_base(Parent): """ return self._reduced_affine_vector_space - cpdef reduced_projective_vector_space(self): + cpdef reduced_projective_vector_space(self) noexcept: """ Return the vector space that is spanned by the homogeneous coordinates. @@ -507,7 +507,7 @@ cdef class PointConfiguration_base(Parent): """ return self._reduced_projective_vector_space - cpdef ambient_dim(self): + cpdef ambient_dim(self) noexcept: """ Return the dimension of the ambient space of the point configuration. @@ -524,7 +524,7 @@ cdef class PointConfiguration_base(Parent): """ return self._ambient_dim - cpdef dim(self): + cpdef dim(self) noexcept: """ Return the actual dimension of the point configuration. @@ -540,7 +540,7 @@ cdef class PointConfiguration_base(Parent): """ return self._dim - cpdef base_ring(self): + cpdef base_ring(self) noexcept: r""" Return the base ring, that is, the ring containing the coordinates of the points. @@ -565,7 +565,7 @@ cdef class PointConfiguration_base(Parent): """ return self._base_ring - cpdef bint is_affine(self): + cpdef bint is_affine(self) noexcept: """ Return whether the configuration is defined by affine points. @@ -632,7 +632,7 @@ cdef class PointConfiguration_base(Parent): """ return self._pts[i] - cpdef n_points(self): + cpdef n_points(self) noexcept: """ Return the number of points. @@ -653,7 +653,7 @@ cdef class PointConfiguration_base(Parent): """ return len(self._pts) - cpdef points(self): + cpdef points(self) noexcept: """ Return a list of the points. @@ -731,7 +731,7 @@ cdef class PointConfiguration_base(Parent): """ return len(self._pts) - cpdef simplex_to_int(self, simplex): + cpdef simplex_to_int(self, simplex) noexcept: r""" Return an integer that uniquely identifies the given simplex. @@ -776,7 +776,7 @@ cdef class PointConfiguration_base(Parent): k = l+1 return s - cpdef int_to_simplex(self, int s): + cpdef int_to_simplex(self, int s) noexcept: r""" Reverse the enumeration of possible simplices in :meth:`simplex_to_int`. diff --git a/src/sage/graphs/asteroidal_triples.pyx b/src/sage/graphs/asteroidal_triples.pyx index d2423c912e3..fc5cc3ff09b 100644 --- a/src/sage/graphs/asteroidal_triples.pyx +++ b/src/sage/graphs/asteroidal_triples.pyx @@ -184,7 +184,7 @@ cdef list is_asteroidal_triple_free_C(uint32_t n, short_digraph sd, uint32_t** connected_structure, uint32_t* waiting_list, - bitset_t seen): + bitset_t seen) noexcept: """ INPUT: diff --git a/src/sage/graphs/base/boost_graph.pyx b/src/sage/graphs/base/boost_graph.pyx index f158aaafd27..84b048c84c5 100644 --- a/src/sage/graphs/base/boost_graph.pyx +++ b/src/sage/graphs/base/boost_graph.pyx @@ -55,7 +55,7 @@ from libcpp.set cimport set as cset from libcpp.pair cimport pair -cdef boost_graph_from_sage_graph(BoostGenGraph *g, g_sage, vertex_to_int, reverse=False): +cdef boost_graph_from_sage_graph(BoostGenGraph *g, g_sage, vertex_to_int, reverse=False) noexcept: r""" Initialize the Boost graph ``g`` to be equal to ``g_sage``. @@ -98,7 +98,7 @@ cdef boost_weighted_graph_from_sage_graph(BoostWeightedGraph *g, g_sage, vertex_to_int, weight_function=None, - reverse=False): + reverse=False) noexcept: r""" Initialize the Boost weighted graph ``g`` to be equal to ``g_sage``. @@ -169,7 +169,7 @@ cdef boost_weighted_graph_from_sage_graph(BoostWeightedGraph *g, g.add_edge(vertex_to_int[u], vertex_to_int[v], 1) -cdef boost_edge_connectivity(BoostVecGenGraph *g): +cdef boost_edge_connectivity(BoostVecGenGraph *g) noexcept: r""" Compute the edge connectivity of the input Boost graph. @@ -189,7 +189,7 @@ cdef boost_edge_connectivity(BoostVecGenGraph *g): return (result.ec, edges) -cpdef edge_connectivity(g): +cpdef edge_connectivity(g) noexcept: r""" Compute the edge connectivity of the input graph, using Boost. @@ -244,7 +244,7 @@ cpdef edge_connectivity(g): return (ec, [(int_to_vertex[u], int_to_vertex[v]) for u, v in edges]) -cdef boost_clustering_coeff(BoostGenGraph *g, vertices): +cdef boost_clustering_coeff(BoostGenGraph *g, vertices) noexcept: r""" Compute the clustering coefficient of all vertices in the list provided. @@ -276,7 +276,7 @@ cdef boost_clustering_coeff(BoostGenGraph *g, vertices): return ((sum(clust_of_v.itervalues()) / len(clust_of_v)), clust_of_v) -cpdef clustering_coeff(g, vertices=None): +cpdef clustering_coeff(g, vertices=None) noexcept: r""" Compute the clustering coefficient of the input graph, using Boost. @@ -343,7 +343,7 @@ cpdef clustering_coeff(g, vertices=None): @cython.binding(True) -cpdef dominator_tree(g, root, return_dict=False, reverse=False): +cpdef dominator_tree(g, root, return_dict=False, reverse=False) noexcept: r""" Use Boost to compute the dominator tree of ``g``, rooted at ``root``. @@ -500,7 +500,7 @@ cpdef dominator_tree(g, root, return_dict=False, reverse=False): return Graph(edges) -cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'): +cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee') noexcept: r""" Use Boost heuristics to approximate the bandwidth of the input graph. @@ -608,7 +608,7 @@ cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'): cpdef min_spanning_tree(g, weight_function=None, - algorithm='Kruskal'): + algorithm='Kruskal') noexcept: r""" Use Boost to compute the minimum spanning tree of the input graph. @@ -733,7 +733,7 @@ cpdef min_spanning_tree(g, return [(u, v, g.edge_label(u, v)) for u, v in edges] -cpdef blocks_and_cut_vertices(g): +cpdef blocks_and_cut_vertices(g) noexcept: r""" Compute the blocks and cut vertices of the graph. @@ -828,7 +828,7 @@ cpdef blocks_and_cut_vertices(g): return (result_blocks, list(result_cut)) -cpdef shortest_paths(g, start, weight_function=None, algorithm=None): +cpdef shortest_paths(g, start, weight_function=None, algorithm=None) noexcept: r""" Compute the shortest paths from ``start`` to all other vertices. @@ -1026,7 +1026,7 @@ cpdef shortest_paths(g, start, weight_function=None, algorithm=None): return (dist, pred) -cdef get_predecessors(BoostWeightedGraph g, result, int_to_v, directed, weight_type): +cdef get_predecessors(BoostWeightedGraph g, result, int_to_v, directed, weight_type) noexcept: r""" Return the predecessor matrix from the distance matrix of the graph. @@ -1083,7 +1083,7 @@ cdef get_predecessors(BoostWeightedGraph g, result, int_to_v, directed, weight_t return pred -cpdef johnson_shortest_paths(g, weight_function=None, distances=True, predecessors=False): +cpdef johnson_shortest_paths(g, weight_function=None, distances=True, predecessors=False) noexcept: r""" Use Johnson algorithm to solve the all-pairs-shortest-paths. @@ -1238,7 +1238,7 @@ cpdef johnson_shortest_paths(g, weight_function=None, distances=True, predecesso return pred -cpdef floyd_warshall_shortest_paths(g, weight_function=None, distances=True, predecessors=False): +cpdef floyd_warshall_shortest_paths(g, weight_function=None, distances=True, predecessors=False) noexcept: r""" Use Floyd-Warshall algorithm to solve the all-pairs-shortest-paths. @@ -1394,7 +1394,7 @@ cpdef floyd_warshall_shortest_paths(g, weight_function=None, distances=True, pre return pred -cpdef johnson_closeness_centrality(g, weight_function=None): +cpdef johnson_closeness_centrality(g, weight_function=None) noexcept: r""" Use Johnson algorithm to compute the closeness centrality of all vertices. @@ -1499,7 +1499,7 @@ cpdef johnson_closeness_centrality(g, weight_function=None): return {v: closeness[i] for i, v in enumerate(int_to_v) if closeness[i] != sys.float_info.max} -cpdef min_cycle_basis(g_sage, weight_function=None, by_weight=False): +cpdef min_cycle_basis(g_sage, weight_function=None, by_weight=False) noexcept: r""" Return a minimum weight cycle basis of the input graph ``g_sage``. @@ -1618,7 +1618,7 @@ cpdef min_cycle_basis(g_sage, weight_function=None, by_weight=False): return cycle_basis -cpdef eccentricity_DHV(g, vertex_list=None, weight_function=None, check_weight=True): +cpdef eccentricity_DHV(g, vertex_list=None, weight_function=None, check_weight=True) noexcept: r""" Return the vector of eccentricities using the algorithm of [Dragan2018]_. @@ -1806,7 +1806,7 @@ cpdef eccentricity_DHV(g, vertex_list=None, weight_function=None, check_weight=T return eccentricity -cpdef radius_DHV(g, weight_function=None, check_weight=True): +cpdef radius_DHV(g, weight_function=None, check_weight=True) noexcept: r""" Return the radius of weighted graph `g`. @@ -1943,7 +1943,7 @@ cpdef radius_DHV(g, weight_function=None, check_weight=True): return UB -cpdef diameter_DHV(g, weight_function=None, check_weight=True): +cpdef diameter_DHV(g, weight_function=None, check_weight=True) noexcept: r""" Return the diameter of weighted graph `g`. @@ -2116,7 +2116,7 @@ cpdef diameter_DHV(g, weight_function=None, check_weight=True): cdef tuple diameter_lower_bound_2Dsweep(BoostVecWeightedDiGraphU g_boost, BoostVecWeightedDiGraphU rev_g_boost, v_index source, - str algorithm): + str algorithm) noexcept: r""" Return a lower bound on the diameter of `G`. @@ -2477,7 +2477,7 @@ cdef double diameter_DiFUB(BoostVecWeightedDiGraphU g_boost, return LB cpdef diameter(G, algorithm=None, source=None, - weight_function=None, check_weight=True): + weight_function=None, check_weight=True) noexcept: r""" Return the diameter of `G`. @@ -2613,7 +2613,7 @@ cpdef diameter(G, algorithm=None, source=None, return LB cpdef shortest_paths_from_vertices(g, vertex_list=None, order=None, - weight_function=None, algorithm=None): + weight_function=None, algorithm=None) noexcept: r""" Compute the shortest paths to all vertices from each vertex in ``vertex_list``. @@ -2856,7 +2856,7 @@ cpdef shortest_paths_from_vertices(g, vertex_list=None, order=None, return distances, predecessors -cpdef wiener_index(g, algorithm=None, weight_function=None, check_weight=True): +cpdef wiener_index(g, algorithm=None, weight_function=None, check_weight=True) noexcept: r""" Return the Wiener index of the graph. diff --git a/src/sage/graphs/base/c_graph.pxd b/src/sage/graphs/base/c_graph.pxd index d5302e81cdd..1d5fb583eb5 100644 --- a/src/sage/graphs/base/c_graph.pxd +++ b/src/sage/graphs/base/c_graph.pxd @@ -21,13 +21,13 @@ cdef class CGraph: ################################### cpdef bint has_vertex(self, int n) except -1 - cpdef check_vertex(self, int n) - cpdef del_vertex(self, int v) - cpdef int current_allocation(self) - cpdef list verts(self) - cpdef add_vertices(self, verts) + cpdef check_vertex(self, int n) noexcept + cpdef del_vertex(self, int v) noexcept + cpdef int current_allocation(self) noexcept + cpdef list verts(self) noexcept + cpdef add_vertices(self, verts) noexcept cdef int del_vertex_unsafe(self, int) except -1 - cpdef realloc(self, int) + cpdef realloc(self, int) noexcept cdef int add_vertex_unsafe(self, int) except -1 ################################### @@ -42,9 +42,9 @@ cdef class CGraph: cdef int del_arc_unsafe(self, int, int) except -1 - cpdef add_arc(self, int u, int v) + cpdef add_arc(self, int u, int v) noexcept cpdef bint has_arc(self, int u, int v) except -1 - cpdef del_all_arcs(self, int u, int v) + cpdef del_all_arcs(self, int u, int v) noexcept ################################### # Labeled Edge Functions @@ -56,10 +56,10 @@ cdef class CGraph: cdef int arc_label_unsafe(self, int, int) except -1 cdef int all_arcs_unsafe(self, int, int, int *, int) except -1 - cpdef int arc_label(self, int u, int v) - cpdef list all_arcs(self, int u, int v) - cpdef del_arc_label(self, int u, int v, int l) - cpdef bint has_arc_label(self, int u, int v, int l) + cpdef int arc_label(self, int u, int v) noexcept + cpdef list all_arcs(self, int u, int v) noexcept + cpdef del_arc_label(self, int u, int v, int l) noexcept + cpdef bint has_arc_label(self, int u, int v, int l) noexcept ################################### # Neighbor Functions @@ -76,16 +76,16 @@ cdef class CGraph: cdef int next_out_neighbor_unsafe(self, int, int, int*) except -2 cdef int next_in_neighbor_unsafe(self, int, int, int*) except -2 - cdef adjacency_sequence_out(self, int n, int *vertices, int v, int* sequence) - cdef adjacency_sequence_in(self, int n, int *vertices, int v, int* sequence) - cpdef list in_neighbors(self, int v) - cpdef list out_neighbors(self, int u) + cdef adjacency_sequence_out(self, int n, int *vertices, int v, int* sequence) noexcept + cdef adjacency_sequence_in(self, int n, int *vertices, int v, int* sequence) noexcept + cpdef list in_neighbors(self, int v) noexcept + cpdef list out_neighbors(self, int u) noexcept cdef class CGraphBackend(GenericGraphBackend): cdef int get_vertex(self, u) except ? -2 cdef int get_vertex_checked(self, u) except ? -2 - cdef vertex_label(self, int u_int) + cdef vertex_label(self, int u_int) noexcept cdef int check_labelled_vertex(self, u, bint reverse) except ? -1 #cdef CGraph _cg # a child class should declare this accordingly cdef bint _directed @@ -94,12 +94,12 @@ cdef class CGraphBackend(GenericGraphBackend): cdef dict edge_labels cdef bint _loops cdef bint _multiple_edges - cdef CGraph cg(self) - cpdef add_edge(self, object u, object v, object l, bint directed) - cpdef del_edge(self, object u, object v, object l, bint directed) + cdef CGraph cg(self) noexcept + cpdef add_edge(self, object u, object v, object l, bint directed) noexcept + cpdef del_edge(self, object u, object v, object l, bint directed) noexcept cdef bint _has_labeled_edge_unsafe(self, int, int, object) except -1 - cdef bint _delete_edge_before_adding(self) + cdef bint _delete_edge_before_adding(self) noexcept cdef int new_edge_label(self, object l) except -1 cdef int free_edge_label(self, int l_int) except -1 cdef int _use_edge_iterator_on_subgraph(self, CGraphBackend other, object vertices, const int modus) except -1 - cdef list _all_edge_labels(self, int u, int v, uint32_t* edge=*) + cdef list _all_edge_labels(self, int u, int v, uint32_t* edge=*) noexcept diff --git a/src/sage/graphs/base/c_graph.pyx b/src/sage/graphs/base/c_graph.pyx index 79e62e13a33..7ca6c5dd124 100644 --- a/src/sage/graphs/base/c_graph.pyx +++ b/src/sage/graphs/base/c_graph.pyx @@ -126,7 +126,7 @@ cdef class CGraph: n < self.active_vertices.size and bitset_in(self.active_vertices, n)) - cpdef check_vertex(self, int n): + cpdef check_vertex(self, int n) noexcept: """ Check that ``n`` is a vertex of ``self``. @@ -333,7 +333,7 @@ cdef class CGraph: self.realloc(2 * self.active_vertices.size) return self.add_vertex_unsafe(k) - cpdef add_vertices(self, verts): + cpdef add_vertices(self, verts) noexcept: """ Add vertices from the iterable ``verts``. @@ -433,7 +433,7 @@ cdef class CGraph: self.num_verts -= 1 bitset_remove(self.active_vertices, v) - cpdef del_vertex(self, int v): + cpdef del_vertex(self, int v) noexcept: """ Delete the vertex ``v``, along with all edges incident to it. @@ -523,7 +523,7 @@ cdef class CGraph: if self.has_vertex(v): self.del_vertex_unsafe(v) - cpdef int current_allocation(self): + cpdef int current_allocation(self) noexcept: r""" Report the number of vertices allocated. @@ -581,7 +581,7 @@ cdef class CGraph: """ return self.active_vertices.size - cpdef list verts(self): + cpdef list verts(self) noexcept: """ Return a list of the vertices in ``self``. @@ -614,7 +614,7 @@ cdef class CGraph: """ return bitset_list(self.active_vertices) - cpdef realloc(self, int total): + cpdef realloc(self, int total) noexcept: """ Reallocate the number of vertices to use, without actually adding any. @@ -725,7 +725,7 @@ cdef class CGraph: cdef int del_arc_unsafe(self, int u, int v) except -1: raise NotImplementedError() - cpdef add_arc(self, int u, int v): + cpdef add_arc(self, int u, int v) noexcept: """ Add arc ``(u, v)`` to the graph. @@ -823,7 +823,7 @@ cdef class CGraph: return False return self.has_arc_unsafe(u, v) == 1 - cpdef del_all_arcs(self, int u, int v): + cpdef del_all_arcs(self, int u, int v) noexcept: """ Delete all arcs from ``u`` to ``v``. @@ -891,7 +891,7 @@ cdef class CGraph: cdef int all_arcs_unsafe(self, int u, int v, int* arc_labels, int size) except -1: raise NotImplementedError() - cpdef int arc_label(self, int u, int v): + cpdef int arc_label(self, int u, int v) noexcept: """ Retrieves the first label found associated with ``(u, v)``. @@ -933,7 +933,7 @@ cdef class CGraph: self.check_vertex(v) return self.arc_label_unsafe(u, v) - cpdef list all_arcs(self, int u, int v): + cpdef list all_arcs(self, int u, int v) noexcept: """ Gives the labels of all arcs ``(u, v)``. An unlabeled arc is interpreted as having label 0. @@ -973,7 +973,7 @@ cdef class CGraph: sig_free(arc_labels) return output - cpdef del_arc_label(self, int u, int v, int l): + cpdef del_arc_label(self, int u, int v, int l) noexcept: """ Delete an arc ``(u, v)`` with label ``l``. @@ -1006,7 +1006,7 @@ cdef class CGraph: raise ValueError("Label ({0}) must be a nonnegative integer.".format(l)) self.del_arc_label_unsafe(u, v, l) - cpdef bint has_arc_label(self, int u, int v, int l): + cpdef bint has_arc_label(self, int u, int v, int l) noexcept: """ Indicates whether there is an arc ``(u, v)`` with label ``l``. @@ -1124,7 +1124,7 @@ cdef class CGraph: cdef int next_in_neighbor_unsafe(self, int v, int u, int* l) except -2: raise NotImplementedError() - cdef adjacency_sequence_out(self, int n, int *vertices, int v, int* sequence): + cdef adjacency_sequence_out(self, int n, int *vertices, int v, int* sequence) noexcept: r""" Return the adjacency sequence corresponding to a list of vertices and a vertex. @@ -1164,7 +1164,7 @@ cdef class CGraph: for i in range(n): sequence[i] = self.has_arc_unsafe(v, vertices[i]) - cdef adjacency_sequence_in(self, int n, int *vertices, int v, int* sequence): + cdef adjacency_sequence_in(self, int n, int *vertices, int v, int* sequence) noexcept: r""" Compute the adjacency sequence corresponding to a list of vertices and a vertex. @@ -1203,7 +1203,7 @@ cdef class CGraph: for i in range(n): sequence[i] = self.has_arc_unsafe(vertices[i], v) - cpdef list out_neighbors(self, int u): + cpdef list out_neighbors(self, int u) noexcept: """ Return the list of out-neighbors of the vertex ``u``. @@ -1257,7 +1257,7 @@ cdef class CGraph: sig_free(neighbors) return output - cpdef list in_neighbors(self, int v): + cpdef list in_neighbors(self, int v) noexcept: """ Return the list of in-neighbors of the vertex ``v``. @@ -1375,7 +1375,7 @@ cdef class CGraphBackend(GenericGraphBackend): # Basic Access ################################### - cdef CGraph cg(self): + cdef CGraph cg(self) noexcept: r""" Return the attribute ``_cg`` casted into ``CGraph``. """ @@ -1553,7 +1553,7 @@ cdef class CGraphBackend(GenericGraphBackend): """ return self.cg().num_verts - cdef bint _delete_edge_before_adding(self): + cdef bint _delete_edge_before_adding(self) noexcept: """ Return whether we should delete edges before adding any. @@ -1631,7 +1631,7 @@ cdef class CGraphBackend(GenericGraphBackend): else: return -1 - cdef vertex_label(self, int u_int): + cdef vertex_label(self, int u_int) noexcept: """ Return the object represented by ``u_int``, or ``None`` if this does not represent a vertex. @@ -2357,7 +2357,7 @@ cdef class CGraphBackend(GenericGraphBackend): continue self.add_edge(u, v, l, directed) - cpdef add_edge(self, object u, object v, object l, bint directed): + cpdef add_edge(self, object u, object v, object l, bint directed) noexcept: """ Add the edge ``(u,v)`` to self. @@ -2489,7 +2489,7 @@ cdef class CGraphBackend(GenericGraphBackend): l = None self.del_edge(u, v, l, directed) - cpdef del_edge(self, object u, object v, object l, bint directed): + cpdef del_edge(self, object u, object v, object l, bint directed) noexcept: """ Delete edge ``(u, v, l)``. @@ -2607,7 +2607,7 @@ cdef class CGraphBackend(GenericGraphBackend): cdef int free_edge_label(self, int l_int) except -1: raise NotImplementedError() - cdef list _all_edge_labels(self, int u, int v, uint32_t* edge=NULL): + cdef list _all_edge_labels(self, int u, int v, uint32_t* edge=NULL) noexcept: """ Gives the labels of all arcs from ``u`` to ``v``. @@ -4885,7 +4885,7 @@ cdef class Search_iterator: """ return self - cdef inline next_breadth_first_search(self): + cdef inline next_breadth_first_search(self) noexcept: r""" Return the next vertex in a breadth first search traversal of a graph. @@ -4947,7 +4947,7 @@ cdef class Search_iterator: return value_prev, value return value - cdef inline next_depth_first_search(self): + cdef inline next_depth_first_search(self) noexcept: r""" Return the next vertex in a depth first search traversal of a graph. @@ -5009,7 +5009,7 @@ cdef class Search_iterator: # Functions to simplify edge iterator. ############################## -cdef inline bint _reorganize_edge(object v, object u, const int modus): +cdef inline bint _reorganize_edge(object v, object u, const int modus) noexcept: """ Return ``True`` if ``v`` and ``u`` should be exchanged according to the modus. diff --git a/src/sage/graphs/base/dense_graph.pxd b/src/sage/graphs/base/dense_graph.pxd index 839fa8ccba6..f5c194cec8a 100644 --- a/src/sage/graphs/base/dense_graph.pxd +++ b/src/sage/graphs/base/dense_graph.pxd @@ -21,5 +21,5 @@ cdef int copy_dense_graph(DenseGraph dest, DenseGraph src) except -1 cdef class DenseGraphBackend(CGraphBackend): cdef DenseGraph _cg - cdef inline CGraph cg(self): + cdef inline CGraph cg(self) noexcept: return self._cg diff --git a/src/sage/graphs/base/dense_graph.pyx b/src/sage/graphs/base/dense_graph.pyx index 9cb0a1676ae..db4a02a5a3f 100644 --- a/src/sage/graphs/base/dense_graph.pyx +++ b/src/sage/graphs/base/dense_graph.pyx @@ -195,7 +195,7 @@ cdef class DenseGraph(CGraph): sig_free(self.out_degrees) bitset_free(self.active_vertices) - cpdef realloc(self, int total_verts): + cpdef realloc(self, int total_verts) noexcept: """ Reallocate the number of vertices to use, without actually adding any. @@ -580,7 +580,7 @@ cdef class DenseGraphBackend(CGraphBackend): self.vertex_labels = {} self.vertex_ints = {} - cdef bint _delete_edge_before_adding(self): + cdef bint _delete_edge_before_adding(self) noexcept: """ Return whether we should delete edges before adding any. diff --git a/src/sage/graphs/base/sparse_graph.pxd b/src/sage/graphs/base/sparse_graph.pxd index 719ad0ef8c9..b925e9170ec 100644 --- a/src/sage/graphs/base/sparse_graph.pxd +++ b/src/sage/graphs/base/sparse_graph.pxd @@ -31,19 +31,19 @@ cdef class SparseGraph(CGraph): cdef SparseGraphBTNode **vertices cdef SparseGraphBTNode **vertices_rev cdef bint _directed - cpdef bint is_directed(self) + cpdef bint is_directed(self) noexcept cdef int _del_arc_unsafe(self, int, int, SparseGraphBTNode **) except -1 cdef int _add_arc_label_unsafe(self, int, int, int, SparseGraphBTNode **) except -1 - cdef int _del_arc_label_unsafe(self, int, int, int, SparseGraphBTNode **) - cdef SparseGraphLLNode* arc_labels_unsafe(self, int u, int v) - cpdef int out_degree(self, int u) - cpdef int in_degree(self, int u) + cdef int _del_arc_label_unsafe(self, int, int, int, SparseGraphBTNode **) noexcept + cdef SparseGraphLLNode* arc_labels_unsafe(self, int u, int v) noexcept + cpdef int out_degree(self, int u) noexcept + cpdef int in_degree(self, int u) noexcept - cdef int out_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers) - cdef int in_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers) + cdef int out_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers) noexcept + cdef int in_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers) noexcept - cdef inline SparseGraphBTNode* next_out_neighbor_BTNode_unsafe(self, int u, int v): + cdef inline SparseGraphBTNode* next_out_neighbor_BTNode_unsafe(self, int u, int v) noexcept: """ Return the next out-neighbor of ``u`` that is greater than ``v``. @@ -53,7 +53,7 @@ cdef class SparseGraph(CGraph): """ return self.next_neighbor_BTNode_unsafe(self.vertices, u, v) - cdef inline SparseGraphBTNode* next_in_neighbor_BTNode_unsafe(self, int v, int u): + cdef inline SparseGraphBTNode* next_in_neighbor_BTNode_unsafe(self, int v, int u) noexcept: """ Return the next in-neighbor of ``v`` that is greater than ``u``. @@ -63,12 +63,12 @@ cdef class SparseGraph(CGraph): """ return self.next_neighbor_BTNode_unsafe(self.vertices_rev, v, u) - cdef inline SparseGraphBTNode* next_neighbor_BTNode_unsafe(self, SparseGraphBTNode** vertices, int u, int v) + cdef inline SparseGraphBTNode* next_neighbor_BTNode_unsafe(self, SparseGraphBTNode** vertices, int u, int v) noexcept cdef class SparseGraphBackend(CGraphBackend): cdef int edge_labels_max cdef list edge_labels_available_ids cdef SparseGraph _cg - cdef inline CGraph cg(self): + cdef inline CGraph cg(self) noexcept: return self._cg diff --git a/src/sage/graphs/base/sparse_graph.pyx b/src/sage/graphs/base/sparse_graph.pyx index 714da06e519..e512832d958 100644 --- a/src/sage/graphs/base/sparse_graph.pyx +++ b/src/sage/graphs/base/sparse_graph.pyx @@ -207,7 +207,7 @@ cdef enum: # or three nodes. -cdef inline int compare(int a, int b): +cdef inline int compare(int a, int b) noexcept: # Here we rely on the fact that C performs arithmetic on unsigned # ints modulo 2^wordsize. cdef unsigned int aa = a, bb = b # signed ints lead to badness like a>b>c>a... @@ -370,7 +370,7 @@ cdef class SparseGraph(CGraph): sig_free(self.out_degrees) bitset_free(self.active_vertices) - cpdef realloc(self, int total): + cpdef realloc(self, int total) noexcept: """ Reallocate the number of vertices to use, without actually adding any. @@ -459,7 +459,7 @@ cdef class SparseGraph(CGraph): # self.active_vertices bitset_realloc(self.active_vertices, s_total) - cpdef inline bint is_directed(self): + cpdef inline bint is_directed(self) noexcept: r""" Return whether the graph is directed. @@ -610,7 +610,7 @@ cdef class SparseGraph(CGraph): # Neighbor functions ################################### - cdef int out_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers): + cdef int out_neighbors_BTNode_unsafe(self, int u, SparseGraphBTNode *** p_pointers) noexcept: """ List the out-neighbors of a vertex as BTNodes @@ -667,7 +667,7 @@ cdef class SparseGraph(CGraph): else: return -1 - cdef inline SparseGraphBTNode* next_neighbor_BTNode_unsafe(self, SparseGraphBTNode** vertices, int u, int v): + cdef inline SparseGraphBTNode* next_neighbor_BTNode_unsafe(self, SparseGraphBTNode** vertices, int u, int v) noexcept: """ Return the next neighbor of ``u`` that is greater than ``v``. @@ -710,7 +710,7 @@ cdef class SparseGraph(CGraph): return temp return NULL - cpdef int out_degree(self, int u): + cpdef int out_degree(self, int u) noexcept: """ Returns the out-degree of ``v`` @@ -732,7 +732,7 @@ cdef class SparseGraph(CGraph): """ return self.out_degrees[u] - cdef int in_neighbors_BTNode_unsafe(self, int v, SparseGraphBTNode *** p_pointers): + cdef int in_neighbors_BTNode_unsafe(self, int v, SparseGraphBTNode *** p_pointers) noexcept: """ List the in-neighbors of a vertex as BTNodes @@ -789,7 +789,7 @@ cdef class SparseGraph(CGraph): else: return -1 - cpdef int in_degree(self, int v): + cpdef int in_degree(self, int v) noexcept: """ Returns the in-degree of ``v`` @@ -995,7 +995,7 @@ cdef class SparseGraph(CGraph): return -1 return num_arcs - cdef SparseGraphLLNode* arc_labels_unsafe(self, int u, int v): + cdef SparseGraphLLNode* arc_labels_unsafe(self, int u, int v) noexcept: """ Return the first label of arcs (u, v) or ``NULL`` if there are none. @@ -1024,7 +1024,7 @@ cdef class SparseGraph(CGraph): return NULL return temp.labels - cdef inline int _del_arc_label_unsafe(self, int u, int v, int l, SparseGraphBTNode **parent): + cdef inline int _del_arc_label_unsafe(self, int u, int v, int l, SparseGraphBTNode **parent) noexcept: """ .. WARNING:: diff --git a/src/sage/graphs/base/static_dense_graph.pxd b/src/sage/graphs/base/static_dense_graph.pxd index 0e580a02b57..d1c2a0aa3f9 100644 --- a/src/sage/graphs/base/static_dense_graph.pxd +++ b/src/sage/graphs/base/static_dense_graph.pxd @@ -1,4 +1,4 @@ from sage.data_structures.binary_matrix cimport binary_matrix_t from libc.stdint cimport uint32_t, uint64_t -cdef dict dense_graph_init(binary_matrix_t m, g, translation = ?, force_undirected = ?) +cdef dict dense_graph_init(binary_matrix_t m, g, translation = ?, force_undirected = ?) noexcept diff --git a/src/sage/graphs/base/static_dense_graph.pyx b/src/sage/graphs/base/static_dense_graph.pyx index 78711fae2f1..9d8732b2f83 100644 --- a/src/sage/graphs/base/static_dense_graph.pyx +++ b/src/sage/graphs/base/static_dense_graph.pyx @@ -54,7 +54,7 @@ from itertools import product from sage.misc.flatten import flatten -cdef dict dense_graph_init(binary_matrix_t m, g, translation=None, force_undirected=False): +cdef dict dense_graph_init(binary_matrix_t m, g, translation=None, force_undirected=False) noexcept: r""" Fill a binary matrix with the information from a Sage (di)graph. diff --git a/src/sage/graphs/base/static_sparse_backend.pxd b/src/sage/graphs/base/static_sparse_backend.pxd index 1bffe2b3be2..db62534cb09 100644 --- a/src/sage/graphs/base/static_sparse_backend.pxd +++ b/src/sage/graphs/base/static_sparse_backend.pxd @@ -18,6 +18,6 @@ cdef class StaticSparseBackend(CGraphBackend): cdef list _vertex_to_labels cdef dict _vertex_to_int cdef StaticSparseCGraph _cg - cdef inline CGraph cg(self): + cdef inline CGraph cg(self) noexcept: return self._cg cdef int _use_edge_iterator_on_subgraph(self, CGraphBackend other, object vertices, const int modus) except -1 diff --git a/src/sage/graphs/base/static_sparse_backend.pyx b/src/sage/graphs/base/static_sparse_backend.pyx index 2eecc1a69d0..ae76a399240 100644 --- a/src/sage/graphs/base/static_sparse_backend.pyx +++ b/src/sage/graphs/base/static_sparse_backend.pyx @@ -196,7 +196,7 @@ cdef class StaticSparseCGraph(CGraph): """ self.add_vertex_unsafe(k) - cpdef del_vertex(self, int k): + cpdef del_vertex(self, int k) noexcept: r""" Remove a vertex from the graph. No way. @@ -211,7 +211,7 @@ cdef class StaticSparseCGraph(CGraph): """ self.del_vertex_unsafe(k) - cpdef list verts(self): + cpdef list verts(self) noexcept: r""" Returns the list of vertices @@ -318,7 +318,7 @@ cdef class StaticSparseCGraph(CGraph): neighbors[i] = self.g_rev.neighbors[u][i] return -1 if size < degree else degree - cpdef list out_neighbors(self, int u): + cpdef list out_neighbors(self, int u) noexcept: r""" List the out-neighbors of a vertex @@ -343,7 +343,7 @@ cdef class StaticSparseCGraph(CGraph): cdef int i return [ self.g.neighbors[u][i] for i in range(out_degree(self.g, u))] - cpdef list in_neighbors(self, int u): + cpdef list in_neighbors(self, int u) noexcept: r""" Return the in-neighbors of a vertex @@ -556,7 +556,7 @@ cdef class StaticSparseBackend(CGraphBackend): """ return v in self._vertex_to_int - cpdef add_edge(self, object u, object v, object l, bint directed): + cpdef add_edge(self, object u, object v, object l, bint directed) noexcept: r""" Set edge label. No way. @@ -601,7 +601,7 @@ cdef class StaticSparseBackend(CGraphBackend): """ raise ValueError("graph is immutable; please change a copy instead (use function copy())") - cpdef del_edge(self, object u, object v, object l, bint directed): + cpdef del_edge(self, object u, object v, object l, bint directed) noexcept: r""" Set edge label. No way. @@ -698,7 +698,7 @@ cdef class StaticSparseBackend(CGraphBackend): return self._all_edge_labels(u, v, edge) return edge_label(cg.g, edge) - cdef inline list _all_edge_labels(self, int u, int v, uint32_t* edge=NULL): + cdef inline list _all_edge_labels(self, int u, int v, uint32_t* edge=NULL) noexcept: """ Gives the labels of all arcs from ``u`` to ``v``. diff --git a/src/sage/graphs/base/static_sparse_graph.pxd b/src/sage/graphs/base/static_sparse_graph.pxd index b7d6be3a823..b5cd2d73009 100644 --- a/src/sage/graphs/base/static_sparse_graph.pxd +++ b/src/sage/graphs/base/static_sparse_graph.pxd @@ -23,17 +23,17 @@ ctypedef struct short_digraph_s: ctypedef short_digraph_s short_digraph[1] cdef int init_short_digraph(short_digraph g, G, edge_labelled=?, vertex_list=?) except -1 -cdef void free_short_digraph(short_digraph g) +cdef void free_short_digraph(short_digraph g) noexcept cdef int init_reverse(short_digraph dst, short_digraph src) except -1 -cdef int out_degree(short_digraph g, int u) -cdef uint32_t * has_edge(short_digraph g, int u, int v) -cdef object edge_label(short_digraph g, uint32_t * edge) -cdef int tarjan_strongly_connected_components_C(short_digraph g, int *scc) -cdef void strongly_connected_components_digraph_C(short_digraph g, int nscc, int *scc, short_digraph output) +cdef int out_degree(short_digraph g, int u) noexcept +cdef uint32_t * has_edge(short_digraph g, int u, int v) noexcept +cdef object edge_label(short_digraph g, uint32_t * edge) noexcept +cdef int tarjan_strongly_connected_components_C(short_digraph g, int *scc) noexcept +cdef void strongly_connected_components_digraph_C(short_digraph g, int nscc, int *scc, short_digraph output) noexcept cdef uint32_t simple_BFS(short_digraph g, uint32_t source, uint32_t *distances, uint32_t *predecessors, uint32_t *waiting_list, - bitset_t seen) + bitset_t seen) noexcept diff --git a/src/sage/graphs/base/static_sparse_graph.pyx b/src/sage/graphs/base/static_sparse_graph.pyx index 4b98ff027a3..90e47b6e069 100644 --- a/src/sage/graphs/base/static_sparse_graph.pyx +++ b/src/sage/graphs/base/static_sparse_graph.pyx @@ -310,7 +310,7 @@ cdef int init_short_digraph(short_digraph g, G, edge_labelled=False, vertex_list cpython.Py_XINCREF(g.edge_labels) -cdef inline int n_edges(short_digraph g): +cdef inline int n_edges(short_digraph g) noexcept: """ Return the number of edges in ``g``. @@ -319,7 +319,7 @@ cdef inline int n_edges(short_digraph g): return (g.neighbors[g.n] - g.edges) -cdef inline int out_degree(short_digraph g, int i): +cdef inline int out_degree(short_digraph g, int i) noexcept: """ Return the out-degree of vertex `i` in ``g``. @@ -402,14 +402,14 @@ cdef int init_reverse(short_digraph dst, short_digraph src) except -1: return 0 -cdef int compare_uint32_p(const_void *a, const_void *b): +cdef int compare_uint32_p(const_void *a, const_void *b) noexcept: """ Comparison function needed for ``bsearch``. """ return ( a)[0] - ( b)[0] -cdef inline uint32_t * has_edge(short_digraph g, int u, int v): +cdef inline uint32_t * has_edge(short_digraph g, int u, int v) noexcept: r""" Test the existence of an edge. @@ -418,7 +418,7 @@ cdef inline uint32_t * has_edge(short_digraph g, int u, int v): return bsearch(&v, g.neighbors[u], g.neighbors[u + 1] - g.neighbors[u], sizeof(uint32_t), compare_uint32_p) -cdef inline object edge_label(short_digraph g, uint32_t * edge): +cdef inline object edge_label(short_digraph g, uint32_t * edge) noexcept: r""" Return the label associated with a given edge """ @@ -433,7 +433,7 @@ cdef uint32_t simple_BFS(short_digraph g, uint32_t *distances, uint32_t *predecessors, uint32_t *waiting_list, - bitset_t seen): + bitset_t seen) noexcept: """ Perform a breadth first search (BFS) using the same method as in sage.graphs.distances_all_pairs.all_pairs_shortest_path_BFS @@ -565,7 +565,7 @@ cdef int can_be_reached_from(short_digraph g, int src, bitset_t reached) except sig_free(stack) -cdef int tarjan_strongly_connected_components_C(short_digraph g, int *scc): +cdef int tarjan_strongly_connected_components_C(short_digraph g, int *scc) noexcept: r""" The Tarjan algorithm to compute strongly connected components (SCCs). @@ -765,7 +765,7 @@ def tarjan_strongly_connected_components(G): return output -cdef void strongly_connected_components_digraph_C(short_digraph g, int nscc, int *scc, short_digraph output): +cdef void strongly_connected_components_digraph_C(short_digraph g, int nscc, int *scc, short_digraph output) noexcept: r""" Compute the strongly connected components (SCCs) digraph of `g`. @@ -889,7 +889,7 @@ def strongly_connected_components_digraph(G): return output, {v: scc[i] for i, v in enumerate(int_to_vertex)} -cdef strongly_connected_component_containing_vertex(short_digraph g, short_digraph g_reversed, int v, bitset_t scc): +cdef strongly_connected_component_containing_vertex(short_digraph g, short_digraph g_reversed, int v, bitset_t scc) noexcept: """ Feed ``scc`` with the vertices in the strongly connected component of ``v``. """ @@ -903,7 +903,7 @@ cdef strongly_connected_component_containing_vertex(short_digraph g, short_digra bitset_intersection(scc, scc, scc_reversed) -cdef void free_short_digraph(short_digraph g): +cdef void free_short_digraph(short_digraph g) noexcept: """ Free the resources used by ``g`` """ diff --git a/src/sage/graphs/centrality.pyx b/src/sage/graphs/centrality.pyx index 161f3f710e2..2fa2d4d303e 100755 --- a/src/sage/graphs/centrality.pyx +++ b/src/sage/graphs/centrality.pyx @@ -123,7 +123,7 @@ def centrality_betweenness(G, bint exact=False, bint normalize=True): @cython.cdivision(True) -cdef dict centrality_betweenness_C(G, numerical_type _, bint normalize=True): +cdef dict centrality_betweenness_C(G, numerical_type _, bint normalize=True) noexcept: r""" Return the centrality betweenness of G (C implementation) @@ -327,7 +327,7 @@ cdef dict centrality_betweenness_C(G, numerical_type _, bint normalize=True): return {vv: betweenness_list[i] for i, vv in enumerate(int_to_vertex)} -cdef void _estimate_reachable_vertices_dir(short_digraph g, int* reachL, int* reachU): +cdef void _estimate_reachable_vertices_dir(short_digraph g, int* reachL, int* reachU) noexcept: r""" For each vertex ``v``, bounds the number of vertices reachable from ``v``. @@ -460,7 +460,7 @@ cdef void _estimate_reachable_vertices_dir(short_digraph g, int* reachL, int* re reachU[i] = min(reachU_scc[scc[i]], g.n) -cdef void _compute_reachable_vertices_undir(short_digraph g, int* reachable): +cdef void _compute_reachable_vertices_undir(short_digraph g, int* reachable) noexcept: r""" For each vertex ``v``, compute the number of vertices reachable from ``v``. @@ -513,7 +513,7 @@ cdef void _compute_reachable_vertices_undir(short_digraph g, int* reachable): reachable[v] = len(currentcc) -cdef void _sort_vertices_degree(short_digraph g, int* sorted_verts): +cdef void _sort_vertices_degree(short_digraph g, int* sorted_verts) noexcept: r""" Sort vertices in decreasing order of degree. diff --git a/src/sage/graphs/connectivity.pxd b/src/sage/graphs/connectivity.pxd index 36898d75e76..329d2d29dad 100644 --- a/src/sage/graphs/connectivity.pxd +++ b/src/sage/graphs/connectivity.pxd @@ -16,9 +16,9 @@ cdef class _Component: cdef _LinkedList * edge_list cdef int component_type - cdef add_edge(self, Py_ssize_t e_index) - cdef finish_tric_or_poly(self, Py_ssize_t e_index) - cdef list get_edge_list(self) + cdef add_edge(self, Py_ssize_t e_index) noexcept + cdef finish_tric_or_poly(self, Py_ssize_t e_index) noexcept + cdef list get_edge_list(self) noexcept cdef class TriconnectivitySPQR: cdef MemoryAllocator mem @@ -88,7 +88,7 @@ cdef class TriconnectivitySPQR: ### Methods ### - cdef inline __tstack_push(self, int h, int a, int b): + cdef inline __tstack_push(self, int h, int a, int b) noexcept: """ Push ``(h, a, b)`` triple on ``Tstack``. """ @@ -97,26 +97,26 @@ cdef class TriconnectivitySPQR: self.t_stack_a[self.t_stack_top] = a self.t_stack_b[self.t_stack_top] = b - cdef inline __tstack_push_eos(self): + cdef inline __tstack_push_eos(self) noexcept: """ Push end-of-stack marker on ``Tstack``. """ self.t_stack_top += 1 self.t_stack_a[self.t_stack_top] = -1 - cdef inline bint __tstack_not_eos(self): + cdef inline bint __tstack_not_eos(self) noexcept: """ Return ``True`` iff end-of-stack marker is not on top of ``Tstack``. """ return self.t_stack_a[self.t_stack_top] != -1 - cdef inline int __estack_pop(self): + cdef inline int __estack_pop(self) noexcept: """ Pop from estack and return the popped element """ return self.e_stack.pop() - cdef inline __new_component(self, list edges, int type_c): + cdef inline __new_component(self, list edges, int type_c) noexcept: """ Create a new component and add ``edges`` to it. @@ -124,7 +124,7 @@ cdef class TriconnectivitySPQR: """ self.components_list.append(_Component(edges, type_c)) - cdef inline bint __is_virtual_edge(self, int e_index): + cdef inline bint __is_virtual_edge(self, int e_index) noexcept: """ Return ``True`` if edge number ``e_index`` is a virtual edge. @@ -134,7 +134,7 @@ cdef class TriconnectivitySPQR: """ return e_index >= self.m - cdef inline int __edge_other_extremity(self, int e_index, int u): + cdef inline int __edge_other_extremity(self, int e_index, int u) noexcept: """ Return the other extremity of the edge """ @@ -143,16 +143,16 @@ cdef class TriconnectivitySPQR: return self.edge_extremity_first[e_index] - cdef int __new_virtual_edge(self, int u, int v) - cdef _LinkedListNode * __new_LinkedListNode(self, Py_ssize_t e_index) - cdef Py_ssize_t __high(self, Py_ssize_t v) - cdef __del_high(self, int e_index) - cdef __split_multiple_edges(self) - cdef int __dfs1(self, int start, bint check=*) - cdef __build_acceptable_adj_struct(self) - cdef __path_finder(self, int start) - cdef __dfs2(self) + cdef int __new_virtual_edge(self, int u, int v) noexcept + cdef _LinkedListNode * __new_LinkedListNode(self, Py_ssize_t e_index) noexcept + cdef Py_ssize_t __high(self, Py_ssize_t v) noexcept + cdef __del_high(self, int e_index) noexcept + cdef __split_multiple_edges(self) noexcept + cdef int __dfs1(self, int start, bint check=*) noexcept + cdef __build_acceptable_adj_struct(self) noexcept + cdef __path_finder(self, int start) noexcept + cdef __dfs2(self) noexcept cdef int __path_search(self, int start) except -1 - cdef __assemble_triconnected_components(self) - cdef __build_spqr_tree(self) + cdef __assemble_triconnected_components(self) noexcept + cdef __build_spqr_tree(self) noexcept diff --git a/src/sage/graphs/connectivity.pyx b/src/sage/graphs/connectivity.pyx index 5a206221da9..8880d1f2b75 100644 --- a/src/sage/graphs/connectivity.pyx +++ b/src/sage/graphs/connectivity.pyx @@ -2674,7 +2674,7 @@ def spqr_tree_to_graph(T): # Helper methods for ``TriconnectivitySPQR``. # Define a doubly linked list -cdef inline _LinkedListNode_initialize(_LinkedListNode * node, Py_ssize_t data): +cdef inline _LinkedListNode_initialize(_LinkedListNode * node, Py_ssize_t data) noexcept: """ Initialize the ``_LinkedListNode`` with value data. """ @@ -2683,7 +2683,7 @@ cdef inline _LinkedListNode_initialize(_LinkedListNode * node, Py_ssize_t data): node.data = data -cdef inline _LinkedList_initialize(_LinkedList * ll): +cdef inline _LinkedList_initialize(_LinkedList * ll) noexcept: """ Initialize the ``_LinkedList``. """ @@ -2691,7 +2691,7 @@ cdef inline _LinkedList_initialize(_LinkedList * ll): ll.tail = NULL ll.length = 0 -cdef _LinkedList_set_head(_LinkedList * ll, _LinkedListNode * h): +cdef _LinkedList_set_head(_LinkedList * ll, _LinkedListNode * h) noexcept: """ Set the node ``h`` as the head and tail of the linked list ``ll``. """ @@ -2699,19 +2699,19 @@ cdef _LinkedList_set_head(_LinkedList * ll, _LinkedListNode * h): ll.tail = h ll.length = 1 -cdef inline _LinkedListNode * _LinkedList_get_head(_LinkedList * ll): +cdef inline _LinkedListNode * _LinkedList_get_head(_LinkedList * ll) noexcept: """ Return the head of the linked list ``ll``. """ return ll.head -cdef inline Py_ssize_t _LinkedList_get_length(_LinkedList * ll): +cdef inline Py_ssize_t _LinkedList_get_length(_LinkedList * ll) noexcept: """ Return the length of the linked list ``ll``. """ return ll.length -cdef _LinkedList_append(_LinkedList * ll, _LinkedListNode * node): +cdef _LinkedList_append(_LinkedList * ll, _LinkedListNode * node) noexcept: """ Append the node ``node`` to the linked list ``ll``. """ @@ -2723,7 +2723,7 @@ cdef _LinkedList_append(_LinkedList * ll, _LinkedListNode * node): ll.tail = node ll.length += 1 -cdef _LinkedList_remove(_LinkedList * ll, _LinkedListNode * node): +cdef _LinkedList_remove(_LinkedList * ll, _LinkedListNode * node) noexcept: """ Remove the node ``node`` from the linked list ``ll``. """ @@ -2741,7 +2741,7 @@ cdef _LinkedList_remove(_LinkedList * ll, _LinkedListNode * node): node.next.prev = node.prev ll.length -= 1 -cdef _LinkedList_push_front(_LinkedList * ll, _LinkedListNode * node): +cdef _LinkedList_push_front(_LinkedList * ll, _LinkedListNode * node) noexcept: """ Add node ``node`` to the beginning of the linked list ``ll``. """ @@ -2753,7 +2753,7 @@ cdef _LinkedList_push_front(_LinkedList * ll, _LinkedListNode * node): ll.head = node ll.length += 1 -cdef _LinkedList_concatenate(_LinkedList * lst1, _LinkedList * lst2): +cdef _LinkedList_concatenate(_LinkedList * lst1, _LinkedList * lst2) noexcept: """ Concatenate lst2 to lst1. @@ -2766,7 +2766,7 @@ cdef _LinkedList_concatenate(_LinkedList * lst1, _LinkedList * lst2): lst2.head = NULL lst2.length = 0 -cdef str _LinkedList_to_string(_LinkedList * ll): +cdef str _LinkedList_to_string(_LinkedList * ll) noexcept: """ Return a string representation of self. """ @@ -2825,7 +2825,7 @@ cdef class _Component: self.add_edge(e_index) self.component_type = type_c - cdef add_edge(self, Py_ssize_t e_index): + cdef add_edge(self, Py_ssize_t e_index) noexcept: """ Add edge index ``e_index`` to the component. """ @@ -2833,7 +2833,7 @@ cdef class _Component: _LinkedListNode_initialize(node, e_index) _LinkedList_append(self.edge_list, node) - cdef finish_tric_or_poly(self, Py_ssize_t e_index): + cdef finish_tric_or_poly(self, Py_ssize_t e_index) noexcept: r""" Finalize the component by adding edge ``e``. @@ -2871,7 +2871,7 @@ cdef class _Component: type_str = "Triconnected: " return type_str + _LinkedList_to_string(self.edge_list) - cdef list get_edge_list(self): + cdef list get_edge_list(self) noexcept: """ Return the list of edges belonging to the component. """ @@ -3269,7 +3269,7 @@ cdef class TriconnectivitySPQR: self.__build_spqr_tree() - cdef int __new_virtual_edge(self, int u, int v): + cdef int __new_virtual_edge(self, int u, int v) noexcept: """ Return a new virtual edge between ``u`` and ``v``. """ @@ -3281,7 +3281,7 @@ cdef class TriconnectivitySPQR: self.edge_status[e_index] = 0 return e_index - cdef _LinkedListNode * __new_LinkedListNode(self, Py_ssize_t e_index): + cdef _LinkedListNode * __new_LinkedListNode(self, Py_ssize_t e_index) noexcept: """ Create a new ``_LinkedListNode`` initialized with value ``e_index``. """ @@ -3289,7 +3289,7 @@ cdef class TriconnectivitySPQR: _LinkedListNode_initialize(node, e_index) return node - cdef Py_ssize_t __high(self, Py_ssize_t v): + cdef Py_ssize_t __high(self, Py_ssize_t v) noexcept: """ Return the ``high(v)`` value, which is the first value in ``highpt`` list of ``v``. @@ -3299,7 +3299,7 @@ cdef class TriconnectivitySPQR: return head.data return 0 - cdef __del_high(self, int e_index): + cdef __del_high(self, int e_index) noexcept: """ Delete edge ``e`` from the ``highpt`` list of the endpoint ``v`` it belongs to. @@ -3313,7 +3313,7 @@ cdef class TriconnectivitySPQR: v = self.edge_extremity_second[e_index] _LinkedList_remove(self.highpt[v], it) - cdef __split_multiple_edges(self): + cdef __split_multiple_edges(self) noexcept: """ Make the graph simple and build bonds recording multiple edges. @@ -3362,7 +3362,7 @@ cdef class TriconnectivitySPQR: sb.append(virtual_e_index) self.__new_component(sb, 0) - cdef int __dfs1(self, int start, bint check=True): + cdef int __dfs1(self, int start, bint check=True) noexcept: """ Build the palm-tree of the graph using a dfs traversal. @@ -3485,7 +3485,7 @@ cdef class TriconnectivitySPQR: return cut_vertex # cut_vertex is -1 if graph does not have a cut vertex - cdef __build_acceptable_adj_struct(self): + cdef __build_acceptable_adj_struct(self) noexcept: """ Build the adjacency lists for each vertex with certain properties of the ordering, using the ``lowpt1`` and ``lowpt2`` values. @@ -3540,7 +3540,7 @@ cdef class TriconnectivitySPQR: _LinkedList_append(self.adj[self.edge_extremity_first[e_index]], node) self.in_adj[e_index] = node - cdef __path_finder(self, int start): + cdef __path_finder(self, int start) noexcept: """ This function is a helper function for :meth:`__dfs2` function. @@ -3599,7 +3599,7 @@ cdef class TriconnectivitySPQR: self.dfs_counter -= 1 stack_top -= 1 - cdef __dfs2(self): + cdef __dfs2(self) noexcept: """ Update the values of ``lowpt1`` and ``lowpt2`` lists with the help of new numbering obtained from :meth:`__path_finder`. @@ -3982,7 +3982,7 @@ cdef class TriconnectivitySPQR: # Go to next edge in adjacency list e_node_dict[v] = e_node.next - cdef __assemble_triconnected_components(self): + cdef __assemble_triconnected_components(self) noexcept: """ Iterate through all the split components built by :meth:`__path_finder` and merges two bonds or two polygons that share an edge for constructing @@ -4109,7 +4109,7 @@ cdef class TriconnectivitySPQR: self.comp_type.append((<_Component> comp).component_type) self.comp_final_edge_list.append(e_list_new) - cdef __build_spqr_tree(self): + cdef __build_spqr_tree(self) noexcept: """ Build the SPQR-tree of the graph and store it in variable ``self.spqr_tree``. See diff --git a/src/sage/graphs/convexity_properties.pxd b/src/sage/graphs/convexity_properties.pxd index f6c1b68b6b8..cc80e214ea5 100644 --- a/src/sage/graphs/convexity_properties.pxd +++ b/src/sage/graphs/convexity_properties.pxd @@ -7,9 +7,9 @@ cdef class ConvexityProperties: cdef dict _dict_vertices_to_integers cdef binary_matrix_t _cache_hull_pairs - cdef list _vertices_to_integers(self, vertices) - cdef list _integers_to_vertices(self, list integers) - cdef _bitset_convex_hull(self, bitset_t hull) - cpdef hull(self, list vertices) - cdef _greedy_increase(self, bitset_t bs) - cpdef hull_number(self, value_only = *, verbose = *) + cdef list _vertices_to_integers(self, vertices) noexcept + cdef list _integers_to_vertices(self, list integers) noexcept + cdef _bitset_convex_hull(self, bitset_t hull) noexcept + cpdef hull(self, list vertices) noexcept + cdef _greedy_increase(self, bitset_t bs) noexcept + cpdef hull_number(self, value_only = *, verbose = *) noexcept diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index c422d0c3190..0c96c518e83 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -230,20 +230,20 @@ cdef class ConvexityProperties: """ binary_matrix_free(self._cache_hull_pairs) - cdef list _vertices_to_integers(self, vertices): + cdef list _vertices_to_integers(self, vertices) noexcept: r""" Converts a list of vertices to a list of integers with the cached data. """ return [self._dict_vertices_to_integers[v] for v in vertices] - cdef list _integers_to_vertices(self, list integers): + cdef list _integers_to_vertices(self, list integers) noexcept: r""" Convert a list of integers to a list of vertices with the cached data. """ cdef int i return [self._list_integers_to_vertices[i] for i in integers] - cdef _bitset_convex_hull(self, bitset_t hull): + cdef _bitset_convex_hull(self, bitset_t hull) noexcept: r""" Compute the convex hull of a list of vertices given as a bitset. @@ -293,7 +293,7 @@ cdef class ConvexityProperties: # Otherwise, update and back to the loop count = tmp_count - cpdef hull(self, list vertices): + cpdef hull(self, list vertices) noexcept: r""" Return the convex hull of a set of vertices. @@ -324,7 +324,7 @@ cdef class ConvexityProperties: return answer - cdef _greedy_increase(self, bitset_t bs): + cdef _greedy_increase(self, bitset_t bs) noexcept: r""" Given a bitset whose hull is not the whole set, greedily add vertices and stop before its hull is the whole set. @@ -346,7 +346,7 @@ cdef class ConvexityProperties: bitset_free(tmp) - cpdef hull_number(self, value_only=True, verbose=False): + cpdef hull_number(self, value_only=True, verbose=False) noexcept: r""" Compute the hull number and a corresponding generating set. diff --git a/src/sage/graphs/distances_all_pairs.pxd b/src/sage/graphs/distances_all_pairs.pxd index 22b81467ec6..98301b92213 100644 --- a/src/sage/graphs/distances_all_pairs.pxd +++ b/src/sage/graphs/distances_all_pairs.pxd @@ -1,11 +1,11 @@ from libc.stdint cimport uint32_t cdef unsigned short * c_shortest_path_all_pairs(G, vertex_list=*) except NULL -cdef unsigned short * c_distances_all_pairs(G, vertex_list=*) +cdef unsigned short * c_distances_all_pairs(G, vertex_list=*) noexcept cdef all_pairs_shortest_path_BFS(gg, unsigned short * predecessors, unsigned short * distances, uint32_t * eccentricity, - vertex_list=*) + vertex_list=*) noexcept cdef uint32_t * c_eccentricity(G, vertex_list=*) except NULL diff --git a/src/sage/graphs/distances_all_pairs.pyx b/src/sage/graphs/distances_all_pairs.pyx index 9445442f603..a61fd4168a4 100644 --- a/src/sage/graphs/distances_all_pairs.pyx +++ b/src/sage/graphs/distances_all_pairs.pyx @@ -145,7 +145,7 @@ from sage.graphs.base.static_sparse_graph cimport (short_digraph, cdef inline c_all_pairs_shortest_path_BFS(short_digraph sd, unsigned short* predecessors, unsigned short* distances, - uint32_t* eccentricity): + uint32_t* eccentricity) noexcept: r""" See the module's documentation. """ @@ -271,7 +271,7 @@ cdef inline all_pairs_shortest_path_BFS(gg, unsigned short* predecessors, unsigned short* distances, uint32_t* eccentricity, - vertex_list=None): + vertex_list=None) noexcept: r""" See the module's documentation. @@ -412,7 +412,7 @@ def shortest_path_all_pairs(G): # Distances # ############# -cdef unsigned short * c_distances_all_pairs(G, vertex_list=None): +cdef unsigned short * c_distances_all_pairs(G, vertex_list=None) noexcept: r""" Returns the matrix of distances in G. @@ -1085,7 +1085,7 @@ cdef uint32_t diameter_lower_bound_2sweep(short_digraph g, uint32_t* distances, uint32_t* predecessors, uint32_t* waiting_list, - bitset_t seen): + bitset_t seen) noexcept: """ Compute a lower bound on the diameter using the 2-sweep algorithm. @@ -1144,7 +1144,7 @@ cdef uint32_t diameter_lower_bound_2sweep(short_digraph g, cdef tuple diameter_lower_bound_2Dsweep(short_digraph g, short_digraph rev_g, - uint32_t source): + uint32_t source) noexcept: r""" Lower bound on the diameter of digraph using directed version of 2-sweep. @@ -1258,7 +1258,7 @@ cdef tuple diameter_lower_bound_2Dsweep(short_digraph g, cdef tuple diameter_lower_bound_multi_sweep(short_digraph g, - uint32_t source): + uint32_t source) noexcept: """ Lower bound on the diameter using multi-sweep. @@ -1336,7 +1336,7 @@ cdef tuple diameter_lower_bound_multi_sweep(short_digraph g, cdef uint32_t diameter_iFUB(short_digraph g, - uint32_t source): + uint32_t source) noexcept: """ Compute the diameter of the input Graph using the ``iFUB`` algorithm. @@ -1420,7 +1420,7 @@ cdef uint32_t diameter_iFUB(short_digraph g, cdef uint32_t diameter_DiFUB(short_digraph sd, - uint32_t source): + uint32_t source) noexcept: r""" Return the diameter of unweighted directed graph. @@ -1545,7 +1545,7 @@ cdef uint32_t diameter_DiFUB(short_digraph sd, return LB -cdef uint32_t diameter_DHV(short_digraph g): +cdef uint32_t diameter_DHV(short_digraph g) noexcept: r""" Return the diameter of unweighted graph `g`. @@ -2088,7 +2088,7 @@ def wiener_index(G): # Szeged index # ################ -cdef uint64_t c_szeged_index_low_memory(short_digraph sd): +cdef uint64_t c_szeged_index_low_memory(short_digraph sd) noexcept: r""" Return the Szeged index of the graph. @@ -2196,7 +2196,7 @@ cdef uint64_t c_szeged_index_low_memory(short_digraph sd): return s -cdef uint64_t c_szeged_index_high_memory(short_digraph sd): +cdef uint64_t c_szeged_index_high_memory(short_digraph sd) noexcept: r""" Return the Szeged index of the graph. diff --git a/src/sage/graphs/edge_connectivity.pyx b/src/sage/graphs/edge_connectivity.pyx index 014e46f7500..72416b560b6 100644 --- a/src/sage/graphs/edge_connectivity.pyx +++ b/src/sage/graphs/edge_connectivity.pyx @@ -300,7 +300,7 @@ cdef class GabowEdgeConnectivity: _ = self.compute_edge_connectivity() sig_check() - cdef build_graph_data_structure(self): + cdef build_graph_data_structure(self) noexcept: r""" Build graph data structures. @@ -447,7 +447,7 @@ cdef class GabowEdgeConnectivity: return True - cdef void increase_memory_for_new_tree(self, int tree): + cdef void increase_memory_for_new_tree(self, int tree) noexcept: """ Allocate data structure for the new tree/forest. @@ -495,7 +495,7 @@ cdef class GabowEdgeConnectivity: self.L_roots[tree] = self.UNUSED self.tree_flag[tree] = False - cdef void compute_dfs_tree(self): + cdef void compute_dfs_tree(self) noexcept: r""" Find a DFS spanning forest of `G \backslash T`. @@ -530,7 +530,7 @@ cdef class GabowEdgeConnectivity: # Each call of find_dfs_tree creates an f-tree self.num_start_f_trees += 1 - cdef void find_dfs_tree(self, int r): + cdef void find_dfs_tree(self, int r) noexcept: r""" Find more vertices of the f-tree rooted at `r`. @@ -577,7 +577,7 @@ cdef class GabowEdgeConnectivity: # We are done with u. We pop. t -= 1 - cdef void find_dfs_tree_rec(self, int u, int r): + cdef void find_dfs_tree_rec(self, int u, int r) noexcept: r""" Find more vertices of the f-tree rooted at `r`. @@ -609,7 +609,7 @@ cdef class GabowEdgeConnectivity: # recursively find more vertices and grow the subtree rooted at r self.find_dfs_tree_rec(v, r) - cdef int choose_root(self): + cdef int choose_root(self) noexcept: """ Return the root of an active f_tree, or INT_MAX if none exists. @@ -694,7 +694,7 @@ cdef class GabowEdgeConnectivity: return True return False - cdef void join(self, int e_id): + cdef void join(self, int e_id) noexcept: """ Assign edge e_id to current tree. @@ -864,7 +864,7 @@ cdef class GabowEdgeConnectivity: return self.label_A_path(e_id) - cdef bint is_joining_edge(self, int e_id): + cdef bint is_joining_edge(self, int e_id) noexcept: """ Check if edge e_id is joining. @@ -879,7 +879,7 @@ cdef class GabowEdgeConnectivity: cdef int root_y = self.root[self.my_to[e_id]] return (root_x != root_y) and (root_x == self.augmenting_root or root_y == self.augmenting_root) - cdef int label_A_path(self, int e_id): + cdef int label_A_path(self, int e_id) noexcept: """ Labels the incident unused edges as the label_A_step of the algorithm @@ -913,7 +913,7 @@ cdef class GabowEdgeConnectivity: return INT_MAX - cdef bint label_step(self, int e_id, int e_label): + cdef bint label_step(self, int e_id, int e_label) noexcept: """ Label edge e_id with e_label and check whether edge e_id is joining. @@ -935,7 +935,7 @@ cdef class GabowEdgeConnectivity: # The roots are different. Check whether one of them is on the f_tree return root_x == self.augmenting_root or root_y == self.augmenting_root - cdef bint any_unused_is_unlabeled(self, int x): + cdef bint any_unused_is_unlabeled(self, int x) noexcept: """ Check if each unused edge directed to x is unlabeled @@ -955,7 +955,7 @@ cdef class GabowEdgeConnectivity: return True - cdef void augmentation_algorithm(self): + cdef void augmentation_algorithm(self) noexcept: """ Trace the path of the found joining edges @@ -972,7 +972,7 @@ cdef class GabowEdgeConnectivity: self.joining_edges.pop() self.trace_back(e_id, e_state) - cdef void trace_back(self, int e_id, int e_state): + cdef void trace_back(self, int e_id, int e_state) noexcept: """ Trace the path of a joining edge and transfer the edges to the appropriate tree Ti. @@ -1027,7 +1027,7 @@ cdef class GabowEdgeConnectivity: e = ep ep = self.labels[e] - cdef re_init(self, int tree): + cdef re_init(self, int tree) noexcept: """ Make f_trees active (except the f_tree of the root), update depths and parent values, and clear the labels. @@ -1085,7 +1085,7 @@ cdef class GabowEdgeConnectivity: if j != self.root_vertex: self.forests[j] = True - cdef void update_parents_depths(self, int tree): + cdef void update_parents_depths(self, int tree) noexcept: """ Update parents, depths, and, if current_tree is k, the vertex labels to the root of each f_tree. @@ -1115,7 +1115,7 @@ cdef class GabowEdgeConnectivity: self.update_parents_dfs(tree, v) self.root[i] = self.root[v] - cdef void update_parents_dfs(self, int tree, int x): + cdef void update_parents_dfs(self, int tree, int x) noexcept: """ Helper method for ``update_parents_depths``. @@ -1157,7 +1157,7 @@ cdef class GabowEdgeConnectivity: self.my_parent_edge_id[tree][v] = e_id self.my_depth[tree][v] = depth - cdef void save_current_k_intersection(self): + cdef void save_current_k_intersection(self) noexcept: """ Save the current k-intersection. diff --git a/src/sage/graphs/generic_graph_pyx.pxd b/src/sage/graphs/generic_graph_pyx.pxd index 23f45e38080..1a472c59a70 100644 --- a/src/sage/graphs/generic_graph_pyx.pxd +++ b/src/sage/graphs/generic_graph_pyx.pxd @@ -8,7 +8,7 @@ ctypedef fused dimension_t: D_TWO D_THREE -cdef run_spring(int, dimension_t, double*, int*, int, int, bint) +cdef run_spring(int, dimension_t, double*, int*, int, int, bint) noexcept cdef class GenericGraph_pyx(SageObject): pass @@ -17,7 +17,7 @@ cdef class GenericGraph_pyx(SageObject): cdef class SubgraphSearch: cdef int ng cdef int nh - cdef (bint) (*is_admissible) (int, int *, int *) + cdef (bint) (*is_admissible) (int, int *, int *) noexcept cdef DenseGraph g cdef DenseGraph h cdef int *busy diff --git a/src/sage/graphs/generic_graph_pyx.pyx b/src/sage/graphs/generic_graph_pyx.pyx index c8777a62f23..613d6c1c4ef 100644 --- a/src/sage/graphs/generic_graph_pyx.pyx +++ b/src/sage/graphs/generic_graph_pyx.pyx @@ -258,7 +258,7 @@ def spring_layout_fast(G, iterations=50, int dim=2, vpos=None, bint rescale=True @cython.cdivision(True) -cdef run_spring(int iterations, dimension_t _dim, double* pos, int* edges, int n, int m, bint height): +cdef run_spring(int iterations, dimension_t _dim, double* pos, int* edges, int n, int m, bint height) noexcept: r""" Find a locally optimal layout for this graph, according to the constraints that neighboring nodes want to be a fixed distance @@ -388,7 +388,7 @@ cdef run_spring(int iterations, dimension_t _dim, double* pos, int* edges, int n @cython.cdivision(True) -cdef inline double sqrt_approx(double x, double y, double xx, double yy): +cdef inline double sqrt_approx(double x, double y, double xx, double yy) noexcept: r""" Approximation of `\sqrt(x^2+y^2)`. @@ -979,7 +979,7 @@ cdef class SubgraphSearch: sig_off() raise StopIteration -cdef inline bint vectors_equal(int n, int *a, int *b): +cdef inline bint vectors_equal(int n, int *a, int *b) noexcept: r""" Tests whether the two given vectors are equal. Two integer vectors `a = (a_1, a_2, \dots, a_n)` and `b = (b_1, b_2, \dots, b_n)` are equal @@ -1002,7 +1002,7 @@ cdef inline bint vectors_equal(int n, int *a, int *b): return False return True -cdef inline bint vectors_inferior(int n, int *a, int *b): +cdef inline bint vectors_inferior(int n, int *a, int *b) noexcept: r""" Tests whether the second vector of integers is inferior to the first. Let `u = (u_1, u_2, \dots, u_k)` and `v = (v_1, v_2, \dots, v_k)` be two @@ -1157,7 +1157,7 @@ def _test_vectors_equal_inferior(): cpdef tuple find_hamiltonian(G, long max_iter=100000, long reset_bound=30000, - long backtrack_bound=1000, find_path=False): + long backtrack_bound=1000, find_path=False) noexcept: r""" Randomized backtracking for finding Hamiltonian cycles and paths. diff --git a/src/sage/graphs/genus.pyx b/src/sage/graphs/genus.pyx index 90fb4bf4c52..4370f3135af 100644 --- a/src/sage/graphs/genus.pyx +++ b/src/sage/graphs/genus.pyx @@ -49,7 +49,7 @@ from sage.graphs.base.dense_graph cimport DenseGraph from sage.graphs.graph import Graph -cdef inline int edge_map(int i): +cdef inline int edge_map(int i) noexcept: """ We might as well make the edge map nice, since the vertex map is so slippery. This is the fastest way I could find to establish the @@ -202,7 +202,7 @@ cdef class simple_connected_genus_backtracker: # print(self.face_map[v], end="") # print(']') - cdef inline void freeze_face(self): + cdef inline void freeze_face(self) noexcept: """ Quickly store the current face_map so we can recover the embedding it corresponds to later. @@ -269,7 +269,7 @@ cdef class simple_connected_genus_backtracker: return embedding - cdef int run_cycle(self, int i): + cdef int run_cycle(self, int i) noexcept: r""" Mark off the orbit of `i` under face_map. @@ -297,7 +297,7 @@ cdef class simple_connected_genus_backtracker: j = self.face_map[j] return 1 - cdef void flip(self, int v, int i): + cdef void flip(self, int v, int i) noexcept: r""" This is where the real work happens. Once cycles have been counted for the initial face_map, we make small local changes, and look at their @@ -389,7 +389,7 @@ cdef class simple_connected_genus_backtracker: w[i] = v2 w[i + 1] = v1 - cdef int count_cycles(self): + cdef int count_cycles(self) noexcept: """ Count all cycles. """ @@ -461,14 +461,14 @@ cdef class simple_connected_genus_backtracker: sig_off() return g - cdef void reset_swap(self, int v): + cdef void reset_swap(self, int v) noexcept: """ Reset the swapper associated with vertex ``v``. """ cdef int d = self.degree[v] - 1 reset_swap(d, self.swappers[v], self.swappers[v] + d) - cdef int next_swap(self, int v): + cdef int next_swap(self, int v) noexcept: """ Compute and return the next swap associated with the vertex ``v``. """ @@ -478,7 +478,7 @@ cdef class simple_connected_genus_backtracker: cdef int genus_backtrack(self, int cutoff, bint record_embedding, - (int (*)(simple_connected_genus_backtracker, int, bint, int))check_embedding): + (int (*)(simple_connected_genus_backtracker, int, bint, int))check_embedding) noexcept: """ Here's the main backtracking routine. @@ -523,7 +523,7 @@ cdef class simple_connected_genus_backtracker: cdef int min_genus_check(simple_connected_genus_backtracker self, int cutoff, bint record_embedding, - int initial): + int initial) noexcept: """ Search for the minimal genus. @@ -543,7 +543,7 @@ cdef int min_genus_check(simple_connected_genus_backtracker self, cdef int max_genus_check(simple_connected_genus_backtracker self, int cutoff, bint record_embedding, - int initial): + int initial) noexcept: """ Same as min_genus_check, but search for a maximum. """ diff --git a/src/sage/graphs/graph_coloring.pyx b/src/sage/graphs/graph_coloring.pyx index d93745b85b5..327435969fe 100644 --- a/src/sage/graphs/graph_coloring.pyx +++ b/src/sage/graphs/graph_coloring.pyx @@ -327,7 +327,7 @@ def all_graph_colorings(G, n, count_only=False, hex_colors=False, raise RuntimeError("too much recursion, Graph coloring failed") -cpdef first_coloring(G, n=0, hex_colors=False): +cpdef first_coloring(G, n=0, hex_colors=False) noexcept: r""" Return the first vertex coloring found. @@ -365,7 +365,7 @@ cpdef first_coloring(G, n=0, hex_colors=False): return C -cpdef number_of_n_colorings(G, n): +cpdef number_of_n_colorings(G, n) noexcept: r""" Compute the number of `n`-colorings of a graph @@ -397,7 +397,7 @@ cpdef number_of_n_colorings(G, n): return m -cpdef numbers_of_colorings(G): +cpdef numbers_of_colorings(G) noexcept: r""" Compute the number of colorings of a graph. @@ -416,7 +416,7 @@ cpdef numbers_of_colorings(G): return answer -cpdef chromatic_number(G): +cpdef chromatic_number(G) noexcept: r""" Return the chromatic number of the graph. diff --git a/src/sage/graphs/graph_decompositions/bandwidth.pyx b/src/sage/graphs/graph_decompositions/bandwidth.pyx index bbd3916ac2b..61bacd2daf5 100644 --- a/src/sage/graphs/graph_decompositions/bandwidth.pyx +++ b/src/sage/graphs/graph_decompositions/bandwidth.pyx @@ -294,7 +294,7 @@ cdef bint bandwidth_C(int n, int k, index_t * left_to_order, # begins with the assigned vertices, ends with the others index_t * index_array_tmp, # tmp space range_t ** ith_range_array, # array of ranges, for every step of the algorithm - range_t * range_array_tmp): # tmp space + range_t * range_array_tmp) noexcept: # tmp space cdef int i, v cdef int pi # the position for which a vertex is being chosen @@ -366,7 +366,7 @@ cdef bint bandwidth_C(int n, int k, # swap back left_to_order[i], left_to_order[current[i]] = left_to_order[current[i]], left_to_order[i] -cdef bint is_matching_feasible(int n, range_t * range_array, range_t * range_array_tmp, index_t * index_array_tmp): +cdef bint is_matching_feasible(int n, range_t * range_array, range_t * range_array_tmp, index_t * index_array_tmp) noexcept: r""" Test if the matching is feasible diff --git a/src/sage/graphs/graph_decompositions/clique_separators.pyx b/src/sage/graphs/graph_decompositions/clique_separators.pyx index b4f92db5172..0989a5a9dae 100644 --- a/src/sage/graphs/graph_decompositions/clique_separators.pyx +++ b/src/sage/graphs/graph_decompositions/clique_separators.pyx @@ -140,7 +140,7 @@ def make_labelled_rooted_tree(atoms, cliques): return to_tree(0, len(cliques)) -cdef inline bint is_clique(short_digraph sd, vector[int] Hx): +cdef inline bint is_clique(short_digraph sd, vector[int] Hx) noexcept: """ Check if the subgraph sd[Hx] is a clique. diff --git a/src/sage/graphs/graph_decompositions/cutwidth.pyx b/src/sage/graphs/graph_decompositions/cutwidth.pyx index ddaf746adac..e4e139084c0 100644 --- a/src/sage/graphs/graph_decompositions/cutwidth.pyx +++ b/src/sage/graphs/graph_decompositions/cutwidth.pyx @@ -530,7 +530,7 @@ def cutwidth_dyn(G, lower_bound=0): sig_free(neighborhoods) -cdef inline int exists(FastDigraph g, uint8_t* neighborhoods, int S, int cost_S, int v, int k): +cdef inline int exists(FastDigraph g, uint8_t* neighborhoods, int S, int cost_S, int v, int k) noexcept: r""" Check whether an ordering with the given cost `k` exists, and updates data in the neighborhoods array at the same time. See the module's documentation. diff --git a/src/sage/graphs/graph_decompositions/fast_digraph.pxd b/src/sage/graphs/graph_decompositions/fast_digraph.pxd index 85466f67ac1..2687f8f974d 100644 --- a/src/sage/graphs/graph_decompositions/fast_digraph.pxd +++ b/src/sage/graphs/graph_decompositions/fast_digraph.pxd @@ -6,7 +6,7 @@ cdef class FastDigraph: cdef list int_to_vertices cdef int * degree -cdef int compute_out_neighborhood_cardinality(FastDigraph, int) +cdef int compute_out_neighborhood_cardinality(FastDigraph, int) noexcept -cdef int popcount32(int) -cdef int slow_popcount32(int) +cdef int popcount32(int) noexcept +cdef int slow_popcount32(int) noexcept diff --git a/src/sage/graphs/graph_decompositions/fast_digraph.pyx b/src/sage/graphs/graph_decompositions/fast_digraph.pyx index 3d7c4b2fea7..2d28ccf4d05 100644 --- a/src/sage/graphs/graph_decompositions/fast_digraph.pyx +++ b/src/sage/graphs/graph_decompositions/fast_digraph.pyx @@ -109,7 +109,7 @@ cdef class FastDigraph: print(((self.graph[i] >> j) & 1), end="") print("") -cdef inline int compute_out_neighborhood_cardinality(FastDigraph g, int S): +cdef inline int compute_out_neighborhood_cardinality(FastDigraph g, int S) noexcept: r""" Return the cardinality of `N^+(S)\S`. @@ -139,7 +139,7 @@ cdef inline int compute_out_neighborhood_cardinality(FastDigraph g, int S): tmp &= (~S) return popcount32(tmp) -cdef inline int popcount32(int i): +cdef inline int popcount32(int i) noexcept: r""" Return the number of '1' bits in a 32-bits integer. @@ -184,7 +184,7 @@ def test_popcount(): i += 1 -cdef inline int slow_popcount32(int i): +cdef inline int slow_popcount32(int i) noexcept: """ Return the number of '1' bits in a 32-bits integer. diff --git a/src/sage/graphs/graph_decompositions/rankwidth.pxd b/src/sage/graphs/graph_decompositions/rankwidth.pxd index d24460b5bb9..a23faceac4f 100644 --- a/src/sage/graphs/graph_decompositions/rankwidth.pxd +++ b/src/sage/graphs/graph_decompositions/rankwidth.pxd @@ -9,4 +9,4 @@ cdef extern from "rw.h": subset_t *cslots subset_t *adjacency_matrix -cdef void print_rank_dec(subset_t s, int l) +cdef void print_rank_dec(subset_t s, int l) noexcept diff --git a/src/sage/graphs/graph_decompositions/rankwidth.pyx b/src/sage/graphs/graph_decompositions/rankwidth.pyx index b08a64b79d3..5be540bafe2 100644 --- a/src/sage/graphs/graph_decompositions/rankwidth.pyx +++ b/src/sage/graphs/graph_decompositions/rankwidth.pyx @@ -200,7 +200,7 @@ def rank_decomposition(G, verbose=False): return (rank_width, g) -cdef int sage_graph_to_matrix(G): +cdef int sage_graph_to_matrix(G) noexcept: r""" Convert the given Sage graph as an adjacency matrix. """ @@ -235,11 +235,11 @@ cdef int sage_graph_to_matrix(G): return 0 -cdef uint_fast32_t bitmask(int i): +cdef uint_fast32_t bitmask(int i) noexcept: return (1ul << i) -cdef void set_am(int i, int j, int val): +cdef void set_am(int i, int j, int val) noexcept: r""" Set/Unset an arc between vertices i and j @@ -255,7 +255,7 @@ cdef void set_am(int i, int j, int val): adjacency_matrix[j] |= bitmask(i) -cdef void print_rank_dec(subset_t s, int l): +cdef void print_rank_dec(subset_t s, int l) noexcept: r""" Print the current rank decomposition as a text @@ -321,7 +321,7 @@ def mkgraph(int num_vertices): return g -cdef bitset_to_vertex_set(subset_t s): +cdef bitset_to_vertex_set(subset_t s) noexcept: """ Return as a Set object the set corresponding to the given subset_t variable. diff --git a/src/sage/graphs/graph_decompositions/tree_decomposition.pxd b/src/sage/graphs/graph_decompositions/tree_decomposition.pxd index e8afe048691..2de876e8889 100644 --- a/src/sage/graphs/graph_decompositions/tree_decomposition.pxd +++ b/src/sage/graphs/graph_decompositions/tree_decomposition.pxd @@ -13,4 +13,4 @@ cdef class TreelengthConnected: cdef GenericGraph_pyx tree # The final tree decomposition is stored cdef unsigned int length cdef bint leq_k - cdef bint _treelength(self, g, k) + cdef bint _treelength(self, g, k) noexcept diff --git a/src/sage/graphs/graph_decompositions/tree_decomposition.pyx b/src/sage/graphs/graph_decompositions/tree_decomposition.pyx index 1e364277c8c..90f14298c5a 100644 --- a/src/sage/graphs/graph_decompositions/tree_decomposition.pyx +++ b/src/sage/graphs/graph_decompositions/tree_decomposition.pyx @@ -1048,7 +1048,7 @@ cdef class TreelengthConnected: sig_free(self.c_distances) sig_free(self.distances) - cdef bint _treelength(self, g, k): + cdef bint _treelength(self, g, k) noexcept: r""" Check whether the treelength of `g` is at most `k`. diff --git a/src/sage/graphs/graph_decompositions/vertex_separation.pxd b/src/sage/graphs/graph_decompositions/vertex_separation.pxd index fa757b2c28e..fbadc893436 100644 --- a/src/sage/graphs/graph_decompositions/vertex_separation.pxd +++ b/src/sage/graphs/graph_decompositions/vertex_separation.pxd @@ -1,4 +1,4 @@ from libc.stdint cimport uint8_t from sage.graphs.graph_decompositions.fast_digraph cimport FastDigraph -cdef list find_order(FastDigraph, uint8_t *, int) +cdef list find_order(FastDigraph, uint8_t *, int) noexcept diff --git a/src/sage/graphs/graph_decompositions/vertex_separation.pyx b/src/sage/graphs/graph_decompositions/vertex_separation.pyx index 90fb086e1ae..548229f303b 100644 --- a/src/sage/graphs/graph_decompositions/vertex_separation.pyx +++ b/src/sage/graphs/graph_decompositions/vertex_separation.pyx @@ -1011,7 +1011,7 @@ def vertex_separation_exp(G, verbose=False): # Actual algorithm, breadth-first search and updates of the costs of the sets # ############################################################################### -cdef inline int exists(FastDigraph g, uint8_t* neighborhoods, int current, int cost): +cdef inline int exists(FastDigraph g, uint8_t* neighborhoods, int current, int cost) noexcept: """ Check whether an ordering with the given cost exists, and updates data in the neighborhoods array at the same time. See the module's documentation. @@ -1053,7 +1053,7 @@ cdef inline int exists(FastDigraph g, uint8_t* neighborhoods, int current, int c return neighborhoods[current] -cdef list find_order(FastDigraph g, uint8_t* neighborhoods, int cost): +cdef list find_order(FastDigraph g, uint8_t* neighborhoods, int cost) noexcept: """ Return the ordering once we are sure it exists """ @@ -1083,14 +1083,14 @@ cdef list find_order(FastDigraph g, uint8_t* neighborhoods, int cost): # Min/Max functions -cdef inline int minimum(int a, int b): +cdef inline int minimum(int a, int b) noexcept: if a < b: return a else: return b -cdef inline int maximum(int a, int b): +cdef inline int maximum(int a, int b) noexcept: if a > b: return a else: @@ -1742,7 +1742,7 @@ def vertex_separation_BAB(G, return (width if width < upper_bound else -1), order -cdef inline _my_invert_positions(int *prefix, int *positions, int pos_a, int pos_b): +cdef inline _my_invert_positions(int *prefix, int *positions, int pos_a, int pos_b) noexcept: """ Permute vertices at positions ``pos_a`` and ``pos_b`` in array ``prefix``, and record the new positions in array ``positions``. @@ -1767,7 +1767,7 @@ cdef int vertex_separation_BAB_C(binary_matrix_t H, set prefix_storage, int max_prefix_length, int max_prefix_number, - bint verbose): + bint verbose) noexcept: r""" Branch and Bound algorithm for the process number and the vertex separation. diff --git a/src/sage/graphs/hyperbolicity.pyx b/src/sage/graphs/hyperbolicity.pyx index 880fccfc8f9..5361ebbff95 100644 --- a/src/sage/graphs/hyperbolicity.pyx +++ b/src/sage/graphs/hyperbolicity.pyx @@ -236,7 +236,7 @@ def _my_subgraph(G, vertices, relabel=False, return_map=False): # Building blocks ###################################################################### -cdef inline int __hyp__(unsigned short** distances, int a, int b, int c, int d): +cdef inline int __hyp__(unsigned short** distances, int a, int b, int c, int d) noexcept: """ Return the hyperbolicity of the given 4-tuple. """ @@ -263,7 +263,7 @@ cdef inline int __hyp__(unsigned short** distances, int a, int b, int c, int d): cdef tuple hyperbolicity_basic_algorithm(int N, unsigned short** distances, - verbose): + verbose) noexcept: """ Return **twice** the hyperbolicity of a graph, and a certificate. @@ -368,7 +368,7 @@ def _greedy_dominating_set(H, verbose=False): cdef inline distances_and_far_apart_pairs(gg, unsigned short* distances, unsigned short* far_apart_pairs, - list int_to_vertex): + list int_to_vertex) noexcept: """ Compute both distances between all pairs and far-apart pairs. @@ -482,7 +482,7 @@ cdef inline pair** sort_pairs(uint32_t N, unsigned short** values, unsigned short** to_include, uint32_t* nb_p, - uint32_t* nb_pairs_of_length): + uint32_t* nb_pairs_of_length) noexcept: """ Return an array of unordered pairs {i,j} in increasing order of values. @@ -583,7 +583,7 @@ cdef tuple hyperbolicity_BCCM(int N, int h_LB, float approximation_factor, float additive_gap, - verbose=False): + verbose=False) noexcept: """ Return the hyperbolicity of a graph. @@ -841,7 +841,7 @@ cdef tuple hyperbolicity_CCL(int N, int h_LB, float approximation_factor, float additive_gap, - verbose=False): + verbose=False) noexcept: """ Return the hyperbolicity of a graph. @@ -1465,7 +1465,7 @@ def hyperbolicity(G, # Distribution of the hyperbolicity of 4-tuples ###################################################################### -cdef dict __hyperbolicity_distribution__(int N, unsigned short** distances): +cdef dict __hyperbolicity_distribution__(int N, unsigned short** distances) noexcept: """ Return the distribution of the hyperbolicity of the 4-tuples of the graph. @@ -1526,7 +1526,7 @@ cdef extern from "stdlib.h": void c_libc_srandom "srandom"(unsigned int seed) -cdef dict __hyperbolicity_sampling__(int N, unsigned short** distances, uint64_t sampling_size): +cdef dict __hyperbolicity_sampling__(int N, unsigned short** distances, uint64_t sampling_size) noexcept: """ Return a sampling of the hyperbolicity distribution of the graph. diff --git a/src/sage/graphs/independent_sets.pyx b/src/sage/graphs/independent_sets.pyx index f1dc1260c34..c5105df067d 100644 --- a/src/sage/graphs/independent_sets.pyx +++ b/src/sage/graphs/independent_sets.pyx @@ -20,7 +20,7 @@ from sage.misc.cachefunc import cached_method from sage.graphs.base.static_dense_graph cimport dense_graph_init -cdef inline int ismaximal(binary_matrix_t g, int n, bitset_t s): +cdef inline int ismaximal(binary_matrix_t g, int n, bitset_t s) noexcept: cdef int i for i in range(n): if (not bitset_in(s, i)) and bitset_are_disjoint(g.rows[i], s): diff --git a/src/sage/graphs/matchpoly.pyx b/src/sage/graphs/matchpoly.pyx index 10c8d524164..7bd14c38bcd 100644 --- a/src/sage/graphs/matchpoly.pyx +++ b/src/sage/graphs/matchpoly.pyx @@ -348,7 +348,7 @@ def complete_poly(n): return b -cdef void delete_and_add(int **edges, int nverts, int nedges, int totverts, int depth, fmpz_poly_t pol): +cdef void delete_and_add(int **edges, int nverts, int nedges, int totverts, int depth, fmpz_poly_t pol) noexcept: """ Add matching polynomial to pol via recursion. diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index 2c3cecfeed5..dc5f9d960bf 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -1738,7 +1738,7 @@ def is_nowhere0_twoweight(int v, int k, int l, int mu): return (Nowhere0WordsTwoWeightCodeGraph, q) -cdef eigenvalues(int v, int k, int l, int mu): +cdef eigenvalues(int v, int k, int l, int mu) noexcept: r""" Return the eigenvalues of a (v,k,l,mu)-strongly regular graph. @@ -1848,7 +1848,7 @@ def eigenmatrix(int v, int k, int l, int mu): return Matrix(ZZ, [[1, k, v-k-1], [1, r, -r-1], [1, s, -s-1]]) -cpdef latin_squares_graph_parameters(int v, int k, int l,int mu): +cpdef latin_squares_graph_parameters(int v, int k, int l,int mu) noexcept: r""" Check whether (v,k,l,mu)-strongly regular graph has parameters of an `L_g(n)` s.r.g. @@ -2690,7 +2690,7 @@ def SRG_1288_792_476_504(): return G -cdef bint seems_feasible(int v, int k, int l, int mu): +cdef bint seems_feasible(int v, int k, int l, int mu) noexcept: r""" Check if the set of parameters seems feasible. @@ -3258,7 +3258,7 @@ def _build_small_srg_database(): _small_srg_database[N, K, l, m] = [strongly_regular_from_two_weight_code, code['M']] -cdef load_brouwer_database(): +cdef load_brouwer_database() noexcept: r""" Loads Andries Brouwer's database into _brouwer_database. """ diff --git a/src/sage/graphs/traversals.pxd b/src/sage/graphs/traversals.pxd index a81c72dcd9d..c9a8444be0c 100644 --- a/src/sage/graphs/traversals.pxd +++ b/src/sage/graphs/traversals.pxd @@ -5,4 +5,4 @@ cdef maximum_cardinality_search_M_short_digraph(short_digraph sd, int* alpha, int* alpha_inv, list F, - bint* X) + bint* X) noexcept diff --git a/src/sage/graphs/traversals.pyx b/src/sage/graphs/traversals.pyx index 8769f14f602..ae8518d3b25 100644 --- a/src/sage/graphs/traversals.pyx +++ b/src/sage/graphs/traversals.pyx @@ -107,7 +107,7 @@ def _is_valid_lex_BFS_order(G, L): return True -cdef lex_BFS_fast_short_digraph(short_digraph sd, uint32_t *sigma, uint32_t *pred): +cdef lex_BFS_fast_short_digraph(short_digraph sd, uint32_t *sigma, uint32_t *pred) noexcept: r""" Perform a lexicographic breadth first search (LexBFS) on the graph. @@ -1735,7 +1735,7 @@ def maximum_cardinality_search(G, reverse=False, tree=False, initial_vertex=None return alpha -cdef inline int swap(int* alpha, int* alpha_inv, int u, int new_pos_u): +cdef inline int swap(int* alpha, int* alpha_inv, int u, int new_pos_u) noexcept: """ Swap positions of u and v in alpha, where v is be the vertex occupying cell new_pos_u in alpha. @@ -1747,7 +1747,7 @@ cdef inline int swap(int* alpha, int* alpha_inv, int u, int new_pos_u): cdef maximum_cardinality_search_M_short_digraph(short_digraph sd, int initial_vertex, - int* alpha, int* alpha_inv, list F, bint* X): + int* alpha, int* alpha_inv, list F, bint* X) noexcept: r""" Compute the ordering and the edges of the triangulation produced by MCS-M. diff --git a/src/sage/graphs/trees.pxd b/src/sage/graphs/trees.pxd index eba4ce1ec1e..f2c81ab49a7 100644 --- a/src/sage/graphs/trees.pxd +++ b/src/sage/graphs/trees.pxd @@ -10,5 +10,5 @@ cdef class TreeIterator: cdef int r cdef int *l cdef int *current_level_sequence - cdef int generate_first_level_sequence(self) - cdef int generate_next_level_sequence(self) + cdef int generate_first_level_sequence(self) noexcept + cdef int generate_next_level_sequence(self) noexcept diff --git a/src/sage/graphs/trees.pyx b/src/sage/graphs/trees.pyx index 8dbf3493435..422fa28baa1 100644 --- a/src/sage/graphs/trees.pyx +++ b/src/sage/graphs/trees.pyx @@ -157,7 +157,7 @@ cdef class TreeIterator: return G - cdef int generate_first_level_sequence(self): + cdef int generate_first_level_sequence(self) noexcept: r""" Generates the level sequence representing the first tree with `n` vertices """ @@ -193,7 +193,7 @@ cdef class TreeIterator: return 0 - cdef int generate_next_level_sequence(self): + cdef int generate_next_level_sequence(self) noexcept: r""" Generates the level sequence representing the next tree with `n` vertices """ diff --git a/src/sage/graphs/weakly_chordal.pyx b/src/sage/graphs/weakly_chordal.pyx index 44c35e39dbe..d1a6b03ae5d 100644 --- a/src/sage/graphs/weakly_chordal.pyx +++ b/src/sage/graphs/weakly_chordal.pyx @@ -43,7 +43,7 @@ from sage.graphs.base.static_sparse_graph cimport free_short_digraph from sage.graphs.base.static_sparse_graph cimport out_degree -cdef inline int has_edge(bitset_t bs, int u, int v, int n): +cdef inline int has_edge(bitset_t bs, int u, int v, int n) noexcept: return bitset_in(bs, u * n + v) @@ -51,7 +51,7 @@ cdef inline is_long_hole_free_process(g, short_digraph sd, bitset_t dense_graph, list id_label, int* path, int* InPath, int* neighbor_index, set VisitedP3, bint certificate, - int a, int b, int c, int n): + int a, int b, int c, int n) noexcept: """ This method is part of method ``is_long_hole_free``. @@ -281,7 +281,7 @@ cdef inline is_long_antihole_free_process(g, short_digraph sd, bitset_t dense_gr list id_label, int* path, int* InPath, int* neighbor_index, set VisitedP3, bint certificate, - int a, int b, int c, int n): + int a, int b, int c, int n) noexcept: """ This method is part of method ``is_long_antihole_free``. diff --git a/src/sage/groups/libgap_wrapper.pxd b/src/sage/groups/libgap_wrapper.pxd index 0c43b098140..25599eea2a8 100644 --- a/src/sage/groups/libgap_wrapper.pxd +++ b/src/sage/groups/libgap_wrapper.pxd @@ -4,5 +4,5 @@ from sage.libs.gap.element cimport GapElement cdef class ElementLibGAP(MultiplicativeGroupElement): cdef GapElement _libgap - cpdef GapElement gap(self) - cpdef _mul_(self, other) + cpdef GapElement gap(self) noexcept + cpdef _mul_(self, other) noexcept diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx index c65afa447e5..edcd50dfa4f 100644 --- a/src/sage/groups/libgap_wrapper.pyx +++ b/src/sage/groups/libgap_wrapper.pyx @@ -485,7 +485,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement): else: raise TypeError('need a libgap group element or "1" in constructor') - cpdef GapElement gap(self): + cpdef GapElement gap(self) noexcept: """ Return a LibGAP representation of the element. @@ -607,7 +607,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement): from sage.misc.latex import latex return latex(self._repr_()) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiplication of group elements @@ -629,7 +629,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement): return P.element_class(P, ( left)._libgap * ( right)._libgap) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ This method implements comparison. @@ -649,7 +649,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement): return richcmp((left)._libgap, (right)._libgap, op) - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ Division of group elements. diff --git a/src/sage/groups/matrix_gps/group_element.pxd b/src/sage/groups/matrix_gps/group_element.pxd index 36a5a9fc4ce..1b32eea3602 100644 --- a/src/sage/groups/matrix_gps/group_element.pxd +++ b/src/sage/groups/matrix_gps/group_element.pxd @@ -1,10 +1,10 @@ from sage.structure.element cimport MultiplicativeGroupElement, Element, MonoidElement, Matrix -cpdef is_MatrixGroupElement(x) +cpdef is_MatrixGroupElement(x) noexcept cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): cdef public Matrix _matrix - cpdef _act_on_(self, x, bint self_on_left) - cpdef _mul_(self, other) - cpdef list list(self) + cpdef _act_on_(self, x, bint self_on_left) noexcept + cpdef _mul_(self, other) noexcept + cpdef list list(self) noexcept diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 2764e33a7a8..d95fa0aa086 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -89,7 +89,7 @@ except ImportError: MatrixGroupElement_gap = () -cpdef is_MatrixGroupElement(x): +cpdef is_MatrixGroupElement(x) noexcept: """ Test whether ``x`` is a matrix group element @@ -222,7 +222,7 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ return self._matrix._latex_() - cpdef _act_on_(self, x, bint self_on_left): + cpdef _act_on_(self, x, bint self_on_left) noexcept: """ EXAMPLES:: @@ -245,7 +245,7 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): except TypeError: return None - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ EXAMPLES:: @@ -266,7 +266,7 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): cdef MatrixGroupElement_generic y = other return richcmp(x._matrix, y._matrix, op) - cpdef list list(self): + cpdef list list(self) noexcept: """ Return list representation of this matrix. @@ -327,7 +327,7 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ return self.matrix() - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Return the product of ``self`` and`` other``, which must have identical parents. diff --git a/src/sage/groups/matrix_gps/group_element_gap.pxd b/src/sage/groups/matrix_gps/group_element_gap.pxd index e0ecbefea5c..2633f21892c 100644 --- a/src/sage/groups/matrix_gps/group_element_gap.pxd +++ b/src/sage/groups/matrix_gps/group_element_gap.pxd @@ -1,5 +1,5 @@ from sage.groups.libgap_wrapper cimport ElementLibGAP cdef class MatrixGroupElement_gap(ElementLibGAP): - cpdef _act_on_(self, x, bint self_on_left) - cpdef list list(self) + cpdef _act_on_(self, x, bint self_on_left) noexcept + cpdef list list(self) noexcept diff --git a/src/sage/groups/matrix_gps/group_element_gap.pyx b/src/sage/groups/matrix_gps/group_element_gap.pyx index b07c0f01a44..7c581377f6f 100644 --- a/src/sage/groups/matrix_gps/group_element_gap.pyx +++ b/src/sage/groups/matrix_gps/group_element_gap.pyx @@ -136,7 +136,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): """ return self.matrix()._latex_() - cpdef _act_on_(self, x, bint self_on_left): + cpdef _act_on_(self, x, bint self_on_left) noexcept: """ EXAMPLES:: @@ -157,7 +157,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): except TypeError: return None - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ EXAMPLES:: @@ -230,7 +230,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): """ return self.matrix() - cpdef list list(self): + cpdef list list(self) noexcept: """ Return list representation of this matrix. diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd index 5fe1ebd140d..f13b0d06bc6 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd @@ -19,9 +19,9 @@ cdef struct aut_gp_and_can_lab: StabilizerChain *group int *relabeling -cdef aut_gp_and_can_lab *allocate_agcl_output(int) +cdef aut_gp_and_can_lab *allocate_agcl_output(int) noexcept -cdef void deallocate_agcl_output(aut_gp_and_can_lab *) +cdef void deallocate_agcl_output(aut_gp_and_can_lab *) noexcept cdef struct agcl_work_space: int degree @@ -39,15 +39,15 @@ cdef struct agcl_work_space: OrbitPartition *orbits_of_permutation # degree n PartitionStack *first_ps # degree n -cdef agcl_work_space *allocate_agcl_work_space(int) +cdef agcl_work_space *allocate_agcl_work_space(int) noexcept -cdef void deallocate_agcl_work_space(agcl_work_space *) +cdef void deallocate_agcl_work_space(agcl_work_space *) noexcept cdef aut_gp_and_can_lab *get_aut_gp_and_can_lab( void *, PartitionStack *, int, - bint (*)(PartitionStack *, void *), - int (*)(PartitionStack *, void *, int *, int), - int (*)(int *, int *, void *, void *, int), bint, StabilizerChain *, + bint (*)(PartitionStack *, void *) noexcept, + int (*)(PartitionStack *, void *, int *, int) noexcept, + int (*)(int *, int *, void *, void *, int), bint, StabilizerChain * noexcept, agcl_work_space *, aut_gp_and_can_lab *) except NULL diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 04d978afef3..920ff69c3df 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -116,7 +116,7 @@ from cysignals.memory cimport sig_malloc, sig_realloc, sig_free from .data_structures cimport * from sage.data_structures.bitset_base cimport * -cdef inline int agcl_cmp(int a, int b): +cdef inline int agcl_cmp(int a, int b) noexcept: if a < b: return -1 elif a == b: @@ -126,13 +126,13 @@ cdef inline int agcl_cmp(int a, int b): # Functions -cdef bint all_children_are_equivalent_trivial(PartitionStack *PS, void *S): +cdef bint all_children_are_equivalent_trivial(PartitionStack *PS, void *S) noexcept: return 0 -cdef int refine_and_return_invariant_trivial(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_and_return_invariant_trivial(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: return 0 -cdef int compare_structures_trivial(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_structures_trivial(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: return 0 def test_get_aut_gp_and_can_lab_trivially(int n=6, @@ -212,7 +212,7 @@ def test_intersect_parabolic_with_alternating(int n=9, list partition=[[0,1,2],[ SC_dealloc(group) deallocate_agcl_output(output) -cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: cdef list MS1 = S1 cdef list MS2 = S2 cdef int i, j @@ -293,7 +293,7 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]): sig_free(c_perm) return label -cdef aut_gp_and_can_lab *allocate_agcl_output(int n): +cdef aut_gp_and_can_lab *allocate_agcl_output(int n) noexcept: r""" Allocate an instance of the aut_gp_and_can_lab struct of degree n. This can be input to the get_aut_gp_and_can_lab function, and the output will be @@ -313,7 +313,7 @@ cdef aut_gp_and_can_lab *allocate_agcl_output(int n): return NULL return output -cdef void deallocate_agcl_output(aut_gp_and_can_lab *output): +cdef void deallocate_agcl_output(aut_gp_and_can_lab *output) noexcept: r""" Deallocates an aut_gp_and_can_lab struct. """ @@ -323,7 +323,7 @@ cdef void deallocate_agcl_output(aut_gp_and_can_lab *output): sig_free(output.generators) sig_free(output) -cdef agcl_work_space *allocate_agcl_work_space(int n): +cdef agcl_work_space *allocate_agcl_work_space(int n) noexcept: r""" Allocates work space for the get_aut_gp_and_can_lab function. It can be input to the function in which case it must be deallocated after the @@ -375,7 +375,7 @@ cdef agcl_work_space *allocate_agcl_work_space(int n): return NULL return work_space -cdef void deallocate_agcl_work_space(agcl_work_space *work_space): +cdef void deallocate_agcl_work_space(agcl_work_space *work_space) noexcept: r""" Deallocate work space for the get_aut_gp_and_can_lab function. """ @@ -397,11 +397,11 @@ cdef void deallocate_agcl_work_space(agcl_work_space *work_space): cdef aut_gp_and_can_lab *get_aut_gp_and_can_lab(void *S, PartitionStack *partition, int n, - bint (*all_children_are_equivalent)(PartitionStack *PS, void *S), + bint (*all_children_are_equivalent)(PartitionStack *PS, void *S) noexcept, int (*refine_and_return_invariant)(PartitionStack *PS, void *S, - int *cells_to_refine_by, int ctrb_len), + int *cells_to_refine_by, int ctrb_len) noexcept, int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, - int degree), + int degree) noexcept, bint canonical_label, StabilizerChain *input_group, agcl_work_space *work_space_prealloc, aut_gp_and_can_lab *output_prealloc) except NULL: """ diff --git a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd index dfcf347df4c..daa7a59b2b6 100644 --- a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd +++ b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd @@ -29,7 +29,7 @@ from .double_coset cimport (double_coset, cdef struct iterator: void *data - void *(*next)(void *data, int *degree, bint *mem_err) + void *(*next)(void *data, int *degree, bint *mem_err) noexcept cdef struct canonical_generator_data: StabilizerChain *group @@ -52,33 +52,33 @@ cdef struct canonical_generator_data: bint dealloc bint pr - bint (*all_children_are_equivalent)(PartitionStack *, void *) - int (*refine_and_return_invariant)(PartitionStack *, void *, int *, int) - int (*compare_structures)(int *, int *, void *, void *, int) + bint (*all_children_are_equivalent)(PartitionStack *, void *) noexcept + int (*refine_and_return_invariant)(PartitionStack *, void *, int *, int) noexcept + int (*compare_structures)(int *, int *, void *, void *, int) noexcept - int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *) - void *(*apply_augmentation)(void *, void *, void *, int *, bint *) - void (*free_object)(void *) - void (* free_iter_data)(void *) - void (*free_aug)(void *) - void *(*canonical_parent)(void *child, void *parent, int *permutation, int *degree, bint *) + int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *) noexcept + void *(*apply_augmentation)(void *, void *, void *, int *, bint *) noexcept + void (*free_object)(void *) noexcept + void (* free_iter_data)(void *) noexcept + void (*free_aug)(void *) noexcept + void *(*canonical_parent)(void *child, void *parent, int *permutation, int *degree, bint *) noexcept -cdef canonical_generator_data *allocate_cgd(int, int) +cdef canonical_generator_data *allocate_cgd(int, int) noexcept -cdef void deallocate_cgd(canonical_generator_data *) +cdef void deallocate_cgd(canonical_generator_data *) noexcept -cdef void *canonical_generator_next(void *, int *, bint *) +cdef void *canonical_generator_next(void *, int *, bint *) noexcept cdef iterator *setup_canonical_generator(int degree, - bint (*all_children_are_equivalent)(PartitionStack *, void *), - int (*refine_and_return_invariant)(PartitionStack *, void *, int *, int), - int (*compare_structures)(int *, int *, void *, void *, int), - int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *), - void *(*apply_augmentation)(void *, void *, void *, int *, bint *), - void (*free_object)(void *), - void (* free_iter_data)(void *), - void (*free_aug)(void *), - void *(*canonical_parent)(void *, void *, int *, int *, bint *), + bint (*all_children_are_equivalent)(PartitionStack *, void *) noexcept, + int (*refine_and_return_invariant)(PartitionStack *, void *, int *, int) noexcept, + int (*compare_structures)(int *, int *, void *, void *, int) noexcept, + int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *) noexcept, + void *(*apply_augmentation)(void *, void *, void *, int *, bint *) noexcept, + void (*free_object)(void *) noexcept, + void (* free_iter_data)(void *) noexcept, + void (*free_aug)(void *) noexcept, + void *(*canonical_parent)(void *, void *, int *, int *, bint *) noexcept, int max_depth, bint reduce_children, iterator *cangen_prealloc) except NULL diff --git a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx index 680dbf5675d..a8a25050413 100644 --- a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx +++ b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx @@ -172,7 +172,7 @@ from cysignals.memory cimport sig_malloc, sig_free from .data_structures cimport* -cdef void *canonical_generator_next(void *can_gen_data, int *degree, bint *mem_err): +cdef void *canonical_generator_next(void *can_gen_data, int *degree, bint *mem_err) noexcept: r""" This function is part of the iterator struct which will iterate over objects. Return value of ``NULL`` indicates termination. @@ -281,7 +281,7 @@ cdef void *canonical_generator_next(void *can_gen_data, int *degree, bint *mem_e cgd.level -= 1 return cgd.object_stack[cgd.level] -cdef canonical_generator_data *allocate_cgd(int max_depth, int degree): +cdef canonical_generator_data *allocate_cgd(int max_depth, int degree) noexcept: r""" Allocate the data part of the canonical generation iterator struct. """ @@ -341,7 +341,7 @@ cdef canonical_generator_data *allocate_cgd(int max_depth, int degree): return cgd -cdef void deallocate_cgd(canonical_generator_data *cgd): +cdef void deallocate_cgd(canonical_generator_data *cgd) noexcept: r""" Deallocate the data part of the canonical generation iterator struct. """ @@ -378,17 +378,17 @@ cdef void deallocate_cgd(canonical_generator_data *cgd): cdef iterator *setup_canonical_generator(int degree, - bint (*all_children_are_equivalent)(PartitionStack *PS, void *S), + bint (*all_children_are_equivalent)(PartitionStack *PS, void *S) noexcept, int (*refine_and_return_invariant)(PartitionStack *PS, void *S, - int *cells_to_refine_by, int ctrb_len), + int *cells_to_refine_by, int ctrb_len) noexcept, int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, - int degree), - int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *), - void *(*apply_augmentation)(void *, void *, void *, int *, bint *), - void (*free_object)(void *), - void (*free_iter_data)(void *), - void (*free_aug)(void *), - void *(*canonical_parent)(void *child, void *parent, int *permutation, int *degree, bint *mem_err), + int degree) noexcept, + int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *) noexcept, + void *(*apply_augmentation)(void *, void *, void *, int *, bint *) noexcept, + void (*free_object)(void *) noexcept, + void (*free_iter_data)(void *) noexcept, + void (*free_aug)(void *) noexcept, + void *(*canonical_parent)(void *child, void *parent, int *permutation, int *degree, bint *mem_err) noexcept, int max_depth, bint reduce_children, iterator *cangen_prealloc) except NULL: """ Canonical generation of isomorphism classes of objects. diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pxd b/src/sage/groups/perm_gps/partn_ref/data_structures.pxd index 8c5ae14b5bb..4c7152e5d6d 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pxd +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pxd @@ -68,11 +68,11 @@ cdef struct StabilizerChain: # OrbitPartition (OP) -cdef OrbitPartition *OP_new(int n) +cdef OrbitPartition *OP_new(int n) noexcept -cdef void OP_dealloc(OrbitPartition *OP) +cdef void OP_dealloc(OrbitPartition *OP) noexcept -cdef inline int OP_copy_from_to(OrbitPartition *OP, OrbitPartition *OP2): +cdef inline int OP_copy_from_to(OrbitPartition *OP, OrbitPartition *OP2) noexcept: """ Copy all data from OP to OP2, we suppose that @@ -81,7 +81,7 @@ cdef inline int OP_copy_from_to(OrbitPartition *OP, OrbitPartition *OP2): """ memcpy(OP2.parent, OP.parent, 4*OP.degree * sizeof(int) ) -cdef inline OrbitPartition *OP_copy(OrbitPartition *OP): +cdef inline OrbitPartition *OP_copy(OrbitPartition *OP) noexcept: """ Allocate and return a pointer to a copy of a OrbitPartition of degree n. @@ -95,9 +95,9 @@ cdef inline OrbitPartition *OP_copy(OrbitPartition *OP): OP_copy_from_to(OP, OP2) return OP2 -cdef OP_string(OrbitPartition *OP) +cdef OP_string(OrbitPartition *OP) noexcept -cdef inline void OP_clear(OrbitPartition *OP): +cdef inline void OP_clear(OrbitPartition *OP) noexcept: cdef int i, n = OP.degree for i from 0 <= i < n: OP.parent[i] = i @@ -105,7 +105,7 @@ cdef inline void OP_clear(OrbitPartition *OP): OP.mcr[i] = i OP.size[i] = 1 -cdef inline int OP_find(OrbitPartition *OP, int n): +cdef inline int OP_find(OrbitPartition *OP, int n) noexcept: """ Report the representative ("root") of the cell which contains n. """ @@ -115,7 +115,7 @@ cdef inline int OP_find(OrbitPartition *OP, int n): OP.parent[n] = OP_find(OP, OP.parent[n]) return OP.parent[n] -cdef inline int OP_join(OrbitPartition *OP, int m, int n): +cdef inline int OP_join(OrbitPartition *OP, int m, int n) noexcept: """ Join the cells containing m and n, if they are different. """ @@ -137,7 +137,7 @@ cdef inline int OP_join(OrbitPartition *OP, int m, int n): if m_root != n_root: OP.num_cells -= 1 -cdef inline int OP_merge_list_perm(OrbitPartition *OP, int *gamma): +cdef inline int OP_merge_list_perm(OrbitPartition *OP, int *gamma) noexcept: """ Joins the cells of OP which intersect the same orbit of gamma. @@ -162,7 +162,7 @@ cdef inline int OP_merge_list_perm(OrbitPartition *OP, int *gamma): # PartitionStack (PS) -cdef inline int PS_copy_from_to(PartitionStack *PS, PartitionStack *PS2): +cdef inline int PS_copy_from_to(PartitionStack *PS, PartitionStack *PS2) noexcept: """ Copy all data from PS to PS2. """ @@ -170,7 +170,7 @@ cdef inline int PS_copy_from_to(PartitionStack *PS, PartitionStack *PS2): PS2.degree = PS.degree memcpy(PS2.entries, PS.entries, 2*PS.degree * sizeof(int) ) -cdef inline bint PS_is_discrete(PartitionStack *PS): +cdef inline bint PS_is_discrete(PartitionStack *PS) noexcept: """ Returns whether the deepest partition consists only of singleton cells. """ @@ -180,7 +180,7 @@ cdef inline bint PS_is_discrete(PartitionStack *PS): return 0 return 1 -cdef inline int PS_num_cells(PartitionStack *PS): +cdef inline int PS_num_cells(PartitionStack *PS) noexcept: """ Returns the number of cells. """ @@ -190,7 +190,7 @@ cdef inline int PS_num_cells(PartitionStack *PS): ncells += 1 return ncells -cdef inline void PS_move_min_to_front(PartitionStack *PS, int start, int end): +cdef inline void PS_move_min_to_front(PartitionStack *PS, int start, int end) noexcept: """ Makes sure that the first element of the segment of entries i with start <= i <= end is minimal. @@ -204,20 +204,20 @@ cdef inline void PS_move_min_to_front(PartitionStack *PS, int start, int end): PS.entries[min_loc] = PS.entries[start] PS.entries[start] = minimum -cdef inline bint PS_is_mcr(PartitionStack *PS, int m): +cdef inline bint PS_is_mcr(PartitionStack *PS, int m) noexcept: """ Returns whether PS.elements[m] (not m!) is the smallest element of its cell. """ return m == 0 or PS.levels[m-1] <= PS.depth -cdef inline bint PS_is_fixed(PartitionStack *PS, int m): +cdef inline bint PS_is_fixed(PartitionStack *PS, int m) noexcept: """ Returns whether PS.elements[m] (not m!) is in a singleton cell, assuming PS_is_mcr(PS, m) is already true. """ return PS.levels[m] <= PS.depth -cdef inline int PS_clear(PartitionStack *PS): +cdef inline int PS_clear(PartitionStack *PS) noexcept: """ Sets the current partition to the first shallower one, i.e. forgets about boundaries between cells that are new to the current level. @@ -230,7 +230,7 @@ cdef inline int PS_clear(PartitionStack *PS): PS_move_min_to_front(PS, cur_start, i) cur_start = i+1 -cdef inline int PS_move_all_mins_to_front(PartitionStack *PS): +cdef inline int PS_move_all_mins_to_front(PartitionStack *PS) noexcept: """ Move minimal cell elements to the front of each cell. """ @@ -240,7 +240,7 @@ cdef inline int PS_move_all_mins_to_front(PartitionStack *PS): PS_move_min_to_front(PS, cur_start, i) cur_start = i+1 -cdef inline int PS_get_perm_from(PartitionStack *PS1, PartitionStack *PS2, int *gamma): +cdef inline int PS_get_perm_from(PartitionStack *PS1, PartitionStack *PS2, int *gamma) noexcept: """ Store the permutation determined by PS2[i] -> PS1[i] for each i, where PS[i] denotes the entry of the ith cell of the discrete partition PS. @@ -249,25 +249,25 @@ cdef inline int PS_get_perm_from(PartitionStack *PS1, PartitionStack *PS2, int * for i from 0 <= i < PS1.degree: gamma[PS2.entries[i]] = PS1.entries[i] -cdef PartitionStack *PS_new(int n, bint unit_partition) +cdef PartitionStack *PS_new(int n, bint unit_partition) noexcept -cdef PartitionStack *PS_copy(PartitionStack *PS) +cdef PartitionStack *PS_copy(PartitionStack *PS) noexcept -cdef void PS_dealloc(PartitionStack *PS) +cdef void PS_dealloc(PartitionStack *PS) noexcept -cdef PS_print(PartitionStack *PS) +cdef PS_print(PartitionStack *PS) noexcept -cdef void PS_unit_partition(PartitionStack *PS) +cdef void PS_unit_partition(PartitionStack *PS) noexcept -cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=?) +cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=?) noexcept -cdef PartitionStack *PS_from_list(list L) +cdef PartitionStack *PS_from_list(list L) noexcept -cdef list PS_singletons(PartitionStack * part) +cdef list PS_singletons(PartitionStack * part) noexcept -cdef int PS_all_new_cells(PartitionStack *PS, bitset_t** nonsingletons_ptr) +cdef int PS_all_new_cells(PartitionStack *PS, bitset_t** nonsingletons_ptr) noexcept -cdef inline bint stacks_are_equivalent(PartitionStack *PS1, PartitionStack *PS2): +cdef inline bint stacks_are_equivalent(PartitionStack *PS1, PartitionStack *PS2) noexcept: cdef int i, j, depth = min(PS1.depth, PS2.depth) for i from 0 <= i < PS1.degree: if PS1.levels[i] == PS2.levels[i]: @@ -277,9 +277,9 @@ cdef inline bint stacks_are_equivalent(PartitionStack *PS1, PartitionStack *PS2) return 0 return 1 -cdef int sort_by_function(PartitionStack *PS, int start, int *degrees) +cdef int sort_by_function(PartitionStack *PS, int start, int *degrees) noexcept -cdef inline int PS_split_point(PartitionStack *PS, int v): +cdef inline int PS_split_point(PartitionStack *PS, int v) noexcept: """ Detaches the point v from the cell it is in, putting the singleton cell of just v in front. Returns the position where v is now located. @@ -312,8 +312,8 @@ cdef inline int PS_split_point(PartitionStack *PS, int v): cdef inline int split_point_and_refine(PartitionStack *PS, int v, void *S, int (*refine_and_return_invariant) - (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len), - int *cells_to_refine_by): + (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept, + int *cells_to_refine_by) noexcept: """ Make the partition stack one longer by copying the last partition in the stack, split off a given point, and refine. Return the invariant given by @@ -337,24 +337,24 @@ cdef inline int split_point_and_refine(PartitionStack *PS, int v, void *S, # StabilizerChain (SC) -cdef StabilizerChain *SC_new(int n, bint init_gens=?) +cdef StabilizerChain *SC_new(int n, bint init_gens=?) noexcept -cdef int SC_realloc_gens(StabilizerChain *SC, int level, int size) +cdef int SC_realloc_gens(StabilizerChain *SC, int level, int size) noexcept -cdef void SC_dealloc(StabilizerChain *SC) +cdef void SC_dealloc(StabilizerChain *SC) noexcept cdef int SC_copy_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, - int level) + int level) noexcept -cdef StabilizerChain *SC_alternating_group(int n) +cdef StabilizerChain *SC_alternating_group(int n) noexcept cdef int SC_insert_and_sift(StabilizerChain *SC, int level, int *pi, - int num_perms, bint sift) + int num_perms, bint sift) noexcept cdef int SC_insert_base_point_nomalloc(StabilizerChain *SC_dest, - StabilizerChain *SC, int level, int p) + StabilizerChain *SC, int level, int p) noexcept -cdef inline int SC_perm_is_identity(int *perm, int degree): +cdef inline int SC_perm_is_identity(int *perm, int degree) noexcept: for i from 0 <= i < degree: if perm[i] != i: break @@ -362,7 +362,7 @@ cdef inline int SC_perm_is_identity(int *perm, int degree): return 1 return 0 -cdef inline void SC_mult_perms(int *out, int *first, int *second, int degree): +cdef inline void SC_mult_perms(int *out, int *first, int *second, int degree) noexcept: """ DON'T DO THIS WITH out == second! """ @@ -370,7 +370,7 @@ cdef inline void SC_mult_perms(int *out, int *first, int *second, int degree): for i from 0 <= i < degree: out[i] = second[first[i]] -cdef inline void SC_invert_perm(int *out, int *input, int degree): +cdef inline void SC_invert_perm(int *out, int *input, int degree) noexcept: """ DON'T DO THIS WITH out == in! """ @@ -378,12 +378,12 @@ cdef inline void SC_invert_perm(int *out, int *input, int degree): for i from 0 <= i < degree: out[input[i]] = i -cdef inline void SC_identify(int *perm, int degree): +cdef inline void SC_identify(int *perm, int degree) noexcept: cdef int i for i from 0 <= i < degree: perm[i] = i -cdef inline void SC_add_base_point(StabilizerChain *SC, int b): +cdef inline void SC_add_base_point(StabilizerChain *SC, int b) noexcept: """ Adds base point b to the end of SC. Assumes b is not already in the base. """ @@ -397,7 +397,7 @@ cdef inline void SC_add_base_point(StabilizerChain *SC, int b): SC.labels[SC.base_size][b] = 0 SC.base_size += 1 -cdef inline int SC_cleanup(StabilizerChain *SC): +cdef inline int SC_cleanup(StabilizerChain *SC) noexcept: """ Remove redundant base elements from SC. @@ -423,7 +423,7 @@ cdef inline int SC_cleanup(StabilizerChain *SC): SC.base_size = new return (old == new) -cdef inline void SC_compose_up_to_base(StabilizerChain *SC, int level, int x, int *perm): +cdef inline void SC_compose_up_to_base(StabilizerChain *SC, int level, int x, int *perm) noexcept: """ Repeatedly compose the given perm by labels on the Schreier tree, starting with x, until the base is reached. The composition is stored to perm. @@ -442,7 +442,7 @@ cdef inline void SC_compose_up_to_base(StabilizerChain *SC, int level, int x, in x = SC.parents[level][x] SC_mult_perms(perm, perm, label, n) -cdef inline void SC_scan(StabilizerChain *SC, int level, int x, int gen_index, int *gen, int sign): +cdef inline void SC_scan(StabilizerChain *SC, int level, int x, int gen_index, int *gen, int sign) noexcept: """ See whether the point x is moved to a point outside the tree by gen, and if so add it to the tree (arc label is gen_inv). @@ -459,7 +459,7 @@ cdef inline void SC_scan(StabilizerChain *SC, int level, int x, int gen_index, i SC.parents[level][y] = x SC.labels[level][y] = sign*(gen_index+1) -cdef inline int SC_insert(StabilizerChain *SC, int level, int *pi, int num_perms): +cdef inline int SC_insert(StabilizerChain *SC, int level, int *pi, int num_perms) noexcept: """ Add permutations in pi to the stabilizer chain. The array pi is a sequence of num_perms permutations, each in list representation, hence pi should be @@ -476,10 +476,10 @@ cdef inline int SC_insert(StabilizerChain *SC, int level, int *pi, int num_perms """ return SC_insert_and_sift(SC, level, pi, num_perms, 1) -cdef inline int SC_update_tree(StabilizerChain *SC, int level, int *pi, int num_perms): +cdef inline int SC_update_tree(StabilizerChain *SC, int level, int *pi, int num_perms) noexcept: return SC_insert_and_sift(SC, level, pi, num_perms, 0) -cdef inline void SC_order(StabilizerChain *SC, int i, mpz_t order): +cdef inline void SC_order(StabilizerChain *SC, int i, mpz_t order) noexcept: """ Gives the order of the stabilizer of base points up to but not including the i-th, storing it to ``order``, which must be already initialized. @@ -491,7 +491,7 @@ cdef inline void SC_order(StabilizerChain *SC, int i, mpz_t order): for k from i <= k < SC.base_size: mpz_mul_si(order, order, SC.orbit_sizes[k]) -cdef inline bint SC_contains(StabilizerChain *SC, int level, int *pi, bint modify): +cdef inline bint SC_contains(StabilizerChain *SC, int level, int *pi, bint modify) noexcept: """ Test whether pi is in the level-th stabilizer. @@ -514,7 +514,7 @@ cdef inline bint SC_contains(StabilizerChain *SC, int level, int *pi, bint modif SC_compose_up_to_base(SC, i, x, perm) return SC_perm_is_identity(perm, n) -cdef inline void SC_random_element(StabilizerChain *SC, int level, int *perm): +cdef inline void SC_random_element(StabilizerChain *SC, int level, int *perm) noexcept: """ Gives a random element of the level-th stabilizer. For a random element of the whole group, set level to 0. Must have level < SC.base_size. @@ -527,10 +527,10 @@ cdef inline void SC_random_element(StabilizerChain *SC, int level, int *perm): cdef int compute_relabeling(StabilizerChain *group, StabilizerChain *scratch_group, - int *permutation, int *relabeling) + int *permutation, int *relabeling) noexcept cdef inline void update_perm_stack(StabilizerChain *group, int level, int point, - int *perm_stack): + int *perm_stack) noexcept: """ Ensure that perm_stack[level] is gamma_0^{-1}...gamma_{level-1}^{-1}, where each gamma_i represents the coset representative at the ith level determined @@ -545,8 +545,8 @@ cdef inline void update_perm_stack(StabilizerChain *group, int level, int point, cdef inline int split_point_and_refine_by_orbits(PartitionStack *PS, int v, void *S, int (*refine_and_return_invariant) - (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len), - int *cells_to_refine_by, StabilizerChain *SC, int *perm_stack): + (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept, + int *cells_to_refine_by, StabilizerChain *SC, int *perm_stack) noexcept: """ """ PS.depth += 1 PS_clear(PS) @@ -555,12 +555,12 @@ cdef inline int split_point_and_refine_by_orbits(PartitionStack *PS, int v, return refine_also_by_orbits(PS, S, refine_and_return_invariant, cells_to_refine_by, 1, SC, perm_stack) cdef int refine_by_orbits(PartitionStack *PS, StabilizerChain *SC, - int *perm_stack, int *cells_to_refine_by, int *ctrb_len) + int *perm_stack, int *cells_to_refine_by, int *ctrb_len) noexcept cdef inline int refine_also_by_orbits(PartitionStack *PS, void *S, int (*refine_and_return_invariant) - (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len), - int *cells_to_refine_by, int ctrb_len, StabilizerChain *SC, int *perm_stack): + (PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept, + int *cells_to_refine_by, int ctrb_len, StabilizerChain *SC, int *perm_stack) noexcept: """ """ cdef int inv inv = refine_by_orbits(PS, SC, perm_stack, cells_to_refine_by, &ctrb_len) diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index 285c1afd1eb..02a74f5c676 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -40,7 +40,7 @@ from sage.arith.misc import is_prime as n_is_prime # OrbitPartition (OP) -cdef inline OrbitPartition *OP_new(int n): +cdef inline OrbitPartition *OP_new(int n) noexcept: """ Allocate and return a pointer to a new OrbitPartition of degree n. Returns a null pointer in the case of an allocation failure. @@ -61,12 +61,12 @@ cdef inline OrbitPartition *OP_new(int n): OP_clear(OP) return OP -cdef inline void OP_dealloc(OrbitPartition *OP): +cdef inline void OP_dealloc(OrbitPartition *OP) noexcept: if OP is not NULL: sig_free(OP.parent) sig_free(OP) -cdef OP_string(OrbitPartition *OP): +cdef OP_string(OrbitPartition *OP) noexcept: """ Return a string representation of the OrbitPartition. """ @@ -179,7 +179,7 @@ def OP_represent(int n, merges, perm): # PartitionStack (PS) -cdef inline PartitionStack *PS_new(int n, bint unit_partition): +cdef inline PartitionStack *PS_new(int n, bint unit_partition) noexcept: """ Allocate and return a pointer to a new PartitionStack of degree n. Returns a null pointer in the case of an allocation failure. @@ -199,7 +199,7 @@ cdef inline PartitionStack *PS_new(int n, bint unit_partition): PS_unit_partition(PS) return PS -cdef void PS_unit_partition(PartitionStack *PS): +cdef void PS_unit_partition(PartitionStack *PS) noexcept: """ Set partition stack to a single partition with a single cell. """ @@ -211,7 +211,7 @@ cdef void PS_unit_partition(PartitionStack *PS): PS.entries[n-1] = n - 1 PS.levels[n-1] = -1 -cdef inline PartitionStack *PS_copy(PartitionStack *PS): +cdef inline PartitionStack *PS_copy(PartitionStack *PS) noexcept: """ Allocate and return a pointer to a copy of PartitionStack PS. Returns a null pointer in the case of an allocation failure. @@ -230,12 +230,12 @@ cdef inline PartitionStack *PS_copy(PartitionStack *PS): PS_copy_from_to(PS, PS2) return PS2 -cdef inline void PS_dealloc(PartitionStack *PS): +cdef inline void PS_dealloc(PartitionStack *PS) noexcept: if PS is not NULL: sig_free(PS.entries) sig_free(PS) -cdef PartitionStack *PS_from_list(list L): +cdef PartitionStack *PS_from_list(list L) noexcept: """ Allocate and return a pointer to a PartitionStack representing L. Returns a null pointer in the case of an allocation failure. @@ -260,7 +260,7 @@ cdef PartitionStack *PS_from_list(list L): PS.degree = n return PS -cdef PS_print(PartitionStack *PS): +cdef PS_print(PartitionStack *PS) noexcept: """ Print a visual representation of PS. """ @@ -268,7 +268,7 @@ cdef PS_print(PartitionStack *PS): for i in range(PS.depth + 1): PS_print_partition(PS, i) -cdef PS_print_partition(PartitionStack *PS, int k): +cdef PS_print_partition(PartitionStack *PS, int k) noexcept: """ Print the partition at depth k. """ @@ -282,7 +282,7 @@ cdef PS_print_partition(PartitionStack *PS, int k): s = s[:-1] + ')' print(s) -cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL): +cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL) noexcept: """ Find the first occurrence of the smallest cell of size greater than one, which is admissible (checked by the function ``test_allowance``). @@ -317,7 +317,7 @@ cdef int PS_first_smallest(PartitionStack *PS, bitset_t b, int *second_pos=NULL) return PS.entries[location] -cdef int PS_all_new_cells(PartitionStack *PS, bitset_t** nonsingletons_ptr): +cdef int PS_all_new_cells(PartitionStack *PS, bitset_t** nonsingletons_ptr) noexcept: """ Suppose a cell ``C`` was split into ``a`` components at ``PS.level``. Set the rows of the matrix ``nonsingletons_ptr`` to the first @@ -381,7 +381,7 @@ cdef int PS_find_element(PartitionStack *PS, bitset_t b, int x) except -1: i += 1 return location -cdef list PS_singletons(PartitionStack * part): +cdef list PS_singletons(PartitionStack * part) noexcept: """ Return the list of all singletons in the PartitionStack. """ @@ -550,7 +550,7 @@ cdef enum: default_num_gens = 8 default_num_bits = 64 -cdef StabilizerChain *SC_new(int n, bint init_gens=True): +cdef StabilizerChain *SC_new(int n, bint init_gens=True) noexcept: """ Allocate and return a pointer to a new StabilizerChain of degree n. Returns a null pointer in the case of an allocation failure. @@ -620,7 +620,7 @@ cdef StabilizerChain *SC_new(int n, bint init_gens=True): return SC -cdef inline int SC_realloc_gens(StabilizerChain *SC, int level, int size): +cdef inline int SC_realloc_gens(StabilizerChain *SC, int level, int size) noexcept: """ Reallocate generator array at level `level` to size `size`. @@ -642,7 +642,7 @@ cdef inline int SC_realloc_gens(StabilizerChain *SC, int level, int size): SC.array_size[level] = size return 0 -cdef inline void SC_dealloc(StabilizerChain *SC): +cdef inline void SC_dealloc(StabilizerChain *SC) noexcept: cdef int i, n if SC is not NULL: n = SC.degree @@ -657,7 +657,7 @@ cdef inline void SC_dealloc(StabilizerChain *SC): OP_dealloc(SC.OP_scratch) sig_free(SC) -cdef StabilizerChain *SC_symmetric_group(int n): +cdef StabilizerChain *SC_symmetric_group(int n) noexcept: """ Returns a stabilizer chain for the symmetric group on {0, 1, ..., n-1}. @@ -698,7 +698,7 @@ cdef StabilizerChain *SC_symmetric_group(int n): memcpy(SC.gen_inverses[i] + n*j, SC.generators[i] + n*j, n * sizeof(int) ) return SC -cdef StabilizerChain *SC_alternating_group(int n): +cdef StabilizerChain *SC_alternating_group(int n) noexcept: """ Returns a stabilizer chain for the alternating group on {0, 1, ..., n-1}. @@ -742,7 +742,7 @@ cdef StabilizerChain *SC_alternating_group(int n): SC_invert_perm(SC.gen_inverses[i] + n*j, SC.generators[i] + n*j, n) return SC -cdef int SC_realloc_bitsets(StabilizerChain *SC, unsigned long size): +cdef int SC_realloc_bitsets(StabilizerChain *SC, unsigned long size) noexcept: """ If size is larger than current allocation, double the size of the bitsets until it is not. @@ -776,7 +776,7 @@ cdef int SC_realloc_bitsets(StabilizerChain *SC, unsigned long size): memset(SC.gen_is_id.bits + (size_old >> index_shift) + 1, 0, (limbs - (size_old >> index_shift) - 1) * sizeof(unsigned long)) return 0 -cdef StabilizerChain *SC_copy(StabilizerChain *SC, int level): +cdef StabilizerChain *SC_copy(StabilizerChain *SC, int level) noexcept: """ Creates a copy of the first `level` levels of SC. Must have 0 < level. @@ -804,7 +804,7 @@ cdef StabilizerChain *SC_copy(StabilizerChain *SC, int level): SC_copy_nomalloc(SCC, SC, level) # no chance for memory error here... return SCC -cdef int SC_copy_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int level): +cdef int SC_copy_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int level) noexcept: cdef int i, n = SC.degree level = min(level, SC.base_size) SC_dest.base_size = level @@ -818,7 +818,7 @@ cdef int SC_copy_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int lev memcpy(SC_dest.gen_inverses[i], SC.gen_inverses[i], SC.num_gens[i]*n * sizeof(int) ) return 0 -cdef SC_print_level(StabilizerChain *SC, int level): +cdef SC_print_level(StabilizerChain *SC, int level) noexcept: cdef int i, j, n = SC.degree if level < SC.base_size: print('/ level {}'.format(level)) @@ -839,7 +839,7 @@ cdef SC_print_level(StabilizerChain *SC, int level): print(r'\ base_size {}'.format(SC.base_size)) -cdef StabilizerChain *SC_new_base(StabilizerChain *SC, int *base, int base_len): +cdef StabilizerChain *SC_new_base(StabilizerChain *SC, int *base, int base_len) noexcept: """ Create a new stabilizer chain whose base starts with the given base, and which represents the same permutation group. Original StabilizerChain is @@ -857,7 +857,7 @@ cdef StabilizerChain *SC_new_base(StabilizerChain *SC, int *base, int base_len): return NULL return NEW -cdef int SC_new_base_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int *base, int base_len): +cdef int SC_new_base_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int *base, int base_len) noexcept: cdef int i SC_dest.base_size = 0 for i in range(base_len): @@ -867,7 +867,7 @@ cdef int SC_new_base_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int return 1 return 0 -cdef int SC_update(StabilizerChain *dest, StabilizerChain *source, int level): +cdef int SC_update(StabilizerChain *dest, StabilizerChain *source, int level) noexcept: cdef mpz_t src_order, dst_order cdef int *perm = dest.perm_scratch mpz_init(src_order) @@ -901,7 +901,7 @@ cdef int SC_update(StabilizerChain *dest, StabilizerChain *source, int level): mpz_clear(dst_order) return 0 -cdef StabilizerChain *SC_insert_base_point(StabilizerChain *SC, int level, int p): +cdef StabilizerChain *SC_insert_base_point(StabilizerChain *SC, int level, int p) noexcept: """ Insert the point ``p`` as a base point on level ``level``. Return a new StabilizerChain with this new base. Original StabilizerChain is unmodified. @@ -928,7 +928,7 @@ cdef StabilizerChain *SC_insert_base_point(StabilizerChain *SC, int level, int p return NULL return NEW -cdef int SC_insert_base_point_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int level, int p): +cdef int SC_insert_base_point_nomalloc(StabilizerChain *SC_dest, StabilizerChain *SC, int level, int p) noexcept: cdef int i, b SC_copy_nomalloc(SC_dest, SC, level) SC_add_base_point(SC_dest, p) @@ -940,7 +940,7 @@ cdef int SC_insert_base_point_nomalloc(StabilizerChain *SC_dest, StabilizerChain return 1 return 0 -cdef int SC_re_tree(StabilizerChain *SC, int level, int *perm, int x): +cdef int SC_re_tree(StabilizerChain *SC, int level, int *perm, int x) noexcept: """ Return values: 0 - No errors. @@ -981,7 +981,7 @@ cdef int SC_re_tree(StabilizerChain *SC, int level, int *perm, int x): i += 1 return 0 -cdef int SC_sift(StabilizerChain *SC, int level, int x, int *gens, int num_gens, int *new_gens): +cdef int SC_sift(StabilizerChain *SC, int level, int x, int *gens, int num_gens, int *new_gens) noexcept: """ Apply Schreier's subgroup lemma[1] as follows. Given a level, a point x, and a generator s, find the coset traversal element r coming from x. @@ -1027,7 +1027,7 @@ cdef int SC_sift(StabilizerChain *SC, int level, int x, int *gens, int num_gens, SC_mult_perms(perm, perm, perm_rep_inv, n) return SC_insert(SC, level+1, new_gens, num_gens) -cdef int SC_insert_and_sift(StabilizerChain *SC, int level, int *pi, int num_perms, bint sift): +cdef int SC_insert_and_sift(StabilizerChain *SC, int level, int *pi, int num_perms, bint sift) noexcept: cdef int i, j, b, n = SC.degree cdef int perm_gen_index if sift: @@ -1134,7 +1134,7 @@ cdef int SC_insert_and_sift(StabilizerChain *SC, int level, int *pi, int num_per section += 1 return 0 -cdef bint SC_is_giant(int n, int num_perms, int *perms, float p, bitset_t support): +cdef bint SC_is_giant(int n, int num_perms, int *perms, float p, bitset_t support) noexcept: """ Test whether the group generated by the input permutations is a giant, i.e., the alternating or symmetric group. @@ -1614,7 +1614,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, # Functions -cdef int sort_by_function(PartitionStack *PS, int start, int *degrees): +cdef int sort_by_function(PartitionStack *PS, int start, int *degrees) noexcept: """ A simple counting sort, given the degrees of vertices to a certain cell. @@ -1658,7 +1658,7 @@ cdef int sort_by_function(PartitionStack *PS, int start, int *degrees): j += 1 return max_location -cdef int refine_by_orbits(PartitionStack *PS, StabilizerChain *SC, int *perm_stack, int *cells_to_refine_by, int *ctrb_len): +cdef int refine_by_orbits(PartitionStack *PS, StabilizerChain *SC, int *perm_stack, int *cells_to_refine_by, int *ctrb_len) noexcept: """ Given a stabilizer chain SC, refine the partition stack PS so that each cell contains elements from at most one orbit, and sort the refined cells by @@ -1699,7 +1699,7 @@ cdef int refine_by_orbits(PartitionStack *PS, StabilizerChain *SC, int *perm_sta return invariant cdef int compute_relabeling(StabilizerChain *group, StabilizerChain *scratch_group, - int *permutation, int *relabeling): + int *permutation, int *relabeling) noexcept: """ Technically, compute the INVERSE of the relabeling """ diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pxd b/src/sage/groups/perm_gps/partn_ref/double_coset.pxd index 7db1b7764c3..1ca972a8e33 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pxd +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pxd @@ -12,7 +12,7 @@ from .data_structures cimport * from sage.data_structures.bitset cimport bitset_t from sage.rings.integer cimport Integer -cdef inline int int_cmp(int a, int b): +cdef inline int int_cmp(int a, int b) noexcept: if a < b: return -1 elif a == b: @@ -33,12 +33,12 @@ cdef struct dc_work_space: bitset_t *bitset_array # (n + 2*len_of_fp_and_mcr + 1) bitset_t's, each of size n OrbitPartition *orbits_of_subgroup # degree n -cdef dc_work_space *allocate_dc_work_space(int) +cdef dc_work_space *allocate_dc_work_space(int) noexcept -cdef void deallocate_dc_work_space(dc_work_space *) +cdef void deallocate_dc_work_space(dc_work_space *) noexcept cdef int double_coset( void *, void *, PartitionStack *, int *, int, - bint (*)(PartitionStack *, void *), - int (*)(PartitionStack *, void *, int *, int), - int (*)(int *, int *, void *, void *, int), + bint (*)(PartitionStack *, void *) noexcept, + int (*)(PartitionStack *, void *, int *, int) noexcept, + int (*)(int *, int *, void *, void *, int) noexcept, StabilizerChain *, dc_work_space *, int *) except -1 diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index e3c7bc75f05..b29abddd20a 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -101,13 +101,13 @@ from sage.data_structures.bitset_base cimport * # Functions -cdef bint all_children_are_equivalent_trivial(PartitionStack *PS, void *S): +cdef bint all_children_are_equivalent_trivial(PartitionStack *PS, void *S) noexcept: return 0 -cdef int refine_and_return_invariant_trivial(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_and_return_invariant_trivial(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: return 0 -cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: cdef list MS1 = S1 cdef list MS2 = S2 cdef int i, j @@ -199,7 +199,7 @@ def coset_eq(list perm1=[0,1,2,3,4,5], list perm2=[1,2,3,4,5,0], list gens=[[1,2 sig_free(isomorphism) return x -cdef dc_work_space *allocate_dc_work_space(int n): +cdef dc_work_space *allocate_dc_work_space(int n) noexcept: r""" Allocates work space for the double_coset function. It can be input to the function in which case it must be deallocated after the @@ -249,7 +249,7 @@ cdef dc_work_space *allocate_dc_work_space(int n): return NULL return work_space -cdef void deallocate_dc_work_space(dc_work_space *work_space): +cdef void deallocate_dc_work_space(dc_work_space *work_space) noexcept: r""" Deallocates work space for the double_coset function. """ @@ -269,11 +269,11 @@ cdef void deallocate_dc_work_space(dc_work_space *work_space): sig_free(work_space) cdef int double_coset(void *S1, void *S2, PartitionStack *partition1, int *ordering2, - int n, bint (*all_children_are_equivalent)(PartitionStack *PS, void *S), + int n, bint (*all_children_are_equivalent)(PartitionStack *PS, void *S) noexcept, int (*refine_and_return_invariant)(PartitionStack *PS, void *S, - int *cells_to_refine_by, int ctrb_len), + int *cells_to_refine_by, int ctrb_len) noexcept, int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, - int degree), + int degree) noexcept, StabilizerChain *input_group, dc_work_space *work_space_prealloc, int *isom) except -1: """ diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd index 005142f8bc7..a06c9fc8532 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd @@ -24,17 +24,17 @@ cdef class BinaryCodeStruct: cdef int *alpha # length nwords + degree cdef int *scratch # length 3*nwords + 3*degree + 2 cdef aut_gp_and_can_lab *output - cdef int (*ith_word)(BinaryCodeStruct self, int, bitset_s *) + cdef int (*ith_word)(BinaryCodeStruct self, int, bitset_s *) noexcept cdef class LinearBinaryCodeStruct(BinaryCodeStruct): cdef bitset_s *basis cdef bitset_s *scratch_bitsets # length 2*dimension + 2 cdef int dimension -cdef int ith_word_linear(BinaryCodeStruct, int, bitset_s *) +cdef int ith_word_linear(BinaryCodeStruct, int, bitset_s *) noexcept cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct): cdef bitset_s *words cdef bitset_s *scratch_bitsets # length 4*nwords + 1 -cdef int ith_word_nonlinear(BinaryCodeStruct, int, bitset_s *) +cdef int ith_word_nonlinear(BinaryCodeStruct, int, bitset_s *) noexcept -cdef int refine_by_bip_degree(PartitionStack *, void *, int *, int) +cdef int refine_by_bip_degree(PartitionStack *, void *, int *, int) noexcept diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx index 06f548f4b7c..6339dbbd2e5 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx @@ -360,7 +360,7 @@ cdef class LinearBinaryCodeStruct(BinaryCodeStruct): if self.output is not NULL: deallocate_agcl_output(self.output) -cdef int ith_word_linear(BinaryCodeStruct self, int i, bitset_s *word): +cdef int ith_word_linear(BinaryCodeStruct self, int i, bitset_s *word) noexcept: cdef LinearBinaryCodeStruct LBCS = self cdef int j bitset_zero(word) @@ -621,12 +621,12 @@ cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct): sig_free(output) return output_py -cdef int ith_word_nonlinear(BinaryCodeStruct self, int i, bitset_s *word): +cdef int ith_word_nonlinear(BinaryCodeStruct self, int i, bitset_s *word) noexcept: cdef NonlinearBinaryCodeStruct NBCS = self bitset_copy(word, &NBCS.words[i]) return 0 -cdef int refine_by_bip_degree(PartitionStack *col_ps, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_by_bip_degree(PartitionStack *col_ps, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: r""" Refines the input partition by checking degrees of vertices to the given cells in the associated bipartite graph (vertices split into columns and @@ -750,7 +750,7 @@ cdef int refine_by_bip_degree(PartitionStack *col_ps, void *S, int *cells_to_ref current_cell_against += 1 return invariant -cdef int compare_linear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_linear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: r""" Compare gamma_1(S1) and gamma_2(S2). @@ -826,7 +826,7 @@ cdef int compare_linear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, in return bitset_check(&basis_2[i], gamma_2[cur_col]) - bitset_check(&basis_1[i], gamma_1[cur_col]) return 0 -cdef int compare_nonlinear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_nonlinear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: r""" Compare gamma_1(S1) and gamma_2(S2). @@ -912,7 +912,7 @@ cdef int compare_nonlinear_codes(int *gamma_1, int *gamma_2, void *S1, void *S2, return 0 -cdef bint all_children_are_equivalent(PartitionStack *col_ps, void *S): +cdef bint all_children_are_equivalent(PartitionStack *col_ps, void *S) noexcept: """ Returns True if any refinement of the current partition results in the same structure. @@ -955,7 +955,7 @@ cdef bint all_children_are_equivalent(PartitionStack *col_ps, void *S): return 1 return 0 -cdef inline int word_degree(PartitionStack *word_ps, BinaryCodeStruct BCS, int entry, int cell_index, PartitionStack *col_ps): +cdef inline int word_degree(PartitionStack *word_ps, BinaryCodeStruct BCS, int entry, int cell_index, PartitionStack *col_ps) noexcept: """ Returns the number of edges from the vertex corresponding to entry to vertices in the cell corresponding to cell_index. @@ -985,7 +985,7 @@ cdef inline int word_degree(PartitionStack *word_ps, BinaryCodeStruct BCS, int e bitset_free(word) return h -cdef inline int col_degree(PartitionStack *col_ps, BinaryCodeStruct BCS, int entry, int cell_index, PartitionStack *word_ps): +cdef inline int col_degree(PartitionStack *col_ps, BinaryCodeStruct BCS, int entry, int cell_index, PartitionStack *word_ps) noexcept: """ Returns the number of edges from the vertex corresponding to entry to vertices in the cell corresponding to cell_index. @@ -1011,7 +1011,7 @@ cdef inline int col_degree(PartitionStack *col_ps, BinaryCodeStruct BCS, int ent bitset_free(word) return degree -cdef inline int sort_by_function_codes(PartitionStack *PS, int start, int *degrees, int *counts, int *output, int count_max): +cdef inline int sort_by_function_codes(PartitionStack *PS, int start, int *degrees, int *counts, int *output, int count_max) noexcept: """ A simple counting sort, given the degrees of vertices to a certain cell. diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index cafe8a26c75..83c91f3296d 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -506,7 +506,7 @@ def search_tree(G_in, partition, lab=True, dig=False, dict_rep=False, certificat else: return tuple(return_tuple) -cdef int refine_by_degree(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_by_degree(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: r""" Refine the input partition by checking degrees of vertices to the given cells. @@ -643,7 +643,7 @@ cdef int refine_by_degree(PartitionStack *PS, void *S, int *cells_to_refine_by, else: return 0 -cdef int compare_graphs(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_graphs(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: r""" Compare gamma_1(S1) and gamma_2(S2). @@ -674,7 +674,7 @@ cdef int compare_graphs(int *gamma_1, int *gamma_2, void *S1, void *S2, int degr return -1 return 0 -cdef bint all_children_are_equivalent(PartitionStack *PS, void *S): +cdef bint all_children_are_equivalent(PartitionStack *PS, void *S) noexcept: """ Return True if every refinement of the current partition results in the same structure. @@ -712,7 +712,7 @@ cdef bint all_children_are_equivalent(PartitionStack *PS, void *S): return 1 return 0 -cdef inline int degree(PartitionStack *PS, CGraph G, int entry, int cell_index, bint reverse): +cdef inline int degree(PartitionStack *PS, CGraph G, int entry, int cell_index, bint reverse) noexcept: """ Return the number of edges from the vertex corresponding to entry to vertices in the cell corresponding to cell_index. @@ -1065,7 +1065,7 @@ from cpython.ref cimport * # * Seed objects are graphs with n vertices and no edges. # * Augmentations consist of adding a single edge, or a loop. -cdef void *dg_edge_gen_next(void *data, int *degree, bint *mem_err): +cdef void *dg_edge_gen_next(void *data, int *degree, bint *mem_err) noexcept: r""" The ``next`` function in an edge iterator. The iterator generates unique representatives under the action of the automorphism group of the parent @@ -1099,7 +1099,7 @@ cdef void *dg_edge_gen_next(void *data, int *degree, bint *mem_err): mem_err[0] = 1 return edge_candidate -cdef void *allocate_degd(int degree): +cdef void *allocate_degd(int degree) noexcept: r""" Allocate the data part of the iterator over edges to add to the graph. """ @@ -1116,7 +1116,7 @@ cdef void *allocate_degd(int degree): degd.edge_iterator = edge_iterator return degd -cdef void deallocate_degd(void *data): +cdef void deallocate_degd(void *data) noexcept: r""" Deallocate the data part of the iterator over edges to add to the graph. """ @@ -1124,7 +1124,7 @@ cdef void deallocate_degd(void *data): free_subset_gen(degd.edge_iterator) sig_free(degd) -cdef int gen_children_dg_edge(void *S, aut_gp_and_can_lab *group, iterator *it): +cdef int gen_children_dg_edge(void *S, aut_gp_and_can_lab *group, iterator *it) noexcept: r""" Setup an iterator over edges to be added. """ @@ -1136,7 +1136,7 @@ cdef int gen_children_dg_edge(void *S, aut_gp_and_can_lab *group, iterator *it): start_canonical_generator(group.group, NULL, n, edge_iterator) return (edge_iterator is NULL) -cdef void *apply_dg_edge_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err): +cdef void *apply_dg_edge_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err) noexcept: r""" Apply the augmentation to ``parent`` storing the result in ``child``. Here ``aug`` represents an edge to be added. @@ -1161,7 +1161,7 @@ cdef void *apply_dg_edge_aug(void *parent, void *aug, void *child, int *degree, degree[0] = DG.num_verts return GS_child -cdef void *allocate_dg_edge(int n, bint loops): +cdef void *allocate_dg_edge(int n, bint loops) noexcept: r""" Allocates an object for this augmentation scheme. """ @@ -1185,7 +1185,7 @@ cdef void *allocate_dg_edge(int n, bint loops): GS.scratch = scratch return GS -cdef void free_dg_edge(void *child): +cdef void free_dg_edge(void *child) noexcept: r""" Deallocates an object for this augmentation scheme. """ @@ -1194,7 +1194,7 @@ cdef void free_dg_edge(void *child): Py_DECREF(GS.G) Py_DECREF(GS) -cdef void *canonical_dg_edge_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err): +cdef void *canonical_dg_edge_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err) noexcept: r""" Applies ``permutation`` to ``child``, determines an arbitrary parent by deleting the lexicographically largest edge, applies the inverse of @@ -1224,7 +1224,7 @@ cdef void *canonical_dg_edge_parent(void *child, void *parent, int *permutation, degree[0] = n return GS_par -cdef iterator *allocate_dg_edge_gen(int degree, int depth, bint loops): +cdef iterator *allocate_dg_edge_gen(int degree, int depth, bint loops) noexcept: r""" Allocates the iterator for generating graphs. """ @@ -1254,7 +1254,7 @@ cdef iterator *allocate_dg_edge_gen(int degree, int depth, bint loops): dg_edge_gen.next = canonical_generator_next return dg_edge_gen -cdef void free_dg_edge_gen(iterator *dg_edge_gen): +cdef void free_dg_edge_gen(iterator *dg_edge_gen) noexcept: r""" Deallocates the iterator for generating graphs. """ @@ -1394,7 +1394,7 @@ def generate_dense_graphs_edge_addition(int n, bint loops, G=None, depth=None, # * Augmentations consist of adding a single vertex connected to some subset of # the previous vertices. -cdef int gen_children_dg_vert(void *S, aut_gp_and_can_lab *group, iterator *it): +cdef int gen_children_dg_vert(void *S, aut_gp_and_can_lab *group, iterator *it) noexcept: r""" Setup an iterator over subsets to join a new vertex to. """ @@ -1405,7 +1405,7 @@ cdef int gen_children_dg_vert(void *S, aut_gp_and_can_lab *group, iterator *it): start_canonical_generator(group.group, NULL, n, subset_iterator) return (subset_iterator is NULL) -cdef void *apply_dg_vert_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err): +cdef void *apply_dg_vert_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err) noexcept: r""" Apply the augmentation to ``parent`` storing the result in ``child``. Here ``aug`` represents a subset to join to a new vertex. @@ -1429,7 +1429,7 @@ cdef void *apply_dg_vert_aug(void *parent, void *aug, void *child, int *degree, degree[0] = n+1 return GS_child -cdef void *allocate_dg_vert(int n, int depth): +cdef void *allocate_dg_vert(int n, int depth) noexcept: r""" Allocates an object for this augmentation scheme. """ @@ -1455,7 +1455,7 @@ cdef void *allocate_dg_vert(int n, int depth): GS.scratch = scratch return GS -cdef void free_dg_vert(void *child): +cdef void free_dg_vert(void *child) noexcept: r""" Deallocates an object for this augmentation scheme. """ @@ -1464,7 +1464,7 @@ cdef void free_dg_vert(void *child): Py_DECREF(GS.G) Py_DECREF(GS) -cdef void *canonical_dg_vert_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err): +cdef void *canonical_dg_vert_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err) noexcept: r""" Applies ``permutation`` to ``child``, determines an arbitrary parent by deleting the lexicographically largest vertex, applies the inverse of @@ -1486,7 +1486,7 @@ cdef void *canonical_dg_vert_parent(void *child, void *parent, int *permutation, degree[0] = n return GS_par -cdef iterator *allocate_dg_vert_gen(int degree, int depth): +cdef iterator *allocate_dg_vert_gen(int degree, int depth) noexcept: r""" Allocates the iterator for generating graphs. """ @@ -1527,7 +1527,7 @@ cdef iterator *allocate_dg_vert_gen(int degree, int depth): dg_vert_gen.next = canonical_generator_next return dg_vert_gen -cdef void free_dg_vert_gen(iterator *dg_vert_gen): +cdef void free_dg_vert_gen(iterator *dg_vert_gen) noexcept: r""" Deallocates the iterator for generating graphs. """ @@ -1535,7 +1535,7 @@ cdef void free_dg_vert_gen(iterator *dg_vert_gen): deallocate_cgd(cgd) sig_free(dg_vert_gen) -cdef void free_cgd_2(void *data): +cdef void free_cgd_2(void *data) noexcept: r""" A simpler alternative to ``free_cgd``. """ diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd index 898dfa97528..faabab4024e 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd @@ -13,6 +13,6 @@ from .data_structures cimport * # name of the three functions to customize -cdef int refine_list(PartitionStack *, void *, int *, int) -cdef int compare_lists(int *, int *, void *, void *, int) -cdef bint all_list_children_are_equivalent(PartitionStack *, void *) +cdef int refine_list(PartitionStack *, void *, int *, int) noexcept +cdef int compare_lists(int *, int *, void *, void *, int) noexcept +cdef bint all_list_children_are_equivalent(PartitionStack *, void *) noexcept diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx index 5942edd5438..462f96bef00 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx @@ -62,13 +62,13 @@ def is_isomorphic(self, other): sig_free(output) return output_py -cdef bint all_list_children_are_equivalent(PartitionStack *PS, void *S): +cdef bint all_list_children_are_equivalent(PartitionStack *PS, void *S) noexcept: return 0 -cdef int refine_list(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_list(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: return 0 -cdef int compare_lists(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_lists(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: r""" Compare two lists according to the lexicographic order. """ diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd index 0273291f014..7799111e457 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd @@ -25,7 +25,7 @@ cdef class MatrixStruct: cdef PartitionStack *temp_col_ps cdef aut_gp_and_can_lab *output -cdef int refine_matrix(PartitionStack *, void *, int *, int) -cdef int compare_matrices(int *, int *, void *, void *, int) -cdef bint all_matrix_children_are_equivalent(PartitionStack *, void *) +cdef int refine_matrix(PartitionStack *, void *, int *, int) noexcept +cdef int compare_matrices(int *, int *, void *, void *, int) noexcept +cdef bint all_matrix_children_are_equivalent(PartitionStack *, void *) noexcept diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx index e2388616a34..4d55e2a09a2 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx @@ -269,7 +269,7 @@ cdef class MatrixStruct: sig_free(output) return output_py -cdef int refine_matrix(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_matrix(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: cdef MatrixStruct M = S cdef int temp_inv, invariant = 1 cdef bint changed = 1 @@ -282,7 +282,7 @@ cdef int refine_matrix(PartitionStack *PS, void *S, int *cells_to_refine_by, int changed = 0 return invariant -cdef int compare_matrices(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_matrices(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: cdef MatrixStruct MS1 = S1 cdef MatrixStruct MS2 = S2 M1 = MS1.matrix @@ -299,7 +299,7 @@ cdef int compare_matrices(int *gamma_1, int *gamma_2, void *S1, void *S2, int de return 0 return -1 if rows1 < rows2 else 1 -cdef bint all_matrix_children_are_equivalent(PartitionStack *PS, void *S): +cdef bint all_matrix_children_are_equivalent(PartitionStack *PS, void *S) noexcept: return 0 def random_tests(n=10, nrows_max=50, ncols_max=50, nsymbols_max=10, perms_per_matrix=5, density_range=(.1,.9)): diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx index 4d53f3a0332..0a7de54bc4f 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx @@ -388,7 +388,7 @@ class PythonObjectWrapper: self.rari_fn = rari_fn self.cs_fn = cs_fn -cdef bint all_children_are_equivalent_python(PartitionStack *PS, void *S): +cdef bint all_children_are_equivalent_python(PartitionStack *PS, void *S) noexcept: """ Python conversion of all_children_are_equivalent function. """ @@ -397,7 +397,7 @@ cdef bint all_children_are_equivalent_python(PartitionStack *PS, void *S): PS_copy_from_to(PS, Py_PS.c_ps) return S_obj.acae_fn(Py_PS, S_obj.obj) -cdef int refine_and_return_invariant_python(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_and_return_invariant_python(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: """ Python conversion of refine_and_return_invariant function. """ @@ -408,7 +408,7 @@ cdef int refine_and_return_invariant_python(PartitionStack *PS, void *S, int *ce cdef list ctrb_py = [cells_to_refine_by[i] for i from 0 <= i < ctrb_len] return S_obj.rari_fn(Py_PS, S_obj.obj, ctrb_py) -cdef int compare_structures_python(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_structures_python(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: """ Python conversion of compare_structures function. """ diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd index 19f60c7f153..9a1d0da4bf2 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd @@ -32,29 +32,29 @@ cdef struct subset: bitset_s bits int *scratch # must be of size 3*n + 1 -cdef int refine_set(PartitionStack *, void *, int *, int) -cdef int compare_sets(int *, int *, void *, void *, int) -cdef bint all_set_children_are_equivalent(PartitionStack *, void *) +cdef int refine_set(PartitionStack *, void *, int *, int) noexcept +cdef int compare_sets(int *, int *, void *, void *, int) noexcept +cdef bint all_set_children_are_equivalent(PartitionStack *, void *) noexcept -cdef void *allocate_subset(int) +cdef void *allocate_subset(int) noexcept cdef struct subset_generator_data: OrbitPartition *orbits int cur_point bitset_s bits -cdef void *allocate_sgd(int) -cdef void deallocate_sgd(void *) +cdef void *allocate_sgd(int) noexcept +cdef void deallocate_sgd(void *) noexcept -cdef void *subset_generator_next(void *, int *, bint *) +cdef void *subset_generator_next(void *, int *, bint *) noexcept -cdef int generate_child_subsets(void *S, aut_gp_and_can_lab *group, iterator *it) -cdef void *apply_subset_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err) -cdef void free_subset(void *child) -cdef void free_subset_aug(void *) -cdef void *canonical_set_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err) +cdef int generate_child_subsets(void *S, aut_gp_and_can_lab *group, iterator *it) noexcept +cdef void *apply_subset_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err) noexcept +cdef void free_subset(void *child) noexcept +cdef void free_subset_aug(void *) noexcept +cdef void *canonical_set_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err) noexcept -cdef iterator *allocate_subset_gen(int degree, int max_size) -cdef int allocate_subset_gen_2(int degree, int max_size, iterator *it) -cdef void free_subset_gen(iterator *subset_gen) -cdef iterator *setup_set_gen(iterator *subset_gen, int degree, int max_size) +cdef iterator *allocate_subset_gen(int degree, int max_size) noexcept +cdef int allocate_subset_gen_2(int degree, int max_size, iterator *it) noexcept +cdef void free_subset_gen(iterator *subset_gen) noexcept +cdef iterator *setup_set_gen(iterator *subset_gen, int degree, int max_size) noexcept diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx index 7affe0cd965..cf8dd1b8c40 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx @@ -181,7 +181,7 @@ def set_stab_py(generators, sett, relab=False): return stab_gens, relabeling return stab_gens -cdef aut_gp_and_can_lab *set_stab(StabilizerChain *supergroup, subset *sett, bint relab): +cdef aut_gp_and_can_lab *set_stab(StabilizerChain *supergroup, subset *sett, bint relab) noexcept: r""" Computes the set stabilizer of ``sett`` within ``supergroup``. (Note that ``set`` is a reserved Python keyword.) If ``relab`` is specified then @@ -439,10 +439,10 @@ cdef int sets_isom(StabilizerChain *supergroup, subset *set1, subset *set2, int PS_dealloc(part) return x -cdef bint all_set_children_are_equivalent(PartitionStack *PS, void *S): +cdef bint all_set_children_are_equivalent(PartitionStack *PS, void *S) noexcept: return 0 -cdef int refine_set(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len): +cdef int refine_set(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept: """ Given a set S, refine the partition stack PS so that each cell contains elements which are all either in the set or not in the set. If the depth is @@ -466,10 +466,10 @@ cdef int refine_set(PartitionStack *PS, void *S, int *cells_to_refine_by, int ct start += i + 1 return 0 -cdef inline int _bint_cmp(bint a, bint b): +cdef inline int _bint_cmp(bint a, bint b) noexcept: return ( b) - ( a) -cdef int compare_sets(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree): +cdef int compare_sets(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept: r""" Compare two sets according to the lexicographic order. """ @@ -484,7 +484,7 @@ cdef int compare_sets(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree return j return 0 -cdef void *allocate_subset(int n): +cdef void *allocate_subset(int n) noexcept: r""" Allocates a subset struct of degree n. """ @@ -503,7 +503,7 @@ cdef void *allocate_subset(int n): set1.scratch = scratch return set1 -cdef void free_subset(void *child): +cdef void free_subset(void *child) noexcept: r""" Deallocates a subset struct. """ @@ -513,7 +513,7 @@ cdef void free_subset(void *child): bitset_free(&set1.bits) sig_free(set1) -cdef void *allocate_sgd(int degree): +cdef void *allocate_sgd(int degree) noexcept: r""" Allocates the data part of an iterator which generates augmentations, i.e., elements to add to the set. @@ -525,7 +525,7 @@ cdef void *allocate_sgd(int degree): return NULL return sgd -cdef void deallocate_sgd(void *data): +cdef void deallocate_sgd(void *data) noexcept: r""" Deallocates the data part of the augmentation iterator. """ @@ -534,7 +534,7 @@ cdef void deallocate_sgd(void *data): OP_dealloc(sgd.orbits) sig_free(sgd) -cdef void *subset_generator_next(void *data, int *degree, bint *mem_err): +cdef void *subset_generator_next(void *data, int *degree, bint *mem_err) noexcept: r""" Returns the next element to consider adding to the set. """ @@ -550,7 +550,7 @@ cdef void *subset_generator_next(void *data, int *degree, bint *mem_err): return NULL return &sgd.cur_point -cdef int generate_child_subsets(void *S, aut_gp_and_can_lab *group, iterator *child_iterator): +cdef int generate_child_subsets(void *S, aut_gp_and_can_lab *group, iterator *child_iterator) noexcept: r""" Sets up an iterator of augmentations, i.e., elements to add to the given set. """ @@ -570,7 +570,7 @@ cdef int generate_child_subsets(void *S, aut_gp_and_can_lab *group, iterator *ch sgd.bits = subset1.bits return 0 -cdef void *apply_subset_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err): +cdef void *apply_subset_aug(void *parent, void *aug, void *child, int *degree, bint *mem_err) noexcept: r""" Adds the element represented by ``aug`` to ``parent``, storing the result to ``child``. @@ -584,10 +584,10 @@ cdef void *apply_subset_aug(void *parent, void *aug, void *child, int *degree, b degree[0] = n return set1 -cdef void free_subset_aug(void *aug): +cdef void free_subset_aug(void *aug) noexcept: return -cdef void *canonical_set_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err): +cdef void *canonical_set_parent(void *child, void *parent, int *permutation, int *degree, bint *mem_err) noexcept: r""" Determines the canonical parent of the set ``child`` by applying ``permutation``, deleting the largest element in lexicographic order, and @@ -617,7 +617,7 @@ cdef void *canonical_set_parent(void *child, void *parent, int *permutation, int degree[0] = n return par -cdef iterator *allocate_subset_gen(int degree, int max_size): +cdef iterator *allocate_subset_gen(int degree, int max_size) noexcept: r""" Allocates the generator of subsets. """ @@ -628,7 +628,7 @@ cdef iterator *allocate_subset_gen(int degree, int max_size): subset_gen = NULL return subset_gen -cdef int allocate_subset_gen_2(int degree, int max_size, iterator *it): +cdef int allocate_subset_gen_2(int degree, int max_size, iterator *it) noexcept: r""" Given an already allocated iterator, allocates the generator of subsets. """ @@ -654,7 +654,7 @@ cdef int allocate_subset_gen_2(int degree, int max_size, iterator *it): it.next = canonical_generator_next return 0 -cdef void free_subset_gen(iterator *subset_gen): +cdef void free_subset_gen(iterator *subset_gen) noexcept: r""" Frees the iterator of subsets. """ @@ -664,7 +664,7 @@ cdef void free_subset_gen(iterator *subset_gen): deallocate_cgd(cgd) sig_free(subset_gen) -cdef iterator *setup_set_gen(iterator *subset_gen, int degree, int max_size): +cdef iterator *setup_set_gen(iterator *subset_gen, int degree, int max_size) noexcept: r""" Initiates the iterator of subsets. """ diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd index df300e4e0ce..cf964bfd17c 100644 --- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd +++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd @@ -23,13 +23,13 @@ cdef extern from *: cdef tuple PS_refinement(PartitionStack * part, long *refine_vals, long *best, int begin, int end, - bint * cand_initialized, bint *changed_partition) + bint * cand_initialized, bint *changed_partition) noexcept cdef class _BestValStore: cdef int default_data_length cdef int storage_length cdef long *values - cdef long * get_row(self, int i) + cdef long * get_row(self, int i) noexcept cdef class LabelledBranching: cdef int n @@ -38,8 +38,8 @@ cdef class LabelledBranching: cdef int *act_perm cdef GapElement group, ClosureGroup cdef Parent sym_gp - cdef bint has_empty_intersection(self, PartitionStack * part) - cpdef add_gen(self, GapElement_Permutation gen) + cdef bint has_empty_intersection(self, PartitionStack * part) noexcept + cpdef add_gen(self, GapElement_Permutation gen) noexcept cdef class PartitionRefinement_generic: cdef PartitionStack * _part @@ -57,33 +57,33 @@ cdef class PartitionRefinement_generic: # the following allow us to debug the program via latex cdef object _latex_debug_string - cdef void _init_latex(self) - cdef void _finish_latex(self) - cdef void _latex_new_lvl(self) - cdef void _latex_finish_lvl(self) + cdef void _init_latex(self) noexcept + cdef void _finish_latex(self) noexcept + cdef void _latex_new_lvl(self) noexcept + cdef void _latex_finish_lvl(self) noexcept # methods which have to be implemented in derived classes - cdef bint _inner_min_(self, int pos, bint* inner_group_changed) - cdef bint _refine(self, bint *part_changed, bint inner_group_changed, bint first_step) - cdef tuple _store_state_(self) - cdef void _restore_state_(self, tuple act_state) - cdef void _store_best_(self) - cdef bint _minimization_allowed_on_col(self, int pos) - cdef void _latex_act_node(self, str comment=*, int printlvl=*) # only if you want to allow + cdef bint _inner_min_(self, int pos, bint* inner_group_changed) noexcept + cdef bint _refine(self, bint *part_changed, bint inner_group_changed, bint first_step) noexcept + cdef tuple _store_state_(self) noexcept + cdef void _restore_state_(self, tuple act_state) noexcept + cdef void _store_best_(self) noexcept + cdef bint _minimization_allowed_on_col(self, int pos) noexcept + cdef void _latex_act_node(self, str comment=*, int printlvl=*) noexcept # only if you want to allow # some debugging output # methods used in the main algorithm - cdef void _init_partition_stack(self, list partition) - cdef void _start_Sn_backtrack(self) - cdef void _backtrack(self, bint first_step=?) - cdef void _leaf_computations(self) - cdef bint _cut_by_known_automs(self) - cdef bint _inner_min_unminimized(self, bint *inner_group_changed) + cdef void _init_partition_stack(self, list partition) noexcept + cdef void _start_Sn_backtrack(self) noexcept + cdef void _backtrack(self, bint first_step=?) noexcept + cdef void _leaf_computations(self) noexcept + cdef bint _cut_by_known_automs(self) noexcept + cdef bint _inner_min_unminimized(self, bint *inner_group_changed) noexcept cdef bint _one_refinement(self, long *best, int begin, int end, bint* inner_group_changed, bint* changed_partition, - str refine_name) - cdef int len(self) + str refine_name) noexcept + cdef int len(self) noexcept cdef int PS_first_smallest_PR(PartitionStack *PS, bitset_t b, int *second_pos=?, - PartitionRefinement_generic partn_ref_alg=?) + PartitionRefinement_generic partn_ref_alg=?) noexcept 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 6e4e2b27eeb..4a723873ae7 100644 --- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx +++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx @@ -191,7 +191,7 @@ from sage.data_structures.bitset_base cimport * cdef tuple PS_refinement(PartitionStack * part, long *refine_vals, long *best, int begin, int end, - bint * cand_initialized, bint *changed_partition): + bint * cand_initialized, bint *changed_partition) noexcept: """ Refine the partition stack by the values given by ``refine_vals``. We also compare our actual refinement result with the vector ``best`` in the @@ -281,7 +281,7 @@ cdef class _BestValStore: """ sig_free(self.values) - cdef long * get_row(self, int i): + cdef long * get_row(self, int i) noexcept: r""" Return the i-th row. @@ -356,7 +356,7 @@ cdef class LabelledBranching: sig_free(self.father) sig_free(self.act_perm) - cpdef add_gen(self, GapElement_Permutation gen): + cpdef add_gen(self, GapElement_Permutation gen) noexcept: r""" Add a further generator to the group and update the complete labeled branching. @@ -390,7 +390,7 @@ cdef class LabelledBranching: if libgap.IsTrivial(h).sage(): break - cdef bint has_empty_intersection(self, PartitionStack * part): + cdef bint has_empty_intersection(self, PartitionStack * part) noexcept: r""" Pruning by automorphisms. @@ -493,7 +493,7 @@ cdef class PartitionRefinement_generic: ##################################################################### # The following functions have to be implemented by derived classes ##################################################################### - cdef bint _inner_min_(self, int pos, bint * inner_group_changed): + cdef bint _inner_min_(self, int pos, bint * inner_group_changed) noexcept: """ Minimize the node by the action of the inner group on the i-th position. @@ -509,7 +509,7 @@ cdef class PartitionRefinement_generic: """ raise NotImplementedError - cdef bint _refine(self, bint *part_changed, bint inner_group_changed, bint first_step): + cdef bint _refine(self, bint *part_changed, bint inner_group_changed, bint first_step) noexcept: r""" Refine the partition ``self._part``. @@ -524,26 +524,26 @@ cdef class PartitionRefinement_generic: """ raise NotImplementedError - cdef tuple _store_state_(self): + cdef tuple _store_state_(self) noexcept: r""" Store the current state of the node to a tuple, such that it can be restored by :meth:`_restore_state_`. """ raise NotImplementedError - cdef void _restore_state_(self, tuple act_state): + cdef void _restore_state_(self, tuple act_state) noexcept: r""" The inverse of :meth:`_store_state_`. """ raise NotImplementedError - cdef void _store_best_(self): + cdef void _store_best_(self) noexcept: r""" Store this leaf node as the actual best candidate for the canonical form. """ raise NotImplementedError - cdef bint _minimization_allowed_on_col(self, int pos): + cdef bint _minimization_allowed_on_col(self, int pos) noexcept: r""" Decide if we are allowed to perform the inner minimization on position ``pos`` which is supposed to be a singleton. @@ -611,7 +611,7 @@ cdef class PartitionRefinement_generic: ############################################### # THE BACKTRACK ALGORITHM: ############################################### - cdef void _init_partition_stack(self, list partition): + cdef void _init_partition_stack(self, list partition) noexcept: r""" Initialize the partition stack. @@ -631,7 +631,7 @@ cdef class PartitionRefinement_generic: sig_free(self._refine_vals_scratch) raise MemoryError('initializing the partition stack') - cdef void _start_Sn_backtrack(self): + cdef void _start_Sn_backtrack(self) noexcept: r""" Start the partition refinement algorithm. """ @@ -639,7 +639,7 @@ cdef class PartitionRefinement_generic: self._backtrack(True) self._finish_latex() - cdef void _backtrack(self, bint first_step=False): + cdef void _backtrack(self, bint first_step=False) noexcept: r""" Backtracking with pruning. @@ -718,7 +718,7 @@ cdef class PartitionRefinement_generic: bitset_free(b) self._latex_finish_lvl() - cdef bint _inner_min_unminimized(self, bint *inner_group_changed): + cdef bint _inner_min_unminimized(self, bint *inner_group_changed) noexcept: r""" Compute a subsequence `J = (j_0, \ldots, j_{l-1})` of fixed coordinates, which were not yet used in @@ -785,7 +785,7 @@ cdef class PartitionRefinement_generic: return True cdef bint _one_refinement(self, long * best, int begin, int end, bint *inner_group_changed, - bint *changed_partition, str refine_name): + bint *changed_partition, str refine_name) noexcept: r""" Let ``self._refine_vals_scratch`` contain the result of the `(S_n)_C`-homomorphism `\omega` and ``best`` be the result of `\omega` applied to the candidate. @@ -818,13 +818,13 @@ cdef class PartitionRefinement_generic: self._latex_act_node(refine_name) return False - cdef int len(self): + cdef int len(self) noexcept: r""" Return the degree of the acting symmetric group. """ return self._n - cdef void _leaf_computations(self): + cdef void _leaf_computations(self) noexcept: r""" All necessary computations which have to be performed in a leaf. @@ -855,7 +855,7 @@ cdef class PartitionRefinement_generic: self._store_best_() self._latex_act_node("NEW") - cdef bint _cut_by_known_automs(self): + cdef bint _cut_by_known_automs(self) noexcept: r""" Return ``True`` if the subtree below this node does not contain any *interesting* information. @@ -871,7 +871,7 @@ cdef class PartitionRefinement_generic: # BACKTRACK_WITHLATEX_DEBUG = 1 in the setup.py script when # building this module! ########################################################################### - cdef void _latex_act_node(self, str comment="", int printlvl=0): + cdef void _latex_act_node(self, str comment="", int printlvl=0) noexcept: r""" Append the actual node as a string of latex-commands to ``self._latex_debug_string`` @@ -900,7 +900,7 @@ cdef class PartitionRefinement_generic: print("sorry, no debug output was written. " + "Set BACKTRACK_WITHLATEX_DEBUG to True if interested in this information") - cdef void _init_latex(self): + cdef void _init_latex(self) noexcept: r""" Add some initial commands to the string ``self._latex_debug_string``. @@ -916,7 +916,7 @@ cdef class PartitionRefinement_generic: self._latex_debug_string += "[." self._latex_act_node() - cdef void _finish_latex(self): + cdef void _finish_latex(self) noexcept: r""" Add some final commands to the string ``self._latex_debug_string``. @@ -925,7 +925,7 @@ cdef class PartitionRefinement_generic: self._latex_debug_string += "]\n" self._latex_debug_string += "\\end{tikzpicture} }\n" - cdef void _latex_new_lvl(self): + cdef void _latex_new_lvl(self) noexcept: r""" Add some commands to the string ``self._latex_debug_string``, in the case that the depth was increased during the backtracking. @@ -933,7 +933,7 @@ cdef class PartitionRefinement_generic: if BACKTRACK_WITHLATEX_DEBUG: self._latex_debug_string += "[." - cdef void _latex_finish_lvl(self): + cdef void _latex_finish_lvl(self) noexcept: r""" Add some commands to the string ``self._latex_debug_string``, in the case that we return to a node in the backtracking. @@ -943,7 +943,7 @@ cdef class PartitionRefinement_generic: cdef int PS_first_smallest_PR(PartitionStack *PS, bitset_t b, int *second_pos=NULL, - PartitionRefinement_generic partn_ref_alg=None): + PartitionRefinement_generic partn_ref_alg=None) noexcept: """ Find the first occurrence of the smallest cell of size greater than one, which is admissible (checked by the function ``test_allowance``). diff --git a/src/sage/groups/perm_gps/permgroup_element.pxd b/src/sage/groups/perm_gps/permgroup_element.pxd index 0a584745f96..c0cab01c706 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pxd +++ b/src/sage/groups/perm_gps/permgroup_element.pxd @@ -8,21 +8,21 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): cdef int n cdef int perm_buf[15] # to avoid malloc for small elements cdef GapElement _libgap - cdef PermutationGroupElement _new_c(self) - cdef _alloc(self, int) - cpdef _set_identity(self) - cpdef _set_list_images(self, v, bint convert) - cpdef _set_libgap(self, GapElement p) - cpdef _set_list_cycles(self, c, bint convert) - cpdef _set_string(self, str s) - cpdef _set_permutation_group_element(self, PermutationGroupElement p, bint convert) + cdef PermutationGroupElement _new_c(self) noexcept + cdef _alloc(self, int) noexcept + cpdef _set_identity(self) noexcept + cpdef _set_list_images(self, v, bint convert) noexcept + cpdef _set_libgap(self, GapElement p) noexcept + cpdef _set_list_cycles(self, c, bint convert) noexcept + cpdef _set_string(self, str s) noexcept + cpdef _set_permutation_group_element(self, PermutationGroupElement p, bint convert) noexcept - cpdef _mul_(self, other) - cpdef PermutationGroupElement _generate_new(self, list new_list) - cpdef PermutationGroupElement _generate_new_GAP(self, old) - cpdef _gap_list(self) - cpdef domain(self) + cpdef _mul_(self, other) noexcept + cpdef PermutationGroupElement _generate_new(self, list new_list) noexcept + cpdef PermutationGroupElement _generate_new_GAP(self, old) noexcept + cpdef _gap_list(self) noexcept + cpdef domain(self) noexcept cdef public _SageObject__custom_name - cpdef list _act_on_list_on_position(self, list x) - cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x) - cpdef ETuple _act_on_etuple_on_position(self, ETuple x) + cpdef list _act_on_list_on_position(self, list x) noexcept + cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x) noexcept + cpdef ETuple _act_on_etuple_on_position(self, ETuple x) noexcept diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 2522b5c346d..29eae266c53 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -149,7 +149,7 @@ cdef arith_llong arith = arith_llong() cdef extern from *: long long LLONG_MAX -cdef int etuple_index_cmp(const void * a, const void * b) nogil: +cdef int etuple_index_cmp(const void * a, const void * b) noexcept nogil: return (( a)[0] > ( b)[0]) - (( a)[0] < ( b)[0]) def make_permgroup_element(G, x): @@ -513,7 +513,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): if p not in P: raise ValueError('permutation %s not in %s' % (g, parent)) - cpdef _set_identity(self): + cpdef _set_identity(self) noexcept: r""" TESTS:: @@ -532,7 +532,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): for i in range(self.n): self.perm[i] = i - cpdef _set_list_images(self, v, bint convert): + cpdef _set_list_images(self, v, bint convert) noexcept: r""" TESTS:: @@ -566,7 +566,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): for i in range(vn, self.n): self.perm[i] = i - cpdef _set_libgap(self, GapElement p): + cpdef _set_libgap(self, GapElement p) noexcept: r""" TESTS:: @@ -615,7 +615,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): self._libgap = p - cpdef _set_permutation_group_element(self, PermutationGroupElement p, bint convert): + cpdef _set_permutation_group_element(self, PermutationGroupElement p, bint convert) noexcept: r""" TESTS:: @@ -669,7 +669,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): for i in range(p.n, self.n): self.perm[i] = i - cpdef _set_list_cycles(self, c, bint convert): + cpdef _set_list_cycles(self, c, bint convert) noexcept: r""" TESTS:: @@ -716,7 +716,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): raise ValueError("invalid list of cycles to initialize a permutation") self.perm[j] = t[0] - 1 - cpdef _set_string(self, str s): + cpdef _set_string(self, str s) noexcept: r""" TESTS:: @@ -807,7 +807,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): """ return make_permgroup_element_v2, (self._parent, self.domain(), self._parent.domain()) - cdef _alloc(self, int n): + cdef _alloc(self, int n) noexcept: if n < 16 and self.perm == NULL: self.perm = self.perm_buf elif self.perm == NULL: @@ -817,7 +817,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): self.n = n - cdef PermutationGroupElement _new_c(self): + cdef PermutationGroupElement _new_c(self) noexcept: cdef type t = type(self) cdef PermutationGroupElement other = t.__new__(t) if HAS_DICTIONARY(self): @@ -977,7 +977,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): """ return self.cycles()[i] - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare group elements ``self`` and ``other``. @@ -1086,7 +1086,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): else: return from_gap[i] - cpdef list _act_on_list_on_position(self, list x): + cpdef list _act_on_list_on_position(self, list x) noexcept: r""" Returns the right action of ``self`` on the list ``x``. This is the action on positions. @@ -1114,7 +1114,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): assert len(x) == self.n, '%s and %s should have the same length'%(self, x) return [ x[self.perm[i]] for i in range(self.n) ] - cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x): + cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x) noexcept: r""" Returns the right action of ``self`` on the ClonableIntArray ``x``. This is the action on positions. @@ -1138,7 +1138,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): y.set_immutable() return y - cpdef ETuple _act_on_etuple_on_position(self, ETuple x): + cpdef ETuple _act_on_etuple_on_position(self, ETuple x) noexcept: r""" Return the right action of this permutation on the ETuple ``x``. @@ -1178,7 +1178,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): qsort(result._data, result._nonzero, 2 * sizeof(int), etuple_index_cmp) return result - cpdef _act_on_(self, x, bint self_on_left): + cpdef _act_on_(self, x, bint self_on_left) noexcept: r""" Return the result of the action of ``self`` on ``x``. @@ -1298,7 +1298,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return coercion_model.bin_op(left, right, operator.mul) - cpdef _mul_(left, _right): + cpdef _mul_(left, _right) noexcept: r""" EXAMPLES:: @@ -1315,7 +1315,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): prod.perm[i] = right.perm[left.perm[i]] return prod - cpdef PermutationGroupElement _generate_new(self, list v): + cpdef PermutationGroupElement _generate_new(self, list v) noexcept: r""" Generate a new permutation group element with the same parent as ``self`` from ``v``. @@ -1333,7 +1333,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): new._set_list_images(v, False) return new - cpdef PermutationGroupElement _generate_new_GAP(self, lst_in): + cpdef PermutationGroupElement _generate_new_GAP(self, lst_in) noexcept: r""" Generate a new permutation group element with the same parent as ``self`` from the GAP list ``lst_in``. @@ -1384,7 +1384,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): inv.perm[self.perm[i]] = i return inv - cpdef _gap_list(self): + cpdef _gap_list(self) noexcept: r""" Returns this permutation in list notation compatible with the GAP numbering. @@ -1432,7 +1432,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): from sage.combinat.permutation import Permutation return Permutation(self._gap_list()).cycle_string() - cpdef domain(self): + cpdef domain(self) noexcept: r""" Return the domain of ``self``. @@ -2086,7 +2086,7 @@ cdef class SymmetricGroupElement(PermutationGroupElement): return self.has_descent(i, side='left') -cdef bint is_valid_permutation(int* perm, int n): +cdef bint is_valid_permutation(int* perm, int n) noexcept: r""" This is used in the __init__ method. diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pxd b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pxd index bd4f62d497f..1808129c4b7 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pxd +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pxd @@ -4,5 +4,5 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): cdef tuple v cdef object perm, alpha - cdef _new_c(self) - cpdef _mul_(self, other) + cdef _new_c(self) noexcept + cpdef _mul_(self, other) noexcept diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx index ae9ce18efb1..453f2be85f0 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx @@ -135,7 +135,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): self.perm = perm self.alpha = alpha - cdef _new_c(self): + cdef _new_c(self) noexcept: # Create a copy of self. cdef SemimonomialTransformation x x = SemimonomialTransformation.__new__(SemimonomialTransformation) @@ -173,7 +173,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): """ return hash(self.v) + hash(self.perm) + hash(self.get_autom()) - cpdef _mul_(left, _right): + cpdef _mul_(left, _right) noexcept: r""" Multiplication of elements. @@ -247,7 +247,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): return "(%s; %s, %s)"%(self.v, self.perm.cycle_string(), self.get_autom()) - cpdef _richcmp_(left, _right, int op): + cpdef _richcmp_(left, _right, int op) noexcept: """ Compare group elements ``self`` and ``right``. diff --git a/src/sage/interacts/library_cython.pyx b/src/sage/interacts/library_cython.pyx index 37e75a16e7d..a2b36489165 100644 --- a/src/sage/interacts/library_cython.pyx +++ b/src/sage/interacts/library_cython.pyx @@ -16,7 +16,7 @@ AUTHORS: #***************************************************************************** -cpdef julia(ff_j, z, int iterations): +cpdef julia(ff_j, z, int iterations) noexcept: """ Helper function for the Julia Fractal interact example. @@ -44,7 +44,7 @@ cpdef julia(ff_j, z, int iterations): return z -cpdef mandel(ff_m, z, int iterations): +cpdef mandel(ff_m, z, int iterations) noexcept: """ Helper function for the Mandelbrot Fractal interact example. @@ -73,7 +73,7 @@ cpdef mandel(ff_m, z, int iterations): return z -cpdef cellular(rule, int N): +cpdef cellular(rule, int N) noexcept: """ Cythonized helper function for the cellular_automata fractal. diff --git a/src/sage/lfunctions/zero_sums.pyx b/src/sage/lfunctions/zero_sums.pyx index 75ee990b1fc..46f84d6f12d 100644 --- a/src/sage/lfunctions/zero_sums.pyx +++ b/src/sage/lfunctions/zero_sums.pyx @@ -1066,7 +1066,7 @@ cdef class LFunctionZeroSum_EllipticCurve(LFunctionZeroSum_abstract): double logq, double thetaq, double sqrtq, - double z): + double z) noexcept: r""" Private cdef method to compute the logarithmic derivative summand for the sinc^2 sum at prime values for when @@ -1096,7 +1096,7 @@ cdef class LFunctionZeroSum_EllipticCurve(LFunctionZeroSum_abstract): double t, int ap, double p, - double logp): + double logp) noexcept: r""" Private cdef method to compute the logarithmic derivative summand for the sinc^2 sum at prime values for when @@ -1109,7 +1109,7 @@ cdef class LFunctionZeroSum_EllipticCurve(LFunctionZeroSum_abstract): logp = c_log(p) return -(t - logp) * (logp / p) * ap - cpdef _zerosum_sincsquared_fast(self, Delta=1, bad_primes=None): + cpdef _zerosum_sincsquared_fast(self, Delta=1, bad_primes=None) noexcept: r""" A faster cythonized implementation of self._zerosum_sincsquared(). diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index a8e73e57b52..a4942781c5e 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -28,20 +28,20 @@ from cpython.object cimport Py_EQ, Py_NE #it would be preferrable to let bint_symbolp wrap an efficient macro #but the macro provided in object.h doesn't seem to work -cdef bint bint_symbolp(cl_object obj): +cdef bint bint_symbolp(cl_object obj) noexcept: return not(cl_symbolp(obj) == ECL_NIL) #these type predicates are only provided in "cl_*" form, so we wrap them #with the proper type cast. -cdef bint bint_numberp(cl_object obj): +cdef bint bint_numberp(cl_object obj) noexcept: return not(cl_numberp(obj) == ECL_NIL) -cdef bint bint_integerp(cl_object obj): +cdef bint bint_integerp(cl_object obj) noexcept: return not(cl_integerp(obj) == ECL_NIL) -cdef bint bint_rationalp(cl_object obj): +cdef bint bint_rationalp(cl_object obj) noexcept: return not(cl_rationalp(obj) == ECL_NIL) -cdef bint bint_base_string_p(cl_object obj): +cdef bint bint_base_string_p(cl_object obj) noexcept: return not(si_base_string_p(obj) == ECL_NIL) cdef extern from "eclsig.h": @@ -60,7 +60,7 @@ cdef extern from "eclsig.h": cl_object safe_cl_eval(cl_object *error, cl_object form) -cdef cl_object string_to_object(char * s): +cdef cl_object string_to_object(char * s) noexcept: return ecl_read_from_cstring(s) # We need to keep a list of objects bound to python, to protect them from being @@ -77,7 +77,7 @@ cdef cl_object string_to_object(char * s): # chained in a "free list" for quick allocation (and if the free list is empty # upon allocating a node, the array needs to be extended) -cdef cl_object insert_node_after(cl_object node,cl_object value): +cdef cl_object insert_node_after(cl_object node,cl_object value) noexcept: cdef cl_object next,newnode next=cl_cadr(node) @@ -87,7 +87,7 @@ cdef cl_object insert_node_after(cl_object node,cl_object value): cl_rplacd(cl_cdr(next),newnode) return newnode -cdef void remove_node(cl_object node): +cdef void remove_node(cl_object node) noexcept: cdef cl_object next, prev next=cl_cadr(node) prev=cl_cddr(node) @@ -284,7 +284,7 @@ def init_ecl(): ecl_has_booted = 1 -cdef ecl_string_to_python(cl_object s): +cdef ecl_string_to_python(cl_object s) noexcept: if bint_base_string_p(s): return char_to_str(ecl_base_string_pointer_safe(s)) else: @@ -484,7 +484,7 @@ cdef cl_object python_to_ecl(pyobj, bint read_strings) except NULL: raise TypeError("Unimplemented type for python_to_ecl") -cdef ecl_to_python(cl_object o): +cdef ecl_to_python(cl_object o) noexcept: cdef cl_object s cdef Integer N # conversions from an ecl object to a python object. @@ -663,7 +663,7 @@ cdef class EclObject: cdef cl_object obj #the wrapped object cdef cl_object node #linked list pointer: car(node) == obj - cdef void set_obj(EclObject self, cl_object o): + cdef void set_obj(EclObject self, cl_object o) noexcept: if self.node: remove_node(self.node) self.node=NULL @@ -1341,13 +1341,13 @@ cdef class EclListIterator: return r #input: a cl-object. Output: EclObject wrapping that. -cdef EclObject ecl_wrap(cl_object o): +cdef EclObject ecl_wrap(cl_object o) noexcept: cdef EclObject obj = EclObject.__new__(EclObject) obj.set_obj(o) return obj #convenience routine to more easily evaluate strings -cpdef EclObject ecl_eval(str s): +cpdef EclObject ecl_eval(str s) noexcept: r""" Read and evaluate string in Lisp and return the result diff --git a/src/sage/libs/eclib/mat.pxd b/src/sage/libs/eclib/mat.pxd index 41b0cc628c1..0bba3eb62d5 100644 --- a/src/sage/libs/eclib/mat.pxd +++ b/src/sage/libs/eclib/mat.pxd @@ -4,7 +4,7 @@ cdef class Matrix: cdef mat* M cdef class MatrixFactory: - cdef new_matrix(self, mat M) + cdef new_matrix(self, mat M) noexcept diff --git a/src/sage/libs/eclib/mat.pyx b/src/sage/libs/eclib/mat.pyx index 39dee4afc94..24c5ce55fb2 100644 --- a/src/sage/libs/eclib/mat.pyx +++ b/src/sage/libs/eclib/mat.pyx @@ -240,11 +240,11 @@ cdef class Matrix: cdef class MatrixFactory: - cdef new_matrix(self, mat M): + cdef new_matrix(self, mat M) noexcept: return new_Matrix(M) -cdef Matrix new_Matrix(mat M): +cdef Matrix new_Matrix(mat M) noexcept: cdef Matrix A = Matrix() A.M = new mat(M) return A diff --git a/src/sage/libs/eclib/mwrank.pyx b/src/sage/libs/eclib/mwrank.pyx index 11219ddefa6..49b20a33c0e 100644 --- a/src/sage/libs/eclib/mwrank.pyx +++ b/src/sage/libs/eclib/mwrank.pyx @@ -68,7 +68,7 @@ cdef extern from "wrap.cpp": long two_descent_get_selmer_rank(two_descent* t) void two_descent_saturate(two_descent* t, long sat_bd, long sat_low_bd) -cdef object string_sigoff(char* s): +cdef object string_sigoff(char* s) noexcept: sig_off() # Makes a python string and deletes what is pointed to by s. t = char_to_str(s) @@ -238,7 +238,7 @@ cdef class _bigint: return string_sigoff(bigint_to_str(self.x)) -cdef make_bigint(bigint* x): +cdef make_bigint(bigint* x) noexcept: cdef _bigint y sig_off() y = _bigint.__new__(_bigint) diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index 20a797c0197..6050c487835 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -187,5 +187,5 @@ cdef extern from "flint_wrap.h": void fmpq_poly_tanh_series(fmpq_poly_t, const fmpq_poly_t, slong) # since the fmpq_poly header seems to be lacking this inline function -cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly): +cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept: return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly)) diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd index b596e0c04b6..7d28c2795b4 100644 --- a/src/sage/libs/flint/fmpz_factor.pxd +++ b/src/sage/libs/flint/fmpz_factor.pxd @@ -9,4 +9,4 @@ cdef extern from "flint_wrap.h": void fmpz_factor_init(fmpz_factor_t) void fmpz_factor(fmpz_factor_t, const fmpz_t) -cdef fmpz_factor_to_pairlist(const fmpz_factor_t) +cdef fmpz_factor_to_pairlist(const fmpz_factor_t) noexcept diff --git a/src/sage/libs/flint/fmpz_factor.pyx b/src/sage/libs/flint/fmpz_factor.pyx index 330ba3d4d4e..aeb9c76f9e3 100644 --- a/src/sage/libs/flint/fmpz_factor.pyx +++ b/src/sage/libs/flint/fmpz_factor.pyx @@ -2,7 +2,7 @@ from cysignals.signals cimport sig_check from sage.libs.flint.fmpz cimport fmpz_get_mpz from sage.rings.integer cimport Integer -cdef fmpz_factor_to_pairlist(const fmpz_factor_t factors): +cdef fmpz_factor_to_pairlist(const fmpz_factor_t factors) noexcept: r""" Helper function that converts a fmpz_factor_t into a list of (factor, exponent) pairs. The factors are Integers, and the diff --git a/src/sage/libs/flint/nmod_poly_linkage.pxi b/src/sage/libs/flint/nmod_poly_linkage.pxi index 45f4410d785..32087acf9dc 100644 --- a/src/sage/libs/flint/nmod_poly_linkage.pxi +++ b/src/sage/libs/flint/nmod_poly_linkage.pxi @@ -24,16 +24,16 @@ from sage.libs.flint.nmod_poly cimport * from sage.libs.flint.ulong_extras cimport * from sage.structure.factorization import Factorization -cdef inline celement *celement_new(unsigned long n): +cdef inline celement *celement_new(unsigned long n) noexcept: cdef celement *g = sig_malloc(sizeof(nmod_poly_t)) nmod_poly_init(g, n) return g -cdef inline int celement_delete(nmod_poly_t e, unsigned long n): +cdef inline int celement_delete(nmod_poly_t e, unsigned long n) noexcept: nmod_poly_clear(e) sig_free(e) -cdef inline int celement_construct(nmod_poly_t e, unsigned long n): +cdef inline int celement_construct(nmod_poly_t e, unsigned long n) noexcept: """ EXAMPLES:: @@ -43,7 +43,7 @@ cdef inline int celement_construct(nmod_poly_t e, unsigned long n): """ nmod_poly_init(e, n) -cdef inline int celement_destruct(nmod_poly_t e, unsigned long n): +cdef inline int celement_destruct(nmod_poly_t e, unsigned long n) noexcept: """ EXAMPLES:: @@ -66,7 +66,7 @@ cdef inline int celement_gen(nmod_poly_t e, long i, unsigned long n) except -2: nmod_poly_zero(e) nmod_poly_set_coeff_ui(e, 1, 1) -cdef object celement_repr(nmod_poly_t e, unsigned long n): +cdef object celement_repr(nmod_poly_t e, unsigned long n) noexcept: raise NotImplementedError cdef inline int celement_set(nmod_poly_t res, nmod_poly_t a, unsigned long n) except -2: @@ -617,7 +617,7 @@ cdef inline int celement_xgcd(nmod_poly_t res, nmod_poly_t s, nmod_poly_t t, nmo nmod_poly_xgcd(res, s, t, a, b) -cdef factor_helper(Polynomial_zmod_flint poly, bint squarefree=False): +cdef factor_helper(Polynomial_zmod_flint poly, bint squarefree=False) noexcept: """ EXAMPLES:: diff --git a/src/sage/libs/gap/element.pxd b/src/sage/libs/gap/element.pxd index d6bf4f8b3ff..7882414df20 100644 --- a/src/sage/libs/gap/element.pxd +++ b/src/sage/libs/gap/element.pxd @@ -18,20 +18,20 @@ cdef Obj make_gap_record(sage_dict) except NULL cdef Obj make_gap_integer(sage_int) except NULL cdef Obj make_gap_string(sage_string) except NULL -cdef GapElement make_any_gap_element(parent, Obj obj) -cdef GapElement make_GapElement(parent, Obj obj) -cdef GapElement_List make_GapElement_List(parent, Obj obj) -cdef GapElement_Record make_GapElement_Record(parent, Obj obj) -cdef GapElement_Integer make_GapElement_Integer(parent, Obj obj) -cdef GapElement_Rational make_GapElement_Rational(parent, Obj obj) -cdef GapElement_String make_GapElement_String(parent, Obj obj) -cdef GapElement_Boolean make_GapElement_Boolean(parent, Obj obj) -cdef GapElement_Function make_GapElement_Function(parent, Obj obj) -cdef GapElement_Permutation make_GapElement_Permutation(parent, Obj obj) - -cdef char *capture_stdout(Obj, Obj) -cdef char *gap_element_str(Obj) -cdef char *gap_element_repr(Obj) +cdef GapElement make_any_gap_element(parent, Obj obj) noexcept +cdef GapElement make_GapElement(parent, Obj obj) noexcept +cdef GapElement_List make_GapElement_List(parent, Obj obj) noexcept +cdef GapElement_Record make_GapElement_Record(parent, Obj obj) noexcept +cdef GapElement_Integer make_GapElement_Integer(parent, Obj obj) noexcept +cdef GapElement_Rational make_GapElement_Rational(parent, Obj obj) noexcept +cdef GapElement_String make_GapElement_String(parent, Obj obj) noexcept +cdef GapElement_Boolean make_GapElement_Boolean(parent, Obj obj) noexcept +cdef GapElement_Function make_GapElement_Function(parent, Obj obj) noexcept +cdef GapElement_Permutation make_GapElement_Permutation(parent, Obj obj) noexcept + +cdef char *capture_stdout(Obj, Obj) noexcept +cdef char *gap_element_str(Obj) noexcept +cdef char *gap_element_repr(Obj) noexcept cdef class GapElement(RingElement): @@ -43,18 +43,18 @@ cdef class GapElement(RingElement): cdef bint _compare_by_id cdef bint _compare_equal(self, Element other) except -2 cdef bint _compare_less(self, Element other) except -2 - cpdef _set_compare_by_id(self) - cpdef _assert_compare_by_id(self) + cpdef _set_compare_by_id(self) noexcept + cpdef _assert_compare_by_id(self) noexcept - cdef _initialize(self, parent, Obj obj) - cpdef _type_number(self) - cpdef is_bool(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _mod_(self, other) - cpdef _pow_(self, other) + cdef _initialize(self, parent, Obj obj) noexcept + cpdef _type_number(self) noexcept + cpdef is_bool(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _mod_(self, other) noexcept + cpdef _pow_(self, other) noexcept - cpdef GapElement deepcopy(self, bint mut) + cpdef GapElement deepcopy(self, bint mut) noexcept cdef class GapElement_Integer(GapElement): pass @@ -63,10 +63,10 @@ cdef class GapElement_Rational(GapElement): pass cdef class GapElement_IntegerMod(GapElement): - cpdef GapElement_Integer lift(self) + cpdef GapElement_Integer lift(self) noexcept cdef class GapElement_FiniteField(GapElement): - cpdef GapElement_Integer lift(self) + cpdef GapElement_Integer lift(self) noexcept cdef class GapElement_Cyclotomic(GapElement): pass @@ -87,7 +87,7 @@ cdef class GapElement_MethodProxy(GapElement_Function): cdef GapElement first_argument cdef class GapElement_Record(GapElement): - cpdef UInt record_name_to_index(self, name) + cpdef UInt record_name_to_index(self, name) noexcept cdef class GapElement_RecordIterator(): cdef GapElement_Record rec diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx index 363024ae281..a5f0dfcd24c 100644 --- a/src/sage/libs/gap/element.pyx +++ b/src/sage/libs/gap/element.pyx @@ -110,7 +110,7 @@ cdef Obj make_gap_matrix(sage_list, gap_ring) except NULL: GAP_Leave() -cdef char *capture_stdout(Obj func, Obj obj): +cdef char *capture_stdout(Obj func, Obj obj) noexcept: """ Call a single-argument GAP function ``func`` with the argument ``obj`` and return the stdout from that function call. @@ -145,7 +145,7 @@ cdef char *capture_stdout(Obj func, Obj obj): GAP_Leave() -cdef char *gap_element_repr(Obj obj): +cdef char *gap_element_repr(Obj obj) noexcept: """ Implement ``repr()`` of ``GapElement``s using the ``ViewObj()`` function, which is by default closest to what you get when displaying an object in @@ -161,7 +161,7 @@ cdef char *gap_element_repr(Obj obj): GAP_Leave() -cdef char *gap_element_str(Obj obj): +cdef char *gap_element_str(Obj obj) noexcept: """ Implement ``str()`` of ``GapElement``s using the ``Print()`` function. @@ -266,7 +266,7 @@ cdef Obj make_gap_string(sage_string) except NULL: ### generic construction of GapElements #################################### ############################################################################ -cdef GapElement make_any_gap_element(parent, Obj obj): +cdef GapElement make_any_gap_element(parent, Obj obj) noexcept: """ Return the GAP element wrapper of ``obj`` @@ -354,7 +354,7 @@ cdef GapElement make_any_gap_element(parent, Obj obj): ### GapElement ############################################################# ############################################################################ -cdef GapElement make_GapElement(parent, Obj obj): +cdef GapElement make_GapElement(parent, Obj obj) noexcept: r""" Turn a Gap C object (of type ``Obj``) into a Cython ``GapElement``. @@ -387,7 +387,7 @@ cdef GapElement make_GapElement(parent, Obj obj): return r -cpdef _from_sage(elem): +cpdef _from_sage(elem) noexcept: """ Currently just used for unpickling; equivalent to calling ``libgap(elem)`` to convert a Sage object to a `GapElement` where possible. @@ -460,7 +460,7 @@ cdef class GapElement(RingElement): """ raise TypeError('this class cannot be instantiated from Python') - cdef _initialize(self, parent, Obj obj): + cdef _initialize(self, parent, Obj obj) noexcept: r""" Initialize the GapElement. @@ -544,7 +544,7 @@ cdef class GapElement(RingElement): else: return self - cpdef GapElement deepcopy(self, bint mut): + cpdef GapElement deepcopy(self, bint mut) noexcept: r""" Return a deepcopy of this Gap object @@ -647,7 +647,7 @@ cdef class GapElement(RingElement): GAP_IN = libgap.eval(r'\in') return GAP_IN(other, self).sage() - cpdef _type_number(self): + cpdef _type_number(self) noexcept: """ Return the GAP internal type number. @@ -776,7 +776,7 @@ cdef class GapElement(RingElement): s = char_to_str(gap_element_repr(self.value)) return s.strip() - cpdef _set_compare_by_id(self): + cpdef _set_compare_by_id(self) noexcept: """ Set comparison to compare by ``id`` @@ -814,7 +814,7 @@ cdef class GapElement(RingElement): """ self._compare_by_id = True - cpdef _assert_compare_by_id(self): + cpdef _assert_compare_by_id(self) noexcept: """ Ensure that comparison is by ``id`` @@ -851,7 +851,7 @@ cdef class GapElement(RingElement): """ return hash(str(self)) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare ``self`` with ``other``. @@ -973,7 +973,7 @@ cdef class GapElement(RingElement): GAP_Leave() sig_off() - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Add two GapElement objects. @@ -1002,7 +1002,7 @@ cdef class GapElement(RingElement): GAP_Leave() return make_any_gap_element(self.parent(), result) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Subtract two GapElement objects. @@ -1031,7 +1031,7 @@ cdef class GapElement(RingElement): return make_any_gap_element(self.parent(), result) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: r""" Multiply two GapElement objects. @@ -1060,7 +1060,7 @@ cdef class GapElement(RingElement): GAP_Leave() return make_any_gap_element(self.parent(), result) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: r""" Divide two GapElement objects. @@ -1094,7 +1094,7 @@ cdef class GapElement(RingElement): GAP_Leave() return make_any_gap_element(self.parent(), result) - cpdef _mod_(self, right): + cpdef _mod_(self, right) noexcept: r""" Modulus of two GapElement objects. @@ -1121,7 +1121,7 @@ cdef class GapElement(RingElement): GAP_Leave() return make_any_gap_element(self.parent(), result) - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: r""" Exponentiation of two GapElement objects. @@ -1170,7 +1170,7 @@ cdef class GapElement(RingElement): GAP_Leave() return make_any_gap_element(self._parent, result) - cpdef _pow_int(self, other): + cpdef _pow_int(self, other) noexcept: """ TESTS:: @@ -1232,7 +1232,7 @@ cdef class GapElement(RingElement): """ return GAP_IsRecord(self.value) - cpdef is_bool(self): + cpdef is_bool(self) noexcept: r""" Return whether the wrapped GAP object is a GAP boolean. @@ -1401,7 +1401,7 @@ cdef class GapElement(RingElement): ### GapElement_Integer ##################################################### ############################################################################ -cdef GapElement_Integer make_GapElement_Integer(parent, Obj obj): +cdef GapElement_Integer make_GapElement_Integer(parent, Obj obj) noexcept: r""" Turn a Gap integer object into a GapElement_Integer Sage object @@ -1555,7 +1555,7 @@ cdef class GapElement_Integer(GapElement): ### GapElement_Float ##################################################### ########################################################################## -cdef GapElement_Float make_GapElement_Float(parent, Obj obj): +cdef GapElement_Float make_GapElement_Float(parent, Obj obj) noexcept: r""" Turn a Gap macfloat object into a GapElement_Float Sage object @@ -1628,7 +1628,7 @@ cdef class GapElement_Float(GapElement): ### GapElement_IntegerMod ##################################################### ############################################################################ -cdef GapElement_IntegerMod make_GapElement_IntegerMod(parent, Obj obj): +cdef GapElement_IntegerMod make_GapElement_IntegerMod(parent, Obj obj) noexcept: r""" Turn a Gap integer object into a :class:`GapElement_IntegerMod` Sage object @@ -1656,7 +1656,7 @@ cdef class GapElement_IntegerMod(GapElement): """ - cpdef GapElement_Integer lift(self): + cpdef GapElement_Integer lift(self) noexcept: """ Return an integer lift. @@ -1709,7 +1709,7 @@ cdef class GapElement_IntegerMod(GapElement): ### GapElement_FiniteField ##################################################### ############################################################################ -cdef GapElement_FiniteField make_GapElement_FiniteField(parent, Obj obj): +cdef GapElement_FiniteField make_GapElement_FiniteField(parent, Obj obj) noexcept: r""" Turn a GAP finite field object into a :class:`GapElement_FiniteField` Sage object @@ -1737,7 +1737,7 @@ cdef class GapElement_FiniteField(GapElement): """ - cpdef GapElement_Integer lift(self): + cpdef GapElement_Integer lift(self) noexcept: """ Return an integer lift. @@ -1876,7 +1876,7 @@ cdef class GapElement_FiniteField(GapElement): ### GapElement_Cyclotomic ##################################################### ############################################################################ -cdef GapElement_Cyclotomic make_GapElement_Cyclotomic(parent, Obj obj): +cdef GapElement_Cyclotomic make_GapElement_Cyclotomic(parent, Obj obj) noexcept: r""" Turn a Gap cyclotomic object into a :class:`GapElement_Cyclotomic` Sage object. @@ -1964,7 +1964,7 @@ cdef class GapElement_Cyclotomic(GapElement): ### GapElement_Rational #################################################### ############################################################################ -cdef GapElement_Rational make_GapElement_Rational(parent, Obj obj): +cdef GapElement_Rational make_GapElement_Rational(parent, Obj obj) noexcept: r""" Turn a Gap Rational number (of type ``Obj``) into a Cython ``GapElement_Rational``. @@ -2036,7 +2036,7 @@ cdef class GapElement_Rational(GapElement): ### GapElement_Ring ##################################################### ############################################################################ -cdef GapElement_Ring make_GapElement_Ring(parent, Obj obj): +cdef GapElement_Ring make_GapElement_Ring(parent, Obj obj) noexcept: r""" Turn a Gap integer object into a :class:`GapElement_Ring` Sage object. @@ -2200,7 +2200,7 @@ cdef class GapElement_Ring(GapElement): ### GapElement_Boolean ##################################################### ############################################################################ -cdef GapElement_Boolean make_GapElement_Boolean(parent, Obj obj): +cdef GapElement_Boolean make_GapElement_Boolean(parent, Obj obj) noexcept: r""" Turn a Gap Boolean number (of type ``Obj``) into a Cython ``GapElement_Boolean``. @@ -2292,7 +2292,7 @@ cdef class GapElement_Boolean(GapElement): ### GapElement_String #################################################### ############################################################################ -cdef GapElement_String make_GapElement_String(parent, Obj obj): +cdef GapElement_String make_GapElement_String(parent, Obj obj) noexcept: r""" Turn a Gap String (of type ``Obj``) into a Cython ``GapElement_String``. @@ -2352,7 +2352,7 @@ cdef class GapElement_String(GapElement): ### GapElement_Function #################################################### ############################################################################ -cdef GapElement_Function make_GapElement_Function(parent, Obj obj): +cdef GapElement_Function make_GapElement_Function(parent, Obj obj) noexcept: r""" Turn a Gap C function object (of type ``Obj``) into a Cython ``GapElement_Function``. @@ -2562,7 +2562,7 @@ cdef class GapElement_Function(GapElement): ### GapElement_MethodProxy ################################################# ############################################################################ -cdef GapElement_MethodProxy make_GapElement_MethodProxy(parent, Obj function, GapElement base_object): +cdef GapElement_MethodProxy make_GapElement_MethodProxy(parent, Obj function, GapElement base_object) noexcept: r""" Turn a Gap C rec object (of type ``Obj``) into a Cython ``GapElement_Record``. @@ -2652,7 +2652,7 @@ cdef class GapElement_MethodProxy(GapElement_Function): ### GapElement_List ######################################################## ############################################################################ -cdef GapElement_List make_GapElement_List(parent, Obj obj): +cdef GapElement_List make_GapElement_List(parent, Obj obj) noexcept: r""" Turn a Gap C List object (of type ``Obj``) into a Cython ``GapElement_List``. @@ -2990,7 +2990,7 @@ cdef class GapElement_List(GapElement): ############################################################################ -cdef GapElement_Permutation make_GapElement_Permutation(parent, Obj obj): +cdef GapElement_Permutation make_GapElement_Permutation(parent, Obj obj) noexcept: r""" Turn a Gap C permutation object (of type ``Obj``) into a Cython ``GapElement_Permutation``. @@ -3055,7 +3055,7 @@ cdef class GapElement_Permutation(GapElement): ### GapElement_Record ###################################################### ############################################################################ -cdef GapElement_Record make_GapElement_Record(parent, Obj obj): +cdef GapElement_Record make_GapElement_Record(parent, Obj obj) noexcept: r""" Turn a Gap C rec object (of type ``Obj``) into a Cython ``GapElement_Record``. @@ -3135,7 +3135,7 @@ cdef class GapElement_Record(GapElement): """ return GapElement_RecordIterator(self) - cpdef UInt record_name_to_index(self, name): + cpdef UInt record_name_to_index(self, name) noexcept: r""" Convert string to GAP record index. diff --git a/src/sage/libs/gap/util.pxd b/src/sage/libs/gap/util.pxd index 118146133f4..e7b499a7b5a 100644 --- a/src/sage/libs/gap/util.pxd +++ b/src/sage/libs/gap/util.pxd @@ -17,25 +17,25 @@ from .gap_includes cimport Obj cdef class ObjWrapper(): cdef Obj value -cdef ObjWrapper wrap_obj(Obj obj) +cdef ObjWrapper wrap_obj(Obj obj) noexcept # returns the refcount dictionary for debugging purposes -cpdef get_owned_objects() +cpdef get_owned_objects() noexcept # Reference count GAP objects that you want to prevent from being # garbage collected -cdef void reference_obj(Obj obj) -cdef void dereference_obj(Obj obj) +cdef void reference_obj(Obj obj) noexcept +cdef void dereference_obj(Obj obj) noexcept # callback from the GAP memory manager so we can mark all_gap_elements.values() -cdef void gasman_callback() with gil +cdef void gasman_callback() noexcept with gil ############################################################################ ### Initialization of GAP ################################################## ############################################################################ -cdef initialize() +cdef initialize() noexcept ############################################################################ diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index 3c286d2020d..f4f18589e14 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -103,7 +103,7 @@ cdef class ObjWrapper(): return (self.value) -cdef ObjWrapper wrap_obj(Obj obj): +cdef ObjWrapper wrap_obj(Obj obj) noexcept: """ Constructor function for :class:`ObjWrapper` """ @@ -120,14 +120,14 @@ cdef dict owned_objects_refcount = dict() # # used in Sage's libgap.Gap.count_GAP_objects # -cpdef get_owned_objects(): +cpdef get_owned_objects() noexcept: """ Helper to access the refcount dictionary from Python code """ return owned_objects_refcount -cdef void reference_obj(Obj obj): +cdef void reference_obj(Obj obj) noexcept: """ Reference ``obj`` """ @@ -140,7 +140,7 @@ cdef void reference_obj(Obj obj): owned_objects_refcount[wrapped] = 1 -cdef void dereference_obj(Obj obj): +cdef void dereference_obj(Obj obj) noexcept: """ Reference ``obj`` """ @@ -151,7 +151,7 @@ cdef void dereference_obj(Obj obj): owned_objects_refcount[wrapped] = refcount - 1 -cdef void gasman_callback() with gil: +cdef void gasman_callback() noexcept with gil: """ Callback before each GAP garbage collection """ @@ -184,7 +184,7 @@ MakeImmutable(libgap_errout); """ -cdef initialize(): +cdef initialize() noexcept: """ Initialize the GAP library, if it hasn't already been initialized. It is safe to call this multiple times. One can set @@ -404,7 +404,7 @@ class GAPError(ValueError): # ValueError for historical reasons """ -cdef str extract_libgap_errout(): +cdef str extract_libgap_errout() noexcept: """ Reads the global variable libgap_errout and returns a Python string containing the error message (with some boilerplate removed). @@ -428,7 +428,7 @@ cdef str extract_libgap_errout(): return msg_py -cdef void error_handler() with gil: +cdef void error_handler() noexcept with gil: """ The libgap error handler. diff --git a/src/sage/libs/glpk/error.pyx b/src/sage/libs/glpk/error.pyx index 2e3ac1c386a..1d265f3ef65 100644 --- a/src/sage/libs/glpk/error.pyx +++ b/src/sage/libs/glpk/error.pyx @@ -41,7 +41,7 @@ class GLPKError(MIPSolverException): cdef error_message = "" -cdef int sage_glpk_term_hook(void *info, const char *s) with gil: +cdef int sage_glpk_term_hook(void *info, const char *s) noexcept with gil: """ A hook to intercept all output written by GLPK. """ @@ -56,7 +56,7 @@ cdef int sage_glpk_term_hook(void *info, const char *s) with gil: return 0 -cdef void sage_glpk_error_hook(void *info) with gil: +cdef void sage_glpk_error_hook(void *info) noexcept with gil: """ A hook to intercept GLPK errors. """ diff --git a/src/sage/libs/gmp/binop.pxd b/src/sage/libs/gmp/binop.pxd index 8ff7aee190d..983e6de5214 100644 --- a/src/sage/libs/gmp/binop.pxd +++ b/src/sage/libs/gmp/binop.pxd @@ -6,17 +6,17 @@ from .types cimport mpz_t, mpq_t from .mpz cimport mpz_set, mpz_add, mpz_mul from .mpq cimport mpq_canonicalize, mpq_numref, mpq_denref, mpq_add -cdef inline void mpq_add_z(mpq_t res, mpq_t op1, mpz_t op2): +cdef inline void mpq_add_z(mpq_t res, mpq_t op1, mpz_t op2) noexcept: mpz_mul(mpq_numref(res), mpq_denref(op1), op2) mpz_add(mpq_numref(res), mpq_numref(res), mpq_numref(op1)) mpz_set(mpq_denref(res), mpq_denref(op1)) -cdef inline void mpq_div_zz(mpq_t res, mpz_t op1, mpz_t op2): +cdef inline void mpq_div_zz(mpq_t res, mpz_t op1, mpz_t op2) noexcept: mpz_set(mpq_numref(res), op1) mpz_set(mpq_denref(res), op2) mpq_canonicalize(res) -cdef inline void mpq_mul_z(mpq_t res, mpq_t op1, mpz_t op2): +cdef inline void mpq_mul_z(mpq_t res, mpq_t op1, mpz_t op2) noexcept: # (A/B) * C = (C/B) * A mpq_div_zz(res, op2, mpq_denref(op1)) mpz_mul(mpq_numref(res), mpq_numref(res), mpq_numref(op1)) diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd index 84e1bb8cd87..846444d2082 100644 --- a/src/sage/libs/gmp/pylong.pxd +++ b/src/sage/libs/gmp/pylong.pxd @@ -5,7 +5,7 @@ Various functions to deal with conversion mpz <-> Python int/long from cpython.longintrepr cimport py_long from sage.libs.gmp.types cimport * -cdef mpz_get_pylong(mpz_srcptr z) -cdef mpz_get_pyintlong(mpz_srcptr z) +cdef mpz_get_pylong(mpz_srcptr z) noexcept +cdef mpz_get_pyintlong(mpz_srcptr z) noexcept cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1 -cdef Py_hash_t mpz_pythonhash(mpz_srcptr z) +cdef Py_hash_t mpz_pythonhash(mpz_srcptr z) noexcept diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx index 1a36c29d3fa..833d44c9bc9 100644 --- a/src/sage/libs/gmp/pylong.pyx +++ b/src/sage/libs/gmp/pylong.pyx @@ -56,7 +56,7 @@ cdef extern from *: cdef size_t PyLong_nails = 8*sizeof(digit) - PyLong_SHIFT -cdef mpz_get_pylong_large(mpz_srcptr z): +cdef mpz_get_pylong_large(mpz_srcptr z) noexcept: """ Convert a non-zero ``mpz`` to a Python ``long``. """ @@ -68,7 +68,7 @@ cdef mpz_get_pylong_large(mpz_srcptr z): return L -cdef mpz_get_pylong(mpz_srcptr z): +cdef mpz_get_pylong(mpz_srcptr z) noexcept: """ Convert an ``mpz`` to a Python ``long``. """ @@ -77,7 +77,7 @@ cdef mpz_get_pylong(mpz_srcptr z): return mpz_get_pylong_large(z) -cdef mpz_get_pyintlong(mpz_srcptr z): +cdef mpz_get_pyintlong(mpz_srcptr z) noexcept: """ Convert an ``mpz`` to a Python ``int`` if possible, or a ``long`` if the value is too large. @@ -97,7 +97,7 @@ cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1: mpz_neg(z, z) -cdef Py_hash_t mpz_pythonhash(mpz_srcptr z): +cdef Py_hash_t mpz_pythonhash(mpz_srcptr z) noexcept: """ Hash an ``mpz``, where the hash value is the same as the hash value of the corresponding Python ``int`` or ``long``, except that we do diff --git a/src/sage/libs/gmp/randomize.pxd b/src/sage/libs/gmp/randomize.pxd index cdbef70f2c7..3876c0dda13 100644 --- a/src/sage/libs/gmp/randomize.pxd +++ b/src/sage/libs/gmp/randomize.pxd @@ -8,7 +8,7 @@ from sage.misc.randstate cimport randstate, current_randstate, SAGE_RAND_MAX ########################### -cdef inline void mpq_randomize_entry(mpq_t x, mpz_t num_bound, mpz_t den_bound): +cdef inline void mpq_randomize_entry(mpq_t x, mpz_t num_bound, mpz_t den_bound) noexcept: cdef randstate rstate = current_randstate() mpz_urandomm(mpq_numref(x), rstate.gmp_state, num_bound) mpz_urandomm(mpq_denref(x), rstate.gmp_state, den_bound) @@ -18,24 +18,24 @@ cdef inline void mpq_randomize_entry(mpq_t x, mpz_t num_bound, mpz_t den_bound): mpz_mul_si(mpq_numref(x), mpq_numref(x), -1) mpq_canonicalize(x) -cdef inline void mpq_randomize_entry_nonzero(mpq_t x, mpz_t num_bound, mpz_t den_bound): +cdef inline void mpq_randomize_entry_nonzero(mpq_t x, mpz_t num_bound, mpz_t den_bound) noexcept: mpq_randomize_entry(x, num_bound, den_bound) while mpq_sgn(x) == 0: mpq_randomize_entry(x, num_bound, den_bound) -cdef inline void mpq_randomize_entry_as_int(mpq_t x, mpz_t bound): +cdef inline void mpq_randomize_entry_as_int(mpq_t x, mpz_t bound) noexcept: cdef randstate rstate = current_randstate() mpz_urandomm(mpq_numref(x), rstate.gmp_state, bound) mpz_set_si(mpq_denref(x), 1) if rstate.c_random() % 2: mpz_mul_si(mpq_numref(x), mpq_numref(x), -1) -cdef inline void mpq_randomize_entry_as_int_nonzero(mpq_t x, mpz_t bound): +cdef inline void mpq_randomize_entry_as_int_nonzero(mpq_t x, mpz_t bound) noexcept: mpq_randomize_entry_as_int(x, bound) while mpq_sgn(x) == 0: mpq_randomize_entry_as_int(x, bound) -cdef inline void mpq_randomize_entry_recip_uniform(mpq_t x): +cdef inline void mpq_randomize_entry_recip_uniform(mpq_t x) noexcept: cdef randstate rstate = current_randstate() # Numerator is selected the same way as ZZ.random_element(); # denominator is selected in a similar way, but @@ -52,7 +52,7 @@ cdef inline void mpq_randomize_entry_recip_uniform(mpq_t x): mpz_set_si(mpq_denref(x), SAGE_RAND_MAX / den) mpq_canonicalize(x) -cdef inline void mpq_randomize_entry_recip_uniform_nonzero(mpq_t x): +cdef inline void mpq_randomize_entry_recip_uniform_nonzero(mpq_t x) noexcept: mpq_randomize_entry_recip_uniform(x) while mpq_sgn(x) == 0: mpq_randomize_entry_recip_uniform(x) diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pxd b/src/sage/libs/lcalc/lcalc_Lfunction.pxd index 1d595180a6f..715fa46bba0 100644 --- a/src/sage/libs/lcalc/lcalc_Lfunction.pxd +++ b/src/sage/libs/lcalc/lcalc_Lfunction.pxd @@ -104,14 +104,14 @@ ctypedef double Double cdef class Lfunction: cdef void *thisptr - cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) - cdef c_Complex _value(self,c_Complex s,int derivative) - cdef c_Complex _hardy_z_function(self,c_Complex s) - cdef int _compute_rank(self) + cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept + cdef c_Complex _value(self,c_Complex s,int derivative) noexcept + cdef c_Complex _hardy_z_function(self,c_Complex s) noexcept + cdef int _compute_rank(self) noexcept #strange bug, replacing Double with double gives me a compile error - cdef Double _typedN(self, double T) - cdef void _find_zeros_v(self, double T1, double T2, double stepsize,doublevec *result) - cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result) + cdef Double _typedN(self, double T) noexcept + cdef void _find_zeros_v(self, double T1, double T2, double stepsize,doublevec *result) noexcept + cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result) noexcept cdef str _repr diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pyx b/src/sage/libs/lcalc/lcalc_Lfunction.pyx index 7b871ed049f..4950ed1d97f 100644 --- a/src/sage/libs/lcalc/lcalc_Lfunction.pyx +++ b/src/sage/libs/lcalc/lcalc_Lfunction.pyx @@ -408,25 +408,25 @@ cdef class Lfunction: return returnvalue # Needs to be overriden - cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r): + cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept: raise NotImplementedError - cdef c_Complex _value(self,c_Complex s,int derivative): + cdef c_Complex _value(self,c_Complex s,int derivative) noexcept: raise NotImplementedError - cdef c_Complex _hardy_z_function(self,c_Complex s): + cdef c_Complex _hardy_z_function(self,c_Complex s) noexcept: raise NotImplementedError - cdef int _compute_rank(self): + cdef int _compute_rank(self) noexcept: raise NotImplementedError - cdef double _typedN(self,double T): + cdef double _typedN(self,double T) noexcept: raise NotImplementedError - cdef void _find_zeros_v(self,double T1, double T2, double stepsize, doublevec *result): + cdef void _find_zeros_v(self,double T1, double T2, double stepsize, doublevec *result) noexcept: raise NotImplementedError - cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result): + cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result) noexcept: raise NotImplementedError ############################################################################## @@ -497,7 +497,7 @@ cdef class Lfunction_I(Lfunction): self._repr += " with integer Dirichlet coefficients" # override - cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r): + cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept: cdef int N = len(dirichlet_coeff) cdef Integer tmpi cdef int * coeffs = new_ints(N+1) #lcalc ignores 0the coefficient @@ -507,22 +507,22 @@ cdef class Lfunction_I(Lfunction): self.thisptr=new_c_Lfunction_I(NAME, what_type, N, coeffs, Period, q, w, A, g, l, n_poles, p, r) del_ints(coeffs) - cdef inline c_Complex _value(self,c_Complex s,int derivative): + cdef inline c_Complex _value(self,c_Complex s,int derivative) noexcept: return ((self.thisptr)).value(s, derivative, "pure") - cdef inline c_Complex _hardy_z_function(self,c_Complex s): + cdef inline c_Complex _hardy_z_function(self,c_Complex s) noexcept: return ((self.thisptr)).value(s, 0, "rotated pure") - cdef int _compute_rank(self): + cdef int _compute_rank(self) noexcept: return ((self.thisptr)).compute_rank() - cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result): + cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result) noexcept: (self.thisptr).find_zeros_v(T1,T2,stepsize,result[0]) - cdef double _typedN(self, double T): + cdef double _typedN(self, double T) noexcept: return (self.thisptr).N(T) - cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result): + cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result) noexcept: (self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result) # debug tools @@ -633,7 +633,7 @@ cdef class Lfunction_D(Lfunction): self._repr += " with real Dirichlet coefficients" # override - cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r): + cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept: cdef int i cdef RealNumber tmpr cdef int N = len(dirichlet_coeff) @@ -644,23 +644,23 @@ cdef class Lfunction_D(Lfunction): self.thisptr=new_c_Lfunction_D(NAME, what_type, N, coeffs, Period, q, w, A, g, l, n_poles, p, r) del_doubles(coeffs) - cdef inline c_Complex _value(self,c_Complex s,int derivative): + cdef inline c_Complex _value(self,c_Complex s,int derivative) noexcept: return ((self.thisptr)).value(s, derivative, "pure") - cdef inline c_Complex _hardy_z_function(self,c_Complex s): + cdef inline c_Complex _hardy_z_function(self,c_Complex s) noexcept: return ((self.thisptr)).value(s, 0, "rotated pure") - cdef inline int _compute_rank(self): + cdef inline int _compute_rank(self) noexcept: return ((self.thisptr)).compute_rank() - cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result): + cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result) noexcept: (self.thisptr).find_zeros_v(T1,T2,stepsize,result[0]) - cdef double _typedN(self, double T): + cdef double _typedN(self, double T) noexcept: return (self.thisptr).N(T) - cdef int _find_zeros(self, long count, long start,double max_refine, int rank, const char* message_stamp, doublevec *result): + cdef int _find_zeros(self, long count, long start,double max_refine, int rank, const char* message_stamp, doublevec *result) noexcept: (self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result) # debug tools @@ -773,7 +773,7 @@ cdef class Lfunction_C: self._repr += " with complex Dirichlet coefficients" # override - cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r): + cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept: cdef int i cdef int N = len(dirichlet_coeff) cdef ComplexNumber tmpc @@ -788,24 +788,24 @@ cdef class Lfunction_C: del_Complexes(coeffs) - cdef inline c_Complex _value(self,c_Complex s,int derivative): + cdef inline c_Complex _value(self,c_Complex s,int derivative) noexcept: return ((self.thisptr)).value(s, derivative, "pure") - cdef inline c_Complex _hardy_z_function(self,c_Complex s): + cdef inline c_Complex _hardy_z_function(self,c_Complex s) noexcept: return ((self.thisptr)).value(s, 0,"rotated pure") - cdef inline int _compute_rank(self): + cdef inline int _compute_rank(self) noexcept: return ((self.thisptr)).compute_rank() - cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result): + cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result) noexcept: (self.thisptr).find_zeros_v(T1,T2,stepsize,result[0]) - cdef double _typedN(self, double T): + cdef double _typedN(self, double T) noexcept: return (self.thisptr).N(T) - cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result): + cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result) noexcept: (self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result) # debug tools @@ -873,24 +873,24 @@ cdef class Lfunction_Zeta(Lfunction): self.thisptr = new_c_Lfunction_Zeta() self._repr = "The Riemann zeta function" - cdef inline c_Complex _value(self,c_Complex s,int derivative): + cdef inline c_Complex _value(self,c_Complex s,int derivative) noexcept: return ((self.thisptr)).value(s, derivative, "pure") - cdef inline c_Complex _hardy_z_function(self,c_Complex s): + cdef inline c_Complex _hardy_z_function(self,c_Complex s) noexcept: return ((self.thisptr)).value(s, 0, "rotated pure") - cdef inline int _compute_rank(self): + cdef inline int _compute_rank(self) noexcept: return ((self.thisptr)).compute_rank() - cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result): + cdef void _find_zeros_v(self, double T1, double T2, double stepsize, doublevec *result) noexcept: (self.thisptr).find_zeros_v(T1,T2,stepsize,result[0]) - cdef double _typedN(self, double T): + cdef double _typedN(self, double T) noexcept: return (self.thisptr).N(T) - cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result): + cdef int _find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result) noexcept: (self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result) def __dealloc__(self): diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd index 1753277b1f1..f140a0fc321 100644 --- a/src/sage/libs/linbox/conversion.pxd +++ b/src/sage/libs/linbox/conversion.pxd @@ -77,7 +77,7 @@ cdef inline linbox_specifier get_method(str algo) except ERROR: # matrix_modn_sparse (sparse matrix over Z/nZ) # ################################################ -cdef inline void set_linbox_matrix_modn_sparse(SparseMatrix_Modular_uint64& A, Matrix_modn_sparse m): +cdef inline void set_linbox_matrix_modn_sparse(SparseMatrix_Modular_uint64& A, Matrix_modn_sparse m) noexcept: r""" Set the entries of a LinBox matrix from a Sage matrix. @@ -93,7 +93,7 @@ cdef inline void set_linbox_matrix_modn_sparse(SparseMatrix_Modular_uint64& A, M for j in range( row.num_nonzero): A.setEntry(i, row.positions[j], row.entries[j]) -cdef inline SparseMatrix_Modular_uint64 * new_linbox_matrix_modn_sparse(Modular_uint64 &F, Matrix_modn_sparse m): +cdef inline SparseMatrix_Modular_uint64 * new_linbox_matrix_modn_sparse(Modular_uint64 &F, Matrix_modn_sparse m) noexcept: r""" Return a new LinBox matrix from a Sage matrix. @@ -112,7 +112,7 @@ cdef inline SparseMatrix_Modular_uint64 * new_linbox_matrix_modn_sparse(Modular_ # matrix_integer_sparse # ######################### -cdef inline void set_linbox_matrix_integer_sparse(SparseMatrix_integer& A, Matrix_integer_sparse m): +cdef inline void set_linbox_matrix_integer_sparse(SparseMatrix_integer& A, Matrix_integer_sparse m) noexcept: r""" Set the entries of a LinBox matrix from a Sage matrix. @@ -131,7 +131,7 @@ cdef inline void set_linbox_matrix_integer_sparse(SparseMatrix_integer& A, Matri mpz_set(t.get_mpz(), v.entries[k]) A.setEntry(i, j, t) -cdef inline SparseMatrix_integer * new_linbox_matrix_integer_sparse(ZRing &ZZ, Matrix_integer_sparse m): +cdef inline SparseMatrix_integer * new_linbox_matrix_integer_sparse(ZRing &ZZ, Matrix_integer_sparse m) noexcept: r""" Return a new LinBox matrix from a Sage matrix. @@ -149,7 +149,7 @@ cdef inline SparseMatrix_integer * new_linbox_matrix_integer_sparse(ZRing &ZZ, M # vector integer dense # ######################## -cdef inline DenseVector_integer * new_linbox_vector_integer_dense(ZRing &ZZ, Vector_integer_dense v): +cdef inline DenseVector_integer * new_linbox_vector_integer_dense(ZRing &ZZ, Vector_integer_dense v) noexcept: r""" Return a new linbox vector from a sage one. @@ -167,7 +167,7 @@ cdef inline DenseVector_integer * new_linbox_vector_integer_dense(ZRing &ZZ, Vec return V -cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_integer &v): +cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_integer &v) noexcept: r""" Return a new Sage vector from a LinBox one. diff --git a/src/sage/libs/linbox/linbox_flint_interface.pxd b/src/sage/libs/linbox/linbox_flint_interface.pxd index 3cee66657f0..f47d5386a01 100644 --- a/src/sage/libs/linbox/linbox_flint_interface.pxd +++ b/src/sage/libs/linbox/linbox_flint_interface.pxd @@ -5,16 +5,16 @@ from sage.libs.flint.types cimport fmpz_t, fmpz_mat_t, fmpz_poly_t # set C <- A * B -cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B) +cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B) noexcept # set cp to the characteristic polynomial of A -cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A) +cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A) noexcept # set mp to the minimal polynomial of A -cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A) +cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A) noexcept # return the rank of A -cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A) +cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A) noexcept # set det to the determinant of A -cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A) +cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A) noexcept diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx index 415cd473947..dabd375c2b8 100644 --- a/src/sage/libs/linbox/linbox_flint_interface.pyx +++ b/src/sage/libs/linbox/linbox_flint_interface.pyx @@ -43,7 +43,7 @@ cimport sage.libs.linbox.linbox as linbox from .linbox cimport PolynomialRing_integer -cdef void fmpz_mat_get_linbox(linbox.DenseMatrix_integer& A, fmpz_mat_t m): +cdef void fmpz_mat_get_linbox(linbox.DenseMatrix_integer& A, fmpz_mat_t m) noexcept: r""" Set the entries of A from m (no allocation performed). @@ -59,7 +59,7 @@ cdef void fmpz_mat_get_linbox(linbox.DenseMatrix_integer& A, fmpz_mat_t m): A.setEntry(i, j, t) -cdef void fmpz_mat_set_linbox(fmpz_mat_t m, linbox.DenseMatrix_integer& A): +cdef void fmpz_mat_set_linbox(fmpz_mat_t m, linbox.DenseMatrix_integer& A) noexcept: r""" Set the entries of m from A (no allocation performed). @@ -72,7 +72,7 @@ cdef void fmpz_mat_set_linbox(fmpz_mat_t m, linbox.DenseMatrix_integer& A): fmpz_set_mpz(fmpz_mat_entry(m, i, j), A.getEntry(i, j).get_mpz_const()) -cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q): +cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q) noexcept: r""" Set the entries of the polynomial p from q (no allocation performed). @@ -89,7 +89,7 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q) _fmpz_poly_set_length(p, q.size()) -cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B): +cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B) noexcept: r""" Set C to be A * B. """ @@ -115,7 +115,7 @@ cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B): fmpz_mat_set_linbox(C, LBC[0]) -cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A): +cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A) noexcept: r""" Set cp to the characteristic polynomial of A. """ @@ -133,7 +133,7 @@ cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A): del m_A -cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A): +cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A) noexcept: r""" Set mp to the minimal polynomial of A. """ @@ -151,7 +151,7 @@ cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A): del m_A -cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A): +cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A) noexcept: r""" Return the rank of A """ @@ -168,7 +168,7 @@ cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A): return r -cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A): +cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A) noexcept: r""" Set det to the determinant of A. """ diff --git a/src/sage/libs/linkages/padics/Polynomial_ram.pxi b/src/sage/libs/linkages/padics/Polynomial_ram.pxi index e0584ecb8ad..2048bb0a3c2 100644 --- a/src/sage/libs/linkages/padics/Polynomial_ram.pxi +++ b/src/sage/libs/linkages/padics/Polynomial_ram.pxi @@ -318,7 +318,7 @@ cdef inline int cpow(celement out, celement a, mpz_t n, long prec, PowComputer_ _expansion_zero = [] # the expansion_mode enum is defined in padic_template_element_header.pxi -cdef inline cexpansion_next(celement value, expansion_mode mode, long curpower, PowComputer_ prime_pow): +cdef inline cexpansion_next(celement value, expansion_mode mode, long curpower, PowComputer_ prime_pow) noexcept: if mode == teichmuller_mode: raise NotImplementedError # This is not very efficient, but there's no clear better way. @@ -339,7 +339,7 @@ cdef inline cexpansion_next(celement value, expansion_mode mode, long curpower, cshift_notrunc(value, value, -1, curpower, prime_pow, False) return term -cdef inline cexpansion_getitem(celement value, long m, PowComputer_ prime_pow): +cdef inline cexpansion_getitem(celement value, long m, PowComputer_ prime_pow) noexcept: """ Return the `m`th `p`-adic digit in the ``simple_mode`` expansion. @@ -383,7 +383,7 @@ cdef int cteichmuller(celement out, celement value, long prec, PowComputer_ prim else: out._coeffs = [value[0].parent().teichmuller(value[0])] -cdef list ccoefficients(celement x, long valshift, long prec, PowComputer_ prime_pow): +cdef list ccoefficients(celement x, long valshift, long prec, PowComputer_ prime_pow) noexcept: """ Return a list of coefficients, as elements that can be converted into the base ring. diff --git a/src/sage/libs/linkages/padics/Polynomial_shared.pxi b/src/sage/libs/linkages/padics/Polynomial_shared.pxi index 367bbc2f33d..b210b53ce19 100644 --- a/src/sage/libs/linkages/padics/Polynomial_shared.pxi +++ b/src/sage/libs/linkages/padics/Polynomial_shared.pxi @@ -332,7 +332,7 @@ cdef inline int ccopy(celement out, celement a, PowComputer_ prime_pow) except - """ out._coeffs = a._coeffs[:] -cdef inline cpickle(celement a, PowComputer_ prime_pow): +cdef inline cpickle(celement a, PowComputer_ prime_pow) noexcept: r""" Return a representation of ``a`` for pickling. diff --git a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi index 843070f4a42..afb9d191609 100644 --- a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi +++ b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi @@ -497,7 +497,7 @@ cdef inline int ccopy(celement out, celement a, PowComputer_ prime_pow) except - """ fmpz_poly_set(out, a) -cdef inline cpickle(celement a, PowComputer_ prime_pow): +cdef inline cpickle(celement a, PowComputer_ prime_pow) noexcept: """ Serialization into objects that Sage knows how to pickle. @@ -544,7 +544,7 @@ cdef inline long chash(celement a, long ordp, long prec, PowComputer_ prime_pow) fmpz_poly_get_coeff_mpz(h.value, a, 0) return hash(h) -cdef inline cmodp_rep(fmpz_poly_t rep, fmpz_poly_t value, expansion_mode mode, bint return_list, PowComputer_ prime_pow): +cdef inline cmodp_rep(fmpz_poly_t rep, fmpz_poly_t value, expansion_mode mode, bint return_list, PowComputer_ prime_pow) noexcept: """ Compute a polynomial that is reduced modulo p and equivalent to the given value. @@ -577,7 +577,7 @@ cdef inline cmodp_rep(fmpz_poly_t rep, fmpz_poly_t value, expansion_mode mode, b return L # the expansion_mode enum is defined in padic_template_element_header.pxi -cdef inline cexpansion_next(fmpz_poly_t value, expansion_mode mode, long curpower, PowComputer_ prime_pow): +cdef inline cexpansion_next(fmpz_poly_t value, expansion_mode mode, long curpower, PowComputer_ prime_pow) noexcept: """ Return the next digit in a `p`-adic expansion of ``value``. @@ -607,7 +607,7 @@ cdef inline cexpansion_next(fmpz_poly_t value, expansion_mode mode, long curpowe _fmpz_poly_normalise(value) return trim_zeros(ans) # defined in sage.rings.padics.misc and imported in padic_template_element -cdef inline cexpansion_getitem(fmpz_poly_t value, long m, PowComputer_ prime_pow): +cdef inline cexpansion_getitem(fmpz_poly_t value, long m, PowComputer_ prime_pow) noexcept: """ Return the `m`th `p`-adic digit in the ``simple_mode`` expansion. @@ -637,7 +637,7 @@ cdef inline cexpansion_getitem(fmpz_poly_t value, long m, PowComputer_ prime_pow # The element is filled in for zero in the p-adic expansion if necessary. _expansion_zero = [] -cdef list ccoefficients(celement x, long valshift, long prec, PowComputer_ prime_pow): +cdef list ccoefficients(celement x, long valshift, long prec, PowComputer_ prime_pow) noexcept: """ Return a list of coefficients, as elements that can be converted into the base ring. @@ -847,7 +847,7 @@ cdef inline int cconv_mpz_t_out(mpz_t out, celement x, long valshift, long prec, ## Extra functions ## -cdef cmatrix_mod_pn(celement a, long aprec, long valshift, PowComputer_ prime_pow): +cdef cmatrix_mod_pn(celement a, long aprec, long valshift, PowComputer_ prime_pow) noexcept: r""" Returns the matrix of right multiplication by the element on the power basis `1, x, x^2, \ldots, x^{d-1}` for this diff --git a/src/sage/libs/linkages/padics/mpz.pxi b/src/sage/libs/linkages/padics/mpz.pxi index 3a555e441dc..ba8c143f3b7 100644 --- a/src/sage/libs/linkages/padics/mpz.pxi +++ b/src/sage/libs/linkages/padics/mpz.pxi @@ -435,7 +435,7 @@ cdef inline int ccopy(mpz_t out, mpz_t a, PowComputer_ prime_pow) except -1: """ mpz_set(out, a) -cdef inline cpickle(mpz_t a, PowComputer_ prime_pow): +cdef inline cpickle(mpz_t a, PowComputer_ prime_pow) noexcept: """ Serialization into objects that Sage knows how to pickle. @@ -493,7 +493,7 @@ cdef inline long chash(mpz_t a, long ordp, long prec, PowComputer_ prime_pow) ex return n # the expansion_mode enum is defined in padic_template_element_header.pxi -cdef inline cexpansion_next(mpz_t value, expansion_mode mode, long curpower, PowComputer_ prime_pow): +cdef inline cexpansion_next(mpz_t value, expansion_mode mode, long curpower, PowComputer_ prime_pow) noexcept: """ Return the next digit in a `p`-adic expansion of ``value``. @@ -523,7 +523,7 @@ cdef inline cexpansion_next(mpz_t value, expansion_mode mode, long curpower, Pow mpz_sub(value, value, prime_pow.pow_mpz_t_tmp(curpower)) return ans -cdef inline cexpansion_getitem(mpz_t value, long m, PowComputer_ prime_pow): +cdef inline cexpansion_getitem(mpz_t value, long m, PowComputer_ prime_pow) noexcept: """ Return the `m`th `p`-adic digit in the ``simple_mode`` expansion. @@ -545,7 +545,7 @@ cdef inline cexpansion_getitem(mpz_t value, long m, PowComputer_ prime_pow): # It could be [] for some other linkages. _expansion_zero = Integer(0) -cdef list ccoefficients(mpz_t x, long valshift, long prec, PowComputer_ prime_pow): +cdef list ccoefficients(mpz_t x, long valshift, long prec, PowComputer_ prime_pow) noexcept: """ Return a list of coefficients, as elements that can be converted into the base ring. diff --git a/src/sage/libs/linkages/padics/relaxed/flint.pxi b/src/sage/libs/linkages/padics/relaxed/flint.pxi index 5955ea23e18..3dab6ecbc30 100644 --- a/src/sage/libs/linkages/padics/relaxed/flint.pxi +++ b/src/sage/libs/linkages/padics/relaxed/flint.pxi @@ -44,7 +44,7 @@ from sage.rings.finite_rings.finite_field_constructor import GF cdef fmpz_t digit_zero digit_init(digit_zero) -cdef inline void digit_init(fmpz_t a): +cdef inline void digit_init(fmpz_t a) noexcept: r""" Initialize a digit and set to it the value `0`. @@ -54,7 +54,7 @@ cdef inline void digit_init(fmpz_t a): """ fmpz_init(a) -cdef inline void digit_clear(fmpz_t a): +cdef inline void digit_clear(fmpz_t a) noexcept: r""" Deallocate memory assigned to a digit. @@ -66,7 +66,7 @@ cdef inline void digit_clear(fmpz_t a): # get and set -cdef inline Integer digit_get_sage(fmpz_t a): +cdef inline Integer digit_get_sage(fmpz_t a) noexcept: r""" Convert a digit to a Sage element. @@ -82,7 +82,7 @@ cdef inline Integer digit_get_sage(fmpz_t a): fmpz_get_mpz(elt.value, a) return elt -cdef inline void digit_set(fmpz_t a, fmpz_t b): +cdef inline void digit_set(fmpz_t a, fmpz_t b) noexcept: r""" Set up a digit. @@ -93,7 +93,7 @@ cdef inline void digit_set(fmpz_t a, fmpz_t b): """ fmpz_set(a, b) -cdef inline void digit_set_ui(fmpz_t a, slong b): +cdef inline void digit_set_ui(fmpz_t a, slong b) noexcept: r""" Set an integral value of a digit. @@ -104,7 +104,7 @@ cdef inline void digit_set_ui(fmpz_t a, slong b): """ fmpz_set_ui(a, b) -cdef inline void digit_set_sage(fmpz_t a, Integer elt): +cdef inline void digit_set_sage(fmpz_t a, Integer elt) noexcept: r""" Set the value of a digit. @@ -117,7 +117,7 @@ cdef inline void digit_set_sage(fmpz_t a, Integer elt): # comparisons -cdef inline bint digit_equal(fmpz_t a, fmpz_t b): +cdef inline bint digit_equal(fmpz_t a, fmpz_t b) noexcept: r""" Comparison of two digits. @@ -132,7 +132,7 @@ cdef inline bint digit_equal(fmpz_t a, fmpz_t b): """ return fmpz_equal(a, b) -cdef inline bint digit_equal_ui(fmpz_t a, slong b): +cdef inline bint digit_equal_ui(fmpz_t a, slong b) noexcept: r""" Comparison of a digit and an integer @@ -147,7 +147,7 @@ cdef inline bint digit_equal_ui(fmpz_t a, slong b): """ return fmpz_equal_ui(a, b) -cdef inline bint digit_is_zero(fmpz_t a): +cdef inline bint digit_is_zero(fmpz_t a) noexcept: r""" Comparison to zero @@ -163,7 +163,7 @@ cdef inline bint digit_is_zero(fmpz_t a): # random -cdef inline void digit_random_init(flint_rand_t generator, slong seed): +cdef inline void digit_random_init(flint_rand_t generator, slong seed) noexcept: r""" Initialize the random generator with a new seed @@ -174,7 +174,7 @@ cdef inline void digit_random_init(flint_rand_t generator, slong seed): """ flint_randseed(generator, seed, seed*seed + 1) -cdef inline void digit_random(fmpz_t res, PowComputer_flint prime_pow, flint_rand_t generator): +cdef inline void digit_random(fmpz_t res, PowComputer_flint prime_pow, flint_rand_t generator) noexcept: r""" Set a digit to a random value in the distinguished set of representatives. @@ -187,7 +187,7 @@ cdef inline void digit_random(fmpz_t res, PowComputer_flint prime_pow, flint_ran # operations -cdef inline void digit_add(fmpz_t res, fmpz_t a, fmpz_t b): +cdef inline void digit_add(fmpz_t res, fmpz_t a, fmpz_t b) noexcept: r""" Add two digits. @@ -199,7 +199,7 @@ cdef inline void digit_add(fmpz_t res, fmpz_t a, fmpz_t b): """ fmpz_add(res, a, b) -cdef inline void digit_sub(fmpz_t res, fmpz_t a, fmpz_t b): +cdef inline void digit_sub(fmpz_t res, fmpz_t a, fmpz_t b) noexcept: r""" Subtract two digits. @@ -211,7 +211,7 @@ cdef inline void digit_sub(fmpz_t res, fmpz_t a, fmpz_t b): """ fmpz_sub(res, a, b) -cdef inline void digit_mul(fmpz_t res, fmpz_t a, fmpz_t b): +cdef inline void digit_mul(fmpz_t res, fmpz_t a, fmpz_t b) noexcept: r""" Multiply two digits. @@ -223,7 +223,7 @@ cdef inline void digit_mul(fmpz_t res, fmpz_t a, fmpz_t b): """ fmpz_mul(res, a, b) -cdef inline void digit_mod(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow): +cdef inline void digit_mod(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow) noexcept: r""" Reduce a digit modulo the uniformizer. @@ -235,7 +235,7 @@ cdef inline void digit_mod(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow): """ fmpz_mod(res, a, prime_pow.fprime) -cdef inline void digit_quorem(fmpz_t quo, fmpz_t rem, fmpz_t a, PowComputer_flint prime_pow): +cdef inline void digit_quorem(fmpz_t quo, fmpz_t rem, fmpz_t a, PowComputer_flint prime_pow) noexcept: r""" Reduce a digit modulo the uniformizer and keep the carry. @@ -248,7 +248,7 @@ cdef inline void digit_quorem(fmpz_t quo, fmpz_t rem, fmpz_t a, PowComputer_flin """ fmpz_tdiv_qr(quo, rem, a, prime_pow.fprime) -cdef inline void digit_smallest(cdigit res, cdigit carry, cdigit a, PowComputer_flint prime_pow): +cdef inline void digit_smallest(cdigit res, cdigit carry, cdigit a, PowComputer_flint prime_pow) noexcept: r""" Compute the smallest representative of a digit. @@ -275,7 +275,7 @@ cdef inline void digit_smallest(cdigit res, cdigit carry, cdigit a, PowComputer_ fmpz_set_ui(carry, 0) fmpz_clear(b) -cdef inline void digit_inv(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow): +cdef inline void digit_inv(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow) noexcept: r""" Compute the multiplicative inverse of a digit modulo the uniformizer. @@ -290,7 +290,7 @@ cdef inline void digit_inv(fmpz_t res, fmpz_t a, PowComputer_flint prime_pow): fmpz_gcdinv(gcd, res, a, prime_pow.fprime) fmpz_clear(gcd) -cdef bint digit_sqrt(fmpz_t ans, fmpz_t x, PowComputer_flint prime_pow): +cdef bint digit_sqrt(fmpz_t ans, fmpz_t x, PowComputer_flint prime_pow) noexcept: r""" Compute the square root of a digit modulo the uniformizer. @@ -306,7 +306,7 @@ cdef bint digit_sqrt(fmpz_t ans, fmpz_t x, PowComputer_flint prime_pow): # Operations on elements (represented as series of digits) ########################################################## -cdef inline void element_init(fmpz_poly_t x): +cdef inline void element_init(fmpz_poly_t x) noexcept: r""" Initialize an element. @@ -316,7 +316,7 @@ cdef inline void element_init(fmpz_poly_t x): """ fmpz_poly_init(x) -cdef inline void element_clear(fmpz_poly_t x): +cdef inline void element_clear(fmpz_poly_t x) noexcept: r""" Deallocate memory assigned to an element. @@ -328,7 +328,7 @@ cdef inline void element_clear(fmpz_poly_t x): # get and set -cdef inline Integer element_get_sage(fmpz_poly_t x, PowComputer_flint prime_pow): +cdef inline Integer element_get_sage(fmpz_poly_t x, PowComputer_flint prime_pow) noexcept: r""" Convert a digit to a Sage element. @@ -348,7 +348,7 @@ cdef inline Integer element_get_sage(fmpz_poly_t x, PowComputer_flint prime_pow) fmpz_clear(value) return ans -cdef inline void element_set(fmpz_poly_t x, fmpz_poly_t y): +cdef inline void element_set(fmpz_poly_t x, fmpz_poly_t y) noexcept: r""" Set an element @@ -361,7 +361,7 @@ cdef inline void element_set(fmpz_poly_t x, fmpz_poly_t y): # get and set digits -cdef inline fmpz* element_get_digit(fmpz_poly_t x, slong i): +cdef inline fmpz* element_get_digit(fmpz_poly_t x, slong i) noexcept: r""" Return the `i`-th coefficient of `x`. @@ -372,7 +372,7 @@ cdef inline fmpz* element_get_digit(fmpz_poly_t x, slong i): """ return get_coeff(x, i) -cdef inline void element_get_slice(fmpz_poly_t res, fmpz_poly_t x, slong start, slong length): +cdef inline void element_get_slice(fmpz_poly_t res, fmpz_poly_t x, slong start, slong length) noexcept: r""" Select a slice of an element. @@ -391,7 +391,7 @@ cdef inline void element_get_slice(fmpz_poly_t res, fmpz_poly_t x, slong start, """ get_slice(res, x, start, length) -cdef inline void element_set_digit(fmpz_poly_t x, fmpz_t a, slong i): +cdef inline void element_set_digit(fmpz_poly_t x, fmpz_t a, slong i) noexcept: r""" Set `i`-th coefficient of `x` to the value `a`. @@ -403,7 +403,7 @@ cdef inline void element_set_digit(fmpz_poly_t x, fmpz_t a, slong i): """ fmpz_poly_set_coeff_fmpz(x, i, a) -cdef inline void element_set_digit_ui(fmpz_poly_t x, slong a, slong i): +cdef inline void element_set_digit_ui(fmpz_poly_t x, slong a, slong i) noexcept: r""" Set `i`-th coefficient of `x` to the value `a`. @@ -415,7 +415,7 @@ cdef inline void element_set_digit_ui(fmpz_poly_t x, slong a, slong i): """ fmpz_poly_set_coeff_ui(x, i, a) -cdef inline void element_set_digit_sage(fmpz_poly_t x, Integer a, slong i): +cdef inline void element_set_digit_sage(fmpz_poly_t x, Integer a, slong i) noexcept: r""" Set `i`-th coefficient of `x` to the value `a`. @@ -429,7 +429,7 @@ cdef inline void element_set_digit_sage(fmpz_poly_t x, Integer a, slong i): # operations -cdef inline void element_iadd_digit(fmpz_poly_t x, fmpz_t a, slong i): +cdef inline void element_iadd_digit(fmpz_poly_t x, fmpz_t a, slong i) noexcept: r""" Inplace addition: add `a` to the `i`-th coefficient of `x`. @@ -442,7 +442,7 @@ cdef inline void element_iadd_digit(fmpz_poly_t x, fmpz_t a, slong i): """ iadd_coeff(x, a, i) -cdef inline void element_isub_digit(fmpz_poly_t x, fmpz_t a, slong i): +cdef inline void element_isub_digit(fmpz_poly_t x, fmpz_t a, slong i) noexcept: r""" Inplace subtraction: subtract `a` to the `i`-th coefficient of `x`. @@ -455,7 +455,7 @@ cdef inline void element_isub_digit(fmpz_poly_t x, fmpz_t a, slong i): """ isub_coeff(x, a, i) -cdef inline void element_iadd_slice(fmpz_poly_t x, fmpz_poly_t slice, slong start): +cdef inline void element_iadd_slice(fmpz_poly_t x, fmpz_poly_t slice, slong start) noexcept: r""" Inplace addition: add a slice to an element @@ -468,7 +468,7 @@ cdef inline void element_iadd_slice(fmpz_poly_t x, fmpz_poly_t slice, slong star """ iadd_shifted(x, slice, start) -cdef inline void element_scalarmul(fmpz_poly_t res, fmpz_poly_t x, fmpz_t a): +cdef inline void element_scalarmul(fmpz_poly_t res, fmpz_poly_t x, fmpz_t a) noexcept: r""" Scalar multiplication. @@ -480,7 +480,7 @@ cdef inline void element_scalarmul(fmpz_poly_t res, fmpz_poly_t x, fmpz_t a): """ fmpz_poly_scalar_mul_fmpz(res, x, a) -cdef inline void element_mul(fmpz_poly_t res, fmpz_poly_t x, fmpz_poly_t y): +cdef inline void element_mul(fmpz_poly_t res, fmpz_poly_t x, fmpz_poly_t y) noexcept: r""" Multiplication. @@ -492,7 +492,7 @@ cdef inline void element_mul(fmpz_poly_t res, fmpz_poly_t x, fmpz_poly_t y): """ fmpz_poly_mul(res, x, y) -cdef inline void element_reduce_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow): +cdef inline void element_reduce_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow) noexcept: r""" Reduce the `i`-th digit of `x` and propagate carry. @@ -504,7 +504,7 @@ cdef inline void element_reduce_digit(fmpz_poly_t x, slong i, PowComputer_flint """ reduce_coeff(x, i, prime_pow.fprime) -cdef inline void element_reducesmall_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow): +cdef inline void element_reducesmall_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow) noexcept: r""" Reduce the `i`-th digit of `x` and propagate carry, assuming that `x` is between `0` and `2*p - 1`. @@ -517,7 +517,7 @@ cdef inline void element_reducesmall_digit(fmpz_poly_t x, slong i, PowComputer_f """ reducesmall_coeff(x, i, prime_pow.fprime) -cdef inline void element_reduceneg_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow): +cdef inline void element_reduceneg_digit(fmpz_poly_t x, slong i, PowComputer_flint prime_pow) noexcept: r""" Reduce the `i`-th digit of `x` and propagate carry, assuming that `x` is between `-p` and `p-1`. @@ -530,7 +530,7 @@ cdef inline void element_reduceneg_digit(fmpz_poly_t x, slong i, PowComputer_fli """ reduceneg_coeff(x, i, prime_pow.fprime) -cdef inline void element_shift_right(fmpz_poly_t x): +cdef inline void element_shift_right(fmpz_poly_t x) noexcept: r""" Remove the first digit of ``x``. diff --git a/src/sage/libs/mpmath/ext_impl.pxd b/src/sage/libs/mpmath/ext_impl.pxd index b934826ef56..f2540d326dd 100644 --- a/src/sage/libs/mpmath/ext_impl.pxd +++ b/src/sage/libs/mpmath/ext_impl.pxd @@ -4,63 +4,63 @@ ctypedef struct MPopts: long prec int rounding -cdef mpz_set_integer(mpz_t v, x) -cdef mpzi(mpz_t n) -cdef mpzl(mpz_t n) -cdef str rndmode_to_python(int rnd) -cdef rndmode_from_python(str rnd) +cdef mpz_set_integer(mpz_t v, x) noexcept +cdef mpzi(mpz_t n) noexcept +cdef mpzl(mpz_t n) noexcept +cdef str rndmode_to_python(int rnd) noexcept +cdef rndmode_from_python(str rnd) noexcept ctypedef struct MPF: mpz_t man mpz_t exp int special -cdef void MPF_init(MPF *x) -cdef void MPF_clear(MPF *x) -cdef void MPF_set(MPF *dest, MPF *src) -cdef void MPF_set_zero(MPF *x) -cdef void MPF_set_one(MPF *x) -cdef void MPF_set_nan(MPF *x) -cdef void MPF_set_inf(MPF *x) -cdef void MPF_set_ninf(MPF *x) -cdef MPF_set_si(MPF *x, long n) -cdef MPF_set_int(MPF *x, n) -cdef MPF_set_man_exp(MPF *x, man, exp) -cdef MPF_set_tuple(MPF *x, tuple value) -cdef MPF_to_tuple(MPF *x) -cdef MPF_set_double(MPF *r, double x) -cdef double MPF_to_double(MPF *x, bint strict) -cdef MPF_to_fixed(mpz_t r, MPF *x, long prec, bint truncate) -cdef int MPF_sgn(MPF *x) -cdef void MPF_neg(MPF *r, MPF *s) -cdef void MPF_abs(MPF *r, MPF *s) -cdef MPF_normalize(MPF *x, MPopts opts) -cdef void MPF_pos(MPF *x, MPF *y, MPopts opts) -cdef MPF_add(MPF *r, MPF *s, MPF *t, MPopts opts) -cdef MPF_sub(MPF *r, MPF *s, MPF *t, MPopts opts) -cdef bint MPF_eq(MPF *s, MPF *t) -cdef bint MPF_ne(MPF *s, MPF *t) -cdef int MPF_cmp(MPF *s, MPF *t) -cdef bint MPF_lt(MPF *s, MPF *t) -cdef bint MPF_le(MPF *s, MPF *t) -cdef bint MPF_gt(MPF *s, MPF *t) -cdef bint MPF_ge(MPF *s, MPF *t) -cdef MPF_mul(MPF *r, MPF *s, MPF *t, MPopts opts) -cdef MPF_div(MPF *r, MPF *s, MPF *t, MPopts opts) -cdef int MPF_sqrt(MPF *r, MPF *s, MPopts opts) -cdef MPF_hypot(MPF *r, MPF *a, MPF *b, MPopts opts) -cdef MPF_pow_int(MPF *r, MPF *x, mpz_t n, MPopts opts) -cdef MPF_set_double(MPF *r, double x) -cdef MPF_exp(MPF *y, MPF *x, MPopts opts) -cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts) -cdef MPF_complex_exp(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts) -cdef int MPF_log(MPF *y, MPF *x, MPopts opts) -cdef MPF_set_pi(MPF *x, MPopts opts) -cdef MPF_set_ln2(MPF *x, MPopts opts) -cdef MPF_cos(MPF *c, MPF *x, MPopts opts) -cdef MPF_sin(MPF *c, MPF *x, MPopts opts) -cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts) +cdef void MPF_init(MPF *x) noexcept +cdef void MPF_clear(MPF *x) noexcept +cdef void MPF_set(MPF *dest, MPF *src) noexcept +cdef void MPF_set_zero(MPF *x) noexcept +cdef void MPF_set_one(MPF *x) noexcept +cdef void MPF_set_nan(MPF *x) noexcept +cdef void MPF_set_inf(MPF *x) noexcept +cdef void MPF_set_ninf(MPF *x) noexcept +cdef MPF_set_si(MPF *x, long n) noexcept +cdef MPF_set_int(MPF *x, n) noexcept +cdef MPF_set_man_exp(MPF *x, man, exp) noexcept +cdef MPF_set_tuple(MPF *x, tuple value) noexcept +cdef MPF_to_tuple(MPF *x) noexcept +cdef MPF_set_double(MPF *r, double x) noexcept +cdef double MPF_to_double(MPF *x, bint strict) noexcept +cdef MPF_to_fixed(mpz_t r, MPF *x, long prec, bint truncate) noexcept +cdef int MPF_sgn(MPF *x) noexcept +cdef void MPF_neg(MPF *r, MPF *s) noexcept +cdef void MPF_abs(MPF *r, MPF *s) noexcept +cdef MPF_normalize(MPF *x, MPopts opts) noexcept +cdef void MPF_pos(MPF *x, MPF *y, MPopts opts) noexcept +cdef MPF_add(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept +cdef MPF_sub(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept +cdef bint MPF_eq(MPF *s, MPF *t) noexcept +cdef bint MPF_ne(MPF *s, MPF *t) noexcept +cdef int MPF_cmp(MPF *s, MPF *t) noexcept +cdef bint MPF_lt(MPF *s, MPF *t) noexcept +cdef bint MPF_le(MPF *s, MPF *t) noexcept +cdef bint MPF_gt(MPF *s, MPF *t) noexcept +cdef bint MPF_ge(MPF *s, MPF *t) noexcept +cdef MPF_mul(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept +cdef MPF_div(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept +cdef int MPF_sqrt(MPF *r, MPF *s, MPopts opts) noexcept +cdef MPF_hypot(MPF *r, MPF *a, MPF *b, MPopts opts) noexcept +cdef MPF_pow_int(MPF *r, MPF *x, mpz_t n, MPopts opts) noexcept +cdef MPF_set_double(MPF *r, double x) noexcept +cdef MPF_exp(MPF *y, MPF *x, MPopts opts) noexcept +cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts) noexcept +cdef MPF_complex_exp(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts) noexcept +cdef int MPF_log(MPF *y, MPF *x, MPopts opts) noexcept +cdef MPF_set_pi(MPF *x, MPopts opts) noexcept +cdef MPF_set_ln2(MPF *x, MPopts opts) noexcept +cdef MPF_cos(MPF *c, MPF *x, MPopts opts) noexcept +cdef MPF_sin(MPF *c, MPF *x, MPopts opts) noexcept +cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts) noexcept cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts) except -1 -cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPopts opts) +cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPopts opts) noexcept cdef MPF_hypsum(MPF *a, MPF *b, int p, int q, param_types, str ztype, coeffs, \ - z, long prec, long wp, long epsshift, dict magnitude_check, kwargs) + z, long prec, long wp, long epsshift, dict magnitude_check, kwargs) noexcept diff --git a/src/sage/libs/mpmath/ext_impl.pyx b/src/sage/libs/mpmath/ext_impl.pyx index 2d8d2470273..aa69f6e0409 100644 --- a/src/sage/libs/mpmath/ext_impl.pyx +++ b/src/sage/libs/mpmath/ext_impl.pyx @@ -42,7 +42,7 @@ from sage.rings.integer cimport Integer from sage.libs.gmp.pylong cimport * -cdef mpz_set_integer(mpz_t v, x): +cdef mpz_set_integer(mpz_t v, x) noexcept: if isinstance(x, int): mpz_set_pylong(v, x) elif isinstance(x, Integer): @@ -50,21 +50,21 @@ cdef mpz_set_integer(mpz_t v, x): else: raise TypeError("cannot convert %s to an integer" % x) -cdef inline void mpz_add_si(mpz_t a, mpz_t b, long x): +cdef inline void mpz_add_si(mpz_t a, mpz_t b, long x) noexcept: if x >= 0: mpz_add_ui(a, b, x) else: # careful: overflow when negating INT_MIN mpz_sub_ui(a, b, (-x)) -cdef inline mpzi(mpz_t n): +cdef inline mpzi(mpz_t n) noexcept: return mpz_get_pyintlong(n) -cdef inline mpzl(mpz_t n): +cdef inline mpzl(mpz_t n) noexcept: return mpz_get_pylong(n) # This should be done better -cdef int mpz_tstbit_abs(mpz_t z, unsigned long bit_index): +cdef int mpz_tstbit_abs(mpz_t z, unsigned long bit_index) noexcept: cdef int res if mpz_sgn(z) < 0: mpz_neg(z, z) @@ -74,7 +74,7 @@ cdef int mpz_tstbit_abs(mpz_t z, unsigned long bit_index): res = mpz_tstbit(z, bit_index) return res -cdef void mpz_set_fixed(mpz_t t, MPF *x, int prec, bint abs=False): +cdef void mpz_set_fixed(mpz_t t, MPF *x, int prec, bint abs=False) noexcept: """ Set t = x, or t = |x|, as a fixed-point number with prec bits. """ @@ -87,7 +87,7 @@ cdef void mpz_set_fixed(mpz_t t, MPF *x, int prec, bint abs=False): if abs: mpz_abs(t, t) -cdef unsigned long mpz_bitcount(mpz_t z): +cdef unsigned long mpz_bitcount(mpz_t z) noexcept: if mpz_sgn(z) == 0: return 0 return mpz_sizeinbase(z, 2) @@ -101,7 +101,7 @@ cdef unsigned long mpz_bitcount(mpz_t z): # Note: MPFR's emax is 1073741823 DEF MAX_SHIFT = 536870912 # 2^29 -cdef int mpz_reasonable_shift(mpz_t z): +cdef int mpz_reasonable_shift(mpz_t z) noexcept: if mpz_sgn(z) > 0: return mpz_cmp_ui(z, MAX_SHIFT) < 0 else: @@ -120,28 +120,28 @@ DEF S_INF = 3 DEF S_NINF = 4 DEF S_NAN = 5 -cdef inline str rndmode_to_python(int rnd): +cdef inline str rndmode_to_python(int rnd) noexcept: if rnd == ROUND_N: return 'n' if rnd == ROUND_F: return 'f' if rnd == ROUND_C: return 'c' if rnd == ROUND_D: return 'd' if rnd == ROUND_U: return 'u' -cdef inline rndmode_from_python(str rnd): +cdef inline rndmode_from_python(str rnd) noexcept: if rnd == 'n': return ROUND_N if rnd == 'f': return ROUND_F if rnd == 'c': return ROUND_C if rnd == 'd': return ROUND_D if rnd == 'u': return ROUND_U -cdef inline mpfr_rnd_t rndmode_to_mpfr(int rnd): +cdef inline mpfr_rnd_t rndmode_to_mpfr(int rnd) noexcept: if rnd == ROUND_N: return MPFR_RNDN if rnd == ROUND_F: return MPFR_RNDD if rnd == ROUND_C: return MPFR_RNDU if rnd == ROUND_D: return MPFR_RNDZ if rnd == ROUND_U: return MPFR_RNDA -cdef inline int reciprocal_rnd(int rnd): +cdef inline int reciprocal_rnd(int rnd) noexcept: if rnd == ROUND_N: return ROUND_N if rnd == ROUND_D: return ROUND_U if rnd == ROUND_U: return ROUND_D @@ -163,19 +163,19 @@ cdef double _double_inf = float("1e300") * float("1e300") cdef double _double_ninf = -_double_inf cdef double _double_nan = _double_inf - _double_inf -cdef inline void MPF_init(MPF *x): +cdef inline void MPF_init(MPF *x) noexcept: """Allocate space and set value to zero. Must be called exactly once when creating a new MPF.""" x.special = S_ZERO mpz_init(x.man) mpz_init(x.exp) -cdef inline void MPF_clear(MPF *x): +cdef inline void MPF_clear(MPF *x) noexcept: """Deallocate space. Must be called exactly once when finished with an MPF.""" mpz_clear(x.man) mpz_clear(x.exp) -cdef inline void MPF_set(MPF *dest, MPF *src): +cdef inline void MPF_set(MPF *dest, MPF *src) noexcept: """Clone MPF value. Assumes source value is already normalized.""" if src is dest: return @@ -183,29 +183,29 @@ cdef inline void MPF_set(MPF *dest, MPF *src): mpz_set(dest.man, src.man) mpz_set(dest.exp, src.exp) -cdef inline void MPF_set_zero(MPF *x): +cdef inline void MPF_set_zero(MPF *x) noexcept: """Set value to 0.""" x.special = S_ZERO -cdef inline void MPF_set_one(MPF *x): +cdef inline void MPF_set_one(MPF *x) noexcept: """Set value to 1.""" x.special = S_NORMAL mpz_set_ui(x.man, 1) mpz_set_ui(x.exp, 0) -cdef inline void MPF_set_nan(MPF *x): +cdef inline void MPF_set_nan(MPF *x) noexcept: """Set value to NaN (not a number).""" x.special = S_NAN -cdef inline void MPF_set_inf(MPF *x): +cdef inline void MPF_set_inf(MPF *x) noexcept: """Set value to +infinity.""" x.special = S_INF -cdef inline void MPF_set_ninf(MPF *x): +cdef inline void MPF_set_ninf(MPF *x) noexcept: """Set value to -infinity.""" x.special = S_NINF -cdef MPF_set_si(MPF *x, long n): +cdef MPF_set_si(MPF *x, long n) noexcept: """Set value to that of a given C (long) integer.""" if n: x.special = S_NORMAL @@ -215,7 +215,7 @@ cdef MPF_set_si(MPF *x, long n): else: MPF_set_zero(x) -cdef MPF_set_int(MPF *x, n): +cdef MPF_set_int(MPF *x, n) noexcept: """Set value to that of a given Python integer.""" x.special = S_NORMAL mpz_set_integer(x.man, n) @@ -225,7 +225,7 @@ cdef MPF_set_int(MPF *x, n): else: MPF_set_zero(x) -cdef MPF_set_man_exp(MPF *x, man, exp): +cdef MPF_set_man_exp(MPF *x, man, exp) noexcept: """ Set value to man*2^exp where man, exp may be of any appropriate Python integer types. @@ -260,7 +260,7 @@ cdef tuple _mpf_fnan = (0, MPZ_ZERO, -123, -1) cdef tuple _mpf_finf = (0, MPZ_ZERO, -456, -2) cdef tuple _mpf_fninf = (1, MPZ_ZERO, -789, -3) -cdef MPF_set_tuple(MPF *x, tuple value): +cdef MPF_set_tuple(MPF *x, tuple value) noexcept: """ Set value of an MPF to that of a normalized (sign, man, exp, bc) tuple in the format used by mpmath.libmp. @@ -289,7 +289,7 @@ cdef MPF_set_tuple(MPF *x, tuple value): else: MPF_set_nan(x) -cdef MPF_to_tuple(MPF *x): +cdef MPF_to_tuple(MPF *x) noexcept: """Convert MPF value to (sign, man, exp, bc) tuple.""" cdef Integer man if x.special: @@ -309,7 +309,7 @@ cdef MPF_to_tuple(MPF *x): bc = mpz_sizeinbase(x.man, 2) return (sign, man, exp, bc) -cdef MPF_set_double(MPF *r, double x): +cdef MPF_set_double(MPF *r, double x) noexcept: """ Set r to the value of a C double x. """ @@ -334,7 +334,7 @@ cdef MPF_set_double(MPF *r, double x): import math as pymath # TODO: implement this function safely without using the Python math module -cdef double MPF_to_double(MPF *x, bint strict): +cdef double MPF_to_double(MPF *x, bint strict) noexcept: """Convert MPF value to a Python float.""" if x.special == S_NORMAL: man = mpzi(x.man) @@ -366,7 +366,7 @@ cdef double MPF_to_double(MPF *x, bint strict): return _double_ninf return _double_nan -cdef MPF_to_fixed(mpz_t r, MPF *x, long prec, bint truncate): +cdef MPF_to_fixed(mpz_t r, MPF *x, long prec, bint truncate) noexcept: """ Set r = x, r being in the format of a fixed-point number with prec bits. Floor division is used unless truncate=True in which case @@ -395,7 +395,7 @@ cdef MPF_to_fixed(mpz_t r, MPF *x, long prec, bint truncate): return raise OverflowError("cannot convert huge number to fixed-point format") -cdef int MPF_sgn(MPF *x): +cdef int MPF_sgn(MPF *x) noexcept: """ Gives the sign of an MPF (-1, 0, or 1). """ @@ -407,7 +407,7 @@ cdef int MPF_sgn(MPF *x): return 0 return mpz_sgn(x.man) -cdef void MPF_neg(MPF *r, MPF *s): +cdef void MPF_neg(MPF *r, MPF *s) noexcept: """ Sets r = -s. MPF_neg(x, x) negates in place. """ @@ -428,7 +428,7 @@ cdef void MPF_neg(MPF *r, MPF *s): if r is not s: mpz_set(r.exp, s.exp) -cdef void MPF_abs(MPF *r, MPF *s): +cdef void MPF_abs(MPF *r, MPF *s) noexcept: """ Sets r = abs(s). MPF_abs(r, r) sets the absolute value in place. """ @@ -443,7 +443,7 @@ cdef void MPF_abs(MPF *r, MPF *s): if r is not s: mpz_set(r.exp, s.exp) -cdef MPF_normalize(MPF *x, MPopts opts): +cdef MPF_normalize(MPF *x, MPopts opts) noexcept: """ Normalize. @@ -500,7 +500,7 @@ cdef MPF_normalize(MPF *x, MPopts opts): shift += trail mpz_add_si(x.exp, x.exp, shift) -cdef void MPF_pos(MPF *x, MPF *y, MPopts opts): +cdef void MPF_pos(MPF *x, MPF *y, MPopts opts) noexcept: """ Set x = +y (i.e. copy the value, and round if the working precision is smaller than the width @@ -509,7 +509,7 @@ cdef void MPF_pos(MPF *x, MPF *y, MPopts opts): MPF_set(x, y) MPF_normalize(x, opts) -cdef void _add_special(MPF *r, MPF *s, MPF *t): +cdef void _add_special(MPF *r, MPF *s, MPF *t) noexcept: if s.special == S_ZERO: # (+0) + (-0) = +0 if t.special == S_NZERO: @@ -542,7 +542,7 @@ cdef void _add_special(MPF *r, MPF *s, MPF *t): MPF_set(r, t) return -cdef void _sub_special(MPF *r, MPF *s, MPF *t): +cdef void _sub_special(MPF *r, MPF *s, MPF *t) noexcept: if s.special == S_ZERO: # (+0) - (+/-0) = (+0) if t.special == S_NZERO: @@ -577,7 +577,7 @@ cdef void _sub_special(MPF *r, MPF *s, MPF *t): else: MPF_neg(r, t) -cdef void _mul_special(MPF *r, MPF *s, MPF *t): +cdef void _mul_special(MPF *r, MPF *s, MPF *t) noexcept: if s.special == S_ZERO: if t.special == S_NORMAL or t.special == S_ZERO: MPF_set(r, s) @@ -616,7 +616,7 @@ cdef void _mul_special(MPF *r, MPF *s, MPF *t): else: MPF_set_ninf(r) -cdef _div_special(MPF *r, MPF *s, MPF *t): +cdef _div_special(MPF *r, MPF *s, MPF *t) noexcept: # TODO: handle signed zeros correctly if s.special == S_NAN or t.special == S_NAN: MPF_set_nan(r) @@ -637,7 +637,7 @@ cdef _div_special(MPF *r, MPF *s, MPF *t): elif t.special == S_INF or t.special == S_NINF: MPF_set_zero(r) -cdef _add_perturbation(MPF *r, MPF *s, int sign, MPopts opts): +cdef _add_perturbation(MPF *r, MPF *s, int sign, MPopts opts) noexcept: cdef long shift if opts.rounding == ROUND_N: MPF_set(r, s) @@ -650,7 +650,7 @@ cdef _add_perturbation(MPF *r, MPF *s, int sign, MPopts opts): mpz_sub_ui(r.exp, s.exp, shift) MPF_normalize(r, opts) -cdef MPF_add(MPF *r, MPF *s, MPF *t, MPopts opts): +cdef MPF_add(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept: """ Set r = s + t, with exact rounding. @@ -704,7 +704,7 @@ cdef MPF_add(MPF *r, MPF *s, MPF *t, MPopts opts): else: _add_perturbation(r, t, mpz_sgn(s.man), opts) -cdef MPF_sub(MPF *r, MPF *s, MPF *t, MPopts opts): +cdef MPF_sub(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept: """ Set r = s - t, with exact rounding. @@ -760,7 +760,7 @@ cdef MPF_sub(MPF *r, MPF *s, MPF *t, MPopts opts): _add_perturbation(r, t, -mpz_sgn(s.man), opts) MPF_neg(r, r) -cdef bint MPF_eq(MPF *s, MPF *t): +cdef bint MPF_eq(MPF *s, MPF *t) noexcept: """ Evaluates s == t. """ @@ -773,7 +773,7 @@ cdef bint MPF_eq(MPF *s, MPF *t): return True return False -cdef bint MPF_ne(MPF *s, MPF *t): +cdef bint MPF_ne(MPF *s, MPF *t) noexcept: """ Evaluates s != t. """ @@ -783,7 +783,7 @@ cdef bint MPF_ne(MPF *s, MPF *t): return (mpz_cmp(s.man, t.man) != 0) or (mpz_cmp(s.exp, t.exp) != 0) return s.special != t.special -cdef int MPF_cmp(MPF *s, MPF *t): +cdef int MPF_cmp(MPF *s, MPF *t) noexcept: """ Evaluates cmp(s,t). Conventions for nan follow those of the mpmath.libmp function. @@ -818,7 +818,7 @@ cdef int MPF_cmp(MPF *s, MPF *t): MPF_sub(&tmp1, s, t, opts_mini_prec) return MPF_sgn(&tmp1) -cdef bint MPF_lt(MPF *s, MPF *t): +cdef bint MPF_lt(MPF *s, MPF *t) noexcept: """ Evaluates s < t. """ @@ -826,7 +826,7 @@ cdef bint MPF_lt(MPF *s, MPF *t): return False return MPF_cmp(s, t) < 0 -cdef bint MPF_le(MPF *s, MPF *t): +cdef bint MPF_le(MPF *s, MPF *t) noexcept: """ Evaluates s <= t. """ @@ -834,7 +834,7 @@ cdef bint MPF_le(MPF *s, MPF *t): return False return MPF_cmp(s, t) <= 0 -cdef bint MPF_gt(MPF *s, MPF *t): +cdef bint MPF_gt(MPF *s, MPF *t) noexcept: """ Evaluates s > t. """ @@ -842,7 +842,7 @@ cdef bint MPF_gt(MPF *s, MPF *t): return False return MPF_cmp(s, t) > 0 -cdef bint MPF_ge(MPF *s, MPF *t): +cdef bint MPF_ge(MPF *s, MPF *t) noexcept: """ Evaluates s >= t. """ @@ -850,7 +850,7 @@ cdef bint MPF_ge(MPF *s, MPF *t): return False return MPF_cmp(s, t) >= 0 -cdef MPF_mul(MPF *r, MPF *s, MPF *t, MPopts opts): +cdef MPF_mul(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept: """ Set r = s * t, with correct rounding. @@ -866,7 +866,7 @@ cdef MPF_mul(MPF *r, MPF *s, MPF *t, MPopts opts): if opts.prec: MPF_normalize(r, opts) -cdef MPF_div(MPF *r, MPF *s, MPF *t, MPopts opts): +cdef MPF_div(MPF *r, MPF *s, MPF *t, MPopts opts) noexcept: """ Set r = s / t, with correct rounding. """ @@ -912,7 +912,7 @@ cdef MPF_div(MPF *r, MPF *s, MPF *t, MPopts opts): mpz_sub_ui(r.exp, r.exp, extra) MPF_normalize(r, opts) -cdef int MPF_sqrt(MPF *r, MPF *s, MPopts opts): +cdef int MPF_sqrt(MPF *r, MPF *s, MPopts opts) noexcept: """ Set r = sqrt(s), with correct rounding. """ @@ -961,7 +961,7 @@ cdef int MPF_sqrt(MPF *r, MPF *s, MPopts opts): MPF_normalize(r, opts) return 0 -cdef MPF_hypot(MPF *r, MPF *a, MPF *b, MPopts opts): +cdef MPF_hypot(MPF *r, MPF *a, MPF *b, MPopts opts) noexcept: """ Set r = sqrt(a^2 + b^2) """ @@ -981,7 +981,7 @@ cdef MPF_hypot(MPF *r, MPF *a, MPF *b, MPopts opts): MPF_add(r, &tmp1, &tmp2, tmp_opts) MPF_sqrt(r, r, opts) -cdef MPF_pow_int(MPF *r, MPF *x, mpz_t n, MPopts opts): +cdef MPF_pow_int(MPF *r, MPF *x, mpz_t n, MPopts opts) noexcept: """ Set r = x ** n. Currently falls back to mpmath.libmp unless n is tiny. @@ -1074,7 +1074,7 @@ cdef int _pi_prec = -1 cdef mpz_t _ln2_value cdef int _ln2_prec = -1 -cdef mpz_set_pi(mpz_t x, int prec): +cdef mpz_set_pi(mpz_t x, int prec) noexcept: """ Set x = pi as a fixed-point number. """ @@ -1090,7 +1090,7 @@ cdef mpz_set_pi(mpz_t x, int prec): mpz_set(x, _pi_value) _pi_prec = prec -cdef mpz_set_ln2(mpz_t x, int prec): +cdef mpz_set_ln2(mpz_t x, int prec) noexcept: """ Set x = ln(2) as a fixed-point number. """ @@ -1106,7 +1106,7 @@ cdef mpz_set_ln2(mpz_t x, int prec): mpz_set(x, _ln2_value) _ln2_prec = prec -cdef void _cy_exp_mpfr(mpz_t y, mpz_t x, int prec): +cdef void _cy_exp_mpfr(mpz_t y, mpz_t x, int prec) noexcept: """ Computes y = exp(x) for fixed-point numbers y and x using MPFR, assuming that no overflow will occur. @@ -1122,7 +1122,7 @@ cdef void _cy_exp_mpfr(mpz_t y, mpz_t x, int prec): mpfr_clear(yf) mpfr_clear(xf) -cdef cy_exp_basecase(mpz_t y, mpz_t x, int prec): +cdef cy_exp_basecase(mpz_t y, mpz_t x, int prec) noexcept: """ Computes y = exp(x) for fixed-point numbers y and x, assuming that x is small (|x| ~< 1). At small precisions, this function @@ -1174,7 +1174,7 @@ cdef cy_exp_basecase(mpz_t y, mpz_t x, int prec): mpz_clear(a) -cdef MPF_exp(MPF *y, MPF *x, MPopts opts): +cdef MPF_exp(MPF *y, MPF *x, MPopts opts) noexcept: """ Set y = exp(x). """ @@ -1229,7 +1229,7 @@ cdef MPF_exp(MPF *y, MPF *x, MPopts opts): MPF_normalize(y, opts) -cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts): +cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts) noexcept: """ Set c+di = sqrt(a+bi). @@ -1287,7 +1287,7 @@ cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts): MPF_clear(&u) MPF_clear(&v) -cdef int MPF_get_mpfr_overflow(mpfr_t y, MPF *x): +cdef int MPF_get_mpfr_overflow(mpfr_t y, MPF *x) noexcept: """ Store the mpmath number x exactly in the MPFR variable y. The precision of y will be adjusted if necessary. If the exponent overflows, only @@ -1321,7 +1321,7 @@ cdef int MPF_get_mpfr_overflow(mpfr_t y, MPF *x): else: return 1 -cdef MPF_set_mpfr(MPF *y, mpfr_t x, MPopts opts): +cdef MPF_set_mpfr(MPF *y, mpfr_t x, MPopts opts) noexcept: """ Convert the MPFR number x to a normalized MPF y. inf/nan and zero are handled. @@ -1345,7 +1345,7 @@ cdef MPF_set_mpfr(MPF *y, mpfr_t x, MPopts opts): y.special = S_NORMAL MPF_normalize(y, opts) -cdef int MPF_log(MPF *y, MPF *x, MPopts opts): +cdef int MPF_log(MPF *y, MPF *x, MPopts opts) noexcept: """ Set y = log(|x|). Returns 1 if x is negative. """ @@ -1400,7 +1400,7 @@ cdef int MPF_log(MPF *y, MPF *x, MPopts opts): mpfr_clear(yy) return negative -cdef MPF_set_pi(MPF *x, MPopts opts): +cdef MPF_set_pi(MPF *x, MPopts opts) noexcept: """ Set x = pi. """ @@ -1409,7 +1409,7 @@ cdef MPF_set_pi(MPF *x, MPopts opts): mpz_set_si(x.exp, -(opts.prec+20)) MPF_normalize(x, opts) -cdef MPF_set_ln2(MPF *x, MPopts opts): +cdef MPF_set_ln2(MPF *x, MPopts opts) noexcept: """ Set x = ln(2). """ @@ -1493,7 +1493,7 @@ cdef mpz_t log_int_cache[MAX_LOG_INT_CACHE+1] cdef long log_int_cache_prec[MAX_LOG_INT_CACHE+1] cdef bint log_int_cache_initialized = 0 -cdef mpz_log_int(mpz_t v, mpz_t n, int prec): +cdef mpz_log_int(mpz_t v, mpz_t n, int prec) noexcept: """ Set v = log(n) where n is an integer and v is a fixed-point number with the specified precision. @@ -1543,7 +1543,7 @@ def log_int_fixed(n, long prec, ln2=None): return t -cdef _MPF_cos_python(MPF *c, MPF *x, MPopts opts): +cdef _MPF_cos_python(MPF *c, MPF *x, MPopts opts) noexcept: """ Computes c = cos(x) by calling the mpmath.libmp Python implementation. """ @@ -1552,7 +1552,7 @@ cdef _MPF_cos_python(MPF *c, MPF *x, MPopts opts): rndmode_to_python(opts.rounding), 1, False) MPF_set_tuple(c, ct) -cdef _MPF_sin_python(MPF *s, MPF *x, MPopts opts): +cdef _MPF_sin_python(MPF *s, MPF *x, MPopts opts) noexcept: """ Computes s = sin(x) by calling the mpmath.libmp Python implementation. """ @@ -1562,7 +1562,7 @@ cdef _MPF_sin_python(MPF *s, MPF *x, MPopts opts): MPF_set_tuple(s, st) -cdef MPF_cos(MPF *c, MPF *x, MPopts opts): +cdef MPF_cos(MPF *c, MPF *x, MPopts opts) noexcept: """ Set c = cos(x) """ @@ -1585,7 +1585,7 @@ cdef MPF_cos(MPF *c, MPF *x, MPopts opts): mpfr_clear(xf) mpfr_clear(cf) -cdef MPF_sin(MPF *s, MPF *x, MPopts opts): +cdef MPF_sin(MPF *s, MPF *x, MPopts opts) noexcept: """ Set s = sin(x) """ @@ -1608,7 +1608,7 @@ cdef MPF_sin(MPF *s, MPF *x, MPopts opts): mpfr_clear(xf) mpfr_clear(sf) -cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts): +cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts) noexcept: """ Set c = cos(x), s = sin(x) """ @@ -1638,7 +1638,7 @@ cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts): mpfr_clear(sf) -cdef MPF_complex_exp(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts): +cdef MPF_complex_exp(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts) noexcept: """ Set re+im*i = exp(a+bi) """ @@ -1752,7 +1752,7 @@ cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts) except -1: MPF_clear(&w) return 0 -cdef MPF_complex_square(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts): +cdef MPF_complex_square(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts) noexcept: """ Set re+im*i = (a+bi)^2 = a^2-b^2, 2ab*i. """ @@ -1769,7 +1769,7 @@ cdef MPF_complex_square(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts): MPF_clear(&u) -cdef MPF_complex_reciprocal(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts): +cdef MPF_complex_reciprocal(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts) noexcept: """ Set re+im*i = 1/(a+bi), i.e. compute the reciprocal of a complex number. @@ -1793,7 +1793,7 @@ cdef MPF_complex_reciprocal(MPF *re, MPF *im, MPF *a, MPF *b, MPopts opts): MPF_clear(&m) -cdef MPF_complex_pow_int(MPF *zre, MPF *zim, MPF *xre, MPF *xim, mpz_t n, MPopts opts): +cdef MPF_complex_pow_int(MPF *zre, MPF *zim, MPF *xre, MPF *xim, mpz_t n, MPopts opts) noexcept: """ Set zre+zim*i = (xre+xim) ^ n, i.e. raise a complex number to an integer power. """ @@ -1859,7 +1859,7 @@ cdef MPF_complex_pow_int(MPF *zre, MPF *zim, MPF *xre, MPF *xim, mpz_t n, MPopts MPF_set_tuple(zim, vi) -cdef MPF_complex_pow_re(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *y, MPopts opts): +cdef MPF_complex_pow_re(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *y, MPopts opts) noexcept: """ Set (zre+zim*i) = (xre+xim*i) ^ y, i.e. raise a complex number to a real power. @@ -1904,7 +1904,7 @@ cdef MPF_complex_pow_re(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *y, MPopts o MPF_set_tuple(zim, vi) -cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPopts opts): +cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPopts opts) noexcept: """ Set (zre + zim*i) = (xre+xim*i) ^ (yre+yim*i). """ @@ -1922,7 +1922,7 @@ cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPF_set_tuple(zim, vi) -cdef mpz_set_tuple_fixed(mpz_t x, tuple t, long prec): +cdef mpz_set_tuple_fixed(mpz_t x, tuple t, long prec) noexcept: """ Set the integer x to a fixed-point number with specified precision and the value of t = (sign,man,exp,bc). Truncating division is used @@ -1939,7 +1939,7 @@ cdef mpz_set_tuple_fixed(mpz_t x, tuple t, long prec): else: mpz_tdiv_q_2exp(x, x, -offset) -cdef mpz_set_complex_tuple_fixed(mpz_t x, mpz_t y, tuple t, long prec): +cdef mpz_set_complex_tuple_fixed(mpz_t x, mpz_t y, tuple t, long prec) noexcept: """ Set the integers (x,y) to fixed-point numbers with the values of the mpf pair t = ((xsign,xman,xexp,xbc), (ysign,yman,yexp,ybc)). @@ -1947,7 +1947,7 @@ cdef mpz_set_complex_tuple_fixed(mpz_t x, mpz_t y, tuple t, long prec): mpz_set_tuple_fixed(x, t[0], prec) mpz_set_tuple_fixed(y, t[1], prec) -cdef MPF_set_fixed(MPF *x, mpz_t man, long wp, long prec, int rnd): +cdef MPF_set_fixed(MPF *x, mpz_t man, long wp, long prec, int rnd) noexcept: """ Set value of an MPF given a fixed-point mantissa of precision wp, rounding to the given precision and rounding mode. @@ -1978,7 +1978,7 @@ cdef mpz_t BCIM[MAX_PARAMS] cdef MPF_hypsum(MPF *a, MPF *b, int p, int q, param_types, str ztype, coeffs, z, - long prec, long wp, long epsshift, dict magnitude_check, kwargs): + long prec, long wp, long epsshift, dict magnitude_check, kwargs) noexcept: """ Evaluates a+bi = pFq(..., z) by summing the hypergeometric series in fixed-point arithmetic. diff --git a/src/sage/libs/mpmath/ext_main.pyx b/src/sage/libs/mpmath/ext_main.pyx index a46c85ba52f..a00c5ee4831 100644 --- a/src/sage/libs/mpmath/ext_main.pyx +++ b/src/sage/libs/mpmath/ext_main.pyx @@ -109,7 +109,7 @@ cdef class constant cdef class wrapped_libmp_function cdef class wrapped_specfun -cdef __isint(MPF *v): +cdef __isint(MPF *v) noexcept: return v.special == S_ZERO or (v.special == S_NORMAL and mpz_sgn(v.exp) >= 0) cdef int MPF_set_any(MPF *re, MPF *im, x, MPopts opts, bint str_tuple_ok) except -1: @@ -185,7 +185,7 @@ cdef int MPF_set_any(MPF *re, MPF *im, x, MPopts opts, bint str_tuple_ok) except return 1 return 0 -cdef binop(int op, x, y, MPopts opts): +cdef binop(int op, x, y, MPopts opts) noexcept: cdef int typx cdef int typy cdef MPF xre, xim, yre, yim @@ -498,7 +498,7 @@ cdef class Context: _prec_rounding = property(_get_prec_rounding) - cpdef mpf make_mpf(ctx, tuple v): + cpdef mpf make_mpf(ctx, tuple v) noexcept: """ Creates an mpf from tuple data :: @@ -511,7 +511,7 @@ cdef class Context: MPF_set_tuple(&x.value, v) return x - cpdef mpc make_mpc(ctx, tuple v): + cpdef mpc make_mpc(ctx, tuple v) noexcept: """ Creates an mpc from tuple data :: @@ -973,7 +973,7 @@ cdef class Context: # Doing a+b directly doesn't work with mpi, presumably due to # Cython trying to be clever with the operation resolution - cdef _stupid_add(ctx, a, b): + cdef _stupid_add(ctx, a, b) noexcept: return a + b def _convert_param(ctx, x): @@ -1178,7 +1178,7 @@ cdef class Context: f_wrapped.__doc__ = doc setattr(cls, name, f_wrapped) - cdef MPopts _fun_get_opts(ctx, kwargs): + cdef MPopts _fun_get_opts(ctx, kwargs) noexcept: """ Helper function that extracts precision and rounding information from kwargs, or returns the global working precision and rounding diff --git a/src/sage/libs/mpmath/utils.pxd b/src/sage/libs/mpmath/utils.pxd index 686b108da9a..646afa61899 100644 --- a/src/sage/libs/mpmath/utils.pxd +++ b/src/sage/libs/mpmath/utils.pxd @@ -1,3 +1,3 @@ from sage.libs.mpfr.types cimport mpfr_t -cdef mpfr_to_mpfval(mpfr_t) +cdef mpfr_to_mpfval(mpfr_t) noexcept diff --git a/src/sage/libs/mpmath/utils.pyx b/src/sage/libs/mpmath/utils.pyx index 83f8108be08..7265c0bf7a7 100644 --- a/src/sage/libs/mpmath/utils.pyx +++ b/src/sage/libs/mpmath/utils.pyx @@ -16,7 +16,7 @@ from sage.libs.gmp.all cimport * from sage.rings.real_mpfr cimport RealField -cpdef int bitcount(n): +cpdef int bitcount(n) noexcept: """ Bitcount of a Sage Integer or Python int/long. @@ -46,7 +46,7 @@ cpdef int bitcount(n): return 0 return mpz_sizeinbase(m.value, 2) -cpdef isqrt(n): +cpdef isqrt(n) noexcept: """ Square root (rounded to floor) of a Sage Integer or Python int/long. The result is a Sage Integer. @@ -77,7 +77,7 @@ cpdef isqrt(n): mpz_sqrt(y.value, m.value) return y -cpdef from_man_exp(man, exp, long prec = 0, str rnd = 'd'): +cpdef from_man_exp(man, exp, long prec = 0, str rnd = 'd') noexcept: """ Create normalized mpf value tuple from mantissa and exponent. @@ -106,7 +106,7 @@ cpdef from_man_exp(man, exp, long prec = 0, str rnd = 'd'): else: return normalize(0, res, exp, bc, prec, rnd) -cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd): +cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd) noexcept: """ Create normalized mpf value tuple from full list of components. @@ -154,7 +154,7 @@ cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd): bc = mpz_sizeinbase(res.value, 2) return (sign, res, int(exp), bc) -cdef mpfr_from_mpfval(mpfr_t res, tuple x): +cdef mpfr_from_mpfval(mpfr_t res, tuple x) noexcept: """ Set value of an MPFR number (in place) to that of a given mpmath mpf data tuple. @@ -180,7 +180,7 @@ cdef mpfr_from_mpfval(mpfr_t res, tuple x): else: mpfr_set_nan(res) -cdef mpfr_to_mpfval(mpfr_t value): +cdef mpfr_to_mpfval(mpfr_t value) noexcept: """ Given an MPFR value, return an mpmath mpf data tuple representing the same number. diff --git a/src/sage/libs/ntl/conversion.pxd b/src/sage/libs/ntl/conversion.pxd index dfd7647a6c4..840e3947ea3 100644 --- a/src/sage/libs/ntl/conversion.pxd +++ b/src/sage/libs/ntl/conversion.pxd @@ -36,7 +36,7 @@ from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense # matrix_modn_dense_float (dense matrix over Z/nZ) # ################################################ -cdef inline void set_ntl_matrix_modn_dense_float(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_float m): +cdef inline void set_ntl_matrix_modn_dense_float(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_float m) noexcept: r""" set the entries of a NTL matrix from a Sage matrix. @@ -53,7 +53,7 @@ cdef inline void set_ntl_matrix_modn_dense_float(mat_ZZ_p_c& A, ntl_ZZ_pContext_ tmp = ntl_ZZ_p(m[i,j], c) A.put(i, j, tmp.x) -cdef inline void set_ntl_matrix_modn_dense_double(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_double m): +cdef inline void set_ntl_matrix_modn_dense_double(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_double m) noexcept: r""" set the entries of a NTL matrix from a Sage matrix. @@ -70,7 +70,7 @@ cdef inline void set_ntl_matrix_modn_dense_double(mat_ZZ_p_c& A, ntl_ZZ_pContext tmp = ntl_ZZ_p(m[i,j], c) A.put(i, j, tmp.x) -cdef inline void set_ntl_matrix_modn_generic_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_generic_dense m): +cdef inline void set_ntl_matrix_modn_generic_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_generic_dense m) noexcept: r""" set the entries of a NTL matrix from a Sage matrix. @@ -87,7 +87,7 @@ cdef inline void set_ntl_matrix_modn_generic_dense(mat_ZZ_p_c& A, ntl_ZZ_pContex tmp = ntl_ZZ_p(m[i,j], c) A.put(i, j, tmp.x) -cdef inline void set_ntl_matrix_modn_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, m): +cdef inline void set_ntl_matrix_modn_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, m) noexcept: r""" set the entries of a NTL matrix from a Sage matrix. diff --git a/src/sage/libs/ntl/convert.pxd b/src/sage/libs/ntl/convert.pxd index aa733329dce..1a9532f0aba 100644 --- a/src/sage/libs/ntl/convert.pxd +++ b/src/sage/libs/ntl/convert.pxd @@ -1,6 +1,6 @@ from .types cimport ZZ_c from sage.libs.gmp.types cimport mpz_t, mpz_srcptr -cdef void ZZ_to_mpz(mpz_t output, ZZ_c* x) -cdef void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x) -cdef void PyLong_to_ZZ(ZZ_c* z, value) +cdef void ZZ_to_mpz(mpz_t output, ZZ_c* x) noexcept +cdef void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x) noexcept +cdef void PyLong_to_ZZ(ZZ_c* z, value) noexcept diff --git a/src/sage/libs/ntl/convert.pyx b/src/sage/libs/ntl/convert.pyx index d06270d5077..975a3f3fced 100644 --- a/src/sage/libs/ntl/convert.pyx +++ b/src/sage/libs/ntl/convert.pyx @@ -27,7 +27,7 @@ cdef extern from "sage/libs/ntl/ntlwrap_impl.h": void ZZ_to_mpz(mpz_t output, ZZ_c* x) void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x) -cdef void PyLong_to_ZZ(ZZ_c* z, value): +cdef void PyLong_to_ZZ(ZZ_c* z, value) noexcept: """ Convert ``value`` (which must be a Python ``long``) to NTL. """ diff --git a/src/sage/libs/ntl/misc.pxi b/src/sage/libs/ntl/misc.pxi index e9dcd9807b0..e0d24b01a60 100644 --- a/src/sage/libs/ntl/misc.pxi +++ b/src/sage/libs/ntl/misc.pxi @@ -8,7 +8,7 @@ from cysignals.signals cimport sig_off cdef extern from *: void del_charstar "delete[]"(char*) -cdef object string(char* s): +cdef object string(char* s) noexcept: """ Takes a char* allocated using malloc, and converts it to a Python string, then deletes the allocated memory. Also unsets the signal @@ -20,7 +20,7 @@ cdef object string(char* s): sig_free(s) return t -cdef object string_delete(char* s): +cdef object string_delete(char* s) noexcept: """ Takes a char* allocated using C++ new, and converts it to a Python string, then deletes the allocated memory. Also unsets the signal diff --git a/src/sage/libs/ntl/ntl_GF2E.pxd b/src/sage/libs/ntl/ntl_GF2E.pxd index 8977f711078..f634042e7cb 100644 --- a/src/sage/libs/ntl/ntl_GF2E.pxd +++ b/src/sage/libs/ntl/ntl_GF2E.pxd @@ -4,5 +4,5 @@ from .ntl_GF2EContext cimport ntl_GF2EContext_class cdef class ntl_GF2E(): cdef GF2E_c x cdef ntl_GF2EContext_class c - cdef ntl_GF2E _new(self) + cdef ntl_GF2E _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_GF2E.pyx b/src/sage/libs/ntl/ntl_GF2E.pyx index c78fd6704db..078a3e2e6f7 100644 --- a/src/sage/libs/ntl/ntl_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_GF2E.pyx @@ -155,7 +155,7 @@ cdef class ntl_GF2E(): self.c = ntl_GF2EContext(modulus) self.c.restore_c() - cdef ntl_GF2E _new(self): + cdef ntl_GF2E _new(self) noexcept: cdef ntl_GF2E r self.c.restore_c() r = ntl_GF2E.__new__(ntl_GF2E) diff --git a/src/sage/libs/ntl/ntl_GF2EContext.pxd b/src/sage/libs/ntl/ntl_GF2EContext.pxd index 44ab9891713..df1f44f87aa 100644 --- a/src/sage/libs/ntl/ntl_GF2EContext.pxd +++ b/src/sage/libs/ntl/ntl_GF2EContext.pxd @@ -4,5 +4,5 @@ from .ntl_GF2X cimport ntl_GF2X cdef class ntl_GF2EContext_class(): cdef GF2EContext_c x cdef ntl_GF2X m - cdef void restore_c(self) + cdef void restore_c(self) noexcept cdef object __weakref__ diff --git a/src/sage/libs/ntl/ntl_GF2EContext.pyx b/src/sage/libs/ntl/ntl_GF2EContext.pyx index 11d06893505..f00bda404df 100644 --- a/src/sage/libs/ntl/ntl_GF2EContext.pyx +++ b/src/sage/libs/ntl/ntl_GF2EContext.pyx @@ -105,7 +105,7 @@ cdef class ntl_GF2EContext_class(): """ self.restore_c() - cdef void restore_c(self): + cdef void restore_c(self) noexcept: self.x.restore() def ntl_GF2EContext( v ): diff --git a/src/sage/libs/ntl/ntl_GF2EX.pxd b/src/sage/libs/ntl/ntl_GF2EX.pxd index 70e06122753..e9a98a3afd6 100644 --- a/src/sage/libs/ntl/ntl_GF2EX.pxd +++ b/src/sage/libs/ntl/ntl_GF2EX.pxd @@ -5,5 +5,5 @@ from .ntl_GF2E cimport ntl_GF2E cdef class ntl_GF2EX(): cdef GF2EX_c x cdef ntl_GF2EContext_class c - cdef ntl_GF2E _new_element(self) - cdef ntl_GF2EX _new(self) + cdef ntl_GF2E _new_element(self) noexcept + cdef ntl_GF2EX _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_GF2EX.pyx b/src/sage/libs/ntl/ntl_GF2EX.pyx index e9dfbab4668..72d18cedd4a 100644 --- a/src/sage/libs/ntl/ntl_GF2EX.pyx +++ b/src/sage/libs/ntl/ntl_GF2EX.pyx @@ -85,14 +85,14 @@ cdef class ntl_GF2EX(): self.c = ntl_GF2EContext(modulus) self.c.restore_c() - cdef ntl_GF2E _new_element(self): + cdef ntl_GF2E _new_element(self) noexcept: cdef ntl_GF2E r self.c.restore_c() r = ntl_GF2E.__new__(ntl_GF2E) r.c = self.c return r - cdef ntl_GF2EX _new(self): + cdef ntl_GF2EX _new(self) noexcept: cdef ntl_GF2EX r self.c.restore_c() r = ntl_GF2EX.__new__(ntl_GF2EX) diff --git a/src/sage/libs/ntl/ntl_GF2X_linkage.pxi b/src/sage/libs/ntl/ntl_GF2X_linkage.pxi index 3f01c91ab00..cf480a34653 100644 --- a/src/sage/libs/ntl/ntl_GF2X_linkage.pxi +++ b/src/sage/libs/ntl/ntl_GF2X_linkage.pxi @@ -24,7 +24,7 @@ from sage.libs.ntl.GF2 cimport * from sage.libs.ntl.GF2X cimport * -cdef GF2X_c *celement_new(long parent): +cdef GF2X_c *celement_new(long parent) noexcept: """ EXAMPLES:: @@ -32,7 +32,7 @@ cdef GF2X_c *celement_new(long parent): """ return new GF2X_c() -cdef int celement_delete(GF2X_c *e, long parent): +cdef int celement_delete(GF2X_c *e, long parent) noexcept: """ EXAMPLES:: @@ -41,7 +41,7 @@ cdef int celement_delete(GF2X_c *e, long parent): """ del e -cdef int celement_construct(GF2X_c *e, long parent): +cdef int celement_construct(GF2X_c *e, long parent) noexcept: """ EXAMPLES:: @@ -49,7 +49,7 @@ cdef int celement_construct(GF2X_c *e, long parent): """ pass -cdef int celement_destruct(GF2X_c *e, long parent): +cdef int celement_destruct(GF2X_c *e, long parent) noexcept: """ EXAMPLES:: @@ -67,7 +67,7 @@ cdef int celement_gen(GF2X_c *e, long i, long parent) except -2: cdef unsigned char g = 2 GF2XFromBytes(e[0], (&g), 1) -cdef object celement_repr(GF2X_c *e, long parent): +cdef object celement_repr(GF2X_c *e, long parent) noexcept: """ We ignore NTL's printing. diff --git a/src/sage/libs/ntl/ntl_ZZ.pxd b/src/sage/libs/ntl/ntl_ZZ.pxd index 31a23b29d46..2ada3d8398c 100644 --- a/src/sage/libs/ntl/ntl_ZZ.pxd +++ b/src/sage/libs/ntl/ntl_ZZ.pxd @@ -2,5 +2,5 @@ from sage.libs.ntl.types cimport ZZ_c cdef class ntl_ZZ(): cdef ZZ_c x - cdef int get_as_int(ntl_ZZ self) - cdef void set_from_int(ntl_ZZ self, int value) + cdef int get_as_int(ntl_ZZ self) noexcept + cdef void set_from_int(ntl_ZZ self, int value) noexcept diff --git a/src/sage/libs/ntl/ntl_ZZ.pyx b/src/sage/libs/ntl/ntl_ZZ.pyx index 41e14fdcf09..37acfef79a8 100644 --- a/src/sage/libs/ntl/ntl_ZZ.pyx +++ b/src/sage/libs/ntl/ntl_ZZ.pyx @@ -32,7 +32,7 @@ from sage.misc.randstate cimport current_randstate from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE -cdef make_ZZ(ZZ_c* x): +cdef make_ZZ(ZZ_c* x) noexcept: cdef ntl_ZZ y y = ntl_ZZ() y.x = x[0] @@ -269,7 +269,7 @@ cdef class ntl_ZZ(): """ return int(self._integer_()) - cdef int get_as_int(ntl_ZZ self): + cdef int get_as_int(ntl_ZZ self) noexcept: r""" Returns value as C int. @@ -312,7 +312,7 @@ cdef class ntl_ZZ(): ZZ_to_mpz(ans.value, &self.x) return ans - cdef void set_from_int(ntl_ZZ self, int value): + cdef void set_from_int(ntl_ZZ self, int value) noexcept: r""" Sets the value from a C int. diff --git a/src/sage/libs/ntl/ntl_ZZX.pxd b/src/sage/libs/ntl/ntl_ZZX.pxd index c15a3f2d1e4..5f6238f73f1 100644 --- a/src/sage/libs/ntl/ntl_ZZX.pxd +++ b/src/sage/libs/ntl/ntl_ZZX.pxd @@ -2,5 +2,5 @@ from .types cimport ZZX_c cdef class ntl_ZZX(): cdef ZZX_c x - cdef void setitem_from_int(ntl_ZZX self, long i, int value) - cdef int getitem_as_int(ntl_ZZX self, long i) + cdef void setitem_from_int(ntl_ZZX self, long i, int value) noexcept + cdef int getitem_as_int(ntl_ZZX self, long i) noexcept diff --git a/src/sage/libs/ntl/ntl_ZZX.pyx b/src/sage/libs/ntl/ntl_ZZX.pyx index 34fd47a8527..343e5883191 100644 --- a/src/sage/libs/ntl/ntl_ZZX.pyx +++ b/src/sage/libs/ntl/ntl_ZZX.pyx @@ -37,7 +37,7 @@ from sage.arith.power cimport generic_power_pos ZZ = IntegerRing() -cdef inline ntl_ZZ make_ZZ(ZZ_c* x): +cdef inline ntl_ZZ make_ZZ(ZZ_c* x) noexcept: """ These make_XXXX functions are deprecated and should be phased out.""" cdef ntl_ZZ y y = ntl_ZZ() @@ -46,12 +46,12 @@ cdef inline ntl_ZZ make_ZZ(ZZ_c* x): return y # You must do sig_on() before calling this function -cdef inline ntl_ZZ make_ZZ_sig_off(ZZ_c* x): +cdef inline ntl_ZZ make_ZZ_sig_off(ZZ_c* x) noexcept: cdef ntl_ZZ y = make_ZZ(x) sig_off() return y -cdef inline ntl_ZZX make_ZZX(ZZX_c* x): +cdef inline ntl_ZZX make_ZZX(ZZX_c* x) noexcept: """ These make_XXXX functions are deprecated and should be phased out.""" cdef ntl_ZZX y y = ntl_ZZX() @@ -60,13 +60,13 @@ cdef inline ntl_ZZX make_ZZX(ZZX_c* x): return y # You must do sig_on() before calling this function -cdef inline ntl_ZZX make_ZZX_sig_off(ZZX_c* x): +cdef inline ntl_ZZX make_ZZX_sig_off(ZZX_c* x) noexcept: cdef ntl_ZZX y = make_ZZX(x) sig_off() return y from sage.structure.proof.proof import get_flag -cdef proof_flag(t): +cdef proof_flag(t) noexcept: return get_flag(t, "polynomial") ############################################################################## @@ -200,7 +200,7 @@ cdef class ntl_ZZX(): cc = ntl_ZZ(a) ZZX_SetCoeff(self.x, i, cc.x) - cdef void setitem_from_int(ntl_ZZX self, long i, int value): + cdef void setitem_from_int(ntl_ZZX self, long i, int value) noexcept: r""" Sets ith coefficient to value. @@ -245,7 +245,7 @@ cdef class ntl_ZZX(): sig_off() return r - cdef int getitem_as_int(ntl_ZZX self, long i): + cdef int getitem_as_int(ntl_ZZX self, long i) noexcept: r""" Returns ith coefficient as C int. Return value is only valid if the result fits into an int. diff --git a/src/sage/libs/ntl/ntl_ZZ_p.pxd b/src/sage/libs/ntl/ntl_ZZ_p.pxd index 4863afeb2c2..08a0a3beb84 100644 --- a/src/sage/libs/ntl/ntl_ZZ_p.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_p.pxd @@ -4,6 +4,6 @@ from .ntl_ZZ_pContext cimport ntl_ZZ_pContext_class cdef class ntl_ZZ_p(): cdef ZZ_p_c x cdef ntl_ZZ_pContext_class c - cdef int get_as_int(ntl_ZZ_p self) - cdef void set_from_int(ntl_ZZ_p self, int value) - cdef ntl_ZZ_p _new(self) + cdef int get_as_int(ntl_ZZ_p self) noexcept + cdef void set_from_int(ntl_ZZ_p self, int value) noexcept + cdef ntl_ZZ_p _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_ZZ_p.pyx b/src/sage/libs/ntl/ntl_ZZ_p.pyx index d032d9b81b9..cca767303f7 100644 --- a/src/sage/libs/ntl/ntl_ZZ_p.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_p.pyx @@ -154,7 +154,7 @@ cdef class ntl_ZZ_p(): self.c = ntl_ZZ_pContext(modulus) self.c.restore_c() - cdef ntl_ZZ_p _new(self): + cdef ntl_ZZ_p _new(self) noexcept: cdef ntl_ZZ_p r self.c.restore_c() r = ntl_ZZ_p.__new__(ntl_ZZ_p) @@ -348,7 +348,7 @@ cdef class ntl_ZZ_p(): """ return self.get_as_int() - cdef int get_as_int(ntl_ZZ_p self): + cdef int get_as_int(ntl_ZZ_p self) noexcept: r""" Returns value as C int. Return value is only valid if the result fits into an int. @@ -375,7 +375,7 @@ cdef class ntl_ZZ_p(): self.c.restore_c() return self.get_as_int() - cdef void set_from_int(ntl_ZZ_p self, int value): + cdef void set_from_int(ntl_ZZ_p self, int value) noexcept: r""" Sets the value from a C int. diff --git a/src/sage/libs/ntl/ntl_ZZ_pContext.pxd b/src/sage/libs/ntl/ntl_ZZ_pContext.pxd index 171776d85d7..61269d95584 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pContext.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pContext.pxd @@ -5,7 +5,7 @@ from .types cimport ZZ_c cdef class ntl_ZZ_pContext_class(): cdef ZZ_pContext_c x - cdef void restore_c(self) + cdef void restore_c(self) noexcept cdef ntl_ZZ p cdef double p_bits cdef object __weakref__ @@ -14,7 +14,7 @@ cdef class ntl_ZZ_pContext_class(): cdef class ntl_ZZ_pContext_factory(): cdef object context_dict - cdef ntl_ZZ_pContext_class make_c(self, ntl_ZZ v) + cdef ntl_ZZ_pContext_class make_c(self, ntl_ZZ v) noexcept cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ntl_ZZ_pContext.pyx b/src/sage/libs/ntl/ntl_ZZ_pContext.pyx index dbcc8af1441..52c04e277cd 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pContext.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pContext.pyx @@ -114,7 +114,7 @@ cdef class ntl_ZZ_pContext_class(): """ self.restore_c() - cdef void restore_c(self): + cdef void restore_c(self) noexcept: self.x.restore() cpdef void _assert_is_current_modulus(self) except *: @@ -162,7 +162,7 @@ cdef class ntl_ZZ_pContext_factory(): def __init__(self): self.context_dict = {} - cdef ntl_ZZ_pContext_class make_c(self, ntl_ZZ v): + cdef ntl_ZZ_pContext_class make_c(self, ntl_ZZ v) noexcept: """ Creates a new ZZ_pContext. diff --git a/src/sage/libs/ntl/ntl_ZZ_pE.pxd b/src/sage/libs/ntl/ntl_ZZ_pE.pxd index 267608a016d..cb9efd2279f 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pE.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pE.pxd @@ -5,6 +5,6 @@ from .ntl_ZZ_pX cimport ntl_ZZ_pX cdef class ntl_ZZ_pE(): cdef ZZ_pE_c x cdef ntl_ZZ_pEContext_class c - cdef ntl_ZZ_pX get_as_ZZ_pX(ntl_ZZ_pE self) - cdef void set_from_ZZ_pX(ntl_ZZ_pE self, ntl_ZZ_pX value) - cdef ntl_ZZ_pE _new(self) + cdef ntl_ZZ_pX get_as_ZZ_pX(ntl_ZZ_pE self) noexcept + cdef void set_from_ZZ_pX(ntl_ZZ_pE self, ntl_ZZ_pX value) noexcept + cdef ntl_ZZ_pE _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_ZZ_pE.pyx b/src/sage/libs/ntl/ntl_ZZ_pE.pyx index 790d5c59648..b0882217e86 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pE.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pE.pyx @@ -149,7 +149,7 @@ cdef class ntl_ZZ_pE(): self.c = ntl_ZZ_pEContext(modulus) self.c.restore_c() - cdef ntl_ZZ_pE _new(self): + cdef ntl_ZZ_pE _new(self) noexcept: cdef ntl_ZZ_pE r self.c.restore_c() r = ntl_ZZ_pE.__new__(ntl_ZZ_pE) @@ -268,7 +268,7 @@ cdef class ntl_ZZ_pE(): return r - cdef ntl_ZZ_pX get_as_ZZ_pX(ntl_ZZ_pE self): + cdef ntl_ZZ_pX get_as_ZZ_pX(ntl_ZZ_pE self) noexcept: r""" Returns value as ntl_ZZ_pX. """ @@ -294,7 +294,7 @@ cdef class ntl_ZZ_pE(): """ return self.get_as_ZZ_pX() - cdef void set_from_ZZ_pX(ntl_ZZ_pE self, ntl_ZZ_pX value): + cdef void set_from_ZZ_pX(ntl_ZZ_pE self, ntl_ZZ_pX value) noexcept: r""" Sets the value from a ZZ_pX. """ diff --git a/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd b/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd index 72c9ec42eab..027c59465a9 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd @@ -13,7 +13,7 @@ cdef class ntl_ZZ_pEContext_class(): cdef ZZ_pEContext_ptrs ptrs cdef ZZ_pEContext_c x cdef ntl_ZZ_pContext_class pc - cdef void restore_c(self) + cdef void restore_c(self) noexcept cdef ntl_ZZ_pX f cpdef void _assert_is_current_modulus(self) except * diff --git a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx index fca10d5667f..affd31d299d 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx @@ -122,7 +122,7 @@ cdef class ntl_ZZ_pEContext_class(): """ self.restore_c() - cdef void restore_c(self): + cdef void restore_c(self) noexcept: """ Sets the global NTL modulus to be self. diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX.pxd b/src/sage/libs/ntl/ntl_ZZ_pEX.pxd index b00e87bbcec..de3e1e54fff 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pEX.pxd @@ -6,4 +6,4 @@ cdef class ntl_ZZ_pEX(): cdef ntl_ZZ_pEContext_class c #cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value) #cdef int getitem_as_int(ntl_ZZ_pX self, long i) - cdef ntl_ZZ_pEX _new(self) + cdef ntl_ZZ_pEX _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX.pyx b/src/sage/libs/ntl/ntl_ZZ_pEX.pyx index c12df77c2f0..6ebde955aa3 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pEX.pyx @@ -133,7 +133,7 @@ cdef class ntl_ZZ_pEX(): raise ValueError("modulus must not be None") self.c.restore_c() - cdef ntl_ZZ_pEX _new(self): + cdef ntl_ZZ_pEX _new(self) noexcept: cdef ntl_ZZ_pEX r self.c.restore_c() r = ntl_ZZ_pEX.__new__(ntl_ZZ_pEX) diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi index caf74e6c64f..22d15b71b45 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi +++ b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi @@ -25,7 +25,7 @@ from sage.libs.ntl.ZZ_pEX cimport * from sage.libs.ntl.ntl_ZZ_pE cimport ntl_ZZ_pE from sage.libs.ntl.types cimport ZZ_pX_c, ZZ_pEX_c -cdef ZZ_pEX_c *celement_new(cparent parent): +cdef ZZ_pEX_c *celement_new(cparent parent) noexcept: """ EXAMPLES:: @@ -36,7 +36,7 @@ cdef ZZ_pEX_c *celement_new(cparent parent): parent[0].zzpec[0].restore() return new ZZ_pEX_c() -cdef int celement_delete(ZZ_pEX_c *e, cparent parent): +cdef int celement_delete(ZZ_pEX_c *e, cparent parent) noexcept: """ EXAMPLES:: @@ -48,7 +48,7 @@ cdef int celement_delete(ZZ_pEX_c *e, cparent parent): parent[0].zzpec[0].restore() del e -cdef int celement_construct(ZZ_pEX_c *e, cparent parent): +cdef int celement_construct(ZZ_pEX_c *e, cparent parent) noexcept: """ EXAMPLES:: @@ -58,7 +58,7 @@ cdef int celement_construct(ZZ_pEX_c *e, cparent parent): parent[0].zzpc[0].restore() parent[0].zzpec[0].restore() -cdef int celement_destruct(ZZ_pEX_c *e, cparent parent): +cdef int celement_destruct(ZZ_pEX_c *e, cparent parent) noexcept: """ EXAMPLES:: @@ -80,7 +80,7 @@ cdef int celement_gen(ZZ_pEX_c *e, long i, cparent parent) except -2: parent[0].zzpec[0].restore() ZZ_pEX_SetX(e[0]) -cdef object celement_repr(ZZ_pEX_c *e, cparent parent): +cdef object celement_repr(ZZ_pEX_c *e, cparent parent) noexcept: """ We ignore NTL's printing. diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pxd b/src/sage/libs/ntl/ntl_ZZ_pX.pxd index 6dfed011120..e414fc5c272 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pxd @@ -4,9 +4,9 @@ from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class cdef class ntl_ZZ_pX(): cdef ZZ_pX_c x cdef ntl_ZZ_pContext_class c - cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value) - cdef int getitem_as_int(ntl_ZZ_pX self, long i) - cdef ntl_ZZ_pX _new(self) + cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value) noexcept + cdef int getitem_as_int(ntl_ZZ_pX self, long i) noexcept + cdef ntl_ZZ_pX _new(self) noexcept cdef class ntl_ZZ_pX_Modulus(): cdef ZZ_pX_Modulus_c x diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 4ad48fb3496..3422239aaac 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -38,7 +38,7 @@ from sage.misc.randstate cimport current_randstate from sage.libs.gmp.mpz cimport * -cdef inline make_ZZ_p(ZZ_p_c* x, ntl_ZZ_pContext_class ctx): +cdef inline make_ZZ_p(ZZ_p_c* x, ntl_ZZ_pContext_class ctx) noexcept: cdef ntl_ZZ_p y sig_off() y = ntl_ZZ_p(modulus = ctx) @@ -47,7 +47,7 @@ cdef inline make_ZZ_p(ZZ_p_c* x, ntl_ZZ_pContext_class ctx): return y -cdef make_ZZ_pX(ZZ_pX_c* x, ntl_ZZ_pContext_class ctx): +cdef make_ZZ_pX(ZZ_pX_c* x, ntl_ZZ_pContext_class ctx) noexcept: cdef ntl_ZZ_pX y y = ntl_ZZ_pX.__new__(ntl_ZZ_pX) y.c = ctx @@ -138,7 +138,7 @@ cdef class ntl_ZZ_pX(): self.c = ntl_ZZ_pContext(ntl_ZZ(modulus)) self.c.restore_c() - cdef ntl_ZZ_pX _new(self): + cdef ntl_ZZ_pX _new(self) noexcept: cdef ntl_ZZ_pX r self.c.restore_c() r = ntl_ZZ_pX.__new__(ntl_ZZ_pX) @@ -222,7 +222,7 @@ cdef class ntl_ZZ_pX(): self.c.restore_c() ZZ_pX_SetCoeff(self.x, i, _a.x) - cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value): + cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value) noexcept: r""" Sets ith coefficient to value. @@ -267,7 +267,7 @@ cdef class ntl_ZZ_pX(): r.x = ZZ_pX_coeff( self.x, i) return r - cdef int getitem_as_int(ntl_ZZ_pX self, long i): + cdef int getitem_as_int(ntl_ZZ_pX self, long i) noexcept: r""" Returns ith coefficient as C int. Return value is only valid if the result fits into an int. diff --git a/src/sage/libs/ntl/ntl_lzz_p.pxd b/src/sage/libs/ntl/ntl_lzz_p.pxd index ec74b46d447..6a1466b62d3 100644 --- a/src/sage/libs/ntl/ntl_lzz_p.pxd +++ b/src/sage/libs/ntl/ntl_lzz_p.pxd @@ -4,4 +4,4 @@ from .ntl_lzz_pContext cimport ntl_zz_pContext_class cdef class ntl_zz_p(): cdef zz_p_c x cdef ntl_zz_pContext_class c - cdef ntl_zz_p _new(ntl_zz_p self) + cdef ntl_zz_p _new(ntl_zz_p self) noexcept diff --git a/src/sage/libs/ntl/ntl_lzz_p.pyx b/src/sage/libs/ntl/ntl_lzz_p.pyx index af86b9bcf69..0f7fd8fd5e3 100644 --- a/src/sage/libs/ntl/ntl_lzz_p.pyx +++ b/src/sage/libs/ntl/ntl_lzz_p.pyx @@ -150,7 +150,7 @@ cdef class ntl_zz_p(): ## now that we've determined the modulus, set that modulus. self.c.restore_c() - cdef ntl_zz_p _new(self): + cdef ntl_zz_p _new(self) noexcept: """ Quick and dirty zz_p object creation. diff --git a/src/sage/libs/ntl/ntl_lzz_pContext.pxd b/src/sage/libs/ntl/ntl_lzz_pContext.pxd index 058d2842ecc..cffc49f6b4c 100644 --- a/src/sage/libs/ntl/ntl_lzz_pContext.pxd +++ b/src/sage/libs/ntl/ntl_lzz_pContext.pxd @@ -2,5 +2,5 @@ from .types cimport zz_pContext_c cdef class ntl_zz_pContext_class(): cdef zz_pContext_c x - cdef void restore_c(self) + cdef void restore_c(self) noexcept cdef long p diff --git a/src/sage/libs/ntl/ntl_lzz_pContext.pyx b/src/sage/libs/ntl/ntl_lzz_pContext.pyx index 0cb0a69642a..2c1c941b9e8 100644 --- a/src/sage/libs/ntl/ntl_lzz_pContext.pyx +++ b/src/sage/libs/ntl/ntl_lzz_pContext.pyx @@ -92,7 +92,7 @@ cdef class ntl_zz_pContext_class(): """ self.restore_c() - cdef void restore_c(self): + cdef void restore_c(self) noexcept: """ Actual code for the above. diff --git a/src/sage/libs/ntl/ntl_lzz_pX.pxd b/src/sage/libs/ntl/ntl_lzz_pX.pxd index 3ab79084299..2cc09419fe5 100644 --- a/src/sage/libs/ntl/ntl_lzz_pX.pxd +++ b/src/sage/libs/ntl/ntl_lzz_pX.pxd @@ -6,4 +6,4 @@ from sage.libs.ntl.ntl_lzz_pContext cimport ntl_zz_pContext_class cdef class ntl_zz_pX(): cdef zz_pX_c x cdef ntl_zz_pContext_class c - cdef ntl_zz_pX _new(self) + cdef ntl_zz_pX _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_lzz_pX.pyx b/src/sage/libs/ntl/ntl_lzz_pX.pyx index 7d19cc55e37..bbcd9f14dec 100644 --- a/src/sage/libs/ntl/ntl_lzz_pX.pyx +++ b/src/sage/libs/ntl/ntl_lzz_pX.pyx @@ -232,7 +232,7 @@ cdef class ntl_zz_pX(): zz_pX_SetCoeff_long(self.x, i, val) return - cdef ntl_zz_pX _new(self): + cdef ntl_zz_pX _new(self) noexcept: """ Quick and dirty method for creating a new object with the same zz_pContext as self. diff --git a/src/sage/libs/ntl/ntl_mat_GF2.pxd b/src/sage/libs/ntl/ntl_mat_GF2.pxd index b900d2f9e3f..34176ca530e 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2.pxd +++ b/src/sage/libs/ntl/ntl_mat_GF2.pxd @@ -3,5 +3,5 @@ from .ntl_GF2 cimport ntl_GF2 cdef class ntl_mat_GF2(): cdef mat_GF2_c x - cdef ntl_GF2 _new_element(self) - cdef ntl_mat_GF2 _new(self) + cdef ntl_GF2 _new_element(self) noexcept + cdef ntl_mat_GF2 _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_mat_GF2.pyx b/src/sage/libs/ntl/ntl_mat_GF2.pyx index ee90bf17fce..4c7b19a066b 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2.pyx @@ -118,12 +118,12 @@ cdef class ntl_mat_GF2(): mat_GF2_setitem(&self.x, i, j, &(elem).x) sig_off() - cdef ntl_GF2 _new_element(self): + cdef ntl_GF2 _new_element(self) noexcept: cdef ntl_GF2 r r = ntl_GF2.__new__(ntl_GF2) return r - cdef ntl_mat_GF2 _new(self): + cdef ntl_mat_GF2 _new(self) noexcept: cdef ntl_mat_GF2 r r = ntl_mat_GF2.__new__(ntl_mat_GF2) r.x.SetDims(self.x.NumRows(),self.x.NumCols()) diff --git a/src/sage/libs/ntl/ntl_mat_GF2E.pxd b/src/sage/libs/ntl/ntl_mat_GF2E.pxd index 5c8aacd5cef..c01392b81db 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2E.pxd +++ b/src/sage/libs/ntl/ntl_mat_GF2E.pxd @@ -5,5 +5,5 @@ from .ntl_GF2E cimport ntl_GF2E cdef class ntl_mat_GF2E(): cdef mat_GF2E_c x cdef ntl_GF2EContext_class c - cdef ntl_GF2E _new_element(self) - cdef ntl_mat_GF2E _new(self) + cdef ntl_GF2E _new_element(self) noexcept + cdef ntl_mat_GF2E _new(self) noexcept diff --git a/src/sage/libs/ntl/ntl_mat_GF2E.pyx b/src/sage/libs/ntl/ntl_mat_GF2E.pyx index 46a5c9bc59e..24f75c6c026 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2E.pyx @@ -136,14 +136,14 @@ cdef class ntl_mat_GF2E(): self.c = ntl_GF2EContext(modulus) self.c.restore_c() - cdef ntl_GF2E _new_element(self): + cdef ntl_GF2E _new_element(self) noexcept: cdef ntl_GF2E r self.c.restore_c() r = ntl_GF2E.__new__(ntl_GF2E) r.c = self.c return r - cdef ntl_mat_GF2E _new(self): + cdef ntl_mat_GF2E _new(self) noexcept: cdef ntl_mat_GF2E r self.c.restore_c() r = ntl_mat_GF2E.__new__(ntl_mat_GF2E) diff --git a/src/sage/libs/ntl/ntl_mat_ZZ.pyx b/src/sage/libs/ntl/ntl_mat_ZZ.pyx index fb1769db352..8df56b2632e 100644 --- a/src/sage/libs/ntl/ntl_mat_ZZ.pyx +++ b/src/sage/libs/ntl/ntl_mat_ZZ.pyx @@ -32,7 +32,7 @@ from cpython.object cimport PyObject_RichCompare from .ntl_ZZ import unpickle_class_args -cdef inline ntl_ZZ make_ZZ(ZZ_c* x): +cdef inline ntl_ZZ make_ZZ(ZZ_c* x) noexcept: cdef ntl_ZZ y y = ntl_ZZ() y.x = x[0] @@ -40,12 +40,12 @@ cdef inline ntl_ZZ make_ZZ(ZZ_c* x): return y # You must do sig_on() before calling this function -cdef inline ntl_ZZ make_ZZ_sig_off(ZZ_c* x): +cdef inline ntl_ZZ make_ZZ_sig_off(ZZ_c* x) noexcept: cdef ntl_ZZ y = make_ZZ(x) sig_off() return y -cdef inline ntl_mat_ZZ make_mat_ZZ(mat_ZZ_c* x): +cdef inline ntl_mat_ZZ make_mat_ZZ(mat_ZZ_c* x) noexcept: cdef ntl_mat_ZZ y y = ntl_mat_ZZ.__new__(ntl_mat_ZZ) y.x = x[0] @@ -55,7 +55,7 @@ cdef inline ntl_mat_ZZ make_mat_ZZ(mat_ZZ_c* x): return y # You must do sig_on() before calling this function -cdef inline ntl_mat_ZZ make_mat_ZZ_sig_off(mat_ZZ_c* x): +cdef inline ntl_mat_ZZ make_mat_ZZ_sig_off(mat_ZZ_c* x) noexcept: cdef ntl_mat_ZZ y = make_mat_ZZ(x) sig_off() return y diff --git a/src/sage/libs/pari/convert_flint.pxd b/src/sage/libs/pari/convert_flint.pxd index 774b3c48bd8..3d6003f56bd 100644 --- a/src/sage/libs/pari/convert_flint.pxd +++ b/src/sage/libs/pari/convert_flint.pxd @@ -2,12 +2,12 @@ from cypari2.types cimport GEN from cypari2.gen cimport Gen from sage.libs.flint.types cimport fmpz_t, fmpz_mat_t, fmpq_t, fmpq_mat_t -cdef GEN _new_GEN_from_fmpz_t(fmpz_t value) -cdef GEN _new_GEN_from_fmpz_mat_t(fmpz_mat_t B) -cdef GEN _new_GEN_from_fmpz_mat_t_rotate90(fmpz_mat_t B) -cdef Gen integer_matrix(fmpz_mat_t B, bint rotate) +cdef GEN _new_GEN_from_fmpz_t(fmpz_t value) noexcept +cdef GEN _new_GEN_from_fmpz_mat_t(fmpz_mat_t B) noexcept +cdef GEN _new_GEN_from_fmpz_mat_t_rotate90(fmpz_mat_t B) noexcept +cdef Gen integer_matrix(fmpz_mat_t B, bint rotate) noexcept -cdef GEN _new_GEN_from_fmpq_t(fmpq_t value) -cdef GEN _new_GEN_from_fmpq_mat_t(fmpq_mat_t B) -cdef GEN _new_GEN_from_fmpq_mat_t_rotate90(fmpq_mat_t B) -cdef Gen rational_matrix(fmpq_mat_t B, bint rotate) +cdef GEN _new_GEN_from_fmpq_t(fmpq_t value) noexcept +cdef GEN _new_GEN_from_fmpq_mat_t(fmpq_mat_t B) noexcept +cdef GEN _new_GEN_from_fmpq_mat_t_rotate90(fmpq_mat_t B) noexcept +cdef Gen rational_matrix(fmpq_mat_t B, bint rotate) noexcept diff --git a/src/sage/libs/pari/convert_flint.pyx b/src/sage/libs/pari/convert_flint.pyx index 07dd6cfc3dd..340e72c13bb 100644 --- a/src/sage/libs/pari/convert_flint.pyx +++ b/src/sage/libs/pari/convert_flint.pyx @@ -31,7 +31,7 @@ from cypari2.stack cimport new_gen from .convert_gmp cimport _new_GEN_from_mpz_t -cdef inline GEN _new_GEN_from_fmpz_t(fmpz_t value): +cdef inline GEN _new_GEN_from_fmpz_t(fmpz_t value) noexcept: r""" Create a new PARI ``t_INT`` from a ``fmpz_t``. @@ -44,7 +44,7 @@ cdef inline GEN _new_GEN_from_fmpz_t(fmpz_t value): return stoi(value[0]) -cdef inline GEN _new_GEN_from_fmpq_t(fmpq_t value): +cdef inline GEN _new_GEN_from_fmpq_t(fmpq_t value) noexcept: r""" Create a new PARI ``t_RAT`` from a ``fmpq_t``. @@ -58,7 +58,7 @@ cdef inline GEN _new_GEN_from_fmpq_t(fmpq_t value): return mkfrac(num, denom) -cdef GEN _new_GEN_from_fmpz_mat_t(fmpz_mat_t B): +cdef GEN _new_GEN_from_fmpz_mat_t(fmpz_mat_t B) noexcept: r""" Create a new PARI ``t_MAT`` with ``nr`` rows and ``nc`` columns from a ``fmpz_mat_t``. @@ -76,7 +76,7 @@ cdef GEN _new_GEN_from_fmpz_mat_t(fmpz_mat_t B): return A -cdef GEN _new_GEN_from_fmpq_mat_t(fmpq_mat_t B): +cdef GEN _new_GEN_from_fmpq_mat_t(fmpq_mat_t B) noexcept: cdef GEN x cdef GEN A = zeromatcopy(fmpq_mat_nrows(B), fmpq_mat_ncols(B)) cdef Py_ssize_t i, j @@ -86,7 +86,7 @@ cdef GEN _new_GEN_from_fmpq_mat_t(fmpq_mat_t B): set_gcoeff(A, i+1, j+1, x) # A[i+1, j+1] = x (using 1-based indexing) return A -cdef GEN _new_GEN_from_fmpz_mat_t_rotate90(fmpz_mat_t B): +cdef GEN _new_GEN_from_fmpz_mat_t_rotate90(fmpz_mat_t B) noexcept: r""" Create a new PARI ``t_MAT`` with ``nr`` rows and ``nc`` columns from a ``fmpz_mat_t`` and rotate the matrix 90 degrees @@ -106,7 +106,7 @@ cdef GEN _new_GEN_from_fmpz_mat_t_rotate90(fmpz_mat_t B): return A -cdef GEN _new_GEN_from_fmpq_mat_t_rotate90(fmpq_mat_t B): +cdef GEN _new_GEN_from_fmpq_mat_t_rotate90(fmpq_mat_t B) noexcept: r""" Create a new PARI ``t_MAT`` with ``nr`` rows and ``nc`` columns from a ``fmpq_mat_t`` and rotate the matrix 90 degrees @@ -126,7 +126,7 @@ cdef GEN _new_GEN_from_fmpq_mat_t_rotate90(fmpq_mat_t B): return A -cdef Gen integer_matrix(fmpz_mat_t B, bint rotate): +cdef Gen integer_matrix(fmpz_mat_t B, bint rotate) noexcept: """ EXAMPLES:: @@ -142,7 +142,7 @@ cdef Gen integer_matrix(fmpz_mat_t B, bint rotate): return new_gen(g) -cdef Gen rational_matrix(fmpq_mat_t B, bint rotate): +cdef Gen rational_matrix(fmpq_mat_t B, bint rotate) noexcept: """ EXAMPLES:: diff --git a/src/sage/libs/pari/convert_gmp.pxd b/src/sage/libs/pari/convert_gmp.pxd index e08380f571d..b745a823ab5 100644 --- a/src/sage/libs/pari/convert_gmp.pxd +++ b/src/sage/libs/pari/convert_gmp.pxd @@ -2,12 +2,12 @@ from cypari2.types cimport GEN from cypari2.gen cimport Gen from sage.libs.gmp.types cimport mpz_t, mpq_t, mpz_ptr, mpq_ptr -cdef Gen new_gen_from_mpz_t(mpz_t value) -cdef GEN _new_GEN_from_mpz_t(mpz_t value) -cdef Gen new_gen_from_mpq_t(mpq_t value) -cdef GEN _new_GEN_from_mpq_t(mpq_t value) -cdef Gen new_gen_from_padic(long ordp, long relprec, mpz_t prime, mpz_t p_pow, mpz_t unit) -cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc) -cdef Gen rational_matrix(mpq_t** B, long nr, long nc) -cdef void INT_to_mpz(mpz_ptr value, GEN g) -cdef void INTFRAC_to_mpq(mpq_ptr value, GEN g) +cdef Gen new_gen_from_mpz_t(mpz_t value) noexcept +cdef GEN _new_GEN_from_mpz_t(mpz_t value) noexcept +cdef Gen new_gen_from_mpq_t(mpq_t value) noexcept +cdef GEN _new_GEN_from_mpq_t(mpq_t value) noexcept +cdef Gen new_gen_from_padic(long ordp, long relprec, mpz_t prime, mpz_t p_pow, mpz_t unit) noexcept +cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc) noexcept +cdef Gen rational_matrix(mpq_t** B, long nr, long nc) noexcept +cdef void INT_to_mpz(mpz_ptr value, GEN g) noexcept +cdef void INTFRAC_to_mpq(mpq_ptr value, GEN g) noexcept diff --git a/src/sage/libs/pari/convert_gmp.pyx b/src/sage/libs/pari/convert_gmp.pyx index fcd212a8703..4a38bd5f527 100644 --- a/src/sage/libs/pari/convert_gmp.pyx +++ b/src/sage/libs/pari/convert_gmp.pyx @@ -27,7 +27,7 @@ from sage.libs.gmp.all cimport * from cypari2.paridecl cimport * from cypari2.stack cimport new_gen -cdef Gen new_gen_from_mpz_t(mpz_t value): +cdef Gen new_gen_from_mpz_t(mpz_t value) noexcept: """ Create a new PARI Gen of type ``t_INT`` from a given GMP integer ``value``. @@ -53,7 +53,7 @@ cdef Gen new_gen_from_mpz_t(mpz_t value): return new_gen(_new_GEN_from_mpz_t(value)) -cdef inline GEN _new_GEN_from_mpz_t(mpz_t value): +cdef inline GEN _new_GEN_from_mpz_t(mpz_t value) noexcept: r""" Create a new PARI ``t_INT`` from a ``mpz_t``. @@ -73,7 +73,7 @@ cdef inline GEN _new_GEN_from_mpz_t(mpz_t value): return z -cdef Gen new_gen_from_mpq_t(mpq_t value): +cdef Gen new_gen_from_mpq_t(mpq_t value) noexcept: """ Create a new PARI Gen of type ``t_INT`` or ``t_FRAC`` from a given GMP rational ``value``. @@ -105,7 +105,7 @@ cdef Gen new_gen_from_mpq_t(mpq_t value): return new_gen(_new_GEN_from_mpq_t(value)) -cdef inline GEN _new_GEN_from_mpq_t(mpq_t value): +cdef inline GEN _new_GEN_from_mpq_t(mpq_t value) noexcept: r""" Create a new PARI ``t_INT`` or ``t_FRAC`` from a ``mpq_t``. @@ -121,7 +121,7 @@ cdef inline GEN _new_GEN_from_mpq_t(mpq_t value): cdef Gen new_gen_from_padic(long ordp, long relprec, - mpz_t prime, mpz_t p_pow, mpz_t unit): + mpz_t prime, mpz_t p_pow, mpz_t unit) noexcept: """ Create a new PARI Gen of type ``t_PADIC`` from the given input data as GMP integers. @@ -136,7 +136,7 @@ cdef Gen new_gen_from_padic(long ordp, long relprec, return new_gen(z) -cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc): +cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc) noexcept: """ Create a new PARI ``t_MAT`` from a given 2-dimensional array of GMP rationals ``mpq_t``. @@ -155,7 +155,7 @@ cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc): return A -cdef Gen rational_matrix(mpq_t** B, long nr, long nc): +cdef Gen rational_matrix(mpq_t** B, long nr, long nc) noexcept: """ Create a new PARI matrix of type ``t_MAT`` from a given array of GMP rationals ``mpq_t``. @@ -180,7 +180,7 @@ cdef Gen rational_matrix(mpq_t** B, long nr, long nc): return new_gen(g) -cdef inline void INT_to_mpz(mpz_ptr value, GEN g): +cdef inline void INT_to_mpz(mpz_ptr value, GEN g) noexcept: """ Convert a PARI ``t_INT`` to a GMP integer, stored in ``value``. """ @@ -194,7 +194,7 @@ cdef inline void INT_to_mpz(mpz_ptr value, GEN g): mpz_neg(value, value) -cdef void INTFRAC_to_mpq(mpq_ptr value, GEN g): +cdef void INTFRAC_to_mpq(mpq_ptr value, GEN g) noexcept: """ Convert a PARI ``t_INT`` or ``t_FRAC`` to a GMP rational, stored in ``value``. diff --git a/src/sage/libs/pari/convert_sage.pxd b/src/sage/libs/pari/convert_sage.pxd index 266a8204a39..ffa9c0ef6c0 100644 --- a/src/sage/libs/pari/convert_sage.pxd +++ b/src/sage/libs/pari/convert_sage.pxd @@ -2,14 +2,14 @@ from cypari2.gen cimport Gen from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational -cpdef gen_to_sage(Gen z, locals=*) +cpdef gen_to_sage(Gen z, locals=*) noexcept -cpdef set_integer_from_gen(Integer self, Gen x) -cpdef Gen new_gen_from_integer(Integer self) -cpdef set_rational_from_gen(Rational self, Gen x) -cpdef Gen new_gen_from_rational(Rational self) +cpdef set_integer_from_gen(Integer self, Gen x) noexcept +cpdef Gen new_gen_from_integer(Integer self) noexcept +cpdef set_rational_from_gen(Rational self, Gen x) noexcept +cpdef Gen new_gen_from_rational(Rational self) noexcept -cpdef pari_is_prime(Integer p) -cpdef pari_is_prime_power(Integer q, bint get_data) -cpdef unsigned long pari_maxprime() -cpdef list pari_prime_range(long c_start, long c_stop, bint py_ints=*) +cpdef pari_is_prime(Integer p) noexcept +cpdef pari_is_prime_power(Integer q, bint get_data) noexcept +cpdef unsigned long pari_maxprime() noexcept +cpdef list pari_prime_range(long c_start, long c_stop, bint py_ints=*) noexcept diff --git a/src/sage/libs/pari/convert_sage.pyx b/src/sage/libs/pari/convert_sage.pyx index 71a1744698e..500ed520312 100644 --- a/src/sage/libs/pari/convert_sage.pyx +++ b/src/sage/libs/pari/convert_sage.pyx @@ -38,7 +38,7 @@ from sage.rings.padics.factory import Qp from sage.rings.infinity import Infinity -cpdef gen_to_sage(Gen z, locals=None): +cpdef gen_to_sage(Gen z, locals=None) noexcept: """ Convert a PARI gen to a Sage/Python object. @@ -326,7 +326,7 @@ cpdef gen_to_sage(Gen z, locals=None): return sage_eval(str(z), locals=locals) -cpdef set_integer_from_gen(Integer self, Gen x): +cpdef set_integer_from_gen(Integer self, Gen x) noexcept: r""" EXAMPLES:: @@ -374,7 +374,7 @@ cpdef set_integer_from_gen(Integer self, Gen x): INT_to_mpz(self.value, (x).g) -cpdef Gen new_gen_from_integer(Integer self): +cpdef Gen new_gen_from_integer(Integer self) noexcept: """ TESTS:: @@ -386,7 +386,7 @@ cpdef Gen new_gen_from_integer(Integer self): return new_gen_from_mpz_t(self.value) -cpdef set_rational_from_gen(Rational self, Gen x): +cpdef set_rational_from_gen(Rational self, Gen x) noexcept: r""" EXAMPLES:: @@ -406,7 +406,7 @@ cpdef set_rational_from_gen(Rational self, Gen x): mpz_set_si(mpq_denref(self.value), 1) -cpdef Gen new_gen_from_rational(Rational self): +cpdef Gen new_gen_from_rational(Rational self) noexcept: """ TESTS:: @@ -418,7 +418,7 @@ cpdef Gen new_gen_from_rational(Rational self): return new_gen_from_mpq_t(self.value) -cpdef list pari_divisors_small(Integer self): +cpdef list pari_divisors_small(Integer self) noexcept: r""" Return the list of divisors of this number using PARI ``divisorsu``. @@ -464,7 +464,7 @@ cpdef list pari_divisors_small(Integer self): avma = ltop -cpdef pari_is_prime(Integer p): +cpdef pari_is_prime(Integer p) noexcept: r""" Return whether ``p`` is a prime. @@ -491,7 +491,7 @@ cpdef pari_is_prime(Integer p): return bool(uisprime(mpz_get_ui(p.value))) -cpdef pari_is_prime_power(Integer q, bint get_data): +cpdef pari_is_prime_power(Integer q, bint get_data) noexcept: r""" Return whether ``q`` is a prime power. @@ -532,7 +532,7 @@ cpdef pari_is_prime_power(Integer q, bint get_data): return (q, smallInteger(0)) if get_data else False -cpdef unsigned long pari_maxprime(): +cpdef unsigned long pari_maxprime() noexcept: """ Return to which limit PARI has computed the primes. @@ -548,7 +548,7 @@ cpdef unsigned long pari_maxprime(): return maxprime() -cpdef list pari_prime_range(long c_start, long c_stop, bint py_ints=False): +cpdef list pari_prime_range(long c_start, long c_stop, bint py_ints=False) noexcept: """ Return a list of all primes between ``start`` and ``stop - 1``, inclusive. diff --git a/src/sage/libs/pari/convert_sage_complex_double.pxd b/src/sage/libs/pari/convert_sage_complex_double.pxd index 51299d77759..803892b274a 100644 --- a/src/sage/libs/pari/convert_sage_complex_double.pxd +++ b/src/sage/libs/pari/convert_sage_complex_double.pxd @@ -1,13 +1,13 @@ from cypari2.gen cimport Gen from sage.rings.complex_double cimport ComplexDoubleElement -cpdef ComplexDoubleElement pari_to_cdf(Gen g) +cpdef ComplexDoubleElement pari_to_cdf(Gen g) noexcept -cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self) +cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self) noexcept -cpdef ComplexDoubleElement complex_double_element_eta(ComplexDoubleElement self, int flag) -cpdef ComplexDoubleElement complex_double_element_agm(ComplexDoubleElement self, right) -cpdef ComplexDoubleElement complex_double_element_dilog(ComplexDoubleElement self) -cpdef ComplexDoubleElement complex_double_element_gamma(ComplexDoubleElement self) -cpdef ComplexDoubleElement complex_double_element_gamma_inc(ComplexDoubleElement self, t) -cpdef ComplexDoubleElement complex_double_element_zeta(ComplexDoubleElement self) +cpdef ComplexDoubleElement complex_double_element_eta(ComplexDoubleElement self, int flag) noexcept +cpdef ComplexDoubleElement complex_double_element_agm(ComplexDoubleElement self, right) noexcept +cpdef ComplexDoubleElement complex_double_element_dilog(ComplexDoubleElement self) noexcept +cpdef ComplexDoubleElement complex_double_element_gamma(ComplexDoubleElement self) noexcept +cpdef ComplexDoubleElement complex_double_element_gamma_inc(ComplexDoubleElement self, t) noexcept +cpdef ComplexDoubleElement complex_double_element_zeta(ComplexDoubleElement self) noexcept diff --git a/src/sage/libs/pari/convert_sage_complex_double.pyx b/src/sage/libs/pari/convert_sage_complex_double.pyx index ef12c81f5e2..d4022c62a0f 100644 --- a/src/sage/libs/pari/convert_sage_complex_double.pyx +++ b/src/sage/libs/pari/convert_sage_complex_double.pyx @@ -6,7 +6,7 @@ from cypari2.paridecl cimport * from cypari2.convert cimport new_gen_from_double, new_t_COMPLEX_from_double -cpdef ComplexDoubleElement pari_to_cdf(Gen g): +cpdef ComplexDoubleElement pari_to_cdf(Gen g) noexcept: """ Create a CDF element from a PARI ``gen``. @@ -40,7 +40,7 @@ cpdef ComplexDoubleElement pari_to_cdf(Gen g): return z -cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self): +cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self) noexcept: """ Return PARI version of ``self``, as ``t_COMPLEX`` or ``t_REAL``. @@ -60,7 +60,7 @@ cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self): return new_t_COMPLEX_from_double(GSL_REAL(self._complex), GSL_IMAG(self._complex)) -cpdef ComplexDoubleElement complex_double_element_eta(ComplexDoubleElement self, int flag): +cpdef ComplexDoubleElement complex_double_element_eta(ComplexDoubleElement self, int flag) noexcept: """ TESTS:: @@ -74,7 +74,7 @@ cpdef ComplexDoubleElement complex_double_element_eta(ComplexDoubleElement self, return pari_to_cdf(new_gen_from_complex_double_element(self).eta(flag)) -cpdef ComplexDoubleElement complex_double_element_agm(ComplexDoubleElement self, right): +cpdef ComplexDoubleElement complex_double_element_agm(ComplexDoubleElement self, right) noexcept: """ TESTS:: @@ -85,7 +85,7 @@ cpdef ComplexDoubleElement complex_double_element_agm(ComplexDoubleElement self, return pari_to_cdf(new_gen_from_complex_double_element(self).agm(right)) -cpdef ComplexDoubleElement complex_double_element_dilog(ComplexDoubleElement self): +cpdef ComplexDoubleElement complex_double_element_dilog(ComplexDoubleElement self) noexcept: """ TESTS:: @@ -96,7 +96,7 @@ cpdef ComplexDoubleElement complex_double_element_dilog(ComplexDoubleElement sel return pari_to_cdf(new_gen_from_complex_double_element(self).dilog()) -cpdef ComplexDoubleElement complex_double_element_gamma(ComplexDoubleElement self): +cpdef ComplexDoubleElement complex_double_element_gamma(ComplexDoubleElement self) noexcept: """ TESTS:: @@ -107,7 +107,7 @@ cpdef ComplexDoubleElement complex_double_element_gamma(ComplexDoubleElement sel return pari_to_cdf(new_gen_from_complex_double_element(self).gamma()) -cpdef ComplexDoubleElement complex_double_element_gamma_inc(ComplexDoubleElement self, t): +cpdef ComplexDoubleElement complex_double_element_gamma_inc(ComplexDoubleElement self, t) noexcept: """ TESTS:: @@ -118,7 +118,7 @@ cpdef ComplexDoubleElement complex_double_element_gamma_inc(ComplexDoubleElement return pari_to_cdf(new_gen_from_complex_double_element(self).incgam(t)) -cpdef ComplexDoubleElement complex_double_element_zeta(ComplexDoubleElement self): +cpdef ComplexDoubleElement complex_double_element_zeta(ComplexDoubleElement self) noexcept: """ TESTS:: diff --git a/src/sage/libs/pari/convert_sage_real_double.pxd b/src/sage/libs/pari/convert_sage_real_double.pxd index 12fa7418e69..df2119d0370 100644 --- a/src/sage/libs/pari/convert_sage_real_double.pxd +++ b/src/sage/libs/pari/convert_sage_real_double.pxd @@ -1,4 +1,4 @@ from cypari2.gen cimport Gen from sage.rings.real_double cimport RealDoubleElement -cpdef Gen new_gen_from_real_double_element(RealDoubleElement self) +cpdef Gen new_gen_from_real_double_element(RealDoubleElement self) noexcept diff --git a/src/sage/libs/pari/convert_sage_real_double.pyx b/src/sage/libs/pari/convert_sage_real_double.pyx index 6d7ffe7038e..ee7eba3f4a8 100644 --- a/src/sage/libs/pari/convert_sage_real_double.pyx +++ b/src/sage/libs/pari/convert_sage_real_double.pyx @@ -1,6 +1,6 @@ from cypari2.convert cimport new_gen_from_double -cpdef Gen new_gen_from_real_double_element(RealDoubleElement self): +cpdef Gen new_gen_from_real_double_element(RealDoubleElement self) noexcept: """ Return a PARI representation of ``self``. diff --git a/src/sage/libs/pari/misc.pxd b/src/sage/libs/pari/misc.pxd index ae89aff0b84..da162742f1d 100644 --- a/src/sage/libs/pari/misc.pxd +++ b/src/sage/libs/pari/misc.pxd @@ -1,3 +1,3 @@ from cypari2.gen cimport Gen -cdef Gen new_t_POL_from_int_star(int* vals, unsigned long length, long varnum) +cdef Gen new_t_POL_from_int_star(int* vals, unsigned long length, long varnum) noexcept diff --git a/src/sage/libs/pari/misc.pyx b/src/sage/libs/pari/misc.pyx index 1ed774d417c..02fd8403b8e 100644 --- a/src/sage/libs/pari/misc.pyx +++ b/src/sage/libs/pari/misc.pyx @@ -3,7 +3,7 @@ from cypari2.paridecl cimport * from cypari2.stack cimport new_gen -cdef Gen new_t_POL_from_int_star(int* vals, unsigned long length, long varnum): +cdef Gen new_t_POL_from_int_star(int* vals, unsigned long length, long varnum) noexcept: """ Convert an array of ints to a PARI polynomial. diff --git a/src/sage/libs/singular/function.pxd b/src/sage/libs/singular/function.pxd index 503384004d5..29748c039c6 100644 --- a/src/sage/libs/singular/function.pxd +++ b/src/sage/libs/singular/function.pxd @@ -19,7 +19,7 @@ from sage.libs.singular.decl cimport leftv, idhdl, syStrategy, matrix, poly, ide from sage.libs.singular.decl cimport ring as singular_ring from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular, MPolynomial_libsingular -cdef new_sage_polynomial(ring, poly *p) +cdef new_sage_polynomial(ring, poly *p) noexcept cdef poly* access_singular_poly(p) except -1 cdef singular_ring* access_singular_ring(r) except -1 @@ -35,8 +35,8 @@ cdef class Converter(SageObject): cdef object _sage_ring cdef singular_ring* _singular_ring cdef leftv* pop_front(self) except NULL - cdef leftv * _append_leftv(self, leftv *v) - cdef leftv * _append(self, void* data, int res_type) + cdef leftv * _append_leftv(self, leftv *v) noexcept + cdef leftv * _append(self, void* data, int res_type) noexcept cdef leftv * append_polynomial(self, p) except NULL cdef leftv * append_ideal(self, i) except NULL cdef leftv * append_number(self, n) except NULL @@ -50,15 +50,15 @@ cdef class Converter(SageObject): cdef leftv * append_matrix(self, a) except NULL cdef leftv * append_ring(self, r) except NULL cdef leftv * append_module(self, m) except NULL - cdef to_sage_integer_matrix(self, intvec *mat) - cdef object to_sage_module_element_sequence_destructive(self, ideal *i) - cdef to_sage_vector_destructive(self, poly *p, free_module = ?) - cdef to_sage_matrix(self, matrix* mat) - cdef to_python(self, leftv* to_convert) + cdef to_sage_integer_matrix(self, intvec *mat) noexcept + cdef object to_sage_module_element_sequence_destructive(self, ideal *i) noexcept + cdef to_sage_vector_destructive(self, poly *p, free_module = ?) noexcept + cdef to_sage_matrix(self, matrix* mat) noexcept + cdef to_python(self, leftv* to_convert) noexcept cdef class BaseCallHandler: - cdef leftv* handle_call(self, Converter argument_list, singular_ring *_ring=?) - cdef bint free_res(self) + cdef leftv* handle_call(self, Converter argument_list, singular_ring *_ring=?) noexcept + cdef bint free_res(self) noexcept cdef class LibraryCallHandler(BaseCallHandler): cdef idhdl * proc_idhdl @@ -72,9 +72,9 @@ cdef class SingularFunction(SageObject): cdef MPolynomialRing_libsingular _ring cdef BaseCallHandler call_handler - cdef BaseCallHandler get_call_handler(self) - cdef bint function_exists(self) - cdef common_ring(self, tuple args, ring=?) + cdef BaseCallHandler get_call_handler(self) noexcept + cdef bint function_exists(self) noexcept + cdef common_ring(self, tuple args, ring=?) noexcept cdef class SingularLibraryFunction(SingularFunction): pass @@ -83,4 +83,4 @@ cdef class SingularKernelFunction(SingularFunction): pass # the most direct function call interface -cdef call_function(SingularFunction self, tuple args, object R, bint signal_handler=?, object attributes=?) +cdef call_function(SingularFunction self, tuple args, object R, bint signal_handler=?, object attributes=?) noexcept diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx index c597c63aafe..ac4bde0c20b 100644 --- a/src/sage/libs/singular/function.pyx +++ b/src/sage/libs/singular/function.pyx @@ -339,7 +339,7 @@ cdef class Resolution: self._resolution.references -= 1 -cdef leftv* new_leftv(void *data, res_type): +cdef leftv* new_leftv(void *data, res_type) noexcept: """ INPUT: @@ -353,7 +353,7 @@ cdef leftv* new_leftv(void *data, res_type): res.rtyp = res_type return res -cdef free_leftv(leftv *args, ring *r = NULL): +cdef free_leftv(leftv *args, ring *r = NULL) noexcept: """ Kills this ``leftv`` and all ``leftv``s in the tail. @@ -393,7 +393,7 @@ def is_sage_wrapper_for_singular_ring(ring): return True return False -cdef new_sage_polynomial(ring, poly *p): +cdef new_sage_polynomial(ring, poly *p) noexcept: if isinstance(ring, MPolynomialRing_libsingular): return new_MP(ring, p) else: @@ -456,7 +456,7 @@ cdef ring* access_singular_ring(r) except -1: return ( r )._ring raise ValueError("not a singular polynomial ring wrapper") -cdef poly* copy_sage_polynomial_into_singular_poly(p): +cdef poly* copy_sage_polynomial_into_singular_poly(p) noexcept: return p_Copy(access_singular_poly(p), access_singular_ring(p.parent())) @@ -653,7 +653,7 @@ cdef class Converter(SageObject): res.next = NULL return res - cdef leftv *_append_leftv(self, leftv *v): + cdef leftv *_append_leftv(self, leftv *v) noexcept: """ Append a new Singular element to the list. """ @@ -667,7 +667,7 @@ cdef class Converter(SageObject): self.args = v return v - cdef leftv *_append(self, void* data, int res_type): + cdef leftv *_append(self, void* data, int res_type) noexcept: """ Create a new ``leftv`` and append it to the list. @@ -678,7 +678,7 @@ cdef class Converter(SageObject): """ return self._append_leftv( new_leftv(data, res_type) ) - cdef to_sage_matrix(self, matrix* mat): + cdef to_sage_matrix(self, matrix* mat) noexcept: """ Convert singular matrix to matrix over the polynomial ring. """ @@ -693,7 +693,7 @@ cdef class Converter(SageObject): result[i,j] = p return result - cdef to_sage_vector_destructive(self, poly *p, free_module = None): + cdef to_sage_vector_destructive(self, poly *p, free_module = None) noexcept: cdef int rank if free_module: rank = free_module.rank() @@ -733,7 +733,7 @@ cdef class Converter(SageObject): result.append(new_sage_polynomial(self._sage_ring, first)) return free_module(result) - cdef object to_sage_module_element_sequence_destructive( self, ideal *i): + cdef object to_sage_module_element_sequence_destructive( self, ideal *i) noexcept: """ Convert a SINGULAR module to a Sage Sequence (the format Sage stores a Groebner basis in). @@ -756,7 +756,7 @@ cdef class Converter(SageObject): return Sequence(l, check=False, immutable=True) - cdef to_sage_integer_matrix(self, intvec* mat): + cdef to_sage_integer_matrix(self, intvec* mat) noexcept: """ Convert Singular matrix to matrix over the polynomial ring. """ @@ -908,7 +908,7 @@ cdef class Converter(SageObject): b = str_to_bytes(n) return self._append(omStrDup(b), STRING_CMD) - cdef to_python(self, leftv* to_convert): + cdef to_python(self, leftv* to_convert) noexcept: """ Convert the ``leftv`` to a Python object. @@ -994,13 +994,13 @@ cdef class BaseCallHandler: A call handler is an abstraction which hides the details of the implementation differences between kernel and library functions. """ - cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL): + cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept: """ Actual function call. """ return NULL - cdef bint free_res(self): + cdef bint free_res(self) noexcept: """ Do we need to free the result object. """ @@ -1029,7 +1029,7 @@ cdef class LibraryCallHandler(BaseCallHandler): """ super().__init__() - cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL): + cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept: if _ring != currRing: rChangeCurrRing(_ring) cdef bint error = iiMake_proc(self.proc_idhdl, NULL, argument_list.args) cdef leftv * res @@ -1041,7 +1041,7 @@ cdef class LibraryCallHandler(BaseCallHandler): return res raise RuntimeError("Error raised calling singular function") - cdef bint free_res(self): + cdef bint free_res(self) noexcept: """ We do not need to free the result object for library functions. @@ -1073,7 +1073,7 @@ cdef class KernelCallHandler(BaseCallHandler): self.cmd_n = cmd_n self.arity = arity - cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL): + cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept: cdef leftv * res res = omAllocBin(sleftv_bin) res.Init() @@ -1129,7 +1129,7 @@ cdef class KernelCallHandler(BaseCallHandler): .format(number_of_arguments, self.arity)) return NULL - cdef bint free_res(self): + cdef bint free_res(self) noexcept: """ We need to free the result object for kernel functions. """ @@ -1168,13 +1168,13 @@ cdef class SingularFunction(SageObject): currRingHdl.data.uring = omAlloc0Bin(sip_sring_bin) currRingHdl.data.uring.ref += 1 - cdef BaseCallHandler get_call_handler(self): + cdef BaseCallHandler get_call_handler(self) noexcept: """ Return a call handler which does the actual work. """ raise NotImplementedError - cdef bint function_exists(self): + cdef bint function_exists(self) noexcept: """ Return ``True`` if the function exists in this interface. """ @@ -1358,7 +1358,7 @@ The Singular documentation for '%s' is given below. else: return prefix + "\n::\n\n"+" Singular documentation not found" - cdef common_ring(self, tuple args, ring=None): + cdef common_ring(self, tuple args, ring=None) noexcept: """ Return the common ring for the argument list ``args``. @@ -1442,7 +1442,7 @@ The Singular documentation for '%s' is given below. return richcmp(lx._name, rx._name, op) -cdef inline call_function(SingularFunction self, tuple args, object R, bint signal_handler=True, attributes=None): +cdef inline call_function(SingularFunction self, tuple args, object R, bint signal_handler=True, attributes=None) noexcept: global currRingHdl global errorreported global currentVoice @@ -1530,7 +1530,7 @@ cdef class SingularLibraryFunction(SingularFunction): super().__init__(name) self.call_handler = self.get_call_handler() - cdef BaseCallHandler get_call_handler(self): + cdef BaseCallHandler get_call_handler(self) noexcept: cdef idhdl* singular_idhdl = ggetid(str_to_bytes(self._name)) if singular_idhdl==NULL: raise NameError("Singular library function {!r} is not defined".format(self._name)) @@ -1541,7 +1541,7 @@ cdef class SingularLibraryFunction(SingularFunction): res.proc_idhdl = singular_idhdl return res - cdef bint function_exists(self): + cdef bint function_exists(self) noexcept: cdef idhdl* singular_idhdl = ggetid(str_to_bytes(self._name)) return singular_idhdl!=NULL @@ -1577,7 +1577,7 @@ cdef class SingularKernelFunction(SingularFunction): super().__init__(name) self.call_handler = self.get_call_handler() - cdef BaseCallHandler get_call_handler(self): + cdef BaseCallHandler get_call_handler(self) noexcept: cdef int cmd_n = 0 arity = IsCmd(str_to_bytes(self._name), cmd_n) # call by reverence for CMD_n if not cmd_n: @@ -1585,7 +1585,7 @@ cdef class SingularKernelFunction(SingularFunction): return KernelCallHandler(cmd_n, arity) - cdef bint function_exists(self): + cdef bint function_exists(self) noexcept: cdef int cmd_n = -1 arity = IsCmd(str_to_bytes(self._name), cmd_n) # call by reverence for CMD_n return cmd_n != -1 @@ -1842,7 +1842,7 @@ def list_of_functions(packages=False): h = IDNEXT(h) return l -cdef inline RingWrap new_RingWrap(ring* r): +cdef inline RingWrap new_RingWrap(ring* r) noexcept: cdef RingWrap ring_wrap_result = RingWrap.__new__(RingWrap) ring_wrap_result._ring = r ring_wrap_result._ring.ref += 1 diff --git a/src/sage/libs/singular/groebner_strategy.pxd b/src/sage/libs/singular/groebner_strategy.pxd index 605e2679228..391f11aee97 100644 --- a/src/sage/libs/singular/groebner_strategy.pxd +++ b/src/sage/libs/singular/groebner_strategy.pxd @@ -11,11 +11,11 @@ cdef class GroebnerStrategy(SageObject): cdef MPolynomialRing_libsingular _parent cdef object _ideal - cpdef MPolynomial_libsingular normal_form(self, MPolynomial_libsingular p) + cpdef MPolynomial_libsingular normal_form(self, MPolynomial_libsingular p) noexcept cdef class NCGroebnerStrategy(SageObject): cdef skStrategy *_strat cdef NCPolynomialRing_plural _parent cdef object _ideal - cpdef NCPolynomial_plural normal_form(self, NCPolynomial_plural p) + cpdef NCPolynomial_plural normal_form(self, NCPolynomial_plural p) noexcept diff --git a/src/sage/libs/singular/groebner_strategy.pyx b/src/sage/libs/singular/groebner_strategy.pyx index c2417fb927d..40a0a0f939d 100644 --- a/src/sage/libs/singular/groebner_strategy.pyx +++ b/src/sage/libs/singular/groebner_strategy.pyx @@ -260,7 +260,7 @@ cdef class GroebnerStrategy(SageObject): """ return unpickle_GroebnerStrategy0, (self._ideal,) - cpdef MPolynomial_libsingular normal_form(self, MPolynomial_libsingular p): + cpdef MPolynomial_libsingular normal_form(self, MPolynomial_libsingular p) noexcept: """ Compute the normal form of ``p`` with respect to the generators of this object. @@ -511,7 +511,7 @@ cdef class NCGroebnerStrategy(SageObject): """ return unpickle_NCGroebnerStrategy0, (self._ideal,) - cpdef NCPolynomial_plural normal_form(self, NCPolynomial_plural p): + cpdef NCPolynomial_plural normal_form(self, NCPolynomial_plural p) noexcept: """ Compute the normal form of ``p`` with respect to the generators of this object. diff --git a/src/sage/libs/singular/polynomial.pxd b/src/sage/libs/singular/polynomial.pxd index c5cbd292cca..df27179da54 100644 --- a/src/sage/libs/singular/polynomial.pxd +++ b/src/sage/libs/singular/polynomial.pxd @@ -17,21 +17,21 @@ from sage.structure.element cimport RingElement from sage.libs.singular.decl cimport poly, ring cdef int singular_polynomial_check(poly *p, ring *r) except -1 -cdef int singular_polynomial_add (poly **ret, poly *p, poly *q, ring *r) -cdef int singular_polynomial_call (poly **ret, poly *p, ring *r, list args, poly *(*get_element)(object)) -cdef int singular_polynomial_cmp (poly *p, poly *q, ring *r) -cdef int singular_polynomial_rmul (poly **ret, poly *p, RingElement q, ring *r) +cdef int singular_polynomial_add (poly **ret, poly *p, poly *q, ring *r) noexcept +cdef int singular_polynomial_call (poly **ret, poly *p, ring *r, list args, poly *(*get_element)(object)) noexcept +cdef int singular_polynomial_cmp (poly *p, poly *q, ring *r) noexcept +cdef int singular_polynomial_rmul (poly **ret, poly *p, RingElement q, ring *r) noexcept cdef int singular_polynomial_mul (poly **ret, poly *p, poly *q, ring *r) except -1 -cdef int singular_polynomial_sub (poly **ret, poly *p, poly *q, ring *r) +cdef int singular_polynomial_sub (poly **ret, poly *p, poly *q, ring *r) noexcept cdef int singular_polynomial_div_coeff (poly **ret, poly *p, poly *q, ring *r) except -1 cdef int singular_polynomial_pow (poly **ret, poly *p, unsigned long exp, ring *r) except -1 -cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r) +cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r) noexcept -cdef object singular_polynomial_latex(poly *p, ring *r, object base, object latex_gens) -cdef object singular_polynomial_str(poly *p, ring *r) -cdef object singular_polynomial_str_with_changed_varnames(poly *p, ring *r, object varnames) -cdef long singular_polynomial_deg(poly *p, poly *x, ring *r) +cdef object singular_polynomial_latex(poly *p, ring *r, object base, object latex_gens) noexcept +cdef object singular_polynomial_str(poly *p, ring *r) noexcept +cdef object singular_polynomial_str_with_changed_varnames(poly *p, ring *r, object varnames) noexcept +cdef long singular_polynomial_deg(poly *p, poly *x, ring *r) noexcept -cdef int singular_polynomial_length_bounded(poly *p, int bound) +cdef int singular_polynomial_length_bounded(poly *p, int bound) noexcept cdef int singular_vector_maximal_component(poly *v, ring *r) except -1 cdef int singular_polynomial_subst(poly **p, int var_index, poly *value, ring *r) except -1 diff --git a/src/sage/libs/singular/polynomial.pyx b/src/sage/libs/singular/polynomial.pyx index 9f81a20b0a7..d208aa9a37c 100644 --- a/src/sage/libs/singular/polynomial.pyx +++ b/src/sage/libs/singular/polynomial.pyx @@ -51,7 +51,7 @@ cdef int singular_polynomial_check(poly *p, ring *r) except -1: p = p.next return 0 -cdef int singular_polynomial_add(poly **ret, poly *p, poly *q, ring *r): +cdef int singular_polynomial_add(poly **ret, poly *p, poly *q, ring *r) noexcept: """ ``ret[0] = p+q`` where ``p`` and ``p`` in ``r``. @@ -78,7 +78,7 @@ cdef int singular_polynomial_add(poly **ret, poly *p, poly *q, ring *r): ret[0] = p_Add_q(p, q, r) return 0 -cdef int singular_polynomial_sub(poly **ret, poly *p, poly *q, ring *r): +cdef int singular_polynomial_sub(poly **ret, poly *p, poly *q, ring *r) noexcept: """ ``ret[0] = p-q`` where ``p`` and ``p`` in ``r``. @@ -105,7 +105,7 @@ cdef int singular_polynomial_sub(poly **ret, poly *p, poly *q, ring *r): ret[0] = p_Add_q(p, p_Neg(q, r), r) return 0 -cdef int singular_polynomial_rmul(poly **ret, poly *p, RingElement n, ring *r): +cdef int singular_polynomial_rmul(poly **ret, poly *p, RingElement n, ring *r) noexcept: """ ``ret[0] = n*p`` where ``n`` is a coefficient and ``p`` in ``r``. @@ -132,7 +132,7 @@ cdef int singular_polynomial_rmul(poly **ret, poly *p, RingElement n, ring *r): n_Delete(&_n, r.cf) return 0 -cdef int singular_polynomial_call(poly **ret, poly *p, ring *r, list args, poly *(*get_element)(object)): +cdef int singular_polynomial_call(poly **ret, poly *p, ring *r, list args, poly *(*get_element)(object)) noexcept: """ ``ret[0] = p(*args)`` where each entry in arg is a polynomial and ``p`` in ``r``. @@ -231,7 +231,7 @@ cdef int singular_polynomial_call(poly **ret, poly *p, ring *r, list args, poly return 0 -cdef int singular_polynomial_cmp(poly *p, poly *q, ring *r): +cdef int singular_polynomial_cmp(poly *p, poly *q, ring *r) noexcept: """ Compare two Singular elements ``p`` and ``q`` in ``r``. @@ -399,7 +399,7 @@ cdef int singular_polynomial_pow(poly **ret, poly *p, unsigned long exp, ring *r sig_off() return 0 -cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r): +cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r) noexcept: """ ``ret[0] = -p where ``p`` in ``r``. @@ -425,7 +425,7 @@ cdef int singular_polynomial_neg(poly **ret, poly *p, ring *r): ret[0] = p_Neg(p_Copy(p,r),r) return 0 -cdef object singular_polynomial_str(poly *p, ring *r): +cdef object singular_polynomial_str(poly *p, ring *r) noexcept: """ Return the string representation of ``p``. @@ -450,7 +450,7 @@ cdef object singular_polynomial_str(poly *p, ring *r): s = parenthvar_pattern.sub("\\1", s) return s -cdef object singular_polynomial_latex(poly *p, ring *r, object base, object latex_gens): +cdef object singular_polynomial_latex(poly *p, ring *r, object base, object latex_gens) noexcept: r""" Return the LaTeX string representation of ``p``. @@ -532,7 +532,7 @@ cdef object singular_polynomial_latex(poly *p, ring *r, object base, object late return "0" return poly -cdef object singular_polynomial_str_with_changed_varnames(poly *p, ring *r, object varnames): +cdef object singular_polynomial_str_with_changed_varnames(poly *p, ring *r, object varnames) noexcept: cdef char **_names cdef char **_orig_names cdef int i @@ -555,7 +555,7 @@ cdef object singular_polynomial_str_with_changed_varnames(poly *p, ring *r, obje omFree(_names) return s -cdef long singular_polynomial_deg(poly *p, poly *x, ring *r): +cdef long singular_polynomial_deg(poly *p, poly *x, ring *r) noexcept: cdef long _deg, deg cdef int dummy @@ -579,7 +579,7 @@ cdef long singular_polynomial_deg(poly *p, poly *x, ring *r): p = pNext(p) return deg -cdef int singular_polynomial_length_bounded(poly *p, int bound): +cdef int singular_polynomial_length_bounded(poly *p, int bound) noexcept: """ Return the number of monomials in ``p`` but stop counting at ``bound``. diff --git a/src/sage/libs/singular/ring.pxd b/src/sage/libs/singular/ring.pxd index b6cc791355b..70ff788f21c 100644 --- a/src/sage/libs/singular/ring.pxd +++ b/src/sage/libs/singular/ring.pxd @@ -52,7 +52,7 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL cdef ring *singular_ring_reference(ring *existing_ring) except NULL # carefully delete a ring once its refcount is zero -cdef void singular_ring_delete(ring *doomed) +cdef void singular_ring_delete(ring *doomed) noexcept # Used internally for reference counting -cdef wrap_ring(ring* R) +cdef wrap_ring(ring* R) noexcept diff --git a/src/sage/libs/singular/ring.pyx b/src/sage/libs/singular/ring.pyx index 56dc364219c..494fd2c0caf 100644 --- a/src/sage/libs/singular/ring.pyx +++ b/src/sage/libs/singular/ring.pyx @@ -618,7 +618,7 @@ cdef class ring_wrapper_Py(): return (self._ring == r._ring) == (op == Py_EQ) -cdef wrap_ring(ring* R): +cdef wrap_ring(ring* R) noexcept: """ Wrap a C ring pointer into a Python object. @@ -690,7 +690,7 @@ cdef ring *singular_ring_reference(ring *existing_ring) except NULL: ############################################################################# -cdef void singular_ring_delete(ring *doomed): +cdef void singular_ring_delete(ring *doomed) noexcept: """ Carefully deallocate the ring, without changing "currRing" (since this method can be called at unpredictable times due to garbage @@ -745,7 +745,7 @@ cdef void singular_ring_delete(ring *doomed): ############################################################################# # helpers for debugging -cpdef poison_currRing(frame, event, arg): +cpdef poison_currRing(frame, event, arg) noexcept: """ Poison the ``currRing`` pointer. @@ -778,7 +778,7 @@ cpdef poison_currRing(frame, event, arg): return poison_currRing -cpdef print_currRing(): +cpdef print_currRing() noexcept: """ Print the ``currRing`` pointer. diff --git a/src/sage/libs/singular/singular.pxd b/src/sage/libs/singular/singular.pxd index e1a55fbcd84..d943a1018a2 100644 --- a/src/sage/libs/singular/singular.pxd +++ b/src/sage/libs/singular/singular.pxd @@ -18,41 +18,41 @@ from sage.rings.number_field.number_field_base cimport NumberField # Conversion from Singular to Sage types # ====================================== -cdef Rational si2sa_QQ(number (*), number **, ring (*)) -cdef Integer si2sa_ZZ(number (*),ring (*)) +cdef Rational si2sa_QQ(number (*), number **, ring (*)) noexcept +cdef Integer si2sa_ZZ(number (*),ring (*)) noexcept -cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache) -cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache) -cdef object si2sa_GFq_generic(number *n, ring *_ring, object base) -cdef object si2sa_ZZmod(number *n, ring *_ring, object base) +cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache) noexcept +cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache) noexcept +cdef object si2sa_GFq_generic(number *n, ring *_ring, object base) noexcept +cdef object si2sa_ZZmod(number *n, ring *_ring, object base) noexcept -cdef object si2sa_NF(number *n, ring *_ring, object base) +cdef object si2sa_NF(number *n, ring *_ring, object base) noexcept -cdef object si2sa_intvec(intvec *v) +cdef object si2sa_intvec(intvec *v) noexcept # dispatches to all the above. -cdef object si2sa(number *n, ring *_ring, object base) +cdef object si2sa(number *n, ring *_ring, object base) noexcept -cdef list singular_monomial_exponents(poly *p, ring *r) -cpdef list si2sa_resolution(Resolution res) -cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees) +cdef list singular_monomial_exponents(poly *p, ring *r) noexcept +cpdef list si2sa_resolution(Resolution res) noexcept +cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees) noexcept # ====================================== # Conversion from Sage to Singular types # ====================================== -cdef number *sa2si_QQ(Rational ,ring (*)) -cdef number *sa2si_ZZ(Integer d, ring *_ring) +cdef number *sa2si_QQ(Rational ,ring (*)) noexcept +cdef number *sa2si_ZZ(Integer d, ring *_ring) noexcept -cdef number *sa2si_GFqGivaro(int exp ,ring (*)) -cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring) -cdef number *sa2si_GFq_generic(object vector, ring *_ring) -cdef number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) +cdef number *sa2si_GFqGivaro(int exp ,ring (*)) noexcept +cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring) noexcept +cdef number *sa2si_GFq_generic(object vector, ring *_ring) noexcept +cdef number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept -cdef number *sa2si_NF(object element, ring *_ring) +cdef number *sa2si_NF(object element, ring *_ring) noexcept # dispatches to all the above. -cdef number *sa2si(Element elem, ring * _ring) +cdef number *sa2si(Element elem, ring * _ring) noexcept # ============== # Initialisation @@ -60,4 +60,4 @@ cdef number *sa2si(Element elem, ring * _ring) cdef int overflow_check(unsigned long e, ring *_ring) except -1 -cdef init_libsingular() +cdef init_libsingular() noexcept diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx index f357ce611c9..63a6e9b332f 100644 --- a/src/sage/libs/singular/singular.pyx +++ b/src/sage/libs/singular/singular.pyx @@ -56,7 +56,7 @@ ctypedef struct fraction "fractionObject": _saved_options = (int(0),0,0) -cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring): +cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring) noexcept: """ Create a sage rational number from a singular one. @@ -128,7 +128,7 @@ cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring): mpq_clear(_z) return z -cdef Integer si2sa_ZZ(number *n, ring *_ring): +cdef Integer si2sa_ZZ(number *n, ring *_ring) noexcept: """ Create a sage integer number from a singular one. @@ -163,7 +163,7 @@ cdef Integer si2sa_ZZ(number *n, ring *_ring): z.set_from_mpz(n) return z -cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache): +cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache) noexcept: """ Create a sage element of a small finite field from a singular one. @@ -218,7 +218,7 @@ cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache): z = pNext(z) return (cache._zero_element)._new_c(ret) -cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache): +cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache) noexcept: """ Create a sage element of a finite field of characteristic 2 from a singular one. @@ -270,7 +270,7 @@ cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache): z = pNext(z) return ret -cdef object si2sa_GFq_generic(number *n, ring *_ring, object base): +cdef object si2sa_GFq_generic(number *n, ring *_ring, object base) noexcept: """ Create a sage element of a generic finite field from a singular one. @@ -332,7 +332,7 @@ cdef object si2sa_GFq_generic(number *n, ring *_ring, object base): z = pNext(z) return ret -cdef object si2sa_transext_QQ(number *n, ring *_ring, object base): +cdef object si2sa_transext_QQ(number *n, ring *_ring, object base) noexcept: """ Create a sage element of a transcendental extension of ``QQ`` from a singular one. @@ -421,7 +421,7 @@ cdef object si2sa_transext_QQ(number *n, ring *_ring, object base): return snumer/sdenom -cdef object si2sa_transext_FF(number *n, ring *_ring, object base): +cdef object si2sa_transext_FF(number *n, ring *_ring, object base) noexcept: """ Create a sage element of a transcendental extension of a prime field from a singular one. @@ -504,7 +504,7 @@ cdef object si2sa_transext_FF(number *n, ring *_ring, object base): return snumer/sdenom -cdef object si2sa_NF(number *n, ring *_ring, object base): +cdef object si2sa_NF(number *n, ring *_ring, object base) noexcept: """ Create a sage element of a number field from a singular one. @@ -570,7 +570,7 @@ cdef object si2sa_NF(number *n, ring *_ring, object base): z = pNext(z) return base(ret) -cdef inline object si2sa_ZZmod(number *n, ring *_ring, object base): +cdef inline object si2sa_ZZmod(number *n, ring *_ring, object base) noexcept: """ Create a sage element of a ring of integers modulo n from a singular one. @@ -632,7 +632,7 @@ cdef inline object si2sa_ZZmod(number *n, ring *_ring, object base): return base(_ring.cf.cfInt(n,_ring.cf)) -cdef list singular_monomial_exponents(poly *p, ring *r): +cdef list singular_monomial_exponents(poly *p, ring *r) noexcept: r""" Return the list of exponents of monomial ``p``. """ @@ -643,7 +643,7 @@ cdef list singular_monomial_exponents(poly *p, ring *r): ml[v-1] = p_GetExp(p, v, r) return ml -cpdef list si2sa_resolution(Resolution res): +cpdef list si2sa_resolution(Resolution res) noexcept: r""" Pull the data from Singular resolution ``res`` to construct a Sage resolution. @@ -760,7 +760,7 @@ cpdef list si2sa_resolution(Resolution res): return res_mats -cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees): +cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees) noexcept: """ Pull the data from Singular resolution ``res`` to construct a Sage resolution. @@ -898,7 +898,7 @@ cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees): return (res_mats, res_degs) -cdef number *sa2si_QQ(Rational r, ring *_ring): +cdef number *sa2si_QQ(Rational r, ring *_ring) noexcept: """ Create a singular number from a sage rational. @@ -928,7 +928,7 @@ cdef number *sa2si_QQ(Rational r, ring *_ring): if _ring != currRing: rChangeCurrRing(_ring) return nlInit2gmp( mpq_numref(r.value), mpq_denref(r.value),_ring.cf ) -cdef number *sa2si_GFqGivaro(int quo, ring *_ring): +cdef number *sa2si_GFqGivaro(int quo, ring *_ring) noexcept: """ Create a singular number in a small finite field. @@ -995,7 +995,7 @@ cdef number *sa2si_GFqGivaro(int quo, ring *_ring): _ring.cf.cfDelete(&a, _ring.cf) return n1 -cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring): +cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring) noexcept: """ Create a singular number from a sage element of a finite field of characteristic 2. @@ -1061,7 +1061,7 @@ cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring): return n1 -cdef number *sa2si_GFq_generic(object elem, ring *_ring): +cdef number *sa2si_GFq_generic(object elem, ring *_ring) noexcept: """ Create a singular number from a sage element of a generic finite field. @@ -1126,7 +1126,7 @@ cdef number *sa2si_GFq_generic(object elem, ring *_ring): return n1 -cdef number *sa2si_transext_QQ(object elem, ring *_ring): +cdef number *sa2si_transext_QQ(object elem, ring *_ring) noexcept: """ Create a singular number from a sage element of a transcendental extension of the rationals. @@ -1276,7 +1276,7 @@ cdef number *sa2si_transext_QQ(object elem, ring *_ring): return n1 -cdef number *sa2si_transext_FF(object elem, ring *_ring): +cdef number *sa2si_transext_FF(object elem, ring *_ring) noexcept: """ Create a singular number from a sage element of a transcendental extension of a prime field. @@ -1377,7 +1377,7 @@ cdef number *sa2si_transext_FF(object elem, ring *_ring): return n1 -cdef number *sa2si_NF(object elem, ring *_ring): +cdef number *sa2si_NF(object elem, ring *_ring) noexcept: """ Create a singular number from a sage element of a number field. @@ -1469,7 +1469,7 @@ cdef number *sa2si_NF(object elem, ring *_ring): return n1 -cdef number *sa2si_ZZ(Integer d, ring *_ring): +cdef number *sa2si_ZZ(Integer d, ring *_ring) noexcept: """ Create a singular number from a sage Integer. @@ -1500,7 +1500,7 @@ cdef number *sa2si_ZZ(Integer d, ring *_ring): mpz_set(n, d.value) return n -cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring): +cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept: """ Create a singular number from a sage element of a IntegerModRing. @@ -1582,7 +1582,7 @@ cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring): else: raise ValueError -cdef object si2sa(number *n, ring *_ring, object base): +cdef object si2sa(number *n, ring *_ring, object base) noexcept: r""" Create a sage number from a singular one @@ -1633,7 +1633,7 @@ cdef object si2sa(number *n, ring *_ring, object base): else: raise ValueError("cannot convert from SINGULAR number") -cdef number *sa2si(Element elem, ring * _ring): +cdef number *sa2si(Element elem, ring * _ring) noexcept: r""" Create a singular number from a sage one. @@ -1681,7 +1681,7 @@ cdef number *sa2si(Element elem, ring * _ring): raise ValueError("cannot convert to SINGULAR number") -cdef object si2sa_intvec(intvec *v): +cdef object si2sa_intvec(intvec *v) noexcept: r""" create a sage tuple from a singular vector of integers @@ -1744,7 +1744,7 @@ cdef int overflow_check(unsigned long e, ring *_ring) except -1: if unlikely(e > _ring.bitmask): raise OverflowError("exponent overflow (%d)"%(e)) -cdef init_libsingular(): +cdef init_libsingular() noexcept: """ This initializes the SINGULAR library. This is a hack to some extent. @@ -1812,7 +1812,7 @@ saved_PATH = os.environ["PATH"] init_libsingular() os.environ["PATH"] = saved_PATH -cdef void libsingular_error_callback(const_char_ptr s): +cdef void libsingular_error_callback(const_char_ptr s) noexcept: _s = char_to_str(s) error_messages.append(_s) diff --git a/src/sage/libs/symmetrica/sb.pxi b/src/sage/libs/symmetrica/sb.pxi index b884d33dafd..31faf7e3d96 100644 --- a/src/sage/libs/symmetrica/sb.pxi +++ b/src/sage/libs/symmetrica/sb.pxi @@ -12,7 +12,7 @@ cdef extern from 'symmetrica/def.h': INT mult_schubert_polynom(OP a,OP b,OP c) -cdef object _check_schubert(object a, OP ca): +cdef object _check_schubert(object a, OP ca) noexcept: if a in Permutations(): if isinstance(a, builtinlist): a = Permutation(a) diff --git a/src/sage/libs/symmetrica/symmetrica.pxi b/src/sage/libs/symmetrica/symmetrica.pxi index 95f9e52fbda..60c3ec23070 100644 --- a/src/sage/libs/symmetrica/symmetrica.pxi +++ b/src/sage/libs/symmetrica/symmetrica.pxi @@ -385,7 +385,7 @@ cdef object two, fifteen, thirty, zero, sage_maxint cdef int maxint = 2147483647 -cdef void late_import(): +cdef void late_import() noexcept: global matrix_constructor, \ Integer, \ Tableau, \ @@ -467,7 +467,7 @@ cdef void late_import(): sage_maxint = Integer(maxint) ########################################## -cdef object _py(OP a): +cdef object _py(OP a) noexcept: cdef OBJECTKIND objk objk = s_o_k(a) if objk == INTEGER: @@ -569,7 +569,7 @@ cdef int _op_int(object x, OP a) except -1: M_I_I(x, a) return 0 -cdef object _py_int(OP a): +cdef object _py_int(OP a) noexcept: late_import() return Integer(S_I_I(a)) @@ -597,7 +597,7 @@ cdef int _op_longint(object x, OP a) except -1: freeall(op_maxint_long) return 0 -cdef object _py_longint(OP a): +cdef object _py_longint(OP a) noexcept: late_import() cdef longint *x = S_O_S(a).ob_longint cdef loc *l = x.floc @@ -620,7 +620,7 @@ cdef object _py_longint(OP a): ########### #Fractions# ########### -cdef object _py_fraction(OP a): +cdef object _py_fraction(OP a) noexcept: return _py(S_B_O(a))/_py(S_B_U(a)) cdef int _op_fraction(object f, OP a) except -1: @@ -632,14 +632,14 @@ cdef int _op_fraction(object f, OP a) except -1: ######### #Vectors# ######### -cdef object _py_vector(OP a): +cdef object _py_vector(OP a) noexcept: cdef INT i res = [] for i from 0 <= i < s_v_li(a): res.append( _py(s_v_i(a, i))) return res -cdef void* _op_il_vector(object l, OP a): +cdef void* _op_il_vector(object l, OP a) noexcept: cdef INT length, i length = len(l) @@ -650,7 +650,7 @@ cdef void* _op_il_vector(object l, OP a): ######### #Numbers# ######### -cdef object _py_sq_radical(OP a): +cdef object _py_sq_radical(OP a) noexcept: late_import() cdef OP ptr @@ -674,7 +674,7 @@ cdef object _py_sq_radical(OP a): ############ #Partitions# ############ -cdef void* _op_partition(object p, OP a): +cdef void* _op_partition(object p, OP a) noexcept: cdef int n, i, j if not EMPTYP(a): @@ -689,7 +689,7 @@ cdef void* _op_partition(object p, OP a): _op_integer(p[i], S_PA_I(a,j)) j = j + 1 -cdef object _py_partition(OP a): +cdef object _py_partition(OP a) noexcept: cdef INT n, i late_import() res = [] @@ -701,7 +701,7 @@ cdef object _py_partition(OP a): ################ #Skew Partition# ################ -cdef void* _op_skew_partition(object p, OP a): +cdef void* _op_skew_partition(object p, OP a) noexcept: cdef OP gross, klein gross = callocobject() klein = callocobject() @@ -709,14 +709,14 @@ cdef void* _op_skew_partition(object p, OP a): _op_partition(p[1], klein) b_gk_spa(gross, klein, a) -cdef object _py_skew_partition(OP a): +cdef object _py_skew_partition(OP a) noexcept: late_import() return SkewPartition( [ _py_partition(s_spa_g(a)), _py_partition(s_spa_k(a)) ] ) ############## #Permutations# ############## -cdef void* _op_permutation(object p, OP a): +cdef void* _op_permutation(object p, OP a) noexcept: cdef int n, i, j if not EMPTYP(a): @@ -727,7 +727,7 @@ cdef void* _op_permutation(object p, OP a): for i from 0 <= i < n: _op_integer(p[i], s_p_i(a,i)) -cdef object _py_permutation(OP a): +cdef object _py_permutation(OP a) noexcept: late_import() cdef INT n, i res = [] @@ -743,7 +743,7 @@ cdef object _py_permutation(OP a): ####### #Lists# ####### -cdef object _py_list(OP a): +cdef object _py_list(OP a) noexcept: cdef OP x x = a res = [] @@ -761,7 +761,7 @@ cdef object _py_list(OP a): ############# #Polynomials# ############# -cdef object _py_polynom(OP a): +cdef object _py_polynom(OP a) noexcept: late_import() cdef int maxneeded = 0, i = 0 cdef OP pointer = a @@ -792,7 +792,7 @@ cdef object _py_polynom(OP a): return P(d) -cdef object _py_polynom_alphabet(OP a, object alphabet, object length): +cdef object _py_polynom_alphabet(OP a, object alphabet, object length) noexcept: """ Converts a symmetrica multivariate polynomial a to a Sage multivariate polynomials. Alphabet specifies the names of the variables which are @@ -828,7 +828,7 @@ cdef object _py_polynom_alphabet(OP a, object alphabet, object length): pointer = s_po_n(pointer) return res -cdef object _op_polynom(object d, OP res): +cdef object _op_polynom(object d, OP res) noexcept: late_import() poly_ring = d.parent() @@ -865,7 +865,7 @@ cdef object _op_polynom(object d, OP res): ####################################### #Schur symmetric functions and friends# ####################################### -cdef object _py_schur(OP a): +cdef object _py_schur(OP a) noexcept: late_import() z_elt = _py_schur_general(a) if len(z_elt) == 0: @@ -879,10 +879,10 @@ cdef object _py_schur(OP a): z._monomial_coefficients = z_elt return z -cdef void* _op_schur(object d, OP res): +cdef void* _op_schur(object d, OP res) noexcept: _op_schur_general(d, res) -cdef object _py_monomial(OP a): #Monomial symmetric functions +cdef object _py_monomial(OP a) noexcept: #Monomial symmetric functions late_import() z_elt = _py_schur_general(a) if len(z_elt) == 0: @@ -895,14 +895,14 @@ cdef object _py_monomial(OP a): #Monomial symmetric functions z._monomial_coefficients = z_elt return z -cdef void* _op_monomial(object d, OP res): #Monomial symmetric functions +cdef void* _op_monomial(object d, OP res) noexcept: #Monomial symmetric functions cdef OP pointer = res _op_schur_general(d, res) while pointer != NULL: c_o_k(pointer, MONOMIAL) pointer = s_s_n(pointer) -cdef object _py_powsym(OP a): #Power-sum symmetric functions +cdef object _py_powsym(OP a) noexcept: #Power-sum symmetric functions late_import() z_elt = _py_schur_general(a) if len(z_elt) == 0: @@ -915,7 +915,7 @@ cdef object _py_powsym(OP a): #Power-sum symmetric functions z._monomial_coefficients = z_elt return z -cdef void* _op_powsym(object d, OP res): #Power-sum symmetric functions +cdef void* _op_powsym(object d, OP res) noexcept: #Power-sum symmetric functions cdef OP pointer = res _op_schur_general(d, res) while pointer != NULL: @@ -923,7 +923,7 @@ cdef void* _op_powsym(object d, OP res): #Power-sum symmetric functions pointer = s_s_n(pointer) -cdef object _py_elmsym(OP a): #Elementary symmetric functions +cdef object _py_elmsym(OP a) noexcept: #Elementary symmetric functions late_import() z_elt = _py_schur_general(a) if len(z_elt) == 0: @@ -936,7 +936,7 @@ cdef object _py_elmsym(OP a): #Elementary symmetric functions z._monomial_coefficients = z_elt return z -cdef void* _op_elmsym(object d, OP res): #Elementary symmetric functions +cdef void* _op_elmsym(object d, OP res) noexcept: #Elementary symmetric functions cdef OP pointer = res _op_schur_general(d, res) while pointer != NULL: @@ -944,7 +944,7 @@ cdef void* _op_elmsym(object d, OP res): #Elementary symmetric functions pointer = s_s_n(pointer) -cdef object _py_homsym(OP a): #Homogenous symmetric functions +cdef object _py_homsym(OP a) noexcept: #Homogenous symmetric functions late_import() z_elt = _py_schur_general(a) if len(z_elt) == 0: @@ -957,7 +957,7 @@ cdef object _py_homsym(OP a): #Homogenous symmetric functions z._monomial_coefficients = z_elt return z -cdef void* _op_homsym(object d, OP res): #Homogenous symmetric functions +cdef void* _op_homsym(object d, OP res) noexcept: #Homogenous symmetric functions cdef OP pointer = res _op_schur_general(d, res) while pointer != NULL: @@ -965,7 +965,7 @@ cdef void* _op_homsym(object d, OP res): #Homogenous symmetric functions pointer = s_s_n(pointer) -cdef object _py_schur_general(OP a): +cdef object _py_schur_general(OP a) noexcept: cdef OP pointer = a d = {} if a == NULL: @@ -975,13 +975,13 @@ cdef object _py_schur_general(OP a): pointer = s_s_n(pointer) return d -cdef void* _op_schur_general(object d, OP res): +cdef void* _op_schur_general(object d, OP res) noexcept: if isinstance(d, dict): _op_schur_general_dict(d, res) else: _op_schur_general_sf(d, res) -cdef void* _op_schur_general_sf(object f, OP res): +cdef void* _op_schur_general_sf(object f, OP res) noexcept: late_import() base_ring = f.parent().base_ring() if not ( base_ring is QQ or base_ring is ZZ ): @@ -989,7 +989,7 @@ cdef void* _op_schur_general_sf(object f, OP res): _op_schur_general_dict( f.monomial_coefficients(), res) -cdef void* _op_schur_general_dict(object d, OP res): +cdef void* _op_schur_general_dict(object d, OP res) noexcept: late_import() cdef OP next @@ -1022,19 +1022,19 @@ cdef void* _op_schur_general_dict(object d, OP res): ###################### #Schubert Polynomials# ###################### -cdef void* _op_schubert_general(object d, OP res): +cdef void* _op_schubert_general(object d, OP res) noexcept: if isinstance(d, dict): _op_schubert_dict(d, res) else: _op_schubert_sp(d, res) -cdef void* _op_schubert_perm(object a, OP res): +cdef void* _op_schubert_perm(object a, OP res) noexcept: cdef OP caperm = callocobject() _op_permutation(a, caperm) m_perm_sch(caperm, res) freeall(caperm) -cdef void* _op_schubert_sp(object f, OP res): +cdef void* _op_schubert_sp(object f, OP res) noexcept: late_import() base_ring = f.parent().base_ring() if not ( base_ring is QQ or base_ring is ZZ ): @@ -1042,7 +1042,7 @@ cdef void* _op_schubert_sp(object f, OP res): _op_schubert_dict( f.monomial_coefficients(), res) -cdef void* _op_schubert_dict(object d, OP res): +cdef void* _op_schubert_dict(object d, OP res) noexcept: late_import() cdef OP next @@ -1069,7 +1069,7 @@ cdef void* _op_schubert_dict(object d, OP res): insert(next, res, NULL, NULL) -cdef object _py_schubert(OP a): +cdef object _py_schubert(OP a) noexcept: late_import() cdef OP pointer = a cdef dict z_elt = {} @@ -1096,7 +1096,7 @@ cdef object _py_schubert(OP a): ########## #Matrices# ########## -cdef object _py_matrix(OP a): +cdef object _py_matrix(OP a) noexcept: late_import() @@ -1119,7 +1119,7 @@ cdef object _py_matrix(OP a): return matrix_constructor(res) -cdef void* _op_matrix(object a, OP res): +cdef void* _op_matrix(object a, OP res) noexcept: #FIXME: only constructs integer matrices cdef INT i,j,rows, cols @@ -1136,7 +1136,7 @@ cdef void* _op_matrix(object a, OP res): ########## #Tableaux# ########## -cdef object _py_tableau(OP t): +cdef object _py_tableau(OP t) noexcept: late_import() diff --git a/src/sage/matrix/action.pyx b/src/sage/matrix/action.pyx index 5c6296a1c35..849163a511f 100644 --- a/src/sage/matrix/action.pyx +++ b/src/sage/matrix/action.pyx @@ -203,7 +203,7 @@ cdef class MatrixMatrixAction(MatrixMulAction): return MatrixSpace(base, self.G.nrows(), self.underlying_set().ncols(), sparse = self.G.is_sparse() and self.underlying_set().is_sparse()) - cpdef _act_(self, g, s): + cpdef _act_(self, g, s) noexcept: """ EXAMPLES: @@ -313,7 +313,7 @@ cdef class MatrixVectorAction(MatrixMulAction): self.underlying_set().degree())) return FreeModule(base, self.G.nrows(), sparse = self.G.is_sparse()) - cpdef _act_(self, g, s): + cpdef _act_(self, g, s) noexcept: cdef Matrix A = g cdef Vector v = s if A._parent._base is not self._codomain._base: @@ -364,7 +364,7 @@ cdef class VectorMatrixAction(MatrixMulAction): self.underlying_set().degree())) return FreeModule(base, self.G.ncols(), sparse = self.G.is_sparse()) - cpdef _act_(self, g, s): + cpdef _act_(self, g, s) noexcept: cdef Matrix A = g cdef Vector v = s if A._parent._base is not self._codomain._base: @@ -423,7 +423,7 @@ cdef class MatrixPolymapAction(MatrixMulAction): return End(self.underlying_set().domain().change_ring(base)) return Hom(self.underlying_set().domain().change_ring(base), self.underlying_set().codomain().change_ring(base)) - cpdef _act_(self, mat, f): + cpdef _act_(self, mat, f) noexcept: """ Call the action @@ -496,7 +496,7 @@ cdef class PolymapMatrixAction(MatrixMulAction): return End(self.underlying_set().domain().change_ring(base)) return Hom(self.underlying_set().domain().change_ring(base), self.underlying_set().codomain().change_ring(base)) - cpdef _act_(self, mat, f): + cpdef _act_(self, mat, f) noexcept: """ Call the action. @@ -564,7 +564,7 @@ cdef class MatrixSchemePointAction(MatrixMulAction): amb = self.underlying_set().codomain() return amb.change_ring(base)(base) - cpdef _act_(self, mat, P): + cpdef _act_(self, mat, P) noexcept: """ Action of matrices on scheme points. diff --git a/src/sage/matrix/args.pxd b/src/sage/matrix/args.pxd index 581f89b0cc5..fc26bc35914 100644 --- a/src/sage/matrix/args.pxd +++ b/src/sage/matrix/args.pxd @@ -33,7 +33,7 @@ cdef class SparseEntry: cdef public object entry -cdef inline SparseEntry make_SparseEntry(long i, long j, entry): +cdef inline SparseEntry make_SparseEntry(long i, long j, entry) noexcept: e = SparseEntry.__new__(SparseEntry) e.i = i e.j = j @@ -53,18 +53,18 @@ cdef class MatrixArgs: cdef public dict kwds # **kwds for MatrixSpace() cdef bint is_finalized - cpdef Matrix matrix(self, bint convert=?) - cpdef list list(self, bint convert=?) - cpdef dict dict(self, bint convert=?) + cpdef Matrix matrix(self, bint convert=?) noexcept + cpdef list list(self, bint convert=?) noexcept + cpdef dict dict(self, bint convert=?) noexcept - cdef inline bint ref_safe(self): + cdef inline bint ref_safe(self) noexcept: """ Can we safely return self.entries without making a copy? A refcount of 1 means that self.entries is the only reference. """ return (self.entries).ob_refcnt == 1 - cdef inline bint need_to_convert(self, x): + cdef inline bint need_to_convert(self, x) noexcept: """Is ``x`` not an element of ``self.base``?""" if not isinstance(x, Element): return True @@ -119,4 +119,4 @@ cdef class MatrixArgs: cdef int set_seq_flat(self, entries) except -1 -cpdef MatrixArgs MatrixArgs_init(space, entries) +cpdef MatrixArgs MatrixArgs_init(space, entries) noexcept diff --git a/src/sage/matrix/args.pyx b/src/sage/matrix/args.pyx index c5a121743a5..bdb6eb796dd 100644 --- a/src/sage/matrix/args.pyx +++ b/src/sage/matrix/args.pyx @@ -39,7 +39,7 @@ except ImportError: CommutativeMonoids = monoids.Monoids().Commutative() -cdef inline bint element_is_scalar(Element x): +cdef inline bint element_is_scalar(Element x) noexcept: """ Should this element be considered a scalar (as opposed to a vector)? """ @@ -606,7 +606,7 @@ cdef class MatrixArgs: self.finalize() return self.nrows * self.ncols - cpdef Matrix matrix(self, bint convert=True): + cpdef Matrix matrix(self, bint convert=True) noexcept: """ Return the entries of the matrix as a Sage Matrix. @@ -694,7 +694,7 @@ cdef class MatrixArgs: self.typ = MA_ENTRIES_MATRIX return M - cpdef list list(self, bint convert=True): + cpdef list list(self, bint convert=True) noexcept: """ Return the entries of the matrix as a flat list of scalars. @@ -761,7 +761,7 @@ cdef class MatrixArgs: self.typ = MA_ENTRIES_SEQ_FLAT return L - cpdef dict dict(self, bint convert=True): + cpdef dict dict(self, bint convert=True) noexcept: """ Return the entries of the matrix as a dict. The keys of this dict are the non-zero positions ``(i,j)``. The corresponding @@ -1360,7 +1360,7 @@ cdef class MatrixArgs: return MA_ENTRIES_SEQ_SEQ -cpdef MatrixArgs MatrixArgs_init(space, entries): +cpdef MatrixArgs MatrixArgs_init(space, entries) noexcept: """ Construct a :class:`MatrixArgs` object from a matrix space and entries. This is the typical use in a matrix constructor. diff --git a/src/sage/matrix/matrix0.pxd b/src/sage/matrix/matrix0.pxd index fe320458130..d2276ef486d 100644 --- a/src/sage/matrix/matrix0.pxd +++ b/src/sage/matrix/matrix0.pxd @@ -21,8 +21,8 @@ cdef class Matrix(sage.structure.element.Matrix): cdef public object _base_ring cdef bint _is_immutable - cpdef _add_(self, other) - cpdef _sub_(self, other) + cpdef _add_(self, other) noexcept + cpdef _sub_(self, other) noexcept cdef bint _will_use_strassen(self, Matrix right) except -2 cdef bint _will_use_strassen_echelon(self) except -2 @@ -31,37 +31,37 @@ cdef class Matrix(sage.structure.element.Matrix): # Implementation of hash function cdef long _hash_(self) except -1 - cdef void get_hash_constants(self, long C[5]) + cdef void get_hash_constants(self, long C[5]) noexcept # Cache cdef public object _cache cdef long hash # cached hash value - cdef void clear_cache(self) - cdef fetch(self, key) - cdef cache(self, key, x) + cdef void clear_cache(self) noexcept + cdef fetch(self, key) noexcept + cdef cache(self, key, x) noexcept # Mutability and bounds checking - cdef check_bounds(self, Py_ssize_t i, Py_ssize_t j) - cdef check_mutability(self) - cdef check_bounds_and_mutability(self, Py_ssize_t i, Py_ssize_t j) + cdef check_bounds(self, Py_ssize_t i, Py_ssize_t j) noexcept + cdef check_mutability(self) noexcept + cdef check_bounds_and_mutability(self, Py_ssize_t i, Py_ssize_t j) noexcept # Unsafe entry access - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) - cdef _coerce_element(self, x) + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) noexcept + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept + cdef _coerce_element(self, x) noexcept cdef bint get_is_zero_unsafe(self, Py_ssize_t i, Py_ssize_t j) except -1 # Row and column operations - cdef check_row_bounds(self, Py_ssize_t r1, Py_ssize_t r2) - cdef check_column_bounds(self, Py_ssize_t c1, Py_ssize_t c2) - cdef check_row_bounds_and_mutability(self, Py_ssize_t r1, Py_ssize_t r2) - cdef check_column_bounds_and_mutability(self, Py_ssize_t c1, Py_ssize_t c2) - cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2) - cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2) - cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t col_start) - cdef add_multiple_of_column_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t row_start) - cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col) - cdef rescale_col_c(self, Py_ssize_t i, s, Py_ssize_t start_row) + cdef check_row_bounds(self, Py_ssize_t r1, Py_ssize_t r2) noexcept + cdef check_column_bounds(self, Py_ssize_t c1, Py_ssize_t c2) noexcept + cdef check_row_bounds_and_mutability(self, Py_ssize_t r1, Py_ssize_t r2) noexcept + cdef check_column_bounds_and_mutability(self, Py_ssize_t c1, Py_ssize_t c2) noexcept + cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2) noexcept + cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2) noexcept + cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t col_start) noexcept + cdef add_multiple_of_column_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t row_start) noexcept + cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col) noexcept + cdef rescale_col_c(self, Py_ssize_t i, s, Py_ssize_t start_row) noexcept # Helper function for inverse of sparse matrices - cdef build_inverse_from_augmented_sparse(self, A) + cdef build_inverse_from_augmented_sparse(self, A) noexcept diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index dfb3d0090b2..d7a0487e6cd 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -334,14 +334,14 @@ cdef class Matrix(sage.structure.element.Matrix): """ self.clear_cache() - cdef void clear_cache(self): + cdef void clear_cache(self) noexcept: """ Clear the properties cache. """ self._cache = None self.hash = -1 - cdef fetch(self, key): + cdef fetch(self, key) noexcept: """ Try to get an element from the cache; if there isn't anything there, return None. @@ -353,7 +353,7 @@ cdef class Matrix(sage.structure.element.Matrix): except KeyError: return None - cdef cache(self, key, x): + cdef cache(self, key, x) noexcept: """ Record x in the cache with given key. """ @@ -380,7 +380,7 @@ cdef class Matrix(sage.structure.element.Matrix): # Mutability and bounds checking ########################################################### - cdef check_bounds(self, Py_ssize_t i, Py_ssize_t j): + cdef check_bounds(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ This function gets called when you're about to access the i,j entry of this matrix. If i, j are out of range, an IndexError is @@ -389,7 +389,7 @@ cdef class Matrix(sage.structure.element.Matrix): if i<0 or i >= self._nrows or j<0 or j >= self._ncols: raise IndexError("matrix index out of range") - cdef check_mutability(self): + cdef check_mutability(self) noexcept: """ This function gets called when you're about to change this matrix. @@ -403,7 +403,7 @@ cdef class Matrix(sage.structure.element.Matrix): else: self._cache = None - cdef check_bounds_and_mutability(self, Py_ssize_t i, Py_ssize_t j): + cdef check_bounds_and_mutability(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ This function gets called when you're about to set the i,j entry of this matrix. If i or j is out of range, an :class:`IndexError` @@ -516,7 +516,7 @@ cdef class Matrix(sage.structure.element.Matrix): # Entry access # The first two must be overloaded in the derived class ########################################################### - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) noexcept: """ Set entry quickly without doing any bounds checking. Calling this with invalid arguments is allowed to produce a segmentation fault. @@ -526,7 +526,7 @@ cdef class Matrix(sage.structure.element.Matrix): """ raise NotImplementedError("this must be defined in the derived class (type=%s)" % type(self)) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Entry access, but fast since it might be without bounds checking. @@ -1562,7 +1562,7 @@ cdef class Matrix(sage.structure.element.Matrix): - cdef _coerce_element(self, x): + cdef _coerce_element(self, x) noexcept: """ Return coercion of x into the base ring of self. """ @@ -2431,11 +2431,11 @@ cdef class Matrix(sage.structure.element.Matrix): # involve multiplication outside base ring, including # with_ versions of these methods for this situation ################################################### - cdef check_row_bounds(self, Py_ssize_t r1, Py_ssize_t r2): + cdef check_row_bounds(self, Py_ssize_t r1, Py_ssize_t r2) noexcept: if r1 < 0 or r1 >= self._nrows or r2 < 0 or r2 >= self._nrows: raise IndexError("matrix row index out of range") - cdef check_row_bounds_and_mutability(self, Py_ssize_t r1, Py_ssize_t r2): + cdef check_row_bounds_and_mutability(self, Py_ssize_t r1, Py_ssize_t r2) noexcept: if self._is_immutable: raise ValueError("Matrix is immutable; please change a copy instead (i.e., use copy(M) to change a copy of M).") else: @@ -2443,11 +2443,11 @@ cdef class Matrix(sage.structure.element.Matrix): if r1 < 0 or r1 >= self._nrows or r2 < 0 or r2 >= self._nrows: raise IndexError("matrix row index out of range") - cdef check_column_bounds(self, Py_ssize_t c1, Py_ssize_t c2): + cdef check_column_bounds(self, Py_ssize_t c1, Py_ssize_t c2) noexcept: if c1 < 0 or c1 >= self._ncols or c2 < 0 or c2 >= self._ncols: raise IndexError("matrix column index out of range") - cdef check_column_bounds_and_mutability(self, Py_ssize_t c1, Py_ssize_t c2): + cdef check_column_bounds_and_mutability(self, Py_ssize_t c1, Py_ssize_t c2) noexcept: if self._is_immutable: raise ValueError("Matrix is immutable; please change a copy instead (i.e., use copy(M) to change a copy of M).") else: @@ -2633,7 +2633,7 @@ cdef class Matrix(sage.structure.element.Matrix): temp.swap_columns_c(cycle[0], elt) return temp - cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2): + cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2) noexcept: cdef Py_ssize_t r for r from 0 <= r < self._nrows: a = self.get_unsafe(r, c2) @@ -2815,7 +2815,7 @@ cdef class Matrix(sage.structure.element.Matrix): temp.swap_rows_c(cycle[0], elt) return temp - cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2): + cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2) noexcept: cdef Py_ssize_t c for c from 0 <= c < self._ncols: a = self.get_unsafe(r2, c) @@ -2950,7 +2950,7 @@ cdef class Matrix(sage.structure.element.Matrix): except TypeError: raise TypeError('Multiplying row by %s element cannot be done over %s, use change_ring or with_added_multiple_of_row instead.' % (s.parent(), self.base_ring())) - cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col): + cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col) noexcept: cdef Py_ssize_t c for c from start_col <= c < self._ncols: self.set_unsafe(i, c, self.get_unsafe(i, c) + s*self.get_unsafe(j, c)) @@ -3035,7 +3035,7 @@ cdef class Matrix(sage.structure.element.Matrix): except TypeError: raise TypeError('Multiplying column by %s element cannot be done over %s, use change_ring or with_added_multiple_of_column instead.' % (s.parent(), self.base_ring())) - cdef add_multiple_of_column_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_row): + cdef add_multiple_of_column_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_row) noexcept: cdef Py_ssize_t r for r from start_row <= r < self._nrows: self.set_unsafe(r, i, self.get_unsafe(r, i) + s*self.get_unsafe(r, j)) @@ -3150,7 +3150,7 @@ cdef class Matrix(sage.structure.element.Matrix): except TypeError: raise TypeError('Rescaling row by %s element cannot be done over %s, use change_ring or with_rescaled_row instead.' % (s.parent(), self.base_ring())) - cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col): + cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col) noexcept: cdef Py_ssize_t j for j from start_col <= j < self._ncols: self.set_unsafe(i, j, self.get_unsafe(i, j)*s) @@ -3265,7 +3265,7 @@ cdef class Matrix(sage.structure.element.Matrix): except TypeError: raise TypeError('Rescaling column by %s element cannot be done over %s, use change_ring or with_rescaled_col instead.' % (s.parent(), self.base_ring())) - cdef rescale_col_c(self, Py_ssize_t i, s, Py_ssize_t start_row): + cdef rescale_col_c(self, Py_ssize_t i, s, Py_ssize_t start_row) noexcept: cdef Py_ssize_t j for j from start_row <= j < self._nrows: self.set_unsafe(j, i, self.get_unsafe(j, i)*s) @@ -5038,7 +5038,7 @@ cdef class Matrix(sage.structure.element.Matrix): ################################################### # Arithmetic ################################################### - cdef _vector_times_matrix_(self, Vector v): + cdef _vector_times_matrix_(self, Vector v) noexcept: r""" Return the vector times matrix product. @@ -5095,7 +5095,7 @@ cdef class Matrix(sage.structure.element.Matrix): return sum([v[i] * self.row(i, from_list=True) for i in range(self._nrows)], M(0)) - cdef _matrix_times_vector_(self, Vector v): + cdef _matrix_times_vector_(self, Vector v) noexcept: """ EXAMPLES:: @@ -5206,7 +5206,7 @@ cdef class Matrix(sage.structure.element.Matrix): MS = self.matrix_space(n, m) return MS(X).transpose() - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Add two matrices with the same parent. @@ -5230,7 +5230,7 @@ cdef class Matrix(sage.structure.element.Matrix): A.set_unsafe(i,j,self.get_unsafe(i,j)._add_(right.get_unsafe(i,j))) return A - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Subtract two matrices with the same parent. @@ -5296,7 +5296,7 @@ cdef class Matrix(sage.structure.element.Matrix): """ return self.change_ring(self._base_ring.quotient_ring(p)) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -5334,7 +5334,7 @@ cdef class Matrix(sage.structure.element.Matrix): ans.set_unsafe(r, c, x * self.get_unsafe(r, c)) return ans - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES: @@ -5378,7 +5378,7 @@ cdef class Matrix(sage.structure.element.Matrix): ans.set_unsafe(r, c, self.get_unsafe(r, c) * x) return ans - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right) noexcept: r""" Return the product of two matrices. @@ -5771,7 +5771,7 @@ cdef class Matrix(sage.structure.element.Matrix): raise ZeroDivisionError("input matrix must be nonsingular") return A.matrix_from_columns(list(range(self._ncols, 2 * self._ncols))) - cdef build_inverse_from_augmented_sparse(self, A): + cdef build_inverse_from_augmented_sparse(self, A) noexcept: # We can directly use the dict entries of A cdef Py_ssize_t i, nrows cdef dict data = A._dict() @@ -6038,7 +6038,7 @@ cdef class Matrix(sage.structure.element.Matrix): return -2 return h - cdef void get_hash_constants(self, long C[5]): + cdef void get_hash_constants(self, long C[5]) noexcept: """ Get constants for the hash algorithm. """ @@ -6074,7 +6074,7 @@ cdef class Matrix(sage.structure.element.Matrix): # C[0] = (1 - m * (m - 1)/2) * C[2] - (m - 1) * C[1] C[0] = (1 - mm) * C[2] - (m - 1) * C[1] - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare two matrices. diff --git a/src/sage/matrix/matrix1.pxd b/src/sage/matrix/matrix1.pxd index 28eb1ca5b84..666cd4e6240 100644 --- a/src/sage/matrix/matrix1.pxd +++ b/src/sage/matrix/matrix1.pxd @@ -1,7 +1,7 @@ from .matrix0 cimport Matrix as Matrix0 cdef class Matrix(Matrix0): - cdef _stack_impl(self, bottom) + cdef _stack_impl(self, bottom) noexcept - cpdef row_ambient_module(self, base_ring=*, sparse=*) - cpdef column_ambient_module(self, base_ring=*, sparse=*) + cpdef row_ambient_module(self, base_ring=*, sparse=*) noexcept + cpdef column_ambient_module(self, base_ring=*, sparse=*) noexcept diff --git a/src/sage/matrix/matrix1.pyx b/src/sage/matrix/matrix1.pyx index 2ee50b25b7b..14a8538a535 100644 --- a/src/sage/matrix/matrix1.pyx +++ b/src/sage/matrix/matrix1.pyx @@ -854,7 +854,7 @@ cdef class Matrix(Matrix0): ############################################################################################# # rows, columns, sparse_rows, sparse_columns, dense_rows, dense_columns, row, column ############################################################################################# - cpdef row_ambient_module(self, base_ring=None, sparse=None): + cpdef row_ambient_module(self, base_ring=None, sparse=None) noexcept: r""" Return the free module that contains the rows of the matrix. @@ -911,7 +911,7 @@ cdef class Matrix(Matrix0): deprecation(32984, 'the method _row_ambient_module is deprecated use row_ambient_module (without underscore) instead') return self.row_ambient_module(base_ring) - cpdef column_ambient_module(self, base_ring=None, sparse=None): + cpdef column_ambient_module(self, base_ring=None, sparse=None) noexcept: r""" Return the free module that contains the columns of the matrix. @@ -1747,7 +1747,7 @@ cdef class Matrix(Matrix0): Z._subdivide_on_stack(self, other) return Z - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: """ Implementation of :meth:`stack`. diff --git a/src/sage/matrix/matrix2.pxd b/src/sage/matrix/matrix2.pxd index 6f99ff58d02..ad5bf85df04 100644 --- a/src/sage/matrix/matrix2.pxd +++ b/src/sage/matrix/matrix2.pxd @@ -15,10 +15,10 @@ Generic matrices from .matrix1 cimport Matrix as Matrix1 cdef class Matrix(Matrix1): - cdef _det_by_minors(self, Py_ssize_t level) - cdef _pf_bfl(self) + cdef _det_by_minors(self, Py_ssize_t level) noexcept + cdef _pf_bfl(self) noexcept cdef bint _is_positive_definite_or_semidefinite(self, bint semi) except -1 - cdef tuple _block_ldlt(self, bint classical) - cpdef _echelon(self, str algorithm) - cpdef _echelon_in_place(self, str algorithm) - cpdef matrix_window(self, Py_ssize_t row=*, Py_ssize_t col=*, Py_ssize_t nrows=*, Py_ssize_t ncols=*, bint check=*) + cdef tuple _block_ldlt(self, bint classical) noexcept + cpdef _echelon(self, str algorithm) noexcept + cpdef _echelon_in_place(self, str algorithm) noexcept + cpdef matrix_window(self, Py_ssize_t row=*, Py_ssize_t col=*, Py_ssize_t nrows=*, Py_ssize_t ncols=*, bint check=*) noexcept diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index f63ed12ce26..8af0889927f 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -2189,7 +2189,7 @@ cdef class Matrix(Matrix1): self.cache('det', d) return d - cdef _det_by_minors(self, Py_ssize_t level): + cdef _det_by_minors(self, Py_ssize_t level) noexcept: """ Compute the determinant of the upper-left level x level submatrix of self. Does not handle degenerate cases, level MUST be >= 2 @@ -2559,7 +2559,7 @@ cdef class Matrix(Matrix1): return res - cdef _pf_bfl(self): + cdef _pf_bfl(self) noexcept: r""" Computes the Pfaffian of ``self`` using the Baer-Faddeev-LeVerrier algorithm. @@ -7944,7 +7944,7 @@ cdef class Matrix(Matrix1): else: return E - cpdef _echelon(self, str algorithm): + cpdef _echelon(self, str algorithm) noexcept: """ Return the echelon form of ``self`` using ``algorithm``. @@ -8024,7 +8024,7 @@ cdef class Matrix(Matrix1): """ return self._echelon('classical') - cpdef _echelon_in_place(self, str algorithm): + cpdef _echelon_in_place(self, str algorithm) noexcept: """ Transform ``self`` into echelon form and return the pivots of ``self``. @@ -8847,7 +8847,7 @@ cdef class Matrix(Matrix1): cpdef matrix_window(self, Py_ssize_t row=0, Py_ssize_t col=0, Py_ssize_t nrows=-1, Py_ssize_t ncols=-1, - bint check=1): + bint check=1) noexcept: """ Return the requested matrix window. @@ -14041,7 +14041,7 @@ cdef class Matrix(Matrix1): raise ValueError(msg.format(d)) return L, vector(L.base_ring(), d) - cdef tuple _block_ldlt(self, bint classical): + cdef tuple _block_ldlt(self, bint classical) noexcept: r""" Perform a user-unfriendly block-`LDL^{T}` factorization of the Hermitian matrix `A` diff --git a/src/sage/matrix/matrix_cdv.pxd b/src/sage/matrix/matrix_cdv.pxd index f7684da49f2..2deb72f25a2 100644 --- a/src/sage/matrix/matrix_cdv.pxd +++ b/src/sage/matrix/matrix_cdv.pxd @@ -1,3 +1,3 @@ from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense -cpdef hessenbergize_cdvf(Matrix_generic_dense) +cpdef hessenbergize_cdvf(Matrix_generic_dense) noexcept diff --git a/src/sage/matrix/matrix_cdv.pyx b/src/sage/matrix/matrix_cdv.pyx index dfbdb053328..6faf51eb6ad 100644 --- a/src/sage/matrix/matrix_cdv.pyx +++ b/src/sage/matrix/matrix_cdv.pyx @@ -20,7 +20,7 @@ from sage.rings.infinity import Infinity # We assume that H is square -cpdef hessenbergize_cdvf(Matrix_generic_dense H): +cpdef hessenbergize_cdvf(Matrix_generic_dense H) noexcept: r""" Replace `H` with an Hessenberg form of it. diff --git a/src/sage/matrix/matrix_complex_ball_dense.pxd b/src/sage/matrix/matrix_complex_ball_dense.pxd index fab9172f8b2..622925a0ee9 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pxd +++ b/src/sage/matrix/matrix_complex_ball_dense.pxd @@ -3,11 +3,11 @@ from .matrix_dense cimport Matrix_dense from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense from sage.structure.parent cimport Parent -cdef void matrix_to_acb_mat(acb_mat_t target, source) +cdef void matrix_to_acb_mat(acb_mat_t target, source) noexcept cdef Matrix_generic_dense acb_mat_to_matrix( - acb_mat_t source, Parent CIF) + acb_mat_t source, Parent CIF) noexcept cdef class Matrix_complex_ball_dense(Matrix_dense): cdef acb_mat_t value - cdef Matrix_complex_ball_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) - cpdef _pow_int(self, n) + cdef Matrix_complex_ball_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept + cpdef _pow_int(self, n) noexcept diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx index 3f56772a663..22366b5f1f2 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pyx +++ b/src/sage/matrix/matrix_complex_ball_dense.pyx @@ -56,7 +56,7 @@ from sage.misc.superseded import experimental from sage.rings.polynomial import polynomial_ring_constructor -cdef void matrix_to_acb_mat(acb_mat_t target, source): +cdef void matrix_to_acb_mat(acb_mat_t target, source) noexcept: """ Convert a matrix containing :class:`ComplexIntervalFieldElement` to an ``acb_mat_t``. @@ -80,14 +80,14 @@ cdef void matrix_to_acb_mat(acb_mat_t target, source): ComplexIntervalFieldElement_to_acb(acb_mat_entry(target, r, c), source[r][c]) -cdef ComplexIntervalFieldElement _to_CIF(acb_t source, ComplexIntervalFieldElement template): +cdef ComplexIntervalFieldElement _to_CIF(acb_t source, ComplexIntervalFieldElement template) noexcept: cdef ComplexIntervalFieldElement result result = template._new() acb_to_ComplexIntervalFieldElement( result, source) return result -cdef Matrix_generic_dense acb_mat_to_matrix(acb_mat_t source, Parent CIF): +cdef Matrix_generic_dense acb_mat_to_matrix(acb_mat_t source, Parent CIF) noexcept: """ Convert an ``acb_mat_t`` to a matrix containing :class:`ComplexIntervalFieldElement`. @@ -114,7 +114,7 @@ cdef Matrix_generic_dense acb_mat_to_matrix(acb_mat_t source, Parent CIF): for c in range(ncols)] for r in range(nrows)]) -cdef inline long prec(Matrix_complex_ball_dense mat): +cdef inline long prec(Matrix_complex_ball_dense mat) noexcept: return mat._base_ring._prec cdef class Matrix_complex_ball_dense(Matrix_dense): @@ -158,7 +158,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): """ acb_mat_clear(self.value) - cdef Matrix_complex_ball_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols): + cdef Matrix_complex_ball_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: r""" Return a new matrix over the same base ring. """ @@ -252,7 +252,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): z = se.entry acb_set(acb_mat_entry(self.value, se.i, se.j), z.value) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) noexcept: """ Set position ``i``, ``j`` of this matrix to ``x``. @@ -278,7 +278,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): """ acb_set(acb_mat_entry(self.value, i, j), ( x).value) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Return ``(i, j)`` entry of this matrix as a new ComplexBall. @@ -307,7 +307,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): acb_set(z.value, acb_mat_entry(self.value, i, j)) return z - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" EXAMPLES:: @@ -401,7 +401,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: r""" TESTS:: @@ -414,7 +414,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: r""" TESTS:: @@ -427,7 +427,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res - cpdef _lmul_(self, Element a): + cpdef _lmul_(self, Element a) noexcept: r""" TESTS:: @@ -440,7 +440,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res - cpdef _rmul_(self, Element a): + cpdef _rmul_(self, Element a) noexcept: r""" TESTS:: @@ -449,7 +449,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): """ return self._lmul_(a) - cdef _matrix_times_matrix_(self, Matrix other): + cdef _matrix_times_matrix_(self, Matrix other) noexcept: r""" TESTS:: @@ -462,7 +462,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: r""" Return the ``n``-th power of this matrix. @@ -961,7 +961,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): sig_off() return res -cdef _acb_vec_to_list(acb_ptr vec, long n, Parent parent): +cdef _acb_vec_to_list(acb_ptr vec, long n, Parent parent) noexcept: cdef ComplexBall b res = [] for i in range(n): diff --git a/src/sage/matrix/matrix_cyclo_dense.pxd b/src/sage/matrix/matrix_cyclo_dense.pxd index 4bbb862355e..1ce4e1e1cfd 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pxd +++ b/src/sage/matrix/matrix_cyclo_dense.pxd @@ -12,5 +12,5 @@ cdef class Matrix_cyclo_dense(Matrix_dense): cdef int _n cdef _randomize_rational_column_unsafe(Matrix_cyclo_dense self, - Py_ssize_t col, mpz_t nump1, mpz_t denp1, distribution=?) + Py_ssize_t col, mpz_t nump1, mpz_t denp1, distribution=?) noexcept diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx index a49bb6240e6..c3ec3ebf81a 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -159,7 +159,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): QQmat = Matrix_rational_dense(QQspace, L, False, False) self._matrix = QQmat.transpose() - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: """ Set the ij-th entry of self. @@ -286,7 +286,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): mpz_clear(numer) mpz_clear(denom) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Get the ij-th of self. @@ -488,7 +488,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): # * _dict -- sparse dictionary of underlying elements (need not be a copy) ######################################################################## - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Return the sum of two dense cyclotomic matrices. @@ -516,7 +516,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): A._matrix = self._matrix + (right)._matrix return A - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return the difference of two dense cyclotomic matrices. @@ -543,7 +543,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): A._matrix = self._matrix - (right)._matrix return A - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Multiply a dense cyclotomic matrix by a scalar. @@ -584,7 +584,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): A._matrix = T * self._matrix return A - cdef _matrix_times_matrix_(self, baseMatrix right): + cdef _matrix_times_matrix_(self, baseMatrix right) noexcept: """ Return the product of two cyclotomic dense matrices. @@ -719,7 +719,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): """ return hash(self._matrix) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Implement comparison of two cyclotomic matrices with identical parents. @@ -977,7 +977,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): return ht cdef _randomize_rational_column_unsafe(Matrix_cyclo_dense self, - Py_ssize_t col, mpz_t nump1, mpz_t denp1, distribution=None): + Py_ssize_t col, mpz_t nump1, mpz_t denp1, distribution=None) noexcept: """ Randomizes all entries in column ``col``. This is a helper method used in the implementation of dense matrices over cyclotomic fields. diff --git a/src/sage/matrix/matrix_dense.pxd b/src/sage/matrix/matrix_dense.pxd index 310ee33b0b7..3343438682b 100644 --- a/src/sage/matrix/matrix_dense.pxd +++ b/src/sage/matrix/matrix_dense.pxd @@ -1,4 +1,4 @@ from .matrix cimport Matrix cdef class Matrix_dense(Matrix): - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept diff --git a/src/sage/matrix/matrix_dense.pyx b/src/sage/matrix/matrix_dense.pyx index 0f5089b5122..29b6f4faae2 100644 --- a/src/sage/matrix/matrix_dense.pyx +++ b/src/sage/matrix/matrix_dense.pyx @@ -16,10 +16,10 @@ import sage.structure.sequence cdef class Matrix_dense(matrix.Matrix): - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 0 - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 1 def __copy__(self): @@ -32,7 +32,7 @@ cdef class Matrix_dense(matrix.Matrix): A.subdivide(*self.subdivisions()) return A - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: self.set_unsafe(i, j, value) def _pickle(self): @@ -53,7 +53,7 @@ cdef class Matrix_dense(matrix.Matrix): else: raise RuntimeError("unknown matrix version (=%s)" % version) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ EXAMPLES:: diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index bf8ade78c14..f4312a479e5 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -146,7 +146,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): # LEVEL 2 functionality # * def _pickle # * def _unpickle - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two matrices together. @@ -169,7 +169,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): M._matrix_numpy = _left._matrix_numpy + _right._matrix_numpy return M - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return self - right @@ -220,7 +220,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): # def _pickle(self): #unsure how to implement # def _unpickle(self, data, int version): # use version >= 0 #unsure how to implement ###################################################################### - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right) noexcept: r""" Multiply ``self * right`` as matrices. @@ -3557,7 +3557,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): posdef = self.fetch(cache_str) return posdef - cdef _vector_times_matrix_(self,Vector v): + cdef _vector_times_matrix_(self,Vector v) noexcept: if self._nrows == 0 or self._ncols == 0: return self.row_ambient_module().zero_vector() global numpy @@ -3570,7 +3570,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): ans = numpy.dot(v_numpy,self._matrix_numpy) return M(ans) - cdef _matrix_times_vector_(self,Vector v): + cdef _matrix_times_vector_(self,Vector v) noexcept: if self._nrows == 0 or self._ncols == 0: return self.column_ambient_module().zero_vector() diff --git a/src/sage/matrix/matrix_gap.pxd b/src/sage/matrix/matrix_gap.pxd index 0667c158df8..bb4801258cf 100644 --- a/src/sage/matrix/matrix_gap.pxd +++ b/src/sage/matrix/matrix_gap.pxd @@ -4,6 +4,6 @@ from sage.libs.gap.element cimport GapElement cdef class Matrix_gap(Matrix_dense): cdef GapElement _libgap - cpdef GapElement gap(self) - cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols) + cpdef GapElement gap(self) noexcept + cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept diff --git a/src/sage/matrix/matrix_gap.pyx b/src/sage/matrix/matrix_gap.pyx index f3f77dcbe15..853cb0626a1 100644 --- a/src/sage/matrix/matrix_gap.pyx +++ b/src/sage/matrix/matrix_gap.pyx @@ -122,7 +122,7 @@ cdef class Matrix_gap(Matrix_dense): mat.append(row) self._libgap = libgap(mat) - cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols): + cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: if nrows == self._nrows and ncols == self._ncols: P = self._parent else: @@ -163,7 +163,7 @@ cdef class Matrix_gap(Matrix_dense): """ return self._parent, (self.list(),) - cpdef GapElement gap(self): + cpdef GapElement gap(self) noexcept: r""" Return the underlying gap object. @@ -181,10 +181,10 @@ cdef class Matrix_gap(Matrix_dense): """ return self._libgap - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: return self._base_ring(self._libgap[i,j]) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) noexcept: r""" TESTS:: @@ -201,7 +201,7 @@ cdef class Matrix_gap(Matrix_dense): """ self._libgap[i,j] = x - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare ``self`` and ``right``. @@ -280,7 +280,7 @@ cdef class Matrix_gap(Matrix_dense): else: return Matrix_dense.__invert__(self) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: r""" TESTS:: @@ -293,7 +293,7 @@ cdef class Matrix_gap(Matrix_dense): ans._libgap = left._libgap + ( right)._libgap return ans - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: r""" TESTS:: @@ -306,7 +306,7 @@ cdef class Matrix_gap(Matrix_dense): ans._libgap = left._libgap - ( right)._libgap return ans - cdef Matrix _matrix_times_matrix_(left, Matrix right): + cdef Matrix _matrix_times_matrix_(left, Matrix right) noexcept: r""" TESTS:: diff --git a/src/sage/matrix/matrix_generic_dense.pxd b/src/sage/matrix/matrix_generic_dense.pxd index 74994a27d72..86963fe05df 100644 --- a/src/sage/matrix/matrix_generic_dense.pxd +++ b/src/sage/matrix/matrix_generic_dense.pxd @@ -2,4 +2,4 @@ from .matrix_dense cimport Matrix_dense cdef class Matrix_generic_dense(Matrix_dense): cdef list _entries - cdef Matrix_generic_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) + cdef Matrix_generic_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept diff --git a/src/sage/matrix/matrix_generic_dense.pyx b/src/sage/matrix/matrix_generic_dense.pyx index 9c16ac3c486..3e51e0d1703 100644 --- a/src/sage/matrix/matrix_generic_dense.pyx +++ b/src/sage/matrix/matrix_generic_dense.pyx @@ -81,7 +81,7 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): ma = MatrixArgs_init(parent, entries) self._entries = ma.list(coerce) - cdef Matrix_generic_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols): + cdef Matrix_generic_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: r""" Return a new dense matrix with no entries set. """ @@ -93,10 +93,10 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): cdef type t = type(self) return t.__new__(t, MS) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: self._entries[i*self._ncols + j] = value - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: return self._entries[i*self._ncols + j] @@ -209,7 +209,7 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): @cython.boundscheck(False) @cython.wraparound(False) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two generic dense matrices with the same parent. @@ -233,7 +233,7 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): @cython.boundscheck(False) @cython.wraparound(False) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two generic dense matrices with the same parent. diff --git a/src/sage/matrix/matrix_generic_sparse.pyx b/src/sage/matrix/matrix_generic_sparse.pyx index 4cd7cecc7e8..2570d08b55d 100644 --- a/src/sage/matrix/matrix_generic_sparse.pyx +++ b/src/sage/matrix/matrix_generic_sparse.pyx @@ -187,7 +187,7 @@ cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse): """ return bool(self._entries) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: if not value: try: del self._entries[(i,j)] @@ -196,7 +196,7 @@ cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse): else: self._entries[(i,j)] = value - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: return self._entries.get((i,j), self._zero) cdef bint get_is_zero_unsafe(self, Py_ssize_t i, Py_ssize_t j) except -1: @@ -247,7 +247,7 @@ cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse): # x * _dict -- copy of the sparse dictionary of underlying elements ######################################################################## - cpdef _add_(self, _other): + cpdef _add_(self, _other) noexcept: """ EXAMPLES:: diff --git a/src/sage/matrix/matrix_gf2e_dense.pxd b/src/sage/matrix/matrix_gf2e_dense.pxd index c8d81d279f9..70391868740 100644 --- a/src/sage/matrix/matrix_gf2e_dense.pxd +++ b/src/sage/matrix/matrix_gf2e_dense.pxd @@ -9,6 +9,6 @@ cdef class Matrix_gf2e_dense(Matrix_dense): cdef object _zero cdef m4ri_word _zero_word # m4ri_word representation of _zero - cpdef Matrix_gf2e_dense _multiply_newton_john(Matrix_gf2e_dense self, Matrix_gf2e_dense right) - cpdef Matrix_gf2e_dense _multiply_karatsuba(Matrix_gf2e_dense self, Matrix_gf2e_dense right) - cpdef Matrix_gf2e_dense _multiply_strassen(Matrix_gf2e_dense self, Matrix_gf2e_dense right, cutoff=*) + cpdef Matrix_gf2e_dense _multiply_newton_john(Matrix_gf2e_dense self, Matrix_gf2e_dense right) noexcept + cpdef Matrix_gf2e_dense _multiply_karatsuba(Matrix_gf2e_dense self, Matrix_gf2e_dense right) noexcept + cpdef Matrix_gf2e_dense _multiply_strassen(Matrix_gf2e_dense self, Matrix_gf2e_dense right, cutoff=*) noexcept diff --git a/src/sage/matrix/matrix_gf2e_dense.pyx b/src/sage/matrix/matrix_gf2e_dense.pyx index 977dbd0d6b5..25db5315598 100644 --- a/src/sage/matrix/matrix_gf2e_dense.pyx +++ b/src/sage/matrix/matrix_gf2e_dense.pyx @@ -128,7 +128,7 @@ cdef class M4RIE_finite_field: if self.ff: gf2e_free(self.ff) -cdef m4ri_word poly_to_word(f): +cdef m4ri_word poly_to_word(f) noexcept: return f.to_integer() @@ -232,7 +232,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): se = t mzed_write_elem(self._entries, se.i, se.j, poly_to_word(se.entry)) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: """ A[i,j] = value without bound checks @@ -259,7 +259,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): """ mzed_write_elem(self._entries, i, j, poly_to_word(value)) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Get A[i,j] without bound checks. @@ -298,7 +298,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): """ return mzed_read_elem(self._entries, i, j) == self._zero_word - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Return A+B @@ -324,7 +324,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): return A - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -385,7 +385,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): sig_off() return ans - cdef _matrix_times_matrix_(self, Matrix right): + cdef _matrix_times_matrix_(self, Matrix right) noexcept: """ Return A*B @@ -428,7 +428,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): sig_off() return ans - cpdef Matrix_gf2e_dense _multiply_newton_john(Matrix_gf2e_dense self, Matrix_gf2e_dense right): + cpdef Matrix_gf2e_dense _multiply_newton_john(Matrix_gf2e_dense self, Matrix_gf2e_dense right) noexcept: """ Return A*B using Newton-John tables. @@ -490,7 +490,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): sig_off() return ans - cpdef Matrix_gf2e_dense _multiply_karatsuba(Matrix_gf2e_dense self, Matrix_gf2e_dense right): + cpdef Matrix_gf2e_dense _multiply_karatsuba(Matrix_gf2e_dense self, Matrix_gf2e_dense right) noexcept: r""" Matrix multiplication using Karatsuba over polynomials with matrix coefficients over GF(2). @@ -538,7 +538,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): sig_off() return ans - cpdef Matrix_gf2e_dense _multiply_strassen(Matrix_gf2e_dense self, Matrix_gf2e_dense right, cutoff=0): + cpdef Matrix_gf2e_dense _multiply_strassen(Matrix_gf2e_dense self, Matrix_gf2e_dense right, cutoff=0) noexcept: """ Winograd-Strassen matrix multiplication with Newton-John multiplication as base case. @@ -592,7 +592,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): sig_off() return ans - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Return ``a*B`` for ``a`` an element of the base field. @@ -625,7 +625,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): """ return self.__copy__() - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ EXAMPLES:: @@ -993,7 +993,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): return A - cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col): + cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col) noexcept: """ Return ``multiple * self[row][start_col:]`` @@ -1034,7 +1034,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): mzed_rescale_row(self._entries, row, start_col, x) - cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col): + cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept: """ Compute ``self[row_to][start_col:] += multiple * self[row_from][start_col:]``. @@ -1068,7 +1068,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): mzed_add_multiple_of_row(self._entries, row_to, self._entries, row_from, x, start_col) - cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2): + cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2) noexcept: """ Swap rows ``row1`` and ``row2``. @@ -1092,7 +1092,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): """ mzed_row_swap(self._entries, row1, row2) - cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2): + cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2) noexcept: """ Swap columns ``col1`` and ``col2``. @@ -1189,7 +1189,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense): A._entries = mzed_concat(A._entries, self._entries, right._entries) return A - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Stack ``self`` on top of ``bottom``. diff --git a/src/sage/matrix/matrix_integer_dense.pxd b/src/sage/matrix/matrix_integer_dense.pxd index 50d83753454..d606deacc45 100644 --- a/src/sage/matrix/matrix_integer_dense.pxd +++ b/src/sage/matrix/matrix_integer_dense.pxd @@ -11,16 +11,16 @@ cdef class Matrix_integer_dense(Matrix_dense): cdef fmpz_mat_t _matrix cdef object _pivots cdef int mpz_height(self, mpz_t height) except -1 - cdef _mod_int_c(self, mod_int modulus) - cdef _mod_two(self) - cdef _pickle_version0(self) - cdef _unpickle_version0(self, data) - cpdef _export_as_string(self, int base=?) - cdef void set_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, const mpz_t value) - cdef void set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) - cdef inline void get_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, mpz_t value) - cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) - cdef inline double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) + cdef _mod_int_c(self, mod_int modulus) noexcept + cdef _mod_two(self) noexcept + cdef _pickle_version0(self) noexcept + cdef _unpickle_version0(self, data) noexcept + cpdef _export_as_string(self, int base=?) noexcept + cdef void set_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, const mpz_t value) noexcept + cdef void set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) noexcept + cdef inline void get_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, mpz_t value) noexcept + cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) noexcept + cdef inline double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) noexcept # HNF Modn cdef int _hnf_modn(Matrix_integer_dense self, Matrix_integer_dense res, @@ -28,7 +28,7 @@ cdef class Matrix_integer_dense(Matrix_dense): cdef int* _hnf_modn_impl(Matrix_integer_dense self, unsigned int det, Py_ssize_t nrows, Py_ssize_t ncols) except NULL - cdef Matrix_integer_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) + cdef Matrix_integer_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept -cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=*) +cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=*) noexcept diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index 2dbeea17a3b..207aa73a592 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -163,7 +163,7 @@ cdef inline mpz_t * fmpz_mat_to_mpz_array(fmpz_mat_t m) except? NULL: return entries -cdef inline void mpz_array_clear(mpz_t * a, size_t length): +cdef inline void mpz_array_clear(mpz_t * a, size_t length) noexcept: cdef size_t i for i in range(length): mpz_clear(a[i]) @@ -311,7 +311,7 @@ cdef class Matrix_integer_dense(Matrix_dense): z = se.entry fmpz_set_mpz(fmpz_mat_entry(self._matrix, se.i, se.j), z.value) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object x) noexcept: """ Set position i,j of this matrix to ``x``. @@ -337,7 +337,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ self.set_unsafe_mpz(i, j, (x).value) - cdef void set_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, const mpz_t value): + cdef void set_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, const mpz_t value) noexcept: """ Set position i,j of this matrix to ``value``. @@ -362,19 +362,19 @@ cdef class Matrix_integer_dense(Matrix_dense): """ fmpz_set_mpz(fmpz_mat_entry(self._matrix,i,j), value) - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: """ Set position i,j of this matrix to ``value``. """ fmpz_set_si(fmpz_mat_entry(self._matrix,i,j), value) - cdef void set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value): + cdef void set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) noexcept: """ Set position i,j of this matrix to ``value``. """ fmpz_set_d(fmpz_mat_entry(self._matrix,i,j), value) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Return the (i, j) entry of self as a new Integer. @@ -402,7 +402,7 @@ cdef class Matrix_integer_dense(Matrix_dense): self.get_unsafe_mpz(i, j, z.value) return z - cdef inline void get_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, mpz_t value): + cdef inline void get_unsafe_mpz(self, Py_ssize_t i, Py_ssize_t j, mpz_t value) noexcept: """ Copy entry i,j of the matrix ``self`` to ``value``. @@ -428,7 +428,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ fmpz_get_mpz(value,fmpz_mat_entry(self._matrix, i, j)) - cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j): + cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Return the (i, j) entry of self as a new Integer. @@ -439,7 +439,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ return fmpz_get_si(fmpz_mat_entry(self._matrix, i, j)) - cdef inline double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j): + cdef inline double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Return the (i, j) entry of self as a new Integer. @@ -490,7 +490,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ return self._pickle_version0(), 0 - cdef _pickle_version0(self): + cdef _pickle_version0(self) noexcept: """ EXAMPLES:: @@ -500,7 +500,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ return str_to_bytes(self._export_as_string(32), 'ascii') - cpdef _export_as_string(self, int base=10): + cpdef _export_as_string(self, int base=10) noexcept: """ Return space separated string of the entries in this matrix, in the given base. This is optimized for speed. @@ -585,7 +585,7 @@ cdef class Matrix_integer_dense(Matrix_dense): else: raise RuntimeError("unknown matrix version (=%s)"%version) - cdef _unpickle_version0(self, data): + cdef _unpickle_version0(self, data) noexcept: cdef Py_ssize_t i, j, n, k data = data.split() n = self._nrows * self._ncols @@ -611,7 +611,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # LEVEL 1 helpers: # These function support the implementation of the level 1 functionality. ######################################################################## - cdef Matrix_integer_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols): + cdef Matrix_integer_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: """ Return a new matrix over the integers from given parent All memory is allocated for this matrix, but its @@ -820,7 +820,7 @@ cdef class Matrix_integer_dense(Matrix_dense): fmpz_clear(s) return M - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right) noexcept: cdef Matrix_integer_dense M if self._ncols != right._nrows: @@ -833,7 +833,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sig_off() return M - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -853,7 +853,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sig_off() return M - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two dense matrices over ZZ. @@ -878,7 +878,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sig_off() return M - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two dense matrices over ZZ. @@ -1018,7 +1018,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sig_off() return M - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: r""" Compare ``self`` with ``right``, examining entries in lexicographic (row major) ordering. @@ -1052,7 +1052,7 @@ cdef class Matrix_integer_dense(Matrix_dense): return rich_to_bool(op, 0) # TODO: Implement better - cdef _vector_times_matrix_(self, Vector v): + cdef _vector_times_matrix_(self, Vector v) noexcept: """ Return the vector times matrix product. @@ -1577,7 +1577,7 @@ cdef class Matrix_integer_dense(Matrix_dense): else: return self._mod_int_c(modulus) - cdef _mod_two(self): + cdef _mod_two(self) noexcept: """ TESTS: @@ -1591,7 +1591,7 @@ cdef class Matrix_integer_dense(Matrix_dense): MS = matrix_space.MatrixSpace(GF(2), self._nrows, self._ncols) return Matrix_mod2_dense(MS, self, True, True) - cdef _mod_int_c(self, mod_int p): + cdef _mod_int_c(self, mod_int p) noexcept: from .matrix_modn_dense_float import MAX_MODULUS as MAX_MODULUS_FLOAT from .matrix_modn_dense_double import MAX_MODULUS as MAX_MODULUS_DOUBLE @@ -1678,7 +1678,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sig_free(entry_list) return res - cpdef _echelon_in_place(self, str algorithm): + cpdef _echelon_in_place(self, str algorithm) noexcept: cdef Matrix_integer_dense E E = self.echelon_form() sig_on() @@ -5245,7 +5245,7 @@ cdef class Matrix_integer_dense(Matrix_dense): fmpz_get_mpz(v._entries[j], fmpz_mat_entry(self._matrix, j, i)) return v - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Return the matrix ``self`` on top of ``bottom``:: @@ -5946,7 +5946,7 @@ cdef class Matrix_integer_dense(Matrix_dense): return ComputeMinimalPolynomials(self).integer_valued_polynomials_generators() -cdef inline GEN pari_GEN(Matrix_integer_dense B): +cdef inline GEN pari_GEN(Matrix_integer_dense B) noexcept: r""" Create the PARI GEN object on the stack defined by the integer matrix B. This is used internally by the function for conversion @@ -5959,7 +5959,7 @@ cdef inline GEN pari_GEN(Matrix_integer_dense B): return A -cdef extract_hnf_from_pari_matrix(Matrix_integer_dense self, Gen H, bint include_zero_rows): +cdef extract_hnf_from_pari_matrix(Matrix_integer_dense self, Gen H, bint include_zero_rows) noexcept: cdef mpz_t tmp mpz_init(tmp) @@ -5981,7 +5981,7 @@ cdef extract_hnf_from_pari_matrix(Matrix_integer_dense self, Gen H, bint include return B -cdef _clear_columns(Matrix_integer_dense A, pivots, Py_ssize_t n): +cdef _clear_columns(Matrix_integer_dense A, pivots, Py_ssize_t n) noexcept: # Clear all columns cdef Py_ssize_t i, k, p, l, m = A._ncols cdef fmpz_t c,t @@ -6004,7 +6004,7 @@ cdef _clear_columns(Matrix_integer_dense A, pivots, Py_ssize_t n): sig_off() -cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=None): +cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=None) noexcept: """ INPUT: diff --git a/src/sage/matrix/matrix_integer_sparse.pxd b/src/sage/matrix/matrix_integer_sparse.pxd index 43e3b98c4f0..d69b4879dc5 100644 --- a/src/sage/matrix/matrix_integer_sparse.pxd +++ b/src/sage/matrix/matrix_integer_sparse.pxd @@ -5,4 +5,4 @@ from .matrix_sparse cimport Matrix_sparse cdef class Matrix_integer_sparse(Matrix_sparse): cdef mpz_vector* _matrix - cdef _mod_int_c(self, mod_int p) + cdef _mod_int_c(self, mod_int p) noexcept diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index f4320fcd914..0712500e67d 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -109,10 +109,10 @@ cdef class Matrix_integer_sparse(Matrix_sparse): if z: mpz_vector_set_entry(&self._matrix[se.i], se.j, z.value) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept: mpz_vector_set_entry(&self._matrix[i], j, ( x).value) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: cdef Integer x x = Integer() mpz_vector_get_entry(x.value, &self._matrix[i], j) @@ -159,7 +159,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): # def _multiply_classical(left, matrix.Matrix _right): # def _list(self): - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -181,7 +181,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): mpz_vector_scalar_multiply(M_row, self_row, _x.value) return M - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: cdef Py_ssize_t i cdef Matrix_integer_sparse M @@ -195,7 +195,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): mpz_clear(mul) return M - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: cdef Py_ssize_t i cdef Matrix_integer_sparse M @@ -230,7 +230,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): self.cache('dict', d) return d - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right) noexcept: """ Return the product of the sparse integer matrices ``self`` and ``_right``. @@ -380,7 +380,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): """ return self._mod_int_c(modulus) - cdef _mod_int_c(self, mod_int p): + cdef _mod_int_c(self, mod_int p) noexcept: cdef Py_ssize_t i, j cdef Matrix_modn_sparse res cdef mpz_vector* self_row diff --git a/src/sage/matrix/matrix_mod2_dense.pxd b/src/sage/matrix/matrix_mod2_dense.pxd index ea3575ef3be..82df8116a5c 100644 --- a/src/sage/matrix/matrix_mod2_dense.pxd +++ b/src/sage/matrix/matrix_mod2_dense.pxd @@ -6,8 +6,8 @@ cdef class Matrix_mod2_dense(Matrix_dense): cdef object _one cdef object _zero - cpdef Matrix_mod2_dense _multiply_m4rm(Matrix_mod2_dense self, Matrix_mod2_dense right, int k) - cpdef Matrix_mod2_dense _multiply_strassen(Matrix_mod2_dense self, Matrix_mod2_dense right, int cutoff) + cpdef Matrix_mod2_dense _multiply_m4rm(Matrix_mod2_dense self, Matrix_mod2_dense right, int k) noexcept + cpdef Matrix_mod2_dense _multiply_strassen(Matrix_mod2_dense self, Matrix_mod2_dense right, int cutoff) noexcept # For conversion to other systems - cpdef _export_as_string(self) + cpdef _export_as_string(self) noexcept diff --git a/src/sage/matrix/matrix_mod2_dense.pyx b/src/sage/matrix/matrix_mod2_dense.pyx index 6365eb271aa..98708b4e9fb 100644 --- a/src/sage/matrix/matrix_mod2_dense.pyx +++ b/src/sage/matrix/matrix_mod2_dense.pyx @@ -329,16 +329,16 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse return h # this exists for compatibility with matrix_modn_dense - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: """ Set the (i,j) entry of self to the int value. """ mzd_write_bit(self._entries, i, j, int(value)) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: mzd_write_bit(self._entries, i, j, int(value)) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: if mzd_read_bit(self._entries, i, j): return self._one else: @@ -521,7 +521,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse # def _pickle(self): # def _unpickle(self, data, int version): # use version >= 0 - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Matrix addition. @@ -559,7 +559,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse return A - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Matrix addition. @@ -575,7 +575,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse """ return self._add_(right) - cdef _matrix_times_vector_(self, Vector v): + cdef _matrix_times_vector_(self, Vector v) noexcept: """ EXAMPLES:: @@ -620,7 +620,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse sig_off() return c - cdef _matrix_times_matrix_(self, Matrix right): + cdef _matrix_times_matrix_(self, Matrix right) noexcept: """ Matrix multiplication. @@ -633,7 +633,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse return self._multiply_strassen(right, 0) - cpdef Matrix_mod2_dense _multiply_m4rm(Matrix_mod2_dense self, Matrix_mod2_dense right, int k): + cpdef Matrix_mod2_dense _multiply_m4rm(Matrix_mod2_dense self, Matrix_mod2_dense right, int k) noexcept: """ Multiply matrices using the 'Method of the Four Russians Multiplication' (M4RM) or Konrod's method. @@ -762,7 +762,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse A._entries = mzd_mul_naive(A._entries, self._entries,(right)._entries) return A - cpdef Matrix_mod2_dense _multiply_strassen(Matrix_mod2_dense self, Matrix_mod2_dense right, int cutoff): + cpdef Matrix_mod2_dense _multiply_strassen(Matrix_mod2_dense self, Matrix_mod2_dense right, int cutoff) noexcept: r""" Strassen-Winograd `O(n^{2.807})` multiplication [Str1969]_. @@ -1237,7 +1237,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse mzd_write_bit(self._entries, i, j, 1) sig_off() - cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col): + cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col) noexcept: """ EXAMPLES:: @@ -1250,7 +1250,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse mzd_row_clear_offset(self._entries, row, start_col) cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, - Py_ssize_t start_col): + Py_ssize_t start_col) noexcept: """ EXAMPLES:: @@ -1263,7 +1263,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse if int(multiple) % 2: mzd_row_add_offset(self._entries, row_to, row_from, start_col) - cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2): + cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2) noexcept: """ EXAMPLES:: @@ -1279,7 +1279,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse """ mzd_row_swap(self._entries, row1, row2) - cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2): + cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2) noexcept: """ EXAMPLES:: @@ -1408,7 +1408,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse A.subdivide(*self.subdivisions()) return A - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Compare ``self`` with ``right``. @@ -1557,7 +1557,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse Z._subdivide_on_augment(self, other) return Z - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Stack ``self`` on top of ``bottom``. @@ -1744,7 +1744,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse gdImageDestroy(im) return unpickle_matrix_mod2_dense_v2, (r,c, data, size, self._is_immutable) - cpdef _export_as_string(self): + cpdef _export_as_string(self) noexcept: """ Return space separated string of the entries in this matrix. @@ -1953,7 +1953,7 @@ for i from 0 <= i < 256: # gmp's ULONG_PARITY may use special # assembly instructions, could be faster -cpdef inline unsigned long parity(m4ri_word a): +cpdef inline unsigned long parity(m4ri_word a) noexcept: """ Return the parity of the number of bits in a. @@ -1973,7 +1973,7 @@ cpdef inline unsigned long parity(m4ri_word a): a ^= a >> 8 return parity_table[a & 0xFF] -cdef inline unsigned long parity_mask(m4ri_word a): +cdef inline unsigned long parity_mask(m4ri_word a) noexcept: return -parity(a) diff --git a/src/sage/matrix/matrix_modn_dense_double.pyx b/src/sage/matrix/matrix_modn_dense_double.pyx index 12bc79159d3..858c3fcb887 100644 --- a/src/sage/matrix/matrix_modn_dense_double.pyx +++ b/src/sage/matrix/matrix_modn_dense_double.pyx @@ -73,7 +73,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): # note that INTEGER_MOD_INT32_LIMIT is ceil(sqrt(2^31-1)) < 94906266 self._fits_int32 = ((self).p <= INTEGER_MOD_INT32_LIMIT) - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: r""" Set the (i,j) entry of self to the int value. @@ -101,7 +101,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): """ self._matrix[i][j] = value - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept: r""" Set the (i,j) entry with no bounds-checking, or any other checks. @@ -136,7 +136,7 @@ cdef class Matrix_modn_dense_double(Matrix_modn_dense_template): else: self._matrix[i][j] = (x).ivalue - cdef IntegerMod_abstract get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef IntegerMod_abstract get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: r""" Return the (i,j) entry with no bounds-checking. diff --git a/src/sage/matrix/matrix_modn_dense_float.pyx b/src/sage/matrix/matrix_modn_dense_float.pyx index 8744cf494e3..325e492f5fb 100644 --- a/src/sage/matrix/matrix_modn_dense_float.pyx +++ b/src/sage/matrix/matrix_modn_dense_float.pyx @@ -67,7 +67,7 @@ cdef class Matrix_modn_dense_float(Matrix_modn_dense_template): """ self._get_template = self._base_ring.zero() - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: r""" Set the (i,j) entry of self to the int value. @@ -91,7 +91,7 @@ cdef class Matrix_modn_dense_float(Matrix_modn_dense_template): """ self._matrix[i][j] = value - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept: r""" Set the (i,j) entry with no bounds-checking, or any other checks. @@ -121,7 +121,7 @@ cdef class Matrix_modn_dense_float(Matrix_modn_dense_template): """ self._matrix[i][j] = (x).ivalue - cdef IntegerMod_int get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef IntegerMod_int get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: r""" Return the (i,j) entry with no bounds-checking. diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 66618d2cbf1..55cff5b9ac7 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -131,7 +131,7 @@ from sage.cpython.string cimport char_to_str cdef long num = 1 cdef bint little_endian = ((&num))[0] -cdef inline celement_invert(celement a, celement n): +cdef inline celement_invert(celement a, celement n) noexcept: """ Invert the finite field element `a` modulo `n`. """ @@ -172,7 +172,7 @@ cdef inline bint linbox_is_zero(celement modulus, celement* entries, Py_ssize_t return 0 return 1 -cdef inline linbox_echelonize(celement modulus, celement* entries, Py_ssize_t nrows, Py_ssize_t ncols): +cdef inline linbox_echelonize(celement modulus, celement* entries, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: """ Return the reduced row echelon form of this matrix. """ @@ -213,7 +213,7 @@ cdef inline linbox_echelonize(celement modulus, celement* entries, Py_ssize_t nr del F return r, pivots -cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_t nrows, Py_ssize_t ncols): +cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: # See trac #13878: This is to avoid sending invalid data to linbox, # which would yield a segfault in Sage's debug version. TODO: Fix # that bug upstream. @@ -276,7 +276,7 @@ cdef inline int linbox_rank(celement modulus, celement* entries, Py_ssize_t nrow del F return r -cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t n): +cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t n) noexcept: """ Return the determinant of this matrix. """ @@ -299,7 +299,7 @@ cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t del F return d -cdef inline celement linbox_matrix_matrix_multiply(celement modulus, celement* ans, celement* A, celement* B, Py_ssize_t m, Py_ssize_t n, Py_ssize_t k) : +cdef inline celement linbox_matrix_matrix_multiply(celement modulus, celement* ans, celement* A, celement* B, Py_ssize_t m, Py_ssize_t n, Py_ssize_t k) noexcept: """ C = A*B """ @@ -327,7 +327,7 @@ cdef inline celement linbox_matrix_matrix_multiply(celement modulus, celement* a del F -cdef inline int linbox_matrix_vector_multiply(celement modulus, celement* C, celement* A, celement* b, Py_ssize_t m, Py_ssize_t n, FFLAS_TRANSPOSE trans): +cdef inline int linbox_matrix_vector_multiply(celement modulus, celement* C, celement* A, celement* b, Py_ssize_t m, Py_ssize_t n, FFLAS_TRANSPOSE trans) noexcept: """ C = A*v """ @@ -347,7 +347,7 @@ cdef inline int linbox_matrix_vector_multiply(celement modulus, celement* C, cel del F -cdef inline linbox_minpoly(celement modulus, Py_ssize_t nrows, celement* entries): +cdef inline linbox_minpoly(celement modulus, Py_ssize_t nrows, celement* entries) noexcept: """ Compute the minimal polynomial. """ @@ -368,7 +368,7 @@ cdef inline linbox_minpoly(celement modulus, Py_ssize_t nrows, celement* entries del F return l -cdef inline linbox_charpoly(celement modulus, Py_ssize_t nrows, celement* entries): +cdef inline linbox_charpoly(celement modulus, Py_ssize_t nrows, celement* entries) noexcept: """ Compute the characteristic polynomial. """ @@ -396,7 +396,7 @@ cdef inline linbox_charpoly(celement modulus, Py_ssize_t nrows, celement* entrie return l -cpdef __matrix_from_rows_of_matrices(X): +cpdef __matrix_from_rows_of_matrices(X) noexcept: """ Return a matrix whose row ``i`` is constructed from the entries of matrix ``X[i]``. @@ -802,7 +802,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): sig_off() return M - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -856,7 +856,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): return A - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Add two dense matrices over `\Z/n\Z` @@ -900,7 +900,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): return M - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Subtract two dense matrices over `\Z/n\Z` @@ -936,7 +936,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): sig_off() return M - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: r""" Compare two dense matrices over `\Z/n\Z`. @@ -988,7 +988,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): sig_off() return rich_to_bool(op, 0) - cdef _matrix_times_matrix_(self, Matrix right): + cdef _matrix_times_matrix_(self, Matrix right) noexcept: """ return ``self*right`` @@ -1146,7 +1146,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): return ans - cdef _vector_times_matrix_(self, Vector v): + cdef _vector_times_matrix_(self, Vector v) noexcept: """ ``v*self`` @@ -1203,7 +1203,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): sig_free(_c) return c - cdef _matrix_times_vector_(self, Vector v): + cdef _matrix_times_vector_(self, Vector v) noexcept: """ ``self*v`` @@ -2283,7 +2283,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): else: return Matrix_dense.determinant(self) - cdef xgcd_eliminate(self, celement * row1, celement* row2, Py_ssize_t start_col): + cdef xgcd_eliminate(self, celement * row1, celement* row2, Py_ssize_t start_col) noexcept: r""" Reduces ``row1`` and ``row2`` by a unimodular transformation using the xgcd relation between their first coefficients ``a`` and @@ -2325,7 +2325,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): row1[i] = tmp return g - cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col): + cdef rescale_row_c(self, Py_ssize_t row, multiple, Py_ssize_t start_col) noexcept: """ Rescale ``self[row]`` by ``multiple`` but only start at column index ``start_col``. @@ -2376,7 +2376,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): for i from start_col <= i < self._ncols: v[i] = (v[i]*multiple) % p - cdef rescale_col_c(self, Py_ssize_t col, multiple, Py_ssize_t start_row): + cdef rescale_col_c(self, Py_ssize_t col, multiple, Py_ssize_t start_row) noexcept: """ EXAMPLES:: @@ -2419,7 +2419,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): for i from start_row <= i < self._nrows: self._matrix[i][col] = (self._matrix[i][col]*multiple) % p - cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col): + cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept: """ Add ``multiple`` times ``self[row_from]`` to ``self[row_to]`` statting in column ``start_col``. @@ -2456,7 +2456,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): for i from start_col <= i < nc: v_to[i] = ((multiple) * v_from[i] + v_to[i]) % p - cdef add_multiple_of_column_c(self, Py_ssize_t col_to, Py_ssize_t col_from, multiple, Py_ssize_t start_row): + cdef add_multiple_of_column_c(self, Py_ssize_t col_to, Py_ssize_t col_from, multiple, Py_ssize_t start_row) noexcept: """ Add ``multiple`` times ``self[row_from]`` to ``self[row_to]`` statting in column ``start_col``. @@ -2491,7 +2491,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): for i from start_row <= i < self._nrows: m[i][col_to] = (m[i][col_to] + (multiple) * m[i][col_from]) %p - cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2): + cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2) noexcept: """ EXAMPLES:: @@ -2509,7 +2509,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): r1[i] = r2[i] r2[i] = temp - cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2): + cdef swap_columns_c(self, Py_ssize_t col1, Py_ssize_t col2) noexcept: """ EXAMPLES:: @@ -2678,7 +2678,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): return 'Matrix(%s,%s,%s,StringToIntegerSequence("%s"))'%( s, self._nrows, self._ncols, self._export_as_string()) - cpdef _export_as_string(self): + cpdef _export_as_string(self) noexcept: """ Return space separated string of the entries in this matrix. @@ -2830,7 +2830,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): return M - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Implementation of :meth:`stack` by returning a new matrix formed by appending the matrix ``bottom`` beneath ``self``. @@ -3230,7 +3230,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): _matrix_from_rows_of_matrices = staticmethod(__matrix_from_rows_of_matrices) - cdef int _copy_row_to_mod_int_array(self, mod_int *to, Py_ssize_t i): + cdef int _copy_row_to_mod_int_array(self, mod_int *to, Py_ssize_t i) noexcept: cdef Py_ssize_t j cdef celement *_from = self._entries+(i*self._ncols) for j in range(self._ncols): diff --git a/src/sage/matrix/matrix_modn_dense_template_header.pxi b/src/sage/matrix/matrix_modn_dense_template_header.pxi index 84f4d10c29c..18e149fb5de 100644 --- a/src/sage/matrix/matrix_modn_dense_template_header.pxi +++ b/src/sage/matrix/matrix_modn_dense_template_header.pxi @@ -9,6 +9,6 @@ cdef class Matrix_modn_dense_template(Matrix_dense): cdef celement **_matrix cdef celement *_entries cdef mod_int p - cdef xgcd_eliminate (self, celement * row1, celement* row2, Py_ssize_t start_col) - cpdef _export_as_string(self) - cdef int _copy_row_to_mod_int_array(self, mod_int *to, Py_ssize_t i) + cdef xgcd_eliminate (self, celement * row1, celement* row2, Py_ssize_t start_col) noexcept + cpdef _export_as_string(self) noexcept + cdef int _copy_row_to_mod_int_array(self, mod_int *to, Py_ssize_t i) noexcept diff --git a/src/sage/matrix/matrix_modn_sparse.pxd b/src/sage/matrix/matrix_modn_sparse.pxd index dded069b3d8..37dd99bf5f3 100644 --- a/src/sage/matrix/matrix_modn_sparse.pxd +++ b/src/sage/matrix/matrix_modn_sparse.pxd @@ -4,4 +4,4 @@ from sage.modules.vector_modn_sparse cimport * cdef class Matrix_modn_sparse(Matrix_sparse): cdef c_vector_modint* rows cdef public int p - cdef swap_rows_c(self, Py_ssize_t n1, Py_ssize_t n2) + cdef swap_rows_c(self, Py_ssize_t n1, Py_ssize_t n2) noexcept diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index 9c12d6b9e1d..235fc4e7b81 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -173,10 +173,10 @@ cdef class Matrix_modn_sparse(Matrix_sparse): if z: set_entry(&self.rows[se.i], se.j, z) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: set_entry(&self.rows[i], j, ( value).ivalue) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: cdef IntegerMod_int n n = IntegerMod_int.__new__(IntegerMod_int) IntegerMod_abstract.__init__(n, self._base_ring) @@ -255,7 +255,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): else: raise ValueError("unknown matrix format") - cdef Matrix _matrix_times_matrix_(self, Matrix _right): + cdef Matrix _matrix_times_matrix_(self, Matrix _right) noexcept: """ This code is implicitly called for multiplying self by another sparse matrix. @@ -392,7 +392,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): self.check_bounds_and_mutability(r2,0) self.swap_rows_c(r1, r2) - cdef swap_rows_c(self, Py_ssize_t n1, Py_ssize_t n2): + cdef swap_rows_c(self, Py_ssize_t n1, Py_ssize_t n2) noexcept: """ Swap the rows in positions n1 and n2. No bounds checking. """ @@ -401,7 +401,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): self.rows[n1] = self.rows[n2] self.rows[n2] = tmp - cpdef _echelon_in_place(self, str algorithm): + cpdef _echelon_in_place(self, str algorithm) noexcept: """ Replace self by its reduction to reduced row echelon form. diff --git a/src/sage/matrix/matrix_numpy_dense.pxd b/src/sage/matrix/matrix_numpy_dense.pxd index a0ec36c9228..fafc6fda5f7 100644 --- a/src/sage/matrix/matrix_numpy_dense.pxd +++ b/src/sage/matrix/matrix_numpy_dense.pxd @@ -8,5 +8,5 @@ cdef class Matrix_numpy_dense(Matrix_dense): cdef object _python_dtype cdef object _sage_dtype cdef object _sage_vector_dtype - cdef Matrix_numpy_dense _new(self, int nrows=*, int ncols=*) + cdef Matrix_numpy_dense _new(self, int nrows=*, int ncols=*) noexcept cdef cnumpy.ndarray _matrix_numpy diff --git a/src/sage/matrix/matrix_numpy_dense.pyx b/src/sage/matrix/matrix_numpy_dense.pyx index 31ffaa0a51c..d0e55fa927a 100644 --- a/src/sage/matrix/matrix_numpy_dense.pyx +++ b/src/sage/matrix/matrix_numpy_dense.pyx @@ -145,7 +145,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): for j in range(ma.ncols): self.set_unsafe(i, j, next(it)) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, object value) noexcept: """ Set the (i,j) entry to value without any bounds checking, mutability checking, etc. @@ -169,7 +169,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): self._python_dtype(value)) #TODO: Throw an error if status == -1 - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Get the (i,j) entry without any bounds checking, etc. """ @@ -177,7 +177,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): return self._sage_dtype(cnumpy.PyArray_GETITEM(self._matrix_numpy, cnumpy.PyArray_GETPTR2(self._matrix_numpy, i, j))) - cdef Matrix_numpy_dense _new(self, int nrows=-1, int ncols=-1): + cdef Matrix_numpy_dense _new(self, int nrows=-1, int ncols=-1) noexcept: """ Return a new uninitialized matrix with same parent as ``self``. diff --git a/src/sage/matrix/matrix_rational_dense.pxd b/src/sage/matrix/matrix_rational_dense.pxd index 5b59339d6f1..64d2c646e51 100644 --- a/src/sage/matrix/matrix_rational_dense.pxd +++ b/src/sage/matrix/matrix_rational_dense.pxd @@ -8,14 +8,14 @@ cdef class Matrix_rational_dense(Matrix_dense): cdef int fmpz_height(self, fmpz_t height) except -1 # cdef int _rescale(self, mpq_t a) except -1 - cdef _pickle_version0(self) - cdef _unpickle_version0(self, data) - cpdef _export_as_string(self, int base=?) + cdef _pickle_version0(self) noexcept + cdef _unpickle_version0(self, data) noexcept + cpdef _export_as_string(self, int base=?) noexcept - cdef _add_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) - cdef _sub_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) + cdef _add_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) noexcept + cdef _sub_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) noexcept - cdef inline Matrix_rational_dense _new_matrix(self, Py_ssize_t nrows, Py_ssize_t ncols) + cdef inline Matrix_rational_dense _new_matrix(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept cdef class MatrixWindow: cdef Matrix_rational_dense _matrix diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index c9e1d87b049..4f1e5e415e1 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -147,7 +147,7 @@ cdef class Matrix_rational_dense(Matrix_dense): fmpq_mat_init(self._matrix, self._nrows, self._ncols) sig_off() - cdef inline Matrix_rational_dense _new_matrix(self, Py_ssize_t nrows, Py_ssize_t ncols): + cdef inline Matrix_rational_dense _new_matrix(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: if nrows == self._nrows and ncols == self._ncols: parent = self._parent else: @@ -255,10 +255,10 @@ cdef class Matrix_rational_dense(Matrix_dense): tmp) fmpq_clear(tmp) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: fmpq_set_mpq(fmpq_mat_entry(self._matrix, i, j), ( value).value) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: cdef Rational x x = Rational.__new__(Rational) fmpq_get_mpq(x.value, fmpq_mat_entry(self._matrix, i, j)) @@ -275,14 +275,14 @@ cdef class Matrix_rational_dense(Matrix_dense): """ return fmpq_is_zero(fmpq_mat_entry(self._matrix, i,j)) - cdef _add_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n): + cdef _add_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) noexcept: # doesn't check immutability # doesn't do bounds checks. # assumes that self[i,j] is an integer. cdef fmpz * entry = fmpq_numref(fmpq_mat_entry(self._matrix, i, j)) fmpz_add_ui(entry, entry, n) - cdef _sub_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n): + cdef _sub_ui_unsafe_assuming_int(self, Py_ssize_t i, Py_ssize_t j, unsigned long int n) noexcept: # doesn't check immutability # doesn't do bounds checks. # assumes that self[i,j] is an integer. @@ -298,10 +298,10 @@ cdef class Matrix_rational_dense(Matrix_dense): else: raise RuntimeError("unknown matrix version (=%s)" % version) - cdef _pickle_version0(self): + cdef _pickle_version0(self) noexcept: return self._export_as_string(32) - cpdef _export_as_string(self, int base=10): + cpdef _export_as_string(self, int base=10) noexcept: """ Return space separated string of the entries in this matrix, in the given base. This is optimized for speed. @@ -356,7 +356,7 @@ cdef class Matrix_rational_dense(Matrix_dense): sig_free(s) return data - cdef _unpickle_version0(self, data): + cdef _unpickle_version0(self, data) noexcept: r""" TESTS:: @@ -398,7 +398,7 @@ cdef class Matrix_rational_dense(Matrix_dense): # * _dict -- sparse dictionary of underlying elements (need not be a copy) # ####################################################################### - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -417,7 +417,7 @@ cdef class Matrix_rational_dense(Matrix_dense): fmpq_clear(x) return M - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two dense matrices over QQ. @@ -440,7 +440,7 @@ cdef class Matrix_rational_dense(Matrix_dense): sig_off() return ans - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two dense matrices over QQ. @@ -461,7 +461,7 @@ cdef class Matrix_rational_dense(Matrix_dense): sig_off() return ans - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: r""" TESTS:: @@ -502,7 +502,7 @@ cdef class Matrix_rational_dense(Matrix_dense): return rich_to_bool(op, -1) return rich_to_bool(op, 0) - cdef _vector_times_matrix_(self, Vector v): + cdef _vector_times_matrix_(self, Vector v) noexcept: r""" Return the vector times matrix product. @@ -1127,7 +1127,7 @@ cdef class Matrix_rational_dense(Matrix_dense): self.cache('minpoly', g) return g - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix right) noexcept: """ EXAMPLES:: @@ -1809,7 +1809,7 @@ cdef class Matrix_rational_dense(Matrix_dense): fmpq_mat_swap(self._matrix, (E)._matrix) return pivots - cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2): + cdef swap_rows_c(self, Py_ssize_t r1, Py_ssize_t r2) noexcept: """ EXAMPLES:: @@ -1825,7 +1825,7 @@ cdef class Matrix_rational_dense(Matrix_dense): fmpq_swap(fmpq_mat_entry(self._matrix, r1, c), fmpq_mat_entry(self._matrix, r2, c)) - cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2): + cdef swap_columns_c(self, Py_ssize_t c1, Py_ssize_t c2) noexcept: """ EXAMPLES:: @@ -2947,7 +2947,7 @@ cdef class Matrix_rational_dense(Matrix_dense): return A.LLL(*args, **kwargs) / d -cdef new_matrix_from_pari_GEN(parent, GEN d): +cdef new_matrix_from_pari_GEN(parent, GEN d) noexcept: """ Given a PARI GEN with ``t_INT`` or ``t_FRAC entries, create a :class:`Matrix_rational_dense` from it. diff --git a/src/sage/matrix/matrix_rational_sparse.pyx b/src/sage/matrix/matrix_rational_sparse.pyx index 06b9689e849..497c58408b7 100644 --- a/src/sage/matrix/matrix_rational_sparse.pyx +++ b/src/sage/matrix/matrix_rational_sparse.pyx @@ -93,10 +93,10 @@ cdef class Matrix_rational_sparse(Matrix_sparse): if z: mpq_vector_set_entry(&self._matrix[se.i], se.j, z.value) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept: mpq_vector_set_entry(&self._matrix[i], j, ( x).value) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: cdef Rational x x = Rational() mpq_vector_get_entry(x.value, &self._matrix[i], j) @@ -168,7 +168,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse): # * _list -- list of underlying elements (need not be a copy) # * x _dict -- sparse dictionary of underlying elements (need not be a copy) - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right): + cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right) noexcept: cdef Matrix_rational_sparse right, ans right = _right diff --git a/src/sage/matrix/matrix_real_double_dense.pxd b/src/sage/matrix/matrix_real_double_dense.pxd index a6b2ad32ffc..3be163114c5 100644 --- a/src/sage/matrix/matrix_real_double_dense.pxd +++ b/src/sage/matrix/matrix_real_double_dense.pxd @@ -1,5 +1,5 @@ from .matrix_double_dense cimport Matrix_double_dense cdef class Matrix_real_double_dense(Matrix_double_dense): - cdef set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) - cdef double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) + cdef set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) noexcept + cdef double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) noexcept diff --git a/src/sage/matrix/matrix_real_double_dense.pyx b/src/sage/matrix/matrix_real_double_dense.pyx index eeff7658041..542638ed17d 100644 --- a/src/sage/matrix/matrix_real_double_dense.pyx +++ b/src/sage/matrix/matrix_real_double_dense.pyx @@ -99,7 +99,7 @@ cdef class Matrix_real_double_dense(Matrix_double_dense): self.__create_matrix__() return - cdef set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value): + cdef set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) noexcept: """ Set the (i,j) entry to value without any type checking or bound checking. @@ -110,7 +110,7 @@ cdef class Matrix_real_double_dense(Matrix_double_dense): """ self.set_unsafe(i,j,value) - cdef double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j): + cdef double get_unsafe_double(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Get the (i,j) entry without any type checking or bound checking. diff --git a/src/sage/matrix/matrix_sparse.pyx b/src/sage/matrix/matrix_sparse.pyx index 15f4cb093ee..a98c6bfe64c 100644 --- a/src/sage/matrix/matrix_sparse.pyx +++ b/src/sage/matrix/matrix_sparse.pyx @@ -27,10 +27,10 @@ import sage.matrix.matrix_space cdef class Matrix_sparse(matrix.Matrix): - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 1 - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 0 def change_ring(self, ring): @@ -301,7 +301,7 @@ cdef class Matrix_sparse(matrix.Matrix): return left.new_matrix(left._nrows, right._ncols, entries=e, coerce=False, copy=False) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Left scalar multiplication. Internal usage only. @@ -370,7 +370,7 @@ cdef class Matrix_sparse(matrix.Matrix): else: raise RuntimeError("unknown matrix version (=%s)" % version) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Rich comparison. @@ -968,7 +968,7 @@ cdef class Matrix_sparse(matrix.Matrix): A.set_unsafe(new_row, new_col, entry) return A - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Stack ``self`` on top of ``bottom``:: @@ -1119,7 +1119,7 @@ cdef class Matrix_sparse(matrix.Matrix): Z._subdivide_on_augment(self, other) return Z - cdef _vector_times_matrix_(self, Vector v): + cdef _vector_times_matrix_(self, Vector v) noexcept: """ Return the vector times matrix product. @@ -1152,7 +1152,7 @@ cdef class Matrix_sparse(matrix.Matrix): s[j] += v[i] * a return s - cdef _matrix_times_vector_(self, Vector v): + cdef _matrix_times_vector_(self, Vector v) noexcept: """ Return the matrix times vector product. @@ -1210,6 +1210,6 @@ cdef class Matrix_sparse(matrix.Matrix): @cython.wraparound(False) # Return v[i][j] where v is a list of tuples. # No checking is done, make sure you feed it valid input! -cdef inline Py_ssize_t get_ij(v, Py_ssize_t i, Py_ssize_t j): +cdef inline Py_ssize_t get_ij(v, Py_ssize_t i, Py_ssize_t j) noexcept: t = (v)[i] return (t)[j] diff --git a/src/sage/matrix/matrix_window.pxd b/src/sage/matrix/matrix_window.pxd index 6b7ce409d45..523f0d2b235 100644 --- a/src/sage/matrix/matrix_window.pxd +++ b/src/sage/matrix/matrix_window.pxd @@ -6,30 +6,30 @@ cdef class MatrixWindow: cdef object _cached_zero # YOU *REALLY SHOULD* OVERRIDE THESE: - cpdef add(MatrixWindow self, MatrixWindow A) - cpdef subtract(MatrixWindow self, MatrixWindow A) - cpdef set_to_sum(MatrixWindow self, MatrixWindow A, MatrixWindow B) - cpdef set_to_diff(MatrixWindow self, MatrixWindow A, MatrixWindow B) - cpdef set_to_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) - cpdef add_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) - cpdef subtract_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) + cpdef add(MatrixWindow self, MatrixWindow A) noexcept + cpdef subtract(MatrixWindow self, MatrixWindow A) noexcept + cpdef set_to_sum(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept + cpdef set_to_diff(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept + cpdef set_to_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept + cpdef add_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept + cpdef subtract_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept - cpdef bint element_is_zero(MatrixWindow self, Py_ssize_t i, Py_ssize_t j) - cpdef set_to(MatrixWindow self, MatrixWindow A) - cpdef set_to_zero(MatrixWindow self) + cpdef bint element_is_zero(MatrixWindow self, Py_ssize_t i, Py_ssize_t j) noexcept + cpdef set_to(MatrixWindow self, MatrixWindow A) noexcept + cpdef set_to_zero(MatrixWindow self) noexcept # FOR BETTER SPEED, OVERRIDE ANY SUBSET OF THESE (OPTIONAL): - cpdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) - cpdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) - cpdef to_matrix(MatrixWindow self) - cpdef new_empty_window(MatrixWindow self, Py_ssize_t nrows, Py_ssize_t ncols) + cpdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept + cpdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept + cpdef to_matrix(MatrixWindow self) noexcept + cpdef new_empty_window(MatrixWindow self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept # NO BENEFIT TO OVERRIDING THESE: cpdef MatrixWindow matrix_window(MatrixWindow self, Py_ssize_t row, Py_ssize_t col, - Py_ssize_t n_rows, Py_ssize_t n_cols) + Py_ssize_t n_rows, Py_ssize_t n_cols) noexcept cpdef MatrixWindow new_matrix_window(MatrixWindow self, Matrix matrix, Py_ssize_t row, Py_ssize_t col, - Py_ssize_t n_rows, Py_ssize_t n_cols) - cpdef matrix(MatrixWindow self) - cpdef swap_rows(MatrixWindow self, Py_ssize_t a, Py_ssize_t b) - cdef object _zero(self) + Py_ssize_t n_rows, Py_ssize_t n_cols) noexcept + cpdef matrix(MatrixWindow self) noexcept + cpdef swap_rows(MatrixWindow self, Py_ssize_t a, Py_ssize_t b) noexcept + cdef object _zero(self) noexcept diff --git a/src/sage/matrix/matrix_window.pyx b/src/sage/matrix/matrix_window.pyx index e6046919191..671eee0a845 100644 --- a/src/sage/matrix/matrix_window.pyx +++ b/src/sage/matrix/matrix_window.pyx @@ -22,7 +22,7 @@ cdef class MatrixWindow: cpdef MatrixWindow new_matrix_window(MatrixWindow self, Matrix matrix, Py_ssize_t row, Py_ssize_t col, - Py_ssize_t n_rows, Py_ssize_t n_cols): + Py_ssize_t n_rows, Py_ssize_t n_cols) noexcept: """ This method is here only to provide a fast cdef way of constructing new matrix windows. The only implicit assumption @@ -47,13 +47,13 @@ cdef class MatrixWindow: self._nrows = nrows self._ncols = ncols - cdef object _zero(self): + cdef object _zero(self) noexcept: if self._cached_zero is None: self._cached_zero = self._matrix.base_ring()(0) # expensive return self._cached_zero cpdef MatrixWindow matrix_window(MatrixWindow self, Py_ssize_t row, Py_ssize_t col, - Py_ssize_t n_rows, Py_ssize_t n_cols): + Py_ssize_t n_rows, Py_ssize_t n_cols) noexcept: """ Returns a matrix window relative to this window of the underlying matrix. @@ -62,7 +62,7 @@ cdef class MatrixWindow: return self return self.new_matrix_window(self._matrix, self._row + row, self._col + col, n_rows, n_cols) - cpdef new_empty_window(MatrixWindow self, Py_ssize_t nrows, Py_ssize_t ncols): + cpdef new_empty_window(MatrixWindow self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept: a = self._matrix.new_matrix(nrows, ncols) return self.new_matrix_window(a, 0, 0, nrows, ncols) @@ -79,10 +79,10 @@ cdef class MatrixWindow: raise TypeError("Parents must be equal.") self.set_to(src) - cpdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x): + cpdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x) noexcept: self._matrix.set_unsafe(i + self._row, j + self._col, x) - cpdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cpdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: return self._matrix.get_unsafe(i + self._row, j + self._col) def __setitem__(self, ij, x): @@ -119,14 +119,14 @@ cdef class MatrixWindow: i = ij return self.row(i) - cpdef matrix(MatrixWindow self): + cpdef matrix(MatrixWindow self) noexcept: """ Returns the underlying matrix that this window is a view of. """ return self._matrix - cpdef to_matrix(MatrixWindow self): + cpdef to_matrix(MatrixWindow self) noexcept: """ Returns an actual matrix object representing this view. """ @@ -142,7 +142,7 @@ cdef class MatrixWindow: def ncols(MatrixWindow self): return self._ncols - cpdef set_to(MatrixWindow self, MatrixWindow A): + cpdef set_to(MatrixWindow self, MatrixWindow A) noexcept: """ Change self, making it equal A. """ @@ -154,14 +154,14 @@ cdef class MatrixWindow: self.set_unsafe(i, j, A.get_unsafe(i, j)) return 0 - cpdef set_to_zero(MatrixWindow self): + cpdef set_to_zero(MatrixWindow self) noexcept: cdef Py_ssize_t i, j z = self._zero() for i from 0 <= i < self._nrows: for j from 0 <= j < self._ncols: self.set_unsafe(i, j, z) - cpdef add(MatrixWindow self, MatrixWindow A): + cpdef add(MatrixWindow self, MatrixWindow A) noexcept: cdef Py_ssize_t i, j if self._nrows != A._nrows or self._ncols != A._ncols: raise ArithmeticError("incompatible dimensions") @@ -169,7 +169,7 @@ cdef class MatrixWindow: for j from 0 <= j < self._ncols: self.set_unsafe(i, j, self.get_unsafe(i, j) + A.get_unsafe(i, j)) - cpdef subtract(MatrixWindow self, MatrixWindow A): + cpdef subtract(MatrixWindow self, MatrixWindow A) noexcept: cdef Py_ssize_t i, j if self._nrows != A._nrows or self._ncols != A._ncols: raise ArithmeticError("incompatible dimensions") @@ -177,7 +177,7 @@ cdef class MatrixWindow: for j from 0 <= j < self._ncols: self.set_unsafe(i, j, self.get_unsafe(i, j) - A.get_unsafe(i, j)) - cpdef set_to_sum(MatrixWindow self, MatrixWindow A, MatrixWindow B): + cpdef set_to_sum(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept: cdef Py_ssize_t i, j if self._nrows != A._nrows or self._ncols != A._ncols: raise ArithmeticError("incompatible dimensions") @@ -187,13 +187,13 @@ cdef class MatrixWindow: for j from 0 <= j < self._ncols: self.set_unsafe(i, j, A.get_unsafe(i, j) + B.get_unsafe(i, j)) - cpdef set_to_diff(MatrixWindow self, MatrixWindow A, MatrixWindow B): + cpdef set_to_diff(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept: cdef Py_ssize_t i, j for i from 0 <= i < self._nrows: for j from 0 <= j < self._ncols: self.set_unsafe(i, j, A.get_unsafe(i, j) - B.get_unsafe(i, j)) - cpdef set_to_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B): + cpdef set_to_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept: cdef Py_ssize_t i, j, k if A._ncols != B._nrows or self._nrows != A._nrows or self._ncols != B._ncols: raise ArithmeticError("incompatible dimensions") @@ -204,7 +204,7 @@ cdef class MatrixWindow: s = s + A.get_unsafe(i, k) * B.get_unsafe(k, j) self.set_unsafe(i, j, s) - cpdef add_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B): + cpdef add_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept: cdef Py_ssize_t i, j, k if A._ncols != B._nrows or self._nrows != A._nrows or self._ncols != B._ncols: raise ArithmeticError("incompatible dimensions") @@ -215,7 +215,7 @@ cdef class MatrixWindow: s = s + A.get_unsafe(i, k) * B.get_unsafe(k, j) self.set_unsafe(i, j, s) - cpdef subtract_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B): + cpdef subtract_prod(MatrixWindow self, MatrixWindow A, MatrixWindow B) noexcept: cdef Py_ssize_t i, j, k if A._ncols != B._nrows or self._nrows != A._nrows or self._ncols != B._ncols: raise ArithmeticError("incompatible dimensions") @@ -226,7 +226,7 @@ cdef class MatrixWindow: s = s - A.get_unsafe(i, k) * B.get_unsafe(k, j) self.set_unsafe(i, j, s) - cpdef swap_rows(MatrixWindow self, Py_ssize_t a, Py_ssize_t b): + cpdef swap_rows(MatrixWindow self, Py_ssize_t a, Py_ssize_t b) noexcept: self._matrix.swap_rows_c(self._row + a, self._row + b) def echelon_in_place(MatrixWindow self): @@ -238,5 +238,5 @@ cdef class MatrixWindow: self.set_to(echelon.matrix_window()) return echelon.pivots() - cpdef bint element_is_zero(MatrixWindow self, Py_ssize_t i, Py_ssize_t j): + cpdef bint element_is_zero(MatrixWindow self, Py_ssize_t i, Py_ssize_t j) noexcept: return self._matrix.get_unsafe(i+self._row, j+self._col) == self._zero() diff --git a/src/sage/matrix/strassen.pyx b/src/sage/matrix/strassen.pyx index 13a8c152fd9..9e2797c9925 100644 --- a/src/sage/matrix/strassen.pyx +++ b/src/sage/matrix/strassen.pyx @@ -50,7 +50,7 @@ def strassen_window_multiply(C, A,B, cutoff): cdef strassen_window_multiply_c(MatrixWindow C, MatrixWindow A, - MatrixWindow B, Py_ssize_t cutoff): + MatrixWindow B, Py_ssize_t cutoff) noexcept: # todo -- I'm not sure how to interpret "cutoff". Should it be... # (a) the minimum side length of the matrices (currently implemented below) # (b) the maximum side length of the matrices @@ -235,7 +235,7 @@ cdef strassen_window_multiply_c(MatrixWindow C, MatrixWindow A, C_bulk = C.matrix_window(0, 0, A_sub_nrows << 1, B_sub_ncols << 1) C_bulk.add_prod(A_last_col, B_last_row) -cdef subtract_strassen_product(MatrixWindow result, MatrixWindow A, MatrixWindow B, Py_ssize_t cutoff): +cdef subtract_strassen_product(MatrixWindow result, MatrixWindow A, MatrixWindow B, Py_ssize_t cutoff) noexcept: cdef MatrixWindow to_sub if (cutoff == -1 or result.ncols() <= cutoff or result.nrows() <= cutoff): result.subtract_prod(A, B) @@ -311,7 +311,7 @@ def strassen_echelon(MatrixWindow A, cutoff): sig_off() -cdef strassen_echelon_c(MatrixWindow A, Py_ssize_t cutoff, Py_ssize_t mul_cutoff): +cdef strassen_echelon_c(MatrixWindow A, Py_ssize_t cutoff, Py_ssize_t mul_cutoff) noexcept: # The following notation will be used in the comments below, which should be understood to give # the general idea of what's going on, as if there were no inconvenient non-pivot columns. # The original matrix is given by [ A B ] diff --git a/src/sage/matroids/basis_exchange_matroid.pxd b/src/sage/matroids/basis_exchange_matroid.pxd index 28cc7ad868c..b762fd9ed9d 100644 --- a/src/sage/matroids/basis_exchange_matroid.pxd +++ b/src/sage/matroids/basis_exchange_matroid.pxd @@ -15,86 +15,86 @@ cdef class BasisExchangeMatroid(Matroid): cdef _weak_invariant_var, _strong_invariant_var, _heuristic_invariant_var cdef SetSystem _weak_partition_var, _strong_partition_var, _heuristic_partition_var - cdef _relabel(self, l) + cdef _relabel(self, l) noexcept - cdef _pack(self, bitset_t, X) - cdef __unpack(self, bitset_t) + cdef _pack(self, bitset_t, X) noexcept + cdef __unpack(self, bitset_t) noexcept cdef bint _is_exchange_pair(self, long x, long y) except -1 cdef int _exchange(self, long x, long y) except -1 cdef int _move(self, bitset_t X, bitset_t Y) except -1 - cdef __fundamental_cocircuit(self, bitset_t, long x) - cdef __fundamental_circuit(self, bitset_t, long y) + cdef __fundamental_cocircuit(self, bitset_t, long x) noexcept + cdef __fundamental_circuit(self, bitset_t, long y) noexcept - cdef __max_independent(self, bitset_t, bitset_t) - cdef __circuit(self, bitset_t, bitset_t) - cdef __closure(self, bitset_t, bitset_t) - cdef __max_coindependent(self, bitset_t, bitset_t) - cdef __cocircuit(self, bitset_t, bitset_t) - cdef _coclosure_internal(self, bitset_t, bitset_t) + cdef __max_independent(self, bitset_t, bitset_t) noexcept + cdef __circuit(self, bitset_t, bitset_t) noexcept + cdef __closure(self, bitset_t, bitset_t) noexcept + cdef __max_coindependent(self, bitset_t, bitset_t) noexcept + cdef __cocircuit(self, bitset_t, bitset_t) noexcept + cdef _coclosure_internal(self, bitset_t, bitset_t) noexcept - cdef __augment(self, bitset_t, bitset_t, bitset_t) + cdef __augment(self, bitset_t, bitset_t, bitset_t) noexcept cdef bint __is_independent(self, bitset_t F) except -1 - cdef __move_current_basis(self, bitset_t, bitset_t) - - cdef bint _set_current_basis(self, F) - - cpdef groundset(self) - cpdef groundset_list(self) - cpdef full_rank(self) - cpdef full_corank(self) - - cpdef basis(self) - cpdef _move_current_basis(self, X, Y) - - cpdef _max_independent(self, F) - cpdef _rank(self, F) - cpdef _circuit(self, F) - cpdef _fundamental_circuit(self, B, e) - cpdef _closure(self, F) - - cpdef _max_coindependent(self, F) - cpdef _corank(self, F) - cpdef _cocircuit(self, F) - cpdef _fundamental_cocircuit(self, B, e) - cpdef _coclosure(self, F) - - cpdef _augment(self, X, Y) - cpdef _is_independent(self, F) - - cpdef f_vector(self) - cdef _f_vector_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long rnk) - cpdef flats(self, R) - cdef _flats_rec(self, SetSystem Rflats, long R, bitset_t* flats, bitset_t* todo, long elt, long rnk) - cpdef coflats(self, R) - cdef _coflats_rec(self, SetSystem Rcoflats, long R, bitset_t* coflats, bitset_t* todo, long elt, long cornk) - cdef _flat_element_inv(self, long k) - cdef _flat_element_inv_rec(self, object f_inc, long R, bitset_t* flats, bitset_t* todo, long elt, long i) - - cpdef bases_count(self) - cpdef independent_r_sets(self, long r) - cpdef bases(self) - cpdef dependent_r_sets(self, long r) - cpdef nonbases(self) - - cpdef nonspanning_circuits(self) - cpdef cocircuits(self) - cpdef circuits(self) - - cpdef _characteristic_setsystem(self) - cpdef _weak_invariant(self) - cpdef _weak_partition(self) - cpdef _strong_invariant(self) - cpdef _strong_partition(self) - cpdef _heuristic_invariant(self) - cpdef _heuristic_partition(self) - cdef _flush(self) - - cpdef _equitable_partition(self, P=*) - cpdef _is_isomorphic(self, other, certificate=*) - cpdef _isomorphism(self, other) - cpdef _is_isomorphism(self, other, morphism) - cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism) - - cpdef is_valid(self) - -cdef bint nxksrd(bitset_s *b, long n, long k, bint succ) + cdef __move_current_basis(self, bitset_t, bitset_t) noexcept + + cdef bint _set_current_basis(self, F) noexcept + + cpdef groundset(self) noexcept + cpdef groundset_list(self) noexcept + cpdef full_rank(self) noexcept + cpdef full_corank(self) noexcept + + cpdef basis(self) noexcept + cpdef _move_current_basis(self, X, Y) noexcept + + cpdef _max_independent(self, F) noexcept + cpdef _rank(self, F) noexcept + cpdef _circuit(self, F) noexcept + cpdef _fundamental_circuit(self, B, e) noexcept + cpdef _closure(self, F) noexcept + + cpdef _max_coindependent(self, F) noexcept + cpdef _corank(self, F) noexcept + cpdef _cocircuit(self, F) noexcept + cpdef _fundamental_cocircuit(self, B, e) noexcept + cpdef _coclosure(self, F) noexcept + + cpdef _augment(self, X, Y) noexcept + cpdef _is_independent(self, F) noexcept + + cpdef f_vector(self) noexcept + cdef _f_vector_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long rnk) noexcept + cpdef flats(self, R) noexcept + cdef _flats_rec(self, SetSystem Rflats, long R, bitset_t* flats, bitset_t* todo, long elt, long rnk) noexcept + cpdef coflats(self, R) noexcept + cdef _coflats_rec(self, SetSystem Rcoflats, long R, bitset_t* coflats, bitset_t* todo, long elt, long cornk) noexcept + cdef _flat_element_inv(self, long k) noexcept + cdef _flat_element_inv_rec(self, object f_inc, long R, bitset_t* flats, bitset_t* todo, long elt, long i) noexcept + + cpdef bases_count(self) noexcept + cpdef independent_r_sets(self, long r) noexcept + cpdef bases(self) noexcept + cpdef dependent_r_sets(self, long r) noexcept + cpdef nonbases(self) noexcept + + cpdef nonspanning_circuits(self) noexcept + cpdef cocircuits(self) noexcept + cpdef circuits(self) noexcept + + cpdef _characteristic_setsystem(self) noexcept + cpdef _weak_invariant(self) noexcept + cpdef _weak_partition(self) noexcept + cpdef _strong_invariant(self) noexcept + cpdef _strong_partition(self) noexcept + cpdef _heuristic_invariant(self) noexcept + cpdef _heuristic_partition(self) noexcept + cdef _flush(self) noexcept + + cpdef _equitable_partition(self, P=*) noexcept + cpdef _is_isomorphic(self, other, certificate=*) noexcept + cpdef _isomorphism(self, other) noexcept + cpdef _is_isomorphism(self, other, morphism) noexcept + cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism) noexcept + + cpdef is_valid(self) noexcept + +cdef bint nxksrd(bitset_s *b, long n, long k, bint succ) noexcept diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index fc902bc19c0..c27a8cba33d 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -191,7 +191,7 @@ cdef class BasisExchangeMatroid(Matroid): bitset_free(self._output) bitset_free(self._temp) - cdef _relabel(self, l): + cdef _relabel(self, l) noexcept: """ Relabel each element `e` as `l[e]`, where `l` is a given injective map. @@ -231,7 +231,7 @@ cdef class BasisExchangeMatroid(Matroid): self._heuristic_partition_var._relabel(l) # the engine - cdef _pack(self, bitset_t I, F): + cdef _pack(self, bitset_t I, F) noexcept: """ Encode a subset F of the groundset into a bitpacked set of integers """ @@ -239,7 +239,7 @@ cdef class BasisExchangeMatroid(Matroid): for f in F: bitset_add(I, self._idx[f]) - cdef __unpack(self, bitset_t I): + cdef __unpack(self, bitset_t I) noexcept: """ Unencode a bitpacked set of integers to a subset of the groundset. """ @@ -286,7 +286,7 @@ cdef class BasisExchangeMatroid(Matroid): y = bitset_next(Y, y + 1) x = bitset_next(X, x + 1) - cdef __fundamental_cocircuit(self, bitset_t C, long x): + cdef __fundamental_cocircuit(self, bitset_t C, long x) noexcept: """ Return the unique cocircuit that meets ``self._current_basis`` in exactly element ``x``. """ @@ -300,7 +300,7 @@ cdef class BasisExchangeMatroid(Matroid): y = bitset_next(self._temp, y + 1) bitset_add(C, x) - cdef __fundamental_circuit(self, bitset_t C, long y): + cdef __fundamental_circuit(self, bitset_t C, long y) noexcept: """ Return the unique circuit contained in ``self._current_basis`` union ``y``. """ @@ -313,7 +313,7 @@ cdef class BasisExchangeMatroid(Matroid): x = bitset_next(self._current_basis, x + 1) bitset_add(C, y) - cdef __max_independent(self, bitset_t R, bitset_t F): + cdef __max_independent(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``max_independent``. """ @@ -322,7 +322,7 @@ cdef class BasisExchangeMatroid(Matroid): self._move(self._inside, self._outside) bitset_intersection(R, self._current_basis, F) - cdef __circuit(self, bitset_t R, bitset_t F): + cdef __circuit(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``circuit``. """ @@ -349,7 +349,7 @@ cdef class BasisExchangeMatroid(Matroid): return y = bitset_next(self._outside, y + 1) - cdef __closure(self, bitset_t R, bitset_t F): + cdef __closure(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``closure``. """ @@ -363,7 +363,7 @@ cdef class BasisExchangeMatroid(Matroid): bitset_difference(R, R, F) x = bitset_next(self._inside, x + 1) - cdef __max_coindependent(self, bitset_t R, bitset_t F): + cdef __max_coindependent(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``max_coindependent``. """ @@ -373,7 +373,7 @@ cdef class BasisExchangeMatroid(Matroid): self._move(self._inside, self._outside) bitset_difference(R, F, self._current_basis) - cdef __cocircuit(self, bitset_t R, bitset_t F): + cdef __cocircuit(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``cocircuit``. """ @@ -401,7 +401,7 @@ cdef class BasisExchangeMatroid(Matroid): return x = bitset_next(self._inside, x + 1) - cdef _coclosure_internal(self, bitset_t R, bitset_t F): + cdef _coclosure_internal(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``closure``. """ @@ -416,7 +416,7 @@ cdef class BasisExchangeMatroid(Matroid): bitset_difference(R, R, F) y = bitset_next(self._outside, y + 1) - cdef __augment(self, bitset_t R, bitset_t X, bitset_t Y): + cdef __augment(self, bitset_t R, bitset_t X, bitset_t Y) noexcept: """ Bitpacked version of ``augment``. """ @@ -437,7 +437,7 @@ cdef class BasisExchangeMatroid(Matroid): self._move(self._inside, self._outside) return bitset_isempty(self._outside) - cdef __move_current_basis(self, bitset_t X, bitset_t Y): + cdef __move_current_basis(self, bitset_t X, bitset_t Y) noexcept: """ Bitpacked version of ``_move_current_basis``. """ @@ -450,7 +450,7 @@ cdef class BasisExchangeMatroid(Matroid): self._move(self._inside, self._outside) # functions for derived classes and for parent class - cdef bint _set_current_basis(self, F): + cdef bint _set_current_basis(self, F) noexcept: """ Set _current_basis to subset of the groundset ``F``. """ @@ -461,7 +461,7 @@ cdef class BasisExchangeMatroid(Matroid): return bitset_isempty(self._outside) and bitset_isempty(self._inside) # groundset and full_rank - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -479,7 +479,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self._groundset - cpdef groundset_list(self): + cpdef groundset_list(self) noexcept: """ Return a list of elements of the groundset of the matroid. @@ -525,7 +525,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self._groundset_size - cpdef full_rank(self): + cpdef full_rank(self) noexcept: r""" Return the rank of the matroid. @@ -546,7 +546,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self._matroid_rank - cpdef full_corank(self): + cpdef full_corank(self) noexcept: r""" Return the corank of the matroid. @@ -574,7 +574,7 @@ cdef class BasisExchangeMatroid(Matroid): # matroid oracles - cpdef basis(self): + cpdef basis(self) noexcept: r""" Return an arbitrary basis of the matroid. @@ -603,7 +603,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self.__unpack(self._current_basis) - cpdef _move_current_basis(self, X, Y): + cpdef _move_current_basis(self, X, Y) noexcept: """ Change current basis so that intersection with X is maximized, intersection with Y is minimized. @@ -634,7 +634,7 @@ cdef class BasisExchangeMatroid(Matroid): self._pack(self._input2, Y) self.__move_current_basis(self._input, self._input2) - cpdef _max_independent(self, F): + cpdef _max_independent(self, F) noexcept: """ Compute a maximal independent subset. @@ -665,7 +665,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__max_independent(self._output, self._input) return self.__unpack(self._output) - cpdef _rank(self, F): + cpdef _rank(self, F) noexcept: """ Compute the rank of a subset of the ground set. @@ -696,7 +696,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__max_independent(self._output, self._input) return bitset_len(self._output) - cpdef _circuit(self, F): + cpdef _circuit(self, F) noexcept: """ Return a minimal dependent subset. @@ -733,7 +733,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__circuit(self._output, self._input) return self.__unpack(self._output) - cpdef _fundamental_circuit(self, B, e): + cpdef _fundamental_circuit(self, B, e) noexcept: r""" Return the `B`-fundamental circuit using `e`. @@ -760,7 +760,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__fundamental_circuit(self._output, self._idx[e]) return self.__unpack(self._output) - cpdef _closure(self, F): + cpdef _closure(self, F) noexcept: """ Return the closure of a set. @@ -791,7 +791,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__closure(self._output, self._input) return self.__unpack(self._output) - cpdef _max_coindependent(self, F): + cpdef _max_coindependent(self, F) noexcept: """ Compute a maximal coindependent subset. @@ -822,7 +822,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__max_coindependent(self._output, self._input) return self.__unpack(self._output) - cpdef _corank(self, F): + cpdef _corank(self, F) noexcept: """ Return the corank of a set. @@ -852,7 +852,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__max_coindependent(self._output, self._input) return bitset_len(self._output) - cpdef _cocircuit(self, F): + cpdef _cocircuit(self, F) noexcept: """ Return a minimal codependent subset. @@ -889,7 +889,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__cocircuit(self._output, self._input) return self.__unpack(self._output) - cpdef _fundamental_cocircuit(self, B, e): + cpdef _fundamental_cocircuit(self, B, e) noexcept: r""" Return the `B`-fundamental circuit using `e`. @@ -916,7 +916,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__fundamental_cocircuit(self._output, self._idx[e]) return self.__unpack(self._output) - cpdef _coclosure(self, F): + cpdef _coclosure(self, F) noexcept: """ Return the coclosure of a set. @@ -947,7 +947,7 @@ cdef class BasisExchangeMatroid(Matroid): self._coclosure_internal(self._output, self._input) return self.__unpack(self._output) - cpdef _augment(self, X, Y): + cpdef _augment(self, X, Y) noexcept: r""" Return a maximal subset `I` of `Y` such that `r(X + I)=r(X) + r(I)`. @@ -978,7 +978,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__augment(self._output, self._input, self._input2) return self.__unpack(self._output) - cpdef _is_independent(self, F): + cpdef _is_independent(self, F) noexcept: """ Test if input is independent. @@ -1011,7 +1011,7 @@ cdef class BasisExchangeMatroid(Matroid): # connectivity - cpdef components(self): + cpdef components(self) noexcept: """ Return an iterable containing the components of the matroid. @@ -1095,7 +1095,7 @@ cdef class BasisExchangeMatroid(Matroid): sig_free(comp) return res - cpdef _link(self, S, T): + cpdef _link(self, S, T) noexcept: r""" Given disjoint subsets `S` and `T`, return a connector `I` and a separation `X`, which are optimal dual solutions in Tutte's Linking Theorem: @@ -1242,7 +1242,7 @@ cdef class BasisExchangeMatroid(Matroid): # enumeration - cpdef f_vector(self): + cpdef f_vector(self) noexcept: r""" Return the `f`-vector of the matroid. @@ -1283,7 +1283,7 @@ cdef class BasisExchangeMatroid(Matroid): sig_free(todo) return f_vec - cdef _f_vector_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long i): + cdef _f_vector_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long i) noexcept: """ Recursion for the f_vector method. """ @@ -1301,7 +1301,7 @@ cdef class BasisExchangeMatroid(Matroid): self._f_vector_rec(f_vec, flats, todo, e + 1, i + 1) e = bitset_next(todo[i], e) - cpdef flats(self, r): + cpdef flats(self, r) noexcept: """ Return the collection of flats of the matroid of specified rank. @@ -1356,7 +1356,7 @@ cdef class BasisExchangeMatroid(Matroid): sig_free(todo) return Rflats - cdef _flats_rec(self, SetSystem Rflats, long R, bitset_t* flats, bitset_t* todo, long elt, long i): + cdef _flats_rec(self, SetSystem Rflats, long R, bitset_t* flats, bitset_t* todo, long elt, long i) noexcept: """ Recursion for the ``flats`` method. """ @@ -1376,7 +1376,7 @@ cdef class BasisExchangeMatroid(Matroid): self._flats_rec(Rflats, R, flats, todo, e + 1, i + 1) e = bitset_next(todo[i], e) - cpdef coflats(self, r): + cpdef coflats(self, r) noexcept: """ Return the collection of coflats of the matroid of specified corank. @@ -1431,7 +1431,7 @@ cdef class BasisExchangeMatroid(Matroid): sig_free(todo) return Rcoflats - cdef _coflats_rec(self, SetSystem Rcoflats, long R, bitset_t* coflats, bitset_t* todo, long elt, long i): + cdef _coflats_rec(self, SetSystem Rcoflats, long R, bitset_t* coflats, bitset_t* todo, long elt, long i) noexcept: """ Recursion for the ``coflats`` method. """ @@ -1451,7 +1451,7 @@ cdef class BasisExchangeMatroid(Matroid): self._coflats_rec(Rcoflats, R, coflats, todo, e + 1, i + 1) e = bitset_next(todo[i], e) - cdef _flat_element_inv(self, long k): + cdef _flat_element_inv(self, long k) noexcept: """ Compute a flat-element invariant of the matroid. """ @@ -1486,7 +1486,7 @@ cdef class BasisExchangeMatroid(Matroid): f_vec = tuple([f_inc[i][self._groundset_size] for i in range(k + 1)]) return fie, f_vec - cdef _flat_element_inv_rec(self, object f_inc, long R, bitset_t* flats, bitset_t* todo, long elt, long i): + cdef _flat_element_inv_rec(self, object f_inc, long R, bitset_t* flats, bitset_t* todo, long elt, long i) noexcept: """ Recursion for ``_flat_element_inv``. """ @@ -1513,7 +1513,7 @@ cdef class BasisExchangeMatroid(Matroid): self._flat_element_inv_rec(f_inc, R, flats, todo, e + 1, i + 1) e = bitset_next(todo[i], e) - cpdef bases_count(self): + cpdef bases_count(self) noexcept: """ Return the number of bases of the matroid. @@ -1546,7 +1546,7 @@ cdef class BasisExchangeMatroid(Matroid): self._bcount = res return self._bcount - cpdef independent_sets(self): + cpdef independent_sets(self) noexcept: r""" Return the list of independent subsets of the matroid. @@ -1602,7 +1602,7 @@ cdef class BasisExchangeMatroid(Matroid): sig_free(T) return res - cpdef independent_r_sets(self, long r): + cpdef independent_r_sets(self, long r) noexcept: """ Return the list of size-``r`` independent subsets of the matroid. @@ -1637,7 +1637,7 @@ cdef class BasisExchangeMatroid(Matroid): repeat = nxksrd(self._input, self._groundset_size, r, True) return BB - cpdef bases(self): + cpdef bases(self) noexcept: """ Return the list of bases of the matroid. @@ -1657,7 +1657,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self.independent_r_sets(self.full_rank()) - cpdef dependent_r_sets(self, long r): + cpdef dependent_r_sets(self, long r) noexcept: """ Return the list of dependent subsets of fixed size. @@ -1697,7 +1697,7 @@ cdef class BasisExchangeMatroid(Matroid): NB.resize() return NB - cpdef nonbases(self): + cpdef nonbases(self) noexcept: """ Return the list of nonbases of the matroid. @@ -1722,7 +1722,7 @@ cdef class BasisExchangeMatroid(Matroid): """ return self.dependent_r_sets(self.full_rank()) - cpdef nonspanning_circuits(self): + cpdef nonspanning_circuits(self) noexcept: """ Return the list of nonspanning circuits of the matroid. @@ -1771,7 +1771,7 @@ cdef class BasisExchangeMatroid(Matroid): NSC.resize() return NSC - cpdef noncospanning_cocircuits(self): + cpdef noncospanning_cocircuits(self) noexcept: """ Return the list of noncospanning cocircuits of the matroid. @@ -1821,7 +1821,7 @@ cdef class BasisExchangeMatroid(Matroid): NSC.resize() return NSC - cpdef cocircuits(self): + cpdef cocircuits(self) noexcept: """ Return the list of cocircuits of the matroid. @@ -1869,7 +1869,7 @@ cdef class BasisExchangeMatroid(Matroid): NSC.resize() return NSC - cpdef circuits(self): + cpdef circuits(self) noexcept: """ Return the list of circuits of the matroid. @@ -1921,7 +1921,7 @@ cdef class BasisExchangeMatroid(Matroid): # isomorphism - cpdef _characteristic_setsystem(self): + cpdef _characteristic_setsystem(self) noexcept: r""" Return a characteristic set-system for this matroid, on the same ground set. @@ -1943,7 +1943,7 @@ cdef class BasisExchangeMatroid(Matroid): else: return self.noncospanning_cocircuits() - cpdef _weak_invariant(self): + cpdef _weak_invariant(self) noexcept: """ Return an isomorphism invariant of the matroid. @@ -1974,7 +1974,7 @@ cdef class BasisExchangeMatroid(Matroid): self._weak_partition_var = SetSystem(self._E, [fie[f] for f in sorted(fie)]) return self._weak_invariant_var - cpdef _weak_partition(self): + cpdef _weak_partition(self) noexcept: """ Return an ordered partition based on the incidences of elements with low-dimensional flats. @@ -1988,7 +1988,7 @@ cdef class BasisExchangeMatroid(Matroid): self._weak_invariant() return self._weak_partition_var - cpdef _strong_invariant(self): + cpdef _strong_invariant(self) noexcept: """ Return an isomorphism invariant of the matroid. @@ -2014,7 +2014,7 @@ cdef class BasisExchangeMatroid(Matroid): self._strong_invariant_var = CP[2] return self._strong_invariant_var - cpdef _strong_partition(self): + cpdef _strong_partition(self) noexcept: """ Return an equitable partition which refines _weak_partition(). @@ -2028,7 +2028,7 @@ cdef class BasisExchangeMatroid(Matroid): self._strong_invariant() return self._strong_partition_var - cpdef _heuristic_invariant(self): + cpdef _heuristic_invariant(self) noexcept: """ Return a number characteristic for the construction of _heuristic_partition(). @@ -2047,7 +2047,7 @@ cdef class BasisExchangeMatroid(Matroid): self._heuristic_invariant_var = CP[2] return self._heuristic_invariant_var - cpdef _heuristic_partition(self): + cpdef _heuristic_partition(self) noexcept: """ Return an ordered partition into singletons which refines an equitable partition of the matroid. @@ -2071,7 +2071,7 @@ cdef class BasisExchangeMatroid(Matroid): self._heuristic_invariant() return self._heuristic_partition_var - cdef _flush(self): + cdef _flush(self) noexcept: """ Delete all invariants. """ @@ -2079,7 +2079,7 @@ cdef class BasisExchangeMatroid(Matroid): self._strong_invariant_var = None self._heuristic_invariant_var = None - cpdef _equitable_partition(self, P=None): + cpdef _equitable_partition(self, P=None) noexcept: """ Return the equitable refinement of a given ordered partition. @@ -2110,7 +2110,7 @@ cdef class BasisExchangeMatroid(Matroid): EQ = self._characteristic_setsystem()._equitable_partition() return EQ[0] - cpdef _is_isomorphism(self, other, morphism): + cpdef _is_isomorphism(self, other, morphism) noexcept: r""" Version of is_isomorphism() that does no type checking. @@ -2157,7 +2157,7 @@ cdef class BasisExchangeMatroid(Matroid): ot = other return self.__is_isomorphism(ot, morphism) - cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism): + cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism) noexcept: """ Bitpacked version of ``is_isomorphism``. """ @@ -2177,7 +2177,7 @@ cdef class BasisExchangeMatroid(Matroid): repeat = nxksrd(self._input, self._groundset_size, self._matroid_rank, True) return True - cpdef _isomorphism(self, other): + cpdef _isomorphism(self, other) noexcept: """ Return an isomorphism form ``self`` to ``other``, if one exists. @@ -2265,7 +2265,7 @@ cdef class BasisExchangeMatroid(Matroid): return self._characteristic_setsystem()._isomorphism(other._characteristic_setsystem(), PS, PO) - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. @@ -2352,7 +2352,7 @@ cdef class BasisExchangeMatroid(Matroid): return self._characteristic_setsystem()._isomorphism(other._characteristic_setsystem(), PS, PO) is not None - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -2422,7 +2422,7 @@ cdef class BasisExchangeMatroid(Matroid): return True -cdef bint nxksrd(bitset_s* b, long n, long k, bint succ): +cdef bint nxksrd(bitset_s* b, long n, long k, bint succ) noexcept: """ Next size-k subset of a size-n set in a revolving-door sequence. diff --git a/src/sage/matroids/basis_matroid.pxd b/src/sage/matroids/basis_matroid.pxd index 6b3c0d27c9a..a4202bfedac 100644 --- a/src/sage/matroids/basis_matroid.pxd +++ b/src/sage/matroids/basis_matroid.pxd @@ -14,33 +14,33 @@ cdef class BasisMatroid(BasisExchangeMatroid): cdef _bases_invariant3_var cdef SetSystem _bases_partition3_var - cdef reset_current_basis(self) - - cpdef _is_basis(self, X) - - cpdef bases_count(self) - cpdef bases(self) - cpdef nonbases(self) - - cpdef truncation(self) - cpdef _extension(self, e, H) - cpdef _with_coloop(self, e) - cpdef relabel(self, l) - - cpdef _bases_invariant(self) - cpdef _bases_partition(self) - cpdef _bases_invariant2(self) - cpdef _bases_partition2(self) - cpdef _bases_invariant3(self) - cpdef _bases_partition3(self) - cdef _reset_invariants(self) - cpdef bint is_distinguished(self, e) - cpdef _is_relaxation(self, M, morphism) - cpdef _is_isomorphism(self, M, morphism) - cpdef _isomorphism(self, other) - cpdef _is_isomorphic(self, other, certificate=*) - - -cdef binom_init(long n, long k) -cdef long set_to_index(bitset_t S) -cdef index_to_set(bitset_t, long, long, long) + cdef reset_current_basis(self) noexcept + + cpdef _is_basis(self, X) noexcept + + cpdef bases_count(self) noexcept + cpdef bases(self) noexcept + cpdef nonbases(self) noexcept + + cpdef truncation(self) noexcept + cpdef _extension(self, e, H) noexcept + cpdef _with_coloop(self, e) noexcept + cpdef relabel(self, l) noexcept + + cpdef _bases_invariant(self) noexcept + cpdef _bases_partition(self) noexcept + cpdef _bases_invariant2(self) noexcept + cpdef _bases_partition2(self) noexcept + cpdef _bases_invariant3(self) noexcept + cpdef _bases_partition3(self) noexcept + cdef _reset_invariants(self) noexcept + cpdef bint is_distinguished(self, e) noexcept + cpdef _is_relaxation(self, M, morphism) noexcept + cpdef _is_isomorphism(self, M, morphism) noexcept + cpdef _isomorphism(self, other) noexcept + cpdef _is_isomorphic(self, other, certificate=*) noexcept + + +cdef binom_init(long n, long k) noexcept +cdef long set_to_index(bitset_t S) noexcept +cdef index_to_set(bitset_t, long, long, long) noexcept diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index 6dff6506981..93cf56ec60c 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -290,7 +290,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): bitset_add(self._b, y) return bitset_in(self._bb, set_to_index(self._b)) - cdef reset_current_basis(self): + cdef reset_current_basis(self) noexcept: """ Set the current basis to the (lexicographically) first basis of the matroid. @@ -299,7 +299,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): # a function that is very efficient for this class - cpdef _is_basis(self, X): + cpdef _is_basis(self, X) noexcept: """ Test if input is a basis. @@ -331,7 +331,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): # dual and minors - cpdef dual(self): + cpdef dual(self) noexcept: r""" Return the dual of the matroid. @@ -372,7 +372,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): D._bcount = self._bcount return D - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: """ Return a minor. @@ -409,7 +409,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): NB = [frozenset(B) for B in combinations(E, mr) if not self._is_basis(contractions | frozenset(B))] return BasisMatroid(groundset=E, nonbases=NB, rank=mr) - cpdef truncation(self): + cpdef truncation(self) noexcept: r""" Return a rank-1 truncation of the matroid. @@ -442,7 +442,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): return None return BasisMatroid(groundset=self._E, nonbases=self.dependent_r_sets(self.full_rank() - 1), rank=self.full_rank() - 1) - cpdef _extension(self, e, H): + cpdef _extension(self, e, H) noexcept: r""" Extend the matroid by a new element. @@ -494,7 +494,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): BE += BB return BasisMatroid(groundset=self._E + (e,), bases=BE) - cpdef _with_coloop(self, e): + cpdef _with_coloop(self, e) noexcept: r""" Return the matroid that arises by adding an element `e` to the groundset, that is a coloop of the resulting matroid. @@ -521,7 +521,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): cdef frozenset se = frozenset([e]) return BasisMatroid(groundset=self._E + (e,), bases=[B | se for B in self.bases()]) - cpdef relabel(self, l): + cpdef relabel(self, l) noexcept: """ Return an isomorphic matroid with relabeled groundset. @@ -562,7 +562,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): # enumeration - cpdef bases_count(self): + cpdef bases_count(self) noexcept: r""" Return the number of bases of the matroid. @@ -582,7 +582,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bcount = bitset_len(self._bb) return self._bcount - cpdef bases(self): + cpdef bases(self) noexcept: r""" Return the list of bases of the matroid. @@ -613,7 +613,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): b = bitset_next(self._bb, b + 1) return BB - cpdef nonbases(self): + cpdef nonbases(self) noexcept: r""" Return the list of nonbases of the matroid. @@ -658,7 +658,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): # isomorphism test - cpdef _bases_invariant(self): + cpdef _bases_invariant(self) noexcept: """ Return an isomorphism invariant based on the incidences of groundset elements with bases. @@ -702,7 +702,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_partition_var = SetSystem(self._E, [[self._E[e] for e in bi[c]] for c in sorted(bi)]) return self._bases_invariant_var - cpdef _bases_partition(self): + cpdef _bases_partition(self) noexcept: """ Return an ordered partition based on the incidences of groundset elements with bases. @@ -717,7 +717,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_invariant() return self._bases_partition_var - cpdef _bases_invariant2(self): + cpdef _bases_invariant2(self) noexcept: """ Return an isomorphism invariant of the matroid. @@ -744,7 +744,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_invariant2_var = CP[2] return self._bases_invariant2_var - cpdef _bases_partition2(self): + cpdef _bases_partition2(self) noexcept: """ Return an equitable partition which refines :meth:``. @@ -759,7 +759,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_invariant2() return self._bases_partition2_var - cpdef _bases_invariant3(self): + cpdef _bases_invariant3(self) noexcept: """ Return a number characteristic for the construction of :meth:``. @@ -778,7 +778,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_invariant3_var = CP[2] return self._bases_invariant3_var - cpdef _bases_partition3(self): + cpdef _bases_partition3(self) noexcept: """ Return an ordered partition into singletons which refines an equitable partition of the matroid. @@ -802,7 +802,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_invariant3() return self._bases_partition3_var - cdef _reset_invariants(self): + cdef _reset_invariants(self) noexcept: """ Remove all precomputed invariants. """ @@ -816,7 +816,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): self._bases_partition3_var = None self._flush() - cpdef bint is_distinguished(self, e): + cpdef bint is_distinguished(self, e) noexcept: """ Return whether ``e`` is a 'distinguished' element of the groundset. @@ -863,7 +863,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): q = q2 return e in q - cpdef _is_relaxation(self, other, morphism): + cpdef _is_relaxation(self, other, morphism) noexcept: """ Return if the application of a groundset morphism to this matroid yields a relaxation of the given matroid. @@ -923,7 +923,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): bitset_free(bb_comp) return True - cpdef _is_isomorphism(self, other, morphism): + cpdef _is_isomorphism(self, other, morphism) noexcept: """ Version of :meth:`is_isomorphism` that does no type checking. @@ -961,7 +961,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): ot = other return self.bases_count() == (ot).bases_count() and self._is_relaxation(ot, morphism) - cpdef _isomorphism(self, other): + cpdef _isomorphism(self, other) noexcept: """ Return isomorphism from ``self`` to ``other``, if one exists. @@ -1040,7 +1040,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): return self.nonbases()._isomorphism(other.nonbases(), PS, PO) - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Return if this matroid is isomorphic to the given matroid. @@ -1244,7 +1244,7 @@ cdef class BasisMatroid(BasisExchangeMatroid): cdef long binom[2956][33] # Cached binomial table -cdef binom_init(long N, long K): +cdef binom_init(long N, long K) noexcept: """ Fill up the cached binomial table. """ @@ -1270,7 +1270,7 @@ cdef binom_init(long N, long K): if binom[N][K] == 0: raise ValueError("BasisMatroid: number of potential bases would exceed 2^32") -cdef long set_to_index(bitset_t S): +cdef long set_to_index(bitset_t S) noexcept: """ Compute the rank of a set of integers amongst the sets of integers of the same cardinality. @@ -1286,7 +1286,7 @@ cdef long set_to_index(bitset_t S): return index -cdef index_to_set(bitset_t S, long index, long k, long n): +cdef index_to_set(bitset_t S, long index, long k, long n) noexcept: r""" Compute the k-subset of `\{0, ..., n-1\}` of rank index """ diff --git a/src/sage/matroids/circuit_closures_matroid.pxd b/src/sage/matroids/circuit_closures_matroid.pxd index e2c4afdaff9..1ec965db0fe 100644 --- a/src/sage/matroids/circuit_closures_matroid.pxd +++ b/src/sage/matroids/circuit_closures_matroid.pxd @@ -4,11 +4,11 @@ cdef class CircuitClosuresMatroid(Matroid): cdef frozenset _groundset # _E cdef dict _circuit_closures # _CC cdef int _matroid_rank # _R - cpdef groundset(self) - cpdef _rank(self, X) - cpdef full_rank(self) - cpdef _is_independent(self, F) - cpdef _max_independent(self, F) - cpdef _circuit(self, F) - cpdef circuit_closures(self) - cpdef _is_isomorphic(self, other, certificate=*) + cpdef groundset(self) noexcept + cpdef _rank(self, X) noexcept + cpdef full_rank(self) noexcept + cpdef _is_independent(self, F) noexcept + cpdef _max_independent(self, F) noexcept + cpdef _circuit(self, F) noexcept + cpdef circuit_closures(self) noexcept + cpdef _is_isomorphic(self, other, certificate=*) noexcept diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 4e79b0575e2..1fc11f0c344 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -165,7 +165,7 @@ cdef class CircuitClosuresMatroid(Matroid): self._circuit_closures[k] = frozenset([frozenset(X) for X in circuit_closures[k]]) self._matroid_rank = self.rank(self._groundset) - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -183,7 +183,7 @@ cdef class CircuitClosuresMatroid(Matroid): """ return frozenset(self._groundset) - cpdef _rank(self, X): + cpdef _rank(self, X) noexcept: """ Return the rank of a set ``X``. @@ -207,7 +207,7 @@ cdef class CircuitClosuresMatroid(Matroid): return len(self._max_independent(X)) # OPTIONAL, OPTIMIZED FOR THIS CLASS - cpdef full_rank(self): + cpdef full_rank(self) noexcept: r""" Return the rank of the matroid. @@ -228,7 +228,7 @@ cdef class CircuitClosuresMatroid(Matroid): """ return self._matroid_rank - cpdef _is_independent(self, F): + cpdef _is_independent(self, F) noexcept: """ Test if input is independent. @@ -259,7 +259,7 @@ cdef class CircuitClosuresMatroid(Matroid): return False return True - cpdef _max_independent(self, F): + cpdef _max_independent(self, F) noexcept: """ Compute a maximal independent subset. @@ -296,7 +296,7 @@ cdef class CircuitClosuresMatroid(Matroid): return frozenset(I) - cpdef _circuit(self, F): + cpdef _circuit(self, F) noexcept: """ Return a minimal dependent subset. @@ -329,7 +329,7 @@ cdef class CircuitClosuresMatroid(Matroid): return frozenset(S) raise ValueError("no circuit in independent set") - cpdef circuit_closures(self): + cpdef circuit_closures(self) noexcept: """ Return the list of closures of circuits of the matroid. @@ -363,7 +363,7 @@ cdef class CircuitClosuresMatroid(Matroid): """ return self._circuit_closures - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. diff --git a/src/sage/matroids/extension.pxd b/src/sage/matroids/extension.pxd index 1d44f460c52..34d813eeb7c 100644 --- a/src/sage/matroids/extension.pxd +++ b/src/sage/matroids/extension.pxd @@ -6,12 +6,12 @@ cdef class CutNode: cdef bitset_t _p_free, _p_in, _l0, _l1 cdef long _ml - cdef CutNode copy(self) - cdef bint insert_plane(self, long p0) - cdef bint remove_plane(self, long p0) - cdef select_plane(self) + cdef CutNode copy(self) noexcept + cdef bint insert_plane(self, long p0) noexcept + cdef bint remove_plane(self, long p0) noexcept + cdef select_plane(self) noexcept - cdef list planes(self) + cdef list planes(self) noexcept cdef class LinearSubclassesIter: cdef LinearSubclasses _MC diff --git a/src/sage/matroids/extension.pyx b/src/sage/matroids/extension.pyx index 1f2cb38a65c..061ba37089e 100644 --- a/src/sage/matroids/extension.pyx +++ b/src/sage/matroids/extension.pyx @@ -87,10 +87,10 @@ cdef class CutNode: bitset_free(self._l0) bitset_free(self._l1) - cdef CutNode copy(self): + cdef CutNode copy(self) noexcept: return CutNode(self._MC, self) - cdef bint insert_plane(self, long p0): + cdef bint insert_plane(self, long p0) noexcept: """ Add a hyperplane to the linear subclass. """ @@ -128,7 +128,7 @@ cdef class CutNode: return False return True - cdef bint remove_plane(self, long p0): + cdef bint remove_plane(self, long p0) noexcept: """ Remove a hyperplane from the linear subclass. """ @@ -153,7 +153,7 @@ cdef class CutNode: return False return True - cdef select_plane(self): + cdef select_plane(self) noexcept: """ Choose a hyperplane from the linear subclass. """ @@ -169,7 +169,7 @@ cdef class CutNode: return bitset_first(self._p_free) - cdef list planes(self): + cdef list planes(self) noexcept: """ Return all hyperplanes from the linear subclass. """ diff --git a/src/sage/matroids/lean_matrix.pxd b/src/sage/matroids/lean_matrix.pxd index 3512bcfce31..f71e22f63ee 100644 --- a/src/sage/matroids/lean_matrix.pxd +++ b/src/sage/matroids/lean_matrix.pxd @@ -5,18 +5,18 @@ cdef class LeanMatrix: cdef long _nrows cdef long _ncols - cdef LeanMatrix copy(self) # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept # Deprecated Sage matrix operation cdef int resize(self, long k) except -1 # Not a Sage matrix operation - cdef LeanMatrix stack(self, LeanMatrix M) - cdef LeanMatrix augment(self, LeanMatrix M) - cdef LeanMatrix prepend_identity(self) # Not a Sage matrix operation + cdef LeanMatrix stack(self, LeanMatrix M) noexcept + cdef LeanMatrix augment(self, LeanMatrix M) noexcept + cdef LeanMatrix prepend_identity(self) noexcept # Not a Sage matrix operation cpdef long ncols(self) except -1 cpdef long nrows(self) except -1 - cpdef base_ring(self) - cpdef characteristic(self) # Not a Sage matrix operation + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept # Not a Sage matrix operation - cdef get_unsafe(self, long r, long c) + cdef get_unsafe(self, long r, long c) noexcept cdef int set_unsafe(self, long r, long c, x) except -1 cdef bint is_nonzero(self, long r, long c) except -2 # Not a Sage matrix operation @@ -25,16 +25,16 @@ cdef class LeanMatrix: cdef int rescale_row_c(self, long x, s, bint col_start) except -1 cdef int rescale_column_c(self, long y, s, bint start_row) except -1 cdef int pivot(self, long x, long y) except -1 # Not a Sage matrix operation - cdef list gauss_jordan_reduce(self, columns) # Not a Sage matrix operation + cdef list gauss_jordan_reduce(self, columns) noexcept # Not a Sage matrix operation - cdef list nonzero_positions_in_row(self, long r) + cdef list nonzero_positions_in_row(self, long r) noexcept - cdef LeanMatrix transpose(self) - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) - cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) + cdef LeanMatrix transpose(self) noexcept + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept + cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) noexcept - cdef shifting_all(self, P_rows, P_cols, Q_rows, Q_cols, int m) - cdef shifting(self, U_1, V_2, U_2, V_1, z2, z1, int m) + cdef shifting_all(self, P_rows, P_cols, Q_rows, Q_cols, int m) noexcept + cdef shifting(self, U_1, V_2, U_2, V_1, z2, z1, int m) noexcept cdef class GenericMatrix(LeanMatrix): cdef _base_ring, _characteristic @@ -42,29 +42,29 @@ cdef class GenericMatrix(LeanMatrix): cdef _zero cdef _one - cdef inline row_inner_product(self, long i, long j) # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation cdef class BinaryMatrix(LeanMatrix): cdef bitset_t* _M cdef bitset_t _temp cdef inline long row_len(self, long i) except -1 # Not a Sage matrix operation - cdef inline bint row_inner_product(self, long i, long j) # Not a Sage matrix operation + cdef inline bint row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation - cdef inline bint get(self, long x, long y) # Not a Sage matrix operation - cdef inline void set(self, long x, long y) # Not a Sage matrix operation + cdef inline bint get(self, long x, long y) noexcept # Not a Sage matrix operation + cdef inline void set(self, long x, long y) noexcept # Not a Sage matrix operation - cdef inline list row_sum(self, object L) # Not a Sage matrix operation - cdef inline list row_union(self, object L) # Not a Sage matrix operation + cdef inline list row_sum(self, object L) noexcept # Not a Sage matrix operation + cdef inline list row_union(self, object L) noexcept # Not a Sage matrix operation - cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) - cdef matrix_from_rows_and_columns_reordered(self, rows, columns) + cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) noexcept + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept - cdef list _character(self, bitset_t x) - cdef BinaryMatrix _distinguish_by(self, BinaryMatrix P) - cdef BinaryMatrix _splice_by(self, BinaryMatrix P) - cdef BinaryMatrix _isolate(self, long r) - cdef BinaryMatrix equitable_partition(self, BinaryMatrix P=*) # Not a Sage matrix operation + cdef list _character(self, bitset_t x) noexcept + cdef BinaryMatrix _distinguish_by(self, BinaryMatrix P) noexcept + cdef BinaryMatrix _splice_by(self, BinaryMatrix P) noexcept + cdef BinaryMatrix _isolate(self, long r) noexcept + cdef BinaryMatrix equitable_partition(self, BinaryMatrix P=*) noexcept # Not a Sage matrix operation cdef bint is_isomorphic(self, BinaryMatrix other, BinaryMatrix s_eq=*, BinaryMatrix o_eq=*) except -2 # Not a Sage matrix operation @@ -73,16 +73,16 @@ cdef class TernaryMatrix(LeanMatrix): cdef bitset_t *_M1 # _M1[i] = negative support of row i cdef bitset_t _s, _t, _u # registers - cdef inline long get(self, long r, long c) # Not a Sage matrix operation + cdef inline long get(self, long r, long c) noexcept # Not a Sage matrix operation cdef inline int set(self, long r, long c, x) except -1 # Not a Sage matrix operation - cdef bint _is_negative(self, long r, long c) + cdef bint _is_negative(self, long r, long c) noexcept - cdef inline long row_len(self, long i) # Not a Sage matrix operation - cdef inline long row_inner_product(self, long i, long j) # Not a Sage matrix operation - cdef void row_subs(self, long x, long y) # Not a Sage matrix operation - cdef void _row_negate(self, long x) - cdef matrix_from_rows_and_columns_reordered(self, rows, columns) + cdef inline long row_len(self, long i) noexcept # Not a Sage matrix operation + cdef inline long row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation + cdef void row_subs(self, long x, long y) noexcept # Not a Sage matrix operation + cdef void _row_negate(self, long x) noexcept + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept cdef class QuaternaryMatrix(LeanMatrix): cdef bitset_t *_M0 # _M0[i] = 1-support of row i @@ -90,36 +90,36 @@ cdef class QuaternaryMatrix(LeanMatrix): cdef bitset_t _s, _t, _u # registers cdef object _gf4, _zero, _one, _x_zero, _x_one - cdef inline get(self, long r, long c) # Not a Sage matrix operation + cdef inline get(self, long r, long c) noexcept # Not a Sage matrix operation cdef inline int set(self, long r, long c, x) except -1 # Not a Sage matrix operation cdef inline long row_len(self, long i) except -1 # Not a Sage matrix operation - cdef inline row_inner_product(self, long i, long j) # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation cdef inline int _row_div(self, long x, object s) except -1 - cdef matrix_from_rows_and_columns_reordered(self, rows, columns) - cdef void conjugate(self) # Not a Sage matrix operation + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept + cdef void conjugate(self) noexcept # Not a Sage matrix operation cdef class PlusMinusOneMatrix(LeanMatrix): cdef int* _entries - cdef inline int get(self, long r, long c) # Not a Sage matrix operation - cdef inline void set(self, long r, long c, int x) # Not a Sage matrix operation + cdef inline int get(self, long r, long c) noexcept # Not a Sage matrix operation + cdef inline void set(self, long r, long c, int x) noexcept # Not a Sage matrix operation cdef inline long row_len(self, long i) except -1 # Not a Sage matrix operation - cdef inline row_inner_product(self, long i, long j) # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation cdef class RationalMatrix(LeanMatrix): cdef mpq_t* _entries - cdef inline long index(self, long r, long c) # Not a Sage matrix operation - cdef inline void set(self, long r, long c, mpq_t x) # Not a Sage matrix operation + cdef inline long index(self, long r, long c) noexcept # Not a Sage matrix operation + cdef inline void set(self, long r, long c, mpq_t x) noexcept # Not a Sage matrix operation cdef inline long row_len(self, long i) except -1 # Not a Sage matrix operation - cdef inline row_inner_product(self, long i, long j) # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept # Not a Sage matrix operation cdef int add_multiple_of_row_mpq(self, long x, long y, mpq_t s, bint col_start) except -1 cdef int rescale_row_mpq(self, long x, mpq_t s, bint col_start) except -1 cdef int rescale_column_mpq(self, long y, mpq_t s, bint start_row) except -1 -cpdef GenericMatrix generic_identity(n, ring) +cpdef GenericMatrix generic_identity(n, ring) noexcept diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index a137cbf70e5..740864af9ce 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -112,7 +112,7 @@ cdef class LeanMatrix: M[r, c] = self.get_unsafe(r, c) return M - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation """ Make a copy of ``self``. """ @@ -125,7 +125,7 @@ cdef class LeanMatrix: """ raise NotImplementedError - cdef LeanMatrix stack(self, LeanMatrix M): + cdef LeanMatrix stack(self, LeanMatrix M) noexcept: """ Stack ``self`` on top of ``M``. Assumes ``self`` and ``M`` are of same type, and compatible dimensions. @@ -142,7 +142,7 @@ cdef class LeanMatrix: A.set_unsafe(i + sr, j, M.get_unsafe(i, j)) return A - cdef LeanMatrix augment(self, LeanMatrix M): + cdef LeanMatrix augment(self, LeanMatrix M) noexcept: """ Concatenates ``self`` with ``M``, placing ``M`` to the right of ``self``. Assumes ``self`` and ``M`` are of same type, and compatible @@ -159,7 +159,7 @@ cdef class LeanMatrix: A.set_unsafe(i, j + sc, M.get_unsafe(i, j)) return A - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation """ Return the matrix obtained by prepending an identity matrix. Special case of ``augment``. @@ -198,7 +198,7 @@ cdef class LeanMatrix: """ return self._nrows - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring. @@ -213,7 +213,7 @@ cdef class LeanMatrix: """ raise NotImplementedError("subclasses need to implement this.") - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -226,7 +226,7 @@ cdef class LeanMatrix: """ return self.base_ring().characteristic() - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: """ Return the value in row ``r``, column ``c``. """ @@ -310,7 +310,7 @@ cdef class LeanMatrix: self.add_multiple_of_row_c(i, x, -s, 0) return 0 - cdef list gauss_jordan_reduce(self, columns): # Not a Sage matrix operation + cdef list gauss_jordan_reduce(self, columns) noexcept: # Not a Sage matrix operation """ Row-reduce so the lexicographically first basis indexes an identity submatrix. @@ -335,13 +335,13 @@ cdef class LeanMatrix: break return P - cdef list nonzero_positions_in_row(self, long r): + cdef list nonzero_positions_in_row(self, long r) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ return [i for i in range(self._ncols) if self.is_nonzero(r, i)] - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -352,7 +352,7 @@ cdef class LeanMatrix: A.set_unsafe(j, i, self.get_unsafe(i, j)) return A - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Multiply two matrices. Assumes ``self`` and ``M`` are of same type, and compatible dimensions. @@ -365,7 +365,7 @@ cdef class LeanMatrix: A.set_unsafe(i, j, self.get_unsafe(i, k) * other.get_unsafe(k, j)) return A - cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns): + cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) noexcept: """ Return submatrix indexed by indicated rows and columns. """ @@ -518,7 +518,7 @@ cdef class LeanMatrix: """ raise NotImplementedError("subclasses need to implement this.") - cdef shifting_all(self, P_rows, P_cols, Q_rows, Q_cols, int m): + cdef shifting_all(self, P_rows, P_cols, Q_rows, Q_cols, int m) noexcept: r""" Given a partial matrix `M`. If the submatrix `M` using rows `P_rows` columns `P_cols` and submatrix using rows `Q_rows` columns @@ -562,7 +562,7 @@ cdef class LeanMatrix: return True, cert return False, None - cdef shifting(self, U_1, V_2, U_2, V_1, z2, z1, int m): + cdef shifting(self, U_1, V_2, U_2, V_1, z2, z1, int m) noexcept: r""" Let `E_1` be the submatrix using rows `U_1` and columns `V_2` with optional column `z2` attached. @@ -760,7 +760,7 @@ cdef class GenericMatrix(LeanMatrix): """ return "LeanMatrix instance with " + str(self._nrows) + " rows and " + str(self._ncols) + " columns over " + repr(self._base_ring) - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef GenericMatrix M = GenericMatrix(self._nrows, self._ncols, M=self) return M @@ -776,7 +776,7 @@ cdef class GenericMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix M): + cdef LeanMatrix stack(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is a GenericMatrix instance! """ @@ -787,7 +787,7 @@ cdef class GenericMatrix(LeanMatrix): A._ncols = self._ncols return A - cdef LeanMatrix augment(self, LeanMatrix M): + cdef LeanMatrix augment(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is a GenericMatrix instance! """ @@ -800,14 +800,14 @@ cdef class GenericMatrix(LeanMatrix): A._entries[i * A._ncols + self._ncols:(i + 1) * A._ncols]=(M)._entries[i * Mn:(i + 1) * Mn] return A - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation cdef GenericMatrix A = GenericMatrix(self._nrows, self._ncols + self._nrows, ring=self._base_ring) for i in range(self._nrows): A._entries[i * A._ncols + i] = self._one A._entries[i * A._ncols + self._nrows:(i + 1) * A._ncols]=self._entries[i * self._ncols:(i + 1) * self._ncols] return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring of ``self``. @@ -820,7 +820,7 @@ cdef class GenericMatrix(LeanMatrix): """ return self._base_ring - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -835,7 +835,7 @@ cdef class GenericMatrix(LeanMatrix): self._characteristic = self._base_ring.characteristic() return self._characteristic - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: return self._entries[r * self._ncols + c] cdef int set_unsafe(self, long r, long c, x) except -1: @@ -851,7 +851,7 @@ cdef class GenericMatrix(LeanMatrix): self._entries[y * self._ncols:(y + 1) * self._ncols] = tmp return 0 - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -863,7 +863,7 @@ cdef class GenericMatrix(LeanMatrix): A.set_unsafe(j, i, self.get_unsafe(i, j)) return A - cdef inline row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -877,7 +877,7 @@ cdef class GenericMatrix(LeanMatrix): res += x * y return res - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -1084,7 +1084,7 @@ cdef class BinaryMatrix(LeanMatrix): M[i, j] = 1 return M - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef BinaryMatrix B cdef long i B = BinaryMatrix(self.nrows(), self.ncols()) @@ -1111,7 +1111,7 @@ cdef class BinaryMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix MM): + cdef LeanMatrix stack(self, LeanMatrix MM) noexcept: """ Given ``A`` and ``B``, return [A] @@ -1125,7 +1125,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_copy(R._M[i + self.nrows()], M._M[i]) return R - cdef LeanMatrix augment(self, LeanMatrix MM): + cdef LeanMatrix augment(self, LeanMatrix MM) noexcept: """ Given ``A`` and ``B``, return [A B] @@ -1139,7 +1139,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_set_to(R._M[i], self.ncols() + j, bitset_in(M._M[i], j)) return R - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation """ Return the matrix obtained by prepending an identity matrix. Special case of ``augment``. """ @@ -1150,7 +1150,7 @@ cdef class BinaryMatrix(LeanMatrix): A.set(i, i) return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return `GF(2)`. @@ -1164,7 +1164,7 @@ cdef class BinaryMatrix(LeanMatrix): global GF2 return GF2 - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -1177,7 +1177,7 @@ cdef class BinaryMatrix(LeanMatrix): """ return 2 - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: global GF2_one, GF2_zero if bitset_in(self._M[r], c): return GF2_one @@ -1193,10 +1193,10 @@ cdef class BinaryMatrix(LeanMatrix): cdef inline bint is_nonzero(self, long r, long c) except -2: # Not a Sage matrix operation return bitset_in(self._M[r], c) - cdef inline bint get(self, long r, long c): # Not a Sage matrix operation + cdef inline bint get(self, long r, long c) noexcept: # Not a Sage matrix operation return bitset_in(self._M[r], c) - cdef inline void set(self, long x, long y): # Not a Sage matrix operation + cdef inline void set(self, long x, long y) noexcept: # Not a Sage matrix operation bitset_add(self._M[x], y) cdef int pivot(self, long x, long y) except -1: # Not a Sage matrix operation @@ -1224,7 +1224,7 @@ cdef class BinaryMatrix(LeanMatrix): """ return bitset_len(self._M[i]) - cdef inline bint row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline bint row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -1245,13 +1245,13 @@ cdef class BinaryMatrix(LeanMatrix): bitset_copy(self._M[j], self._temp) return 0 - cdef inline list nonzero_positions_in_row(self, long i): + cdef inline list nonzero_positions_in_row(self, long i) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ return bitset_list(self._M[i]) - cdef inline list row_sum(self, object L): # Not a Sage matrix operation + cdef inline list row_sum(self, object L) noexcept: # Not a Sage matrix operation """ Return the mod-2 sum of the rows indexed by ``L``. """ @@ -1260,7 +1260,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_symmetric_difference(self._temp, self._temp, self._M[l]) return bitset_list(self._temp) - cdef inline list row_union(self, object L): # Not a Sage matrix operation + cdef inline list row_union(self, object L) noexcept: # Not a Sage matrix operation """ Return the ``or`` of the rows indexed by ``L``. """ @@ -1269,7 +1269,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_union(self._temp, self._temp, self._M[l]) return bitset_list(self._temp) - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -1283,7 +1283,7 @@ cdef class BinaryMatrix(LeanMatrix): j = bitset_next(self._M[i], j + 1) return T - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -1298,7 +1298,7 @@ cdef class BinaryMatrix(LeanMatrix): j = bitset_next(self._M[i], j + 1) return M - cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns): + cdef LeanMatrix matrix_from_rows_and_columns(self, rows, columns) noexcept: """ Return submatrix indexed by indicated rows and columns. """ @@ -1310,7 +1310,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_add(A._M[r], c) return A - cdef matrix_from_rows_and_columns_reordered(self, rows, columns): + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept: """ Return a submatrix indexed by indicated rows and columns, as well as the column order of the resulting submatrix. @@ -1367,7 +1367,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_free(mask) return A, order - cdef list _character(self, bitset_t x): # Not a Sage matrix operation + cdef list _character(self, bitset_t x) noexcept: # Not a Sage matrix operation """ Return the vector of intersection lengths of the rows with ``x``. """ @@ -1378,7 +1378,7 @@ cdef class BinaryMatrix(LeanMatrix): I.append(bitset_len(self._temp)) return I - cdef BinaryMatrix _distinguish_by(self, BinaryMatrix P): + cdef BinaryMatrix _distinguish_by(self, BinaryMatrix P) noexcept: """ Helper method for equitable partition. """ @@ -1399,7 +1399,7 @@ cdef class BinaryMatrix(LeanMatrix): i += 1 return Q - cdef BinaryMatrix _splice_by(self, BinaryMatrix P): + cdef BinaryMatrix _splice_by(self, BinaryMatrix P) noexcept: """ Helper method for equitable partition. """ @@ -1416,7 +1416,7 @@ cdef class BinaryMatrix(LeanMatrix): Q.resize(r) return Q - cdef BinaryMatrix _isolate(self, long j): + cdef BinaryMatrix _isolate(self, long j) noexcept: """ Helper method for isomorphism test. """ @@ -1429,7 +1429,7 @@ cdef class BinaryMatrix(LeanMatrix): bitset_add(Q._M[self._nrows], j) return Q - cdef BinaryMatrix equitable_partition(self, BinaryMatrix P=None): + cdef BinaryMatrix equitable_partition(self, BinaryMatrix P=None) noexcept: """ Compute an equitable partition of the columns. """ @@ -1720,7 +1720,7 @@ cdef class TernaryMatrix(LeanMatrix): M[i, j] = self.get(i, j) return M - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: global GF3_zero, GF3_one, GF3_minus_one if not bitset_in(self._M0[r], c): return GF3_zero @@ -1732,7 +1732,7 @@ cdef class TernaryMatrix(LeanMatrix): self.set(r, c, x) return 0 - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef TernaryMatrix T cdef long i T = TernaryMatrix(self._nrows, self._ncols) @@ -1766,7 +1766,7 @@ cdef class TernaryMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix MM): + cdef LeanMatrix stack(self, LeanMatrix MM) noexcept: cdef TernaryMatrix R cdef TernaryMatrix M = MM cdef long i @@ -1776,7 +1776,7 @@ cdef class TernaryMatrix(LeanMatrix): bitset_copy(R._M1[i + self.nrows()], M._M1[i]) return R - cdef LeanMatrix augment(self, LeanMatrix MM): + cdef LeanMatrix augment(self, LeanMatrix MM) noexcept: cdef TernaryMatrix R cdef TernaryMatrix M = MM cdef long i, j @@ -1787,7 +1787,7 @@ cdef class TernaryMatrix(LeanMatrix): bitset_set_to(R._M1[i], self.ncols() + j, bitset_in(M._M1[i], j)) return R - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation """ Return the matrix obtained by prepending an identity matrix. @@ -1801,7 +1801,7 @@ cdef class TernaryMatrix(LeanMatrix): A.set(i, i, 1) return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return GF(3). @@ -1815,7 +1815,7 @@ cdef class TernaryMatrix(LeanMatrix): global GF3 return GF3 - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -1828,7 +1828,7 @@ cdef class TernaryMatrix(LeanMatrix): """ return 3 - cdef inline long get(self, long r, long c): # Not a Sage matrix operation + cdef inline long get(self, long r, long c) noexcept: # Not a Sage matrix operation if not bitset_in(self._M0[r], c): return 0 if not bitset_in(self._M1[r], c): @@ -1850,16 +1850,16 @@ cdef class TernaryMatrix(LeanMatrix): cdef inline bint is_nonzero(self, long r, long c) except -2: # Not a Sage matrix operation return bitset_in(self._M0[r], c) - cdef inline bint _is_negative(self, long r, long c): + cdef inline bint _is_negative(self, long r, long c) noexcept: return bitset_in(self._M1[r], c) - cdef inline long row_len(self, long i): # Not a Sage matrix operation + cdef inline long row_len(self, long i) noexcept: # Not a Sage matrix operation """ Return number of nonzero entries in row ``i``. """ return bitset_len(self._M0[i]) - cdef inline long row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline long row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -1897,7 +1897,7 @@ cdef class TernaryMatrix(LeanMatrix): self.row_subs(x, y) return 0 - cdef void row_subs(self, long x, long y): # Not a Sage matrix operation + cdef void row_subs(self, long x, long y) noexcept: # Not a Sage matrix operation """ Subtract row ``y`` from row ``x``. """ @@ -1908,7 +1908,7 @@ cdef class TernaryMatrix(LeanMatrix): bitset_symmetric_difference(self._s, self._M0[y], self._M1[x]) bitset_intersection(self._M1[x], self._s, self._t) - cdef void _row_negate(self, long x): + cdef void _row_negate(self, long x) noexcept: bitset_symmetric_difference(self._M1[x], self._M1[x], self._M0[x]) cdef int swap_rows_c(self, long x, long y) except -1: @@ -1944,13 +1944,13 @@ cdef class TernaryMatrix(LeanMatrix): self.row_subs(i, x) return 0 - cdef list nonzero_positions_in_row(self, long r): + cdef list nonzero_positions_in_row(self, long r) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ return bitset_list(self._M0[r]) - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -1966,7 +1966,7 @@ cdef class TernaryMatrix(LeanMatrix): j = bitset_next(self._M0[i], j + 1) return T - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -1986,7 +1986,7 @@ cdef class TernaryMatrix(LeanMatrix): M.resize(self._nrows) return M - cdef matrix_from_rows_and_columns_reordered(self, rows, columns): + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept: """ Return a submatrix indexed by indicated rows and columns, as well as the column order of the resulting submatrix. @@ -2298,7 +2298,7 @@ cdef class QuaternaryMatrix(LeanMatrix): M[i, j] = self.get(i, j) return M - cdef inline get(self, long r, long c): # Not a Sage matrix operation + cdef inline get(self, long r, long c) noexcept: # Not a Sage matrix operation if bitset_in(self._M0[r], c): if bitset_in(self._M1[r], c): return self._x_one @@ -2325,7 +2325,7 @@ cdef class QuaternaryMatrix(LeanMatrix): bitset_add(self._M1[r], c) return 0 - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: return self.get(r, c) cdef int set_unsafe(self, long r, long c, x) except -1: @@ -2335,7 +2335,7 @@ cdef class QuaternaryMatrix(LeanMatrix): cdef inline bint is_nonzero(self, long r, long c) except -2: # Not a Sage matrix operation return bitset_in(self._M0[r], c) or bitset_in(self._M1[r], c) - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef QuaternaryMatrix T cdef long i T = QuaternaryMatrix(self._nrows, self._ncols, ring=self._gf4) @@ -2368,7 +2368,7 @@ cdef class QuaternaryMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix MM): + cdef LeanMatrix stack(self, LeanMatrix MM) noexcept: cdef QuaternaryMatrix R cdef QuaternaryMatrix M = MM cdef long i @@ -2378,7 +2378,7 @@ cdef class QuaternaryMatrix(LeanMatrix): bitset_copy(R._M1[i + self.nrows()], M._M1[i]) return R - cdef LeanMatrix augment(self, LeanMatrix MM): + cdef LeanMatrix augment(self, LeanMatrix MM) noexcept: cdef QuaternaryMatrix R cdef QuaternaryMatrix M = MM cdef long i, j @@ -2389,7 +2389,7 @@ cdef class QuaternaryMatrix(LeanMatrix): bitset_set_to(R._M1[i], self.ncols() + j, bitset_in(M._M1[i], j)) return R - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation """ Return the matrix obtained by prepending an identity matrix. Special case of ``augment``. @@ -2402,7 +2402,7 @@ cdef class QuaternaryMatrix(LeanMatrix): A.set(i, i, 1) return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return copy of `GF(4)` with appropriate generator. @@ -2415,7 +2415,7 @@ cdef class QuaternaryMatrix(LeanMatrix): """ return self._gf4 - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -2435,7 +2435,7 @@ cdef class QuaternaryMatrix(LeanMatrix): bitset_union(self._t, self._M0[i], self._M1[i]) return bitset_len(self._t) - cdef inline row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -2527,14 +2527,14 @@ cdef class QuaternaryMatrix(LeanMatrix): self.add_multiple_of_row_c(i, x, self.get(i, y), 0) return 0 - cdef list nonzero_positions_in_row(self, long r): + cdef list nonzero_positions_in_row(self, long r) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ bitset_union(self._t, self._M0[r], self._M1[r]) return bitset_list(self._t) - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -2546,7 +2546,7 @@ cdef class QuaternaryMatrix(LeanMatrix): T.set(i, j, self.get(j, i)) return T - cdef void conjugate(self): # Not a Sage matrix operation + cdef void conjugate(self) noexcept: # Not a Sage matrix operation """ Apply the nontrivial GF(4)-automorphism to the entries. """ @@ -2554,7 +2554,7 @@ cdef class QuaternaryMatrix(LeanMatrix): for i in range(self._nrows): bitset_symmetric_difference(self._M0[i], self._M0[i], self._M1[i]) - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -2570,7 +2570,7 @@ cdef class QuaternaryMatrix(LeanMatrix): M.resize(self._nrows) return M - cdef matrix_from_rows_and_columns_reordered(self, rows, columns): + cdef matrix_from_rows_and_columns_reordered(self, rows, columns) noexcept: """ Return a submatrix indexed by indicated rows and columns, as well as the column order of the resulting submatrix. @@ -2726,7 +2726,7 @@ cdef class QuaternaryMatrix(LeanMatrix): data = (self.nrows(), self.ncols(), ring, versionB, size, limbs, longsize, M0, M1) return sage.matroids.unpickling.unpickle_quaternary_matrix, (version, data) -cpdef GenericMatrix generic_identity(n, ring): +cpdef GenericMatrix generic_identity(n, ring) noexcept: """ Return a GenericMatrix instance containing the `n \times n` identity matrix over ``ring``. @@ -2848,13 +2848,13 @@ cdef class PlusMinusOneMatrix(LeanMatrix): """ return "PlusMinusOneMatrix instance with {} rows and {} columns".format(self._nrows, self._ncols) - cdef inline int get(self, long r, long c): # Not a Sage matrix operation + cdef inline int get(self, long r, long c) noexcept: # Not a Sage matrix operation return self._entries[r * self._ncols + c] - cdef inline void set(self, long r, long c, int x): # Not a Sage matrix operation + cdef inline void set(self, long r, long c, int x) noexcept: # Not a Sage matrix operation self._entries[r * self._ncols + c] = x - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: """ Return a Sage Integer, for safety down the line when dividing. @@ -2883,7 +2883,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): cdef bint is_nonzero(self, long r, long c) except -2: # Not a Sage matrix operation return self.get(r, c) != 0 - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef PlusMinusOneMatrix M = PlusMinusOneMatrix(self._nrows, self._ncols) memcpy(M._entries, self._entries, self._nrows * self._ncols * sizeof(int)) return M @@ -2901,7 +2901,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix M): + cdef LeanMatrix stack(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is an PlusMinusOneMatrix instance of right dimensions! @@ -2912,7 +2912,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): memcpy(A._entries + self._nrows * self._ncols, (M)._entries, M.nrows() * M.ncols() * sizeof(int)) return A - cdef LeanMatrix augment(self, LeanMatrix M): + cdef LeanMatrix augment(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is a PlusMinusOneMatrix instance! """ @@ -2925,7 +2925,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): memcpy(A._entries + (i * A._ncols + self._ncols), (M)._entries + i * Mn, Mn * sizeof(int)) return A - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation cdef PlusMinusOneMatrix A = PlusMinusOneMatrix(self._nrows, self._ncols + self._nrows, ring=self._base_ring) cdef long i for i in range(self._nrows): @@ -2933,7 +2933,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): memcpy(A._entries + (i * A._ncols + self._nrows), self._entries + i * self._ncols, self._ncols * sizeof(int)) return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring of ``self``. @@ -2946,7 +2946,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): """ return ZZ - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -2970,7 +2970,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): res += 1 return res - cdef inline row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -3055,7 +3055,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): self.add_multiple_of_row_c(i, x, -s, 0) return 0 - cdef list nonzero_positions_in_row(self, long r): + cdef list nonzero_positions_in_row(self, long r) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ @@ -3066,7 +3066,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): res.append(j - r * self._ncols) return res - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -3078,7 +3078,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): A.set(j, i, self.get(i, j)) return A - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -3095,7 +3095,7 @@ cdef class PlusMinusOneMatrix(LeanMatrix): A.set(i, j, s) return A - cdef list gauss_jordan_reduce(self, columns): # Not a Sage matrix operation + cdef list gauss_jordan_reduce(self, columns) noexcept: # Not a Sage matrix operation """ Row-reduce so the lexicographically first basis indexes an identity submatrix. @@ -3295,13 +3295,13 @@ cdef class RationalMatrix(LeanMatrix): """ return "RationalMatrix instance with {} rows and {} columns".format(self._nrows, self._ncols) - cdef inline long index(self, long r, long c): # Not a Sage matrix operation + cdef inline long index(self, long r, long c) noexcept: # Not a Sage matrix operation return r * self._ncols + c - cdef inline void set(self, long r, long c, mpq_t x): # Not a Sage matrix operation + cdef inline void set(self, long r, long c, mpq_t x) noexcept: # Not a Sage matrix operation mpq_set(self._entries[r * self._ncols + c], x) - cdef get_unsafe(self, long r, long c): + cdef get_unsafe(self, long r, long c) noexcept: """ Return a Sage Integer, for safety down the line when dividing. @@ -3332,7 +3332,7 @@ cdef class RationalMatrix(LeanMatrix): cdef bint is_nonzero(self, long r, long c) except -2: # Not a Sage matrix operation return mpq_sgn(self._entries[self.index(r, c)]) != 0 - cdef LeanMatrix copy(self): # Deprecated Sage matrix operation + cdef LeanMatrix copy(self) noexcept: # Deprecated Sage matrix operation cdef RationalMatrix M = RationalMatrix(self._nrows, self._ncols) cdef long i for i in range(self._nrows * self._ncols): @@ -3358,7 +3358,7 @@ cdef class RationalMatrix(LeanMatrix): self._nrows = k return 0 - cdef LeanMatrix stack(self, LeanMatrix M): + cdef LeanMatrix stack(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is an RationalMatrix instance of right dimensions! @@ -3373,7 +3373,7 @@ cdef class RationalMatrix(LeanMatrix): mpq_set(A._entries[l+i], (M)._entries[i]) return A - cdef LeanMatrix augment(self, LeanMatrix M): + cdef LeanMatrix augment(self, LeanMatrix M) noexcept: """ Warning: assumes ``M`` is a RationalMatrix instance! """ @@ -3387,7 +3387,7 @@ cdef class RationalMatrix(LeanMatrix): mpq_set(A._entries[i*A._ncols + self._ncols + j], (M)._entries[i*Mn + j]) return A - cdef LeanMatrix prepend_identity(self): # Not a Sage matrix operation + cdef LeanMatrix prepend_identity(self) noexcept: # Not a Sage matrix operation cdef RationalMatrix A = RationalMatrix(self._nrows, self._ncols + self._nrows) cdef long i, j for i in range(self._nrows): @@ -3396,7 +3396,7 @@ cdef class RationalMatrix(LeanMatrix): mpq_set(A._entries[A.index(i,self._nrows+j)], self._entries[self.index(i,j)]) return A - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring of ``self``. @@ -3409,7 +3409,7 @@ cdef class RationalMatrix(LeanMatrix): """ return QQ - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of ``self.base_ring()``. @@ -3433,7 +3433,7 @@ cdef class RationalMatrix(LeanMatrix): res += 1 return res - cdef inline row_inner_product(self, long i, long j): # Not a Sage matrix operation + cdef inline row_inner_product(self, long i, long j) noexcept: # Not a Sage matrix operation """ Return the inner product between rows ``i`` and ``j``. """ @@ -3542,7 +3542,7 @@ cdef class RationalMatrix(LeanMatrix): mpq_clear(t) return 0 - cdef list nonzero_positions_in_row(self, long r): + cdef list nonzero_positions_in_row(self, long r) noexcept: """ Get coordinates of nonzero entries of row ``r``. """ @@ -3553,7 +3553,7 @@ cdef class RationalMatrix(LeanMatrix): res.append(j - r * self._ncols) return res - cdef LeanMatrix transpose(self): + cdef LeanMatrix transpose(self) noexcept: """ Return the transpose of the matrix. """ @@ -3565,7 +3565,7 @@ cdef class RationalMatrix(LeanMatrix): A.set(j, i, self._entries[self.index(i, j)]) return A - cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other): + cdef LeanMatrix _matrix_times_matrix_(self, LeanMatrix other) noexcept: """ Return the product ``self * other``. """ @@ -3585,7 +3585,7 @@ cdef class RationalMatrix(LeanMatrix): mpq_clear(s) return A - cdef list gauss_jordan_reduce(self, columns): # Not a Sage matrix operation + cdef list gauss_jordan_reduce(self, columns) noexcept: # Not a Sage matrix operation """ Row-reduce so the lexicographically first basis indexes an identity submatrix. diff --git a/src/sage/matroids/linear_matroid.pxd b/src/sage/matroids/linear_matroid.pxd index 9aebd446b68..663886fa58e 100644 --- a/src/sage/matroids/linear_matroid.pxd +++ b/src/sage/matroids/linear_matroid.pxd @@ -10,87 +10,87 @@ cdef class LinearMatroid(BasisExchangeMatroid): cdef long *_prow cdef object _zero, _one - cpdef _forget(self) - cpdef base_ring(self) - cpdef characteristic(self) - - cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation) - cdef _exchange_value_internal(self, long x, long y) - - cpdef representation(self, B=*, reduced=*, labels=*, order=*, lift_map=*) - cpdef _current_rows_cols(self, B=*) - cpdef representation_vectors(self) - cpdef LeanMatrix _basic_representation(self, B=*) - cpdef LeanMatrix _reduced_representation(self, B=*) - - cpdef bint _is_field_isomorphism(self, LinearMatroid other, morphism) - cpdef is_field_equivalent(self, other) - cpdef is_field_isomorphism(self, other, morphism) + cpdef _forget(self) noexcept + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept + + cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation) noexcept + cdef _exchange_value_internal(self, long x, long y) noexcept + + cpdef representation(self, B=*, reduced=*, labels=*, order=*, lift_map=*) noexcept + cpdef _current_rows_cols(self, B=*) noexcept + cpdef representation_vectors(self) noexcept + cpdef LeanMatrix _basic_representation(self, B=*) noexcept + cpdef LeanMatrix _reduced_representation(self, B=*) noexcept + + cpdef bint _is_field_isomorphism(self, LinearMatroid other, morphism) noexcept + cpdef is_field_equivalent(self, other) noexcept + cpdef is_field_isomorphism(self, other, morphism) noexcept # cpdef is_field_isomorphic(self, other) # TODO: currently only works as ``def`` - cpdef _fast_isom_test(self, other) - - cpdef _minor(self, contractions, deletions) - cpdef dual(self) - cpdef has_line_minor(self, k, hyperlines=*, certificate=*) - cpdef has_field_minor(self, N) - - cpdef _exchange_value(self, e, f) - cpdef fundamental_cycle(self, B, e) - cpdef fundamental_cocycle(self, B, e) - - cpdef _line_ratios(self, F) - cpdef _line_length(self, F) - - cpdef _line_cross_ratios(self, F) - cpdef cross_ratios(self, hyperlines=*) - cpdef cross_ratio(self, F, a, b, c, d) - cpdef _line_cross_ratio_test(self, F, x, fundamentals) - cpdef _cross_ratio_test(self, x, fundamentals, hyperlines=*) - - cpdef linear_extension(self, element, chain=*, col=*) - cpdef linear_coextension(self, element, cochain=*, row=*) - cpdef _linear_extensions(self, element, chains) - cpdef _linear_coextensions(self, element, cochains) - cdef _extend_chains(self, C, f, fundamentals=*) - cpdef _linear_extension_chains(self, F, fundamentals=*) - cpdef linear_extension_chains(self, F=*, simple=*, fundamentals=*) - cpdef linear_coextension_cochains(self, F=*, cosimple=*, fundamentals=*) - cpdef linear_extensions(self, element=*, F=*, simple=*, fundamentals=*) - cpdef linear_coextensions(self, element=*, F=*, cosimple=*, fundamentals=*) - - cpdef _is_3connected_shifting(self, certificate=*) - cpdef _is_4connected_shifting(self, certificate=*) - - cpdef is_valid(self) + cpdef _fast_isom_test(self, other) noexcept + + cpdef _minor(self, contractions, deletions) noexcept + cpdef dual(self) noexcept + cpdef has_line_minor(self, k, hyperlines=*, certificate=*) noexcept + cpdef has_field_minor(self, N) noexcept + + cpdef _exchange_value(self, e, f) noexcept + cpdef fundamental_cycle(self, B, e) noexcept + cpdef fundamental_cocycle(self, B, e) noexcept + + cpdef _line_ratios(self, F) noexcept + cpdef _line_length(self, F) noexcept + + cpdef _line_cross_ratios(self, F) noexcept + cpdef cross_ratios(self, hyperlines=*) noexcept + cpdef cross_ratio(self, F, a, b, c, d) noexcept + cpdef _line_cross_ratio_test(self, F, x, fundamentals) noexcept + cpdef _cross_ratio_test(self, x, fundamentals, hyperlines=*) noexcept + + cpdef linear_extension(self, element, chain=*, col=*) noexcept + cpdef linear_coextension(self, element, cochain=*, row=*) noexcept + cpdef _linear_extensions(self, element, chains) noexcept + cpdef _linear_coextensions(self, element, cochains) noexcept + cdef _extend_chains(self, C, f, fundamentals=*) noexcept + cpdef _linear_extension_chains(self, F, fundamentals=*) noexcept + cpdef linear_extension_chains(self, F=*, simple=*, fundamentals=*) noexcept + cpdef linear_coextension_cochains(self, F=*, cosimple=*, fundamentals=*) noexcept + cpdef linear_extensions(self, element=*, F=*, simple=*, fundamentals=*) noexcept + cpdef linear_coextensions(self, element=*, F=*, cosimple=*, fundamentals=*) noexcept + + cpdef _is_3connected_shifting(self, certificate=*) noexcept + cpdef _is_4connected_shifting(self, certificate=*) noexcept + + cpdef is_valid(self) noexcept cdef class BinaryMatroid(LinearMatroid): cdef tuple _b_invariant, _b_partition cdef BinaryMatrix _b_projection, _eq_part - cpdef base_ring(self) - cpdef characteristic(self) + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept - cpdef _current_rows_cols(self, B=*) - cpdef LeanMatrix _basic_representation(self, B=*) - cpdef LeanMatrix _reduced_representation(self, B=*) + cpdef _current_rows_cols(self, B=*) noexcept + cpdef LeanMatrix _basic_representation(self, B=*) noexcept + cpdef LeanMatrix _reduced_representation(self, B=*) noexcept - cdef __fundamental_cocircuit(self, bitset_t, long x) + cdef __fundamental_cocircuit(self, bitset_t, long x) noexcept - cpdef _is_isomorphic(self, other, certificate=*) + cpdef _is_isomorphic(self, other, certificate=*) noexcept - cpdef _minor(self, contractions, deletions) + cpdef _minor(self, contractions, deletions) noexcept - cpdef _make_invariant(self) - cpdef _invariant(self) - cpdef bicycle_dimension(self) - cpdef brown_invariant(self) - cpdef _principal_tripartition(self) - cpdef BinaryMatrix _projection(self) - cpdef BinaryMatrix _projection_partition(self) - cpdef _fast_isom_test(self, other) + cpdef _make_invariant(self) noexcept + cpdef _invariant(self) noexcept + cpdef bicycle_dimension(self) noexcept + cpdef brown_invariant(self) noexcept + cpdef _principal_tripartition(self) noexcept + cpdef BinaryMatrix _projection(self) noexcept + cpdef BinaryMatrix _projection_partition(self) noexcept + cpdef _fast_isom_test(self, other) noexcept - cpdef is_graphic(self) - cpdef is_valid(self) + cpdef is_graphic(self) noexcept + cpdef is_valid(self) noexcept cdef class TernaryMatroid(LinearMatroid): @@ -98,74 +98,74 @@ cdef class TernaryMatroid(LinearMatroid): cdef tuple _t_invariant, _t_partition cdef TernaryMatrix _t_projection - cpdef base_ring(self) - cpdef characteristic(self) + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept - cpdef _current_rows_cols(self, B=*) - cpdef LeanMatrix _basic_representation(self, B=*) - cpdef LeanMatrix _reduced_representation(self, B=*) + cpdef _current_rows_cols(self, B=*) noexcept + cpdef LeanMatrix _basic_representation(self, B=*) noexcept + cpdef LeanMatrix _reduced_representation(self, B=*) noexcept - cdef __fundamental_cocircuit(self, bitset_t, long x) + cdef __fundamental_cocircuit(self, bitset_t, long x) noexcept - cpdef _is_isomorphic(self, other, certificate=*) + cpdef _is_isomorphic(self, other, certificate=*) noexcept - cpdef _minor(self, contractions, deletions) + cpdef _minor(self, contractions, deletions) noexcept - cpdef _make_invariant(self) - cpdef _invariant(self) - cpdef bicycle_dimension(self) - cpdef character(self) - cpdef _principal_quadripartition(self) - cpdef TernaryMatrix _projection(self) - cpdef _fast_isom_test(self, other) + cpdef _make_invariant(self) noexcept + cpdef _invariant(self) noexcept + cpdef bicycle_dimension(self) noexcept + cpdef character(self) noexcept + cpdef _principal_quadripartition(self) noexcept + cpdef TernaryMatrix _projection(self) noexcept + cpdef _fast_isom_test(self, other) noexcept - cpdef is_valid(self) + cpdef is_valid(self) noexcept cdef class QuaternaryMatroid(LinearMatroid): cdef object _x_zero, _x_one cdef tuple _q_invariant, _q_partition cdef QuaternaryMatrix _q_projection - cpdef base_ring(self) - cpdef characteristic(self) + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept - cpdef _current_rows_cols(self, B=*) - cpdef LeanMatrix _basic_representation(self, B=*) - cpdef LeanMatrix _reduced_representation(self, B=*) + cpdef _current_rows_cols(self, B=*) noexcept + cpdef LeanMatrix _basic_representation(self, B=*) noexcept + cpdef LeanMatrix _reduced_representation(self, B=*) noexcept - cdef __fundamental_cocircuit(self, bitset_t, long x) + cdef __fundamental_cocircuit(self, bitset_t, long x) noexcept - cpdef _is_isomorphic(self, other, certificate=*) + cpdef _is_isomorphic(self, other, certificate=*) noexcept - cpdef _minor(self, contractions, deletions) + cpdef _minor(self, contractions, deletions) noexcept - cpdef _make_invariant(self) - cpdef _invariant(self) - cpdef bicycle_dimension(self) - cpdef _principal_tripartition(self) - cpdef _fast_isom_test(self, other) + cpdef _make_invariant(self) noexcept + cpdef _invariant(self) noexcept + cpdef bicycle_dimension(self) noexcept + cpdef _principal_tripartition(self) noexcept + cpdef _fast_isom_test(self, other) noexcept - cpdef is_valid(self) + cpdef is_valid(self) noexcept cdef class RegularMatroid(LinearMatroid): cdef _bases_count, _r_invariant cdef _r_projection, _r_hypergraph cdef _hypergraph_vertex_partition, _hypergraph_tuples - cpdef base_ring(self) - cpdef characteristic(self) + cpdef base_ring(self) noexcept + cpdef characteristic(self) noexcept - cpdef _is_isomorphic(self, other, certificate=*) + cpdef _is_isomorphic(self, other, certificate=*) noexcept - cpdef _invariant(self) - cpdef _fast_isom_test(self, other) + cpdef _invariant(self) noexcept + cpdef _fast_isom_test(self, other) noexcept - cpdef bases_count(self) - cpdef _projection(self) - cpdef _hypergraph(self) - cdef _hypertest(self, other) - cpdef has_line_minor(self, k, hyperlines=*, certificate=*) - cpdef _linear_extension_chains(self, F, fundamentals=*) + cpdef bases_count(self) noexcept + cpdef _projection(self) noexcept + cpdef _hypergraph(self) noexcept + cdef _hypertest(self, other) noexcept + cpdef has_line_minor(self, k, hyperlines=*, certificate=*) noexcept + cpdef _linear_extension_chains(self, F, fundamentals=*) noexcept - cpdef is_graphic(self) - cpdef is_valid(self) + cpdef is_graphic(self) noexcept + cpdef is_valid(self) noexcept diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index 5b434dcac98..81a9f9e5a89 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -148,10 +148,10 @@ cdef GF3, GF3_one, GF3_zero, GF3_minus_one # provide alternative implementations # Below is some code, commented out currently, to get you going. -cdef inline gauss_jordan_reduce(LeanMatrix A, columns): +cdef inline gauss_jordan_reduce(LeanMatrix A, columns) noexcept: return A.gauss_jordan_reduce(columns) # Not a Sage matrix operation -cdef inline characteristic(LeanMatrix A): +cdef inline characteristic(LeanMatrix A) noexcept: return A.characteristic() # Not a Sage matrix operation # Implementation using default Sage matrices @@ -297,7 +297,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): sig_free(self._prow) self._prow = NULL - cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation): + cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation) noexcept: """ Setup the internal representation matrix ``self._A`` and the array of row- and column indices ``self._prow``. @@ -345,7 +345,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): self._prow[self._A.nrows() + r] = r return P - cpdef _forget(self): + cpdef _forget(self) noexcept: """ Remove the internal representation matrix. @@ -364,7 +364,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): """ self._representation = None - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring of the matrix representing the matroid. @@ -377,7 +377,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): """ return self._A.base_ring() - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of the base ring of the matrix representing the matroid. @@ -422,7 +422,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): self._prow[x] = py BasisExchangeMatroid._exchange(self, x, y) - cdef _exchange_value_internal(self, long x, long y): + cdef _exchange_value_internal(self, long x, long y) noexcept: r""" Return the (x, y) entry of the current representation. """ @@ -471,7 +471,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): # representations - cpdef representation(self, B=None, reduced=False, labels=None, order=None, lift_map=None): + cpdef representation(self, B=None, reduced=False, labels=None, order=None, lift_map=None) noexcept: r""" Return a matrix representing the matroid. @@ -649,7 +649,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): else: return lift_cross_ratios(A._matrix_(), lift_map) - cpdef _current_rows_cols(self, B=None): + cpdef _current_rows_cols(self, B=None) noexcept: """ Return the current row and column labels of a reduced matrix. @@ -688,7 +688,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): cols[self._prow[self._idx[e]]] = e return rows, cols - cpdef LeanMatrix _basic_representation(self, B=None): + cpdef LeanMatrix _basic_representation(self, B=None) noexcept: """ Return a basic matrix representation of the matroid. @@ -737,7 +737,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): i += 1 return A - cpdef representation_vectors(self): + cpdef representation_vectors(self) noexcept: """ Return a dictionary that associates a column vector with each element of the matroid. @@ -757,7 +757,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): R = self._matrix_().columns() return {e: R[self._idx[e]] for e in self.groundset()} - cpdef LeanMatrix _reduced_representation(self, B=None): + cpdef LeanMatrix _reduced_representation(self, B=None) noexcept: r""" Return a reduced representation of the matroid, i.e. a matrix `R` such that `[I\ \ R]` represents the matroid. @@ -796,7 +796,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): # (field) isomorphism - cpdef bint _is_field_isomorphism(self, LinearMatroid other, morphism): # not safe if self == other + cpdef bint _is_field_isomorphism(self, LinearMatroid other, morphism) noexcept: # not safe if self == other r""" Version of :meth:`` that does no type checking. @@ -879,7 +879,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): normalization[N.pop()] = self._one return True - cpdef is_field_equivalent(self, other): + cpdef is_field_equivalent(self, other) noexcept: """ Test for matroid representation equality. @@ -966,7 +966,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): morphism = {e: e for e in self.groundset()} return self._is_field_isomorphism(other, morphism) - cpdef is_field_isomorphism(self, other, morphism): + cpdef is_field_isomorphism(self, other, morphism) noexcept: r""" Test if a provided morphism induces a bijection between represented matroids. @@ -1052,7 +1052,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): else: return self._is_field_isomorphism(copy(other), mf) - cpdef _fast_isom_test(self, other): + cpdef _fast_isom_test(self, other) noexcept: """ Fast (field) isomorphism test for some subclasses. @@ -1278,7 +1278,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): # minors, dual - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: r""" Return a minor. @@ -1322,7 +1322,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): M.set_unsafe(i, j, self._exchange_value(rows[i], cols[j])) return type(self)(reduced_matrix=M, groundset=rows + cols) - cpdef dual(self): + cpdef dual(self) noexcept: r""" Return the dual of the matroid. @@ -1354,7 +1354,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): rows, cols = self._current_rows_cols() return type(self)(reduced_matrix=R, groundset=cols + rows) - cpdef has_line_minor(self, k, hyperlines=None, certificate=False): + cpdef has_line_minor(self, k, hyperlines=None, certificate=False) noexcept: r""" Test if the matroid has a `U_{2, k}`-minor. @@ -1409,7 +1409,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): pass return Matroid.has_line_minor(self, k, hyperlines, certificate) - cpdef has_field_minor(self, N): + cpdef has_field_minor(self, N) noexcept: """ Check if ``self`` has a minor field isomorphic to ``N``. @@ -1467,7 +1467,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): # cycles, cocycles and cross ratios - cpdef _exchange_value(self, e, f): + cpdef _exchange_value(self, e, f) noexcept: """ Return the matrix entry indexed by row `e` and column `f`. @@ -1495,7 +1495,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): """ return self._exchange_value_internal(self._idx[e], self._idx[f]) - cpdef fundamental_cycle(self, B, e): + cpdef fundamental_cycle(self, B, e) noexcept: """ Return the fundamental cycle, relative to ``B``, containing element ``e``. @@ -1541,7 +1541,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): chain[f] = -x return chain - cpdef fundamental_cocycle(self, B, e): + cpdef fundamental_cocycle(self, B, e) noexcept: """ Return the fundamental cycle, relative to ``B``, containing element ``e``. @@ -1586,7 +1586,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): cochain[f] = x return cochain - cpdef _line_ratios(self, F): + cpdef _line_ratios(self, F) noexcept: """ Return the set of nonzero ratios of column entries after contracting a rank-`r-2` flat ``F``. @@ -1617,7 +1617,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): rat.add(s * (t ** (-1))) return rat - cpdef _line_length(self, F): + cpdef _line_length(self, F) noexcept: """ Return ``len(M.contract(F).simplify())``, where ``F`` is assumed to be a flat of rank 2 less than the matroid. @@ -1637,7 +1637,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): """ return 2 + len(self._line_ratios(F)) - cpdef _line_cross_ratios(self, F): + cpdef _line_cross_ratios(self, F) noexcept: """ Return the set of cross ratios of column entries after contracting a rank-`r-2` flat ``F``. @@ -1665,7 +1665,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): cr.add(r2 / r1) return cr - cpdef cross_ratios(self, hyperlines=None): + cpdef cross_ratios(self, hyperlines=None) noexcept: r""" Return the set of cross ratios that occur in this linear matroid. @@ -1723,7 +1723,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): CR.difference_update(asc) return CR2 - cpdef cross_ratio(self, F, a, b, c, d): + cpdef cross_ratio(self, F, a, b, c, d) noexcept: r""" Return the cross ratio of the four ordered points ``a, b, c, d`` after contracting a flat ``F`` of codimension 2. @@ -1781,7 +1781,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): raise ValueError("points a, b, c, d do not form a 4-point line in M/F") return cr1 / cr2 - cpdef _line_cross_ratio_test(self, F, x, fundamentals): + cpdef _line_cross_ratio_test(self, F, x, fundamentals) noexcept: r""" Check whether the cross ratios involving a fixed element in a fixed rank-2 minor are in a specified subset. @@ -1841,7 +1841,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): return False return True - cpdef _cross_ratio_test(self, x, fundamentals, hyperlines=None): + cpdef _cross_ratio_test(self, x, fundamentals, hyperlines=None) noexcept: r""" Test if the cross ratios using a given element of this linear matroid are contained in a given set of fundamentals. @@ -1890,7 +1890,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): return True # linear extension - cpdef linear_extension(self, element, chain=None, col=None): + cpdef linear_extension(self, element, chain=None, col=None) noexcept: r""" Return a linear extension of this matroid. @@ -1959,7 +1959,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): raise TypeError("chain argument needs to be a dictionary") return self._linear_extensions(element, [chain])[0] - cpdef linear_coextension(self, element, cochain=None, row=None): + cpdef linear_coextension(self, element, cochain=None, row=None) noexcept: r""" Return a linear coextension of this matroid. @@ -2060,7 +2060,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): raise TypeError("cochain argument needs to be a dictionary") return self._linear_coextensions(element, [cochain])[0] - cpdef _linear_extensions(self, element, chains): + cpdef _linear_extensions(self, element, chains) noexcept: r""" Return the linear extensions of this matroid representation specified by the given chains. @@ -2108,7 +2108,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): ext.append(type(self)(matrix=M, groundset=E)) return ext - cpdef _linear_coextensions(self, element, cochains): + cpdef _linear_coextensions(self, element, cochains) noexcept: r""" Return the linear coextensions of this matroid representation specified by the given cochains. @@ -2156,7 +2156,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): coext.append(type(self)(matrix=M, groundset=E)) return coext - cdef _extend_chains(self, C, f, fundamentals=None): + cdef _extend_chains(self, C, f, fundamentals=None) noexcept: r""" Extend a list of chains for ``self / f`` to a list of chains for ``self``. @@ -2218,7 +2218,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): res = [chain for chain in res if len(chain) < 2 or self._linear_extensions(ne, [chain])[0]._cross_ratio_test(ne, fundamentals, hyperlines)] return res - cpdef _linear_extension_chains(self, F, fundamentals=None): # assumes independent F + cpdef _linear_extension_chains(self, F, fundamentals=None) noexcept: # assumes independent F r""" Create a list of chains that determine single-element extensions of this linear matroid representation. @@ -2294,7 +2294,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): chains = new_chains return chains - cpdef linear_extension_chains(self, F=None, simple=False, fundamentals=None): + cpdef linear_extension_chains(self, F=None, simple=False, fundamentals=None) noexcept: r""" Create a list of chains that determine the single-element extensions of this linear matroid representation. @@ -2393,7 +2393,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): chains = simple_chains return chains - cpdef linear_coextension_cochains(self, F=None, cosimple=False, fundamentals=None): + cpdef linear_coextension_cochains(self, F=None, cosimple=False, fundamentals=None) noexcept: r""" Create a list of cochains that determine the single-element coextensions of this linear matroid representation. @@ -2451,7 +2451,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): """ return self.dual().linear_extension_chains(F=F, simple=cosimple, fundamentals=fundamentals) - cpdef linear_extensions(self, element=None, F=None, simple=False, fundamentals=None): + cpdef linear_extensions(self, element=None, F=None, simple=False, fundamentals=None) noexcept: r""" Create a list of linear matroids represented by rank-preserving single-element extensions of this linear matroid representation. @@ -2519,7 +2519,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): chains = self.linear_extension_chains(F, simple=simple, fundamentals=fundamentals) return self._linear_extensions(element, chains) - cpdef linear_coextensions(self, element=None, F=None, cosimple=False, fundamentals=None): + cpdef linear_coextensions(self, element=None, F=None, cosimple=False, fundamentals=None) noexcept: r""" Create a list of linear matroids represented by corank-preserving single-element coextensions of this linear matroid representation. @@ -2590,7 +2590,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): cochains = self.linear_coextension_cochains(F, cosimple=cosimple, fundamentals=fundamentals) return self._linear_coextensions(element, cochains) - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data represent an actual matroid. @@ -2641,7 +2641,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): # connectivity - cpdef _is_3connected_shifting(self, certificate=False): + cpdef _is_3connected_shifting(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 4-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -2720,7 +2720,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): return True, None return True - cpdef _is_4connected_shifting(self, certificate=False): + cpdef _is_4connected_shifting(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 4-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -3125,7 +3125,7 @@ cdef class BinaryMatroid(LinearMatroid): self._zero = GF2_zero self._one = GF2_one - cpdef base_ring(self): + cpdef base_ring(self) noexcept: r""" Return the base ring of the matrix representing the matroid, in this case `\GF{2}`. @@ -3139,7 +3139,7 @@ cdef class BinaryMatroid(LinearMatroid): global GF2 return GF2 - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of the base ring of the matrix representing the matroid, in this case `2`. @@ -3167,13 +3167,13 @@ cdef class BinaryMatroid(LinearMatroid): self._prow[y] = p BasisExchangeMatroid._exchange(self, x, y) - cdef __fundamental_cocircuit(self, bitset_t C, long x): + cdef __fundamental_cocircuit(self, bitset_t C, long x) noexcept: r""" Fill bitset `C` with the incidence vector of the `B`-fundamental cocircuit using ``x``. Internal method using packed elements. """ bitset_copy(C, (self._A)._M[self._prow[x]]) - cdef _coclosure_internal(self, bitset_t R, bitset_t F): + cdef _coclosure_internal(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``coclosure``. @@ -3196,7 +3196,7 @@ cdef class BinaryMatroid(LinearMatroid): bitset_add(R, y) y = bitset_next(self._inside, y + 1) - cdef _exchange_value_internal(self, long x, long y): + cdef _exchange_value_internal(self, long x, long y) noexcept: r""" Return the (x, y) entry of the current representation. """ @@ -3222,7 +3222,7 @@ cdef class BinaryMatroid(LinearMatroid): S = "Binary matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements, type (" + str(self.bicycle_dimension()) + ', ' + str(self.brown_invariant()) + ')' return S - cpdef _current_rows_cols(self, B=None): + cpdef _current_rows_cols(self, B=None) noexcept: """ Return the current row and column labels of a reduced matrix. @@ -3264,7 +3264,7 @@ cdef class BinaryMatroid(LinearMatroid): c += 1 return rows, cols - cpdef LeanMatrix _basic_representation(self, B=None): + cpdef LeanMatrix _basic_representation(self, B=None) noexcept: """ Return a basic matrix representation of the matroid. @@ -3303,7 +3303,7 @@ cdef class BinaryMatroid(LinearMatroid): self._move_current_basis(B, set()) return self._A.copy() # Deprecated Sage matrix operation - cpdef LeanMatrix _reduced_representation(self, B=None): + cpdef LeanMatrix _reduced_representation(self, B=None) noexcept: r""" Return a reduced representation of the matroid, i.e. a matrix `R` such that `[I\ \ R]` represents the matroid. @@ -3345,7 +3345,7 @@ cdef class BinaryMatroid(LinearMatroid): # isomorphism - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. @@ -3394,7 +3394,7 @@ cdef class BinaryMatroid(LinearMatroid): else: return LinearMatroid._is_isomorphic(self, other) - cpdef _is_isomorphism(self, other, morphism): + cpdef _is_isomorphism(self, other, morphism) noexcept: r""" Test if a given bijection is an isomorphism. @@ -3425,7 +3425,7 @@ cdef class BinaryMatroid(LinearMatroid): return LinearMatroid._is_isomorphism(self, other, morphism) # invariants - cpdef _make_invariant(self): + cpdef _make_invariant(self) noexcept: """ Create an invariant. @@ -3515,7 +3515,7 @@ cdef class BinaryMatroid(LinearMatroid): self._b_invariant = tuple([d, b2, len(Fm), len(F0), len(Fp), p[0], p[1], p[2]]) self._b_partition = tuple([Fm, F0, Fp]) - cpdef _invariant(self): + cpdef _invariant(self) noexcept: r""" Return a matroid invariant. @@ -3544,7 +3544,7 @@ cdef class BinaryMatroid(LinearMatroid): self._make_invariant() return self._b_invariant - cpdef bicycle_dimension(self): + cpdef bicycle_dimension(self) noexcept: r""" Return the bicycle dimension of the binary matroid. @@ -3567,7 +3567,7 @@ cdef class BinaryMatroid(LinearMatroid): self._make_invariant() return self._b_invariant[0] - cpdef brown_invariant(self): + cpdef brown_invariant(self) noexcept: r""" Return the value of Brown's invariant for the binary matroid. @@ -3604,7 +3604,7 @@ cdef class BinaryMatroid(LinearMatroid): self._make_invariant() return self._b_invariant[1] - cpdef _principal_tripartition(self): + cpdef _principal_tripartition(self) noexcept: r""" Return the principal tripartition of the binary matroid. @@ -3642,7 +3642,7 @@ cdef class BinaryMatroid(LinearMatroid): P = self._b_partition return frozenset([self._E[e] for e in P[0]]), frozenset([self._E[e] for e in P[1]]), frozenset([self._E[e] for e in P[2]]) - cpdef BinaryMatrix _projection(self): + cpdef BinaryMatrix _projection(self) noexcept: """ Return the projection matrix onto the row space. @@ -3684,7 +3684,7 @@ cdef class BinaryMatroid(LinearMatroid): self._make_invariant() return self._b_projection - cpdef BinaryMatrix _projection_partition(self): + cpdef BinaryMatrix _projection_partition(self) noexcept: """ Return the equitable partition of the graph whose incidence matrix is the projection matrix of this matroid. @@ -3716,7 +3716,7 @@ cdef class BinaryMatroid(LinearMatroid): self._eq_part = self._b_projection.equitable_partition() # Not a Sage matrix operation return self._eq_part - cpdef _fast_isom_test(self, other): + cpdef _fast_isom_test(self, other) noexcept: r""" Run a quick test to see if two binary matroids are isomorphic. @@ -3750,7 +3750,7 @@ cdef class BinaryMatroid(LinearMatroid): # minors, dual - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: r""" Return a minor. @@ -3793,7 +3793,7 @@ cdef class BinaryMatroid(LinearMatroid): keep_initial_representation=False) # graphicness test - cpdef is_graphic(self): + cpdef is_graphic(self) noexcept: """ Test if the binary matroid is graphic. @@ -3864,7 +3864,7 @@ cdef class BinaryMatroid(LinearMatroid): # now self is graphic iff there is a binary vector x so that M*x = 0 and x_0 = 1, so: return BinaryMatroid(m).corank(frozenset([0])) > 0 - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -3885,7 +3885,7 @@ cdef class BinaryMatroid(LinearMatroid): # representability - cpdef binary_matroid(self, randomized_tests=1, verify = True): + cpdef binary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a binary matroid representing ``self``. @@ -3915,7 +3915,7 @@ cdef class BinaryMatroid(LinearMatroid): """ return self - cpdef is_binary(self, randomized_tests=1): + cpdef is_binary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a binary matroid. @@ -4193,7 +4193,7 @@ cdef class TernaryMatroid(LinearMatroid): self._one = GF3_one self._two = GF3_minus_one - cpdef base_ring(self): + cpdef base_ring(self) noexcept: r""" Return the base ring of the matrix representing the matroid, in this case `\GF{3}`. @@ -4207,7 +4207,7 @@ cdef class TernaryMatroid(LinearMatroid): global GF3 return GF3 - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of the base ring of the matrix representing the matroid, in this case `3`. @@ -4235,13 +4235,13 @@ cdef class TernaryMatroid(LinearMatroid): self._prow[y] = p BasisExchangeMatroid._exchange(self, x, y) - cdef __fundamental_cocircuit(self, bitset_t C, long x): + cdef __fundamental_cocircuit(self, bitset_t C, long x) noexcept: r""" Fill bitset `C` with the incidence vector of the `B`-fundamental cocircuit using ``x``. Internal method using packed elements. """ bitset_copy(C, (self._A)._M0[self._prow[x]]) - cdef _coclosure_internal(self, bitset_t R, bitset_t F): + cdef _coclosure_internal(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``coclosure``. @@ -4264,7 +4264,7 @@ cdef class TernaryMatroid(LinearMatroid): bitset_add(R, y) y = bitset_next(self._inside, y + 1) - cdef _exchange_value_internal(self, long x, long y): + cdef _exchange_value_internal(self, long x, long y) noexcept: r""" Return the (x, y) entry of the current representation. """ @@ -4296,7 +4296,7 @@ cdef class TernaryMatroid(LinearMatroid): S = S + '-' return S - cpdef _current_rows_cols(self, B=None): + cpdef _current_rows_cols(self, B=None) noexcept: """ Return the current row and column labels of a reduced matrix. @@ -4338,7 +4338,7 @@ cdef class TernaryMatroid(LinearMatroid): c += 1 return rows, cols - cpdef LeanMatrix _basic_representation(self, B=None): + cpdef LeanMatrix _basic_representation(self, B=None) noexcept: """ Return a basic matrix representation of the matroid. @@ -4377,7 +4377,7 @@ cdef class TernaryMatroid(LinearMatroid): self._move_current_basis(B, set()) return self._A.copy() # Deprecated Sage matrix operation - cpdef LeanMatrix _reduced_representation(self, B=None): + cpdef LeanMatrix _reduced_representation(self, B=None) noexcept: r""" Return a reduced representation of the matroid, i.e. a matrix `R` such that `[I\ \ R]` represents the matroid. @@ -4419,7 +4419,7 @@ cdef class TernaryMatroid(LinearMatroid): # isomorphism - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. Internal version that performs no checks on input. @@ -4458,7 +4458,7 @@ cdef class TernaryMatroid(LinearMatroid): # invariants - cpdef _make_invariant(self): + cpdef _make_invariant(self) noexcept: """ Create an invariant. @@ -4530,7 +4530,7 @@ cdef class TernaryMatroid(LinearMatroid): self._t_partition = tuple([F, Fa, Fb, Fc]) self._t_invariant = tuple([d, c, len(F), len(Fa), len(Fb), len(Fc), p[0], p[1], p[2], p[3], p[4], p[5]]) - cpdef _invariant(self): + cpdef _invariant(self) noexcept: r""" Return a matroid invariant. @@ -4559,7 +4559,7 @@ cdef class TernaryMatroid(LinearMatroid): self._make_invariant() return self._t_invariant - cpdef bicycle_dimension(self): + cpdef bicycle_dimension(self) noexcept: r""" Return the bicycle dimension of the ternary matroid. @@ -4582,7 +4582,7 @@ cdef class TernaryMatroid(LinearMatroid): self._make_invariant() return self._t_invariant[0] - cpdef character(self): + cpdef character(self) noexcept: r""" Return the character of the ternary matroid. @@ -4608,7 +4608,7 @@ cdef class TernaryMatroid(LinearMatroid): self._make_invariant() return self._t_invariant[1] - cpdef _principal_quadripartition(self): + cpdef _principal_quadripartition(self) noexcept: r""" Return an ordered partition of the ground set. @@ -4643,7 +4643,7 @@ cdef class TernaryMatroid(LinearMatroid): self._make_invariant() return tuple([[self._E[j] for j in self._t_partition[0]], [self._E[j] for j in self._t_partition[1]], [self._E[j] for j in self._t_partition[2]], [self._E[j] for j in self._t_partition[3]]]) - cpdef TernaryMatrix _projection(self): + cpdef TernaryMatrix _projection(self) noexcept: """ Return the projection matrix onto the row space. @@ -4685,7 +4685,7 @@ cdef class TernaryMatroid(LinearMatroid): self._make_invariant() return self._t_projection - cpdef _fast_isom_test(self, other): + cpdef _fast_isom_test(self, other) noexcept: r""" Run a quick test to see if two ternary matroids are isomorphic. @@ -4716,7 +4716,7 @@ cdef class TernaryMatroid(LinearMatroid): # minors, dual - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: r""" Return a minor. @@ -4758,7 +4758,7 @@ cdef class TernaryMatroid(LinearMatroid): basis=bas, keep_initial_representation=False) - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -4779,7 +4779,7 @@ cdef class TernaryMatroid(LinearMatroid): # representability - cpdef ternary_matroid(self, randomized_tests=1, verify = True): + cpdef ternary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a ternary matroid representing ``self``. @@ -4809,7 +4809,7 @@ cdef class TernaryMatroid(LinearMatroid): """ return self - cpdef is_ternary(self, randomized_tests=1): + cpdef is_ternary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a binary matroid. @@ -5094,7 +5094,7 @@ cdef class QuaternaryMatroid(LinearMatroid): self._x_zero = (self._A)._x_zero self._x_one = (self._A)._x_one - cpdef base_ring(self): + cpdef base_ring(self) noexcept: r""" Return the base ring of the matrix representing the matroid, in this case `\GF{4}`. @@ -5108,7 +5108,7 @@ cdef class QuaternaryMatroid(LinearMatroid): """ return (self._A).base_ring() - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of the base ring of the matrix representing the matroid, in this case `2`. @@ -5137,13 +5137,13 @@ cdef class QuaternaryMatroid(LinearMatroid): self._prow[y] = p BasisExchangeMatroid._exchange(self, x, y) - cdef __fundamental_cocircuit(self, bitset_t C, long x): + cdef __fundamental_cocircuit(self, bitset_t C, long x) noexcept: r""" Fill bitset `C` with the incidence vector of the `B`-fundamental cocircuit using ``x``. Internal method using packed elements. """ bitset_union(C, (self._A)._M0[self._prow[x]], (self._A)._M1[self._prow[x]]) - cdef _coclosure_internal(self, bitset_t R, bitset_t F): + cdef _coclosure_internal(self, bitset_t R, bitset_t F) noexcept: """ Bitpacked version of ``coclosure``. @@ -5166,7 +5166,7 @@ cdef class QuaternaryMatroid(LinearMatroid): bitset_add(R, y) y = bitset_next(self._inside, y + 1) - cdef _exchange_value_internal(self, long x, long y): + cdef _exchange_value_internal(self, long x, long y) noexcept: r""" Return the (x, y) entry of the current representation. """ @@ -5186,7 +5186,7 @@ cdef class QuaternaryMatroid(LinearMatroid): S = "Quaternary matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements" return S - cpdef _current_rows_cols(self, B=None): + cpdef _current_rows_cols(self, B=None) noexcept: """ Return the current row and column labels of a reduced matrix. @@ -5229,7 +5229,7 @@ cdef class QuaternaryMatroid(LinearMatroid): c += 1 return rows, cols - cpdef LeanMatrix _basic_representation(self, B=None): + cpdef LeanMatrix _basic_representation(self, B=None) noexcept: """ Return a basic matrix representation of the matroid. @@ -5272,7 +5272,7 @@ cdef class QuaternaryMatroid(LinearMatroid): self._move_current_basis(B, set()) return self._A.copy() # Deprecated Sage matrix operation - cpdef LeanMatrix _reduced_representation(self, B=None): + cpdef LeanMatrix _reduced_representation(self, B=None) noexcept: r""" Return a reduced representation of the matroid, i.e. a matrix `R` such that `[I\ \ R]` represents the matroid. @@ -5316,7 +5316,7 @@ cdef class QuaternaryMatroid(LinearMatroid): _, cols = self._current_rows_cols() return self._A.matrix_from_rows_and_columns(range(self.full_rank()), [self._idx[e] for e in cols]) - cpdef _make_invariant(self): + cpdef _make_invariant(self) noexcept: """ Create an invariant. @@ -5383,7 +5383,7 @@ cdef class QuaternaryMatroid(LinearMatroid): self._q_partition = tuple([F, Fa, Fb]) self._q_invariant = tuple([d, len(F), len(Fa), len(Fb), p[0], p[1], p[2]]) - cpdef _invariant(self): + cpdef _invariant(self) noexcept: r""" Return a matroid invariant. @@ -5412,7 +5412,7 @@ cdef class QuaternaryMatroid(LinearMatroid): self._make_invariant() return self._q_invariant - cpdef bicycle_dimension(self): + cpdef bicycle_dimension(self) noexcept: r""" Return the bicycle dimension of the quaternary matroid. @@ -5439,7 +5439,7 @@ cdef class QuaternaryMatroid(LinearMatroid): self._make_invariant() return self._q_invariant[0] - cpdef _principal_tripartition(self): + cpdef _principal_tripartition(self) noexcept: r""" Return the principal tripartition of the quaternary matroid. @@ -5478,7 +5478,7 @@ cdef class QuaternaryMatroid(LinearMatroid): P = self._q_partition return frozenset([self._E[e] for e in P[0]]), frozenset([self._E[e] for e in P[1]]), frozenset([self._E[e] for e in P[2]]) - cpdef _fast_isom_test(self, other): + cpdef _fast_isom_test(self, other) noexcept: r""" Run a quick test to see if two quaternary matroids are isomorphic. @@ -5507,7 +5507,7 @@ cdef class QuaternaryMatroid(LinearMatroid): # minors, dual - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: r""" Return a minor. @@ -5549,7 +5549,7 @@ cdef class QuaternaryMatroid(LinearMatroid): basis=bas, keep_initial_representation=False) - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -5769,7 +5769,7 @@ cdef class RegularMatroid(LinearMatroid): """ LinearMatroid.__init__(self, matrix, groundset, reduced_matrix, ring=ZZ, keep_initial_representation=keep_initial_representation) - cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation): + cdef list _setup_internal_representation(self, matrix, reduced_matrix, ring, keep_initial_representation) noexcept: """ Setup the internal representation matrix ``self._A`` and the array of row- and column indices ``self._prow``. @@ -5812,7 +5812,7 @@ cdef class RegularMatroid(LinearMatroid): self._prow[self._A.nrows() + r] = r return P - cpdef base_ring(self): + cpdef base_ring(self) noexcept: r""" Return the base ring of the matrix representing the matroid, in this case `\ZZ`. @@ -5825,7 +5825,7 @@ cdef class RegularMatroid(LinearMatroid): """ return ZZ - cpdef characteristic(self): + cpdef characteristic(self) noexcept: """ Return the characteristic of the base ring of the matrix representing the matroid, in this case `0`. @@ -5869,7 +5869,7 @@ cdef class RegularMatroid(LinearMatroid): self._prow[x] = py BasisExchangeMatroid._exchange(self, x, y) - cdef _exchange_value_internal(self, long x, long y): + cdef _exchange_value_internal(self, long x, long y) noexcept: r""" Return the (x, y) entry of the current representation. @@ -5896,7 +5896,7 @@ cdef class RegularMatroid(LinearMatroid): S = "Regular matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements with " + str(self.bases_count()) + " bases" return S - cpdef bases_count(self): + cpdef bases_count(self) noexcept: """ Count the number of bases. @@ -5916,7 +5916,7 @@ cdef class RegularMatroid(LinearMatroid): self._bases_count = (R * R.transpose()).det() return self._bases_count - cpdef _projection(self): + cpdef _projection(self) noexcept: """ Return the projection matrix onto the row space. @@ -5956,7 +5956,7 @@ cdef class RegularMatroid(LinearMatroid): self._r_projection = R.transpose() * (R * R.transpose()).adjugate() * R return self._r_projection - cpdef _invariant(self): + cpdef _invariant(self) noexcept: """ Compute a regular matroid invariant. @@ -6006,7 +6006,7 @@ cdef class RegularMatroid(LinearMatroid): self._r_invariant = hash(tuple([tuple([(w, A[w]) for w in sorted(A)]), tuple([(w, B[w]) for w in sorted(B)]), N])) return self._r_invariant - cpdef _hypergraph(self): + cpdef _hypergraph(self) noexcept: """ Create a bipartite digraph and a vertex partition. @@ -6089,7 +6089,7 @@ cdef class RegularMatroid(LinearMatroid): # self._r_hypergraph = self._r_hypergraph.max_refined() # return self._r_hypergraph - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. @@ -6157,7 +6157,7 @@ cdef class RegularMatroid(LinearMatroid): else: return LinearMatroid._is_isomorphic(self, other) - cpdef _fast_isom_test(self, other): + cpdef _fast_isom_test(self, other) noexcept: r""" Run a quick test to see if two regular matroids are isomorphic. @@ -6198,7 +6198,7 @@ cdef class RegularMatroid(LinearMatroid): if self._is_field_isomorphism(other, m): return True - cdef _hypertest(self, other): + cdef _hypertest(self, other) noexcept: """ Test if the hypergraphs associated with ``self`` and ``other`` are isomorphic, and if so return an isomorphism. @@ -6231,7 +6231,7 @@ cdef class RegularMatroid(LinearMatroid): idx={str(f):f for f in other.groundset()} return {e:idx[m[str(e)]] for e in self.groundset() if str(e) in m} - cpdef has_line_minor(self, k, hyperlines=None, certificate=False): + cpdef has_line_minor(self, k, hyperlines=None, certificate=False) noexcept: r""" Test if the matroid has a `U_{2, k}`-minor. @@ -6284,7 +6284,7 @@ cdef class RegularMatroid(LinearMatroid): return False return Matroid.has_line_minor(self, k, hyperlines, certificate) - cpdef _linear_extension_chains(self, F, fundamentals=None): + cpdef _linear_extension_chains(self, F, fundamentals=None) noexcept: r""" Create a list of chains that determine single-element extensions of this linear matroid representation. @@ -6321,7 +6321,7 @@ cdef class RegularMatroid(LinearMatroid): fundamentals = set([1]) return LinearMatroid._linear_extension_chains(self, F, fundamentals) - cpdef is_graphic(self): + cpdef is_graphic(self) noexcept: """ Test if the regular matroid is graphic. @@ -6354,7 +6354,7 @@ cdef class RegularMatroid(LinearMatroid): """ return BinaryMatroid(reduced_matrix=self._reduced_representation()).is_graphic() - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -6385,7 +6385,7 @@ cdef class RegularMatroid(LinearMatroid): # representation - cpdef binary_matroid(self, randomized_tests=1, verify = True): + cpdef binary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a binary matroid representing ``self``. @@ -6417,7 +6417,7 @@ cdef class RegularMatroid(LinearMatroid): A, E = self.representation(B = self.basis(), reduced = False, labels = True) return BinaryMatroid(matrix = A, groundset = E) - cpdef is_binary(self, randomized_tests=1): + cpdef is_binary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a binary matroid. @@ -6445,7 +6445,7 @@ cdef class RegularMatroid(LinearMatroid): """ return True - cpdef ternary_matroid(self, randomized_tests=1, verify = True): + cpdef ternary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a ternary matroid representing ``self``. @@ -6477,7 +6477,7 @@ cdef class RegularMatroid(LinearMatroid): A, E = self.representation(B = self.basis(), reduced = False, labels = True) return TernaryMatroid(matrix = A, groundset = E) - cpdef is_ternary(self, randomized_tests=1): + cpdef is_ternary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a ternary matroid. diff --git a/src/sage/matroids/matroid.pxd b/src/sage/matroids/matroid.pxd index e9ddfec96ae..6c385f10e32 100644 --- a/src/sage/matroids/matroid.pxd +++ b/src/sage/matroids/matroid.pxd @@ -7,36 +7,36 @@ cdef class Matroid(SageObject): cdef int _stored_size # virtual methods - cpdef groundset(self) - cpdef _rank(self, X) + cpdef groundset(self) noexcept + cpdef _rank(self, X) noexcept # internal methods, assuming verified input - cpdef _max_independent(self, X) - cpdef _circuit(self, X) - cpdef _fundamental_circuit(self, B, e) - cpdef _closure(self, X) - cpdef _corank(self, X) - cpdef _max_coindependent(self, X) - cpdef _cocircuit(self, X) - cpdef _fundamental_cocircuit(self, B, e) - cpdef _coclosure(self, X) - cpdef _augment(self, X, Y) - - cpdef _is_independent(self, X) - cpdef _is_basis(self, X) - cpdef _is_circuit(self, X) - cpdef _is_closed(self, X) - cpdef _is_coindependent(self, X) - cpdef _is_cobasis(self, X) - cpdef _is_cocircuit(self, X) - cpdef _is_coclosed(self, X) - - cpdef _minor(self, contractions, deletions) - cpdef _has_minor(self, N, bint certificate=*) - cpdef _line_length(self, F) - cpdef _extension(self, element, hyperplanes) - - cdef inline _subset_internal(self, X): + cpdef _max_independent(self, X) noexcept + cpdef _circuit(self, X) noexcept + cpdef _fundamental_circuit(self, B, e) noexcept + cpdef _closure(self, X) noexcept + cpdef _corank(self, X) noexcept + cpdef _max_coindependent(self, X) noexcept + cpdef _cocircuit(self, X) noexcept + cpdef _fundamental_cocircuit(self, B, e) noexcept + cpdef _coclosure(self, X) noexcept + cpdef _augment(self, X, Y) noexcept + + cpdef _is_independent(self, X) noexcept + cpdef _is_basis(self, X) noexcept + cpdef _is_circuit(self, X) noexcept + cpdef _is_closed(self, X) noexcept + cpdef _is_coindependent(self, X) noexcept + cpdef _is_cobasis(self, X) noexcept + cpdef _is_cocircuit(self, X) noexcept + cpdef _is_coclosed(self, X) noexcept + + cpdef _minor(self, contractions, deletions) noexcept + cpdef _has_minor(self, N, bint certificate=*) noexcept + cpdef _line_length(self, F) noexcept + cpdef _extension(self, element, hyperplanes) noexcept + + cdef inline _subset_internal(self, X) noexcept: """ Convert ``X`` to a ``frozenset`` and check that it is a subset of the groundset. @@ -48,7 +48,7 @@ cdef class Matroid(SageObject): raise ValueError(f"{X!r} is not a subset of the groundset") return S - cdef inline __subset_all(self, X): + cdef inline __subset_all(self, X) noexcept: """ If ``X`` is ``None``, return the groundset. @@ -66,157 +66,157 @@ cdef class Matroid(SageObject): return S # ** user-facing methods ** - cpdef size(self) + cpdef size(self) noexcept # matroid oracle - cpdef rank(self, X=*) - cpdef full_rank(self) - cpdef basis(self) - cpdef max_independent(self, X) - cpdef circuit(self, X=*) - cpdef fundamental_circuit(self, B, e) - cpdef closure(self, X) - cpdef k_closure(self, X, k) - - cpdef augment(self, X, Y=*) - - cpdef corank(self, X=*) - cpdef full_corank(self) - cpdef cobasis(self) - cpdef max_coindependent(self, X) - cpdef cocircuit(self, X=*) - cpdef fundamental_cocircuit(self, B, e) - cpdef coclosure(self, X) - - cpdef loops(self) - cpdef is_independent(self, X) - cpdef is_dependent(self, X) - cpdef is_basis(self, X) - cpdef is_circuit(self, X) - cpdef is_closed(self, X) - cpdef is_subset_k_closed(self, X, int k) - - cpdef coloops(self) - cpdef is_coindependent(self, X) - cpdef is_codependent(self, X) - cpdef is_cobasis(self, X) - cpdef is_cocircuit(self, X) - cpdef is_coclosed(self, X) + cpdef rank(self, X=*) noexcept + cpdef full_rank(self) noexcept + cpdef basis(self) noexcept + cpdef max_independent(self, X) noexcept + cpdef circuit(self, X=*) noexcept + cpdef fundamental_circuit(self, B, e) noexcept + cpdef closure(self, X) noexcept + cpdef k_closure(self, X, k) noexcept + + cpdef augment(self, X, Y=*) noexcept + + cpdef corank(self, X=*) noexcept + cpdef full_corank(self) noexcept + cpdef cobasis(self) noexcept + cpdef max_coindependent(self, X) noexcept + cpdef cocircuit(self, X=*) noexcept + cpdef fundamental_cocircuit(self, B, e) noexcept + cpdef coclosure(self, X) noexcept + + cpdef loops(self) noexcept + cpdef is_independent(self, X) noexcept + cpdef is_dependent(self, X) noexcept + cpdef is_basis(self, X) noexcept + cpdef is_circuit(self, X) noexcept + cpdef is_closed(self, X) noexcept + cpdef is_subset_k_closed(self, X, int k) noexcept + + cpdef coloops(self) noexcept + cpdef is_coindependent(self, X) noexcept + cpdef is_codependent(self, X) noexcept + cpdef is_cobasis(self, X) noexcept + cpdef is_cocircuit(self, X) noexcept + cpdef is_coclosed(self, X) noexcept # verification - cpdef is_valid(self) + cpdef is_valid(self) noexcept # enumeration - cpdef circuits(self) - cpdef nonspanning_circuits(self) - cpdef cocircuits(self) - cpdef noncospanning_cocircuits(self) - cpdef circuit_closures(self) - cpdef nonspanning_circuit_closures(self) - cpdef bases(self) - cpdef independent_sets(self) - cpdef independent_r_sets(self, long r) - cpdef nonbases(self) - cpdef dependent_r_sets(self, long r) - cpdef _extend_flags(self, flags) - cpdef _flags(self, r) - cpdef flats(self, r) - cpdef coflats(self, r) - cpdef hyperplanes(self) - cpdef f_vector(self) - cpdef broken_circuits(self, ordering=*) - cpdef no_broken_circuits_sets(self, ordering=*) + cpdef circuits(self) noexcept + cpdef nonspanning_circuits(self) noexcept + cpdef cocircuits(self) noexcept + cpdef noncospanning_cocircuits(self) noexcept + cpdef circuit_closures(self) noexcept + cpdef nonspanning_circuit_closures(self) noexcept + cpdef bases(self) noexcept + cpdef independent_sets(self) noexcept + cpdef independent_r_sets(self, long r) noexcept + cpdef nonbases(self) noexcept + cpdef dependent_r_sets(self, long r) noexcept + cpdef _extend_flags(self, flags) noexcept + cpdef _flags(self, r) noexcept + cpdef flats(self, r) noexcept + cpdef coflats(self, r) noexcept + cpdef hyperplanes(self) noexcept + cpdef f_vector(self) noexcept + cpdef broken_circuits(self, ordering=*) noexcept + cpdef no_broken_circuits_sets(self, ordering=*) noexcept # isomorphism - cpdef is_isomorphic(self, other, certificate=*) - cpdef _is_isomorphic(self, other, certificate=*) - cpdef isomorphism(self, other) - cpdef _isomorphism(self, other) - cpdef equals(self, other) - cpdef is_isomorphism(self, other, morphism) - cpdef _is_isomorphism(self, other, morphism) + cpdef is_isomorphic(self, other, certificate=*) noexcept + cpdef _is_isomorphic(self, other, certificate=*) noexcept + cpdef isomorphism(self, other) noexcept + cpdef _isomorphism(self, other) noexcept + cpdef equals(self, other) noexcept + cpdef is_isomorphism(self, other, morphism) noexcept + cpdef _is_isomorphism(self, other, morphism) noexcept # minors, dual, truncation - cpdef minor(self, contractions=*, deletions=*) - cpdef contract(self, X) - cpdef delete(self, X) - cpdef _backslash_(self, X) - cpdef dual(self) - cpdef truncation(self) - cpdef has_minor(self, N, bint certificate=*) - cpdef has_line_minor(self, k, hyperlines=*, certificate=*) - cpdef _has_line_minor(self, k, hyperlines, certificate=*) + cpdef minor(self, contractions=*, deletions=*) noexcept + cpdef contract(self, X) noexcept + cpdef delete(self, X) noexcept + cpdef _backslash_(self, X) noexcept + cpdef dual(self) noexcept + cpdef truncation(self) noexcept + cpdef has_minor(self, N, bint certificate=*) noexcept + cpdef has_line_minor(self, k, hyperlines=*, certificate=*) noexcept + cpdef _has_line_minor(self, k, hyperlines, certificate=*) noexcept # extension - cpdef extension(self, element=*, subsets=*) - cpdef coextension(self, element=*, subsets=*) - cpdef modular_cut(self, subsets) - cpdef linear_subclasses(self, line_length=*, subsets=*) - cpdef extensions(self, element=*, line_length=*, subsets=*) + cpdef extension(self, element=*, subsets=*) noexcept + cpdef coextension(self, element=*, subsets=*) noexcept + cpdef modular_cut(self, subsets) noexcept + cpdef linear_subclasses(self, line_length=*, subsets=*) noexcept + cpdef extensions(self, element=*, line_length=*, subsets=*) noexcept # connectivity - cpdef simplify(self) - cpdef cosimplify(self) - cpdef is_simple(self) - cpdef is_cosimple(self) - cpdef components(self) - cpdef is_connected(self, certificate=*) - cpdef connectivity(self, S, T=*) - cpdef _connectivity(self, S, T) - cpdef is_kconnected(self, k, certificate=*) - cpdef link(self, S, T) - cpdef _link(self, S, T) - cpdef _is_3connected_shifting(self, certificate=*) - cpdef _is_4connected_shifting(self, certificate=*) - cpdef _shifting_all(self, X, P_rows, P_cols, Q_rows, Q_cols, m) - cpdef _shifting(self, X, X_1, Y_2, X_2, Y_1, m) - cpdef is_3connected(self, certificate=*, algorithm=*) - cpdef is_4connected(self, certificate=*, algorithm=*) - cpdef _is_3connected_CE(self, certificate=*) - cpdef _is_3connected_BC(self, certificate=*) - cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits) + cpdef simplify(self) noexcept + cpdef cosimplify(self) noexcept + cpdef is_simple(self) noexcept + cpdef is_cosimple(self) noexcept + cpdef components(self) noexcept + cpdef is_connected(self, certificate=*) noexcept + cpdef connectivity(self, S, T=*) noexcept + cpdef _connectivity(self, S, T) noexcept + cpdef is_kconnected(self, k, certificate=*) noexcept + cpdef link(self, S, T) noexcept + cpdef _link(self, S, T) noexcept + cpdef _is_3connected_shifting(self, certificate=*) noexcept + cpdef _is_4connected_shifting(self, certificate=*) noexcept + cpdef _shifting_all(self, X, P_rows, P_cols, Q_rows, Q_cols, m) noexcept + cpdef _shifting(self, X, X_1, Y_2, X_2, Y_1, m) noexcept + cpdef is_3connected(self, certificate=*, algorithm=*) noexcept + cpdef is_4connected(self, certificate=*, algorithm=*) noexcept + cpdef _is_3connected_CE(self, certificate=*) noexcept + cpdef _is_3connected_BC(self, certificate=*) noexcept + cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits) noexcept # representability - cpdef _local_binary_matroid(self, basis=*) - cpdef binary_matroid(self, randomized_tests=*, verify=*) - cpdef is_binary(self, randomized_tests=*) - cpdef _local_ternary_matroid(self, basis=*) - cpdef ternary_matroid(self, randomized_tests=*, verify=*) - cpdef is_ternary(self, randomized_tests=*) + cpdef _local_binary_matroid(self, basis=*) noexcept + cpdef binary_matroid(self, randomized_tests=*, verify=*) noexcept + cpdef is_binary(self, randomized_tests=*) noexcept + cpdef _local_ternary_matroid(self, basis=*) noexcept + cpdef ternary_matroid(self, randomized_tests=*, verify=*) noexcept + cpdef is_ternary(self, randomized_tests=*) noexcept # matroid k-closed - cpdef is_k_closed(self, int k) + cpdef is_k_closed(self, int k) noexcept # matroid chordality - cpdef _is_circuit_chordal(self, frozenset C, bint certificate=*) - cpdef is_circuit_chordal(self, C, bint certificate=*) - cpdef is_chordal(self, k1=*, k2=*, bint certificate=*) - cpdef chordality(self) + cpdef _is_circuit_chordal(self, frozenset C, bint certificate=*) noexcept + cpdef is_circuit_chordal(self, C, bint certificate=*) noexcept + cpdef is_chordal(self, k1=*, k2=*, bint certificate=*) noexcept + cpdef chordality(self) noexcept # optimization - cpdef max_weight_independent(self, X=*, weights=*) - cpdef max_weight_coindependent(self, X=*, weights=*) - cpdef is_max_weight_independent_generic(self, X=*, weights=*) - cpdef is_max_weight_coindependent_generic(self, X=*, weights=*) - cpdef intersection(self, other, weights=*) - cpdef _intersection(self, other, weights) - cpdef _intersection_augmentation(self, other, weights, Y) - cpdef intersection_unweighted(self, other) - cpdef _intersection_unweighted(self, other) - cpdef _intersection_augmentation_unweighted(self, other, Y) - cpdef partition(self) + cpdef max_weight_independent(self, X=*, weights=*) noexcept + cpdef max_weight_coindependent(self, X=*, weights=*) noexcept + cpdef is_max_weight_independent_generic(self, X=*, weights=*) noexcept + cpdef is_max_weight_coindependent_generic(self, X=*, weights=*) noexcept + cpdef intersection(self, other, weights=*) noexcept + cpdef _intersection(self, other, weights) noexcept + cpdef _intersection_augmentation(self, other, weights, Y) noexcept + cpdef intersection_unweighted(self, other) noexcept + cpdef _intersection_unweighted(self, other) noexcept + cpdef _intersection_augmentation_unweighted(self, other, Y) noexcept + cpdef partition(self) noexcept # invariants - cpdef _internal(self, B) - cpdef _external(self, B) - cpdef tutte_polynomial(self, x=*, y=*) - cpdef flat_cover(self, solver=*, verbose=*, integrality_tolerance=*) + cpdef _internal(self, B) noexcept + cpdef _external(self, B) noexcept + cpdef tutte_polynomial(self, x=*, y=*) noexcept + cpdef flat_cover(self, solver=*, verbose=*, integrality_tolerance=*) noexcept # misc - cpdef bergman_complex(self) - cpdef augmented_bergman_complex(self) + cpdef bergman_complex(self) noexcept + cpdef augmented_bergman_complex(self) noexcept # visualization - cpdef plot(self,B=*,lineorders=*,pos_method=*,pos_dict=*,save_pos=*) - cpdef show(self,B=*,lineorders=*,pos_method=*,pos_dict=*,save_pos=*,lims=*) - cpdef _fix_positions(self,pos_dict=*,lineorders=*) + cpdef plot(self,B=*,lineorders=*,pos_method=*,pos_dict=*,save_pos=*) noexcept + cpdef show(self,B=*,lineorders=*,pos_method=*,pos_dict=*,save_pos=*,lims=*) noexcept + cpdef _fix_positions(self,pos_dict=*,lineorders=*) noexcept diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 93976cd6e43..51692e8f1c1 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -459,7 +459,7 @@ cdef class Matroid(SageObject): # virtual methods - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -485,7 +485,7 @@ cdef class Matroid(SageObject): """ raise NotImplementedError("subclasses need to implement this.") - cpdef _rank(self, X): + cpdef _rank(self, X) noexcept: r""" Return the rank of a set ``X``. @@ -520,7 +520,7 @@ cdef class Matroid(SageObject): # for better efficiency, its best to override the following methods in # each derived class - cpdef _max_independent(self, X): + cpdef _max_independent(self, X) noexcept: """ Compute a maximal independent subset. @@ -552,7 +552,7 @@ cdef class Matroid(SageObject): res.discard(e) return frozenset(res) - cpdef _circuit(self, X): + cpdef _circuit(self, X) noexcept: """ Return a minimal dependent subset. @@ -591,7 +591,7 @@ cdef class Matroid(SageObject): l -= 1 return frozenset(Z) - cpdef _fundamental_circuit(self, B, e): + cpdef _fundamental_circuit(self, B, e) noexcept: r""" Return the `B`-fundamental circuit using `e`. @@ -614,7 +614,7 @@ cdef class Matroid(SageObject): """ return self._circuit(B.union([e])) - cpdef _closure(self, X): + cpdef _closure(self, X) noexcept: """ Return the closure of a set. @@ -643,7 +643,7 @@ cdef class Matroid(SageObject): X.discard(y) return frozenset(X) - cpdef _corank(self, X): + cpdef _corank(self, X) noexcept: """ Return the corank of a set. @@ -665,7 +665,7 @@ cdef class Matroid(SageObject): """ return len(X) + self._rank(self.groundset().difference(X)) - self.full_rank() - cpdef _max_coindependent(self, X): + cpdef _max_coindependent(self, X) noexcept: """ Compute a maximal coindependent subset. @@ -697,7 +697,7 @@ cdef class Matroid(SageObject): res.discard(e) return frozenset(res) - cpdef _cocircuit(self, X): + cpdef _cocircuit(self, X) noexcept: """ Return a minimal codependent subset. @@ -736,7 +736,7 @@ cdef class Matroid(SageObject): l -= 1 return frozenset(Z) - cpdef _fundamental_cocircuit(self, B, e): + cpdef _fundamental_cocircuit(self, B, e) noexcept: r""" Return the `B`-fundamental circuit using `e`. @@ -759,7 +759,7 @@ cdef class Matroid(SageObject): """ return self._cocircuit(self.groundset().difference(B).union([e])) - cpdef _coclosure(self, X): + cpdef _coclosure(self, X) noexcept: """ Return the coclosure of a set. @@ -788,7 +788,7 @@ cdef class Matroid(SageObject): X.discard(y) return frozenset(X) - cpdef _augment(self, X, Y): + cpdef _augment(self, X, Y) noexcept: r""" Return a maximal subset `I` of `Y` such that `r(X + I)=r(X) + r(I)`. @@ -828,7 +828,7 @@ cdef class Matroid(SageObject): # override the following methods for even better efficiency - cpdef _is_independent(self, X): + cpdef _is_independent(self, X) noexcept: """ Test if input is independent. @@ -852,7 +852,7 @@ cdef class Matroid(SageObject): """ return len(X) == self._rank(X) - cpdef _is_basis(self, X): + cpdef _is_basis(self, X) noexcept: """ Test if input is a basis. @@ -888,7 +888,7 @@ cdef class Matroid(SageObject): """ return self._is_independent(X) - cpdef _is_circuit(self, X): + cpdef _is_circuit(self, X) noexcept: """ Test if input is a circuit. @@ -923,7 +923,7 @@ cdef class Matroid(SageObject): Z.add(x) return True - cpdef _is_closed(self, X): + cpdef _is_closed(self, X) noexcept: """ Test if input is a closed set. @@ -955,7 +955,7 @@ cdef class Matroid(SageObject): X.discard(y) return True - cpdef _is_coindependent(self, X): + cpdef _is_coindependent(self, X) noexcept: """ Test if input is coindependent. @@ -979,7 +979,7 @@ cdef class Matroid(SageObject): """ return self._corank(X) == len(X) - cpdef _is_cobasis(self, X): + cpdef _is_cobasis(self, X) noexcept: """ Test if input is a cobasis. @@ -1010,7 +1010,7 @@ cdef class Matroid(SageObject): """ return self._is_basis(self.groundset().difference(X)) - cpdef _is_cocircuit(self, X): + cpdef _is_cocircuit(self, X) noexcept: """ Test if input is a cocircuit. @@ -1045,7 +1045,7 @@ cdef class Matroid(SageObject): Z.add(x) return True - cpdef _is_coclosed(self, X): + cpdef _is_coclosed(self, X) noexcept: """ Test if input is a coclosed set. @@ -1077,7 +1077,7 @@ cdef class Matroid(SageObject): X.discard(y) return True - cpdef _minor(self, contractions, deletions): + cpdef _minor(self, contractions, deletions) noexcept: r""" Return a minor. @@ -1116,7 +1116,7 @@ cdef class Matroid(SageObject): from . import minor_matroid return minor_matroid.MinorMatroid(self, contractions, deletions) - cpdef _has_minor(self, N, bint certificate=False): + cpdef _has_minor(self, N, bint certificate=False) noexcept: """ Test if matroid has the specified minor, and optionally return frozensets ``X`` and ``Y`` so that ``N`` is isomorphic to ``self.minor(X, Y)``. @@ -1172,7 +1172,7 @@ cdef class Matroid(SageObject): return False, None return False - cpdef _line_length(self, F): + cpdef _line_length(self, F) noexcept: """ Compute the length of the line specified through flat ``F``. @@ -1198,7 +1198,7 @@ cdef class Matroid(SageObject): """ return len(self.minor(contractions=F).simplify()) - cpdef _extension(self, element, hyperplanes): + cpdef _extension(self, element, hyperplanes) noexcept: """ Extend the matroid by a new element. @@ -1266,7 +1266,7 @@ cdef class Matroid(SageObject): """ return self.size() - cpdef size(self): + cpdef size(self) noexcept: """ Return the size of the groundset. @@ -1343,7 +1343,7 @@ cdef class Matroid(SageObject): # User-visible methods - cpdef rank(self, X=None): + cpdef rank(self, X=None) noexcept: r""" Return the rank of ``X``. @@ -1377,7 +1377,7 @@ cdef class Matroid(SageObject): return self.full_rank() return self._rank(self._subset_internal(X)) - cpdef full_rank(self): + cpdef full_rank(self) noexcept: r""" Return the rank of the matroid. @@ -1400,7 +1400,7 @@ cdef class Matroid(SageObject): self._stored_full_rank = self._rank(self.groundset()) return self._stored_full_rank - cpdef basis(self): + cpdef basis(self) noexcept: r""" Return an arbitrary basis of the matroid. @@ -1429,7 +1429,7 @@ cdef class Matroid(SageObject): """ return self._max_independent(self.groundset()) - cpdef max_independent(self, X): + cpdef max_independent(self, X) noexcept: """ Compute a maximal independent subset of ``X``. @@ -1456,7 +1456,7 @@ cdef class Matroid(SageObject): """ return self._max_independent(self._subset_internal(X)) - cpdef circuit(self, X=None): + cpdef circuit(self, X=None) noexcept: """ Return a circuit. @@ -1498,7 +1498,7 @@ cdef class Matroid(SageObject): """ return self._circuit(self.__subset_all(X)) - cpdef fundamental_circuit(self, B, e): + cpdef fundamental_circuit(self, B, e) noexcept: r""" Return the `B`-fundamental circuit using `e`. @@ -1533,7 +1533,7 @@ cdef class Matroid(SageObject): raise ValueError("input e is not an element of the groundset.") return self._fundamental_circuit(B, e) - cpdef closure(self, X): + cpdef closure(self, X) noexcept: """ Return the closure of a set ``X``. @@ -1561,7 +1561,7 @@ cdef class Matroid(SageObject): """ return self._closure(self._subset_internal(X)) - cpdef k_closure(self, X, k): + cpdef k_closure(self, X, k) noexcept: r""" Return the ``k``-closure of ``X``. @@ -1611,7 +1611,7 @@ cdef class Matroid(SageObject): S = cl return S - cpdef augment(self, X, Y=None): + cpdef augment(self, X, Y=None) noexcept: r""" Return a maximal subset `I` of `Y - X` such that `r(X + I) = r(X) + r(I)`. @@ -1649,7 +1649,7 @@ cdef class Matroid(SageObject): Y = self.__subset_all(Y) return self._augment(X, Y.difference(X)) - cpdef corank(self, X=None): + cpdef corank(self, X=None) noexcept: r""" Return the corank of ``X``, or the corank of the groundset if ``X`` is ``None``. @@ -1686,7 +1686,7 @@ cdef class Matroid(SageObject): """ return self._corank(self.__subset_all(X)) - cpdef full_corank(self): + cpdef full_corank(self) noexcept: """ Return the corank of the matroid. @@ -1710,7 +1710,7 @@ cdef class Matroid(SageObject): """ return self.size() - self.full_rank() - cpdef cobasis(self): + cpdef cobasis(self) noexcept: """ Return an arbitrary cobasis of the matroid. @@ -1746,7 +1746,7 @@ cdef class Matroid(SageObject): """ return self.max_coindependent(self.groundset()) - cpdef max_coindependent(self, X): + cpdef max_coindependent(self, X) noexcept: """ Compute a maximal coindependent subset of ``X``. @@ -1784,7 +1784,7 @@ cdef class Matroid(SageObject): """ return self._max_coindependent(self._subset_internal(X)) - cpdef coclosure(self, X): + cpdef coclosure(self, X) noexcept: """ Return the coclosure of a set ``X``. @@ -1816,7 +1816,7 @@ cdef class Matroid(SageObject): """ return self._coclosure(self._subset_internal(X)) - cpdef cocircuit(self, X=None): + cpdef cocircuit(self, X=None) noexcept: """ Return a cocircuit. @@ -1864,7 +1864,7 @@ cdef class Matroid(SageObject): """ return self._cocircuit(self.__subset_all(X)) - cpdef fundamental_cocircuit(self, B, e): + cpdef fundamental_cocircuit(self, B, e) noexcept: r""" Return the `B`-fundamental cocircuit using `e`. @@ -1903,7 +1903,7 @@ cdef class Matroid(SageObject): raise ValueError("input e is not an element of B.") return self._fundamental_cocircuit(B, e) - cpdef loops(self): + cpdef loops(self) noexcept: r""" Return the set of loops of the matroid. @@ -1924,7 +1924,7 @@ cdef class Matroid(SageObject): """ return self._closure(set()) - cpdef is_independent(self, X): + cpdef is_independent(self, X) noexcept: r""" Check if a subset ``X`` is independent in the matroid. @@ -1950,7 +1950,7 @@ cdef class Matroid(SageObject): """ return self._is_independent(self._subset_internal(X)) - cpdef is_dependent(self, X): + cpdef is_dependent(self, X) noexcept: r""" Check if a subset ``X`` is dependent in the matroid. @@ -1976,7 +1976,7 @@ cdef class Matroid(SageObject): """ return not self._is_independent(self._subset_internal(X)) - cpdef is_basis(self, X): + cpdef is_basis(self, X) noexcept: r""" Check if a subset is a basis of the matroid. @@ -2005,7 +2005,7 @@ cdef class Matroid(SageObject): return False return self._is_basis(X) - cpdef is_closed(self, X): + cpdef is_closed(self, X) noexcept: r""" Test if a subset is a closed set of the matroid. @@ -2038,7 +2038,7 @@ cdef class Matroid(SageObject): """ return self._is_closed(self._subset_internal(X)) - cpdef is_subset_k_closed(self, X, int k): + cpdef is_subset_k_closed(self, X, int k) noexcept: r""" Test if ``X`` is a ``k``-closed set of the matroid. @@ -2093,7 +2093,7 @@ cdef class Matroid(SageObject): return False return True - cpdef is_circuit(self, X): + cpdef is_circuit(self, X) noexcept: r""" Test if a subset is a circuit of the matroid. @@ -2121,7 +2121,7 @@ cdef class Matroid(SageObject): """ return self._is_circuit(self._subset_internal(X)) - cpdef coloops(self): + cpdef coloops(self) noexcept: r""" Return the set of coloops of the matroid. @@ -2148,7 +2148,7 @@ cdef class Matroid(SageObject): """ return self._coclosure(set()) - cpdef is_coindependent(self, X): + cpdef is_coindependent(self, X) noexcept: r""" Check if a subset is coindependent in the matroid. @@ -2181,7 +2181,7 @@ cdef class Matroid(SageObject): """ return self._is_coindependent(self._subset_internal(X)) - cpdef is_codependent(self, X): + cpdef is_codependent(self, X) noexcept: r""" Check if a subset is codependent in the matroid. @@ -2214,7 +2214,7 @@ cdef class Matroid(SageObject): """ return not self._is_coindependent(self._subset_internal(X)) - cpdef is_cobasis(self, X): + cpdef is_cobasis(self, X) noexcept: r""" Check if a subset is a cobasis of the matroid. @@ -2251,7 +2251,7 @@ cdef class Matroid(SageObject): return False return self._is_cobasis(X) - cpdef is_cocircuit(self, X): + cpdef is_cocircuit(self, X) noexcept: r""" Test if a subset is a cocircuit of the matroid. @@ -2285,7 +2285,7 @@ cdef class Matroid(SageObject): """ return self._is_cocircuit(self._subset_internal(X)) - cpdef is_coclosed(self, X): + cpdef is_coclosed(self, X) noexcept: r""" Test if a subset is a coclosed set of the matroid. @@ -2320,7 +2320,7 @@ cdef class Matroid(SageObject): # verification - cpdef is_valid(self): + cpdef is_valid(self) noexcept: r""" Test if the data obey the matroid axioms. @@ -2372,7 +2372,7 @@ cdef class Matroid(SageObject): # enumeration - cpdef circuits(self): + cpdef circuits(self) noexcept: """ Return the list of circuits of the matroid. @@ -2400,7 +2400,7 @@ cdef class Matroid(SageObject): for e in self.groundset().difference(B)]) return list(C) - cpdef nonspanning_circuits(self): + cpdef nonspanning_circuits(self) noexcept: """ Return the list of nonspanning circuits of the matroid. @@ -2430,7 +2430,7 @@ cdef class Matroid(SageObject): C.add(self._circuit(N)) return list(C) - cpdef cocircuits(self): + cpdef cocircuits(self) noexcept: """ Return the list of cocircuits of the matroid. @@ -2455,7 +2455,7 @@ cdef class Matroid(SageObject): C.update([self._cocircuit(self.groundset().difference(B).union(set([e]))) for e in B]) return list(C) - cpdef noncospanning_cocircuits(self): + cpdef noncospanning_cocircuits(self) noexcept: """ Return the list of noncospanning cocircuits of the matroid. @@ -2481,7 +2481,7 @@ cdef class Matroid(SageObject): """ return self.dual().nonspanning_circuits() - cpdef circuit_closures(self): + cpdef circuit_closures(self) noexcept: """ Return the list of closures of circuits of the matroid. @@ -2517,7 +2517,7 @@ cdef class Matroid(SageObject): CC[len(C) - 1].add(self.closure(C)) return {r: CC[r] for r in range(self.rank() + 1) if CC[r]} - cpdef nonspanning_circuit_closures(self): + cpdef nonspanning_circuit_closures(self) noexcept: """ Return the list of closures of nonspanning circuits of the matroid. @@ -2550,7 +2550,7 @@ cdef class Matroid(SageObject): CC[len(C) - 1].add(self.closure(C)) return {r: CC[r] for r in range(self.rank() + 1) if CC[r]} - cpdef nonbases(self): + cpdef nonbases(self) noexcept: r""" Return the list of nonbases of the matroid. @@ -2584,7 +2584,7 @@ cdef class Matroid(SageObject): res.append(X) return res - cpdef dependent_r_sets(self, long r): + cpdef dependent_r_sets(self, long r) noexcept: r""" Return the list of dependent subsets of fixed size. @@ -2617,7 +2617,7 @@ cdef class Matroid(SageObject): res.append(X) return res - cpdef bases(self): + cpdef bases(self) noexcept: r""" Return the list of bases of the matroid. @@ -2649,7 +2649,7 @@ cdef class Matroid(SageObject): res.append(X) return res - cpdef independent_sets(self): + cpdef independent_sets(self) noexcept: r""" Return the list of independent subsets of the matroid. @@ -2693,7 +2693,7 @@ cdef class Matroid(SageObject): r -= 1 return res - cpdef independent_r_sets(self, long r): + cpdef independent_r_sets(self, long r) noexcept: r""" Return the list of size-``r`` independent subsets of the matroid. @@ -2733,7 +2733,7 @@ cdef class Matroid(SageObject): res.append(X) return res - cpdef _extend_flags(self, flags): + cpdef _extend_flags(self, flags) noexcept: r""" Recursion for the ``self._flags(r)`` method. @@ -2759,7 +2759,7 @@ cdef class Matroid(SageObject): X = newX return newflags - cpdef _flags(self, r): + cpdef _flags(self, r) noexcept: r""" Compute rank-``r`` flats, with extra information for more speed. @@ -2797,7 +2797,7 @@ cdef class Matroid(SageObject): flags = self._extend_flags(flags) return flags - cpdef flats(self, r): + cpdef flats(self, r) noexcept: r""" Return the collection of flats of the matroid of specified rank. @@ -2826,7 +2826,7 @@ cdef class Matroid(SageObject): return SetSystem(list(self.groundset()), subsets=[f[0] for f in self._flags(r)]) - cpdef coflats(self, r): + cpdef coflats(self, r) noexcept: r""" Return the collection of coflats of the matroid of specified corank. @@ -2869,7 +2869,7 @@ cdef class Matroid(SageObject): for X in self.flats(i)] return LatticePoset((F, lambda x, y: x < y)) - cpdef hyperplanes(self): + cpdef hyperplanes(self) noexcept: """ Return the set of hyperplanes of the matroid. @@ -2893,7 +2893,7 @@ cdef class Matroid(SageObject): """ return self.flats(self.full_rank() - 1) - cpdef f_vector(self): + cpdef f_vector(self) noexcept: r""" Return the `f`-vector of the matroid. @@ -2919,7 +2919,7 @@ cdef class Matroid(SageObject): f_vec.append(len(flags)) return f_vec - cpdef broken_circuits(self, ordering=None): + cpdef broken_circuits(self, ordering=None) noexcept: r""" Return the list of broken circuits of ``self``. @@ -2961,7 +2961,7 @@ cdef class Matroid(SageObject): break return frozenset(ret) - cpdef no_broken_circuits_sets(self, ordering=None): + cpdef no_broken_circuits_sets(self, ordering=None) noexcept: r""" Return the no broken circuits (NBC) sets of ``self``. @@ -3197,7 +3197,7 @@ cdef class Matroid(SageObject): # isomorphism and equality - cpdef is_isomorphic(self, other, certificate=False): + cpdef is_isomorphic(self, other, certificate=False) noexcept: r""" Test matroid isomorphism. @@ -3241,7 +3241,7 @@ cdef class Matroid(SageObject): raise TypeError("can only test for isomorphism between matroids.") return self._is_isomorphic(other, certificate) - cpdef _is_isomorphic(self, other, certificate=False): + cpdef _is_isomorphic(self, other, certificate=False) noexcept: """ Test if ``self`` is isomorphic to ``other``. @@ -3282,7 +3282,7 @@ cdef class Matroid(SageObject): return True return (self.full_rank() == other.full_rank() and self.nonbases()._isomorphism(other.nonbases()) is not None) - cpdef isomorphism(self, other): + cpdef isomorphism(self, other) noexcept: r""" Return a matroid isomorphism. @@ -3321,7 +3321,7 @@ cdef class Matroid(SageObject): raise TypeError("can only give isomorphism between matroids.") return self._isomorphism(other) - cpdef _isomorphism(self, other): + cpdef _isomorphism(self, other) noexcept: """ Return isomorphism from ``self`` to ``other``, if such an isomorphism exists. @@ -3354,7 +3354,7 @@ cdef class Matroid(SageObject): else: return None - cpdef equals(self, other): + cpdef equals(self, other) noexcept: """ Test for matroid equality. @@ -3441,7 +3441,7 @@ cdef class Matroid(SageObject): morphism = {e: e for e in self.groundset()} return self._is_isomorphism(other, morphism) - cpdef is_isomorphism(self, other, morphism): + cpdef is_isomorphism(self, other, morphism) noexcept: r""" Test if a provided morphism induces a matroid isomorphism. @@ -3580,7 +3580,7 @@ cdef class Matroid(SageObject): return False return self._is_isomorphism(other, mf) - cpdef _is_isomorphism(self, other, morphism): + cpdef _is_isomorphism(self, other, morphism) noexcept: r""" Version of :meth:`is_isomorphism` that does no type checking. @@ -3699,7 +3699,7 @@ cdef class Matroid(SageObject): # Minors and duality - cpdef minor(self, contractions=None, deletions=None): + cpdef minor(self, contractions=None, deletions=None) noexcept: r""" Return the minor of ``self`` obtained by contracting, respectively deleting, the element(s) of ``contractions`` and ``deletions``. @@ -3815,7 +3815,7 @@ cdef class Matroid(SageObject): conset, delset = sanitize_contractions_deletions(self, contractions, deletions) return self._minor(conset, delset) - cpdef contract(self, X): + cpdef contract(self, X) noexcept: r""" Contract elements. @@ -3895,7 +3895,7 @@ cdef class Matroid(SageObject): """ return self.contract(X) - cpdef delete(self, X): + cpdef delete(self, X) noexcept: r""" Delete elements. @@ -3961,7 +3961,7 @@ cdef class Matroid(SageObject): """ return self.minor(deletions=X) - cpdef _backslash_(self, X): + cpdef _backslash_(self, X) noexcept: r""" Shorthand for ``self.delete(X)``. @@ -3978,7 +3978,7 @@ cdef class Matroid(SageObject): deprecation(36394, 'the backslash operator has been deprecated; use M.delete(X) instead') return self.delete(X) - cpdef dual(self): + cpdef dual(self) noexcept: r""" Return the dual of the matroid. @@ -4012,7 +4012,7 @@ cdef class Matroid(SageObject): from . import dual_matroid return dual_matroid.DualMatroid(self) - cpdef truncation(self): + cpdef truncation(self) noexcept: """ Return a rank-1 truncation of the matroid. @@ -4043,7 +4043,7 @@ cdef class Matroid(SageObject): return self._extension(l, [])._minor(contractions=frozenset([l]), deletions=frozenset([])) - cpdef has_minor(self, N, bint certificate=False): + cpdef has_minor(self, N, bint certificate=False) noexcept: """ Check if ``self`` has a minor isomorphic to ``N``, and optionally return frozensets ``X`` and ``Y`` so that ``N`` is isomorphic to ``self.minor(X, Y)``. @@ -4090,7 +4090,7 @@ cdef class Matroid(SageObject): raise ValueError("N must be a matroid.") return self._has_minor(N, certificate) - cpdef has_line_minor(self, k, hyperlines=None, certificate=False): + cpdef has_line_minor(self, k, hyperlines=None, certificate=False) noexcept: r""" Test if the matroid has a `U_{2, k}`-minor. @@ -4161,7 +4161,7 @@ cdef class Matroid(SageObject): # get simplified away anyway. return self._has_line_minor(k, hyperlines, certificate) - cpdef _has_line_minor(self, k, hyperlines, certificate=False): + cpdef _has_line_minor(self, k, hyperlines, certificate=False) noexcept: r""" Test if the matroid has a `U_{2, k}`-minor. @@ -4208,7 +4208,7 @@ cdef class Matroid(SageObject): # extensions - cpdef extension(self, element=None, subsets=None): + cpdef extension(self, element=None, subsets=None) noexcept: r""" Return an extension of the matroid. @@ -4285,7 +4285,7 @@ cdef class Matroid(SageObject): hyperplanes = [H for H in self.modular_cut(subsets) if self._rank(H) == r] return self._extension(element, hyperplanes) - cpdef coextension(self, element=None, subsets=None): + cpdef coextension(self, element=None, subsets=None) noexcept: r""" Return a coextension of the matroid. @@ -4349,7 +4349,7 @@ cdef class Matroid(SageObject): """ return self.dual().extension(element, subsets).dual() - cpdef modular_cut(self, subsets): + cpdef modular_cut(self, subsets) noexcept: r""" Compute the modular cut generated by ``subsets``. @@ -4439,7 +4439,7 @@ cdef class Matroid(SageObject): final_list.add(F) return final_list - cpdef linear_subclasses(self, line_length=None, subsets=None): + cpdef linear_subclasses(self, line_length=None, subsets=None) noexcept: r""" Return an iterable set of linear subclasses of the matroid. @@ -4508,7 +4508,7 @@ cdef class Matroid(SageObject): from . import extension return extension.LinearSubclasses(self, line_length=line_length, subsets=subsets) - cpdef extensions(self, element=None, line_length=None, subsets=None): + cpdef extensions(self, element=None, line_length=None, subsets=None) noexcept: r""" Return an iterable set of single-element extensions of the matroid. @@ -4639,7 +4639,7 @@ cdef class Matroid(SageObject): # connectivity - cpdef simplify(self): + cpdef simplify(self) noexcept: r""" Return the simplification of the matroid. @@ -4678,7 +4678,7 @@ cdef class Matroid(SageObject): return self._minor(contractions=frozenset([]), deletions=self.groundset().difference(res)) - cpdef cosimplify(self): + cpdef cosimplify(self) noexcept: r""" Return the cosimplification of the matroid. @@ -4717,7 +4717,7 @@ cdef class Matroid(SageObject): return self._minor(contractions=self.groundset().difference(res), deletions=frozenset([])) - cpdef is_simple(self): + cpdef is_simple(self) noexcept: """ Test if the matroid is simple. @@ -4750,7 +4750,7 @@ cdef class Matroid(SageObject): return False return True - cpdef is_cosimple(self): + cpdef is_cosimple(self) noexcept: r""" Test if the matroid is cosimple. @@ -4786,7 +4786,7 @@ cdef class Matroid(SageObject): return False return True - cpdef components(self): + cpdef components(self) noexcept: """ Return a list of the components of the matroid. @@ -4827,7 +4827,7 @@ cdef class Matroid(SageObject): components = components2 return components - cpdef is_connected(self, certificate=False): + cpdef is_connected(self, certificate=False) noexcept: r""" Test if the matroid is connected. @@ -4867,7 +4867,7 @@ cdef class Matroid(SageObject): else: return False - cpdef connectivity(self, S, T=None): + cpdef connectivity(self, S, T=None) noexcept: r""" Evaluate the connectivity function of the matroid. @@ -4908,7 +4908,7 @@ cdef class Matroid(SageObject): raise ValueError("S and T are not disjoint") return len(self._link(S, T)[0]) - self.full_rank() + self._rank(S) + self._rank(T) - cpdef _connectivity(self, S, T): + cpdef _connectivity(self, S, T) noexcept: r""" Return the connectivity of two subsets ``S`` and ``T`` in the matroid. @@ -4947,7 +4947,7 @@ cdef class Matroid(SageObject): """ return len(self._link(S,T)[0]) - self.full_rank() + self.rank(S) + self.rank(T) - cpdef link(self, S, T): + cpdef link(self, S, T) noexcept: r""" Given disjoint subsets `S` and `T`, return a connector `I` and a separation `X`, which are optimal dual solutions in Tutte's Linking Theorem: @@ -4994,7 +4994,7 @@ cdef class Matroid(SageObject): raise ValueError("S and T are not disjoint") return self._link(S, T) - cpdef _link(self, S, T): + cpdef _link(self, S, T) noexcept: r""" Given disjoint subsets `S` and `T`, return a connector `I` and a separation `X`, which are optimal dual solutions in Tutte's Linking Theorem: @@ -5077,7 +5077,7 @@ cdef class Matroid(SageObject): I = I.symmetric_difference(path) return frozenset(I), frozenset(predecessor)|S - cpdef is_kconnected(self, k, certificate=False): + cpdef is_kconnected(self, k, certificate=False) noexcept: r""" Return ``True`` if the matroid is `k`-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -5203,7 +5203,7 @@ cdef class Matroid(SageObject): return True, None return True - cpdef is_3connected(self, certificate=False, algorithm=None): + cpdef is_3connected(self, certificate=False, algorithm=None) noexcept: r""" Return ``True`` if the matroid is 3-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -5283,7 +5283,7 @@ cdef class Matroid(SageObject): return self._is_3connected_shifting(certificate) raise ValueError("Not a valid algorithm.") - cpdef is_4connected(self, certificate=False, algorithm=None): + cpdef is_4connected(self, certificate=False, algorithm=None) noexcept: r""" Return ``True`` if the matroid is 4-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -5335,7 +5335,7 @@ cdef class Matroid(SageObject): return self._is_4connected_shifting(certificate) raise ValueError("Not a valid algorithm.") - cpdef _is_3connected_CE(self, certificate=False): + cpdef _is_3connected_CE(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 3-connected, ``False`` otherwise. @@ -5463,7 +5463,7 @@ cdef class Matroid(SageObject): else: return True - cpdef _is_3connected_shifting(self, certificate=False): + cpdef _is_3connected_shifting(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 3-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -5541,7 +5541,7 @@ cdef class Matroid(SageObject): return True, None return True - cpdef _is_4connected_shifting(self, certificate=False): + cpdef _is_4connected_shifting(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 4-connected, ``False`` otherwise. It can optionally return a separator as a witness. @@ -5645,7 +5645,7 @@ cdef class Matroid(SageObject): return True, None return True - cpdef _shifting_all(self, X, P_rows, P_cols, Q_rows, Q_cols, m): + cpdef _shifting_all(self, X, P_rows, P_cols, Q_rows, Q_cols, m) noexcept: r""" Given a basis ``X``. If the submatrix of the partial matrix using rows `P_rows` columns `P_cols` and submatrix using rows `Q_rows` columns @@ -5707,7 +5707,7 @@ cdef class Matroid(SageObject): return True, cert return False, None - cpdef _shifting(self, X, X_1, Y_2, X_2, Y_1, m): + cpdef _shifting(self, X, X_1, Y_2, X_2, Y_1, m) noexcept: r""" Given a basis ``X``. If the submatrix of the partial matrix using rows `X_1` columns `Y_2` and submatrix using rows `X_2` columns @@ -5799,7 +5799,7 @@ cdef class Matroid(SageObject): return False, None return True, S_2 - cpdef _is_3connected_BC(self, certificate=False): + cpdef _is_3connected_BC(self, certificate=False) noexcept: r""" Return ``True`` if the matroid is 3-connected, ``False`` otherwise. @@ -5855,7 +5855,7 @@ cdef class Matroid(SageObject): fund_cocircuits = set([self._fundamental_cocircuit(basis, e) for e in basis]) return self._is_3connected_BC_recursion(self.basis(), fund_cocircuits) - cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits): + cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits) noexcept: r""" A helper function for ``_is_3connected_BC``. This method assumes the matroid is both simple and cosimple. Under the assumption, it return @@ -5955,7 +5955,7 @@ cdef class Matroid(SageObject): # representability - cpdef _local_binary_matroid(self, basis=None): + cpdef _local_binary_matroid(self, basis=None) noexcept: r""" Return a binary matroid `M` so that relative to a fixed basis `B`, `X` is a basis of ``self`` if and only if `X` is a basis of `M` @@ -5996,7 +5996,7 @@ cdef class Matroid(SageObject): from sage.matroids.linear_matroid import BinaryMatroid return BinaryMatroid(groundset=E, matrix=A, basis=basis, keep_initial_representation=False) - cpdef binary_matroid(self, randomized_tests=1, verify = True): + cpdef binary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a binary matroid representing ``self``, if such a representation exists. @@ -6054,7 +6054,7 @@ cdef class Matroid(SageObject): else: return None - cpdef is_binary(self, randomized_tests=1): + cpdef is_binary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a binary matroid. @@ -6092,7 +6092,7 @@ cdef class Matroid(SageObject): """ return self.binary_matroid(randomized_tests=randomized_tests, verify=True) is not None - cpdef _local_ternary_matroid(self, basis=None): + cpdef _local_ternary_matroid(self, basis=None) noexcept: r""" Return a ternary matroid `M` so that if ``self`` is ternary, then `M` is field isomorphic to ``self``. @@ -6183,7 +6183,7 @@ cdef class Matroid(SageObject): from sage.matroids.linear_matroid import TernaryMatroid return TernaryMatroid(groundset=E, matrix=A, basis=basis, keep_initial_representation=False) - cpdef ternary_matroid(self, randomized_tests=1, verify = True): + cpdef ternary_matroid(self, randomized_tests=1, verify = True) noexcept: r""" Return a ternary matroid representing ``self``, if such a representation exists. @@ -6241,7 +6241,7 @@ cdef class Matroid(SageObject): else: return None - cpdef is_ternary(self, randomized_tests=1): + cpdef is_ternary(self, randomized_tests=1) noexcept: r""" Decide if ``self`` is a ternary matroid. @@ -6281,7 +6281,7 @@ cdef class Matroid(SageObject): # matroid k-closed - cpdef is_k_closed(self, int k): + cpdef is_k_closed(self, int k) noexcept: r""" Return if ``self`` is a ``k``-closed matroid. @@ -6318,7 +6318,7 @@ cdef class Matroid(SageObject): # matroid chordality - cpdef _is_circuit_chordal(self, frozenset C, bint certificate=False): + cpdef _is_circuit_chordal(self, frozenset C, bint certificate=False) noexcept: """ Check if the circuit ``C`` has a chord. @@ -6366,7 +6366,7 @@ cdef class Matroid(SageObject): return False, None return False - cpdef is_circuit_chordal(self, C, bint certificate=False): + cpdef is_circuit_chordal(self, C, bint certificate=False) noexcept: r""" Check if the circuit ``C`` has a chord. @@ -6408,7 +6408,7 @@ cdef class Matroid(SageObject): raise ValueError("input C is not a circuit") return self._is_circuit_chordal(frozenset(C), certificate) - cpdef is_chordal(self, k1=4, k2=None, bint certificate=False): + cpdef is_chordal(self, k1=4, k2=None, bint certificate=False) noexcept: r""" Return if a matroid is ``[k1, k2]``-chordal. @@ -6463,7 +6463,7 @@ cdef class Matroid(SageObject): return False return True - cpdef chordality(self): + cpdef chordality(self) noexcept: r""" Return the minimal `k` such that the matroid ``M`` is `k`-chordal. @@ -6495,7 +6495,7 @@ cdef class Matroid(SageObject): # optimization - cpdef max_weight_independent(self, X=None, weights=None): + cpdef max_weight_independent(self, X=None, weights=None) noexcept: r""" Return a maximum-weight independent set contained in a subset. @@ -6582,7 +6582,7 @@ cdef class Matroid(SageObject): res.discard(e) return frozenset(res) - cpdef max_weight_coindependent(self, X=None, weights=None): + cpdef max_weight_coindependent(self, X=None, weights=None) noexcept: r""" Return a maximum-weight coindependent set contained in ``X``. @@ -6674,7 +6674,7 @@ cdef class Matroid(SageObject): res.discard(e) return frozenset(res) - cpdef is_max_weight_independent_generic(self, X=None, weights=None): + cpdef is_max_weight_independent_generic(self, X=None, weights=None) noexcept: r""" Test if only one basis of the subset ``X`` has maximal weight. @@ -6823,7 +6823,7 @@ cdef class Matroid(SageObject): del res[-1] return True - cpdef is_max_weight_coindependent_generic(self, X=None, weights=None): + cpdef is_max_weight_coindependent_generic(self, X=None, weights=None) noexcept: r""" Test if only one cobasis of the subset ``X`` has maximal weight. @@ -6980,7 +6980,7 @@ cdef class Matroid(SageObject): del res[-1] return True - cpdef intersection(self, other, weights=None): + cpdef intersection(self, other, weights=None) noexcept: r""" Return a maximum-weight common independent set. @@ -7038,7 +7038,7 @@ cdef class Matroid(SageObject): raise TypeError("the weights argument does not seem to be a collection of weights for the groundset.") return self._intersection(other, wt) - cpdef _intersection(self, other, weights): + cpdef _intersection(self, other, weights) noexcept: r""" Return a maximum-weight common independent. @@ -7078,7 +7078,7 @@ cdef class Matroid(SageObject): U = self._intersection_augmentation(other, weights, Y) return Y - cpdef _intersection_augmentation(self, other, weights, Y): + cpdef _intersection_augmentation(self, other, weights, Y) noexcept: r""" Return an augmenting set for the matroid intersection problem. @@ -7169,7 +7169,7 @@ cdef class Matroid(SageObject): path.add(u) return True, frozenset(path) - cpdef intersection_unweighted(self, other): + cpdef intersection_unweighted(self, other) noexcept: r""" Return a maximum-cardinality common independent set. @@ -7205,7 +7205,7 @@ cdef class Matroid(SageObject): raise ValueError("matroid intersection requires equal groundsets.") return self._intersection_unweighted(other) - cpdef _intersection_unweighted(self, other): + cpdef _intersection_unweighted(self, other) noexcept: r""" Return a maximum common independent. @@ -7241,7 +7241,7 @@ cdef class Matroid(SageObject): U = self._intersection_augmentation_unweighted(other, Y) return Y - cpdef _intersection_augmentation_unweighted(self, other, Y): + cpdef _intersection_augmentation_unweighted(self, other, Y) noexcept: r""" Return a common independent set larger than `Y` or report failure. @@ -7377,7 +7377,7 @@ cdef class Matroid(SageObject): predecessor[v] = u return True, Y - cpdef partition(self): + cpdef partition(self) noexcept: r""" Return a minimum number of disjoint independent sets that covers the groundset. @@ -7443,7 +7443,7 @@ cdef class Matroid(SageObject): # invariants - cpdef _internal(self, B): + cpdef _internal(self, B) noexcept: """ Return the set of internally active elements of a basis `B`. @@ -7482,7 +7482,7 @@ cdef class Matroid(SageObject): A.add(e) return A - cpdef _external(self, B): + cpdef _external(self, B) noexcept: """ Return the set of externally active elements of a basis `B`. @@ -7522,7 +7522,7 @@ cdef class Matroid(SageObject): A.add(e) return A - cpdef tutte_polynomial(self, x=None, y=None): + cpdef tutte_polynomial(self, x=None, y=None) noexcept: r""" Return the Tutte polynomial of the matroid. @@ -7583,7 +7583,7 @@ cdef class Matroid(SageObject): T = T(a, b) return T - cpdef flat_cover(self, solver=None, verbose=0, integrality_tolerance=1e-3): + cpdef flat_cover(self, solver=None, verbose=0, integrality_tolerance=1e-3) noexcept: """ Return a minimum-size cover of the nonbases by non-spanning flats. @@ -7738,7 +7738,7 @@ cdef class Matroid(SageObject): ret.rename("Chow ring of {} over {}".format(self, R)) return ret - cpdef plot(self, B=None, lineorders=None, pos_method=None,pos_dict=None,save_pos=False): + cpdef plot(self, B=None, lineorders=None, pos_method=None,pos_dict=None,save_pos=False) noexcept: """ Return geometric representation as a sage graphics object. @@ -7799,7 +7799,7 @@ cdef class Matroid(SageObject): lineorders2=matroids_plot_helpers.lineorders_union(self._cached_info['lineorders'],lineorders) return matroids_plot_helpers.geomrep(self,B,lineorders2,pd=pos_dict, sp=save_pos) - cpdef show(self,B=None,lineorders=None,pos_method=None,pos_dict=None,save_pos=False,lims=None): + cpdef show(self,B=None,lineorders=None,pos_method=None,pos_dict=None,save_pos=False,lims=None) noexcept: """ Show the geometric representation of the matroid. @@ -7848,7 +7848,7 @@ cdef class Matroid(SageObject): G.show(xmin=lims[0], xmax=lims[1], ymin=lims[2], ymax=lims[3]) return - cpdef _fix_positions(self,pos_dict=None,lineorders=None): + cpdef _fix_positions(self,pos_dict=None,lineorders=None) noexcept: """ Cache point positions and line orders without actually plotting @@ -7916,7 +7916,7 @@ cdef class Matroid(SageObject): from sage.topology.simplicial_complex import SimplicialComplex return SimplicialComplex(self.no_broken_circuits_sets(ordering)) - cpdef bergman_complex(self): + cpdef bergman_complex(self) noexcept: r""" Return the Bergman complex of ``self``. @@ -7941,7 +7941,7 @@ cdef class Matroid(SageObject): L = self.lattice_of_flats() return L.subposet(L.list()[1: -1]).order_complex() - cpdef augmented_bergman_complex(self): + cpdef augmented_bergman_complex(self) noexcept: r""" Return the augmented Bergman complex of ``self``. diff --git a/src/sage/matroids/set_system.pxd b/src/sage/matroids/set_system.pxd index c1b0b75f1e5..69a4bc8443c 100644 --- a/src/sage/matroids/set_system.pxd +++ b/src/sage/matroids/set_system.pxd @@ -8,29 +8,29 @@ cdef class SetSystem: cdef long _len, _capacity cdef bitset_t _temp - cdef copy(self) - cdef _relabel(self, l) - cpdef _complements(self) + cdef copy(self) noexcept + cdef _relabel(self, l) noexcept + cpdef _complements(self) noexcept - cdef resize(self, k=*) - cdef _append(self, bitset_t X) - cdef append(self, X) - cdef _subset(self, long k) - cdef subset(self, k) - cpdef _get_groundset(self) + cdef resize(self, k=*) noexcept + cdef _append(self, bitset_t X) noexcept + cdef append(self, X) noexcept + cdef _subset(self, long k) noexcept + cdef subset(self, k) noexcept + cpdef _get_groundset(self) noexcept - cdef list _incidence_count(self, E) - cdef SetSystem _groundset_partition(self, SetSystem P, list cnt) - cdef long subset_characteristic(self, SetSystem P, long e) - cdef subsets_partition(self, SetSystem P=*, E=*) - cdef _distinguish(self, Py_ssize_t v) - cpdef is_connected(self) + cdef list _incidence_count(self, E) noexcept + cdef SetSystem _groundset_partition(self, SetSystem P, list cnt) noexcept + cdef long subset_characteristic(self, SetSystem P, long e) noexcept + cdef subsets_partition(self, SetSystem P=*, E=*) noexcept + cdef _distinguish(self, Py_ssize_t v) noexcept + cpdef is_connected(self) noexcept - cdef initial_partition(self, SetSystem P=*, E=*) - cpdef _equitable_partition(self, SetSystem P=*, EP=*) - cpdef _heuristic_partition(self, SetSystem P=*, EP=*) - cpdef _isomorphism(self, SetSystem other, SetSystem SP=*, SetSystem OP=*) - cpdef _equivalence(self, is_equiv, SetSystem other, SetSystem SP=*, SetSystem OP=*) + cdef initial_partition(self, SetSystem P=*, E=*) noexcept + cpdef _equitable_partition(self, SetSystem P=*, EP=*) noexcept + cpdef _heuristic_partition(self, SetSystem P=*, EP=*) noexcept + cpdef _isomorphism(self, SetSystem other, SetSystem SP=*, SetSystem OP=*) noexcept + cpdef _equivalence(self, is_equiv, SetSystem other, SetSystem SP=*, SetSystem OP=*) noexcept cdef class SetSystemIterator: cdef SetSystem _H diff --git a/src/sage/matroids/set_system.pyx b/src/sage/matroids/set_system.pyx index cb4daf4099a..1c943ed6203 100644 --- a/src/sage/matroids/set_system.pyx +++ b/src/sage/matroids/set_system.pyx @@ -202,14 +202,14 @@ cdef class SetSystem: """ return "Iterator over a system of subsets" - cdef copy(self): + cdef copy(self) noexcept: cdef SetSystem S S = SetSystem(self._groundset, capacity=len(self)) for i in range(len(self)): S._append(self._subsets[i]) return S - cdef _relabel(self, l): + cdef _relabel(self, l) noexcept: """ Relabel each element `e` of the ground set as `l(e)`, where `l` is a given injective map. @@ -235,7 +235,7 @@ cdef class SetSystem: for i in range(self._groundset_size): self._idx[self._groundset[i]] = i - cpdef _complements(self): + cpdef _complements(self) noexcept: """ Return a SetSystem containing the complements of each element in the groundset. @@ -260,7 +260,7 @@ cdef class SetSystem: S._append(self._temp) return S - cdef inline resize(self, k=None): + cdef inline resize(self, k=None) noexcept: """ Change the capacity of the SetSystem. """ @@ -273,7 +273,7 @@ cdef class SetSystem: self._subsets = check_reallocarray(self._subsets, k2, sizeof(bitset_t)) self._capacity = k2 - cdef inline _append(self, bitset_t X): + cdef inline _append(self, bitset_t X) noexcept: """ Append subset in internal, bitset format """ @@ -283,7 +283,7 @@ cdef class SetSystem: bitset_copy(self._subsets[self._len], X) self._len += 1 - cdef inline append(self, X): + cdef inline append(self, X) noexcept: """ Append subset. """ @@ -295,13 +295,13 @@ cdef class SetSystem: bitset_add(self._subsets[self._len], self._idx[x]) self._len += 1 - cdef inline _subset(self, long k): + cdef inline _subset(self, long k) noexcept: """ Return the k-th subset, in index format. """ return bitset_list(self._subsets[k]) - cdef subset(self, k): + cdef subset(self, k) noexcept: """ Return the k-th subset. """ @@ -313,7 +313,7 @@ cdef class SetSystem: i = bitset_next(self._subsets[k], i + 1) return frozenset(F) - cpdef _get_groundset(self): + cpdef _get_groundset(self) noexcept: """ Return the ground set of this SetSystem. @@ -326,7 +326,7 @@ cdef class SetSystem: """ return frozenset(self._groundset) - cpdef is_connected(self): + cpdef is_connected(self) noexcept: """ Test if the :class:`SetSystem` is connected. @@ -381,7 +381,7 @@ cdef class SetSystem: # isomorphism - cdef list _incidence_count(self, E): + cdef list _incidence_count(self, E) noexcept: """ For the sub-collection indexed by ``E``, count how often each element occurs. @@ -396,7 +396,7 @@ cdef class SetSystem: i = bitset_next(self._subsets[e], i + 1) return cnt - cdef SetSystem _groundset_partition(self, SetSystem P, list cnt): + cdef SetSystem _groundset_partition(self, SetSystem P, list cnt) noexcept: """ Helper method for partition methods below. """ @@ -437,7 +437,7 @@ cdef class SetSystem: bitset_discard(P._subsets[i], v) P._append(self._temp) - cdef long subset_characteristic(self, SetSystem P, long e): + cdef long subset_characteristic(self, SetSystem P, long e) noexcept: """ Helper method for partition methods below. """ @@ -449,7 +449,7 @@ cdef class SetSystem: c += bitset_len(self._temp) return c - cdef subsets_partition(self, SetSystem P=None, E=None): + cdef subsets_partition(self, SetSystem P=None, E=None) noexcept: """ Helper method for partition methods below. """ @@ -478,7 +478,7 @@ cdef class SetSystem: EP.append(ep) return EP, hash(tuple(eh)) - cdef _distinguish(self, Py_ssize_t v): + cdef _distinguish(self, Py_ssize_t v) noexcept: """ Helper method for partition methods below. """ @@ -493,7 +493,7 @@ cdef class SetSystem: return S # partition functions - cdef initial_partition(self, SetSystem P=None, E=None): + cdef initial_partition(self, SetSystem P=None, E=None) noexcept: """ Helper method for partition methods below. """ @@ -508,7 +508,7 @@ cdef class SetSystem: self._groundset_partition(P, cnt) return P - cpdef _equitable_partition(self, SetSystem P=None, EP=None): + cpdef _equitable_partition(self, SetSystem P=None, EP=None) noexcept: r""" Return an equitable ordered partition of the ground set of the hypergraph whose edges are the subsets in this SetSystem. @@ -589,7 +589,7 @@ cdef class SetSystem: return P, EP, h - cpdef _heuristic_partition(self, SetSystem P=None, EP=None): + cpdef _heuristic_partition(self, SetSystem P=None, EP=None) noexcept: """ Return an heuristic ordered partition into singletons of the ground set of the hypergraph whose edges are the subsets in this SetSystem. @@ -637,7 +637,7 @@ cdef class SetSystem: return self._heuristic_partition(P._distinguish(bitset_first(P._subsets[i])), EP) return P, EP, h - cpdef _isomorphism(self, SetSystem other, SetSystem SP=None, SetSystem OP=None): + cpdef _isomorphism(self, SetSystem other, SetSystem SP=None, SetSystem OP=None) noexcept: """ Return a groundset isomorphism between this SetSystem and an other. @@ -697,7 +697,7 @@ cdef class SetSystem: return None return dict([(self._groundset[bitset_first(SP._subsets[i])], other._groundset[bitset_first(OP._subsets[i])]) for i in range(len(SP))]) - cpdef _equivalence(self, is_equiv, SetSystem other, SetSystem SP=None, SetSystem OP=None): + cpdef _equivalence(self, is_equiv, SetSystem other, SetSystem SP=None, SetSystem OP=None) noexcept: """ Return a groundset isomorphism that is an equivalence between this SetSystem and an other. diff --git a/src/sage/matroids/union_matroid.pxd b/src/sage/matroids/union_matroid.pxd index 5511a62af3b..6e3a6e8d96e 100644 --- a/src/sage/matroids/union_matroid.pxd +++ b/src/sage/matroids/union_matroid.pxd @@ -3,17 +3,17 @@ from .matroid cimport Matroid cdef class MatroidUnion(Matroid): cdef list matroids cdef frozenset _groundset - cpdef groundset(self) - cpdef _rank(self, X) + cpdef groundset(self) noexcept + cpdef _rank(self, X) noexcept cdef class MatroidSum(Matroid): cdef list summands cdef frozenset _groundset - cpdef groundset(self) - cpdef _rank(self, X) + cpdef groundset(self) noexcept + cpdef _rank(self, X) noexcept cdef class PartitionMatroid(Matroid): cdef dict p cdef frozenset _groundset - cpdef groundset(self) - cpdef _rank(self, X) + cpdef groundset(self) noexcept + cpdef _rank(self, X) noexcept diff --git a/src/sage/matroids/union_matroid.pyx b/src/sage/matroids/union_matroid.pyx index f97de43c766..802b8d609f4 100644 --- a/src/sage/matroids/union_matroid.pyx +++ b/src/sage/matroids/union_matroid.pyx @@ -53,7 +53,7 @@ cdef class MatroidUnion(Matroid): E.update(M.groundset()) self._groundset = frozenset(E) - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -72,7 +72,7 @@ cdef class MatroidUnion(Matroid): """ return self._groundset - cpdef _rank(self, X): + cpdef _rank(self, X) noexcept: r""" Return the rank of a set ``X``. @@ -187,7 +187,7 @@ cdef class MatroidSum(Matroid): S = S + M._repr_() +"\n" return S[:-1] - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -206,7 +206,7 @@ cdef class MatroidSum(Matroid): """ return self._groundset - cpdef _rank(self, X): + cpdef _rank(self, X) noexcept: r""" Return the rank of a set ``X``. @@ -286,7 +286,7 @@ cdef class PartitionMatroid(Matroid): E.update(P) self._groundset = frozenset(E) - cpdef groundset(self): + cpdef groundset(self) noexcept: """ Return the groundset of the matroid. @@ -305,7 +305,7 @@ cdef class PartitionMatroid(Matroid): """ return self._groundset - cpdef _rank(self, X): + cpdef _rank(self, X) noexcept: r""" Return the rank of a set ``X``. diff --git a/src/sage/misc/allocator.pxd b/src/sage/misc/allocator.pxd index 7945a75241f..ba4321cf71c 100644 --- a/src/sage/misc/allocator.pxd +++ b/src/sage/misc/allocator.pxd @@ -1,5 +1,5 @@ from cpython.object cimport * -cdef hook_tp_functions_type(object t, newfunc tp_new, destructor tp_dealloc, bint useGC) +cdef hook_tp_functions_type(object t, newfunc tp_new, destructor tp_dealloc, bint useGC) noexcept -cdef hook_tp_functions(object global_dummy, newfunc tp_new, destructor tp_dealloc, bint useGC) +cdef hook_tp_functions(object global_dummy, newfunc tp_new, destructor tp_dealloc, bint useGC) noexcept diff --git a/src/sage/misc/allocator.pyx b/src/sage/misc/allocator.pyx index b7fafdce286..b6d865b00e6 100644 --- a/src/sage/misc/allocator.pyx +++ b/src/sage/misc/allocator.pyx @@ -1,6 +1,6 @@ from cpython.ref cimport Py_INCREF -cdef _hook_tp_functions_type(PyTypeObject *t, newfunc tp_new, destructor tp_dealloc, bint useGC): +cdef _hook_tp_functions_type(PyTypeObject *t, newfunc tp_new, destructor tp_dealloc, bint useGC) noexcept: """ Initialize the fast integer creation functions. """ @@ -25,12 +25,12 @@ cdef _hook_tp_functions_type(PyTypeObject *t, newfunc tp_new, destructor tp_deal t.tp_dealloc = tp_dealloc -cdef hook_tp_functions_type(object tp, newfunc tp_new, destructor tp_dealloc, bint useGC): +cdef hook_tp_functions_type(object tp, newfunc tp_new, destructor tp_dealloc, bint useGC) noexcept: cdef PyTypeObject *t = tp _hook_tp_functions_type(t, tp_new, tp_dealloc, useGC) -cdef hook_tp_functions(object global_dummy, newfunc tp_new, destructor tp_dealloc, bint useGC): +cdef hook_tp_functions(object global_dummy, newfunc tp_new, destructor tp_dealloc, bint useGC) noexcept: """ Initialize the fast integer creation functions. """ diff --git a/src/sage/misc/binary_tree.pyx b/src/sage/misc/binary_tree.pyx index b23c9ee7266..6287753a335 100644 --- a/src/sage/misc/binary_tree.pyx +++ b/src/sage/misc/binary_tree.pyx @@ -11,7 +11,7 @@ from cysignals.memory cimport sig_malloc, sig_free from cpython.ref cimport PyObject, Py_INCREF, Py_XDECREF -cdef binary_tree_node *BinaryTreeNode(int key, object value): +cdef binary_tree_node *BinaryTreeNode(int key, object value) noexcept: cdef binary_tree_node *t t = sig_malloc(sizeof(binary_tree_node)) t.key = key @@ -21,18 +21,18 @@ cdef binary_tree_node *BinaryTreeNode(int key, object value): t.value = value return t -cdef void free_binary_tree_node(binary_tree_node *self): +cdef void free_binary_tree_node(binary_tree_node *self) noexcept: Py_XDECREF(self.value) sig_free(self) -cdef inline void binary_tree_dealloc(binary_tree_node *self): +cdef inline void binary_tree_dealloc(binary_tree_node *self) noexcept: if self != NULL: binary_tree_dealloc(self.left) binary_tree_dealloc(self.right) free_binary_tree_node(self) -cdef void binary_tree_insert(binary_tree_node *self, int key, object value): +cdef void binary_tree_insert(binary_tree_node *self, int key, object value) noexcept: if self.key == key: return elif self.key > key: @@ -46,7 +46,7 @@ cdef void binary_tree_insert(binary_tree_node *self, int key, object value): else: binary_tree_insert(self.right, key, value) -cdef object binary_tree_get(binary_tree_node *self, int key): +cdef object binary_tree_get(binary_tree_node *self, int key) noexcept: if self.key == key: return self.value elif self.key > key: @@ -60,7 +60,7 @@ cdef object binary_tree_get(binary_tree_node *self, int key): else: return binary_tree_get(self.right, key) -cdef object binary_tree_delete(binary_tree_node *self, int key): +cdef object binary_tree_delete(binary_tree_node *self, int key) noexcept: cdef object t if self.key > key: if self.left == NULL: @@ -81,7 +81,7 @@ cdef object binary_tree_delete(binary_tree_node *self, int key): else: return binary_tree_delete(self.right, key) -cdef binary_tree_node *binary_tree_left_excise(binary_tree_node *self): +cdef binary_tree_node *binary_tree_left_excise(binary_tree_node *self) noexcept: cdef binary_tree_node *left cdef binary_tree_node *cur if self.left == NULL: @@ -99,7 +99,7 @@ cdef binary_tree_node *binary_tree_left_excise(binary_tree_node *self): -cdef binary_tree_node *binary_tree_right_excise(binary_tree_node *self): +cdef binary_tree_node *binary_tree_right_excise(binary_tree_node *self) noexcept: cdef binary_tree_node *right cdef binary_tree_node *cur if self.right == NULL: @@ -116,7 +116,7 @@ cdef binary_tree_node *binary_tree_right_excise(binary_tree_node *self): return right -cdef binary_tree_node *binary_tree_head_excise(binary_tree_node *self): +cdef binary_tree_node *binary_tree_head_excise(binary_tree_node *self) noexcept: cdef binary_tree_node *cur cdef int right # We have a pointer we're about to free. Chances are, we'll never @@ -152,7 +152,7 @@ LIST_POSTORDER = 4 LIST_KEYS = 8 LIST_VALUES = 16 -cdef object binary_tree_list(binary_tree_node *cur, int behavior): +cdef object binary_tree_list(binary_tree_node *cur, int behavior) noexcept: if behavior & LIST_KEYS: item = int(cur.key) else: diff --git a/src/sage/misc/c3.pyx b/src/sage/misc/c3.pyx index d777a0e25ca..47fed790dfe 100644 --- a/src/sage/misc/c3.pyx +++ b/src/sage/misc/c3.pyx @@ -21,7 +21,7 @@ AUTHOR: # **************************************************************************** -cpdef list C3_algorithm(object start, str bases, str attribute, bint proper): +cpdef list C3_algorithm(object start, str bases, str attribute, bint proper) noexcept: """ An implementation of the C3 algorithm. diff --git a/src/sage/misc/c3_controlled.pxd b/src/sage/misc/c3_controlled.pxd index d5dd5c23183..7383b0cf999 100644 --- a/src/sage/misc/c3_controlled.pxd +++ b/src/sage/misc/c3_controlled.pxd @@ -1 +1 @@ -cpdef tuple C3_sorted_merge(list lists, key=?) +cpdef tuple C3_sorted_merge(list lists, key=?) noexcept diff --git a/src/sage/misc/c3_controlled.pyx b/src/sage/misc/c3_controlled.pyx index 442dda7264f..6e34f0a4ba8 100644 --- a/src/sage/misc/c3_controlled.pyx +++ b/src/sage/misc/c3_controlled.pyx @@ -659,7 +659,7 @@ def C3_merge(list lists): raise ValueError("Cannot merge the items %s."%', '.join(repr(head) for head in heads)) return out -cpdef identity(x): +cpdef identity(x) noexcept: r""" EXAMPLES:: @@ -669,7 +669,7 @@ cpdef identity(x): """ return x -cpdef tuple C3_sorted_merge(list lists, key=identity): +cpdef tuple C3_sorted_merge(list lists, key=identity) noexcept: r""" Return the sorted input lists merged using the ``C3`` algorithm, with a twist. diff --git a/src/sage/misc/cachefunc.pxd b/src/sage/misc/cachefunc.pxd index 8e5d9dfa42a..747e9b60df0 100644 --- a/src/sage/misc/cachefunc.pxd +++ b/src/sage/misc/cachefunc.pxd @@ -1,7 +1,7 @@ from .function_mangling cimport ArgumentFixer -cpdef dict_key(o) -cpdef cache_key(o) +cpdef dict_key(o) noexcept +cpdef cache_key(o) noexcept cdef class CachedFunction(): cdef public str __name__ @@ -11,8 +11,8 @@ cdef class CachedFunction(): cdef public cache # not always of type cdef bint is_classmethod cdef int argfix_init(self) except -1 - cdef get_key_args_kwds(self, tuple args, dict kwds) - cdef fix_args_kwds(self, tuple args, dict kwds) + cdef get_key_args_kwds(self, tuple args, dict kwds) noexcept + cdef fix_args_kwds(self, tuple args, dict kwds) noexcept cdef empty_key cdef key cdef bint do_pickle @@ -23,7 +23,7 @@ cdef class CachedMethod(): cdef public str __cached_module__ cdef CachedFunction _cachedfunc cdef Py_ssize_t nargs - cpdef _get_instance_cache(self, inst) + cpdef _get_instance_cache(self, inst) noexcept cdef class CacheDict(dict): pass diff --git a/src/sage/misc/cachefunc.pyx b/src/sage/misc/cachefunc.pyx index 2b1d38c12b9..20b3b5acbe4 100644 --- a/src/sage/misc/cachefunc.pyx +++ b/src/sage/misc/cachefunc.pyx @@ -535,7 +535,7 @@ cdef class NonpicklingDict(dict): cdef unhashable_key = object() -cpdef inline dict_key(o): +cpdef inline dict_key(o) noexcept: """ Return a key to cache object ``o`` in a dict. @@ -560,7 +560,7 @@ cpdef inline dict_key(o): return o -cpdef inline cache_key(o): +cpdef inline cache_key(o) noexcept: r""" Helper function to return a hashable key for ``o`` which can be used for caching. @@ -600,7 +600,7 @@ cpdef inline cache_key(o): return o -cdef cache_key_unhashable(o): +cdef cache_key_unhashable(o) noexcept: """ Return a key for caching an item which is unhashable. """ @@ -786,7 +786,7 @@ cdef class CachedFunction(): def __module__(self): return self.__cached_module__ - cdef get_key_args_kwds(self, tuple args, dict kwds): + cdef get_key_args_kwds(self, tuple args, dict kwds) noexcept: """ Return the key in the cache to be used when ``args`` and ``kwds`` are passed in as parameters. @@ -814,7 +814,7 @@ cdef class CachedFunction(): self._argument_fixer = ArgumentFixer(self.f, classmethod=self.is_classmethod) - cdef fix_args_kwds(self, tuple args, dict kwds): + cdef fix_args_kwds(self, tuple args, dict kwds) noexcept: r""" Normalize parameters to obtain a key for the cache. @@ -1841,7 +1841,7 @@ cdef class CachedMethodCaller(CachedFunction): """ return self.f(self._instance, *args, **kwds) - cdef fix_args_kwds(self, tuple args, dict kwds): + cdef fix_args_kwds(self, tuple args, dict kwds) noexcept: r""" Normalize parameters to obtain a key for the cache. @@ -2505,7 +2505,7 @@ cdef class GloballyCachedMethodCaller(CachedMethodCaller): The only difference is that the instance is used as part of the key. """ - cdef get_key_args_kwds(self, tuple args, dict kwds): + cdef get_key_args_kwds(self, tuple args, dict kwds) noexcept: """ Return the key in the cache to be used when ``args`` and ``kwds`` are passed in as parameters. @@ -2750,7 +2750,7 @@ cdef class CachedMethod(): """ return self.__get__(inst)(*args, **kwds) - cpdef _get_instance_cache(self, inst): + cpdef _get_instance_cache(self, inst) noexcept: """ Return the cache dictionary. @@ -3238,7 +3238,7 @@ cdef class CachedInParentMethod(CachedMethod): self._cache_name = '_cache__' + 'element_' + (name or f.__name__) self._cachedfunc = CachedFunction(f, classmethod=True, name=name, key=key, do_pickle=do_pickle) - cpdef _get_instance_cache(self, inst): + cpdef _get_instance_cache(self, inst) noexcept: """ Return the cache dictionary, which is stored in the parent. diff --git a/src/sage/misc/citation.pyx b/src/sage/misc/citation.pyx index 9377ce73636..aca83edf22c 100644 --- a/src/sage/misc/citation.pyx +++ b/src/sage/misc/citation.pyx @@ -143,7 +143,7 @@ cdef extern from *: """ -cpdef inline bint cython_profile_enabled(): +cpdef inline bint cython_profile_enabled() noexcept: """ Return whether Cython profiling is enabled. diff --git a/src/sage/misc/fast_methods.pxd b/src/sage/misc/fast_methods.pxd index de5c496c168..4df34feab62 100644 --- a/src/sage/misc/fast_methods.pxd +++ b/src/sage/misc/fast_methods.pxd @@ -4,7 +4,7 @@ cdef extern from "Python.h": cdef class FastHashable_class: cdef Py_ssize_t _hash -cdef inline long hash_by_id(void * p): +cdef inline long hash_by_id(void * p) noexcept: r""" This function is a copy paste from the default Python hash function. """ diff --git a/src/sage/misc/function_mangling.pxd b/src/sage/misc/function_mangling.pxd index 01604088adc..74f1a6e2282 100644 --- a/src/sage/misc/function_mangling.pxd +++ b/src/sage/misc/function_mangling.pxd @@ -7,4 +7,4 @@ cdef class ArgumentFixer: cdef dict _defaults cdef public tuple _default_tuple - cdef fix_to_pos_args_kwds(self, tuple args, dict kwargs) + cdef fix_to_pos_args_kwds(self, tuple args, dict kwargs) noexcept diff --git a/src/sage/misc/function_mangling.pyx b/src/sage/misc/function_mangling.pyx index 1392fc4f2fd..c614f97e9df 100644 --- a/src/sage/misc/function_mangling.pyx +++ b/src/sage/misc/function_mangling.pyx @@ -284,7 +284,7 @@ cdef class ArgumentFixer: """ return self.fix_to_pos_args_kwds(args, kwds) - cdef fix_to_pos_args_kwds(self, tuple args, dict kwds): + cdef fix_to_pos_args_kwds(self, tuple args, dict kwds) noexcept: """ Fast Cython implementation of :meth:`fix_to_pos`. """ diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx index 7fc73407ace..0ac9fb03d95 100644 --- a/src/sage/misc/lazy_import.pyx +++ b/src/sage/misc/lazy_import.pyx @@ -79,7 +79,7 @@ except ImportError: FeatureNotPresentError = () -cdef inline obj(x): +cdef inline obj(x) noexcept: if type(x) is LazyImport: return (x).get_object() else: @@ -92,7 +92,7 @@ cdef bint startup_guard = True cdef bint finish_startup_called = False -cpdef finish_startup(): +cpdef finish_startup() noexcept: """ Finish the startup phase. @@ -113,7 +113,7 @@ cpdef finish_startup(): finish_startup_called = True -cpdef ensure_startup_finished(): +cpdef ensure_startup_finished() noexcept: """ Make sure that the startup phase is finished. @@ -129,7 +129,7 @@ cpdef ensure_startup_finished(): startup_guard = False -cpdef bint is_during_startup(): +cpdef bint is_during_startup() noexcept: """ Return whether Sage is currently starting up. @@ -147,7 +147,7 @@ cpdef bint is_during_startup(): return startup_guard -cpdef test_fake_startup(): +cpdef test_fake_startup() noexcept: """ For testing purposes only. @@ -216,7 +216,7 @@ cdef class LazyImport(): self._deprecation = deprecation self._feature = feature - cdef inline get_object(self): + cdef inline get_object(self) noexcept: """ Faster, Cython-only partially-inlined version of ``_get_object``. """ @@ -224,7 +224,7 @@ cdef class LazyImport(): return self._object return self._get_object() - cpdef _get_object(self): + cpdef _get_object(self) noexcept: """ Return the wrapped object, importing it if necessary. diff --git a/src/sage/misc/lazy_list.pxd b/src/sage/misc/lazy_list.pxd index f8b51b47835..d512cfb69f4 100644 --- a/src/sage/misc/lazy_list.pxd +++ b/src/sage/misc/lazy_list.pxd @@ -3,10 +3,10 @@ cdef class lazy_list_generic(): cdef lazy_list_generic master # a reference if self is a slice cdef Py_ssize_t start, stop, step - cpdef get(self, Py_ssize_t i) + cpdef get(self, Py_ssize_t i) noexcept cpdef int _fit(self, Py_ssize_t n) except -1 cpdef int _update_cache_up_to(self, Py_ssize_t i) except -1 - cpdef list _get_cache_(self) + cpdef list _get_cache_(self) noexcept cdef class lazy_list_from_iterator(lazy_list_generic): cdef object iterator diff --git a/src/sage/misc/lazy_list.pyx b/src/sage/misc/lazy_list.pyx index cd750933860..71847e566ad 100644 --- a/src/sage/misc/lazy_list.pyx +++ b/src/sage/misc/lazy_list.pyx @@ -610,7 +610,7 @@ cdef class lazy_list_generic(): return 1 return 0 - cpdef get(self, Py_ssize_t i): + cpdef get(self, Py_ssize_t i) noexcept: r""" Return the element at position ``i``. @@ -880,7 +880,7 @@ cdef class lazy_list_generic(): self.cache.extend(l) return 0 - cpdef list _get_cache_(self): + cpdef list _get_cache_(self) noexcept: r""" Return the internal cache. diff --git a/src/sage/misc/lazy_string.pxd b/src/sage/misc/lazy_string.pxd index 7f7354e03ca..d74a18763a2 100644 --- a/src/sage/misc/lazy_string.pxd +++ b/src/sage/misc/lazy_string.pxd @@ -2,5 +2,5 @@ cdef class _LazyString(): cdef func cdef args cdef kwargs - cdef val(self) - cpdef update_lazy_string(self, args, kwds) + cdef val(self) noexcept + cpdef update_lazy_string(self, args, kwds) noexcept diff --git a/src/sage/misc/lazy_string.pyx b/src/sage/misc/lazy_string.pyx index dd92fb38142..4777c44a7a2 100644 --- a/src/sage/misc/lazy_string.pyx +++ b/src/sage/misc/lazy_string.pyx @@ -203,7 +203,7 @@ cdef class _LazyString(): self.args = args self.kwargs = kwargs - cdef val(self): + cdef val(self) noexcept: cdef f = self.func if isinstance(f, str): return f % self.args @@ -503,7 +503,7 @@ cdef class _LazyString(): except Exception: return '<%s broken>' % self.__class__.__name__ - cpdef update_lazy_string(self, args, kwds): + cpdef update_lazy_string(self, args, kwds) noexcept: """ Change this lazy string in-place. diff --git a/src/sage/misc/misc_c.pxd b/src/sage/misc/misc_c.pxd index acb36ab6d99..17ef467911a 100644 --- a/src/sage/misc/misc_c.pxd +++ b/src/sage/misc/misc_c.pxd @@ -1,2 +1,2 @@ -cpdef list normalize_index(object key, int size) +cpdef list normalize_index(object key, int size) noexcept diff --git a/src/sage/misc/misc_c.pyx b/src/sage/misc/misc_c.pyx index 1a856b4ea36..b60794c32d0 100644 --- a/src/sage/misc/misc_c.pyx +++ b/src/sage/misc/misc_c.pyx @@ -147,7 +147,7 @@ def prod(x, z=None, Py_ssize_t recursion_cutoff=5): return prod -cdef balanced_list_prod(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff): +cdef balanced_list_prod(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff) noexcept: """ INPUT: @@ -182,7 +182,7 @@ cdef balanced_list_prod(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutof return balanced_list_prod(L, offset, k, cutoff) * balanced_list_prod(L, offset + k, count - k, cutoff) -cpdef iterator_prod(L, z=None): +cpdef iterator_prod(L, z=None) noexcept: """ Attempt to do a balanced product of an arbitrary and unknown length sequence (such as a generator). Intermediate multiplications are always @@ -397,7 +397,7 @@ def balanced_sum(x, z=None, Py_ssize_t recursion_cutoff=5): return sum -cdef balanced_list_sum(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff): +cdef balanced_list_sum(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff) noexcept: """ INPUT: @@ -432,7 +432,7 @@ cdef balanced_list_sum(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff return balanced_list_sum(L, offset, k, cutoff) + balanced_list_sum(L, offset + k, count - k, cutoff) -cpdef list normalize_index(object key, int size): +cpdef list normalize_index(object key, int size) noexcept: """ Normalize an index key and return a valid index or list of indices within the range(0, size). diff --git a/src/sage/misc/nested_class.pyx b/src/sage/misc/nested_class.pyx index 4863fe45554..e397b356c22 100644 --- a/src/sage/misc/nested_class.pyx +++ b/src/sage/misc/nested_class.pyx @@ -93,7 +93,7 @@ __all__ = ['modify_for_nested_pickle', 'nested_pickle', #, 'SubClass', 'CopiedClass', 'A1' ] -cpdef modify_for_nested_pickle(cls, str name_prefix, module, first_run=True): +cpdef modify_for_nested_pickle(cls, str name_prefix, module, first_run=True) noexcept: r""" Modify the subclasses of the given class to be picklable, by giving them a mangled name and putting the mangled name in the diff --git a/src/sage/misc/parser.pyx b/src/sage/misc/parser.pyx index ee5b041383c..ef0219d5a80 100644 --- a/src/sage/misc/parser.pyx +++ b/src/sage/misc/parser.pyx @@ -92,10 +92,10 @@ def token_to_str(int token): return chr(token) -cdef inline bint is_alphanumeric(c): +cdef inline bint is_alphanumeric(c) noexcept: return c.isalnum() or c == '_' -cdef inline bint is_whitespace(c): +cdef inline bint is_whitespace(c) noexcept: return c.isspace() @@ -203,7 +203,7 @@ cdef class Tokenizer: token = self.next() return all - cpdef reset(self, int pos = 0): + cpdef reset(self, int pos = 0) noexcept: """ Reset the tokenizer to a given position. @@ -327,7 +327,7 @@ cdef class Tokenizer: self.pos = pos return ERROR - cpdef int next(self): + cpdef int next(self) noexcept: """ Returns the next token in the string. @@ -350,7 +350,7 @@ cdef class Tokenizer: self.token = self.find() return self.token - cpdef int last(self): + cpdef int last(self) noexcept: """ Returns the last token seen. @@ -369,7 +369,7 @@ cdef class Tokenizer: """ return self.token - cpdef int peek(self): + cpdef int peek(self) noexcept: """ Returns the next token that will be encountered, without changing the state of self. @@ -420,7 +420,7 @@ cdef class Tokenizer: self.pos = self.last_pos self.token = 0 - cpdef last_token_string(self): + cpdef last_token_string(self) noexcept: """ Return the actual contents of the last token. @@ -530,7 +530,7 @@ cdef class Parser: """ return self.callable_constructor - cpdef parse(self, s, bint accept_eqn=True): + cpdef parse(self, s, bint accept_eqn=True) noexcept: """ Parse the given string. @@ -552,7 +552,7 @@ cdef class Parser: self.parse_error(tokens) return expr - cpdef parse_expression(self, s): + cpdef parse_expression(self, s) noexcept: """ Parse an expression. @@ -569,7 +569,7 @@ cdef class Parser: self.parse_error(tokens) return expr - cpdef parse_sequence(self, s): + cpdef parse_sequence(self, s) noexcept: """ Parse a (possibly nested) set of lists and tuples. @@ -593,7 +593,7 @@ cdef class Parser: all = all[0] return all - cpdef p_matrix(self, Tokenizer tokens): + cpdef p_matrix(self, Tokenizer tokens) noexcept: """ Parse a matrix @@ -621,7 +621,7 @@ cdef class Parser: else: self.parse_error(tokens, "Malformed matrix") - cpdef p_sequence(self, Tokenizer tokens): + cpdef p_sequence(self, Tokenizer tokens) noexcept: """ Parse a (possibly nested) set of lists and tuples. @@ -666,7 +666,7 @@ cdef class Parser: tokens.backtrack() return all - cpdef p_list(self, Tokenizer tokens): + cpdef p_list(self, Tokenizer tokens) noexcept: """ Parse a list of items. @@ -688,7 +688,7 @@ cdef class Parser: self.parse_error(tokens, "Malformed list") return all - cpdef p_tuple(self, Tokenizer tokens): + cpdef p_tuple(self, Tokenizer tokens) noexcept: """ Parse a tuple of items. @@ -723,7 +723,7 @@ cdef class Parser: return self.p_eqn(tokens) # eqn ::= expr op expr | expr - cpdef p_eqn(self, Tokenizer tokens): + cpdef p_eqn(self, Tokenizer tokens) noexcept: r""" Parse an equation or expression. @@ -769,7 +769,7 @@ cdef class Parser: return lhs # expr ::= term | expr '+' term | expr '-' term - cpdef p_expr(self, Tokenizer tokens): + cpdef p_expr(self, Tokenizer tokens) noexcept: """ Parse a list of one or more terms. @@ -804,7 +804,7 @@ cdef class Parser: return operand1 # term ::= factor | term '*' factor | term '/' factor - cpdef p_term(self, Tokenizer tokens): + cpdef p_term(self, Tokenizer tokens) noexcept: """ Parse a single term (consisting of one or more factors). @@ -845,7 +845,7 @@ cdef class Parser: return operand1 # factor ::= '+' factor | '-' factor | power - cpdef p_factor(self, Tokenizer tokens): + cpdef p_factor(self, Tokenizer tokens) noexcept: """ Parse a single factor, which consists of any number of unary +/- and a power. @@ -872,7 +872,7 @@ cdef class Parser: return self.p_power(tokens) # power ::= (atom | atom!) ^ factor | atom | atom! - cpdef p_power(self, Tokenizer tokens): + cpdef p_power(self, Tokenizer tokens) noexcept: """ Parses a power. Note that exponentiation groups right to left. @@ -917,7 +917,7 @@ cdef class Parser: return operand1 # atom ::= int | float | name | '(' expr ')' | name '(' args ')' - cpdef p_atom(self, Tokenizer tokens): + cpdef p_atom(self, Tokenizer tokens) noexcept: """ Parse an atom. This is either a parenthesized expression, a function call, or a literal name/int/float. @@ -973,7 +973,7 @@ cdef class Parser: self.parse_error(tokens) # args = arg (',' arg)* | EMPTY - cpdef p_args(self, Tokenizer tokens): + cpdef p_args(self, Tokenizer tokens) noexcept: """ Returns a list, dict pair. @@ -1003,7 +1003,7 @@ cdef class Parser: return args, kwds # arg = expr | name '=' expr - cpdef p_arg(self, Tokenizer tokens): + cpdef p_arg(self, Tokenizer tokens) noexcept: """ Returns an expr, or a (name, expr) tuple corresponding to a single function call argument. @@ -1044,7 +1044,7 @@ cdef class Parser: tokens.backtrack() return self.p_expr(tokens) - cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"): + cdef parse_error(self, Tokenizer tokens, msg="Malformed expression") noexcept: raise SyntaxError(msg, tokens.s, tokens.pos) diff --git a/src/sage/misc/persist.pyx b/src/sage/misc/persist.pyx index 80d4f9b23d5..319682aa74a 100644 --- a/src/sage/misc/persist.pyx +++ b/src/sage/misc/persist.pyx @@ -75,7 +75,7 @@ already_pickled = { } already_unpickled = { } -cdef _normalize_filename(s): +cdef _normalize_filename(s) noexcept: """ Append the .sobj extension to a filename if it doesn't already have it. """ diff --git a/src/sage/misc/randstate.pxd b/src/sage/misc/randstate.pxd index 434dad3a5f2..c83873a7c99 100644 --- a/src/sage/misc/randstate.pxd +++ b/src/sage/misc/randstate.pxd @@ -16,14 +16,14 @@ cdef class randstate: cdef object _gp_saved_seeds - cpdef set_seed_libc(self, bint force) - cpdef set_seed_ntl(self, bint force) + cpdef set_seed_libc(self, bint force) noexcept + cpdef set_seed_ntl(self, bint force) noexcept - cpdef int c_random(self) - cpdef double c_rand_double(self) + cpdef int c_random(self) noexcept + cpdef double c_rand_double(self) noexcept - cpdef ZZ_seed(self) - cpdef long_seed(self) + cpdef ZZ_seed(self) noexcept + cpdef long_seed(self) noexcept -cpdef randstate current_randstate() -cpdef int random() +cpdef randstate current_randstate() noexcept +cpdef int random() noexcept diff --git a/src/sage/misc/randstate.pyx b/src/sage/misc/randstate.pyx index 06d6f8ce894..5c883c928b4 100644 --- a/src/sage/misc/randstate.pyx +++ b/src/sage/misc/randstate.pyx @@ -443,7 +443,7 @@ cdef randstate _pari_seed_randstate # randstate object was the most recent one to seed it. _gp_seed_randstates = weakref.WeakKeyDictionary() -cpdef randstate current_randstate(): +cpdef randstate current_randstate() noexcept: r""" Return the current random number state. @@ -610,7 +610,7 @@ cdef class randstate: self._python_random = rand return rand - cpdef ZZ_seed(self): + cpdef ZZ_seed(self) noexcept: r""" When called on the current :class:`randstate`, returns a 128-bit :mod:`Integer ` suitable for seeding another @@ -625,7 +625,7 @@ cdef class randstate: from sage.rings.integer_ring import ZZ return ZZ.random_element(long(1)<<128) - cpdef long_seed(self): + cpdef long_seed(self) noexcept: r""" When called on the current :class:`randstate`, returns a 128-bit Python long suitable for seeding another random number generator. @@ -639,7 +639,7 @@ cdef class randstate: from sage.rings.integer_ring import ZZ return long(ZZ.random_element(long(1)<<128)) - cpdef set_seed_libc(self, bint force): + cpdef set_seed_libc(self, bint force) noexcept: r""" Checks to see if ``self`` was the most recent :class:`randstate` to seed the libc random number generator. If not, seeds the @@ -664,7 +664,7 @@ cdef class randstate: c_libc_srandom(gmp_urandomb_ui(self.gmp_state, sizeof(int)*8)) _libc_seed_randstate = self - cpdef set_seed_ntl(self, bint force): + cpdef set_seed_ntl(self, bint force) noexcept: r""" Checks to see if ``self`` was the most recent :class:`randstate` to seed the NTL random number generator. If not, seeds @@ -805,7 +805,7 @@ cdef class randstate: _pari_seed_randstate = self - cpdef int c_random(self): + cpdef int c_random(self) noexcept: r""" Returns a 31-bit random number. Intended for internal use only; instead of calling ``current_randstate().c_random()``, @@ -828,7 +828,7 @@ cdef class randstate: """ return gmp_urandomb_ui(self.gmp_state, 31) - cpdef double c_rand_double(self): + cpdef double c_rand_double(self) noexcept: r""" Returns a random floating-point number between 0 and 1. @@ -922,7 +922,7 @@ cdef class randstate: return False -cpdef set_random_seed(seed=None): +cpdef set_random_seed(seed=None) noexcept: r""" Set the current random number seed from the given ``seed`` (which must be coercible to a Python long). @@ -954,7 +954,7 @@ set_random_seed() # Create an alias for randstate to be used in context managers seed = randstate -cpdef int random(): +cpdef int random() noexcept: r""" Returns a 31-bit random number. Intended as a drop-in replacement for the libc :func:`random()` function. @@ -1025,7 +1025,7 @@ def benchmark_mt(): for i from 0 <= i < 100000: gmp_urandomb_ui(rstate.gmp_state, 32) -cpdef int _doctest_libc_random(): +cpdef int _doctest_libc_random() noexcept: r""" Returns the result of :func:`random()` from libc. diff --git a/src/sage/misc/sage_ostools.pyx b/src/sage/misc/sage_ostools.pyx index 678b6731b82..0034f7a5d89 100644 --- a/src/sage/misc/sage_ostools.pyx +++ b/src/sage/misc/sage_ostools.pyx @@ -81,7 +81,7 @@ def restore_cwd(chdir=None): os.chdir(orig_cwd) -cdef file_and_fd(x, int* fd): +cdef file_and_fd(x, int* fd) noexcept: """ If ``x`` is a file, return ``x`` and set ``*fd`` to its file descriptor. If ``x`` is an integer, return ``None`` and set diff --git a/src/sage/misc/search.pxd b/src/sage/misc/search.pxd index 8cc43ba1b0f..0986f27c51d 100644 --- a/src/sage/misc/search.pxd +++ b/src/sage/misc/search.pxd @@ -1 +1 @@ -cpdef search(object v, object x) \ No newline at end of file +cpdef search(object v, object x) noexcept \ No newline at end of file diff --git a/src/sage/misc/search.pyx b/src/sage/misc/search.pyx index a9e7149113e..3991bbc8f3e 100644 --- a/src/sage/misc/search.pyx +++ b/src/sage/misc/search.pyx @@ -25,7 +25,7 @@ extra comparison. Also, the function names make more sense. import bisect -cpdef search(object v, object x): +cpdef search(object v, object x) noexcept: """ Return (True,i) where i is such that v[i] == x if there is such an i, or (False,j) otherwise, where j is the position where x should be inserted diff --git a/src/sage/modular/arithgroup/arithgroup_element.pyx b/src/sage/modular/arithgroup/arithgroup_element.pyx index dee0b479c74..41b268ea4ef 100644 --- a/src/sage/modular/arithgroup/arithgroup_element.pyx +++ b/src/sage/modular/arithgroup/arithgroup_element.pyx @@ -158,7 +158,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): """ return '%s' % self.__x._latex_() - cpdef _richcmp_(self, right_r, int op): + cpdef _richcmp_(self, right_r, int op) noexcept: """ Compare self to right, where right is guaranteed to have the same parent as self. @@ -204,7 +204,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): """ return True - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Return self * right. diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index 863c1d6b654..cd80cb32f3e 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -1030,30 +1030,30 @@ cdef class Farey: #--- conversions ------------------------------------------------------------ -cdef public long convert_to_long(n): +cdef public long convert_to_long(n) noexcept: cdef long m = n return m -cdef public object convert_to_Integer(mpz_class a): +cdef public object convert_to_Integer(mpz_class a) noexcept: A = Integer() A.set_from_mpz(a.get_mpz_t()) return A -cdef public object convert_to_rational(mpq_class r): +cdef public object convert_to_rational(mpq_class r) noexcept: a = Integer() a.set_from_mpz(r.get_num_mpz_t()) b = Integer() b.set_from_mpz(r.get_den_mpz_t()) return a/b -cdef public object convert_to_cusp(mpq_class r): +cdef public object convert_to_cusp(mpq_class r) noexcept: a = Integer() a.set_from_mpz(r.get_num_mpz_t()) b = Integer() b.set_from_mpz(r.get_den_mpz_t()) return Cusp(a/b) -cdef public object convert_to_SL2Z(cpp_SL2Z M): +cdef public object convert_to_SL2Z(cpp_SL2Z M) noexcept: a = convert_to_Integer(M.a()) b = convert_to_Integer(M.b()) c = convert_to_Integer(M.c()) diff --git a/src/sage/modular/hypergeometric_misc.pxd b/src/sage/modular/hypergeometric_misc.pxd index 00bf9a97e9a..4198ca8848b 100644 --- a/src/sage/modular/hypergeometric_misc.pxd +++ b/src/sage/modular/hypergeometric_misc.pxd @@ -1,2 +1,2 @@ cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D, - gtable, int gtable_prec, bint use_longs) + gtable, int gtable_prec, bint use_longs) noexcept diff --git a/src/sage/modular/hypergeometric_misc.pyx b/src/sage/modular/hypergeometric_misc.pyx index af2c4f74e15..a930d2414bf 100644 --- a/src/sage/modular/hypergeometric_misc.pyx +++ b/src/sage/modular/hypergeometric_misc.pyx @@ -7,7 +7,7 @@ from cysignals.signals cimport sig_check cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D, - gtable, int gtable_prec, bint use_longs): + gtable, int gtable_prec, bint use_longs) noexcept: r""" Compute coefficients for the hypergeometric trace formula. diff --git a/src/sage/modular/modform/eis_series_cython.pyx b/src/sage/modular/modform/eis_series_cython.pyx index c29fef9cef7..29ba08039d7 100644 --- a/src/sage/modular/modform/eis_series_cython.pyx +++ b/src/sage/modular/modform/eis_series_cython.pyx @@ -14,7 +14,7 @@ from sage.libs.flint.fmpz_poly cimport * from sage.libs.gmp.mpz cimport * from sage.libs.flint.fmpz_poly cimport Fmpz_poly -cpdef Ek_ZZ(int k, int prec=10): +cpdef Ek_ZZ(int k, int prec=10) noexcept: """ Return list of prec integer coefficients of the weight k Eisenstein series of level 1, normalized so the coefficient of q @@ -140,7 +140,7 @@ cpdef Ek_ZZ(int k, int prec=10): return val -cpdef eisenstein_series_poly(int k, int prec = 10) : +cpdef eisenstein_series_poly(int k, int prec = 10) noexcept: r""" Return the q-expansion up to precision ``prec`` of the weight `k` Eisenstein series, as a FLINT :class:`~sage.libs.flint.fmpz_poly.Fmpz_poly` diff --git a/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx b/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx index f91a3e256f0..ffebe813c92 100644 --- a/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx +++ b/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx @@ -12,7 +12,7 @@ from libc.math cimport ceil, floor, sqrt from libc.string cimport memcpy -cpdef to_series(L, var): +cpdef to_series(L, var) noexcept: """ Create a power series element out of a list ``L`` in the variable`` var``. diff --git a/src/sage/modular/modsym/heilbronn.pyx b/src/sage/modular/modsym/heilbronn.pyx index 45f0921034d..ba42d70aa9e 100644 --- a/src/sage/modular/modsym/heilbronn.pyx +++ b/src/sage/modular/modsym/heilbronn.pyx @@ -46,7 +46,7 @@ from sage.matrix.matrix_cyclo_dense cimport Matrix_cyclo_dense ctypedef long long llong -cdef int llong_prod_mod(int a, int b, int N): +cdef int llong_prod_mod(int a, int b, int N) noexcept: cdef int c c = ((( a) * ( b)) % ( N)) if c < 0: @@ -83,10 +83,10 @@ cdef int list_append4(list* L, int a, int b, int c, int d) except -1: list_append(L, c) list_append(L, d) -cdef void list_clear(list L): +cdef void list_clear(list L) noexcept: sig_free(L.v) -cdef void list_init(list* L): +cdef void list_init(list* L) noexcept: L.n = 16 L.i = 0 L.v = expand(0, 0, L.n) @@ -170,7 +170,7 @@ cdef class Heilbronn: self.list.v[4*i+2], self.list.v[4*i+3]]) return L - cdef apply_only(self, int u, int v, int N, int* a, int* b): + cdef apply_only(self, int u, int v, int N, int* a, int* b) noexcept: """ INPUT: @@ -210,7 +210,7 @@ cdef class Heilbronn: b[i] = llong_prod_mod(u,self.list.v[4*i+1],N) + llong_prod_mod(v,self.list.v[4*i+3], N) sig_off() - cdef apply_to_polypart(self, fmpz_poly_t* ans, int i, int k): + cdef apply_to_polypart(self, fmpz_poly_t* ans, int i, int k) noexcept: r""" INPUT: diff --git a/src/sage/modular/modsym/manin_symbol.pyx b/src/sage/modular/modsym/manin_symbol.pyx index c02c1f26dbf..52026160b38 100644 --- a/src/sage/modular/modsym/manin_symbol.pyx +++ b/src/sage/modular/modsym/manin_symbol.pyx @@ -199,7 +199,7 @@ cdef class ManinSymbol(Element): """ return self._repr_() - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Comparison function for ManinSymbols. diff --git a/src/sage/modular/modsym/p1list.pxd b/src/sage/modular/modsym/p1list.pxd index b66f28b8ad6..17254d4a8fb 100644 --- a/src/sage/modular/modsym/p1list.pxd +++ b/src/sage/modular/modsym/p1list.pxd @@ -24,5 +24,5 @@ cdef class P1List: cdef int (*_normalize)(int N, int u, int v, int* uu, int* vv, int* ss, int compute_s) except -1 - cpdef index(self, int u, int v) - cdef index_and_scalar(self, int u, int v, int* i, int* s) + cpdef index(self, int u, int v) noexcept + cdef index_and_scalar(self, int u, int v, int* i, int* s) noexcept diff --git a/src/sage/modular/modsym/p1list.pyx b/src/sage/modular/modsym/p1list.pyx index 1fc3e2de952..0427ae068a3 100644 --- a/src/sage/modular/modsym/p1list.pyx +++ b/src/sage/modular/modsym/p1list.pyx @@ -991,7 +991,7 @@ cdef class P1List(): _, j = search(self.__list, (uu,vv)) return j - cpdef index(self, int u, int v): + cpdef index(self, int u, int v) noexcept: r""" Return the index of the class of `(u,v)` in the fixed list of representatives of @@ -1034,7 +1034,7 @@ cdef class P1List(): except KeyError: return -1 - cdef index_and_scalar(self, int u, int v, int* i, int* s): + cdef index_and_scalar(self, int u, int v, int* i, int* s) noexcept: r""" Compute the index of the class of `(u,v)` in the fixed list of representatives of `\mathbb{P}^1(\ZZ/N\ZZ)` and scalar s diff --git a/src/sage/modular/pollack_stevens/dist.pxd b/src/sage/modular/pollack_stevens/dist.pxd index 95689892050..0a38551d8a6 100644 --- a/src/sage/modular/pollack_stevens/dist.pxd +++ b/src/sage/modular/pollack_stevens/dist.pxd @@ -5,17 +5,17 @@ from sage.rings.padics.pow_computer cimport PowComputer_class cdef class Dist(ModuleElement): - cpdef normalize(self, include_zeroth_moment=*) + cpdef normalize(self, include_zeroth_moment=*) noexcept cdef long ordp - cpdef long _ord_p(self) - cdef long _relprec(self) - cdef _unscaled_moment(self, long i) + cpdef long _ord_p(self) noexcept + cdef long _relprec(self) noexcept + cdef _unscaled_moment(self, long i) noexcept cdef class Dist_vector(Dist): cdef public _moments - cdef Dist_vector _new_c(self) - cdef Dist_vector _addsub(self, Dist_vector right, bint negate) - cpdef _add_(self, other) + cdef Dist_vector _new_c(self) noexcept + cdef Dist_vector _addsub(self, Dist_vector right, bint negate) noexcept + cpdef _add_(self, other) noexcept cdef class WeightKAction(Action): @@ -30,8 +30,8 @@ cdef class WeightKAction(Action): cdef public _dettwist cdef public _Sigma0 - cpdef acting_matrix(self, g, M) - cpdef _compute_acting_matrix(self, g, M) + cpdef acting_matrix(self, g, M) noexcept + cpdef _compute_acting_matrix(self, g, M) noexcept cdef class WeightKAction_vector(WeightKAction): pass diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx index 7a869a1c05a..fe1f5583cd5 100644 --- a/src/sage/modular/pollack_stevens/dist.pyx +++ b/src/sage/modular/pollack_stevens/dist.pyx @@ -138,7 +138,7 @@ cdef class Dist(ModuleElement): """ return self.parent().prime() ** (self.ordp) * self._moments - cpdef normalize(self, include_zeroth_moment=True): + cpdef normalize(self, include_zeroth_moment=True) noexcept: r""" Normalize so that the precision of the `i`-th moment is `n-i`, where `n` is the number of moments. @@ -158,13 +158,13 @@ cdef class Dist(ModuleElement): """ raise NotImplementedError - cdef long _relprec(self): + cdef long _relprec(self) noexcept: raise NotImplementedError - cdef _unscaled_moment(self, long i): + cdef _unscaled_moment(self, long i) noexcept: raise NotImplementedError - cpdef long _ord_p(self): + cpdef long _ord_p(self) noexcept: r""" Return power of `p` by which the moments are shifted. @@ -481,7 +481,7 @@ cdef class Dist(ModuleElement): pass return alpha - cpdef _richcmp_(_left, _right, int op): + cpdef _richcmp_(_left, _right, int op) noexcept: r""" Comparison. @@ -800,7 +800,7 @@ cdef class Dist_vector(Dist): """ return (self.__class__, (self._moments, self.parent(), self.ordp, False)) - cdef Dist_vector _new_c(self): + cdef Dist_vector _new_c(self) noexcept: r""" Creates an empty distribution. @@ -866,7 +866,7 @@ cdef class Dist_vector(Dist): return QQ(self.moment(0)) raise TypeError("k must be 0") - cdef long _relprec(self): + cdef long _relprec(self) noexcept: """ Return the number of moments. @@ -880,7 +880,7 @@ cdef class Dist_vector(Dist): """ return len(self._moments) - cdef _unscaled_moment(self, long n): + cdef _unscaled_moment(self, long n) noexcept: r""" Return the `n`-th moment, unscaled by the overall power of `p` stored in ``self.ordp``. @@ -894,7 +894,7 @@ cdef class Dist_vector(Dist): """ return self._moments[n] - cdef Dist_vector _addsub(self, Dist_vector right, bint negate): + cdef Dist_vector _addsub(self, Dist_vector right, bint negate) noexcept: r""" Common code for the sum and the difference of two distributions @@ -934,7 +934,7 @@ cdef class Dist_vector(Dist): ans._moments = smoments + rmoments return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: r""" Sum of two distributions. @@ -947,7 +947,7 @@ cdef class Dist_vector(Dist): """ return self._addsub(_right, False) - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: r""" Difference of two distributions. @@ -960,7 +960,7 @@ cdef class Dist_vector(Dist): """ return self._addsub(_right, True) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: r""" Scalar product of a distribution with a ring element that coerces into the base ring. @@ -1044,7 +1044,7 @@ cdef class Dist_vector(Dist): """ return Integer(len(self._moments) + self.ordp) - cpdef normalize(self, include_zeroth_moment=True): + cpdef normalize(self, include_zeroth_moment=True) noexcept: r""" Normalize by reducing modulo `Fil^N`, where `N` is the number of moments. @@ -1270,7 +1270,7 @@ cdef class WeightKAction(Action): self._actmat = {} self._maxprecs = {} - cpdef acting_matrix(self, g, M): + cpdef acting_matrix(self, g, M) noexcept: r""" The matrix defining the action of ``g`` at precision ``M``. @@ -1328,7 +1328,7 @@ cdef class WeightKAction(Action): mats[M] = A return A - cpdef _compute_acting_matrix(self, g, M): + cpdef _compute_acting_matrix(self, g, M) noexcept: r""" Compute the matrix defining the action of ``g`` at precision ``M``. @@ -1357,7 +1357,7 @@ cdef class WeightKAction(Action): cdef class WeightKAction_vector(WeightKAction): - cpdef _compute_acting_matrix(self, g, M): + cpdef _compute_acting_matrix(self, g, M) noexcept: r""" Compute the matrix defining the action of ``g`` at precision ``M``. @@ -1419,7 +1419,7 @@ cdef class WeightKAction_vector(WeightKAction): B *= (a * d - b * c) ** (self._dettwist) return B - cpdef _act_(self, g, _v): + cpdef _act_(self, g, _v) noexcept: r""" The right action of ``g`` on a distribution. diff --git a/src/sage/modules/finite_submodule_iter.pxd b/src/sage/modules/finite_submodule_iter.pxd index 8173f265673..900f041e3a0 100644 --- a/src/sage/modules/finite_submodule_iter.pxd +++ b/src/sage/modules/finite_submodule_iter.pxd @@ -13,7 +13,7 @@ cdef class FiniteZZsubmodule_iterator: cdef int _count cdef int _order cdef bint _immutable - cdef ModuleElement _iteration(FiniteZZsubmodule_iterator self) + cdef ModuleElement _iteration(FiniteZZsubmodule_iterator self) noexcept cdef class FiniteFieldsubspace_iterator(FiniteZZsubmodule_iterator): pass diff --git a/src/sage/modules/finite_submodule_iter.pyx b/src/sage/modules/finite_submodule_iter.pyx index bb4a730cad9..ab335200e0d 100644 --- a/src/sage/modules/finite_submodule_iter.pyx +++ b/src/sage/modules/finite_submodule_iter.pyx @@ -190,7 +190,7 @@ cdef class FiniteZZsubmodule_iterator: """ return self - cdef ModuleElement _iteration(FiniteZZsubmodule_iterator self): + cdef ModuleElement _iteration(FiniteZZsubmodule_iterator self) noexcept: """ This is the core implementation of the iteration. diff --git a/src/sage/modules/free_module_element.pxd b/src/sage/modules/free_module_element.pxd index 64a1760a259..e524a458474 100644 --- a/src/sage/modules/free_module_element.pxd +++ b/src/sage/modules/free_module_element.pxd @@ -2,15 +2,15 @@ from sage.structure.element cimport Vector cdef class FreeModuleElement(Vector): cdef int set_unsafe(self, Py_ssize_t i, value) except -1 - cdef get_unsafe(self, Py_ssize_t i) - cpdef int hamming_weight(self) + cdef get_unsafe(self, Py_ssize_t i) noexcept + cpdef int hamming_weight(self) noexcept cdef class FreeModuleElement_generic_dense(FreeModuleElement): # data cdef list _entries # cdef'd methods - cdef _new_c(self, object v) + cdef _new_c(self, object v) noexcept cdef class FreeModuleElement_generic_sparse(FreeModuleElement): @@ -18,5 +18,5 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): cdef dict _entries # cdef'd methods - cdef _new_c(self, object v) + cdef _new_c(self, object v) noexcept diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index c9af9bcbdf7..a2c077cc8c8 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -1762,7 +1762,7 @@ cdef class FreeModuleElement(Vector): # abstract base class s = sum(a ** p for a in abs_self) return s**(__one__/p) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -1842,7 +1842,7 @@ cdef class FreeModuleElement(Vector): # abstract base class raise IndexError("vector index out of range") return self.get_unsafe(n) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ Cython function to get the `i`'th entry of this vector. @@ -2484,7 +2484,7 @@ cdef class FreeModuleElement(Vector): # abstract base class else: return points(v, **kwds) - cpdef _dot_product_coerce_(left, Vector right): + cpdef _dot_product_coerce_(left, Vector right) noexcept: """ Return the dot product of left and right. @@ -3584,7 +3584,7 @@ cdef class FreeModuleElement(Vector): # abstract base class """ return self.is_dense_c() - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return self.parent().is_dense() def is_sparse(self): @@ -3602,7 +3602,7 @@ cdef class FreeModuleElement(Vector): # abstract base class """ return self.is_sparse_c() - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return self.parent().is_sparse() def is_vector(self): @@ -3760,7 +3760,7 @@ cdef class FreeModuleElement(Vector): # abstract base class """ return self.nonzero_positions() - cpdef int hamming_weight(self): + cpdef int hamming_weight(self) noexcept: """ Return the number of positions ``i`` such that ``self[i] != 0``. @@ -4227,7 +4227,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): sage: isinstance(hash(v), int) True """ - cdef _new_c(self, object v): + cdef _new_c(self, object v) noexcept: """ Create a new dense free module element with minimal overhead and no type checking. @@ -4245,10 +4245,10 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): x._degree = self._degree return x - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 0 def __copy__(self): @@ -4371,7 +4371,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): @cython.boundscheck(False) @cython.wraparound(False) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add left and right. @@ -4388,7 +4388,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): @cython.boundscheck(False) @cython.wraparound(False) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ Subtract right from left. @@ -4406,7 +4406,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): v = [( a[i])._sub_( b[i]) for i in range(left._degree)] return left._new_c(v) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -4420,7 +4420,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): v = [left * x for x in self._entries] return self._new_c(v) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -4438,7 +4438,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): @cython.boundscheck(False) @cython.wraparound(False) - cpdef _pairwise_product_(left, Vector right): + cpdef _pairwise_product_(left, Vector right) noexcept: """ EXAMPLES:: @@ -4470,7 +4470,7 @@ cdef class FreeModuleElement_generic_dense(FreeModuleElement): @cython.boundscheck(False) @cython.wraparound(False) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -4678,7 +4678,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): sage: (b-a).dict() {2: -1} """ - cdef _new_c(self, object v): + cdef _new_c(self, object v) noexcept: """ Create a new sparse free module element with minimal overhead and no type checking. @@ -4696,10 +4696,10 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): x._degree = self._degree return x - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 0 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 1 def __copy__(self): @@ -4829,7 +4829,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): entries_dict = dict(entries_dict) # make a copy/convert to dict self._entries = entries_dict - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add left and right. @@ -4851,7 +4851,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): v[i] = a return left._new_c(v) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ EXAMPLES:: @@ -4871,7 +4871,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): v[i] = -a return left._new_c(v) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -4887,7 +4887,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): v[i] = prod return self._new_c(v) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -4903,7 +4903,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): v[i] = prod return self._new_c(v) - cpdef _dot_product_coerce_(left, Vector right): + cpdef _dot_product_coerce_(left, Vector right) noexcept: """ Return the dot product of left and right. @@ -4955,7 +4955,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): z += a * e[i] return z - cpdef _pairwise_product_(left, Vector right): + cpdef _pairwise_product_(left, Vector right) noexcept: """ EXAMPLES:: @@ -4973,7 +4973,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): v[i] = prod return left._new_c(v) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare two sparse free module elements. @@ -5104,7 +5104,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): raise IndexError("vector index out of range") return self.get_unsafe(n) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -5269,7 +5269,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): """ return sorted(self._entries) - cpdef int hamming_weight(self): + cpdef int hamming_weight(self) noexcept: """ Returns the number of positions ``i`` such that ``self[i] != 0``. diff --git a/src/sage/modules/module.pyx b/src/sage/modules/module.pyx index 818d139c3ba..21bb44f8e67 100644 --- a/src/sage/modules/module.pyx +++ b/src/sage/modules/module.pyx @@ -132,7 +132,7 @@ cdef class Module(Parent): category = Modules(base) Parent.__init__(self, base=base, category=category, names=names) - cpdef _coerce_map_from_(self, M): + cpdef _coerce_map_from_(self, M) noexcept: """ Return a coercion map from `M` to ``self``, or None. diff --git a/src/sage/modules/vector_double_dense.pyx b/src/sage/modules/vector_double_dense.pyx index 551da99669e..a47d91a7fdd 100644 --- a/src/sage/modules/vector_double_dense.pyx +++ b/src/sage/modules/vector_double_dense.pyx @@ -81,7 +81,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): 30.0 """ - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two vectors together. @@ -101,7 +101,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): return self._new(_left._vector_numpy + _right._vector_numpy) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return self - right @@ -121,7 +121,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): return self._new(_left._vector_numpy - _right._vector_numpy) - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: """ Dot product of self and right. @@ -145,7 +145,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): return self._sage_dtype(numpy.dot(_left._vector_numpy, _right._vector_numpy)) - cpdef _pairwise_product_(self, Vector right): + cpdef _pairwise_product_(self, Vector right) noexcept: """ Return the component-wise product of self and right. @@ -168,7 +168,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): return self._new(_left._vector_numpy * _right._vector_numpy) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ Multiply a scalar and vector @@ -184,7 +184,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): return self._new(self._python_dtype(left)*self._vector_numpy) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Multiply a scalar and vector diff --git a/src/sage/modules/vector_integer_dense.pxd b/src/sage/modules/vector_integer_dense.pxd index 6a221546b34..322a10c369b 100644 --- a/src/sage/modules/vector_integer_dense.pxd +++ b/src/sage/modules/vector_integer_dense.pxd @@ -6,7 +6,7 @@ cdef class Vector_integer_dense(FreeModuleElement): cdef mpz_t* _entries cdef int _init(self, Py_ssize_t degree, Parent parent) except -1 - cdef inline Vector_integer_dense _new_c(self): + cdef inline Vector_integer_dense _new_c(self) noexcept: cdef type t = type(self) cdef Vector_integer_dense x = (t.__new__(t)) x._init(self._degree, self._parent) diff --git a/src/sage/modules/vector_integer_dense.pyx b/src/sage/modules/vector_integer_dense.pyx index 177ada5dea1..52e0bbd4064 100644 --- a/src/sage/modules/vector_integer_dense.pyx +++ b/src/sage/modules/vector_integer_dense.pyx @@ -65,9 +65,9 @@ cimport sage.modules.free_module_element as free_module_element from sage.libs.gmp.mpz cimport * cdef class Vector_integer_dense(free_module_element.FreeModuleElement): - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 0 def __copy__(self): @@ -130,7 +130,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_clear(self._entries[i]) sig_free(self._entries) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -159,7 +159,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): return rich_to_bool(op, 1) return rich_to_bool(op, 0) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -215,7 +215,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): return (unpickle_v1, (self._parent, self.list(), self._degree, not self._is_immutable)) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: cdef Vector_integer_dense z, r r = right z = self._new_c() @@ -225,7 +225,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): return z - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: cdef Vector_integer_dense z, r r = right z = self._new_c() @@ -234,7 +234,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_sub(z._entries[i], self._entries[i], r._entries[i]) return z - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: """ Dot product of dense vectors over the integers. @@ -258,7 +258,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_clear(t) return z - cpdef _pairwise_product_(self, Vector right): + cpdef _pairwise_product_(self, Vector right) noexcept: """ EXAMPLES:: @@ -274,7 +274,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_mul(z._entries[i], self._entries[i], r._entries[i]) return z - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: cdef Vector_integer_dense z cdef Integer a a = left @@ -284,7 +284,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_mul(z._entries[i], self._entries[i], a.value) return z - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: cdef Vector_integer_dense z cdef Integer a a = right @@ -294,7 +294,7 @@ cdef class Vector_integer_dense(free_module_element.FreeModuleElement): mpz_mul(z._entries[i], self._entries[i], a.value) return z - cpdef _neg_(self): + cpdef _neg_(self) noexcept: cdef Vector_integer_dense z z = self._new_c() cdef Py_ssize_t i diff --git a/src/sage/modules/vector_integer_sparse.pxd b/src/sage/modules/vector_integer_sparse.pxd index 463b3b2c0e1..4791b778497 100644 --- a/src/sage/modules/vector_integer_sparse.pxd +++ b/src/sage/modules/vector_integer_sparse.pxd @@ -14,15 +14,15 @@ cdef struct mpz_vector: cdef int allocate_mpz_vector(mpz_vector* v, Py_ssize_t num_nonzero) except -1 cdef int mpz_vector_init(mpz_vector* v, Py_ssize_t degree, Py_ssize_t num_nonzero) except -1 -cdef void mpz_vector_clear(mpz_vector* v) -cdef Py_ssize_t mpz_binary_search0(mpz_t* v, Py_ssize_t n, mpz_t x) -cdef Py_ssize_t mpz_binary_search(mpz_t* v, Py_ssize_t n, mpz_t x, Py_ssize_t* ins) +cdef void mpz_vector_clear(mpz_vector* v) noexcept +cdef Py_ssize_t mpz_binary_search0(mpz_t* v, Py_ssize_t n, mpz_t x) noexcept +cdef Py_ssize_t mpz_binary_search(mpz_t* v, Py_ssize_t n, mpz_t x, Py_ssize_t* ins) noexcept cdef int mpz_vector_get_entry(mpz_t ans, mpz_vector* v, Py_ssize_t n) except -1 -cdef bint mpz_vector_is_entry_zero_unsafe(mpz_vector* v, Py_ssize_t n) -cdef object mpz_vector_to_list(mpz_vector* v) +cdef bint mpz_vector_is_entry_zero_unsafe(mpz_vector* v, Py_ssize_t n) noexcept +cdef object mpz_vector_to_list(mpz_vector* v) noexcept cdef int mpz_vector_set_entry(mpz_vector* v, Py_ssize_t n, mpz_t x) except -1 cdef int mpz_vector_set_entry_str(mpz_vector* v, Py_ssize_t n, char *x_str) except -1 cdef int add_mpz_vector_init(mpz_vector* sum, mpz_vector* v, mpz_vector* w, mpz_t multiple) except -1 cdef int mpz_vector_scale(mpz_vector* v, mpz_t scalar) except -1 cdef int mpz_vector_scalar_multiply(mpz_vector* v, mpz_vector* w, mpz_t scalar) except -1 -cdef int mpz_vector_cmp(mpz_vector* v, mpz_vector* w) +cdef int mpz_vector_cmp(mpz_vector* v, mpz_vector* w) noexcept diff --git a/src/sage/modules/vector_integer_sparse.pyx b/src/sage/modules/vector_integer_sparse.pyx index de91aab408e..9fdecf6a326 100644 --- a/src/sage/modules/vector_integer_sparse.pyx +++ b/src/sage/modules/vector_integer_sparse.pyx @@ -42,7 +42,7 @@ cdef int mpz_vector_init(mpz_vector* v, Py_ssize_t degree, Py_ssize_t num_nonzer v.num_nonzero = num_nonzero v.degree = degree -cdef void mpz_vector_clear(mpz_vector* v): +cdef void mpz_vector_clear(mpz_vector* v) noexcept: cdef Py_ssize_t i # Free all mpz objects allocated in creating v for i from 0 <= i < v.num_nonzero: @@ -54,7 +54,7 @@ cdef void mpz_vector_clear(mpz_vector* v): sig_free(v.entries) sig_free(v.positions) -cdef Py_ssize_t mpz_binary_search0(mpz_t* v, Py_ssize_t n, mpz_t x): +cdef Py_ssize_t mpz_binary_search0(mpz_t* v, Py_ssize_t n, mpz_t x) noexcept: """ Find the position of the integers x in the array v, which has length n. Returns -1 if x is not in the array v. @@ -79,7 +79,7 @@ cdef Py_ssize_t mpz_binary_search0(mpz_t* v, Py_ssize_t n, mpz_t x): return k return -1 -cdef Py_ssize_t mpz_binary_search(mpz_t* v, Py_ssize_t n, mpz_t x, Py_ssize_t* ins): +cdef Py_ssize_t mpz_binary_search(mpz_t* v, Py_ssize_t n, mpz_t x, Py_ssize_t* ins) noexcept: """ Find the position of the integer x in the array v, which has length n. Returns -1 if x is not in the array v, and in this case ins is @@ -142,7 +142,7 @@ cdef int mpz_vector_get_entry(mpz_t ans, mpz_vector* v, Py_ssize_t n) except -1: mpz_set(ans, v.entries[m]) return 0 -cdef bint mpz_vector_is_entry_zero_unsafe(mpz_vector* v, Py_ssize_t n): +cdef bint mpz_vector_is_entry_zero_unsafe(mpz_vector* v, Py_ssize_t n) noexcept: """ Return if the ``n``-th entry of the sparse vector ``v`` is zero. @@ -151,7 +151,7 @@ cdef bint mpz_vector_is_entry_zero_unsafe(mpz_vector* v, Py_ssize_t n): """ return binary_search0(v.positions, v.num_nonzero, n) == -1 -cdef object mpz_vector_to_list(mpz_vector* v): +cdef object mpz_vector_to_list(mpz_vector* v) noexcept: """ Returns a Python list of 2-tuples (i,x), where x=v[i] runs through the nonzero elements of x, in order. @@ -388,7 +388,7 @@ cdef int mpz_vector_scalar_multiply(mpz_vector* v, mpz_vector* w, mpz_t scalar) v.positions[i] = w.positions[i] return 0 -cdef int mpz_vector_cmp(mpz_vector* v, mpz_vector* w): +cdef int mpz_vector_cmp(mpz_vector* v, mpz_vector* w) noexcept: if v.degree < w.degree: return -1 elif v.degree > w.degree: diff --git a/src/sage/modules/vector_mod2_dense.pxd b/src/sage/modules/vector_mod2_dense.pxd index a5542fe1345..98a77624019 100644 --- a/src/sage/modules/vector_mod2_dense.pxd +++ b/src/sage/modules/vector_mod2_dense.pxd @@ -6,5 +6,5 @@ cdef class Vector_mod2_dense(FreeModuleElement): cdef mzd_t* _entries cdef object _base_ring - cdef _new_c(self) - cdef _init(self, Py_ssize_t degree, parent) + cdef _new_c(self) noexcept + cdef _init(self, Py_ssize_t degree, parent) noexcept diff --git a/src/sage/modules/vector_mod2_dense.pyx b/src/sage/modules/vector_mod2_dense.pyx index 93fc3f32cd1..243d8020138 100644 --- a/src/sage/modules/vector_mod2_dense.pyx +++ b/src/sage/modules/vector_mod2_dense.pyx @@ -50,7 +50,7 @@ cimport sage.modules.free_module_element as free_module_element from sage.libs.m4ri cimport * cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): - cdef _new_c(self): + cdef _new_c(self) noexcept: """ EXAMPLES:: @@ -65,7 +65,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): y._init(self._degree, self._parent) return y - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: """ EXAMPLES:: @@ -75,7 +75,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): """ return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: """ EXAMPLES:: @@ -105,7 +105,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): mzd_copy(y._entries, self._entries) return y - cdef _init(self, Py_ssize_t degree, parent): + cdef _init(self, Py_ssize_t degree, parent) noexcept: """ EXAMPLES:: @@ -227,7 +227,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): if self._entries: mzd_free(self._entries) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -253,7 +253,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): c = mzd_cmp(left._entries, (right)._entries) return rich_to_bool(op, c) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -302,7 +302,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): return unpickle_v0, (self._parent, self.list(), self._degree, self._is_immutable) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ EXAMPLES:: @@ -317,7 +317,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): mzd_add(z._entries, self._entries, (right)._entries) return z - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -332,7 +332,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): mzd_add(z._entries, self._entries, (right)._entries) return z - cpdef int hamming_weight(self): + cpdef int hamming_weight(self) noexcept: """ Return the number of positions ``i`` such that ``self[i] != 0``. @@ -349,7 +349,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): return res - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: """ EXAMPLES:: @@ -397,7 +397,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): return n - cpdef _pairwise_product_(self, Vector right): + cpdef _pairwise_product_(self, Vector right) noexcept: """ EXAMPLES:: @@ -419,7 +419,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): zrow[i] = (lrow[i] & rrow[i]) return z - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -450,7 +450,7 @@ cdef class Vector_mod2_dense(free_module_element.FreeModuleElement): else: return self._new_c() - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: diff --git a/src/sage/modules/vector_modn_dense.pxd b/src/sage/modules/vector_modn_dense.pxd index 4e0aff593fe..2482f999d37 100644 --- a/src/sage/modules/vector_modn_dense.pxd +++ b/src/sage/modules/vector_modn_dense.pxd @@ -6,6 +6,6 @@ cdef class Vector_modn_dense(FreeModuleElement): cdef mod_int _p cdef object _base_ring - cdef _new_c(self) - cdef _init(self, Py_ssize_t degree, parent, mod_int p) + cdef _new_c(self) noexcept + cdef _init(self, Py_ssize_t degree, parent, mod_int p) noexcept diff --git a/src/sage/modules/vector_modn_dense.pyx b/src/sage/modules/vector_modn_dense.pyx index 8608672031d..57103bd48c4 100644 --- a/src/sage/modules/vector_modn_dense.pyx +++ b/src/sage/modules/vector_modn_dense.pyx @@ -135,16 +135,16 @@ cimport sage.modules.free_module_element as free_module_element cdef class Vector_modn_dense(free_module_element.FreeModuleElement): - cdef _new_c(self): + cdef _new_c(self) noexcept: cdef Vector_modn_dense y y = Vector_modn_dense.__new__(Vector_modn_dense) y._init(self._degree, self._parent, self._p) return y - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 0 def __copy__(self): @@ -155,7 +155,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): y._entries[i] = self._entries[i] return y - cdef _init(self, Py_ssize_t degree, parent, mod_int p): + cdef _init(self, Py_ssize_t degree, parent, mod_int p) noexcept: self._degree = degree self._parent = parent self._p = p @@ -194,7 +194,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): def __dealloc__(self): sig_free(self._entries) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -220,7 +220,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): return rich_to_bool(op, 1) return rich_to_bool(op, 0) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -276,7 +276,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): return unpickle_v1, (self._parent, self.list(), self._degree, self._p, not self._is_immutable) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: cdef Vector_modn_dense z, r r = right z = self._new_c() @@ -286,7 +286,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): return z - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: cdef Vector_modn_dense z, r r = right z = self._new_c() @@ -295,7 +295,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): z._entries[i] = (self._p + self._entries[i] - r._entries[i]) % self._p return z - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: cdef size_t i cdef IntegerMod_int n cdef IntegerMod_int64 m @@ -316,7 +316,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): m.ivalue = (m.ivalue + self._entries[i] * r._entries[i]) % self._p return m - cpdef _pairwise_product_(self, Vector right): + cpdef _pairwise_product_(self, Vector right) noexcept: """ EXAMPLES:: @@ -334,7 +334,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): z._entries[i] = (self._entries[i] * r._entries[i]) % self._p return z - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: cdef Vector_modn_dense z cdef mod_int a = ivalue(left) @@ -345,7 +345,7 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): z._entries[i] = (self._entries[i] * a) % self._p return z - cpdef _neg_(self): + cpdef _neg_(self) noexcept: cdef Vector_modn_dense z z = self._new_c() cdef Py_ssize_t i diff --git a/src/sage/modules/vector_modn_sparse.pxd b/src/sage/modules/vector_modn_sparse.pxd index 41d2dd1dd43..d345ecd1e12 100644 --- a/src/sage/modules/vector_modn_sparse.pxd +++ b/src/sage/modules/vector_modn_sparse.pxd @@ -9,12 +9,12 @@ cdef struct c_vector_modint: cdef int allocate_c_vector_modint(c_vector_modint* v, Py_ssize_t num_nonzero) except -1 cdef int init_c_vector_modint(c_vector_modint* v, int p, Py_ssize_t degree, Py_ssize_t num_nonzero) except -1 -cdef void clear_c_vector_modint(c_vector_modint* v) -cdef Py_ssize_t binary_search0_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x) -cdef Py_ssize_t binary_search_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x, Py_ssize_t* ins) +cdef void clear_c_vector_modint(c_vector_modint* v) noexcept +cdef Py_ssize_t binary_search0_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x) noexcept +cdef Py_ssize_t binary_search_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x, Py_ssize_t* ins) noexcept cdef int_fast64_t get_entry(c_vector_modint* v, Py_ssize_t n) except -1 -cdef bint is_entry_zero_unsafe(c_vector_modint* v, Py_ssize_t n) -cdef object to_list(c_vector_modint* v) +cdef bint is_entry_zero_unsafe(c_vector_modint* v, Py_ssize_t n) noexcept +cdef object to_list(c_vector_modint* v) noexcept cdef int set_entry(c_vector_modint* v, Py_ssize_t n, int_fast64_t x) except -1 cdef int add_c_vector_modint_init(c_vector_modint* sum, c_vector_modint* v, c_vector_modint* w, int multiple) except -1 cdef int scale_c_vector_modint(c_vector_modint* v, int_fast64_t scalar) except -1 diff --git a/src/sage/modules/vector_modn_sparse.pyx b/src/sage/modules/vector_modn_sparse.pyx index e2dd1d7c1a6..9ea760c31a2 100644 --- a/src/sage/modules/vector_modn_sparse.pyx +++ b/src/sage/modules/vector_modn_sparse.pyx @@ -38,12 +38,12 @@ cdef int init_c_vector_modint(c_vector_modint* v, int p, Py_ssize_t degree, return 0 -cdef void clear_c_vector_modint(c_vector_modint* v): +cdef void clear_c_vector_modint(c_vector_modint* v) noexcept: sig_free(v.entries) sig_free(v.positions) -cdef Py_ssize_t binary_search0_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x): +cdef Py_ssize_t binary_search0_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x) noexcept: """ Find the position of the int x in the array v, which has length n. @@ -70,7 +70,7 @@ cdef Py_ssize_t binary_search0_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x) return -1 -cdef Py_ssize_t binary_search_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x, Py_ssize_t* ins): +cdef Py_ssize_t binary_search_modn(Py_ssize_t* v, Py_ssize_t n, int_fast64_t x, Py_ssize_t* ins) noexcept: """ Find the position of the integer x in the array v, which has length n. @@ -121,7 +121,7 @@ cdef int_fast64_t get_entry(c_vector_modint* v, Py_ssize_t n) except -1: return 0 return v.entries[m] -cdef bint is_entry_zero_unsafe(c_vector_modint* v, Py_ssize_t n): +cdef bint is_entry_zero_unsafe(c_vector_modint* v, Py_ssize_t n) noexcept: """ Return if the ``n``-th entry of the sparse vector ``v`` is zero. @@ -130,7 +130,7 @@ cdef bint is_entry_zero_unsafe(c_vector_modint* v, Py_ssize_t n): """ return binary_search0_modn(v.positions, v.num_nonzero, n) == -1 -cdef object to_list(c_vector_modint* v): +cdef object to_list(c_vector_modint* v) noexcept: """ Return a Python list of 2-tuples (i,x), where x=v[i] runs through the nonzero elements of x, in order. diff --git a/src/sage/modules/vector_numpy_dense.pxd b/src/sage/modules/vector_numpy_dense.pxd index b019bc8ebac..6af57a997c5 100644 --- a/src/sage/modules/vector_numpy_dense.pxd +++ b/src/sage/modules/vector_numpy_dense.pxd @@ -8,5 +8,5 @@ cdef class Vector_numpy_dense(FreeModuleElement): cdef object _sage_dtype cdef object _sage_vector_dtype cdef numpy.ndarray _vector_numpy - cdef Vector_numpy_dense _new(self, numpy.ndarray vector_numpy) - cdef _replace_self_with_numpy(self, numpy.ndarray numpy_array) + cdef Vector_numpy_dense _new(self, numpy.ndarray vector_numpy) noexcept + cdef _replace_self_with_numpy(self, numpy.ndarray numpy_array) noexcept diff --git a/src/sage/modules/vector_numpy_dense.pyx b/src/sage/modules/vector_numpy_dense.pyx index f0e2224b96d..fc14cc4829a 100644 --- a/src/sage/modules/vector_numpy_dense.pyx +++ b/src/sage/modules/vector_numpy_dense.pyx @@ -68,7 +68,7 @@ cdef class Vector_numpy_dense(FreeModuleElement): self._degree = parent.degree() self._parent = parent - cdef Vector_numpy_dense _new(self, numpy.ndarray vector_numpy): + cdef Vector_numpy_dense _new(self, numpy.ndarray vector_numpy) noexcept: """ Return a new vector with same parent as self. """ @@ -101,13 +101,13 @@ cdef class Vector_numpy_dense(FreeModuleElement): self._vector_numpy = numpy.PyArray_SimpleNew(1, dims, self._numpy_dtypeint) return - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: """ Return True (i.e., 1) if self is dense. """ return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: """ Return True (i.e., 1) if self is sparse. """ @@ -231,7 +231,7 @@ cdef class Vector_numpy_dense(FreeModuleElement): self._python_dtype(value)) #TODO: Throw an error if status == -1 - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -248,7 +248,7 @@ cdef class Vector_numpy_dense(FreeModuleElement): return self._sage_dtype(numpy.PyArray_GETITEM(self._vector_numpy, numpy.PyArray_GETPTR1(self._vector_numpy, i))) - cdef _replace_self_with_numpy(self, numpy.ndarray numpy_array): + cdef _replace_self_with_numpy(self, numpy.ndarray numpy_array) noexcept: """ Replace the underlying numpy array with numpy_array. """ diff --git a/src/sage/modules/vector_rational_dense.pxd b/src/sage/modules/vector_rational_dense.pxd index 34db6f6252b..1bcde479153 100644 --- a/src/sage/modules/vector_rational_dense.pxd +++ b/src/sage/modules/vector_rational_dense.pxd @@ -6,7 +6,7 @@ cdef class Vector_rational_dense(FreeModuleElement): cdef mpq_t* _entries cdef int _init(self, Py_ssize_t degree, Parent parent) except -1 - cdef inline Vector_rational_dense _new_c(self): + cdef inline Vector_rational_dense _new_c(self) noexcept: cdef type t = type(self) cdef Vector_rational_dense x = (t.__new__(t)) x._init(self._degree, self._parent) diff --git a/src/sage/modules/vector_rational_dense.pyx b/src/sage/modules/vector_rational_dense.pyx index 34b23515348..bca39f51f5a 100644 --- a/src/sage/modules/vector_rational_dense.pyx +++ b/src/sage/modules/vector_rational_dense.pyx @@ -67,15 +67,15 @@ cimport sage.modules.free_module_element as free_module_element from sage.libs.gmp.mpq cimport * -cdef inline _Rational_from_mpq(mpq_t e): +cdef inline _Rational_from_mpq(mpq_t e) noexcept: cdef Rational z = Rational.__new__(Rational) mpq_set(z.value, e) return z cdef class Vector_rational_dense(free_module_element.FreeModuleElement): - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: return 1 - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: return 0 def __copy__(self): @@ -162,7 +162,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_clear(self._entries[i]) sig_free(self._entries) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -192,7 +192,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): return rich_to_bool(op, 1) return rich_to_bool(op, 0) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ EXAMPLES:: @@ -253,7 +253,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): return (unpickle_v1, (self._parent, self.list(), self._degree, not self._is_immutable)) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: cdef Vector_rational_dense z, r r = right z = self._new_c() @@ -262,7 +262,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_add(z._entries[i], self._entries[i], r._entries[i]) return z - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: cdef Vector_rational_dense z, r r = right z = self._new_c() @@ -271,7 +271,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_sub(z._entries[i], self._entries[i], r._entries[i]) return z - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: """ Dot product of dense vectors over the rationals. @@ -296,7 +296,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_clear(t) return z - cpdef _pairwise_product_(self, Vector right): + cpdef _pairwise_product_(self, Vector right) noexcept: """ EXAMPLES:: @@ -312,7 +312,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_mul(z._entries[i], self._entries[i], r._entries[i]) return z - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: cdef Vector_rational_dense z cdef Rational a if isinstance(left, Rational): @@ -330,7 +330,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_mul(z._entries[i], self._entries[i], a.value) return z - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: cdef Vector_rational_dense z cdef Rational a if isinstance(right, Rational): @@ -348,7 +348,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement): mpq_mul(z._entries[i], self._entries[i], a.value) return z - cpdef _neg_(self): + cpdef _neg_(self) noexcept: cdef Vector_rational_dense z z = self._new_c() cdef Py_ssize_t i diff --git a/src/sage/modules/vector_rational_sparse.pxd b/src/sage/modules/vector_rational_sparse.pxd index 0888a8700fe..b738ad18edb 100644 --- a/src/sage/modules/vector_rational_sparse.pxd +++ b/src/sage/modules/vector_rational_sparse.pxd @@ -15,15 +15,15 @@ cdef struct mpq_vector: cdef int reallocate_mpq_vector(mpq_vector* v, Py_ssize_t num_nonzero) except -1 cdef int allocate_mpq_vector(mpq_vector* v, Py_ssize_t num_nonzero) except -1 cdef int mpq_vector_init(mpq_vector* v, Py_ssize_t degree, Py_ssize_t num_nonzero) except -1 -cdef void mpq_vector_clear(mpq_vector* v) -cdef Py_ssize_t mpq_binary_search0(mpq_t* v, Py_ssize_t n, mpq_t x) -cdef Py_ssize_t mpq_binary_search(mpq_t* v, Py_ssize_t n, mpq_t x, Py_ssize_t* ins) +cdef void mpq_vector_clear(mpq_vector* v) noexcept +cdef Py_ssize_t mpq_binary_search0(mpq_t* v, Py_ssize_t n, mpq_t x) noexcept +cdef Py_ssize_t mpq_binary_search(mpq_t* v, Py_ssize_t n, mpq_t x, Py_ssize_t* ins) noexcept cdef int mpq_vector_get_entry(mpq_t ans, mpq_vector* v, Py_ssize_t n) except -1 -cdef bint mpq_vector_is_entry_zero_unsafe(mpq_vector* v, Py_ssize_t n) -cdef object mpq_vector_to_list(mpq_vector* v) +cdef bint mpq_vector_is_entry_zero_unsafe(mpq_vector* v, Py_ssize_t n) noexcept +cdef object mpq_vector_to_list(mpq_vector* v) noexcept cdef int mpq_vector_set_entry(mpq_vector* v, Py_ssize_t n, mpq_t x) except -1 cdef int mpq_vector_set_entry_str(mpq_vector* v, Py_ssize_t n, char *x_str) except -1 cdef int add_mpq_vector_init(mpq_vector* sum, mpq_vector* v, mpq_vector* w, mpq_t multiple) except -1 cdef int mpq_vector_scale(mpq_vector* v, mpq_t scalar) except -1 cdef int mpq_vector_scalar_multiply(mpq_vector* v, mpq_vector* w, mpq_t scalar) except -1 -cdef int mpq_vector_cmp(mpq_vector* v, mpq_vector* w) +cdef int mpq_vector_cmp(mpq_vector* v, mpq_vector* w) noexcept diff --git a/src/sage/modules/vector_rational_sparse.pyx b/src/sage/modules/vector_rational_sparse.pyx index 14d0953b3df..2058d9bef25 100644 --- a/src/sage/modules/vector_rational_sparse.pyx +++ b/src/sage/modules/vector_rational_sparse.pyx @@ -47,7 +47,7 @@ cdef int mpq_vector_init(mpq_vector* v, Py_ssize_t degree, Py_ssize_t num_nonzer v.num_nonzero = num_nonzero v.degree = degree -cdef void mpq_vector_clear(mpq_vector* v): +cdef void mpq_vector_clear(mpq_vector* v) noexcept: cdef Py_ssize_t i if v.entries == NULL: return @@ -61,7 +61,7 @@ cdef void mpq_vector_clear(mpq_vector* v): sig_free(v.entries) sig_free(v.positions) -cdef Py_ssize_t mpq_binary_search0(mpq_t* v, Py_ssize_t n, mpq_t x): +cdef Py_ssize_t mpq_binary_search0(mpq_t* v, Py_ssize_t n, mpq_t x) noexcept: """ Find the position of the rational x in the array v, which has length n. Returns -1 if x is not in the array v. @@ -86,7 +86,7 @@ cdef Py_ssize_t mpq_binary_search0(mpq_t* v, Py_ssize_t n, mpq_t x): return k return -1 -cdef Py_ssize_t mpq_binary_search(mpq_t* v, Py_ssize_t n, mpq_t x, Py_ssize_t* ins): +cdef Py_ssize_t mpq_binary_search(mpq_t* v, Py_ssize_t n, mpq_t x, Py_ssize_t* ins) noexcept: """ Find the position of the integer x in the array v, which has length n. Returns -1 if x is not in the array v, and in this case ins is @@ -149,7 +149,7 @@ cdef int mpq_vector_get_entry(mpq_t ans, mpq_vector* v, Py_ssize_t n) except -1: mpq_set(ans, v.entries[m]) return 0 -cdef bint mpq_vector_is_entry_zero_unsafe(mpq_vector* v, Py_ssize_t n): +cdef bint mpq_vector_is_entry_zero_unsafe(mpq_vector* v, Py_ssize_t n) noexcept: """ Return if the ``n``-th entry of the sparse vector ``v`` is zero. @@ -158,7 +158,7 @@ cdef bint mpq_vector_is_entry_zero_unsafe(mpq_vector* v, Py_ssize_t n): """ return binary_search0(v.positions, v.num_nonzero, n) == -1 -cdef object mpq_vector_to_list(mpq_vector* v): +cdef object mpq_vector_to_list(mpq_vector* v) noexcept: """ Returns a Python list of 2-tuples (i,x), where x=v[i] runs through the nonzero elements of x, in order. @@ -395,7 +395,7 @@ cdef int mpq_vector_scalar_multiply(mpq_vector* v, mpq_vector* w, mpq_t scalar) v.positions[i] = w.positions[i] return 0 -cdef int mpq_vector_cmp(mpq_vector* v, mpq_vector* w): +cdef int mpq_vector_cmp(mpq_vector* v, mpq_vector* w) noexcept: if v.degree < w.degree: return -1 elif v.degree > w.degree: diff --git a/src/sage/modules/with_basis/indexed_element.pxd b/src/sage/modules/with_basis/indexed_element.pxd index ebc785d7ccf..06fec702dcf 100644 --- a/src/sage/modules/with_basis/indexed_element.pxd +++ b/src/sage/modules/with_basis/indexed_element.pxd @@ -5,8 +5,8 @@ cdef class IndexedFreeModuleElement(ModuleElement): cdef long _hash cdef bint _hash_set - cpdef _add_(self, other) - cpdef _sub_(self, other) - cpdef _neg_(self) + cpdef _add_(self, other) noexcept + cpdef _sub_(self, other) noexcept + cpdef _neg_(self) noexcept - cpdef dict monomial_coefficients(self, bint copy=*) + cpdef dict monomial_coefficients(self, bint copy=*) noexcept diff --git a/src/sage/modules/with_basis/indexed_element.pyx b/src/sage/modules/with_basis/indexed_element.pyx index 90f7b8ec580..db2ff9ee4a5 100644 --- a/src/sage/modules/with_basis/indexed_element.pyx +++ b/src/sage/modules/with_basis/indexed_element.pyx @@ -227,7 +227,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): """ return self - cpdef dict monomial_coefficients(self, bint copy=True): + cpdef dict monomial_coefficients(self, bint copy=True) noexcept: """ Return the internal dictionary which has the combinatorial objects indexing the basis as keys and their corresponding coefficients as @@ -540,7 +540,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): repr_monomial = self._parent._latex_term, is_latex=True, strip_one=True) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Rich comparison for equal parents. @@ -650,7 +650,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): w = sorted(elt._monomial_coefficients.items()) return richcmp(v, w, op) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ EXAMPLES:: @@ -673,7 +673,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): add(self._monomial_coefficients, (other)._monomial_coefficients)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: @@ -691,7 +691,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): """ return type(self)(self._parent, negate(self._monomial_coefficients)) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ EXAMPLES:: @@ -830,7 +830,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): to_vector = _vector_ - cpdef _acted_upon_(self, scalar, bint self_on_left): + cpdef _acted_upon_(self, scalar, bint self_on_left) noexcept: """ Return the action of ``scalar`` (an element of the base ring) on ``self``. @@ -904,7 +904,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): scal(scalar, self._monomial_coefficients, factor_on_left=not self_on_left)) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ For backward compatibility. @@ -916,7 +916,7 @@ cdef class IndexedFreeModuleElement(ModuleElement): """ return self._acted_upon_(right, True) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ For backward compatibility. diff --git a/src/sage/monoids/free_abelian_monoid_element.pxd b/src/sage/monoids/free_abelian_monoid_element.pxd index 092cd343f05..fe65af79711 100644 --- a/src/sage/monoids/free_abelian_monoid_element.pxd +++ b/src/sage/monoids/free_abelian_monoid_element.pxd @@ -8,7 +8,7 @@ cdef class FreeAbelianMonoidElement(MonoidElement): cdef int _init(self, Py_ssize_t n, Parent parent) except -1 - cdef inline FreeAbelianMonoidElement _new_c(self): + cdef inline FreeAbelianMonoidElement _new_c(self) noexcept: cdef type t = type(self) cdef FreeAbelianMonoidElement x = (t.__new__(t)) x._init(self._n, self._parent) diff --git a/src/sage/monoids/free_abelian_monoid_element.pyx b/src/sage/monoids/free_abelian_monoid_element.pyx index 65df8efe613..66bd3a15ed5 100644 --- a/src/sage/monoids/free_abelian_monoid_element.pyx +++ b/src/sage/monoids/free_abelian_monoid_element.pyx @@ -263,7 +263,7 @@ cdef class FreeAbelianMonoidElement(MonoidElement): s = "1" return s - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Rich comparison. diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 22bdfd20ea6..4100fb71b76 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -92,7 +92,7 @@ cdef class CVXOPTBackend(GenericBackend): else: self.set_sense(-1) - cpdef __copy__(self): + cpdef __copy__(self) noexcept: # Added a second inequality to this doctest, # because otherwise CVXOPT complains: ValueError: Rank(A) < p or Rank([G; A]) < n """ @@ -204,7 +204,7 @@ cdef class CVXOPTBackend(GenericBackend): self.col_name_var.append(name) return len(self.objective_function) - 1 - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable. @@ -223,7 +223,7 @@ cdef class CVXOPTBackend(GenericBackend): if vtype != -1: raise ValueError('This backend does not handle integer variables ! Read the doc !') - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -249,7 +249,7 @@ cdef class CVXOPTBackend(GenericBackend): else: self.is_maximize = 0 - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -277,7 +277,7 @@ cdef class CVXOPTBackend(GenericBackend): else: return self.objective_function[variable] - cpdef set_objective(self, list coeff, d = 0.0): + cpdef set_objective(self, list coeff, d = 0.0) noexcept: """ Set the objective function. @@ -302,13 +302,13 @@ cdef class CVXOPTBackend(GenericBackend): self.objective_function[i] = coeff[i] obj_constant_term = d - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Does not apply for the cvxopt solver """ pass - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -356,7 +356,7 @@ cdef class CVXOPTBackend(GenericBackend): self.objective_function.append(0) self.col_name_var.append(None) - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -554,7 +554,7 @@ cdef class CVXOPTBackend(GenericBackend): return 0 - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -586,7 +586,7 @@ cdef class CVXOPTBackend(GenericBackend): i+=1 return sum - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -613,7 +613,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return self.answer['x'][variable] - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -631,7 +631,7 @@ cdef class CVXOPTBackend(GenericBackend): return len(self.objective_function) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -650,7 +650,7 @@ cdef class CVXOPTBackend(GenericBackend): return len(self.row_upper_bound) - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -669,7 +669,7 @@ cdef class CVXOPTBackend(GenericBackend): else: return 0 - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -693,7 +693,7 @@ cdef class CVXOPTBackend(GenericBackend): self.prob_name = name - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -731,7 +731,7 @@ cdef class CVXOPTBackend(GenericBackend): return (idx, coeff) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -759,7 +759,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return (self.row_lower_bound[index], self.row_upper_bound[index]) - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -787,7 +787,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return (self.col_lower_bound[index], self.col_upper_bound[index]) - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. CVXOPT does not allow integer variables, so this is a bit moot. @@ -814,7 +814,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return False - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. CVXOPT does not allow integer variables, so this is a bit moot. @@ -841,7 +841,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return False - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. CVXOPT does not allow integer variables, so this is a bit moot. @@ -870,7 +870,7 @@ cdef class CVXOPTBackend(GenericBackend): """ return True - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -890,7 +890,7 @@ cdef class CVXOPTBackend(GenericBackend): return self.row_name_var[index] return "constraint_" + repr(index) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name @@ -914,7 +914,7 @@ cdef class CVXOPTBackend(GenericBackend): return self.col_name_var[index] return "x_" + repr(index) - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -943,7 +943,7 @@ cdef class CVXOPTBackend(GenericBackend): else: return self.col_upper_bound[index] - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable @@ -972,7 +972,7 @@ cdef class CVXOPTBackend(GenericBackend): else: return self.col_lower_bound[index] - cpdef solver_parameter(self, name, value = None): + cpdef solver_parameter(self, name, value = None) noexcept: """ Return or define a solver parameter diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index bb999559ee2..aefa91439bf 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -161,7 +161,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): return 0 - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -196,7 +196,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): i+=1 return sum - cpdef _get_answer(self): + cpdef _get_answer(self) noexcept: """ return the complete output dict of the solver @@ -222,7 +222,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): """ return self.answer - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -256,7 +256,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): """ return self.answer['x'][variable] - cpdef dual_variable(self, int i, sparse=False): + cpdef dual_variable(self, int i, sparse=False) noexcept: """ The `i`-th dual variable @@ -306,7 +306,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): assert(n == self.answer['zs'][i].size[1]) # must be square matrix return Matrix(n, n, list(self.answer['zs'][i]), sparse=sparse) - cpdef slack(self, int i, sparse=False): + cpdef slack(self, int i, sparse=False) noexcept: """ Slack of the `i`-th constraint @@ -358,7 +358,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): return Matrix(n, n, list(self.answer['ss'][i]), sparse=sparse) - cpdef solver_parameter(self, name, value = None): + cpdef solver_parameter(self, name, value = None) noexcept: """ Return or define a solver parameter diff --git a/src/sage/numerical/backends/cvxpy_backend.pxd b/src/sage/numerical/backends/cvxpy_backend.pxd index ed4d63ccc63..96dd9c33390 100644 --- a/src/sage/numerical/backends/cvxpy_backend.pxd +++ b/src/sage/numerical/backends/cvxpy_backend.pxd @@ -37,4 +37,4 @@ cdef class CVXPYBackend(GenericBackend): coefficients=*) \ except -1 - cpdef cvxpy_problem(self) + cpdef cvxpy_problem(self) noexcept diff --git a/src/sage/numerical/backends/cvxpy_backend.pyx b/src/sage/numerical/backends/cvxpy_backend.pyx index 4ffae61809a..7cf5ccc8fb6 100644 --- a/src/sage/numerical/backends/cvxpy_backend.pyx +++ b/src/sage/numerical/backends/cvxpy_backend.pyx @@ -142,7 +142,7 @@ cdef class CVXPYBackend: objective = cvxpy.Minimize(0) self.problem = cvxpy.Problem(objective, ()) - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Returns a copy of self. @@ -172,7 +172,7 @@ cdef class CVXPYBackend: cp.obj_constant_term = self.obj_constant_term return cp - cpdef cvxpy_problem(self): + cpdef cvxpy_problem(self) noexcept: return self.problem def cvxpy_variables(self): @@ -284,7 +284,7 @@ cdef class CVXPYBackend: return index - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the log (verbosity) level @@ -302,7 +302,7 @@ cdef class CVXPYBackend: """ pass - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -361,7 +361,7 @@ cdef class CVXPYBackend: self.constraint_names.append(name) self.problem = cvxpy.Problem(self.problem.objective, constraints) - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -408,7 +408,7 @@ cdef class CVXPYBackend: #self.objective_coefficients.append(0) goes to "self.add_variable" self.add_variable(coefficients=zip(indices, coeffs)) - cpdef set_objective(self, list coeff, d=0.0): + cpdef set_objective(self, list coeff, d=0.0) noexcept: """ Set the objective function. @@ -440,7 +440,7 @@ cdef class CVXPYBackend: self.problem = cvxpy.Problem(objective, constraints) self.obj_constant_term = d - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -468,7 +468,7 @@ cdef class CVXPYBackend: objective = cvxpy.Minimize(expr) self.problem = cvxpy.Problem(objective, self.problem.constraints) - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -543,7 +543,7 @@ cdef class CVXPYBackend: raise MIPSolverException(f"cvxpy.Problem.solve: Problem is unbounded") raise MIPSolverException(f"cvxpy.Problem.solve reported an unknown problem status: {status}") - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -570,7 +570,7 @@ cdef class CVXPYBackend: """ return self.problem.value + self.obj_constant_term - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -597,7 +597,7 @@ cdef class CVXPYBackend: """ return float(self.variables[variable].value) - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -614,7 +614,7 @@ cdef class CVXPYBackend: """ return len(self.variables) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -630,7 +630,7 @@ cdef class CVXPYBackend: """ return len(self.problem.constraints) - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -646,7 +646,7 @@ cdef class CVXPYBackend: """ return isinstance(self.problem.objective, cvxpy.Maximize) - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -671,7 +671,7 @@ cdef class CVXPYBackend: else: self.prob_name = str(name) - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -707,7 +707,7 @@ cdef class CVXPYBackend: coef.append(self.Matrix[i][j]) return (idx, coef) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -736,7 +736,7 @@ cdef class CVXPYBackend: """ return (self.row_lower_bound[index], self.row_upper_bound[index]) - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -764,7 +764,7 @@ cdef class CVXPYBackend: """ return (self.col_lower_bound[index], self.col_upper_bound[index]) - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -785,7 +785,7 @@ cdef class CVXPYBackend: """ return bool(self.variables[index].boolean_idx) - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -806,7 +806,7 @@ cdef class CVXPYBackend: """ return bool(self.variables[index].integer_idx) - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -827,7 +827,7 @@ cdef class CVXPYBackend: """ return not self.is_variable_binary(index) and not self.is_variable_integer(index) - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -845,7 +845,7 @@ cdef class CVXPYBackend: """ return self.constraint_names[index] or ("constraint_" + repr(index)) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name @@ -867,7 +867,7 @@ cdef class CVXPYBackend: """ return self.variables[index].name() - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -899,7 +899,7 @@ cdef class CVXPYBackend: else: return self.col_upper_bound[index] - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable diff --git a/src/sage/numerical/backends/generic_backend.pxd b/src/sage/numerical/backends/generic_backend.pxd index 2d031424d1e..60983afc6f2 100644 --- a/src/sage/numerical/backends/generic_backend.pxd +++ b/src/sage/numerical/backends/generic_backend.pxd @@ -12,49 +12,49 @@ from sage.structure.sage_object cimport SageObject cdef class GenericBackend (SageObject): cpdef int add_variable(self, lower_bound=*, upper_bound=*, binary=*, continuous=*, integer=*, obj=*, name=*) except -1 cpdef int add_variables(self, int, lower_bound=*, upper_bound=*, binary=*, continuous=*, integer=*, obj=*, names=*) except -1 - cpdef set_variable_type(self, int variable, int vtype) - cpdef set_sense(self, int sense) - cpdef objective_coefficient(self, int variable, coeff=*) - cpdef objective_constant_term(self, d=*) - cpdef set_objective(self, list coeff, d=*) - cpdef set_verbosity(self, int level) - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=*) - cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=*) - cpdef remove_constraint(self, int) - cpdef remove_constraints(self, constraints) - cpdef add_col(self, indices, coeffs) - cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=*) + cpdef set_variable_type(self, int variable, int vtype) noexcept + cpdef set_sense(self, int sense) noexcept + cpdef objective_coefficient(self, int variable, coeff=*) noexcept + cpdef objective_constant_term(self, d=*) noexcept + cpdef set_objective(self, list coeff, d=*) noexcept + cpdef set_verbosity(self, int level) noexcept + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=*) noexcept + cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=*) noexcept + cpdef remove_constraint(self, int) noexcept + cpdef remove_constraints(self, constraints) noexcept + cpdef add_col(self, indices, coeffs) noexcept + cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=*) noexcept cpdef int solve(self) except -1 - cpdef get_objective_value(self) - cpdef best_known_objective_bound(self) - cpdef get_relative_objective_gap(self) - cpdef get_variable_value(self, int variable) - cpdef bint is_maximization(self) - cpdef write_lp(self, name) - cpdef write_mps(self, name, int modern) - cpdef row(self, int i) - cpdef int ncols(self) - cpdef int nrows(self) - cpdef bint is_variable_binary(self, int) - cpdef bint is_variable_integer(self, int) - cpdef bint is_variable_continuous(self, int) - cpdef problem_name(self, name = *) - cpdef row_bounds(self, int index) - cpdef col_bounds(self, int index) - cpdef row_name(self, int index) - cpdef col_name(self, int index) - cpdef variable_upper_bound(self, int index, value = *) - cpdef variable_lower_bound(self, int index, value = *) - cpdef solver_parameter(self, name, value=*) - cpdef zero(self) - cpdef base_ring(self) - cpdef __copy__(self) - cpdef copy(self) - cpdef bint is_variable_basic(self, int index) - cpdef bint is_variable_nonbasic_at_lower_bound(self, int index) - cpdef bint is_slack_variable_basic(self, int index) - cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index) + cpdef get_objective_value(self) noexcept + cpdef best_known_objective_bound(self) noexcept + cpdef get_relative_objective_gap(self) noexcept + cpdef get_variable_value(self, int variable) noexcept + cpdef bint is_maximization(self) noexcept + cpdef write_lp(self, name) noexcept + cpdef write_mps(self, name, int modern) noexcept + cpdef row(self, int i) noexcept + cpdef int ncols(self) noexcept + cpdef int nrows(self) noexcept + cpdef bint is_variable_binary(self, int) noexcept + cpdef bint is_variable_integer(self, int) noexcept + cpdef bint is_variable_continuous(self, int) noexcept + cpdef problem_name(self, name = *) noexcept + cpdef row_bounds(self, int index) noexcept + cpdef col_bounds(self, int index) noexcept + cpdef row_name(self, int index) noexcept + cpdef col_name(self, int index) noexcept + cpdef variable_upper_bound(self, int index, value = *) noexcept + cpdef variable_lower_bound(self, int index, value = *) noexcept + cpdef solver_parameter(self, name, value=*) noexcept + cpdef zero(self) noexcept + cpdef base_ring(self) noexcept + cpdef __copy__(self) noexcept + cpdef copy(self) noexcept + cpdef bint is_variable_basic(self, int index) noexcept + cpdef bint is_variable_nonbasic_at_lower_bound(self, int index) noexcept + cpdef bint is_slack_variable_basic(self, int index) noexcept + cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index) noexcept cdef object obj_constant_term -cpdef GenericBackend get_solver(constraint_generation = ?, solver = ?, base_ring = ?) +cpdef GenericBackend get_solver(constraint_generation = ?, solver = ?, base_ring = ?) noexcept diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 74cc99cb9e5..6d43a6ba958 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -33,11 +33,11 @@ from copy import copy cdef class GenericBackend: - cpdef base_ring(self): + cpdef base_ring(self) noexcept: from sage.rings.real_double import RDF return RDF - cpdef zero(self): + cpdef zero(self) noexcept: return self.base_ring()(0) cpdef int add_variable(self, lower_bound=0, upper_bound=None, @@ -207,7 +207,7 @@ cdef class GenericBackend: tester.assertEqual(p.col_name(ncols_before), 'a') tester.assertAlmostEqual(p.objective_coefficient(ncols_before), 42.0) - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable @@ -235,7 +235,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -280,7 +280,7 @@ cdef class GenericBackend: tester.assertIsNone(p.set_sense(1)) tester.assertEqual(p.is_maximization(), True) - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -305,7 +305,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef objective_constant_term(self, d=None): + cpdef objective_constant_term(self, d=None) noexcept: """ Set or get the constant term in the objective function @@ -328,7 +328,7 @@ cdef class GenericBackend: else: self.obj_constant_term = d - cpdef set_objective(self, list coeff, d = 0.0): + cpdef set_objective(self, list coeff, d = 0.0) noexcept: """ Set the objective function. @@ -362,7 +362,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the log (verbosity) level @@ -378,7 +378,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef remove_constraint(self, int i): + cpdef remove_constraint(self, int i) noexcept: r""" Remove a constraint. @@ -405,7 +405,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef remove_constraints(self, constraints): + cpdef remove_constraints(self, constraints) noexcept: r""" Remove several constraints. @@ -432,7 +432,7 @@ cdef class GenericBackend: self.remove_constraint(c) last = c - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -467,7 +467,7 @@ cdef class GenericBackend: """ raise NotImplementedError('add_linear_constraint') - cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a vector-valued linear constraint. @@ -546,7 +546,7 @@ cdef class GenericBackend: p.add_linear_constraint_vector(2, coeffs, lower, upper, 'foo') # FIXME: Tests here. Careful what we expect regarding ranged constraints with some solvers. - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -606,7 +606,7 @@ cdef class GenericBackend: for 1 <= i <= 4: tester.assertEqual(p.row(i), ([0], [i])) - cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None): + cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None) noexcept: """ Add ``'number`` linear constraints. @@ -729,7 +729,7 @@ cdef class GenericBackend: with tester.assertRaises(MIPSolverException) as cm: # unbounded p.solve() - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -757,7 +757,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef best_known_objective_bound(self): + cpdef best_known_objective_bound(self) noexcept: r""" Return the value of the currently best known bound. @@ -790,7 +790,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef get_relative_objective_gap(self): + cpdef get_relative_objective_gap(self) noexcept: r""" Return the relative objective gap of the best known solution. @@ -825,7 +825,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -853,7 +853,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -879,7 +879,7 @@ cdef class GenericBackend: p = self tester.assertGreaterEqual(self.ncols(), 0) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -896,7 +896,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -912,7 +912,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -932,7 +932,7 @@ cdef class GenericBackend: raise NotImplementedError() - cpdef write_lp(self, name): + cpdef write_lp(self, name) noexcept: """ Write the problem to a ``.lp`` file @@ -954,7 +954,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef write_mps(self, name, int modern): + cpdef write_mps(self, name, int modern) noexcept: """ Write the problem to a ``.mps`` file @@ -977,7 +977,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef copy(self): + cpdef copy(self) noexcept: """ Returns a copy of self. @@ -994,7 +994,7 @@ cdef class GenericBackend: return self.__copy__() # Override this method in backends. - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Returns a copy of self. @@ -1032,7 +1032,7 @@ cdef class GenericBackend: """ return self.__copy__() - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -1061,7 +1061,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -1089,7 +1089,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -1117,7 +1117,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -1140,7 +1140,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -1162,7 +1162,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -1187,7 +1187,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -1206,7 +1206,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index``-th column name @@ -1309,7 +1309,7 @@ cdef class GenericBackend: p._test_copy(**options) p._test_copy_does_not_share_data(**options) - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -1335,7 +1335,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable @@ -1361,7 +1361,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef solver_parameter(self, name, value = None): + cpdef solver_parameter(self, name, value = None) noexcept: """ Return or define a solver parameter @@ -1387,7 +1387,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_variable_basic(self, int index): + cpdef bint is_variable_basic(self, int index) noexcept: """ Test whether the given variable is basic. @@ -1417,7 +1417,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the given variable is nonbasic at lower bound. @@ -1447,7 +1447,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_slack_variable_basic(self, int index): + cpdef bint is_slack_variable_basic(self, int index) noexcept: """ Test whether the slack variable of the given row is basic. @@ -1477,7 +1477,7 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the given variable is nonbasic at lower bound. @@ -1677,7 +1677,7 @@ def default_mip_solver(solver=None): else: raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'InteractiveLP', a callable, or None.") -cpdef GenericBackend get_solver(constraint_generation = False, solver = None, base_ring = None): +cpdef GenericBackend get_solver(constraint_generation = False, solver = None, base_ring = None) noexcept: """ Return a solver according to the given preferences diff --git a/src/sage/numerical/backends/generic_sdp_backend.pxd b/src/sage/numerical/backends/generic_sdp_backend.pxd index 68039c672fd..446b9ce8c25 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pxd +++ b/src/sage/numerical/backends/generic_sdp_backend.pxd @@ -10,28 +10,28 @@ cdef class GenericSDPBackend: cpdef int add_variable(self, obj=*, name=*) except -1 cpdef int add_variables(self, int, names=*) except -1 - cpdef set_sense(self, int sense) - cpdef objective_coefficient(self, int variable, coeff=*) - cpdef set_objective(self, list coeff, d=*) - cpdef add_linear_constraint(self, constraints, name=*) - cpdef add_linear_constraints(self, int number, names=*) + cpdef set_sense(self, int sense) noexcept + cpdef objective_coefficient(self, int variable, coeff=*) noexcept + cpdef set_objective(self, list coeff, d=*) noexcept + cpdef add_linear_constraint(self, constraints, name=*) noexcept + cpdef add_linear_constraints(self, int number, names=*) noexcept cpdef int solve(self) except -1 - cpdef get_objective_value(self) - cpdef get_variable_value(self, int variable) - cpdef dual_variable(self, int variable, sparse=*) - cpdef slack(self, int variable, sparse=*) - cpdef bint is_maximization(self) - cpdef row(self, int i) - cpdef int ncols(self) - cpdef int nrows(self) - cpdef problem_name(self, name=*) - cpdef row_name(self, int index) - cpdef col_name(self, int index) - cpdef solver_parameter(self, name, value=*) - cpdef zero(self) - cpdef base_ring(self) + cpdef get_objective_value(self) noexcept + cpdef get_variable_value(self, int variable) noexcept + cpdef dual_variable(self, int variable, sparse=*) noexcept + cpdef slack(self, int variable, sparse=*) noexcept + cpdef bint is_maximization(self) noexcept + cpdef row(self, int i) noexcept + cpdef int ncols(self) noexcept + cpdef int nrows(self) noexcept + cpdef problem_name(self, name=*) noexcept + cpdef row_name(self, int index) noexcept + cpdef col_name(self, int index) noexcept + cpdef solver_parameter(self, name, value=*) noexcept + cpdef zero(self) noexcept + cpdef base_ring(self) noexcept cdef obj_constant_term cdef dict matrices_dim -cpdef GenericSDPBackend get_solver(solver=?, base_ring=?) +cpdef GenericSDPBackend get_solver(solver=?, base_ring=?) noexcept diff --git a/src/sage/numerical/backends/generic_sdp_backend.pyx b/src/sage/numerical/backends/generic_sdp_backend.pyx index 45a56b3b6e3..bad0e3511e2 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pyx +++ b/src/sage/numerical/backends/generic_sdp_backend.pyx @@ -29,7 +29,7 @@ AUTHORS: cdef class GenericSDPBackend: - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ The base ring @@ -42,7 +42,7 @@ cdef class GenericSDPBackend: from sage.rings.real_double import RDF return RDF - cpdef zero(self): + cpdef zero(self) noexcept: """ Zero of the base ring @@ -120,7 +120,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -143,7 +143,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -168,7 +168,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef set_objective(self, list coeff, d=0.0): + cpdef set_objective(self, list coeff, d=0.0) noexcept: """ Set the objective function. @@ -194,7 +194,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef add_linear_constraint(self, coefficients, name=None): + cpdef add_linear_constraint(self, coefficients, name=None) noexcept: """ Add a linear constraint. @@ -228,7 +228,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef add_linear_constraints(self, int number, names=None): + cpdef add_linear_constraints(self, int number, names=None) noexcept: """ Add constraints. @@ -282,7 +282,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -310,7 +310,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -338,7 +338,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -356,7 +356,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -373,7 +373,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -389,7 +389,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -409,7 +409,7 @@ cdef class GenericSDPBackend: raise NotImplementedError() - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -440,7 +440,7 @@ cdef class GenericSDPBackend: - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -459,7 +459,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name @@ -481,7 +481,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef dual_variable(self, int i, sparse=False): + cpdef dual_variable(self, int i, sparse=False) noexcept: """ The `i`-th dual variable @@ -527,7 +527,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef slack(self, int i, sparse=False): + cpdef slack(self, int i, sparse=False) noexcept: """ Slack of the `i`-th constraint @@ -575,7 +575,7 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef solver_parameter(self, name, value = None): + cpdef solver_parameter(self, name, value = None) noexcept: """ Return or define a solver parameter @@ -686,7 +686,7 @@ def default_sdp_solver(solver=None): raise ValueError("'solver' should be set to 'CVXOPT', 'Matrix', a class, or None.") -cpdef GenericSDPBackend get_solver(solver=None, base_ring=None): +cpdef GenericSDPBackend get_solver(solver=None, base_ring=None) noexcept: """ Return a solver according to the given preferences. diff --git a/src/sage/numerical/backends/glpk_backend.pxd b/src/sage/numerical/backends/glpk_backend.pxd index 03dbe2c8688..064c69cac18 100644 --- a/src/sage/numerical/backends/glpk_backend.pxd +++ b/src/sage/numerical/backends/glpk_backend.pxd @@ -26,15 +26,15 @@ cdef class GLPKBackend(GenericBackend): cdef glp_smcp * smcp cdef int simplex_or_intopt cdef search_tree_data_t search_tree_data - cpdef __copy__(self) + cpdef __copy__(self) noexcept cpdef int print_ranges(self, filename = *) except -1 - cpdef double get_row_dual(self, int variable) + cpdef double get_row_dual(self, int variable) noexcept cpdef double get_col_dual(self, int variable) except? -1 cpdef int get_row_stat(self, int variable) except? -1 cpdef int get_col_stat(self, int variable) except? -1 - cpdef eval_tab_row(self, int k) - cpdef eval_tab_col(self, int k) - cpdef get_row_prim(self, int i) - cpdef set_row_stat(self, int i, int stat) - cpdef set_col_stat(self, int j, int stat) - cpdef int warm_up(self) + cpdef eval_tab_row(self, int k) noexcept + cpdef eval_tab_col(self, int k) noexcept + cpdef get_row_prim(self, int i) noexcept + cpdef set_row_stat(self, int i, int stat) noexcept + cpdef set_col_stat(self, int j, int stat) noexcept + cpdef int warm_up(self) noexcept diff --git a/src/sage/numerical/backends/glpk_backend.pyx b/src/sage/numerical/backends/glpk_backend.pyx index 4b90438bc8c..0fa5c2d3b98 100644 --- a/src/sage/numerical/backends/glpk_backend.pyx +++ b/src/sage/numerical/backends/glpk_backend.pyx @@ -228,7 +228,7 @@ cdef class GLPKBackend(GenericBackend): return n_var - 1 - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable @@ -278,7 +278,7 @@ cdef class GLPKBackend(GenericBackend): else: glp_set_col_kind(self.lp, variable+1, GLP_CV) - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -304,7 +304,7 @@ cdef class GLPKBackend(GenericBackend): else: glp_set_obj_dir(self.lp, GLP_MIN) - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -347,7 +347,7 @@ cdef class GLPKBackend(GenericBackend): else: glp_set_obj_coef(self.lp, variable + 1, coeff) - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -379,7 +379,7 @@ cdef class GLPKBackend(GenericBackend): raise ValueError("Problem name for GLPK must not be longer than 255 characters.") glp_set_prob_name(self.lp, name) - cpdef set_objective(self, list coeff, d = 0.0): + cpdef set_objective(self, list coeff, d = 0.0) noexcept: """ Set the objective function. @@ -409,7 +409,7 @@ cdef class GLPKBackend(GenericBackend): self.obj_constant_term = d - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the verbosity level @@ -471,7 +471,7 @@ cdef class GLPKBackend(GenericBackend): self.iocp.msg_lev = GLP_MSG_ALL self.smcp.msg_lev = GLP_MSG_ALL - cpdef remove_constraint(self, int i): + cpdef remove_constraint(self, int i) noexcept: r""" Remove a constraint from self. @@ -510,7 +510,7 @@ cdef class GLPKBackend(GenericBackend): glp_del_rows(self.lp, 1, rows) glp_std_basis(self.lp) - cpdef remove_constraints(self, constraints): + cpdef remove_constraints(self, constraints) noexcept: r""" Remove several constraints. @@ -562,7 +562,7 @@ cdef class GLPKBackend(GenericBackend): sig_free(rows) glp_std_basis(self.lp) - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -649,7 +649,7 @@ cdef class GLPKBackend(GenericBackend): if name is not None: glp_set_row_name(self.lp, n, str_to_bytes(name)) - cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None): + cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None) noexcept: """ Add ``'number`` linear constraints. @@ -697,7 +697,7 @@ cdef class GLPKBackend(GenericBackend): glp_set_row_name(self.lp, n-i, str_to_bytes(names[number-i-1])) - cpdef row(self, int index): + cpdef row(self, int index) noexcept: r""" Return a row @@ -754,7 +754,7 @@ cdef class GLPKBackend(GenericBackend): return (indices, values) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -806,7 +806,7 @@ cdef class GLPKBackend(GenericBackend): (ub if ub != +DBL_MAX else None) ) - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -859,7 +859,7 @@ cdef class GLPKBackend(GenericBackend): (ub if ub != +DBL_MAX else None) ) - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -1149,7 +1149,7 @@ cdef class GLPKBackend(GenericBackend): raise MIPSolverException("GLPK: "+solution_status_msg.get(solution_status, "unknown error during call to GLPK : "+str(solution_status))) return 0 - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Returns the value of the objective function. @@ -1180,7 +1180,7 @@ cdef class GLPKBackend(GenericBackend): else: return glp_get_obj_val(self.lp) - cpdef best_known_objective_bound(self): + cpdef best_known_objective_bound(self) noexcept: r""" Return the value of the currently best known bound. @@ -1213,7 +1213,7 @@ cdef class GLPKBackend(GenericBackend): """ return self.search_tree_data.best_bound - cpdef get_relative_objective_gap(self): + cpdef get_relative_objective_gap(self) noexcept: r""" Return the relative objective gap of the best known solution. @@ -1255,7 +1255,7 @@ cdef class GLPKBackend(GenericBackend): """ return self.search_tree_data.mip_gap - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Returns the value of a variable given by the solver. @@ -1301,7 +1301,7 @@ cdef class GLPKBackend(GenericBackend): else: return glp_get_col_prim(self.lp, variable + 1) - cpdef get_row_prim(self, int i): + cpdef get_row_prim(self, int i) noexcept: r""" Returns the value of the auxiliary variable associated with i-th row. @@ -1349,7 +1349,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_row_prim(self.lp, i+1) - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -1366,7 +1366,7 @@ cdef class GLPKBackend(GenericBackend): """ return glp_get_num_cols(self.lp) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -1383,7 +1383,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_num_rows(self.lp) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name @@ -1425,7 +1425,7 @@ cdef class GLPKBackend(GenericBackend): else: return "" - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -1466,7 +1466,7 @@ cdef class GLPKBackend(GenericBackend): else: return "" - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -1503,7 +1503,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_col_kind(self.lp, index + 1) == GLP_BV - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -1540,7 +1540,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_col_kind(self.lp, index + 1) == GLP_IV - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -1579,7 +1579,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_col_kind(self.lp, index + 1) == GLP_CV - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -1596,7 +1596,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_obj_dir(self.lp) == GLP_MAX - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -1695,7 +1695,7 @@ cdef class GLPKBackend(GenericBackend): glp_set_col_bnds(self.lp, index + 1, GLP_DB, min, dvalue) sig_off() - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable @@ -1795,7 +1795,7 @@ cdef class GLPKBackend(GenericBackend): glp_set_col_bnds(self.lp, index + 1, GLP_DB, value, max) sig_off() - cpdef write_lp(self, filename): + cpdef write_lp(self, filename) noexcept: """ Write the problem to a .lp file @@ -1822,7 +1822,7 @@ cdef class GLPKBackend(GenericBackend): filename = str_to_bytes(filename, FS_ENCODING, 'surrogateescape') glp_write_lp(self.lp, NULL, filename) - cpdef write_mps(self, filename, int modern): + cpdef write_mps(self, filename, int modern) noexcept: """ Write the problem to a .mps file @@ -1849,7 +1849,7 @@ cdef class GLPKBackend(GenericBackend): filename = str_to_bytes(filename, FS_ENCODING, 'surrogateescape') glp_write_mps(self.lp, modern, NULL, filename) - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Returns a copy of self. @@ -1870,7 +1870,7 @@ cdef class GLPKBackend(GenericBackend): return p - cpdef solver_parameter(self, name, value = None): + cpdef solver_parameter(self, name, value = None) noexcept: """ Return or define a solver parameter @@ -2319,7 +2319,7 @@ cdef class GLPKBackend(GenericBackend): else: raise ValueError("This parameter is not available.") - cpdef bint is_variable_basic(self, int index): + cpdef bint is_variable_basic(self, int index) noexcept: """ Test whether the given variable is basic. @@ -2350,7 +2350,7 @@ cdef class GLPKBackend(GenericBackend): """ return self.get_col_stat(index) == GLP_BS - cpdef bint is_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the given variable is nonbasic at lower bound. This assumes that the problem has been solved with the simplex method @@ -2380,7 +2380,7 @@ cdef class GLPKBackend(GenericBackend): """ return self.get_col_stat(index) == GLP_NL - cpdef bint is_slack_variable_basic(self, int index): + cpdef bint is_slack_variable_basic(self, int index) noexcept: """ Test whether the slack variable of the given row is basic. @@ -2411,7 +2411,7 @@ cdef class GLPKBackend(GenericBackend): """ return self.get_row_stat(index) == GLP_BS - cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the slack variable of the given row is nonbasic at lower bound. @@ -2525,7 +2525,7 @@ cdef class GLPKBackend(GenericBackend): 'surrogateescape')) return res - cpdef double get_row_dual(self, int variable): + cpdef double get_row_dual(self, int variable) noexcept: r""" Returns the dual value of a constraint. @@ -2721,7 +2721,7 @@ cdef class GLPKBackend(GenericBackend): return glp_get_col_stat(self.lp, j+1) - cpdef set_row_stat(self, int i, int stat): + cpdef set_row_stat(self, int i, int stat) noexcept: r""" Set the status of a constraint. @@ -2756,7 +2756,7 @@ cdef class GLPKBackend(GenericBackend): glp_set_row_stat(self.lp, i+1, stat) - cpdef set_col_stat(self, int j, int stat): + cpdef set_col_stat(self, int j, int stat) noexcept: r""" Set the status of a variable. @@ -2791,7 +2791,7 @@ cdef class GLPKBackend(GenericBackend): glp_set_col_stat(self.lp, j+1, stat) - cpdef int warm_up(self): + cpdef int warm_up(self) noexcept: r""" Warm up the basis using current statuses assigned to rows and cols. @@ -2827,7 +2827,7 @@ cdef class GLPKBackend(GenericBackend): """ return glp_warm_up(self.lp) - cpdef eval_tab_row(self, int k): + cpdef eval_tab_row(self, int k) noexcept: r""" Computes a row of the current simplex tableau. @@ -2926,7 +2926,7 @@ cdef class GLPKBackend(GenericBackend): values = [c_values[j+1] for j in range(i)] return (indices, values) - cpdef eval_tab_col(self, int k): + cpdef eval_tab_col(self, int k) noexcept: r""" Computes a column of the current simplex tableau. @@ -3033,7 +3033,7 @@ cdef class GLPKBackend(GenericBackend): sig_free(self.iocp) sig_free(self.smcp) -cdef void glp_callback(glp_tree* tree, void* info): +cdef void glp_callback(glp_tree* tree, void* info) noexcept: r""" A callback routine called by glp_intopt diff --git a/src/sage/numerical/backends/glpk_exact_backend.pxd b/src/sage/numerical/backends/glpk_exact_backend.pxd index ed55d9bce3e..40489d2ac94 100644 --- a/src/sage/numerical/backends/glpk_exact_backend.pxd +++ b/src/sage/numerical/backends/glpk_exact_backend.pxd @@ -13,4 +13,4 @@ from .glpk_backend cimport GLPKBackend cdef class GLPKExactBackend(GLPKBackend): cpdef int add_variable(self, lower_bound=*, upper_bound=*, binary=*, continuous=*, integer=*, obj=*, name=*) except -1 cpdef int add_variables(self, int, lower_bound=*, upper_bound=*, binary=*, continuous=*, integer=*, obj=*, names=*) except -1 - cpdef set_variable_type(self, int variable, int vtype) + cpdef set_variable_type(self, int variable, int vtype) noexcept diff --git a/src/sage/numerical/backends/glpk_exact_backend.pyx b/src/sage/numerical/backends/glpk_exact_backend.pyx index 3031748eb42..3508942f5e4 100644 --- a/src/sage/numerical/backends/glpk_exact_backend.pyx +++ b/src/sage/numerical/backends/glpk_exact_backend.pyx @@ -156,7 +156,7 @@ cdef class GLPKExactBackend(GLPKBackend): return GLPKBackend.add_variables(self, number, lower_bound, upper_bound, binary, continuous, integer, obj, names) - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable. diff --git a/src/sage/numerical/backends/glpk_graph_backend.pxd b/src/sage/numerical/backends/glpk_graph_backend.pxd index 1b63765de7f..926c60134dc 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pxd +++ b/src/sage/numerical/backends/glpk_graph_backend.pxd @@ -27,29 +27,29 @@ ctypedef struct c_a_data: cdef class GLPKGraphBackend(): cdef glp_graph * graph - cpdef add_vertex(self, name = ?) - cpdef list add_vertices(self, vertices) - cpdef __add_vertices_sage(self, g) - cpdef dict get_vertex(self, vertex) - cpdef dict get_vertices(self, verts) - cpdef set_vertex_demand(self, vertex, param) - cpdef set_vertices_demand(self, list pairs) - cpdef list vertices(self) - cpdef add_edge(self, u, v, dict params = ?) - cpdef __add_edges_sage(self, g) - cpdef list add_edges(self, edges) - cpdef delete_edge(self, u, v, dict params = ?) - cpdef tuple get_edge(self, u, v) - cpdef list edges(self) - cpdef delete_vertex(self, vert) - cpdef delete_vertices(self, list verts) - cpdef int _find_vertex(self, vert) - cpdef int write_graph(self, fname) - cpdef int write_ccdata(self, fname) - cpdef int write_mincost(self, fname) + cpdef add_vertex(self, name = ?) noexcept + cpdef list add_vertices(self, vertices) noexcept + cpdef __add_vertices_sage(self, g) noexcept + cpdef dict get_vertex(self, vertex) noexcept + cpdef dict get_vertices(self, verts) noexcept + cpdef set_vertex_demand(self, vertex, param) noexcept + cpdef set_vertices_demand(self, list pairs) noexcept + cpdef list vertices(self) noexcept + cpdef add_edge(self, u, v, dict params = ?) noexcept + cpdef __add_edges_sage(self, g) noexcept + cpdef list add_edges(self, edges) noexcept + cpdef delete_edge(self, u, v, dict params = ?) noexcept + cpdef tuple get_edge(self, u, v) noexcept + cpdef list edges(self) noexcept + cpdef delete_vertex(self, vert) noexcept + cpdef delete_vertices(self, list verts) noexcept + cpdef int _find_vertex(self, vert) noexcept + cpdef int write_graph(self, fname) noexcept + cpdef int write_ccdata(self, fname) noexcept + cpdef int write_mincost(self, fname) noexcept cpdef double mincost_okalg(self) except -1 cdef int s cdef int t cpdef int write_maxflow(self, fname) except -1 cpdef double maxflow_ffalg(self, u = ?, v = ?) except -1 - cpdef double cpp(self) + cpdef double cpp(self) noexcept diff --git a/src/sage/numerical/backends/glpk_graph_backend.pyx b/src/sage/numerical/backends/glpk_graph_backend.pyx index 1c0dc2974df..dcc6425d8de 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pyx +++ b/src/sage/numerical/backends/glpk_graph_backend.pyx @@ -230,7 +230,7 @@ cdef class GLPKGraphBackend(): else: ValueError("Input data is not supported") - cpdef add_vertex(self, name=None): + cpdef add_vertex(self, name=None) noexcept: """ Adds an isolated vertex to the graph. @@ -284,7 +284,7 @@ cdef class GLPKGraphBackend(): glp_set_vertex_name(self.graph, vn, str_to_bytes(s)) return s - cpdef __add_vertices_sage(self, g): + cpdef __add_vertices_sage(self, g) noexcept: """ Adds vertices to the GLPK Graph. @@ -326,7 +326,7 @@ cdef class GLPKGraphBackend(): glp_create_v_index(self.graph) - cpdef list add_vertices(self, vertices): + cpdef list add_vertices(self, vertices) noexcept: """ Adds vertices from an iterable container of vertices. @@ -378,7 +378,7 @@ cdef class GLPKGraphBackend(): else: return None - cpdef set_vertex_demand(self, vertex, demand): + cpdef set_vertex_demand(self, vertex, demand) noexcept: """ Sets the demand of the vertex in a mincost flow algorithm. @@ -415,7 +415,7 @@ cdef class GLPKGraphBackend(): cdef double val = demand (vert.data).rhs = val - cpdef set_vertices_demand(self, list pairs): + cpdef set_vertices_demand(self, list pairs) noexcept: """ Sets the parameters of selected vertices. @@ -443,7 +443,7 @@ cdef class GLPKGraphBackend(): except KeyError: pass - cpdef dict get_vertex(self, vertex): + cpdef dict get_vertex(self, vertex) noexcept: """ Returns a specific vertex as a ``dict`` Object. @@ -490,7 +490,7 @@ cdef class GLPKGraphBackend(): "ls" : vdata.ls } - cpdef dict get_vertices(self, verts): + cpdef dict get_vertices(self, verts) noexcept: """ Returns a dictionary of the dictionaries associated to each vertex. @@ -519,7 +519,7 @@ cdef class GLPKGraphBackend(): vl = [(v, self.get_vertex(v)) for v in verts] return dict([(v, p) for v, p in vl if p is not None]) - cpdef list vertices(self): + cpdef list vertices(self) noexcept: """ Returns the list of all vertices @@ -551,7 +551,7 @@ cdef class GLPKGraphBackend(): if self.graph.v[i+1].name is not NULL else None for i in range(self.graph.nv)] - cpdef add_edge(self, u, v, dict params=None): + cpdef add_edge(self, u, v, dict params=None) noexcept: """ Adds an edge between vertices ``u`` and ``v``. @@ -615,7 +615,7 @@ cdef class GLPKGraphBackend(): glp_del_arc(self.graph, a) raise TypeError("Invalid edge parameter.") - cpdef list add_edges(self, edges): + cpdef list add_edges(self, edges) noexcept: """ Adds edges to the graph. @@ -653,7 +653,7 @@ cdef class GLPKGraphBackend(): for ed in edges: self.add_edge(*ed) - cpdef __add_edges_sage(self, g): + cpdef __add_edges_sage(self, g) noexcept: """ Adds edges to the Graph. @@ -708,7 +708,7 @@ cdef class GLPKGraphBackend(): if "low" in label: (a.data).low = low - cpdef tuple get_edge(self, u, v): + cpdef tuple get_edge(self, u, v) noexcept: """ Returns an edge connecting two vertices. @@ -764,7 +764,7 @@ cdef class GLPKGraphBackend(): return None - cpdef list edges(self): + cpdef list edges(self) noexcept: """ Returns a ``list`` of all edges in the graph @@ -813,7 +813,7 @@ cdef class GLPKGraphBackend(): i += 1 return edge_list - cpdef delete_vertex(self, vert): + cpdef delete_vertex(self, vert) noexcept: r""" Removes a vertex from the graph. @@ -849,7 +849,7 @@ cdef class GLPKGraphBackend(): glp_del_vertices(self.graph, ndel, num) - cpdef delete_vertices(self, list verts): + cpdef delete_vertices(self, list verts) noexcept: r""" Removes vertices from the graph. @@ -893,7 +893,7 @@ cdef class GLPKGraphBackend(): sig_free(num) - cpdef delete_edge(self, u, v, dict params=None): + cpdef delete_edge(self, u, v, dict params=None) noexcept: """ Deletes an edge from the graph. @@ -1005,7 +1005,7 @@ cdef class GLPKGraphBackend(): for edge in edges: self.delete_edge(*edge) - cpdef int _find_vertex(self, name): + cpdef int _find_vertex(self, name) noexcept: """ Returns the index of a vertex specified by a name @@ -1032,7 +1032,7 @@ cdef class GLPKGraphBackend(): glp_create_v_index(self.graph) return glp_find_vertex(self.graph, str_to_bytes(name)) - 1 - cpdef int write_graph(self, fname): + cpdef int write_graph(self, fname) noexcept: r""" Writes the graph to a plain text file @@ -1060,7 +1060,7 @@ cdef class GLPKGraphBackend(): fname = str_to_bytes(fname, FS_ENCODING, 'surrogateescape') return glp_write_graph(self.graph, fname) - cpdef int write_ccdata(self, fname): + cpdef int write_ccdata(self, fname) noexcept: r""" Writes the graph to a text file in DIMACS format. @@ -1092,7 +1092,7 @@ cdef class GLPKGraphBackend(): fname = str_to_bytes(fname, FS_ENCODING, 'surrogateescape') return glp_write_ccdata(self.graph, 0, fname) - cpdef int write_mincost(self, fname): + cpdef int write_mincost(self, fname) noexcept: """ Writes the mincost flow problem data to a text file in DIMACS format @@ -1321,7 +1321,7 @@ cdef class GLPKGraphBackend(): return graph_sol - cpdef double cpp(self): + cpdef double cpp(self) noexcept: r""" Solves the critical path problem of a project network. diff --git a/src/sage/numerical/backends/interactivelp_backend.pxd b/src/sage/numerical/backends/interactivelp_backend.pxd index 07e63a7bb44..f29187632fc 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pxd +++ b/src/sage/numerical/backends/interactivelp_backend.pxd @@ -30,6 +30,6 @@ cdef class InteractiveLPBackend(GenericBackend): coefficients=*) \ except -1 - cpdef dictionary(self) + cpdef dictionary(self) noexcept - cpdef interactive_lp_problem(self) + cpdef interactive_lp_problem(self) noexcept diff --git a/src/sage/numerical/backends/interactivelp_backend.pyx b/src/sage/numerical/backends/interactivelp_backend.pyx index 773c13b781c..665631f19de 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pyx +++ b/src/sage/numerical/backends/interactivelp_backend.pyx @@ -81,7 +81,7 @@ cdef class InteractiveLPBackend: self.row_names = [] - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Returns a copy of self. @@ -104,7 +104,7 @@ cdef class InteractiveLPBackend: cp.prob_name = self.prob_name return cp - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ Return the base ring. @@ -252,7 +252,7 @@ cdef class InteractiveLPBackend: problem_type, ring, objective_constant_term=d) return self.ncols() - 1 - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable. @@ -306,7 +306,7 @@ cdef class InteractiveLPBackend: d = self.lp.objective_constant_term() return A, b, c, x, constraint_types, variable_types, problem_type, base_ring, d - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -336,7 +336,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -369,7 +369,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef objective_constant_term(self, d=None): + cpdef objective_constant_term(self, d=None) noexcept: """ Set or get the constant term in the objective function @@ -395,7 +395,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef set_objective(self, list coeff, d = 0): + cpdef set_objective(self, list coeff, d = 0) noexcept: """ Set the objective function. @@ -445,7 +445,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the log (verbosity) level @@ -461,7 +461,7 @@ cdef class InteractiveLPBackend: """ self.verbosity = level - cpdef remove_constraint(self, int i): + cpdef remove_constraint(self, int i) noexcept: r""" Remove a constraint. @@ -495,7 +495,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -557,7 +557,7 @@ cdef class InteractiveLPBackend: problem_type, ring, objective_constant_term=d) - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -632,7 +632,7 @@ cdef class InteractiveLPBackend: else: raise MIPSolverException("InteractiveLP: Problem is unbounded") - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -663,7 +663,7 @@ cdef class InteractiveLPBackend: v = - v return v - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -691,7 +691,7 @@ cdef class InteractiveLPBackend: solution = self.std_form_transformation(self.final_dictionary.basic_solution()) return solution[variable] - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -708,7 +708,7 @@ cdef class InteractiveLPBackend: """ return self.lp.n_variables() - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -724,7 +724,7 @@ cdef class InteractiveLPBackend: """ return self.lp.n_constraints() - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -740,7 +740,7 @@ cdef class InteractiveLPBackend: """ return self.lp.problem_type() == "max" - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -765,7 +765,7 @@ cdef class InteractiveLPBackend: else: self.prob_name = str(name) - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -799,7 +799,7 @@ cdef class InteractiveLPBackend: coeffs.append(A[i][j]) return (indices, coeffs) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -834,7 +834,7 @@ cdef class InteractiveLPBackend: else: raise ValueError("Bad constraint_type") - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -870,7 +870,7 @@ cdef class InteractiveLPBackend: else: raise ValueError("Bad _variable_types") - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -892,7 +892,7 @@ cdef class InteractiveLPBackend: """ return False - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -913,7 +913,7 @@ cdef class InteractiveLPBackend: """ return False - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -935,7 +935,7 @@ cdef class InteractiveLPBackend: """ return True - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -954,7 +954,7 @@ cdef class InteractiveLPBackend: """ return self.row_names[index] - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index``-th column name @@ -976,7 +976,7 @@ cdef class InteractiveLPBackend: """ return str(self.lp.decision_variables()[index]) - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -1020,7 +1020,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable @@ -1064,7 +1064,7 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef bint is_variable_basic(self, int index): + cpdef bint is_variable_basic(self, int index) noexcept: """ Test whether the given variable is basic. @@ -1094,7 +1094,7 @@ cdef class InteractiveLPBackend: """ return self.lp_std_form.decision_variables()[index] in self.final_dictionary.basic_variables() - cpdef bint is_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the given variable is nonbasic at lower bound. @@ -1124,7 +1124,7 @@ cdef class InteractiveLPBackend: """ return self.lp_std_form.decision_variables()[index] in self.final_dictionary.nonbasic_variables() - cpdef bint is_slack_variable_basic(self, int index): + cpdef bint is_slack_variable_basic(self, int index) noexcept: """ Test whether the slack variable of the given row is basic. @@ -1154,7 +1154,7 @@ cdef class InteractiveLPBackend: """ return self.lp_std_form.slack_variables()[index] in self.final_dictionary.basic_variables() - cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index): + cpdef bint is_slack_variable_nonbasic_at_lower_bound(self, int index) noexcept: """ Test whether the given variable is nonbasic at lower bound. @@ -1184,7 +1184,7 @@ cdef class InteractiveLPBackend: """ return self.lp_std_form.slack_variables()[index] in self.final_dictionary.nonbasic_variables() - cpdef dictionary(self): + cpdef dictionary(self) noexcept: # Proposed addition to the general interface, # which would for other solvers return backend dictionaries (#18804) """ @@ -1220,7 +1220,7 @@ cdef class InteractiveLPBackend: """ return self.final_dictionary - cpdef interactive_lp_problem(self): + cpdef interactive_lp_problem(self) noexcept: """ Return the :class:`InteractiveLPProblem` object associated with this backend. diff --git a/src/sage/numerical/backends/matrix_sdp_backend.pyx b/src/sage/numerical/backends/matrix_sdp_backend.pyx index 7668c64ecc1..7704ff91c90 100644 --- a/src/sage/numerical/backends/matrix_sdp_backend.pyx +++ b/src/sage/numerical/backends/matrix_sdp_backend.pyx @@ -55,7 +55,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): base_ring = QQ self._base_ring = base_ring - cpdef base_ring(self): + cpdef base_ring(self) noexcept: """ The base ring @@ -166,7 +166,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.add_variable() return len(self.objective_function) - 1 - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -192,7 +192,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): else: self.is_maximize = 0 - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -220,7 +220,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): else: return self.objective_function[variable] - cpdef set_objective(self, list coeff, d=0.0): + cpdef set_objective(self, list coeff, d=0.0) noexcept: """ Set the objective function. @@ -245,7 +245,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.objective_function[i] = coeff[i] obj_constant_term = d - cpdef add_linear_constraint(self, coefficients, name=None): + cpdef add_linear_constraint(self, coefficients, name=None) noexcept: """ Add a linear constraint. @@ -292,7 +292,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.matrices_dim[self.nrows()] = m.dimensions()[0] # self.row_name_var.append(name) - cpdef add_linear_constraints(self, int number, names=None): + cpdef add_linear_constraints(self, int number, names=None) noexcept: """ Add constraints. @@ -317,7 +317,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): name=None if names is None else names[i]) - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -335,7 +335,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): return len(self.objective_function) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -354,7 +354,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): return len(self.matrices_dim) - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -373,7 +373,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): else: return 0 - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -396,7 +396,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.name = name - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -436,7 +436,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): matrices.append(m) return (indices, matrices) - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -457,7 +457,7 @@ cdef class MatrixSDPBackend(GenericSDPBackend): return self.row_name_var[index] return "constraint_" + repr(index) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index 03b54b34359..f437527e42c 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -90,14 +90,14 @@ cdef class PPLBackend(GenericBackend): else: self.set_sense(-1) - cpdef base_ring(self): + cpdef base_ring(self) noexcept: from sage.rings.rational_field import QQ return QQ - cpdef zero(self): + cpdef zero(self) noexcept: return self.base_ring()(0) - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Returns a copy of self. @@ -377,7 +377,7 @@ cdef class PPLBackend(GenericBackend): self.col_name_var.append(None) return len(self.objective_function) - 1 - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable. @@ -430,7 +430,7 @@ cdef class PPLBackend(GenericBackend): else: raise ValueError("Invalid variable type: {}".format(vtype)) - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -456,7 +456,7 @@ cdef class PPLBackend(GenericBackend): else: self.is_maximize = 0 - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -484,7 +484,7 @@ cdef class PPLBackend(GenericBackend): else: return self.objective_function[variable] - cpdef set_objective(self, list coeff, d=0): + cpdef set_objective(self, list coeff, d=0) noexcept: """ Set the objective function. @@ -526,7 +526,7 @@ cdef class PPLBackend(GenericBackend): self.objective_function[i] = coeff[i] self.obj_constant_term = Rational(d) - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the log (verbosity) level. Not Implemented. @@ -537,7 +537,7 @@ cdef class PPLBackend(GenericBackend): sage: p.set_verbosity(0) """ - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -593,7 +593,7 @@ cdef class PPLBackend(GenericBackend): self.row_upper_bound.append(upper_bound) self.row_name_var.append(name) - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -637,7 +637,7 @@ cdef class PPLBackend(GenericBackend): self.objective_function.append(0) self.col_name_var.append(None) - cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None): + cpdef add_linear_constraints(self, int number, lower_bound, upper_bound, names=None) noexcept: """ Add constraints. @@ -727,7 +727,7 @@ cdef class PPLBackend(GenericBackend): return 0 - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the exact value of the objective function. @@ -762,7 +762,7 @@ cdef class PPLBackend(GenericBackend): ans = Rational(self.mip.optimal_value()) return ans / self.obj_denominator + self.obj_constant_term - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -790,7 +790,7 @@ cdef class PPLBackend(GenericBackend): g = self.mip.optimizing_point() return Integer(g.coefficient(Variable(variable))) / Integer(g.divisor()) - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -807,7 +807,7 @@ cdef class PPLBackend(GenericBackend): """ return len(self.objective_function) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -823,7 +823,7 @@ cdef class PPLBackend(GenericBackend): """ return len(self.Matrix) - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -842,7 +842,7 @@ cdef class PPLBackend(GenericBackend): else: return 0 - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -863,7 +863,7 @@ cdef class PPLBackend(GenericBackend): return self.name self.name = name - cpdef row(self, int i): + cpdef row(self, int i) noexcept: """ Return a row @@ -898,7 +898,7 @@ cdef class PPLBackend(GenericBackend): coef.append(self.Matrix[i][j]) return (idx, coef) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -926,7 +926,7 @@ cdef class PPLBackend(GenericBackend): """ return (self.row_lower_bound[index], self.row_upper_bound[index]) - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -955,7 +955,7 @@ cdef class PPLBackend(GenericBackend): return (self.col_lower_bound[index], self.col_upper_bound[index]) - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -976,7 +976,7 @@ cdef class PPLBackend(GenericBackend): """ return index in self.integer_variables and self.col_bounds(index) == (0, 1) - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -997,7 +997,7 @@ cdef class PPLBackend(GenericBackend): """ return index in self.integer_variables and self.col_bounds(index) != (0, 1) - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -1018,7 +1018,7 @@ cdef class PPLBackend(GenericBackend): """ return index not in self.integer_variables - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -1038,7 +1038,7 @@ cdef class PPLBackend(GenericBackend): return self.row_name_var[index] return "constraint_" + repr(index) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index`` th col name @@ -1062,7 +1062,7 @@ cdef class PPLBackend(GenericBackend): return self.col_name_var[index] return "x_" + repr(index) - cpdef variable_upper_bound(self, int index, value = False): + cpdef variable_upper_bound(self, int index, value = False) noexcept: """ Return or define the upper bound on a variable @@ -1094,7 +1094,7 @@ cdef class PPLBackend(GenericBackend): else: return self.col_upper_bound[index] - cpdef variable_lower_bound(self, int index, value = False): + cpdef variable_lower_bound(self, int index, value = False) noexcept: """ Return or define the lower bound on a variable diff --git a/src/sage/numerical/backends/scip_backend.pxd b/src/sage/numerical/backends/scip_backend.pxd index dc4981a89c3..c7a7c4d780c 100644 --- a/src/sage/numerical/backends/scip_backend.pxd +++ b/src/sage/numerical/backends/scip_backend.pxd @@ -16,6 +16,6 @@ cdef class SCIPBackend(GenericBackend): cdef object variables cdef object constraints - cpdef _get_model(self) - cpdef get_row_prim(self, int i) - cpdef write_cip(self, filename) + cpdef _get_model(self) noexcept + cpdef get_row_prim(self, int i) noexcept + cpdef write_cip(self, filename) noexcept diff --git a/src/sage/numerical/backends/scip_backend.pyx b/src/sage/numerical/backends/scip_backend.pyx index fbec62ebcbf..606b16190a8 100644 --- a/src/sage/numerical/backends/scip_backend.pyx +++ b/src/sage/numerical/backends/scip_backend.pyx @@ -66,7 +66,7 @@ cdef class SCIPBackend(GenericBackend): self.constraints = self.model.getConss() return self.constraints - cpdef _get_model(self): + cpdef _get_model(self) noexcept: """ Get the model as a pyscipopt Model. @@ -161,7 +161,7 @@ cdef class SCIPBackend(GenericBackend): return index - cpdef set_variable_type(self, int variable, int vtype): + cpdef set_variable_type(self, int variable, int vtype) noexcept: """ Set the type of a variable @@ -192,7 +192,7 @@ cdef class SCIPBackend(GenericBackend): vtypenames = {1: 'I', 0: 'B', -1: 'C'} self.model.chgVarType(var=self.variables[variable], vtype=vtypenames[vtype]) - cpdef set_sense(self, int sense): + cpdef set_sense(self, int sense) noexcept: """ Set the direction (maximization/minimization). @@ -222,7 +222,7 @@ cdef class SCIPBackend(GenericBackend): else: raise AssertionError("sense must be either 1 or -1") - cpdef objective_coefficient(self, int variable, coeff=None): + cpdef objective_coefficient(self, int variable, coeff=None) noexcept: """ Set or get the coefficient of a variable in the objective function @@ -255,7 +255,7 @@ cdef class SCIPBackend(GenericBackend): linfun = sum([e * c for e, c in objexpr.terms.iteritems() if e != var]) + var * coeff self.model.setObjective(linfun, sense=self.model.getObjectiveSense()) - cpdef problem_name(self, name=None): + cpdef problem_name(self, name=None) noexcept: """ Return or define the problem's name @@ -277,7 +277,7 @@ cdef class SCIPBackend(GenericBackend): else: self.model.setProbName(name) - cpdef set_objective(self, list coeff, d=0.0): + cpdef set_objective(self, list coeff, d=0.0) noexcept: """ Set the objective function. @@ -303,7 +303,7 @@ cdef class SCIPBackend(GenericBackend): linfun = sum([c * x for c, x in zip(coeff, self.variables)]) + d self.model.setObjective(linfun, sense=self.model.getObjectiveSense()) - cpdef set_verbosity(self, int level): + cpdef set_verbosity(self, int level) noexcept: """ Set the verbosity level @@ -331,7 +331,7 @@ cdef class SCIPBackend(GenericBackend): else: raise AssertionError('level must be "0" or "1"') - cpdef remove_constraint(self, int i): + cpdef remove_constraint(self, int i) noexcept: r""" Remove a constraint from self. @@ -369,7 +369,7 @@ cdef class SCIPBackend(GenericBackend): self.model.delCons(self.get_constraints()[i]) self.constraints = None - cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None): + cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None) noexcept: """ Add a linear constraint. @@ -417,7 +417,7 @@ cdef class SCIPBackend(GenericBackend): self.model.addCons(cons, name=name) self.constraints = None - cpdef row(self, int index): + cpdef row(self, int index) noexcept: r""" Return a row @@ -454,7 +454,7 @@ cdef class SCIPBackend(GenericBackend): values.append(coeff) return (indices, values) - cpdef row_bounds(self, int index): + cpdef row_bounds(self, int index) noexcept: """ Return the bounds of a specific constraint. @@ -487,7 +487,7 @@ cdef class SCIPBackend(GenericBackend): rhs = None return (lhs, rhs) - cpdef col_bounds(self, int index): + cpdef col_bounds(self, int index) noexcept: """ Return the bounds of a specific variable. @@ -522,7 +522,7 @@ cdef class SCIPBackend(GenericBackend): ub = None return (lb, ub) - cpdef add_col(self, indices, coeffs): + cpdef add_col(self, indices, coeffs) noexcept: """ Add a column. @@ -648,7 +648,7 @@ cdef class SCIPBackend(GenericBackend): # raise MIPSolverException("SCIP: Time limit reached") return 0 - cpdef get_objective_value(self): + cpdef get_objective_value(self) noexcept: """ Return the value of the objective function. @@ -675,7 +675,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getObjVal() - cpdef best_known_objective_bound(self): + cpdef best_known_objective_bound(self) noexcept: r""" Return the value of the currently best known bound. @@ -695,7 +695,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getPrimalbound() - cpdef get_relative_objective_gap(self): + cpdef get_relative_objective_gap(self) noexcept: r""" Return the relative objective gap of the best known solution. @@ -722,7 +722,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getGap() - cpdef get_variable_value(self, int variable): + cpdef get_variable_value(self, int variable) noexcept: """ Return the value of a variable given by the solver. @@ -749,7 +749,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getVal(self.variables[variable]) - cpdef get_row_prim(self, int i): + cpdef get_row_prim(self, int i) noexcept: r""" Return the value of the auxiliary variable associated with i-th row. @@ -781,7 +781,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getActivity(self.get_constraints()[i]) - cpdef int ncols(self): + cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -798,7 +798,7 @@ cdef class SCIPBackend(GenericBackend): """ return len(self.variables) - cpdef int nrows(self): + cpdef int nrows(self) noexcept: """ Return the number of rows/constraints. @@ -814,7 +814,7 @@ cdef class SCIPBackend(GenericBackend): """ return len(self.get_constraints()) - cpdef col_name(self, int index): + cpdef col_name(self, int index) noexcept: """ Return the ``index``th col name @@ -833,7 +833,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.variables[index].name - cpdef row_name(self, int index): + cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -851,7 +851,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.get_constraints()[index].name - cpdef bint is_variable_binary(self, int index): + cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. @@ -874,7 +874,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.variables[index].vtype() == 'BINARY' - cpdef bint is_variable_integer(self, int index): + cpdef bint is_variable_integer(self, int index) noexcept: """ Test whether the given variable is of integer type. @@ -896,7 +896,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.variables[index].vtype() == 'INTEGER' - cpdef bint is_variable_continuous(self, int index): + cpdef bint is_variable_continuous(self, int index) noexcept: """ Test whether the given variable is of continuous/real type. @@ -920,7 +920,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.variables[index].vtype() == 'CONTINUOUS' - cpdef bint is_maximization(self): + cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -936,7 +936,7 @@ cdef class SCIPBackend(GenericBackend): """ return self.model.getObjectiveSense() != 'minimize' - cpdef variable_upper_bound(self, int index, value=False): + cpdef variable_upper_bound(self, int index, value=False) noexcept: """ Return or define the upper bound on a variable @@ -997,7 +997,7 @@ cdef class SCIPBackend(GenericBackend): else: self.model.chgVarUb(var=var, ub=value) - cpdef variable_lower_bound(self, int index, value=False): + cpdef variable_lower_bound(self, int index, value=False) noexcept: """ Return or define the lower bound on a variable @@ -1059,7 +1059,7 @@ cdef class SCIPBackend(GenericBackend): else: self.model.chgVarLb(var=var, lb=value) - cpdef write_cip(self, filename): + cpdef write_cip(self, filename) noexcept: """ Write the problem to a .cip file @@ -1082,7 +1082,7 @@ cdef class SCIPBackend(GenericBackend): """ self.model.writeProblem(filename) - cpdef write_lp(self, filename): + cpdef write_lp(self, filename) noexcept: """ Write the problem to a .lp file @@ -1111,7 +1111,7 @@ cdef class SCIPBackend(GenericBackend): self.model.writeProblem(filenamestr) - cpdef write_mps(self, filename, int modern): + cpdef write_mps(self, filename, int modern) noexcept: """ Write the problem to a .mps file @@ -1140,7 +1140,7 @@ cdef class SCIPBackend(GenericBackend): self.model.writeProblem(filenamestr) - cpdef __copy__(self): + cpdef __copy__(self) noexcept: """ Return a copy of self. @@ -1178,7 +1178,7 @@ cdef class SCIPBackend(GenericBackend): assert self.nrows() == cp.nrows() return cp - cpdef solver_parameter(self, name, value=None): + cpdef solver_parameter(self, name, value=None) noexcept: """ Return or define a solver parameter diff --git a/src/sage/numerical/linear_functions.pxd b/src/sage/numerical/linear_functions.pxd index 568f04b75af..4ad836d8d6d 100644 --- a/src/sage/numerical/linear_functions.pxd +++ b/src/sage/numerical/linear_functions.pxd @@ -1,30 +1,30 @@ from sage.structure.parent cimport Parent, Parent_richcmp_element_without_coercion from sage.structure.element cimport ModuleElement, RingElement, Element -cpdef is_LinearFunction(x) +cpdef is_LinearFunction(x) noexcept cdef class LinearFunctionOrConstraint(ModuleElement): pass cdef class LinearFunctionsParent_class(Parent): - cpdef _element_constructor_(self, x) - cpdef _coerce_map_from_(self, R) + cpdef _element_constructor_(self, x) noexcept + cpdef _coerce_map_from_(self, R) noexcept cdef public _multiplication_symbol cdef class LinearFunction(LinearFunctionOrConstraint): cdef dict _f - cpdef _add_(self, other) - cpdef iteritems(self) - cpdef _acted_upon_(self, x, bint self_on_left) - cpdef is_zero(self) - cpdef equals(LinearFunction left, LinearFunction right) + cpdef _add_(self, other) noexcept + cpdef iteritems(self) noexcept + cpdef _acted_upon_(self, x, bint self_on_left) noexcept + cpdef is_zero(self) noexcept + cpdef equals(LinearFunction left, LinearFunction right) noexcept cdef class LinearConstraintsParent_class(Parent): cdef LinearFunctionsParent_class _LF - cpdef _element_constructor_(self, left, right=?, equality=?) - cpdef _coerce_map_from_(self, R) + cpdef _element_constructor_(self, left, right=?, equality=?) noexcept + cpdef _coerce_map_from_(self, R) noexcept cdef class LinearConstraint(LinearFunctionOrConstraint): cdef bint equality cdef list constraints - cpdef equals(LinearConstraint left, LinearConstraint right) + cpdef equals(LinearConstraint left, LinearConstraint right) noexcept diff --git a/src/sage/numerical/linear_functions.pyx b/src/sage/numerical/linear_functions.pyx index f3fc6fe419c..edeed1dfef7 100644 --- a/src/sage/numerical/linear_functions.pyx +++ b/src/sage/numerical/linear_functions.pyx @@ -114,7 +114,7 @@ from sage.misc.cachefunc import cached_function # #***************************************************************************** -cpdef is_LinearFunction(x): +cpdef is_LinearFunction(x) noexcept: """ Test whether ``x`` is a linear function @@ -663,7 +663,7 @@ cdef class LinearFunctionsParent_class(Parent): """ return 'Linear functions over ' + str(self.base_ring()) - cpdef _element_constructor_(self, x): + cpdef _element_constructor_(self, x) noexcept: """ Construct a :class:`LinearFunction` from ``x``. @@ -693,7 +693,7 @@ cdef class LinearFunctionsParent_class(Parent): return LinearFunction(self, (x)._f) return LinearFunction(self, x) - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: """ Allow coercion of scalars into linear functions. @@ -802,7 +802,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): else: self._f = {-1: R(f)} - cpdef iteritems(self): + cpdef iteritems(self) noexcept: """ Iterate over the index, coefficient pairs. @@ -905,7 +905,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): except KeyError: return self.parent().base_ring().zero() - cpdef _add_(self, b): + cpdef _add_(self, b) noexcept: r""" Defining the + operator @@ -922,7 +922,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): P = self.parent() return P(e) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Defining the - operator (opposite). @@ -936,7 +936,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): P = self.parent() return P({id: -coeff for id, coeff in self._f.iteritems()}) - cpdef _sub_(self, b): + cpdef _sub_(self, b) noexcept: r""" Defining the - operator (subtraction). @@ -955,7 +955,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): P = self.parent() return P(e) - cpdef _lmul_(self, Element b): + cpdef _lmul_(self, Element b) noexcept: r""" Multiplication by scalars @@ -971,7 +971,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): P = self.parent() return P(dict([(id,b*coeff) for (id, coeff) in self._f.iteritems()])) - cpdef _acted_upon_(self, x, bint self_on_left): + cpdef _acted_upon_(self, x, bint self_on_left) noexcept: """ Act with scalars that do not have a natural coercion into ``self.base_ring()`` @@ -1130,7 +1130,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): else: return t - cpdef is_zero(self): + cpdef is_zero(self) noexcept: """ Test whether ``self`` is zero. @@ -1150,7 +1150,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): return False return True - cpdef equals(LinearFunction left, LinearFunction right): + cpdef equals(LinearFunction left, LinearFunction right) noexcept: """ Logically compare ``left`` and ``right``. @@ -1267,7 +1267,7 @@ cdef class LinearConstraintsParent_class(Parent): """ return 'Linear constraints over ' + str(self.linear_functions_parent().base_ring()) - cpdef _element_constructor_(self, left, right=None, equality=False): + cpdef _element_constructor_(self, left, right=None, equality=False) noexcept: """ Construct a :class:`LinearConstraint`. @@ -1332,7 +1332,7 @@ cdef class LinearConstraintsParent_class(Parent): else: return LinearConstraint(self, [left, right], equality=equality) - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: """ Allow coercion of scalars into linear functions. @@ -1432,7 +1432,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint): LF = parent.linear_functions_parent() self.constraints = [ LF(term) for term in terms ] - cpdef equals(LinearConstraint left, LinearConstraint right): + cpdef equals(LinearConstraint left, LinearConstraint right) noexcept: """ Compare ``left`` and ``right``. diff --git a/src/sage/numerical/linear_tensor_element.pxd b/src/sage/numerical/linear_tensor_element.pxd index 1cd84d3e33f..528f58b991c 100644 --- a/src/sage/numerical/linear_tensor_element.pxd +++ b/src/sage/numerical/linear_tensor_element.pxd @@ -2,4 +2,4 @@ from sage.structure.element cimport Element, ModuleElement cdef class LinearTensor(ModuleElement): cdef dict _f - cpdef _add_(self, other) + cpdef _add_(self, other) noexcept diff --git a/src/sage/numerical/linear_tensor_element.pyx b/src/sage/numerical/linear_tensor_element.pyx index c77aa290e21..e2c88619469 100644 --- a/src/sage/numerical/linear_tensor_element.pyx +++ b/src/sage/numerical/linear_tensor_element.pyx @@ -261,7 +261,7 @@ cdef class LinearTensor(ModuleElement): s += ']' return s - cpdef _add_(self, b): + cpdef _add_(self, b) noexcept: r""" Return sum. @@ -285,7 +285,7 @@ cdef class LinearTensor(ModuleElement): result[key] = self._f.get(key, 0) + coeff return self.parent()(result) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the negative. @@ -305,7 +305,7 @@ cdef class LinearTensor(ModuleElement): result[key] = -coeff return self.parent()(result) - cpdef _sub_(self, b): + cpdef _sub_(self, b) noexcept: r""" Return difference. @@ -331,7 +331,7 @@ cdef class LinearTensor(ModuleElement): result[key] = self._f.get(key, 0) - coeff return self.parent()(result) - cpdef _lmul_(self, Element b): + cpdef _lmul_(self, Element b) noexcept: r""" Return multiplication by scalar. diff --git a/src/sage/numerical/mip.pxd b/src/sage/numerical/mip.pxd index 3046d8b4886..612324a5424 100644 --- a/src/sage/numerical/mip.pxd +++ b/src/sage/numerical/mip.pxd @@ -19,11 +19,11 @@ cdef class MixedIntegerLinearProgram(SageObject): cdef int __INTEGER cdef object _linear_functions_parent cdef object _linear_constraints_parent - cpdef int number_of_constraints(self) - cpdef int number_of_variables(self) + cpdef int number_of_constraints(self) noexcept + cpdef int number_of_variables(self) noexcept cdef int _check_redundant cdef list _constraints - cpdef sum(self, L) + cpdef sum(self, L) noexcept cdef class MIPVariable(SageObject): @@ -34,5 +34,5 @@ cdef class MIPVariable(SageObject): cdef str _name cdef object _lower_bound cdef object _upper_bound - cdef _matrix_rmul_impl(self, m) - cdef _matrix_lmul_impl(self, m) + cdef _matrix_rmul_impl(self, m) noexcept + cdef _matrix_lmul_impl(self, m) noexcept diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 3711d9562cf..71dc66360da 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -869,7 +869,7 @@ cdef class MixedIntegerLinearProgram(SageObject): """ return tuple(self.new_variable() for i in range(n)) - cpdef int number_of_constraints(self): + cpdef int number_of_constraints(self) noexcept: r""" Return the number of constraints assigned so far. @@ -883,7 +883,7 @@ cdef class MixedIntegerLinearProgram(SageObject): """ return self._backend.nrows() - cpdef int number_of_variables(self): + cpdef int number_of_variables(self) noexcept: r""" Returns the number of variables used so far. @@ -2878,7 +2878,7 @@ cdef class MixedIntegerLinearProgram(SageObject): else: self._backend.solver_parameter(name, value) - cpdef sum(self, L): + cpdef sum(self, L) noexcept: r""" Efficiently computes the sum of a sequence of :class:`~sage.numerical.linear_functions.LinearFunction` elements @@ -3658,7 +3658,7 @@ cdef class MIPVariable(SageObject): return NotImplemented return ( right)._matrix_lmul_impl(left) - cdef _matrix_rmul_impl(self, m): + cdef _matrix_rmul_impl(self, m) noexcept: """ Implement the action of a matrix multiplying from the right. """ @@ -3672,7 +3672,7 @@ cdef class MIPVariable(SageObject): T = self._p.linear_functions_parent().tensor(V) return T(result) - cdef _matrix_lmul_impl(self, m): + cdef _matrix_lmul_impl(self, m) noexcept: """ Implement the action of a matrix multiplying from the left. """ diff --git a/src/sage/numerical/sdp.pxd b/src/sage/numerical/sdp.pxd index e0351dde4f3..47964ef1789 100644 --- a/src/sage/numerical/sdp.pxd +++ b/src/sage/numerical/sdp.pxd @@ -13,12 +13,12 @@ cdef class SemidefiniteProgram(SageObject): cdef dict _variables cdef object _linear_functions_parent cdef object _linear_constraints_parent - cpdef int number_of_constraints(self) - cpdef int number_of_variables(self) + cpdef int number_of_constraints(self) noexcept + cpdef int number_of_variables(self) noexcept cdef list _constraints - cpdef sum(self, L) - cpdef dual_variable(self, int i, sparse=*) - cpdef slack(self, int i, sparse=*) + cpdef sum(self, L) noexcept + cpdef dual_variable(self, int i, sparse=*) noexcept + cpdef slack(self, int i, sparse=*) noexcept cdef class SDPVariable(Element): @@ -26,9 +26,9 @@ cdef class SDPVariable(Element): cdef dict _dict cdef str _name cdef bint _hasname - cdef _matrix_rmul_impl(self, m) - cdef _matrix_lmul_impl(self, m) - cpdef _acted_upon_(self, mat, bint self_on_left) + cdef _matrix_rmul_impl(self, m) noexcept + cdef _matrix_lmul_impl(self, m) noexcept + cpdef _acted_upon_(self, mat, bint self_on_left) noexcept cdef class SDPVariableParent(Parent): diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index 77f7fa5254c..e7b96a2abef 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -565,7 +565,7 @@ cdef class SemidefiniteProgram(SageObject): """ return self.linear_functions_parent().gen(i) - cpdef int number_of_constraints(self): + cpdef int number_of_constraints(self) noexcept: r""" Returns the number of constraints assigned so far. @@ -587,7 +587,7 @@ cdef class SemidefiniteProgram(SageObject): """ return self._backend.nrows() - cpdef int number_of_variables(self): + cpdef int number_of_variables(self) noexcept: r""" Returns the number of variables used so far. @@ -959,7 +959,7 @@ cdef class SemidefiniteProgram(SageObject): return self._backend.get_objective_value() - cpdef dual_variable(self, int i, sparse=False): + cpdef dual_variable(self, int i, sparse=False) noexcept: """ The `i`-th dual variable. @@ -1008,7 +1008,7 @@ cdef class SemidefiniteProgram(SageObject): """ return self._backend.dual_variable(i, sparse=sparse) - cpdef slack(self, int i, sparse=False): + cpdef slack(self, int i, sparse=False) noexcept: """ Slack of the `i`-th constraint @@ -1101,7 +1101,7 @@ cdef class SemidefiniteProgram(SageObject): else: self._backend.solver_parameter(name, value) - cpdef sum(self, L): + cpdef sum(self, L) noexcept: r""" Efficiently computes the sum of a sequence of :class:`~sage.numerical.linear_functions.LinearFunction` elements. @@ -1324,7 +1324,7 @@ cdef class SDPVariable(Element): """ return self._dict.values() - cdef _matrix_rmul_impl(self, m): + cdef _matrix_rmul_impl(self, m) noexcept: """ Implement the action of a matrix multiplying from the right. """ @@ -1338,7 +1338,7 @@ cdef class SDPVariable(Element): T = self._p.linear_functions_parent().tensor(V) return T(result) - cdef _matrix_lmul_impl(self, m): + cdef _matrix_lmul_impl(self, m) noexcept: """ Implement the action of a matrix multiplying from the left. """ @@ -1352,7 +1352,7 @@ cdef class SDPVariable(Element): T = self._p.linear_functions_parent().tensor(V) return T(result) - cpdef _acted_upon_(self, mat, bint self_on_left): + cpdef _acted_upon_(self, mat, bint self_on_left) noexcept: """ Act with matrices on SDPVariables. diff --git a/src/sage/plot/complex_plot.pyx b/src/sage/plot/complex_plot.pyx index cb6a9cf8ca0..01d8060ea01 100644 --- a/src/sage/plot/complex_plot.pyx +++ b/src/sage/plot/complex_plot.pyx @@ -44,13 +44,13 @@ DEFAULT_LOGARITHMIC_CONTOUR_BASE = 2 DEFAULT_LINEAR_CONTOUR_BASE = 10 -cdef inline ComplexDoubleElement new_CDF_element(double x, double y): +cdef inline ComplexDoubleElement new_CDF_element(double x, double y) noexcept: z = ComplexDoubleElement.__new__(ComplexDoubleElement) GSL_SET_COMPLEX(&z._complex, x, y) return z -cdef inline double mag_to_lightness(double r, double rate=0.5): +cdef inline double mag_to_lightness(double r, double rate=0.5) noexcept: """ Return a lightness for the given magnitude. @@ -101,7 +101,7 @@ cdef inline double mag_to_lightness(double r, double rate=0.5): return atan(log(pow(r, rate)+1)) * (4/PI) - 1 -cdef inline double cyclic_logarithmic_mag_to_lightness(double r, double base=2): +cdef inline double cyclic_logarithmic_mag_to_lightness(double r, double base=2) noexcept: r""" Return a lightness for the given magnitude. @@ -152,7 +152,7 @@ cdef inline double cyclic_logarithmic_mag_to_lightness(double r, double base=2): return .15 - rem/2. -cdef inline double cyclic_linear_mag_to_lightness(double r, double base=10): +cdef inline double cyclic_linear_mag_to_lightness(double r, double base=10) noexcept: r""" Return a lightness for the given magnitude. @@ -205,7 +205,7 @@ cdef inline double cyclic_linear_mag_to_lightness(double r, double base=10): cdef inline double mag_and_arg_to_lightness(double r, double arg, - double base=2, int nphases=10): + double base=2, int nphases=10) noexcept: r""" Return a lightness for the given magnitude and argument. diff --git a/src/sage/plot/plot3d/implicit_surface.pyx b/src/sage/plot/plot3d/implicit_surface.pyx index db8a3f226f3..f5773a63d08 100644 --- a/src/sage/plot/plot3d/implicit_surface.pyx +++ b/src/sage/plot/plot3d/implicit_surface.pyx @@ -97,7 +97,7 @@ DEFAULT_PLOT_POINTS = 40 cdef double nan = float(RDF('NaN')) -cdef inline bint marching_has_edge(double a, double b, double contour, double *f, bint *has_nan): +cdef inline bint marching_has_edge(double a, double b, double contour, double *f, bint *has_nan) noexcept: if isnan(a) or isnan(b): has_nan[0] = True return False @@ -111,10 +111,10 @@ cdef inline bint marching_has_edge(double a, double b, double contour, double *f return True # Returns 0 or 1 -cdef inline int marching_is_inside(double v, double contour): +cdef inline int marching_is_inside(double v, double contour) noexcept: return isnan(v) or v < contour -cdef void interpolate_point_c(point_c *result, double frac, point_c *inputs): +cdef void interpolate_point_c(point_c *result, double frac, point_c *inputs) noexcept: result[0].x = inputs[0].x + frac*(inputs[1].x - inputs[0].x) result[0].y = inputs[0].y + frac*(inputs[1].y - inputs[0].y) result[0].z = inputs[0].z + frac*(inputs[1].z - inputs[0].z) @@ -133,7 +133,7 @@ cdef class VertexInfo: # This point in "evaluation space" cdef point_c eval_pt - cdef void update_eval_pt(self, point_c *eval_min, point_c *eval_scale): + cdef void update_eval_pt(self, point_c *eval_min, point_c *eval_scale) noexcept: """ Use eval_min and eval_scale to transform self.pt into evaluation space and store the result in self.eval_pt. @@ -153,7 +153,7 @@ cdef class VertexInfo: return '<{}, {}, {}>'.format(self.pt.x, self.pt.y, self.pt.z) -cdef mk_VertexInfo(double x, double y, double z, point_c *eval_min, point_c *eval_scale): +cdef mk_VertexInfo(double x, double y, double z, point_c *eval_min, point_c *eval_scale) noexcept: cdef VertexInfo v v = VertexInfo.__new__(VertexInfo) v.pt.x = x @@ -452,7 +452,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): self.process_cubes(self.slices[0], self.slices[1]) - cpdef _update_yz_vertices(self, int x, np.ndarray _prev, np.ndarray _cur, np.ndarray _next): + cpdef _update_yz_vertices(self, int x, np.ndarray _prev, np.ndarray _cur, np.ndarray _next) noexcept: """ TESTS:: @@ -560,7 +560,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): else: z_vertices[y,z] = None - cpdef _update_x_vertices(self, int x, np.ndarray _prev, np.ndarray _left, np.ndarray _right, np.ndarray _next): + cpdef _update_x_vertices(self, int x, np.ndarray _prev, np.ndarray _left, np.ndarray _right, np.ndarray _next) noexcept: """ TESTS:: @@ -635,10 +635,10 @@ cdef class MarchingCubesTriangles(MarchingCubes): else: x_vertices[y,z] = None - cdef bint in_region(self, VertexInfo v): + cdef bint in_region(self, VertexInfo v) noexcept: return (self.region(v.eval_pt.x, v.eval_pt.y, v.eval_pt.z) > 0) - cdef apply_point_func(self, point_c *pt, fn, VertexInfo v): + cdef apply_point_func(self, point_c *pt, fn, VertexInfo v) noexcept: if isinstance(fn, tuple): pt[0].x = fn[0](v.eval_pt.x, v.eval_pt.y, v.eval_pt.z) pt[0].y = fn[1](v.eval_pt.x, v.eval_pt.y, v.eval_pt.z) @@ -649,7 +649,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): pt[0].y = t[1] pt[0].z = t[2] - cdef apply_color_func(self, color_c *pt, fn, cm, VertexInfo v): + cdef apply_color_func(self, color_c *pt, fn, cm, VertexInfo v) noexcept: t = fn(v.eval_pt.x, v.eval_pt.y, v.eval_pt.z) pt[0].r, pt[0].g, pt[0].b, _ = cm(t) @@ -659,7 +659,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): double center, double lx, double ux, double ly, double uy, - double lz, double uz): + double lz, double uz) noexcept: # What a mess! It would be much nicer-looking code to pass slices # in here and do the subscripting in here. Unfortunately, # that would also be much slower, because we'd have to re-initialize @@ -684,7 +684,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): g[0].y = gy g[0].z = gz - cpdef process_cubes(self, np.ndarray _left, np.ndarray _right): + cpdef process_cubes(self, np.ndarray _left, np.ndarray _right) noexcept: """ TESTS:: @@ -788,7 +788,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): all_vertex_info[my_triangles[i+1]], all_vertex_info[my_triangles[i+2]]) - cpdef add_triangle(self, VertexInfo v1, VertexInfo v2, VertexInfo v3): + cpdef add_triangle(self, VertexInfo v1, VertexInfo v2, VertexInfo v3) noexcept: """ Called when a new triangle is generated by the marching cubes algorithm to update the results array. @@ -845,7 +845,7 @@ cdef class MarchingCubesTriangles(MarchingCubes): self.results.append(face) -cpdef render_implicit(f, xrange, yrange, zrange, plot_points, cube_marchers): +cpdef render_implicit(f, xrange, yrange, zrange, plot_points, cube_marchers) noexcept: """ INPUT: diff --git a/src/sage/plot/plot3d/index_face_set.pyx b/src/sage/plot/plot3d/index_face_set.pyx index 3968db3ab51..af5a9cfd32b 100644 --- a/src/sage/plot/plot3d/index_face_set.pyx +++ b/src/sage/plot/plot3d/index_face_set.pyx @@ -69,7 +69,7 @@ from .transform cimport Transformation # Fast routines for generating string representations of the polygons. # -------------------------------------------------------------------- -cdef inline format_tachyon_texture(color_c rgb): +cdef inline format_tachyon_texture(color_c rgb) noexcept: cdef char rs[200] cdef Py_ssize_t cr = sprintf_3d(rs, "TEXTURE\n AMBIENT 0.3 DIFFUSE 0.7 SPECULAR 0 OPACITY 1.0\n COLOR %g %g %g \n TEXFUNC 0", @@ -77,7 +77,7 @@ cdef inline format_tachyon_texture(color_c rgb): return bytes_to_str(PyBytes_FromStringAndSize(rs, cr)) -cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R): +cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R) noexcept: cdef char ss[250] # PyBytes_FromFormat doesn't do floats? cdef Py_ssize_t r = sprintf_9d(ss, @@ -88,22 +88,22 @@ cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R): return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_json_vertex(point_c P): +cdef inline format_json_vertex(point_c P) noexcept: cdef char ss[100] cdef Py_ssize_t r = sprintf_3d(ss, '{"x":%g,"y":%g,"z":%g}', P.x, P.y, P.z) return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_json_face(face_c face): +cdef inline format_json_face(face_c face) noexcept: s = "[{}]".format(",".join(str(face.vertices[i]) for i in range(face.n))) return s -cdef inline format_obj_vertex(point_c P): +cdef inline format_obj_vertex(point_c P) noexcept: cdef char ss[100] # PyBytes_FromFormat doesn't do floats? cdef Py_ssize_t r = sprintf_3d(ss, "v %g %g %g", P.x, P.y, P.z) return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_obj_face(face_c face, int off): +cdef inline format_obj_face(face_c face, int off) noexcept: cdef char ss[100] cdef Py_ssize_t r, i if face.n == 3: @@ -115,7 +115,7 @@ cdef inline format_obj_face(face_c face, int off): # PyBytes_FromFormat is almost twice as slow return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_obj_face_back(face_c face, int off): +cdef inline format_obj_face_back(face_c face, int off) noexcept: cdef char ss[100] cdef Py_ssize_t r, i if face.n == 3: @@ -126,13 +126,13 @@ cdef inline format_obj_face_back(face_c face, int off): return "f " + " ".join(str(face.vertices[i] + off) for i from face.n > i >= 0) return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_pmesh_vertex(point_c P): +cdef inline format_pmesh_vertex(point_c P) noexcept: cdef char ss[100] # PyBytes_FromFormat doesn't do floats? cdef Py_ssize_t r = sprintf_3d(ss, "%g %g %g", P.x, P.y, P.z) return bytes_to_str(PyBytes_FromStringAndSize(ss, r)) -cdef inline format_pmesh_face(face_c face, int has_color): +cdef inline format_pmesh_face(face_c face, int has_color) noexcept: cdef char ss[100] cdef Py_ssize_t r, i cdef int color diff --git a/src/sage/plot/plot3d/parametric_surface.pyx b/src/sage/plot/plot3d/parametric_surface.pyx index 11676df7dfe..f62bc08b1a7 100644 --- a/src/sage/plot/plot3d/parametric_surface.pyx +++ b/src/sage/plot/plot3d/parametric_surface.pyx @@ -129,7 +129,7 @@ from sage.ext.interpreters.wrapper_rdf cimport Wrapper_rdf include "point_c.pxi" -cdef inline bint smash_edge(point_c* vs, face_c* f, int a, int b): +cdef inline bint smash_edge(point_c* vs, face_c* f, int a, int b) noexcept: if point_c_eq(vs[f.vertices[a]], vs[f.vertices[b]]): f.vertices[b] = f.vertices[a] f.n -= 1 diff --git a/src/sage/plot/plot3d/point_c.pxi b/src/sage/plot/plot3d/point_c.pxi index aa6699d368e..ba9561ab18c 100644 --- a/src/sage/plot/plot3d/point_c.pxi +++ b/src/sage/plot/plot3d/point_c.pxi @@ -21,13 +21,13 @@ from libc cimport math cdef inline bint point_c_set(point_c* res, P) except -2: res.x, res.y, res.z = P[0], P[1], P[2] -cdef inline bint point_c_eq(point_c P, point_c Q): +cdef inline bint point_c_eq(point_c P, point_c Q) noexcept: return P.x == Q.x and P.y == Q.y and P.z == Q.z -cdef inline bint point_c_isfinite(point_c P): +cdef inline bint point_c_isfinite(point_c P) noexcept: return math.isfinite(P.x) and math.isfinite(P.y) and math.isfinite(P.z) -cdef inline int point_c_cmp(point_c P, point_c Q): +cdef inline int point_c_cmp(point_c P, point_c Q) noexcept: """ Lexographic order """ @@ -48,7 +48,7 @@ cdef inline int point_c_cmp(point_c P, point_c Q): else: return 1 -cdef inline void point_c_update_finite_lower_bound(point_c* res, point_c P): +cdef inline void point_c_update_finite_lower_bound(point_c* res, point_c P) noexcept: # We use the condition "not P.x > res.x" so that the condition returns True if res.x is NaN if math.isfinite(P.x) and not P.x > res.x: res.x = P.x @@ -57,7 +57,7 @@ cdef inline void point_c_update_finite_lower_bound(point_c* res, point_c P): if math.isfinite(P.z) and not P.z > res.z: res.z = P.z -cdef inline void point_c_update_finite_upper_bound(point_c* res, point_c P): +cdef inline void point_c_update_finite_upper_bound(point_c* res, point_c P) noexcept: # We use the condition "not P.x < res.x" so that the condition returns True if res.x is NaN if math.isfinite(P.x) and not P.x < res.x: res.x = P.x @@ -66,49 +66,49 @@ cdef inline void point_c_update_finite_upper_bound(point_c* res, point_c P): if math.isfinite(P.z) and not P.z < res.z: res.z = P.z -cdef inline void point_c_lower_bound(point_c* res, point_c P, point_c Q): +cdef inline void point_c_lower_bound(point_c* res, point_c P, point_c Q) noexcept: res.x = P.x if P.x < Q.x else Q.x res.y = P.y if P.y < Q.y else Q.y res.z = P.z if P.z < Q.z else Q.z -cdef inline void point_c_upper_bound(point_c* res, point_c P, point_c Q): +cdef inline void point_c_upper_bound(point_c* res, point_c P, point_c Q) noexcept: res.x = P.x if P.x > Q.x else Q.x res.y = P.y if P.y > Q.y else Q.y res.z = P.z if P.z > Q.z else Q.z -cdef inline void point_c_add(point_c* res, point_c P, point_c Q): +cdef inline void point_c_add(point_c* res, point_c P, point_c Q) noexcept: res.x = P.x + Q.x res.y = P.y + Q.y res.z = P.z + Q.z -cdef inline void point_c_sub(point_c* res, point_c P, point_c Q): +cdef inline void point_c_sub(point_c* res, point_c P, point_c Q) noexcept: res.x = P.x - Q.x res.y = P.y - Q.y res.z = P.z - Q.z -cdef inline void point_c_mul(point_c* res, point_c P, double a): +cdef inline void point_c_mul(point_c* res, point_c P, double a) noexcept: res.x = a * P.x res.y = a * P.y res.z = a * P.z -cdef inline double point_c_dot(point_c P, point_c Q): +cdef inline double point_c_dot(point_c P, point_c Q) noexcept: return P.x*Q.x + P.y*Q.y + P.z*Q.z -cdef inline void point_c_cross(point_c* res, point_c P, point_c Q): +cdef inline void point_c_cross(point_c* res, point_c P, point_c Q) noexcept: res.x = P.y * Q.z - P.z * Q.y res.y = P.z * Q.x - P.x * Q.z res.z = P.x * Q.y - P.y * Q.x -cdef inline double point_c_len(point_c P): +cdef inline double point_c_len(point_c P) noexcept: return math.sqrt(point_c_dot(P, P)) -cdef inline void point_c_middle(point_c* res, point_c P, point_c Q, double a): +cdef inline void point_c_middle(point_c* res, point_c P, point_c Q, double a) noexcept: cdef double b = 1 - a res.x = b * P.x + a * Q.x res.y = b * P.y + a * Q.y res.z = b * P.z + a * Q.z -cdef inline void point_c_transform(point_c* res, double* M, point_c P): +cdef inline void point_c_transform(point_c* res, double* M, point_c P) noexcept: """ M is a flattened 4x4 matrix, row major, representing an Euclidean Transformation. Operate on P as a point. @@ -117,7 +117,7 @@ cdef inline void point_c_transform(point_c* res, double* M, point_c P): res.y = M[4]*P.x + M[5]*P.y + M[6]*P.z + M[7] res.z = M[8]*P.x + M[9]*P.y + M[10]*P.z + M[11] -cdef inline void point_c_stretch(point_c* res, double* M, point_c P): +cdef inline void point_c_stretch(point_c* res, double* M, point_c P) noexcept: """ M is a flattened 4x4 matrix, row major, representing an Euclidean Transformation. Operate on P as a vector (i.e. ignore the translation component) @@ -126,20 +126,20 @@ cdef inline void point_c_stretch(point_c* res, double* M, point_c P): res.y = M[4]*P.x + M[5]*P.y + M[6]*P.z res.z = M[8]*P.x + M[9]*P.y + M[10]*P.z -cdef inline void face_c_normal(point_c* res, face_c face, point_c* vlist): +cdef inline void face_c_normal(point_c* res, face_c face, point_c* vlist) noexcept: cdef point_c e1, e2 point_c_sub(&e1, vlist[face.vertices[0]], vlist[face.vertices[1]]) point_c_sub(&e2, vlist[face.vertices[2]], vlist[face.vertices[1]]) point_c_cross(res, e1, e2) -cdef inline double cos_face_angle(face_c F, face_c E, point_c* vlist): +cdef inline double cos_face_angle(face_c F, face_c E, point_c* vlist) noexcept: cdef point_c nF, nE face_c_normal(&nF, F, vlist) face_c_normal(&nE, E, vlist) cdef double dot = point_c_dot(nF, nE) return dot / math.sqrt(point_c_dot(nF, nF)*point_c_dot(nE, nE)) -cdef inline double sin_face_angle(face_c F, face_c E, point_c* vlist): +cdef inline double sin_face_angle(face_c F, face_c E, point_c* vlist) noexcept: cdef point_c nF, nE face_c_normal(&nF, F, vlist) face_c_normal(&nE, E, vlist) diff --git a/src/sage/plot/plot3d/transform.pxd b/src/sage/plot/plot3d/transform.pxd index 1ae51ca9967..87695fc3d87 100644 --- a/src/sage/plot/plot3d/transform.pxd +++ b/src/sage/plot/plot3d/transform.pxd @@ -13,8 +13,8 @@ cdef class Transformation: cdef matrix cdef double _matrix_data[12] cdef object _svd - cpdef transform_point(self, x) - cpdef transform_vector(self, v) - cpdef transform_bounding_box(self, box) - cdef void transform_point_c(self, point_c* res, point_c P) - cdef void transform_vector_c(self, point_c* res, point_c P) + cpdef transform_point(self, x) noexcept + cpdef transform_vector(self, v) noexcept + cpdef transform_bounding_box(self, box) noexcept + cdef void transform_point_c(self, point_c* res, point_c P) noexcept + cdef void transform_vector_c(self, point_c* res, point_c P) noexcept diff --git a/src/sage/plot/plot3d/transform.pyx b/src/sage/plot/plot3d/transform.pyx index 5bff0d71ddc..fefbb26dede 100644 --- a/src/sage/plot/plot3d/transform.pyx +++ b/src/sage/plot/plot3d/transform.pyx @@ -75,19 +75,19 @@ cdef class Transformation: len_a = a.dot_product(a) return max([abs(len_a - b.dot_product(b)) for b in basis]) < eps - cpdef transform_point(self, x): + cpdef transform_point(self, x) noexcept: cdef point_c res, P P.x, P.y, P.z = x point_c_transform(&res, self._matrix_data, P) return res.x, res.y, res.z - cpdef transform_vector(self, v): + cpdef transform_vector(self, v) noexcept: cdef point_c res, P P.x, P.y, P.z = v point_c_stretch(&res, self._matrix_data, P) return res.x, res.y, res.z - cpdef transform_bounding_box(self, box): + cpdef transform_bounding_box(self, box) noexcept: cdef point_c lower, upper, res, temp cdef point_c bounds[2] bounds[0].x, bounds[0].y, bounds[0].z = box[0] @@ -105,10 +105,10 @@ cdef class Transformation: return (lower.x, lower.y, lower.z), (upper.x, upper.y, upper.z) - cdef void transform_point_c(self, point_c* res, point_c P): + cdef void transform_point_c(self, point_c* res, point_c P) noexcept: point_c_transform(res, self._matrix_data, P) - cdef void transform_vector_c(self, point_c* res, point_c P): + cdef void transform_vector_c(self, point_c* res, point_c P) noexcept: point_c_stretch(res, self._matrix_data, P) def __mul__(Transformation self, Transformation other): diff --git a/src/sage/quadratic_forms/count_local_2.pyx b/src/sage/quadratic_forms/count_local_2.pyx index 3ce05a3a413..9b7d3e15178 100644 --- a/src/sage/quadratic_forms/count_local_2.pyx +++ b/src/sage/quadratic_forms/count_local_2.pyx @@ -87,7 +87,7 @@ def count_modp__by_gauss_sum(n, p, m, Qdet): return count -cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec): +cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec) noexcept: """ This Cython routine is documented in its Python wrapper method QuadraticForm.count_congruence_solutions_by_type(). @@ -181,7 +181,7 @@ def CountAllLocalTypesNaive(Q, p, k, m, zvec, nzvec): return CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec) -cdef local_solution_type_cdef(Q, p, w, zvec, nzvec): +cdef local_solution_type_cdef(Q, p, w, zvec, nzvec) noexcept: """ Internal routine to check if a given solution vector `w` (of `Q(w) = m` mod `p^k`) is of a certain local type and satisfies certain diff --git a/src/sage/quadratic_forms/quadratic_form__evaluate.pyx b/src/sage/quadratic_forms/quadratic_form__evaluate.pyx index 95e82e669dc..8a5aeafd831 100644 --- a/src/sage/quadratic_forms/quadratic_form__evaluate.pyx +++ b/src/sage/quadratic_forms/quadratic_form__evaluate.pyx @@ -44,7 +44,7 @@ def QFEvaluateVector(Q, v): return QFEvaluateVector_cdef(Q, v) -cdef QFEvaluateVector_cdef(Q, v): +cdef QFEvaluateVector_cdef(Q, v) noexcept: r""" Routine to quickly evaluate a quadratic form `Q` on a vector `v`. See the Python wrapper function :meth:`QFEvaluate` above for details. @@ -111,7 +111,7 @@ def QFEvaluateMatrix(Q, M, Q2): return QFEvaluateMatrix_cdef(Q, M, Q2) -cdef QFEvaluateMatrix_cdef(Q, M, Q2): +cdef QFEvaluateMatrix_cdef(Q, M, Q2) noexcept: r""" Routine to quickly evaluate a quadratic form `Q` on a matrix `M`. See the Python wrapper function :func:`QFEvaluateMatrix` above for details. diff --git a/src/sage/quivers/algebra_elements.pxd b/src/sage/quivers/algebra_elements.pxd index 3beb69914d0..e47696270da 100644 --- a/src/sage/quivers/algebra_elements.pxd +++ b/src/sage/quivers/algebra_elements.pxd @@ -83,14 +83,14 @@ cdef class PathAlgebraElement(RingElement): # functions. cdef path_order_t cmp_terms cdef long _hash - cpdef _add_(self, other) - cpdef _mul_(self, other) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept cpdef ssize_t degree(self) except -2 - cpdef dict monomial_coefficients(self) - cpdef list coefficients(self) - cpdef list monomials(self) - cpdef list support(self) - cpdef list terms(self) - cpdef object coefficient(self, QuiverPath P) - cdef list _sorted_items_for_printing(self) - cdef inline PathAlgebraElement _new_(self, path_homog_poly_t *h) + cpdef dict monomial_coefficients(self) noexcept + cpdef list coefficients(self) noexcept + cpdef list monomials(self) noexcept + cpdef list support(self) noexcept + cpdef list terms(self) noexcept + cpdef object coefficient(self, QuiverPath P) noexcept + cdef list _sorted_items_for_printing(self) noexcept + cdef inline PathAlgebraElement _new_(self, path_homog_poly_t *h) noexcept diff --git a/src/sage/quivers/algebra_elements.pxi b/src/sage/quivers/algebra_elements.pxi index a6372328fdd..7b9a9883f28 100644 --- a/src/sage/quivers/algebra_elements.pxi +++ b/src/sage/quivers/algebra_elements.pxi @@ -68,7 +68,7 @@ cdef bint mon_create_keep(path_mon_t out, biseq_t Mon, long Pos, mp_size_t L_len # It changes an existing monomial in-place (which should NEVER # be done on a monomial that is in use), re-allocating memory # and filling it with the given bounded integer sequence (not a copy). -cdef bint mon_realloc_keep(path_mon_t out, biseq_t Mon, long Pos, mp_size_t L_len, mp_size_t S_len): +cdef bint mon_realloc_keep(path_mon_t out, biseq_t Mon, long Pos, mp_size_t L_len, mp_size_t S_len) noexcept: biseq_dealloc(out.path) out.path[0] = Mon[0] out.pos = Pos @@ -84,11 +84,11 @@ cdef inline bint mon_copy(path_mon_t out, path_mon_t M) except -1: # Deallocate the monomial, which means to decrease the reference count, # or to actually deallocate the data if there is no reference left. -cdef inline void mon_free(path_mon_t M): +cdef inline void mon_free(path_mon_t M) noexcept: biseq_dealloc(M.path) # Linearisation -cdef inline tuple mon_pickle(path_mon_t M): +cdef inline tuple mon_pickle(path_mon_t M) noexcept: return (bitset_pickle(M.path.data) if M.path.length>0 else (), M.path.itembitsize, M.path.length, M.pos, M.l_len, M.s_len) @@ -286,7 +286,7 @@ freelist.used = 0 freelist.pool = check_allocarray(poolsize, sizeof(path_term_t*)) # Deallocate the term, and return the pointer .nxt, without using kill list -cdef inline path_term_t *term_free_force(path_term_t *T): +cdef inline path_term_t *term_free_force(path_term_t *T) noexcept: mon_free(T.mon) cdef path_term_t *out = T.nxt sig_free(T) @@ -323,7 +323,7 @@ _freelist_protector = _FreeListProtector() # Put the term on the freelist (unless the list is full), # and return the pointer .nxt -cdef inline path_term_t *term_free(path_term_t *T): +cdef inline path_term_t *term_free(path_term_t *T) noexcept: if T.coef!=NULL: Py_XDECREF(T.coef) if likely(freelist.used < poolsize): @@ -408,18 +408,18 @@ cdef path_term_t *term_copy_recursive(path_term_t *T) except NULL: return first # Hash of a term; probably not a good one. -cdef inline long term_hash(path_term_t *T): +cdef inline long term_hash(path_term_t *T) noexcept: return (hash(T.coef)+(T.mon.l_len<<5)+(T.mon.pos<<10))^bitset_hash(T.mon.path.data) # Recall that a monomial a*I*b (with I a generator of a free module) # is encoded by a path a*s*b for some monomial s that refers to a # so-called Schreyer ordering. The total degree of a*I*b is the length # of a plus the length of b. -cdef inline mp_size_t term_total_degree(path_term_t *T): +cdef inline mp_size_t term_total_degree(path_term_t *T) noexcept: return T.mon.path.length-T.mon.s_len # Linearisation -cdef inline tuple term_pickle(path_term_t *T): +cdef inline tuple term_pickle(path_term_t *T) noexcept: return (T.coef, mon_pickle(T.mon)) # De-linearisation @@ -628,14 +628,14 @@ cdef inline path_poly_t *poly_create() except NULL: return out # Deallocate all terms of the polynomial, but NOT the polynomial itself -cdef inline void poly_dealloc(path_poly_t *P): +cdef inline void poly_dealloc(path_poly_t *P) noexcept: cdef path_term_t *T = P.lead while T!=NULL: T = term_free(T) # Deallocate all terms of the polynomial, and free the chunk of memory # used by the polynomial. -cdef inline void poly_free(path_poly_t *P): +cdef inline void poly_free(path_poly_t *P) noexcept: poly_dealloc(P) sig_free(P) @@ -689,7 +689,7 @@ cdef bint poly_icopy_scale(path_poly_t *out, path_poly_t *P, object coef) except return True # Linearisation of a path polynomials -cdef list poly_pickle(path_poly_t *P): +cdef list poly_pickle(path_poly_t *P) noexcept: cdef list L = [] cdef path_term_t *T = P.lead while T != NULL: @@ -722,7 +722,7 @@ cdef bint poly_inplace_unpickle(path_poly_t *P, list data) except -1: # Rich comparison of P1 and P2, using the given monomial ordering cmp_terms. # Return a boolean. -cdef bint poly_richcmp(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_terms, int op): +cdef bint poly_richcmp(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_terms, int op) noexcept: cdef path_term_t *T1 = P1.lead cdef path_term_t *T2 = P2.lead cdef int c @@ -747,7 +747,7 @@ cdef bint poly_richcmp(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_terms, return rich_to_bool(op, 1) # Hash of a polynomial. Probably not a very strong hash. -cdef inline long poly_hash(path_poly_t *P): +cdef inline long poly_hash(path_poly_t *P) noexcept: cdef path_term_t *T = P.lead cdef long out = 0 while T != NULL: @@ -758,7 +758,7 @@ cdef inline long poly_hash(path_poly_t *P): # Change T1 inplace to T1+T2.coeff*T1. If the new coefficient is zero, # then T1.coef becomes NULL -cdef inline void term_iadd(path_term_t *T1, path_term_t *T2): +cdef inline void term_iadd(path_term_t *T1, path_term_t *T2) noexcept: cdef object coef = (T1.coef) + (T2.coef) Py_XDECREF(T1.coef) if coef: @@ -1205,7 +1205,7 @@ cdef path_homog_poly_t *homog_poly_init_list(int start, int end, list L, path_or poly_iadd_term_d(out.poly, term_create(coef, P._path, pos, 0, 0), cmp_terms) return out -cdef void homog_poly_free(path_homog_poly_t *P): +cdef void homog_poly_free(path_homog_poly_t *P) noexcept: cdef path_homog_poly_t *nxt while P!=NULL: nxt = P.nxt @@ -1232,7 +1232,7 @@ cdef path_homog_poly_t *homog_poly_copy(path_homog_poly_t *H) except NULL: return out # Linearisation -cdef list homog_poly_pickle(path_homog_poly_t *H): +cdef list homog_poly_pickle(path_homog_poly_t *H) noexcept: cdef list L = [] while H != NULL: L.append((H.start, H.end, poly_pickle(H.poly))) @@ -1297,7 +1297,7 @@ cdef path_homog_poly_t *homog_poly_scale(path_homog_poly_t *H, object coef) exce H = H.nxt return out -cdef path_homog_poly_t *homog_poly_get_predecessor_of_component(path_homog_poly_t *H, int s, int e): +cdef path_homog_poly_t *homog_poly_get_predecessor_of_component(path_homog_poly_t *H, int s, int e) noexcept: # Search through H.nxt.nxt... and return the pointer C to a component of H # such that either C.nxt.start==s and C.nxt.end==e, or the component for # (s,e) should be inserted between C and C.nxt. Return NULL if H==NULL or diff --git a/src/sage/quivers/algebra_elements.pyx b/src/sage/quivers/algebra_elements.pyx index 3d05ba7e270..54906701d26 100644 --- a/src/sage/quivers/algebra_elements.pyx +++ b/src/sage/quivers/algebra_elements.pyx @@ -211,7 +211,7 @@ cdef class PathAlgebraElement(RingElement): """ return path_algebra_element_unpickle, (self._parent, homog_poly_pickle(self.data)) - cdef list _sorted_items_for_printing(self): + cdef list _sorted_items_for_printing(self) noexcept: """ Return list of pairs ``(M,c)``, where ``c`` is a coefficient and ``M`` will be passed to ``self.parent()._repr_monomial`` resp. to @@ -402,7 +402,7 @@ cdef class PathAlgebraElement(RingElement): H = H.nxt return True - cpdef dict monomial_coefficients(self): + cpdef dict monomial_coefficients(self) noexcept: """ Return the dictionary keyed by the monomials appearing in this element, the values being the coefficients. @@ -451,7 +451,7 @@ cdef class PathAlgebraElement(RingElement): H = H.nxt return D - cpdef list coefficients(self): + cpdef list coefficients(self) noexcept: """ Return the list of coefficients. @@ -485,7 +485,7 @@ cdef class PathAlgebraElement(RingElement): H = H.nxt return L - cpdef list monomials(self): + cpdef list monomials(self) noexcept: """ Return the list of monomials appearing in this element. @@ -547,7 +547,7 @@ cdef class PathAlgebraElement(RingElement): H = H.nxt return L - cpdef list terms(self): + cpdef list terms(self) noexcept: """ Return the list of terms. @@ -600,7 +600,7 @@ cdef class PathAlgebraElement(RingElement): H = H.nxt return L - cpdef list support(self): + cpdef list support(self) noexcept: """ Return the list of monomials, as elements of the underlying partial semigroup. @@ -685,7 +685,7 @@ cdef class PathAlgebraElement(RingElement): return tmp raise ValueError("{} is not a single term".format(self)) - cpdef object coefficient(self, QuiverPath P): + cpdef object coefficient(self, QuiverPath P) noexcept: """ Return the coefficient of a monomial. @@ -775,7 +775,7 @@ cdef class PathAlgebraElement(RingElement): T = T.nxt H = H.nxt - cdef PathAlgebraElement _new_(self, path_homog_poly_t *h): + cdef PathAlgebraElement _new_(self, path_homog_poly_t *h) noexcept: """ Create a new path algebra element from C interface data. """ @@ -941,7 +941,7 @@ cdef class PathAlgebraElement(RingElement): self._hash = hash(frozenset(self.monomial_coefficients().items())) return self._hash - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Helper for comparison of path algebra elements. @@ -999,7 +999,7 @@ cdef class PathAlgebraElement(RingElement): return rich_to_bool(op, 1) # negation - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: @@ -1013,7 +1013,7 @@ cdef class PathAlgebraElement(RingElement): return self._new_(homog_poly_neg(self.data)) # addition - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ EXAMPLES:: @@ -1089,7 +1089,7 @@ cdef class PathAlgebraElement(RingElement): H1 = H1.nxt H2 = H2.nxt - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ EXAMPLES:: @@ -1178,7 +1178,7 @@ cdef class PathAlgebraElement(RingElement): # (scalar) multiplication - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -1208,7 +1208,7 @@ cdef class PathAlgebraElement(RingElement): return self._new_(outnxt) return self._new_(out) - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -1275,7 +1275,7 @@ cdef class PathAlgebraElement(RingElement): # Multiplication in the algebra - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ EXAMPLES:: @@ -1381,7 +1381,7 @@ cdef class PathAlgebraElement(RingElement): tmp = tmp.nxt return self._new_(out_orig) -cpdef PathAlgebraElement path_algebra_element_unpickle(P, list data): +cpdef PathAlgebraElement path_algebra_element_unpickle(P, list data) noexcept: """ Auxiliary function for unpickling. diff --git a/src/sage/quivers/paths.pxd b/src/sage/quivers/paths.pxd index 5757bf6e219..88bfe92ca0f 100644 --- a/src/sage/quivers/paths.pxd +++ b/src/sage/quivers/paths.pxd @@ -4,9 +4,9 @@ from sage.data_structures.bounded_integer_sequences cimport biseq_t cdef class QuiverPath(MonoidElement): cdef biseq_t _path cdef int _start, _end - cdef QuiverPath _new_(self, int start, int end) - cpdef _mul_(self, other) - cpdef _mod_(self, right) - cpdef tuple complement(self, QuiverPath subpath) + cdef QuiverPath _new_(self, int start, int end) noexcept + cpdef _mul_(self, other) noexcept + cpdef _mod_(self, right) noexcept + cpdef tuple complement(self, QuiverPath subpath) noexcept cpdef bint has_subpath(self, QuiverPath subpath) except -1 cpdef bint has_prefix(self, QuiverPath subpath) except -1 diff --git a/src/sage/quivers/paths.pyx b/src/sage/quivers/paths.pyx index f2642ada119..38fdc03beba 100644 --- a/src/sage/quivers/paths.pyx +++ b/src/sage/quivers/paths.pyx @@ -109,7 +109,7 @@ cdef class QuiverPath(MonoidElement): """ biseq_dealloc(self._path) - cdef QuiverPath _new_(self, int start, int end): + cdef QuiverPath _new_(self, int start, int end) noexcept: """ TESTS:: @@ -260,7 +260,7 @@ cdef class QuiverPath(MonoidElement): """ return self._path.length != 0 - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Comparison for :class:`QuiverPaths`. @@ -465,7 +465,7 @@ cdef class QuiverPath(MonoidElement): for i in range(self._path.length): yield E[biseq_getitem(self._path, i)] - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Compose two paths. @@ -503,7 +503,7 @@ cdef class QuiverPath(MonoidElement): biseq_init_concat(OUT._path, self._path,right._path) return OUT - cpdef _mod_(self, other): + cpdef _mod_(self, other) noexcept: """ Return what remains of this path after removing the initial segment ``other``. @@ -606,7 +606,7 @@ cdef class QuiverPath(MonoidElement): return (None, None, None) return (self[:i], self[i:], P[self._path.length-i:]) - cpdef tuple complement(self, QuiverPath subpath): + cpdef tuple complement(self, QuiverPath subpath) noexcept: """ Return a pair ``(a,b)`` of paths s.t. ``self = a*subpath*b``, or ``(None, None)`` if ``subpath`` is not a subpath of this path. diff --git a/src/sage/rings/complex_arb.pxd b/src/sage/rings/complex_arb.pxd index 5f858a20fcf..d985745c1f5 100644 --- a/src/sage/rings/complex_arb.pxd +++ b/src/sage/rings/complex_arb.pxd @@ -6,7 +6,7 @@ from sage.rings.ring cimport Field cdef void ComplexIntervalFieldElement_to_acb( acb_t target, - ComplexIntervalFieldElement source) + ComplexIntervalFieldElement source) noexcept cdef int acb_to_ComplexIntervalFieldElement( ComplexIntervalFieldElement target, @@ -14,15 +14,15 @@ cdef int acb_to_ComplexIntervalFieldElement( cdef class ComplexBall(RingElement): cdef acb_t value - cdef ComplexBall _new(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef ComplexIntervalFieldElement _complex_mpfi_(self, parent) - cpdef RealBall real(self) - cpdef RealBall imag(self) - cpdef pow(self, expo, analytic=?) + cdef ComplexBall _new(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef ComplexIntervalFieldElement _complex_mpfi_(self, parent) noexcept + cpdef RealBall real(self) noexcept + cpdef RealBall imag(self) noexcept + cpdef pow(self, expo, analytic=?) noexcept - cdef inline ComplexBall _new(self): + cdef inline ComplexBall _new(self) noexcept: cdef ComplexBall res = ComplexBall.__new__(ComplexBall) res._parent = self._parent return res diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index a22ce3c5e53..f36a89bb229 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -197,7 +197,7 @@ from sage.rings.integer_ring import ZZ cdef void ComplexIntervalFieldElement_to_acb( acb_t target, - ComplexIntervalFieldElement source): + ComplexIntervalFieldElement source) noexcept: """ Convert a :class:`ComplexIntervalFieldElement` to an ``acb``. @@ -250,7 +250,7 @@ cdef class IntegrationContext: cdef object exn_tb cdef int acb_calc_func_callback(acb_ptr out, const acb_t inp, void * param, - long order, long prec): + long order, long prec) noexcept: r""" Callback used for numerical integration @@ -1254,16 +1254,16 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): return res -cdef inline bint _do_sig(long prec): +cdef inline bint _do_sig(long prec) noexcept: """ Whether signal handlers should be installed for calls to arb. """ return (prec > 1000) -cdef inline long prec(ComplexBall ball): +cdef inline long prec(ComplexBall ball) noexcept: return ball._parent._prec -cdef bint arb_contained_unit_interval(arb_t b): +cdef bint arb_contained_unit_interval(arb_t b) noexcept: r""" Test if a real ball is contained in [-1,1]. Useful for dealing with branch cuts of inverse trigonometric functions. @@ -1281,7 +1281,7 @@ cdef bint arb_contained_unit_interval(arb_t b): finally: arb_clear(u) -cdef bint arb_gt_neg_one(arb_t b): +cdef bint arb_gt_neg_one(arb_t b) noexcept: r""" Test if a real ball is contained in [-1,∞). Useful for dealing with branch cuts. @@ -1293,7 +1293,7 @@ cdef bint arb_gt_neg_one(arb_t b): arb_clear(neg_one) return res -cdef inline real_ball_field(ComplexBall ball): +cdef inline real_ball_field(ComplexBall ball) noexcept: return ball._parent._base cdef class ComplexBall(RingElement): @@ -1545,7 +1545,7 @@ cdef class ComplexBall(RingElement): # Conversions - cpdef ComplexIntervalFieldElement _complex_mpfi_(self, parent): + cpdef ComplexIntervalFieldElement _complex_mpfi_(self, parent) noexcept: """ Return :class:`ComplexIntervalFieldElement` of the same value. @@ -1804,7 +1804,7 @@ cdef class ComplexBall(RingElement): # Real and imaginary part, midpoint, radius - cpdef RealBall real(self): + cpdef RealBall real(self) noexcept: """ Return the real part of this ball. @@ -1825,7 +1825,7 @@ cdef class ComplexBall(RingElement): arb_set(r.value, acb_realref(self.value)) return r - cpdef RealBall imag(self): + cpdef RealBall imag(self) noexcept: """ Return the imaginary part of this ball. @@ -2330,7 +2330,7 @@ cdef class ComplexBall(RingElement): """ return acb_is_real(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare ``left`` and ``right``. @@ -2617,7 +2617,7 @@ cdef class ComplexBall(RingElement): acb_conj(res.value, self.value) return res - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Return the sum of two balls, rounded to the ambient field's precision. @@ -2635,7 +2635,7 @@ cdef class ComplexBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ Return the difference of two balls, rounded to the ambient field's precision. @@ -2676,7 +2676,7 @@ cdef class ComplexBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Return the product of two balls, rounded to the ambient field's precision. @@ -2776,7 +2776,7 @@ cdef class ComplexBall(RingElement): raise TypeError("unsupported operand type(s) for >>: '{}' and '{}'" .format(type(val).__name__, type(shift).__name__)) - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Return the quotient of two balls, rounded to the ambient field's precision. @@ -2843,7 +2843,7 @@ cdef class ComplexBall(RingElement): else: return sage.structure.element.bin_op(base, expo, operator.pow) - cpdef pow(self, expo, analytic=False): + cpdef pow(self, expo, analytic=False) noexcept: r""" Raise this ball to the power of ``expo``. diff --git a/src/sage/rings/complex_conversion.pxd b/src/sage/rings/complex_conversion.pxd index 2053005e340..d6144974f9a 100644 --- a/src/sage/rings/complex_conversion.pxd +++ b/src/sage/rings/complex_conversion.pxd @@ -4,4 +4,4 @@ from sage.categories.map cimport Map cdef class CCtoCDF(Map): - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept diff --git a/src/sage/rings/complex_conversion.pyx b/src/sage/rings/complex_conversion.pyx index abf179064c6..e7e53724f9c 100644 --- a/src/sage/rings/complex_conversion.pyx +++ b/src/sage/rings/complex_conversion.pyx @@ -5,7 +5,7 @@ from sage.libs.gsl.complex cimport GSL_SET_COMPLEX cdef class CCtoCDF(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: sage: from sage.rings.complex_conversion import CCtoCDF diff --git a/src/sage/rings/complex_double.pxd b/src/sage/rings/complex_double.pxd index 821b9943b51..789db2ba3ad 100644 --- a/src/sage/rings/complex_double.pxd +++ b/src/sage/rings/complex_double.pxd @@ -11,10 +11,10 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): cdef class ComplexDoubleElement(sage.structure.element.FieldElement): cdef gsl_complex _complex - cdef ComplexDoubleElement _new_c(self, gsl_complex x) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _pow_(self, other) + cdef ComplexDoubleElement _new_c(self, gsl_complex x) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _pow_(self, other) noexcept -cdef ComplexDoubleElement new_ComplexDoubleElement() +cdef ComplexDoubleElement new_ComplexDoubleElement() noexcept diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 8b9883d1279..ed46913433f 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -377,7 +377,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): else: return ComplexDoubleElement(x, 0) - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Return the canonical coerce of `x` into the complex double field, if it is defined, otherwise raise a ``TypeError``. @@ -691,7 +691,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): return Factorization([(x - a, 1) for a in roots], unit) -cdef ComplexDoubleElement new_ComplexDoubleElement(): +cdef ComplexDoubleElement new_ComplexDoubleElement() noexcept: """ Creates a new (empty) :class:`ComplexDoubleElement`. """ @@ -761,7 +761,7 @@ cdef class ComplexDoubleElement(FieldElement): return (ComplexDoubleElement, (GSL_REAL(self._complex), GSL_IMAG(self._complex))) - cdef ComplexDoubleElement _new_c(self, gsl_complex x): + cdef ComplexDoubleElement _new_c(self, gsl_complex x) noexcept: """ C-level code for creating a :class:`ComplexDoubleElement` from a ``gsl_complex``. @@ -786,7 +786,7 @@ cdef class ComplexDoubleElement(FieldElement): """ return hash(complex(self)) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ We order the complex numbers in dictionary order by real parts then imaginary parts. @@ -1158,7 +1158,7 @@ cdef class ComplexDoubleElement(FieldElement): # Arithmetic ####################################################################### - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add ``self`` and ``right``. @@ -1170,7 +1170,7 @@ cdef class ComplexDoubleElement(FieldElement): return self._new_c(gsl_complex_add(self._complex, (right)._complex)) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract ``self`` and ``right``. @@ -1182,7 +1182,7 @@ cdef class ComplexDoubleElement(FieldElement): return self._new_c(gsl_complex_sub(self._complex, (right)._complex)) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply ``self`` and ``right``. @@ -1194,7 +1194,7 @@ cdef class ComplexDoubleElement(FieldElement): return self._new_c(gsl_complex_mul(self._complex, (right)._complex)) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by ``right``. @@ -1228,7 +1228,7 @@ cdef class ComplexDoubleElement(FieldElement): """ return self._new_c(gsl_complex_inverse(self._complex)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ This function returns the negative of the complex number `z`: @@ -1615,7 +1615,7 @@ cdef class ComplexDoubleElement(FieldElement): """ return self.real().is_NaN() or self.imag().is_NaN() - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: r""" The complex number ``self`` raised to the power ``other``. @@ -1681,7 +1681,7 @@ cdef class ComplexDoubleElement(FieldElement): z = other return self._new_c(gsl_complex_pow(self._complex, z._complex)) - cdef _pow_long(self, long other): + cdef _pow_long(self, long other) noexcept: if other == 1: return self elif other == 0: @@ -1697,7 +1697,7 @@ cdef class ComplexDoubleElement(FieldElement): res = gsl_complex_pow_real(self._complex, other) return self._new_c(res) - cpdef _pow_int(self, other): + cpdef _pow_int(self, other) noexcept: if not GSL_IMAG(self._complex): # If self is real, the result should be real too real = GSL_REAL(self._complex) ** other @@ -2515,7 +2515,7 @@ cdef class FloatToCDF(Morphism): R = Set_PythonType(R) Morphism.__init__(self, Hom(R, CDF)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Create an :class:`ComplexDoubleElement`. @@ -2565,7 +2565,7 @@ cdef class ComplexToCDF(Morphism): R = Set_PythonType(R) Morphism.__init__(self, Hom(R, CDF)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Create an :class:`ComplexDoubleElement`. @@ -2619,7 +2619,7 @@ def ComplexDoubleField(): from sage.misc.parser import Parser cdef cdf_parser = Parser(float, float, {"I" : _CDF.gen(), "i" : _CDF.gen()}) -cdef inline double complex extract_double_complex(ComplexDoubleElement x): +cdef inline double complex extract_double_complex(ComplexDoubleElement x) noexcept: """ Return the value of ``x`` as a c99 complex double. """ @@ -2629,7 +2629,7 @@ cdef inline double complex extract_double_complex(ComplexDoubleElement x): return z -cdef inline ComplexDoubleElement ComplexDoubleElement_from_doubles(double re, double im): +cdef inline ComplexDoubleElement ComplexDoubleElement_from_doubles(double re, double im) noexcept: """ Create a new :class:`ComplexDoubleElement` with the specified real and imaginary parts. diff --git a/src/sage/rings/complex_interval.pxd b/src/sage/rings/complex_interval.pxd index b0a64632ad5..56513b65747 100644 --- a/src/sage/rings/complex_interval.pxd +++ b/src/sage/rings/complex_interval.pxd @@ -11,7 +11,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): cdef mpfr_prec_t _prec cdef object _multiplicative_order - cdef inline ComplexIntervalFieldElement _new(self): + cdef inline ComplexIntervalFieldElement _new(self) noexcept: """ Quickly create a new complex interval with the same parent as ``self``. @@ -20,7 +20,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): cdef object _multiplicative_order = None return t.__new__(t, self._parent) - cdef inline RealIntervalFieldElement _new_real(self): + cdef inline RealIntervalFieldElement _new_real(self) noexcept: """ Quickly create a new real interval with the same precision as ``self``. diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index 7fe25fd8114..c38261d136d 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -681,7 +681,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): """ return mpfi_has_zero(self.__re) and mpfi_has_zero(self.__im) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add ``self`` and ``right``. @@ -695,7 +695,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): mpfi_add(x.__im, self.__im, (right).__im) return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract ``self`` by ``right``. @@ -709,7 +709,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): mpfi_sub(x.__im, self.__im, (right).__im) return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply ``self`` and ``right``. @@ -779,7 +779,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): mpfi_clear(t) return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by ``right``. @@ -1512,7 +1512,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): """ return bool(self.real()) or bool(self.imag()) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" As with the real interval fields this never returns false positives. diff --git a/src/sage/rings/complex_mpc.pxd b/src/sage/rings/complex_mpc.pxd index f7d8cb9492c..68fb73f4afa 100644 --- a/src/sage/rings/complex_mpc.pxd +++ b/src/sage/rings/complex_mpc.pxd @@ -6,9 +6,9 @@ cimport sage.rings.ring cdef class MPComplexNumber(sage.structure.element.FieldElement): cdef mpc_t value cdef char init - cdef MPComplexNumber _new(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) + cdef MPComplexNumber _new(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept cdef class MPComplexField_class(sage.rings.ring.Field): cdef readonly int _prec @@ -16,5 +16,5 @@ cdef class MPComplexField_class(sage.rings.ring.Field): cdef object __rnd_str cdef object __real_field cdef object __imag_field - cdef MPComplexNumber _new(self) - cpdef _an_element_(self) + cdef MPComplexNumber _new(self) noexcept + cpdef _an_element_(self) noexcept diff --git a/src/sage/rings/complex_mpc.pyx b/src/sage/rings/complex_mpc.pyx index ae2bd50c735..562286db44e 100644 --- a/src/sage/rings/complex_mpc.pyx +++ b/src/sage/rings/complex_mpc.pyx @@ -118,14 +118,14 @@ _mpc_rounding_modes = [ 'RNDNN', 'RNDZN', 'RNDUN', 'RNDDN', '', '', '', '', '', '', '', '', '', '', '', '', 'RNDDN', 'RNDZD', 'RNDUD', 'RNDDD' ] -cdef inline mpfr_rnd_t rnd_re(mpc_rnd_t rnd): +cdef inline mpfr_rnd_t rnd_re(mpc_rnd_t rnd) noexcept: """ Return the numeric value of the real part rounding mode. This is an internal function. """ return (rnd & 3) -cdef inline mpfr_rnd_t rnd_im(mpc_rnd_t rnd): +cdef inline mpfr_rnd_t rnd_im(mpc_rnd_t rnd) noexcept: """ Return the numeric value of the imaginary part rounding mode. This is an internal function. @@ -145,7 +145,7 @@ complex_ten = '(?P(?P' + sign + r')?\s*(?P' + sign + r')\s*(?P' + imaginary_ten + '))?)' re_complex_ten = re.compile(r'^\s*(?:' + complex_ten + r')\s*$', re.I) -cpdef inline split_complex_string(string, int base=10): +cpdef inline split_complex_string(string, int base=10) noexcept: """ Split and return in that order the real and imaginary parts of a complex in a string. @@ -322,7 +322,7 @@ cdef class MPComplexField_class(sage.rings.ring.Field): ParentWithGens.__init__(self, self._real_field(), ('I',), False, category=Fields().Infinite()) self._populate_coercion_lists_(coerce_list=[MPFRtoMPC(self._real_field(), self)]) - cdef MPComplexNumber _new(self): + cdef MPComplexNumber _new(self) noexcept: """ Return a new complex number with parent ``self`. """ @@ -436,7 +436,7 @@ cdef class MPComplexField_class(sage.rings.ring.Field): zz._set(z) return zz - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Canonical coercion of `z` to this mpc complex field. @@ -538,7 +538,7 @@ cdef class MPComplexField_class(sage.rings.ring.Field): """ return 1 - cpdef _an_element_(self): + cpdef _an_element_(self) noexcept: """ Return an element of this complex field. @@ -698,7 +698,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): A floating point approximation to a complex number using any specified precision common to both real and imaginary part. """ - cdef MPComplexNumber _new(self): + cdef MPComplexNumber _new(self) noexcept: """ Return a new complex number with same parent as ``self``. """ @@ -1258,7 +1258,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): """ return gmpy2.GMPy_MPC_From_mpfr(self.value.re, self.value.im) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare ``self`` to ``other``. @@ -1375,7 +1375,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): # Basic Arithmetic ################################ - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two complex numbers with the same parent. @@ -1390,7 +1390,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): mpc_add(z.value, self.value, (right).value, (self._parent).__rnd) return z - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two complex numbers with the same parent. @@ -1405,7 +1405,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): mpc_sub(z.value, self.value, (right).value, (self._parent).__rnd) return z - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two complex numbers with the same parent. @@ -1420,7 +1420,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): mpc_mul(z.value, self.value, (right).value, (self._parent).__rnd) return z - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide two complex numbers with the same parent. @@ -1439,7 +1439,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): mpc_div(z.value, self.value, x.value, (self._parent).__rnd) return z - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the negative of this complex number. @@ -2391,12 +2391,12 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): mpc_set(res.value, a.value, rnd) return res -cdef inline mp_exp_t min_exp_t(mp_exp_t a, mp_exp_t b): +cdef inline mp_exp_t min_exp_t(mp_exp_t a, mp_exp_t b) noexcept: return a if a < b else b -cdef inline mp_exp_t max_exp_t(mp_exp_t a, mp_exp_t b): +cdef inline mp_exp_t max_exp_t(mp_exp_t a, mp_exp_t b) noexcept: return a if a > b else b -cdef inline mp_exp_t max_exp(MPComplexNumber z): +cdef inline mp_exp_t max_exp(MPComplexNumber z) noexcept: """ Quickly return the maximum exponent of the real and complex parts of ``z``, which is useful for estimating its magnitude. @@ -2444,7 +2444,7 @@ __create_MPComplexNumber_version0 = __create__MPComplexNumber_version0 #***************************************************************************** cdef class MPCtoMPC(Map): - cpdef Element _call_(self, z): + cpdef Element _call_(self, z) noexcept: """ EXAMPLES:: @@ -2481,7 +2481,7 @@ cdef class MPCtoMPC(Map): return MPCtoMPC(self.codomain(), self.domain()) cdef class INTEGERtoMPC(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -2504,7 +2504,7 @@ cdef class INTEGERtoMPC(Map): return y cdef class MPFRtoMPC(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -2528,7 +2528,7 @@ cdef class MPFRtoMPC(Map): return y cdef class CCtoMPC(Map): - cpdef Element _call_(self, z): + cpdef Element _call_(self, z) noexcept: """ EXAMPLES:: diff --git a/src/sage/rings/complex_mpfr.pxd b/src/sage/rings/complex_mpfr.pxd index 9b8c8d08bf4..4aa6de62a69 100644 --- a/src/sage/rings/complex_mpfr.pxd +++ b/src/sage/rings/complex_mpfr.pxd @@ -9,9 +9,9 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): cdef mpfr_prec_t _prec cdef object _multiplicative_order - cpdef _add_(self, other) - cpdef _mul_(self, other) - cdef RealNumber abs_c(ComplexNumber self) - cdef RealNumber norm_c(ComplexNumber self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cdef RealNumber abs_c(ComplexNumber self) noexcept + cdef RealNumber norm_c(ComplexNumber self) noexcept - cdef ComplexNumber _new(self) + cdef ComplexNumber _new(self) noexcept diff --git a/src/sage/rings/complex_mpfr.pyx b/src/sage/rings/complex_mpfr.pyx index 1862cea7bbf..d6f92bb2fee 100644 --- a/src/sage/rings/complex_mpfr.pyx +++ b/src/sage/rings/complex_mpfr.pyx @@ -867,7 +867,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): True """ - cdef ComplexNumber _new(self): + cdef ComplexNumber _new(self) noexcept: """ Quickly creates a new initialized complex number with the same parent as ``self``. @@ -1460,7 +1460,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): import sympy return self.real()._sympy_() + self.imag()._sympy_() * sympy.I - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add ``self`` to ``right``. @@ -1475,7 +1475,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): mpfr_add(x.__im, self.__im, (right).__im, rnd) return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract ``right`` from ``self``. @@ -1490,7 +1490,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): mpfr_sub(x.__im, self.__im, (right).__im, rnd) return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply ``self`` by ``right``. @@ -1559,7 +1559,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): """ return self.norm_c() - cdef RealNumber norm_c(ComplexNumber self): + cdef RealNumber norm_c(ComplexNumber self) noexcept: cdef RealNumber x x = RealNumber(self._parent._real_field(), None) @@ -1576,7 +1576,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): mpfr_clear(t1) return x - cdef RealNumber abs_c(ComplexNumber self): + cdef RealNumber abs_c(ComplexNumber self) noexcept: cdef RealNumber x x = RealNumber(self._parent._real_field(), None) @@ -1594,7 +1594,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): mpfr_clear(t1) return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by ``right``. @@ -1951,7 +1951,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): return complex(mpfr_get_d(self.__re, rnd), mpfr_get_d(self.__im, rnd)) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare ``left`` and ``right``. @@ -3340,7 +3340,7 @@ cdef class RRtoCC(Map): self._zero = ComplexNumber(CC, 0) self._repr_type_str = "Natural" - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ A helper for pickling and copying. @@ -3366,7 +3366,7 @@ cdef class RRtoCC(Map): slots['_zero'] = self._zero return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ A helper for unpickling and copying. @@ -3385,7 +3385,7 @@ cdef class RRtoCC(Map): Map._update_slots(self, _slots) self._zero = _slots['_zero'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -3399,13 +3399,13 @@ cdef class RRtoCC(Map): mpfr_set_ui(z.__im, 0, rnd) return z -cdef inline mp_exp_t min_exp_t(mp_exp_t a, mp_exp_t b): +cdef inline mp_exp_t min_exp_t(mp_exp_t a, mp_exp_t b) noexcept: return a if a < b else b -cdef inline mp_exp_t max_exp_t(mp_exp_t a, mp_exp_t b): +cdef inline mp_exp_t max_exp_t(mp_exp_t a, mp_exp_t b) noexcept: return a if a > b else b -cdef inline mp_exp_t max_exp(ComplexNumber z): +cdef inline mp_exp_t max_exp(ComplexNumber z) noexcept: """ Quickly return the maximum exponent of the real and complex parts of z, which is useful for estimating its magnitude. @@ -3416,7 +3416,7 @@ cdef inline mp_exp_t max_exp(ComplexNumber z): return mpfr_get_exp(z.__im) return max_exp_t(mpfr_get_exp(z.__re), mpfr_get_exp(z.__im)) -cpdef int cmp_abs(ComplexNumber a, ComplexNumber b): +cpdef int cmp_abs(ComplexNumber a, ComplexNumber b) noexcept: """ Return `-1`, `0`, or `1` according to whether `|a|` is less than, equal to, or greater than `|b|`. diff --git a/src/sage/rings/convert/mpfi.pyx b/src/sage/rings/convert/mpfi.pyx index 3ca01ac276f..abef4963bcf 100644 --- a/src/sage/rings/convert/mpfi.pyx +++ b/src/sage/rings/convert/mpfi.pyx @@ -35,7 +35,7 @@ from ..complex_double cimport ComplexDoubleElement from cypari2.gen cimport Gen -cdef inline int return_real(mpfi_ptr im): +cdef inline int return_real(mpfi_ptr im) noexcept: """ Called by ``mpfi_set_sage`` on the imaginary part when converting a real number. diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index d4df0e5ea05..ad0b735eaaa 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -30,7 +30,7 @@ from sage.misc.misc_c import prod cdef extern from "limits.h": long LONG_MAX -cpdef aurifeuillian(n, m, F=None, bint check=True): +cpdef aurifeuillian(n, m, F=None, bint check=True) noexcept: r""" Return the Aurifeuillian factors `F_n^\pm(m^2n)`. @@ -114,7 +114,7 @@ cpdef aurifeuillian(n, m, F=None, bint check=True): assert (not check or Fm.divides(F)) return [Fm, F // Fm] -cpdef factor_aurifeuillian(n, check=True): +cpdef factor_aurifeuillian(n, check=True) noexcept: r""" Return Aurifeuillian factors of `n` if `n = x^{(2k-1)x} \pm 1` (where the sign is '-' if x = 1 mod 4, and '+' otherwise) else `n` @@ -245,7 +245,7 @@ def factor_cunningham(m, proof=None): else: return IntegerFactorization(L)*n.factor(proof=proof) -cpdef factor_trial_division(m, long limit=LONG_MAX): +cpdef factor_trial_division(m, long limit=LONG_MAX) noexcept: r""" Return partial factorization of ``self`` obtained using trial division for all primes up to ``limit``, where ``limit`` must fit in a C ``signed long``. diff --git a/src/sage/rings/fast_arith.pxd b/src/sage/rings/fast_arith.pxd index 7a99e658b91..c13e5e36548 100644 --- a/src/sage/rings/fast_arith.pxd +++ b/src/sage/rings/fast_arith.pxd @@ -1,4 +1,4 @@ -cpdef prime_range(start, stop=*, algorithm=*, bint py_ints=*) +cpdef prime_range(start, stop=*, algorithm=*, bint py_ints=*) noexcept cdef class arith_int: cdef int abs_int(self, int x) except -1 diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx index 0eca810920e..5d43ed41c6f 100644 --- a/src/sage/rings/fast_arith.pyx +++ b/src/sage/rings/fast_arith.pyx @@ -40,7 +40,7 @@ from libc.math cimport sqrt from sage.rings.integer cimport Integer -cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): +cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False) noexcept: r""" Return a list of all primes between ``start`` and ``stop - 1``, inclusive. diff --git a/src/sage/rings/finite_rings/element_base.pxd b/src/sage/rings/finite_rings/element_base.pxd index c214e4745a9..ec09f9cc769 100644 --- a/src/sage/rings/finite_rings/element_base.pxd +++ b/src/sage/rings/finite_rings/element_base.pxd @@ -8,5 +8,5 @@ cdef class FinitePolyExtElement(FiniteRingElement): pass cdef class Cache_base(SageObject): - cpdef FinitePolyExtElement fetch_int(self, number) + cpdef FinitePolyExtElement fetch_int(self, number) noexcept diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index e9ab5b5d4ab..beeae9fa4c9 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -1077,7 +1077,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): integer_representation = deprecated_function_alias(33941, to_integer) cdef class Cache_base(SageObject): - cpdef FinitePolyExtElement fetch_int(self, number): + cpdef FinitePolyExtElement fetch_int(self, number) noexcept: r""" Given an integer less than `p^n` with base `2` representation `a_0 + a_1 \cdot 2 + \cdots + a_k 2^k`, this returns diff --git a/src/sage/rings/finite_rings/element_givaro.pxd b/src/sage/rings/finite_rings/element_givaro.pxd index c4d16de21f5..1e5c4b46527 100644 --- a/src/sage/rings/finite_rings/element_givaro.pxd +++ b/src/sage/rings/finite_rings/element_givaro.pxd @@ -62,7 +62,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): cdef int element cdef Cache_givaro _cache cdef object _multiplicative_order - cdef FiniteField_givaroElement _new_c(self, int value) + cdef FiniteField_givaroElement _new_c(self, int value) noexcept cdef class Cache_givaro(Cache_base): cdef GivaroGfq *objectptr # C++ object @@ -73,13 +73,13 @@ cdef class Cache_givaro(Cache_base): cdef bint _has_array cdef bint _is_conway cdef Parent parent - cdef gen_array(self) - cpdef int exponent(self) - cpdef int order_c(self) - cpdef int characteristic(self) - cpdef FiniteField_givaroElement gen(self) - cpdef FiniteField_givaroElement element_from_data(self, e) - cdef FiniteField_givaroElement _new_c(self, int value) + cdef gen_array(self) noexcept + cpdef int exponent(self) noexcept + cpdef int order_c(self) noexcept + cpdef int characteristic(self) noexcept + cpdef FiniteField_givaroElement gen(self) noexcept + cpdef FiniteField_givaroElement element_from_data(self, e) noexcept + cdef FiniteField_givaroElement _new_c(self, int value) noexcept cpdef int int_to_log(self, int i) except -1 cpdef int log_to_int(self, int i) except -1 @@ -87,4 +87,4 @@ cdef class FiniteField_givaro_iterator: cdef int iterator cdef Cache_givaro _cache -cdef FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x) +cdef FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x) noexcept diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx index ead2551ded5..0483b4949e7 100644 --- a/src/sage/rings/finite_rings/element_givaro.pyx +++ b/src/sage/rings/finite_rings/element_givaro.pyx @@ -76,7 +76,7 @@ cdef object MPolynomial cdef object Polynomial -cdef void late_import(): +cdef void late_import() noexcept: """ Late import of modules """ @@ -208,7 +208,7 @@ cdef class Cache_givaro(Cache_base): self._array = self.gen_array() self._has_array = True - cdef gen_array(self): + cdef gen_array(self) noexcept: """ Generates an array/list/tuple containing all elements of ``self`` indexed by their power with respect to the internal generator. @@ -226,7 +226,7 @@ cdef class Cache_givaro(Cache_base): """ delete(self.objectptr) - cpdef int characteristic(self): + cpdef int characteristic(self) noexcept: """ Return the characteristic of this field. @@ -249,7 +249,7 @@ cdef class Cache_givaro(Cache_base): """ return Integer(self.order_c()) - cpdef int order_c(self): + cpdef int order_c(self) noexcept: """ Return the order of this field. @@ -261,7 +261,7 @@ cdef class Cache_givaro(Cache_base): """ return self.objectptr.cardinality() - cpdef int exponent(self): + cpdef int exponent(self) noexcept: r""" Return the degree of this field over `\GF{p}`. @@ -295,7 +295,7 @@ cdef class Cache_givaro(Cache_base): self.objectptr.random(generator, res) return make_FiniteField_givaroElement(self, res) - cpdef FiniteField_givaroElement element_from_data(self, e): + cpdef FiniteField_givaroElement element_from_data(self, e) noexcept: """ Coerces several data types to ``self``. @@ -466,7 +466,7 @@ cdef class Cache_givaro(Cache_base): return make_FiniteField_givaroElement(self, res) - cpdef FiniteField_givaroElement gen(self): + cpdef FiniteField_givaroElement gen(self) noexcept: """ Return a generator of the field. @@ -546,7 +546,7 @@ cdef class Cache_givaro(Cache_base): sig_off() return r - cpdef FiniteField_givaroElement fetch_int(self, number): + cpdef FiniteField_givaroElement fetch_int(self, number) noexcept: r""" Given an integer ``n`` return a finite field element in ``self`` which equals ``n`` under the condition that :meth:`gen()` is set to @@ -754,7 +754,7 @@ cdef class Cache_givaro(Cache_base): rep = 'int' return unpickle_Cache_givaro, (self.parent, p, k, self.parent.polynomial(), rep, self._has_array) - cdef FiniteField_givaroElement _new_c(self, int value): + cdef FiniteField_givaroElement _new_c(self, int value) noexcept: return make_FiniteField_givaroElement(self, value) @@ -872,7 +872,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): self._cache = parent._cache self.element = 0 - cdef FiniteField_givaroElement _new_c(self, int value): + cdef FiniteField_givaroElement _new_c(self, int value) noexcept: return make_FiniteField_givaroElement(self._cache, value) def __dealloc__(FiniteField_givaroElement self): @@ -1076,7 +1076,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): else: raise ValueError("must be a perfect square.") - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two elements. @@ -1091,7 +1091,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): (right).element) return make_FiniteField_givaroElement(self._cache, r) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two elements. @@ -1108,7 +1108,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): (right).element) return make_FiniteField_givaroElement(self._cache, r) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide two elements @@ -1130,7 +1130,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): (right).element) return make_FiniteField_givaroElement(self._cache, r) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two elements. @@ -1281,7 +1281,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): return make_FiniteField_givaroElement(cache, cache.objectptr.one) return make_FiniteField_givaroElement(cache, r) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Comparison of finite field elements is correct or equality tests and somewhat random for ``<`` and ``>`` type of @@ -1738,7 +1738,7 @@ def unpickle_FiniteField_givaroElement(parent, int x): from sage.misc.persist import register_unpickle_override register_unpickle_override('sage.rings.finite_field_givaro', 'unpickle_FiniteField_givaroElement', unpickle_FiniteField_givaroElement) -cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x): +cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x) noexcept: cdef FiniteField_givaroElement y if cache._has_array: diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pxd b/src/sage/rings/finite_rings/element_ntl_gf2e.pxd index e98744413b5..b699f6e3ef6 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pxd +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pxd @@ -13,9 +13,9 @@ cdef class Cache_ntl_gf2e(Cache_base): cdef public FiniteField_ntl_gf2eElement _gen cdef Integer _order cdef Integer _degree - cdef FiniteField_ntl_gf2eElement _new(self) + cdef FiniteField_ntl_gf2eElement _new(self) noexcept cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): cdef GF2E_c x cdef Cache_ntl_gf2e _cache - cdef FiniteField_ntl_gf2eElement _new(FiniteField_ntl_gf2eElement self) + cdef FiniteField_ntl_gf2eElement _new(FiniteField_ntl_gf2eElement self) noexcept diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index 7c5ab521b7a..ef41e6d8dc1 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -96,10 +96,10 @@ cdef int late_import() except -1: cdef extern from "arpa/inet.h": unsigned int htonl(unsigned int) -cdef little_endian(): +cdef little_endian() noexcept: return htonl(1) != 1 -cdef unsigned int switch_endianess(unsigned int i): +cdef unsigned int switch_endianess(unsigned int i) noexcept: cdef size_t j cdef unsigned int ret = 0 for j in range(sizeof(int)): @@ -205,7 +205,7 @@ cdef class Cache_ntl_gf2e(Cache_base): mod_poly = GF2XModulus_GF2X(modulus) print(ccrepr(mod_poly)) - cdef FiniteField_ntl_gf2eElement _new(self): + cdef FiniteField_ntl_gf2eElement _new(self) noexcept: """ Return a new element in ``self``. Use this method to construct 'empty' elements. @@ -374,7 +374,7 @@ cdef class Cache_ntl_gf2e(Cache_base): raise ValueError("Cannot coerce element %s to this field." % e) - cpdef FiniteField_ntl_gf2eElement fetch_int(self, number): + cpdef FiniteField_ntl_gf2eElement fetch_int(self, number) noexcept: r""" Given an integer less than `p^n` with base `2` representation `a_0 + a_1 \cdot 2 + \cdots + a_k 2^k`, this returns @@ -508,7 +508,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): self._parent = parent (self._parent._cache).F.restore() - cdef FiniteField_ntl_gf2eElement _new(FiniteField_ntl_gf2eElement self): + cdef FiniteField_ntl_gf2eElement _new(FiniteField_ntl_gf2eElement self) noexcept: cdef FiniteField_ntl_gf2eElement y (self._parent._cache).F.restore() y = FiniteField_ntl_gf2eElement.__new__(FiniteField_ntl_gf2eElement) @@ -654,7 +654,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): else: return a - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two elements. @@ -670,7 +670,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): GF2E_add(r.x, (self).x, (right).x) return r - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two elements. @@ -686,7 +686,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): GF2E_mul(r.x, (self).x, (right).x) return r - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Divide two elements. @@ -709,7 +709,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): GF2E_div(r.x, self.x, o.x) return r - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two elements. @@ -758,7 +758,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): cdef FiniteField_ntl_gf2eElement o = self._parent._cache._one_element return o._div_(self) - cdef _pow_long(self, long n): + cdef _pow_long(self, long n) noexcept: """ EXAMPLES:: @@ -797,7 +797,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): GF2E_power(r.x, self.x, n) return r - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Comparison of finite field elements. diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pxd b/src/sage/rings/finite_rings/element_pari_ffelt.pxd index 0b66436dcd4..f80aeb55532 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pxd +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pxd @@ -7,6 +7,6 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): # This holds a reference to a PARI clone. cdef GEN val - cdef FiniteFieldElement_pari_ffelt _new(self) - cdef void construct(self, GEN g) + cdef FiniteFieldElement_pari_ffelt _new(self) noexcept + cdef void construct(self, GEN g) noexcept cdef int construct_from(self, x) except -1 diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 2d29f424e3b..792aa9ce257 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -345,7 +345,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): if self.val is not NULL: gunclone_deep(self.val) - cdef FiniteFieldElement_pari_ffelt _new(self): + cdef FiniteFieldElement_pari_ffelt _new(self) noexcept: """ Create an empty element with the same parent as ``self``. """ @@ -354,7 +354,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): x._parent = self._parent return x - cdef void construct(self, GEN g): + cdef void construct(self, GEN g) noexcept: """ Initialise ``self`` to the FFELT ``g``, reset the PARI stack, and call sig_off(). @@ -599,7 +599,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): # immutable return self - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Comparison of finite field elements. @@ -659,7 +659,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): sig_off() return rich_to_bool(op, r) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Addition. @@ -675,7 +675,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): (right).val)) return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtraction. @@ -691,7 +691,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): (right).val)) return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiplication. @@ -707,7 +707,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): (right).val)) return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Division. diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index 4e799ad57e8..c60f3d2ec07 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -1316,7 +1316,7 @@ cdef class FiniteField(Field): return V, phi, psi - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: r""" Canonical coercion to ``self``. @@ -1387,7 +1387,7 @@ cdef class FiniteField(Field): and hasattr(self, '_prefix') and hasattr(R, '_prefix')): return R.hom((self.gen() ** ((self.order() - 1)//(R.order() - 1)),)) - cpdef _convert_map_from_(self, R): + cpdef _convert_map_from_(self, R) noexcept: """ Conversion from p-adic fields. diff --git a/src/sage/rings/finite_rings/hom_finite_field.pxd b/src/sage/rings/finite_rings/hom_finite_field.pxd index 199d655d6d6..64da809024f 100644 --- a/src/sage/rings/finite_rings/hom_finite_field.pxd +++ b/src/sage/rings/finite_rings/hom_finite_field.pxd @@ -11,7 +11,7 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens): cdef _gen cdef _section_class - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic): @@ -19,4 +19,4 @@ cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic): cdef long _degree_fixed cdef long _order - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept diff --git a/src/sage/rings/finite_rings/hom_finite_field.pyx b/src/sage/rings/finite_rings/hom_finite_field.pyx index fa38753d79f..5f54c04dd36 100644 --- a/src/sage/rings/finite_rings/hom_finite_field.pyx +++ b/src/sage/rings/finite_rings/hom_finite_field.pyx @@ -121,7 +121,7 @@ cdef class SectionFiniteFieldHomomorphism_generic(Section): """ A class implementing sections of embeddings between finite fields. """ - cpdef Element _call_(self, x): # Not optimized + cpdef Element _call_(self, x) noexcept: # Not optimized """ TESTS:: @@ -291,7 +291,7 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens): """ return self.domain()._latex_() + " \\hookrightarrow " + self.codomain()._latex_() - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -426,7 +426,7 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens): """ return Morphism.__hash__(self) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: r""" Helper function for copying and pickling @@ -454,7 +454,7 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens): slots['_section_class'] = self._section_class return slots - cdef _update_slots(self, dict slots): + cdef _update_slots(self, dict slots) noexcept: r""" Helper function for copying and pickling @@ -609,7 +609,7 @@ cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic): return s - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -830,7 +830,7 @@ cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic): """ return Morphism.__hash__(self) - cdef _update_slots(self, dict slots): + cdef _update_slots(self, dict slots) noexcept: r""" Helper function for copying and pickling diff --git a/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd b/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd index eec5a6d299d..62898386212 100644 --- a/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd +++ b/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd @@ -11,7 +11,7 @@ cdef class SectionFiniteFieldHomomorphism_givaro(SectionFiniteFieldHomomorphism_ cdef long _power cdef Cache_givaro _codomain_cache - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept cdef class FiniteFieldHomomorphism_givaro(FiniteFieldHomomorphism_generic): @@ -20,7 +20,7 @@ cdef class FiniteFieldHomomorphism_givaro(FiniteFieldHomomorphism_generic): cdef long _power cdef Cache_givaro _codomain_cache - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept cdef class FrobeniusEndomorphism_givaro(FrobeniusEndomorphism_finite_field): diff --git a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx index aae6c84ab25..21036266df1 100644 --- a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx +++ b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx @@ -96,7 +96,7 @@ cdef class SectionFiniteFieldHomomorphism_givaro(SectionFiniteFieldHomomorphism_ self._codomain_cache = ((self._codomain.gen()))._cache - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -174,7 +174,7 @@ cdef class FiniteFieldHomomorphism_givaro(FiniteFieldHomomorphism_generic): self._order_codomain = codomain.cardinality() - 1 - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -263,7 +263,7 @@ cdef class FrobeniusEndomorphism_givaro(FrobeniusEndomorphism_finite_field): # copied from element_givaro.pyx -cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x): +cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x) noexcept: cdef FiniteField_givaroElement y if cache._has_array: diff --git a/src/sage/rings/finite_rings/hom_prime_finite_field.pyx b/src/sage/rings/finite_rings/hom_prime_finite_field.pyx index e141120d918..6bc38546612 100644 --- a/src/sage/rings/finite_rings/hom_prime_finite_field.pyx +++ b/src/sage/rings/finite_rings/hom_prime_finite_field.pyx @@ -35,7 +35,7 @@ from sage.rings.finite_rings.finite_field_base import FiniteField cdef class SectionFiniteFieldHomomorphism_prime(SectionFiniteFieldHomomorphism_generic): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: try: return self._codomain._element_constructor(x) except TypeError: @@ -75,7 +75,7 @@ cdef class FiniteFieldHomomorphism_prime(FiniteFieldHomomorphism_generic): FiniteFieldHomomorphism_generic.__init__(self, parent, im_gens, base_map=base_map, check=check, section_class=section_class) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -104,7 +104,7 @@ cdef class FrobeniusEndomorphism_prime(FrobeniusEndomorphism_finite_field): self._order = 1 self._power = 0 - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: diff --git a/src/sage/rings/finite_rings/integer_mod.pxd b/src/sage/rings/finite_rings/integer_mod.pxd index 351ffa25e1b..5d16bad880e 100644 --- a/src/sage/rings/finite_rings/integer_mod.pxd +++ b/src/sage/rings/finite_rings/integer_mod.pxd @@ -10,7 +10,7 @@ cdef class NativeIntStruct: cdef int_fast64_t int64 cdef readonly list table # list of elements of IntegerModRing(n) cdef readonly list inverses # list of inverses (None if not invertible) - cdef inline type element_class(self): + cdef inline type element_class(self) noexcept: if self.int32 > 0: return IntegerMod_int elif self.int64 > 0: @@ -21,35 +21,35 @@ cdef class NativeIntStruct: cdef class IntegerMod_abstract(FiniteRingElement): cdef NativeIntStruct _modulus - cdef _new_c_from_long(self, long value) - cdef IntegerMod_abstract _new_c_fast(self, unsigned long value) - cdef void set_from_mpz(self, mpz_t value) - cdef void set_from_long(self, long value) - cdef void set_from_ulong_fast(self, unsigned long value) + cdef _new_c_from_long(self, long value) noexcept + cdef IntegerMod_abstract _new_c_fast(self, unsigned long value) noexcept + cdef void set_from_mpz(self, mpz_t value) noexcept + cdef void set_from_long(self, long value) noexcept + cdef void set_from_ulong_fast(self, unsigned long value) noexcept cdef bint is_square_c(self) except -2 - cpdef bint is_one(self) - cpdef bint is_unit(self) - cpdef _floordiv_(self, other) + cpdef bint is_one(self) noexcept + cpdef bint is_unit(self) noexcept + cpdef _floordiv_(self, other) noexcept cdef class IntegerMod_gmp(IntegerMod_abstract): cdef mpz_t value - cdef IntegerMod_gmp _new_c(self) - cdef shift(IntegerMod_gmp self, long k) + cdef IntegerMod_gmp _new_c(self) noexcept + cdef shift(IntegerMod_gmp self, long k) noexcept cdef class IntegerMod_int(IntegerMod_abstract): cdef int_fast32_t ivalue - cdef void set_from_int(IntegerMod_int self, int_fast32_t value) - cdef int_fast32_t get_int_value(IntegerMod_int self) - cdef IntegerMod_int _new_c(self, int_fast32_t value) - cdef shift(IntegerMod_int self, int k) + cdef void set_from_int(IntegerMod_int self, int_fast32_t value) noexcept + cdef int_fast32_t get_int_value(IntegerMod_int self) noexcept + cdef IntegerMod_int _new_c(self, int_fast32_t value) noexcept + cdef shift(IntegerMod_int self, int k) noexcept cdef class IntegerMod_int64(IntegerMod_abstract): cdef int_fast64_t ivalue - cdef void set_from_int(IntegerMod_int64 self, int_fast64_t value) - cdef int_fast64_t get_int_value(IntegerMod_int64 self) - cdef IntegerMod_int64 _new_c(self, int_fast64_t value) - cdef shift(IntegerMod_int64 self, int k) + cdef void set_from_int(IntegerMod_int64 self, int_fast64_t value) noexcept + cdef int_fast64_t get_int_value(IntegerMod_int64 self) noexcept + cdef IntegerMod_int64 _new_c(self, int_fast64_t value) noexcept + cdef shift(IntegerMod_int64 self, int k) noexcept cdef int_fast32_t mod_inverse_int(int_fast32_t x, int_fast32_t n) except 0 -cdef bint use_32bit_type(int_fast64_t modulus) +cdef bint use_32bit_type(int_fast64_t modulus) noexcept diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index 4fb4656cdd2..b2cd1a1fa24 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -78,7 +78,7 @@ from libc.math cimport log2, ceil from sage.libs.gmp.all cimport * -cdef bint use_32bit_type(int_fast64_t modulus): +cdef bint use_32bit_type(int_fast64_t modulus) noexcept: return modulus <= INTEGER_MOD_INT32_LIMIT from sage.arith.long cimport ( @@ -219,7 +219,7 @@ def is_IntegerMod(x): return isinstance(x, IntegerMod_abstract) -cdef inline inverse_or_None(x): +cdef inline inverse_or_None(x) noexcept: try: return ~x except ArithmeticError: @@ -393,7 +393,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): raise self.set_from_mpz(z.value) - cdef IntegerMod_abstract _new_c_fast(self, unsigned long value): + cdef IntegerMod_abstract _new_c_fast(self, unsigned long value) noexcept: cdef type t = type(self) x = t.__new__(t) x._parent = self._parent @@ -401,7 +401,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): x.set_from_ulong_fast(value) return x - cdef _new_c_from_long(self, long value): + cdef _new_c_from_long(self, long value) noexcept: cdef type t = type(self) cdef IntegerMod_abstract x = t.__new__(t) x._parent = self._parent @@ -409,13 +409,13 @@ cdef class IntegerMod_abstract(FiniteRingElement): x.set_from_long(value) return x - cdef void set_from_mpz(self, mpz_t value): + cdef void set_from_mpz(self, mpz_t value) noexcept: raise NotImplementedError("must be defined in child class") - cdef void set_from_long(self, long value): + cdef void set_from_long(self, long value) noexcept: raise NotImplementedError("must be defined in child class") - cdef void set_from_ulong_fast(self, unsigned long value): + cdef void set_from_ulong_fast(self, unsigned long value) noexcept: """ Set ``self`` to the value in ``value`` where ``value`` is assumed to be less than the modulus @@ -999,10 +999,10 @@ cdef class IntegerMod_abstract(FiniteRingElement): else: return x - n - cpdef bint is_one(self): + cpdef bint is_one(self) noexcept: raise NotImplementedError - cpdef bint is_unit(self): + cpdef bint is_unit(self) noexcept: raise NotImplementedError @coerce_binop @@ -1916,7 +1916,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): return infinity return r - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Exact division for prime moduli, for compatibility with other fields. @@ -1975,7 +1975,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): def __cinit__(self): mpz_init(self.value) - cdef IntegerMod_gmp _new_c(self): + cdef IntegerMod_gmp _new_c(self) noexcept: cdef IntegerMod_gmp x x = IntegerMod_gmp.__new__(IntegerMod_gmp) x._modulus = self._modulus @@ -1985,12 +1985,12 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): def __dealloc__(self): mpz_clear(self.value) - cdef void set_from_mpz(self, mpz_t value): + cdef void set_from_mpz(self, mpz_t value) noexcept: cdef sage.rings.integer.Integer modulus modulus = self._modulus.sageInteger mpz_mod(self.value, value, modulus.value) - cdef void set_from_long(self, long value): + cdef void set_from_long(self, long value) noexcept: r""" EXAMPLES:: @@ -2001,7 +2001,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_set_si(self.value, value) mpz_mod(self.value, self.value, self._modulus.sageInteger.value) - cdef void set_from_ulong_fast(self, unsigned long value): + cdef void set_from_ulong_fast(self, unsigned long value) noexcept: mpz_set_ui(self.value, value) def __lshift__(IntegerMod_gmp self, k): @@ -2032,7 +2032,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): """ return self.shift(-long(k)) - cdef shift(IntegerMod_gmp self, long k): + cdef shift(IntegerMod_gmp self, long k) noexcept: r""" Performs a bit-shift specified by ``k`` on ``self``. @@ -2074,7 +2074,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_fdiv_q_2exp(x.value, self.value, -k) return x - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ EXAMPLES:: @@ -2089,7 +2089,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): i = mpz_cmp((left).value, (right).value) return rich_to_bool_sgn(op, i) - cpdef bint is_one(IntegerMod_gmp self): + cpdef bint is_one(IntegerMod_gmp self) noexcept: """ Returns ``True`` if this is `1`, otherwise ``False``. @@ -2117,7 +2117,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): """ return mpz_cmp_si(self.value, 0) != 0 - cpdef bint is_unit(self): + cpdef bint is_unit(self) noexcept: """ Return ``True`` iff this element is a unit. @@ -2175,7 +2175,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): # immutable return self - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ EXAMPLES:: @@ -2190,7 +2190,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_sub(x.value, x.value, self._modulus.sageInteger.value) return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -2205,7 +2205,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_add(x.value, x.value, self._modulus.sageInteger.value) return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: @@ -2221,7 +2221,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_sub(x.value, self._modulus.sageInteger.value, self.value) return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -2235,7 +2235,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): mpz_fdiv_r(x.value, x.value, self._modulus.sageInteger.value) return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ EXAMPLES:: @@ -2419,7 +2419,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): True """ - cdef IntegerMod_int _new_c(self, int_fast32_t value): + cdef IntegerMod_int _new_c(self, int_fast32_t value) noexcept: if self._modulus.table is not None: return self._modulus.table[value] cdef IntegerMod_int x = IntegerMod_int.__new__(IntegerMod_int) @@ -2428,18 +2428,18 @@ cdef class IntegerMod_int(IntegerMod_abstract): x.ivalue = value return x - cdef void set_from_mpz(self, mpz_t value): + cdef void set_from_mpz(self, mpz_t value) noexcept: self.ivalue = mpz_fdiv_ui(value, self._modulus.int32) - cdef void set_from_long(self, long value): + cdef void set_from_long(self, long value) noexcept: self.ivalue = value % self._modulus.int32 if self.ivalue < 0: self.ivalue += self._modulus.int32 - cdef void set_from_ulong_fast(self, unsigned long value): + cdef void set_from_ulong_fast(self, unsigned long value) noexcept: self.ivalue = value - cdef void set_from_int(IntegerMod_int self, int_fast32_t ivalue): + cdef void set_from_int(IntegerMod_int self, int_fast32_t ivalue) noexcept: if ivalue < 0: self.ivalue = self._modulus.int32 + (ivalue % self._modulus.int32) elif ivalue >= self._modulus.int32: @@ -2447,10 +2447,10 @@ cdef class IntegerMod_int(IntegerMod_abstract): else: self.ivalue = ivalue - cdef int_fast32_t get_int_value(IntegerMod_int self): + cdef int_fast32_t get_int_value(IntegerMod_int self) noexcept: return self.ivalue - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ EXAMPLES:: @@ -2472,7 +2472,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): else: return rich_to_bool(op, 1) - cpdef bint is_one(IntegerMod_int self): + cpdef bint is_one(IntegerMod_int self) noexcept: """ Returns ``True`` if this is `1`, otherwise ``False``. @@ -2504,7 +2504,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): """ return self.ivalue != 0 - cpdef bint is_unit(IntegerMod_int self): + cpdef bint is_unit(IntegerMod_int self) noexcept: """ Return ``True`` iff this element is a unit @@ -2574,7 +2574,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): # immutable return self - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ EXAMPLES:: @@ -2588,7 +2588,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): x = x - self._modulus.int32 return self._new_c(x) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -2602,7 +2602,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): x = x + self._modulus.int32 return self._new_c(x) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: @@ -2615,7 +2615,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): return self return self._new_c(self._modulus.int32 - self.ivalue) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -2625,7 +2625,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): """ return self._new_c((self.ivalue * (right).ivalue) % self._modulus.int32) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ EXAMPLES:: @@ -2698,7 +2698,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): """ return self.shift(-int(k)) - cdef shift(IntegerMod_int self, int k): + cdef shift(IntegerMod_int self, int k) noexcept: """ Performs a bit-shift specified by ``k`` on ``self``. @@ -3089,7 +3089,7 @@ cdef class IntegerMod_int(IntegerMod_abstract): ### End of class -cdef int_fast32_t gcd_int(int_fast32_t a, int_fast32_t b): +cdef int_fast32_t gcd_int(int_fast32_t a, int_fast32_t b) noexcept: """ Returns the gcd of a and b @@ -3145,7 +3145,7 @@ cdef int_fast32_t mod_inverse_int(int_fast32_t x, int_fast32_t n) except 0: raise ZeroDivisionError(f"inverse of Mod({x}, {n}) does not exist") -cdef int_fast32_t mod_pow_int(int_fast32_t base, int_fast32_t exp, int_fast32_t n): +cdef int_fast32_t mod_pow_int(int_fast32_t base, int_fast32_t exp, int_fast32_t n) noexcept: """ Returns base^exp mod n @@ -3251,7 +3251,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): - Robert Bradshaw (2006-09-14) """ - cdef IntegerMod_int64 _new_c(self, int_fast64_t value): + cdef IntegerMod_int64 _new_c(self, int_fast64_t value) noexcept: cdef IntegerMod_int64 x x = IntegerMod_int64.__new__(IntegerMod_int64) x._modulus = self._modulus @@ -3259,18 +3259,18 @@ cdef class IntegerMod_int64(IntegerMod_abstract): x.ivalue = value return x - cdef void set_from_mpz(self, mpz_t value): + cdef void set_from_mpz(self, mpz_t value) noexcept: self.ivalue = mpz_fdiv_ui(value, self._modulus.int64) - cdef void set_from_long(self, long value): + cdef void set_from_long(self, long value) noexcept: self.ivalue = value % self._modulus.int64 if self.ivalue < 0: self.ivalue += self._modulus.int64 - cdef void set_from_ulong_fast(self, unsigned long value): + cdef void set_from_ulong_fast(self, unsigned long value) noexcept: self.ivalue = value - cdef void set_from_int(IntegerMod_int64 self, int_fast64_t ivalue): + cdef void set_from_int(IntegerMod_int64 self, int_fast64_t ivalue) noexcept: if ivalue < 0: self.ivalue = self._modulus.int64 + (ivalue % self._modulus.int64) # Is ivalue % self._modulus.int64 actually negative? elif ivalue >= self._modulus.int64: @@ -3278,10 +3278,10 @@ cdef class IntegerMod_int64(IntegerMod_abstract): else: self.ivalue = ivalue - cdef int_fast64_t get_int_value(IntegerMod_int64 self): + cdef int_fast64_t get_int_value(IntegerMod_int64 self) noexcept: return self.ivalue - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ EXAMPLES:: @@ -3303,7 +3303,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): else: return rich_to_bool(op, 1) - cpdef bint is_one(IntegerMod_int64 self): + cpdef bint is_one(IntegerMod_int64 self) noexcept: """ Returns ``True`` if this is `1`, otherwise ``False``. @@ -3331,7 +3331,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): """ return self.ivalue != 0 - cpdef bint is_unit(IntegerMod_int64 self): + cpdef bint is_unit(IntegerMod_int64 self) noexcept: """ Return ``True`` iff this element is a unit. @@ -3410,7 +3410,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): # immutable return self - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ EXAMPLES:: @@ -3424,7 +3424,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): x = x - self._modulus.int64 return self._new_c(x) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -3438,7 +3438,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): x = x + self._modulus.int64 return self._new_c(x) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ EXAMPLES:: @@ -3451,7 +3451,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): return self return self._new_c(self._modulus.int64 - self.ivalue) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -3462,7 +3462,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): return self._new_c((self.ivalue * (right).ivalue) % self._modulus.int64) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ EXAMPLES:: @@ -3518,7 +3518,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract): """ return self.shift(-int(k)) - cdef shift(IntegerMod_int64 self, int k): + cdef shift(IntegerMod_int64 self, int k) noexcept: """ Performs a bit-shift specified by ``k`` on ``self``. @@ -3765,7 +3765,7 @@ cdef int mpz_pow_helper(mpz_t res, mpz_t base, object exp, mpz_t modulus) except if not mpz_invert(res, res, modulus): raise ZeroDivisionError("Inverse does not exist.") -cdef int_fast64_t gcd_int64(int_fast64_t a, int_fast64_t b): +cdef int_fast64_t gcd_int64(int_fast64_t a, int_fast64_t b) noexcept: """ Returns the gcd of a and b @@ -3819,7 +3819,7 @@ cdef int_fast64_t mod_inverse_int64(int_fast64_t x, int_fast64_t n) except 0: raise ZeroDivisionError(f"inverse of Mod({x}, {n}) does not exist") -cdef int_fast64_t mod_pow_int64(int_fast64_t base, int_fast64_t exp, int_fast64_t n): +cdef int_fast64_t mod_pow_int64(int_fast64_t base, int_fast64_t exp, int_fast64_t n) noexcept: """ Returns base^exp mod n @@ -3994,7 +3994,7 @@ def square_root_mod_prime_power(IntegerMod_abstract a, p, e): x *= p**(val//2) return x -cpdef square_root_mod_prime(IntegerMod_abstract a, p=None): +cpdef square_root_mod_prime(IntegerMod_abstract a, p=None) noexcept: r""" Calculates the square root of `a`, where `a` is an integer mod `p`; if `a` is not a perfect square, @@ -4269,7 +4269,7 @@ cdef class IntegerMod_hom(Morphism): self.zero = C._element_constructor_(0) self.modulus = C._pyx_order - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for pickling and copying. @@ -4296,7 +4296,7 @@ cdef class IntegerMod_hom(Morphism): slots['modulus'] = self.modulus return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for pickling and copying. @@ -4324,7 +4324,7 @@ cdef class IntegerMod_hom(Morphism): self.zero = _slots['zero'] self.modulus = _slots['modulus'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: return IntegerMod(self._codomain, x) cdef class IntegerMod_to_IntegerMod(IntegerMod_hom): @@ -4355,7 +4355,7 @@ cdef class IntegerMod_to_IntegerMod(IntegerMod_hom): import sage.categories.homset IntegerMod_hom.__init__(self, sage.categories.homset.Hom(R, S)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: cdef IntegerMod_abstract a zero = self.zero cdef unsigned long value @@ -4423,7 +4423,7 @@ cdef class Integer_to_IntegerMod(IntegerMod_hom): import sage.categories.homset IntegerMod_hom.__init__(self, sage.categories.homset.Hom(integer_ring.ZZ, R)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: cdef IntegerMod_abstract a cdef Py_ssize_t res if self.modulus.table is not None: @@ -4495,7 +4495,7 @@ cdef class IntegerMod_to_Integer(Map): from sage.categories.sets_cat import Sets Morphism.__init__(self, sage.categories.homset.Hom(R, integer_ring.ZZ, Sets())) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: cdef Integer ans = Integer.__new__(Integer) if isinstance(x, IntegerMod_gmp): mpz_set(ans.value, (x).value) @@ -4534,7 +4534,7 @@ cdef class Int_to_IntegerMod(IntegerMod_hom): from sage.sets.pythonclass import Set_PythonType IntegerMod_hom.__init__(self, sage.categories.homset.Hom(Set_PythonType(int), R)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: cdef IntegerMod_abstract a zero = self.zero diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index b466ee5e2c1..17a431f3496 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -995,7 +995,7 @@ cdef class ReductionMap(Map): self._repr_type_str = "Partially defined reduction" Map.__init__(self, Hom(K, F, SetsWithPartialMaps())) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1026,7 +1026,7 @@ cdef class ReductionMap(Map): slots['_section'] = self._section return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1056,7 +1056,7 @@ cdef class ReductionMap(Map): self._PB = _slots['_PB'] self._section = _slots['_section'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Apply this reduction map to an element that coerces into the global field. @@ -1305,7 +1305,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): self._repr_type_str = "Reduction" RingHomomorphism.__init__(self, Hom(K,F)) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1337,7 +1337,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): slots['_section'] = self._section return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1368,7 +1368,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): self._PB = _slots['_PB'] self._section = _slots['_section'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Applies this morphism to an element. @@ -1572,7 +1572,7 @@ cdef class LiftingMap(Section): self._PB = PB Section.__init__(self, reduction) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1598,7 +1598,7 @@ cdef class LiftingMap(Section): slots['_PB'] = self._PB return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1623,7 +1623,7 @@ cdef class LiftingMap(Section): self._to_order = _slots['_to_order'] self._PB = _slots['_PB'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Lift from this residue class field to the number field. diff --git a/src/sage/rings/fraction_field_FpT.pxd b/src/sage/rings/fraction_field_FpT.pxd index 5029a49727c..a385a3d7742 100644 --- a/src/sage/rings/fraction_field_FpT.pxd +++ b/src/sage/rings/fraction_field_FpT.pxd @@ -10,15 +10,15 @@ cdef class FpTElement(FieldElement): cdef bint initialized cdef long p - cdef FpTElement _new_c(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cdef FpTElement _copy_c(self) - cpdef numerator(self) - cpdef denominator(self) - cpdef FpTElement next(self) - cpdef _sqrt_or_None(self) - cpdef bint is_square(self) + cdef FpTElement _new_c(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cdef FpTElement _copy_c(self) noexcept + cpdef numerator(self) noexcept + cpdef denominator(self) noexcept + cpdef FpTElement next(self) noexcept + cpdef _sqrt_or_None(self) noexcept + cpdef bint is_square(self) noexcept cdef class FpT_iter: cdef parent diff --git a/src/sage/rings/fraction_field_FpT.pyx b/src/sage/rings/fraction_field_FpT.pyx index c9bb5d5a384..4c99862ca24 100644 --- a/src/sage/rings/fraction_field_FpT.pyx +++ b/src/sage/rings/fraction_field_FpT.pyx @@ -160,7 +160,7 @@ cdef class FpTElement(FieldElement): return (unpickle_FpT_element, (self._parent, self.numer(), self.denom())) - cdef FpTElement _new_c(self): + cdef FpTElement _new_c(self) noexcept: """ Creates a new FpTElement in the same field, leaving the value to be initialized. """ @@ -172,7 +172,7 @@ cdef class FpTElement(FieldElement): x.initialized = True return x - cdef FpTElement _copy_c(self): + cdef FpTElement _copy_c(self) noexcept: """ Creates a new FpTElement in the same field, with the same value as self. """ @@ -199,7 +199,7 @@ cdef class FpTElement(FieldElement): """ return self.numerator() - cpdef numerator(self): + cpdef numerator(self) noexcept: """ Return the numerator of this element, as an element of the polynomial ring. @@ -230,7 +230,7 @@ cdef class FpTElement(FieldElement): """ return self.denominator() - cpdef denominator(self): + cpdef denominator(self) noexcept: """ Return the denominator of this element, as an element of the polynomial ring. @@ -358,7 +358,7 @@ cdef class FpTElement(FieldElement): else: return "\\frac{%s}{%s}" % (self.numer()._latex_(), self.denom()._latex_()) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare this with another element. @@ -463,7 +463,7 @@ cdef class FpTElement(FieldElement): nmod_poly_swap(x._numer, x._denom) return x - cpdef _add_(self, _other): + cpdef _add_(self, _other) noexcept: """ Return the sum of this fraction field element and another. @@ -491,7 +491,7 @@ cdef class FpTElement(FieldElement): normalize(x._numer, x._denom, self.p) return x - cpdef _sub_(self, _other): + cpdef _sub_(self, _other) noexcept: """ Return the difference of this fraction field element and another. @@ -513,7 +513,7 @@ cdef class FpTElement(FieldElement): normalize(x._numer, x._denom, self.p) return x - cpdef _mul_(self, _other): + cpdef _mul_(self, _other) noexcept: """ Return the product of this fraction field element and another. @@ -533,7 +533,7 @@ cdef class FpTElement(FieldElement): normalize(x._numer, x._denom, self.p) return x - cpdef _div_(self, _other): + cpdef _div_(self, _other) noexcept: """ Return the quotient of this fraction field element and another. @@ -557,7 +557,7 @@ cdef class FpTElement(FieldElement): normalize(x._numer, x._denom, self.p) return x - cpdef FpTElement next(self): + cpdef FpTElement next(self) noexcept: """ Iterate through all polynomials, returning the "next" polynomial after this one. @@ -663,7 +663,7 @@ cdef class FpTElement(FieldElement): nmod_poly_clear(g) return next - cpdef _sqrt_or_None(self): + cpdef _sqrt_or_None(self) noexcept: """ Return the square root of ``self``, or ``None``. @@ -735,7 +735,7 @@ cdef class FpTElement(FieldElement): nmod_poly_clear(denom) return None - cpdef bint is_square(self): + cpdef bint is_square(self) noexcept: """ Return ``True`` if this element is the square of another element of the fraction field. @@ -1052,7 +1052,7 @@ cdef class Polyring_FpT_coerce(RingHomomorphism): RingHomomorphism.__init__(self, R.ring_of_integers().Hom(R)) self.p = R.base_ring().characteristic() - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1068,7 +1068,7 @@ cdef class Polyring_FpT_coerce(RingHomomorphism): slots['p'] = self.p return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1083,7 +1083,7 @@ cdef class Polyring_FpT_coerce(RingHomomorphism): self.p = _slots['p'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Applies the coercion. @@ -1106,7 +1106,7 @@ cdef class Polyring_FpT_coerce(RingHomomorphism): ans.initialized = True return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function allows the map to take multiple arguments, usually used to specify both numerator and denominator. @@ -1255,7 +1255,7 @@ cdef class FpT_Polyring_section(Section): self.p = f.p Section.__init__(self, f) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1277,7 +1277,7 @@ cdef class FpT_Polyring_section(Section): slots['p'] = self.p return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1298,7 +1298,7 @@ cdef class FpT_Polyring_section(Section): self.p = _slots['p'] Section._update_slots(self, _slots) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Applies the section. @@ -1370,7 +1370,7 @@ cdef class Fp_FpT_coerce(RingHomomorphism): RingHomomorphism.__init__(self, R.base_ring().Hom(R)) self.p = R.base_ring().characteristic() - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1389,7 +1389,7 @@ cdef class Fp_FpT_coerce(RingHomomorphism): slots['p'] = self.p return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1407,7 +1407,7 @@ cdef class Fp_FpT_coerce(RingHomomorphism): self.p = _slots['p'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Applies the coercion. @@ -1430,7 +1430,7 @@ cdef class Fp_FpT_coerce(RingHomomorphism): ans.initialized = True return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function allows the map to take multiple arguments, usually used to specify both numerator and denominator. @@ -1558,7 +1558,7 @@ cdef class FpT_Fp_section(Section): self.p = f.p Section.__init__(self, f) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1586,7 +1586,7 @@ cdef class FpT_Fp_section(Section): slots['p'] = self.p return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1613,7 +1613,7 @@ cdef class FpT_Fp_section(Section): self.p = _slots['p'] Section._update_slots(self, _slots) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Applies the section. @@ -1692,7 +1692,7 @@ cdef class ZZ_FpT_coerce(RingHomomorphism): RingHomomorphism.__init__(self, ZZ.Hom(R)) self.p = R.base_ring().characteristic() - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1713,7 +1713,7 @@ cdef class ZZ_FpT_coerce(RingHomomorphism): slots['p'] = self.p return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1733,7 +1733,7 @@ cdef class ZZ_FpT_coerce(RingHomomorphism): self.p = _slots['p'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Applies the coercion. @@ -1756,7 +1756,7 @@ cdef class ZZ_FpT_coerce(RingHomomorphism): ans.initialized = True return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function allows the map to take multiple arguments, usually used to specify both numerator and denominator. @@ -1842,7 +1842,7 @@ cdef class ZZ_FpT_coerce(RingHomomorphism): """ return ZZ.convert_map_from(self.codomain().base_ring()) * Fp_FpT_coerce(self.codomain()).section() -cdef inline bint normalize(nmod_poly_t numer, nmod_poly_t denom, long p): +cdef inline bint normalize(nmod_poly_t numer, nmod_poly_t denom, long p) noexcept: """ Put ``numer`` / ``denom`` into a normal form: denominator monic and sharing no common factor with the numerator. @@ -1887,14 +1887,14 @@ cdef inline bint normalize(nmod_poly_t numer, nmod_poly_t denom, long p): nmod_poly_clear(g) -cdef inline unsigned long nmod_poly_leading(nmod_poly_t poly): +cdef inline unsigned long nmod_poly_leading(nmod_poly_t poly) noexcept: """ Return the leading coefficient of ``poly``. """ return nmod_poly_get_coeff_ui(poly, nmod_poly_degree(poly)) -cdef inline void nmod_poly_inc(nmod_poly_t poly, bint monic): +cdef inline void nmod_poly_inc(nmod_poly_t poly, bint monic) noexcept: """ Set poly to the "next" polynomial: this is just counting in base p. @@ -1915,7 +1915,7 @@ cdef inline void nmod_poly_inc(nmod_poly_t poly, bint monic): nmod_poly_set_coeff_ui(poly, n + 1, 1) -cdef inline long nmod_poly_cmp(nmod_poly_t a, nmod_poly_t b): +cdef inline long nmod_poly_cmp(nmod_poly_t a, nmod_poly_t b) noexcept: """ Compare `a` and `b`, returning 0 if they are equal. @@ -1943,7 +1943,7 @@ cdef inline long nmod_poly_cmp(nmod_poly_t a, nmod_poly_t b): return 0 -cdef bint nmod_poly_sqrt_check(nmod_poly_t poly): +cdef bint nmod_poly_sqrt_check(nmod_poly_t poly) noexcept: """ Quick check to see if ``poly`` could possibly be a square. """ @@ -1971,7 +1971,7 @@ def unpickle_FpT_element(K, numer, denom): # Somehow this isn't in FLINT, evidently. It could be moved # elsewhere at some point. -cdef int sage_cmp_nmod_poly_t(nmod_poly_t L, nmod_poly_t R): +cdef int sage_cmp_nmod_poly_t(nmod_poly_t L, nmod_poly_t R) noexcept: """ Compare two ``nmod_poly_t`` in a Pythonic way, so this returns `-1`, `0`, or `1`, and is consistent. diff --git a/src/sage/rings/fraction_field_element.pyx b/src/sage/rings/fraction_field_element.pyx index 2134c2fa07b..cb0bbce912f 100644 --- a/src/sage/rings/fraction_field_element.pyx +++ b/src/sage/rings/fraction_field_element.pyx @@ -159,7 +159,7 @@ cdef class FractionFieldElement(FieldElement): nden = codomain.coerce(self._denominator._im_gens_(codomain, im_gens, base_map=base_map)) return codomain.coerce(nnum/nden) - cpdef reduce(self): + cpdef reduce(self) noexcept: """ Reduce this fraction. @@ -548,7 +548,7 @@ cdef class FractionFieldElement(FieldElement): return s - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Compute the sum of ``self`` and ``right``. @@ -633,7 +633,7 @@ cdef class FractionFieldElement(FieldElement): return self.__class__(self._parent, rnum*sden + rden*snum, rden*sden, coerce=False, reduce=False) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Computes the product of ``self`` and ``right``. @@ -699,7 +699,7 @@ cdef class FractionFieldElement(FieldElement): return self.__class__(self._parent, rnum * snum, rden * sden, coerce=False, reduce=False) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Computes the quotient of ``self`` and ``right``. @@ -934,7 +934,7 @@ cdef class FractionFieldElement(FieldElement): return self.__class__(self._parent, self._denominator, self._numerator, coerce=False, reduce=False) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ EXAMPLES:: @@ -1171,7 +1171,7 @@ cdef class FractionFieldElement_1poly_field(FractionFieldElement): if not reduce: self.normalize_leading_coefficients() - cdef normalize_leading_coefficients(self): + cdef normalize_leading_coefficients(self) noexcept: """ See :meth:`reduce`. """ @@ -1216,7 +1216,7 @@ cdef class FractionFieldElement_1poly_field(FractionFieldElement): L.sort() return L - cpdef reduce(self): + cpdef reduce(self) noexcept: """ Pick a normalized representation of self. diff --git a/src/sage/rings/function_field/element.pxd b/src/sage/rings/function_field/element.pxd index f0418634f82..9ffdbd48383 100644 --- a/src/sage/rings/function_field/element.pxd +++ b/src/sage/rings/function_field/element.pxd @@ -5,6 +5,6 @@ cdef class FunctionFieldElement(FieldElement): cdef readonly object _x cdef readonly object _matrix - cdef FunctionFieldElement _new_c(self) - cpdef bint is_nth_power(self, n) - cpdef FunctionFieldElement nth_root(self, n) + cdef FunctionFieldElement _new_c(self) noexcept + cpdef bint is_nth_power(self, n) noexcept + cpdef FunctionFieldElement nth_root(self, n) noexcept diff --git a/src/sage/rings/function_field/element.pyx b/src/sage/rings/function_field/element.pyx index 9a82b611d18..dceaa85fd2e 100644 --- a/src/sage/rings/function_field/element.pyx +++ b/src/sage/rings/function_field/element.pyx @@ -122,7 +122,7 @@ cdef class FunctionFieldElement(FieldElement): return (make_FunctionFieldElement, (self._parent, type(self), self._x)) - cdef FunctionFieldElement _new_c(self): + cdef FunctionFieldElement _new_c(self) noexcept: cdef type t = type(self) cdef FunctionFieldElement x = t.__new__(t) x._parent = self._parent @@ -671,7 +671,7 @@ cdef class FunctionFieldElement(FieldElement): # v < 0 raise ValueError('has a pole at the place') - cpdef bint is_nth_power(self, n): + cpdef bint is_nth_power(self, n) noexcept: r""" Return whether this element is an ``n``-th power in the rational function field. @@ -698,7 +698,7 @@ cdef class FunctionFieldElement(FieldElement): """ raise NotImplementedError("is_nth_power() not implemented for generic elements") - cpdef FunctionFieldElement nth_root(self, n): + cpdef FunctionFieldElement nth_root(self, n) noexcept: """ Return an ``n``-th root of this element in the function field. diff --git a/src/sage/rings/function_field/element_polymod.pyx b/src/sage/rings/function_field/element_polymod.pyx index 9e198d0b042..5e748b22a6f 100644 --- a/src/sage/rings/function_field/element_polymod.pyx +++ b/src/sage/rings/function_field/element_polymod.pyx @@ -112,7 +112,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): """ return hash(self._x) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Do rich comparison with the other element with respect to ``op`` @@ -129,7 +129,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): cdef FunctionFieldElement right = other return richcmp(left._x, right._x, op) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add the element with the other element. @@ -152,7 +152,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): res._x = self._x + (right)._x return res - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract the other element from the element. @@ -173,7 +173,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): res._x = self._x - (right)._x return res - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply the element with the other element. @@ -192,7 +192,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): res._x = (self._x * (right)._x) % self._parent.polynomial() return res - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide the element with the other element. @@ -231,7 +231,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): P = self._parent return P(self._x.xgcd(P._polynomial)[1]) - cpdef list list(self): + cpdef list list(self) noexcept: """ Return the list of the coefficients representing the element. @@ -251,7 +251,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): """ return self._x.padded_list(self._parent.degree()) - cpdef FunctionFieldElement nth_root(self, n): + cpdef FunctionFieldElement nth_root(self, n) noexcept: r""" Return an ``n``-th root of this element in the function field. @@ -317,7 +317,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): raise NotImplementedError("nth_root() not implemented for this n") - cpdef bint is_nth_power(self, n): + cpdef bint is_nth_power(self, n) noexcept: r""" Return whether this element is an ``n``-th power in the function field. @@ -367,7 +367,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement): raise NotImplementedError("is_nth_power() not implemented for this n") - cdef FunctionFieldElement _pth_root(self): + cdef FunctionFieldElement _pth_root(self) noexcept: r""" Helper method for :meth:`nth_root` and :meth:`is_nth_power` which computes a `p`-th root if the characteristic is `p` and the constant diff --git a/src/sage/rings/function_field/element_rational.pyx b/src/sage/rings/function_field/element_rational.pyx index 0d306d6826e..faa70ee7aee 100644 --- a/src/sage/rings/function_field/element_rational.pyx +++ b/src/sage/rings/function_field/element_rational.pyx @@ -85,7 +85,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): """ return self._x - cpdef list list(self): + cpdef list list(self) noexcept: """ Return a list with just the element. @@ -143,7 +143,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): """ return hash(self._x) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare the element with the other element with respect to ``op`` @@ -174,7 +174,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): except TypeError: return NotImplemented - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add the element with the other element. @@ -192,7 +192,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): res._x = self._x + (right)._x return res - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract the other element from the element. @@ -210,7 +210,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): res._x = self._x - (right)._x return res - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply the element with the other element @@ -228,7 +228,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): res._x = self._x * (right)._x return res - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide the element with the other element @@ -359,7 +359,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): else: return self._parent(self._x.sqrt()) - cpdef bint is_nth_power(self, n): + cpdef bint is_nth_power(self, n) noexcept: r""" Return whether this element is an ``n``-th power in the rational function field. @@ -412,7 +412,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): raise NotImplementedError("is_nth_power() not implemented for the given n") - cpdef FunctionFieldElement nth_root(self, n): + cpdef FunctionFieldElement nth_root(self, n) noexcept: r""" Return an ``n``-th root of this element in the function field. diff --git a/src/sage/rings/integer.pxd b/src/sage/rings/integer.pxd index fff6b56a5fc..2f81c164943 100644 --- a/src/sage/rings/integer.pxd +++ b/src/sage/rings/integer.pxd @@ -10,35 +10,35 @@ cdef class Integer(EuclideanDomainElement): # https://github.com/cython/cython/issues/1984 cdef __mpz_struct value[1] - cdef void set_from_mpz(self, mpz_t value) - cdef hash_c(self) - - cpdef __pari__(self) - - cpdef _shift_helper(Integer self, y, int sign) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _pow_(self, other) - cdef _and(Integer self, Integer other) - cdef _or(Integer self, Integer other) - cdef _xor(Integer self, Integer other) - - cpdef size_t _exact_log_log2_iter(self,Integer m) - cpdef size_t _exact_log_mpfi_log(self,m) - cpdef RingElement _valuation(Integer self, Integer p) - cdef object _val_unit(Integer self, Integer p) - cdef Integer _divide_knowing_divisible_by(Integer self, Integer right) - cdef bint _is_power_of(Integer self, Integer n) + cdef void set_from_mpz(self, mpz_t value) noexcept + cdef hash_c(self) noexcept + + cpdef __pari__(self) noexcept + + cpdef _shift_helper(Integer self, y, int sign) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _pow_(self, other) noexcept + cdef _and(Integer self, Integer other) noexcept + cdef _or(Integer self, Integer other) noexcept + cdef _xor(Integer self, Integer other) noexcept + + cpdef size_t _exact_log_log2_iter(self,Integer m) noexcept + cpdef size_t _exact_log_mpfi_log(self,m) noexcept + cpdef RingElement _valuation(Integer self, Integer p) noexcept + cdef object _val_unit(Integer self, Integer p) noexcept + cdef Integer _divide_knowing_divisible_by(Integer self, Integer right) noexcept + cdef bint _is_power_of(Integer self, Integer n) noexcept cdef bint _pseudoprime_is_prime(self, proof) except -1 cdef int mpz_set_str_python(mpz_ptr z, char* s, int base) except -1 -cdef Integer smallInteger(long value) +cdef Integer smallInteger(long value) noexcept cdef bint _small_primes_table[500] -cdef inline Integer _Integer_from_mpz(mpz_t e): +cdef inline Integer _Integer_from_mpz(mpz_t e) noexcept: cdef Integer z = Integer.__new__(Integer) mpz_set(z.value, e) return z diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 4202bcc9a10..5ce9df2fc3c 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -210,11 +210,11 @@ cdef object numpy_long_interface = {'typestr': '=i4' if sizeof(long) == 4 else ' cdef object numpy_int64_interface = {'typestr': '=i8'} cdef object numpy_object_interface = {'typestr': '|O'} -cdef set_from_Integer(Integer self, Integer other): +cdef set_from_Integer(Integer self, Integer other) noexcept: mpz_set(self.value, other.value) -cdef _digits_naive(mpz_t v,l,int offset,Integer base,digits): +cdef _digits_naive(mpz_t v,l,int offset,Integer base,digits) noexcept: """ This method fills in digit entries in the list, l, using the most basic digit algorithm -- repeat division by base. @@ -261,7 +261,7 @@ cdef _digits_naive(mpz_t v,l,int offset,Integer base,digits): mpz_clear(mpz_value) -cdef _digits_internal(mpz_t v,l,int offset,int power_index,power_list,digits): +cdef _digits_internal(mpz_t v,l,int offset,int power_index,power_list,digits) noexcept: """ INPUT: @@ -335,7 +335,7 @@ def is_Integer(x): """ return isinstance(x, Integer) -cdef inline Integer as_Integer(x): +cdef inline Integer as_Integer(x) noexcept: if isinstance(x, Integer): return x else: @@ -772,7 +772,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): """ return codomain.coerce(self) - cdef _xor(Integer self, Integer other): + cdef _xor(Integer self, Integer other) noexcept: cdef Integer x x = PY_NEW(Integer) mpz_xor(x.value, self.value, other.value) @@ -914,7 +914,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return rich_to_bool_sgn(op, c) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" EXAMPLES:: @@ -1733,7 +1733,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): else: return self.abs().exact_log(base) + 1 - cdef void set_from_mpz(Integer self, mpz_t value): + cdef void set_from_mpz(Integer self, mpz_t value) noexcept: mpz_set(self.value, value) def __add__(left, right): @@ -1762,7 +1762,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return coercion_model.bin_op(left, right, operator.add) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Integer addition. @@ -1780,7 +1780,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): mpz_add(x.value, self.value, (right).value) return x - cdef _add_long(self, long n): + cdef _add_long(self, long n) noexcept: """ Fast path for adding a C long. @@ -1849,7 +1849,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return coercion_model.bin_op(left, right, operator.sub) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Integer subtraction. @@ -1887,12 +1887,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): mpz_neg(x.value, self.value) return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: cdef Integer x = PY_NEW(Integer) mpz_neg(x.value, self.value) return x - cpdef _act_on_(self, s, bint self_on_left): + cpdef _act_on_(self, s, bint self_on_left) noexcept: """ EXAMPLES:: @@ -1909,7 +1909,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): else: return s * int(self) # will raise the appropriate exception - cdef _mul_long(self, long n): + cdef _mul_long(self, long n) noexcept: """ Fast path for multiplying a C long. @@ -1957,7 +1957,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return coercion_model.bin_op(left, right, operator.mul) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Integer multiplication. @@ -2030,7 +2030,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return coercion_model.bin_op(left, right, operator.truediv) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: r""" Computes `\frac{a}{b}` @@ -2047,7 +2047,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): mpq_div_zz(x.value, self.value, (right).value) return x - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: r""" Computes the whole part of `\frac{x}{y}`. @@ -2189,7 +2189,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): # left is a non-Element: do the powering with a Python int return left ** int(right) - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: """ Integer powering. @@ -2269,7 +2269,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): else: return ~r - cdef _pow_long(self, long n): + cdef _pow_long(self, long n) noexcept: if n == 0: return smallInteger(1) elif n == 1: @@ -2299,7 +2299,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sig_off() return q - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ Integer powering to an integer exponent. @@ -2429,7 +2429,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): raise ValueError("%s is not a %s power" % (self, integer_ring.ZZ(n).ordinal_str())) - cpdef size_t _exact_log_log2_iter(self,Integer m): + cpdef size_t _exact_log_log2_iter(self,Integer m) noexcept: r""" This is only for internal use only. You should expect it to crash and burn for negative or other malformed input. In particular, if @@ -2508,7 +2508,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sig_off() return l_min - cpdef size_t _exact_log_mpfi_log(self,m): + cpdef size_t _exact_log_mpfi_log(self,m) noexcept: """ This is only for internal use only. You should expect it to crash and burn for negative or other malformed input. @@ -3683,7 +3683,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): """ return mpz_pythonhash(self.value) - cdef hash_c(self): + cdef hash_c(self) noexcept: """ A C version of the __hash__ function. """ @@ -4174,7 +4174,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sig_off() return t - cpdef RingElement _valuation(Integer self, Integer p): + cpdef RingElement _valuation(Integer self, Integer p) noexcept: r""" Return the p-adic valuation of ``self``. @@ -4199,7 +4199,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): mpz_clear(u) return v - cdef object _val_unit(Integer self, Integer p): + cdef object _val_unit(Integer self, Integer p) noexcept: r""" Return a pair: the p-adic valuation of ``self``, and the p-adic unit of ``self``. @@ -4348,7 +4348,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): mpz_tdiv_q_2exp(odd.value, self.value, bits) return odd - cdef Integer _divide_knowing_divisible_by(Integer self, Integer right): + cdef Integer _divide_knowing_divisible_by(Integer self, Integer right) noexcept: r""" Return the integer ``self`` / ``right`` when ``self`` is divisible by right. @@ -4901,7 +4901,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return R.zero() return R(self).abs().log() - cdef bint _is_power_of(Integer self, Integer n): + cdef bint _is_power_of(Integer self, Integer n) noexcept: r""" Return a non-zero int if there is an integer b with `\mathtt{self} = n^b`. @@ -6176,7 +6176,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): d = self//4 return d%4 in [2,3] and d.is_squarefree() - cpdef __pari__(self): + cpdef __pari__(self) noexcept: """ Return the PARI version of this integer. @@ -6642,7 +6642,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return g, s, t - cpdef _shift_helper(Integer self, y, int sign): + cpdef _shift_helper(Integer self, y, int sign) noexcept: """ Compute left and right shifts of integers. Shifts ``self`` ``y`` bits to the left if ``sign`` is `1`, and to the right @@ -6784,7 +6784,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return x >> int(y) return (x)._shift_helper(y, -1) - cdef _and(Integer self, Integer other): + cdef _and(Integer self, Integer other) noexcept: cdef Integer x = PY_NEW(Integer) mpz_and(x.value, self.value, other.value) return x @@ -6805,7 +6805,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return (x)._and(y) return coercion_model.bin_op(x, y, operator.and_) - cdef _or(Integer self, Integer other): + cdef _or(Integer self, Integer other) noexcept: cdef Integer x = PY_NEW(Integer) mpz_ior(x.value, self.value, other.value) return x @@ -7414,7 +7414,7 @@ cdef class int_to_Z(Morphism): from sage.sets.pythonclass import Set_PythonType Morphism.__init__(self, sage.categories.homset.Hom(Set_PythonType(int), integer_ring.ZZ)) - cpdef Element _call_(self, a): + cpdef Element _call_(self, a) noexcept: """ Return a new integer with the same value as ``a``. @@ -7459,7 +7459,7 @@ cdef class long_to_Z(Morphism): from sage.sets.pythonclass import Set_PythonType Morphism.__init__(self, sage.categories.homset.Hom(Set_PythonType(long), integer_ring.ZZ)) - cpdef Element _call_(self, a): + cpdef Element _call_(self, a) noexcept: cdef Integer r cdef long l cdef int err = 0 @@ -7607,7 +7607,7 @@ cdef PyObject* fast_tp_new(type t, args, kwds) except NULL: return new -cdef void fast_tp_dealloc(PyObject* o): +cdef void fast_tp_dealloc(PyObject* o) noexcept: # If there is room in the pool for a used integer object, # then put it in rather than deallocating it. global integer_pool, integer_pool_count @@ -7642,7 +7642,7 @@ cdef void fast_tp_dealloc(PyObject* o): from sage.misc.allocator cimport hook_tp_functions -cdef hook_fast_tp_functions(): +cdef hook_fast_tp_functions() noexcept: """ Initialize the fast integer creation functions. """ @@ -7660,7 +7660,7 @@ cdef hook_fast_tp_functions(): # to be constructed/destructed. hook_tp_functions(global_dummy_Integer, (&fast_tp_new), (&fast_tp_dealloc), False) -cdef integer(x): +cdef integer(x) noexcept: if isinstance(x, Integer): return x return Integer(x) @@ -7688,7 +7688,7 @@ hook_fast_tp_functions() # zero and one initialization initialized = False -cdef set_zero_one_elements(): +cdef set_zero_one_elements() noexcept: global the_integer_ring, initialized if initialized: return the_integer_ring._zero_element = Integer(0) @@ -7707,7 +7707,7 @@ DEF small_pool_max = 256 # we could use the above zero and one here cdef list small_pool = [Integer(k) for k in range(small_pool_min, small_pool_max+1)] -cdef inline Integer smallInteger(long value): +cdef inline Integer smallInteger(long value) noexcept: """ This is the fastest way to create a (likely) small Integer. """ diff --git a/src/sage/rings/integer_fake.pxd b/src/sage/rings/integer_fake.pxd index 4a02062c64b..2bd7a91142e 100644 --- a/src/sage/rings/integer_fake.pxd +++ b/src/sage/rings/integer_fake.pxd @@ -46,7 +46,7 @@ cdef extern from "integer_fake.h": bint unlikely(bint c) # Defined by Cython -cdef inline bint is_Integer(x): +cdef inline bint is_Integer(x) noexcept: global Integer if unlikely(Integer is NULL): import sage.rings.integer diff --git a/src/sage/rings/integer_ring.pyx b/src/sage/rings/integer_ring.pyx index c7a05a13e16..b510c4ba992 100644 --- a/src/sage/rings/integer_ring.pyx +++ b/src/sage/rings/integer_ring.pyx @@ -72,7 +72,7 @@ cimport sage.rings.integer as integer from . import ring arith = None -cdef void late_import(): +cdef void late_import() noexcept: # A hack to avoid circular imports. global arith if arith is None: @@ -524,7 +524,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): yield -n n += 1 - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: r""" ``x`` canonically coerces to the integers `\ZZ` only if ``x`` is an int, long or already an element of `\ZZ`. diff --git a/src/sage/rings/laurent_series_ring_element.pxd b/src/sage/rings/laurent_series_ring_element.pxd index 8df5a92c9e7..2b37b80e3b0 100644 --- a/src/sage/rings/laurent_series_ring_element.pxd +++ b/src/sage/rings/laurent_series_ring_element.pxd @@ -4,7 +4,7 @@ cdef class LaurentSeries(AlgebraElement): cdef ModuleElement __u cdef long __n - cdef _normalize(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) + cdef _normalize(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept diff --git a/src/sage/rings/laurent_series_ring_element.pyx b/src/sage/rings/laurent_series_ring_element.pyx index d56996f3f78..b15e6cbdcf0 100644 --- a/src/sage/rings/laurent_series_ring_element.pyx +++ b/src/sage/rings/laurent_series_ring_element.pyx @@ -303,7 +303,7 @@ cdef class LaurentSeries(AlgebraElement): x = im_gens[0] return codomain(self.__u._im_gens_(codomain, im_gens, base_map=base_map) * x**self.__n) - cdef _normalize(self): + cdef _normalize(self) noexcept: r""" A Laurent series is a pair (u(t), n), where either u=0 (to some precision) or u is a unit. This pair corresponds to @@ -729,7 +729,7 @@ cdef class LaurentSeries(AlgebraElement): self.__u = self.__u._parent(coeffs) self._normalize() - cpdef _add_(self, right_m): + cpdef _add_(self, right_m) noexcept: """ Add two power series with the same parent. @@ -787,7 +787,7 @@ cdef class LaurentSeries(AlgebraElement): # 3. Add return type(self)(self._parent, f1 + f2, m) - cpdef _sub_(self, right_m): + cpdef _sub_(self, right_m) noexcept: """ Subtract two power series with the same parent. @@ -915,7 +915,7 @@ cdef class LaurentSeries(AlgebraElement): """ return type(self)(self._parent, -self.__u, self.__n) - cpdef _mul_(self, right_r): + cpdef _mul_(self, right_r) noexcept: """ EXAMPLES:: @@ -930,10 +930,10 @@ cdef class LaurentSeries(AlgebraElement): self.__u * right.__u, self.__n + right.__n) - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: return type(self)(self._parent, self.__u._rmul_(c), self.__n) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: return type(self)(self._parent, self.__u._lmul_(c), self.__n) def __pow__(_self, r, dummy): @@ -1082,7 +1082,7 @@ cdef class LaurentSeries(AlgebraElement): """ return type(self)(self._parent, self.__u >> (n - self.__n), n) - cpdef _div_(self, right_r): + cpdef _div_(self, right_r) noexcept: """ EXAMPLES:: @@ -1203,7 +1203,7 @@ cdef class LaurentSeries(AlgebraElement): """ return min(self.valuation(), other.valuation()) - cpdef _richcmp_(self, right_r, int op): + cpdef _richcmp_(self, right_r, int op) noexcept: r""" Comparison of ``self`` and ``right``. diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 5f7dc12cdb1..04fca55cd60 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -514,7 +514,7 @@ cdef class RingMap_lift(RingMap): H = R.Hom(S, Sets()) RingMap.__init__(self, H) - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -533,7 +533,7 @@ cdef class RingMap_lift(RingMap): self.to_S = _slots['to_S'] Morphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -549,7 +549,7 @@ cdef class RingMap_lift(RingMap): slots['to_S'] = self.to_S return slots - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare a ring lifting maps ``self`` to ``other``. @@ -613,7 +613,7 @@ cdef class RingMap_lift(RingMap): """ return "Choice of lifting map" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate this function at ``x``. @@ -700,7 +700,7 @@ cdef class RingHomomorphism(RingMap): raise TypeError("lift must have correct codomain") self._lift = lift - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -719,7 +719,7 @@ cdef class RingHomomorphism(RingMap): self._lift = _slots['_lift'] Morphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1809,7 +1809,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): """ return self._base_map - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1829,7 +1829,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): self._base_map = _slots.get('_base_map') RingHomomorphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1850,7 +1850,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): slots['_base_map'] = self._base_map return slots - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" EXAMPLES: @@ -1957,7 +1957,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): s += '\nwith map of base ring' return s - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate this homomorphism at ``x``. @@ -2121,7 +2121,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): """ return self._underlying - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -2151,7 +2151,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): self._underlying = _slots['__underlying'] # double underscore for legacy pickles RingHomomorphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -2182,7 +2182,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): slots['__underlying'] = self._underlying return slots - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" EXAMPLES: @@ -2266,7 +2266,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): U = repr(self._underlying).split('\n') return 'Induced from base ring by\n'+'\n'.join(U) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate this homomorphism at ``x``. @@ -2370,7 +2370,7 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): """ return self._morphism._repr_defn() - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the value of this morphism at ``x``. @@ -2389,7 +2389,7 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): """ return self._morphism(x.numerator()) / self._morphism(x.denominator()) - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper function for copying and pickling. @@ -2408,7 +2408,7 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): self._morphism = _slots['_morphism'] RingHomomorphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper function for copying and pickling. @@ -2475,7 +2475,7 @@ cdef class RingHomomorphism_cover(RingHomomorphism): """ RingHomomorphism.__init__(self, parent) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate this covering homomorphism at ``x``, which just involves coercing ``x`` into the domain, then codomain. @@ -2534,7 +2534,7 @@ cdef class RingHomomorphism_cover(RingHomomorphism): """ return self.codomain().defining_ideal() - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare ``self`` to ``other``. @@ -2685,7 +2685,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): self._lift = pi.lift() self.phi = phi - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -2714,7 +2714,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): self.phi = _slots['phi'] RingHomomorphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -2778,7 +2778,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): """ return self.phi - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare ``self`` to ``other``. @@ -2839,7 +2839,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): return '\n'.join('{} |--> {}'.format(D.gen(i), ig[i]) for i in range(D.ngens())) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate this function at ``x``. @@ -2898,7 +2898,7 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): self._q = self._p ** self._power RingHomomorphism.__init__(self, Hom(domain, domain)) - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Update information with the given slots. @@ -2918,7 +2918,7 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): self._q = self._p ** self._power RingHomomorphism._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Return additional information about this morphism as a dictionary. @@ -3008,7 +3008,7 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): s = '\\verb"Frob"^{%s}' % self._power return s - cpdef Element _call_ (self, x): + cpdef Element _call_ (self, x) noexcept: """ TESTS:: diff --git a/src/sage/rings/number_field/number_field_base.pxd b/src/sage/rings/number_field/number_field_base.pxd index ba6a8e98143..f34a25d0dcb 100644 --- a/src/sage/rings/number_field/number_field_base.pxd +++ b/src/sage/rings/number_field/number_field_base.pxd @@ -4,4 +4,4 @@ cdef class NumberField(Field): cdef int _embedded_real cdef list _gen_approx - cpdef _get_embedding_approx(self, size_t i) + cpdef _get_embedding_approx(self, size_t i) noexcept diff --git a/src/sage/rings/number_field/number_field_base.pyx b/src/sage/rings/number_field/number_field_base.pyx index 1d09825477a..538dc8b0579 100644 --- a/src/sage/rings/number_field/number_field_base.pyx +++ b/src/sage/rings/number_field/number_field_base.pyx @@ -392,7 +392,7 @@ cdef class NumberField(Field): self._gen_approx = [] self._embedded_real = 1 - cpdef _get_embedding_approx(self, size_t i): + cpdef _get_embedding_approx(self, size_t i) noexcept: r""" Return an interval approximation of the generator of this number field. diff --git a/src/sage/rings/number_field/number_field_element.pxd b/src/sage/rings/number_field/number_field_element.pxd index c3d8a8b4a4b..612e5cce09c 100644 --- a/src/sage/rings/number_field/number_field_element.pxd +++ b/src/sage/rings/number_field/number_field_element.pxd @@ -21,26 +21,26 @@ cdef class NumberFieldElement(NumberFieldElement_base): cdef object __pari cdef object __matrix - cdef _new(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) + cdef _new(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept - cpdef _add_(self, other) - cpdef _mul_(self, other) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept - cpdef _copy_for_parent(self, Parent parent) + cpdef _copy_for_parent(self, Parent parent) noexcept - cdef number_field(self) + cdef number_field(self) noexcept - cdef void _ntl_coeff_as_mpz(self, mpz_t z, long i) - cdef void _ntl_denom_as_mpz(self, mpz_t z) + cdef void _ntl_coeff_as_mpz(self, mpz_t z, long i) noexcept + cdef void _ntl_denom_as_mpz(self, mpz_t z) noexcept - cdef void _reduce_c_(self) + cdef void _reduce_c_(self) noexcept - cpdef list _coefficients(self) + cpdef list _coefficients(self) noexcept - cpdef bint is_rational(self) - cpdef bint is_one(self) + cpdef bint is_rational(self) noexcept + cpdef bint is_one(self) noexcept cdef int _randomize(self, num_bound, den_bound, distribution) except -1 diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 749b10437f3..e141c38ba79 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -172,7 +172,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: a^3 -a - 1 """ - cdef _new(self): + cdef _new(self) noexcept: """ Quickly creates a new initialized NumberFieldElement with the same parent as self. @@ -184,7 +184,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): x._fld_denominator = self._fld_denominator return x - cdef number_field(self): + cdef number_field(self) noexcept: r""" Return the number field of self. Only accessible from Cython. @@ -784,7 +784,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): return QQ.zero() return coeffs[n] - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" EXAMPLES:: @@ -2438,7 +2438,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): else: return sbase.power(exp, hold=True) - cdef void _reduce_c_(self): + cdef void _reduce_c_(self) noexcept: """ Pull out common factors from the numerator and denominator! """ @@ -2457,7 +2457,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): self._numerator = t2 self._denominator = t1 - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" EXAMPLES:: @@ -2483,7 +2483,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): x._reduce_c_() return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" EXAMPLES:: @@ -2508,7 +2508,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): x._reduce_c_() return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Returns the product of self and other as elements of a number field. @@ -2556,7 +2556,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): # but asymptotically fast poly multiplication means it's # actually faster to *not* build a table!?! - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Returns the quotient of self and other as elements of a number field. @@ -2668,7 +2668,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): """ return not IsZero_ZZX(self._numerator) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" EXAMPLES:: @@ -2683,7 +2683,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): x._denominator = self._denominator return x - cpdef _copy_for_parent(self, Parent parent): + cpdef _copy_for_parent(self, Parent parent) noexcept: r""" Return a copy of ``self`` with the parent replaced by ``parent``. @@ -3247,7 +3247,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): return h - cpdef list _coefficients(self): + cpdef list _coefficients(self) noexcept: """ Return the coefficients of the underlying polynomial corresponding to this number field element. @@ -3280,13 +3280,13 @@ cdef class NumberFieldElement(NumberFieldElement_base): mpz_clear(den) return coeffs - cdef void _ntl_coeff_as_mpz(self, mpz_t z, long i): + cdef void _ntl_coeff_as_mpz(self, mpz_t z, long i) noexcept: if i > ZZX_deg(self._numerator): mpz_set_ui(z, 0) else: ZZX_getitem_as_mpz(z, &self._numerator, i) - cdef void _ntl_denom_as_mpz(self, mpz_t z): + cdef void _ntl_denom_as_mpz(self, mpz_t z) noexcept: cdef Integer denom = Integer.__new__(Integer) ZZ_to_mpz(denom.value, &self._denominator) mpz_set(z, denom.value) @@ -3418,7 +3418,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): if not self: return ZZ.one() else: return sage.rings.infinity.infinity - cpdef bint is_one(self): + cpdef bint is_one(self) noexcept: r""" Test whether this number field element is `1`. @@ -3440,7 +3440,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): return ZZX_IsOne(self._numerator) == 1 and \ ZZ_IsOne(self._denominator) == 1 - cpdef bint is_rational(self): + cpdef bint is_rational(self) noexcept: r""" Test whether this number field element is a rational number. @@ -5267,7 +5267,7 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute): self._number_field = K (self)._parent = order - cdef _new(self): + cdef _new(self) noexcept: """ Quickly creates a new initialized NumberFieldElement with the same parent as ``self``. @@ -5289,7 +5289,7 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute): x._fld_denominator = self._fld_denominator return x - cdef number_field(self): + cdef number_field(self) noexcept: r""" Return the number field of ``self``. Only accessible from Cython. @@ -5383,10 +5383,10 @@ cdef class OrderElement_relative(NumberFieldElement_relative): (self)._parent = order self._number_field = K - cdef number_field(self): + cdef number_field(self) noexcept: return self._number_field - cdef _new(self): + cdef _new(self) noexcept: """ Quickly creates a new initialized NumberFieldElement with the same parent as self. @@ -5695,7 +5695,7 @@ class CoordinateFunction(): ################# -cdef void _ntl_poly(f, ZZX_c *num, ZZ_c *den): +cdef void _ntl_poly(f, ZZX_c *num, ZZ_c *den) noexcept: cdef long i cdef ZZ_c coeff cdef ntl_ZZX _num diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pxd b/src/sage/rings/number_field/number_field_element_quadratic.pxd index 7a4f063de73..76661971848 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pxd +++ b/src/sage/rings/number_field/number_field_element_quadratic.pxd @@ -10,25 +10,25 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): cdef mpz_t a, b, denom cdef Integer D cdef bint standard_embedding - cpdef NumberFieldElement galois_conjugate(self) + cpdef NumberFieldElement galois_conjugate(self) noexcept - cpdef list _coefficients(self) + cpdef list _coefficients(self) noexcept cdef int _randomize(self, num_bound, den_bound, distribution) except -1 cdef int arb_set_real(self, arb_t x, long prec) except -1 - cdef void arb_set_imag(self, arb_t x, long prec) + cdef void arb_set_imag(self, arb_t x, long prec) noexcept - cpdef tuple parts(self) + cpdef tuple parts(self) noexcept cdef class NumberFieldElement_quadratic_sqrt(NumberFieldElement_quadratic): pass cdef class NumberFieldElement_gaussian(NumberFieldElement_quadratic_sqrt): - cpdef real_part(self) - cpdef imag_part(self) + cpdef real_part(self) noexcept + cpdef imag_part(self) noexcept cdef class OrderElement_quadratic(NumberFieldElement_quadratic): pass -cpdef bint is_sqrt_disc(Rational ad, Rational bd) +cpdef bint is_sqrt_disc(Rational ad, Rational bd) noexcept diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pyx b/src/sage/rings/number_field/number_field_element_quadratic.pyx index c32f6aadd10..57c2df2cb43 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx @@ -225,7 +225,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): # __cmp__, sign, real, imag, floor, ceil, ... self.standard_embedding = parent._standard_embedding - cdef _new(self): + cdef _new(self) noexcept: """ Quickly creates a new initialized NumberFieldElement_quadratic with the same parent as self. @@ -243,7 +243,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): x.D = self.D return x - cdef number_field(self): + cdef number_field(self) noexcept: r""" Return the number field to which this element belongs. Since this is a Cython cdef method, it is not directly accessible by the user, but the @@ -350,7 +350,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_set(denom.value, self.denom) return "new QuadraticExtension({}, {}, {})".format(a/denom, b/denom, self.D) - cpdef _copy_for_parent(self, Parent parent): + cpdef _copy_for_parent(self, Parent parent) noexcept: r""" Return a copy of ``self`` with the parent replaced by ``parent``. @@ -786,7 +786,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): fmpz_clear(tmpz) return 0 - cdef void arb_set_imag(self, arb_t x, long prec): + cdef void arb_set_imag(self, arb_t x, long prec) noexcept: "Set x to the imaginary part of this element" cdef fmpz_t tmpz cdef arb_t rootD @@ -892,7 +892,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): self.arb_set_imag(acb_imagref(res.value), R._prec) return res - cpdef tuple parts(self): + cpdef tuple parts(self) noexcept: r""" Return a pair of rationals `a` and `b` such that ``self`` `= a+b\sqrt{D}`. @@ -1038,7 +1038,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): return test return -test - cpdef _richcmp_(left, _right, int op): + cpdef _richcmp_(left, _right, int op) noexcept: r""" Rich comparison of elements. @@ -1295,7 +1295,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): # Arithmetic ######################################################### - cdef void _reduce_c_(self): + cdef void _reduce_c_(self) noexcept: r""" Reduces into canonical form. @@ -1318,7 +1318,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_clear(gcd) - cpdef _add_(self, other_m): + cpdef _add_(self, other_m) noexcept: """ EXAMPLES:: @@ -1376,7 +1376,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): return res - cpdef _sub_(self, other_m): + cpdef _sub_(self, other_m) noexcept: """ EXAMPLES:: @@ -1444,7 +1444,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_set(res.denom, self.denom) return res - cpdef _mul_(self, other_m): + cpdef _mul_(self, other_m) noexcept: """ EXAMPLES:: @@ -1512,7 +1512,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): res._reduce_c_() return res - cpdef _rmul_(self, Element _c): + cpdef _rmul_(self, Element _c) noexcept: """ EXAMPLES:: @@ -1529,7 +1529,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): res._reduce_c_() return res - cpdef _lmul_(self, Element _c): + cpdef _lmul_(self, Element _c) noexcept: """ EXAMPLES:: @@ -1613,7 +1613,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): res._reduce_c_() return res - cpdef NumberFieldElement galois_conjugate(self): + cpdef NumberFieldElement galois_conjugate(self) noexcept: """ Return the image of this element under action of the nontrivial element of the Galois group of this field. @@ -1734,7 +1734,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpq_canonicalize(res.value) return res - cpdef bint is_one(self): + cpdef bint is_one(self) noexcept: r""" Check whether this number field element is `1`. @@ -1758,7 +1758,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_cmp_ui(self.b, 0) == 0 and mpz_cmp_ui(self.denom, 1) == 0) - cpdef bint is_rational(self): + cpdef bint is_rational(self) noexcept: r""" Check whether this number field element is a rational number. @@ -1931,7 +1931,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): mpz_neg(q.b, self.b) return q - cpdef list _coefficients(self): + cpdef list _coefficients(self) noexcept: """ EXAMPLES:: @@ -2417,7 +2417,7 @@ cdef class NumberFieldElement_quadratic_sqrt(NumberFieldElement_quadratic): mpz_set(denom.value, self.denom) return denom - cpdef list _coefficients(self): + cpdef list _coefficients(self) noexcept: """ EXAMPLES:: @@ -2557,7 +2557,7 @@ cdef class NumberFieldElement_gaussian(NumberFieldElement_quadratic_sqrt): return qqbar.AlgebraicReal(coeffs[0]) raise ValueError(f"unable to convert {self!r} to an element of {parent!r}") - cpdef real_part(self): + cpdef real_part(self) noexcept: r""" Real part. @@ -2579,7 +2579,7 @@ cdef class NumberFieldElement_gaussian(NumberFieldElement_quadratic_sqrt): real = real_part - cpdef imag_part(self): + cpdef imag_part(self) noexcept: r""" Imaginary part. @@ -2744,14 +2744,14 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic): else: return self.charpoly() - cdef number_field(self): + cdef number_field(self) noexcept: # So few functions actually use self.number_field() for quadratic elements, so # it is better *not* to return a cached value (since the call to _parent.number_field()) # is expensive. return self._parent.number_field() # We must override these since the basering is now ZZ not QQ. - cpdef _rmul_(self, Element _c): + cpdef _rmul_(self, Element _c) noexcept: """ EXAMPLES:: @@ -2771,7 +2771,7 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic): res._reduce_c_() return res - cpdef _lmul_(self, Element _c): + cpdef _lmul_(self, Element _c) noexcept: """ EXAMPLES:: @@ -2840,7 +2840,7 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic): R = self.parent() return R(_inverse_mod_generic(self, I)) - cpdef list _coefficients(self): + cpdef list _coefficients(self) noexcept: """ EXAMPLES:: @@ -2945,7 +2945,7 @@ cdef class Z_to_quadratic_field_element(Morphism): import sage.categories.homset Morphism.__init__(self, sage.categories.homset.Hom(ZZ, K)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Evaluate at an integer ``x``. @@ -3047,7 +3047,7 @@ cdef class Q_to_quadratic_field_element(Morphism): import sage.categories.homset Morphism.__init__(self, sage.categories.homset.Hom(QQ, K)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Evaluate at a rational ``x``. @@ -3099,7 +3099,7 @@ cdef class Q_to_quadratic_field_element(Morphism): ##################################################################### ## Helper function -cpdef bint is_sqrt_disc(Rational ad, Rational bd): +cpdef bint is_sqrt_disc(Rational ad, Rational bd) noexcept: r""" Return ``True`` if the pair ``(ad, bd)`` is `\sqrt{D}`. diff --git a/src/sage/rings/number_field/number_field_morphisms.pyx b/src/sage/rings/number_field/number_field_morphisms.pyx index 862b32ffc02..18c2c54d2f2 100644 --- a/src/sage/rings/number_field/number_field_morphisms.pyx +++ b/src/sage/rings/number_field/number_field_morphisms.pyx @@ -61,7 +61,7 @@ cdef class NumberFieldEmbedding(Morphism): else: self._gen_image = R(gen_embedding) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ A helper for pickling and copying. @@ -92,7 +92,7 @@ cdef class NumberFieldEmbedding(Morphism): slots['_gen_image'] = self._gen_image return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ A helper for unpickling and copying. @@ -118,7 +118,7 @@ cdef class NumberFieldEmbedding(Morphism): Morphism._update_slots(self, _slots) self._gen_image = _slots['_gen_image'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -321,7 +321,7 @@ cdef class EmbeddedNumberFieldConversion(Map): self.ambient_field = ambient_field Map.__init__(self, K, L) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -343,7 +343,7 @@ cdef class EmbeddedNumberFieldConversion(Map): return gen_image -cpdef matching_root(poly, target, ambient_field=None, margin=1, max_prec=None): +cpdef matching_root(poly, target, ambient_field=None, margin=1, max_prec=None) noexcept: """ Given a polynomial and a ``target``, choose the root that ``target`` best approximates as compared in ``ambient_field``. @@ -406,7 +406,7 @@ cpdef matching_root(poly, target, ambient_field=None, margin=1, max_prec=None): ambient_field = ambient_field.to_prec(ambient_field.prec() * 2) -cpdef closest(target, values, margin=1): +cpdef closest(target, values, margin=1) noexcept: """ This is a utility function that returns the item in ``values`` closest to target (with respect to the ``abs`` function). If ``margin`` is greater @@ -625,7 +625,7 @@ cdef class CyclotomicFieldEmbedding(NumberFieldEmbedding): self.ratio = L._log_gen(K.coerce_embedding()(K.gen())) self._gen_image = L.gen() ** self.ratio - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ A helper for pickling and copying. @@ -656,7 +656,7 @@ cdef class CyclotomicFieldEmbedding(NumberFieldEmbedding): slots['ratio'] = self.ratio return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ A helper for unpickling and copying. @@ -683,7 +683,7 @@ cdef class CyclotomicFieldEmbedding(NumberFieldEmbedding): self._gen_image = _slots['_gen_image'] self.ratio = _slots['ratio'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -764,7 +764,7 @@ cdef class CyclotomicFieldConversion(Map): self.phi = L.hom([M.gen()**(n3//n2)]) Map.__init__(self, K, L) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Call a conversion map between cyclotomic fields. diff --git a/src/sage/rings/number_field/totallyreal.pyx b/src/sage/rings/number_field/totallyreal.pyx index 87ae68a4d59..505bf92c35f 100644 --- a/src/sage/rings/number_field/totallyreal.pyx +++ b/src/sage/rings/number_field/totallyreal.pyx @@ -112,7 +112,7 @@ from sage.rings.number_field.totallyreal_data import tr_data, int_has_small_squa from sage.rings.number_field.totallyreal_data cimport tr_data -cpdef double odlyzko_bound_totallyreal(int n): +cpdef double odlyzko_bound_totallyreal(int n) noexcept: r""" This function returns the unconditional Odlyzko bound for the root discriminant of a totally real number field of degree `n`. diff --git a/src/sage/rings/number_field/totallyreal_data.pxd b/src/sage/rings/number_field/totallyreal_data.pxd index 57ab69dca8b..efa01dbb4b7 100644 --- a/src/sage/rings/number_field/totallyreal_data.pxd +++ b/src/sage/rings/number_field/totallyreal_data.pxd @@ -1,13 +1,13 @@ -cdef double eval_seq_as_poly(int *f, int n, double x) -cdef double newton(int *f, int *df, int n, double x0, double eps) -cdef void newton_in_intervals(int *f, int *df, int n, double *beta, double eps, double *rts) -cpdef lagrange_degree_3(int n, int an1, int an2, int an3) +cdef double eval_seq_as_poly(int *f, int n, double x) noexcept +cdef double newton(int *f, int *df, int n, double x0, double eps) noexcept +cdef void newton_in_intervals(int *f, int *df, int n, double *beta, double eps, double *rts) noexcept +cpdef lagrange_degree_3(int n, int an1, int an2, int an3) noexcept cimport sage.rings.integer -cdef int eval_seq_as_poly_int(int *f, int n, int x) +cdef int eval_seq_as_poly_int(int *f, int n, int x) noexcept -cdef int easy_is_irreducible(int *a, int n) +cdef int easy_is_irreducible(int *a, int n) noexcept cdef class tr_data: @@ -22,5 +22,5 @@ cdef class tr_data: cdef int *df - cdef void incr(self, int *f_out, int verbose, int haltk, int phc) + cdef void incr(self, int *f_out, int verbose, int haltk, int phc) noexcept diff --git a/src/sage/rings/number_field/totallyreal_data.pyx b/src/sage/rings/number_field/totallyreal_data.pyx index 84e292f79b2..e504fb6b45f 100644 --- a/src/sage/rings/number_field/totallyreal_data.pyx +++ b/src/sage/rings/number_field/totallyreal_data.pyx @@ -112,7 +112,7 @@ def hermite_constant(n): return gamma -cdef double eval_seq_as_poly(int *f, int n, double x): +cdef double eval_seq_as_poly(int *f, int n, double x) noexcept: r""" Evaluates the sequence a, thought of as a polynomial with @@ -129,7 +129,7 @@ cdef double eval_seq_as_poly(int *f, int n, double x): s = s * x + f[i] return s -cdef double newton(int *f, int *df, int n, double x0, double eps): +cdef double newton(int *f, int *df, int n, double x0, double eps) noexcept: r""" Find the real root x of f (with derivative df) near x0 with provable precision eps, i.e. |x-z| < eps where z is the actual @@ -174,7 +174,7 @@ cdef double newton(int *f, int *df, int n, double x0, double eps): return x cdef void newton_in_intervals(int *f, int *df, int n, double *beta, - double eps, double *rts): + double eps, double *rts) noexcept: r""" Find the real roots of f in the intervals specified by beta: @@ -192,7 +192,7 @@ cdef void newton_in_intervals(int *f, int *df, int n, double *beta, for i from 0 <= i < n: rts[i] = newton(f, df, n, (beta[i]+beta[i+1])/2, eps) -cpdef lagrange_degree_3(int n, int an1, int an2, int an3): +cpdef lagrange_degree_3(int n, int an1, int an2, int an3) noexcept: r""" Private function. Solves the equations which arise in the Lagrange multiplier for degree 3: for each `1 \leq r \leq n-2`, we solve @@ -346,7 +346,7 @@ def int_has_small_square_divisor(sage.rings.integer.Integer d): return asq -cdef int eval_seq_as_poly_int(int *f, int n, int x): +cdef int eval_seq_as_poly_int(int *f, int n, int x) noexcept: r""" Evaluates the sequence a, thought of as a polynomial with @@ -366,7 +366,7 @@ eps_abs = 10.**(-12) phi = 0.618033988749895 sqrt2 = 1.41421356237310 -cdef int easy_is_irreducible(int *a, int n): +cdef int easy_is_irreducible(int *a, int n) noexcept: r""" Very often, polynomials have roots in {+/-1, +/-2, +/-phi, sqrt2}, so we rule these out quickly. Returns 0 if reducible, 1 if inconclusive. @@ -635,7 +635,7 @@ cdef class tr_data: return g - cdef void incr(self, int *f_out, int verbose, int haltk, int phc): + cdef void incr(self, int *f_out, int verbose, int haltk, int phc) noexcept: r""" This function 'increments' the totally real data to the next value which satisfies the bounds essentially given by Rolle's diff --git a/src/sage/rings/padics/CA_template.pxi b/src/sage/rings/padics/CA_template.pxi index 152db86eaf9..cf4eb55a327 100644 --- a/src/sage/rings/padics/CA_template.pxi +++ b/src/sage/rings/padics/CA_template.pxi @@ -94,7 +94,7 @@ cdef class CAElement(pAdicTemplateElement): else: cconv(self.value, x, self.absprec, 0, self.prime_pow) - cdef CAElement _new_c(self): + cdef CAElement _new_c(self) noexcept: """ Create a new element with the same basic info. @@ -119,7 +119,7 @@ cdef class CAElement(pAdicTemplateElement): cconstruct(ans.value, ans.prime_pow) return ans - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec): + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept: """ Create a new element with a given value and absolute precision. @@ -196,7 +196,7 @@ cdef class CAElement(pAdicTemplateElement): """ return unpickle_cae_v2, (self.__class__, self.parent(), cpickle(self.value, self.prime_pow), self.absprec) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the additive inverse of this element. @@ -213,7 +213,7 @@ cdef class CAElement(pAdicTemplateElement): creduce_small(ans.value, ans.value, ans.absprec, ans.prime_pow) return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Return the sum of this element and ``_right``. @@ -237,7 +237,7 @@ cdef class CAElement(pAdicTemplateElement): creduce(ans.value, ans.value, ans.absprec, ans.prime_pow) return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Return the difference of this element and ``_right``. @@ -281,7 +281,7 @@ cdef class CAElement(pAdicTemplateElement): """ return ~self.parent().fraction_field()(self) - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ Return the product of this element and ``_right``. @@ -304,7 +304,7 @@ cdef class CAElement(pAdicTemplateElement): creduce(ans.value, ans.value, ans.absprec, ans.prime_pow) return ans - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Return the quotient of this element and ``right``. @@ -531,7 +531,7 @@ cdef class CAElement(pAdicTemplateElement): pright.value, rval, pright.absprec, self.prime_pow) return ans - cdef pAdicTemplateElement _lshift_c(self, long shift): + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept: r""" Multiplies by `\pi^{\mbox{shift}}`. @@ -563,7 +563,7 @@ cdef class CAElement(pAdicTemplateElement): cshift_notrunc(ans.value, self.value, shift, ans.absprec, ans.prime_pow, self.prime_pow.e > 1) return ans - cdef pAdicTemplateElement _rshift_c(self, long shift): + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept: r""" Divides by ``π^{\mbox{shift}}``. @@ -812,7 +812,7 @@ cdef class CAElement(pAdicTemplateElement): return 0 return ccmp(self.value, right.value, aprec, aprec < self.absprec, aprec < right.absprec, self.prime_pow) - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec): + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept: """ Return an arbitrary lift of this element to higher precision. @@ -995,7 +995,7 @@ cdef class CAElement(pAdicTemplateElement): mpz_set_si(ans.value, self.absprec - self.valuation_c()) return ans - cpdef pAdicTemplateElement unit_part(CAElement self): + cpdef pAdicTemplateElement unit_part(CAElement self) noexcept: r""" Return the unit part of this element. @@ -1015,7 +1015,7 @@ cdef class CAElement(pAdicTemplateElement): ans.absprec = (self).absprec - val return ans - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of this element. @@ -1043,7 +1043,7 @@ cdef class CAElement(pAdicTemplateElement): """ return cvaluation(self.value, self.absprec, self.prime_pow) - cpdef val_unit(self): + cpdef val_unit(self) noexcept: r""" Return a 2-tuple, the first element set to the valuation of this element, and the second to the unit part of this element. @@ -1112,7 +1112,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_CA_ZZ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1132,7 +1132,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1151,7 +1151,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1170,7 +1170,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): cconv_mpz_t(ans.value, (x).value, ans.absprec, True, ans.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1265,7 +1265,7 @@ cdef class pAdicConvert_CA_ZZ(RingMap): else: RingMap.__init__(self, Hom(R, ZZ, Sets())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1306,7 +1306,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): Morphism.__init__(self, Hom(QQ, R, SetsWithPartialMaps())) self._zero = R.element_class(R, 0) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1325,7 +1325,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1343,7 +1343,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): self._zero = _slots['_zero'] Morphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1362,7 +1362,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): ans.absprec = ans.prime_pow.ram_prec_cap return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1443,7 +1443,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): self._zero = K(0) self._section = pAdicConvert_CA_frac_field(K, R) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1467,7 +1467,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): ans._normalize() return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1543,7 +1543,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): self._section = copy.copy(self._section) return self._section - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1572,7 +1572,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1658,7 +1658,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): Morphism.__init__(self, Hom(K, R, SetsWithPartialMaps())) self._zero = R(0) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1689,7 +1689,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): ans.value._coeffs = [R(c) for c in ans.value._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1744,7 +1744,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): ans.value._coeffs = [R(c) for c in ans.value._coeffs] return ans - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1772,7 +1772,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. diff --git a/src/sage/rings/padics/CA_template_header.pxi b/src/sage/rings/padics/CA_template_header.pxi index d15a055cb4d..87194617daa 100644 --- a/src/sage/rings/padics/CA_template_header.pxi +++ b/src/sage/rings/padics/CA_template_header.pxi @@ -31,7 +31,7 @@ cdef class CAElement(pAdicTemplateElement): cdef celement value cdef long absprec - cdef CAElement _new_c(self) + cdef CAElement _new_c(self) noexcept cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): cdef CAElement _zero diff --git a/src/sage/rings/padics/CR_template.pxi b/src/sage/rings/padics/CR_template.pxi index 57ab352a66f..7c74f5ecc61 100644 --- a/src/sage/rings/padics/CR_template.pxi +++ b/src/sage/rings/padics/CR_template.pxi @@ -42,7 +42,7 @@ from sage.categories.sets_cat import Sets from sage.categories.sets_with_partial_maps import SetsWithPartialMaps from sage.categories.homset import Hom -cdef inline bint exactzero(long ordp): +cdef inline bint exactzero(long ordp) noexcept: """ Whether a given valuation represents an exact zero. """ @@ -176,7 +176,7 @@ cdef class CRElement(pAdicTemplateElement): self.ordp = absprec self.relprec = 0 - cdef CRElement _new_c(self): + cdef CRElement _new_c(self) noexcept: """ Creates a new element with the same basic info. @@ -203,7 +203,7 @@ cdef class CRElement(pAdicTemplateElement): cconstruct(ans.unit, ans.prime_pow) return ans - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec): + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept: """ Creates a new element with a given value and absolute precision. @@ -305,7 +305,7 @@ cdef class CRElement(pAdicTemplateElement): """ return unpickle_cre_v2, (self.__class__, self.parent(), cpickle(self.unit, self.prime_pow), self.ordp, self.relprec) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the additive inverse of this element. @@ -329,7 +329,7 @@ cdef class CRElement(pAdicTemplateElement): creduce(ans.unit, ans.unit, ans.relprec, ans.prime_pow) return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Return the sum of this element and ``_right``. @@ -373,7 +373,7 @@ cdef class CRElement(pAdicTemplateElement): creduce(ans.unit, ans.unit, ans.relprec, ans.prime_pow) return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Return the difference of this element and ``_right``. @@ -447,7 +447,7 @@ cdef class CRElement(pAdicTemplateElement): cinvert(ans.unit, self.unit, ans.relprec, ans.prime_pow) return ans - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: r""" Return the product of this element and ``_right``. @@ -478,7 +478,7 @@ cdef class CRElement(pAdicTemplateElement): check_ordp(ans.ordp) return ans - cpdef _div_(self, _right): + cpdef _div_(self, _right) noexcept: """ Return the quotient of this element and ``right``. @@ -731,7 +731,7 @@ cdef class CRElement(pAdicTemplateElement): ans.ordp = 0 return ans - cdef pAdicTemplateElement _lshift_c(self, long shift): + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept: r""" Multiplies by `\pi^{\mbox{shift}}`. @@ -762,7 +762,7 @@ cdef class CRElement(pAdicTemplateElement): ccopy(ans.unit, self.unit, ans.prime_pow) return ans - cdef pAdicTemplateElement _rshift_c(self, long shift): + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept: r""" Divides by ``\pi^{\mbox{shift}}``. @@ -1192,7 +1192,7 @@ cdef class CRElement(pAdicTemplateElement): return 0 return ccmp(self.unit, right.unit, rprec, rprec < self.relprec, rprec < right.relprec, self.prime_pow) - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec): + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept: """ Lifts this element to another with precision at least ``absprec``. @@ -1415,7 +1415,7 @@ cdef class CRElement(pAdicTemplateElement): mpz_set_si(ans.value, self.relprec) return ans - cpdef pAdicTemplateElement unit_part(self): + cpdef pAdicTemplateElement unit_part(self) noexcept: r""" Return `u`, where this element is `\pi^v u`. @@ -1459,7 +1459,7 @@ cdef class CRElement(pAdicTemplateElement): ccopy(ans.unit, (self).unit, ans.prime_pow) return ans - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of this element. @@ -1478,7 +1478,7 @@ cdef class CRElement(pAdicTemplateElement): """ return self.ordp - cpdef val_unit(self, p=None): + cpdef val_unit(self, p=None) noexcept: """ Return a pair ``(self.valuation(), self.unit_part())``. @@ -1568,7 +1568,7 @@ cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_CR_ZZ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1594,7 +1594,7 @@ cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1620,7 +1620,7 @@ cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1639,7 +1639,7 @@ cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): ans.ordp = cconv_mpz_t(ans.unit, (x).value, ans.relprec, False, ans.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both), or an empty element is @@ -1735,7 +1735,7 @@ cdef class pAdicConvert_CR_ZZ(RingMap): else: RingMap.__init__(self, Hom(R, ZZ, Sets())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1786,7 +1786,7 @@ cdef class pAdicCoercion_QQ_CR(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_CR_QQ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1812,7 +1812,7 @@ cdef class pAdicCoercion_QQ_CR(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1838,7 +1838,7 @@ cdef class pAdicCoercion_QQ_CR(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1859,7 +1859,7 @@ cdef class pAdicCoercion_QQ_CR(RingHomomorphism): ans.ordp = cconv_mpq_t(ans.unit, (x).value, ans.relprec, False, self._zero.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both), or an empty element is @@ -1953,7 +1953,7 @@ cdef class pAdicConvert_CR_QQ(RingMap): else: RingMap.__init__(self, Hom(R, QQ, Sets())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -2000,7 +2000,7 @@ cdef class pAdicConvert_QQ_CR(Morphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_CR_QQ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -2020,7 +2020,7 @@ cdef class pAdicConvert_QQ_CR(Morphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -2039,7 +2039,7 @@ cdef class pAdicConvert_QQ_CR(Morphism): self._section = _slots['_section'] Morphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -2060,7 +2060,7 @@ cdef class pAdicConvert_QQ_CR(Morphism): raise ValueError("p divides the denominator") return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both), or an empty element is @@ -2162,7 +2162,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): self._zero = K(0) self._section = pAdicConvert_CR_frac_field(K, R) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -2187,7 +2187,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -2267,7 +2267,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): self._section = copy.copy(self._section) return self._section - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -2296,7 +2296,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -2382,7 +2382,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): Morphism.__init__(self, Hom(K, R, SetsWithPartialMaps())) self._zero = R(0) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -2407,7 +2407,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -2466,7 +2466,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -2494,7 +2494,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. diff --git a/src/sage/rings/padics/CR_template_header.pxi b/src/sage/rings/padics/CR_template_header.pxi index 54c482f7ff2..b969463bc72 100644 --- a/src/sage/rings/padics/CR_template_header.pxi +++ b/src/sage/rings/padics/CR_template_header.pxi @@ -32,9 +32,9 @@ cdef class CRElement(pAdicTemplateElement): cdef long ordp cdef long relprec - cdef CRElement _new_c(self) + cdef CRElement _new_c(self) noexcept cdef int _normalize(self) except -1 - cpdef val_unit(self, p=*) + cpdef val_unit(self, p=*) noexcept cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): cdef CRElement _zero diff --git a/src/sage/rings/padics/FM_template.pxi b/src/sage/rings/padics/FM_template.pxi index e319255a85c..3e4a9fdc4cb 100644 --- a/src/sage/rings/padics/FM_template.pxi +++ b/src/sage/rings/padics/FM_template.pxi @@ -89,7 +89,7 @@ cdef class FMElement(pAdicTemplateElement): else: cconv(self.value, x, self.prime_pow.ram_prec_cap, 0, self.prime_pow) - cdef FMElement _new_c(self): + cdef FMElement _new_c(self) noexcept: """ Creates a new element with the same basic info. @@ -108,7 +108,7 @@ cdef class FMElement(pAdicTemplateElement): cconstruct(ans.value, ans.prime_pow) return ans - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec): + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept: """ Creates a new element with a given value and absolute precision. @@ -179,7 +179,7 @@ cdef class FMElement(pAdicTemplateElement): """ return unpickle_fme_v2, (self.__class__, self.parent(), cpickle(self.value, self.prime_pow)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the additive inverse of this element. @@ -194,7 +194,7 @@ cdef class FMElement(pAdicTemplateElement): creduce_small(ans.value, ans.value, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: r""" Return the sum of this element and ``_right``. @@ -214,7 +214,7 @@ cdef class FMElement(pAdicTemplateElement): creduce_small(ans.value, ans.value, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: r""" Return the difference of this element and ``_right``. @@ -259,7 +259,7 @@ cdef class FMElement(pAdicTemplateElement): cinvert(ans.value, self.value, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: r""" Return the product of this element and ``_right``. @@ -277,7 +277,7 @@ cdef class FMElement(pAdicTemplateElement): creduce(ans.value, ans.value, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _div_(self, _right): + cpdef _div_(self, _right) noexcept: r""" Return the quotient of this element and ``right``. ``right`` must have valuation zero. @@ -379,7 +379,7 @@ cdef class FMElement(pAdicTemplateElement): cpow(ans.value, self.value, right.value, self.prime_pow.ram_prec_cap, self.prime_pow) return ans - cdef pAdicTemplateElement _lshift_c(self, long shift): + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept: r""" Multiplies self by `\pi^{shift}`. @@ -426,7 +426,7 @@ cdef class FMElement(pAdicTemplateElement): cshift_notrunc(ans.value, self.value, shift, ans.prime_pow.ram_prec_cap, ans.prime_pow, True) return ans - cdef pAdicTemplateElement _rshift_c(self, long shift): + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept: r""" Divides by `\pi^{shift}`, and truncates. @@ -647,7 +647,7 @@ cdef class FMElement(pAdicTemplateElement): cdef FMElement right = _right return ccmp(self.value, right.value, self.prime_pow.ram_prec_cap, False, False, self.prime_pow) - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec): + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept: """ Lifts this element to another with precision at least absprec. @@ -777,7 +777,7 @@ cdef class FMElement(pAdicTemplateElement): mpz_set_si(ans.value, self.prime_pow.ram_prec_cap - self.valuation_c()) return ans - cpdef pAdicTemplateElement unit_part(FMElement self): + cpdef pAdicTemplateElement unit_part(FMElement self) noexcept: r""" Return the unit part of ``self``. @@ -802,7 +802,7 @@ cdef class FMElement(pAdicTemplateElement): cremove(ans.value, (self).value, (self).prime_pow.ram_prec_cap, (self).prime_pow) return ans - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of this element. @@ -833,7 +833,7 @@ cdef class FMElement(pAdicTemplateElement): # for backward compatibility return cvaluation(self.value, self.prime_pow.ram_prec_cap, self.prime_pow) - cpdef val_unit(self): + cpdef val_unit(self) noexcept: """ Return a 2-tuple, the first element set to the valuation of ``self``, and the second to the unit part of ``self``. @@ -895,7 +895,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_FM_ZZ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -915,7 +915,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -934,7 +934,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -952,7 +952,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): cconv_mpz_t(ans.value, (x).value, ans.prime_pow.ram_prec_cap, True, ans.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1038,7 +1038,7 @@ cdef class pAdicConvert_FM_ZZ(RingMap): else: RingMap.__init__(self, Hom(R, ZZ, Sets())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1079,7 +1079,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): Morphism.__init__(self, Hom(QQ, R, SetsWithPartialMaps())) self._zero = R.element_class(R, 0) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1098,7 +1098,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1116,7 +1116,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): self._zero = _slots['_zero'] Morphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1134,7 +1134,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): cconv_mpq_t(ans.value, (x).value, ans.prime_pow.ram_prec_cap, True, ans.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1206,7 +1206,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): self._zero = K(0) self._section = pAdicConvert_FM_frac_field(K, R) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1229,7 +1229,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1298,7 +1298,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): self._section = copy.copy(self._section) return self._section - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1326,7 +1326,7 @@ cdef class pAdicCoercion_FM_frac_field(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1412,7 +1412,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): Morphism.__init__(self, Hom(K, R, SetsWithPartialMaps())) self._zero = R(0) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1437,7 +1437,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): ans.value._coeffs = [R(c) for c in ans.value._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1485,7 +1485,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): ans.value._coeffs = [R(c) for c in ans.value._coeffs] return ans - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1513,7 +1513,7 @@ cdef class pAdicConvert_FM_frac_field(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. diff --git a/src/sage/rings/padics/FM_template_header.pxi b/src/sage/rings/padics/FM_template_header.pxi index bd651167622..d9ecc7d0715 100644 --- a/src/sage/rings/padics/FM_template_header.pxi +++ b/src/sage/rings/padics/FM_template_header.pxi @@ -31,7 +31,7 @@ cdef class FMElement(pAdicTemplateElement): cdef celement value cdef long absprec - cdef FMElement _new_c(self) + cdef FMElement _new_c(self) noexcept cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): cdef FMElement _zero diff --git a/src/sage/rings/padics/FP_template.pxi b/src/sage/rings/padics/FP_template.pxi index 695e66e2712..e4950778756 100644 --- a/src/sage/rings/padics/FP_template.pxi +++ b/src/sage/rings/padics/FP_template.pxi @@ -45,7 +45,7 @@ from sage.categories.sets_cat import Sets from sage.categories.sets_with_partial_maps import SetsWithPartialMaps from sage.categories.homset import Hom -cdef inline bint overunderflow(long* ordp, celement unit, PowComputer_ prime_pow): +cdef inline bint overunderflow(long* ordp, celement unit, PowComputer_ prime_pow) noexcept: """ Check for over and underflow. If detected, sets ordp and unit appropriately, and returns True. If not, returns False. @@ -60,7 +60,7 @@ cdef inline bint overunderflow(long* ordp, celement unit, PowComputer_ prime_pow return False return True -cdef inline bint overunderflow_mpz(long* ordp, mpz_t ordp_mpz, celement unit, PowComputer_ prime_pow): +cdef inline bint overunderflow_mpz(long* ordp, mpz_t ordp_mpz, celement unit, PowComputer_ prime_pow) noexcept: """ Check for over and underflow with an mpz_t ordp. If detected, sets ordp and unit appropriately, and returns True. If not, returns False. @@ -75,13 +75,13 @@ cdef inline bint overunderflow_mpz(long* ordp, mpz_t ordp_mpz, celement unit, Po return True return False -cdef inline bint very_pos_val(long ordp): +cdef inline bint very_pos_val(long ordp) noexcept: return ordp >= maxordp -cdef inline bint very_neg_val(long ordp): +cdef inline bint very_neg_val(long ordp) noexcept: return ordp <= minusmaxordp -cdef inline bint huge_val(long ordp): +cdef inline bint huge_val(long ordp) noexcept: return very_pos_val(ordp) or very_neg_val(ordp) cdef class FPElement(pAdicTemplateElement): @@ -171,7 +171,7 @@ cdef class FPElement(pAdicTemplateElement): csetone(self.unit, self.prime_pow) self.ordp = minusmaxordp - cdef FPElement _new_c(self): + cdef FPElement _new_c(self) noexcept: """ Creates a new element with the same basic info. @@ -196,7 +196,7 @@ cdef class FPElement(pAdicTemplateElement): cconstruct(ans.unit, ans.prime_pow) return ans - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec): + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept: """ Creates a new element with a given value and absolute precision. @@ -312,7 +312,7 @@ cdef class FPElement(pAdicTemplateElement): # """ # return (self)._richcmp(right, op) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the additive inverse of this element. @@ -331,7 +331,7 @@ cdef class FPElement(pAdicTemplateElement): creduce_small(ans.unit, ans.unit, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: r""" Return the sum of this element and ``_right``. @@ -375,7 +375,7 @@ cdef class FPElement(pAdicTemplateElement): creduce(ans.unit, ans.unit, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: r""" Return the difference of this element and ``_right``. @@ -454,7 +454,7 @@ cdef class FPElement(pAdicTemplateElement): cinvert(ans.unit, self.unit, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: r""" Return the product of this element and ``_right``. @@ -487,7 +487,7 @@ cdef class FPElement(pAdicTemplateElement): creduce(ans.unit, ans.unit, ans.prime_pow.ram_prec_cap, ans.prime_pow) return ans - cpdef _div_(self, _right): + cpdef _div_(self, _right) noexcept: r""" Return the quotient of this element and ``right``. @@ -663,7 +663,7 @@ cdef class FPElement(pAdicTemplateElement): ans.ordp = 0 return ans - cdef pAdicTemplateElement _lshift_c(self, long shift): + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept: r""" Multiplies self by `\pi^{shift}`. @@ -716,7 +716,7 @@ cdef class FPElement(pAdicTemplateElement): ccopy(ans.unit, self.unit, ans.prime_pow) return ans - cdef pAdicTemplateElement _rshift_c(self, long shift): + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept: r""" Divides by `\pi^{shift}`. @@ -985,7 +985,7 @@ cdef class FPElement(pAdicTemplateElement): cdef FPElement right = _right return ccmp(self.unit, right.unit, self.prime_pow.ram_prec_cap, False, False, self.prime_pow) - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec): + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept: """ Lift this element to another with precision at least absprec. @@ -1134,7 +1134,7 @@ cdef class FPElement(pAdicTemplateElement): mpz_set_si(ans.value, self.prime_pow.ram_prec_cap) return ans - cpdef pAdicTemplateElement unit_part(FPElement self): + cpdef pAdicTemplateElement unit_part(FPElement self) noexcept: r""" Return the unit part of this element. @@ -1164,7 +1164,7 @@ cdef class FPElement(pAdicTemplateElement): ccopy(ans.unit, (self).unit, ans.prime_pow) return ans - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of this element. @@ -1201,7 +1201,7 @@ cdef class FPElement(pAdicTemplateElement): """ return self.ordp - cpdef val_unit(self, p=None): + cpdef val_unit(self, p=None) noexcept: """ Return a 2-tuple, the first element set to the valuation of this element, and the second to the unit part. @@ -1275,7 +1275,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_FP_ZZ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1295,7 +1295,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1314,7 +1314,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1332,7 +1332,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): ans.ordp = cconv_mpz_t(ans.unit, (x).value, ans.prime_pow.ram_prec_cap, False, ans.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1426,7 +1426,7 @@ cdef class pAdicConvert_FP_ZZ(RingMap): else: RingMap.__init__(self, Hom(R, ZZ, Sets())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1487,7 +1487,7 @@ cdef class pAdicCoercion_QQ_FP(RingHomomorphism): self._zero = R.element_class(R, 0) self._section = pAdicConvert_FP_QQ(R) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1513,7 +1513,7 @@ cdef class pAdicCoercion_QQ_FP(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1538,7 +1538,7 @@ cdef class pAdicCoercion_QQ_FP(RingHomomorphism): self._section = _slots['_section'] RingHomomorphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1560,7 +1560,7 @@ cdef class pAdicCoercion_QQ_FP(RingHomomorphism): ans.ordp = cconv_mpq_t(ans.unit, (x).value, ans.prime_pow.ram_prec_cap, False, self._zero.prime_pow) return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1643,7 +1643,7 @@ cdef class pAdicConvert_FP_QQ(RingMap): """ RingMap.__init__(self, Hom(R, QQ, SetsWithPartialMaps())) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: """ Evaluation. @@ -1690,7 +1690,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): Morphism.__init__(self, Hom(QQ, R, SetsWithPartialMaps())) self._zero = R.element_class(R, 0) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -1709,7 +1709,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -1727,7 +1727,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): self._zero = _slots['_zero'] Morphism._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluation. @@ -1747,7 +1747,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): raise ValueError("p divides the denominator") return ans - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ This function is used when some precision cap is passed in (relative or absolute or both). @@ -1827,7 +1827,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): self._zero = K(0) self._section = pAdicConvert_FP_frac_field(K, R) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: r""" Evaluation. @@ -1851,7 +1851,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: r""" This function is used when some precision cap is passed in (relative or absolute or both). @@ -1920,7 +1920,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): """ return self._section - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: r""" Helper for copying and pickling. @@ -1948,7 +1948,7 @@ cdef class pAdicCoercion_FP_frac_field(RingHomomorphism): _slots['_section'] = self.section() # use method since it copies coercion-internal sections. return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: r""" Helper for copying and pickling. @@ -2003,7 +2003,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): Morphism.__init__(self, Hom(K, R, SetsWithPartialMaps())) self._zero = R(0) - cpdef Element _call_(self, _x): + cpdef Element _call_(self, _x) noexcept: r""" Evaluation. @@ -2027,7 +2027,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cpdef Element _call_with_args(self, _x, args=(), kwds={}): + cpdef Element _call_with_args(self, _x, args=(), kwds={}) noexcept: r""" This function is used when some precision cap is passed in (relative or absolute or both). @@ -2083,7 +2083,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): ans.unit._coeffs = [K(c) for c in ans.unit._coeffs] return ans - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: r""" Helper for copying and pickling. @@ -2111,7 +2111,7 @@ cdef class pAdicConvert_FP_frac_field(Morphism): _slots['_zero'] = self._zero return _slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: r""" Helper for copying and pickling. diff --git a/src/sage/rings/padics/FP_template_header.pxi b/src/sage/rings/padics/FP_template_header.pxi index fde598e05fd..108d8042850 100644 --- a/src/sage/rings/padics/FP_template_header.pxi +++ b/src/sage/rings/padics/FP_template_header.pxi @@ -31,10 +31,10 @@ cdef class FPElement(pAdicTemplateElement): cdef celement unit cdef long ordp - cdef FPElement _new_c(self) + cdef FPElement _new_c(self) noexcept cdef int _normalize(self) except -1 cdef int _set_infinity(self) except -1 - cpdef val_unit(self, p=*) + cpdef val_unit(self, p=*) noexcept cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): cdef FPElement _zero diff --git a/src/sage/rings/padics/local_generic_element.pyx b/src/sage/rings/padics/local_generic_element.pyx index 0db91750eca..6177f74c047 100644 --- a/src/sage/rings/padics/local_generic_element.pyx +++ b/src/sage/rings/padics/local_generic_element.pyx @@ -32,7 +32,7 @@ cdef class LocalGenericElement(CommutativeRingElement): #cpdef _add_(self, right): # raise NotImplementedError - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: r""" Returns the quotient of ``self`` by ``right``. @@ -433,7 +433,7 @@ cdef class LocalGenericElement(CommutativeRingElement): #def __pow__(self, right): # raise NotImplementedError - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Returns the difference between ``self`` and ``right``. diff --git a/src/sage/rings/padics/morphism.pxd b/src/sage/rings/padics/morphism.pxd index b6afedd2377..a904ba14ca0 100644 --- a/src/sage/rings/padics/morphism.pxd +++ b/src/sage/rings/padics/morphism.pxd @@ -7,4 +7,4 @@ cdef class FrobeniusEndomorphism_padics(RingHomomorphism): cdef long _power cdef long _order - cpdef Element _call_(self, x) + cpdef Element _call_(self, x) noexcept diff --git a/src/sage/rings/padics/morphism.pyx b/src/sage/rings/padics/morphism.pyx index b29fc204b43..87aa8fef1a7 100644 --- a/src/sage/rings/padics/morphism.pyx +++ b/src/sage/rings/padics/morphism.pyx @@ -85,7 +85,7 @@ cdef class FrobeniusEndomorphism_padics(RingHomomorphism): self._order = self._degree / domain.absolute_f().gcd(self._power) RingHomomorphism.__init__(self, Hom(domain, domain)) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -104,7 +104,7 @@ cdef class FrobeniusEndomorphism_padics(RingHomomorphism): slots['_order'] = self._order return slots - cdef _update_slots(self, dict slots): + cdef _update_slots(self, dict slots) noexcept: """ Helper for copying and pickling. @@ -165,7 +165,7 @@ cdef class FrobeniusEndomorphism_padics(RingHomomorphism): s = "Frob^%s" % self._power return s - cpdef Element _call_ (self, x): + cpdef Element _call_ (self, x) noexcept: """ TESTS:: @@ -329,7 +329,7 @@ cdef class FrobeniusEndomorphism_padics(RingHomomorphism): codomain = self.codomain() return hash((domain, codomain, ('Frob', self._power))) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare ``left`` and ``right`` diff --git a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pxd b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pxd index 7afe94b1bf3..2bcb237be77 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pxd +++ b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pxd @@ -13,12 +13,12 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): cdef int _set(self, ZZ_pX_c* value, long absprec) except -1 cdef int _set_from_mpq_part2(self, mpq_t x) except -1 - cpdef pAdicZZpXCRElement to_fraction_field(self) - cdef pAdicZZpXCAElement _new_c(self, long absprec) - cdef pAdicZZpXCAElement _lshift_c(self, long n) - cdef pAdicZZpXCAElement _rshift_c(self, long n) - cpdef pAdicZZpXCAElement unit_part(self) - cpdef _ntl_rep_abs(self) - cpdef ntl_ZZ_pX _ntl_rep(self) + cpdef pAdicZZpXCRElement to_fraction_field(self) noexcept + cdef pAdicZZpXCAElement _new_c(self, long absprec) noexcept + cdef pAdicZZpXCAElement _lshift_c(self, long n) noexcept + cdef pAdicZZpXCAElement _rshift_c(self, long n) noexcept + cpdef pAdicZZpXCAElement unit_part(self) noexcept + cpdef _ntl_rep_abs(self) noexcept + cpdef ntl_ZZ_pX _ntl_rep(self) noexcept - cpdef pAdicZZpXCAElement lift_to_precision(self, absprec=*) + cpdef pAdicZZpXCAElement lift_to_precision(self, absprec=*) noexcept diff --git a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx index 0f5270a9980..b13f79ea6f2 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx @@ -836,7 +836,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): else: self._set_prec_abs(ordp + relprec) - cdef pAdicZZpXCAElement _new_c(self, long absprec): + cdef pAdicZZpXCAElement _new_c(self, long absprec) noexcept: """ Returns a new element with the same parent as ``self`` and absolute precision ``absprec``. @@ -934,7 +934,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): """ return ~self.to_fraction_field() - cpdef pAdicZZpXCRElement to_fraction_field(self): + cpdef pAdicZZpXCRElement to_fraction_field(self) noexcept: """ Returns ``self`` cast into the fraction field of ``self.parent()``. @@ -961,7 +961,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ans.unit = self.value return ans - cdef pAdicZZpXCAElement _lshift_c(self, long n): + cdef pAdicZZpXCAElement _lshift_c(self, long n) noexcept: """ Multiplies ``self`` by the uniformizer raised to the power ``n``. If ``n`` is negative, right shifts by ``-n``. @@ -1012,7 +1012,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): return ans return self._rshift_c(-mpz_get_si((shift).value)) - cdef pAdicZZpXCAElement _rshift_c(self, long n): + cdef pAdicZZpXCAElement _rshift_c(self, long n) noexcept: """ Divides ``self`` by the uniformizer raised to the power ``n``. If parent is not a field, throws away the non-positive part of @@ -1110,7 +1110,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): return ans return self._rshift_c(mpz_get_si((shift).value)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Returns ``-self``. @@ -1376,7 +1376,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sig_off() return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Computes the sum of ``self`` and ``right``. @@ -1414,7 +1414,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ZZ_pX_add(ans.value, tmpP, right.value) return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Returns the difference of ``self`` and ``right``. @@ -1455,7 +1455,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ZZ_pX_sub(ans.value, tmpP, right.value) return ans - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ Returns the product of ``self`` and ``right``. @@ -1508,7 +1508,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ZZ_pX_MulMod_pre(ans.value, self_adapted, right_adapted, self.prime_pow.get_modulus_capdiv(ans_absprec)[0]) return ans - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Returns the quotient of ``self`` by ``right``. @@ -1640,7 +1640,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ans = (self.valuation_c() >= aprec) return ans - cpdef ntl_ZZ_pX _ntl_rep(self): + cpdef ntl_ZZ_pX _ntl_rep(self) noexcept: """ Return an ``ntl_ZZ_pX`` that holds the value of ``self``. @@ -1662,7 +1662,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): ans.x = self.value return ans - cpdef _ntl_rep_abs(self): + cpdef _ntl_rep_abs(self) noexcept: """ Return a pair ``(f, 0)`` where ``f = self._ntl_rep()``. @@ -1742,7 +1742,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): S = R[var] return S(self._polynomial_list()) - cdef ZZ_p_c _const_term(self): + cdef ZZ_p_c _const_term(self) noexcept: """ Returns the constant term of ``self.value``. @@ -1781,7 +1781,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): # Should be sped up later return (self - right).is_zero(absprec) - cpdef pAdicZZpXCAElement lift_to_precision(self, absprec=None): + cpdef pAdicZZpXCAElement lift_to_precision(self, absprec=None) noexcept: """ Returns a ``pAdicZZpXCAElement`` congruent to ``self`` but with absolute precision at least ``absprec``. @@ -2215,7 +2215,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): # """ # raise NotImplementedError - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Returns the valuation of ``self``. @@ -2252,7 +2252,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): else: return self.absprec - cpdef pAdicZZpXCAElement unit_part(self): + cpdef pAdicZZpXCAElement unit_part(self) noexcept: """ Returns the unit part of ``self``, ie ``self / uniformizer^(self.valuation())`` @@ -2275,7 +2275,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): """ return self._rshift_c(self.valuation_c()) - cdef ext_p_list(self, bint pos): + cdef ext_p_list(self, bint pos) noexcept: """ Returns a list of integers (in the Eisenstein case) or a list of lists of integers (in the unramified case). ``self`` can diff --git a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pxd b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pxd index 9744b2a3f62..4d458507ee0 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pxd +++ b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pxd @@ -19,14 +19,14 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): cdef int _set_from_ZZ_pX_part1(self, ZZ_pX_c* poly) except -1 cdef int _set_from_ZZ_pX_part2(self, ZZ_pX_c* poly) except -1 - cdef pAdicZZpXCRElement _new_c(self, long relprec) + cdef pAdicZZpXCRElement _new_c(self, long relprec) noexcept cdef int _internal_lshift(self, long shift) except -1 cdef int _normalize(self) except -1 - cdef pAdicZZpXCRElement _lshift_c(self, long n) - cdef pAdicZZpXCRElement _rshift_c(self, long n) - cpdef pAdicZZpXCRElement unit_part(self) - cpdef ntl_ZZ_pX _ntl_rep_unnormalized(self) - cpdef _ntl_rep_abs(self) - cpdef ntl_ZZ_pX _ntl_rep(self) + cdef pAdicZZpXCRElement _lshift_c(self, long n) noexcept + cdef pAdicZZpXCRElement _rshift_c(self, long n) noexcept + cpdef pAdicZZpXCRElement unit_part(self) noexcept + cpdef ntl_ZZ_pX _ntl_rep_unnormalized(self) noexcept + cpdef _ntl_rep_abs(self) noexcept + cpdef ntl_ZZ_pX _ntl_rep(self) noexcept - cpdef pAdicZZpXCRElement lift_to_precision(self, absprec=*) + cpdef pAdicZZpXCRElement lift_to_precision(self, absprec=*) noexcept diff --git a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx index 8a8828a5712..f0406955abe 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx @@ -1468,7 +1468,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): shift = shift >> 1 i += 1 - cdef pAdicZZpXCRElement _new_c(self, long relprec): + cdef pAdicZZpXCRElement _new_c(self, long relprec) noexcept: """ Return a new element with the same parent as ``self`` and relative precision ``relprec`` @@ -1593,7 +1593,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sig_off() return ans - cdef pAdicZZpXCRElement _lshift_c(self, long n): + cdef pAdicZZpXCRElement _lshift_c(self, long n) noexcept: """ Multiplies ``self`` by the uniformizer raised to the power ``n``. If ``n`` is negative, right shifts by ``-n``. @@ -1660,7 +1660,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): return ans return self._lshift_c(mpz_get_si((shift).value)) - cdef pAdicZZpXCRElement _rshift_c(self, long n): + cdef pAdicZZpXCRElement _rshift_c(self, long n) noexcept: """ Divides self by the uniformizer raised to the power ``n``. If parent is not a field, throws away the non-positive part of @@ -1763,7 +1763,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): return ans return self._rshift_c(mpz_get_si((shift).value)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Negation @@ -2043,7 +2043,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sig_off() return ans - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Compute the sum of ``self`` and ``right``. @@ -2160,7 +2160,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): ans.relprec = -ans.relprec return ans - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return the difference of two elements @@ -2186,7 +2186,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): # For now, a simple implementation return self + (-right) - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ Return the product of two elements @@ -2239,7 +2239,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sig_off() return ans - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Return the quotient of two elements @@ -2383,7 +2383,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): ans = (self.ordp >= aprec) return ans - cpdef ntl_ZZ_pX _ntl_rep_unnormalized(self): + cpdef ntl_ZZ_pX _ntl_rep_unnormalized(self) noexcept: """ Return an ``ntl_ZZ_pX`` holding the current unit part of this element @@ -2412,7 +2412,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): ans.x = self.unit return ans - cpdef ntl_ZZ_pX _ntl_rep(self): + cpdef ntl_ZZ_pX _ntl_rep(self) noexcept: """ Return an ``ntl_ZZ_pX`` that holds the unit part of this element @@ -2433,7 +2433,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): self._normalize() return self._ntl_rep_unnormalized() - cpdef _ntl_rep_abs(self): + cpdef _ntl_rep_abs(self) noexcept: """ Return a pair ``(f, k)`` where ``f`` is an ``ntl_ZZ_pX`` and ``k`` is a non-positive integer such that ``self = f(self.parent.gen())*p^k`` @@ -2571,7 +2571,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): S = R[var] return S(self._polynomial_list()) - cdef ZZ_p_c _const_term(self): + cdef ZZ_p_c _const_term(self) noexcept: """ Return the constant term of ``self.unit``. @@ -2619,7 +2619,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): # """ # raise NotImplementedError - cpdef pAdicZZpXCRElement lift_to_precision(self, absprec=None): + cpdef pAdicZZpXCRElement lift_to_precision(self, absprec=None) noexcept: """ Return a ``pAdicZZpXCRElement`` congruent to this element but with absolute precision at least ``absprec``. @@ -3143,7 +3143,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): # """ # raise NotImplementedError - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of this element. @@ -3167,7 +3167,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): self._normalize() return self.ordp - cpdef pAdicZZpXCRElement unit_part(self): + cpdef pAdicZZpXCRElement unit_part(self) noexcept: """ Return the unit part of this element, ie ``self / uniformizer^(self.valuation())``. @@ -3205,7 +3205,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): ans.unit = self.unit return ans - cdef ext_p_list(self, bint pos): + cdef ext_p_list(self, bint pos) noexcept: """ Return a list of integers (in the Eisenstein case) or a list of lists of integers (in the unramified case). ``self`` can be diff --git a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pxd b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pxd index 90626089442..33754581e48 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pxd +++ b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pxd @@ -4,8 +4,8 @@ from sage.structure.element cimport RingElement, ModuleElement cdef class pAdicZZpXFMElement(pAdicZZpXElement): cdef ZZ_pX_c value - cdef pAdicZZpXFMElement _new_c(self) - cdef pAdicZZpXFMElement _lshift_c(self, long n) - cdef pAdicZZpXFMElement _rshift_c(self, long n) + cdef pAdicZZpXFMElement _new_c(self) noexcept + cdef pAdicZZpXFMElement _lshift_c(self, long n) noexcept + cdef pAdicZZpXFMElement _rshift_c(self, long n) noexcept - cpdef pAdicZZpXFMElement unit_part(self) + cpdef pAdicZZpXFMElement unit_part(self) noexcept diff --git a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx index ec5e833662f..70d09266445 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx @@ -415,7 +415,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): holder.x = self.value return make_ZZpXFMElement, (self.parent(), holder) - cdef pAdicZZpXFMElement _new_c(self): + cdef pAdicZZpXFMElement _new_c(self) noexcept: """ Return a new element with the same parent as ``self``. @@ -434,7 +434,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): ans.prime_pow = self.prime_pow return ans - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ First compare valuations, then compare the values. @@ -504,7 +504,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sig_off() return ans - cdef pAdicZZpXFMElement _lshift_c(self, long n): + cdef pAdicZZpXFMElement _lshift_c(self, long n) noexcept: """ Multiply ``self`` by the uniformizer raised to the power ``n``. @@ -565,7 +565,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): return ans return self._lshift_c(mpz_get_si((shift).value)) - cdef pAdicZZpXFMElement _rshift_c(self, long n): + cdef pAdicZZpXFMElement _rshift_c(self, long n) noexcept: """ Divide ``self`` by the uniformizer raised to the power ``n``. @@ -656,7 +656,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): return ans return self._rshift_c(mpz_get_si((shift).value)) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Returns ``-self``. @@ -747,7 +747,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sig_off() return ans - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Return ``self`` + ``right``. @@ -766,7 +766,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): ZZ_pX_add(ans.value, self.value, (right).value) return ans - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Return the product of ``self`` and ``right``. @@ -790,7 +790,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): ZZ_pX_MulMod_pre(ans.value, self.value, (right).value, self.prime_pow.get_top_modulus()[0]) return ans - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return the difference of ``self`` and ``right``. @@ -813,7 +813,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): ZZ_pX_sub(ans.value, self.value, (right).value) return ans - cpdef _div_(self, _right): + cpdef _div_(self, _right) noexcept: """ Returns the quotient of ``self`` by ``right``. @@ -1205,7 +1205,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): S = R[var] return S(self._polynomial_list()) - cdef ZZ_p_c _const_term(self): + cdef ZZ_p_c _const_term(self) noexcept: """ Return the constant term of ``self.unit``. @@ -1591,7 +1591,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): mpz_set_ui(ans.value, self.prime_pow.ram_prec_cap - self.valuation_c()) return ans - cpdef pAdicZZpXFMElement unit_part(self): + cpdef pAdicZZpXFMElement unit_part(self) noexcept: """ Return the unit part of ``self``, ie ``self / uniformizer^(self.valuation())`` @@ -1629,7 +1629,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): """ return self._rshift_c(self.valuation_c()) - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ Return the valuation of ``self``. @@ -1663,7 +1663,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): else: return index + valuation * self.prime_pow.e - cdef ext_p_list(self, bint pos): + cdef ext_p_list(self, bint pos) noexcept: r""" Return a list giving a series representation of ``self``. diff --git a/src/sage/rings/padics/padic_ZZ_pX_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_element.pyx index b23f010edde..81a6cd1e28c 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_element.pyx @@ -227,7 +227,7 @@ cdef class pAdicZZpXElement(pAdicExtElement): else: raise ValueError("context must be a power of the appropriate prime") - cdef ext_p_list_precs(self, bint pos, long prec): + cdef ext_p_list_precs(self, bint pos, long prec) noexcept: """ Returns a list giving a series representation of ``self``. @@ -621,7 +621,7 @@ def _test_preprocess_list(R, L): return preprocess_list(R(0), L) -cdef preprocess_list(pAdicZZpXElement elt, L): +cdef preprocess_list(pAdicZZpXElement elt, L) noexcept: """ See the documentation for :func:`_test_preprocess_list`. """ @@ -736,7 +736,7 @@ def _find_val_aprec_test(R, L): """ return find_val_aprec(R.prime_pow, L) -cdef find_val_aprec(PowComputer_ext pp, L): +cdef find_val_aprec(PowComputer_ext pp, L) noexcept: r""" Given a list ``L``, finds the minimum valuation, minimum absolute precision and minimum common type of the elements. @@ -841,7 +841,7 @@ def _test_get_val_prec(R, a): """ return get_val_prec(R.prime_pow, a) -cdef get_val_prec(PowComputer_ext pp, a): +cdef get_val_prec(PowComputer_ext pp, a) noexcept: r""" Return valuation, absolute precision and type of an input element. diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pxd b/src/sage/rings/padics/padic_capped_absolute_element.pxd index 48c8500a678..b80b6593bf6 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pxd +++ b/src/sage/rings/padics/padic_capped_absolute_element.pxd @@ -6,8 +6,8 @@ ctypedef mpz_t celement include "CA_template_header.pxi" cdef class pAdicCappedAbsoluteElement(CAElement): - cdef lift_c(self) - cdef pari_gen _to_gen(self) + cdef lift_c(self) noexcept + cdef pari_gen _to_gen(self) noexcept from sage.rings.padics.pow_computer cimport PowComputer_base cdef class PowComputer_(PowComputer_base): diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pyx b/src/sage/rings/padics/padic_capped_absolute_element.pyx index 69d5b474f20..061d36fd309 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pyx +++ b/src/sage/rings/padics/padic_capped_absolute_element.pyx @@ -97,7 +97,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): """ return self.lift_c() - cdef lift_c(self): + cdef lift_c(self) noexcept: """ Implementation of lift. @@ -124,7 +124,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): """ return self._to_gen() - cdef pari_gen _to_gen(self): + cdef pari_gen _to_gen(self) noexcept: """ Converts this element to an equivalent pari element. diff --git a/src/sage/rings/padics/padic_capped_relative_element.pxd b/src/sage/rings/padics/padic_capped_relative_element.pxd index 2cf6d5276f5..5c929be226d 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pxd +++ b/src/sage/rings/padics/padic_capped_relative_element.pxd @@ -5,8 +5,8 @@ ctypedef mpz_t celement include "CR_template_header.pxi" cdef class pAdicCappedRelativeElement(CRElement): - cdef lift_c(self) - cdef pari_gen _to_gen(self) + cdef lift_c(self) noexcept + cdef pari_gen _to_gen(self) noexcept from sage.rings.padics.pow_computer cimport PowComputer_base cdef class PowComputer_(PowComputer_base): diff --git a/src/sage/rings/padics/padic_capped_relative_element.pyx b/src/sage/rings/padics/padic_capped_relative_element.pyx index 10db90d1342..c32b882ff8e 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pyx +++ b/src/sage/rings/padics/padic_capped_relative_element.pyx @@ -160,7 +160,7 @@ cdef class pAdicCappedRelativeElement(CRElement): """ return self.lift_c() - cdef lift_c(self): + cdef lift_c(self) noexcept: """ Implementation of lift. @@ -210,7 +210,7 @@ cdef class pAdicCappedRelativeElement(CRElement): """ return self._to_gen() - cdef pari_gen _to_gen(self): + cdef pari_gen _to_gen(self) noexcept: """ Convert this element to an equivalent pari element. diff --git a/src/sage/rings/padics/padic_ext_element.pxd b/src/sage/rings/padics/padic_ext_element.pxd index b3e4a37ab1f..e267f0129c7 100644 --- a/src/sage/rings/padics/padic_ext_element.pxd +++ b/src/sage/rings/padics/padic_ext_element.pxd @@ -32,6 +32,6 @@ cdef class pAdicExtElement(pAdicGenericElement): cdef long _check_ZZ_pContext(self, ntl_ZZ_pContext_class ctx) except -1 cdef long _check_ZZ_pEContext(self, ntl_ZZ_pEContext_class ctx) except -1 - cdef ext_p_list(self, bint pos) - cdef ext_p_list_precs(self, bint pos, long prec) - cdef ZZ_p_c _const_term(self) + cdef ext_p_list(self, bint pos) noexcept + cdef ext_p_list_precs(self, bint pos, long prec) noexcept + cdef ZZ_p_c _const_term(self) noexcept diff --git a/src/sage/rings/padics/padic_ext_element.pyx b/src/sage/rings/padics/padic_ext_element.pyx index 94a7d93c727..0b5bc0f1249 100644 --- a/src/sage/rings/padics/padic_ext_element.pyx +++ b/src/sage/rings/padics/padic_ext_element.pyx @@ -262,10 +262,10 @@ cdef class pAdicExtElement(pAdicGenericElement): cdef long _check_ZZ_pEContext(self, ntl_ZZ_pEContext_class ctx) except -1: raise NotImplementedError - cdef ext_p_list(self, bint pos): + cdef ext_p_list(self, bint pos) noexcept: raise NotImplementedError - cdef ext_p_list_precs(self, bint pos, long prec): + cdef ext_p_list_precs(self, bint pos, long prec) noexcept: raise NotImplementedError def _const_term_test(self): @@ -290,7 +290,7 @@ cdef class pAdicExtElement(pAdicGenericElement): ans.x = self._const_term() return ans - cdef ZZ_p_c _const_term(self): + cdef ZZ_p_c _const_term(self) noexcept: raise NotImplementedError def _ext_p_list(self, pos): diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pxd b/src/sage/rings/padics/padic_fixed_mod_element.pxd index cd619a1bcb2..4d9bff415d0 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pxd +++ b/src/sage/rings/padics/padic_fixed_mod_element.pxd @@ -6,8 +6,8 @@ ctypedef mpz_t celement include "FM_template_header.pxi" cdef class pAdicFixedModElement(FMElement): - cdef lift_c(self) - cdef pari_gen _to_gen(self) + cdef lift_c(self) noexcept + cdef pari_gen _to_gen(self) noexcept from sage.rings.padics.pow_computer cimport PowComputer_base cdef class PowComputer_(PowComputer_base): diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pyx b/src/sage/rings/padics/padic_fixed_mod_element.pyx index 2e9e9a1ed3b..d538b10475d 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pyx +++ b/src/sage/rings/padics/padic_fixed_mod_element.pyx @@ -156,7 +156,7 @@ cdef class pAdicFixedModElement(FMElement): """ return self.lift_c() - cdef lift_c(self): + cdef lift_c(self) noexcept: r""" Returns an integer congruent to this element modulo the precision. @@ -188,7 +188,7 @@ cdef class pAdicFixedModElement(FMElement): """ return self._to_gen() - cdef pari_gen _to_gen(self): + cdef pari_gen _to_gen(self) noexcept: """ Convert ``self`` to an equivalent pari element. diff --git a/src/sage/rings/padics/padic_floating_point_element.pxd b/src/sage/rings/padics/padic_floating_point_element.pxd index 721c471d253..816a9fce705 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pxd +++ b/src/sage/rings/padics/padic_floating_point_element.pxd @@ -5,8 +5,8 @@ ctypedef mpz_t celement include "FP_template_header.pxi" cdef class pAdicFloatingPointElement(FPElement): - cdef lift_c(self) - cdef pari_gen _to_gen(self) + cdef lift_c(self) noexcept + cdef pari_gen _to_gen(self) noexcept from sage.rings.padics.pow_computer cimport PowComputer_base cdef class PowComputer_(PowComputer_base): diff --git a/src/sage/rings/padics/padic_floating_point_element.pyx b/src/sage/rings/padics/padic_floating_point_element.pyx index 32c8e25cde2..70f5ce806af 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pyx +++ b/src/sage/rings/padics/padic_floating_point_element.pyx @@ -158,7 +158,7 @@ cdef class pAdicFloatingPointElement(FPElement): """ return self.lift_c() - cdef lift_c(self): + cdef lift_c(self) noexcept: r""" Implementation of lift. @@ -204,7 +204,7 @@ cdef class pAdicFloatingPointElement(FPElement): """ return self._to_gen() - cdef pari_gen _to_gen(self): + cdef pari_gen _to_gen(self) noexcept: """ Convert this element to an equivalent pari element. diff --git a/src/sage/rings/padics/padic_generic_element.pxd b/src/sage/rings/padics/padic_generic_element.pxd index 780aa4655bf..091d56bb912 100644 --- a/src/sage/rings/padics/padic_generic_element.pxd +++ b/src/sage/rings/padics/padic_generic_element.pxd @@ -8,11 +8,11 @@ from sage.rings.padics.pow_computer cimport PowComputer_class from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational -cpdef gauss_table(long long p, int f, int prec, bint use_longs) +cpdef gauss_table(long long p, int f, int prec, bint use_longs) noexcept cdef class pAdicGenericElement(LocalGenericElement): - cdef long valuation_c(self) - cpdef val_unit(self) + cdef long valuation_c(self) noexcept + cpdef val_unit(self) noexcept cdef int _set_from_Integer(self, Integer x, absprec, relprec) except -1 cdef int _set_from_mpz(self, mpz_t x) except -1 @@ -41,7 +41,7 @@ cdef class pAdicGenericElement(LocalGenericElement): cdef bint _set_prec_rel(self, long relprec) except -1 cdef bint _set_prec_both(self, long absprec, long relprec) except -1 - cpdef abs(self, prec=*) - cpdef _mod_(self, right) - cpdef _floordiv_(self, right) + cpdef abs(self, prec=*) noexcept + cpdef _mod_(self, right) noexcept + cpdef _floordiv_(self, right) noexcept cpdef bint _is_base_elt(self, p) except -1 diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index f68405dcc6f..c54005de2f7 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -43,7 +43,7 @@ from sage.structure.richcmp cimport rich_to_bool cdef long maxordp = (1L << (sizeof(long) * 8 - 2)) - 1 cdef class pAdicGenericElement(LocalGenericElement): - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" First compare valuations, then compare normalized residue of unit part. @@ -354,7 +354,7 @@ cdef class pAdicGenericElement(LocalGenericElement): raise ZeroDivisionError("cannot divide by zero") return self._floordiv_(right) - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Implements floor division. @@ -464,7 +464,7 @@ cdef class pAdicGenericElement(LocalGenericElement): """ return ~self.parent().fraction_field()(self, relprec = self.precision_relative()) - cpdef _mod_(self, right): + cpdef _mod_(self, right) noexcept: """ If self is in a field, returns 0. If in a ring, returns a p-adic integer such that @@ -2093,7 +2093,7 @@ cdef class pAdicGenericElement(LocalGenericElement): mpz_set_si(ans.value, v) return ans - cdef long valuation_c(self): + cdef long valuation_c(self) noexcept: """ This function is overridden in subclasses to provide an actual implementation of valuation. @@ -2112,7 +2112,7 @@ cdef class pAdicGenericElement(LocalGenericElement): """ raise NotImplementedError - cpdef val_unit(self): + cpdef val_unit(self) noexcept: r""" Return ``(self.valuation(), self.unit_part())``. To be overridden in derived classes. @@ -3995,7 +3995,7 @@ cdef class pAdicGenericElement(LocalGenericElement): """ return self.abs() - cpdef abs(self, prec=None): + cpdef abs(self, prec=None) noexcept: """ Return the `p`-adic absolute value of ``self``. @@ -4486,7 +4486,7 @@ def _compute_g(p, n, prec, terms): g[i+1] = -(g[i]/(v-v**2)).integral() return [x.truncate(terms) for x in g] -cpdef dwork_mahler_coeffs(R, int bd=20): +cpdef dwork_mahler_coeffs(R, int bd=20) noexcept: r""" Compute Dwork's formula for Mahler coefficients of `p`-adic Gamma. @@ -4534,7 +4534,7 @@ cpdef dwork_mahler_coeffs(R, int bd=20): v.append(R(x << i)) return v -cpdef evaluate_dwork_mahler(v, x, long long p, int bd, long long a): +cpdef evaluate_dwork_mahler(v, x, long long p, int bd, long long a) noexcept: """ Evaluate Dwork's Mahler series for `p`-adic Gamma. @@ -4564,7 +4564,7 @@ cpdef evaluate_dwork_mahler(v, x, long long p, int bd, long long a): return -s cdef long long evaluate_dwork_mahler_long(array.array v, long long x, long long p, int bd, - long long a, long long q): + long long a, long long q) noexcept: cdef int k cdef long long a1, s, u bd -= 1 @@ -4578,7 +4578,7 @@ cdef long long evaluate_dwork_mahler_long(array.array v, long long x, long long s = s % q return -s -cpdef gauss_table(long long p, int f, int prec, bint use_longs): +cpdef gauss_table(long long p, int f, int prec, bint use_longs) noexcept: r""" Compute a table of Gauss sums using the Gross-Koblitz formula. diff --git a/src/sage/rings/padics/padic_printing.pxd b/src/sage/rings/padics/padic_printing.pxd index 44698b3d73d..e0ce12540c6 100644 --- a/src/sage/rings/padics/padic_printing.pxd +++ b/src/sage/rings/padics/padic_printing.pxd @@ -22,16 +22,16 @@ cdef class pAdicPrinter_class(SageObject): cdef long max_terse_terms cdef object show_prec - cdef base_p_list(self, value, bint pos) - cdef _repr_gen(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, pname) - cdef _repr_spec(self, pAdicGenericElement elt, bint do_latex, bint pos, int _mode, bint paren, pname) - cdef _print_list_as_poly(self, L, bint do_latex, polyname, long expshift, bint increasing) - cdef _truncate_list(self, L, max_terms, zero) - cdef _var(self, x, exp, do_latex) - cdef _dot_var(self, x, exp, do_latex) - cdef _co_dot_var(self, co, x, exp, do_latex) - cdef _plus_ellipsis(self, bint do_latex) - cdef _ellipsis(self, bint do_latex) - cdef _terse_frac(self, a, v, u, ram_name, bint do_latex) - cdef _print_unram_term(self, L, bint do_latex, polyname, long max_unram_terms, long expshift, bint increasing) - cdef _print_term_of_poly(self, s, coeff, bint do_latex, polyname, long exp) + cdef base_p_list(self, value, bint pos) noexcept + cdef _repr_gen(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, pname) noexcept + cdef _repr_spec(self, pAdicGenericElement elt, bint do_latex, bint pos, int _mode, bint paren, pname) noexcept + cdef _print_list_as_poly(self, L, bint do_latex, polyname, long expshift, bint increasing) noexcept + cdef _truncate_list(self, L, max_terms, zero) noexcept + cdef _var(self, x, exp, do_latex) noexcept + cdef _dot_var(self, x, exp, do_latex) noexcept + cdef _co_dot_var(self, co, x, exp, do_latex) noexcept + cdef _plus_ellipsis(self, bint do_latex) noexcept + cdef _ellipsis(self, bint do_latex) noexcept + cdef _terse_frac(self, a, v, u, ram_name, bint do_latex) noexcept + cdef _print_unram_term(self, L, bint do_latex, polyname, long max_unram_terms, long expshift, bint increasing) noexcept + cdef _print_term_of_poly(self, s, coeff, bint do_latex, polyname, long exp) noexcept diff --git a/src/sage/rings/padics/padic_printing.pyx b/src/sage/rings/padics/padic_printing.pyx index aef767034a8..a75f85b4cf0 100644 --- a/src/sage/rings/padics/padic_printing.pyx +++ b/src/sage/rings/padics/padic_printing.pyx @@ -816,7 +816,7 @@ cdef class pAdicPrinter_class(SageObject): """ return self.base_p_list(value, pos) - cdef base_p_list(self, value, bint pos): + cdef base_p_list(self, value, bint pos) noexcept: """ Returns a list of integers forming the base p expansion of value. @@ -894,7 +894,7 @@ cdef class pAdicPrinter_class(SageObject): pprint = latex_variable_name(pprint) return self._repr_gen(elt, do_latex, _pos, _mode, pprint) - cdef _repr_gen(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, ram_name): + cdef _repr_gen(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, ram_name) noexcept: r""" Prints a string representation of the element. See __init__ for more details on print modes. @@ -1054,7 +1054,7 @@ cdef class pAdicPrinter_class(SageObject): if s == "": s = "0" return s - cdef _repr_spec(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, bint paren, ram_name): + cdef _repr_spec(self, pAdicGenericElement elt, bint do_latex, bint pos, int mode, bint paren, ram_name) noexcept: """ A function used by repr_gen for terse and series printing. @@ -1271,7 +1271,7 @@ cdef class pAdicPrinter_class(SageObject): s = "(" + s + ")" return s - cdef _var(self, x, exp, do_latex): + cdef _var(self, x, exp, do_latex) noexcept: """ Returns a representation of 'x^exp', latexed if necessary. """ @@ -1284,7 +1284,7 @@ cdef class pAdicPrinter_class(SageObject): else: return "%s^%s"%(x, exp) - cdef _dot_var(self, x, exp, do_latex): + cdef _dot_var(self, x, exp, do_latex) noexcept: """ Returns a representation of '*x^exp', latexed if necessary. """ @@ -1300,7 +1300,7 @@ cdef class pAdicPrinter_class(SageObject): else: return "*%s^%s"%(x, exp) - cdef _co_dot_var(self, co, x, exp, do_latex): + cdef _co_dot_var(self, co, x, exp, do_latex) noexcept: """ Returns a representation of 'co*x^exp', latexed if necessary. @@ -1325,7 +1325,7 @@ cdef class pAdicPrinter_class(SageObject): else: return "%s*%s^%s"%(co, x, exp) - cdef _plus_ellipsis(self, bint do_latex): + cdef _plus_ellipsis(self, bint do_latex) noexcept: """ Returns a representation of '+ ...', latexed if necessary. """ @@ -1334,7 +1334,7 @@ cdef class pAdicPrinter_class(SageObject): else: return " + ..." - cdef _ellipsis(self, bint do_latex): + cdef _ellipsis(self, bint do_latex) noexcept: """ Returns a representation of '...', latexed if necessary. """ @@ -1343,7 +1343,7 @@ cdef class pAdicPrinter_class(SageObject): else: return "..." - cdef _truncate_list(self, L, max_terms, zero): + cdef _truncate_list(self, L, max_terms, zero) noexcept: """ Takes a list L of coefficients and returns a list with at most max_terms nonzero terms. @@ -1375,7 +1375,7 @@ cdef class pAdicPrinter_class(SageObject): ans.append(c) return ans, False - cdef _print_unram_term(self, L, bint do_latex, polyname, long max_unram_terms, long expshift, bint increasing): + cdef _print_unram_term(self, L, bint do_latex, polyname, long max_unram_terms, long expshift, bint increasing) noexcept: """ Returns a string representation of L when considered as a polynomial, truncating to at most max_unram_terms nonzero terms. @@ -1448,7 +1448,7 @@ cdef class pAdicPrinter_class(SageObject): s = self._print_term_of_poly(s, L[j], do_latex, polyname, exp) return s - cdef _terse_frac(self, a, v, u, ram_name, bint do_latex): + cdef _terse_frac(self, a, v, u, ram_name, bint do_latex) noexcept: """ Returns a representation of a=u/ram_name^v, latexed if necessary. """ @@ -1468,7 +1468,7 @@ cdef class pAdicPrinter_class(SageObject): arep = "%s/%s^%s"%(u, ram_name, -v) return arep - cdef _print_list_as_poly(self, L, bint do_latex, polyname, long expshift, bint increasing): + cdef _print_list_as_poly(self, L, bint do_latex, polyname, long expshift, bint increasing) noexcept: """ Prints a list L as a polynomial. @@ -1499,7 +1499,7 @@ cdef class pAdicPrinter_class(SageObject): s = self._print_term_of_poly(s, L[j], do_latex, polyname, exp) return s - cdef _print_term_of_poly(self, s, coeff, bint do_latex, polyname, long exp): + cdef _print_term_of_poly(self, s, coeff, bint do_latex, polyname, long exp) noexcept: """ Appends +coeff*polyname^exp to s, latexed if necessary. """ diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index 06d65d1672c..4ca0356774f 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -187,7 +187,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): """ raise NotImplementedError - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec): + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept: """ Creates a new element with a given value and absolute precision. @@ -263,7 +263,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): check_ordp(s) return self._lshift_c(s) - cdef pAdicTemplateElement _lshift_c(self, long shift): + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept: raise NotImplementedError def __rshift__(pAdicTemplateElement self, shift): @@ -311,7 +311,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): check_ordp(s) return self._rshift_c(s) - cdef pAdicTemplateElement _rshift_c(self, long shift): + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept: """ Divides by ``p^shift`` and truncates (if the parent is not a field). """ @@ -379,7 +379,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): ans.check_preccap() return ans - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec): + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept: """ Lift this element to another with precision at least ``absprec``. """ @@ -623,7 +623,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): else: return trim_zeros(list(self.unit_part().expansion(lift_mode='smallest'))) - cpdef pAdicTemplateElement unit_part(self): + cpdef pAdicTemplateElement unit_part(self) noexcept: r""" Returns the unit part of this element. @@ -753,7 +753,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): else: raise NotImplementedError("reduction modulo p^n with n>1") -cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowComputer_ prime_pow): +cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowComputer_ prime_pow) noexcept: """ This function is used by exponentiation in both ``CR_template.pxi`` and ``CA_template.pxi`` to determine the extra precision gained from @@ -867,7 +867,7 @@ cdef long padic_pow_helper(celement result, celement base, long base_val, long b cpow(result, prime_pow.powhelper_oneunit, right.value, bloga_aprec, prime_pow) return bloga_aprec -cdef _zero(expansion_mode mode, teich_ring): +cdef _zero(expansion_mode mode, teich_ring) noexcept: """ Return an appropriate zero for a given expansion mode. diff --git a/src/sage/rings/padics/padic_template_element_header.pxi b/src/sage/rings/padics/padic_template_element_header.pxi index 11e1cc7fab7..4cd07b8c4bd 100644 --- a/src/sage/rings/padics/padic_template_element_header.pxi +++ b/src/sage/rings/padics/padic_template_element_header.pxi @@ -39,11 +39,11 @@ cdef enum expansion_mode: cdef class pAdicTemplateElement(pAdicGenericElement): cdef PowComputer_ prime_pow cdef int _set(self, x, long val, long xprec, absprec, relprec) except -1 - cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) + cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec) noexcept cdef int _get_unit(self, celement value) except -1 - cdef pAdicTemplateElement _lshift_c(self, long shift) - cdef pAdicTemplateElement _rshift_c(self, long shift) + cdef pAdicTemplateElement _lshift_c(self, long shift) noexcept + cdef pAdicTemplateElement _rshift_c(self, long shift) noexcept #cpdef RingElement _floordiv_c_impl(self, RingElement right) cdef int check_preccap(self) except -1 - cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) - cpdef pAdicTemplateElement unit_part(self) + cdef pAdicTemplateElement lift_to_precision_c(self, long absprec) noexcept + cpdef pAdicTemplateElement unit_part(self) noexcept diff --git a/src/sage/rings/padics/pow_computer.pxd b/src/sage/rings/padics/pow_computer.pxd index 8766725882e..b70553b77e0 100644 --- a/src/sage/rings/padics/pow_computer.pxd +++ b/src/sage/rings/padics/pow_computer.pxd @@ -22,8 +22,8 @@ cdef class PowComputer_class(SageObject): cdef unsigned long cache_limit cdef unsigned long prec_cap - cdef Integer pow_Integer(self, long n) - cdef mpz_srcptr pow_mpz_t_top(self) + cdef Integer pow_Integer(self, long n) noexcept + cdef mpz_srcptr pow_mpz_t_top(self) noexcept cdef mpz_srcptr pow_mpz_t_tmp(self, long n) except NULL cdef mpz_t temp_m diff --git a/src/sage/rings/padics/pow_computer.pyx b/src/sage/rings/padics/pow_computer.pyx index 4c05f1886b5..4753be2c6ee 100644 --- a/src/sage/rings/padics/pow_computer.pyx +++ b/src/sage/rings/padics/pow_computer.pyx @@ -146,7 +146,7 @@ cdef class PowComputer_class(SageObject): return richcmp(s.in_field, o.in_field, op) - cdef Integer pow_Integer(self, long n): + cdef Integer pow_Integer(self, long n) noexcept: """ Returns self.prime^n @@ -280,7 +280,7 @@ cdef class PowComputer_class(SageObject): mpz_set(ans.value, self.pow_mpz_t_tmp(mpz_get_si(_n.value))) return ans - cdef mpz_srcptr pow_mpz_t_top(self): + cdef mpz_srcptr pow_mpz_t_top(self) noexcept: """ Returns a pointer to self.prime^self.prec_cap as an ``mpz_srcptr``. @@ -549,7 +549,7 @@ cdef class PowComputer_base(PowComputer_class): """ return PowComputer, (self.prime, self.cache_limit, self.prec_cap, self.in_field) - cdef mpz_srcptr pow_mpz_t_top(self): + cdef mpz_srcptr pow_mpz_t_top(self) noexcept: """ Returns a pointer to self.prime^self.prec_cap as an ``mpz_srcptr``. @@ -594,7 +594,7 @@ cdef class PowComputer_base(PowComputer_class): return self.temp_m pow_comp_cache = {} -cdef PowComputer_base PowComputer_c(Integer m, Integer cache_limit, Integer prec_cap, in_field, prec_type=None): +cdef PowComputer_base PowComputer_c(Integer m, Integer cache_limit, Integer prec_cap, in_field, prec_type=None) noexcept: """ Returns a PowComputer. diff --git a/src/sage/rings/padics/pow_computer_ext.pxd b/src/sage/rings/padics/pow_computer_ext.pxd index 114696b34fa..e4eca660bb3 100644 --- a/src/sage/rings/padics/pow_computer_ext.pxd +++ b/src/sage/rings/padics/pow_computer_ext.pxd @@ -16,23 +16,23 @@ cdef class PowComputer_ext(PowComputer_class): cdef object _ext_type cdef ZZ_c* pow_ZZ_tmp(self, long n) except NULL - cdef ZZ_c* pow_ZZ_top(self) + cdef ZZ_c* pow_ZZ_top(self) noexcept - cdef void cleanup_ext(self) + cdef void cleanup_ext(self) noexcept cdef class PowComputer_ZZ_pX(PowComputer_ext): - cdef ntl_ZZ_pContext_class get_context(self, long n) - cdef ntl_ZZ_pContext_class get_context_capdiv(self, long n) - cdef ntl_ZZ_pContext_class get_top_context(self) - cdef restore_context(self, long n) - cdef restore_context_capdiv(self, long n) - cdef void restore_top_context(self) - cdef ZZ_pX_Modulus_c* get_modulus(self, long n) - cdef ZZ_pX_Modulus_c* get_modulus_capdiv(self, long n) - cdef ZZ_pX_Modulus_c* get_top_modulus(self) + cdef ntl_ZZ_pContext_class get_context(self, long n) noexcept + cdef ntl_ZZ_pContext_class get_context_capdiv(self, long n) noexcept + cdef ntl_ZZ_pContext_class get_top_context(self) noexcept + cdef restore_context(self, long n) noexcept + cdef restore_context_capdiv(self, long n) noexcept + cdef void restore_top_context(self) noexcept + cdef ZZ_pX_Modulus_c* get_modulus(self, long n) noexcept + cdef ZZ_pX_Modulus_c* get_modulus_capdiv(self, long n) noexcept + cdef ZZ_pX_Modulus_c* get_top_modulus(self) noexcept cdef int eis_shift(self, ZZ_pX_c* x, ZZ_pX_c* a, long n, long finalprec) except -1 cdef int eis_shift_capdiv(self, ZZ_pX_c* x, ZZ_pX_c* a, long n, long finalprec) except -1 - cdef long capdiv(self, long n) + cdef long capdiv(self, long n) noexcept cdef int teichmuller_set_c (self, ZZ_pX_c* x, ZZ_pX_c* a, long absprec) except -1 cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): @@ -45,13 +45,13 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): cdef ZZ_pX_Multiplier_c* low_shifter cdef ZZ_pX_Multiplier_c* high_shifter - cdef void cleanup_ZZ_pX_FM_Eis(self) + cdef void cleanup_ZZ_pX_FM_Eis(self) noexcept cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): cdef object c # using a python list so that we can store ntl_ZZ_pContext_class objects cdef ZZ_pX_Modulus_c *mod - cdef void cleanup_ZZ_pX_small(self) + cdef void cleanup_ZZ_pX_small(self) noexcept cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): cdef int low_length @@ -59,7 +59,7 @@ cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): cdef ZZ_pX_c* low_shifter cdef ZZ_pX_c* high_shifter - cdef void cleanup_ZZ_pX_small_Eis(self) + cdef void cleanup_ZZ_pX_small_Eis(self) noexcept cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): cdef object context_list # using a python list so that we can store ntl_ZZ_pContext_class objects @@ -71,7 +71,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): cdef object context_dict #currently using a dict, optimize for speed later cdef object modulus_dict #currently using a dict, optimize for speed later - cdef void cleanup_ZZ_pX_big(self) + cdef void cleanup_ZZ_pX_big(self) noexcept cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): cdef int low_length @@ -79,7 +79,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): cdef ZZ_pX_c* low_shifter cdef ZZ_pX_c* high_shifter - cdef void cleanup_ZZ_pX_big_Eis(self) + cdef void cleanup_ZZ_pX_big_Eis(self) noexcept #cdef class PowComputer_ZZ_pEX(PowComputer_ext): # cdef ntl_ZZ_pEContext get_context(self, long n) diff --git a/src/sage/rings/padics/pow_computer_ext.pyx b/src/sage/rings/padics/pow_computer_ext.pyx index 3d47d3af2f9..742464a492d 100644 --- a/src/sage/rings/padics/pow_computer_ext.pyx +++ b/src/sage/rings/padics/pow_computer_ext.pyx @@ -537,7 +537,7 @@ cdef class PowComputer_ext(PowComputer_class): mpz_set_si(ram_prec_cap.value, self.ram_prec_cap) return PowComputer_ext_maker, (self.prime, cache_limit, prec_cap, ram_prec_cap, self.in_field, self._poly, self._prec_type, self._ext_type, self._shift_seed) - cdef void cleanup_ext(self): + cdef void cleanup_ext(self) noexcept: """ Frees memory allocated in PowComputer_ext. @@ -674,7 +674,7 @@ cdef class PowComputer_ext(PowComputer_class): return ans - cdef mpz_srcptr pow_mpz_t_top(self): + cdef mpz_srcptr pow_mpz_t_top(self) noexcept: """ Returns self.prime^self.prec_cap as an ``mpz_srcptr``. @@ -687,7 +687,7 @@ cdef class PowComputer_ext(PowComputer_class): ZZ_to_mpz(self.temp_m, &self.top_power) return self.temp_m - cdef ZZ_c* pow_ZZ_top(self): + cdef ZZ_c* pow_ZZ_top(self) noexcept: """ Returns self.prime^self.prec_cap as a ZZ_c. @@ -759,7 +759,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): r.x = (self.get_top_modulus()[0]).val() return r - cdef ntl_ZZ_pContext_class get_context(self, long n): + cdef ntl_ZZ_pContext_class get_context(self, long n) noexcept: """ Returns a ZZ_pContext for self.prime^(abs(n)). @@ -792,7 +792,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): cdef Integer _n = Integer(n) return self.get_context(mpz_get_si(_n.value)) - cdef ntl_ZZ_pContext_class get_context_capdiv(self, long n): + cdef ntl_ZZ_pContext_class get_context_capdiv(self, long n) noexcept: """ Returns a ZZ_pContext for self.prime^((n-1) // self.e + 1) @@ -852,7 +852,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): self.get_modulus(_n) return cputime(t) - cdef ntl_ZZ_pContext_class get_top_context(self): + cdef ntl_ZZ_pContext_class get_top_context(self) noexcept: """ Returns a ZZ_pContext for self.prime^self.prec_cap @@ -876,7 +876,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): """ return self.get_top_context() - cdef restore_context(self, long n): + cdef restore_context(self, long n) noexcept: """ Restores the contest corresponding to self.prime^n @@ -899,7 +899,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): cdef Integer _n = Integer(n) self.restore_context(mpz_get_si(_n.value)) - cdef restore_context_capdiv(self, long n): + cdef restore_context_capdiv(self, long n) noexcept: """ Restores the context for self.prime^((n-1) // self.e + 1) @@ -922,7 +922,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): cdef Integer _n = Integer(n) self.restore_context_capdiv(mpz_get_si(_n.value)) - cdef void restore_top_context(self): + cdef void restore_top_context(self) noexcept: """ Restores the context corresponding to self.prime^self.prec_cap @@ -944,7 +944,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): """ self.restore_top_context() - cdef ZZ_pX_Modulus_c* get_modulus(self, long n): + cdef ZZ_pX_Modulus_c* get_modulus(self, long n) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^n) @@ -987,14 +987,14 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): ZZ_pX_MulMod_pre(r.x, aa.x, bb.x, self.get_modulus(mpz_get_si(n.value))[0]) return r - cdef ZZ_pX_Modulus_c* get_modulus_capdiv(self, long n): + cdef ZZ_pX_Modulus_c* get_modulus_capdiv(self, long n) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^((n-1) // self.e + 1) """ return self.get_modulus(self.capdiv(n)) - cdef ZZ_pX_Modulus_c* get_top_modulus(self): + cdef ZZ_pX_Modulus_c* get_top_modulus(self) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^self.prec_cap) @@ -1031,7 +1031,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): ZZ_pX_MulMod_pre(ans.x, a.x, b.x, self.get_top_modulus()[0]) return ans - cdef long capdiv(self, long n): + cdef long capdiv(self, long n) noexcept: """ If n >= 0 returns ceil(n / self.e) @@ -1248,7 +1248,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): else: raise NotImplementedError("NOT IMPLEMENTED IN PowComputer_ZZ_pX_FM") - cdef ntl_ZZ_pContext_class get_top_context(self): + cdef ntl_ZZ_pContext_class get_top_context(self) noexcept: """ Returns a ZZ_pContext for self.prime^self.prec_cap @@ -1260,7 +1260,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): """ return self.c - cdef void restore_top_context(self): + cdef void restore_top_context(self) noexcept: """ Restores the context corresponding to self.prime^self.prec_cap @@ -1271,7 +1271,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): """ self.c.restore_c() - cdef ZZ_pX_Modulus_c* get_top_modulus(self): + cdef ZZ_pX_Modulus_c* get_top_modulus(self) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^self.prec_cap) @@ -1285,7 +1285,7 @@ cdef class PowComputer_ZZ_pX_FM(PowComputer_ZZ_pX): """ return &self.mod - cdef ZZ_pX_Modulus_c* get_modulus(self, long n): + cdef ZZ_pX_Modulus_c* get_modulus(self, long n) noexcept: """ Duplicates functionality of get_top_modulus if n == self.prec_cap. @@ -1421,7 +1421,7 @@ cdef class PowComputer_ZZ_pX_FM_Eis(PowComputer_ZZ_pX_FM): if self._initialized: self.cleanup_ZZ_pX_FM_Eis() - cdef void cleanup_ZZ_pX_FM_Eis(self): + cdef void cleanup_ZZ_pX_FM_Eis(self) noexcept: """ Does the actual work of deallocating low_shifter and high_shifter. @@ -1609,7 +1609,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): if self._initialized: self.cleanup_ZZ_pX_small() - cdef void cleanup_ZZ_pX_small(self): + cdef void cleanup_ZZ_pX_small(self) noexcept: """ Deallocates cache of contexts, moduli. @@ -1620,7 +1620,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): """ Delete_ZZ_pX_Modulus_array(self.mod) - cdef ntl_ZZ_pContext_class get_context(self, long n): + cdef ntl_ZZ_pContext_class get_context(self, long n) noexcept: """ Return the context for p^n. This will use the cache if ``abs(n) <= self.cache_limit``. @@ -1646,7 +1646,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): except IndexError: return PowComputer_ZZ_pX.get_context(self, n) - cdef restore_context(self, long n): + cdef restore_context(self, long n) noexcept: """ Restore the context for p^n. This will use the cache if ``abs(n) <= self.cache_limit``. @@ -1667,7 +1667,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): except IndexError: (PowComputer_ZZ_pX.get_context(self, n)).restore_c() - cdef ntl_ZZ_pContext_class get_top_context(self): + cdef ntl_ZZ_pContext_class get_top_context(self) noexcept: """ Returns a ZZ_pContext for self.prime^self.prec_cap @@ -1679,7 +1679,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): """ return self.c[self.prec_cap] - cdef void restore_top_context(self): + cdef void restore_top_context(self) noexcept: """ Restores the context corresponding to self.prime^self.prec_cap @@ -1690,7 +1690,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): """ (self.c[self.prec_cap]).restore_c() - cdef ZZ_pX_Modulus_c* get_modulus(self, long n): + cdef ZZ_pX_Modulus_c* get_modulus(self, long n) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^n). @@ -1718,7 +1718,7 @@ cdef class PowComputer_ZZ_pX_small(PowComputer_ZZ_pX): ZZ_pX_Modulus_build(self.mod[self.prec_cap+1], tmp) return &(self.mod[self.prec_cap+1]) - cdef ZZ_pX_Modulus_c* get_top_modulus(self): + cdef ZZ_pX_Modulus_c* get_top_modulus(self) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^self.prec_cap) @@ -1853,7 +1853,7 @@ cdef class PowComputer_ZZ_pX_small_Eis(PowComputer_ZZ_pX_small): if self._initialized: self.cleanup_ZZ_pX_small_Eis() - cdef void cleanup_ZZ_pX_small_Eis(self): + cdef void cleanup_ZZ_pX_small_Eis(self) noexcept: """ Does the actual work of deallocating low_shifter and high_shifter. @@ -1976,7 +1976,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): if self._initialized: self.cleanup_ZZ_pX_big() - cdef void cleanup_ZZ_pX_big(self): + cdef void cleanup_ZZ_pX_big(self) noexcept: """ Deallocates the stored moduli and contexts. @@ -2043,7 +2043,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): """ return self.modulus_dict - cdef ntl_ZZ_pContext_class get_context(self, long n): + cdef ntl_ZZ_pContext_class get_context(self, long n) noexcept: """ Returns the context for p^n. @@ -2079,7 +2079,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): self.context_dict[n] = PowComputer_ZZ_pX.get_context(self, n) return self.context_dict[n] - cdef ntl_ZZ_pContext_class get_top_context(self): + cdef ntl_ZZ_pContext_class get_top_context(self) noexcept: """ Returns a ZZ_pContext for self.prime^self.prec_cap @@ -2091,7 +2091,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): """ return self.top_context - cdef void restore_top_context(self): + cdef void restore_top_context(self) noexcept: """ Restores the context corresponding to self.prime^self.prec_cap @@ -2102,7 +2102,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): """ self.top_context.restore_c() - cdef ZZ_pX_Modulus_c* get_modulus(self, long n): + cdef ZZ_pX_Modulus_c* get_modulus(self, long n) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^n). @@ -2149,7 +2149,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): self.modulus_dict[n] = holder return &(holder.x) - cdef ZZ_pX_Modulus_c* get_top_modulus(self): + cdef ZZ_pX_Modulus_c* get_top_modulus(self) noexcept: """ Returns the modulus corresponding to self.polynomial() (mod self.prime^self.prec_cap) @@ -2284,7 +2284,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): if self._initialized: self.cleanup_ZZ_pX_big_Eis() - cdef void cleanup_ZZ_pX_big_Eis(self): + cdef void cleanup_ZZ_pX_big_Eis(self) noexcept: """ Does the actual work of deallocating low_shifter and high_shifter. diff --git a/src/sage/rings/padics/pow_computer_flint.pxd b/src/sage/rings/padics/pow_computer_flint.pxd index eb89afae07d..83185ec9cc9 100644 --- a/src/sage/rings/padics/pow_computer_flint.pxd +++ b/src/sage/rings/padics/pow_computer_flint.pxd @@ -11,7 +11,7 @@ cdef class PowComputer_flint(PowComputer_class): cdef mpz_t top_power cdef fmpz_t* pow_fmpz_t_tmp(self, unsigned long n) except NULL - cdef unsigned long capdiv(self, unsigned long n) + cdef unsigned long capdiv(self, unsigned long n) noexcept cdef fmpz_t tfmpz @@ -21,9 +21,9 @@ cdef class PowComputer_flint_1step(PowComputer_flint): cdef fmpz_poly_t powhelper_oneunit cdef fmpz_poly_t powhelper_teichdiff cdef fmpz_poly_t* _moduli - cdef fmpz_poly_t* get_modulus(self, unsigned long n) - cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long n) - cdef _new_fmpz_poly(self, fmpz_poly_t value, var=*) + cdef fmpz_poly_t* get_modulus(self, unsigned long n) noexcept + cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long n) noexcept + cdef _new_fmpz_poly(self, fmpz_poly_t value, var=*) noexcept cdef class PowComputer_flint_unram(PowComputer_flint_1step): # WARNING: diff --git a/src/sage/rings/padics/pow_computer_flint.pyx b/src/sage/rings/padics/pow_computer_flint.pyx index e521ea6e078..2525a8bd040 100644 --- a/src/sage/rings/padics/pow_computer_flint.pyx +++ b/src/sage/rings/padics/pow_computer_flint.pyx @@ -149,14 +149,14 @@ cdef class PowComputer_flint(PowComputer_class): fmpz_get_mpz(self.temp_m, self.pow_fmpz_t_tmp(n)[0]) return self.temp_m - cdef mpz_srcptr pow_mpz_t_top(self): + cdef mpz_srcptr pow_mpz_t_top(self) noexcept: """ Returns a pointer to an ``mpz_t`` holding `p^N`, where `N` is the precision cap. """ return self.top_power - cdef unsigned long capdiv(self, unsigned long n): + cdef unsigned long capdiv(self, unsigned long n) noexcept: """ Returns ceil(n / e). """ @@ -367,7 +367,7 @@ cdef class PowComputer_flint_1step(PowComputer_flint): return NotImplemented return False - cdef fmpz_poly_t* get_modulus(self, unsigned long k): + cdef fmpz_poly_t* get_modulus(self, unsigned long k) noexcept: """ Return the defining polynomial reduced modulo `p^k`. @@ -385,7 +385,7 @@ cdef class PowComputer_flint_1step(PowComputer_flint): self.pow_fmpz_t_tmp(k)[0]) return &(self._moduli[c]) - cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long k): + cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long k) noexcept: """ Returns the defining polynomial reduced modulo `p^a`, where `a` is the ceiling of `k/e`. @@ -432,7 +432,7 @@ cdef class PowComputer_flint_1step(PowComputer_flint): fmpz_poly_set(ans._poly, self.get_modulus(_n)[0]) return ans - cdef _new_fmpz_poly(self, fmpz_poly_t value, var='x'): + cdef _new_fmpz_poly(self, fmpz_poly_t value, var='x') noexcept: """ Returns a polynomial with the value stored in ``value`` and variable name ``var``. diff --git a/src/sage/rings/padics/pow_computer_relative.pxd b/src/sage/rings/padics/pow_computer_relative.pxd index e0e5aa5600e..9bc6f1b487a 100644 --- a/src/sage/rings/padics/pow_computer_relative.pxd +++ b/src/sage/rings/padics/pow_computer_relative.pxd @@ -20,10 +20,10 @@ cdef class PowComputer_relative(PowComputer_class): # allow cached methods cdef public dict _cached_methods - cdef unsigned long capdiv(self, unsigned long n) + cdef unsigned long capdiv(self, unsigned long n) noexcept cdef class PowComputer_relative_eis(PowComputer_relative): # (x^e - modulus)/p cdef public Polynomial_generic_dense _shift_seed cdef public Polynomial_generic_dense _inv_shift_seed - cpdef Polynomial_generic_dense invert(self, Polynomial_generic_dense element, long prec) + cpdef Polynomial_generic_dense invert(self, Polynomial_generic_dense element, long prec) noexcept diff --git a/src/sage/rings/padics/pow_computer_relative.pyx b/src/sage/rings/padics/pow_computer_relative.pyx index fc51eb3410f..88f39e6ffe6 100644 --- a/src/sage/rings/padics/pow_computer_relative.pyx +++ b/src/sage/rings/padics/pow_computer_relative.pyx @@ -152,7 +152,7 @@ cdef class PowComputer_relative(PowComputer_class): """ return "Relative PowComputer for modulus %s" % (self.modulus,) - cdef unsigned long capdiv(self, unsigned long n): + cdef unsigned long capdiv(self, unsigned long n) noexcept: r""" Return `\lceil n/e \rceil`. """ @@ -219,7 +219,7 @@ cdef class PowComputer_relative_eis(PowComputer_relative): PowComputer_relative.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly, shift_seed) self._inv_shift_seed = self.invert(shift_seed, self.ram_prec_cap) - cpdef Polynomial_generic_dense invert(self, Polynomial_generic_dense a, long prec): + cpdef Polynomial_generic_dense invert(self, Polynomial_generic_dense a, long prec) noexcept: r""" Return the inverse of ``a``. diff --git a/src/sage/rings/padics/relaxed_template.pxi b/src/sage/rings/padics/relaxed_template.pxi index 751e42700f0..6e0fd4fac50 100644 --- a/src/sage/rings/padics/relaxed_template.pxi +++ b/src/sage/rings/padics/relaxed_template.pxi @@ -123,7 +123,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ return p == self._parent.prime() - cdef cdigit_ptr _getdigit_relative(self, long i): + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept: r""" Return a pointer on the `i`-th significant digit of this number. @@ -139,7 +139,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ pass - cdef cdigit_ptr _getdigit_absolute(self, long i): + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept: r""" Return a pointer on the digit in position `i` of this number. @@ -156,7 +156,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ pass - cdef void _getslice_relative(self, celement slice, long start, long length): + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept: r""" Select a slice of the digits of this number. @@ -177,7 +177,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ pass - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -197,7 +197,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ raise NotImplementedError("must be implemented in subclasses") - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -219,7 +219,7 @@ cdef class RelaxedElement(pAdicGenericElement): return ERROR_PRECISION return 0 - cdef int _jump_relative_c(self, long prec, long halt): + cdef int _jump_relative_c(self, long prec, long halt) noexcept: r""" Compute the digits of this number until the relative precision ``prec``. @@ -1317,7 +1317,7 @@ cdef class RelaxedElement(pAdicGenericElement): ans._init_jump() return ans - cdef long valuation_c(self, long halt=-maxordp): + cdef long valuation_c(self, long halt=-maxordp) noexcept: r""" Return the best lower bound we have on the valuation of this element at the current stage of the computation. @@ -1709,7 +1709,7 @@ cdef class RelaxedElement(pAdicGenericElement): """ return self.__rshift__(-s) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: r""" Return the sum of this element with ``other``. @@ -1728,7 +1728,7 @@ cdef class RelaxedElement(pAdicGenericElement): return self return element_class_add(self._parent, self, other) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: r""" Return the difference of this element and ``other``. @@ -1750,7 +1750,7 @@ cdef class RelaxedElement(pAdicGenericElement): return self return element_class_sub(self._parent, self, other) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the opposite of this element. @@ -1767,7 +1767,7 @@ cdef class RelaxedElement(pAdicGenericElement): return self return element_class_sub(self._parent, self._parent.zero(), self) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return the product of this element with ``other``. @@ -1789,7 +1789,7 @@ cdef class RelaxedElement(pAdicGenericElement): return other return element_class_mul(self._parent, self, other) - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: r""" Return the quotient if this element by ``other``. @@ -2054,7 +2054,7 @@ cdef class RelaxedElement_abandon(RelaxedElement): """ self._valuation = -maxordp - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this element. @@ -2082,21 +2082,21 @@ cdef class RelaxedElementWithDigits(RelaxedElement): """ element_clear(self._digits) - cdef cdigit_ptr _getdigit_relative(self, long i): + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in relative precision. """ return element_get_digit(self._digits, i) - cdef cdigit_ptr _getdigit_absolute(self, long i): + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in absolute precision. """ return element_get_digit(self._digits, i - self._valuation) - cdef void _getslice_relative(self, celement slice, long start, long length): + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept: r""" Select a slice of the sequence of digits of this element. @@ -2170,21 +2170,21 @@ cdef class RelaxedElement_zero(RelaxedElement): """ return self.__class__, (self._parent,) - cdef cdigit_ptr _getdigit_relative(self, long i): + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in relative precision. """ return digit_zero - cdef cdigit_ptr _getdigit_absolute(self, long i): + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in absolute precision. """ return digit_zero - cdef void _getslice_relative(self, celement slice, long start, long length): + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept: r""" Select a slice of the sequence of digits of this element. @@ -2198,7 +2198,7 @@ cdef class RelaxedElement_zero(RelaxedElement): """ element_init(slice) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -2212,7 +2212,7 @@ cdef class RelaxedElement_zero(RelaxedElement): """ return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -2274,7 +2274,7 @@ cdef class RelaxedElement_one(RelaxedElementWithDigits): """ return self.__class__, (self._parent,) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -2290,7 +2290,7 @@ cdef class RelaxedElement_one(RelaxedElementWithDigits): self._precrel = prec return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -2366,21 +2366,21 @@ cdef class RelaxedElement_bound(RelaxedElement): """ return self.__class__, (self._parent, self._x, self._precbound) - cdef cdigit_ptr _getdigit_relative(self, long i): + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in relative precision. """ return self._x._getdigit_relative(i) - cdef cdigit_ptr _getdigit_absolute(self, long i): + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in absolute precision. """ return self._x._getdigit_absolute(i) - cdef void _getslice_relative(self, celement slice, long start, long length): + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept: r""" Select a slice of the digits of this number. @@ -2401,7 +2401,7 @@ cdef class RelaxedElement_bound(RelaxedElement): """ self._x._getslice_relative(slice, start, length) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Jump to the absolute precision ``prec``. @@ -2424,7 +2424,7 @@ cdef class RelaxedElement_bound(RelaxedElement): self._precrel = min(x._precrel, self._precbound - self._valuation) return error - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Jump to the next digit. @@ -2507,7 +2507,7 @@ cdef class RelaxedElement_value(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._value, self._shift, self._precbound) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -2531,7 +2531,7 @@ cdef class RelaxedElement_value(RelaxedElementWithDigits): return ERROR_OVERFLOW return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -2648,7 +2648,7 @@ cdef class RelaxedElement_random(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._initialvaluation, self._precbound, self._seed) - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Generate the next digit of this number at random. @@ -2746,14 +2746,14 @@ cdef class RelaxedElement_slice(RelaxedElement): """ return self.__class__, (self._parent, self._x, self._start, self._stop, self._shift) - cdef cdigit_ptr _getdigit_relative(self, long i): + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in relative precision. """ return self._getdigit_absolute(i + self._valuation) - cdef cdigit_ptr _getdigit_absolute(self, long i): + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept: r""" Return a pointer on the `i`-th digit of this number in absolute precision. @@ -2764,7 +2764,7 @@ cdef class RelaxedElement_slice(RelaxedElement): else: return self._x._getdigit_absolute(j) - cdef void _getslice_relative(self, celement slice, long start, long length): + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept: r""" Select a slice of the sequence of digits of this element. @@ -2788,7 +2788,7 @@ cdef class RelaxedElement_slice(RelaxedElement): cdef long stop_absolute = min(self._stop, s + length) x._getslice_relative(slice, start_absolute - x._valuation, stop_absolute - start_absolute) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Jump to the absolute precision ``prec``. @@ -2820,7 +2820,7 @@ cdef class RelaxedElement_slice(RelaxedElement): self._precrel = prec - self._valuation return error - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Jump to the next digit. @@ -2895,7 +2895,7 @@ cdef class RelaxedElement_add(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._x, self._y) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -2925,7 +2925,7 @@ cdef class RelaxedElement_add(RelaxedElementWithDigits): n += 1 return error - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3002,7 +3002,7 @@ cdef class RelaxedElement_sub(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._x, self._y) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -3032,7 +3032,7 @@ cdef class RelaxedElement_sub(RelaxedElementWithDigits): n += 1 return error - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3137,7 +3137,7 @@ cdef class RelaxedElement_mul(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._x, self._y) - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3191,7 +3191,7 @@ cdef class RelaxedElement_mul(RelaxedElementWithDigits): self._precrel += 1 return 0 - cdef int _update_last_digit(self): + cdef int _update_last_digit(self) noexcept: r""" Redo the computation of the last digit and update carries accordingly. @@ -3259,7 +3259,7 @@ cdef class RelaxedElement_muldigit(RelaxedElementWithDigits): self._valuation = y._valuation self._init_jump() - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3379,7 +3379,7 @@ cdef class RelaxedElement_div(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._num, self._denom, self._valuation, self._precbound) - cdef int _bootstrap_c(self): + cdef int _bootstrap_c(self) noexcept: r""" Bootstrap the computation of the digits of this element, that is: @@ -3425,7 +3425,7 @@ cdef class RelaxedElement_div(RelaxedElementWithDigits): self._definition = element_class_sub(parent, a, d) return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3524,7 +3524,7 @@ cdef class RelaxedElement_sqrt(RelaxedElementWithDigits): """ return self.__class__, (self._parent, self._x) - cdef int _bootstrap_c(self): + cdef int _bootstrap_c(self) noexcept: r""" Bootstrap the computation of the digits of this element, that is: @@ -3606,7 +3606,7 @@ cdef class RelaxedElement_sqrt(RelaxedElementWithDigits): self._definition = (y + c - u*u) / d return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3710,7 +3710,7 @@ cdef class RelaxedElement_teichmuller(RelaxedElementWithDigits): xbar = digit_get_sage(element_get_digit(self._digits, 0)) return self.__class__, (self._parent, xbar) - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Compute the digits of this number until the absolute precision ``prec``. @@ -3730,7 +3730,7 @@ cdef class RelaxedElement_teichmuller(RelaxedElementWithDigits): return 0 return RelaxedElement._jump_c(self, prec) - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3837,7 +3837,7 @@ cdef class RelaxedElement_unknown(RelaxedElementWithDigits): definition = self._definition return unpickle_unknown, (id(self), self.__class__, self._parent, self._initialvaluation, digits, definition) - cpdef set(self, RelaxedElement definition): + cpdef set(self, RelaxedElement definition) noexcept: r""" Set the recursive definition of this self-referent number. @@ -3901,7 +3901,7 @@ cdef class RelaxedElement_unknown(RelaxedElementWithDigits): self._init_jump() return eq - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Compute the next digit of this number. @@ -3991,20 +3991,20 @@ cdef class RelaxedElement_zeroone(RelaxedElementWithDigits): RelaxedElement.__init__(self, parent) self._valuation = valuation - cdef void _setdigit_to_zero(self): + cdef void _setdigit_to_zero(self) noexcept: r""" Append `0` to the list of digits of this element. """ self._precrel += 1 - cdef void _setdigit_to_one(self): + cdef void _setdigit_to_one(self) noexcept: r""" Append `1` to the list of digits of this element. """ element_set_digit_ui(self._digits, 1, self._precrel) self._precrel += 1 - cdef int _jump_c(self, long prec): + cdef int _jump_c(self, long prec) noexcept: r""" Jump to the absolute precision ``prec``. @@ -4020,7 +4020,7 @@ cdef class RelaxedElement_zeroone(RelaxedElementWithDigits): return ERROR_NOTDEFINED return 0 - cdef int _next_c(self): + cdef int _next_c(self) noexcept: r""" Jump to the next digit. @@ -4154,7 +4154,7 @@ cdef class ExpansionIter(): """ return self - cdef _next_simple(self): + cdef _next_simple(self) noexcept: r""" Return the next digit of this expansion (simple mode). """ @@ -4164,7 +4164,7 @@ cdef class ExpansionIter(): self.current += 1 return digit_get_sage(self.digit) - cdef _next_smallest(self): + cdef _next_smallest(self) noexcept: r""" Return the next digit of this expansion (smallest mode). """ @@ -4175,7 +4175,7 @@ cdef class ExpansionIter(): self.current += 1 return digit_get_sage(self.digit) - cdef _next_teichmuller(self): + cdef _next_teichmuller(self) noexcept: r""" Return the next digit of this expansion (Teichmüller mode). """ diff --git a/src/sage/rings/padics/relaxed_template_header.pxi b/src/sage/rings/padics/relaxed_template_header.pxi index 5425c11c45d..1baa4bfdbe7 100644 --- a/src/sage/rings/padics/relaxed_template_header.pxi +++ b/src/sage/rings/padics/relaxed_template_header.pxi @@ -34,16 +34,16 @@ cdef class RelaxedElement(pAdicGenericElement): cdef long _precbound cdef PowComputer_class prime_pow - cdef cdigit_ptr _getdigit_relative(self, long i) - cdef cdigit_ptr _getdigit_absolute(self, long i) - cdef void _getslice_relative(self, celement slice, long start, long length) + cdef cdigit_ptr _getdigit_relative(self, long i) noexcept + cdef cdigit_ptr _getdigit_absolute(self, long i) noexcept + cdef void _getslice_relative(self, celement slice, long start, long length) noexcept cdef int _init_jump(self) except -1 - cdef int _jump_c(self, long prec) - cdef int _jump_relative_c(self, long prec, long halt) - cdef int _next_c(self) + cdef int _jump_c(self, long prec) noexcept + cdef int _jump_relative_c(self, long prec, long halt) noexcept + cdef int _next_c(self) noexcept - cdef long valuation_c(self, long halt=*) + cdef long valuation_c(self, long halt=*) noexcept cdef bint _is_equal(self, RelaxedElement right, long prec, bint permissive) except -1 cdef class RelaxedElement_abandon(RelaxedElement): @@ -98,7 +98,7 @@ cdef class RelaxedElement_mul(RelaxedElementWithDigits): cdef cdigit _lastdigit_x cdef RelaxedElement _y cdef cdigit _lastdigit_y - cdef int _update_last_digit(self) + cdef int _update_last_digit(self) noexcept cdef class RelaxedElement_muldigit(RelaxedElementWithDigits): cdef cdigit_ptr _x @@ -110,13 +110,13 @@ cdef class RelaxedElement_div(RelaxedElementWithDigits): cdef RelaxedElement _num cdef RelaxedElement _denom cdef RelaxedElement _definition - cdef int _bootstrap_c(self) + cdef int _bootstrap_c(self) noexcept cdef bint _bootstraping cdef class RelaxedElement_sqrt(RelaxedElementWithDigits): cdef RelaxedElement _x cdef RelaxedElement _definition - cdef int _bootstrap_c(self) + cdef int _bootstrap_c(self) noexcept cdef class RelaxedElement_teichmuller(RelaxedElementWithDigits): cdef bint _ready @@ -130,7 +130,7 @@ cdef class RelaxedElement_teichmuller(RelaxedElementWithDigits): cdef class RelaxedElement_unknown(RelaxedElementWithDigits): cdef RelaxedElement _definition cdef long _next - cpdef set(self, RelaxedElement definition) + cpdef set(self, RelaxedElement definition) noexcept # for pickling cdef long _initialvaluation cdef long _initialprecrel @@ -138,8 +138,8 @@ cdef class RelaxedElement_unknown(RelaxedElementWithDigits): # Expansion cdef class RelaxedElement_zeroone(RelaxedElementWithDigits): - cdef void _setdigit_to_zero(self) - cdef void _setdigit_to_one(self) + cdef void _setdigit_to_zero(self) noexcept + cdef void _setdigit_to_one(self) noexcept cdef class ExpansionIter(): cdef RelaxedElement elt @@ -149,11 +149,11 @@ cdef class ExpansionIter(): cdef long current cdef cdigit digit # simple mode - cdef _next_simple(self) + cdef _next_simple(self) noexcept # smallest mode cdef cdigit carry - cdef _next_smallest(self) + cdef _next_smallest(self) noexcept # teichmuller mode cdef RelaxedElement tail cdef dict coefficients - cdef _next_teichmuller(self) + cdef _next_teichmuller(self) noexcept diff --git a/src/sage/rings/polynomial/evaluation_flint.pxd b/src/sage/rings/polynomial/evaluation_flint.pxd index b699871ba0c..4504e8af63c 100644 --- a/src/sage/rings/polynomial/evaluation_flint.pxd +++ b/src/sage/rings/polynomial/evaluation_flint.pxd @@ -2,5 +2,5 @@ from sage.libs.flint.types cimport fmpz_poly_t from sage.libs.mpfr.types cimport mpfr_t from sage.libs.mpfi.types cimport mpfi_t -cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t a) -cdef fmpz_poly_evaluation_mpfi(mpfi_t res, const fmpz_poly_t poly, const mpfi_t a) +cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t a) noexcept +cdef fmpz_poly_evaluation_mpfi(mpfi_t res, const fmpz_poly_t poly, const mpfi_t a) noexcept diff --git a/src/sage/rings/polynomial/evaluation_flint.pyx b/src/sage/rings/polynomial/evaluation_flint.pyx index fc75fabd42d..94204c0556b 100644 --- a/src/sage/rings/polynomial/evaluation_flint.pyx +++ b/src/sage/rings/polynomial/evaluation_flint.pyx @@ -34,7 +34,7 @@ from sage.libs.gmp.mpq cimport * from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpz_poly cimport * -cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t a): +cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t a) noexcept: cdef mpz_t c cdef long i @@ -49,7 +49,7 @@ cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t mpz_clear(c) -cdef fmpz_poly_evaluation_mpfi(mpfi_t res, const fmpz_poly_t poly, const mpfi_t a): +cdef fmpz_poly_evaluation_mpfi(mpfi_t res, const fmpz_poly_t poly, const mpfi_t a) noexcept: cdef mpz_t c cdef long i diff --git a/src/sage/rings/polynomial/evaluation_ntl.pxd b/src/sage/rings/polynomial/evaluation_ntl.pxd index 9af0a0b9d40..4551037ecca 100644 --- a/src/sage/rings/polynomial/evaluation_ntl.pxd +++ b/src/sage/rings/polynomial/evaluation_ntl.pxd @@ -2,5 +2,5 @@ from sage.libs.ntl.types cimport ZZX_c from sage.libs.mpfr.types cimport mpfr_t from sage.libs.mpfi.types cimport mpfi_t -cdef ZZX_evaluation_mpfr(mpfr_t res, ZZX_c poly, const mpfr_t a) -cdef ZZX_evaluation_mpfi(mpfi_t res, ZZX_c poly, const mpfi_t a) +cdef ZZX_evaluation_mpfr(mpfr_t res, ZZX_c poly, const mpfr_t a) noexcept +cdef ZZX_evaluation_mpfi(mpfi_t res, ZZX_c poly, const mpfi_t a) noexcept diff --git a/src/sage/rings/polynomial/evaluation_ntl.pyx b/src/sage/rings/polynomial/evaluation_ntl.pyx index 28b3917d3a1..b6ff4732542 100644 --- a/src/sage/rings/polynomial/evaluation_ntl.pyx +++ b/src/sage/rings/polynomial/evaluation_ntl.pyx @@ -38,7 +38,7 @@ from sage.libs.ntl.ZZ cimport * from sage.libs.ntl.ZZX cimport * -cdef ZZX_evaluation_mpfr(mpfr_t res, ZZX_c poly, const mpfr_t a): +cdef ZZX_evaluation_mpfr(mpfr_t res, ZZX_c poly, const mpfr_t a) noexcept: cdef mpz_t c cdef long i @@ -53,7 +53,7 @@ cdef ZZX_evaluation_mpfr(mpfr_t res, ZZX_c poly, const mpfr_t a): mpz_clear(c) -cdef ZZX_evaluation_mpfi(mpfi_t res, ZZX_c poly, const mpfi_t a): +cdef ZZX_evaluation_mpfi(mpfi_t res, ZZX_c poly, const mpfi_t a) noexcept: cdef mpz_t c cdef long i diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx index d2abf325fd8..754a2bad1b7 100644 --- a/src/sage/rings/polynomial/hilbert.pyx +++ b/src/sage/rings/polynomial/hilbert.pyx @@ -57,7 +57,7 @@ cdef class Node: fmpz_poly_clear(self.RMult) fmpz_poly_clear(self.LeftFHS) -cdef inline size_t median(list v): +cdef inline size_t median(list v) noexcept: """ Specialized version of :func:`from sage.stats.basic_stats.median`. """ @@ -74,7 +74,7 @@ cdef inline size_t median(list v): # cdef functions related with lists of monomials ### -cdef inline bint indivisible_in_list(ETuple m, list L, size_t i): +cdef inline bint indivisible_in_list(ETuple m, list L, size_t i) noexcept: """ Return if ``m`` divisible by any monomial in ``L[:i]``. """ @@ -84,7 +84,7 @@ cdef inline bint indivisible_in_list(ETuple m, list L, size_t i): return False return True -cdef inline list interred(list L): +cdef inline list interred(list L) noexcept: """ Return interreduction of a list of monomials. @@ -116,7 +116,7 @@ cdef inline list interred(list L): result.append(m) return result -cdef list quotient(list L, ETuple m): +cdef list quotient(list L, ETuple m) noexcept: """ Return the quotient of the ideal represented by ``L`` and the monomial represented by ``m``. @@ -127,7 +127,7 @@ cdef list quotient(list L, ETuple m): result.append((PyList_GET_ITEM(L,i)).divide_by_gcd(m)) return interred(result) -cdef list quotient_by_var(list L, size_t index): +cdef list quotient_by_var(list L, size_t index) noexcept: """ Return the quotient of the ideal represented by ``L`` and the variable number ``index``. @@ -140,7 +140,7 @@ cdef list quotient_by_var(list L, size_t index): result.append(( PyList_GET_ITEM(L, i)).divide_by_var(index)) return interred(result) -cdef ETuple sum_from_list(list L, size_t s, size_t l): +cdef ETuple sum_from_list(list L, size_t s, size_t l) noexcept: """ Compute the vector sum of the ETuples in ``L[s:s+l]`` in a balanced way. """ @@ -154,7 +154,7 @@ cdef ETuple sum_from_list(list L, size_t s, size_t l): m2 = sum_from_list(L, s+l2, l-l2) return m1.eadd(m2) -cdef bint HilbertBaseCase(Polynomial_integer_dense_flint fhs, Node D, tuple w): +cdef bint HilbertBaseCase(Polynomial_integer_dense_flint fhs, Node D, tuple w) noexcept: """ Try to compute the first Hilbert series of ``D.Id``, or return ``NotImplemented``. @@ -286,7 +286,7 @@ cdef bint HilbertBaseCase(Polynomial_integer_dense_flint fhs, Node D, tuple w): # We are in a truly difficult case and give up for now... return False -cdef make_children(Node D, tuple w): +cdef make_children(Node D, tuple w) noexcept: """ Create child nodes in ``D`` that allow to compute the first Hilbert series of ``D.Id``. diff --git a/src/sage/rings/polynomial/laurent_polynomial.pxd b/src/sage/rings/polynomial/laurent_polynomial.pxd index 8e9107aeb47..d99243aaf3d 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pxd +++ b/src/sage/rings/polynomial/laurent_polynomial.pxd @@ -2,16 +2,16 @@ from sage.structure.element cimport CommutativeAlgebraElement, ModuleElement, Ri cdef class LaurentPolynomial(CommutativeAlgebraElement): - cdef LaurentPolynomial _new_c(self) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _floordiv_(self, other) + cdef LaurentPolynomial _new_c(self) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _floordiv_(self, other) noexcept cpdef long number_of_terms(self) except -1 - cpdef dict dict(self) + cpdef dict dict(self) noexcept cdef class LaurentPolynomial_univariate(LaurentPolynomial): cdef ModuleElement __u cdef long __n - cpdef _normalize(self) - cpdef _unsafe_mutate(self, i, value) + cpdef _normalize(self) noexcept + cpdef _unsafe_mutate(self, i, value) noexcept diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index cf92b0e43d1..9d28ed6a872 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -21,7 +21,7 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): """ Base class for Laurent polynomials. """ - cdef LaurentPolynomial _new_c(self): + cdef LaurentPolynomial _new_c(self) noexcept: """ Return a new Laurent polynomial. @@ -37,7 +37,7 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): ans._parent = self._parent return ans - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Abstract addition method @@ -52,7 +52,7 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): """ raise NotImplementedError - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Abstract multiplication method @@ -67,7 +67,7 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): """ raise NotImplementedError - cpdef _floordiv_(self, other): + cpdef _floordiv_(self, other) noexcept: """ Abstract floor division method @@ -220,7 +220,7 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): """ return self.number_of_terms() - cpdef dict dict(self): + cpdef dict dict(self) noexcept: """ Abstract ``dict`` method. @@ -531,7 +531,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): u = u.map_coefficients(base_map) return codomain(u(x) * x**self.__n) - cpdef _normalize(self): + cpdef _normalize(self) noexcept: r""" A Laurent series is a pair `(u(t), n)`, where either `u = 0` (to some precision) or `u` is a unit. This pair corresponds to @@ -840,7 +840,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): d = {repr(g): R.var(g) for g in self._parent.gens()} return self.subs(**d) - cpdef dict dict(self): + cpdef dict dict(self) noexcept: """ Return a dictionary representing ``self``. @@ -895,7 +895,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): """ raise IndexError("Laurent polynomials are immutable") - cpdef _unsafe_mutate(self, i, value): + cpdef _unsafe_mutate(self, i, value) noexcept: r""" Sage assumes throughout that commutative ring elements are immutable. This is relevant for caching, etc. But sometimes you @@ -921,7 +921,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): self.__u = self.__u._parent(coeffs) self._normalize() - cpdef _add_(self, right_m): + cpdef _add_(self, right_m) noexcept: """ Add two Laurent polynomials with the same parent. @@ -975,7 +975,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): ret._normalize() return ret - cpdef _sub_(self, right_m): + cpdef _sub_(self, right_m) noexcept: """ Subtract two Laurent polynomials with the same parent. @@ -1048,7 +1048,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): # No need to normalize return ret - cpdef _mul_(self, right_r): + cpdef _mul_(self, right_r) noexcept: """ EXAMPLES:: @@ -1066,7 +1066,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): ret._normalize() return ret - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ EXAMPLES:: @@ -1082,7 +1082,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): ret._normalize() return ret - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ EXAMPLES:: @@ -1152,7 +1152,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): c = self._parent._R(self.__u.leading_coefficient() ** right) return self._parent.element_class(self._parent, c, self.__n*right) - cpdef _floordiv_(self, rhs): + cpdef _floordiv_(self, rhs) noexcept: """ Perform division with remainder and return the quotient. @@ -1240,7 +1240,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): # No need to normalize return ret - cpdef _div_(self, rhs): + cpdef _div_(self, rhs) noexcept: """ EXAMPLES:: @@ -1415,7 +1415,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): qr._normalize() return ql, qr - cpdef _richcmp_(self, right_r, int op): + cpdef _richcmp_(self, right_r, int op) noexcept: r""" Comparison of ``self`` and ``right_r``. diff --git a/src/sage/rings/polynomial/laurent_polynomial_mpair.pxd b/src/sage/rings/polynomial/laurent_polynomial_mpair.pxd index 79f09def6aa..f71ccb57030 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_mpair.pxd +++ b/src/sage/rings/polynomial/laurent_polynomial_mpair.pxd @@ -7,8 +7,8 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): cdef ETuple _mon cdef MPolynomial _poly cdef PolyDict _prod - cdef _compute_polydict(self) - cdef _normalize(self, i=*) - cpdef rescale_vars(self, dict d, h=*, new_ring=*) - cpdef toric_coordinate_change(self, M, h=*, new_ring=*) - cpdef toric_substitute(self, v, v1, a, h=*, new_ring=*) + cdef _compute_polydict(self) noexcept + cdef _normalize(self, i=*) noexcept + cpdef rescale_vars(self, dict d, h=*, new_ring=*) noexcept + cpdef toric_coordinate_change(self, M, h=*, new_ring=*) noexcept + cpdef toric_substitute(self, v, v1, a, h=*, new_ring=*) noexcept diff --git a/src/sage/rings/polynomial/laurent_polynomial_mpair.pyx b/src/sage/rings/polynomial/laurent_polynomial_mpair.pyx index e14f1b36ce5..9c118a97a0f 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_mpair.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial_mpair.pyx @@ -250,7 +250,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): from sage.misc.misc_c import prod return codomain(p(im_gens) * prod(ig**m[im_gens.index(ig)] for ig in im_gens)) - cdef _normalize(self, i=None): + cdef _normalize(self, i=None) noexcept: r""" Remove the common monomials from ``self._poly`` and store them in ``self._mon``. @@ -301,7 +301,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): self._poly = (self._poly // self._poly._parent.gen(i)) self._mon = self._mon.eadd_p(e, i) - cdef _compute_polydict(self): + cdef _compute_polydict(self) noexcept: """ EXAMPLES:: @@ -767,7 +767,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): v.sort() return tuple(v) - cpdef dict dict(self): + cpdef dict dict(self) noexcept: """ Return ``self`` represented as a ``dict``. @@ -809,7 +809,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): denom *= var[i] ** (-j) return (numer, denom) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ Return the Laurent polynomial ``self + right``. @@ -834,7 +834,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly += right._poly return ans - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ Return the Laurent polynomial ``self - right``. @@ -860,7 +860,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly -= right._poly return ans - cpdef _div_(self, rhs): + cpdef _div_(self, rhs) noexcept: """ Return the division of ``self`` by ``rhs``. @@ -911,7 +911,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): """ return self._poly.is_monomial() - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return ``-self``. @@ -927,7 +927,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly = -self._poly return ans - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Return ``self * right`` where ``right`` is in ``self``'s base ring. @@ -943,7 +943,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly = self._poly * right return ans - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ Return ``left * self`` where ``left`` is in ``self``'s base ring. @@ -959,7 +959,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly = left * self._poly return ans - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Return ``self * right``. @@ -976,7 +976,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly = self._poly * (right)._poly return ans - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Perform division with remainder and return the quotient. @@ -1078,7 +1078,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): rl._normalize() return (ql, rl) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: """ Compare two polynomials in a `LaurentPolynomialRing` based on the term order from the parent ring. If the parent ring does not specify a term @@ -1645,7 +1645,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): ans._poly = root return (True, ans) - cpdef rescale_vars(self, dict d, h=None, new_ring=None): + cpdef rescale_vars(self, dict d, h=None, new_ring=None) noexcept: r""" Rescale variables in a Laurent polynomial. @@ -1712,7 +1712,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): return new_ring(ans) return ans - cpdef toric_coordinate_change(self, M, h=None, new_ring=None): + cpdef toric_coordinate_change(self, M, h=None, new_ring=None) noexcept: r""" Apply a matrix to the exponents in a Laurent polynomial. @@ -1781,7 +1781,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): return new_ring(ans) return ans - cpdef toric_substitute(self, v, v1, a, h=None, new_ring=None): + cpdef toric_substitute(self, v, v1, a, h=None, new_ring=None) noexcept: r""" Perform a single-variable substitution up to a toric coordinate change. diff --git a/src/sage/rings/polynomial/multi_polynomial.pxd b/src/sage/rings/polynomial/multi_polynomial.pxd index 5dc75e6bd3f..73bde26ab51 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pxd +++ b/src/sage/rings/polynomial/multi_polynomial.pxd @@ -3,8 +3,8 @@ from .commutative_polynomial cimport CommutativePolynomial cdef class MPolynomial(CommutativePolynomial): cdef long _hash_c(self) except -1 - cpdef _mod_(self, right) - cpdef dict _mpoly_dict_recursive(self, tuple vars=*, base_ring=*) + cpdef _mod_(self, right) noexcept + cpdef dict _mpoly_dict_recursive(self, tuple vars=*, base_ring=*) noexcept cdef class MPolynomial_libsingular(MPolynomial): diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index d0a430bbfd8..d680f227210 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -433,7 +433,7 @@ cdef class MPolynomial(CommutativePolynomial): z *= var return ring(v) - cpdef dict _mpoly_dict_recursive(self, tuple vars=None, base_ring=None): + cpdef dict _mpoly_dict_recursive(self, tuple vars=None, base_ring=None) noexcept: r""" Return a ``dict`` of coefficient entries suitable for construction of a ``MPolynomial_polydict`` with the given variables. @@ -812,7 +812,7 @@ cdef class MPolynomial(CommutativePolynomial): d[e.unweighted_degree()][e] = c return {k: self._parent(d[k]) for k in d} - cpdef _mod_(self, other): + cpdef _mod_(self, other) noexcept: r""" EXAMPLES:: @@ -2891,7 +2891,7 @@ def _is_M_convex_(points): return True -cdef remove_from_tuple(e, int ind): +cdef remove_from_tuple(e, int ind) noexcept: w = list(e) del w[ind] if len(w) == 1: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd index 58f853973dc..fefa241523d 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd +++ b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd @@ -1,4 +1,4 @@ from sage.libs.singular.decl cimport ideal, ring -cdef object singular_ideal_to_sage_sequence(ideal *i, ring *r, object parent) +cdef object singular_ideal_to_sage_sequence(ideal *i, ring *r, object parent) noexcept cdef ideal *sage_ideal_to_singular_ideal(I) except NULL diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx index 14820418454..38e251d84ce 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx @@ -67,7 +67,7 @@ from sage.structure.sequence import Sequence from sage.rings.polynomial.plural cimport NCPolynomialRing_plural, NCPolynomial_plural -cdef object singular_ideal_to_sage_sequence(ideal *i, ring *r, object parent): +cdef object singular_ideal_to_sage_sequence(ideal *i, ring *r, object parent) noexcept: """ convert a SINGULAR ideal to a Sage Sequence (the format Sage stores a Groebner basis in) diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pxd b/src/sage/rings/polynomial/multi_polynomial_libsingular.pxd index c9cec10e2bc..744774ea231 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pxd +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pxd @@ -8,14 +8,14 @@ cdef class MPolynomialRing_libsingular cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): cdef poly *_poly cdef ring *_parent_ring - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _floordiv_(self, right) - cpdef _repr_short_(self) - cpdef is_constant(self) - cpdef _homogenize(self, int var) - cpdef MPolynomial_libsingular _new_constant_poly(self, x, MPolynomialRing_libsingular P) - cpdef long number_of_terms(self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _floordiv_(self, right) noexcept + cpdef _repr_short_(self) noexcept + cpdef is_constant(self) noexcept + cpdef _homogenize(self, int var) noexcept + cpdef MPolynomial_libsingular _new_constant_poly(self, x, MPolynomialRing_libsingular P) noexcept + cpdef long number_of_terms(self) noexcept cdef class MPolynomialRing_libsingular(MPolynomialRing_base): cdef object __singular @@ -26,4 +26,4 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base): cdef ring *_ring # new polynomials -cdef MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, poly *p) +cdef MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, poly *p) noexcept diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 8b1086714f5..e9787a2e0f7 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -462,7 +462,7 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base): memo[id(self)] = self return self - cpdef _coerce_map_from_(self, other): + cpdef _coerce_map_from_(self, other) noexcept: """ Return ``True`` if and only if there exists a coercion map from ``other`` to ``self``. @@ -1974,7 +1974,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): memo[id(self)] = cpy return cpy - cpdef MPolynomial_libsingular _new_constant_poly(self, x, MPolynomialRing_libsingular P): + cpdef MPolynomial_libsingular _new_constant_poly(self, x, MPolynomialRing_libsingular P) noexcept: r""" Quickly create a new constant polynomial with value x in the parent P. @@ -2136,7 +2136,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): """ return self._hash_c() - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare left and right. @@ -2194,7 +2194,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): cdef ring *r = (left)._parent_ring return rich_to_bool(op, singular_polynomial_cmp(p, q, r)) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add left and right. @@ -2210,7 +2210,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): (right)._poly, r) return new_MP((left)._parent, _p) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ Subtract left and right. @@ -2227,7 +2227,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): _ring) return new_MP((left)._parent, _p) - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ Multiply self with a base ring element. @@ -2251,7 +2251,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): singular_polynomial_rmul(&_p, self._poly, left, _ring) return new_MP((self)._parent, _p) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply left and right. @@ -2275,7 +2275,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): (left)._parent_ring) return new_MP((left)._parent,_p) - cpdef _div_(left, right_ringelement): + cpdef _div_(left, right_ringelement) noexcept: r""" Divide left by right @@ -2478,7 +2478,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): s = singular_polynomial_str(self._poly, _ring) return s - cpdef _repr_short_(self): + cpdef _repr_short_(self) noexcept: """ This is a faster but less pretty way to print polynomials. If available it uses the short SINGULAR notation. @@ -3029,7 +3029,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): yield (tuple(exp), si2sa(p_GetCoeff(p, r), r, base)) p = pNext(p) - cpdef long number_of_terms(self): + cpdef long number_of_terms(self) noexcept: """ Return the number of non-zero coefficients of this polynomial. @@ -3281,7 +3281,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): rChangeCurrRing(_ring) return bool(p_IsHomogeneous(self._poly,_ring)) - cpdef _homogenize(self, int var): + cpdef _homogenize(self, int var) noexcept: """ Return ``self`` if ``self`` is homogeneous. Otherwise return a homogenized polynomial constructed by modifying the degree @@ -3913,7 +3913,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): """ return len(self._variable_indices_(sort=False)) - cpdef is_constant(self): + cpdef is_constant(self) noexcept: """ Return ``True`` if this polynomial is constant. @@ -4055,7 +4055,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): else: return False - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Perform division with remainder and return the quotient. @@ -5900,7 +5900,7 @@ def unpickle_MPolynomial_libsingular(MPolynomialRing_libsingular R, d): return new_MP(R, p) -cdef inline poly *addwithcarry(poly *tempvector, poly *maxvector, int pos, ring *_ring): +cdef inline poly *addwithcarry(poly *tempvector, poly *maxvector, int pos, ring *_ring) noexcept: if p_GetExp(tempvector, pos, _ring) < p_GetExp(maxvector, pos, _ring): p_SetExp(tempvector, pos, p_GetExp(tempvector, pos, _ring)+1, _ring) else: @@ -5910,7 +5910,7 @@ cdef inline poly *addwithcarry(poly *tempvector, poly *maxvector, int pos, ring return tempvector -cdef inline MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, poly *juice): +cdef inline MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, poly *juice) noexcept: """ Construct MPolynomial_libsingular from parent and SINGULAR poly. @@ -5938,5 +5938,5 @@ cdef inline MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, p return p -cdef poly *MPolynomial_libsingular_get_element(object self): +cdef poly *MPolynomial_libsingular_get_element(object self) noexcept: return (self)._poly diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_base.pxd b/src/sage/rings/polynomial/multi_polynomial_ring_base.pxd index eb6f8b70917..a090a15ac34 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring_base.pxd +++ b/src/sage/rings/polynomial/multi_polynomial_ring_base.pxd @@ -8,7 +8,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): cdef public object _magma_gens cdef public dict _magma_cache - cdef _coerce_c_impl(self, x) + cdef _coerce_c_impl(self, x) noexcept cdef class BooleanPolynomialRing_base(MPolynomialRing_base): diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx index c8f66508cc2..66ade555385 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx @@ -554,7 +554,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): else: return self._generic_coerce_map(self.base_ring()) - cdef _coerce_c_impl(self, x): + cdef _coerce_c_impl(self, x) noexcept: """ Return the canonical coercion of x to this multivariate polynomial ring, if one is defined, or raise a TypeError. diff --git a/src/sage/rings/polynomial/ore_polynomial_element.pxd b/src/sage/rings/polynomial/ore_polynomial_element.pxd index aa36112ab90..86b14f7d213 100644 --- a/src/sage/rings/polynomial/ore_polynomial_element.pxd +++ b/src/sage/rings/polynomial/ore_polynomial_element.pxd @@ -8,38 +8,38 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial_generic_dense cdef class OrePolynomial(AlgebraElement): cdef _is_gen - cdef long _hash_c(self) - cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=*) - cpdef OrePolynomial _new_constant_poly(self, RingElement a, Parent P, char check=*) - cpdef _neg_(self) - cpdef _floordiv_(self, right) - cpdef _mod_(self, right) - - cpdef bint is_zero(self) - cpdef bint is_one(self) + cdef long _hash_c(self) noexcept + cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=*) noexcept + cpdef OrePolynomial _new_constant_poly(self, RingElement a, Parent P, char check=*) noexcept + cpdef _neg_(self) noexcept + cpdef _floordiv_(self, right) noexcept + cpdef _mod_(self, right) noexcept + + cpdef bint is_zero(self) noexcept + cpdef bint is_one(self) noexcept - cdef _left_quo_rem(self, OrePolynomial other) - cdef _right_quo_rem(self, OrePolynomial other) - cdef OrePolynomial _left_lcm_cofactor(self, OrePolynomial other) - cdef OrePolynomial _right_lcm_cofactor(self, OrePolynomial other) + cdef _left_quo_rem(self, OrePolynomial other) noexcept + cdef _right_quo_rem(self, OrePolynomial other) noexcept + cdef OrePolynomial _left_lcm_cofactor(self, OrePolynomial other) noexcept + cdef OrePolynomial _right_lcm_cofactor(self, OrePolynomial other) noexcept # Abstract methods - cpdef Integer degree(self) - cpdef list coefficients(self, sparse=*) + cpdef Integer degree(self) noexcept + cpdef list coefficients(self, sparse=*) noexcept -cdef void lmul_gen(list A, Morphism m, d) +cdef void lmul_gen(list A, Morphism m, d) noexcept cdef class OrePolynomial_generic_dense(OrePolynomial): cdef list _coeffs - cdef void _normalize(self) - cpdef _add_(self, other) - cdef list _mul_list(self, list A) - cpdef _mul_(self, other) + cdef void _normalize(self) noexcept + cpdef _add_(self, other) noexcept + cdef list _mul_list(self, list A) noexcept + cpdef _mul_(self, other) noexcept - cpdef dict dict(self) - cpdef list list(self, bint copy=*) + cpdef dict dict(self) noexcept + cpdef list list(self, bint copy=*) noexcept cdef class OrePolynomialBaseringInjection(Morphism): diff --git a/src/sage/rings/polynomial/ore_polynomial_element.pyx b/src/sage/rings/polynomial/ore_polynomial_element.pyx index be154ba8b1a..53c14bbc23f 100644 --- a/src/sage/rings/polynomial/ore_polynomial_element.pyx +++ b/src/sage/rings/polynomial/ore_polynomial_element.pyx @@ -233,7 +233,7 @@ cdef class OrePolynomial(AlgebraElement): """ AlgebraElement.__init__(self, parent) - cdef long _hash_c(self): + cdef long _hash_c(self) noexcept: raise NotImplementedError def __hash__(self): @@ -251,7 +251,7 @@ cdef class OrePolynomial(AlgebraElement): """ return self._hash_c() - cpdef Integer degree(self): + cpdef Integer degree(self) noexcept: r""" Return the degree of ``self``. @@ -272,7 +272,7 @@ cdef class OrePolynomial(AlgebraElement): """ raise NotImplementedError - cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=0): + cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=0) noexcept: r""" Fast creation of a new Ore polynomial @@ -283,7 +283,7 @@ cdef class OrePolynomial(AlgebraElement): """ return P(coeffs) - cpdef OrePolynomial _new_constant_poly(self, RingElement a, Parent P, char check=0): + cpdef OrePolynomial _new_constant_poly(self, RingElement a, Parent P, char check=0) noexcept: r""" Fast creation of a new constant Ore polynomial @@ -580,7 +580,7 @@ cdef class OrePolynomial(AlgebraElement): raise NotImplementedError("the leading coefficient is not a unit") return a * self - cpdef _mod_(self, other): + cpdef _mod_(self, other) noexcept: r""" Return the remainder in the *right* Euclidean division of ``self`` by ``other```. @@ -602,7 +602,7 @@ cdef class OrePolynomial(AlgebraElement): """ return self.right_quo_rem(other)[1] - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: r""" Return the quotient of the *right* Euclidean division of ``self`` by ``right``. @@ -628,7 +628,7 @@ cdef class OrePolynomial(AlgebraElement): q, _ = self.right_quo_rem(right) return q - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: r""" Return the quotient of this Ore polynomial by ``right`` in the fraction field. @@ -940,7 +940,7 @@ cdef class OrePolynomial(AlgebraElement): V = V * lc return G, U, V - cdef _left_quo_rem(self, OrePolynomial other): + cdef _left_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the left Euclidean division of ``self`` by ``other`` (C implementation). @@ -1000,7 +1000,7 @@ cdef class OrePolynomial(AlgebraElement): raise ZeroDivisionError("division by zero is not valid") return self._left_quo_rem(other) - cdef _right_quo_rem(self, OrePolynomial other): + cdef _right_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the right Euclidean division of ``self`` by ``other`` (C implementation). @@ -1309,7 +1309,7 @@ cdef class OrePolynomial(AlgebraElement): A = A.left_monic() return A - cdef OrePolynomial _left_lcm_cofactor(self, OrePolynomial other): + cdef OrePolynomial _left_lcm_cofactor(self, OrePolynomial other) noexcept: r""" Return an Ore polynomial `U` such that `U P = c L` where `P` is this Ore polynomial (``self``), `L` @@ -1387,7 +1387,7 @@ cdef class OrePolynomial(AlgebraElement): V1 = s * V1 return L, V1, L // other - cdef OrePolynomial _right_lcm_cofactor(self, OrePolynomial other): + cdef OrePolynomial _right_lcm_cofactor(self, OrePolynomial other) noexcept: r""" Return an Ore polynomial `U` such that `P U = L c` where `P` is this Ore polynomial (``self``), `L` @@ -1942,7 +1942,7 @@ cdef class OrePolynomial(AlgebraElement): """ return self.is_term() and self.leading_coefficient() == 1 - cpdef list coefficients(self, sparse=True): + cpdef list coefficients(self, sparse=True) noexcept: r""" Return the coefficients of the monomials appearing in ``self``. @@ -2010,7 +2010,7 @@ cdef class OrePolynomial(AlgebraElement): """ return self - cpdef bint is_zero(self): + cpdef bint is_zero(self) noexcept: r""" Return ``True`` if ``self`` is the zero polynomial. @@ -2028,7 +2028,7 @@ cdef class OrePolynomial(AlgebraElement): """ return self.degree() == -1 - cpdef bint is_one(self): + cpdef bint is_one(self) noexcept: r""" Test whether this polynomial is `1`. @@ -2190,7 +2190,7 @@ cdef class OrePolynomial(AlgebraElement): return self.parent().variable_name() -cdef void lmul_gen(list A, Morphism m, d): +cdef void lmul_gen(list A, Morphism m, d) noexcept: r""" If ``A`` is the list of coefficients of an Ore polynomial ``P``, replace it by the list of coefficients of ``X*P`` (where ``X`` @@ -2323,7 +2323,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): """ return (self._parent, (self._coeffs,)) - cdef long _hash_c(self): + cdef long _hash_c(self) noexcept: r""" This hash incorporates the name of the variable. @@ -2354,7 +2354,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): return -2 return result - cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=0): + cdef OrePolynomial _new_c(self, list coeffs, Parent P, char check=0) noexcept: r""" Fast creation of a new Ore polynomial given a list of coefficients. @@ -2380,7 +2380,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): f._normalize() return f - cdef void _normalize(self): + cdef void _normalize(self) noexcept: r""" Remove higher order `0`-coefficients from the representation of ``self``. @@ -2397,7 +2397,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): del x[n] n -= 1 - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" Compare the two Ore polynomials ``self`` and ``other``. @@ -2463,7 +2463,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): except IndexError: return self.base_ring().zero() - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: r""" Return a list of the coefficients of ``self``. @@ -2491,7 +2491,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): else: return (self)._coeffs - cpdef dict dict(self): + cpdef dict dict(self) noexcept: r""" Return a dictionary representation of ``self``. @@ -2513,7 +2513,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): X[i] = c return X - cpdef Integer degree(self): + cpdef Integer degree(self) noexcept: r""" Return the degree of ``self``. @@ -2552,7 +2552,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): """ return Integer(len(self._coeffs) - 1) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Add two polynomials. @@ -2583,7 +2583,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): r = self._new_c([x[i] + y[i] for i in range(dx)], self._parent, 1) return r - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Subtract polynomial ``right`` from ``self``. @@ -2615,7 +2615,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): r = self._new_c([x[i] - y[i] for i in range(dx)], self._parent, 1) return r - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the negative of ``self``. @@ -2678,7 +2678,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): """ return self._new_c(self._coeffs[:n], self._parent, 1) - cdef list _mul_list(self, list A): + cdef list _mul_list(self, list A) noexcept: r""" Return the list of coefficients of the product of this Ore polynomial by that whose coefficients are given by ``A``. @@ -2699,7 +2699,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): BA[j] += coeff * A[j] return BA - cpdef _lmul_(self, Element s): + cpdef _lmul_(self, Element s) noexcept: r""" Return the product ``self * right``. @@ -2718,7 +2718,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): cdef coeffs = self._mul_list([s]) return self._new_c(coeffs, self._parent, 1) - cpdef _rmul_(self, Element s): + cpdef _rmul_(self, Element s) noexcept: r""" Return the product ``left * self``. @@ -2746,7 +2746,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): """ return self._new_c([s * c for c in self._coeffs], self._parent, 1) - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return the product ``self * right``. @@ -2785,7 +2785,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): coeffs = self._mul_list(coeffs) return self._new_c(coeffs, self._parent, 1) - cdef _left_quo_rem(self, OrePolynomial other): + cdef _left_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the left Euclidean division of ``self`` by ``other`` (C implementation). @@ -2814,7 +2814,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): quo.reverse() return self._new_c(quo, self._parent), self._new_c(A[:degB], self._parent, 1) - cdef _right_quo_rem(self, OrePolynomial other): + cdef _right_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the right Euclidean division of ``self`` by ``other`` (C implementation). @@ -2852,7 +2852,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial): quo.reverse() return self._new_c(quo, self._parent), self._new_c(A[:degB], self._parent, 1) - cpdef list coefficients(self, sparse=True): + cpdef list coefficients(self, sparse=True) noexcept: r""" Return the coefficients of the monomials appearing in ``self``. @@ -2988,7 +2988,7 @@ cdef class ConstantOrePolynomialSection(Map): over Rational Field twisted by t |--> t + 1 To: Univariate Polynomial Ring in t over Rational Field """ - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the corresponding element of the base ring if ``self`` is a constant Ore polynomial. Otherwise, it fails. @@ -3096,7 +3096,7 @@ cdef class OrePolynomialBaseringInjection(Morphism): """ return self._an_element - cpdef Element _call_(self, e): + cpdef Element _call_(self, e) noexcept: r""" Return the corresponding Ore polynomial to the element from the base ring according to ``self``. diff --git a/src/sage/rings/polynomial/pbori/pbori.pxd b/src/sage/rings/polynomial/pbori/pbori.pxd index ae4ac1353d2..f9083a681a2 100644 --- a/src/sage/rings/polynomial/pbori/pbori.pxd +++ b/src/sage/rings/polynomial/pbori/pbori.pxd @@ -17,12 +17,12 @@ cdef class BooleanPolynomialRing(BooleanPolynomialRing_base): # it is very important to keep this cached, since otherwise the magma interface will break cdef public object __cover_ring - cdef _convert(self, rhs) + cdef _convert(self, rhs) noexcept cdef class BooleanPolynomial(MPolynomial): cdef PBPoly _pbpoly - cpdef _add_(self, other) - cpdef _mul_(self, other) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept cdef class BooleSet: cdef BooleanPolynomialRing _ring @@ -35,7 +35,7 @@ cdef class CCuddNavigator: cdef class BooleanMonomial(MonoidElement): cdef PBMonom _pbmonom cdef BooleanPolynomialRing _ring - cpdef _mul_(self, other) + cpdef _mul_(self, other) noexcept cdef class BooleanMonomialVariableIterator: cdef object parent diff --git a/src/sage/rings/polynomial/pbori/pbori.pyx b/src/sage/rings/polynomial/pbori/pbori.pyx index 314196faa14..8560837f72e 100644 --- a/src/sage/rings/polynomial/pbori/pbori.pyx +++ b/src/sage/rings/polynomial/pbori/pbori.pyx @@ -607,7 +607,7 @@ cdef class BooleanPolynomialRing(BooleanPolynomialRing_base): return self._repr # Coercion - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ There is coercion from the base ring, from any boolean polynomial ring with compatible variable names, @@ -683,7 +683,7 @@ cdef class BooleanPolynomialRing(BooleanPolynomialRing_base): return False return self._base.has_coerce_map_from(S.base()) - cdef _convert(self, other): + cdef _convert(self, other) noexcept: r""" Canonical conversion of elements from other domains to this boolean polynomial ring. @@ -2269,7 +2269,7 @@ cdef class BooleanMonomial(MonoidElement): gens = self._parent.gens() return self._parent, (tuple(gens.index(x) for x in self.variables()),) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare BooleanMonomial objects. @@ -2633,7 +2633,7 @@ cdef class BooleanMonomial(MonoidElement): """ return new_BMI_from_BooleanMonomial(self) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply this boolean monomial with another boolean monomial. @@ -2805,7 +2805,7 @@ cdef class BooleanMonomial(MonoidElement): # ### -cdef inline BooleanMonomial new_BM(parent, BooleanPolynomialRing ring): +cdef inline BooleanMonomial new_BM(parent, BooleanPolynomialRing ring) noexcept: cdef BooleanMonomial m m = BooleanMonomial.__new__(BooleanMonomial) m._parent = parent @@ -2813,13 +2813,13 @@ cdef inline BooleanMonomial new_BM(parent, BooleanPolynomialRing ring): return m cdef inline BooleanMonomial new_BM_from_PBMonom(parent, - BooleanPolynomialRing ring, PBMonom juice): + BooleanPolynomialRing ring, PBMonom juice) noexcept: cdef BooleanMonomial m = new_BM(parent, ring) m._pbmonom = juice return m cdef inline BooleanMonomial new_BM_from_PBVar(parent, - BooleanPolynomialRing ring, PBVar juice): + BooleanPolynomialRing ring, PBVar juice) noexcept: cdef BooleanMonomial m = new_BM(parent, ring) m._pbmonom = PBMonom(juice) return m @@ -2861,7 +2861,7 @@ cdef class BooleanMonomialVariableIterator: return new_BM_from_PBVar(self.parent, self._ring, value) cdef inline BooleanMonomialVariableIterator new_BMVI_from_BooleanMonomial( - BooleanMonomial monom): + BooleanMonomial monom) noexcept: """ Construct a new iterator over the variable indices of a boolean monomial. @@ -2912,7 +2912,7 @@ cdef class BooleanMonomialIterator: return self.pbind[value] -cdef inline BooleanMonomialIterator new_BMI_from_BooleanMonomial(BooleanMonomial monom): +cdef inline BooleanMonomialIterator new_BMI_from_BooleanMonomial(BooleanMonomial monom) noexcept: """ Construct a new BooleanMonomialIterator """ @@ -3016,7 +3016,7 @@ cdef class BooleanPolynomial(MPolynomial): R = self.parent().cover_ring() return R(self)._latex_() - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ EXAMPLES:: @@ -3031,7 +3031,7 @@ cdef class BooleanPolynomial(MPolynomial): p._pbpoly.iadd((right)._pbpoly) return p - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ EXAMPLES:: @@ -3043,7 +3043,7 @@ cdef class BooleanPolynomial(MPolynomial): """ return left._add_(right) - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -3066,7 +3066,7 @@ cdef class BooleanPolynomial(MPolynomial): else: return self._parent.zero() - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ EXAMPLES:: @@ -3081,7 +3081,7 @@ cdef class BooleanPolynomial(MPolynomial): p._pbpoly.imul((right)._pbpoly) return p - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ EXAMPLES:: @@ -3117,7 +3117,7 @@ cdef class BooleanPolynomial(MPolynomial): """ return self._pbpoly == right._pbpoly - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare left and right. @@ -4794,7 +4794,7 @@ cdef class BooleanPolynomialIterator: self.obj._parent, value) -cdef inline BooleanPolynomialIterator new_BPI_from_BooleanPolynomial(BooleanPolynomial f): +cdef inline BooleanPolynomialIterator new_BPI_from_BooleanPolynomial(BooleanPolynomial f) noexcept: """ Construct a new BooleanMonomialIterator """ @@ -5217,35 +5217,35 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): ## -cdef inline BooleanPolynomial new_BP(BooleanPolynomialRing parent): +cdef inline BooleanPolynomial new_BP(BooleanPolynomialRing parent) noexcept: cdef BooleanPolynomial p p = BooleanPolynomial.__new__(BooleanPolynomial) p._parent = parent return p -cdef inline BooleanPolynomial new_BP_from_PBVar(BooleanPolynomialRing parent, PBVar juice): +cdef inline BooleanPolynomial new_BP_from_PBVar(BooleanPolynomialRing parent, PBVar juice) noexcept: cdef BooleanPolynomial p = new_BP(parent) p._pbpoly = PBBoolePolynomial(juice) return p -cdef inline BooleanPolynomial new_BP_from_PBPoly(BooleanPolynomialRing parent, PBPoly juice): +cdef inline BooleanPolynomial new_BP_from_PBPoly(BooleanPolynomialRing parent, PBPoly juice) noexcept: cdef BooleanPolynomial p = new_BP(parent) p._pbpoly = juice return p -cdef inline BooleanPolynomial new_BP_from_PBMonom(BooleanPolynomialRing parent, PBMonom juice): +cdef inline BooleanPolynomial new_BP_from_PBMonom(BooleanPolynomialRing parent, PBMonom juice) noexcept: cdef BooleanPolynomial p = new_BP(parent) p._pbpoly = PBBoolePolynomial(juice) return p -cdef inline BooleanPolynomial new_BP_from_PBSet(BooleanPolynomialRing parent, PBSet juice): +cdef inline BooleanPolynomial new_BP_from_PBSet(BooleanPolynomialRing parent, PBSet juice) noexcept: cdef BooleanPolynomial p = new_BP(parent) p._pbpoly = PBBoolePolynomial(juice) return p -cdef inline BooleanPolynomial new_BP_from_int(BooleanPolynomialRing parent, int juice): +cdef inline BooleanPolynomial new_BP_from_int(BooleanPolynomialRing parent, int juice) noexcept: cdef BooleanPolynomial p = new_BP(parent) p._pbpoly = PBBoolePolynomial(juice, parent._pbring) return p @@ -5869,7 +5869,7 @@ cdef class BooleSet: return self._pbset.sizeDouble() -cdef inline BooleSet new_BS_from_PBSet(PBSet juice, BooleanPolynomialRing ring): +cdef inline BooleSet new_BS_from_PBSet(PBSet juice, BooleanPolynomialRing ring) noexcept: """ Construct a new BooleSet """ @@ -5917,7 +5917,7 @@ cdef class BooleSetIterator: return new_BM_from_PBMonom(self._parent, self._ring, value) -cdef inline BooleSetIterator new_BSI_from_PBSetIter(BooleSet s): +cdef inline BooleSetIterator new_BSI_from_PBSetIter(BooleSet s) noexcept: """ Construct a new BooleSetIterator """ @@ -6136,7 +6136,7 @@ cdef class BooleanPolynomialVector: self._vec.push_back(p) cdef inline BooleanPolynomialVector new_BPV_from_PBPolyVector( - BooleanPolynomialRing parent, PBPolyVector juice): + BooleanPolynomialRing parent, PBPolyVector juice) noexcept: cdef BooleanPolynomialVector m m = BooleanPolynomialVector.__new__(BooleanPolynomialVector) m._vec = juice @@ -6158,7 +6158,7 @@ cdef class BooleanPolynomialVectorIterator: cdef inline BooleanPolynomialVectorIterator new_BPVI_from_PBPolyVectorIter( - BooleanPolynomialVector vec): + BooleanPolynomialVector vec) noexcept: """ Construct a new BooleanPolynomialVectorIterator """ @@ -7000,7 +7000,7 @@ cdef class GroebnerStrategy: cdef class BooleanMulAction(Action): - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: """ EXAMPLES:: @@ -7025,7 +7025,7 @@ cdef class BooleanMulAction(Action): cdef inline CCuddNavigator new_CN_from_PBNavigator(PBNavigator juice, - Py_ssize_t* pbind): + Py_ssize_t* pbind) noexcept: """ Construct a new CCuddNavigator """ @@ -7547,7 +7547,7 @@ def top_index(s): return (s.ring()).pbind[idx] -cdef long PBRing_identifier(PBRing pbring): +cdef long PBRing_identifier(PBRing pbring) noexcept: cdef long _hash = pbring.hash() ^ hash(pbring.ordering().getOrderCode()) @@ -7560,7 +7560,7 @@ cdef long PBRing_identifier(PBRing pbring): return _hash -cdef object TermOrder_from_PBRing(PBRing _ring): +cdef object TermOrder_from_PBRing(PBRing _ring) noexcept: cdef int n = _ring.nVariables() pb_base_order_code = _ring.ordering().getBaseOrderCode() order_str = inv_order_dict[pb_base_order_code] @@ -7582,7 +7582,7 @@ cdef object TermOrder_from_PBRing(PBRing _ring): return T -cdef BooleanPolynomialRing BooleanPolynomialRing_from_PBRing(PBRing _ring): +cdef BooleanPolynomialRing BooleanPolynomialRing_from_PBRing(PBRing _ring) noexcept: """ Get BooleanPolynomialRing from C++-implementation """ @@ -7899,7 +7899,7 @@ cdef class BooleConstant: return self._pbconst.hasConstantPart() -cdef object pb_block_order(n, order_str, blocks): +cdef object pb_block_order(n, order_str, blocks) noexcept: T = [TermOrder(order_str, blockend - blockstart, force=True) for (blockstart, blockend) in zip([0] + blocks, blocks + [n])] if T: @@ -7910,7 +7910,7 @@ cdef object pb_block_order(n, order_str, blocks): return order_str -cpdef object TermOrder_from_pb_order(int n, order, blocks): +cpdef object TermOrder_from_pb_order(int n, order, blocks) noexcept: if not isinstance(order, str): if order == pbblock_dlex: order_str = pb_block_order(n, "deglex", blocks) diff --git a/src/sage/rings/polynomial/plural.pxd b/src/sage/rings/polynomial/plural.pxd index d3a46f6aa0d..06b48c737f3 100644 --- a/src/sage/rings/polynomial/plural.pxd +++ b/src/sage/rings/polynomial/plural.pxd @@ -32,14 +32,14 @@ cdef class ExteriorAlgebra_plural(NCPolynomialRing_plural): cdef class NCPolynomial_plural(RingElement): cdef poly *_poly - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _repr_short_(self) - cdef long _hash_c(self) - cpdef is_constant(self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _repr_short_(self) noexcept + cdef long _hash_c(self) noexcept + cpdef is_constant(self) noexcept # cpdef _homogenize(self, int var) -cdef NCPolynomial_plural new_NCP(NCPolynomialRing_plural parent, poly *juice) +cdef NCPolynomial_plural new_NCP(NCPolynomialRing_plural parent, poly *juice) noexcept -cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring) -cpdef NCPolynomialRing_plural new_NRing(RingWrap rw, base_ring) +cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring) noexcept +cpdef NCPolynomialRing_plural new_NRing(RingWrap rw, base_ring) noexcept diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx index 16c8c09fbc3..90e3663da5c 100644 --- a/src/sage/rings/polynomial/plural.pyx +++ b/src/sage/rings/polynomial/plural.pyx @@ -573,7 +573,7 @@ cdef class NCPolynomialRing_plural(Ring): " as noncommutative polynomial") # ??? return new_NCP(self, _p) - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ The only things that coerce into this ring are: @@ -1474,7 +1474,7 @@ cdef class NCPolynomial_plural(RingElement): """ return self._hash_c() - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare left and right. @@ -1525,7 +1525,7 @@ cdef class NCPolynomial_plural(RingElement): cdef ring *r = (left._parent)._ring return rich_to_bool(op, singular_polynomial_cmp(p, q, r)) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Adds left and right. @@ -1544,7 +1544,7 @@ cdef class NCPolynomial_plural(RingElement): (left._parent)._ring) return new_NCP((left._parent), _p) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ Subtract left and right. @@ -1566,7 +1566,7 @@ cdef class NCPolynomial_plural(RingElement): _ring) return new_NCP((left._parent), _p) - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ Multiply ``self`` with a base ring element. @@ -1596,7 +1596,7 @@ cdef class NCPolynomial_plural(RingElement): singular_polynomial_rmul(&_p, self._poly, left, _ring) return new_NCP((self._parent),_p) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply left and right. @@ -1627,7 +1627,7 @@ cdef class NCPolynomial_plural(RingElement): (left._parent)._ring) return new_NCP((left._parent),_p) - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ Divide left by right @@ -1808,7 +1808,7 @@ cdef class NCPolynomial_plural(RingElement): s = singular_polynomial_str(self._poly, _ring) return s - cpdef _repr_short_(self): + cpdef _repr_short_(self) noexcept: """ This is a faster but less pretty way to print polynomials. If available it uses the short SINGULAR notation. @@ -2274,7 +2274,7 @@ cdef class NCPolynomial_plural(RingElement): return sum(prod(im_gens[i]**val for i, val in enumerate(t))*base_map(d[t]) for t in d) - cdef long _hash_c(self): + cdef long _hash_c(self) noexcept: """ See :meth:`__hash__` """ @@ -2586,7 +2586,7 @@ cdef class NCPolynomial_plural(RingElement): else: return (self._parent)._base._zero_element - cpdef is_constant(self): + cpdef is_constant(self) noexcept: """ Return ``True`` if this polynomial is constant. @@ -2811,7 +2811,7 @@ cdef class NCPolynomial_plural(RingElement): cdef inline NCPolynomial_plural new_NCP(NCPolynomialRing_plural parent, - poly *juice): + poly *juice) noexcept: """ Construct NCPolynomial_plural from parent and SINGULAR poly. @@ -2832,7 +2832,7 @@ cdef inline NCPolynomial_plural new_NCP(NCPolynomialRing_plural parent, -cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring): +cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring) noexcept: """ Construct MPolynomialRing_libsingular from ringWrap, assuming the ground field to be base_ring @@ -2904,7 +2904,7 @@ cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring): return self -cpdef NCPolynomialRing_plural new_NRing(RingWrap rw, base_ring): +cpdef NCPolynomialRing_plural new_NRing(RingWrap rw, base_ring) noexcept: """ Construct NCPolynomialRing_plural from ringWrap, assuming the ground field to be base_ring @@ -3127,7 +3127,7 @@ def ExteriorAlgebra(base_ring, names,order='degrevlex'): I = H.ideal([H.gen(i) * H.gen(i) for i in range(n)]).twostd() return H.quotient(I) -cdef poly *addwithcarry(poly *tempvector, poly *maxvector, int pos, ring *_ring): +cdef poly *addwithcarry(poly *tempvector, poly *maxvector, int pos, ring *_ring) noexcept: if p_GetExp(tempvector, pos, _ring) < p_GetExp(maxvector, pos, _ring): p_SetExp(tempvector, pos, p_GetExp(tempvector, pos, _ring)+1, _ring) else: diff --git a/src/sage/rings/polynomial/polydict.pxd b/src/sage/rings/polynomial/polydict.pxd index 6bc1901bd7e..432ae7d8c47 100644 --- a/src/sage/rings/polynomial/polydict.pxd +++ b/src/sage/rings/polynomial/polydict.pxd @@ -1,8 +1,8 @@ cdef class PolyDict: cdef dict __repn - cdef PolyDict _new(self, dict pdict) - cpdef remove_zeros(self, zero_test=*) + cdef PolyDict _new(self, dict pdict) noexcept + cpdef remove_zeros(self, zero_test=*) noexcept cdef class ETuple: @@ -10,33 +10,33 @@ cdef class ETuple: cdef size_t _nonzero cdef int *_data - cdef size_t get_position(self, size_t i, size_t start, size_t end) - cdef ETuple _new(self) - cdef int get_exp(self, size_t i) + cdef size_t get_position(self, size_t i, size_t start, size_t end) noexcept + cdef ETuple _new(self) noexcept + cdef int get_exp(self, size_t i) noexcept cpdef int unweighted_degree(self) except * cpdef int weighted_degree(self, tuple w) except * cpdef int unweighted_quotient_degree(self, ETuple other) except * cpdef int weighted_quotient_degree(self, ETuple other, tuple w) except * - cpdef ETuple eadd(self, ETuple other) - cpdef ETuple esub(self, ETuple other) - cpdef ETuple emul(self, int factor) - cpdef ETuple emin(self, ETuple other) - cpdef ETuple emax(self, ETuple other) - cpdef ETuple eadd_p(self, int other, size_t pos) - cpdef ETuple eadd_scaled(self, ETuple other, int scalar) + cpdef ETuple eadd(self, ETuple other) noexcept + cpdef ETuple esub(self, ETuple other) noexcept + cpdef ETuple emul(self, int factor) noexcept + cpdef ETuple emin(self, ETuple other) noexcept + cpdef ETuple emax(self, ETuple other) noexcept + cpdef ETuple eadd_p(self, int other, size_t pos) noexcept + cpdef ETuple eadd_scaled(self, ETuple other, int scalar) noexcept cpdef int dotprod(self, ETuple other) except * - cpdef ETuple escalar_div(self, int n) - cpdef ETuple divide_by_gcd(self, ETuple other) - cpdef ETuple divide_by_var(self, size_t pos) + cpdef ETuple escalar_div(self, int n) noexcept + cpdef ETuple divide_by_gcd(self, ETuple other) noexcept + cpdef ETuple divide_by_var(self, size_t pos) noexcept cpdef bint divides(self, ETuple other) except * - cpdef bint is_constant(self) + cpdef bint is_constant(self) noexcept cpdef bint is_multiple_of(self, int n) except * - cpdef list nonzero_positions(self, bint sort=*) - cpdef common_nonzero_positions(self, ETuple other, bint sort=*) - cpdef list nonzero_values(self, bint sort=*) - cpdef ETuple reversed(self) + cpdef list nonzero_positions(self, bint sort=*) noexcept + cpdef common_nonzero_positions(self, ETuple other, bint sort=*) noexcept + cpdef list nonzero_values(self, bint sort=*) noexcept + cpdef ETuple reversed(self) noexcept -cpdef int gen_index(PolyDict x) -cpdef ETuple monomial_exponent(PolyDict p) +cpdef int gen_index(PolyDict x) noexcept +cpdef ETuple monomial_exponent(PolyDict p) noexcept diff --git a/src/sage/rings/polynomial/polydict.pyx b/src/sage/rings/polynomial/polydict.pyx index 0c847d125a4..aaefb2d99d2 100644 --- a/src/sage/rings/polynomial/polydict.pyx +++ b/src/sage/rings/polynomial/polydict.pyx @@ -44,7 +44,7 @@ from pprint import pformat from sage.misc.latex import latex -cpdef int gen_index(PolyDict x): +cpdef int gen_index(PolyDict x) noexcept: r""" Return the index of the variable represented by ``x`` or ``-1`` if ``x`` is not a monomial of degree one. @@ -69,7 +69,7 @@ cpdef int gen_index(PolyDict x): return e._data[0] -cpdef ETuple monomial_exponent(PolyDict p): +cpdef ETuple monomial_exponent(PolyDict p) noexcept: r""" Return the unique exponent of ``p`` if it is a monomial or raise a ``ValueError``. @@ -189,12 +189,12 @@ cdef class PolyDict: if remove_zero: self.remove_zeros() - cdef PolyDict _new(self, dict pdict): + cdef PolyDict _new(self, dict pdict) noexcept: cdef PolyDict ans = PolyDict.__new__(PolyDict) ans.__repn = pdict return ans - cpdef remove_zeros(self, zero_test=None): + cpdef remove_zeros(self, zero_test=None) noexcept: r""" Remove the entries with zero coefficients. @@ -1366,7 +1366,7 @@ cdef class PolyDict: else: return None -cdef inline bint dual_etuple_iter(ETuple self, ETuple other, size_t *ind1, size_t *ind2, size_t *index, int *exp1, int *exp2): +cdef inline bint dual_etuple_iter(ETuple self, ETuple other, size_t *ind1, size_t *ind2, size_t *index, int *exp1, int *exp2) noexcept: """ This function is a crucial helper function for a number of methods of the ETuple class. @@ -1428,7 +1428,7 @@ cdef class ETuple: question (although, there is no question that this is much faster than the prior use of python dicts). """ - cdef ETuple _new(self): + cdef ETuple _new(self) noexcept: """ Quickly creates a new initialized ETuple with the same length as self. @@ -1615,7 +1615,7 @@ cdef class ETuple: else: return self.get_exp(i) - cdef size_t get_position(self, size_t i, size_t start, size_t end): + cdef size_t get_position(self, size_t i, size_t start, size_t end) noexcept: r""" Return where to insert ``i`` in the data between ``start`` and ``end``. """ @@ -1640,7 +1640,7 @@ cdef class ETuple: left = mid return right - cdef int get_exp(self, size_t i): + cdef int get_exp(self, size_t i) noexcept: """ Return the exponent for the ``i``-th variable. """ @@ -1973,7 +1973,7 @@ cdef class ETuple: ind1 += 2 return deg - cpdef ETuple eadd(self, ETuple other): + cpdef ETuple eadd(self, ETuple other) noexcept: """ Return the vector addition of ``self`` with ``other``. @@ -2023,7 +2023,7 @@ cdef class ETuple: result._nonzero += 1 return result - cpdef ETuple eadd_p(self, int other, size_t pos): + cpdef ETuple eadd_p(self, int other, size_t pos) noexcept: """ Add ``other`` to ``self`` at position ``pos``. @@ -2111,7 +2111,7 @@ cdef class ETuple: return result - cpdef ETuple eadd_scaled(self, ETuple other, int scalar): + cpdef ETuple eadd_scaled(self, ETuple other, int scalar) noexcept: """ Vector addition of ``self`` with ``scalar * other``. @@ -2150,7 +2150,7 @@ cdef class ETuple: result._nonzero += 1 return result - cpdef ETuple esub(self, ETuple other): + cpdef ETuple esub(self, ETuple other) noexcept: """ Vector subtraction of ``self`` with ``other``. @@ -2188,7 +2188,7 @@ cdef class ETuple: result._nonzero += 1 return result - cpdef ETuple emul(self, int factor): + cpdef ETuple emul(self, int factor) noexcept: """ Scalar Vector multiplication of ``self``. @@ -2212,7 +2212,7 @@ cdef class ETuple: result._data[2 * ind + 1] = self._data[2 * ind + 1] * factor return result - cpdef ETuple emax(self, ETuple other): + cpdef ETuple emax(self, ETuple other) noexcept: """ Vector of maximum of components of ``self`` and ``other``. @@ -2259,7 +2259,7 @@ cdef class ETuple: result._nonzero += 1 return result - cpdef ETuple emin(self, ETuple other): + cpdef ETuple emin(self, ETuple other) noexcept: """ Vector of minimum of components of ``self`` and ``other``. @@ -2329,7 +2329,7 @@ cdef class ETuple: result += exp1 * exp2 return result - cpdef ETuple escalar_div(self, int n): + cpdef ETuple escalar_div(self, int n) noexcept: r""" Divide each exponent by ``n``. @@ -2370,7 +2370,7 @@ cdef class ETuple: result._nonzero += 1 return result - cpdef ETuple divide_by_gcd(self, ETuple other): + cpdef ETuple divide_by_gcd(self, ETuple other) noexcept: """ Return ``self / gcd(self, other)``. @@ -2413,7 +2413,7 @@ cdef class ETuple: ind1 += 2 return result - cpdef ETuple divide_by_var(self, size_t pos): + cpdef ETuple divide_by_var(self, size_t pos) noexcept: """ Return division of ``self`` by the variable with index ``pos``. @@ -2501,7 +2501,7 @@ cdef class ETuple: return True - cpdef bint is_constant(self): + cpdef bint is_constant(self) noexcept: """ Return if all exponents are zero in the tuple. @@ -2540,7 +2540,7 @@ cdef class ETuple: return False return True - cpdef list nonzero_positions(self, bint sort=False): + cpdef list nonzero_positions(self, bint sort=False) noexcept: """ Return the positions of non-zero exponents in the tuple. @@ -2559,7 +2559,7 @@ cdef class ETuple: cdef size_t ind return [self._data[2 * ind] for ind in range(self._nonzero)] - cpdef common_nonzero_positions(self, ETuple other, bint sort=False): + cpdef common_nonzero_positions(self, ETuple other, bint sort=False) noexcept: """ Returns an optionally sorted list of non zero positions either in self or other, i.e. the only positions that need to be @@ -2582,7 +2582,7 @@ cdef class ETuple: else: return res - cpdef list nonzero_values(self, bint sort=True): + cpdef list nonzero_values(self, bint sort=True) noexcept: """ Return the non-zero values of the tuple. @@ -2604,7 +2604,7 @@ cdef class ETuple: cdef size_t ind return [self._data[2 * ind + 1] for ind in range(self._nonzero)] - cpdef ETuple reversed(self): + cpdef ETuple reversed(self) noexcept: """ Return the reversed ETuple of ``self``. diff --git a/src/sage/rings/polynomial/polynomial_compiled.pxd b/src/sage/rings/polynomial/polynomial_compiled.pxd index 9a9818e767c..3e5c9f4611f 100644 --- a/src/sage/rings/polynomial/polynomial_compiled.pxd +++ b/src/sage/rings/polynomial/polynomial_compiled.pxd @@ -8,22 +8,22 @@ cdef class CompiledPolynomialFunction: cdef generic_pd _dag cdef object _coeffs - cdef object _parse_structure(CompiledPolynomialFunction) - cdef generic_pd _get_gap(CompiledPolynomialFunction, BinaryTree, int) - cdef void _fill_gaps_binary(CompiledPolynomialFunction, BinaryTree) - cdef object eval(CompiledPolynomialFunction, object) + cdef object _parse_structure(CompiledPolynomialFunction) noexcept + cdef generic_pd _get_gap(CompiledPolynomialFunction, BinaryTree, int) noexcept + cdef void _fill_gaps_binary(CompiledPolynomialFunction, BinaryTree) noexcept + cdef object eval(CompiledPolynomialFunction, object) noexcept cdef class generic_pd: cdef object value cdef int refs, hits cdef int label cdef int eval(self, vars, coeffs) except -2 - cdef generic_pd nodummies(generic_pd) - cdef void reset(self) + cdef generic_pd nodummies(generic_pd) noexcept + cdef void reset(self) noexcept cdef class dummy_pd(generic_pd): cdef generic_pd link - cdef void fill(dummy_pd self, generic_pd link) + cdef void fill(dummy_pd self, generic_pd link) noexcept cdef class var_pd(generic_pd): cdef int index diff --git a/src/sage/rings/polynomial/polynomial_compiled.pyx b/src/sage/rings/polynomial/polynomial_compiled.pyx index f7568893309..1145dfae7ea 100644 --- a/src/sage/rings/polynomial/polynomial_compiled.pyx +++ b/src/sage/rings/polynomial/polynomial_compiled.pyx @@ -119,7 +119,7 @@ cdef class CompiledPolynomialFunction: def __call__(self, x): return self.eval(x) - cdef object eval(CompiledPolynomialFunction self, object x): + cdef object eval(CompiledPolynomialFunction self, object x) noexcept: cdef object temp try: pd_eval(self._dag, x, self._coeffs) #see further down @@ -130,7 +130,7 @@ cdef class CompiledPolynomialFunction: self._dag.reset() raise TypeError(msg) - cdef object _parse_structure(CompiledPolynomialFunction self): + cdef object _parse_structure(CompiledPolynomialFunction self) noexcept: """ Loop through the coefficients of the polynomial, and collect coefficient gap widths. Meanwhile, construct the evaluation @@ -169,7 +169,7 @@ cdef class CompiledPolynomialFunction: return gaps, s - cdef generic_pd _get_gap(CompiledPolynomialFunction self, BinaryTree gaps, int gap): + cdef generic_pd _get_gap(CompiledPolynomialFunction self, BinaryTree gaps, int gap) noexcept: """ Find an entry in the BinaryTree gaps, identified by the int gap. If such an entry does not exist, create it and put it in the tree. @@ -184,7 +184,7 @@ cdef class CompiledPolynomialFunction: gaps.insert(gap,g) return g - cdef void _fill_gaps_binary(CompiledPolynomialFunction self, BinaryTree gaps): + cdef void _fill_gaps_binary(CompiledPolynomialFunction self, BinaryTree gaps) noexcept: """ The desired gaps come in a tree, filled with dummy nodes (with the exception of the var node, which is not a dummy). The nodes are @@ -352,7 +352,7 @@ cdef inline int pd_eval(generic_pd pd, object vars, object coeffs) except -2: pd.eval(vars, coeffs) pd.hits += 1 -cdef inline void pd_clean(generic_pd pd): +cdef inline void pd_clean(generic_pd pd) noexcept: if pd.hits >= pd.refs: pd.value = None pd.hits = 0 @@ -367,10 +367,10 @@ cdef class generic_pd: cdef int eval(generic_pd self, object vars, object coeffs) except -2: raise NotImplementedError - cdef generic_pd nodummies(generic_pd self): + cdef generic_pd nodummies(generic_pd self) noexcept: return self - cdef void reset(generic_pd self): + cdef void reset(generic_pd self) noexcept: self.hits = 0 self.value = None @@ -378,10 +378,10 @@ cdef class dummy_pd(generic_pd): def __init__(dummy_pd self, int label): self.label = label - cdef void fill(dummy_pd self, generic_pd link): + cdef void fill(dummy_pd self, generic_pd link) noexcept: self.link = link - cdef generic_pd nodummies(dummy_pd self): + cdef generic_pd nodummies(dummy_pd self) noexcept: #sorry guys, this is my stop self.link.refs = self.refs return self.link.nodummies() @@ -417,7 +417,7 @@ cdef class coeff_pd(generic_pd): def __repr__(self): return "a%s" % (self.index) - cdef void reset(self): + cdef void reset(self) noexcept: pass cdef class unary_pd(generic_pd): @@ -426,11 +426,11 @@ cdef class unary_pd(generic_pd): self.operand = operand self.operand.refs += 1 - cdef generic_pd nodummies(self): + cdef generic_pd nodummies(self) noexcept: self.operand = self.operand.nodummies() return self - cdef void reset(self): + cdef void reset(self) noexcept: generic_pd.reset(self) self.operand.reset() @@ -467,12 +467,12 @@ cdef class binary_pd(generic_pd): self.left.refs+= 1 self.right.refs+= 1 - cdef generic_pd nodummies(self): + cdef generic_pd nodummies(self) noexcept: self.left = self.left.nodummies() self.right = self.right.nodummies() return self - cdef void reset(self): + cdef void reset(self) noexcept: generic_pd.reset(self) self.left.reset() self.right.reset() diff --git a/src/sage/rings/polynomial/polynomial_complex_arb.pxd b/src/sage/rings/polynomial/polynomial_complex_arb.pxd index e54d85e961b..29e3cc4fd61 100644 --- a/src/sage/rings/polynomial/polynomial_complex_arb.pxd +++ b/src/sage/rings/polynomial/polynomial_complex_arb.pxd @@ -3,4 +3,4 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial cdef class Polynomial_complex_arb(Polynomial): cdef acb_poly_struct[1] _poly # https://github.com/cython/cython/issues/1984 - cdef Polynomial_complex_arb _new(self) + cdef Polynomial_complex_arb _new(self) noexcept diff --git a/src/sage/rings/polynomial/polynomial_complex_arb.pyx b/src/sage/rings/polynomial/polynomial_complex_arb.pyx index 985f1dec394..3e3482330a6 100644 --- a/src/sage/rings/polynomial/polynomial_complex_arb.pyx +++ b/src/sage/rings/polynomial/polynomial_complex_arb.pyx @@ -33,7 +33,7 @@ from sage.structure.element cimport Element from sage.structure.element import coerce_binop -cdef inline long prec(Polynomial_complex_arb pol): +cdef inline long prec(Polynomial_complex_arb pol) noexcept: return pol._parent._base._prec @@ -87,7 +87,7 @@ cdef class Polynomial_complex_arb(Polynomial): """ acb_poly_clear(self._poly) - cdef Polynomial_complex_arb _new(self): + cdef Polynomial_complex_arb _new(self) noexcept: r""" Return a new polynomial with the same parent as this one. """ @@ -230,13 +230,13 @@ cdef class Polynomial_complex_arb(Polynomial): """ return smallInteger(acb_poly_degree(self._poly)) - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: cdef ComplexBall res = ComplexBall.__new__(ComplexBall) res._parent = self._parent._base acb_poly_get_coeff_acb(res.value, self._poly, n) return res - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: r""" Return the coefficient list of this polynomial. @@ -270,7 +270,7 @@ cdef class Polynomial_complex_arb(Polynomial): # Ring and Euclidean arithmetic - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: r""" Return the sum of two polynomials. @@ -290,7 +290,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the opposite of this polynomial. @@ -306,7 +306,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: r""" Return the difference of two polynomials. @@ -326,7 +326,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return the product of two polynomials. @@ -347,7 +347,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef _lmul_(self, Element a): + cpdef _lmul_(self, Element a) noexcept: r""" TESTS:: @@ -367,7 +367,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef _rmul_(self, Element a): + cpdef _rmul_(self, Element a) noexcept: r""" TESTS:: @@ -428,7 +428,7 @@ cdef class Polynomial_complex_arb(Polynomial): # Syntactic transformations - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: r""" Return the truncation to degree `n - 1` of this polynomial. @@ -459,7 +459,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cdef _inplace_truncate(self, long n): + cdef _inplace_truncate(self, long n) noexcept: if n < 0: n = 0 acb_poly_truncate(self._poly, n) @@ -533,7 +533,7 @@ cdef class Polynomial_complex_arb(Polynomial): # Truncated and power series arithmetic - cpdef Polynomial _mul_trunc_(self, Polynomial other, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial other, long n) noexcept: r""" Return the product of ``self`` and ``other``, truncated before degree `n`. @@ -561,7 +561,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef Polynomial inverse_series_trunc(self, long n): + cpdef Polynomial inverse_series_trunc(self, long n) noexcept: r""" Return the power series expansion at 0 of the inverse of this polynomial, truncated before degree `n`. @@ -589,7 +589,7 @@ cdef class Polynomial_complex_arb(Polynomial): sig_off() return res - cpdef Polynomial _power_trunc(self, unsigned long expo, long n): + cpdef Polynomial _power_trunc(self, unsigned long expo, long n) noexcept: r""" Return a power of this polynomial, truncated before degree `n`. diff --git a/src/sage/rings/polynomial/polynomial_element.pxd b/src/sage/rings/polynomial/polynomial_element.pxd index 5dcbf4597d0..b337919a807 100644 --- a/src/sage/rings/polynomial/polynomial_element.pxd +++ b/src/sage/rings/polynomial/polynomial_element.pxd @@ -7,58 +7,58 @@ from .polynomial_compiled cimport CompiledPolynomialFunction cdef class Polynomial(CommutativePolynomial): - cdef Polynomial _new_generic(self, list coeffs) + cdef Polynomial _new_generic(self, list coeffs) noexcept cdef char _is_gen cdef CompiledPolynomialFunction _compiled - cpdef Polynomial truncate(self, long n) - cpdef Polynomial inverse_series_trunc(self, long prec) + cpdef Polynomial truncate(self, long n) noexcept + cpdef Polynomial inverse_series_trunc(self, long prec) noexcept cdef long _hash_c(self) except -1 - cpdef constant_coefficient(self) - cpdef Polynomial _new_constant_poly(self, a, Parent P) - cpdef list list(self, bint copy=*) - cpdef _mul_generic(self, right) - cdef _square_generic(self) + cpdef constant_coefficient(self) noexcept + cpdef Polynomial _new_constant_poly(self, a, Parent P) noexcept + cpdef list list(self, bint copy=*) noexcept + cpdef _mul_generic(self, right) noexcept + cdef _square_generic(self) noexcept cpdef bint is_zero(self) except -1 cpdef bint is_one(self) except -1 cpdef bint is_term(self) except -1 - cpdef dict _mpoly_dict_recursive(self, tuple variables=*, base_ring=*) + cpdef dict _mpoly_dict_recursive(self, tuple variables=*, base_ring=*) noexcept - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _floordiv_(self, right) - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) - cpdef Polynomial _power_trunc(self, unsigned long n, long prec) - cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _floordiv_(self, right) noexcept + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept + cpdef Polynomial _power_trunc(self, unsigned long n, long prec) noexcept + cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right) noexcept # UNSAFE, only call from an inplace operator # may return a new element if not possible to modify inplace - cdef _inplace_truncate(self, long n) + cdef _inplace_truncate(self, long n) noexcept - cdef get_coeff_c(self, Py_ssize_t i) - cdef get_unsafe(self, Py_ssize_t i) - cpdef long number_of_terms(self) + cdef get_coeff_c(self, Py_ssize_t i) noexcept + cdef get_unsafe(self, Py_ssize_t i) noexcept + cpdef long number_of_terms(self) noexcept # See 23227 - cpdef _add_(self, right) - cpdef _mul_(self, right) - cpdef _floordiv_(self, right) + cpdef _add_(self, right) noexcept + cpdef _mul_(self, right) noexcept + cpdef _floordiv_(self, right) noexcept cdef public dict _cached_methods cdef class Polynomial_generic_dense(Polynomial): - cdef Polynomial_generic_dense _new_c(self, list coeffs, Parent P) + cdef Polynomial_generic_dense _new_c(self, list coeffs, Parent P) noexcept cdef list _coeffs cdef int _normalize(self) except -1 - cpdef list list(self, bint copy=*) + cpdef list list(self, bint copy=*) noexcept cdef class Polynomial_generic_dense_inexact(Polynomial_generic_dense): pass -cpdef is_Polynomial(f) -cpdef Polynomial generic_power_trunc(Polynomial p, Integer n, long prec) -cpdef list _dict_to_list(dict x, zero) +cpdef is_Polynomial(f) noexcept +cpdef Polynomial generic_power_trunc(Polynomial p, Integer n, long prec) noexcept +cpdef list _dict_to_list(dict x, zero) noexcept -cpdef bint polynomial_is_variable(x) +cpdef bint polynomial_is_variable(x) noexcept diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index a5b7f937cfe..97863db175c 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -134,7 +134,7 @@ from sage.misc.superseded import deprecation_cython as deprecation, deprecated_f from sage.misc.cachefunc import cached_method -cpdef is_Polynomial(f): +cpdef is_Polynomial(f) noexcept: """ Return ``True`` if ``f`` is of type univariate polynomial. @@ -244,7 +244,7 @@ cdef class Polynomial(CommutativePolynomial): CommutativeAlgebraElement.__init__(self, parent) self._is_gen = is_gen - cdef Polynomial _new_generic(self, list coeffs): + cdef Polynomial _new_generic(self, list coeffs) noexcept: r""" Quickly construct a new polynomial of the same type as ``self``, bypassing the parent's element constructor. @@ -258,7 +258,7 @@ cdef class Polynomial(CommutativePolynomial): n -= 1 return type(self)(self._parent, coeffs, check=False) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Add two polynomials. @@ -287,7 +287,7 @@ cdef class Polynomial(CommutativePolynomial): low = [x[i] + y[i] for i in range(min)] return self._new_generic(low + high) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: return self._new_generic([-x for x in self.list(copy=False)]) cpdef bint is_zero(self) except -1: @@ -370,7 +370,7 @@ cdef class Polynomial(CommutativePolynomial): return point(z, *args, **kwds) raise NotImplementedError("plotting of polynomials over %s not implemented"%R) - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ Multiply self on the left by a scalar. @@ -390,7 +390,7 @@ cdef class Polynomial(CommutativePolynomial): return self._parent.zero() return self._parent(left) * self - cpdef _rmul_(self, Element right): + cpdef _rmul_(self, Element right) noexcept: """ Multiply self on the right by a scalar. @@ -1010,7 +1010,7 @@ cdef class Polynomial(CommutativePolynomial): expr *= x return expr - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare the two polynomials self and other. @@ -1176,7 +1176,7 @@ cdef class Polynomial(CommutativePolynomial): return self.get_coeff_c(pyobject_to_long(n)) - cdef get_coeff_c(self, Py_ssize_t i): + cdef get_coeff_c(self, Py_ssize_t i) noexcept: """ Return the `i`-th coefficient of ``self``. """ @@ -1186,7 +1186,7 @@ cdef class Polynomial(CommutativePolynomial): else: return self._parent._base.zero() - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ Return the `i`-th coefficient of ``self``. @@ -1668,7 +1668,7 @@ cdef class Polynomial(CommutativePolynomial): else: raise ValueError("Impossible inverse modulo") - cpdef Polynomial inverse_series_trunc(self, long prec): + cpdef Polynomial inverse_series_trunc(self, long prec) noexcept: r""" Return a polynomial approximation of precision ``prec`` of the inverse series of this polynomial. @@ -1783,7 +1783,7 @@ cdef class Polynomial(CommutativePolynomial): """ raise NotImplementedError("only implemented for certain base rings") - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -1839,7 +1839,7 @@ cdef class Polynomial(CommutativePolynomial): else: return self._mul_generic(right) - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: r""" Return the truncated multiplication of two polynomials up to ``n``. @@ -2630,7 +2630,7 @@ cdef class Polynomial(CommutativePolynomial): return self._power_trunc(mpz_get_ui(ZZn.value), prec) return generic_power_trunc(self, ZZn, pyobject_to_long(prec)) - cpdef Polynomial _power_trunc(self, unsigned long n, long prec): + cpdef Polynomial _power_trunc(self, unsigned long n, long prec) noexcept: r""" Truncated ``n``-th power of this polynomial up to precision ``prec`` @@ -2918,7 +2918,7 @@ cdef class Polynomial(CommutativePolynomial): """ raise IndexError("polynomials are immutable") - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: r""" Quotient of division of ``self`` by ``other``. This is denoted //. @@ -3002,7 +3002,7 @@ cdef class Polynomial(CommutativePolynomial): return (self.degree() == self.valuation() and self.leading_coefficient()._is_atomic()) - cpdef _mul_generic(self, right): + cpdef _mul_generic(self, right) noexcept: """ Compute the product of ``self`` and ``right`` using the classical quadratic algorithm. This method is the default for inexact rings. @@ -3066,7 +3066,7 @@ cdef class Polynomial(CommutativePolynomial): cdef list y = right.list(copy=False) return self._new_generic(do_schoolbook_product(x, y, -1)) - cdef _square_generic(self): + cdef _square_generic(self) noexcept: cdef list x = self.list(copy=False) cdef Py_ssize_t i, j cdef Py_ssize_t d = len(x)-1 @@ -3333,7 +3333,7 @@ cdef class Polynomial(CommutativePolynomial): @cython.boundscheck(False) @cython.wraparound(False) - cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right): + cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right) noexcept: """ Return the product ``self * term``, where ``term`` is a polynomial with a single term. @@ -3367,7 +3367,7 @@ cdef class Polynomial(CommutativePolynomial): """ return self._parent.base_ring() - cpdef base_extend(self, R): + cpdef base_extend(self, R) noexcept: """ Return a copy of this polynomial but with coefficients in ``R``, if there is a natural map from the coefficient ring of ``self`` to ``R``. @@ -3460,7 +3460,7 @@ cdef class Polynomial(CommutativePolynomial): else: return self._parent.change_ring(R)(self.list(copy=False)) - cpdef dict _mpoly_dict_recursive(self, tuple variables=None, base_ring=None): + cpdef dict _mpoly_dict_recursive(self, tuple variables=None, base_ring=None) noexcept: """ Return a dict of coefficient entries suitable for construction of a MPolynomial_polydict with the given variables. @@ -5627,7 +5627,7 @@ cdef class Polynomial(CommutativePolynomial): return M - cpdef constant_coefficient(self): + cpdef constant_coefficient(self) noexcept: """ Return the constant coefficient of this polynomial. @@ -5645,7 +5645,7 @@ cdef class Polynomial(CommutativePolynomial): # self.degree() >= 0 return self.get_unsafe(0) - cpdef Polynomial _new_constant_poly(self, a, Parent P): + cpdef Polynomial _new_constant_poly(self, a, Parent P) noexcept: """ Create a new constant polynomial from a in P, which MUST be an element of the base ring of P (this is not checked). @@ -6154,7 +6154,7 @@ cdef class Polynomial(CommutativePolynomial): cdef Py_ssize_t i return [i for i, c in enumerate(self.list(copy=False)) if c] - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a new copy of the list of the underlying elements of ``self``. @@ -9797,7 +9797,7 @@ cdef class Polynomial(CommutativePolynomial): """ return self.shift(-k) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: r""" Return the polynomial of degree `< n` which is equivalent to self modulo `x^n`. @@ -9818,7 +9818,7 @@ cdef class Polynomial(CommutativePolynomial): # We must not have check=False, since 0 must not have _coeffs = [0]. return self._parent(self[:n])#, check=False) - cdef _inplace_truncate(self, long prec): + cdef _inplace_truncate(self, long prec) noexcept: return self.truncate(prec) @cached_method @@ -10126,7 +10126,7 @@ cdef class Polynomial(CommutativePolynomial): return RR(sum([abs(i)**p for i in coeffs]))**(1/p) - cpdef long number_of_terms(self): + cpdef long number_of_terms(self) noexcept: """ Return the number of non-zero coefficients of ``self``. @@ -11300,7 +11300,7 @@ cdef class Polynomial(CommutativePolynomial): @cython.boundscheck(False) @cython.wraparound(False) @cython.overflowcheck(False) -cdef list do_schoolbook_product(list x, list y, Py_ssize_t deg): +cdef list do_schoolbook_product(list x, list y, Py_ssize_t deg) noexcept: """ Compute the truncated multiplication of two polynomials represented by lists, using the schoolbook algorithm. @@ -11352,7 +11352,7 @@ cdef list do_schoolbook_product(list x, list y, Py_ssize_t deg): @cython.boundscheck(False) @cython.wraparound(False) @cython.overflowcheck(False) -cdef list do_karatsuba_different_size(list left, list right, Py_ssize_t K_threshold): +cdef list do_karatsuba_different_size(list left, list right, Py_ssize_t K_threshold) noexcept: """ Multiply two polynomials of different degrees by splitting the one of largest degree in chunks that are multiplied with the other using the @@ -11434,7 +11434,7 @@ cdef list do_karatsuba_different_size(list left, list right, Py_ssize_t K_thresh @cython.boundscheck(False) @cython.wraparound(False) @cython.overflowcheck(False) -cdef list do_karatsuba(list left, list right, Py_ssize_t K_threshold,Py_ssize_t start_l, Py_ssize_t start_r,Py_ssize_t num_elts): +cdef list do_karatsuba(list left, list right, Py_ssize_t K_threshold,Py_ssize_t start_l, Py_ssize_t start_r,Py_ssize_t num_elts) noexcept: """ Core routine for Karatsuba multiplication. This function works for two polynomials of the same degree. @@ -11613,14 +11613,14 @@ cdef class Polynomial_generic_dense(Polynomial): else: self._coeffs = x - cdef Polynomial_generic_dense _new_c(self, list coeffs, Parent P): + cdef Polynomial_generic_dense _new_c(self, list coeffs, Parent P) noexcept: cdef type t = type(self) cdef Polynomial_generic_dense f = t.__new__(t) f._parent = P f._coeffs = coeffs return f - cpdef Polynomial _new_constant_poly(self, a, Parent P): + cpdef Polynomial _new_constant_poly(self, a, Parent P) noexcept: """ Create a new constant polynomial in P with value a. @@ -11692,7 +11692,7 @@ cdef class Polynomial_generic_dense(Polynomial): @cython.boundscheck(False) @cython.wraparound(False) - cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right): + cdef Polynomial _mul_term(self, Polynomial term, bint term_on_right) noexcept: """ Return the product ``self * term``, where ``term`` is a polynomial with a single term. @@ -11744,7 +11744,7 @@ cdef class Polynomial_generic_dense(Polynomial): @cython.boundscheck(False) @cython.wraparound(False) - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -11841,7 +11841,7 @@ cdef class Polynomial_generic_dense(Polynomial): res._normalize() return res - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Add two polynomials. @@ -11872,7 +11872,7 @@ cdef class Polynomial_generic_dense(Polynomial): else: return self._new_c(low + high, self._parent) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: cdef Polynomial_generic_dense res cdef Py_ssize_t check=0, i, min x = (self)._coeffs @@ -11893,7 +11893,7 @@ cdef class Polynomial_generic_dense(Polynomial): else: return self._new_c(low + high, self._parent) - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: if not self._coeffs: return self if c._parent is not (self._coeffs[0])._parent: @@ -11905,7 +11905,7 @@ cdef class Polynomial_generic_dense(Polynomial): res._normalize() return res - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: if not self._coeffs: return self if c._parent is not (self._coeffs[0])._parent: @@ -11917,7 +11917,7 @@ cdef class Polynomial_generic_dense(Polynomial): res._normalize() return res - cpdef constant_coefficient(self): + cpdef constant_coefficient(self) noexcept: """ Return the constant coefficient of this polynomial. @@ -11936,7 +11936,7 @@ cdef class Polynomial_generic_dense(Polynomial): else: return self._coeffs[0] - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a new copy of the list of the underlying elements of ``self``. @@ -12123,7 +12123,7 @@ cdef class Polynomial_generic_dense(Polynomial): return self._new_c(quo,self._parent), self._new_c(x,self._parent)._inplace_truncate(n-1) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: r""" Return the polynomial of degree `< n` which is equivalent to self modulo `x^n`. @@ -12157,7 +12157,7 @@ cdef class Polynomial_generic_dense(Polynomial): n -= 1 return self._new_c(self._coeffs[:n], self._parent) - cdef _inplace_truncate(self, long n): + cdef _inplace_truncate(self, long n) noexcept: if n < len(self._coeffs): while n > 0 and not self._coeffs[n-1]: n -= 1 @@ -12208,7 +12208,7 @@ def universal_discriminant(n): return (1 - (n&2))*p.resultant(p.derivative())//pr1.gen(n) -cpdef Polynomial generic_power_trunc(Polynomial p, Integer n, long prec): +cpdef Polynomial generic_power_trunc(Polynomial p, Integer n, long prec) noexcept: r""" Generic truncated power algorithm @@ -12287,7 +12287,7 @@ cpdef Polynomial generic_power_trunc(Polynomial p, Integer n, long prec): return power -cpdef list _dict_to_list(dict x, zero): +cpdef list _dict_to_list(dict x, zero) noexcept: """ Convert a dict to a list. @@ -12465,7 +12465,7 @@ cdef class ConstantPolynomialSection(Map): ... TypeError: not a constant polynomial """ - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -12577,7 +12577,7 @@ cdef class PolynomialBaseringInjection(Morphism): self._repr_type_str = "Polynomial base injection" self._new_constant_poly_ = self._an_element._new_constant_poly - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ EXAMPLES:: @@ -12595,7 +12595,7 @@ cdef class PolynomialBaseringInjection(Morphism): _new_constant_poly_=self._new_constant_poly_) return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ EXAMPLES:: @@ -12611,7 +12611,7 @@ cdef class PolynomialBaseringInjection(Morphism): self._an_element = _slots['_an_element'] self._new_constant_poly_ = _slots['_new_constant_poly_'] - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -12627,7 +12627,7 @@ cdef class PolynomialBaseringInjection(Morphism): """ return self._new_constant_poly_(x, self._codomain) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ TESTS:: @@ -12690,7 +12690,7 @@ cdef class PolynomialBaseringInjection(Morphism): """ return False -cpdef bint polynomial_is_variable(x): +cpdef bint polynomial_is_variable(x) noexcept: r""" Test whether the given polynomial is a variable of its parent ring. diff --git a/src/sage/rings/polynomial/polynomial_gf2x.pyx b/src/sage/rings/polynomial/polynomial_gf2x.pyx index 9dd344ca681..51959a7825c 100644 --- a/src/sage/rings/polynomial/polynomial_gf2x.pyx +++ b/src/sage/rings/polynomial/polynomial_gf2x.pyx @@ -16,7 +16,7 @@ AUTHOR: # to make sure the function get_cparent is found since it is used in # 'polynomial_template.pxi'. -cdef inline cparent get_cparent(parent): +cdef inline cparent get_cparent(parent) noexcept: return 0 # first we include the definitions @@ -70,7 +70,7 @@ cdef class Polynomial_GF2X(Polynomial_template): pass Polynomial_template.__init__(self, parent, x, check, is_gen, construct) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ Return the `i`-th coefficient of ``self``. diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pxd b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pxd index b1b593d6a26..b88c2a66a76 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pxd +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pxd @@ -7,6 +7,6 @@ from sage.structure.parent cimport Parent cdef class Polynomial_integer_dense_flint(Polynomial): cdef fmpz_poly_t _poly - cdef Polynomial_integer_dense_flint _new(self) - cpdef _unsafe_mutate(self, long n, value) - cpdef Integer content(self) + cdef Polynomial_integer_dense_flint _new(self) noexcept + cpdef _unsafe_mutate(self, long n, value) noexcept + cpdef Integer content(self) noexcept diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index 7bb023e8452..20a1d75e66c 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -108,7 +108,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): """ fmpz_poly_clear(self._poly) - cdef Polynomial_integer_dense_flint _new(self): + cdef Polynomial_integer_dense_flint _new(self) noexcept: r""" Quickly creates a new initialized Polynomial_integer_dense_flint with the correct parent and _is_gen == 0. @@ -118,7 +118,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): x._is_gen = 0 return x - cpdef Polynomial _new_constant_poly(self, a, Parent P): + cpdef Polynomial _new_constant_poly(self, a, Parent P) noexcept: r""" Quickly creates a new constant polynomial with value a in parent P @@ -473,7 +473,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): return Polynomial.__call__(self, *x, **kwds) - cpdef Integer content(self): + cpdef Integer content(self) noexcept: r""" Return the greatest common divisor of the coefficients of this polynomial. The sign is the sign of the leading coefficient. The @@ -536,7 +536,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): return Polynomial_integer_dense_flint, \ (self.parent(), self.list(), False, self.is_gen()) - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -635,7 +635,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): name = self.parent().latex_variable_names()[0] return self._repr(name=name, latex=True) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Return ``self`` plus ``right``. @@ -655,7 +655,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Return ``self`` minus ``right``. @@ -675,7 +675,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return negative of ``self``. @@ -958,7 +958,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): return self._parent(rr), ss, tt - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: r""" Return ``self`` multiplied by ``right``. @@ -975,7 +975,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return x - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: r""" Truncated multiplication @@ -1006,7 +1006,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return x - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: r""" Return ``self`` multiplied by ``right``, where ``right`` is a scalar (integer). @@ -1024,7 +1024,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return x - cpdef _rmul_(self, Element right): + cpdef _rmul_(self, Element right) noexcept: r""" Return ``self`` multiplied by ``right``, where right is a scalar (integer). @@ -1164,7 +1164,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return res - cpdef Polynomial _power_trunc(self, unsigned long n, long prec): + cpdef Polynomial _power_trunc(self, unsigned long n, long prec) noexcept: r""" Truncated power @@ -1252,7 +1252,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return res - cpdef Polynomial inverse_series_trunc(self, long prec): + cpdef Polynomial inverse_series_trunc(self, long prec) noexcept: r""" Return a polynomial approximation of precision ``prec`` of the inverse series of this polynomial. @@ -1307,7 +1307,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_off() return res - cpdef _unsafe_mutate(self, long n, value): + cpdef _unsafe_mutate(self, long n, value) noexcept: r""" Sets coefficient of `x^n` to value. @@ -1730,7 +1730,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): from sage.rings.polynomial.padics.polynomial_padic import _pari_padic_factorization_to_sage return _pari_padic_factorization_to_sage(G, R, self.leading_coefficient()) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a new copy of the list of the underlying elements of ``self``. diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pxd b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pxd index fcd907e1abe..982fafb8ebb 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pxd +++ b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pxd @@ -4,4 +4,4 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial cdef class Polynomial_integer_dense_ntl(Polynomial): cdef ZZX_c _poly - cdef Polynomial_integer_dense_ntl _new(self) + cdef Polynomial_integer_dense_ntl _new(self) noexcept diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx index 80a1726bb4e..71234543840 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx @@ -73,7 +73,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): r""" A dense polynomial over the integers, implemented via NTL. """ - cdef Polynomial_integer_dense_ntl _new(self): + cdef Polynomial_integer_dense_ntl _new(self) noexcept: r""" Quickly creates a new initialized Polynomial_integer_dense_ntl with the correct parent and _is_gen == 0. @@ -338,7 +338,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): return Polynomial_integer_dense_ntl, \ (self.parent(), self.list(), False, self.is_gen()) - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -428,7 +428,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): name = self.parent().latex_variable_names()[0] return self._repr(name, latex=True) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: r""" Returns self plus right. @@ -446,7 +446,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: r""" Return self minus right. @@ -464,7 +464,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Returns negative of ``self``. @@ -680,7 +680,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): return S(rr), ss, tt - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: r""" Returns self multiplied by right. @@ -695,7 +695,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): (right)._poly) return x - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: r""" Returns self multiplied by right, where right is a scalar (integer). @@ -714,7 +714,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): ZZX_mul_ZZ(x._poly, self._poly, _right) return x - cpdef _rmul_(self, Element right): + cpdef _rmul_(self, Element right) noexcept: r""" Returns self multiplied by right, where right is a scalar (integer). @@ -1088,7 +1088,7 @@ cdef class Polynomial_integer_dense_ntl(Polynomial): from sage.rings.polynomial.padics.polynomial_padic import _pari_padic_factorization_to_sage return _pari_padic_factorization_to_sage(G, R, self.leading_coefficient()) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a new copy of the list of the underlying elements of ``self``. diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pxd b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pxd index 6934acfee8d..f476dc782ce 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pxd +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pxd @@ -22,14 +22,14 @@ cdef class Polynomial_dense_mod_n(Polynomial): cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): cdef zz_pX_c x cdef ntl_zz_pContext_class c - cdef Polynomial_dense_modn_ntl_zz _new(self) - cpdef _mod_(self, right) + cdef Polynomial_dense_modn_ntl_zz _new(self) noexcept + cpdef _mod_(self, right) noexcept cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): cdef ZZ_pX_c x cdef ntl_ZZ_pContext_class c - cdef Polynomial_dense_modn_ntl_ZZ _new(self) - cpdef _mod_(self, right) + cdef Polynomial_dense_modn_ntl_ZZ _new(self) noexcept + cpdef _mod_(self, right) noexcept cdef class Polynomial_dense_mod_p(Polynomial_dense_mod_n): pass diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index a8f08f5bc6c..65bd584d9ea 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -188,7 +188,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): """ return self._poly - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -220,10 +220,10 @@ cdef class Polynomial_dense_mod_n(Polynomial): return (~self)**(-n) return self.parent()(self._poly**n, construct=True) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: return self.parent()(self._poly + (right)._poly, construct=True) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -233,7 +233,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): """ return self.parent()(self._poly * (right)._poly, construct=True) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: try: return self.parent()(ZZ_pX([c], self.parent().modulus()) * self._poly, construct=True) except RuntimeError as msg: # should this really be a TypeError @@ -284,7 +284,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): return self.parent()(self._poly.left_shift(n), construct=True) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: return self.parent()(self._poly - (right)._poly, construct=True) def __floordiv__(self, right): @@ -316,7 +316,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): """ return smallInteger(max(self._poly.degree(), -1)) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a new copy of the list of the underlying elements of ``self``. @@ -674,7 +674,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): self.x = ntl.x self.c = ntl.c - cdef Polynomial_dense_modn_ntl_zz _new(self): + cdef Polynomial_dense_modn_ntl_zz _new(self) noexcept: cdef Polynomial_dense_modn_ntl_zz y = Polynomial_dense_modn_ntl_zz.__new__(Polynomial_dense_modn_ntl_zz) y.c = self.c y._parent = self._parent @@ -698,7 +698,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): cdef long i return [ zz_p_rep(zz_pX_GetCoeff(self.x, i)) for i from 0 <= i <= zz_pX_deg(self.x) ] - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -720,7 +720,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): self.c.restore_c() zz_pX_SetCoeff_long(self.x, n, value) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ TESTS:: @@ -737,7 +737,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ TESTS:: @@ -754,7 +754,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ TESTS:: @@ -774,7 +774,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: r""" Return the product of ``self`` and ``right`` truncated to the given length `n` @@ -812,7 +812,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ TESTS:: @@ -828,7 +828,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ TESTS:: @@ -938,7 +938,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): sig_off() return q, r - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Return the whole part of ``self``/``right``, without remainder. @@ -962,7 +962,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): sig_off() return q - cpdef _mod_(self, right): + cpdef _mod_(self, right) noexcept: """ EXAMPLES:: @@ -1169,7 +1169,7 @@ cdef class Polynomial_dense_modn_ntl_zz(Polynomial_dense_mod_n): """ return zz_pX_deg(self.x) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: """ Return this polynomial mod `x^n`. @@ -1250,17 +1250,17 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if self.c is not None: self.c.restore_c() - cdef Polynomial_dense_modn_ntl_ZZ _new(self): + cdef Polynomial_dense_modn_ntl_ZZ _new(self) noexcept: cdef Polynomial_dense_modn_ntl_ZZ y = Polynomial_dense_modn_ntl_ZZ.__new__(Polynomial_dense_modn_ntl_ZZ) y.c = self.c y._parent = self._parent return y - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: return [self.get_unsafe(n) for n from 0 <= n <= self.degree()] - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -1292,7 +1292,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): cdef ntl_ZZ_p val = ntl_ZZ_p(a, self.c) ZZ_pX_SetCoeff(self.x, n, val.x) - cpdef _add_(self, _right): + cpdef _add_(self, _right) noexcept: """ TESTS:: @@ -1309,7 +1309,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _sub_(self, _right): + cpdef _sub_(self, _right) noexcept: """ TESTS:: @@ -1326,7 +1326,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _mul_(self, _right): + cpdef _mul_(self, _right) noexcept: """ TESTS:: @@ -1346,7 +1346,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: """ Return the product of ``self`` and ``right`` truncated to the given length `n`, only return terms of degree less than `n`. @@ -1384,7 +1384,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ TESTS:: @@ -1401,7 +1401,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): if do_sig: sig_off() return r - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ TESTS:: @@ -1495,7 +1495,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): sig_off() return q, r - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Return the whole part of ``self`` / ``right``, without remainder. @@ -1519,7 +1519,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): sig_off() return q - cpdef _mod_(self, right): + cpdef _mod_(self, right) noexcept: """ EXAMPLES:: @@ -1730,7 +1730,7 @@ cdef class Polynomial_dense_modn_ntl_ZZ(Polynomial_dense_mod_n): """ return ZZ_pX_deg(self.x) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: """ Return this polynomial mod `x^n`. diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pxd b/src/sage/rings/polynomial/polynomial_rational_flint.pxd index f4644f19d04..dacca987830 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pxd +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pxd @@ -13,8 +13,8 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial cdef class Polynomial_rational_flint(Polynomial): cdef fmpq_poly_t _poly - cdef Polynomial_rational_flint _new(self) - cpdef _mod_(self, right) - cpdef _unsafe_mutate(self, unsigned long n, value) - cpdef Polynomial truncate(self, long n) + cdef Polynomial_rational_flint _new(self) noexcept + cpdef _mod_(self, right) noexcept + cpdef _unsafe_mutate(self, unsigned long n, value) noexcept + cpdef Polynomial truncate(self, long n) noexcept diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index b888b31d214..f651c9f3512 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -58,7 +58,7 @@ from sage.structure.element import coerce_binop from sage.misc.cachefunc import cached_method -cdef inline bint _do_sig(fmpq_poly_t op): +cdef inline bint _do_sig(fmpq_poly_t op) noexcept: """ Return 1 when signal handling should be carried out for an operation on this polynomial and 0 otherwise. @@ -108,7 +108,7 @@ cdef class Polynomial_rational_flint(Polynomial): # Allocation & initialisation # ########################################################################### - cdef Polynomial_rational_flint _new(self): + cdef Polynomial_rational_flint _new(self) noexcept: """ Quickly creates a new polynomial object in this class. @@ -129,7 +129,7 @@ cdef class Polynomial_rational_flint(Polynomial): res._is_gen = 0 return res - cpdef Polynomial _new_constant_poly(self, x, Parent P): + cpdef Polynomial _new_constant_poly(self, x, Parent P) noexcept: r""" Quickly creates a new constant polynomial with value x in parent P @@ -350,7 +350,7 @@ cdef class Polynomial_rational_flint(Polynomial): self._parent._singular_(singular).set_ring() # Expensive! return singular(self._singular_init_()) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ Return a list with the coefficients of ``self``. @@ -394,7 +394,7 @@ cdef class Polynomial_rational_flint(Polynomial): """ return smallInteger(fmpq_poly_degree(self._poly)) - cdef get_unsafe(self, Py_ssize_t n): + cdef get_unsafe(self, Py_ssize_t n) noexcept: """ Return the `n`-th coefficient of ``self``. @@ -416,7 +416,7 @@ cdef class Polynomial_rational_flint(Polynomial): fmpq_poly_get_coeff_mpq(z.value, self._poly, n) return z - cpdef _unsafe_mutate(self, unsigned long n, value): + cpdef _unsafe_mutate(self, unsigned long n, value) noexcept: """ Sets the `n`-th coefficient of ``self`` to value. @@ -550,7 +550,7 @@ cdef class Polynomial_rational_flint(Polynomial): return Polynomial.__call__(self, *x, **kwds) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: """ Return self truncated modulo `t^n`. @@ -837,7 +837,7 @@ cdef class Polynomial_rational_flint(Polynomial): # Arithmetic # ########################################################################### - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Return the sum of two rational polynomials. @@ -865,7 +865,7 @@ cdef class Polynomial_rational_flint(Polynomial): if do_sig: sig_off() return res - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return the difference of two rational polynomials. @@ -893,7 +893,7 @@ cdef class Polynomial_rational_flint(Polynomial): if do_sig: sig_off() return res - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the difference of two rational polynomials. @@ -1047,7 +1047,7 @@ cdef class Polynomial_rational_flint(Polynomial): sig_off() return d, s, t - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Return the product of ``self`` and ``right``. @@ -1076,7 +1076,7 @@ cdef class Polynomial_rational_flint(Polynomial): if do_sig: sig_off() return res - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: r""" Truncated multiplication. @@ -1113,7 +1113,7 @@ cdef class Polynomial_rational_flint(Polynomial): if do_sig: sig_off() return res - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: r""" Return ``left * self``, where ``left`` is a rational number. @@ -1133,7 +1133,7 @@ cdef class Polynomial_rational_flint(Polynomial): if do_sig: sig_off() return res - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: r""" Return ``self * right``, where ``right`` is a rational number. @@ -1345,7 +1345,7 @@ cdef class Polynomial_rational_flint(Polynomial): sig_off() return res - cpdef Polynomial inverse_series_trunc(self, long prec): + cpdef Polynomial inverse_series_trunc(self, long prec) noexcept: r""" Return a polynomial approximation of precision ``prec`` of the inverse series of this polynomial. @@ -1393,7 +1393,7 @@ cdef class Polynomial_rational_flint(Polynomial): sig_off() return res - cpdef _mod_(self, right): + cpdef _mod_(self, right) noexcept: """ Return the remainder of ``self`` and ``right`` obtain by Euclidean division. diff --git a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx index da5462cddd4..15c65081cd9 100644 --- a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx +++ b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx @@ -184,7 +184,7 @@ cdef class PolynomialRealDense(Polynomial): """ return make_PolynomialRealDense, (self._parent, self.list()) - cdef _normalize(self): + cdef _normalize(self) noexcept: """ Remove all leading 0's. """ @@ -197,7 +197,7 @@ cdef class PolynomialRealDense(Polynomial): self._coeffs = check_reallocarray(self._coeffs, i+1, sizeof(mpfr_t)) self._degree = i - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ Return the `i`-th coefficient of ``self``. @@ -225,7 +225,7 @@ cdef class PolynomialRealDense(Polynomial): mpfr_set(r.value, self._coeffs[i], self._base_ring.rnd) return r - cdef PolynomialRealDense _new(self, Py_ssize_t degree): + cdef PolynomialRealDense _new(self, Py_ssize_t degree) noexcept: cdef Py_ssize_t i cdef int prec = self._base_ring._prec cdef PolynomialRealDense f = PolynomialRealDense.__new__(PolynomialRealDense) @@ -257,7 +257,7 @@ cdef class PolynomialRealDense(Polynomial): """ return smallInteger(self._degree) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: r""" Returns the polynomial of degree `< n` which is equivalent to self modulo `x^n`. @@ -310,7 +310,7 @@ cdef class PolynomialRealDense(Polynomial): return self.truncate(i+1) return self._new(-1) - cpdef shift(self, Py_ssize_t n): + cpdef shift(self, Py_ssize_t n) noexcept: r""" Returns this polynomial multiplied by the power `x^n`. If `n` is negative, terms below `x^n` will be discarded. Does not @@ -351,7 +351,7 @@ cdef class PolynomialRealDense(Polynomial): mpfr_set(f._coeffs[i], self._coeffs[i-n], self._base_ring.rnd) return f - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ EXAMPLES:: @@ -386,7 +386,7 @@ cdef class PolynomialRealDense(Polynomial): mpfr_neg(f._coeffs[i], self._coeffs[i], rnd) return f - cpdef _add_(left, _right): + cpdef _add_(left, _right) noexcept: """ EXAMPLES:: @@ -419,7 +419,7 @@ cdef class PolynomialRealDense(Polynomial): f._normalize() return f - cpdef _sub_(left, _right): + cpdef _sub_(left, _right) noexcept: """ EXAMPLES:: @@ -450,7 +450,7 @@ cdef class PolynomialRealDense(Polynomial): f._normalize() return f - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ EXAMPLES:: @@ -472,7 +472,7 @@ cdef class PolynomialRealDense(Polynomial): mpfr_mul(f._coeffs[i], self._coeffs[i], a.value, rnd) return f - cpdef _mul_(left, _right): + cpdef _mul_(left, _right) noexcept: """ Here we use the naive `O(n^2)` algorithm, as asymptotically faster algorithms such as Karatsuba can have very inaccurate results due to intermediate rounding errors. diff --git a/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx b/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx index 7e3e27dd520..3be25f829c4 100644 --- a/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx +++ b/src/sage/rings/polynomial/polynomial_ring_homomorphism.pyx @@ -36,7 +36,7 @@ cdef class PolynomialRingHomomorphism_from_base(RingHomomorphism_from_base): To: Rational Field """ - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Evaluate the homomorphism ``self`` at ``x``. @@ -65,7 +65,7 @@ cdef class PolynomialRingHomomorphism_from_base(RingHomomorphism_from_base): else: return P([f(b) for b in x]) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ Evaluate ``self`` at ``x`` with additional (keyword) arguments. diff --git a/src/sage/rings/polynomial/polynomial_template.pxi b/src/sage/rings/polynomial/polynomial_template.pxi index ada39527536..7c53f107180 100644 --- a/src/sage/rings/polynomial/polynomial_template.pxi +++ b/src/sage/rings/polynomial/polynomial_template.pxi @@ -29,7 +29,7 @@ from sage.interfaces.singular import singular as singular_default def make_element(parent, args): return parent(*args) -cdef inline Polynomial_template element_shift(self, int n): +cdef inline Polynomial_template element_shift(self, int n) noexcept: if not isinstance(self, Polynomial_template): if n > 0: error_msg = "Cannot shift %s << %n."%(self, n) @@ -189,7 +189,7 @@ cdef class Polynomial_template(Polynomial): """ return make_element, ((self)._parent, (self.list(), False, self.is_gen())) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: """ EXAMPLES:: @@ -224,7 +224,7 @@ cdef class Polynomial_template(Polynomial): """ celement_destruct(&self.x, (self)._cparent) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ EXAMPLES:: @@ -242,7 +242,7 @@ cdef class Polynomial_template(Polynomial): #assert(r._parent(pari(self) + pari(right)) == r) return r - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ EXAMPLES:: @@ -276,7 +276,7 @@ cdef class Polynomial_template(Polynomial): #assert(r._parent(-pari(self)) == r) return r - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: """ EXAMPLES:: @@ -322,7 +322,7 @@ cdef class Polynomial_template(Polynomial): celement_mul_scalar(&r.x, &(self).x, left, (self)._cparent) return r - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ EXAMPLES:: @@ -409,7 +409,7 @@ cdef class Polynomial_template(Polynomial): #assert(t._parent(tp) == t) return r,s,t - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ EXAMPLES:: @@ -444,7 +444,7 @@ cdef class Polynomial_template(Polynomial): celement_floordiv(&r.x, &(self).x, &(right).x, (self)._cparent) return r - cpdef _mod_(self, other): + cpdef _mod_(self, other) noexcept: """ EXAMPLES:: @@ -513,7 +513,7 @@ cdef class Polynomial_template(Polynomial): """ return not celement_is_zero(&self.x, (self)._cparent) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ EXAMPLES:: @@ -731,7 +731,7 @@ cdef class Polynomial_template(Polynomial): """ return Integer(celement_len(&self.x, (self)._cparent)-1) - cpdef Polynomial truncate(self, long n): + cpdef Polynomial truncate(self, long n) noexcept: r""" Returns this polynomial mod `x^n`. diff --git a/src/sage/rings/polynomial/polynomial_template_header.pxi b/src/sage/rings/polynomial/polynomial_template_header.pxi index 64ab106f314..ba7184f6643 100644 --- a/src/sage/rings/polynomial/polynomial_template_header.pxi +++ b/src/sage/rings/polynomial/polynomial_template_header.pxi @@ -7,4 +7,4 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial cdef class Polynomial_template(Polynomial): cdef celement x cdef cparent _cparent - cpdef _mod_(self, right) + cpdef _mod_(self, right) noexcept diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pxd b/src/sage/rings/polynomial/polynomial_zmod_flint.pxd index c6a92f3df6c..887f46ea6eb 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pxd +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pxd @@ -10,8 +10,8 @@ include "polynomial_template_header.pxi" cdef cparent get_cparent(parent) except? 0 cdef class Polynomial_zmod_flint(Polynomial_template): - cdef Polynomial_template _new(self) + cdef Polynomial_template _new(self) noexcept cdef int _set_list(self, x) except -1 cdef int _set_fmpz_poly(self, fmpz_poly_t) except -1 - cpdef Polynomial _mul_trunc_opposite(self, Polynomial_zmod_flint other, length) - cpdef rational_reconstruction(self, m, n_deg=?, d_deg=?) + cpdef Polynomial _mul_trunc_opposite(self, Polynomial_zmod_flint other, length) noexcept + cpdef rational_reconstruction(self, m, n_deg=?, d_deg=?) noexcept diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index 4c480673861..6e7f7498329 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -122,7 +122,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): pass Polynomial_template.__init__(self, parent, x, check, is_gen, construct) - cdef Polynomial_template _new(self): + cdef Polynomial_template _new(self) noexcept: """ EXAMPLES:: @@ -137,7 +137,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): e._cparent = self._cparent return e - cpdef Polynomial _new_constant_poly(self, x, Parent P): + cpdef Polynomial _new_constant_poly(self, x, Parent P) noexcept: r""" Quickly creates a new constant polynomial with value x in parent P. @@ -244,7 +244,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): sig_off() return 0 - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: """ Return the `i`-th coefficient of ``self``. @@ -412,7 +412,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): else: raise IndexError("Polynomial coefficient index must be nonnegative.") - cpdef Polynomial _mul_trunc_(self, Polynomial right, long n): + cpdef Polynomial _mul_trunc_(self, Polynomial right, long n) noexcept: """ Return the product of this polynomial and other truncated to the given length `n`. @@ -445,7 +445,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): _mul_short = _mul_trunc_ - cpdef Polynomial _mul_trunc_opposite(self, Polynomial_zmod_flint other, n): + cpdef Polynomial _mul_trunc_opposite(self, Polynomial_zmod_flint other, n) noexcept: """ Return the product of this polynomial and other ignoring the least significant `n` terms of the result which may be set to anything. @@ -482,7 +482,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): _mul_short_opposite = _mul_trunc_opposite - cpdef Polynomial _power_trunc(self, unsigned long n, long prec): + cpdef Polynomial _power_trunc(self, unsigned long n, long prec) noexcept: r""" TESTS:: @@ -519,7 +519,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): nmod_poly_pow_trunc(&ans.x, &self.x, n, prec) return ans - cpdef rational_reconstruction(self, m, n_deg=0, d_deg=0): + cpdef rational_reconstruction(self, m, n_deg=0, d_deg=0) noexcept: """ Construct a rational function `n/d` such that `p*d` is equivalent to `n` modulo `m` where `p` is this polynomial. diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 3cae5e13a48..60968b412da 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -44,7 +44,7 @@ include "polynomial_template.pxi" from sage.libs.ntl.ntl_ZZ_pE cimport ntl_ZZ_pE -cdef inline ZZ_pE_c_to_list(ZZ_pE_c x): +cdef inline ZZ_pE_c_to_list(ZZ_pE_c x) noexcept: cdef list L = [] cdef ZZ_pX_c c_pX cdef ZZ_p_c c_p @@ -152,7 +152,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): Polynomial_template.__init__(self, parent, x, check, is_gen, construct) - cdef get_unsafe(self, Py_ssize_t i): + cdef get_unsafe(self, Py_ssize_t i) noexcept: r""" Return the `i`-th coefficient of ``self``. @@ -176,7 +176,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): cdef ZZ_pE_c c_pE = ZZ_pEX_coeff(self.x, i) return self._parent._base(ZZ_pE_c_to_list(c_pE)) - cpdef list list(self, bint copy=True): + cpdef list list(self, bint copy=True) noexcept: r""" Return the list of coefficients. @@ -198,7 +198,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): return [K(ZZ_pE_c_to_list(ZZ_pEX_coeff(self.x, i))) for i in range(celement_len(&self.x, (self)._cparent))] - cpdef _lmul_(self, Element left): + cpdef _lmul_(self, Element left) noexcept: r""" EXAMPLES:: @@ -410,7 +410,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): ZZ_pEX_MinPolyMod(r.x, ((self % other)).x, (other).x) return r - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" EXAMPLES:: diff --git a/src/sage/rings/polynomial/real_roots.pxd b/src/sage/rings/polynomial/real_roots.pxd index d282f350c7b..17b3ef6d8b8 100644 --- a/src/sage/rings/polynomial/real_roots.pxd +++ b/src/sage/rings/polynomial/real_roots.pxd @@ -20,16 +20,16 @@ cdef class interval_bernstein_polynomial: cdef int bitsize cdef int scale_log2 - cdef void update_variations(self, interval_bernstein_polynomial bp1, interval_bernstein_polynomial bp2) - cdef int degree(self) + cdef void update_variations(self, interval_bernstein_polynomial bp1, interval_bernstein_polynomial bp2) noexcept + cdef int degree(self) noexcept cdef class interval_bernstein_polynomial_integer(interval_bernstein_polynomial): cdef Vector_integer_dense coeffs cdef int error - cdef void _set_bitsize(self) - cdef void _count_variations(self) + cdef void _set_bitsize(self) noexcept + cdef void _count_variations(self) noexcept cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial): cdef Vector_real_double_dense coeffs @@ -37,7 +37,7 @@ cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial): cdef double neg_err cdef double pos_err - cdef void _count_variations(self) + cdef void _count_variations(self) noexcept # forward declaration cdef class rr_gap @@ -66,8 +66,8 @@ cdef class context: cdef dc_log cdef be_log - cdef void dc_log_append(self, x) - cdef void be_log_append(self, x) + cdef void dc_log_append(self, x) noexcept + cdef void be_log_append(self, x) noexcept cdef class ocean: cdef context ctx diff --git a/src/sage/rings/polynomial/real_roots.pyx b/src/sage/rings/polynomial/real_roots.pyx index 97af8b60ffd..79fdf47ca0f 100644 --- a/src/sage/rings/polynomial/real_roots.pyx +++ b/src/sage/rings/polynomial/real_roots.pyx @@ -319,7 +319,7 @@ cdef class interval_bernstein_polynomial: """ return (self.min_variations, self.max_variations) - cdef void update_variations(self, interval_bernstein_polynomial bp1, interval_bernstein_polynomial bp2): + cdef void update_variations(self, interval_bernstein_polynomial bp1, interval_bernstein_polynomial bp2) noexcept: """ Update the max_variations of bp1 and bp2 (which are assumed to be the result of splitting this polynomial). @@ -422,7 +422,7 @@ cdef class interval_bernstein_polynomial: return (p1, p2, rand) return None - cdef int degree(self): + cdef int degree(self) noexcept: raise NotImplementedError() def region(self): @@ -565,7 +565,7 @@ cdef class interval_bernstein_polynomial_integer(interval_bernstein_polynomial): """ return 'i' - cdef void _set_bitsize(self): + cdef void _set_bitsize(self) noexcept: """ A private function that computes the maximum coefficient size of this Bernstein polynomial (in bits). @@ -580,7 +580,7 @@ cdef class interval_bernstein_polynomial_integer(interval_bernstein_polynomial): """ self.bitsize = max_bitsize_intvec(self.coeffs) - cdef void _count_variations(self): + cdef void _count_variations(self) noexcept: """ A private function that counts the number of sign variations in this Bernstein polynomial. Since the coefficients are represented @@ -677,7 +677,7 @@ cdef class interval_bernstein_polynomial_integer(interval_bernstein_polynomial): else: self.max_variations = max(count_maybe_pos, count_maybe_neg) - cdef int degree(self): + cdef int degree(self) noexcept: """ Return the (formal) degree of this polynomial. """ @@ -1480,7 +1480,7 @@ cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial): """ return 'f' - cdef void _count_variations(self): + cdef void _count_variations(self) noexcept: """ A private function that counts the number of sign variations in this Bernstein polynomial. Since the coefficients are represented @@ -1552,7 +1552,7 @@ cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial): else: self.max_variations = max(count_maybe_pos, count_maybe_neg) - cdef int degree(self): + cdef int degree(self) noexcept: """ Return the (formal) degree of this polynomial. """ @@ -1939,7 +1939,7 @@ def relative_bounds(a, b): return ((bl - al) / width, (bh - al) / width) -cdef int bitsize(Integer a): +cdef int bitsize(Integer a) noexcept: """ Compute the number of bits required to write a given integer (the sign is ignored). @@ -2143,7 +2143,7 @@ def bernstein_up(d1, d2, s=None): return m -cdef int subsample_vec(int a, int slen, int llen): +cdef int subsample_vec(int a, int slen, int llen) noexcept: """ Given a vector of length llen, and slen < llen, we want to select slen of the elements of the vector, evenly spaced. @@ -4353,14 +4353,14 @@ cdef class context: s = s + "; wordsize=%d" % self.wordsize return s - cdef void dc_log_append(self, x): + cdef void dc_log_append(self, x) noexcept: """ Optional logging for the root isolation algorithm. """ if self.do_logging: self.dc_log.append(x) - cdef void be_log_append(self, x): + cdef void be_log_append(self, x) noexcept: """ Optional logging for degree reduction in the root isolation algorithm. """ @@ -4528,7 +4528,7 @@ def bernstein_expand(Vector_integer_dense c, int d2): return (c2, ndivides) -cdef int max_bitsize_intvec(Vector_integer_dense b): +cdef int max_bitsize_intvec(Vector_integer_dense b) noexcept: """ Given an integer vector, find the approximate log2 of the maximum of the absolute values of the elements. diff --git a/src/sage/rings/polynomial/skew_polynomial_element.pxd b/src/sage/rings/polynomial/skew_polynomial_element.pxd index b7222e38117..d967e898909 100644 --- a/src/sage/rings/polynomial/skew_polynomial_element.pxd +++ b/src/sage/rings/polynomial/skew_polynomial_element.pxd @@ -1,8 +1,8 @@ from sage.rings.polynomial.ore_polynomial_element cimport OrePolynomial_generic_dense cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): - cdef void _inplace_rmul(self, SkewPolynomial_generic_dense right) - cdef void _inplace_pow(self, Py_ssize_t n) - cpdef right_power_mod(self, exp, modulus) - cpdef left_power_mod(self, exp, modulus) - cpdef operator_eval(self, eval_pt) + cdef void _inplace_rmul(self, SkewPolynomial_generic_dense right) noexcept + cdef void _inplace_pow(self, Py_ssize_t n) noexcept + cpdef right_power_mod(self, exp, modulus) noexcept + cpdef left_power_mod(self, exp, modulus) noexcept + cpdef operator_eval(self, eval_pt) noexcept diff --git a/src/sage/rings/polynomial/skew_polynomial_element.pyx b/src/sage/rings/polynomial/skew_polynomial_element.pyx index 539e924a968..3ea7f87bddf 100644 --- a/src/sage/rings/polynomial/skew_polynomial_element.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_element.pyx @@ -63,7 +63,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): Generic implementation of dense skew polynomial supporting any valid base ring and twisting morphism. """ - cpdef left_power_mod(self, exp, modulus): + cpdef left_power_mod(self, exp, modulus) noexcept: r""" Return the remainder of ``self**exp`` in the left euclidean division by ``modulus``. @@ -125,7 +125,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): _, r = r._left_quo_rem(modulus) return r - cpdef right_power_mod(self, exp, modulus): + cpdef right_power_mod(self, exp, modulus) noexcept: r""" Return the remainder of ``self**exp`` in the right euclidean division by ``modulus``. @@ -326,7 +326,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): """ return self.operator_eval(eval_pt) - cpdef operator_eval(self, eval_pt): + cpdef operator_eval(self, eval_pt) noexcept: r""" Evaluate ``self`` at ``eval_pt`` by the operator evaluation method. @@ -453,7 +453,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): """ return [ self(e) for e in eval_pts ] - cpdef ModuleElement _lmul_(self, Element right): + cpdef ModuleElement _lmul_(self, Element right) noexcept: r""" Return the product ``self * right``. @@ -482,7 +482,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): self._parent, 0) return r - cpdef ModuleElement _rmul_(self, Element left): + cpdef ModuleElement _rmul_(self, Element left) noexcept: r""" Return the product ``left * self``. @@ -509,7 +509,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): r = self._new_c([ left*x[i] for i from 0 <= i < len(x) ], self._parent, 0) return r - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: r""" Return the product ``self * right``. @@ -560,7 +560,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): r = self._new_c(coeffs, parent, 0) return r - cdef void _inplace_rmul(self, SkewPolynomial_generic_dense right): + cdef void _inplace_rmul(self, SkewPolynomial_generic_dense right) noexcept: r""" Replace ``self`` by ``self*right`` (only for internal use). @@ -596,7 +596,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): sum += x[i] * parent.twisting_morphism(i)(y[k-i]) x[k] = sum - cdef void _inplace_pow(self, Py_ssize_t n): + cdef void _inplace_pow(self, Py_ssize_t n) noexcept: r""" Replace ``self`` by ``self**n`` (only for internal use). @@ -621,7 +621,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): self._inplace_rmul(selfpow) n = n >> 1 - cdef _left_quo_rem(self, OrePolynomial other): + cdef _left_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the left euclidean division of ``self`` by ``other`` (C implementation). @@ -650,7 +650,7 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense): q.reverse() return (self._new_c(q, parent), self._new_c(a[:db], parent, 1)) - cdef _right_quo_rem(self, OrePolynomial other): + cdef _right_quo_rem(self, OrePolynomial other) noexcept: r""" Return the quotient and remainder of the right euclidean division of ``self`` by ``other`` (C implementation). diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_field.pxd b/src/sage/rings/polynomial/skew_polynomial_finite_field.pxd index f27cfdd6ff1..1718554cc3a 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_field.pxd +++ b/src/sage/rings/polynomial/skew_polynomial_finite_field.pxd @@ -5,14 +5,14 @@ cdef class SkewPolynomial_finite_field_dense (SkewPolynomial_finite_order_dense) cdef dict _types cdef _factorization - cdef inline _reduced_norm_factored(self) + cdef inline _reduced_norm_factored(self) noexcept # Finding divisors - cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N) + cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N) noexcept # Finding factorizations - cdef _factor_c(self) - cdef _factor_uniform_c(self) + cdef _factor_c(self) noexcept + cdef _factor_uniform_c(self) noexcept -cdef inline SkewPolynomial_finite_field_dense mul_op(SkewPolynomial_finite_field_dense P, SkewPolynomial_finite_field_dense Q): +cdef inline SkewPolynomial_finite_field_dense mul_op(SkewPolynomial_finite_field_dense P, SkewPolynomial_finite_field_dense Q) noexcept: return Q * P diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx index c6b67cba5fb..8066670c4a0 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx @@ -43,7 +43,7 @@ from sage.combinat.q_analogues import q_jordan cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): - cdef inline _reduced_norm_factored(self): + cdef inline _reduced_norm_factored(self) noexcept: """ Return the reduced norm of this polynomial factorized in the center. """ @@ -212,7 +212,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): # Finding divisors # ---------------- - cdef SkewPolynomial_finite_field_dense _rdivisor_c(self, N): + cdef SkewPolynomial_finite_field_dense _rdivisor_c(self, N) noexcept: r""" Return a right divisor of this skew polynomial whose reduced norm is `N`. @@ -747,7 +747,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): # Finding factorizations # ---------------------- - cdef _factor_c(self): + cdef _factor_c(self) noexcept: r""" Compute a factorization of ``self``. @@ -818,7 +818,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): factors.reverse() return Factorization(factors, sort=False, unit=unit) - cdef _factor_uniform_c(self): + cdef _factor_uniform_c(self) noexcept: r""" Compute a uniformly distributed factorization of ``self``. diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_order.pxd b/src/sage/rings/polynomial/skew_polynomial_finite_order.pxd index 438773a39ef..bfaf8d04d14 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_order.pxd +++ b/src/sage/rings/polynomial/skew_polynomial_finite_order.pxd @@ -5,6 +5,6 @@ cdef class SkewPolynomial_finite_order_dense (SkewPolynomial_generic_dense): cdef _charpoly cdef _optbound - cdef _matphir_c(self) - cdef _matmul_c(self) + cdef _matphir_c(self) noexcept + cdef _matmul_c(self) noexcept diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx index 6ab57e1f7c5..968c45c8453 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_order.pyx @@ -71,7 +71,7 @@ cdef class SkewPolynomial_finite_order_dense(SkewPolynomial_generic_dense): self._optbound = None - cdef _matphir_c(self): + cdef _matphir_c(self) noexcept: r""" Return the matrix of the multiplication by `X^r` on the quotient `K[X,\sigma] / K[X,\sigma]*self`. @@ -122,7 +122,7 @@ cdef class SkewPolynomial_finite_order_dense(SkewPolynomial_generic_dense): phir.append(line) return matrix(k, phir) - cdef _matmul_c(self): + cdef _matmul_c(self) noexcept: r""" Return the matrix of the multiplication by ``self`` on `K[X,\sigma]` considered as a free module over `K[X^r]` diff --git a/src/sage/rings/polynomial/weil/weil_polynomials.pyx b/src/sage/rings/polynomial/weil/weil_polynomials.pyx index 2e2d6974fb7..182d0c41e6f 100755 --- a/src/sage/rings/polynomial/weil/weil_polynomials.pyx +++ b/src/sage/rings/polynomial/weil/weil_polynomials.pyx @@ -153,7 +153,7 @@ cdef class dfs_manager: free(self.dy_data_buf) self.dy_data_buf = NULL - cpdef long node_count(self): + cpdef long node_count(self) noexcept: """ Count nodes. @@ -175,7 +175,7 @@ cdef class dfs_manager: count += self.dy_data_buf[i].node_count return count - cpdef object advance_exhaust(self): + cpdef object advance_exhaust(self) noexcept: """ Advance the tree exhaustion. diff --git a/src/sage/rings/power_series_mpoly.pyx b/src/sage/rings/power_series_mpoly.pyx index be59294e75b..fa62a7ef6d6 100644 --- a/src/sage/rings/power_series_mpoly.pyx +++ b/src/sage/rings/power_series_mpoly.pyx @@ -100,7 +100,7 @@ cdef class PowerSeries_mpoly(PowerSeries): def _mpoly(self): return self.__f - cpdef _mul_(self, right_r): + cpdef _mul_(self, right_r) noexcept: """ Return the product of two power series. """ @@ -124,7 +124,7 @@ cdef class PowerSeries_mpoly(PowerSeries): return PowerSeries_mpoly(self._parent, -self.__f, self._prec, check=False) - cpdef _add_(self, right_m): + cpdef _add_(self, right_m) noexcept: """ EXAMPLES: """ @@ -132,7 +132,7 @@ cdef class PowerSeries_mpoly(PowerSeries): return PowerSeries_mpoly(self._parent, self.__f + right.__f, self.common_prec_c(right), check=True) - cpdef _sub_(self, right_m): + cpdef _sub_(self, right_m) noexcept: """ Return difference of two power series. @@ -142,11 +142,11 @@ cdef class PowerSeries_mpoly(PowerSeries): return PowerSeries_mpoly(self._parent, self.__f - right.__f, self.common_prec_c(right), check=True) - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: return PowerSeries_mpoly(self._parent, self.__f._rmul_(c), self._prec, check=False) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: return PowerSeries_mpoly(self._parent, self.__f._lmul_(c), self._prec, check=False) diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx index 94a6d1baacb..6b8d02b5762 100644 --- a/src/sage/rings/power_series_pari.pyx +++ b/src/sage/rings/power_series_pari.pyx @@ -81,7 +81,7 @@ from sage.structure.parent cimport Parent from sage.rings.infinity import infinity -cdef PowerSeries_pari construct_from_pari(parent, pari_gen g): +cdef PowerSeries_pari construct_from_pari(parent, pari_gen g) noexcept: r""" Fast construction of power series from PARI objects of suitable type (series, polynomials, scalars and rational functions). @@ -556,7 +556,7 @@ cdef class PowerSeries_pari(PowerSeries): return self._parent.laurent_series_ring()(h) return construct_from_pari(self._parent, h) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Addition of power series. @@ -573,7 +573,7 @@ cdef class PowerSeries_pari(PowerSeries): """ return construct_from_pari(self._parent, self.g + (right).g) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtraction of power series. @@ -587,7 +587,7 @@ cdef class PowerSeries_pari(PowerSeries): """ return construct_from_pari(self._parent, self.g - (right).g) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiplication of power series. @@ -600,7 +600,7 @@ cdef class PowerSeries_pari(PowerSeries): """ return construct_from_pari(self._parent, self.g * (right).g) - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ Right multiplication by a scalar. @@ -614,7 +614,7 @@ cdef class PowerSeries_pari(PowerSeries): """ return construct_from_pari(self._parent, self.g * c) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ Left multiplication by a scalar. @@ -628,7 +628,7 @@ cdef class PowerSeries_pari(PowerSeries): """ return construct_from_pari(self._parent, c * self.g) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Division of power series. diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index c7cd78db093..083fddaa805 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -485,7 +485,7 @@ cdef class PowerSeries_poly(PowerSeries): return PowerSeries_poly(self._parent, -self.__f, self._prec, check=False) - cpdef _add_(self, right_m): + cpdef _add_(self, right_m) noexcept: """ EXAMPLES:: @@ -516,7 +516,7 @@ cdef class PowerSeries_poly(PowerSeries): return PowerSeries_poly(self._parent, self.__f + right.__f, self.common_prec_c(right), check=True) - cpdef _sub_(self, right_m): + cpdef _sub_(self, right_m) noexcept: """ Return the difference of two power series. @@ -531,7 +531,7 @@ cdef class PowerSeries_poly(PowerSeries): return PowerSeries_poly(self._parent, self.__f - right.__f, self.common_prec_c(right), check=True) - cpdef _mul_(self, right_r): + cpdef _mul_(self, right_r) noexcept: """ Return the product of two power series. @@ -547,7 +547,7 @@ cdef class PowerSeries_poly(PowerSeries): prec=prec, check=True) # check, since truncation may be needed - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ Multiply ``self`` on the right by a scalar. @@ -560,7 +560,7 @@ cdef class PowerSeries_poly(PowerSeries): """ return PowerSeries_poly(self._parent, self.__f * c, self._prec, check=False) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ Multiply ``self`` on the left by a scalar. @@ -744,7 +744,7 @@ cdef class PowerSeries_poly(PowerSeries): else: return self.__f.truncate(prec) - cdef _inplace_truncate(self, long prec): + cdef _inplace_truncate(self, long prec) noexcept: """ Truncate ``self`` to precision ``prec`` in place. @@ -1243,7 +1243,7 @@ cdef class BaseRingFloorDivAction(Action): """ The floor division action of the base ring on a formal power series. """ - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: r""" Let ``g`` act on ``x`` under ``self``. diff --git a/src/sage/rings/power_series_ring_element.pxd b/src/sage/rings/power_series_ring_element.pxd index e5c031ee147..b8c28103131 100644 --- a/src/sage/rings/power_series_ring_element.pxd +++ b/src/sage/rings/power_series_ring_element.pxd @@ -3,9 +3,9 @@ from sage.structure.element cimport AlgebraElement, RingElement cdef class PowerSeries(AlgebraElement): cdef char _is_gen cdef _prec - cdef common_prec_c(self, PowerSeries other) + cdef common_prec_c(self, PowerSeries other) noexcept #_prec(self, RingElement right_r) # UNSAFE, only call from an inplace operator # may return a new element if not possible to modify inplace - cdef _inplace_truncate(self, long prec) + cdef _inplace_truncate(self, long prec) noexcept diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index 5e2c4511e49..ceb8198fafc 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -254,7 +254,7 @@ cdef class PowerSeries(AlgebraElement): else: raise NotImplementedError - cpdef base_extend(self, R): + cpdef base_extend(self, R) noexcept: """ Return a copy of this power series but with coefficients in R. @@ -311,7 +311,7 @@ cdef class PowerSeries(AlgebraElement): S = self._parent.change_ring(R) return S(self) - cpdef _richcmp_(self, right, int op): + cpdef _richcmp_(self, right, int op) noexcept: r""" Comparison of self and ``right``. @@ -813,7 +813,7 @@ cdef class PowerSeries(AlgebraElement): v = [a[i] for i in range(min(prec, len(a)))] return self._parent._poly_ring()(v) - cdef _inplace_truncate(self, long prec): + cdef _inplace_truncate(self, long prec) noexcept: return self.truncate(prec) def add_bigoh(self, prec): @@ -917,7 +917,7 @@ cdef class PowerSeries(AlgebraElement): return self.prec() return min(self.prec(), f.prec()) - cdef common_prec_c(self, PowerSeries f): + cdef common_prec_c(self, PowerSeries f) noexcept: if self._prec is infinity: return f._prec elif f._prec is infinity: @@ -1048,7 +1048,7 @@ cdef class PowerSeries(AlgebraElement): v[k-n] = x return self._parent(v, self.prec()-n) - cpdef _div_(self, denom_r): + cpdef _div_(self, denom_r) noexcept: """ EXAMPLES:: diff --git a/src/sage/rings/puiseux_series_ring_element.pyx b/src/sage/rings/puiseux_series_ring_element.pyx index 503d11ee975..39edce35bc9 100644 --- a/src/sage/rings/puiseux_series_ring_element.pyx +++ b/src/sage/rings/puiseux_series_ring_element.pyx @@ -354,7 +354,7 @@ cdef class PuiseuxSeries(AlgebraElement): n = g / n return g, m, n - cpdef _add_(self, right_m): + cpdef _add_(self, right_m) noexcept: """ Return the sum. @@ -376,7 +376,7 @@ cdef class PuiseuxSeries(AlgebraElement): l = l1 + l2 return type(self)(self._parent, l, g) - cpdef _sub_(self, right_m): + cpdef _sub_(self, right_m) noexcept: """ Return the difference. @@ -398,7 +398,7 @@ cdef class PuiseuxSeries(AlgebraElement): l = l1 - l2 return type(self)(self._parent, l, g) - cpdef _mul_(self, right_r): + cpdef _mul_(self, right_r) noexcept: """ Return the product. @@ -420,7 +420,7 @@ cdef class PuiseuxSeries(AlgebraElement): l = l1 * l2 return type(self)(self._parent, l, g) - cpdef _rmul_(self, Element c): + cpdef _rmul_(self, Element c) noexcept: """ Return the right scalar multiplication. @@ -433,7 +433,7 @@ cdef class PuiseuxSeries(AlgebraElement): """ return type(self)(self._parent, self._l._rmul_(c), self._e) - cpdef _lmul_(self, Element c): + cpdef _lmul_(self, Element c) noexcept: """ Return the left scalar multiplication. @@ -446,7 +446,7 @@ cdef class PuiseuxSeries(AlgebraElement): """ return type(self)(self._parent, self._l._lmul_(c), self._e) - cpdef _div_(self, right_r): + cpdef _div_(self, right_r) noexcept: """ Return the quotient. @@ -508,7 +508,7 @@ cdef class PuiseuxSeries(AlgebraElement): e = self._e * int(denom) return type(self)(self._parent, l, e) - cpdef _richcmp_(self, right_r, int op): + cpdef _richcmp_(self, right_r, int op) noexcept: r""" Comparison of ``self`` and ``right``. diff --git a/src/sage/rings/rational.pxd b/src/sage/rings/rational.pxd index a1b2403c723..f80ec22e9a9 100644 --- a/src/sage/rings/rational.pxd +++ b/src/sage/rings/rational.pxd @@ -3,17 +3,17 @@ from sage.libs.gmp.types cimport mpq_t cimport sage.structure.element cimport sage.rings.integer as integer -cpdef rational_power_parts(a, Rational b, factor_limit=?) +cpdef rational_power_parts(a, Rational b, factor_limit=?) noexcept cdef class Rational(sage.structure.element.FieldElement): cdef mpq_t value - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _pow_(self, other) - cdef __set_value(self, x, unsigned int base) - cdef void set_from_mpq(Rational self, mpq_t value) - cdef _lshift(self, long int exp) - cdef _rshift(self, long int exp) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _pow_(self, other) noexcept + cdef __set_value(self, x, unsigned int base) noexcept + cdef void set_from_mpq(Rational self, mpq_t value) noexcept + cdef _lshift(self, long int exp) noexcept + cdef _rshift(self, long int exp) noexcept - cdef _val_unit(self, integer.Integer p) + cdef _val_unit(self, integer.Integer p) noexcept diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index f8843a2cee7..0b398428006 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -123,16 +123,16 @@ gmpy2.import_gmpy2() cdef class Rational(sage.structure.element.FieldElement) -cdef inline void set_from_mpq(Rational self, mpq_t value): +cdef inline void set_from_mpq(Rational self, mpq_t value) noexcept: mpq_set(self.value, value) -cdef inline void set_from_Rational(Rational self, Rational other): +cdef inline void set_from_Rational(Rational self, Rational other) noexcept: mpq_set(self.value, other.value) -cdef inline void set_from_Integer(Rational self, integer.Integer other): +cdef inline void set_from_Integer(Rational self, integer.Integer other) noexcept: mpq_set_z(self.value, other.value) -cdef object Rational_mul_(Rational a, Rational b): +cdef object Rational_mul_(Rational a, Rational b) noexcept: cdef Rational x x = Rational.__new__(Rational) @@ -142,7 +142,7 @@ cdef object Rational_mul_(Rational a, Rational b): return x -cdef object Rational_div_(Rational a, Rational b): +cdef object Rational_div_(Rational a, Rational b) noexcept: cdef Rational x x = Rational.__new__(Rational) @@ -152,7 +152,7 @@ cdef object Rational_div_(Rational a, Rational b): return x -cdef Rational_add_(Rational self, Rational other): +cdef Rational_add_(Rational self, Rational other) noexcept: cdef Rational x x = Rational.__new__(Rational) sig_on() @@ -160,7 +160,7 @@ cdef Rational_add_(Rational self, Rational other): sig_off() return x -cdef Rational_sub_(Rational self, Rational other): +cdef Rational_sub_(Rational self, Rational other) noexcept: cdef Rational x x = Rational.__new__(Rational) @@ -173,14 +173,14 @@ cdef Rational_sub_(Rational self, Rational other): cdef Parent the_rational_ring = sage.rings.rational_field.Q # make sure zero/one elements are set -cdef set_zero_one_elements(): +cdef set_zero_one_elements() noexcept: global the_rational_ring the_rational_ring._zero_element = Rational(0) the_rational_ring._one_element = Rational(1) set_zero_one_elements() -cpdef Integer integer_rational_power(Integer a, Rational b): +cpdef Integer integer_rational_power(Integer a, Rational b) noexcept: """ Compute `a^b` as an integer, if it is integral, or return ``None``. @@ -262,7 +262,7 @@ cpdef Integer integer_rational_power(Integer a, Rational b): return z -cpdef rational_power_parts(a, Rational b, factor_limit=10**5): +cpdef rational_power_parts(a, Rational b, factor_limit=10**5) noexcept: """ Compute rationals or integers `c` and `d` such that `a^b = c*d^b` with `d` small. This is used for simplifying radicals. @@ -566,7 +566,7 @@ cdef class Rational(sage.structure.element.FieldElement): raise TypeError(f"unable to convert rational {self} to an integer") - cdef __set_value(self, x, unsigned int base): + cdef __set_value(self, x, unsigned int base) noexcept: cdef int n cdef Rational temp_rational cdef integer.Integer a, b @@ -680,7 +680,7 @@ cdef class Rational(sage.structure.element.FieldElement): else: raise TypeError("unable to convert {!r} to a rational".format(x)) - cdef void set_from_mpq(Rational self, mpq_t value): + cdef void set_from_mpq(Rational self, mpq_t value) noexcept: mpq_set(self.value, value) def list(self): @@ -820,7 +820,7 @@ cdef class Rational(sage.structure.element.FieldElement): l = self.continued_fraction_list() return ContinuedFraction_periodic(l) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare two rational numbers. @@ -1801,7 +1801,7 @@ cdef class Rational(sage.structure.element.FieldElement): # TODO -- change to use cpdef? If so, must fix # code in padics, etc. Do search_src('_val_unit'). - cdef _val_unit(Rational self, integer.Integer p): + cdef _val_unit(Rational self, integer.Integer p) noexcept: """ This is called by :meth:`val_unit()`. @@ -2307,7 +2307,7 @@ cdef class Rational(sage.structure.element.FieldElement): return coercion_model.bin_op(left, right, operator.add) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Return ``right`` plus ``self``. @@ -2359,7 +2359,7 @@ cdef class Rational(sage.structure.element.FieldElement): return coercion_model.bin_op(left, right, operator.sub) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Return ``self`` minus ``right``. @@ -2373,7 +2373,7 @@ cdef class Rational(sage.structure.element.FieldElement): mpq_sub(x.value, self.value, (right).value) return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Negate ``self``. @@ -2412,7 +2412,7 @@ cdef class Rational(sage.structure.element.FieldElement): return coercion_model.bin_op(left, right, operator.mul) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Return ``self`` times ``right``. @@ -2469,7 +2469,7 @@ cdef class Rational(sage.structure.element.FieldElement): return coercion_model.bin_op(left, right, operator.truediv) - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Return ``self`` divided by ``right``. @@ -2513,7 +2513,7 @@ cdef class Rational(sage.structure.element.FieldElement): mpq_inv(x.value, self.value) return x - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: """ Raise ``self`` to the rational power ``other``. @@ -2608,7 +2608,7 @@ cdef class Rational(sage.structure.element.FieldElement): from sage.symbolic.ring import SR return SR(c) * SR(d).power(n, hold=True) - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ Raise ``self`` to the integer power ``n``. @@ -2628,7 +2628,7 @@ cdef class Rational(sage.structure.element.FieldElement): # be particularly efficient here. return self._pow_(Rational(n)) - cdef _pow_long(self, long n): + cdef _pow_long(self, long n) noexcept: """ TESTS:: @@ -3663,7 +3663,7 @@ cdef class Rational(sage.structure.element.FieldElement): return False return a.prime_to_S_part(S) == 1 - cdef _lshift(self, long int exp): + cdef _lshift(self, long int exp) noexcept: r""" Return ``self * 2^exp``. """ @@ -3711,7 +3711,7 @@ cdef class Rational(sage.structure.element.FieldElement): return (x)._lshift(y) return coercion_model.bin_op(x, y, operator.lshift) - cdef _rshift(self, long int exp): + cdef _rshift(self, long int exp) noexcept: r""" Return ``self / 2^exp``. """ @@ -4099,7 +4099,7 @@ cdef class Z_to_Q(Morphism): import sage.categories.homset Morphism.__init__(self, sage.categories.homset.Hom(integer_ring.ZZ, rational_field.QQ)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Return the image of the morphism on ``x``. @@ -4166,7 +4166,7 @@ cdef class Q_to_Z(Map): sage: type(ZZ.convert_map_from(QQ)) """ - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ A fast map from the rationals to the integers. @@ -4221,7 +4221,7 @@ cdef class int_to_Q(Morphism): Morphism.__init__(self, sage.categories.homset.Hom( Set_PythonType(long), rational_field.QQ)) - cpdef Element _call_(self, a): + cpdef Element _call_(self, a) noexcept: """ Return the image of the morphism on ``a``. diff --git a/src/sage/rings/real_arb.pxd b/src/sage/rings/real_arb.pxd index 2f48fa06988..0a3a68d1057 100644 --- a/src/sage/rings/real_arb.pxd +++ b/src/sage/rings/real_arb.pxd @@ -4,17 +4,17 @@ from sage.rings.real_mpfi cimport RealIntervalField_class, RealIntervalFieldElem from sage.structure.parent cimport Parent from sage.structure.element cimport RingElement -cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision) +cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision) noexcept cdef int arb_to_mpfi(mpfi_t target, arb_t source, const long precision) except -1 cdef class RealBall(RingElement): cdef arb_t value - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef RealIntervalFieldElement _real_mpfi_(self, RealIntervalField_class parent) - cpdef RealBall psi(self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef RealIntervalFieldElement _real_mpfi_(self, RealIntervalField_class parent) noexcept + cpdef RealBall psi(self) noexcept - cdef inline RealBall _new(self): + cdef inline RealBall _new(self) noexcept: cdef RealBall res = RealBall.__new__(RealBall) res._parent = self._parent return res diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 17859068273..a9ce06d14ca 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -236,7 +236,7 @@ from sage.rings.real_mpfi import RealIntervalField, RealIntervalField_class from sage.structure.unique_representation import UniqueRepresentation from sage.cpython.string cimport char_to_str, str_to_bytes -cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision): +cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision) noexcept: r""" Convert an MPFI interval to an Arb ball. @@ -1145,7 +1145,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): """ return ARF_PREC_EXACT -cdef inline bint _do_sig(long prec): +cdef inline bint _do_sig(long prec) noexcept: """ Whether signal handlers should be installed for calls to arb. @@ -1156,7 +1156,7 @@ cdef inline bint _do_sig(long prec): """ return (prec > 1000) -cdef inline long prec(RealBall ball): +cdef inline long prec(RealBall ball) noexcept: return ball._parent._prec def create_RealBall(parent, serialized): @@ -1553,7 +1553,7 @@ cdef class RealBall(RingElement): # Conversions - cpdef RealIntervalFieldElement _real_mpfi_(self, RealIntervalField_class parent): + cpdef RealIntervalFieldElement _real_mpfi_(self, RealIntervalField_class parent) noexcept: """ Return a :mod:`real interval ` containing this ball. @@ -2255,7 +2255,7 @@ cdef class RealBall(RingElement): """ return arb_is_exact(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare ``left`` and ``right``. @@ -2797,7 +2797,7 @@ cdef class RealBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Return the sum of two balls, rounded to the ambient field's precision. @@ -2815,7 +2815,7 @@ cdef class RealBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ Return the difference of two balls, rounded to the ambient field's precision. @@ -2834,7 +2834,7 @@ cdef class RealBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Return the product of two balls, rounded to the ambient field's precision. @@ -2853,7 +2853,7 @@ cdef class RealBall(RingElement): if _do_sig(prec(self)): sig_off() return res - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Return the quotient of two balls, rounded to the ambient field's precision. @@ -3850,7 +3850,7 @@ cdef class RealBall(RingElement): if _do_sig(prec(self)): sig_off() return result - cpdef RealBall psi(self): + cpdef RealBall psi(self) noexcept: """ Compute the digamma function with argument self. diff --git a/src/sage/rings/real_double.pxd b/src/sage/rings/real_double.pxd index 06d4121ef26..e2c657faec2 100644 --- a/src/sage/rings/real_double.pxd +++ b/src/sage/rings/real_double.pxd @@ -3,13 +3,13 @@ from sage.rings.ring cimport Field cimport sage.rings.abc cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): - cdef _new_c(self, double value) + cdef _new_c(self, double value) noexcept cdef class RealDoubleElement(FieldElement): cdef double _value - cdef _new_c(self, double value) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef RealDoubleElement abs(RealDoubleElement self) + cdef _new_c(self, double value) noexcept + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef RealDoubleElement abs(RealDoubleElement self) noexcept -cdef double_repr(double x) +cdef double_repr(double x) noexcept diff --git a/src/sage/rings/real_double.pyx b/src/sage/rings/real_double.pyx index dea1633dd15..f1e5eb0a2c8 100644 --- a/src/sage/rings/real_double.pyx +++ b/src/sage/rings/real_double.pyx @@ -277,7 +277,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): from sage.rings.complex_double import CDF return CDF - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Canonical coercion of ``S`` to the real double field. @@ -472,7 +472,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): """ return Integer(0) - cdef _new_c(self, double value): + cdef _new_c(self, double value) noexcept: cdef RealDoubleElement x x = PY_NEW(RealDoubleElement) x._value = value @@ -740,7 +740,7 @@ cdef class RealDoubleElement(FieldElement): """ return RealDoubleElement, (self._value, ) - cdef _new_c(self, double value): + cdef _new_c(self, double value) noexcept: cdef RealDoubleElement x x = PY_NEW(RealDoubleElement) x._value = value @@ -1309,7 +1309,7 @@ cdef class RealDoubleElement(FieldElement): x._value = 1.0 / self._value return x - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ Add two real numbers with the same parent. @@ -1322,7 +1322,7 @@ cdef class RealDoubleElement(FieldElement): x._value = self._value + (right)._value return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two real numbers with the same parent. @@ -1335,7 +1335,7 @@ cdef class RealDoubleElement(FieldElement): x._value = self._value - (right)._value return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two real numbers with the same parent. @@ -1348,7 +1348,7 @@ cdef class RealDoubleElement(FieldElement): x._value = self._value * (right)._value return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by ``right``. @@ -1409,7 +1409,7 @@ cdef class RealDoubleElement(FieldElement): else: return self._new_c(-self._value) - cpdef RealDoubleElement abs(RealDoubleElement self): + cpdef RealDoubleElement abs(RealDoubleElement self) noexcept: """ Returns the absolute value of ``self``. @@ -1740,7 +1740,7 @@ cdef class RealDoubleElement(FieldElement): """ return bool(libc.math.isinf(self._value)) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Rich comparison of ``left`` and ``right``. @@ -1998,7 +1998,7 @@ cdef class ToRDF(Morphism): R = Set_PythonType(R) Morphism.__init__(self, Hom(R, RDF)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Send ``x`` to the image under this map. @@ -2093,7 +2093,7 @@ cdef int total_alloc = 0 cdef int use_pool = 0 -cdef PyObject* fast_tp_new(type t, args, kwds): +cdef PyObject* fast_tp_new(type t, args, kwds) noexcept: global element_pool, element_pool_count, total_alloc, use_pool cdef PyObject* new @@ -2151,7 +2151,7 @@ cdef PyObject* fast_tp_new(type t, args, kwds): return new -cdef void fast_tp_dealloc(PyObject* o): +cdef void fast_tp_dealloc(PyObject* o) noexcept: # If there is room in the pool for a used integer object, # then put it in rather than deallocating it. @@ -2185,7 +2185,7 @@ else: # From here on, calling PY_NEW(RealDoubleElement) actually creates an instance of RealDoubleElement_gsl -cdef double_repr(double x): +cdef double_repr(double x) noexcept: """ Convert a double to a string with maximum precision. """ diff --git a/src/sage/rings/real_double_element_gsl.pxd b/src/sage/rings/real_double_element_gsl.pxd index 4ddc886cdf1..39c36999ec4 100644 --- a/src/sage/rings/real_double_element_gsl.pxd +++ b/src/sage/rings/real_double_element_gsl.pxd @@ -2,6 +2,6 @@ from .real_double cimport RealDoubleElement cdef class RealDoubleElement_gsl(RealDoubleElement): - cdef __pow_double(self, double exponent, double sign) - cpdef _pow_(self, other) - cdef _log_base(self, double log_of_base) + cdef __pow_double(self, double exponent, double sign) noexcept + cpdef _pow_(self, other) noexcept + cdef _log_base(self, double log_of_base) noexcept diff --git a/src/sage/rings/real_double_element_gsl.pyx b/src/sage/rings/real_double_element_gsl.pyx index 8b6b3671605..3ebb703b367 100644 --- a/src/sage/rings/real_double_element_gsl.pyx +++ b/src/sage/rings/real_double_element_gsl.pyx @@ -57,7 +57,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): else: return self ** (float(1)/n) - cdef __pow_double(self, double exponent, double sign): + cdef __pow_double(self, double exponent, double sign) noexcept: """ If ``sign == 1`` or ``self >= 0``, return ``self ^ exponent``. If ``sign == -1`` and ``self < 0``, return ``- abs(self) ^ exponent``. @@ -84,7 +84,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): v = -v return self._new_c(sign * gsl_sf_exp(gsl_sf_log(v) * exponent)) - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: """ Return ``self`` raised to the real double power ``other``. @@ -117,7 +117,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): """ return self.__pow_double((other)._value, 1) - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ Return ``self`` raised to the integer power ``n``. @@ -174,7 +174,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): """ return self.__pow_double(n, -1.0 if (n & 1) else 1.0) - cdef _pow_long(self, long n): + cdef _pow_long(self, long n) noexcept: """ Compute ``self`` raised to the power ``n``. @@ -214,7 +214,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): # of n to double might change an odd number to an even number. return self.__pow_double(n, -1.0 if (n & 1) else 1.0) - cdef _log_base(self, double log_of_base): + cdef _log_base(self, double log_of_base) noexcept: if self._value == 0: from .real_double import RDF return RDF(-1)/RDF(0) diff --git a/src/sage/rings/real_interval_absolute.pyx b/src/sage/rings/real_interval_absolute.pyx index 5caf4ac40f1..aab89c97d0e 100644 --- a/src/sage/rings/real_interval_absolute.pyx +++ b/src/sage/rings/real_interval_absolute.pyx @@ -23,7 +23,7 @@ from sage.rings.rational_field import QQ cdef Integer zero = Integer(0) cdef Integer one = Integer(1) -cpdef inline Integer shift_floor(Integer x, long shift): +cpdef inline Integer shift_floor(Integer x, long shift) noexcept: r""" Return `x / 2^s` where `s` is the value of ``shift``, rounded towards `-\infty`. For internal use. @@ -40,7 +40,7 @@ cpdef inline Integer shift_floor(Integer x, long shift): mpz_fdiv_q_2exp(z.value, x.value, shift) return z -cpdef inline Integer shift_ceil(Integer x, long shift): +cpdef inline Integer shift_ceil(Integer x, long shift) noexcept: r""" Return `x / 2^s` where `s` is the value of ``shift``, rounded towards `+\infty`. For internal use. @@ -161,7 +161,7 @@ cdef class RealIntervalAbsoluteField_class(Field): """ return RealIntervalAbsoluteElement(self, x) - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: """ Anything that coerces into the reals coerces into this ring. @@ -223,7 +223,7 @@ cdef class RealIntervalAbsoluteField_class(Field): return self._absprec -cdef inline shift_left(value, shift): +cdef inline shift_left(value, shift) noexcept: """ Utility function for operands that don't support the ``<<`` operator. """ @@ -319,7 +319,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return RealIntervalAbsoluteElement, (self._parent, self.endpoints()) - cdef _new_c(self, Integer _mantissa, Integer _diameter): + cdef _new_c(self, Integer _mantissa, Integer _diameter) noexcept: cdef RealIntervalAbsoluteElement x x = RealIntervalAbsoluteElement.__new__(RealIntervalAbsoluteElement) x._parent = self._parent @@ -327,7 +327,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): x._diameter = _diameter return x - cpdef lower(self): + cpdef lower(self) noexcept: """ Return the lower bound of ``self``. @@ -340,7 +340,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return QQ(self._mantissa) >> (self._parent)._absprec - cpdef midpoint(self): + cpdef midpoint(self) noexcept: """ Return the midpoint of ``self``. @@ -357,7 +357,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return (self._mantissa + self._diameter / 2) >> (self._parent)._absprec - cpdef upper(self): + cpdef upper(self) noexcept: """ Return the upper bound of ``self``. @@ -370,7 +370,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return QQ(self._mantissa + self._diameter) >> (self._parent)._absprec - cpdef absolute_diameter(self): + cpdef absolute_diameter(self) noexcept: """ Return the diameter ``self``. @@ -390,7 +390,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): diameter = absolute_diameter - cpdef endpoints(self): + cpdef endpoints(self) noexcept: """ Return the left and right endpoints of ``self``, as a tuple. @@ -422,7 +422,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return R(self._mantissa, self._mantissa+self._diameter) >> (self._parent)._absprec - cpdef long mpfi_prec(self): + cpdef long mpfi_prec(self) noexcept: """ Return the precision needed to represent this value as an mpfi interval. @@ -495,7 +495,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): x *= (one << self._parent.absprec()) return self._mantissa <= x <= self._mantissa + self._diameter - cpdef bint is_positive(self): + cpdef bint is_positive(self) noexcept: """ Return whether ``self`` is definitely positive. @@ -518,7 +518,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return mpz_sgn(self._mantissa.value) == 1 - cpdef bint contains_zero(self): + cpdef bint contains_zero(self) noexcept: """ Return whether ``self`` contains zero. @@ -544,7 +544,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): return (mpz_sgn(self._mantissa.value) == 0 or (mpz_sgn(self._mantissa.value) == -1 and mpz_cmpabs(self._mantissa.value, self._diameter.value) <= 0)) - cpdef bint is_negative(self): + cpdef bint is_negative(self) noexcept: """ Return whether ``self`` is definitely negative. @@ -568,7 +568,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): return (mpz_sgn(self._mantissa.value) == -1 and mpz_cmpabs(self._mantissa.value, self._diameter.value) > 0) - cdef bint is_exact(self): + cdef bint is_exact(self) noexcept: return not self._diameter def __bool__(self): @@ -612,7 +612,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return self.abs() - cpdef abs(self): + cpdef abs(self) noexcept: """ Return the absolute value of ``self``. @@ -638,7 +638,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): else: return self._new_c(zero, max(-self._mantissa, self._mantissa + self._diameter)) - cpdef _add_(self, _other): + cpdef _add_(self, _other) noexcept: """ TESTS:: @@ -656,7 +656,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): cdef RealIntervalAbsoluteElement other = _other return self._new_c(self._mantissa + other._mantissa, self._diameter + other._diameter) - cpdef _sub_(self, _other): + cpdef _sub_(self, _other) noexcept: """ TESTS:: @@ -676,7 +676,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): cdef RealIntervalAbsoluteElement other = _other return self._new_c(self._mantissa - other._mantissa - other._diameter, self._diameter + other._diameter) - cpdef _mul_(self, _other): + cpdef _mul_(self, _other) noexcept: """ TESTS:: @@ -731,7 +731,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): res = -res return res - cpdef _acted_upon_(self, x, bint self_on_left): + cpdef _acted_upon_(self, x, bint self_on_left) noexcept: """ ``Absprec * relprec -> absprec`` works better than coercing both operands to absolute precision first. @@ -836,7 +836,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): res = -res return res - cpdef _div_(self, _other): + cpdef _div_(self, _other) noexcept: """ TESTS:: @@ -920,7 +920,7 @@ cdef class RealIntervalAbsoluteElement(FieldElement): """ return self.shift(-n) - cdef shift(self, long n): + cdef shift(self, long n) noexcept: if n >= 0: return self._new_c(self._mantissa << n, self._diameter << n) else: diff --git a/src/sage/rings/real_lazy.pxd b/src/sage/rings/real_lazy.pxd index 4110a83ae36..5619e492e9e 100644 --- a/src/sage/rings/real_lazy.pxd +++ b/src/sage/rings/real_lazy.pxd @@ -2,16 +2,16 @@ from sage.rings.ring cimport Field from sage.structure.element cimport RingElement, ModuleElement, Element, FieldElement cdef class LazyField(Field): - cpdef interval_field(self, prec=*) + cpdef interval_field(self, prec=*) noexcept cdef class LazyFieldElement(FieldElement): - cpdef _add_(self, other) - cpdef _mul_(self, other) - cdef LazyFieldElement _new_wrapper(self, value) - cdef LazyFieldElement _new_binop(self, LazyFieldElement left, LazyFieldElement right, op) - cdef LazyFieldElement _new_unop(self, LazyFieldElement arg, op) - cpdef eval(self, R) - cpdef int depth(self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cdef LazyFieldElement _new_wrapper(self, value) noexcept + cdef LazyFieldElement _new_binop(self, LazyFieldElement left, LazyFieldElement right, op) noexcept + cdef LazyFieldElement _new_unop(self, LazyFieldElement arg, op) noexcept + cpdef eval(self, R) noexcept + cpdef int depth(self) noexcept cdef class LazyWrapper(LazyFieldElement): cdef readonly _value diff --git a/src/sage/rings/real_lazy.pyx b/src/sage/rings/real_lazy.pyx index fb96ae89407..54a84e4920a 100644 --- a/src/sage/rings/real_lazy.pyx +++ b/src/sage/rings/real_lazy.pyx @@ -55,7 +55,7 @@ from sage.rings.cc import CC cdef _QQx = None -cdef QQx(): +cdef QQx() noexcept: global _QQx if _QQx is None: _QQx = QQ['x'] @@ -126,7 +126,7 @@ cdef class LazyField(Field): else: raise AttributeError(name) - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: r""" The only things that coerce into this ring are exact rings that embed into `\RR` or `\CC` (depending on whether this field @@ -198,7 +198,7 @@ cdef class LazyField(Field): """ return CLF - cpdef interval_field(self, prec=None): + cpdef interval_field(self, prec=None) noexcept: """ Abstract method to create the corresponding interval field. @@ -533,7 +533,7 @@ cdef int get_new_prec(R, int depth) except -1: cdef class LazyFieldElement(FieldElement): - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add ``left`` with ``right``. @@ -549,7 +549,7 @@ cdef class LazyFieldElement(FieldElement): pass return left._new_binop(left, right, add) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ Subtract ``right`` from ``left``. @@ -565,7 +565,7 @@ cdef class LazyFieldElement(FieldElement): pass return left._new_binop(left, right, sub) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply ``left`` with ``right``. @@ -581,7 +581,7 @@ cdef class LazyFieldElement(FieldElement): pass return left._new_binop(left, right, mul) - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ Divide ``left`` by ``right``. @@ -645,7 +645,7 @@ cdef class LazyFieldElement(FieldElement): """ return self._new_unop(self, inv) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ If things are being wrapped, tries to compare values. That failing, it tries to compare intervals, which may return a false negative. @@ -699,13 +699,13 @@ cdef class LazyFieldElement(FieldElement): """ return hash(complex(self)) - cdef LazyFieldElement _new_wrapper(self, value): + cdef LazyFieldElement _new_wrapper(self, value) noexcept: cdef LazyWrapper e = LazyWrapper.__new__(LazyWrapper) e._parent = self._parent e._value = value return e - cdef LazyFieldElement _new_binop(self, LazyFieldElement left, LazyFieldElement right, op): + cdef LazyFieldElement _new_binop(self, LazyFieldElement left, LazyFieldElement right, op) noexcept: cdef LazyBinop e = LazyBinop.__new__(LazyBinop) e._parent = self._parent e._left = left @@ -713,7 +713,7 @@ cdef class LazyFieldElement(FieldElement): e._op = op return e - cdef LazyFieldElement _new_unop(self, LazyFieldElement arg, op): + cdef LazyFieldElement _new_unop(self, LazyFieldElement arg, op) noexcept: cdef LazyUnop e = LazyUnop.__new__(LazyUnop) e._parent = self._parent e._op = op @@ -817,7 +817,7 @@ cdef class LazyFieldElement(FieldElement): from .complex_mpfr import ComplexField return complex(self.eval(ComplexField(53))) - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Abstract method for converting ``self`` into an element of ``R``. @@ -829,7 +829,7 @@ cdef class LazyFieldElement(FieldElement): """ raise NotImplementedError("Subclasses must override this method.") - cpdef int depth(self): + cpdef int depth(self) noexcept: """ Abstract method for returning the depth of ``self`` as an arithmetic expression. @@ -912,7 +912,7 @@ def make_element(parent, *args): cdef class LazyWrapper(LazyFieldElement): - cpdef int depth(self): + cpdef int depth(self) noexcept: """ Returns the depth of ``self`` as an expression, which is always 0. @@ -1005,7 +1005,7 @@ cdef class LazyWrapper(LazyFieldElement): """ return hash(self._value) - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert ``self`` into an element of ``R``. @@ -1079,7 +1079,7 @@ cdef class LazyBinop(LazyFieldElement): self._right = right self._op = op - cpdef int depth(self): + cpdef int depth(self) noexcept: """ Return the depth of ``self`` as an arithmetic expression. @@ -1103,7 +1103,7 @@ cdef class LazyBinop(LazyFieldElement): cdef int right = self._right.depth() return 1 + (left if left > right else right) - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert the operands to elements of ``R``, then perform the operation on them. @@ -1217,7 +1217,7 @@ cdef class LazyUnop(LazyFieldElement): self._op = op self._arg = arg - cpdef int depth(self): + cpdef int depth(self) noexcept: """ Return the depth of ``self`` as an arithmetic expression. @@ -1239,7 +1239,7 @@ cdef class LazyUnop(LazyFieldElement): """ return 1 + self._arg.depth() - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert ``self`` into an element of ``R``. @@ -1318,7 +1318,7 @@ cdef class LazyNamedUnop(LazyUnop): raise TypeError("extra args must be a tuple") self._extra_args = extra_args - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert ``self`` into an element of ``R``. @@ -1461,7 +1461,7 @@ cdef class LazyConstant(LazyFieldElement): self._name = name self._extra_args = extra_args - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert ``self`` into an element of ``R``. @@ -1616,7 +1616,7 @@ cdef class LazyAlgebraic(LazyFieldElement): approx = (CC if prec == 0 else ComplexField(prec))(approx) self._root_approx = approx - cpdef eval(self, R): + cpdef eval(self, R) noexcept: """ Convert ``self`` into an element of ``R``. @@ -1723,7 +1723,7 @@ cdef class LazyWrapperMorphism(Morphism): from sage.categories.homset import Hom Morphism.__init__(self, Hom(domain, codomain)) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: diff --git a/src/sage/rings/real_mpfi.pxd b/src/sage/rings/real_mpfi.pxd index 4201788d198..32332d81e3e 100644 --- a/src/sage/rings/real_mpfi.pxd +++ b/src/sage/rings/real_mpfi.pxd @@ -32,7 +32,7 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): cdef RealField_class __upper_field cdef object _multiplicative_order - cdef inline RealIntervalFieldElement _new(self): + cdef inline RealIntervalFieldElement _new(self) noexcept: """Return a new real interval with parent ``self``.""" t = self.element_class return (t.__new__(t, self)) @@ -41,9 +41,9 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): cdef class RealIntervalFieldElement(RingElement): cdef mpfi_t value - cdef inline RealIntervalFieldElement _new(self): + cdef inline RealIntervalFieldElement _new(self) noexcept: """Return a new real interval with same parent as ``self``.""" return (self._parent)._new() - cdef RealIntervalFieldElement abs(RealIntervalFieldElement self) - cdef Rational _simplest_rational_helper(self) - cpdef _str_question_style(self, int base, int error_digits, e, bint prefer_sci) + cdef RealIntervalFieldElement abs(RealIntervalFieldElement self) noexcept + cdef Rational _simplest_rational_helper(self) noexcept + cpdef _str_question_style(self, int base, int error_digits, e, bint prefer_sci) noexcept diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index 461b87db869..6e389b53ac2 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -303,7 +303,7 @@ printing_error_digits = 0 #***************************************************************************** cdef dict RealIntervalField_cache = {} -cpdef RealIntervalField_class RealIntervalField(prec=53, sci_not=False): +cpdef RealIntervalField_class RealIntervalField(prec=53, sci_not=False) noexcept: r""" Construct a :class:`RealIntervalField_class`, with caching. @@ -747,7 +747,7 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): {'sci_not': self.scientific_notation(), 'type': 'Interval'}), sage.rings.rational_field.QQ) - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Canonical coercion from ``S`` to this real interval field. @@ -1692,7 +1692,7 @@ cdef class RealIntervalFieldElement(RingElement): else: raise ValueError('Illegal interval printing style %s' % printing_style) - cpdef _str_question_style(self, int base, int error_digits, e, bint prefer_sci): + cpdef _str_question_style(self, int base, int error_digits, e, bint prefer_sci) noexcept: r""" Compute the "question-style print representation" of this value, with the given base and error_digits. See the documentation for @@ -2683,7 +2683,7 @@ cdef class RealIntervalFieldElement(RingElement): else: return Element.__rtruediv__(right, left) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Add two real intervals with the same parent. @@ -2727,7 +2727,7 @@ cdef class RealIntervalFieldElement(RingElement): mpfi_inv(x.value, self.value) return x - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two real intervals with the same parent. @@ -2745,7 +2745,7 @@ cdef class RealIntervalFieldElement(RingElement): mpfi_sub(x.value, self.value, (right).value) return x - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two real intervals with the same parent. @@ -2782,7 +2782,7 @@ cdef class RealIntervalFieldElement(RingElement): return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by ``right``, where both are real intervals with the same parent. @@ -2809,7 +2809,7 @@ cdef class RealIntervalFieldElement(RingElement): (right).value) return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the additive "inverse" of this interval. (Technically, non-precise intervals don't have additive inverses.) @@ -2848,7 +2848,7 @@ cdef class RealIntervalFieldElement(RingElement): """ return self.abs() - cdef RealIntervalFieldElement abs(self): + cdef RealIntervalFieldElement abs(self) noexcept: """ Return the absolute value of ``self``. @@ -3653,7 +3653,7 @@ cdef class RealIntervalFieldElement(RingElement): low_open, high_open) - cdef Rational _simplest_rational_helper(self): + cdef Rational _simplest_rational_helper(self) noexcept: """ Returns the simplest rational in an interval which is either equal to or slightly larger than ``self``. We assume that both endpoints of @@ -3693,7 +3693,7 @@ cdef class RealIntervalFieldElement(RingElement): """ return mpfi_nan_p(self.value) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Implement comparisons between intervals. @@ -5186,7 +5186,7 @@ def _simplest_rational_test_helper(low, high, low_open=False, high_open=False): """ return _simplest_rational_exact(low, high, low_open, high_open) -cdef _simplest_rational_exact(Rational low, Rational high, int low_open, int high_open): +cdef _simplest_rational_exact(Rational low, Rational high, int low_open, int high_open) noexcept: """ Return the simplest rational between ``low`` and ``high``. May return ``low`` or ``high`` unless ``low_open`` or ``high_open`` (respectively) are diff --git a/src/sage/rings/real_mpfr.pxd b/src/sage/rings/real_mpfr.pxd index dd18e87715b..5d44208f339 100644 --- a/src/sage/rings/real_mpfr.pxd +++ b/src/sage/rings/real_mpfr.pxd @@ -13,20 +13,20 @@ cdef class RealField_class(sage.rings.abc.RealField): cdef bint sci_not cdef mpfr_rnd_t rnd cdef object rnd_str - cdef inline RealNumber _new(self): + cdef inline RealNumber _new(self) noexcept: """Return a new real number with parent ``self``.""" return (RealNumber.__new__(RealNumber, self)) cdef class RealNumber(sage.structure.element.RingElement): cdef mpfr_t value - cdef inline RealNumber _new(self): + cdef inline RealNumber _new(self) noexcept: """Return a new real number with same parent as ``self``.""" return (RealNumber.__new__(RealNumber, self._parent)) - cpdef _add_(self, other) - cpdef _mul_(self, other) - cpdef _mod_(self, right) - cdef _set(self, x, int base) - cdef _set_from_GEN_REAL(self, GEN g) - cdef RealNumber abs(RealNumber self) + cpdef _add_(self, other) noexcept + cpdef _mul_(self, other) noexcept + cpdef _mod_(self, right) noexcept + cdef _set(self, x, int base) noexcept + cdef _set_from_GEN_REAL(self, GEN g) noexcept + cdef RealNumber abs(RealNumber self) noexcept -cpdef RealField(mpfr_prec_t prec=*, int sci_not=*, rnd=*) +cpdef RealField(mpfr_prec_t prec=*, int sci_not=*, rnd=*) noexcept diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index fb2eb1d718c..4a091fd9191 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -373,7 +373,7 @@ cdef double LOG_TEN_TWO_PLUS_EPSILON = 3.321928094887363 # a small overestimate cdef object RealField_cache = sage.misc.weak_dict.WeakValueDictionary() -cpdef RealField(mpfr_prec_t prec=53, int sci_not=0, rnd=MPFR_RNDN): +cpdef RealField(mpfr_prec_t prec=53, int sci_not=0, rnd=MPFR_RNDN) noexcept: """ RealField(prec, sci_not, rnd): @@ -666,7 +666,7 @@ cdef class RealField_class(sage.rings.abc.RealField): z._set(x, base) return z - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Canonical coercion of x to this MPFR real field. @@ -1452,7 +1452,7 @@ cdef class RealNumber(sage.structure.element.RingElement): else: return numpy_object_interface - cdef _set(self, x, int base): + cdef _set(self, x, int base) noexcept: # This should not be called except when the number is being created. # Real Numbers are supposed to be immutable. cdef RealField_class parent @@ -1504,7 +1504,7 @@ cdef class RealNumber(sage.structure.element.RingElement): else: raise TypeError("unable to convert {!r} to a real number".format(s)) - cdef _set_from_GEN_REAL(self, GEN g): + cdef _set_from_GEN_REAL(self, GEN g) noexcept: """ EXAMPLES:: @@ -2471,7 +2471,7 @@ cdef class RealNumber(sage.structure.element.RingElement): else: return Element.__rtruediv__(right, left) - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Add two real numbers with the same parent. @@ -2500,7 +2500,7 @@ cdef class RealNumber(sage.structure.element.RingElement): """ return self._parent(1) / self - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ Subtract two real numbers with the same parent. @@ -2541,7 +2541,7 @@ cdef class RealNumber(sage.structure.element.RingElement): import sympy return sympy.Float(self, precision=self._parent.precision()) - cpdef _mul_(self, right): + cpdef _mul_(self, right) noexcept: """ Multiply two real numbers with the same parent. @@ -2574,7 +2574,7 @@ cdef class RealNumber(sage.structure.element.RingElement): return x - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Divide ``self`` by other, where both are real numbers with the same parent. @@ -2594,7 +2594,7 @@ cdef class RealNumber(sage.structure.element.RingElement): (right).value, (self._parent).rnd) return x - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Return the negative of ``self``. @@ -2628,7 +2628,7 @@ cdef class RealNumber(sage.structure.element.RingElement): """ return self.abs() - cdef RealNumber abs(RealNumber self): + cdef RealNumber abs(RealNumber self) noexcept: """ Return the absolute value of ``self``. @@ -2981,7 +2981,7 @@ cdef class RealNumber(sage.structure.element.RingElement): # Rounding etc ################### - cpdef _mod_(left, right): + cpdef _mod_(left, right) noexcept: """ Return the value of ``left - n*right``, rounded according to the rounding mode of the parent, where ``n`` is the integer quotient of @@ -4147,7 +4147,7 @@ cdef class RealNumber(sage.structure.element.RingElement): """ return not mpfr_zero_p(self.value) - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: """ Compare ``self`` and ``other`` according to the rich comparison operator ``op``. @@ -5955,7 +5955,7 @@ def __create__RealNumber_version0(parent, x, base=10): cdef class RRtoRR(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -6004,7 +6004,7 @@ cdef class RRtoRR(Map): return RRtoRR(self._codomain, self.domain()) cdef class ZZtoRR(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -6019,7 +6019,7 @@ cdef class ZZtoRR(Map): return y cdef class QQtoRR(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -6034,7 +6034,7 @@ cdef class QQtoRR(Map): return y cdef class double_toRR(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Takes anything that can be converted to a double. @@ -6054,7 +6054,7 @@ cdef class double_toRR(Map): return y cdef class int_toRR(Map): - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Takes Python int/long instances. diff --git a/src/sage/rings/ring_extension.pxd b/src/sage/rings/ring_extension.pxd index 9115f8d26f8..995bb23a976 100644 --- a/src/sage/rings/ring_extension.pxd +++ b/src/sage/rings/ring_extension.pxd @@ -14,12 +14,12 @@ cdef class RingExtension_generic(CommutativeAlgebra): cdef RingExtension_generic _fraction_field cdef type _fraction_field_type - cpdef is_defined_over(self, base) - cpdef CommutativeRing _check_base(self, CommutativeRing base) - cpdef _degree_over(self, CommutativeRing base) - cpdef _is_finite_over(self, CommutativeRing base) - cpdef _is_free_over(self, CommutativeRing base) - cdef Map _defining_morphism_fraction_field(self, bint extend_base) + cpdef is_defined_over(self, base) noexcept + cpdef CommutativeRing _check_base(self, CommutativeRing base) noexcept + cpdef _degree_over(self, CommutativeRing base) noexcept + cpdef _is_finite_over(self, CommutativeRing base) noexcept + cpdef _is_free_over(self, CommutativeRing base) noexcept + cdef Map _defining_morphism_fraction_field(self, bint extend_base) noexcept cdef class RingExtensionFractionField(RingExtension_generic): @@ -31,7 +31,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): cdef _basis_names cdef _basis_latex_names - cpdef _basis_over(self, CommutativeRing base) + cpdef _basis_over(self, CommutativeRing base) noexcept # cpdef _free_module(self, CommutativeRing base, bint map) diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index d9438aaa648..0388689a3e2 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1007,7 +1007,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): raise RuntimeError("backend is not exposed to the user; cannot print") return latex(self._backend) - cpdef _coerce_map_from_(self, other): + cpdef _coerce_map_from_(self, other) noexcept: r""" Return a coerce map from this extension to ``other`` if defined. @@ -1168,7 +1168,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): """ return self.bases()[-1] - cpdef is_defined_over(self, base): + cpdef is_defined_over(self, base) noexcept: r""" Return whether or not ``base`` is one of the bases of this extension. @@ -1216,7 +1216,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): b = (b)._base return b is base - cpdef CommutativeRing _check_base(self, CommutativeRing base): + cpdef CommutativeRing _check_base(self, CommutativeRing base) noexcept: r""" Check if ``base`` is one of the successive bases of this extension and, if it is, normalize it. @@ -1463,7 +1463,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): base = self._check_base(base) return self._degree_over(base) - cpdef _degree_over(self, CommutativeRing base): + cpdef _degree_over(self, CommutativeRing base) noexcept: r""" Return the degree of this extension over ``base``. @@ -1603,7 +1603,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): b = (b)._base raise NotImplementedError - cpdef _is_finite_over(self, CommutativeRing base): + cpdef _is_finite_over(self, CommutativeRing base) noexcept: r""" Return whether or not this extension is finite over ``base``. @@ -1666,7 +1666,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): b = (b)._base raise NotImplementedError - cpdef _is_free_over(self, CommutativeRing base): + cpdef _is_free_over(self, CommutativeRing base) noexcept: r""" Return whether or not this extension is finite over ``base``. @@ -1782,7 +1782,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): constructor = RingExtensionFractionField, {'ring': self, 'is_backend_exposed': self._is_backend_exposed} return RingExtension(ring, defining_morphism, constructors=[constructor]) - cdef Map _defining_morphism_fraction_field(self, bint extend_base): + cdef Map _defining_morphism_fraction_field(self, bint extend_base) noexcept: r""" Return the defining morphism of the fraction field of this extension. @@ -2207,7 +2207,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): b = b.base_ring() return base - cpdef _degree_over(self, CommutativeRing base): + cpdef _degree_over(self, CommutativeRing base) noexcept: r""" Return the degree of this extension over ``base``. @@ -2234,7 +2234,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): else: return len(self._basis) * self._base._degree_over(base) - cpdef _is_finite_over(self, CommutativeRing base): + cpdef _is_finite_over(self, CommutativeRing base) noexcept: r""" Return whether or not this extension is finite over ``base``. @@ -2253,7 +2253,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): return True return self._base._is_finite_over(base) - cpdef _is_free_over(self, CommutativeRing base): + cpdef _is_free_over(self, CommutativeRing base) noexcept: r""" Return whether or not this extension is free over ``base``. @@ -2314,7 +2314,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): base = self._check_base(base) return self._basis_over(base) - cpdef _basis_over(self, CommutativeRing base): + cpdef _basis_over(self, CommutativeRing base) noexcept: r""" Return a basis of this extension over ``base``. diff --git a/src/sage/rings/ring_extension_conversion.pxd b/src/sage/rings/ring_extension_conversion.pxd index e3815a411ba..74e09e4f356 100644 --- a/src/sage/rings/ring_extension_conversion.pxd +++ b/src/sage/rings/ring_extension_conversion.pxd @@ -1,17 +1,17 @@ from sage.rings.ring_extension cimport RingExtension_generic -cpdef backend_parent(R) -cpdef from_backend_parent(R, RingExtension_generic E) +cpdef backend_parent(R) noexcept +cpdef from_backend_parent(R, RingExtension_generic E) noexcept -cpdef backend_element(x) -cpdef from_backend_element(x, RingExtension_generic E) +cpdef backend_element(x) noexcept +cpdef from_backend_element(x, RingExtension_generic E) noexcept -cdef _backend_morphism(f) -cpdef backend_morphism(f, forget=*) -cpdef from_backend_morphism(f, RingExtension_generic E) +cdef _backend_morphism(f) noexcept +cpdef backend_morphism(f, forget=*) noexcept +cpdef from_backend_morphism(f, RingExtension_generic E) noexcept -cpdef to_backend(arg) -cpdef from_backend(arg, E) +cpdef to_backend(arg) noexcept +cpdef from_backend(arg, E) noexcept diff --git a/src/sage/rings/ring_extension_conversion.pyx b/src/sage/rings/ring_extension_conversion.pyx index eeb6077cd0a..597320e8af8 100644 --- a/src/sage/rings/ring_extension_conversion.pyx +++ b/src/sage/rings/ring_extension_conversion.pyx @@ -26,7 +26,7 @@ from sage.rings.ring_extension_morphism cimport RingExtensionBackendReverseIsomo # For parents ############# -cpdef backend_parent(R): +cpdef backend_parent(R) noexcept: r""" Return the backend parent of ``R``. @@ -49,7 +49,7 @@ cpdef backend_parent(R): else: return R -cpdef from_backend_parent(R, RingExtension_generic E): +cpdef from_backend_parent(R, RingExtension_generic E) noexcept: r""" Try to reconstruct a ring extension (somehow related to ``E``) whose backend is ``R``. @@ -107,7 +107,7 @@ cpdef from_backend_parent(R, RingExtension_generic E): # For elements ############## -cpdef backend_element(x): +cpdef backend_element(x) noexcept: r""" Return the backend element of ``x``. @@ -130,7 +130,7 @@ cpdef backend_element(x): else: return x -cpdef from_backend_element(x, RingExtension_generic E): +cpdef from_backend_element(x, RingExtension_generic E) noexcept: r""" Try to reconstruct an element in a ring extension (somehow related to ``E``) whose backend is ``x``. @@ -181,7 +181,7 @@ cpdef from_backend_element(x, RingExtension_generic E): # For morphisms ############### -cdef _backend_morphism(f): +cdef _backend_morphism(f) noexcept: r""" Return the backend morphism of ``f``. @@ -243,7 +243,7 @@ cdef _backend_morphism(f): return ring.coerce_map_from(domain) raise NotImplementedError -cpdef backend_morphism(f, forget="all"): +cpdef backend_morphism(f, forget="all") noexcept: r""" Return the backend morphism of ``f``. @@ -299,7 +299,7 @@ cpdef backend_morphism(f, forget="all"): g = RingExtensionBackendReverseIsomorphism(f.codomain().Hom(ring)) * g return g -cpdef from_backend_morphism(f, RingExtension_generic E): +cpdef from_backend_morphism(f, RingExtension_generic E) noexcept: r""" Try to reconstruct a morphism between ring extensions (somehow related to ``E``) whose backend is ``f``. @@ -336,7 +336,7 @@ cpdef from_backend_morphism(f, RingExtension_generic E): # Generic ######### -cpdef to_backend(arg): +cpdef to_backend(arg) noexcept: r""" Return the backend of ``arg``. @@ -392,7 +392,7 @@ cpdef to_backend(arg): return (arg)._backend return arg -cpdef from_backend(arg, E): +cpdef from_backend(arg, E) noexcept: r""" Try to reconstruct something (somehow related to ``E``) whose backend is ``arg``. diff --git a/src/sage/rings/ring_extension_element.pxd b/src/sage/rings/ring_extension_element.pxd index 6b62ad58c06..32ce1385248 100644 --- a/src/sage/rings/ring_extension_element.pxd +++ b/src/sage/rings/ring_extension_element.pxd @@ -13,10 +13,10 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): pass cdef class RingExtensionWithBasisElement(RingExtensionElement): - cdef _vector(self, CommutativeRing base) - cdef _matrix(self, CommutativeRing base) - cdef _trace(self, CommutativeRing base) - cdef _norm(self, CommutativeRing base) - cpdef minpoly(self, base=*, var=*) + cdef _vector(self, CommutativeRing base) noexcept + cdef _matrix(self, CommutativeRing base) noexcept + cdef _trace(self, CommutativeRing base) noexcept + cdef _norm(self, CommutativeRing base) noexcept + cpdef minpoly(self, base=*, var=*) noexcept diff --git a/src/sage/rings/ring_extension_element.pyx b/src/sage/rings/ring_extension_element.pyx index fb80ba84e6e..cfc6b19cf2b 100644 --- a/src/sage/rings/ring_extension_element.pyx +++ b/src/sage/rings/ring_extension_element.pyx @@ -358,7 +358,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): return parent.base()(base(self._backend)) raise NotImplementedError("cannot cast %s to the base" % self) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" Compare this element with ``right`` according to the rich comparison operator ``op``. @@ -386,7 +386,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): """ return left._backend._richcmp_(backend_element(right), op) - cpdef _add_(self,other): + cpdef _add_(self,other) noexcept: r""" Return the sum of this element and ``other``. @@ -406,7 +406,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): ans._backend = self._backend + (other)._backend return ans - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the opposite of this element. @@ -426,7 +426,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): ans._backend = -self._backend return ans - cpdef _sub_(self,other): + cpdef _sub_(self,other) noexcept: r""" Return the difference of this element and ``other``. @@ -446,7 +446,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): ans._backend = self._backend - (other)._backend return ans - cpdef _mul_(self,other): + cpdef _mul_(self,other) noexcept: r""" Return the product of this element and ``other``. @@ -466,7 +466,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): ans._backend = self._backend * (other)._backend return ans - cpdef _div_(self,other): + cpdef _div_(self,other) noexcept: r""" Return the quotient of this element by ``other``, considered as an element of the fraction field. @@ -1033,7 +1033,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): base = (self._parent)._check_base(base) return self._vector(base) - cdef _vector(self, CommutativeRing base): + cdef _vector(self, CommutativeRing base) noexcept: r""" Return the vector of coordinates of this element over ``base`` (in the basis output by the method :meth:`basis_over`). @@ -1198,7 +1198,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): raise ValueError("the extension is not finite free") return self._matrix(base) - cdef _matrix(self, CommutativeRing base): + cdef _matrix(self, CommutativeRing base) noexcept: r""" Return the matrix of the multiplication by this element (in the basis output by :meth:`basis_over`). @@ -1286,7 +1286,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): raise ValueError("the extension is not finite free") return self._trace(base) - cdef _trace(self, CommutativeRing base): + cdef _trace(self, CommutativeRing base) noexcept: r""" Return the trace of this element over ``base``. @@ -1379,7 +1379,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): raise ValueError("the extension is not finite free") return self._norm(base) - cdef _norm(self, CommutativeRing base): + cdef _norm(self, CommutativeRing base) noexcept: r""" Return the norm of this element over ``base``. @@ -1483,7 +1483,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): """ return self.matrix(base).charpoly(var) - cpdef minpoly(self, base=None, var='x'): + cpdef minpoly(self, base=None, var='x') noexcept: r""" Return the minimal polynomial of this element over ``base``. diff --git a/src/sage/rings/ring_extension_morphism.pxd b/src/sage/rings/ring_extension_morphism.pxd index a02aff31a50..f3d88ec3891 100644 --- a/src/sage/rings/ring_extension_morphism.pxd +++ b/src/sage/rings/ring_extension_morphism.pxd @@ -4,7 +4,7 @@ from sage.rings.morphism cimport RingMap from sage.rings.ring_extension_element cimport RingExtensionElement -cdef are_equal_morphisms(f, g) +cdef are_equal_morphisms(f, g) noexcept cdef class RingExtensionHomomorphism(RingMap): @@ -31,4 +31,4 @@ cdef class MapRelativeRingToFreeModule(Map): cdef Map _jL cdef _matrix - cdef list backend_coefficients(self, RingExtensionElement x) + cdef list backend_coefficients(self, RingExtensionElement x) noexcept diff --git a/src/sage/rings/ring_extension_morphism.pyx b/src/sage/rings/ring_extension_morphism.pyx index f861d015a35..4d78ee1c5d0 100644 --- a/src/sage/rings/ring_extension_morphism.pyx +++ b/src/sage/rings/ring_extension_morphism.pyx @@ -29,7 +29,7 @@ from sage.rings.ring_extension_conversion cimport backend_parent, backend_elemen # I don't trust the operator == -cdef are_equal_morphisms(f, g): +cdef are_equal_morphisms(f, g) noexcept: r""" Return ``True`` if ``f`` and ``g`` coincide on the generators of the domain, ``False`` otherwise. @@ -227,7 +227,7 @@ cdef class RingExtensionHomomorphism(RingMap): """ return "Ring" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the image of ``x`` under this morphism. @@ -318,7 +318,7 @@ cdef class RingExtensionHomomorphism(RingMap): base_map = base_map.extend_codomain(self.codomain()) return base_map - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare this element with ``other`` according to the rich comparison operator ``op``. @@ -494,7 +494,7 @@ cdef class RingExtensionHomomorphism(RingMap): else: return backend - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper function for copying and pickling. @@ -512,7 +512,7 @@ cdef class RingExtensionHomomorphism(RingMap): self._backend = _slots['_backend'] RingMap._update_slots(self, _slots) - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper function for copying and pickling. @@ -598,7 +598,7 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): """ return "" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the image of ``x`` under this morphism. @@ -688,7 +688,7 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): """ return "" - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the image of ``x`` under this morphism. @@ -771,7 +771,7 @@ cdef class MapFreeModuleToRelativeRing(Map): """ return True - cpdef Element _call_(self, v): + cpdef Element _call_(self, v) noexcept: r""" Return the image of ``x`` under this morphism. @@ -880,7 +880,7 @@ cdef class MapRelativeRingToFreeModule(Map): """ return True - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: r""" Return the image of ``x`` under this morphism. @@ -898,7 +898,7 @@ cdef class MapRelativeRingToFreeModule(Map): coeffs = self.backend_coefficients(x) return self.codomain()(coeffs) - cdef list backend_coefficients(self, RingExtensionElement x): + cdef list backend_coefficients(self, RingExtensionElement x) noexcept: r""" Return the coordinates of the image of ``x`` as elements of the backend ring. diff --git a/src/sage/rings/semirings/tropical_semiring.pyx b/src/sage/rings/semirings/tropical_semiring.pyx index 2922298e286..3f25fb8af98 100644 --- a/src/sage/rings/semirings/tropical_semiring.pyx +++ b/src/sage/rings/semirings/tropical_semiring.pyx @@ -38,7 +38,7 @@ cdef class TropicalSemiringElement(Element): """ cdef ModuleElement _val - cdef TropicalSemiringElement _new(self): + cdef TropicalSemiringElement _new(self) noexcept: """ Return a new tropical semiring element with parent ``self`. """ @@ -132,7 +132,7 @@ cdef class TropicalSemiringElement(Element): return hash(self._val) # Comparisons - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" Return the standard comparison of ``left`` and ``right``. @@ -206,7 +206,7 @@ cdef class TropicalSemiringElement(Element): return rich_to_bool(op, 1) return rich_to_bool(op, 0) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add ``left`` to ``right``. @@ -274,7 +274,7 @@ cdef class TropicalSemiringElement(Element): return self raise ArithmeticError("cannot negate any non-infinite element") - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply ``left`` and ``right``. @@ -300,7 +300,7 @@ cdef class TropicalSemiringElement(Element): x._val = self._val + rhs._val return x - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ Divide ``left`` by ``right``. @@ -398,7 +398,7 @@ cdef class TropicalSemiringElement(Element): from sage.rings.infinity import infinity return infinity - cpdef ModuleElement lift(self): + cpdef ModuleElement lift(self) noexcept: """ Return the value of ``self`` lifted to the base. @@ -656,7 +656,7 @@ cdef class TropicalToTropical(Map): Map from the tropical semiring to itself (possibly with different bases). Used in coercion. """ - cpdef TropicalSemiringElement _call_(self, x): + cpdef TropicalSemiringElement _call_(self, x) noexcept: """ EXAMPLES:: diff --git a/src/sage/rings/sum_of_squares.pxd b/src/sage/rings/sum_of_squares.pxd index 47d43124f8b..d9f2e5ae4fd 100644 --- a/src/sage/rings/sum_of_squares.pxd +++ b/src/sage/rings/sum_of_squares.pxd @@ -1,2 +1,2 @@ from libc.stdint cimport uint_fast32_t, uint32_t -cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]) +cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]) noexcept diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index b8f719d4dac..737911ad53e 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -24,7 +24,7 @@ from cysignals.signals cimport sig_on, sig_off cimport sage.rings.integer as integer from . import integer -cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]): +cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]) noexcept: r""" Return ``1`` if ``n`` is a sum of two squares and ``0`` otherwise. @@ -94,7 +94,7 @@ cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]): return 0 -cdef int three_squares_c(uint_fast32_t n, uint_fast32_t res[3]): +cdef int three_squares_c(uint_fast32_t n, uint_fast32_t res[3]) noexcept: r""" Return `1` if `n` is a sum of three squares and `0` otherwise. diff --git a/src/sage/rings/tate_algebra_element.pxd b/src/sage/rings/tate_algebra_element.pxd index 20aff3a7fc1..5c529825e4c 100644 --- a/src/sage/rings/tate_algebra_element.pxd +++ b/src/sage/rings/tate_algebra_element.pxd @@ -13,19 +13,19 @@ cdef class TateAlgebraTerm(MonoidElement): cdef pAdicGenericElement _coeff cdef ETuple _exponent - cpdef _mul_(self, other) - cdef TateAlgebraTerm _floordiv_c(self, TateAlgebraTerm other) - cpdef _floordiv_(self, other) + cpdef _mul_(self, other) noexcept + cdef TateAlgebraTerm _floordiv_c(self, TateAlgebraTerm other) noexcept + cpdef _floordiv_(self, other) noexcept - cdef TateAlgebraTerm _new_c(self) - cdef long _valuation_c(self) + cdef TateAlgebraTerm _new_c(self) noexcept + cdef long _valuation_c(self) noexcept cdef long _cmp_c(self, TateAlgebraTerm other) except? 300 - cdef Element _call_c(self, list arg) - cpdef TateAlgebraTerm monomial(self) - cpdef TateAlgebraTerm monic(self) - cdef TateAlgebraTerm _gcd_c(self, TateAlgebraTerm other) - cdef TateAlgebraTerm _lcm_c(self, TateAlgebraTerm other) - cdef bint _divides_c(self, TateAlgebraTerm other, bint integral) + cdef Element _call_c(self, list arg) noexcept + cpdef TateAlgebraTerm monomial(self) noexcept + cpdef TateAlgebraTerm monic(self) noexcept + cdef TateAlgebraTerm _gcd_c(self, TateAlgebraTerm other) noexcept + cdef TateAlgebraTerm _lcm_c(self, TateAlgebraTerm other) noexcept + cdef bint _divides_c(self, TateAlgebraTerm other, bint integral) noexcept cdef class TateAlgebraElement(CommutativeAlgebraElement): @@ -35,15 +35,15 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): cdef list _terms_nonzero cdef bint _is_normalized - cdef _normalize(self) - cdef TateAlgebraElement _new_c(self) - cdef list _terms_c(self, bint include_zero=*) - cpdef valuation(self) - cdef TateAlgebraElement _term_mul_c(self, TateAlgebraTerm term) - cdef TateAlgebraElement _positive_lshift_c(self, n) - cdef TateAlgebraElement _lshift_c(self, n) - cpdef TateAlgebraElement monic(self) - cdef _quo_rem_c(self, list divisors, bint quo, bint rem, bint integral) - cdef _quo_rem_check(self, divisors, bint quo, bint rem) - cdef TateAlgebraElement _Spoly_c(self, TateAlgebraElement other) + cdef _normalize(self) noexcept + cdef TateAlgebraElement _new_c(self) noexcept + cdef list _terms_c(self, bint include_zero=*) noexcept + cpdef valuation(self) noexcept + cdef TateAlgebraElement _term_mul_c(self, TateAlgebraTerm term) noexcept + cdef TateAlgebraElement _positive_lshift_c(self, n) noexcept + cdef TateAlgebraElement _lshift_c(self, n) noexcept + cpdef TateAlgebraElement monic(self) noexcept + cdef _quo_rem_c(self, list divisors, bint quo, bint rem, bint integral) noexcept + cdef _quo_rem_check(self, divisors, bint quo, bint rem) noexcept + cdef TateAlgebraElement _Spoly_c(self, TateAlgebraElement other) noexcept diff --git a/src/sage/rings/tate_algebra_element.pyx b/src/sage/rings/tate_algebra_element.pyx index b9be89b99b6..e812a0a7f5f 100644 --- a/src/sage/rings/tate_algebra_element.pyx +++ b/src/sage/rings/tate_algebra_element.pyx @@ -167,7 +167,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return hash((self._coeff, self._exponent)) - cdef TateAlgebraTerm _new_c(self): + cdef TateAlgebraTerm _new_c(self) noexcept: r""" Fast creation of a Tate algebra term. @@ -309,7 +309,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return self._exponent - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return the product of this Tate algebra term with ``other``. @@ -385,7 +385,7 @@ cdef class TateAlgebraTerm(MonoidElement): c = (ks > ko) - (ks < ko) return c - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare the Tate algebra term with ``other`` according to the rich comparison operator ``op``. @@ -446,7 +446,7 @@ cdef class TateAlgebraTerm(MonoidElement): c = (self)._cmp_c(other) return rich_to_bool_sgn(op, c) - cpdef TateAlgebraTerm monomial(self): + cpdef TateAlgebraTerm monomial(self) noexcept: r""" Return this term divided by its coefficient. @@ -466,7 +466,7 @@ cdef class TateAlgebraTerm(MonoidElement): ans._exponent = self._exponent return ans - cpdef TateAlgebraTerm monic(self): + cpdef TateAlgebraTerm monic(self) noexcept: r""" Return this term normalized so that it has valuation 0 and its coefficient is a power of the uniformizer. @@ -540,7 +540,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return ZZ(self._valuation_c()) - cdef long _valuation_c(self): + cdef long _valuation_c(self) noexcept: r""" Return the valuation of this term. @@ -557,7 +557,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return (self._coeff).valuation_c() - self._exponent.dotprod(self._parent._log_radii) - cdef Element _call_c(self, list arg): + cdef Element _call_c(self, list arg) noexcept: """ Return this term evaluated at ``args``. @@ -725,7 +725,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return self._gcd_c(other) - cdef TateAlgebraTerm _gcd_c(self, TateAlgebraTerm other): + cdef TateAlgebraTerm _gcd_c(self, TateAlgebraTerm other) noexcept: r""" Return the greatest common divisor of this term and ``other``. @@ -795,7 +795,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return self._lcm_c(other) - cdef TateAlgebraTerm _lcm_c(self, TateAlgebraTerm other): + cdef TateAlgebraTerm _lcm_c(self, TateAlgebraTerm other) noexcept: r""" Return the least common multiple of two Tate terms. @@ -948,7 +948,7 @@ cdef class TateAlgebraTerm(MonoidElement): """ return self._divides_c(other, integral) - cdef bint _divides_c(self, TateAlgebraTerm other, bint integral): + cdef bint _divides_c(self, TateAlgebraTerm other, bint integral) noexcept: r""" Return ``True`` if this term divides ``other``. @@ -980,7 +980,7 @@ cdef class TateAlgebraTerm(MonoidElement): return False return True - cpdef _floordiv_(self, other): + cpdef _floordiv_(self, other) noexcept: r""" Return the result of the exact division of this term by ``other``. @@ -1013,7 +1013,7 @@ cdef class TateAlgebraTerm(MonoidElement): return (self)._floordiv_c(other) - cdef TateAlgebraTerm _floordiv_c(self, TateAlgebraTerm other): + cdef TateAlgebraTerm _floordiv_c(self, TateAlgebraTerm other) noexcept: r""" Return the result of the exact division of this term by ``other``. @@ -1120,7 +1120,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): if not parent.base_ring().is_field() and self.valuation() < 0: raise ValueError("this series is not in the ring of integers") - cdef TateAlgebraElement _new_c(self): + cdef TateAlgebraElement _new_c(self) noexcept: """ Fast creation of a new Tate series. @@ -1138,7 +1138,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._terms = ans._terms_nonzero = None return ans - cdef _normalize(self): + cdef _normalize(self) noexcept: """ Normalize this series. @@ -1279,7 +1279,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): s += "O\\left(%s^{%s} %s\\right)" % (self._parent._uniformizer_latex, self._prec, self._parent.integer_ring()._latex_()) return s - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: r""" Return the sum of this series and ``other``. @@ -1314,7 +1314,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._normalize() return ans - cpdef _neg_(self): + cpdef _neg_(self) noexcept: r""" Return the opposite of this series. @@ -1334,7 +1334,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._prec = self._prec return ans - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: r""" Return the difference of this series and ``other``. @@ -1367,7 +1367,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._normalize() return ans - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: r""" Return the product of this series with ``other``. @@ -1402,7 +1402,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._normalize() return ans - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: r""" Return the product of this series by ``right``. @@ -1783,7 +1783,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): return root - cpdef _richcmp_(self, other, int op): + cpdef _richcmp_(self, other, int op) noexcept: r""" Compare this series with ``other`` according to the rich comparison operator ``op``. @@ -1922,7 +1922,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): pass return res - cdef TateAlgebraElement _term_mul_c(self, TateAlgebraTerm term): + cdef TateAlgebraElement _term_mul_c(self, TateAlgebraTerm term) noexcept: r""" Return the product of this series by the term ``term``. @@ -1943,7 +1943,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._prec = self._prec + term._valuation_c() return ans - cdef TateAlgebraElement _positive_lshift_c(self, n): + cdef TateAlgebraElement _positive_lshift_c(self, n) noexcept: r""" Return the product of this series by the ``n``-th power of the uniformizer. @@ -1972,7 +1972,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ans._prec = self._prec + n return ans - cdef TateAlgebraElement _lshift_c(self, n): + cdef TateAlgebraElement _lshift_c(self, n) noexcept: r""" Return the product of this series by the ``n``-th power of the uniformizer. @@ -2190,7 +2190,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): self._terms = None return self._terms_c() - cdef list _terms_c(self, bint include_zero=True): + cdef list _terms_c(self, bint include_zero=True) noexcept: r""" Return a list of the terms of this series sorted in descending order. @@ -2453,7 +2453,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): """ return self._prec - cpdef valuation(self): + cpdef valuation(self) noexcept: r""" Return the valuation of this series. @@ -2941,7 +2941,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): """ return self.leading_term(secure=secure).monomial() - cpdef TateAlgebraElement monic(self): + cpdef TateAlgebraElement monic(self) noexcept: r""" Return this series normalized so that it has valuation 0 and its leading coefficient is a power of the uniformizer. @@ -3162,7 +3162,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): poly = self._parent._polynomial_ring(self._poly) return poly.change_ring(Rn) - cdef _quo_rem_c(self, list divisors, bint quo, bint rem, bint integral): + cdef _quo_rem_c(self, list divisors, bint quo, bint rem, bint integral) noexcept: r""" Perform the division of this series by ``divisors``. @@ -3235,7 +3235,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): f._terms = None return quos, f - cdef _quo_rem_check(self, divisors, bint quo, bint rem): + cdef _quo_rem_check(self, divisors, bint quo, bint rem) noexcept: """ Perform the division of this series by ``divisors``. @@ -3491,7 +3491,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): except IndexError: raise ValueError("the S-polynomial of zero is not defined") - cdef TateAlgebraElement _Spoly_c(self, TateAlgebraElement other): + cdef TateAlgebraElement _Spoly_c(self, TateAlgebraElement other) noexcept: """ Return the S-polynomial of this series and ``other``. diff --git a/src/sage/rings/tate_algebra_ideal.pxd b/src/sage/rings/tate_algebra_ideal.pxd index e5581e06b8c..d6c239b9a0c 100644 --- a/src/sage/rings/tate_algebra_ideal.pxd +++ b/src/sage/rings/tate_algebra_ideal.pxd @@ -1,6 +1,6 @@ from sage.rings.tate_algebra_element cimport TateAlgebraTerm from sage.rings.tate_algebra_element cimport TateAlgebraElement -cdef Jpair(p1, p2) -cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElement v, stopval) -cdef TateAlgebraElement reduce(gb, TateAlgebraElement v, stopval) +cdef Jpair(p1, p2) noexcept +cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElement v, stopval) noexcept +cdef TateAlgebraElement reduce(gb, TateAlgebraElement v, stopval) noexcept diff --git a/src/sage/rings/tate_algebra_ideal.pyx b/src/sage/rings/tate_algebra_ideal.pyx index e230a411397..982d9581635 100644 --- a/src/sage/rings/tate_algebra_ideal.pyx +++ b/src/sage/rings/tate_algebra_ideal.pyx @@ -567,7 +567,7 @@ def groebner_basis_buchberger(I, prec, py_integral): # F5 algorithms -cdef Jpair(p1, p2): +cdef Jpair(p1, p2) noexcept: r""" Return the J-pair of ``p1`` and ``p2`` @@ -605,7 +605,7 @@ cdef Jpair(p1, p2): return su2, t2*v2 -cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElement v, stopval): +cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElement v, stopval) noexcept: r""" Return the result of the regular reduction of the pair ``(s,v)`` by ``sgb`` @@ -689,7 +689,7 @@ cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElemen return f -cdef TateAlgebraElement reduce(gb, TateAlgebraElement v, stopval): +cdef TateAlgebraElement reduce(gb, TateAlgebraElement v, stopval) noexcept: r""" Return the result of the reduction of ``v`` by ``gb`` diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 458ce65a61d..66d679a1241 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -38,7 +38,7 @@ from sage.libs.pari.convert_gmp cimport _new_GEN_from_mpz_t DEF N_RES_CLASSES_BSD = 10 -cdef unsigned long valuation(mpz_t a, mpz_t p): +cdef unsigned long valuation(mpz_t a, mpz_t p) noexcept: """ Return the number of times p divides a. """ @@ -85,7 +85,7 @@ def test_valuation(a, p): return valuation(A.value, P.value) -cdef int padic_square(mpz_t a, mpz_t p): +cdef int padic_square(mpz_t a, mpz_t p) noexcept: """ Test if a is a p-adic square. """ @@ -130,7 +130,7 @@ def test_padic_square(a, p): cdef int lemma6(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, - mpz_t x, mpz_t p, unsigned long nu): + mpz_t x, mpz_t p, unsigned long nu) noexcept: """ Implements Lemma 6 of BSD's "Notes on elliptic curves, I" for odd p. @@ -180,7 +180,7 @@ cdef int lemma6(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, cdef int lemma7(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, - mpz_t x, mpz_t p, unsigned long nu): + mpz_t x, mpz_t p, unsigned long nu) noexcept: """ Implements Lemma 7 of BSD's "Notes on elliptic curves, I" for p=2. @@ -246,7 +246,7 @@ cdef int lemma7(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, cdef int Zp_soluble_BSD(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, - mpz_t x_k, mpz_t p, unsigned long k): + mpz_t x_k, mpz_t p, unsigned long k) noexcept: """ Uses the approach of BSD's "Notes on elliptic curves, I" to test for solubility of y^2 == ax^4 + bx^3 + cx^2 + dx + e over Zp, with @@ -283,7 +283,7 @@ cdef int Zp_soluble_BSD(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t pp, unsigned long pp_ui, nmod_poly_factor_t f_factzn, nmod_poly_t f, - fmpz_poly_t f1, fmpz_poly_t linear): + fmpz_poly_t f1, fmpz_poly_t linear) noexcept: """ Uses the approach of Algorithm 5.3.1 of Siksek's thesis to test for solubility of y^2 == ax^4 + bx^3 + cx^2 + dx + e over Zp. @@ -523,7 +523,7 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, return result cdef bint Zp_soluble_siksek_large_p(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t pp, - fmpz_poly_t f1, fmpz_poly_t linear): + fmpz_poly_t f1, fmpz_poly_t linear) noexcept: """ Uses the approach of Algorithm 5.3.1 of Siksek's thesis to test for solubility of y^2 == ax^4 + bx^3 + cx^2 + dx + e over Zp. @@ -790,7 +790,7 @@ cdef bint Zp_soluble_siksek_large_p(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, cdef bint Qp_soluble_siksek(mpz_t A, mpz_t B, mpz_t C, mpz_t D, mpz_t E, mpz_t p, unsigned long P, nmod_poly_factor_t f_factzn, fmpz_poly_t f1, - fmpz_poly_t linear): + fmpz_poly_t linear) noexcept: """ Uses Samir Siksek's thesis results to determine whether the quartic is locally soluble at p. @@ -829,7 +829,7 @@ cdef bint Qp_soluble_siksek(mpz_t A, mpz_t B, mpz_t C, mpz_t D, mpz_t E, cdef bint Qp_soluble_siksek_large_p(mpz_t A, mpz_t B, mpz_t C, mpz_t D, mpz_t E, - mpz_t p, fmpz_poly_t f1, fmpz_poly_t linear): + mpz_t p, fmpz_poly_t f1, fmpz_poly_t linear) noexcept: """ Uses Samir Siksek's thesis results to determine whether the quartic is locally soluble at p, when p is bigger than wordsize, and we can't use @@ -863,7 +863,7 @@ cdef bint Qp_soluble_siksek_large_p(mpz_t A, mpz_t B, mpz_t C, mpz_t D, mpz_t E, mpz_clear(e) return result -cdef bint Qp_soluble_BSD(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t p): +cdef bint Qp_soluble_BSD(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t p) noexcept: """ Uses the original test of Birch and Swinnerton-Dyer to test for local solubility of the quartic at p. @@ -880,7 +880,7 @@ cdef bint Qp_soluble_BSD(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t p): mpz_clear(zero) return result -cdef bint Qp_soluble(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t p): +cdef bint Qp_soluble(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e, mpz_t p) noexcept: """ Try the BSD approach for a few residue classes and if no solution is found, switch to Siksek to try to prove insolubility. diff --git a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx index 296a6b5d075..33e509dca96 100644 --- a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx +++ b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx @@ -200,7 +200,7 @@ fa = sage.rings.fast_arith.arith_llong() cdef llong llgcd(llong a, llong b) except -1: return fa.gcd_longlong(a,b) -cdef llong llinvmod(llong a, llong m): +cdef llong llinvmod(llong a, llong m) noexcept: return fa.inverse_mod_longlong(a, m) DEF TWOPI = 6.28318530717958647 @@ -602,7 +602,7 @@ cdef class _CuspsForModularSymbolNumerical: # from sage.modular.cusps import Cusp # Cusp.__init__(self, a,m) - cdef public int is_unitary(self): + cdef public int is_unitary(self) noexcept: r""" Return whether the cusp is unitary, i.e. whether there exists an Atkin- @@ -1437,7 +1437,7 @@ cdef class ModularSymbolNumerical: # the version using double is 70-80 times faster it seems. cdef complex _integration_to_tau_double(self, complex tau, - int number_of_terms): + int number_of_terms) noexcept: r""" Given a point `\tau` in the upper half plane this returns a complex number that is a close @@ -2014,7 +2014,7 @@ cdef class ModularSymbolNumerical: Integer epsQ, Integer epsQQ, llong* wQ, llong* wQQ, int T, int prec, double eps, - int use_partials=2): + int use_partials=2) noexcept: r""" This is just a helper function for _from_r_to_rr_approx. In case the integral is evaluated directly this function is called. diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx index b0914d6347a..06e6525f5c3 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx +++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx @@ -665,7 +665,7 @@ cdef class PeriodicRegion: return sum(L, F) -cdef frame_data(data, bint full=True): +cdef frame_data(data, bint full=True) noexcept: """ Helper function for PeriodicRegion.expand() and PeriodicRegion.border(). This makes "wrapping around" work @@ -695,7 +695,7 @@ cdef frame_data(data, bint full=True): framed[-1,:] = framed[-3,:] return framed -cdef unframe_data(framed, bint full=True): +cdef unframe_data(framed, bint full=True) noexcept: """ Helper function for PeriodicRegion.expand(). This glues the borders together using the "or" operator. diff --git a/src/sage/schemes/toric/divisor_class.pyx b/src/sage/schemes/toric/divisor_class.pyx index 5a92fe5b38d..3c9a9143eaf 100644 --- a/src/sage/schemes/toric/divisor_class.pyx +++ b/src/sage/schemes/toric/divisor_class.pyx @@ -137,7 +137,7 @@ cdef class ToricRationalDivisorClass(Vector_rational_dense): (self._parent, list(self), self._degree, not self._is_immutable)) - cpdef _act_on_(self, other, bint self_on_left): + cpdef _act_on_(self, other, bint self_on_left) noexcept: """ Act on ``other``. @@ -202,7 +202,7 @@ cdef class ToricRationalDivisorClass(Vector_rational_dense): # Now let the standard framework work... return Vector_rational_dense._act_on_(self, other, self_on_left) - cpdef _dot_product_(self, Vector right): + cpdef _dot_product_(self, Vector right) noexcept: r""" Raise a ``TypeError`` exception. diff --git a/src/sage/sets/finite_set_map_cy.pxd b/src/sage/sets/finite_set_map_cy.pxd index daa46c099e0..998e4f58729 100644 --- a/src/sage/sets/finite_set_map_cy.pxd +++ b/src/sage/sets/finite_set_map_cy.pxd @@ -5,29 +5,29 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -cpdef fibers(f, domain) +cpdef fibers(f, domain) noexcept from sage.structure.parent cimport Parent from sage.structure.list_clone cimport ClonableIntArray cdef class FiniteSetMap_MN(ClonableIntArray): - cpdef _setimage(self, int i, int j) - cpdef _getimage(self, int i) - cpdef setimage(self, i, j) - cpdef getimage(self, i) - cpdef domain(self) - cpdef codomain(self) - cpdef image_set(self) - cpdef fibers(self) - cpdef items(self) + cpdef _setimage(self, int i, int j) noexcept + cpdef _getimage(self, int i) noexcept + cpdef setimage(self, i, j) noexcept + cpdef getimage(self, i) noexcept + cpdef domain(self) noexcept + cpdef codomain(self) noexcept + cpdef image_set(self) noexcept + cpdef fibers(self) noexcept + cpdef items(self) noexcept cpdef FiniteSetMap_MN _compose_internal_(self, FiniteSetMap_MN other, - Parent resParent) - cpdef check(self) + Parent resParent) noexcept + cpdef check(self) noexcept cdef class FiniteSetMap_Set(FiniteSetMap_MN): pass -cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(cls, parent, lst) -cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(cls, parent, d) +cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(cls, parent, lst) noexcept +cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(cls, parent, d) noexcept cdef class FiniteSetEndoMap_N(FiniteSetMap_MN): pass cdef class FiniteSetEndoMap_Set(FiniteSetMap_Set): pass diff --git a/src/sage/sets/finite_set_map_cy.pyx b/src/sage/sets/finite_set_map_cy.pyx index a06dc0a2bd9..1fad423fb81 100644 --- a/src/sage/sets/finite_set_map_cy.pyx +++ b/src/sage/sets/finite_set_map_cy.pyx @@ -58,7 +58,7 @@ from sage.arith.power cimport generic_power from sage.sets.set import Set_object_enumerated -cpdef fibers(f, domain): +cpdef fibers(f, domain) noexcept: r""" Returns the fibers of the function ``f`` on the finite set ``domain`` @@ -157,7 +157,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return True - cpdef domain(self): + cpdef domain(self) noexcept: """ Returns the domain of ``self`` @@ -168,7 +168,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return self._parent.domain() - cpdef codomain(self): + cpdef codomain(self) noexcept: """ Returns the codomain of ``self`` @@ -179,7 +179,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return self._parent.codomain() - cpdef _setimage(self, int i, int j): + cpdef _setimage(self, int i, int j) noexcept: """ Set the image of ``i`` as ``j`` in ``self`` @@ -221,7 +221,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ self._setitem(i, j) - cpdef _getimage(self, int i): + cpdef _getimage(self, int i) noexcept: """ Returns the image of ``i`` by ``self`` @@ -239,7 +239,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return self._getitem(i) - cpdef setimage(self, i, j): + cpdef setimage(self, i, j) noexcept: """ Set the image of ``i`` as ``j`` in ``self`` @@ -268,7 +268,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ self._setitem(int(i), int(j)) - cpdef getimage(self, i): + cpdef getimage(self, i) noexcept: """ Returns the image of ``i`` by ``self`` @@ -286,7 +286,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return self._getitem(int(i)) - cpdef image_set(self): + cpdef image_set(self) noexcept: """ Returns the image set of ``self`` @@ -299,7 +299,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return Set_object_enumerated(self) - cpdef fibers(self): + cpdef fibers(self) noexcept: """ Returns the fibers of ``self`` @@ -318,7 +318,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return fibers(self, self.domain()) - cpdef items(self): + cpdef items(self) noexcept: """ The items of ``self`` @@ -331,7 +331,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): """ return [(i, self._getimage(i)) for i in self.domain()] - cpdef check(self): + cpdef check(self) noexcept: """ Performs checks on ``self`` @@ -362,7 +362,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): self._parent.check_element(self) cpdef FiniteSetMap_MN _compose_internal_(self, FiniteSetMap_MN other, - Parent resParent): + Parent resParent) noexcept: """ TESTS:: @@ -383,7 +383,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray): return res -cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(t, parent, lst): +cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(t, parent, lst) noexcept: """ Creates a ``FiniteSetMap`` from a list @@ -406,7 +406,7 @@ cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(t, parent, lst): super(FiniteSetMap_MN, res).__init__(parent, lst) return res -cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(t, parent, d): +cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(t, parent, d) noexcept: """ Creates a ``FiniteSetMap`` from a dictionary @@ -491,7 +491,7 @@ cdef class FiniteSetMap_Set(FiniteSetMap_MN): parent = self._parent return parent._unrank_codomain(self._getitem(parent._rank_domain(i))) - cpdef image_set(self): + cpdef image_set(self) noexcept: """ Returns the image set of ``self`` @@ -507,7 +507,7 @@ cdef class FiniteSetMap_Set(FiniteSetMap_MN): image_i = self._parent._unrank_codomain return Set_object_enumerated([image_i(i) for i in self]) - cpdef setimage(self, i, j): + cpdef setimage(self, i, j) noexcept: """ Set the image of ``i`` as ``j`` in ``self`` @@ -550,7 +550,7 @@ cdef class FiniteSetMap_Set(FiniteSetMap_MN): parent = self._parent return self._setitem(parent._rank_domain(i), parent._rank_codomain(j)) - cpdef getimage(self, i): + cpdef getimage(self, i) noexcept: """ Returns the image of ``i`` by ``self`` @@ -568,7 +568,7 @@ cdef class FiniteSetMap_Set(FiniteSetMap_MN): parent = self._parent return parent._unrank_codomain(self._getitem(parent._rank_domain(i))) - cpdef items(self): + cpdef items(self) noexcept: """ The items of ``self`` diff --git a/src/sage/sets/pythonclass.pxd b/src/sage/sets/pythonclass.pxd index 4346d918386..70c24f64d9c 100644 --- a/src/sage/sets/pythonclass.pxd +++ b/src/sage/sets/pythonclass.pxd @@ -5,4 +5,4 @@ cdef class Set_PythonType_class(Set_generic): cdef type _type -cpdef Set_PythonType(typ) +cpdef Set_PythonType(typ) noexcept diff --git a/src/sage/sets/pythonclass.pyx b/src/sage/sets/pythonclass.pyx index bfa7f3bc617..ed8c6d940c2 100644 --- a/src/sage/sets/pythonclass.pyx +++ b/src/sage/sets/pythonclass.pyx @@ -19,7 +19,7 @@ from sage.categories.sets_cat import Sets cdef dict _type_set_cache = {} -cpdef Set_PythonType(typ): +cpdef Set_PythonType(typ) noexcept: """ Return the (unique) Parent that represents the set of Python objects of a specified type. diff --git a/src/sage/sets/recursively_enumerated_set.pxd b/src/sage/sets/recursively_enumerated_set.pxd index 48c8312456c..7df7e28ec28 100644 --- a/src/sage/sets/recursively_enumerated_set.pxd +++ b/src/sage/sets/recursively_enumerated_set.pxd @@ -16,15 +16,15 @@ cdef class RecursivelyEnumeratedSet_generic(sage.structure.parent.Parent): cdef readonly _max_depth cdef readonly _graded_component - cpdef seeds(self) - cpdef graded_component(self, depth) + cpdef seeds(self) noexcept + cpdef graded_component(self, depth) noexcept cdef class RecursivelyEnumeratedSet_symmetric(RecursivelyEnumeratedSet_generic): - cdef set _get_next_graded_component(self, set A, set B) + cdef set _get_next_graded_component(self, set A, set B) noexcept - cpdef graded_component(self, depth) + cpdef graded_component(self, depth) noexcept cdef class RecursivelyEnumeratedSet_graded(RecursivelyEnumeratedSet_generic): - cdef set _get_next_graded_component(self, set B) + cdef set _get_next_graded_component(self, set B) noexcept - cpdef graded_component(self, depth) + cpdef graded_component(self, depth) noexcept diff --git a/src/sage/sets/recursively_enumerated_set.pyx b/src/sage/sets/recursively_enumerated_set.pyx index 26bcd769b44..d79e104704f 100644 --- a/src/sage/sets/recursively_enumerated_set.pyx +++ b/src/sage/sets/recursively_enumerated_set.pyx @@ -696,7 +696,7 @@ cdef class RecursivelyEnumeratedSet_generic(Parent): L.append("with max_depth={}".format(self._max_depth)) return " ".join(L) - cpdef seeds(self): + cpdef seeds(self) noexcept: r""" Return an iterable over the seeds of ``self``. @@ -746,7 +746,7 @@ cdef class RecursivelyEnumeratedSet_generic(Parent): raise NotImplementedError("graded_component_iterator method currently" " implemented only for graded or symmetric structure") - cpdef graded_component(self, depth): + cpdef graded_component(self, depth) noexcept: r""" Return the graded component of given depth. @@ -1175,7 +1175,7 @@ cdef class RecursivelyEnumeratedSet_symmetric(RecursivelyEnumeratedSet_generic): yield B A, B = B, self._get_next_graded_component(A, B) - cpdef graded_component(self, depth): + cpdef graded_component(self, depth) noexcept: r""" Return the graded component of given depth. @@ -1242,7 +1242,7 @@ cdef class RecursivelyEnumeratedSet_symmetric(RecursivelyEnumeratedSet_generic): self._graded_component.append(C) return self._graded_component[depth] - cdef set _get_next_graded_component(self, set A, set B): + cdef set _get_next_graded_component(self, set A, set B) noexcept: r""" Return the set of elements of depth `n+1`. @@ -1397,7 +1397,7 @@ cdef class RecursivelyEnumeratedSet_graded(RecursivelyEnumeratedSet_generic): yield B B = self._get_next_graded_component(B) - cpdef graded_component(self, depth): + cpdef graded_component(self, depth) noexcept: r""" Return the graded component of given depth. @@ -1460,7 +1460,7 @@ cdef class RecursivelyEnumeratedSet_graded(RecursivelyEnumeratedSet_generic): self._graded_component.append(C) return self._graded_component[depth] - cdef set _get_next_graded_component(self, set B): + cdef set _get_next_graded_component(self, set B) noexcept: r""" Return the set of elements of depth `n+1`. diff --git a/src/sage/stats/hmm/chmm.pyx b/src/sage/stats/hmm/chmm.pyx index fe84e176a8a..aa35b8cefdc 100644 --- a/src/sage/stats/hmm/chmm.pyx +++ b/src/sage/stats/hmm/chmm.pyx @@ -38,7 +38,7 @@ from sage.misc.randstate cimport current_randstate, randstate # TODO: DELETE THIS FUNCTION WHEN MOVE Gaussian stuff to distributions.pyx!!! (next version) -cdef double random_normal(double mean, double std, randstate rstate): +cdef double random_normal(double mean, double std, randstate rstate) noexcept: r""" Return a number chosen randomly with given mean and standard deviation. @@ -446,7 +446,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): return obs, states - cdef probability_init(self): + cdef probability_init(self) noexcept: r""" Used internally to compute caching information that makes certain computations in the Baum-Welch algorithm faster. This @@ -458,7 +458,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): self.prob[2*i] = 1.0/(sqrt2pi*self.B[2*i+1]) self.prob[2*i+1] = -1.0/(2*self.B[2*i+1]*self.B[2*i+1]) - cdef double random_sample(self, int state, randstate rstate): + cdef double random_sample(self, int state, randstate rstate) noexcept: r""" Return a random sample from the normal distribution associated to the given state. @@ -478,7 +478,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): """ return random_normal(self.B._values[state*2], self.B._values[state*2+1], rstate) - cdef double probability_of(self, int state, double observation): + cdef double probability_of(self, int state, double observation) noexcept: r""" Return a useful continuous analogue of "the probability b_j(o)" of seeing the given observation given that we're in the given @@ -716,7 +716,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): return state_sequence, mx - cdef TimeSeries _backward_scale_all(self, TimeSeries obs, TimeSeries scale): + cdef TimeSeries _backward_scale_all(self, TimeSeries obs, TimeSeries scale) noexcept: r""" This function returns the matrix beta_t(i), and is used internally as part of the Baum-Welch algorithm. @@ -756,7 +756,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): t -= 1 return beta - cdef _forward_scale_all(self, TimeSeries obs): + cdef _forward_scale_all(self, TimeSeries obs) noexcept: r""" Return scaled values alpha_t(i), the sequence of scalings, and the log probability. @@ -821,7 +821,7 @@ cdef class GaussianHiddenMarkovModel(HiddenMarkovModel): # Termination return alpha, scale, log_probability - cdef TimeSeries _baum_welch_xi(self, TimeSeries alpha, TimeSeries beta, TimeSeries obs): + cdef TimeSeries _baum_welch_xi(self, TimeSeries alpha, TimeSeries beta, TimeSeries obs) noexcept: r""" Used internally to compute the scaled quantity xi_t(i,j) appearing in the Baum-Welch reestimation algorithm. @@ -1249,7 +1249,7 @@ cdef class GaussianMixtureHiddenMarkovModel(GaussianHiddenMarkovModel): """ return list(self.mixture) - cdef double random_sample(self, int state, randstate rstate): + cdef double random_sample(self, int state, randstate rstate) noexcept: r""" Return a random sample from the normal distribution associated to the given state. @@ -1270,7 +1270,7 @@ cdef class GaussianMixtureHiddenMarkovModel(GaussianHiddenMarkovModel): cdef GaussianMixtureDistribution G = self.mixture[state] return G._sample(rstate) - cdef double probability_of(self, int state, double observation): + cdef double probability_of(self, int state, double observation) noexcept: r""" Return the probability b_j(o) of see the given observation o (=observation) given that we're in the given state j (=state). @@ -1292,7 +1292,7 @@ cdef class GaussianMixtureHiddenMarkovModel(GaussianHiddenMarkovModel): return G.prob(observation) cdef TimeSeries _baum_welch_mixed_gamma(self, TimeSeries alpha, TimeSeries beta, - TimeSeries obs, int j): + TimeSeries obs, int j) noexcept: r""" Let gamma_t(j,m) be the m-component (in the mixture) of the probability of being in state j at time t, given the diff --git a/src/sage/stats/hmm/distributions.pxd b/src/sage/stats/hmm/distributions.pxd index b07435d3abb..7d613b22a64 100644 --- a/src/sage/stats/hmm/distributions.pxd +++ b/src/sage/stats/hmm/distributions.pxd @@ -22,10 +22,10 @@ cdef class GaussianMixtureDistribution(Distribution): cdef TimeSeries c0, c1, param cdef IntList fixed - cdef double _sample(self, randstate rstate) - cpdef double prob(self, double x) - cpdef double prob_m(self, double x, int m) - cpdef is_fixed(self, i=?) + cdef double _sample(self, randstate rstate) noexcept + cpdef double prob(self, double x) noexcept + cpdef double prob_m(self, double x, int m) noexcept + cpdef is_fixed(self, i=?) noexcept diff --git a/src/sage/stats/hmm/distributions.pyx b/src/sage/stats/hmm/distributions.pyx index 65a743e26f1..ebb85739b2e 100644 --- a/src/sage/stats/hmm/distributions.pyx +++ b/src/sage/stats/hmm/distributions.pyx @@ -34,7 +34,7 @@ from sage.stats.time_series cimport TimeSeries -cdef double random_normal(double mean, double std, randstate rstate): +cdef double random_normal(double mean, double std, randstate rstate) noexcept: r""" Return a floating point number chosen from the normal distribution with given mean and standard deviation, using the given randstate. @@ -282,7 +282,7 @@ cdef class GaussianMixtureDistribution(Distribution): """ return self.c0._length - cpdef is_fixed(self, i=None): + cpdef is_fixed(self, i=None) noexcept: r""" Return whether or not this :class:`GaussianMixtureDistribution` is fixed when using Baum-Welch to update the corresponding HMM. @@ -434,7 +434,7 @@ cdef class GaussianMixtureDistribution(Distribution): T._values[i] = self._sample(rstate) return T - cdef double _sample(self, randstate rstate): + cdef double _sample(self, randstate rstate) noexcept: r""" Used internally to compute a sample from this distribution quickly. @@ -459,7 +459,7 @@ cdef class GaussianMixtureDistribution(Distribution): return random_normal(self.param._values[3*n+1], self.param._values[3*n+2], rstate) raise RuntimeError("invalid probability distribution") - cpdef double prob(self, double x): + cpdef double prob(self, double x) noexcept: r""" Return the probability of `x`. @@ -495,7 +495,7 @@ cdef class GaussianMixtureDistribution(Distribution): s += self.c0._values[n]*exp((x-mu)*(x-mu)*self.c1._values[n]) return s - cpdef double prob_m(self, double x, int m): + cpdef double prob_m(self, double x, int m) noexcept: r""" Return the probability of `x` using just the `m`-th summand. diff --git a/src/sage/stats/hmm/hmm.pxd b/src/sage/stats/hmm/hmm.pxd index 1abcb95392b..f67de100a92 100644 --- a/src/sage/stats/hmm/hmm.pxd +++ b/src/sage/stats/hmm/hmm.pxd @@ -13,5 +13,5 @@ cdef class HiddenMarkovModel: cdef int N cdef TimeSeries A, pi - cdef TimeSeries _baum_welch_gamma(self, TimeSeries alpha, TimeSeries beta) + cdef TimeSeries _baum_welch_gamma(self, TimeSeries alpha, TimeSeries beta) noexcept diff --git a/src/sage/stats/hmm/hmm.pyx b/src/sage/stats/hmm/hmm.pyx index f48d0c9e4db..86de50cc1a3 100644 --- a/src/sage/stats/hmm/hmm.pyx +++ b/src/sage/stats/hmm/hmm.pyx @@ -224,7 +224,7 @@ cdef class HiddenMarkovModel: # Some internal functions used for various general # HMM algorithms. ######################################################### - cdef TimeSeries _baum_welch_gamma(self, TimeSeries alpha, TimeSeries beta): + cdef TimeSeries _baum_welch_gamma(self, TimeSeries alpha, TimeSeries beta) noexcept: r""" Used internally to compute the scaled quantity gamma_t(j) appearing in the Baum-Welch reestimation algorithm. @@ -810,7 +810,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): # Emission symbol mapping, so change our intlist into a list of symbols return self._IntList_to_emission_symbols(obs), states - cdef int _gen_symbol(self, int q, double r): + cdef int _gen_symbol(self, int q, double r) noexcept: r""" Generate a symbol in state q using the randomly chosen floating point number r, which should be between 0 and 1. @@ -897,7 +897,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): else: return self._viterbi(obs) - cpdef _viterbi(self, IntList obs): + cpdef _viterbi(self, IntList obs) noexcept: r""" Used internally to compute the viterbi path, without rescaling. This can be useful for short sequences. @@ -977,7 +977,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): return state_sequence, log(mx) - cpdef _viterbi_scale(self, IntList obs): + cpdef _viterbi_scale(self, IntList obs) noexcept: r""" Used internally to compute the viterbi path with rescaling. @@ -1061,7 +1061,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): return state_sequence, mx - cdef TimeSeries _backward_scale_all(self, IntList obs, TimeSeries scale): + cdef TimeSeries _backward_scale_all(self, IntList obs, TimeSeries scale) noexcept: r""" Return the scaled matrix of values `\beta_t(i)` that appear in the backtracking algorithm. This function is used internally @@ -1108,7 +1108,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): t -= 1 return beta - cdef _forward_scale_all(self, IntList obs): + cdef _forward_scale_all(self, IntList obs) noexcept: r""" Return scaled values alpha_t(i), the sequence of scalings, and the log probability. @@ -1169,7 +1169,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel): # Termination return alpha, scale, log_probability - cdef TimeSeries _baum_welch_xi(self, TimeSeries alpha, TimeSeries beta, IntList obs): + cdef TimeSeries _baum_welch_xi(self, TimeSeries alpha, TimeSeries beta, IntList obs) noexcept: r""" Used internally to compute the scaled quantity xi_t(i,j) appearing in the Baum-Welch reestimation algorithm. diff --git a/src/sage/stats/hmm/util.pxd b/src/sage/stats/hmm/util.pxd index b0d399d9aaf..84a0e201a1b 100644 --- a/src/sage/stats/hmm/util.pxd +++ b/src/sage/stats/hmm/util.pxd @@ -1,7 +1,7 @@ from sage.stats.time_series cimport TimeSeries cdef class HMM_Util: - cpdef normalize_probability_TimeSeries(self, TimeSeries T, Py_ssize_t i, Py_ssize_t j) - cpdef TimeSeries initial_probs_to_TimeSeries(self, pi, bint normalize) - cpdef TimeSeries state_matrix_to_TimeSeries(self, A, int N, bint normalize) + cpdef normalize_probability_TimeSeries(self, TimeSeries T, Py_ssize_t i, Py_ssize_t j) noexcept + cpdef TimeSeries initial_probs_to_TimeSeries(self, pi, bint normalize) noexcept + cpdef TimeSeries state_matrix_to_TimeSeries(self, A, int N, bint normalize) noexcept diff --git a/src/sage/stats/hmm/util.pyx b/src/sage/stats/hmm/util.pyx index 553eb997364..fc849742b80 100644 --- a/src/sage/stats/hmm/util.pyx +++ b/src/sage/stats/hmm/util.pyx @@ -22,7 +22,7 @@ cdef class HMM_Util: """ A class used in order to share cdef's methods between different files. """ - cpdef normalize_probability_TimeSeries(self, TimeSeries T, Py_ssize_t i, Py_ssize_t j): + cpdef normalize_probability_TimeSeries(self, TimeSeries T, Py_ssize_t i, Py_ssize_t j) noexcept: """ This function is used internally by the Hidden Markov Models code. @@ -86,7 +86,7 @@ cdef class HMM_Util: - cpdef TimeSeries initial_probs_to_TimeSeries(self, pi, bint normalize): + cpdef TimeSeries initial_probs_to_TimeSeries(self, pi, bint normalize) noexcept: """ This function is used internally by the __init__ methods of various Hidden Markov Models. @@ -125,7 +125,7 @@ cdef class HMM_Util: return T - cpdef TimeSeries state_matrix_to_TimeSeries(self, A, int N, bint normalize): + cpdef TimeSeries state_matrix_to_TimeSeries(self, A, int N, bint normalize) noexcept: """ This function is used internally by the ``__init__`` methods of Hidden Markov Models to make a transition matrix from ``A``. diff --git a/src/sage/stats/intlist.pxd b/src/sage/stats/intlist.pxd index 9799b5c0a29..d63971aac14 100644 --- a/src/sage/stats/intlist.pxd +++ b/src/sage/stats/intlist.pxd @@ -9,5 +9,5 @@ cdef class IntList: cdef int* _values cdef Py_ssize_t _length - cpdef int prod(self) - cpdef int sum(self) + cpdef int prod(self) noexcept + cpdef int sum(self) noexcept diff --git a/src/sage/stats/intlist.pyx b/src/sage/stats/intlist.pyx index 1bfc74aed96..ce5abfc8b7b 100644 --- a/src/sage/stats/intlist.pyx +++ b/src/sage/stats/intlist.pyx @@ -323,7 +323,7 @@ cdef class IntList: cdef Py_ssize_t i return [self._values[i] for i in range(self._length)] - cpdef int sum(self): + cpdef int sum(self) noexcept: """ Return the sum of the entries of ``self``. @@ -347,7 +347,7 @@ cdef class IntList: sig_off() return s - cpdef int prod(self): + cpdef int prod(self) noexcept: """ Return the product of the entries of ``self``. @@ -544,7 +544,7 @@ cdef class IntList: return self.time_series().plot_histogram(*args, **kwds) -cdef IntList new_int_list(Py_ssize_t length): +cdef IntList new_int_list(Py_ssize_t length) noexcept: """ Function that is used internally to quickly create a new intlist without initializing any of the allocated memory. diff --git a/src/sage/stats/time_series.pxd b/src/sage/stats/time_series.pxd index 635b7faeaa9..7a044b52da9 100644 --- a/src/sage/stats/time_series.pxd +++ b/src/sage/stats/time_series.pxd @@ -1,5 +1,5 @@ cdef class TimeSeries: cdef double* _values cdef Py_ssize_t _length - cpdef rescale(self, double s) - cpdef double sum(self) + cpdef rescale(self, double s) noexcept + cpdef double sum(self) noexcept diff --git a/src/sage/stats/time_series.pyx b/src/sage/stats/time_series.pyx index 1ef69068015..ce51e65baab 100644 --- a/src/sage/stats/time_series.pyx +++ b/src/sage/stats/time_series.pyx @@ -892,7 +892,7 @@ cdef class TimeSeries: t._values[i] = self._values[i*k] return t - cpdef rescale(self, double s): + cpdef rescale(self, double s) noexcept: r""" Change ``self`` by multiplying every value in the series by ``s``. @@ -1223,7 +1223,7 @@ cdef class TimeSeries: t._values[i] = s return t - cpdef double sum(self): + cpdef double sum(self) noexcept: r""" Return the sum of all the entries of ``self``. @@ -2514,7 +2514,7 @@ cdef class TimeSeries: return y -cdef new_time_series(Py_ssize_t length): +cdef new_time_series(Py_ssize_t length) noexcept: r""" Return a new uninitialized time series of the given length. The entries of the time series are garbage. diff --git a/src/sage/structure/category_object.pxd b/src/sage/structure/category_object.pxd index 83d3d4967d4..6bd450c4f68 100644 --- a/src/sage/structure/category_object.pxd +++ b/src/sage/structure/category_object.pxd @@ -10,7 +10,7 @@ from sage.structure.sage_object cimport SageObject -cpdef check_default_category(default_category, category) +cpdef check_default_category(default_category, category) noexcept cdef class CategoryObject(SageObject): cdef public dict _cached_methods @@ -21,7 +21,7 @@ cdef class CategoryObject(SageObject): cdef object __weakref__ cdef long _hash_value - cdef getattr_from_category(self, name) + cdef getattr_from_category(self, name) noexcept -cpdef normalize_names(Py_ssize_t ngens, names) +cpdef normalize_names(Py_ssize_t ngens, names) noexcept cpdef bint certify_names(names) except -1 diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx index c06933494dc..3d187a13dba 100644 --- a/src/sage/structure/category_object.pyx +++ b/src/sage/structure/category_object.pyx @@ -63,7 +63,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.dynamic_class import DynamicMetaclass -cpdef inline check_default_category(default_category, category): +cpdef inline check_default_category(default_category, category) noexcept: ## The resulting category is guaranteed to be ## a sub-category of the default. if category is None: @@ -840,7 +840,7 @@ cdef class CategoryObject(SageObject): """ return self.getattr_from_category(name) - cdef getattr_from_category(self, name): + cdef getattr_from_category(self, name) noexcept: # Lookup a method or attribute from the category abstract classes. # See __getattr__ above for documentation. try: @@ -905,7 +905,7 @@ cdef class CategoryObject(SageObject): """ return dir_with_other_class(self, self.category().parent_class) -cpdef normalize_names(Py_ssize_t ngens, names): +cpdef normalize_names(Py_ssize_t ngens, names) noexcept: r""" Return a tuple of strings of variable names of length ngens given the input names. diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd index e070d1c32e4..8856950d685 100644 --- a/src/sage/structure/coerce.pxd +++ b/src/sage/structure/coerce.pxd @@ -1,11 +1,11 @@ from .parent cimport Parent from .coerce_dict cimport TripleDict -cpdef py_scalar_parent(py_type) -cpdef py_scalar_to_element(py) +cpdef py_scalar_parent(py_type) noexcept +cpdef py_scalar_to_element(py) noexcept cpdef bint parent_is_integers(P) except -1 -cpdef bint is_numpy_type(t) -cpdef bint is_mpmath_type(t) +cpdef bint is_numpy_type(t) noexcept +cpdef bint is_mpmath_type(t) noexcept cdef class CoercionModel: @@ -17,26 +17,26 @@ cdef class CoercionModel: # This MUST be a mapping to actions. cdef readonly TripleDict _action_maps - cpdef canonical_coercion(self, x, y) - cpdef bin_op(self, x, y, op) - cpdef richcmp(self, x, y, int op) + cpdef canonical_coercion(self, x, y) noexcept + cpdef bin_op(self, x, y, op) noexcept + cpdef richcmp(self, x, y, int op) noexcept - cpdef coercion_maps(self, R, S) - cpdef discover_coercion(self, R, S) - cpdef verify_coercion_maps(self, R, S, homs, bint fix=*) - cpdef verify_action(self, action, R, S, op, bint fix=*) + cpdef coercion_maps(self, R, S) noexcept + cpdef discover_coercion(self, R, S) noexcept + cpdef verify_coercion_maps(self, R, S, homs, bint fix=*) noexcept + cpdef verify_action(self, action, R, S, op, bint fix=*) noexcept - cpdef get_action(self, R, S, op=*, r=*, s=*) - cpdef discover_action(self, R, S, op, r=*, s=*) + cpdef get_action(self, R, S, op=*, r=*, s=*) noexcept + cpdef discover_action(self, R, S, op, r=*, s=*) noexcept cdef bint _record_exceptions - cpdef _record_exception(self) + cpdef _record_exception(self) noexcept cdef readonly list _exception_stack cdef bint _exceptions_cleared cdef TripleDict _division_parents - cpdef analyse(self, xp, yp, op=*) - cpdef division_parent(self, Parent P) + cpdef analyse(self, xp, yp, op=*) noexcept + cpdef division_parent(self, Parent P) noexcept # Unique global coercion_model instance diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index d8c3f684217..6dc194c5cf9 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -100,7 +100,7 @@ import traceback from fractions import Fraction cdef type FractionType = Fraction -cpdef py_scalar_parent(py_type): +cpdef py_scalar_parent(py_type) noexcept: """ Returns the Sage equivalent of the given python type, if one exists. If there is no equivalent, return None. @@ -184,7 +184,7 @@ cpdef py_scalar_parent(py_type): else: return None -cpdef py_scalar_to_element(x): +cpdef py_scalar_to_element(x) noexcept: """ Convert ``x`` to a Sage :class:`~sage.structure.element.Element` if possible. @@ -415,7 +415,7 @@ def parent_is_real_numerical(P): return P._is_real_numerical() -cpdef bint is_numpy_type(t): +cpdef bint is_numpy_type(t) noexcept: """ Return ``True`` if and only if `t` is a type whose name starts with ``numpy.`` @@ -466,7 +466,7 @@ cpdef bint is_numpy_type(t): return True return False -cpdef bint is_mpmath_type(t): +cpdef bint is_mpmath_type(t) noexcept: r""" Check whether the type ``t`` is a type whose name starts with either ``mpmath.`` or ``sage.libs.mpmath.``. @@ -688,7 +688,7 @@ cdef class CoercionModel: self._exceptions_cleared = True self._exception_stack = [] - cpdef _record_exception(self): + cpdef _record_exception(self) noexcept: r""" Pushes the last exception that occurred onto the stack for later reference, for internal use. @@ -923,7 +923,7 @@ cdef class CoercionModel: print("Result lives in {}".format(res)) return res - cpdef analyse(self, xp, yp, op=mul): + cpdef analyse(self, xp, yp, op=mul) noexcept: """ Emulate the process of doing arithmetic between xp and yp, returning a list of steps and the parent that the result will live in. @@ -1088,7 +1088,7 @@ cdef class CoercionModel: base = parent(self.canonical_coercion(a, b)[0]) return base - cpdef division_parent(self, Parent P): + cpdef division_parent(self, Parent P) noexcept: r""" Deduces where the result of division in ``P`` lies by calculating the inverse of ``P.one()`` or ``P.an_element()``. @@ -1127,7 +1127,7 @@ cdef class CoercionModel: self._division_parents.set(P, None, None, ret) return ret - cpdef bin_op(self, x, y, op): + cpdef bin_op(self, x, y, op) noexcept: """ Execute the operation ``op`` on `x` and `y`. @@ -1275,7 +1275,7 @@ cdef class CoercionModel: # This causes so much headache. raise bin_op_exception(op, x, y) - cpdef canonical_coercion(self, x, y): + cpdef canonical_coercion(self, x, y) noexcept: r""" Given two elements `x` and `y`, with parents `S` and `R` respectively, find a common parent `Z` such that there are coercions @@ -1421,7 +1421,7 @@ cdef class CoercionModel: raise TypeError("no common canonical parent for objects with parents: '%s' and '%s'"%(xp, yp)) - cpdef coercion_maps(self, R, S): + cpdef coercion_maps(self, R, S) noexcept: r""" Give two parents `R` and `S`, return a pair of coercion maps `f: R \rightarrow Z` and `g: S \rightarrow Z` , if such a `Z` @@ -1570,7 +1570,7 @@ cdef class CoercionModel: self._coercion_maps.set(S, R, None, swap) return homs - cpdef verify_coercion_maps(self, R, S, homs, bint fix=False): + cpdef verify_coercion_maps(self, R, S, homs, bint fix=False) noexcept: """ Make sure this is a valid pair of homomorphisms from `R` and `S` to a common parent. This function is used to protect the user against buggy parents. @@ -1639,7 +1639,7 @@ cdef class CoercionModel: return R_map, S_map - cpdef discover_coercion(self, R, S): + cpdef discover_coercion(self, R, S) noexcept: """ This actually implements the finding of coercion maps as described in the :meth:`coercion_maps` method. @@ -1718,7 +1718,7 @@ cdef class CoercionModel: return None - cpdef get_action(self, R, S, op=mul, r=None, s=None): + cpdef get_action(self, R, S, op=mul, r=None, s=None) noexcept: """ Get the action of R on S or S on R associated to the operation op. @@ -1759,7 +1759,7 @@ cdef class CoercionModel: self._action_maps.set(R, S, op, action) return action - cpdef verify_action(self, action, R, S, op, bint fix=True): + cpdef verify_action(self, action, R, S, op, bint fix=True) noexcept: r""" Verify that ``action`` takes an element of R on the left and S on the right, raising an error if not. @@ -1818,7 +1818,7 @@ cdef class CoercionModel: return action - cpdef discover_action(self, R, S, op, r=None, s=None): + cpdef discover_action(self, R, S, op, r=None, s=None) noexcept: """ INPUT: @@ -1956,7 +1956,7 @@ cdef class CoercionModel: return None - cpdef richcmp(self, x, y, int op): + cpdef richcmp(self, x, y, int op) noexcept: """ Given two arbitrary objects ``x`` and ``y``, coerce them to a common parent and compare them using rich comparison operator diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx index 6df2aec6695..7b1d9491f56 100644 --- a/src/sage/structure/coerce_actions.pyx +++ b/src/sage/structure/coerce_actions.pyx @@ -26,10 +26,10 @@ from sage.categories.action cimport InverseAction, PrecomposedAction from sage.arith.long cimport integer_check_long -cdef _record_exception(): +cdef _record_exception() noexcept: coercion_model._record_exception() -cdef inline an_element(R): +cdef inline an_element(R) noexcept: if isinstance(R, Parent): return R.an_element() else: @@ -118,7 +118,7 @@ cdef class ActOnAction(GenericAction): """ Class for actions defined via the _act_on_ method. """ - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: """ TESTS:: @@ -140,7 +140,7 @@ cdef class ActedUponAction(GenericAction): """ Class for actions defined via the _acted_upon_ method. """ - cpdef _act_(self, g, x): + cpdef _act_(self, g, x) noexcept: """ TESTS:: @@ -586,7 +586,7 @@ cdef class ModuleAction(Action): cdef class LeftModuleAction(ModuleAction): - cpdef _act_(self, g, a): + cpdef _act_(self, g, a) noexcept: """ A left module action is an action that takes the ring element as the first argument (the left side) and the module element as the second @@ -623,7 +623,7 @@ cdef class LeftModuleAction(ModuleAction): cdef class RightModuleAction(ModuleAction): - cpdef _act_(self, g, a): + cpdef _act_(self, g, a) noexcept: """ A right module action is an action that takes the module element as the first argument (the left side) and the ring element as the second @@ -743,7 +743,7 @@ cdef class IntegerMulAction(IntegerAction): test = m + (-m) # make sure addition and negation is allowed super().__init__(Z, M, is_left, operator.mul) - cpdef _act_(self, nn, a): + cpdef _act_(self, nn, a) noexcept: """ EXAMPLES: @@ -879,7 +879,7 @@ cdef class IntegerPowAction(IntegerAction): raise TypeError(f"no integer powering action defined on {M}") super().__init__(Z, M, False, operator.pow) - cpdef _act_(self, n, a): + cpdef _act_(self, n, a) noexcept: """ EXAMPLES: @@ -916,7 +916,7 @@ cdef class IntegerPowAction(IntegerAction): return "Integer Powering" -cdef inline fast_mul(a, n): +cdef inline fast_mul(a, n) noexcept: if n < 0: n = -n a = -a @@ -935,7 +935,7 @@ cdef inline fast_mul(a, n): n = n >> 1 return sum -cdef inline fast_mul_long(a, long s): +cdef inline fast_mul_long(a, long s) noexcept: # It's important to change the signed s to an unsigned n, # since -LONG_MIN = LONG_MIN. See Issue #17844. cdef unsigned long n diff --git a/src/sage/structure/coerce_dict.pxd b/src/sage/structure/coerce_dict.pxd index be14effa0f8..8542545a2f8 100644 --- a/src/sage/structure/coerce_dict.pxd +++ b/src/sage/structure/coerce_dict.pxd @@ -18,8 +18,8 @@ cdef class MonoDict: cdef bint weak_values cdef eraser - cdef mono_cell* lookup(self, PyObject* key) - cdef get(self, k) + cdef mono_cell* lookup(self, PyObject* key) noexcept + cdef get(self, k) noexcept cdef int set(self, k, value) except -1 cdef int resize(self) except -1 @@ -44,7 +44,7 @@ cdef class TripleDict: cdef bint weak_values cdef eraser - cdef triple_cell* lookup(self, PyObject* key1, PyObject* key2, PyObject* key3) - cdef get(self, k1, k2, k3) + cdef triple_cell* lookup(self, PyObject* key1, PyObject* key2, PyObject* key3) noexcept + cdef get(self, k1, k2, k3) noexcept cdef int set(self, k1, k2, k3, value) except -1 cdef int resize(self) except -1 diff --git a/src/sage/structure/coerce_dict.pyx b/src/sage/structure/coerce_dict.pyx index ef86c6af35c..269f1be5fd5 100644 --- a/src/sage/structure/coerce_dict.pyx +++ b/src/sage/structure/coerce_dict.pyx @@ -79,7 +79,7 @@ cdef extern from "sage/cpython/pyx_visit.h": cdef type KeyedRef, ref from weakref import KeyedRef, ref -cdef inline bint is_dead_keyedref(x): +cdef inline bint is_dead_keyedref(x) noexcept: """ Check whether ``x`` is a ``KeyedRef`` which is dead. """ @@ -93,7 +93,7 @@ cdef object dummy = object() cdef PyObject* deleted_key = dummy -cdef inline bint valid(PyObject* obj): +cdef inline bint valid(PyObject* obj) noexcept: """ Check whether ``obj`` points to a valid object """ @@ -110,7 +110,7 @@ cdef class ObjectWrapper: cdef PyObject* obj -cdef inline ObjectWrapper wrap(obj): +cdef inline ObjectWrapper wrap(obj) noexcept: """ Wrap a given Python object in an :class:`ObjectWrapper`. """ @@ -126,7 +126,7 @@ cdef inline PyObject* unwrap(w) except? NULL: return (w).obj -cdef extract_mono_cell(mono_cell* cell): +cdef extract_mono_cell(mono_cell* cell) noexcept: """ Take the refcounted components from a mono_cell, put them in a tuple and return it. The mono_cell itself is marked as "freed". @@ -151,7 +151,7 @@ cdef extract_mono_cell(mono_cell* cell): return t -cdef extract_triple_cell(triple_cell* cell): +cdef extract_triple_cell(triple_cell* cell) noexcept: # See extract_mono_cell for documentation assert valid(cell.key_id1) t = PyTuple_New(4) @@ -425,7 +425,7 @@ cdef class MonoDict: - Simon King (2013-02) - Nils Bruin (2013-11) """ - cdef mono_cell* lookup(self, PyObject* key): + cdef mono_cell* lookup(self, PyObject* key) noexcept: """ Return a pointer to where ``key`` should be stored in this :class:`MonoDict`. @@ -644,7 +644,7 @@ cdef class MonoDict: """ return self.get(k) - cdef get(self, k): + cdef get(self, k) noexcept: cdef mono_cell* cursor = self.lookup(k) if not valid(cursor.key_id): raise KeyError(k) @@ -844,7 +844,7 @@ cdef class MonoDict: # and we have to replicate here) is the "eraser" which in its closure # stores a reference back to the dictionary itself (meaning that # MonoDicts only disappear on cyclic GC). -cdef int MonoDict_traverse(MonoDict self, visitproc visit, void* arg): +cdef int MonoDict_traverse(MonoDict self, visitproc visit, void* arg) noexcept: if not self.mask: return 0 Py_VISIT3(self.eraser, visit, arg) @@ -856,7 +856,7 @@ cdef int MonoDict_traverse(MonoDict self, visitproc visit, void* arg): Py_VISIT3(cursor.value, visit, arg) -cdef int MonoDict_clear(MonoDict self): +cdef int MonoDict_clear(MonoDict self) noexcept: """ We clear a monodict by taking first taking away the table before dereffing its contents. That shortcuts callbacks, so we deref the @@ -1123,7 +1123,7 @@ cdef class TripleDict: - Nils Bruin, 2013-11 """ - cdef triple_cell* lookup(self, PyObject* key1, PyObject* key2, PyObject* key3): + cdef triple_cell* lookup(self, PyObject* key1, PyObject* key2, PyObject* key3) noexcept: """ Return a pointer to where ``(key1, key2, key3)`` should be stored in this :class:`MonoDict`. @@ -1320,7 +1320,7 @@ cdef class TripleDict: raise KeyError(k) return self.get(k1, k2, k3) - cdef get(self, k1, k2, k3): + cdef get(self, k1, k2, k3) noexcept: cdef triple_cell* cursor = self.lookup(k1, k2, k3) if not valid(cursor.key_id1): raise KeyError((k1, k2, k3)) @@ -1524,7 +1524,7 @@ cdef class TripleDict: # and we have to replicate here) is the "eraser" which in its closure # stores a reference back to the dictionary itself (meaning that # TripleDicts only disappear on cyclic GC). -cdef int TripleDict_traverse(TripleDict self, visitproc visit, void* arg): +cdef int TripleDict_traverse(TripleDict self, visitproc visit, void* arg) noexcept: if not self.mask: return 0 Py_VISIT3(self.eraser, visit, arg) @@ -1538,7 +1538,7 @@ cdef int TripleDict_traverse(TripleDict self, visitproc visit, void* arg): Py_VISIT3(cursor.value, visit, arg) -cdef int TripleDict_clear(TripleDict self): +cdef int TripleDict_clear(TripleDict self) noexcept: if not self.mask: return 0 cdef size_t mask = self.mask diff --git a/src/sage/structure/coerce_maps.pxd b/src/sage/structure/coerce_maps.pxd index 0afc1a96adb..e3e969d0266 100644 --- a/src/sage/structure/coerce_maps.pxd +++ b/src/sage/structure/coerce_maps.pxd @@ -24,4 +24,4 @@ cdef class CallableConvertMap(Map): cdef _func -cdef Map CCallableConvertMap(domain, codomain, void* func, name) +cdef Map CCallableConvertMap(domain, codomain, void* func, name) noexcept diff --git a/src/sage/structure/coerce_maps.pyx b/src/sage/structure/coerce_maps.pyx index 1c1464a7899..be6d4807297 100644 --- a/src/sage/structure/coerce_maps.pyx +++ b/src/sage/structure/coerce_maps.pyx @@ -91,7 +91,7 @@ cdef class DefaultConvertMap(Map): """ return self._repr_type_str or ("Coercion" if self._is_coercion else "Conversion") - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Create an element of the codomain from a single element of the domain. @@ -110,7 +110,7 @@ cdef class DefaultConvertMap(Map): print(type(C._element_constructor), C._element_constructor) raise - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ Create an element of the codomain from an element of the domain, with extra arguments. @@ -152,7 +152,7 @@ cdef class DefaultConvertMap_unique(DefaultConvertMap): used when the element_constructor is a bound method (whose self argument is assumed to be bound to the codomain). """ - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: cdef Parent C = self._codomain try: return C._element_constructor(x) @@ -162,7 +162,7 @@ cdef class DefaultConvertMap_unique(DefaultConvertMap): print(type(C._element_constructor), C._element_constructor) raise - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: cdef Parent C = self._codomain try: if len(args) == 0: @@ -212,7 +212,7 @@ cdef class NamedConvertMap(Map): self.method_name = method_name self._repr_type_str = "Conversion via %s method" % self.method_name - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -239,7 +239,7 @@ cdef class NamedConvertMap(Map): slots['method_name'] = self.method_name return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -265,7 +265,7 @@ cdef class NamedConvertMap(Map): self.method_name = _slots['method_name'] Map._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -299,7 +299,7 @@ cdef class NamedConvertMap(Map): e = m._call_(e) return e - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ EXAMPLES:: @@ -366,7 +366,7 @@ cdef class CallableConvertMap(Map): except AttributeError: self._repr_type_str = "Conversion via %s" % self._func - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -386,7 +386,7 @@ cdef class CallableConvertMap(Map): slots['_parent_as_first_arg'] = self._parent_as_first_arg return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -405,7 +405,7 @@ cdef class CallableConvertMap(Map): self._parent_as_first_arg = _slots['_parent_as_first_arg'] Map._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ Because self._func may be anything we do a little bit of sanity checking (the return value must be an element with the correct parent). @@ -447,7 +447,7 @@ cdef class CallableConvertMap(Map): raise RuntimeError("BUG in coercion model: {} returned element with wrong parent (expected {} got {})".format(self._func, C, y._parent)) return y - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ TESTS:: @@ -485,7 +485,7 @@ cdef class CallableConvertMap(Map): cdef class CCallableConvertMap_class(Map): - cdef Element (*_func)(Parent, object) + cdef Element (*_func)(Parent, object) noexcept cdef public _name def __init__(self, domain, codomain, name): @@ -495,7 +495,7 @@ cdef class CCallableConvertMap_class(Map): self._coerce_cost = 10 self._name = name - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ TESTS:: @@ -526,7 +526,7 @@ cdef class CCallableConvertMap_class(Map): return "Conversion via c call '%s'" % self._name -cdef Map CCallableConvertMap(domain, codomain, void* func, name): +cdef Map CCallableConvertMap(domain, codomain, void* func, name) noexcept: """ Use this to create a map from domain to codomain by calling func (which must be a function pointer taking a Parent and object, and @@ -540,7 +540,7 @@ cdef Map CCallableConvertMap(domain, codomain, void* func, name): map._func = func return map -cpdef Element _ccall_test_function(codomain, x): +cpdef Element _ccall_test_function(codomain, x) noexcept: """ For testing CCallableConvertMap_class. Returns x*x*x-x in the codomain. @@ -587,23 +587,23 @@ cdef class ListMorphism(Map): self._real_morphism = real_morphism self._repr_type_str = "List" - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: slots = Map._extra_slots(self) slots['_real_morphism'] = self._real_morphism return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: self._real_morphism = _slots['_real_morphism'] Map._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: try: x = x._data except AttributeError: x = list(x) return self._real_morphism._call_(x) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: try: x = x._data except AttributeError: @@ -632,7 +632,7 @@ cdef class TryMap(Map): else: self._error_types = error_types - cdef dict _extra_slots(self): + cdef dict _extra_slots(self) noexcept: """ Helper for copying and pickling. @@ -655,7 +655,7 @@ cdef class TryMap(Map): slots['_error_types'] = self._error_types return slots - cdef _update_slots(self, dict _slots): + cdef _update_slots(self, dict _slots) noexcept: """ Helper for copying and pickling. @@ -677,7 +677,7 @@ cdef class TryMap(Map): self._error_types = _slots['_error_types'] Map._update_slots(self, _slots) - cpdef Element _call_(self, x): + cpdef Element _call_(self, x) noexcept: """ EXAMPLES:: @@ -696,7 +696,7 @@ cdef class TryMap(Map): except self._error_types: return self._map_b._call_(x) - cpdef Element _call_with_args(self, x, args=(), kwds={}): + cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept: """ EXAMPLES:: diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd index 20c556b985e..1cef67617ff 100644 --- a/src/sage/structure/element.pxd +++ b/src/sage/structure/element.pxd @@ -3,7 +3,7 @@ from .parent cimport Parent from sage.misc.inherit_comparison cimport InheritComparisonMetaclass -cpdef inline parent(x): +cpdef inline parent(x) noexcept: """ Return the parent of the element ``x``. @@ -61,7 +61,7 @@ cpdef inline parent(x): return type(x) -cdef inline int classify_elements(left, right): +cdef inline int classify_elements(left, right) noexcept: """ Given two objects, at least one which is an :class:`Element`, classify their type and parent. This is a finer version of @@ -102,13 +102,13 @@ cdef inline int classify_elements(left, right): return 0o07 # Functions to help understand the result of classify_elements() -cdef inline bint BOTH_ARE_ELEMENT(int cl): +cdef inline bint BOTH_ARE_ELEMENT(int cl) noexcept: return cl & 0o04 -cdef inline bint HAVE_SAME_PARENT(int cl): +cdef inline bint HAVE_SAME_PARENT(int cl) noexcept: return cl & 0o20 -cpdef inline bint have_same_parent(left, right): +cpdef inline bint have_same_parent(left, right) noexcept: """ Return ``True`` if and only if ``left`` and ``right`` have the same parent. @@ -143,36 +143,36 @@ cpdef inline bint have_same_parent(left, right): return HAVE_SAME_PARENT(classify_elements(left, right)) -cdef unary_op_exception(op, x) -cdef bin_op_exception(op, x, y) +cdef unary_op_exception(op, x) noexcept +cdef bin_op_exception(op, x, y) noexcept cdef class Element(SageObject): cdef Parent _parent - cpdef _richcmp_(left, right, int op) + cpdef _richcmp_(left, right, int op) noexcept cpdef int _cmp_(left, right) except -2 - cpdef base_extend(self, R) + cpdef base_extend(self, R) noexcept - cdef getattr_from_category(self, name) + cdef getattr_from_category(self, name) noexcept - cpdef _act_on_(self, x, bint self_on_left) - cpdef _acted_upon_(self, x, bint self_on_left) + cpdef _act_on_(self, x, bint self_on_left) noexcept + cpdef _acted_upon_(self, x, bint self_on_left) noexcept - cdef _add_(self, other) - cdef _sub_(self, other) - cdef _neg_(self) - cdef _add_long(self, long n) + cdef _add_(self, other) noexcept + cdef _sub_(self, other) noexcept + cdef _neg_(self) noexcept + cdef _add_long(self, long n) noexcept - cdef _mul_(self, other) - cdef _mul_long(self, long n) - cdef _matmul_(self, other) - cdef _div_(self, other) - cdef _floordiv_(self, other) - cdef _mod_(self, other) + cdef _mul_(self, other) noexcept + cdef _mul_long(self, long n) noexcept + cdef _matmul_(self, other) noexcept + cdef _div_(self, other) noexcept + cdef _floordiv_(self, other) noexcept + cdef _mod_(self, other) noexcept - cdef _pow_(self, other) - cdef _pow_int(self, n) - cdef _pow_long(self, long n) + cdef _pow_(self, other) noexcept + cdef _pow_int(self, n) noexcept + cdef _pow_long(self, long n) noexcept cdef class ElementWithCachedMethod(Element): @@ -183,33 +183,33 @@ cdef class ModuleElement(Element) # forward declaration cdef class RingElement(ModuleElement) # forward declaration cdef class ModuleElement(Element): - cpdef _add_(self, other) - cpdef _sub_(self, other) - cpdef _neg_(self) + cpdef _add_(self, other) noexcept + cpdef _sub_(self, other) noexcept + cpdef _neg_(self) noexcept # self._rmul_(x) is x * self - cpdef _lmul_(self, Element right) + cpdef _lmul_(self, Element right) noexcept # self._lmul_(x) is self * x - cpdef _rmul_(self, Element left) + cpdef _rmul_(self, Element left) noexcept cdef class ModuleElementWithMutability(ModuleElement): cdef bint _is_immutable - cpdef bint is_immutable(self) - cpdef bint is_mutable(self) + cpdef bint is_immutable(self) noexcept + cpdef bint is_mutable(self) noexcept cdef class MonoidElement(Element): - cpdef _pow_int(self, n) + cpdef _pow_int(self, n) noexcept cdef class MultiplicativeGroupElement(MonoidElement): - cpdef _div_(self, other) + cpdef _div_(self, other) noexcept cdef class AdditiveGroupElement(ModuleElement): pass cdef class RingElement(ModuleElement): - cpdef _mul_(self, other) - cpdef _div_(self, other) - cpdef _pow_int(self, n) + cpdef _mul_(self, other) noexcept + cpdef _div_(self, other) noexcept + cpdef _pow_int(self, n) noexcept cdef class CommutativeRingElement(RingElement): pass @@ -224,11 +224,11 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): pass cdef class EuclideanDomainElement(PrincipalIdealDomainElement): - cpdef _floordiv_(self, other) - cpdef _mod_(self, other) + cpdef _floordiv_(self, other) noexcept + cpdef _mod_(self, other) noexcept cdef class FieldElement(CommutativeRingElement): - cpdef _floordiv_(self, other) + cpdef _floordiv_(self, other) noexcept cdef class AlgebraElement(RingElement): pass @@ -248,13 +248,13 @@ cdef class Vector(ModuleElementWithMutability): # Return the dot product using the simple metric # $e_i \cdot e_j = \delta_{ij}$. The first assumes that the parents # are equal, both assume that the degrees are equal. - cpdef _dot_product_(Vector left, Vector right) - cpdef _dot_product_coerce_(Vector left, Vector right) + cpdef _dot_product_(Vector left, Vector right) noexcept + cpdef _dot_product_coerce_(Vector left, Vector right) noexcept - cpdef _pairwise_product_(Vector left, Vector right) # override, call if parents the same + cpdef _pairwise_product_(Vector left, Vector right) noexcept # override, call if parents the same - cdef bint is_sparse_c(self) - cdef bint is_dense_c(self) + cdef bint is_sparse_c(self) noexcept + cdef bint is_dense_c(self) noexcept cdef class Matrix(ModuleElement): @@ -262,9 +262,9 @@ cdef class Matrix(ModuleElement): cdef Py_ssize_t _nrows cdef Py_ssize_t _ncols - cdef _vector_times_matrix_(matrix_right, Vector vector_left) # OK to override, AND call directly - cdef _matrix_times_vector_(matrix_left, Vector vector_right) # OK to override, AND call directly - cdef _matrix_times_matrix_(left, Matrix right) # OK to override, AND call directly + cdef _vector_times_matrix_(matrix_right, Vector vector_left) noexcept # OK to override, AND call directly + cdef _matrix_times_vector_(matrix_left, Vector vector_right) noexcept # OK to override, AND call directly + cdef _matrix_times_matrix_(left, Matrix right) noexcept # OK to override, AND call directly - cdef bint is_sparse_c(self) - cdef bint is_dense_c(self) + cdef bint is_sparse_c(self) noexcept + cdef bint is_dense_c(self) noexcept diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 543506e9a74..f1cf9d26ac7 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -324,7 +324,7 @@ def make_element(_class, _dict, parent): return make_element_old(_class, _dict, parent) -cdef unary_op_exception(op, x): +cdef unary_op_exception(op, x) noexcept: try: op = op.__name__ op = _coerce_op_symbols[op] @@ -334,7 +334,7 @@ cdef unary_op_exception(op, x): return TypeError(f"unsupported operand parent for {op}: '{px}'") -cdef bin_op_exception(op, x, y): +cdef bin_op_exception(op, x, y) noexcept: try: op = op.__name__ op = _coerce_op_symbols[op] @@ -488,7 +488,7 @@ cdef class Element(SageObject): """ return self.getattr_from_category(name) - cdef getattr_from_category(self, name): + cdef getattr_from_category(self, name) noexcept: # Lookup a method or attribute from the category abstract classes. # See __getattr__ above for documentation. cdef Parent P = self._parent @@ -636,7 +636,7 @@ cdef class Element(SageObject): """ raise NotImplementedError - cpdef base_extend(self, R): + cpdef base_extend(self, R) noexcept: cdef Parent V V = self._parent.base_extend(R) return V.coerce(self) @@ -937,7 +937,7 @@ cdef class Element(SageObject): """ return self.subs(in_dict,**kwds) - cpdef _act_on_(self, x, bint self_on_left): + cpdef _act_on_(self, x, bint self_on_left) noexcept: """ Use this method to implement ``self`` acting on ``x``. @@ -946,7 +946,7 @@ cdef class Element(SageObject): """ return None - cpdef _acted_upon_(self, x, bint self_on_left): + cpdef _acted_upon_(self, x, bint self_on_left) noexcept: """ Use this method to implement ``self`` acted on by x. @@ -1106,7 +1106,7 @@ cdef class Element(SageObject): else: return coercion_model.richcmp(self, other, op) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: r""" Basic default implementation of rich comparisons for elements with equal parents. @@ -1248,7 +1248,7 @@ cdef class Element(SageObject): # reversed addition (__radd__). return NotImplemented - cdef _add_(self, other): + cdef _add_(self, other) noexcept: """ Virtual addition method for elements with identical parents. @@ -1278,7 +1278,7 @@ cdef class Element(SageObject): else: return python_op(other) - cdef _add_long(self, long n): + cdef _add_long(self, long n) noexcept: """ Generic path for adding a C long, assumed to commute. @@ -1360,7 +1360,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _sub_(self, other): + cdef _sub_(self, other) noexcept: """ Virtual subtraction method for elements with identical parents. @@ -1414,7 +1414,7 @@ cdef class Element(SageObject): """ return self._neg_() - cdef _neg_(self): + cdef _neg_(self) noexcept: """ Virtual unary negation method for elements. @@ -1528,7 +1528,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _mul_(self, other): + cdef _mul_(self, other) noexcept: """ Virtual multiplication method for elements with identical parents. @@ -1558,7 +1558,7 @@ cdef class Element(SageObject): else: return python_op(other) - cdef _mul_long(self, long n): + cdef _mul_long(self, long n) noexcept: """ Generic path for multiplying by a C long, assumed to commute. @@ -1640,7 +1640,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _matmul_(self, other): + cdef _matmul_(self, other) noexcept: """ Virtual matrix multiplication method for elements with identical parents. @@ -1743,7 +1743,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _div_(self, other): + cdef _div_(self, other) noexcept: """ Virtual division method for elements with identical parents. This is called for Python 2 division as well as true division. @@ -1844,7 +1844,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _floordiv_(self, other): + cdef _floordiv_(self, other) noexcept: """ Virtual floor division method for elements with identical parents. @@ -1944,7 +1944,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _mod_(self, other): + cdef _mod_(self, other) noexcept: """ Virtual modulo method for elements with identical parents. @@ -2071,7 +2071,7 @@ cdef class Element(SageObject): except TypeError: return NotImplemented - cdef _pow_(self, other): + cdef _pow_(self, other) noexcept: """ Virtual powering method for elements with identical parents. @@ -2101,7 +2101,7 @@ cdef class Element(SageObject): else: return python_op(other) - cdef _pow_int(self, other): + cdef _pow_int(self, other) noexcept: """ Virtual powering method for powering to an integer exponent. @@ -2131,7 +2131,7 @@ cdef class Element(SageObject): else: return python_op(other) - cdef _pow_long(self, long n): + cdef _pow_long(self, long n) noexcept: """ Generic path for powering with a C long. """ @@ -2308,7 +2308,7 @@ cdef class ElementWithCachedMethod(Element): True """ - cdef getattr_from_category(self, name): + cdef getattr_from_category(self, name) noexcept: """ This getattr method ensures that cached methods and lazy attributes can be inherited from the element class of a category. @@ -2376,7 +2376,7 @@ cdef class ModuleElement(Element): """ Generic element of a module. """ - cpdef _add_(self, other): + cpdef _add_(self, other) noexcept: """ Abstract addition method @@ -2391,7 +2391,7 @@ cdef class ModuleElement(Element): """ raise NotImplementedError(f"addition not implemented for {self._parent}") - cdef _add_long(self, long n): + cdef _add_long(self, long n) noexcept: """ Generic path for adding a C long, assumed to commute. """ @@ -2399,21 +2399,21 @@ cdef class ModuleElement(Element): return self return coercion_model.bin_op(self, n, add) - cpdef _sub_(self, other): + cpdef _sub_(self, other) noexcept: """ Default implementation of subtraction using addition and negation. """ return self + (-other) - cpdef _neg_(self): + cpdef _neg_(self) noexcept: """ Default implementation of negation using multiplication with -1. """ return self._mul_long(-1) - cdef _mul_long(self, long n): + cdef _mul_long(self, long n) noexcept: """ Generic path for multiplying by a C long, assumed to commute. """ @@ -2422,7 +2422,7 @@ cdef class ModuleElement(Element): return coercion_model.bin_op(self, n, mul) # rmul -- left * self - cpdef _rmul_(self, Element left): + cpdef _rmul_(self, Element left) noexcept: """ Reversed scalar multiplication for module elements with the module element on the right and the scalar on the left. @@ -2432,7 +2432,7 @@ cdef class ModuleElement(Element): return self._lmul_(left) # lmul -- self * right - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ Scalar multiplication for module elements with the module element on the left and the scalar on the right. @@ -2490,7 +2490,7 @@ cdef class ModuleElementWithMutability(ModuleElement): """ self._is_immutable = 1 - cpdef bint is_mutable(self): + cpdef bint is_mutable(self) noexcept: """ Return True if this vector is mutable, i.e., the entries can be changed. @@ -2505,7 +2505,7 @@ cdef class ModuleElementWithMutability(ModuleElement): """ return not self._is_immutable - cpdef bint is_immutable(self): + cpdef bint is_immutable(self) noexcept: """ Return True if this vector is immutable, i.e., the entries cannot be changed. @@ -2551,7 +2551,7 @@ cdef class MonoidElement(Element): """ raise NotImplementedError - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ Return the (integral) power of self. """ @@ -2619,7 +2619,7 @@ cdef class MultiplicativeGroupElement(MonoidElement): """ return self.multiplicative_order() - cpdef _div_(self, right): + cpdef _div_(self, right) noexcept: """ Default implementation of division using multiplication by the inverse. @@ -2644,7 +2644,7 @@ def is_RingElement(x): cdef class RingElement(ModuleElement): - cpdef _mul_(self, other): + cpdef _mul_(self, other) noexcept: """ Abstract multiplication method @@ -2662,7 +2662,7 @@ cdef class RingElement(ModuleElement): def is_one(self): return self == self._parent.one() - cpdef _pow_int(self, n): + cpdef _pow_int(self, n) noexcept: """ Return the (integral) power of self. @@ -2745,7 +2745,7 @@ cdef class RingElement(ModuleElement): l.append(x) return l - cpdef _div_(self, other): + cpdef _div_(self, other) noexcept: """ Default implementation of division using the fraction field. """ @@ -3403,10 +3403,10 @@ cdef class Expression(CommutativeRingElement): ############################################## cdef class Vector(ModuleElementWithMutability): - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: raise NotImplementedError - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: raise NotImplementedError def __mul__(left, right): @@ -3684,13 +3684,13 @@ cdef class Vector(ModuleElementWithMutability): return (left)._dot_product_(right) return coercion_model.bin_op(left, right, mul) - cpdef _dot_product_(Vector left, Vector right): + cpdef _dot_product_(Vector left, Vector right) noexcept: return left._dot_product_coerce_(right) - cpdef _dot_product_coerce_(Vector left, Vector right): + cpdef _dot_product_coerce_(Vector left, Vector right) noexcept: raise bin_op_exception('*', left, right) - cpdef _pairwise_product_(Vector left, Vector right): + cpdef _pairwise_product_(Vector left, Vector right) noexcept: raise TypeError("unsupported operation for '%s' and '%s'"%(parent(left), parent(right))) def __truediv__(self, right): @@ -3774,10 +3774,10 @@ def is_Vector(x): cdef class Matrix(ModuleElement): - cdef bint is_sparse_c(self): + cdef bint is_sparse_c(self) noexcept: raise NotImplementedError - cdef bint is_dense_c(self): + cdef bint is_dense_c(self) noexcept: raise NotImplementedError def __mul__(left, right): @@ -4153,13 +4153,13 @@ cdef class Matrix(ModuleElement): return right.solve_left(left) return coercion_model.bin_op(left, right, truediv) - cdef _vector_times_matrix_(matrix_right, Vector vector_left): + cdef _vector_times_matrix_(matrix_right, Vector vector_left) noexcept: raise TypeError - cdef _matrix_times_vector_(matrix_left, Vector vector_right): + cdef _matrix_times_vector_(matrix_left, Vector vector_right) noexcept: raise TypeError - cdef _matrix_times_matrix_(left, Matrix right): + cdef _matrix_times_matrix_(left, Matrix right) noexcept: raise TypeError @@ -4289,7 +4289,7 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): def quo_rem(self, other): raise NotImplementedError - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Quotient of division of ``self`` by other. This is denoted //. @@ -4312,7 +4312,7 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): Q, _ = self.quo_rem(right) return Q - cpdef _mod_(self, other): + cpdef _mod_(self, other) noexcept: """ Remainder of division of ``self`` by other. @@ -4351,7 +4351,7 @@ def is_FieldElement(x): return isinstance(x, FieldElement) cdef class FieldElement(CommutativeRingElement): - cpdef _floordiv_(self, right): + cpdef _floordiv_(self, right) noexcept: """ Return the quotient of self and other. Since these are field elements, the floor division is exactly the same as usual division. @@ -4508,7 +4508,7 @@ cdef class InfinityElement(RingElement): # ################################################################################# -cpdef canonical_coercion(x, y): +cpdef canonical_coercion(x, y) noexcept: """ ``canonical_coercion(x,y)`` is what is called before doing an arithmetic operation between ``x`` and ``y``. It returns a pair ``(z,w)`` @@ -4527,7 +4527,7 @@ cpdef canonical_coercion(x, y): return coercion_model.canonical_coercion(x,y) -cpdef bin_op(x, y, op): +cpdef bin_op(x, y, op) noexcept: return coercion_model.bin_op(x, y, op) diff --git a/src/sage/structure/element_wrapper.pxd b/src/sage/structure/element_wrapper.pxd index 4ae146b3dd5..308f4a749ce 100644 --- a/src/sage/structure/element_wrapper.pxd +++ b/src/sage/structure/element_wrapper.pxd @@ -4,8 +4,8 @@ from sage.structure.element cimport Element cdef class ElementWrapper(Element): cdef public object value - cpdef _richcmp_(left, right, int op) - cpdef bint _lt_by_value(self, other) + cpdef _richcmp_(left, right, int op) noexcept + cpdef bint _lt_by_value(self, other) noexcept cdef class ElementWrapperCheckWrappedClass(ElementWrapper): pass diff --git a/src/sage/structure/element_wrapper.pyx b/src/sage/structure/element_wrapper.pyx index 3aa87527d92..42dedbf03c3 100644 --- a/src/sage/structure/element_wrapper.pyx +++ b/src/sage/structure/element_wrapper.pyx @@ -293,7 +293,7 @@ cdef class ElementWrapper(Element): return left._richcmp_(right, op) return coercion_model.richcmp(left, right, op) - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Return ``True`` if ``left`` compares with ``right`` based on ``op``. @@ -357,7 +357,7 @@ cdef class ElementWrapper(Element): return self.value != (right).value return False - cpdef bint _lt_by_value(self, other): + cpdef bint _lt_by_value(self, other) noexcept: """ Return whether ``self`` is strictly smaller than ``other``. diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx index ddb55501d94..1b83ea0c2a9 100644 --- a/src/sage/structure/factory.pyx +++ b/src/sage/structure/factory.pyx @@ -372,7 +372,7 @@ cdef class UniqueFactory(SageObject): version = self.get_version(sage_version) return self.get_object(version, key, kwds) - cpdef get_object(self, version, key, extra_args): + cpdef get_object(self, version, key, extra_args) noexcept: """ Returns the object corresponding to ``key``, creating it with ``extra_args`` if necessary (for example, it isn't in the cache @@ -436,7 +436,7 @@ cdef class UniqueFactory(SageObject): pass return obj - cpdef get_version(self, sage_version): + cpdef get_version(self, sage_version) noexcept: """ This is provided to allow more or less granular control over pickle versioning. Objects pickled in the same version of Sage @@ -507,7 +507,7 @@ cdef class UniqueFactory(SageObject): """ raise NotImplementedError - cpdef other_keys(self, key, obj): + cpdef other_keys(self, key, obj) noexcept: """ Sometimes during object creation, certain defaults are chosen which may result in a new (more specific) key. This allows the more specific @@ -534,7 +534,7 @@ cdef class UniqueFactory(SageObject): """ return [] - cpdef reduce_data(self, obj): + cpdef reduce_data(self, obj) noexcept: """ The results of this function can be returned from :meth:`__reduce__`. This is here so the factory internals can diff --git a/src/sage/structure/list_clone.pxd b/src/sage/structure/list_clone.pxd index f57c7148974..e182ebf8be1 100644 --- a/src/sage/structure/list_clone.pxd +++ b/src/sage/structure/list_clone.pxd @@ -19,46 +19,46 @@ cdef class ClonableElement(Element): cdef long int _hash cpdef bint _require_mutable(self) except -2 - cpdef bint is_mutable(self) - cpdef bint is_immutable(self) - cpdef set_immutable(self) + cpdef bint is_mutable(self) noexcept + cpdef bint is_immutable(self) noexcept + cpdef set_immutable(self) noexcept - cpdef _set_mutable(self) + cpdef _set_mutable(self) noexcept - cpdef ClonableElement clone(self, bint check=?) + cpdef ClonableElement clone(self, bint check=?) noexcept cdef class ClonableArray(ClonableElement): cdef list _list - cpdef list _get_list(self) - cpdef _set_list(self, list lst) - cpdef ClonableArray __copy__(self) - cpdef check(self) - cpdef object _getitem(self, int key) - cpdef _setitem(self, int key, value) + cpdef list _get_list(self) noexcept + cpdef _set_list(self, list lst) noexcept + cpdef ClonableArray __copy__(self) noexcept + cpdef check(self) noexcept + cpdef object _getitem(self, int key) noexcept + cpdef _setitem(self, int key, value) noexcept cpdef int index(self, key, start=*, stop=*) except -1 cpdef int count(self, key) except -1 cpdef long int _hash_(self) except? -1 cdef class ClonableList(ClonableArray): - cpdef append(self, el) - cpdef extend(self, it) - cpdef insert(self, int index, el) - cpdef pop(self, int index=*) - cpdef remove(self, el) + cpdef append(self, el) noexcept + cpdef extend(self, it) noexcept + cpdef insert(self, int index, el) noexcept + cpdef pop(self, int index=*) noexcept + cpdef remove(self, el) noexcept cdef class NormalizedClonableList(ClonableList): - cpdef normalize(self) + cpdef normalize(self) noexcept cdef class ClonableIntArray(ClonableElement): cdef int _len cdef int* _list - cpdef _alloc_(self, int size) - cpdef ClonableIntArray __copy__(self) - cpdef check(self) - cpdef object _getitem(self, int key) - cpdef _setitem(self, int item, value) + cpdef _alloc_(self, int size) noexcept + cpdef ClonableIntArray __copy__(self) noexcept + cpdef check(self) noexcept + cpdef object _getitem(self, int key) noexcept + cpdef _setitem(self, int item, value) noexcept cpdef int index(self, int item) except -1 cpdef long int _hash_(self) except? -1 - cpdef list list(self) + cpdef list list(self) noexcept diff --git a/src/sage/structure/list_clone.pyx b/src/sage/structure/list_clone.pyx index ae50771c7b8..9ca7be464e6 100644 --- a/src/sage/structure/list_clone.pyx +++ b/src/sage/structure/list_clone.pyx @@ -308,7 +308,7 @@ cdef class ClonableElement(Element): if self._is_immutable: raise ValueError("object is immutable; please change a copy instead.") - cpdef bint is_mutable(self): + cpdef bint is_mutable(self) noexcept: """ Return ``True`` if ``self`` is mutable (can be changed) and ``False`` if it is not. @@ -329,7 +329,7 @@ cdef class ClonableElement(Element): """ return not self._is_immutable - cpdef bint is_immutable(self): + cpdef bint is_immutable(self) noexcept: """ Return ``True`` if ``self`` is immutable (cannot be changed) and ``False`` if it is not. @@ -350,7 +350,7 @@ cdef class ClonableElement(Element): """ return self._is_immutable - cpdef set_immutable(self): + cpdef set_immutable(self) noexcept: """ Makes ``self`` immutable, so it can never again be changed. @@ -369,7 +369,7 @@ cdef class ClonableElement(Element): """ self._is_immutable = True - cpdef _set_mutable(self): + cpdef _set_mutable(self) noexcept: """ Makes ``self`` mutable, so it can be changed. @@ -415,7 +415,7 @@ cdef class ClonableElement(Element): self._hash = self._hash_() return self._hash - cpdef ClonableElement clone(self, bint check=True): + cpdef ClonableElement clone(self, bint check=True) noexcept: """ Return a clone that is mutable copy of ``self``. @@ -578,7 +578,7 @@ cdef class ClonableArray(ClonableElement): """ return bool(self._list) - cpdef list _get_list(self): + cpdef list _get_list(self) noexcept: """ Return the list embedded in ``self``. @@ -594,7 +594,7 @@ cdef class ClonableArray(ClonableElement): """ return self._list - cpdef _set_list(self, list lst): + cpdef _set_list(self, list lst) noexcept: """ Set the list embedded in ``self``. @@ -676,7 +676,7 @@ cdef class ClonableArray(ClonableElement): self._require_mutable() self._list[key] = value - cpdef object _getitem(self, int key): + cpdef object _getitem(self, int key) noexcept: """ Same as :meth:`__getitem__` @@ -695,7 +695,7 @@ cdef class ClonableArray(ClonableElement): """ return self._list[key] - cpdef _setitem(self, int key, value): + cpdef _setitem(self, int key, value) noexcept: """ Same as :meth:`__setitem__` @@ -822,7 +822,7 @@ cdef class ClonableArray(ClonableElement): return self._hash # See protocol in comment in sage/structure/element.pyx - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ TESTS:: @@ -845,7 +845,7 @@ cdef class ClonableArray(ClonableElement): cdef ClonableArray rgt = right return richcmp(left._list, rgt._list, op) - cpdef ClonableArray __copy__(self): + cpdef ClonableArray __copy__(self) noexcept: """ Return a copy of ``self`` @@ -889,7 +889,7 @@ cdef class ClonableArray(ClonableElement): res.__dict__ = self.__dict__.copy() return res - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` fulfill the invariants @@ -1006,7 +1006,7 @@ cdef class ClonableList(ClonableArray): .. SEEALSO:: :class:`~sage.structure.list_clone_demo.IncreasingList` for an example of usage. """ - cpdef append(self, el): + cpdef append(self, el) noexcept: """ Appends ``el`` to ``self`` @@ -1035,7 +1035,7 @@ cdef class ClonableList(ClonableArray): self._require_mutable() self._list.append(el) - cpdef extend(self, it): + cpdef extend(self, it) noexcept: """ Extends ``self`` by the content of the iterable ``it`` @@ -1070,7 +1070,7 @@ cdef class ClonableList(ClonableArray): self._require_mutable() self._list.extend(it) - cpdef insert(self, int index, el): + cpdef insert(self, int index, el) noexcept: """ Inserts ``el`` in ``self`` at position ``index`` @@ -1100,7 +1100,7 @@ cdef class ClonableList(ClonableArray): self._require_mutable() self._list.insert(index, el) - cpdef pop(self, int index=-1): + cpdef pop(self, int index=-1) noexcept: """ Remove ``self[index]`` from ``self`` and returns it @@ -1128,7 +1128,7 @@ cdef class ClonableList(ClonableArray): self._require_mutable() return self._list.pop(index) - cpdef remove(self, el): + cpdef remove(self, el) noexcept: """ Remove the first occurrence of ``el`` from ``self`` @@ -1285,7 +1285,7 @@ cdef class ClonableIntArray(ClonableElement): if check: self.check() - cpdef _alloc_(self, int size): + cpdef _alloc_(self, int size) noexcept: """ Allocate the array part of ``self`` for a given size @@ -1371,7 +1371,7 @@ cdef class ClonableIntArray(ClonableElement): """ return iter(self.list()) - cpdef list list(self): + cpdef list list(self) noexcept: """ Convert self into a Python list. @@ -1469,7 +1469,7 @@ cdef class ClonableIntArray(ClonableElement): else: raise IndexError("list index out of range") - cpdef object _getitem(self, int key): + cpdef object _getitem(self, int key) noexcept: """ Same as :meth:`__getitem__` @@ -1487,7 +1487,7 @@ cdef class ClonableIntArray(ClonableElement): else: raise IndexError("list index out of range") - cpdef _setitem(self, int key, value): + cpdef _setitem(self, int key, value) noexcept: """ Same as :meth:`__setitem__` @@ -1575,7 +1575,7 @@ cdef class ClonableIntArray(ClonableElement): return self._hash # See protocol in comment in sage/structure/element.pyx - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ TESTS:: @@ -1623,7 +1623,7 @@ cdef class ClonableIntArray(ClonableElement): return rich_to_bool(op, 1) return rich_to_bool(op, reslen) - cpdef ClonableIntArray __copy__(self): + cpdef ClonableIntArray __copy__(self) noexcept: """ Return a copy of ``self`` @@ -1670,7 +1670,7 @@ cdef class ClonableIntArray(ClonableElement): res.__dict__ = self.__dict__.copy() return res - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` fulfill the invariants @@ -1832,7 +1832,7 @@ cdef class NormalizedClonableList(ClonableList): self.normalize() return ClonableList.__exit__(self, typ, value, tracback) - cpdef normalize(self): + cpdef normalize(self) noexcept: """ Normalize ``self`` diff --git a/src/sage/structure/list_clone_demo.pyx b/src/sage/structure/list_clone_demo.pyx index 0bd018f57c0..fc68eee947e 100644 --- a/src/sage/structure/list_clone_demo.pyx +++ b/src/sage/structure/list_clone_demo.pyx @@ -30,7 +30,7 @@ cdef class IncreasingArray(ClonableArray): sage: TestSuite(IncreasingArrays()([])).run() """ - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` is increasing. @@ -113,7 +113,7 @@ cdef class IncreasingList(ClonableList): sage: TestSuite(IncreasingLists()([])).run() """ - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` is increasing @@ -146,7 +146,7 @@ cdef class IncreasingIntArray(ClonableIntArray): sage: TestSuite(IncreasingIntArrays()([])).run() """ - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` is increasing. @@ -193,7 +193,7 @@ cdef class SortedList(NormalizedClonableList): sage: TestSuite(IncreasingIntArrays()([1,2,3])).run() sage: TestSuite(IncreasingIntArrays()([])).run() """ - cpdef normalize(self): + cpdef normalize(self) noexcept: """ Normalize ``self`` @@ -213,7 +213,7 @@ cdef class SortedList(NormalizedClonableList): self._require_mutable() self._get_list().sort() - cpdef check(self): + cpdef check(self) noexcept: """ Check that ``self`` is strictly increasing diff --git a/src/sage/structure/list_clone_timings_cy.pyx b/src/sage/structure/list_clone_timings_cy.pyx index 46152f1e68b..6237fbe09a7 100644 --- a/src/sage/structure/list_clone_timings_cy.pyx +++ b/src/sage/structure/list_clone_timings_cy.pyx @@ -14,7 +14,7 @@ from sage.structure.list_clone cimport ClonableArray ##################################################################### ###### Timings functions ###### ##################################################################### -cpdef ClonableArray cy_add1_internal(ClonableArray bla): +cpdef ClonableArray cy_add1_internal(ClonableArray bla) noexcept: """ TESTS:: @@ -34,7 +34,7 @@ cpdef ClonableArray cy_add1_internal(ClonableArray bla): return blo -cpdef ClonableArray cy_add1_immutable(ClonableArray bla): +cpdef ClonableArray cy_add1_immutable(ClonableArray bla) noexcept: """ TESTS:: @@ -49,7 +49,7 @@ cpdef ClonableArray cy_add1_immutable(ClonableArray bla): for i in range(len(lbla)): lbla[i] += 1 return bla.__class__(bla._parent, lbla) -cpdef ClonableArray cy_add1_mutable(ClonableArray bla): +cpdef ClonableArray cy_add1_mutable(ClonableArray bla) noexcept: """ TESTS:: @@ -68,7 +68,7 @@ cpdef ClonableArray cy_add1_mutable(ClonableArray bla): return blo -cpdef ClonableArray cy_add1_with(ClonableArray bla): +cpdef ClonableArray cy_add1_with(ClonableArray bla) noexcept: """ TESTS:: diff --git a/src/sage/structure/mutability.pxd b/src/sage/structure/mutability.pxd index 3df360116ad..16a474e8d2e 100644 --- a/src/sage/structure/mutability.pxd +++ b/src/sage/structure/mutability.pxd @@ -14,7 +14,7 @@ Mutability -- Pyrex Implementation cdef class Mutability: cdef public bint _is_immutable - cpdef _require_mutable(self) - cpdef _require_immutable(self) - cpdef bint is_immutable(self) - cpdef bint is_mutable(self) \ No newline at end of file + cpdef _require_mutable(self) noexcept + cpdef _require_immutable(self) noexcept + cpdef bint is_immutable(self) noexcept + cpdef bint is_mutable(self) noexcept \ No newline at end of file diff --git a/src/sage/structure/mutability.pyx b/src/sage/structure/mutability.pyx index 4aa466513c8..46a04784e0c 100644 --- a/src/sage/structure/mutability.pyx +++ b/src/sage/structure/mutability.pyx @@ -66,7 +66,7 @@ cdef class Mutability: """ self._is_immutable = is_immutable - cpdef _require_mutable(self): + cpdef _require_mutable(self) noexcept: r""" Whenever mutability is required, this method can be called. @@ -92,7 +92,7 @@ cdef class Mutability: if self._is_immutable: raise ValueError("object is immutable; please change a copy instead") - cpdef _require_immutable(self): + cpdef _require_immutable(self) noexcept: r""" Whenever immutability is required, this method can be called. @@ -135,7 +135,7 @@ cdef class Mutability: """ self._is_immutable = 1 - cpdef bint is_immutable(self): + cpdef bint is_immutable(self) noexcept: """ Return ``True`` if this object is immutable (cannot be changed) and ``False`` if it is not. @@ -156,7 +156,7 @@ cdef class Mutability: """ return self._is_immutable - cpdef bint is_mutable(self): + cpdef bint is_mutable(self) noexcept: """ Return ``True`` if this object is mutable (can be changed) and ``False`` if it is not. diff --git a/src/sage/structure/parent.pxd b/src/sage/structure/parent.pxd index a9e98c2bd5c..2a9c637af6c 100644 --- a/src/sage/structure/parent.pxd +++ b/src/sage/structure/parent.pxd @@ -20,13 +20,13 @@ cdef class Parent(sage.structure.category_object.CategoryObject): # Flags, see below cdef int flags - cdef inline bint get_flag(self, int flag): + cdef inline bint get_flag(self, int flag) noexcept: return self.flags & flag - cpdef register_coercion(self, mor) - cpdef register_action(self, action) - cpdef register_conversion(self, mor) - cpdef register_embedding(self, embedding) + cpdef register_coercion(self, mor) noexcept + cpdef register_action(self, action) noexcept + cpdef register_conversion(self, mor) noexcept + cpdef register_embedding(self, embedding) noexcept cpdef bint is_exact(self) except -2 @@ -37,33 +37,33 @@ cdef class Parent(sage.structure.category_object.CategoryObject): cpdef bint has_coerce_map_from(self, S) except -2 # returns a Morphism from S to self, or None - cpdef coerce_map_from(self, S) - cpdef _internal_coerce_map_from(self, S) - cpdef _coerce_map_from_(self, S) + cpdef coerce_map_from(self, S) noexcept + cpdef _internal_coerce_map_from(self, S) noexcept + cpdef _coerce_map_from_(self, S) noexcept # returns a Map from S to self, or None - cpdef convert_map_from(self, S) - cpdef _internal_convert_map_from(self, S) - cpdef _convert_map_from_(self, S) - cdef convert_method_map(self, S, method_name) + cpdef convert_map_from(self, S) noexcept + cpdef _internal_convert_map_from(self, S) noexcept + cpdef _convert_map_from_(self, S) noexcept + cdef convert_method_map(self, S, method_name) noexcept # returns the Action by/on self on/by S # corresponding to op and self_on_left - cpdef get_action(self, S, op=*, bint self_on_left=*, self_el=*, S_el=*) - cpdef _get_action_(self, S, op, bint self_on_left) + cpdef get_action(self, S, op=*, bint self_on_left=*, self_el=*, S_el=*) noexcept + cpdef _get_action_(self, S, op, bint self_on_left) noexcept # coerce x into self - cpdef coerce(self, x) + cpdef coerce(self, x) noexcept - cpdef an_element(self) + cpdef an_element(self) noexcept cdef public object _cache_an_element # For internal use - cpdef _generic_convert_map(self, S, category=*) - cpdef _generic_coerce_map(self, S) - cdef discover_coerce_map_from(self, S) - cdef discover_convert_map_from(self, S) - cdef discover_action(self, S, op, bint self_on_left, self_el=*, S_el=*) + cpdef _generic_convert_map(self, S, category=*) noexcept + cpdef _generic_coerce_map(self, S) noexcept + cdef discover_coerce_map_from(self, S) noexcept + cdef discover_convert_map_from(self, S) noexcept + cdef discover_action(self, S, op, bint self_on_left, self_el=*, S_el=*) noexcept # List consisting of Morphisms (from anything to self) # and Parents for which the __call__ method of self diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index 6548d8a3656..6c073e8cd98 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -128,11 +128,11 @@ from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap, from .element cimport parent -cdef _record_exception(): +cdef _record_exception() noexcept: coercion_model._record_exception() cdef object _Integer -cdef bint is_Integer(x): +cdef bint is_Integer(x) noexcept: global _Integer if _Integer is None: from sage.rings.integer import Integer as _Integer @@ -157,7 +157,7 @@ def is_Parent(x): return isinstance(x, Parent) -cdef bint guess_pass_parent(parent, element_constructor): +cdef bint guess_pass_parent(parent, element_constructor) noexcept: # Returning True here is deprecated, see #26879 if isinstance(element_constructor, MethodType): return False @@ -171,7 +171,7 @@ from sage.structure.dynamic_class import dynamic_class Sets_parent_class = Sets().parent_class -cdef inline bint good_as_coerce_domain(S): +cdef inline bint good_as_coerce_domain(S) noexcept: """ Determine whether the input can be the domain of a map. @@ -197,7 +197,7 @@ cdef inline bint good_as_coerce_domain(S): return isinstance(S, (CategoryObject, type)) -cdef inline bint good_as_convert_domain(S): +cdef inline bint good_as_convert_domain(S) noexcept: return isinstance(S, (SageObject, type)) @@ -1188,7 +1188,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): except (TypeError, ValueError, ArithmeticError): return False - cpdef coerce(self, x): + cpdef coerce(self, x) noexcept: """ Return x as an element of self, if and only if there is a canonical coercion from the parent of x to self. @@ -1604,7 +1604,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): except KeyError: pass - cpdef register_coercion(self, mor): + cpdef register_coercion(self, mor) noexcept: r""" Update the coercion model to use `mor : P \to \text{self}` to coerce from a parent ``P`` into ``self``. @@ -1664,7 +1664,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): self._registered_domains.append(D) self._coerce_from_hash.set(D, mor) - cpdef register_action(self, action): + cpdef register_action(self, action) noexcept: r""" Update the coercion model to use ``action`` to act on self. @@ -1728,7 +1728,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): raise ValueError("action must involve self") self._action_list.append(action) - cpdef register_conversion(self, mor): + cpdef register_conversion(self, mor) noexcept: r""" Update the coercion model to use `\text{mor} : P \to \text{self}` to convert from ``P`` into ``self``. @@ -1763,7 +1763,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): else: raise TypeError("conversions must be parents or maps") - cpdef register_embedding(self, embedding): + cpdef register_embedding(self, embedding) noexcept: r""" Add embedding to coercion model. @@ -1900,7 +1900,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): """ return copy(self._embedding) # It might be overkill to make a copy here - cpdef _generic_coerce_map(self, S): + cpdef _generic_coerce_map(self, S) noexcept: r""" Returns a default coercion map based on the data provided to :meth:`_populate_coercion_lists_`. @@ -1931,7 +1931,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): category = self.category()._meet_(S.category()) return self._generic_convert_map(S, category=category) - cpdef _generic_convert_map(self, S, category=None): + cpdef _generic_convert_map(self, S, category=None) noexcept: r""" Returns the default conversion map based on the data provided to :meth:`_populate_coercion_lists_`. @@ -1989,7 +1989,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): method_name = self._convert_method_name return self.convert_method_map(S, method_name) - cdef convert_method_map(self, S, method_name): + cdef convert_method_map(self, S, method_name) noexcept: # Cython implementation of _convert_method_map() cdef Parent P if isinstance(S, Parent): @@ -2090,7 +2090,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): return True return self._internal_coerce_map_from(S) is not None - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: """ Override this method to specify coercions beyond those specified in coerce_list. @@ -2107,7 +2107,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): except AttributeError: return None - cpdef coerce_map_from(self, S): + cpdef coerce_map_from(self, S) noexcept: """ Return a :class:`Map` object to coerce from ``S`` to ``self`` if one exists, or ``None`` if no such coercion exists. @@ -2145,7 +2145,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): """ return copy(self._internal_coerce_map_from(S)) - cpdef _internal_coerce_map_from(self, S): + cpdef _internal_coerce_map_from(self, S) noexcept: """ Return the :class:`Map` object to coerce from ``S`` to ``self`` that is used internally by the coercion system if one exists, or ``None`` @@ -2267,7 +2267,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): finally: _unregister_pair(self, S, "coerce") - cdef discover_coerce_map_from(self, S): + cdef discover_coerce_map_from(self, S) noexcept: """ Precedence for discovering a coercion S -> self goes as follows: @@ -2444,7 +2444,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): if connecting is not None: return (S)._embedding.post_compose(connecting) - cpdef convert_map_from(self, S): + cpdef convert_map_from(self, S) noexcept: """ This function returns a :class:`Map` from `S` to `self`, which may or may not succeed on all inputs. @@ -2470,7 +2470,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): """ return copy(self._internal_convert_map_from(S)) - cpdef _internal_convert_map_from(self, S): + cpdef _internal_convert_map_from(self, S) noexcept: """ This function returns a :class:`Map` from `S` to `self`, which may or may not succeed on all inputs. @@ -2516,7 +2516,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): mor._make_weak_references() return mor - cdef discover_convert_map_from(self, S): + cdef discover_convert_map_from(self, S) noexcept: cdef map.Map mor = self._internal_coerce_map_from(S) if mor is not None: @@ -2544,7 +2544,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): mor = self._generic_convert_map(S) return mor - cpdef _convert_map_from_(self, S): + cpdef _convert_map_from_(self, S) noexcept: """ Override this method to provide additional conversions beyond those given in convert_list. @@ -2558,7 +2558,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): """ return None - cpdef get_action(self, S, op=operator.mul, bint self_on_left=True, self_el=None, S_el=None): + cpdef get_action(self, S, op=operator.mul, bint self_on_left=True, self_el=None, S_el=None) noexcept: """ Returns an action of self on S or S on self. @@ -2594,7 +2594,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): self._action_hash.set(S, op, self_on_left, action) return action - cdef discover_action(self, S, op, bint self_on_left, self_el=None, S_el=None): + cdef discover_action(self, S, op, bint self_on_left, self_el=None, S_el=None) noexcept: """ TESTS:: @@ -2704,7 +2704,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): except TypeError: _record_exception() - cpdef _get_action_(self, S, op, bint self_on_left): + cpdef _get_action_(self, S, op, bint self_on_left) noexcept: """ Override this method to provide an action of self on S or S on self beyond what was specified in action_list. @@ -2716,7 +2716,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject): # TODO: remove once all parents in Sage will inherit properly from # Sets().ParentMethods.an_element - cpdef an_element(self): + cpdef an_element(self) noexcept: r""" Returns a (preferably typical) element of this parent. diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx index dd697f90135..64277588819 100644 --- a/src/sage/structure/parent_base.pyx +++ b/src/sage/structure/parent_base.pyx @@ -14,7 +14,7 @@ Base class for old-style parent objects with a base ring cimport sage.structure.parent as parent from .coerce_exceptions import CoercionException -cdef inline check_old_coerce(parent.Parent p): +cdef inline check_old_coerce(parent.Parent p) noexcept: if p._element_constructor is not None: raise RuntimeError("%s still using old coercion framework" % p) @@ -27,7 +27,7 @@ cdef class ParentWithBase(Parent_old): Parent_old.__init__(self, *args, **kwds) self._base = base - cdef _coerce_c_impl(self,x): + cdef _coerce_c_impl(self,x) noexcept: check_old_coerce(self) from sage.misc.superseded import deprecation deprecation(33497, "_coerce_c_impl is deprecated, use coerce instead") diff --git a/src/sage/structure/parent_gens.pyx b/src/sage/structure/parent_gens.pyx index 3f69b9daee4..6d493e56781 100644 --- a/src/sage/structure/parent_gens.pyx +++ b/src/sage/structure/parent_gens.pyx @@ -73,7 +73,7 @@ cimport sage.structure.parent as parent cimport sage.structure.category_object as category_object -cdef inline check_old_coerce(parent.Parent p): +cdef inline check_old_coerce(parent.Parent p) noexcept: if p._element_constructor is not None: raise RuntimeError("%s still using old coercion framework" % p) diff --git a/src/sage/structure/parent_old.pxd b/src/sage/structure/parent_old.pxd index 54bb4753970..688ae96469a 100644 --- a/src/sage/structure/parent_old.pxd +++ b/src/sage/structure/parent_old.pxd @@ -16,9 +16,9 @@ cdef class Parent(parent.Parent): # Cache for __has_coerce_map_from_c() cdef MonoDict _has_coerce_map_from - cpdef _coerce_c(self, x) - cdef _coerce_c_impl(self, x) + cpdef _coerce_c(self, x) noexcept + cdef _coerce_c_impl(self, x) noexcept - cdef __coerce_map_from_c(self, S) - cdef __coerce_map_from_c_impl(self, S) - cdef __has_coerce_map_from_c(self, S) + cdef __coerce_map_from_c(self, S) noexcept + cdef __coerce_map_from_c_impl(self, S) noexcept + cdef __has_coerce_map_from_c(self, S) noexcept diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx index 77a7888d3b8..b92a826020f 100644 --- a/src/sage/structure/parent_old.pyx +++ b/src/sage/structure/parent_old.pyx @@ -34,7 +34,7 @@ from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class from cpython.object cimport * from cpython.bool cimport * -cdef inline check_old_coerce(Parent p): +cdef inline check_old_coerce(Parent p) noexcept: if p._element_constructor is not None: raise RuntimeError("%s still using old coercion framework" % p) @@ -79,7 +79,7 @@ cdef class Parent(parent.Parent): # New Coercion support functionality ########################################################## - cdef __coerce_map_from_c(self, S): + cdef __coerce_map_from_c(self, S) noexcept: """ EXAMPLES: @@ -143,7 +143,7 @@ cdef class Parent(parent.Parent): return mor - cdef __coerce_map_from_c_impl(self, S): + cdef __coerce_map_from_c_impl(self, S) noexcept: check_old_coerce(self) import sage.categories.morphism from sage.categories.map import Map @@ -183,7 +183,7 @@ cdef class Parent(parent.Parent): check_old_coerce(self) return self._coerce_c(x) - cpdef _coerce_c(self, x): # DO NOT OVERRIDE THIS (call it) + cpdef _coerce_c(self, x) noexcept: # DO NOT OVERRIDE THIS (call it) if self._element_constructor is not None: from sage.misc.superseded import deprecation deprecation(33497, "_coerce_c is deprecated, use coerce instead") @@ -200,7 +200,7 @@ cdef class Parent(parent.Parent): else: return self._coerce_c_impl(x) - cdef _coerce_c_impl(self, x): # OVERRIDE THIS FOR CYTHON CLASSES + cdef _coerce_c_impl(self, x) noexcept: # OVERRIDE THIS FOR CYTHON CLASSES """ Canonically coerce x in assuming that the parent of x is not equal to self. @@ -241,7 +241,7 @@ cdef class Parent(parent.Parent): pass raise TypeError("no canonical coercion of element into self") - cdef __has_coerce_map_from_c(self, S): + cdef __has_coerce_map_from_c(self, S) noexcept: check_old_coerce(self) if self == S: return True @@ -289,7 +289,7 @@ cdef class Parent(parent.Parent): ############################################################### # Coercion Compatibility Layer ############################################################### - cpdef _coerce_map_from_(self, S): + cpdef _coerce_map_from_(self, S) noexcept: if self._element_constructor is None: return self.__coerce_map_from_c(S) else: @@ -303,7 +303,7 @@ cdef class Parent(parent.Parent): self._cache_an_element = self._an_element_impl() return self._cache_an_element - cpdef _generic_convert_map(self, S, category=None): + cpdef _generic_convert_map(self, S, category=None) noexcept: r""" Return a default conversion from ``S``. diff --git a/src/sage/structure/richcmp.pxd b/src/sage/structure/richcmp.pxd index 493af157a79..7db6340ec48 100644 --- a/src/sage/structure/richcmp.pxd +++ b/src/sage/structure/richcmp.pxd @@ -3,7 +3,7 @@ from cpython.object cimport (Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, PyObject_RichCompare) -cpdef inline richcmp(x, y, int op): +cpdef inline richcmp(x, y, int op) noexcept: """ Return the result of the rich comparison of ``x`` and ``y`` with operator ``op``. @@ -50,10 +50,10 @@ cpdef inline richcmp(x, y, int op): return PyObject_RichCompare(x, y, op) -cpdef richcmp_item(x, y, int op) +cpdef richcmp_item(x, y, int op) noexcept -cpdef inline richcmp_not_equal(x, y, int op): +cpdef inline richcmp_not_equal(x, y, int op) noexcept: """ Like ``richcmp(x, y, op)`` but assuming that `x` is not equal to `y`. @@ -117,7 +117,7 @@ cpdef inline richcmp_not_equal(x, y, int op): return richcmp(x, y, op) -cpdef inline bint rich_to_bool(int op, int c): +cpdef inline bint rich_to_bool(int op, int c) noexcept: """ Return the corresponding ``True`` or ``False`` value for a rich comparison, given the result of an old-style comparison. @@ -184,7 +184,7 @@ cpdef inline bint rich_to_bool(int op, int c): return (bits >> (shift & 31)) & 1 -cpdef inline bint rich_to_bool_sgn(int op, Py_ssize_t c): +cpdef inline bint rich_to_bool_sgn(int op, Py_ssize_t c) noexcept: """ Same as ``rich_to_bool``, but allow any `c < 0` and `c > 0` instead of only `-1` and `1`. @@ -196,7 +196,7 @@ cpdef inline bint rich_to_bool_sgn(int op, Py_ssize_t c): return rich_to_bool(op, (c > 0) - (c < 0)) -cpdef inline int revop(int op): +cpdef inline int revop(int op) noexcept: """ Return the reverse operation of ``op``. diff --git a/src/sage/structure/richcmp.pyx b/src/sage/structure/richcmp.pyx index 465f16e8274..7e1720c0e07 100644 --- a/src/sage/structure/richcmp.pyx +++ b/src/sage/structure/richcmp.pyx @@ -68,7 +68,7 @@ richcmp_slotdef[Py_LE] = get_slotdef(bytes.__le__) richcmp_slotdef[Py_GE] = get_slotdef(bytes.__ge__) -cpdef richcmp_item(x, y, int op): +cpdef richcmp_item(x, y, int op) noexcept: """ This function is meant to implement lexicographic rich comparison of sequences (lists, vectors, polynomials, ...). @@ -266,7 +266,7 @@ cpdef richcmp_item(x, y, int op): return NotImplemented -cdef slot_tp_richcompare(self, other, int op): +cdef slot_tp_richcompare(self, other, int op) noexcept: """ Function to put in the ``tp_richcompare`` slot. """ diff --git a/src/sage/symbolic/comparison_impl.pxi b/src/sage/symbolic/comparison_impl.pxi index c07ed620de1..e4b80ad6fad 100644 --- a/src/sage/symbolic/comparison_impl.pxi +++ b/src/sage/symbolic/comparison_impl.pxi @@ -36,7 +36,7 @@ There is also a mixed version: from cpython cimport * -cdef int print_order_c(Expression lhs, Expression rhs): +cdef int print_order_c(Expression lhs, Expression rhs) noexcept: """ Print comparison. @@ -135,7 +135,7 @@ class _print_key(): return print_order_c(self.ex, other.ex) < 0 -cpdef print_sorted(expressions): +cpdef print_sorted(expressions) noexcept: """ Sort a list in print order @@ -219,7 +219,7 @@ class _math_key(): raise ValueError('cannot compare {0} and {1}'.format(self.ex, other.ex)) -cpdef math_sorted(expressions): +cpdef math_sorted(expressions) noexcept: """ Sort a list of symbolic numbers in the "Mathematics" order @@ -409,7 +409,7 @@ class _mixed_key(): return num < 0 -cpdef mixed_sorted(expressions): +cpdef mixed_sorted(expressions) noexcept: """ Sort a list of symbolic numbers in the "Mixed" order diff --git a/src/sage/symbolic/expression.pxd b/src/sage/symbolic/expression.pxd index 33e352b7f3d..a212eb414c0 100644 --- a/src/sage/symbolic/expression.pxd +++ b/src/sage/symbolic/expression.pxd @@ -1,6 +1,6 @@ -cpdef _repr_Expression(x) -cpdef _latex_Expression(x) -cpdef new_Expression(parent, x) -cpdef new_Expression_from_pyobject(parent, x, bint force=?, bint recursive=?) -cpdef new_Expression_wild(parent, unsigned int n=?) -cpdef new_Expression_symbol(parent, name=?, latex_name=?, domain=?) +cpdef _repr_Expression(x) noexcept +cpdef _latex_Expression(x) noexcept +cpdef new_Expression(parent, x) noexcept +cpdef new_Expression_from_pyobject(parent, x, bint force=?, bint recursive=?) noexcept +cpdef new_Expression_wild(parent, unsigned int n=?) noexcept +cpdef new_Expression_symbol(parent, name=?, latex_name=?, domain=?) noexcept diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index 20d7647d2e5..0b80c017a0b 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -409,7 +409,7 @@ include "pynac_impl.pxi" from sage.symbolic.symbols import symbol_table, register_symbol # used to be defined in pynac_impl -cpdef bint is_SymbolicEquation(x): +cpdef bint is_SymbolicEquation(x) noexcept: """ Return True if *x* is a symbolic equation. @@ -452,7 +452,7 @@ cpdef bint is_SymbolicEquation(x): # Defined here but exported by sage.symbolic.ring -cpdef bint _is_SymbolicVariable(x): +cpdef bint _is_SymbolicVariable(x) noexcept: """ Return ``True`` if ``x`` is a variable. @@ -704,7 +704,7 @@ cdef class Expression(Expression_abc): cdef GEx _gobj - cpdef object pyobject(self): + cpdef object pyobject(self) noexcept: """ Get the underlying Python object. @@ -1577,7 +1577,7 @@ cdef class Expression(Expression_abc): return n return sage.rings.rational.Rational(n) - cpdef _eval_self(self, R): + cpdef _eval_self(self, R) noexcept: """ Evaluate this expression numerically. @@ -1638,7 +1638,7 @@ cdef class Expression(Expression_abc): else: raise TypeError("cannot evaluate symbolic expression to a numeric value") - cpdef _convert(self, kwds): + cpdef _convert(self, kwds) noexcept: """ Convert all the numeric coefficients and constants in this expression to the given ring ``R``. This results in an expression which contains @@ -2178,7 +2178,7 @@ cdef class Expression(Expression_abc): finally: sig_off() - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Create a formal symbolic inequality or equality. @@ -2945,7 +2945,7 @@ cdef class Expression(Expression_abc): """ return False - cpdef bint is_polynomial(self, var): + cpdef bint is_polynomial(self, var) noexcept: """ Return ``True`` if ``self`` is a polynomial in the given variable. @@ -2998,7 +2998,7 @@ cdef class Expression(Expression_abc): finally: sig_off() - cpdef bint is_relational(self): + cpdef bint is_relational(self) noexcept: r""" Return ``True`` if ``self`` is a relational expression. @@ -3065,7 +3065,7 @@ cdef class Expression(Expression_abc): return all(nelem.pyobject().base_ring().is_exact() for nelem in numelems_gen(self)) - cpdef bint is_infinity(self): + cpdef bint is_infinity(self) noexcept: """ Return ``True`` if ``self`` is an infinite expression. @@ -3078,7 +3078,7 @@ cdef class Expression(Expression_abc): """ return is_a_infinity(self._gobj) - cpdef bint is_positive_infinity(self): + cpdef bint is_positive_infinity(self) noexcept: """ Return ``True`` if ``self`` is a positive infinite expression. @@ -3093,7 +3093,7 @@ cdef class Expression(Expression_abc): """ return is_a_infinity(self._gobj) and self._gobj.info(info_positive) - cpdef bint is_negative_infinity(self): + cpdef bint is_negative_infinity(self) noexcept: """ Return ``True`` if ``self`` is a negative infinite expression. @@ -3798,7 +3798,7 @@ cdef class Expression(Expression_abc): return False raise NotImplementedError - cdef Expression coerce_in(self, z): + cdef Expression coerce_in(self, z) noexcept: """ Quickly coerce z to be an Expression. """ @@ -3807,7 +3807,7 @@ cdef class Expression(Expression_abc): except TypeError: return self._parent.coerce(z) - cpdef _add_(left, right): + cpdef _add_(left, right) noexcept: """ Add left and right. @@ -3902,7 +3902,7 @@ cdef class Expression(Expression_abc): x = left._gobj + _right._gobj return new_Expression_from_GEx(left._parent, x) - cpdef _sub_(left, right): + cpdef _sub_(left, right) noexcept: """ EXAMPLES:: @@ -3954,7 +3954,7 @@ cdef class Expression(Expression_abc): x = left._gobj - _right._gobj return new_Expression_from_GEx(left._parent, x) - cpdef _mul_(left, right): + cpdef _mul_(left, right) noexcept: """ Multiply left and right. @@ -4120,7 +4120,7 @@ cdef class Expression(Expression_abc): x = left._gobj * _right._gobj return new_Expression_from_GEx(left._parent, x) - cpdef _div_(left, right): + cpdef _div_(left, right) noexcept: """ Divide left and right. @@ -4301,7 +4301,7 @@ cdef class Expression(Expression_abc): """ return print_order_compare_mul(left._gobj, right._gobj) - cpdef _pow_(self, other): + cpdef _pow_(self, other) noexcept: r""" Return ``self`` raised to the power ``other``. @@ -4515,7 +4515,7 @@ cdef class Expression(Expression_abc): x = g_pow(self._gobj, nexp._gobj) return new_Expression_from_GEx(self._parent, x) - cpdef _pow_int(self, other): + cpdef _pow_int(self, other) noexcept: """ TESTS:: @@ -5901,7 +5901,7 @@ cdef class Expression(Expression_abc): subs = substitute - cpdef Expression _subs_expr(self, expr): + cpdef Expression _subs_expr(self, expr) noexcept: """ EXAMPLES:: @@ -13532,7 +13532,7 @@ cdef class Expression(Expression_abc): return S -cpdef _repr_Expression(x): +cpdef _repr_Expression(x) noexcept: r""" Return the string representation of the expression ``x``. @@ -13544,7 +13544,7 @@ cpdef _repr_Expression(x): return ccrepr((x)._gobj) -cpdef _latex_Expression(x): +cpdef _latex_Expression(x) noexcept: r""" Return the standard LaTeX version of the expression `x`. @@ -13620,7 +13620,7 @@ def _eval_on_operands(f): cdef dict dynamic_class_cache = {} -cdef get_dynamic_class_for_function(unsigned serial): +cdef get_dynamic_class_for_function(unsigned serial) noexcept: r""" Create a dynamic class corresponding to the function with given ``serial`` that includes dynamic methods defined by the function. @@ -13715,7 +13715,7 @@ cdef get_dynamic_class_for_function(unsigned serial): return cls -cdef Expression new_Expression_from_GEx(parent, GEx juice): +cdef Expression new_Expression_from_GEx(parent, GEx juice) noexcept: cdef type cls cdef Expression nex if is_exactly_a_function(juice): @@ -13731,7 +13731,7 @@ cdef Expression new_Expression_from_GEx(parent, GEx juice): return nex -cpdef new_Expression(parent, x): +cpdef new_Expression(parent, x) noexcept: r""" Convert ``x`` into the symbolic expression ring ``parent``. @@ -13821,7 +13821,7 @@ cpdef new_Expression(parent, x): return new_Expression_from_GEx(parent, exp) -cpdef new_Expression_from_pyobject(parent, x, bint force=True, bint recursive=True): +cpdef new_Expression_from_pyobject(parent, x, bint force=True, bint recursive=True) noexcept: r""" Wrap the given Python object in a symbolic expression even if it cannot be coerced to the Symbolic Ring. @@ -13892,7 +13892,7 @@ cpdef new_Expression_from_pyobject(parent, x, bint force=True, bint recursive=Tr return new_Expression_from_GEx(parent, exp) -cpdef new_Expression_wild(parent, unsigned int n=0): +cpdef new_Expression_wild(parent, unsigned int n=0) noexcept: r""" Return the n-th wild-card for pattern matching and substitution. @@ -13922,7 +13922,7 @@ cpdef new_Expression_wild(parent, unsigned int n=0): return new_Expression_from_GEx(parent, g_wild(n)) -cpdef new_Expression_symbol(parent, name=None, latex_name=None, domain=None): +cpdef new_Expression_symbol(parent, name=None, latex_name=None, domain=None) noexcept: r""" Look up or create a symbol. @@ -14074,7 +14074,7 @@ cdef class ExpressionIterator: self._ind+=1 return new_Expression_from_GEx(self._ex._parent, ex) -cdef inline ExpressionIterator new_ExpIter_from_Expression(Expression ex): +cdef inline ExpressionIterator new_ExpIter_from_Expression(Expression ex) noexcept: """ Construct a new iterator over a symbolic expression. diff --git a/src/sage/symbolic/function.pxd b/src/sage/symbolic/function.pxd index db1ba6c5d54..1987a393f86 100644 --- a/src/sage/symbolic/function.pxd +++ b/src/sage/symbolic/function.pxd @@ -8,21 +8,21 @@ cdef class Function(SageObject): cdef object _latex_name cdef object _conversions cdef object _evalf_params_first - cdef _is_registered(self) - cdef _register_function(self) + cdef _is_registered(self) noexcept + cdef _register_function(self) noexcept cdef class BuiltinFunction(Function): cdef object _preserved_arg - cdef _is_registered(self) + cdef _is_registered(self) noexcept cdef class GinacFunction(BuiltinFunction): cdef object _ginac_name - cdef _is_registered(self) - cdef _register_function(self) + cdef _is_registered(self) noexcept + cdef _register_function(self) noexcept cdef class SymbolicFunction(Function): # cache hash value cdef long _hash_(self) except -1 cdef bint __hinit cdef long __hcache - cdef _is_registered(self) + cdef _is_registered(self) noexcept diff --git a/src/sage/symbolic/function.pyx b/src/sage/symbolic/function.pyx index f4bd22df0a6..589c500d00d 100644 --- a/src/sage/symbolic/function.pyx +++ b/src/sage/symbolic/function.pyx @@ -245,14 +245,14 @@ cdef class Function(SageObject): self._register_function() register_symbol(self, self._conversions) - cdef _is_registered(self): + cdef _is_registered(self) noexcept: """ Check if this function is already registered. If it is, set `self._serial` to the right value. """ raise NotImplementedError("this is an abstract base class, it shouldn't be initialized directly") - cdef _register_function(self): + cdef _register_function(self) noexcept: """ TESTS: @@ -849,14 +849,14 @@ cdef class GinacFunction(BuiltinFunction): evalf_params_first=evalf_params_first, preserved_arg=preserved_arg, alt_name=alt_name) - cdef _is_registered(self): + cdef _is_registered(self) noexcept: # Since this is function is defined in C++, it is already in # ginac's function registry fname = self._ginac_name if self._ginac_name is not None else self._name self._serial = find_registered_function(fname, self._nargs) return bool(get_sfunction_from_serial(self._serial)) - cdef _register_function(self): + cdef _register_function(self) noexcept: # We don't need to add anything to GiNaC's function registry # However, if any custom methods were provided in the python class, # we should set the properties of the function_options object @@ -1085,7 +1085,7 @@ cdef class BuiltinFunction(Function): else: return res - cdef _is_registered(self): + cdef _is_registered(self) noexcept: """ TESTS: @@ -1203,7 +1203,7 @@ cdef class SymbolicFunction(Function): Function.__init__(self, name, nargs, latex_name, conversions, evalf_params_first) - cdef _is_registered(SymbolicFunction self): + cdef _is_registered(SymbolicFunction self) noexcept: # see if there is already a SymbolicFunction with the same state cdef long myhash = self._hash_() cdef SymbolicFunction sfunc = get_sfunction_from_hash(myhash) diff --git a/src/sage/symbolic/pynac_function_impl.pxi b/src/sage/symbolic/pynac_function_impl.pxi index f20c8faf91a..cca1bb5d196 100644 --- a/src/sage/symbolic/pynac_function_impl.pxi +++ b/src/sage/symbolic/pynac_function_impl.pxi @@ -3,7 +3,7 @@ cpdef call_registered_function(unsigned serial, list args, bint hold, bint allow_numeric_result, - result_parent): + result_parent) noexcept: r""" Call a function registered with Pynac (GiNaC). @@ -173,7 +173,7 @@ cpdef unsigned register_or_update_function(self, name, latex_name, int nargs, cdef dict sfunction_serial_dict = {} -cpdef get_sfunction_from_serial(unsigned int serial): +cpdef get_sfunction_from_serial(unsigned int serial) noexcept: """ Return an already created :class:`SymbolicFunction` given the serial. @@ -189,7 +189,7 @@ cpdef get_sfunction_from_serial(unsigned int serial): return sfunction_serial_dict.get(serial) -cpdef get_sfunction_from_hash(long myhash): +cpdef get_sfunction_from_hash(long myhash) noexcept: """ Return an already created :class:`SymbolicFunction` given the hash. diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi index 7fd7c3b314b..88436ee2705 100644 --- a/src/sage/symbolic/pynac_impl.pxi +++ b/src/sage/symbolic/pynac_impl.pxi @@ -61,7 +61,7 @@ from sage.symbolic.function cimport Function # Symbolic function helpers ################################################################# -cdef ex_to_pyExpression(GEx juice): +cdef ex_to_pyExpression(GEx juice) noexcept: """ Convert given GiNaC::ex object to a python Expression instance. @@ -74,7 +74,7 @@ cdef ex_to_pyExpression(GEx juice): nex._parent = SR return nex -cdef exprseq_to_PyTuple(GEx seq): +cdef exprseq_to_PyTuple(GEx seq) noexcept: """ Convert an exprseq to a Python tuple. @@ -134,7 +134,7 @@ def unpack_operands(Expression ex): return exprseq_to_PyTuple(ex._gobj) -cdef exvector_to_PyTuple(GExVector seq): +cdef exvector_to_PyTuple(GExVector seq) noexcept: """ Converts arguments list given to a function to a PyTuple. @@ -196,7 +196,7 @@ cdef GEx pyExpression_to_ex(res) except *: raise TypeError("function did not return a symbolic expression or an element that can be coerced into a symbolic expression") return (t)._gobj -cdef paramset_to_PyTuple(const_paramset_ref s): +cdef paramset_to_PyTuple(const_paramset_ref s) noexcept: """ Converts a std::multiset to a PyTuple. @@ -226,7 +226,7 @@ def paramset_from_Expression(Expression e): cdef int GINAC_FN_SERIAL = 0 -cdef set_ginac_fn_serial(): +cdef set_ginac_fn_serial() noexcept: """ Initialize the GINAC_FN_SERIAL variable to the number of functions defined by GiNaC. This allows us to prevent collisions with C++ level @@ -236,7 +236,7 @@ cdef set_ginac_fn_serial(): global GINAC_FN_SERIAL GINAC_FN_SERIAL = g_registered_functions().size() -cdef int py_get_ginac_serial(): +cdef int py_get_ginac_serial() noexcept: """ Returns the number of C++ level functions defined by GiNaC. @@ -262,7 +262,7 @@ def get_ginac_serial(): return py_get_ginac_serial() -cdef get_fn_serial_c(): +cdef get_fn_serial_c() noexcept: """ Return overall size of Pynac function registry. """ @@ -288,7 +288,7 @@ def get_fn_serial(): return get_fn_serial_c() -cdef subs_args_to_PyTuple(const GExMap& map, unsigned options, const GExVector& seq): +cdef subs_args_to_PyTuple(const GExMap& map, unsigned options, const GExVector& seq) noexcept: """ Convert arguments from ``GiNaC::subs()`` to a PyTuple. @@ -339,7 +339,7 @@ cdef subs_args_to_PyTuple(const GExMap& map, unsigned options, const GExVector& # Structure: 70 ########################################################################## -cdef stdstring* py_repr(o, int level): +cdef stdstring* py_repr(o, int level) noexcept: """ Return string representation of o. If level > 0, possibly put parentheses around the string. @@ -363,7 +363,7 @@ cdef stdstring* py_repr(o, int level): return string_from_pystr(s) -cdef stdstring* py_latex(o, int level): +cdef stdstring* py_latex(o, int level) noexcept: """ Return latex string representation of o. If level > 0, possibly put parentheses around the string. @@ -395,7 +395,7 @@ cdef stdstring* string_from_pystr(py_str) except NULL: s = b"(INVALID)" # Avoid segfaults for invalid input return new stdstring(s) -cdef stdstring* py_latex_variable(var_name): +cdef stdstring* py_latex_variable(var_name) noexcept: r""" Return a c++ string containing the latex representation of the given variable name. @@ -506,7 +506,7 @@ def py_print_function_pystring(id, args, fname_paren=False): return ''.join(olist) -cdef stdstring* py_print_function(unsigned id, args): +cdef stdstring* py_print_function(unsigned id, args) noexcept: return string_from_pystr(py_print_function_pystring(id, args)) @@ -598,7 +598,7 @@ def py_latex_function_pystring(id, args, fname_paren=False): return ''.join(olist) -cdef stdstring* py_latex_function(unsigned id, args): +cdef stdstring* py_latex_function(unsigned id, args) noexcept: return string_from_pystr(py_latex_function_pystring(id, args)) @@ -628,7 +628,7 @@ def tolerant_is_symbol(a): cdef stdstring* py_print_fderivative(unsigned id, params, - args): + args) noexcept: """ Return a string with the representation of the derivative of the symbolic function specified by the given id, lists of params and args. @@ -689,7 +689,7 @@ def py_print_fderivative_for_doctests(id, params, args): cdef stdstring* py_latex_fderivative(unsigned id, params, - args): + args) noexcept: """ Return a string with the latex representation of the derivative of the symbolic function specified by the given id, lists of params and args. @@ -780,7 +780,7 @@ def py_latex_fderivative_for_doctests(id, params, args): # Archive helpers ################################################################# -cdef stdstring* py_dumps(o): +cdef stdstring* py_dumps(o) noexcept: s = dumps(o, compress=False) # pynac archive format terminates atoms with zeroes. # since pickle output can break the archive format @@ -789,18 +789,18 @@ cdef stdstring* py_dumps(o): s = base64.b64encode(s) return string_from_pystr(s) -cdef py_loads(s): +cdef py_loads(s) noexcept: import base64 s = base64.b64decode(s) return loads(s) -cdef py_get_sfunction_from_serial(unsigned s): +cdef py_get_sfunction_from_serial(unsigned s) noexcept: """ Return the Python object associated with a serial. """ return get_sfunction_from_serial(s) -cdef unsigned py_get_serial_from_sfunction(f): +cdef unsigned py_get_serial_from_sfunction(f) noexcept: """ Given a Function object return its serial. @@ -814,7 +814,7 @@ cdef unsigned py_get_serial_from_sfunction(f): return (f)._serial cdef unsigned py_get_serial_for_new_sfunction(stdstring &s, - unsigned nargs): + unsigned nargs) noexcept: """ Return a symbolic function with the given name and number of arguments. @@ -869,7 +869,7 @@ cdef int py_get_parent_char(o) except -1: # power helpers ################################################################# -cdef py_rational_power_parts(base, exp): +cdef py_rational_power_parts(base, exp) noexcept: if type(base) is not Rational: base = Rational(base) if type(exp) is not Rational: @@ -882,7 +882,7 @@ cdef py_rational_power_parts(base, exp): ################################################################# -cdef py_binomial_int(int n, unsigned int k): +cdef py_binomial_int(int n, unsigned int k) noexcept: cdef bint sign if n < 0: n = -n + (k-1) @@ -898,7 +898,7 @@ cdef py_binomial_int(int n, unsigned int k): else: return ans -cdef py_binomial(n, k): +cdef py_binomial(n, k) noexcept: # Keep track of the sign we should use. cdef bint sign if n < 0: @@ -949,7 +949,7 @@ def test_binomial(n, k): ################################################################# # GCD ################################################################# -cdef py_gcd(n, k): +cdef py_gcd(n, k) noexcept: if isinstance(n, Integer) and isinstance(k, Integer): if mpz_cmp_si((n).value, 1) == 0: return n @@ -969,7 +969,7 @@ cdef py_gcd(n, k): ################################################################# # LCM ################################################################# -cdef py_lcm(n, k): +cdef py_lcm(n, k) noexcept: if isinstance(n, Integer) and isinstance(k, Integer): if mpz_cmp_si((n).value, 1) == 0: return k @@ -987,7 +987,7 @@ cdef py_lcm(n, k): ################################################################# # Real Part ################################################################# -cdef py_real(x): +cdef py_real(x) noexcept: """ Returns the real part of x. @@ -1046,7 +1046,7 @@ def py_real_for_doctests(x): ################################################################# # Imaginary Part ################################################################# -cdef py_imag(x): +cdef py_imag(x) noexcept: """ Return the imaginary part of x. @@ -1103,27 +1103,27 @@ def py_imag_for_doctests(x): ################################################################# # Conjugate ################################################################# -cdef py_conjugate(x): +cdef py_conjugate(x) noexcept: try: return x.conjugate() except AttributeError: return x # assume is real since it doesn't have an imag attribute. -cdef bint py_is_rational(x): +cdef bint py_is_rational(x) noexcept: return (type(x) is Rational or type(x) is Integer or isinstance(x, int)) -cdef bint py_is_equal(x, y): +cdef bint py_is_equal(x, y) noexcept: """ Return True precisely if x and y are equal. """ return bool(x == y) -cdef bint py_is_integer(x): +cdef bint py_is_integer(x) noexcept: r""" Returns True if pynac should treat this object as an integer. @@ -1176,7 +1176,7 @@ def py_is_integer_for_doctests(x): return py_is_integer(x) -cdef bint py_is_even(x): +cdef bint py_is_even(x) noexcept: try: return not(x % 2) except Exception: @@ -1187,7 +1187,7 @@ cdef bint py_is_even(x): return 0 -cdef bint py_is_crational(x): +cdef bint py_is_crational(x) noexcept: if py_is_rational(x): return True return isinstance(x, Element) and (x)._parent is pynac_I._parent @@ -1214,7 +1214,7 @@ def py_is_crational_for_doctest(x): return py_is_crational(x) -cdef bint py_is_real(a): +cdef bint py_is_real(a) noexcept: if isinstance(a, (int, Integer, float)): return True try: @@ -1228,7 +1228,7 @@ cdef bint py_is_real(a): return py_imag(a) == 0 -cdef bint py_is_prime(n): +cdef bint py_is_prime(n) noexcept: try: return n.is_prime() except Exception: # yes, I'm doing this on purpose. @@ -1240,7 +1240,7 @@ cdef bint py_is_prime(n): return False -cdef bint py_is_exact(x): +cdef bint py_is_exact(x) noexcept: if isinstance(x, (int, Integer)): return True if not isinstance(x, Element): @@ -1250,7 +1250,7 @@ cdef bint py_is_exact(x): return isinstance(P, SymbolicRing) or P.is_exact() -cdef py_numer(n): +cdef py_numer(n) noexcept: """ Return the numerator of the given object. This is called for typesetting coefficients. @@ -1298,7 +1298,7 @@ def py_numer_for_doctests(n): """ return py_numer(n) -cdef py_denom(n): +cdef py_denom(n) noexcept: """ Return the denominator of the given object. This is called for typesetting coefficients. @@ -1335,7 +1335,7 @@ def py_denom_for_doctests(n): return py_denom(n) -cdef bint py_is_cinteger(x): +cdef bint py_is_cinteger(x) noexcept: return py_is_integer(x) or (py_is_crational(x) and py_denom(x) == 1) @@ -1357,7 +1357,7 @@ def py_is_cinteger_for_doctest(x): """ return py_is_cinteger(x) -cdef py_float(n, PyObject* kwds): +cdef py_float(n, PyObject* kwds) noexcept: """ Evaluate pynac numeric objects numerically. @@ -1416,7 +1416,7 @@ def py_float_for_doctests(n, kwds): return py_float(n, kwds) -cdef py_RDF_from_double(double x): +cdef py_RDF_from_double(double x) noexcept: cdef RealDoubleElement r = RealDoubleElement.__new__(RealDoubleElement) r._value = x return r @@ -1424,7 +1424,7 @@ cdef py_RDF_from_double(double x): ################################################################# # SPECIAL FUNCTIONS ################################################################# -cdef py_tgamma(x): +cdef py_tgamma(x) noexcept: """ The gamma function exported to pynac. @@ -1469,7 +1469,7 @@ def py_tgamma_for_doctests(x): """ return py_tgamma(x) -cdef py_factorial(x): +cdef py_factorial(x) noexcept: """ The factorial function exported to pynac. @@ -1510,7 +1510,7 @@ def py_factorial_py(x): """ return py_factorial(x) -cdef py_doublefactorial(x): +cdef py_doublefactorial(x) noexcept: n = Integer(x) if n < -1: raise ValueError("argument must be >= -1") @@ -1546,10 +1546,10 @@ def doublefactorial(n): return py_doublefactorial(n) -cdef py_fibonacci(n): +cdef py_fibonacci(n) noexcept: return Integer(pari(n).fibonacci()) -cdef py_step(n): +cdef py_step(n) noexcept: """ Return step function of n. """ @@ -1560,10 +1560,10 @@ cdef py_step(n): return SR(1) return SR(Rational((1,2))) -cdef py_bernoulli(x): +cdef py_bernoulli(x) noexcept: return bernoulli(x) -cdef py_sin(x): +cdef py_sin(x) noexcept: """ TESTS:: @@ -1585,7 +1585,7 @@ cdef py_sin(x): except (TypeError, ValueError): return CC(x).sin() -cdef py_cos(x): +cdef py_cos(x) noexcept: """ TESTS:: @@ -1607,7 +1607,7 @@ cdef py_cos(x): except (TypeError, ValueError): return CC(x).cos() -cdef py_stieltjes(x): +cdef py_stieltjes(x) noexcept: """ Return the Stieltjes constant of the given index. @@ -1649,7 +1649,7 @@ def py_stieltjes_for_doctests(x): """ return py_stieltjes(x) -cdef py_zeta(x): +cdef py_zeta(x) noexcept: """ Return the value of the zeta function at the given value. @@ -1683,7 +1683,7 @@ def py_zeta_for_doctests(x): """ return py_zeta(x) -cdef py_exp(x): +cdef py_exp(x) noexcept: """ Return the value of the exp function at the given value. @@ -1724,7 +1724,7 @@ def py_exp_for_doctests(x): """ return py_exp(x) -cdef py_log(x): +cdef py_log(x) noexcept: """ Return the value of the log function at the given value. @@ -1793,7 +1793,7 @@ def py_log_for_doctests(x): """ return py_log(x) -cdef py_tan(x): +cdef py_tan(x) noexcept: try: return x.tan() except AttributeError: @@ -1803,28 +1803,28 @@ cdef py_tan(x): except TypeError: return CC(x).tan() -cdef py_asin(x): +cdef py_asin(x) noexcept: try: return x.arcsin() except AttributeError: return RR(x).arcsin() -cdef py_acos(x): +cdef py_acos(x) noexcept: try: return x.arccos() except AttributeError: return RR(x).arccos() -cdef py_atan(x): +cdef py_atan(x) noexcept: try: return x.arctan() except AttributeError: return RR(x).arctan() -cdef py_atan2(x, y): +cdef py_atan2(x, y) noexcept: """ Return the value of the two argument arctan function at the given values. @@ -1909,14 +1909,14 @@ def py_atan2_for_doctests(x, y): return py_atan2(x, y) -cdef py_sinh(x): +cdef py_sinh(x) noexcept: try: return x.sinh() except AttributeError: return RR(x).sinh() -cdef py_cosh(x): +cdef py_cosh(x) noexcept: if type(x) is float: return math.cosh(PyFloat_AS_DOUBLE(x)) try: @@ -1925,14 +1925,14 @@ cdef py_cosh(x): return RR(x).cosh() -cdef py_tanh(x): +cdef py_tanh(x) noexcept: try: return x.tanh() except AttributeError: return RR(x).tanh() -cdef py_asinh(x): +cdef py_asinh(x) noexcept: try: return x.arcsinh() except AttributeError: @@ -1943,7 +1943,7 @@ cdef py_asinh(x): return CC(x).arcsinh() -cdef py_acosh(x): +cdef py_acosh(x) noexcept: try: return x.arccosh() except AttributeError: @@ -1954,7 +1954,7 @@ cdef py_acosh(x): return CC(x).arccosh() -cdef py_atanh(x): +cdef py_atanh(x) noexcept: try: return x.arctanh() except AttributeError: @@ -1965,7 +1965,7 @@ cdef py_atanh(x): return CC(x).arctanh() -cdef py_lgamma(x): +cdef py_lgamma(x) noexcept: """ Return the value of the principal branch of the log gamma function at the given value. @@ -2012,11 +2012,11 @@ def py_lgamma_for_doctests(x): return py_lgamma(x) -cdef py_isqrt(x): +cdef py_isqrt(x) noexcept: return Integer(x).isqrt() -cdef py_sqrt(x): +cdef py_sqrt(x) noexcept: try: # WORRY: What if Integer's sqrt calls symbolic one and we go in circle? return x.sqrt() @@ -2024,11 +2024,11 @@ cdef py_sqrt(x): return math.sqrt(float(x)) -cdef py_abs(x): +cdef py_abs(x) noexcept: return abs(x) -cdef py_mod(x, n): +cdef py_mod(x, n) noexcept: """ Return x mod n. Both x and n are assumed to be integers. @@ -2076,7 +2076,7 @@ def py_mod_for_doctests(x, n): return py_mod(x, n) -cdef py_smod(a, b): +cdef py_smod(a, b) noexcept: # Modulus (in symmetric representation). # Equivalent to Maple's mods. # returns a mod b in the range [-iquo(abs(b)-1,2), iquo(abs(b),2)] @@ -2089,15 +2089,15 @@ cdef py_smod(a, b): return c -cdef py_irem(x, n): +cdef py_irem(x, n) noexcept: return Integer(x) % Integer(n) -cdef py_iquo(x, n): +cdef py_iquo(x, n) noexcept: return Integer(x)//Integer(n) -cdef py_iquo2(x, n): +cdef py_iquo2(x, n) noexcept: x = Integer(x) n = Integer(n) try: @@ -2115,7 +2115,7 @@ cdef int py_int_length(x) except -1: return Integer(x).nbits() -cdef py_li(x, n, parent): +cdef py_li(x, n, parent) noexcept: """ Returns a numerical approximation of polylog(n, x) with precision given by the ``parent`` argument. @@ -2152,7 +2152,7 @@ def py_li_for_doctests(x, n, parent): return py_li(x, n, parent) -cdef py_psi(x): +cdef py_psi(x) noexcept: """ EXAMPLES:: @@ -2187,7 +2187,7 @@ def py_psi_for_doctests(x): """ return py_psi(x) -cdef py_psi2(n, x): +cdef py_psi2(n, x) noexcept: """ EXAMPLES:: @@ -2215,7 +2215,7 @@ def py_psi2_for_doctests(n, x): """ return py_psi2(n, x) -cdef py_li2(x): +cdef py_li2(x) noexcept: """ EXAMPLES:: @@ -2249,7 +2249,7 @@ def py_li2_for_doctests(x): # Constants ################################################################## -cdef GConstant py_get_constant(const char* name): +cdef GConstant py_get_constant(const char* name) noexcept: """ Returns a constant given its name. This is called by constant::unarchive in constant.cpp in Pynac and is used for @@ -2264,12 +2264,12 @@ cdef GConstant py_get_constant(const char* name): pc = c._pynac return pc.pointer[0] -cdef py_eval_constant(unsigned serial, kwds): +cdef py_eval_constant(unsigned serial, kwds) noexcept: from sage.symbolic.constants import constants_table constant = constants_table[serial] return kwds['parent'](constant) -cdef py_eval_unsigned_infinity(): +cdef py_eval_unsigned_infinity() noexcept: """ Returns unsigned_infinity. """ @@ -2288,7 +2288,7 @@ def py_eval_unsigned_infinity_for_doctests(): """ return py_eval_unsigned_infinity() -cdef py_eval_infinity(): +cdef py_eval_infinity() noexcept: """ Returns positive infinity, i.e., oo. """ @@ -2307,7 +2307,7 @@ def py_eval_infinity_for_doctests(): """ return py_eval_infinity() -cdef py_eval_neg_infinity(): +cdef py_eval_neg_infinity() noexcept: """ Returns minus_infinity. """ @@ -2330,37 +2330,37 @@ def py_eval_neg_infinity_for_doctests(): # Constructors ################################################################## -cdef py_integer_from_long(long x): +cdef py_integer_from_long(long x) noexcept: return smallInteger(x) -cdef py_integer_from_python_obj(x): +cdef py_integer_from_python_obj(x) noexcept: return Integer(x) -cdef py_integer_from_mpz(mpz_t bigint): +cdef py_integer_from_mpz(mpz_t bigint) noexcept: cdef Integer z = PY_NEW(Integer) mpz_set(z.value, bigint) return z -cdef py_rational_from_mpq(mpq_t bigrat): +cdef py_rational_from_mpq(mpq_t bigrat) noexcept: cdef Rational rat = Rational.__new__(Rational) mpq_set(rat.value, bigrat) mpq_canonicalize(rat.value) return rat -cdef bint py_is_Integer(x): +cdef bint py_is_Integer(x) noexcept: return isinstance(x, Integer) -cdef bint py_is_Rational(x): +cdef bint py_is_Rational(x) noexcept: return isinstance(x, Rational) -cdef mpz_ptr py_mpz_from_integer(x): +cdef mpz_ptr py_mpz_from_integer(x) noexcept: return ((x).value) -cdef mpq_ptr py_mpq_from_rational(x): +cdef mpq_ptr py_mpq_from_rational(x) noexcept: return ((x).value) diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index 822eaacd30b..f3f32b9c922 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -122,7 +122,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): """ return r'\text{SR}' - cpdef _coerce_map_from_(self, R): + cpdef _coerce_map_from_(self, R) noexcept: """ EXAMPLES:: @@ -1221,7 +1221,7 @@ cdef class NumpyToSRMorphism(Morphism): else: raise TypeError("{} is not a numpy number type".format(numpy_type)) - cpdef Element _call_(self, a): + cpdef Element _call_(self, a) noexcept: """ EXAMPLES: @@ -1268,7 +1268,7 @@ cdef class UnderscoreSageMorphism(Morphism): from sage.interfaces.sympy import sympy_init sympy_init() - cpdef Element _call_(self, a): + cpdef Element _call_(self, a) noexcept: """ EXAMPLES: diff --git a/src/sage/symbolic/substitution_map_impl.pxi b/src/sage/symbolic/substitution_map_impl.pxi index ea60e899d1a..c1dc3be748b 100644 --- a/src/sage/symbolic/substitution_map_impl.pxi +++ b/src/sage/symbolic/substitution_map_impl.pxi @@ -24,7 +24,7 @@ cdef class SubstitutionMap(SageObject): cdef GExMap _gmapobj - cpdef Expression apply_to(self, Expression expr, unsigned options): + cpdef Expression apply_to(self, Expression expr, unsigned options) noexcept: """ Apply the substitution to a symbolic expression @@ -51,7 +51,7 @@ cdef class SubstitutionMap(SageObject): return 'SubsMap' # GEx_to_str(&x._gobj) -cdef SubstitutionMap new_SubstitutionMap_from_GExMap(const GExMap& smap): +cdef SubstitutionMap new_SubstitutionMap_from_GExMap(const GExMap& smap) noexcept: """ Wrap a Pynac object into a Python object @@ -75,7 +75,7 @@ cdef SubstitutionMap new_SubstitutionMap_from_GExMap(const GExMap& smap): return result -cpdef SubstitutionMap make_map(subs_dict): +cpdef SubstitutionMap make_map(subs_dict) noexcept: """ Construct a new substitution map diff --git a/src/sage/tests/stl_vector.pyx b/src/sage/tests/stl_vector.pyx index f3b29b30dfe..2a7c1bf5d05 100644 --- a/src/sage/tests/stl_vector.pyx +++ b/src/sage/tests/stl_vector.pyx @@ -115,7 +115,7 @@ cdef class stl_int_vector(SageObject): s += ' data[' + str(i) + '] = ' + str(self.data.at(i)) + '\n' return s.strip() - cpdef sum(self): + cpdef sum(self) noexcept: """ Add the elements. From 3bd553243652ca850915b4f7faf6bb73f577f538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Sun, 22 Oct 2023 14:10:23 -0300 Subject: [PATCH 171/494] Minor fixes after the automatic commit. - fix one incorrectly placed `noexcept` - fix a doctest due to code change --- .../perm_gps/partn_ref/automorphism_group_canonical_label.pxd | 2 +- src/sage/misc/sageinspect.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd index f13b0d06bc6..573eeb83f58 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd @@ -47,7 +47,7 @@ cdef aut_gp_and_can_lab *get_aut_gp_and_can_lab( void *, PartitionStack *, int, bint (*)(PartitionStack *, void *) noexcept, int (*)(PartitionStack *, void *, int *, int) noexcept, - int (*)(int *, int *, void *, void *, int), bint, StabilizerChain * noexcept, + int (*)(int *, int *, void *, void *, int) noexcept, bint, StabilizerChain *, agcl_work_space *, aut_gp_and_can_lab *) except NULL diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 811afc48755..d28e792aeda 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -2383,7 +2383,7 @@ def sage_getsourcelines(obj): '\n', ' cdef GEx _gobj\n', '\n', - ' cpdef object pyobject(self):\n'] + ' cpdef object pyobject(self) noexcept:\n'] sage: lines[-1] # last line # needs sage.symbolic ' return S\n' From 131b74759329d4d48dd8e60f1b3120dd36ff5e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Sun, 22 Oct 2023 14:11:14 -0300 Subject: [PATCH 172/494] disable legacy_implicit_noexcept --- src/sage_setup/cython_options.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage_setup/cython_options.py b/src/sage_setup/cython_options.py index 9725ce0e1af..edeb1c43aad 100644 --- a/src/sage_setup/cython_options.py +++ b/src/sage_setup/cython_options.py @@ -20,7 +20,6 @@ def compiler_directives(profile: bool): fast_getattr=True, # Use Python 3 (including source code semantics) for module compilation language_level="3", - legacy_implicit_noexcept=True, # Enable support for late includes (make declarations in Cython code available to C include files) preliminary_late_includes_cy28=True, # Add hooks for Python profilers into the compiled C code From 8335565313b7aaa858af4e4859c621e23dad4a6d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 22 Oct 2023 19:47:23 -0700 Subject: [PATCH 173/494] build/pkgs/meson: Update to 1.2.3 --- build/pkgs/meson/checksums.ini | 6 +++--- build/pkgs/meson/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/meson/checksums.ini b/build/pkgs/meson/checksums.ini index 97e3fe2c251..bbb4661c960 100644 --- a/build/pkgs/meson/checksums.ini +++ b/build/pkgs/meson/checksums.ini @@ -1,5 +1,5 @@ tarball=meson-VERSION.tar.gz -sha1=39b8a4bff467fdaa5f9ee87e04715bd97a148378 -md5=702bfd8b0648521322d3f145a8fc70ea -cksum=399123386 +sha1=97e766951553ec35315712f0a27d5554a010d4c3 +md5=69da4c63ef06c9d3bcc00ce89abb306f +cksum=2424401184 upstream_url=https://pypi.io/packages/source/m/meson/meson-VERSION.tar.gz diff --git a/build/pkgs/meson/package-version.txt b/build/pkgs/meson/package-version.txt index 23aa8390630..0495c4a88ca 100644 --- a/build/pkgs/meson/package-version.txt +++ b/build/pkgs/meson/package-version.txt @@ -1 +1 @@ -1.2.2 +1.2.3 From 94d13e9876ceeb483c755fcb3a322d8f52dfab36 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 22 Oct 2023 19:48:25 -0700 Subject: [PATCH 174/494] build/pkgs/numpy: Update to 1.26.1 --- build/pkgs/numpy/checksums.ini | 6 +++--- build/pkgs/numpy/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/numpy/checksums.ini b/build/pkgs/numpy/checksums.ini index 886bc13768b..67c13061038 100644 --- a/build/pkgs/numpy/checksums.ini +++ b/build/pkgs/numpy/checksums.ini @@ -1,5 +1,5 @@ tarball=numpy-VERSION.tar.gz -sha1=a3f9d79d7852f5d35ff35693fc31d17ea270d2d0 -md5=69bd28f07afbeed2bb6ecd467afcd469 -cksum=3599108965 +sha1=00f8e85fae2e2ccf8afa78e8da3a058831230ef1 +md5=2d770f4c281d405b690c4bcb3dbe99e2 +cksum=1663231076 upstream_url=https://pypi.io/packages/source/n/numpy/numpy-VERSION.tar.gz diff --git a/build/pkgs/numpy/package-version.txt b/build/pkgs/numpy/package-version.txt index 5ff8c4f5d2a..dd43a143f02 100644 --- a/build/pkgs/numpy/package-version.txt +++ b/build/pkgs/numpy/package-version.txt @@ -1 +1 @@ -1.26.0 +1.26.1 From a8959e898ac2966b8bd4976ecb8b1c211b6596c7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 03:47:33 +0000 Subject: [PATCH 175/494] Add pyright ci annotations --- .github/workflows/build.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5242dfc06f9..82f8ee825d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,21 +103,26 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Set up node to install pyright + - name: Static code check with pyright if: always() && steps.worktree.outcome == 'success' - uses: actions/setup-node@v3 + uses: jakebailey/pyright-action@v1 with: - node-version: '12' - - - name: Install pyright + # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 + version: 1.1.232 + # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. + no-comments: true + working-directory: ./worktree-image + + - name: Static code check with pyright (annotated) if: always() && steps.worktree.outcome == 'success' - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - run: npm install -g pyright@1.1.232 - - - name: Static code check with pyright - if: always() && steps.worktree.outcome == 'success' - run: pyright - working-directory: ./worktree-image + uses: jakebailey/pyright-action@v1 + with: + # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 + version: 1.1.232 + # Issue warnings for all annoted functions + no-comments: false + skip-unannotated: true + working-directory: ./worktree-image - name: Clean (fallback to non-incremental) id: clean From a848f1ec08647133c8d7895b6b218acc6d516335 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 19 Oct 2023 12:27:46 -0700 Subject: [PATCH 176/494] .vscode/settings.json (search.exclude): Replace incomplete list of symlinks by glob patterns --- .vscode/settings.json | 15 ++++++++------- src/doc/en/developer/packaging_sage_library.rst | 3 --- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index be90c535c32..050be4ca5e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,13 +8,14 @@ "src/**/*.so": true }, "search.exclude": { - "build/pkgs/sagemath_categories/src": true, - "build/pkgs/sagemath_objects/src": true, - "build/pkgs/sagelib/src": true, - "pkgs/sage-conf_pypi/sage_root/build": true, - "pkgs/sagemath-categories/sage": true, - "pkgs/sagemath-objects/sage": true, - "pkgs/sagemath-standard/sage": true + // Exclude symbolic links into SAGE_ROOT/pkgs/ + "build/pkgs/*/src": true, + // Exclude symbolic links into SAGE_ROOT/src/ + "pkgs/sage-conf_conda/sage_root": true, + "pkgs/sage-conf_pypi/sage_root": true, + "pkgs/sage-docbuild/sage_docbuild": true, + "pkgs/sage-setup/sage_setup": true, + "pkgs/sagemath-*/sage": true }, "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst index abda71bbed8..4915e240cea 100644 --- a/src/doc/en/developer/packaging_sage_library.rst +++ b/src/doc/en/developer/packaging_sage_library.rst @@ -190,9 +190,6 @@ The technique of using symbolic links pointing into ``SAGE_ROOT/src`` has allowed the modularization effort to keep the ``SAGE_ROOT/src`` tree monolithic: Modularization has been happening behind the scenes and will not change where Sage developers find the source files. -When adding a new distribution package that uses a symbolic link pointing into -``SAGE_ROOT/src``, please update ``search.exclude`` in -``SAGE_ROOT/.vscode/settings.json``. Some of these files may actually be generated from source files with suffix ``.m4`` by the ``SAGE_ROOT/bootstrap`` script via the ``m4`` macro processor. From 5005cc62529163c422b3ac3f02107e7148c7f021 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 04:18:48 +0000 Subject: [PATCH 177/494] Only annotate errors --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82f8ee825d3..b5e630fd789 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,9 +119,9 @@ jobs: with: # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 version: 1.1.232 - # Issue warnings for all annoted functions + # Issue errors no-comments: false - skip-unannotated: true + level: error working-directory: ./worktree-image - name: Clean (fallback to non-incremental) From 7856e140138e86bd2210592b2220f53f565947fd Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 05:41:11 +0000 Subject: [PATCH 178/494] update pyright --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5e630fd789..9f258de05be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,8 +107,7 @@ jobs: if: always() && steps.worktree.outcome == 'success' uses: jakebailey/pyright-action@v1 with: - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - version: 1.1.232 + version: 1.1.332 # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. no-comments: true working-directory: ./worktree-image @@ -117,8 +116,7 @@ jobs: if: always() && steps.worktree.outcome == 'success' uses: jakebailey/pyright-action@v1 with: - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - version: 1.1.232 + version: 1.1.332 # Issue errors no-comments: false level: error From 226a35b2e919ccc39362f27fb65a874a716ec0af Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 06:42:07 +0000 Subject: [PATCH 179/494] fix out of memory --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f258de05be..7ac9c6154d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,6 +111,9 @@ jobs: # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. no-comments: true working-directory: ./worktree-image + env: + # To avoid out of memory errors + NODE_OPTIONS: --max-old-space-size=8192 - name: Static code check with pyright (annotated) if: always() && steps.worktree.outcome == 'success' @@ -121,6 +124,9 @@ jobs: no-comments: false level: error working-directory: ./worktree-image + env: + # To avoid out of memory errors + NODE_OPTIONS: --max-old-space-size=8192 - name: Clean (fallback to non-incremental) id: clean From 6f010eaed64a174426e6566f6912493b08e2ac59 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 07:27:40 +0000 Subject: [PATCH 180/494] Remove private import --- src/sage/functions/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index 249eb2ea56f..eed84964be3 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -2209,7 +2209,7 @@ def _evalf_(self, poly, index, parent=None, algorithm=None): sage: complex_root_of(x^8 - 1, 7).n(20) # needs sage.symbolic 0.70711 + 0.70711*I """ - from sympy.core.evalf import prec_to_dps + from mpmath.libmp import prec_to_dps from sympy.polys import CRootOf, Poly try: prec = parent.precision() From 01eed9839b507a56f5f1b171b288c5e134c8b0b4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 07:34:57 +0000 Subject: [PATCH 181/494] Add manual workaround for out of memory --- src/doc/en/developer/tools.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/doc/en/developer/tools.rst b/src/doc/en/developer/tools.rst index 20878a6175d..fca5d5ef4c1 100644 --- a/src/doc/en/developer/tools.rst +++ b/src/doc/en/developer/tools.rst @@ -327,7 +327,10 @@ Pyright - Tox: Run ``./sage -tox -e pyright path/to/the/file.py`` -- Manual: Run ``pyright path/to/the/file.py`` +- Manual: Run ``pyright path/to/the/file.py``. If you want to check the whole Sage library, you most likely run out of memory with the default settings. + You can use the following command to check the whole library:: + + NODE_OPTIONS="--max-old-space-size=8192" pyright - VS Code: Install the `Pylance `__ extension. From fb1aa91270527b88262e9b6037bfa88f10c902ae Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 27 Sep 2023 13:32:54 -0700 Subject: [PATCH 182/494] build/pkgs/{networkx,scipy,ipywidgets}: Update version range in distros/conda.txt --- build/pkgs/ipywidgets/distros/conda.txt | 2 +- build/pkgs/networkx/distros/conda.txt | 2 +- build/pkgs/scipy/distros/conda.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pkgs/ipywidgets/distros/conda.txt b/build/pkgs/ipywidgets/distros/conda.txt index f943f9d4979..162744f2841 100644 --- a/build/pkgs/ipywidgets/distros/conda.txt +++ b/build/pkgs/ipywidgets/distros/conda.txt @@ -1 +1 @@ -ipywidgets<8.0.0 +ipywidgets>=7.5.1 diff --git a/build/pkgs/networkx/distros/conda.txt b/build/pkgs/networkx/distros/conda.txt index 67cbec89b21..96b0bbb2845 100644 --- a/build/pkgs/networkx/distros/conda.txt +++ b/build/pkgs/networkx/distros/conda.txt @@ -1 +1 @@ -networkx<3.0,>=2.4 +networkx<3.2,>=2.4 diff --git a/build/pkgs/scipy/distros/conda.txt b/build/pkgs/scipy/distros/conda.txt index 21b2670008a..175cd197f8c 100644 --- a/build/pkgs/scipy/distros/conda.txt +++ b/build/pkgs/scipy/distros/conda.txt @@ -1 +1 @@ -scipy<1.11,>=1.5 +scipy<1.12,>=1.5 From 31da06333bb9ce170c048b6f9275d9d6859eff17 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 1 May 2023 18:25:58 -0700 Subject: [PATCH 183/494] build/pkgs/sagenb_export/install-requires.txt: Replace nonexistent PyPI package name by git+https --- build/pkgs/sagenb_export/install-requires.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/sagenb_export/install-requires.txt b/build/pkgs/sagenb_export/install-requires.txt index 0592ab651b1..9c94d6990d1 100644 --- a/build/pkgs/sagenb_export/install-requires.txt +++ b/build/pkgs/sagenb_export/install-requires.txt @@ -1 +1 @@ -sagenb_export >=3.3 +git+https://github.com/vbraun/ExportSageNB.git#egg=sagenb_export From a53205584e8b02b77c9efda33d8827ebadee04b7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 20:03:40 -0700 Subject: [PATCH 184/494] src/sage/schemes/toric/variety.py: Fix pyright 'is possibly unbound' --- src/sage/schemes/toric/variety.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index 82d2ec7769a..c2aea308b9b 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -2250,20 +2250,21 @@ def Todd_class(self, deg=None): 1 """ Td = QQ.one() - if self.dimension() >= 1: + dim = self.dimension() + if dim >= 1: c1 = self.Chern_class(1) Td += QQ.one() / 2 * c1 - if self.dimension() >= 2: - c2 = self.Chern_class(2) - Td += QQ.one() / 12 * (c1**2 + c2) - if self.dimension() >= 3: - Td += QQ.one() / 24 * c1*c2 - if self.dimension() >= 4: - c3 = self.Chern_class(3) - c4 = self.Chern_class(4) - Td += -QQ.one() / 720 * (c1**4 - 4*c1**2*c2 - 3*c2**2 - c1*c3 + c4) - if self.dimension() >= 5: - raise NotImplementedError('Todd class is currently only implemented up to degree 4') + if dim >= 2: + c2 = self.Chern_class(2) + Td += QQ.one() / 12 * (c1**2 + c2) + if dim >= 3: + Td += QQ.one() / 24 * c1*c2 + if dim >= 4: + c3 = self.Chern_class(3) + c4 = self.Chern_class(4) + Td += -QQ.one() / 720 * (c1**4 - 4*c1**2*c2 - 3*c2**2 - c1*c3 + c4) + if dim >= 5: + raise NotImplementedError('Todd class is currently only implemented up to degree 4') if deg is None: return Td else: From fd8beac8fa46a2596e8e4eb8a7895e32deaa7915 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 21:20:09 -0700 Subject: [PATCH 185/494] src/sage/misc/lazy_attribute.pyi: New --- src/sage/misc/lazy_attribute.pyi | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/sage/misc/lazy_attribute.pyi diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi new file mode 100644 index 00000000000..aff688c5f57 --- /dev/null +++ b/src/sage/misc/lazy_attribute.pyi @@ -0,0 +1 @@ +lazy_attribute = property From 8281d2e26ccef6105dfbe805c8813aadb8c7af3c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 21:38:43 -0700 Subject: [PATCH 186/494] src/sage/misc/lazy_attribute.pyi: Add comment --- src/sage/misc/lazy_attribute.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi index aff688c5f57..c4a2cdc2522 100644 --- a/src/sage/misc/lazy_attribute.pyi +++ b/src/sage/misc/lazy_attribute.pyi @@ -1 +1,3 @@ +# This type-stub file helps pyright understand the decorator @lazy_attribute. + lazy_attribute = property From 5d313543f4120b7bfe1cdbcc18d8d67be4b6d291 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 22 Oct 2023 08:19:38 -0700 Subject: [PATCH 187/494] src/sage/misc/lazy_attribute.pyi: Proper type stub for lazy_attribute --- src/sage/misc/lazy_attribute.pyi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi index c4a2cdc2522..6a174a37aa2 100644 --- a/src/sage/misc/lazy_attribute.pyi +++ b/src/sage/misc/lazy_attribute.pyi @@ -1,3 +1,9 @@ # This type-stub file helps pyright understand the decorator @lazy_attribute. -lazy_attribute = property +# Adapted from https://github.com/python/typeshed/blob/b9640005eb586afdbe0a57bac2b88a7a12465069/stdlib/builtins.pyi#L1237-L1254 +class lazy_attribute: + def __init__( + self, + f: Callable[[Any], Any] | None = ... + ) -> None: ... + def __get__(self, a: Any, cls: type) -> Any: ... From 4f66a4ba28671c787849994ba62cf3ec38a8ea6f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 23 Oct 2023 12:09:14 -0700 Subject: [PATCH 188/494] pkgs/sagemath-{bliss,sirocco,tdlib}: Fix MANIFEST.in --- pkgs/sagemath-bliss/MANIFEST.in | 3 +++ pkgs/sagemath-sirocco/MANIFEST.in | 4 ++++ pkgs/sagemath-tdlib/MANIFEST.in | 3 +++ 3 files changed, 10 insertions(+) diff --git a/pkgs/sagemath-bliss/MANIFEST.in b/pkgs/sagemath-bliss/MANIFEST.in index 6d981b9d30e..2572c2b46f7 100644 --- a/pkgs/sagemath-bliss/MANIFEST.in +++ b/pkgs/sagemath-bliss/MANIFEST.in @@ -1,6 +1,9 @@ +prune sage + include VERSION.txt graft sage/graphs/bliss_cpp +include sage/graphs/bliss.p* global-exclude *.c global-exclude *.cpp diff --git a/pkgs/sagemath-sirocco/MANIFEST.in b/pkgs/sagemath-sirocco/MANIFEST.in index 815a868524d..8ac89baa796 100644 --- a/pkgs/sagemath-sirocco/MANIFEST.in +++ b/pkgs/sagemath-sirocco/MANIFEST.in @@ -1,5 +1,9 @@ +prune sage + include VERSION.txt +include sage/libs/sirocco.p* + global-exclude *.c global-exclude *.cpp diff --git a/pkgs/sagemath-tdlib/MANIFEST.in b/pkgs/sagemath-tdlib/MANIFEST.in index 614186d89ab..156e1c3b85a 100644 --- a/pkgs/sagemath-tdlib/MANIFEST.in +++ b/pkgs/sagemath-tdlib/MANIFEST.in @@ -1,9 +1,12 @@ +prune sage + include VERSION.txt global-exclude *.c global-exclude *.cpp include sage/graphs/graph_decompositions/sage_tdlib.cpp +include sage/graphs/graph_decompositions/tdlib.p* global-exclude all__sagemath_*.* global-include all__sagemath_tdlib.py From 0efcbd77a470e27a3dc93b10141c759bd24a4659 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 23 Oct 2023 12:38:03 -0700 Subject: [PATCH 189/494] .github/workflows/dist.yml: Update runners --- .github/workflows/dist.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index de49bbc69a3..909404232cb 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -111,11 +111,11 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-latest arch: x86_64 - - os: ubuntu-20.04 + - os: ubuntu-latest arch: i686 - - os: macos-10.15 + - os: macos-latest arch: auto env: # SPKGs to install as system packages From 34aa22a02815cafae5f5036e0a88c3b7700e9088 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 23 Oct 2023 12:38:51 -0700 Subject: [PATCH 190/494] .github/workflows/dist.yml: Update cibuildwheel to 2.16.2 --- .github/workflows/dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 909404232cb..54da286dcd8 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -156,7 +156,7 @@ jobs: mkdir -p unpacked for pkg in sagemath-objects sagemath-categories; do (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz - pipx run cibuildwheel==2.7.0 unpacked/$pkg* + pipx run cibuildwheel==2.16.2 unpacked/$pkg* done - uses: actions/upload-artifact@v3 From c9f939b2d960dc63b3b57cce9cda6ee7e51a7e6f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 24 Oct 2023 04:55:40 +0900 Subject: [PATCH 191/494] Fix E401 multiple imports on one lines --- src/sage/misc/persist.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/misc/persist.pyx b/src/sage/misc/persist.pyx index 80d4f9b23d5..0230e0b4252 100644 --- a/src/sage/misc/persist.pyx +++ b/src/sage/misc/persist.pyx @@ -1130,7 +1130,8 @@ def unpickle_all(target, debug=False, run_test_suite=False): Successfully unpickled 1 objects. Failed to unpickle 0 objects. """ - import os.path, tarfile + import os.path + import tarfile ok_count = 0 fail_count = 0 From b3725e33932e923053d666acab954c1761b56731 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 23 Oct 2023 13:31:26 -0700 Subject: [PATCH 192/494] .github/workflows/dist.yml: No wheels for 3.12 --- .github/workflows/dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 54da286dcd8..fb2229ba7b4 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -128,7 +128,7 @@ jobs: # CIBW_ARCHS: ${{ matrix.arch }} # https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9, <3.12" # Environment during wheel build CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal" # Use 'build', not 'pip wheel' From f1185a81c43e5119836ffcf773e738d0b132b359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 24 Oct 2023 13:43:35 +0200 Subject: [PATCH 193/494] micro detail --- src/sage/geometry/hyperplane_arrangement/arrangement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/hyperplane_arrangement/arrangement.py b/src/sage/geometry/hyperplane_arrangement/arrangement.py index c25e0733a43..90e620b71bc 100644 --- a/src/sage/geometry/hyperplane_arrangement/arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/arrangement.py @@ -3185,7 +3185,7 @@ def varchenko_matrix(self, names='h'): n = len(region) v = identity_matrix(R, n, n) for i in range(n): - for j in range(i+1, n): + for j in range(i + 1, n): t = prod(h[p] for p in range(k) if self.is_separating_hyperplane(region[i], region[j], self[p])) v[i, j] = v[j, i] = t From 66f732d513c031a5b542ce1685fcdee93c26d6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 24 Oct 2023 13:44:16 +0200 Subject: [PATCH 194/494] some cleanup in quadratic forms --- src/sage/combinat/designs/design_catalog.py | 2 +- src/sage/quadratic_forms/binary_qf.py | 10 +- src/sage/quadratic_forms/genera/all.py | 7 +- .../quadratic_form__automorphisms.py | 9 +- .../quadratic_form__count_local_2.py | 6 +- .../quadratic_form__equivalence_testing.py | 2 +- .../quadratic_form__local_field_invariants.py | 6 +- .../quadratic_forms/quadratic_form__mass.py | 40 ++++---- .../quadratic_form__neighbors.py | 3 +- .../quadratic_form__siegel_product.py | 11 ++- .../quadratic_form__split_local_covering.py | 45 +++++---- .../quadratic_form__ternary_Tornaria.py | 92 ++++++++++--------- .../quadratic_forms/quadratic_form__theta.py | 51 +++++----- .../projective/projective_subscheme.py | 2 +- 14 files changed, 144 insertions(+), 142 deletions(-) diff --git a/src/sage/combinat/designs/design_catalog.py b/src/sage/combinat/designs/design_catalog.py index 26b899cb93d..8bf7f14fd0b 100644 --- a/src/sage/combinat/designs/design_catalog.py +++ b/src/sage/combinat/designs/design_catalog.py @@ -118,4 +118,4 @@ 'OAMainFunctions', as_='orthogonal_arrays') lazy_import('sage.combinat.designs.gen_quadrangles_with_spread', - ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) \ No newline at end of file + ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py index c82a343a04e..6516888e3ac 100755 --- a/src/sage/quadratic_forms/binary_qf.py +++ b/src/sage/quadratic_forms/binary_qf.py @@ -910,7 +910,8 @@ def reduced_form(self, transformation=False, algorithm="default"): if algorithm == 'sage': if self.discriminant() <= 0: raise NotImplementedError('reduction of definite binary ' - 'quadratic forms is not implemented in Sage') + 'quadratic forms is not implemented ' + 'in Sage') return self._reduce_indef(transformation) elif algorithm == 'pari': @@ -1154,14 +1155,15 @@ def cycle(self, proper=False): if self.discriminant().is_square(): # Buchmann/Vollmer assume the discriminant to be non-square raise NotImplementedError('computation of cycles is only ' - 'implemented for non-square discriminants') + 'implemented for non-square ' + 'discriminants') if proper: # Prop 6.10.5 in Buchmann Vollmer C = list(self.cycle(proper=False)) # make a copy that we can modify if len(C) % 2: C += C - for i in range(len(C)//2): - C[2*i+1] = C[2*i+1]._Tau() + for i in range(len(C) // 2): + C[2 * i + 1] = C[2 * i + 1]._Tau() return C if not hasattr(self, '_cycle_list'): C = [self] diff --git a/src/sage/quadratic_forms/genera/all.py b/src/sage/quadratic_forms/genera/all.py index 0b1889ba520..b1f48b5b8f6 100644 --- a/src/sage/quadratic_forms/genera/all.py +++ b/src/sage/quadratic_forms/genera/all.py @@ -1,9 +1,8 @@ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 David Kohel # # Distributed under the terms of the GNU General Public License (GPL) # -# http://www.gnu.org/licenses/ -#***************************************************************************** - +# https://www.gnu.org/licenses/ +# **************************************************************************** from .genus import Genus, LocalGenusSymbol, is_GlobalGenus diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py index d0bf38f71a5..89b2c079478 100644 --- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py +++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py @@ -115,7 +115,6 @@ def short_vector_list_up_to_length(self, len_bound, up_to_sign_flag=False): A list of lists of vectors such that entry `[i]` contains all vectors of length `i`. - EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,3,5,7]) @@ -143,13 +142,13 @@ def short_vector_list_up_to_length(self, len_bound, up_to_sign_flag=False): [], [(0, 1, 0, 0)], [(1, 1, 0, 0), (1, -1, 0, 0), (2, 0, 0, 0)]] - sage: Q = QuadraticForm(matrix(6, [2, 1, 1, 1, -1, -1, 1, 2, 1, 1, -1, -1, 1, 1, 2, 0, -1, -1, 1, 1, 0, 2, 0, -1, -1, -1, -1, 0, 2, 1, -1, -1, -1, -1, 1, 2])) + sage: m6 = matrix(6, [2, 1, 1, 1, -1, -1, 1, 2, 1, 1, -1, -1, + ....: 1, 1, 2, 0, -1, -1, 1, 1, 0, 2, 0, -1, + ....: -1, -1, -1, 0, 2, 1, -1, -1, -1, -1, 1, 2]) + sage: Q = QuadraticForm(m6) sage: vs = Q.short_vector_list_up_to_length(8) sage: [len(vs[i]) for i in range(len(vs))] [1, 72, 270, 720, 936, 2160, 2214, 3600] - sage: vs = Q.short_vector_list_up_to_length(30) # long time (28s on sage.math, 2014) - sage: [len(vs[i]) for i in range(len(vs))] # long time - [1, 72, 270, 720, 936, 2160, 2214, 3600, 4590, 6552, 5184, 10800, 9360, 12240, 13500, 17712, 14760, 25920, 19710, 26064, 28080, 36000, 25920, 47520, 37638, 43272, 45900, 59040, 46800, 75600] The cases of ``len_bound < 2`` led to exception or infinite runtime before. diff --git a/src/sage/quadratic_forms/quadratic_form__count_local_2.py b/src/sage/quadratic_forms/quadratic_form__count_local_2.py index 999da6428de..b125d8d6840 100644 --- a/src/sage/quadratic_forms/quadratic_form__count_local_2.py +++ b/src/sage/quadratic_forms/quadratic_form__count_local_2.py @@ -68,9 +68,9 @@ def count_congruence_solutions_as_vector(self, p, k, m, zvec, nzvec): return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec) -##/////////////////////////////////////////// -##/// Front-ends for our counting routines // -##/////////////////////////////////////////// +# ////////////////////////////////////////// +# // Front-ends for our counting routines // +# ////////////////////////////////////////// def count_congruence_solutions(self, p, k, m, zvec, nzvec): r""" diff --git a/src/sage/quadratic_forms/quadratic_form__equivalence_testing.py b/src/sage/quadratic_forms/quadratic_form__equivalence_testing.py index 7b109b3dc01..148fcbd21f2 100644 --- a/src/sage/quadratic_forms/quadratic_form__equivalence_testing.py +++ b/src/sage/quadratic_forms/quadratic_form__equivalence_testing.py @@ -289,7 +289,7 @@ def has_equivalent_Jordan_decomposition_at_prime(self, other, p): # Check O'Meara's condition (ii) when appropriate if norm_list[i + 1] % (4 * norm_list[i]) == 0: if self_hasse_chain_list[i] * hilbert_symbol(norm_list[i] * other_chain_det_list[i], -self_chain_det_list[i], 2) \ - != other_hasse_chain_list[i] * hilbert_symbol(norm_list[i], -other_chain_det_list[i], 2): # Nipp conditions + != other_hasse_chain_list[i] * hilbert_symbol(norm_list[i], -other_chain_det_list[i], 2): # Nipp conditions return False # All tests passed for the prime 2. diff --git a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py index 35f64198113..aff8dad2d62 100644 --- a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py +++ b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py @@ -5,7 +5,7 @@ quadratic forms over the rationals. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 William Stein and Jonathan Hanke # Copyright (C) 2015 Jeroen Demeyer # @@ -13,8 +13,8 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** ########################################################################### # TO DO: Add routines for hasse invariants at all places, anisotropic diff --git a/src/sage/quadratic_forms/quadratic_form__mass.py b/src/sage/quadratic_forms/quadratic_form__mass.py index 11b581b1dd7..67bf06d888a 100644 --- a/src/sage/quadratic_forms/quadratic_form__mass.py +++ b/src/sage/quadratic_forms/quadratic_form__mass.py @@ -7,27 +7,27 @@ # Import all general mass finding routines from sage.quadratic_forms.quadratic_form__mass__Siegel_densities import \ - mass__by_Siegel_densities, \ - Pall_mass_density_at_odd_prime, \ - Watson_mass_at_2, \ - Kitaoka_mass_at_2, \ - mass_at_two_by_counting_mod_power + mass__by_Siegel_densities, \ + Pall_mass_density_at_odd_prime, \ + Watson_mass_at_2, \ + Kitaoka_mass_at_2, \ + mass_at_two_by_counting_mod_power from sage.quadratic_forms.quadratic_form__mass__Conway_Sloane_masses import \ - parity, \ - is_even, \ - is_odd, \ - conway_species_list_at_odd_prime, \ - conway_species_list_at_2, \ - conway_octane_of_this_unimodular_Jordan_block_at_2, \ - conway_diagonal_factor, \ - conway_cross_product_doubled_power, \ - conway_type_factor, \ - conway_p_mass, \ - conway_standard_p_mass, \ - conway_standard_mass, \ - conway_mass -# conway_generic_mass, \ -# conway_p_mass_adjustment + parity, \ + is_even, \ + is_odd, \ + conway_species_list_at_odd_prime, \ + conway_species_list_at_2, \ + conway_octane_of_this_unimodular_Jordan_block_at_2, \ + conway_diagonal_factor, \ + conway_cross_product_doubled_power, \ + conway_type_factor, \ + conway_p_mass, \ + conway_standard_p_mass, \ + conway_standard_mass, \ + conway_mass +# conway_generic_mass, \ +# conway_p_mass_adjustment ################################################### diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py index 94f6559d51a..fb781e20122 100644 --- a/src/sage/quadratic_forms/quadratic_form__neighbors.py +++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py @@ -389,8 +389,7 @@ def orbits_lines_mod_p(self, p): # but in gap we act from the right!! --> transpose gens = self.automorphism_group().gens() gens = [g.matrix().transpose().change_ring(GF(p)) for g in gens] - orbs = libgap.function_factory( - """function(gens, p) + orbs = libgap.function_factory("""function(gens, p) local one, G, reps, V, n, orb; one:= One(GF(p)); G:=Group(List(gens, g -> g*one)); diff --git a/src/sage/quadratic_forms/quadratic_form__siegel_product.py b/src/sage/quadratic_forms/quadratic_form__siegel_product.py index c439a93f33b..b481f5ad073 100644 --- a/src/sage/quadratic_forms/quadratic_form__siegel_product.py +++ b/src/sage/quadratic_forms/quadratic_form__siegel_product.py @@ -97,12 +97,13 @@ def siegel_product(self, u): verbose(" u = " + str(u) + "\n") # Make the odd generic factors - if ((n % 2) == 1): - m = (n-1) // 2 + if n % 2: + m = (n - 1) // 2 d1 = fundamental_discriminant(((-1)**m) * 2*d * u) # Replaced d by 2d here to compensate for the determinant - f = abs(d1) # gaining an odd power of 2 by using the matrix of 2Q instead - # of the matrix of Q. - # --> Old d1 = CoreDiscriminant((mpz_class(-1)^m) * d * u); + f = abs(d1) + # gaining an odd power of 2 by using the matrix of 2Q instead + # of the matrix of Q. + # --> Old d1 = CoreDiscriminant((mpz_class(-1)^m) * d * u); # Make the ratio of factorials factor: [(2m)! / m!] * prod_{i=1}^m (2*i-1) factor1 = 1 diff --git a/src/sage/quadratic_forms/quadratic_form__split_local_covering.py b/src/sage/quadratic_forms/quadratic_form__split_local_covering.py index 61f8c1a027f..495b439e3ca 100644 --- a/src/sage/quadratic_forms/quadratic_form__split_local_covering.py +++ b/src/sage/quadratic_forms/quadratic_form__split_local_covering.py @@ -14,8 +14,6 @@ from sage.rings.real_double import RDF from sage.matrix.matrix_space import MatrixSpace from sage.matrix.constructor import matrix -from sage.misc.lazy_import import lazy_import -lazy_import("sage.functions.all", "floor") from sage.rings.integer_ring import ZZ from sage.arith.misc import GCD @@ -94,19 +92,19 @@ def cholesky_decomposition(self, bit_prec=53): # 2. Loop on i for i in range(n): - for j in range(i+1, n): - Q[j,i] = Q[i,j] # Is this line redundant? - Q[i,j] = Q[i,j] / Q[i,i] + for j in range(i + 1, n): + Q[j, i] = Q[i, j] # Is this line redundant? + Q[i, j] = Q[i, j] / Q[i, i] # 3. Main Loop - for k in range(i+1, n): + for k in range(i + 1, n): for l in range(k, n): - Q[k,l] = Q[k,l] - Q[k,i] * Q[i,l] + Q[k, l] = Q[k, l] - Q[k, i] * Q[i, l] # 4. Zero out the strictly lower-triangular entries for i in range(n): for j in range(i): - Q[i,j] = 0 + Q[i, j] = 0 return Q @@ -178,7 +176,7 @@ def vectors_by_length(self, bound): # but if eps is too small, roundoff errors may knock off some # vectors of norm = bound (see #7100) eps = RDF(1e-6) - bound = ZZ(floor(max(bound, 0))) + bound = ZZ(max(bound, 0)) # bound is an integer Theta_Precision = bound + eps n = self.dim() @@ -192,7 +190,7 @@ def vectors_by_length(self, bound): # 1. Initialize T = n * [RDF(0)] # Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] - i = n-1 + i = n - 1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) @@ -201,27 +199,27 @@ def vectors_by_length(self, bound): # 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) - L[i] = ( Z - U[i]).floor() + L[i] = (Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() done_flag = False - Q_val = 0 # WARNING: Still need a good way of checking overflow for this value... + Q_val = 0 # WARNING: Still need a good way of checking overflow for this value... # Big loop which runs through all vectors while not done_flag: # 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): - T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) + T[i - 1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) i = i - 1 U[i] = 0 - for j in range(i+1, n): + for j in range(i + 1, n): U[i] = U[i] + Q[i][j] * x[j] # Now go back and compute the bounds... # 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) - L[i] = ( Z - U[i]).floor() + L[i] = (Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() # carry if we go out of bounds -- when Z is so small that @@ -254,7 +252,7 @@ def vectors_by_length(self, bound): # 3a. Increment (and carry if we go out of bounds) x[i] += 1 - while (x[i] > L[i]) and (i < n-1): + while (x[i] > L[i]) and (i < n - 1): i += 1 x[i] += 1 @@ -284,7 +282,6 @@ def complementary_subform_to_vector(self, v): OUTPUT: a :class:`QuadraticForm` over `\ZZ` - EXAMPLES:: sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) @@ -317,7 +314,7 @@ def complementary_subform_to_vector(self, v): # Find the first non-zero component of v, and call it nz (Note: 0 <= nz < n) nz = 0 - while (nz < n) and (v[nz] == 0): + while nz < n and v[nz] == 0: nz += 1 # Abort if v is the zero vector @@ -334,27 +331,27 @@ def complementary_subform_to_vector(self, v): d = Q1[0, 0] # For each row/column, perform elementary operations to cancel them out. - for i in range(1,n): + for i in range(1, n): # Check if the (i,0)-entry is divisible by d, # and stretch its row/column if not. - if Q1[i,0] % d != 0: - Q1 = Q1.multiply_variable(d / GCD(d, Q1[i, 0]//2), i) + if Q1[i, 0] % d: + Q1 = Q1.multiply_variable(d / GCD(d, Q1[i, 0] // 2), i) # Now perform the (symmetric) elementary operations to cancel out the (i,0) entries/ - Q1 = Q1.add_symmetric(-(Q1[i,0]/2) / (GCD(d, Q1[i,0]//2)), i, 0) + Q1 = Q1.add_symmetric(-(Q1[i, 0] // 2) / (GCD(d, Q1[i, 0] // 2)), i, 0) # Check that we're done! done_flag = True for i in range(1, n): - if Q1[0,i] != 0: + if Q1[0, i] != 0: done_flag = False if not done_flag: raise RuntimeError("There is a problem cancelling out the matrix entries! =O") # Return the complementary matrix - return Q1.extract_variables(range(1,n)) + return Q1.extract_variables(range(1, n)) def split_local_cover(self): diff --git a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py index 6ec8bd8022f..d6d537775b3 100644 --- a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py +++ b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py @@ -89,23 +89,23 @@ def content(self): # in quadratic_form.py -#def is_primitive(self): -# """ -# Checks if the form is a multiple of another form... only over ZZ for now. -# """ -# return self.content() == 1 +# def is_primitive(self): +# """ +# Checks if the form is a multiple of another form... only over ZZ for now. +# """ +# return self.content() == 1 # in quadratic_form.py -#def primitive(self): -# """ -# Return a primitive quadratic forms in the similarity class of the given form. +# def primitive(self): +# """ +# Return a primitive quadratic forms in the similarity class of the given form. # -# This only works when we have GCDs... so over ZZ. -# """ -# c=self.content() -# new_coeffs = [self.base_ring()(a/c) for a in self.__coeffs] -# return QuadraticForm(self.base_ring(), self.dim(), new_coeffs) +# This only works when we have GCDs... so over ZZ. +# """ +# c = self.content() +# new_coeffs = [self.base_ring()(a/c) for a in self.__coeffs] +# return QuadraticForm(self.base_ring(), self.dim(), new_coeffs) def adjoint(self): @@ -155,14 +155,14 @@ def antiadjoint(self): ... ValueError: not an adjoint """ + n = self.dim() + R = self.base_ring() try: - n = self.dim() - R = self.base_ring() - d = R(self.disc()**(ZZ(1)/(n-1))) + d = R(self.disc()**(ZZ.one() / (n - 1))) if is_odd(n): - return self.adjoint().scale_by_factor( R(1) / 4 / d**(n-2) ) + return self.adjoint().scale_by_factor(R.one() / 4 / d**(n - 2)) else: - return self.adjoint().scale_by_factor( R(1) / d**(n-2) ) + return self.adjoint().scale_by_factor(R.one() / d**(n - 2)) except TypeError: raise ValueError("not an adjoint") @@ -189,6 +189,7 @@ def is_adjoint(self) -> bool: def reciprocal(self): r""" This gives the reciprocal quadratic form associated to the given form. + This is defined as the multiple of the primitive adjoint with the same content as the given form. @@ -207,14 +208,13 @@ def reciprocal(self): [ * * 37 ] sage: Q.reciprocal().reciprocal() == Q True - """ - return self.adjoint().primitive() . scale_by_factor( self.content() ) + return self.adjoint().primitive() . scale_by_factor(self.content()) def omega(self): r""" - This is the content of the adjoint of the primitive associated quadratic form. + Return the content of the adjoint of the primitive associated quadratic form. Ref: See Dickson's "Studies in Number Theory". @@ -223,15 +223,15 @@ def omega(self): sage: Q = DiagonalQuadraticForm(ZZ, [1,1,37]) sage: Q.omega() 4 - """ return self.primitive().adjoint().content() def delta(self): r""" - This is the omega of the adjoint form, - which is the same as the omega of the reciprocal form. + Return the omega of the adjoint form. + + This is the same as the omega of the reciprocal form. EXAMPLES:: @@ -244,15 +244,16 @@ def delta(self): def level__Tornaria(self): r""" - Return the level of the quadratic form, - defined as + Return the level of the quadratic form. + + This is defined as - level(`B`) for even dimension, - level(`B`)/4 for odd dimension, where `2Q(x) = x^t\cdot B\cdot x`. - This agrees with the usual level for even dimension... + This agrees with the usual level for even dimension. EXAMPLES:: @@ -265,7 +266,7 @@ def level__Tornaria(self): sage: DiagonalQuadraticForm(ZZ, [1,1,1,1]).level__Tornaria() 4 """ - return self.base_ring()(abs(self.disc())/self.omega()/self.content()**self.dim()) + return self.base_ring()(abs(self.disc()) / self.omega() / self.content()**self.dim()) def discrec(self): @@ -289,7 +290,9 @@ def discrec(self): def hasse_conductor(self): """ - This is the product of all primes where the Hasse invariant equals `-1` + Return the Hasse coductor. + + This is the product of all primes where the Hasse invariant equals `-1`. EXAMPLES:: @@ -307,14 +310,17 @@ def hasse_conductor(self): sage: QuadraticForm(ZZ, 3, [2, -2, 0, 2, 0, 5]).hasse_conductor() # needs sage.libs.pari 10 """ - return prod([x[0] for x in factor(2 * self.level()) - if self.hasse_invariant(x[0]) == -1]) + return prod([x for x, _ in factor(2 * self.level()) + if self.hasse_invariant(x) == -1]) def clifford_invariant(self, p): """ - This is the Clifford invariant, i.e. the class in the Brauer group of the - Clifford algebra for even dimension, of the even Clifford Algebra for odd dimension. + Return the Clifford invariant. + + + This is the class in the Brauer group of the Clifford algebra for + even dimension, of the even Clifford Algebra for odd dimension. See Lam (AMS GSM 67) p. 117 for the definition, and p. 119 for the formula relating it to the Hasse invariant. @@ -348,7 +354,7 @@ def clifford_invariant(self, p): def clifford_conductor(self): """ - This is the product of all primes where the Clifford invariant is `-1` + Return the product of all primes where the Clifford invariant is `-1`. .. NOTE:: @@ -385,15 +391,15 @@ def clifford_conductor(self): sage: (H + H + H + H).clifford_conductor() 1 """ - return prod([x[0] for x in factor(2 * self.level()) - if self.clifford_invariant(x[0]) == -1]) + return prod([x for x, _ in factor(2 * self.level()) + if self.clifford_invariant(x) == -1]) # Genus theory def basiclemma(self, M): """ - Find a number represented by self and coprime to `M`. + Find a number represented by ``self`` and coprime to `M`. EXAMPLES:: @@ -423,24 +429,24 @@ def basiclemmavec(self, M): mod = [] M0 = abs(M) if M0 == 1: - return V(0) + return V.zero() for i in range(self.dim()): - M1 = prime_to_m_part(M0, self[i,i]) + M1 = prime_to_m_part(M0, self[i, i]) if M1 != 1: vec.append(V.gen(i)) mod.append(M1) - M0 = M0/M1 + M0 = M0 / M1 if M0 == 1: return tuple(CRT_vectors(vec, mod)) for i in range(self.dim()): for j in range(i): - M1 = prime_to_m_part(M0, self[i,j]) + M1 = prime_to_m_part(M0, self[i, j]) if M1 != 1: vec.append(V.i + V.j) mod.append(M1) - M0 = M0/M1 + M0 = M0 / M1 if M0 == 1: return tuple(CRT_vectors(vec, mod)) @@ -479,7 +485,7 @@ def xi(self, p): return kronecker_symbol(self.basiclemma(p), p) -def xi_rec(self,p): +def xi_rec(self, p): """ Return Xi(`p`) for the reciprocal form. diff --git a/src/sage/quadratic_forms/quadratic_form__theta.py b/src/sage/quadratic_forms/quadratic_form__theta.py index 7aa257d5e71..e6cd5f2f401 100644 --- a/src/sage/quadratic_forms/quadratic_form__theta.py +++ b/src/sage/quadratic_forms/quadratic_form__theta.py @@ -28,8 +28,8 @@ def theta_series(self, Max=10, var_str='q', safe_flag=True): The ``safe_flag`` allows us to select whether we want a copy of the output, or the original output. It is only meaningful when a vector is returned, otherwise a copy is automatically made in - creating the power series. By default ``safe_flag`` = True, so we - return a copy of the cached information. If this is set to False, + creating the power series. By default ``safe_flag`` = ``True``, so we + return a copy of the cached information. If this is set to ``False``, then the routine is much faster but the return values are vulnerable to being corrupted by the user. @@ -63,12 +63,12 @@ def theta_series(self, Max=10, var_str='q', safe_flag=True): if Max == 'mod_form': raise NotImplementedError("we have to figure out the correct number of Fourier coefficients to use") - #return self.theta_by_pari(sturm_bound(self.level(), self.dim() / ZZ(2)) + 1, var_str, safe_flag) + # return self.theta_by_pari(sturm_bound(self.level(), self.dim() / ZZ(2)) + 1, var_str, safe_flag) else: return self.theta_by_pari(M, var_str, safe_flag) -# ------------- Compute the theta function by using the PARI/GP routine qfrep ------------ +# ---- Compute the theta function by using the PARI/GP routine qfrep ---- def theta_by_pari(self, Max, var_str='q', safe_flag=True): r""" @@ -169,22 +169,21 @@ def theta_by_cholesky(self, q_prec): sage: Theta_list = Theta.list() sage: [m for m in range(len(Theta_list)) if Theta_list[m] == 0] [2, 22] - """ # RAISE AN ERROR -- This routine is deprecated! - #raise NotImplementedError, "This routine is deprecated. Try theta_series(), which uses theta_by_pari()." + # raise NotImplementedError("This routine is deprecated. Try theta_series(), which uses theta_by_pari().") from sage.arith.misc import integer_ceil as ceil, integer_floor as floor from sage.misc.functional import sqrt from sage.rings.real_mpfr import RealField n = self.dim() - theta = [0 for i in range(q_prec+1)] + theta = [0 for i in range(q_prec + 1)] PS = PowerSeriesRing(ZZ, 'q') bit_prec = 53 # TO DO: Set this precision to reflect the appropriate roundoff Cholesky = self.cholesky_decomposition(bit_prec) # error estimate, to be confident through our desired q-precision. - Q = Cholesky # <---- REDUNDANT!!! + Q = Cholesky # <---- REDUNDANT!!! R = RealField(bit_prec) half = R(0.5) @@ -198,16 +197,16 @@ def theta_by_cholesky(self, q_prec): x = [0] * n # 2. Compute bounds - #Z = sqrt(T[i] / Q[i,i]) # IMPORTANT NOTE: sqrt preserves the precision of the real number it's given... which is not so good... =| - #L[i] = floor(Z - U[i]) # Note: This is a Sage Integer - #x[i] = ceil(-Z - U[i]) - 1 # Note: This is a Sage Integer too + # Z = sqrt(T[i] / Q[i,i]) # IMPORTANT NOTE: sqrt preserves the precision of the real number it's given... which is not so good... =| + # L[i] = floor(Z - U[i]) # Note: This is a Sage Integer + # x[i] = ceil(-Z - U[i]) - 1 # Note: This is a Sage Integer too done_flag = False from_step4_flag = False from_step3_flag = True # We start by pretending this, since then we get to run through 2 and 3a once. =) - #double Q_val_double; - #unsigned long Q_val; // WARNING: Still need a good way of checking overflow for this value... + # double Q_val_double; + # unsigned long Q_val; // WARNING: Still need a good way of checking overflow for this value... # Big loop which runs through all vectors while not done_flag: @@ -221,7 +220,7 @@ def theta_by_cholesky(self, q_prec): else: # 2. Compute bounds from_step3_flag = False - Z = sqrt(T[i] / Q[i,i]) + Z = sqrt(T[i] / Q[i, i]) L[i] = floor(Z - U[i]) x[i] = ceil(-Z - U[i]) - 1 @@ -249,9 +248,9 @@ def theta_by_cholesky(self, q_prec): eps = 0.000000001 if abs(Q_val_double - Q_val) > eps: raise RuntimeError("Oh No! We have a problem with the floating point precision... \n" - + " Q_val_double = " + str(Q_val_double) + "\n" - + " Q_val = " + str(Q_val) + "\n" - + " x = " + str(x) + "\n") + + " Q_val_double = " + str(Q_val_double) + "\n" + + " Q_val = " + str(Q_val) + "\n" + + " x = " + str(x) + "\n") if Q_val <= q_prec: theta[Q_val] += 2 @@ -333,18 +332,18 @@ def theta_series_degree_2(Q, prec): max = (X + 1) // 4 v_list = (Q.vectors_by_length(max)) # assume a>0 v_list = [[V(_) for _ in vs] for vs in v_list] # coerce vectors into V - verbose("Computed vectors_by_length" , t) + verbose("Computed vectors_by_length", t) # Deal with the singular part - coeffs = {(0,0,0):ZZ(1)} - for i in range(1,max+1): - coeffs[(0,0,i)] = ZZ(2) * len(v_list[i]) + coeffs = {(0, 0, 0): ZZ.one()} + for i in range(1, max + 1): + coeffs[(0, 0, i)] = ZZ(2) * len(v_list[i]) # Now deal with the non-singular part - a_max = int(floor(sqrt(X/3))) + a_max = int(floor(sqrt(X / 3))) for a in range(1, a_max + 1): t = cputime() - c_max = int(floor((a*a + X)/(4*a))) + c_max = int(floor((a * a + X) / (4 * a))) for c in range(a, c_max + 1): for v1 in v_list[a]: v1_H = v1 * H @@ -353,10 +352,10 @@ def B_v1(v): return v1_H * v2 for v2 in v_list[c]: b = abs(B_v1(v2)) - if b <= a and 4*a*c-b*b <= X: - qf = (a,b,c) + if b <= a and 4 * a * c - b * b <= X: + qf = (a, b, c) count = ZZ(4) if b == 0 else ZZ(2) - coeffs[qf] = coeffs.get(qf, ZZ(0)) + count + coeffs[qf] = coeffs.get(qf, ZZ.zero()) + count verbose("done a = %d" % a, t) return coeffs diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 8970637882d..0ccfbcd65b9 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -1513,4 +1513,4 @@ def local_height_arch(self, i, prec=None): sage: X.local_height_arch(1) 4.61512051684126 """ - return self.Chow_form().local_height_arch(i, prec) \ No newline at end of file + return self.Chow_form().local_height_arch(i, prec) From 00c5af45c2c7ebcee63d02f6464a687912046672 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Tue, 24 Oct 2023 13:46:33 +0200 Subject: [PATCH 195/494] remove some useless # needs networkx --- src/sage/graphs/generic_graph.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index c2eab5ebf2e..4bd9da3e244 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -5149,13 +5149,13 @@ def cycle_basis(self, output='vertex'): sage: G = Graph([(0, 2, 'a'), (0, 2, 'b'), (0, 1, 'c'), (1, 2, 'd')], ....: multiedges=True) - sage: G.cycle_basis() # needs networkx + sage: G.cycle_basis() [[2, 0], [2, 0, 1]] - sage: G.cycle_basis(output='edge') # needs networkx + sage: G.cycle_basis(output='edge') [[(0, 2, 'b'), (2, 0, 'a')], [(1, 2, 'd'), (2, 0, 'a'), (0, 1, 'c')]] sage: H = Graph([(1, 2), (2, 3), (2, 3), (3, 4), (1, 4), ....: (1, 4), (4, 5), (5, 6), (4, 6), (6, 7)], multiedges=True) - sage: H.cycle_basis() # needs networkx + sage: H.cycle_basis() [[4, 1], [3, 2], [4, 1, 2, 3], [6, 4, 5]] Disconnected graph:: @@ -5174,13 +5174,13 @@ def cycle_basis(self, output='vertex'): sage: G = graphs.CycleGraph(3) sage: G.allow_multiple_edges(True) - sage: G.cycle_basis() # needs networkx + sage: G.cycle_basis() [[2, 0, 1]] Not yet implemented for directed graphs:: sage: G = DiGraph([(0, 2, 'a'), (0, 1, 'c'), (1, 2, 'd')]) - sage: G.cycle_basis() # needs networkx + sage: G.cycle_basis() Traceback (most recent call last): ... NotImplementedError: not implemented for directed graphs @@ -5191,9 +5191,9 @@ def cycle_basis(self, output='vertex'): sage: G = Graph([(1, 2, 'a'), (2, 3, 'b'), (2, 3, 'c'), ....: (3, 4, 'd'), (3, 4, 'e'), (4, 1, 'f')], multiedges=True) - sage: G.cycle_basis() # needs networkx + sage: G.cycle_basis() [[3, 2], [4, 1, 2, 3], [4, 1, 2, 3]] - sage: G.cycle_basis(output='edge') # needs networkx + sage: G.cycle_basis(output='edge') [[(2, 3, 'c'), (3, 2, 'b')], [(3, 4, 'd'), (4, 1, 'f'), (1, 2, 'a'), (2, 3, 'b')], [(3, 4, 'e'), (4, 1, 'f'), (1, 2, 'a'), (2, 3, 'b')]] From a859ac2863821f89a82b8539457e3a0f732002ca Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 24 Oct 2023 08:23:45 -0400 Subject: [PATCH 196/494] src/sage/misc/latex.py: fix view() Rewriting the view() function to use python's tempfile module instead of sage's own tmp_dir() accidentally broke this function, because the viewer program needs the file to be slightly less temporary than we made it. The viewer would launch, but then view() would immediately return, causing the file that the viewer was about to look for to be deleted. To fix it, we now launch the viewer program synchronously within a helper function, but launch that helper function asynchronously in a new thread. This allows us to clean up the temporary directory only after the subprocess has completed, but still lets view() return immediately. Closes: https://github.com/sagemath/sage/issues/36526 --- src/sage/misc/latex.py | 65 ++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/sage/misc/latex.py b/src/sage/misc/latex.py index e0d32725cec..602a24f404a 100644 --- a/src/sage/misc/latex.py +++ b/src/sage/misc/latex.py @@ -29,7 +29,7 @@ import random import re import shutil -from subprocess import call, PIPE +from subprocess import call, run, PIPE from tempfile import TemporaryDirectory from sage.misc.cachefunc import cached_function, cached_method @@ -1923,27 +1923,48 @@ def view(objects, title='Sage', debug=False, sep='', tiny=False, if pdflatex or (viewer == "pdf" and engine == "latex"): engine = "pdflatex" # command line or notebook with viewer - with TemporaryDirectory() as tmp: - tex_file = os.path.join(tmp, "sage.tex") - with open(tex_file, 'w') as file: - file.write(s) - suffix = _run_latex_(tex_file, debug=debug, engine=engine, png=False) - if suffix == "pdf": - from sage.misc.viewer import pdf_viewer - viewer = pdf_viewer() - elif suffix == "dvi": - from sage.misc.viewer import dvi_viewer - viewer = dvi_viewer() - else: - print("Latex error") - return - output_file = os.path.join(tmp, "sage." + suffix) - # this should get changed if we switch the stuff in misc.viewer to - # producing lists - if debug: - print('viewer: "{}"'.format(viewer)) - call('%s %s' % (viewer, output_file), shell=True, - stdout=PIPE, stderr=PIPE) + + # We can't automatically delete the temporary file in this case + # because we need it to live at least long enough for the viewer + # to open it. Since we're launching the viewer asynchronously, + # that would be tricky. + tmp = TemporaryDirectory() + + tex_file = os.path.join(tmp.name, "sage.tex") + with open(tex_file, 'w') as file: + file.write(s) + suffix = _run_latex_(tex_file, debug=debug, engine=engine, png=False) + if suffix == "pdf": + from sage.misc.viewer import pdf_viewer + viewer = pdf_viewer() + elif suffix == "dvi": + from sage.misc.viewer import dvi_viewer + viewer = dvi_viewer() + else: + print("Latex error") + tmp.cleanup() + return + output_file = os.path.join(tmp.name, "sage." + suffix) + # this should get changed if we switch the stuff in misc.viewer to + # producing lists + if debug: + print('viewer: "{}"'.format(viewer)) + + # Return immediately but only clean up the temporary file after + # the viewer has closed. This function is synchronous and waits + # for the process to complete... + def run_viewer(): + run([viewer, output_file], capture_output=True) + tmp.cleanup() + + # ...but we execute it asynchronously so that view() completes + # immediately. The "daemon" flag is important because, without it, + # sage won't quit until the viewer does. + from threading import Thread + t = Thread(target=run_viewer) + t.daemon = True + t.start() + return From 04988fcd53c56538966d10e2839ce8a6b58ac060 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 6 Oct 2023 14:18:16 -0700 Subject: [PATCH 197/494] build/pkgs/cython: Update to 3.0.3 --- build/pkgs/cython/checksums.ini | 6 +++--- build/pkgs/cython/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/cython/checksums.ini b/build/pkgs/cython/checksums.ini index 5d0bc66c242..1c8178ae701 100644 --- a/build/pkgs/cython/checksums.ini +++ b/build/pkgs/cython/checksums.ini @@ -1,5 +1,5 @@ tarball=Cython-VERSION.tar.gz -sha1=08eb99f7c95b7ca667b1547575e7369d8064b4b3 -md5=00def3f2b96c393098e01eb2f1f169ad -cksum=2321746451 +sha1=c29c8b39c36f04a74eb8891bb0653f89144293df +md5=ea2d206653f67e4783f82c07b531fb21 +cksum=2237745899 upstream_url=https://pypi.io/packages/source/C/Cython/Cython-VERSION.tar.gz diff --git a/build/pkgs/cython/package-version.txt b/build/pkgs/cython/package-version.txt index b5021469305..75a22a26ac4 100644 --- a/build/pkgs/cython/package-version.txt +++ b/build/pkgs/cython/package-version.txt @@ -1 +1 @@ -3.0.2 +3.0.3 From d55592936f50abac7e48ace2e9d23d0a7d7ef5fc Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 17:17:37 -0700 Subject: [PATCH 198/494] build/pkgs/cython: Update to 3.0.4 --- build/pkgs/cython/checksums.ini | 6 +++--- build/pkgs/cython/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/cython/checksums.ini b/build/pkgs/cython/checksums.ini index 1c8178ae701..a728e447c9b 100644 --- a/build/pkgs/cython/checksums.ini +++ b/build/pkgs/cython/checksums.ini @@ -1,5 +1,5 @@ tarball=Cython-VERSION.tar.gz -sha1=c29c8b39c36f04a74eb8891bb0653f89144293df -md5=ea2d206653f67e4783f82c07b531fb21 -cksum=2237745899 +sha1=9924cb41152a854124c264e2046b3d48ec8207a5 +md5=9bafc611be35748b17a62f47bc479b35 +cksum=1074764487 upstream_url=https://pypi.io/packages/source/C/Cython/Cython-VERSION.tar.gz diff --git a/build/pkgs/cython/package-version.txt b/build/pkgs/cython/package-version.txt index 75a22a26ac4..b0f2dcb32fc 100644 --- a/build/pkgs/cython/package-version.txt +++ b/build/pkgs/cython/package-version.txt @@ -1 +1 @@ -3.0.3 +3.0.4 From 8fcddbf80191b1eb653842dbbdbd5fb941690c8b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 17:39:00 -0700 Subject: [PATCH 199/494] build/pkgs/cython/patches/5690.patch: Remove --- build/pkgs/cython/patches/5690.patch | 48 ---------------------------- 1 file changed, 48 deletions(-) delete mode 100644 build/pkgs/cython/patches/5690.patch diff --git a/build/pkgs/cython/patches/5690.patch b/build/pkgs/cython/patches/5690.patch deleted file mode 100644 index cc927879e1f..00000000000 --- a/build/pkgs/cython/patches/5690.patch +++ /dev/null @@ -1,48 +0,0 @@ -diff --git a/Cython/Debugger/DebugWriter.py b/Cython/Debugger/DebugWriter.py -index 8b1fb75b027..2c3c310fc64 100644 ---- a/Cython/Debugger/DebugWriter.py -+++ b/Cython/Debugger/DebugWriter.py -@@ -18,6 +18,21 @@ - etree = None - - from ..Compiler import Errors -+from ..Compiler.StringEncoding import EncodedString -+ -+ -+def is_valid_tag(name): -+ """ -+ Names like '.0' are used internally for arguments -+ to functions creating generator expressions, -+ however they are not identifiers. -+ -+ See https://github.com/cython/cython/issues/5552 -+ """ -+ if isinstance(name, EncodedString): -+ if name.startswith(".") and name[1:].isdecimal(): -+ return False -+ return True - - - class CythonDebugWriter(object): -@@ -39,14 +54,17 @@ def __init__(self, output_dir): - self.start('cython_debug', attrs=dict(version='1.0')) - - def start(self, name, attrs=None): -- self.tb.start(name, attrs or {}) -+ if is_valid_tag(name): -+ self.tb.start(name, attrs or {}) - - def end(self, name): -- self.tb.end(name) -+ if is_valid_tag(name): -+ self.tb.end(name) - - def add_entry(self, name, **attrs): -- self.tb.start(name, attrs) -- self.tb.end(name) -+ if is_valid_tag(name): -+ self.tb.start(name, attrs) -+ self.tb.end(name) - - def serialize(self): - self.tb.end('Module') From 31ead9c1f22a733b86ed65f930bd19f04c8339ce Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 14:46:46 -0700 Subject: [PATCH 200/494] src/MANIFEST.in: Exclude sirocco --- src/MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MANIFEST.in b/src/MANIFEST.in index bbed8838199..07a135dbf07 100644 --- a/src/MANIFEST.in +++ b/src/MANIFEST.in @@ -49,6 +49,7 @@ prune sage/graphs/bliss_cpp prune sage/libs/coxeter3 exclude sage/graphs/mcqd.p* exclude sage/libs/meataxe.p* +exclude sage/libs/sirocco.p* exclude sage/matrix/matrix_gfpn_dense.p* exclude sage/graphs/graph_decomposition/tdlib.p* From d4ba99c82fe84d8d1f192b92a007bb654d7a2000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Tue, 24 Oct 2023 22:47:29 -0300 Subject: [PATCH 201/494] Cleanup conditional assert The code we remove here is a legacy assert which has no equivalent in python 3.12. The way it's implemented uses compile time `IF` which is deprecated in cython 3 so it's desirable to remove. --- src/sage/cpython/dict_del_by_value.pyx | 31 -------------------------- 1 file changed, 31 deletions(-) diff --git a/src/sage/cpython/dict_del_by_value.pyx b/src/sage/cpython/dict_del_by_value.pyx index 19dd2bb2731..fdeb5fee8ff 100644 --- a/src/sage/cpython/dict_del_by_value.pyx +++ b/src/sage/cpython/dict_del_by_value.pyx @@ -46,31 +46,6 @@ cdef extern from "dict_internal.h": PyObject * me_key PyObject * me_value - -# dk_lookup was removed in python 3.11 -DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000 - -IF HAS_DK_LOOKUP: - - cdef extern from *: - """ - #define DK_LOOKUP(dk) ((dk)->dk_lookup) - """ - ctypedef void * dict_lookup_func # Precise definition not needed - dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp) - - cdef dict_lookup_func lookdict - - def init_lookdict(): - global lookdict - # A dict which a non-string key uses the generic "lookdict" - # as lookup function - cdef object D = {} - D[0] = 0 - lookdict = DK_LOOKUP((D).ma_keys) - - init_lookdict() - cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1: """ This is used in callbacks for the weak values of :class:`WeakValueDictionary`. @@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_ return 0 ep = &(entries[ix]) - # We need the lookup function to be the generic lookdict, otherwise - # deletions may not work correctly - IF HAS_DK_LOOKUP: - # Can this fail? In any case dk_lookup was removed in python 3.11 - assert DK_LOOKUP(keys) is lookdict - T = PyList_New(2) PyList_SetItem(T, 0, ep.me_key) PyList_SetItem(T, 1, ep.me_value) From c4c665c18afa7d330229b4d4e34a3538bb35ee72 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 21:57:05 -0700 Subject: [PATCH 202/494] build/pkgs/openssl: Update to 3.0.12 --- build/pkgs/openssl/checksums.ini | 6 +++--- build/pkgs/openssl/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/openssl/checksums.ini b/build/pkgs/openssl/checksums.ini index a443f001e4a..9a4767ed76c 100644 --- a/build/pkgs/openssl/checksums.ini +++ b/build/pkgs/openssl/checksums.ini @@ -1,5 +1,5 @@ tarball=openssl-VERSION.tar.gz -sha1=580d8a7232327fe1fa6e7db54ac060d4321f40ab -md5=61e017cf4fea1b599048f621f1490fbd -cksum=1708357994 +sha1=b48e20c07facfdf6da9ad43a6c5126d51897699b +md5=e6a199cdf867873eef2c6491b674edbc +cksum=391245670 upstream_url=https://www.openssl.org/source/openssl-VERSION.tar.gz diff --git a/build/pkgs/openssl/package-version.txt b/build/pkgs/openssl/package-version.txt index 67786e246ef..f93fc9f42ea 100644 --- a/build/pkgs/openssl/package-version.txt +++ b/build/pkgs/openssl/package-version.txt @@ -1 +1 @@ -3.0.8 +3.0.12 From ffa0af9bd4f7b101f1b53bb82b231deaec193a63 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 25 Oct 2023 13:09:51 +0900 Subject: [PATCH 203/494] Fix for auto mode --- .../common/static/custom-jupyter-sphinx.css | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 40495702c26..66300e5268a 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -91,6 +91,42 @@ body[data-theme="dark"] { } } +@media (prefers-color-scheme: dark) { + body[data-theme="auto"] { /* the same styles with body[data-theme="dark"] */ + .jupyter_container { + color: white; + background-color: black; + } + + .thebelab-button { + color: #d0d0d0; + background-color: #383838; + } + + .thebelab-button:active { + color: #368ce2; + } + + #thebelab-activate-button { + background-color: #383838; + } + + #thebelab-activate-button:active { + color: #368ce2; + } + + .thebelab-cell .jp-OutputArea-output { + color: white; + background-color: black; + } + + .thebelab-cell .jp-OutputArea-output pre { + color: white; + background-color: black; + } + } +} + From 6baecc3f1d434315c2972e40b5399c710a06fc36 Mon Sep 17 00:00:00 2001 From: ymusleh Date: Wed, 25 Oct 2023 01:50:26 -0400 Subject: [PATCH 204/494] Fixed ellipses for doctests and attribution --- src/doc/en/reference/references/index.rst | 14 ++++++++++++-- .../drinfeld_modules/finite_drinfeld_module.py | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index d91866314fc..d9f406d055d 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -246,6 +246,10 @@ REFERENCES: Symposium, Volume 51, page 20. Australian Computer Society, Inc. 2006. +.. [Ang1997] B. Anglès. 1997. *On some characteristic polynomials attached to + finite Drinfeld modules.* manuscripta mathematica 93, 1 (01 Aug 1997), + 369–379. https://doi.org/10.1007/BF02677478 + .. [AP1986] \S. Arnborg, A. Proskurowski, *Characterization and Recognition of Partial 3-Trees*, SIAM Journal of Alg. and Discrete Methods, @@ -4766,11 +4770,17 @@ REFERENCES: Int. Math. Res. Not. (2015). :doi:`10.1093/imrn/rnv194`, :arxiv:`1408.0320`. -.. [MS2019] \Y. Musleh and \'E. Schost. Computing the characteristic polynomial - of a finite rank two Drinfeld module. In Proceedings of the 2019 +.. [MS2019] \Y. Musleh and \'E. Schost. *Computing the characteristic polynomial + of a finite rank two Drinfeld module*. In Proceedings of the 2019 ACM on International Symposium on Symbolic and Algebraic Computation, pages 307–314. ACM, 2019. +.. [MS2023] \Y. Musleh and \'E. Schost. *Computing the Characteristic Polynomial + of Endomorphisms of a finite Drinfeld Module using Crystalline + Cohomology*. In Proceedings of the 2023 ACM on International + Symposium on Symbolic and Algebraic Computation, pages 461–469. + ACM, 2023. + .. [MSSY2001] Mateescu, A., Salomaa, A., Salomaa, K. and Yu, S., *A sharpening of the Parikh mapping*. Theoret. Informatics Appl. 35 (2001) 551-564. diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 6e09538aa91..a54ba1efb05 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -10,6 +10,7 @@ AUTHORS: - Antoine Leudière (2022-04) +- Yossef Musleh (2023-02): added characteristic polynomial methods """ # ***************************************************************************** @@ -323,6 +324,7 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): sage: phi.frobenius_charpoly(algorithm="NotImplemented") Traceback (most recent call last): + ... NotImplementedError: algorithm "NotImplemented" not implemented ALGORITHM: @@ -396,7 +398,8 @@ def _frobenius_charpoly_crystalline(self, var): is equal to that of the Frobenius endomorphism on the Drinfeld module. A recurrence on elements of the cohomology allows us to compute a matrix representation of the Frobenius endomorphism - efficiently using a companion matrix method. + efficiently using a companion matrix method. Based on the algorithm + of section 6.3 in [MS2023]_. """ A = self.function_ring() K = self.base_over_constants_field() @@ -646,6 +649,7 @@ def is_isogenous(self, psi): sage: mu = DrinfeldModule(A, [z + 1, z^2 + z + 1, z^2 + z]) sage: phi.is_isogenous(mu) Traceback (most recent call last): + ... TypeError: Drinfeld modules are not in the same category :: @@ -653,6 +657,7 @@ def is_isogenous(self, psi): sage: mu = 1 sage: phi.is_isogenous(mu) Traceback (most recent call last): + ... TypeError: input must be a Drinfeld module ALGORITHM: From 51fb8a07bbe6b43c9f2c36ad096c43c36cce4b3f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 25 Oct 2023 15:11:50 +0900 Subject: [PATCH 205/494] Fix auto mode also in javascript --- src/doc/common/static/jupyter-sphinx-furo.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/doc/common/static/jupyter-sphinx-furo.js b/src/doc/common/static/jupyter-sphinx-furo.js index 7175c63bed5..f7c596cf853 100644 --- a/src/doc/common/static/jupyter-sphinx-furo.js +++ b/src/doc/common/static/jupyter-sphinx-furo.js @@ -2,8 +2,9 @@ function changeTheme(editor, theme) { if (theme === 'dark') { editor.setOption('theme', 'monokai'); // the same with pygments dark style in conf.py - } - else { + } else if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) { + editor.setOption('theme', 'monokai'); + } else { editor.setOption('theme', 'default'); } } From b516accd30214334b989c12d430d973793016fb5 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 25 Oct 2023 19:58:58 +0900 Subject: [PATCH 206/494] More edits on a-tour-of-sage --- src/doc/en/a_tour_of_sage/index.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index 2cbcf493bcb..debbf5471c1 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -6,18 +6,17 @@ Welcome to Sage This is a short tour of Sage as a calculator. -The Sage command line has a prompt "``sage:``". You do not have to add it. +The Sage command line has a prompt "``sage:``". To experiment with the +following examples, you only enter the part after the prompt. :: sage: 3 + 5 8 -If you use Sage on the Jupyter notebook, then put everything after the -``sage:`` prompt in an input cell, and press shift-enter to compute the -corresponding output. - - +If you use Sage on the Jupyter notebook, then likewise put everything after the +prompt in an input cell, and press :kbd:`Shift-Enter` to get the corresponding +output. The caret symbol means "raise to a power". @@ -40,7 +39,8 @@ Here we integrate a simple function. sage: x = var('x') # create a symbolic variable sage: integrate(sqrt(x) * sqrt(1 + x), x) - 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) + 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) + - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) This asks Sage to solve a quadratic equation. The symbol ``==`` represents equality in Sage. @@ -94,7 +94,8 @@ digits. :: sage: factorial(100) - 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 + 93326215443944152681699238856266700490715968264381621468592963895217599993229915608 + 941463976156518286253697920827223758251185210916864000000000000000000000000 :: @@ -107,7 +108,8 @@ This computes at least 100 digits of :math:`\pi`. :: sage: N(pi, digits=100) - 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 + 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998 + 628034825342117068 This asks Sage to factor a polynomial in two variables. From 87bc908d93aac81da9b8025722a8303f853a09a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 25 Oct 2023 13:53:49 +0200 Subject: [PATCH 207/494] refresh the maple(tm) interface --- src/sage/interfaces/maple.py | 250 +++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 116 deletions(-) diff --git a/src/sage/interfaces/maple.py b/src/sage/interfaces/maple.py index 42f680e001b..7ba21a66cf6 100644 --- a/src/sage/interfaces/maple.py +++ b/src/sage/interfaces/maple.py @@ -24,15 +24,16 @@ EXAMPLES:: - sage: maple('3 * 5') # optional - maple + sage: # optional - maple + sage: maple('3 * 5') 15 - sage: maple.eval('ifactor(2005)') # optional - maple + sage: maple.eval('ifactor(2005)') '``(5)*``(401)' - sage: maple.ifactor(2005) # optional - maple + sage: maple.ifactor(2005) ``(5)*``(401) - sage: maple.fsolve('x^2=cos(x)+4', 'x=0..5') # optional - maple + sage: maple.fsolve('x^2=cos(x)+4', 'x=0..5') 1.914020619 - sage: maple.factor('x^5 - y^5') # optional - maple + sage: maple.factor('x^5 - y^5') (x-y)*(x^4+x^3*y+x^2*y^2+x*y^3+y^4) If the string "error" (case insensitive) occurs in the output of @@ -192,12 +193,13 @@ :: - sage: alpha = maple('(1+sqrt(5))/2') # optional - maple - sage: beta = maple('(1-sqrt(5))/2') # optional - maple - sage: f19 = alpha^19 - beta^19/maple('sqrt(5)') # optional - maple - sage: f19 # optional - maple + sage: # optional - maple + sage: alpha = maple('(1+sqrt(5))/2') + sage: beta = maple('(1-sqrt(5))/2') + sage: f19 = alpha^19 - beta^19/maple('sqrt(5)') + sage: f19 (1/2+1/2*5^(1/2))^19-1/5*(1/2-1/2*5^(1/2))^19*5^(1/2) - sage: f19.simplify() # somewhat randomly ordered output; optional - maple + sage: f19.simplify() # somewhat randomly ordered output 6765+5778/5*5^(1/2) Let's say we want to write a maple program now that squares a @@ -244,6 +246,7 @@ from sage.interfaces.tab_completion import ExtraTabCompletion from sage.misc.instancedoc import instancedoc from sage.structure.richcmp import rich_to_bool +from sage.cpython.string import bytes_to_str COMMANDS_CACHE = '%s/maple_commandlist_cache.sobj' % DOT_SAGE @@ -356,14 +359,15 @@ def _read_in_file_command(self, filename): :: - sage: filename = tmp_filename() # optional - maple - sage: with open(filename, 'w') as f: # optional - maple + sage: # optional - maple + sage: filename = tmp_filename() + sage: with open(filename, 'w') as f: ....: _ = f.write('xx := 22;\n') - sage: maple.read(filename) # optional - maple - sage: maple.get('xx').strip() # optional - maple + sage: maple.read(filename) + sage: maple.get('xx').strip() '22' """ - return 'read "%s"' % filename + return f'read "{filename}"' def _quit_string(self): """ @@ -374,12 +378,13 @@ def _quit_string(self): :: - sage: m = Maple() # optional - maple - sage: a = m(2) # optional - maple - sage: m.is_running() # optional - maple + sage: # optional - maple + sage: m = Maple() + sage: a = m(2) + sage: m.is_running() True - sage: m.quit() # optional - maple - sage: m.is_running() # optional - maple + sage: m.quit() + sage: m.is_running() False """ return 'quit' @@ -418,8 +423,7 @@ def _install_hints(self): chmod +x maple * WINDOWS: - You must install Maple-for-Linux into the VMware machine (sorry, that's - the only way at present). + You must install Maple-for-Linux into the Linux subsystem. """ def expect(self): @@ -428,13 +432,14 @@ def expect(self): EXAMPLES:: - sage: m = Maple() # optional - maple - sage: m.expect() is None # optional - maple + sage: # optional - maple + sage: m = Maple() + sage: m.expect() is None True - sage: m._start() # optional - maple - sage: m.expect() # optional - maple + sage: m._start() + sage: m.expect() Maple with PID ... - sage: m.quit() # optional - maple + sage: m.quit() """ return self._expect @@ -444,13 +449,12 @@ def console(self): EXAMPLES:: - sage: maple.console() # not tested - |^/| Maple 11 (IBM INTEL LINUX) - ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 + sage: maple.console() # not tested + |\^/| Maple 2019 (X86 64 LINUX) + ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2019 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. - > """ maple_console() @@ -476,7 +480,10 @@ def console(self): def completions(self, s): """ Return all commands that complete the command starting with the - string s. This is like typing s[Ctrl-T] in the maple interpreter. + string ``s``. + + This is like typing ``s`` + :kbd:`Ctrl` + :kbd:`T` + in the Maple interpreter. EXAMPLES:: @@ -500,7 +507,8 @@ def completions(self, s): v = E.before E.expect(self._prompt) E.expect(self._prompt) - return v.split()[2:] + E.expect(self._prompt) + return [bytes_to_str(l) for l in v.split()[2:]] def _commands(self): """ @@ -519,9 +527,10 @@ def _commands(self): sum([self.completions(chr(97 + n)) for n in range(26)], []) except RuntimeError: print("\n" * 3) - print("*" * 70) - print("WARNING: You do not have a working version of Maple installed!") - print("*" * 70) + txt = "WARNING: You do not have a working version of Maple installed!" + print("═" * len(txt)) + print(txt) + print("═" * len(txt)) v = [] v.sort() return v @@ -587,29 +596,30 @@ def _eval_line_using_file(self, line, *args, **kwargs): def cputime(self, t=None): r""" - Return the amount of CPU time that the Maple session has used. If - ``t`` is not None, then it returns the difference + Return the amount of CPU time that the Maple session has used. + + If ``t`` is not None, then it returns the difference between the current CPU time and ``t``. EXAMPLES:: - sage: t = maple.cputime() # optional - maple - sage: t # random; optional - maple + sage: # optional - maple + sage: t = maple.cputime() + sage: t # random 0.02 - sage: x = maple('x') # optional - maple - sage: maple.diff(x^2, x) # optional - maple + sage: x = maple('x') + sage: maple.diff(x^2, x) 2*x - sage: maple.cputime(t) # random; optional - maple + sage: maple.cputime(t) # random 0.0 """ if t is None: return float(self('time()')) - else: - return float(self('time() - %s' % float(t))) + return float(self('time() - %s' % float(t))) def set(self, var, value): """ - Set the variable var to the given value. + Set the variable ``var`` to the given ``value``. EXAMPLES:: @@ -624,7 +634,7 @@ def set(self, var, value): def get(self, var): """ - Get the value of the variable var. + Get the value of the variable ``var``. EXAMPLES:: @@ -711,14 +721,13 @@ def _assign_symbol(self): def _source(self, s): """ - Tries to return the source code of a Maple function str as a - string. + Try to return the source code of a Maple function ``s`` as a string. EXAMPLES:: sage: print(maple._source('curry').strip()) # optional - maple - p -> subs('_X' = args[2 .. nargs], () -> p(_X, args)) - sage: maple._source('ZZZ') #not tested + ... -> subs('_X' = _passed[2 .. _npassed],() -> ...(_X, _passed)) + sage: maple._source('ZZZ') # not tested Traceback (most recent call last): ... Exception: no source code could be found @@ -727,12 +736,14 @@ def _source(self, s): src = os.popen(cmd).read() if src.strip() == s: raise RuntimeError("no source code could be found") - else: - return src + it = (line.strip() for line in src.splitlines()) + return ''.join(l for l in it if l) def source(self, s): """ - Display the Maple source (if possible) about s. This is the same as + Display the Maple source (if possible) about ``s``. + + This is the same as returning the output produced by the following Maple commands: interface(verboseproc=2): print(s) @@ -746,8 +757,8 @@ def source(self, s): EXAMPLES:: - sage: maple.source('curry') #not tested - p -> subs('_X' = args[2 .. nargs], () -> p(_X, args)) + sage: maple.source('curry') # not tested + ... -> subs('_X' = _passed[2 .. _npassed],() -> ...(_X, _passed)) """ try: pager()(self._source(s)) @@ -760,11 +771,11 @@ def _help(self, string): EXAMPLES:: - sage: txt = maple._help('gcd') # optional - maple - sage: txt.find('gcd - greatest common divisor') > 0 # optional - maple + sage: txt = maple._help('igcd') # optional - maple + sage: txt.find('igcd - greatest common divisor') >= 0 # optional - maple True """ - return os.popen('echo "?%s" | maple -q' % string).read() + return bytes_to_str(os.popen(f'echo "?{string}" | maple -q').read()) def help(self, string): """ @@ -791,26 +802,25 @@ def with_package(self, package): INPUT: - - - ``package`` - string - + - ``package`` -- string EXAMPLES: Some functions are unknown to Maple until you use with to include the appropriate package. :: - sage: maple.quit() # reset maple; optional -- maple - sage: maple('partition(10)') # optional - maple + sage: # optional - maple + sage: maple.quit() # reset maple + sage: maple('partition(10)') partition(10) - sage: maple('bell(10)') # optional - maple + sage: maple('bell(10)') bell(10) - sage: maple.with_package('combinat') # optional - maple - sage: maple('partition(10)') # optional - maple + sage: maple.with_package('combinat') + sage: maple('partition(10)') [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 1, 2, 2], [1, 1, 1, 1, 2, 2, 2], [1, 1, 2, 2, 2, 2], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 3], [1, 1, 1, 1, 1, 2, 3], [1, 1, 1, 2, 2, 3], [1, 2, 2, 2, 3], [1, 1, 1, 1, 3, 3], [1, 1, 2, 3, 3], [2, 2, 3, 3], [1, 3, 3, 3], [1, 1, 1, 1, 1, 1, 4], [1, 1, 1, 1, 2, 4], [1, 1, 2, 2, 4], [2, 2, 2, 4], [1, 1, 1, 3, 4], [1, 2, 3, 4], [3, 3, 4], [1, 1, 4, 4], [2, 4, 4], [1, 1, 1, 1, 1, 5], [1, 1, 1, 2, 5], [1, 2, 2, 5], [1, 1, 3, 5], [2, 3, 5], [1, 4, 5], [5, 5], [1, 1, 1, 1, 6], [1, 1, 2, 6], [2, 2, 6], [1, 3, 6], [4, 6], [1, 1, 1, 7], [1, 2, 7], [3, 7], [1, 1, 8], [2, 8], [1, 9], [10]] - sage: maple('bell(10)') # optional - maple + sage: maple('bell(10)') 115975 - sage: maple('fibonacci(10)') # optional - maple + sage: maple('fibonacci(10)') 55 """ self.eval('with(%s)' % package) @@ -826,27 +836,28 @@ def clear(self, var): EXAMPLES:: - sage: maple.set('xx', '2') # optional - maple - sage: maple.get('xx') # optional - maple + sage: # optional - maple + sage: maple.set('xx', '2') + sage: maple.get('xx') '2' - sage: maple.clear('xx') # optional - maple - sage: maple.get('xx') # optional - maple + sage: maple.clear('xx') + sage: maple.get('xx') 'xx' """ - self.set(var, "'{}'".format(var)) + self.set(var, f"'{var}'") @instancedoc class MapleFunction(ExpectFunction): - def _instancedoc(self): + def _instancedoc_(self): """ Return the Maple help for this function. This gets called when doing "?" on self. EXAMPLES:: - sage: txt = maple.gcd.__doc__ # optional - maple - sage: txt.find('gcd - greatest common divisor') > 0 # optional - maple + sage: txt = maple.igcd._instancedoc_() # optional - maple + sage: txt.find('igcd - greatest common divisor') >= 0 # optional - maple True """ M = self._parent @@ -862,8 +873,8 @@ def _sage_src_(self): EXAMPLES:: sage: print(maple.curry._sage_src_().strip()) # optional - maple - p -> subs('_X' = args[2 .. nargs], () -> p(_X, args)) - sage: maple.ZZZ._sage_src_() #not tested + ... -> subs('_X' = _passed[2 .. _npassed],() -> ...(_X, _passed)) + sage: maple.ZZZ._sage_src_() # not tested Traceback (most recent call last): ... Exception: no source code could be found @@ -883,23 +894,23 @@ def _instancedoc_(self): EXAMPLES:: sage: two = maple(2) # optional - maple - sage: txt = two.gcd.__doc__ # optional - maple - sage: txt.find('gcd - greatest common divisor') > 0 # optional - maple + sage: txt = two.igcd._instancedoc_() # optional - maple + sage: txt.find('igcd - greatest common divisor') >= 0 # optional - maple True """ return self._obj.parent()._help(self._name) def _sage_src_(self): """ - Return the source code of self. + Return the source code of ``self``. EXAMPLES:: - sage: g = maple('gcd') # optional - maple + sage: g = maple('gcd') # optional - maple sage: print(g.curry._sage_src_().strip()) # optional - maple - p -> subs('_X' = args[2 .. nargs], () -> p(_X, args)) - sage: m = maple('2') # optional - maple - sage: m.ZZZ._sage_src_() #not tested + ... -> subs('_X' = _passed[2 .. _npassed],() -> ...(_X, _passed)) + sage: m = maple('2') # optional - maple + sage: m.ZZZ._sage_src_() # not tested Traceback (most recent call last): ... Exception: no source code could be found @@ -934,15 +945,16 @@ def __hash__(self): EXAMPLES:: - sage: m = maple('x^2+y^2') # optional - maple - sage: m.__hash__() # optional - maple + sage: # optional - maple + sage: m = maple('x^2+y^2') + sage: m.__hash__() # random 188724254834261060184983038723355865733 - sage: hash(m) # random # optional - maple + sage: hash(m) # random 5035731711831192733 - sage: m = maple('x^2+y^3') # optional - maple - sage: m.__hash__() # random # optional - maple + sage: m = maple('x^2+y^3') + sage: m.__hash__() # random 264835029579301191531663246434344770556 - sage: hash(m) # random # optional - maple + sage: hash(m) # random -2187277978252104690 """ return int(maple.eval('StringTools:-Hash(convert(%s, string))' % self.name())[1:-1], 16) @@ -956,40 +968,44 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: a = maple(5) # optional - maple - sage: b = maple(5) # optional - maple - sage: a == b # optional - maple + sage: # optional - maple + sage: a = maple(5) + sage: b = maple(5) + sage: a == b True - sage: a == 5 # optional - maple + sage: a == 5 True :: - sage: c = maple(3) # optional - maple - sage: a == c # optional - maple + sage: # optional - maple + sage: c = maple(3) + sage: a == c False - sage: a < c # optional - maple + sage: a < c False - sage: a < 6 # optional - maple + sage: a < 6 True - sage: c <= a # optional - maple + sage: c <= a True :: - sage: M = matrix(ZZ, 2, range(1,5)) # optional - maple - sage: Mm = maple(M) # optional - maple - sage: Mm == Mm # optional - maple + sage: # optional - maple + sage: M = matrix(ZZ, 2, range(1,5)) + sage: Mm = maple(M) + sage: Mm == Mm True TESTS:: + sage: # optional - maple sage: x = var('x') - sage: t = maple((x+1)^2) # optional - maple - sage: u = maple(x^2+2*x+1) # optional - maple + sage: t = maple((x+1)^2) + sage: u = maple(x^2+2*x+1) sage: u == t # todo: not implemented True # returns False, should use 'testeq' in maple - sage: maple.eval('testeq(%s = %s)' % (t.name(),u.name())) # optional - maple + sage: maple.eval('testeq(%s = %s)' % (t.name(),u.name())) 'true' """ P = self.parent() @@ -1024,21 +1040,23 @@ def _mul_(self, right): EXAMPLES:: - sage: t = maple(5); u = maple(3) # optional - maple - sage: t*u # optional - maple + sage: # optional - maple + sage: t = maple(5); u = maple(3) + sage: t*u 15 - sage: t._mul_(u) # optional - maple + sage: t._mul_(u) 15 - sage: M = matrix(ZZ,2,range(4)) # optional - maple - sage: Mm = maple(M) # optional - maple - sage: Mm*Mm # optional - maple + sage: M = matrix(ZZ,2,range(4)) + sage: Mm = maple(M) + sage: Mm*Mm Matrix(2, 2, [[2,3],[6,11]]) :: - sage: v = vector(ZZ,2,[2,3]) # optional - maple - sage: vm = maple(v) # optional - maple - sage: vm*Mm # optional - maple + sage: # optional - maple + sage: v = vector(ZZ,2,[2,3]) + sage: vm = maple(v) + sage: vm*Mm Vector[row](2, [6,11]) :: From c87037bed75eda7093b13631e898fc3c229f9089 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 10:47:56 -0700 Subject: [PATCH 208/494] build/pkgs/pip: Update to 23.3.1 --- build/pkgs/pip/checksums.ini | 6 +++--- build/pkgs/pip/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/pip/checksums.ini b/build/pkgs/pip/checksums.ini index 9b6376d1abb..52c2edb31f2 100644 --- a/build/pkgs/pip/checksums.ini +++ b/build/pkgs/pip/checksums.ini @@ -1,5 +1,5 @@ tarball=pip-VERSION.tar.gz -sha1=4bdfd8e976b5122cf55f4f4740f7305f1ffa4310 -md5=e9b1226701a56ee3fcc81aba60d25d75 -cksum=1940746834 +sha1=d1400a4eb662e4741ac68957f47bc97d600743f8 +md5=f0c9fba61e9d9badcc9921062e993d84 +cksum=309527365 upstream_url=https://pypi.io/packages/source/p/pip/pip-VERSION.tar.gz diff --git a/build/pkgs/pip/package-version.txt b/build/pkgs/pip/package-version.txt index 3f833b5b536..a9a57c82265 100644 --- a/build/pkgs/pip/package-version.txt +++ b/build/pkgs/pip/package-version.txt @@ -1 +1 @@ -23.2.1 +23.3.1 From c530ab343c7659c0fa8ed1011fe1603e070a483a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 10:48:00 -0700 Subject: [PATCH 209/494] build/pkgs/wheel: Update to 0.41.2 --- build/pkgs/wheel/checksums.ini | 6 +++--- build/pkgs/wheel/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/wheel/checksums.ini b/build/pkgs/wheel/checksums.ini index b01f275c477..b12a1973b0c 100644 --- a/build/pkgs/wheel/checksums.ini +++ b/build/pkgs/wheel/checksums.ini @@ -1,5 +1,5 @@ tarball=wheel-VERSION.tar.gz -sha1=ff9a5efeabf8e73e8b1a8646eaa829154f834726 -md5=83bb4e7bd4d687d398733f341a64ab91 -cksum=518943238 +sha1=34a787f7069762e267e5ed62ed31cc9c87ea910b +md5=06271a9e90c948b7e93dd7ce0fd90272 +cksum=444550709 upstream_url=https://pypi.io/packages/source/w/wheel/wheel-VERSION.tar.gz diff --git a/build/pkgs/wheel/package-version.txt b/build/pkgs/wheel/package-version.txt index 87f0b954e35..6599454d402 100644 --- a/build/pkgs/wheel/package-version.txt +++ b/build/pkgs/wheel/package-version.txt @@ -1 +1 @@ -0.38.4 +0.41.2 From cbeeabaca32c85ced8cf495e9c872c5ca3a7fb53 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 11:03:35 -0700 Subject: [PATCH 210/494] build/pkgs/pip/install-requires.txt: Require >=23.1.0 --- build/pkgs/pip/install-requires.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/pkgs/pip/install-requires.txt b/build/pkgs/pip/install-requires.txt index 5e76a10f694..25a92d4b832 100644 --- a/build/pkgs/pip/install-requires.txt +++ b/build/pkgs/pip/install-requires.txt @@ -1,3 +1,4 @@ -pip >=22.1 +pip >=23.1.0 # for use of the "in-tree-build" feature, default since 21.3, by the Sage distribution # for use of --config-settings, 22.1 +# for use of -C as a shortcut for --config-settings, 23.1.0 From 29e22a023880c973a277a58ee0480cb4d033c108 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 11:06:34 -0700 Subject: [PATCH 211/494] build/pkgs/packaging: Update to 23.2 --- build/pkgs/packaging/checksums.ini | 6 +++--- build/pkgs/packaging/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/packaging/checksums.ini b/build/pkgs/packaging/checksums.ini index 83ab122e324..7d9afce62d3 100644 --- a/build/pkgs/packaging/checksums.ini +++ b/build/pkgs/packaging/checksums.ini @@ -1,5 +1,5 @@ tarball=packaging-VERSION.tar.gz -sha1=1245c28c10ae6cb80164f081daece224b6fa89bc -md5=f7d5c39c6f92cc2dfa1293ba8f6c097c -cksum=11867377 +sha1=603cbd6e3416f1f4b6c0f924216f96fe67d9f6da +md5=d54eeff8c7ca86980528f4132f258d54 +cksum=307392791 upstream_url=https://pypi.io/packages/source/p/packaging/packaging-VERSION.tar.gz diff --git a/build/pkgs/packaging/package-version.txt b/build/pkgs/packaging/package-version.txt index a12b18e4372..3c8ce91a469 100644 --- a/build/pkgs/packaging/package-version.txt +++ b/build/pkgs/packaging/package-version.txt @@ -1 +1 @@ -23.1 +23.2 From 5db8ca8e51b265157aa975e51576238bbe79044f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 11:06:50 -0700 Subject: [PATCH 212/494] build/pkgs/platformdirs: Update to 3.11.0 --- build/pkgs/platformdirs/checksums.ini | 6 +++--- build/pkgs/platformdirs/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/platformdirs/checksums.ini b/build/pkgs/platformdirs/checksums.ini index 288483e8fc2..99113c48626 100644 --- a/build/pkgs/platformdirs/checksums.ini +++ b/build/pkgs/platformdirs/checksums.ini @@ -1,5 +1,5 @@ tarball=platformdirs-VERSION.tar.gz -sha1=c4e0f8486e67a97affbc1b6b267a1f196c4177fa -md5=1c1c8c05e9bc370b78e0a95103523b75 -cksum=4231977838 +sha1=82e215dc9c45eedf9168584fede36d795714f677 +md5=a6ba3a442347fac346982acb597c8bf8 +cksum=2465457023 upstream_url=https://pypi.io/packages/source/p/platformdirs/platformdirs-VERSION.tar.gz diff --git a/build/pkgs/platformdirs/package-version.txt b/build/pkgs/platformdirs/package-version.txt index 30291cba223..afad818663d 100644 --- a/build/pkgs/platformdirs/package-version.txt +++ b/build/pkgs/platformdirs/package-version.txt @@ -1 +1 @@ -3.10.0 +3.11.0 From a12a18a8fd5eb7a7e6ac769cda0118bb84987c84 Mon Sep 17 00:00:00 2001 From: Sourabh singh <96938361+SouSingh@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:48:26 +0530 Subject: [PATCH 213/494] Update nauty to version 2.8.6 #36257 Update nauty version to 2.8.6 fix #36257 --- build/pkgs/nauty/checksums.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/nauty/checksums.ini b/build/pkgs/nauty/checksums.ini index 644f4b75146..6bbfabc1d3c 100644 --- a/build/pkgs/nauty/checksums.ini +++ b/build/pkgs/nauty/checksums.ini @@ -2,4 +2,4 @@ tarball=nautyVERSION.tar.gz sha1=c9fd2b4c99b8c624e430f3f4e1492a4219e3495e md5=2ead635a417e20a18b3aabee83fac1ef cksum=718823455 -upstream_url=http://pallini.di.uniroma1.it/nauty27r1.tar.gz +upstream_url=https://pallini.di.uniroma1.it/nauty2_8_6.tar.gz From f0e747d12335fa4947cbe26bcc90b56e46410277 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 12:54:52 -0700 Subject: [PATCH 214/494] build/pkgs/nauty: Update to 2.8.6 --- build/pkgs/nauty/checksums.ini | 6 +++--- build/pkgs/nauty/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/nauty/checksums.ini b/build/pkgs/nauty/checksums.ini index 6bbfabc1d3c..a9dd1246e91 100644 --- a/build/pkgs/nauty/checksums.ini +++ b/build/pkgs/nauty/checksums.ini @@ -1,5 +1,5 @@ tarball=nautyVERSION.tar.gz -sha1=c9fd2b4c99b8c624e430f3f4e1492a4219e3495e -md5=2ead635a417e20a18b3aabee83fac1ef -cksum=718823455 +sha1=10c39117c55c69c18c6a107110e7c08f3d873652 +md5=7a82f4209f5d552da3078c67e5af872e +cksum=2164796643 upstream_url=https://pallini.di.uniroma1.it/nauty2_8_6.tar.gz diff --git a/build/pkgs/nauty/package-version.txt b/build/pkgs/nauty/package-version.txt index 9a8067baa68..e43686acc36 100644 --- a/build/pkgs/nauty/package-version.txt +++ b/build/pkgs/nauty/package-version.txt @@ -1 +1 @@ -27r1.p1 +2.8.6 From 9368554d7ffc8734f65b5f184c0e8227ca1a4b4d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 13:10:15 -0700 Subject: [PATCH 215/494] build/pkgs/nauty/spkg-install.in: Install more binaries --- build/pkgs/nauty/spkg-install.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/nauty/spkg-install.in b/build/pkgs/nauty/spkg-install.in index 6b25ac9d2ea..cf685ba5370 100644 --- a/build/pkgs/nauty/spkg-install.in +++ b/build/pkgs/nauty/spkg-install.in @@ -7,10 +7,10 @@ sdh_make # No install target so we resort to manual copy PROGRAMS=" -addedgeg amtog biplabg catg complg converseg copyg countg cubhamg deledgeg -delptg directg dreadnaut dretodot dretog genbg genbgL geng genquarticg genrang -genspecialg gentourng gentreeg hamheuristic labelg linegraphg listg multig -newedgeg pickg planarg ranlabg shortg showg subdivideg twohamg vcolg +addedgeg addptg amtog ancestorg assembleg biplabg catg complg converseg copyg countg cubhamg deledgeg +delptg dimacs2g directg dreadnaut dretodot dretog edgetransg genbg genbgL geng gengL genposetg genquarticg genrang +genspecialg gentourng gentreeg hamheuristic labelg linegraphg listg multig nbrhoodg +newedgeg pickg planarg productg ranlabg shortg showg subdivideg twohamg underlyingg vcolg watercluster2 NRswitchg" sdh_install $PROGRAMS "$SAGE_LOCAL/bin" From 83b7a0668f65384cdc001bc8815c419119c5f836 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 13:19:34 -0700 Subject: [PATCH 216/494] build/pkgs/nauty/spkg-configure.m4: Require nauty >= 2.8 --- build/pkgs/nauty/spkg-configure.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/pkgs/nauty/spkg-configure.m4 b/build/pkgs/nauty/spkg-configure.m4 index d986105f2e3..4d5bbcf2091 100644 --- a/build/pkgs/nauty/spkg-configure.m4 +++ b/build/pkgs/nauty/spkg-configure.m4 @@ -1,8 +1,12 @@ # We don't use the "converseg" program, but we need to ensure that we # only detect nauty >= 2.6 because we use the digraph6 format from # that version -- and converseg was added in nauty-2.6. +# +# We also don't use the "genposetg" program (added in nauty 2.8) yet. +# We require it here to prepare Sage for the use of the major new features +# added in 2.7 and 2.8 (https://pallini.di.uniroma1.it/changes24-28.txt). AC_DEFUN([SAGE_TEST_NAUTY_PROGS], [ - m4_foreach([nautyprog], [directg, gentourng, geng, genbg, gentreeg, converseg], [ + m4_foreach([nautyprog], [directg, gentourng, geng, genbg, gentreeg, converseg, genposetg], [ AC_PATH_PROG([$2]nautyprog, [[$1]nautyprog]) AS_IF([test x$[$2]nautyprog = x], [sage_spkg_install_nauty=yes]) ]) From 62c1210b943b129906e5843fb64ff105aace2e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Wed, 25 Oct 2023 18:48:15 -0300 Subject: [PATCH 217/494] Fix more implicit noexcept warnings (automatic) The previous run only fixed files in the sagemath-standard distribution, just because we started with a list of warnings produced when compiling just sagemath-standard. This time we apply the same strategy to files in the other distributions. --- src/sage/graphs/bliss.pyx | 20 ++++---- .../graphs/graph_decompositions/tdlib.pyx | 4 +- src/sage/libs/coxeter3/coxeter.pxd | 6 +-- src/sage/libs/coxeter3/coxeter.pyx | 8 ++-- src/sage/libs/meataxe.pyx | 4 +- src/sage/libs/sirocco.pyx | 8 ++-- src/sage/matrix/matrix_gfpn_dense.pxd | 18 ++++---- src/sage/matrix/matrix_gfpn_dense.pyx | 46 +++++++++---------- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/sage/graphs/bliss.pyx b/src/sage/graphs/bliss.pyx index 0a1b5ea313f..40a576a99cb 100644 --- a/src/sage/graphs/bliss.pyx +++ b/src/sage/graphs/bliss.pyx @@ -65,7 +65,7 @@ cdef extern from "bliss_cpp/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): +cdef int encoding_numbits(int n) noexcept: r""" Return the number of bits needed to encode the `n` numbers from `1` to `n`. In other words, the last bit set in `n`. @@ -79,7 +79,7 @@ cdef int encoding_numbits(int n): return i -cdef void add_gen(void *user_param, unsigned int n, const unsigned int *aut): +cdef void add_gen(void *user_param, unsigned int n, const unsigned int *aut) noexcept: r""" Function called each time a new generator of the automorphism group is found. @@ -129,7 +129,7 @@ cdef void add_gen(void *user_param, unsigned int n, const unsigned int *aut): # constructing bliss graphs from edge lists ##################################################### -cdef Graph *bliss_graph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, labels, partition): +cdef Graph *bliss_graph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, labels, partition) noexcept: r""" Return a bliss graph from the input data @@ -220,7 +220,7 @@ cdef Graph *bliss_graph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, labels, return g -cdef Digraph *bliss_digraph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, labels, partition): +cdef Digraph *bliss_digraph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, labels, partition) noexcept: r""" Return a bliss digraph from the input data @@ -301,7 +301,7 @@ cdef Digraph *bliss_digraph_from_labelled_edges(int Vnr, int Lnr, Vout, Vin, lab ##################################################### cdef canonical_form_from_edge_list(int Vnr, list Vout, list Vin, int Lnr=1, list labels=[], - list partition=None, bint directed=False, bint certificate=False): + list partition=None, bint directed=False, bint certificate=False) noexcept: r""" Return an unsorted list of labelled edges of a canonical form. @@ -378,7 +378,7 @@ cdef canonical_form_from_edge_list(int Vnr, list Vout, list Vin, int Lnr=1, list return new_edges -cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True, certificate=False): +cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True, certificate=False) noexcept: r""" Return a canonical label for the given (di)graph. @@ -599,7 +599,7 @@ cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True ##################################################### cdef automorphism_group_gens_from_edge_list(int Vnr, Vout, Vin, int Lnr=1, labels=[], - int2vert=[], partition=None, bint directed=False): + int2vert=[], partition=None, bint directed=False) noexcept: r""" Return an unsorted list of labelled edges of a canonical form. @@ -650,7 +650,7 @@ cdef automorphism_group_gens_from_edge_list(int Vnr, Vout, Vin, int Lnr=1, label return [[cyc for cyc in gen if cyc[0] is not None] for gen in gens] -cpdef automorphism_group(G, partition=None, use_edge_labels=True): +cpdef automorphism_group(G, partition=None, use_edge_labels=True) noexcept: """ Return the automorphism group of the given (di)graph. @@ -848,7 +848,7 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True): # old direct interactions graphs <-> bliss graphs ##################################################### -cdef Graph *bliss_graph(G, partition, vert2int, int2vert): +cdef Graph *bliss_graph(G, partition, vert2int, int2vert) noexcept: r""" Return a bliss copy of a graph G @@ -882,7 +882,7 @@ cdef Graph *bliss_graph(G, partition, vert2int, int2vert): return g -cdef Digraph *bliss_digraph(G, partition, vert2int, int2vert): +cdef Digraph *bliss_digraph(G, partition, vert2int, int2vert) noexcept: r""" Return a bliss copy of a digraph G diff --git a/src/sage/graphs/graph_decompositions/tdlib.pyx b/src/sage/graphs/graph_decompositions/tdlib.pyx index ad3ded3e876..90cfa756d00 100644 --- a/src/sage/graphs/graph_decompositions/tdlib.pyx +++ b/src/sage/graphs/graph_decompositions/tdlib.pyx @@ -76,7 +76,7 @@ cdef extern from "sage_tdlib.cpp": # the following will be used implicitly to do the translation # between Sage graph encoding and BGL graph encoding. -cdef make_tdlib_graph(G, vertex_to_int, vector[unsigned int] &V, vector[unsigned int] &E): +cdef make_tdlib_graph(G, vertex_to_int, vector[unsigned int] &V, vector[unsigned int] &E) noexcept: for i in range(G.order()): V.push_back(i) @@ -85,7 +85,7 @@ cdef make_tdlib_graph(G, vertex_to_int, vector[unsigned int] &V, vector[unsigned E.push_back(vertex_to_int[v]) -cdef make_sage_decomp(G, vector[vector[int]] &V, vector[unsigned int] &E, int_to_vertex): +cdef make_sage_decomp(G, vector[vector[int]] &V, vector[unsigned int] &E, int_to_vertex) noexcept: cdef int i, j for i in range(len(V)): G.add_vertex(Set([int_to_vertex[j] for j in V[i]])) diff --git a/src/sage/libs/coxeter3/coxeter.pxd b/src/sage/libs/coxeter3/coxeter.pxd index dbd2b8a61c6..c30ca1925b8 100644 --- a/src/sage/libs/coxeter3/coxeter.pxd +++ b/src/sage/libs/coxeter3/coxeter.pxd @@ -21,11 +21,11 @@ cdef class CoxGroup(SageObject): cdef object cartan_type cdef dict in_ordering cdef dict out_ordering - cpdef object full_context(self) + cpdef object full_context(self) noexcept cdef class CoxGroupElement: cdef c_CoxWord word cdef c_CoxGroup* group cdef CoxGroup _parent_group - cdef CoxGroupElement _new(self) - cpdef CoxGroup parent_group(self) + cdef CoxGroupElement _new(self) noexcept + cpdef CoxGroup parent_group(self) noexcept diff --git a/src/sage/libs/coxeter3/coxeter.pyx b/src/sage/libs/coxeter3/coxeter.pyx index 492afca2768..1b21b010481 100644 --- a/src/sage/libs/coxeter3/coxeter.pyx +++ b/src/sage/libs/coxeter3/coxeter.pyx @@ -540,7 +540,7 @@ cdef class CoxGroup(SageObject): """ return isFiniteType(self.x) - cpdef full_context(self): + cpdef full_context(self) noexcept: """ Make all of the elements of a finite Coxeter group available. @@ -741,7 +741,7 @@ cdef class CoxGroupElement: inverse = __invert__ - cpdef CoxGroup parent_group(self): + cpdef CoxGroup parent_group(self) noexcept: """ Return the parent Coxeter group for this element. @@ -959,7 +959,7 @@ cdef class CoxGroupElement: cdef Generator ss = self._parent_group.in_ordering[s] return self.group.isDescent(self.word, s) - cdef CoxGroupElement _new(self): + cdef CoxGroupElement _new(self) noexcept: """ Return a new copy of this element. """ @@ -1130,7 +1130,7 @@ cdef class CoxGroupElement: cdef CoxNbr y = self.group.extendContext(vv.word) return ZZ(self.group.mu(x,y)) -cdef LFlags_to_list(CoxGroup parent, LFlags f): +cdef LFlags_to_list(CoxGroup parent, LFlags f) noexcept: """ Return the right descent set of this element. diff --git a/src/sage/libs/meataxe.pyx b/src/sage/libs/meataxe.pyx index 40cb7c6a286..46559e9e99c 100644 --- a/src/sage/libs/meataxe.pyx +++ b/src/sage/libs/meataxe.pyx @@ -71,7 +71,7 @@ cdef Matrix_t *rawMatrix(int Field, list entries) except NULL: from sage.cpython.string cimport str_to_bytes, char_to_str -cdef void sage_meataxe_error_handler(const MtxErrorRecord_t *err): +cdef void sage_meataxe_error_handler(const MtxErrorRecord_t *err) noexcept: sig_block() ErrText = char_to_str(err.Text) BaseName = char_to_str(err.FileInfo.BaseName) @@ -79,7 +79,7 @@ cdef void sage_meataxe_error_handler(const MtxErrorRecord_t *err): PyErr_SetObject(ErrMsg.get(ErrText.split(': ')[-1], RuntimeError), f"{ErrText} in file {BaseName} (line {LineNo})") sig_unblock() -cdef inline meataxe_init(): +cdef inline meataxe_init() noexcept: ## Assign to a variable that enables MeatAxe to find ## its multiplication tables. global MtxLibDir diff --git a/src/sage/libs/sirocco.pyx b/src/sage/libs/sirocco.pyx index 117d714c5d5..8cca0892c55 100644 --- a/src/sage/libs/sirocco.pyx +++ b/src/sage/libs/sirocco.pyx @@ -27,7 +27,7 @@ cdef extern from "sirocco.h": double* homotopyPath_comps(int degree, double *_coef, double _y0R, double _y0I, int nothercomps, int *degreescomps, double *_coefscomps) -cpdef list[list] contpath_mp(int deg, list values, RealNumber y0r, RealNumber y0i, int prec): +cpdef list[list] contpath_mp(int deg, list values, RealNumber y0r, RealNumber y0i, int prec) noexcept: """ Mimics :func:`contpath`, but with the following differences: @@ -88,7 +88,7 @@ cpdef list[list] contpath_mp(int deg, list values, RealNumber y0r, RealNumber y0 free(rop) return l -cpdef list[list] contpath_mp_comps(int deg, list values, RealNumber y0r, RealNumber y0i, int prec, list otherdegs, list othercoefs): +cpdef list[list] contpath_mp_comps(int deg, list values, RealNumber y0r, RealNumber y0i, int prec, list otherdegs, list othercoefs) noexcept: """ Mimics :func:`contpath`, but with the following differences: @@ -167,7 +167,7 @@ cpdef list[list] contpath_mp_comps(int deg, list values, RealNumber y0r, RealNum return l -cpdef list[list] contpath(int deg, list values, double y0r, double y0i): +cpdef list[list] contpath(int deg, list values, double y0r, double y0i) noexcept: """ INPUT: @@ -222,7 +222,7 @@ cpdef list[list] contpath(int deg, list values, double y0r, double y0i): free(c_values) return l -cpdef list[list] contpath_comps(int deg, list values, double y0r, double y0i, list otherdegrees, list othercoefs): +cpdef list[list] contpath_comps(int deg, list values, double y0r, double y0i, list otherdegrees, list othercoefs) noexcept: """ INPUT: diff --git a/src/sage/matrix/matrix_gfpn_dense.pxd b/src/sage/matrix/matrix_gfpn_dense.pxd index 7a457876b9a..8c435b8ea2f 100644 --- a/src/sage/matrix/matrix_gfpn_dense.pxd +++ b/src/sage/matrix/matrix_gfpn_dense.pxd @@ -18,20 +18,20 @@ from sage.libs.meataxe cimport * cdef class FieldConverter_class: cdef field # A function converting an int to a field element cdef FEL zero_FEL # the FEL representation of zero - cpdef fel_to_field(self, FEL x) + cpdef fel_to_field(self, FEL x) noexcept cpdef FEL field_to_fel(self, x) except 255 -cdef FieldConverter_class FieldConverter(field) +cdef FieldConverter_class FieldConverter(field) noexcept cdef class Matrix_gfpn_dense(Matrix_dense): cdef Matrix_t *Data cdef readonly FieldConverter_class _converter - cdef set_slice_unsafe(self, Py_ssize_t i, Matrix_gfpn_dense S) - cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) - cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j) - cpdef list _rowlist_(self, i, j=*) - cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right) - cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=*) + cdef set_slice_unsafe(self, Py_ssize_t i, Matrix_gfpn_dense S) noexcept + cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) noexcept + cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j) noexcept + cpdef list _rowlist_(self, i, j=*) noexcept + cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right) noexcept + cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=*) noexcept -cdef Matrix_gfpn_dense new_mtx(Matrix_t* mat, Matrix_gfpn_dense template) +cdef Matrix_gfpn_dense new_mtx(Matrix_t* mat, Matrix_gfpn_dense template) noexcept diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx index 8e8e4d7336b..e680412ea0a 100644 --- a/src/sage/matrix/matrix_gfpn_dense.pyx +++ b/src/sage/matrix/matrix_gfpn_dense.pyx @@ -122,7 +122,7 @@ cdef class FieldConverter_class: self.field = field._cache.fetch_int self.zero_FEL = self.field_to_fel(field.zero()) - cpdef fel_to_field(self, FEL x): + cpdef fel_to_field(self, FEL x) noexcept: """ Fetch a python int into the field. @@ -214,7 +214,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): """ self.field = field - cpdef fel_to_field(self, FEL x): + cpdef fel_to_field(self, FEL x) noexcept: """ Fetch a python int into the field. @@ -253,7 +253,7 @@ cdef class PrimeFieldConverter_class(FieldConverter_class): cdef dict _converter_cache = {} -cdef FieldConverter_class FieldConverter(field): +cdef FieldConverter_class FieldConverter(field) noexcept: """ Return a :class:`FieldConverter_class` or :class:`PrimeFieldConverter_class` instance, depending whether the field is prime or not. @@ -282,7 +282,7 @@ cdef FieldConverter_class FieldConverter(field): ## ###################################### -cdef Matrix_gfpn_dense new_mtx(Matrix_t* mat, Matrix_gfpn_dense template): +cdef Matrix_gfpn_dense new_mtx(Matrix_t* mat, Matrix_gfpn_dense template) noexcept: """ Create a new ``Matrix_gfpn_dense`` from a meataxe matrix @@ -550,7 +550,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): else: return mtx_unpickle, (0, 0, 0, '', not self._is_immutable) - cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j): + cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Get an element without checking. @@ -571,7 +571,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): FfSetField(self.Data.Field) return self._converter.fel_to_field(FfExtract(MatGetPtr(self.Data,i), j)) - cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j): + cdef inline int get_unsafe_int(self, Py_ssize_t i, Py_ssize_t j) noexcept: # NOTE: # It is essential that you call FfSetField and FfSetNoc YOURSELF # and that you assert that the matrix is not empty! @@ -593,7 +593,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): FfSetField(self.Data.Field) return FfExtract(MatGetPtr(self.Data,i), j) == self._converter.zero_FEL - cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j): + cpdef Matrix_gfpn_dense get_slice(self, Py_ssize_t i, Py_ssize_t j) noexcept: """ Return a horizontal slice of this matrix. @@ -630,7 +630,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): sig_off() return new_mtx(mat, self) - cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): + cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value) noexcept: """ Set values without bound checking. @@ -661,14 +661,14 @@ cdef class Matrix_gfpn_dense(Matrix_dense): FfSetField(self.Data.Field) FfInsert(MatGetPtr(self.Data,i), j, self._converter.field_to_fel(value)) - cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value): + cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept: # NOTE: # It is essential that you call FfSetField and FfSetNoc YOURSELF # and that you assert that the matrix is not empty! # This method is here for speed! FfInsert(FfGetPtr(self.Data.Data,i), j, FfFromInt(value)) - cdef set_slice_unsafe(self, Py_ssize_t i, Matrix_gfpn_dense S): + cdef set_slice_unsafe(self, Py_ssize_t i, Matrix_gfpn_dense S) noexcept: # Overwrite the self[i:i+S.nrows()] by the contents of S. # # NOTE: @@ -807,7 +807,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): ################## ## comparison - cpdef _richcmp_(left, right, int op): + cpdef _richcmp_(left, right, int op) noexcept: """ Compare two :class:`Matrix_gfpn_dense` matrices. @@ -866,7 +866,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): return rich_to_bool(op, -1) return rich_to_bool(op, 0) - cpdef list _rowlist_(self, i, j=-1): + cpdef list _rowlist_(self, i, j=-1) noexcept: """ Return rows as a flat list of python ints. @@ -966,7 +966,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): ######################### ## Arithmetics - cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col): + cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col) noexcept: """ Rescale row number `i` in-place by multiplication with the scalar `s`. @@ -1042,7 +1042,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): FfSetNoc(noc) FfMulRow(row_head, c) - cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col): + cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept: """ Add the ``multiple``-fold of row ``row_from`` in-place to row ``row_to``, beginning with ``start_col`` @@ -1112,7 +1112,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): FfSetNoc(noc) FfAddMulRow(row_to_head, row_from_head, c) - cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2): + cdef swap_rows_c(self, Py_ssize_t row1, Py_ssize_t row2) noexcept: """ Swap the rows ``row1`` and ``row2`` in-place. @@ -1156,7 +1156,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): raise ValueError("self must be a square matrix") return self._converter.fel_to_field(MatTrace(self.Data)) - cdef _stack_impl(self, bottom): + cdef _stack_impl(self, bottom) noexcept: r""" Stack ``self`` on top of ``bottom``. @@ -1197,7 +1197,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): sig_off() return new_mtx(mat, self) - cpdef _add_(self, right): + cpdef _add_(self, right) noexcept: """ TESTS:: @@ -1224,7 +1224,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): sig_off() return new_mtx(mat, self) - cpdef _sub_(self, right): + cpdef _sub_(self, right) noexcept: """ TESTS:: @@ -1273,7 +1273,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): raise ValueError("The matrix must not be empty") return self._lmul_(self._base_ring(-1)) - cpdef _lmul_(self, Element right): + cpdef _lmul_(self, Element right) noexcept: """ EXAMPLES:: @@ -1316,7 +1316,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): # asymptotically faster. So, we used it by default. return 0 - cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right): + cpdef Matrix_gfpn_dense _multiply_classical(Matrix_gfpn_dense self, Matrix_gfpn_dense right) noexcept: """ Multiplication using the cubic school book multiplication algorithm. @@ -1345,7 +1345,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): sig_off() return new_mtx(mat, self) - cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=0): + cpdef Matrix_gfpn_dense _multiply_strassen(Matrix_gfpn_dense self, Matrix_gfpn_dense right, cutoff=0) noexcept: """ Matrix multiplication using the asymptotically fast Strassen-Winograd algorithm. @@ -1381,7 +1381,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): sig_off() return new_mtx(mat, self) - cdef _mul_long(self, long n): + cdef _mul_long(self, long n) noexcept: """ Multiply an MTX matrix with a field element represented by an integer. @@ -1599,7 +1599,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense): self.cache("left_kernel_matrix", OUT) return OUT - cpdef _echelon_in_place(self, str algorithm): + cpdef _echelon_in_place(self, str algorithm) noexcept: """ Change this matrix into echelon form, using classical Gaussian elimination, and return the pivots. From fe163ac802da29c223ba0fa5b15090bc48217f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Wed, 25 Oct 2023 19:06:00 -0300 Subject: [PATCH 218/494] Support networkx 3.2 In networkx 3.2 the output for cycle_basis() has changed. After a discussion in https://github.com/sagemath/sage/issues/36486 it seems that checking that the output is correct would not be easy. In the spirit of supporting networkx 3.2 at the same time as networkx 3.1, the easiest way is to mark these five tests as random output. --- src/sage/graphs/generic_graph.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..3fdc241a1c4 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'): A cycle basis in Petersen's Graph :: sage: g = graphs.PetersenGraph() - sage: g.cycle_basis() # needs networkx + sage: g.cycle_basis() # needs networkx, random (changes in networkx 3.2) [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5], [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]] One can also get the result as a list of lists of edges:: - sage: g.cycle_basis(output='edge') # needs networkx + sage: g.cycle_basis(output='edge') # needs networkx, random (changes in networkx 3.2) [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None), (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None), (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None), @@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]] sage: sorted(g.minimum_cycle_basis(by_weight=False)) [[1, 2, 3], [1, 3, 4], [5, 6, 7]] - sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX')) # needs networkx + sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX')) # needs networkx, random (changes in networkx 3.2) [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]] - sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX') # needs networkx + sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX') # needs networkx, random (changes in networkx 3.2) [[1, 2, 3], [1, 3, 4], [5, 6, 7]] :: @@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)]) sage: sorted(g.minimum_cycle_basis(by_weight=False)) [[1, 2, 3, 5], [3, 4, 5]] - sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')) # needs networkx + sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')) # needs networkx, random (changes in networkx 3.2) [[1, 2, 3, 5], [3, 4, 5]] TESTS:: From 2c46325e74dfa01077874e9d95fbe3a57da1ed80 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 16:23:40 -0700 Subject: [PATCH 219/494] build/pkgs/meson/spkg-configure.m4: Require >= 1.2.0 (for contourpy) --- build/pkgs/meson/spkg-configure.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/pkgs/meson/spkg-configure.m4 b/build/pkgs/meson/spkg-configure.m4 index dbc575650fc..d85bd144a07 100644 --- a/build/pkgs/meson/spkg-configure.m4 +++ b/build/pkgs/meson/spkg-configure.m4 @@ -1,11 +1,12 @@ SAGE_SPKG_CONFIGURE( [meson], [ dnl scipy 1.11.2 needs meson >= 1.1.0 - AC_CACHE_CHECK([for meson >= 1.1.0], [ac_cv_path_MESON], [ + dnl contourpy needs meson >= 1.2.0 + AC_CACHE_CHECK([for meson >= 1.2.0], [ac_cv_path_MESON], [ AC_PATH_PROGS_FEATURE_CHECK([MESON], [meson], [ meson_version=`$ac_path_MESON --version 2>&1` AS_IF([test -n "$meson_version"], [ - AX_COMPARE_VERSION([$meson_version], [ge], [1.1.0], [ + AX_COMPARE_VERSION([$meson_version], [ge], [1.2.0], [ ac_cv_path_MESON="$ac_path_MESON" ac_path_MESON_found=: ]) From 35b3d723e68dd2c0f0c342777f35ba44d84208ce Mon Sep 17 00:00:00 2001 From: ymusleh <44390016+ymusleh@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:24:01 -0400 Subject: [PATCH 220/494] Update src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antoine Leudière --- .../drinfeld_modules/finite_drinfeld_module.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index a54ba1efb05..86ae336aa6e 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -23,15 +23,15 @@ # http://www.gnu.org/licenses/ # ***************************************************************************** +from sage.functions.log import logb +from sage.functions.other import ceil, sqrt from sage.matrix.constructor import Matrix from sage.matrix.matrix_space import MatrixSpace from sage.matrix.special import companion_matrix +from sage.misc.misc_c import prod from sage.modules.free_module_element import vector -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.function_field.drinfeld_modules.drinfeld_module import DrinfeldModule -from sage.functions.other import ceil, sqrt -from sage.functions.log import logb -from sage.misc.misc_c import prod +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing class DrinfeldModule_finite(DrinfeldModule): From 0d14e5c9e7a2cb5b768afea60e2bdce2f82df285 Mon Sep 17 00:00:00 2001 From: ymusleh <44390016+ymusleh@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:24:18 -0400 Subject: [PATCH 221/494] Update src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antoine Leudière --- .../function_field/drinfeld_modules/finite_drinfeld_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 86ae336aa6e..0e8a2ad5774 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -404,7 +404,7 @@ def _frobenius_charpoly_crystalline(self, var): A = self.function_ring() K = self.base_over_constants_field() charpoly_K = self._frobenius_crystalline_matrix() \ - .charpoly(var).coefficients(sparse=False) + .charpoly(var).coefficients(sparse=False) # The above line obtains the char poly with coefficients in K[T] # This maps them into A = Fq[T] From 5521a952be031fc8c3e3c9be36d25c7d454bb733 Mon Sep 17 00:00:00 2001 From: ymusleh Date: Wed, 25 Oct 2023 21:22:48 -0400 Subject: [PATCH 222/494] Added wrapper for motivic method. --- .../finite_drinfeld_module.py | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 0e8a2ad5774..9410fd42230 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -332,7 +332,8 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): By default, this method uses the so-called *crystalline* algorithm which computes the characteristic polynomial of the Frobenius acting on the crystalline cohomology of the Drinfeld - module. For further details, see [Ang1997]_. + module. For further details, see [Ang1997]_. Other options + include the *motive* method. """ # Throw an error if the user asks for an unimplemented algorithm # even if the char poly has already been computed @@ -412,6 +413,55 @@ def _frobenius_charpoly_crystalline(self, var): coeffs_A = [A([x.in_base() for x in coeff]) for coeff in charpoly_K] return PolynomialRing(A, name=var)(coeffs_A) + def _frobenius_charpoly_motive(self, var): + r""" + Return the characteristic polynomial of the Frobenius + endomorphism using Motivic cohomology. + + The algorithm works for Drinfeld `\mathbb{F}_q[T]`-modules of + any rank. + + This method is private and should not be directly called. + Instead, use :meth:`frobenius_charpoly` with the option + `algorithm='motive'`. + + INPUT: + + - ``var`` -- the name of the second variable + + OUTPUT: a univariate polynomial with coefficients in the + function ring + + EXAMPLES:: + + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(6) + sage: p_root = 2*z12^11 + 2*z12^10 + z12^9 + 3*z12^8 + z12^7 + 2*z12^5 + 2*z12^4 + 3*z12^3 + z12^2 + 2*z12 + sage: phi = DrinfeldModule(A, [p_root, z12^3, z12^5]) + sage: phi.frobenius_charpoly(algorithm='motive') # indirect doctest + X^2 + ((4*z2 + 4)*T^3 + (z2 + 3)*T^2 + 3*T + 2*z2 + 3)*X + 3*z2*T^6 + (4*z2 + 3)*T^5 + (4*z2 + 4)*T^4 + 2*T^3 + (3*z2 + 3)*T^2 + (z2 + 2)*T + 4*z2 + + :: + + sage: Fq = GF(25) + sage: A. = Fq[] + sage: K. = Fq.extension(8) + sage: phi = DrinfeldModule(A, [z, 4, 1, z, z+1, 2, z+2, 1, 1, 3, 1]) + sage: phi.frobenius_charpoly(algorithm='motive') # indirect doctest + X^10 + X^9 + (3*T + z2 + 1)*X^8 + (4*T^2 + z2*T + 2*z2 + 1)*X^7 + ... + (4*z2 + 4)*T^4 + 4*z2*T^2 + (z2 + 2)*T + z2 + + :: + + sage: Fq = GF(27) + sage: A. = Fq[] + sage: K. = Fq.extension(10) + sage: phi = DrinfeldModule(A, [z, z^2 + z, 2, 1, z, z+1, 2, z+2, 0, 1, 1, z^2 + z]) + sage: phi.frobenius_charpoly(algorithm='motive') # indirect doctest + X^11 + (z3^2 + 2*z3)*X^10 + ((z3 + 1)*T + z3)*X^9 + ((2*z3^2 + z3 + 2)*T^2 + ... + (2*z3^2 + 2*z3 + 2)*T + z3^2 + """ + return self.frobenius_endomorphism().characteristic_polynomial(var) + def frobenius_norm(self): r""" Return the Frobenius norm of the Drinfeld module. From 2a150fb78ae765276939cfaa610eda0fb354c993 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 26 Oct 2023 14:17:30 +0900 Subject: [PATCH 223/494] Make auto mode behave according to system preference --- src/doc/common/static/jupyter-sphinx-furo.js | 36 ++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/doc/common/static/jupyter-sphinx-furo.js b/src/doc/common/static/jupyter-sphinx-furo.js index f7c596cf853..5194ff470fc 100644 --- a/src/doc/common/static/jupyter-sphinx-furo.js +++ b/src/doc/common/static/jupyter-sphinx-furo.js @@ -1,4 +1,4 @@ -// Change the editor theme of all CodeMirror cells according to the furo (dark) mode +// Change the editor theme according to the furo light/dark/auto mode function changeTheme(editor, theme) { if (theme === 'dark') { editor.setOption('theme', 'monokai'); // the same with pygments dark style in conf.py @@ -9,19 +9,42 @@ function changeTheme(editor, theme) { } } -// Use the theme data of the document.body element set by setTheme function +// Change the editor theme of all CodeMirror cells +function changeThemeAll(theme) { + const querySet = document.querySelectorAll('.CodeMirror'); + for (var i = 0; i < querySet.length; i++) { + changeTheme(querySet[i].CodeMirror, theme); + } +} + +// Use the theme data of the body element set by setTheme function // defined in https://github.com/pradyunsg/furo/blob/main/src/furo/assets/scripts/furo.js const body = document.body; const observer1 = new MutationObserver((mutationsList) => { for (let mutation of mutationsList) { if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') { const theme = body.dataset.theme; - const querySet = document.querySelectorAll('.CodeMirror'); - for (var i = 0; i < querySet.length; i++) { - changeTheme(querySet[i].CodeMirror, theme); - }}}}); + changeThemeAll(theme); + } + } +}); observer1.observe(body, { attributes: true }); + +// In the furo auto mode, we watch prefers-color-scheme and use the theme data +// of the body element to change the CodeMirror editor theme +const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)'); + +function handlePrefersColorSchemeChange(e) { + const theme = body.dataset.theme; + if (theme === 'auto') { + changeThemeAll(theme); + } +} + +prefersDarkMode.addEventListener('change', handlePrefersColorSchemeChange); + + // Change the editor theme of a new CodeMirror cell. const callback = function(mutationsList, observer) { for(const mutation of mutationsList) { @@ -89,4 +112,3 @@ thebelab.on("status", function (evt, data) { kernel.requestExecute({code: "%display latex"}); } }); - From 7c1a38e3fa4043560c444411b0e55d17b8093510 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 23:41:50 -0700 Subject: [PATCH 224/494] build/pkgs/nauty/patches: Add https://gitweb.gentoo.org/repo/gentoo.git/plain/sci-mathematics/nauty/files/nauty-2.8.6-gentreeg-gentourng.patch --- .../nauty-2.8.6-gentreeg-gentourng.patch | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch diff --git a/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch b/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch new file mode 100644 index 00000000000..322b25326ee --- /dev/null +++ b/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch @@ -0,0 +1,144 @@ +From edb0474a4db8e69f971e4eebe18716309f5a7bb3 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky +Date: Tue, 17 Jan 2023 19:44:49 -0500 +Subject: [PATCH 1/1] Upstream fixes for gentreeg and gentourng. + +https://mailman.anu.edu.au/pipermail/nauty/2023-January/000903.html +--- + gentourng.c | 2 +- + gentreeg.c | 95 ++++++++++++++++++++++++++++------------------------- + 2 files changed, 51 insertions(+), 46 deletions(-) + +diff --git a/gentourng.c b/gentourng.c +index 634e5e8..5c7ffff 100644 +--- a/gentourng.c ++++ b/gentourng.c +@@ -1408,7 +1408,7 @@ PLUGIN_INIT + (*outproc)(outfile,g,1); + } + } +- else ++ else if (!connec || maxn != 2) + { + makeleveldata(); + +diff --git a/gentreeg.c b/gentreeg.c +index 946d5f8..15bf87b 100644 +--- a/gentreeg.c ++++ b/gentreeg.c +@@ -1,4 +1,4 @@ +-/* gentree version 1.3; Brendan McKay Oct 2022 */ ++/* gentree version 1.4; Brendan McKay Dec 2022 */ + /* This program is a wrapper for the program FreeTrees.c written + * by Gang Li & Frank Ruskey. See below for their original + * comments. */ +@@ -32,49 +32,54 @@ Counts for n=1..45: + 1: 1 + 2: 1 + 3: 1 +- 4: 1 +- 5: 2 +- 6: 3 +- 7: 6 +- 8: 11 +- 9: 23 +-10: 47 +-11: 106 +-12: 235 +-13: 551 +-14: 1301 +-15: 3159 +-16: 7741 +-17: 19320 +-18: 48629 +-19: 123867 +-20: 317955 +-21: 823065 +-22: 2144505 +-23: 5623756 +-24: 14828074 +-25: 39299897 +-26: 104636890 +-27: 279793450 +-28: 751065460 +-29: 2023443032 +-30: 5469566585 +-31: 14830871802 +-32: 40330829030 +-33: 109972410221 +-34: 300628862480 +-35: 823779631721 +-36: 2262366343746 +-37: 6226306037178 +-38: 17169677490714 +-39: 47436313524262 +-40: 131290543779126 +-41: 363990257783343 +-42: 1010748076717151 +-43: 2810986483493475 +-44: 7828986221515605 +-45: 21835027912963086 +-********************************/ ++ 4: 2 ++ 5: 3 ++ 6: 6 ++ 7: 11 ++ 8: 23 ++ 9: 47 ++10: 106 ++11: 235 ++12: 551 ++13: 1301 ++14: 3159 ++15: 7741 ++16: 19320 ++17: 48629 ++18: 123867 ++19: 317955 ++20: 823065 ++21: 2144505 ++22: 5623756 ++23: 14828074 ++24: 39299897 ++25: 104636890 ++26: 279793450 ++27: 751065460 ++28: 2023443032 ++29: 5469566585 ++30: 14830871802 ++31: 40330829030 ++32: 109972410221 ++33: 300628862480 ++34: 823779631721 ++35: 2262366343746 ++36: 6226306037178 ++37: 17169677490714 ++38: 47436313524262 ++39: 131290543779126 ++40: 363990257783343 ++41: 1010748076717151 ++42: 2810986483493475 ++43: 7828986221515605 ++44: 21835027912963086 ++45: 60978390985918906 ++46: 170508699155987862 ++47: 477355090753926460 ++48: 1337946100045842285 ++49: 3754194185716399992 ++50: 10545233702911509534 ++*******************************/ + + /* Comments on original program by original authors */ + /*==============================================================*/ +@@ -676,7 +681,7 @@ PLUGIN_INIT + } + else if (nv == 2) + { +- if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 2) ++ if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 1) + { + par[1] = 0; + par[2] = 1; +-- +2.38.2 + From a95b9d63dbdd574ed3a3c016822867ca523a0c78 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 25 Oct 2023 23:42:24 -0700 Subject: [PATCH 225/494] build/pkgs/nauty/package-version.txt: Increase patchlevel --- build/pkgs/nauty/package-version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/nauty/package-version.txt b/build/pkgs/nauty/package-version.txt index e43686acc36..b6b3dcc5aa0 100644 --- a/build/pkgs/nauty/package-version.txt +++ b/build/pkgs/nauty/package-version.txt @@ -1 +1 @@ -2.8.6 +2.8.6.p0 From f592be053db4d5c3a1c2a0060db080b781c289b3 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 26 Oct 2023 16:53:27 +0900 Subject: [PATCH 226/494] Patch jupyter-sphinx a bit more --- .../0001-Patch-for-sage-live-doc.patch | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch index 046c8a4fd6a..afbb0c1273f 100644 --- a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch +++ b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch @@ -1,15 +1,15 @@ -From fa6e7b31ebd7f6dbf02e1e4c1056e4ef1389884e Mon Sep 17 00:00:00 2001 +From 5bffbe38302c695123779f87300d84090b4bd118 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 28 Aug 2023 00:18:59 +0900 Subject: [PATCH] Patch for sage live doc --- - jupyter_sphinx/__init__.py | 2 +- + jupyter_sphinx/__init__.py | 4 ++-- jupyter_sphinx/execute.py | 11 +++++++++++ - 2 files changed, 12 insertions(+), 1 deletion(-) + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py -index 34af884..f2e17e0 100644 +index 34af884..b7ca8ee 100644 --- a/jupyter_sphinx/__init__.py +++ b/jupyter_sphinx/__init__.py @@ -31,7 +31,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource @@ -21,6 +21,15 @@ index 34af884..f2e17e0 100644 logger = logging.getLogger(__name__) +@@ -186,7 +186,7 @@ def setup(app): + app.add_config_value("jupyter_sphinx_embed_url", None, "html") + + # thebelab config, can be either a filename or a dict +- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html") ++ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env") + app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html") + + # linenos config diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py index 558a26b..de44455 100644 --- a/jupyter_sphinx/execute.py @@ -44,5 +53,5 @@ index 558a26b..de44455 100644 # and cells can be zipped and the provided input/output # can be inserted later -- -2.40.1 +2.42.0 From b5e3ce85680638fa02f0d9d2c7ffe3217c5505ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 26 Oct 2023 11:24:42 +0200 Subject: [PATCH 227/494] refine category of RAAGs --- src/sage/groups/raag.py | 64 ++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/sage/groups/raag.py b/src/sage/groups/raag.py index 4bd3787d484..ff7aa0ae9c2 100644 --- a/src/sage/groups/raag.py +++ b/src/sage/groups/raag.py @@ -13,18 +13,15 @@ - Travis Scrimshaw (2018-02-05): Made compatible with :class:`~sage.groups.artin.ArtinGroup` """ - -#**************************************************************************** +# *************************************************************************** # Copyright (C) 2013,2018 Travis Scrimshaw # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** - - +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.libs.gap.element import GapElement from sage.misc.cachefunc import cached_method @@ -38,11 +35,13 @@ from sage.combinat.free_module import CombinatorialFreeModule from sage.categories.fields import Fields +from sage.categories.groups import Groups from sage.categories.algebras_with_basis import AlgebrasWithBasis from sage.algebras.clifford_algebra_element import CohomologyRAAGElement from sage.typeset.ascii_art import ascii_art from sage.typeset.unicode_art import unicode_art + class RightAngledArtinGroup(ArtinGroup): r""" The right-angled Artin group defined by a graph `G`. @@ -186,23 +185,26 @@ def __init__(self, G, names): sage: G = RightAngledArtinGroup(graphs.CycleGraph(5)) sage: TestSuite(G).run() + sage: G.category() + Category of infinite groups """ self._graph = G F = FreeGroup(names=names) CG = Graph(G).complement() # Make sure it's mutable CG.relabel() # Standardize the labels - cm = [[-1]*CG.num_verts() for _ in range(CG.num_verts())] + cm = [[-1] * CG.num_verts() for _ in range(CG.num_verts())] for i in range(CG.num_verts()): cm[i][i] = 1 - for u,v in CG.edge_iterator(labels=False): + for u, v in CG.edge_iterator(labels=False): cm[u][v] = 2 cm[v][u] = 2 self._coxeter_group = CoxeterGroup(CoxeterMatrix(cm, index_set=G.vertices(sort=True))) rels = tuple(F([i + 1, j + 1, -i - 1, -j - 1]) for i, j in CG.edge_iterator(labels=False)) # +/- 1 for indexing - FinitelyPresentedGroup.__init__(self, F, rels) + FinitelyPresentedGroup.__init__(self, F, rels, + category=Groups().Infinite()) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. @@ -226,7 +228,7 @@ def gen(self, i): """ return self.element_class(self, ([i, 1],)) - def gens(self): + def gens(self) -> tuple: """ Return the generators of ``self``. @@ -310,8 +312,9 @@ def _element_constructor_(self, x): def _normal_form(self, word): """ - Return the normal form of the word ``word``. Helper function for - creating elements. + Return the normal form of the word ``word``. + + Helper function for creating elements. EXAMPLES:: @@ -435,16 +438,16 @@ def __init__(self, parent, lst): mult += 1 else: if j < 0: - data.append([-j-1, -mult]) + data.append([-j - 1, -mult]) else: - data.append([j-1, mult]) + data.append([j - 1, mult]) j = i mult = 1 if j is not None: if j < 0: - data.append([-j-1, -mult]) + data.append([-j - 1, -mult]) else: - data.append([j-1, mult]) + data.append([j - 1, mult]) self._data = tuple(data) else: self._data = lst @@ -472,7 +475,7 @@ def __reduce__(self): V = P._graph.vertices(sort=True) return (P, ([[V[i], p] for i, p in self._data],)) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. @@ -499,12 +502,11 @@ def _repr_(self): def to_str(name, p): if p == 1: return "{}".format(name) - else: - return "{}^{}".format(name, p) + return "{}^{}".format(name, p) return '*'.join(to_str(v[i], p) for i, p in self._data) - def _latex_(self): + def _latex_(self) -> str: r""" Return a LaTeX representation of ``self``. @@ -603,7 +605,7 @@ def __invert__(self): lst = [[x[0], -x[1]] for x in reversed(self._data)] return self.__class__(P, P._normal_form(lst)) - def _richcmp_(self, other, op): + def _richcmp_(self, other, op) -> bool: """ Compare ``self`` and ``other``. @@ -627,6 +629,7 @@ def _richcmp_(self, other, op): """ return richcmp(self._data, other._data, op) + class CohomologyRAAG(CombinatorialFreeModule): r""" The cohomology ring of a right-angled Artin group. @@ -652,6 +655,11 @@ def __init__(self, R, A): sage: A = groups.misc.RightAngledArtin(C4) sage: H = A.cohomology() sage: TestSuite(H).run() + + sage: A.cohomology(ZZ) + Traceback (most recent call last): + ... + NotImplementedError: only implemented with coefficients in a field """ if R not in Fields(): raise NotImplementedError("only implemented with coefficients in a field") @@ -666,7 +674,7 @@ def __init__(self, R, A): CombinatorialFreeModule.__init__(self, R, indices, category=cat, prefix='H') self._assign_names(names) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. @@ -680,10 +688,9 @@ def _repr_(self): """ return "Cohomology ring of {} with coefficients in {}".format(self._group, self.base_ring()) - def _repr_term(self, m): + def _repr_term(self, m) -> str: """ - Return a string representation of the basis element indexed by - ``m``. + Return a string representation of the basis element indexed by ``m``. EXAMPLES:: @@ -743,8 +750,7 @@ def _unicode_art_term(self, m): def _latex_term(self, m): r""" - Return a `\LaTeX` representation of the basis element indexed - by ``m``. + Return a `\LaTeX` representation of the basis element indexed by ``m``. EXAMPLES:: @@ -807,7 +813,7 @@ def algebra_generators(self): Finite family {0: e0, 1: e1, 2: e2, 3: e3} """ V = self._group._graph.vertices(True) - d = {x: self.gen(i) for i,x in enumerate(V)} + d = {x: self.gen(i) for i, x in enumerate(V)} from sage.sets.family import Family return Family(V, lambda x: d[x]) From 6d9f69fe212a5511e35b8115353a370c3d3b2a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 26 Oct 2023 11:33:50 +0200 Subject: [PATCH 228/494] expurge parent_old from cryptosystem --- src/sage/crypto/cryptosystem.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/sage/crypto/cryptosystem.py b/src/sage/crypto/cryptosystem.py index 33cc87cf08e..488b9a014b5 100644 --- a/src/sage/crypto/cryptosystem.py +++ b/src/sage/crypto/cryptosystem.py @@ -5,7 +5,9 @@ This module contains base classes for various cryptosystems, including symmetric key and public-key cryptosystems. The classes defined in this module should not be called directly. It is the responsibility of child -classes to implement specific cryptosystems. Take for example the +classes to implement specific cryptosystems. + +Take for example the Hill or matrix cryptosystem as implemented in :class:`HillCryptosystem `. It is a symmetric key cipher so @@ -27,22 +29,21 @@ class of | + VigenereCryptosystem + PublicKeyCryptosystem """ - -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 David Kohel # # Distributed under the terms of the GNU General Public License (GPL) # -# http://www.gnu.org/licenses/ -#***************************************************************************** - -import sage.structure.parent_old as parent_old +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.sets.set import Set_generic -class Cryptosystem(parent_old.Parent, Set_generic): + +class Cryptosystem(Set_generic): r""" A base cryptosystem class. This is meant to be extended by other specialized child classes that implement specific cryptosystems. + A cryptosystem is a pair of maps .. MATH:: @@ -143,7 +144,9 @@ def __init__(self, plaintext_space, ciphertext_space, key_space, def __eq__(self, right): r""" - Comparing ``self`` with ``right``. Two ``Cryptosystem`` objects + Comparing ``self`` with ``right``. + + Two ``Cryptosystem`` objects are the same if they satisfy all of these conditions: - share the same type @@ -323,7 +326,9 @@ def key_space(self): def block_length(self): r""" - Return the block length of this cryptosystem. For some cryptosystems + Return the block length of this cryptosystem. + + For some cryptosystems this is not relevant, in which case the block length defaults to 1. EXAMPLES: @@ -348,6 +353,7 @@ def period(self): raise TypeError("Argument has no associated period.") return self._period + class SymmetricKeyCryptosystem(Cryptosystem): r""" The base class for symmetric key, or secret key, cryptosystems. @@ -373,6 +379,7 @@ def alphabet_size(self): """ return self._cipher_domain.ngens() + class PublicKeyCryptosystem(Cryptosystem): r""" The base class for asymmetric or public-key cryptosystems. From db836986cfde6b2e545e81182f6c1838c518e24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 26 Oct 2023 14:14:17 +0200 Subject: [PATCH 229/494] cleanup in number_field_element --- .../number_field/number_field_element.pxd | 1 - .../number_field/number_field_element.pyx | 143 ++++++++---------- 2 files changed, 64 insertions(+), 80 deletions(-) diff --git a/src/sage/rings/number_field/number_field_element.pxd b/src/sage/rings/number_field/number_field_element.pxd index c3d8a8b4a4b..114b6759aec 100644 --- a/src/sage/rings/number_field/number_field_element.pxd +++ b/src/sage/rings/number_field/number_field_element.pxd @@ -4,7 +4,6 @@ from sage.rings.integer cimport Integer from sage.rings.number_field.number_field_element_base cimport NumberFieldElement_base from sage.rings.polynomial.polynomial_element cimport Polynomial from sage.structure.parent cimport Parent -from sage.structure.parent_base cimport ParentWithBase from sage.libs.ntl.types cimport ZZ_c, ZZX_c from sage.libs.ntl.ntl_ZZX cimport ntl_ZZX from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 749b10437f3..70d41e866af 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -54,7 +54,6 @@ from sage.libs.gmp.pylong cimport mpz_pythonhash from cpython.object cimport Py_EQ, Py_NE, Py_LT, Py_GT, Py_LE, Py_GE from sage.structure.richcmp cimport rich_to_bool -import sage.rings.infinity import sage.rings.polynomial.polynomial_element from sage.rings.polynomial.evaluation_ntl cimport ZZX_evaluation_mpfi import sage.rings.rational_field @@ -97,6 +96,7 @@ from sage.rings.cc import CC # issue 5213 TUNE_CHARPOLY_NF = 25 + def is_NumberFieldElement(x): """ Return ``True`` if `x` is of type :class:`NumberFieldElement`, i.e., an element of @@ -212,12 +212,10 @@ cdef class NumberFieldElement(NumberFieldElement_base): """ INPUT: - - ``parent`` -- a number field - ``f`` -- defines an element of a number field. - EXAMPLES: The following examples illustrate creation of elements of @@ -286,8 +284,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): # set it up and exit immediately # fast pathway mpz_to_ZZ(&coeff, (ZZ(f)).value) - ZZX_SetCoeff( self._numerator, 0, coeff ) - ZZ_conv_from_int( self._denominator, 1 ) + ZZX_SetCoeff(self._numerator, 0, coeff) + ZZ_conv_from_int(self._denominator, 1) return elif isinstance(f, NumberFieldElement): if type(self) is type(f): @@ -308,7 +306,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): num = f * den for i from 0 <= i <= num.degree(): mpz_to_ZZ(&coeff, (ZZ(num[i])).value) - ZZX_SetCoeff( self._numerator, i, coeff ) + ZZX_SetCoeff(self._numerator, i, coeff) def _lift_cyclotomic_element(self, new_parent, bint check=True, int rel=0): """ @@ -356,7 +354,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): if check: from .number_field import NumberField_cyclotomic if not isinstance(self.number_field(), NumberField_cyclotomic) \ - or not isinstance(new_parent, NumberField_cyclotomic): + or not isinstance(new_parent, NumberField_cyclotomic): raise TypeError("The field and the new parent field must both be cyclotomic fields.") if rel == 0: @@ -368,8 +366,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): except TypeError: raise TypeError("The zeta_order of the new field must be a multiple of the zeta_order of the original.") - ## degree 2 is handled differently, because elements are - ## represented differently + # degree 2 is handled differently, because elements are + # represented differently if new_parent.degree() == 2: if rel == 1: return new_parent._element_class(new_parent, self) @@ -378,7 +376,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): cdef type t = type(self) cdef NumberFieldElement x = t.__new__(t) - x._parent = new_parent + x._parent = new_parent x._fld_numerator, x._fld_denominator = new_parent.polynomial_ntl() x._denominator = self._denominator cdef ZZX_c result @@ -527,12 +525,12 @@ cdef class NumberFieldElement(NumberFieldElement_base): from .number_field import NumberField_cyclotomic if isinstance(P, NumberField_cyclotomic): n = P._n() - if n != 2 and n%4 == 2: + if n != 2 and n % 4 == 2: x = p.variables()[0] p = p(-x**((n//2+1)//2)) - E = 'E(%d)'%(n//2) + E = 'E(%d)' % (n//2) else: - E = 'E(%d)'%n + E = 'E(%d)' % n else: E = self.parent()._gap_().GeneratorsOfField()[1].name() return str(p).replace(p.variable_name(), E) @@ -572,8 +570,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): from sage.libs.gap.libgap import libgap E = libgap(P).GeneratorsOfField()[0] n = P._n() - if n%4 == 2: - E = -E**((n//2+1)//2) + if n % 4 == 2: + E = -E**((n // 2 + 1) // 2) return self.polynomial()(E) def _pari_polynomial(self, name='y'): @@ -856,7 +854,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): ZZX_evaluation_mpfi(ra, _right._numerator, v.value) mpfi_div_z(ra, ra, rd) while mpfr_greaterequal_p(&la.right, &ra.left) \ - and mpfr_greaterequal_p(&ra.right, &la.left): + and mpfr_greaterequal_p(&ra.right, &la.left): i += 1 v = P._get_embedding_approx(i) mpfi_set_prec(la, mpfi_get_prec(v.value)) @@ -906,7 +904,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): cdef int _randomize(self, num_bound, den_bound, distribution) except -1: cdef int i cdef Integer denom_temp = Integer.__new__(Integer) - cdef Integer tmp_integer = Integer.__new__(Integer) + cdef Integer tmp_int = Integer.__new__(Integer) cdef ZZ_c ntl_temp cdef list coeff_list cdef Rational tmp_rational @@ -928,16 +926,16 @@ cdef class NumberFieldElement(NumberFieldElement_base): # set the denominator mpz_set_si(denom_temp.value, 1) mpz_to_ZZ(&self._denominator, (denom_temp).value) - for i from 0 <= i < ZZX_deg(self._fld_numerator.x): - tmp_integer = (ZZ.random_element(x=num_bound, - distribution=distribution)) - mpz_to_ZZ(&ntl_temp, (tmp_integer).value) + for i in range(ZZX_deg(self._fld_numerator.x)): + tmp_int = (ZZ.random_element(x=num_bound, + distribution=distribution)) + mpz_to_ZZ(&ntl_temp, (tmp_int).value) ZZX_SetCoeff(self._numerator, i, ntl_temp) else: coeff_list = [] mpz_set_si(denom_temp.value, 1) - tmp_integer = Integer.__new__(Integer) + tmp_int = Integer.__new__(Integer) for i from 0 <= i < ZZX_deg(self._fld_numerator.x): tmp_rational = (QQ.random_element(num_bound=num_bound, @@ -960,19 +958,18 @@ cdef class NumberFieldElement(NumberFieldElement_base): # also know is integral -- so we can use mpz_divexact # below tmp_rational = (coeff_list[i]) - mpz_mul(tmp_integer.value, mpq_numref(tmp_rational.value), + mpz_mul(tmp_int.value, mpq_numref(tmp_rational.value), denom_temp.value) - mpz_divexact(tmp_integer.value, tmp_integer.value, + mpz_divexact(tmp_int.value, tmp_int.value, mpq_denref(tmp_rational.value)) # now set the coefficient of self - mpz_to_ZZ(&ntl_temp, (tmp_integer).value) + mpz_to_ZZ(&ntl_temp, (tmp_int).value) ZZX_SetCoeff(self._numerator, i, ntl_temp) return 0 # No error - def __abs__(self): r""" Return the absolute value of this number field element. @@ -983,7 +980,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): Otherwise, it is the numerical absolute value with respect to the first archimedean embedding, to double precision. - This is the ``abs( )`` Python function. If you want a + This is the ``abs()`` Python function. If you want a different embedding or precision, use ``self.abs(...)``. @@ -1114,7 +1111,6 @@ cdef class NumberFieldElement(NumberFieldElement_base): cdef size_t i cdef RealIntervalFieldElement v - if ZZX_deg(self._numerator) <= 0: mpz_init(num) mpz_init(den) @@ -1133,7 +1129,6 @@ cdef class NumberFieldElement(NumberFieldElement_base): if not ( self._parent)._embedded_real: raise TypeError("floor not uniquely defined since no real embedding is specified") - cdef number_field_base.NumberField P try: P = self._parent @@ -1365,18 +1360,18 @@ cdef class NumberFieldElement(NumberFieldElement_base): """ if (i is None and prec is None - and ( self._parent)._embedded_real): + and ( self._parent)._embedded_real): return self.sign() * self + + if prec is None: + prec = 53 + CCprec = ComplexField(prec) + if i is None and CCprec.has_coerce_map_from(self.parent()): + return CCprec(self).abs() else: - if prec is None: - prec = 53 - CCprec = ComplexField(prec) - if i is None and CCprec.has_coerce_map_from(self.parent()): - return CCprec(self).abs() - else: - i = 0 if i is None else i - P = self.number_field().complex_embeddings(prec)[i] - return P(self).abs() + i = 0 if i is None else i + P = self.number_field().complex_embeddings(prec)[i] + return P(self).abs() def abs_non_arch(self, P, prec=None): r""" @@ -2106,11 +2101,10 @@ cdef class NumberFieldElement(NumberFieldElement_base): K = R.number_field() g = K.fractional_ideal(self, other).gens_reduced() if len(g) > 1: - raise ArithmeticError("ideal (%r, %r) is not principal, gcd is not defined" % (self, other) ) + raise ArithmeticError("ideal (%r, %r) is not principal, gcd is not defined" % (self, other)) return R(g[0]) - def is_totally_positive(self): """ Return ``True`` if ``self`` is positive for all real embeddings of its @@ -2228,7 +2222,6 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: K(5).is_padic_square(p) False """ - infinity = sage.rings.infinity.infinity return self.parent().quadratic_defect(self, P, check=check) == infinity def sqrt(self, all=False, extend=True): @@ -2308,7 +2301,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): root = sqrt(SR(self)) roots = [[root, 1], [-root, 1]] except TypeError: - raise ValueError("%s not a square in %s"%(self, self._parent)) + raise ValueError("%s not a square in %s" % (self, self._parent)) if all: return [r[0] for r in roots] elif roots: @@ -2339,10 +2332,9 @@ cdef class NumberFieldElement(NumberFieldElement_base): roots = f.roots() if all: return [r[0] for r in roots] - elif roots: + if roots: return roots[0][0] - else: - raise ValueError("%s not a %s-th root in %s"%(self, n, self._parent)) + raise ValueError("%s not a %s-th root in %s" % (self, n, self._parent)) def is_nth_power(self, n): r""" @@ -2412,7 +2404,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): TypeError: no canonical coercion from Number Field in a with defining polynomial x^2 + 1 to Symbolic Ring """ if (isinstance(base, NumberFieldElement) and - (isinstance(exp, Integer) or type(exp) is int or exp in ZZ)): + (isinstance(exp, Integer) or type(exp) is int or exp in ZZ)): return generic_power(base, exp) else: cbase, cexp = canonical_coercion(base, exp) @@ -2539,8 +2531,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): else: ZZX_mul(x._numerator, self._numerator, _right._numerator) if ZZX_deg(x._numerator) >= ZZX_deg(self._fld_numerator.x): - ZZX_mul_ZZ( x._numerator, x._numerator, self._fld_denominator.x ) - ZZX_mul_ZZ( temp, self._fld_numerator.x, x._denominator ) + ZZX_mul_ZZ(x._numerator, x._numerator, self._fld_denominator.x) + ZZX_mul_ZZ(temp, self._fld_numerator.x, x._denominator) ZZ_power(temp1,ZZX_LeadCoeff(temp),ZZX_deg(x._numerator)-ZZX_deg(self._fld_numerator.x)+1) ZZX_PseudoRem(x._numerator, x._numerator, temp) ZZ_mul(x._denominator, x._denominator, self._fld_denominator.x) @@ -2840,7 +2832,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): -1/2 """ if ZZX_deg(self._numerator) >= 1: - raise TypeError("Unable to coerce %s to a rational"%self) + raise TypeError("Unable to coerce %s to a rational" % self) cdef Integer num = Integer.__new__(Integer) ZZX_getitem_as_mpz(num.value, &self._numerator, 0) cdef Integer den = Integer.__new__(Integer) @@ -3011,9 +3003,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): from sage.rings.complex_mpfr import ComplexField from sage.rings.imaginary_unit import I from sage.symbolic.constants import pi - CC = ComplexField(53) two_pi_i = 2 * pi * I - k = ( K._n()*CC(K.gen()).log() / CC(two_pi_i) ).real().round() # n ln z / (2 pi i) + k = (K._n()*CC(K.gen()).log() / CC(two_pi_i)).real().round() # n ln z / (2 pi i) gen_image = exp(k*two_pi_i/K._n()) return self.polynomial()(gen_image) else: @@ -3378,21 +3369,21 @@ cdef class NumberFieldElement(NumberFieldElement_base): elif (-self).is_one(): self.__multiplicative_order = ZZ(2) else: - self.__multiplicative_order = sage.rings.infinity.infinity + self.__multiplicative_order = infinity elif not (self.is_integral() and self.norm().is_one()): - self.__multiplicative_order = sage.rings.infinity.infinity + self.__multiplicative_order = infinity elif isinstance(self.number_field(), NumberField_cyclotomic): t = self.number_field()._multiplicative_order_table() f = self.polynomial() if f in t: self.__multiplicative_order = t[f] else: - self.__multiplicative_order = sage.rings.infinity.infinity + self.__multiplicative_order = infinity else: # Now we have a unit of norm 1, and check if it is a root of unity n = self.number_field().zeta_order() if not self**n ==1: - self.__multiplicative_order = sage.rings.infinity.infinity + self.__multiplicative_order = infinity else: from sage.groups.generic import order_from_multiple self.__multiplicative_order = order_from_multiple(self,n,operation='*') @@ -3415,8 +3406,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: K.ring_of_integers().characteristic() # implicit doctest 0 """ - if not self: return ZZ.one() - else: return sage.rings.infinity.infinity + return ZZ.one() if not self else infinity cpdef bint is_one(self): r""" @@ -3438,7 +3428,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): False """ return ZZX_IsOne(self._numerator) == 1 and \ - ZZ_IsOne(self._denominator) == 1 + ZZ_IsOne(self._denominator) == 1 cpdef bint is_rational(self): r""" @@ -3706,7 +3696,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: b^2 - (22+a) 0 """ - return self.charpoly(var).radical() # square free part of charpoly + return self.charpoly(var).radical() # square free part of charpoly def is_integral(self): r""" @@ -3991,13 +3981,13 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: L(1/4).local_height(L.ideal(2, c - a + 1)) 1.38629436111989 """ - if self.valuation(P) >= 0: ## includes the case self=0 + if self.valuation(P) >= 0: # includes the case self=0 from sage.rings.real_mpfr import RealField if prec is None: return RealField().zero() else: return RealField(prec).zero() - ht = self.abs_non_arch(P,prec).log() + ht = self.abs_non_arch(P, prec).log() if not weighted: return ht nP = P.residue_class_degree()*P.absolute_ramification_index() @@ -4332,15 +4322,14 @@ cdef class NumberFieldElement(NumberFieldElement_base): """ L = phi.domain() - ## the code below doesn't work if the morphism is - ## over QQ, since QQ.primitive_element() doesn't - ## make sense + # the code below doesn't work if the morphism is + # over QQ, since QQ.primitive_element() doesn't make sense if L is QQ: K = phi.codomain() if K != self.number_field(): raise ValueError("codomain of phi must be parent of self") - ## the variable name is irrelevant below, because the - ## matrix is over QQ + # the variable name is irrelevant below, because the + # matrix is over QQ F = K.absolute_field('alpha') _, to_F = F.structure() return to_F(self).matrix() @@ -4352,7 +4341,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): raise ValueError("codomain of phi must be parent of self") # Construct a relative extension over L (= QQ(beta)) - M = K.relativize(beta, (K.variable_name()+'0', L.variable_name()+'0') ) + M = K.relativize(beta, (K.variable_name()+'0', L.variable_name()+'0')) # Carry self over to M. _, to_M = M.structure() @@ -4368,7 +4357,6 @@ cdef class NumberFieldElement(NumberFieldElement_base): psi = M.base_field().hom([alpha]) return R.apply_morphism(psi) - def list(self): """ Return the list of coefficients of ``self`` written in terms of a power @@ -4427,10 +4415,9 @@ cdef class NumberFieldElement(NumberFieldElement_base): R = self.number_field().ring_of_integers() try: return _inverse_mod_generic(R(self), I) - except TypeError: # raised by failure of R(self) + except TypeError: # raised by failure of R(self) raise NotImplementedError("inverse_mod is not implemented for non-integral elements") - def residue_symbol(self, P, m, check=True): r""" The `m`-th power residue symbol for an element ``self`` and proper ideal `P`. @@ -4551,7 +4538,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): from sage.sets.set import Set - if K is QQ: # simpler special case avoids relativizing + if K is QQ: # simpler special case avoids relativizing # First set of primes: those which ramify in L/K: S1 = L.absolute_discriminant().prime_factors() # Second set of primes: those where self has nonzero valuation mod d: @@ -4706,7 +4693,7 @@ cdef class NumberFieldElement_absolute(NumberFieldElement): zeta9 """ K = magma(self.parent()) - return '(%s!%s)'%(K.name(), self.list()) + return '(%s!%s)' % (K.name(), self.list()) def absolute_charpoly(self, var='x', algorithm=None): r""" @@ -4848,9 +4835,8 @@ cdef class NumberFieldElement_absolute(NumberFieldElement): sage: R(a).minpoly(algorithm='pari') == R(a).minpoly(algorithm='sage') True - """ - return self.charpoly(var, algorithm).radical() # square free part of charpoly + return self.charpoly(var, algorithm).radical() # square free part of charpoly def list(self): r""" @@ -5571,7 +5557,6 @@ cdef class OrderElement_relative(NumberFieldElement_relative): return R(K(self).absolute_minpoly(var)) - class CoordinateFunction(): r""" This class provides a callable object which expresses @@ -5613,7 +5598,7 @@ class CoordinateFunction(): sage: f = (a + 1).coordinates_in_terms_of_powers(); repr(f) # indirect doctest 'Coordinate function that writes elements in terms of the powers of a + 1' """ - return "Coordinate function that writes elements in terms of the powers of %s"%self.__alpha + return "Coordinate function that writes elements in terms of the powers of %s" % self.__alpha def alpha(self): r""" @@ -5676,7 +5661,7 @@ class CoordinateFunction(): if not isinstance(other, CoordinateFunction): return False - return self.__K == other.__K and self.__alpha == other.__alpha + return self.__K == other.__K and self.__alpha == other.__alpha def __ne__(self, other): """ @@ -5707,4 +5692,4 @@ cdef void _ntl_poly(f, ZZX_c *num, ZZ_c *den): __num = f * __den for i from 0 <= i <= __num.degree(): mpz_to_ZZ(&coeff, (ZZ(__num[i])).value) - ZZX_SetCoeff( num[0], i, coeff ) + ZZX_SetCoeff(num[0], i, coeff) From bf64a650575e2d6a2f29bbfc2c9c430be599288d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 26 Oct 2023 14:38:41 +0200 Subject: [PATCH 230/494] suggested details --- .../quadratic_form__split_local_covering.py | 8 ++++---- .../quadratic_forms/quadratic_form__ternary_Tornaria.py | 3 +-- src/sage/quadratic_forms/quadratic_form__theta.py | 9 +++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/sage/quadratic_forms/quadratic_form__split_local_covering.py b/src/sage/quadratic_forms/quadratic_form__split_local_covering.py index 495b439e3ca..4db788e5e44 100644 --- a/src/sage/quadratic_forms/quadratic_form__split_local_covering.py +++ b/src/sage/quadratic_forms/quadratic_form__split_local_covering.py @@ -239,20 +239,20 @@ def vectors_by_length(self, bound): print(" Float = ", Q_val_double, " Long = ", Q_val) raise RuntimeError("The roundoff error is bigger than 0.001, so we should use more precision somewhere...") - if (Q_val <= bound): + if Q_val <= bound: theta_vec[Q_val].append(deepcopy(x)) # 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True - while (j < n): - if (x[j] != 0): + while j < n: + if x[j] != 0: done_flag = False j += 1 # 3a. Increment (and carry if we go out of bounds) x[i] += 1 - while (x[i] > L[i]) and (i < n - 1): + while i < n - 1 and x[i] > L[i]: i += 1 x[i] += 1 diff --git a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py index d6d537775b3..cc7a6549312 100644 --- a/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py +++ b/src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py @@ -290,7 +290,7 @@ def discrec(self): def hasse_conductor(self): """ - Return the Hasse coductor. + Return the Hasse conductor. This is the product of all primes where the Hasse invariant equals `-1`. @@ -318,7 +318,6 @@ def clifford_invariant(self, p): """ Return the Clifford invariant. - This is the class in the Brauer group of the Clifford algebra for even dimension, of the even Clifford Algebra for odd dimension. diff --git a/src/sage/quadratic_forms/quadratic_form__theta.py b/src/sage/quadratic_forms/quadratic_form__theta.py index e6cd5f2f401..c4f0606df4c 100644 --- a/src/sage/quadratic_forms/quadratic_form__theta.py +++ b/src/sage/quadratic_forms/quadratic_form__theta.py @@ -58,7 +58,7 @@ def theta_series(self, Max=10, var_str='q', safe_flag=True): except TypeError: M = -1 - if (Max not in ['mod_form']) and (not M >= 0): + if Max not in ['mod_form'] and not M >= 0: raise TypeError("Max = {Max} is not an integer >= 0 or an allowed string") if Max == 'mod_form': @@ -205,9 +205,6 @@ def theta_by_cholesky(self, q_prec): from_step4_flag = False from_step3_flag = True # We start by pretending this, since then we get to run through 2 and 3a once. =) - # double Q_val_double; - # unsigned long Q_val; // WARNING: Still need a good way of checking overflow for this value... - # Big loop which runs through all vectors while not done_flag: @@ -226,12 +223,12 @@ def theta_by_cholesky(self, q_prec): # 3a. Main loop x[i] += 1 - while (x[i] > L[i]): + while x[i] > L[i]: i += 1 x[i] += 1 # 3b. Main loop - if (i > 0): + if i > 0: from_step3_flag = True T[i - 1] = T[i] - Q[i, i] * (x[i] + U[i]) * (x[i] + U[i]) i += -1 From 0b350bda410e720824473c319821bd9f3c0d0790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 26 Oct 2023 15:39:27 +0200 Subject: [PATCH 231/494] remove deprecated name parameter in category ; capital name for Coxeter groups --- src/sage/categories/bimodules.py | 16 +-- src/sage/categories/category.py | 102 ++++++++---------- src/sage/categories/category_types.py | 8 +- src/sage/categories/category_with_axiom.py | 2 +- ...eflection_or_generalized_coxeter_groups.py | 2 +- src/sage/categories/coxeter_groups.py | 13 ++- .../finite_complex_reflection_groups.py | 2 +- src/sage/categories/finite_coxeter_groups.py | 45 ++++---- src/sage/categories/finite_weyl_groups.py | 2 +- src/sage/categories/weyl_groups.py | 4 +- 10 files changed, 100 insertions(+), 96 deletions(-) diff --git a/src/sage/categories/bimodules.py b/src/sage/categories/bimodules.py index eccadf20a02..eec2f674aa7 100644 --- a/src/sage/categories/bimodules.py +++ b/src/sage/categories/bimodules.py @@ -37,22 +37,24 @@ class Bimodules(CategoryWithParameters): def __init__(self, left_base, right_base, name=None): """ + The ``name`` parameter is ignored. + EXAMPLES:: sage: C = Bimodules(QQ, ZZ) sage: TestSuite(C).run() """ - if not ( left_base in Rings() or - (isinstance(left_base, Category) - and left_base.is_subcategory(Rings())) ): + if not (left_base in Rings() or + (isinstance(left_base, Category) + and left_base.is_subcategory(Rings()))): raise ValueError("the left base must be a ring or a subcategory of Rings()") - if not ( right_base in Rings() or - (isinstance(right_base, Category) - and right_base.is_subcategory(Rings())) ): + if not (right_base in Rings() or + (isinstance(right_base, Category) + and right_base.is_subcategory(Rings()))): raise ValueError("the right base must be a ring or a subcategory of Rings()") self._left_base_ring = left_base self._right_base_ring = right_base - Category.__init__(self, name) + Category.__init__(self) def _make_named_class_key(self, name): r""" diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py index 29bce8ee415..fcf25b75fd4 100644 --- a/src/sage/categories/category.py +++ b/src/sage/categories/category.py @@ -118,6 +118,7 @@ _join_cache = WeakValueDictionary() + class Category(UniqueRepresentation, SageObject): r""" The base class for modeling mathematical categories, like for example: @@ -448,7 +449,7 @@ class of ``C`` is a dynamic subclass ``Cs_with_category`` of cls = cls.__base__ return super().__classcall__(cls, *args, **options) - def __init__(self, s=None): + def __init__(self): """ Initialize this category. @@ -468,12 +469,10 @@ def __init__(self, s=None): .. NOTE:: - Specifying the name of this category by passing a string - is deprecated. If the default name (built from the name of - the class) is not adequate, please use + If the default name of the category (built from the name of + the class) is not adequate, please implement :meth:`_repr_object_names` to customize it. """ - assert s is None self.__class__ = dynamic_class("{}_with_category".format(self.__class__.__name__), (self.__class__, self.subcategory_class, ), cache=False, reduction=None, @@ -491,49 +490,38 @@ def _label(self): """ t = str(self.__class__.__base__) - t = t[t.rfind('.')+1:] + t = t[t.rfind('.') + 1:] return t[:t.rfind("'")] - # TODO: move this code into the method _repr_object_names once passing a string is not accepted anymore - @lazy_attribute - def __repr_object_names(self): + def _repr_object_names(self): """ - Determine the name of the objects of this category - from its type, if it has not been explicitly given - at initialisation. + Return the name of the objects of this category. EXAMPLES:: - sage: Rings()._Category__repr_object_names - 'rings' - sage: PrincipalIdealDomains()._Category__repr_object_names - 'principal ideal domains' + sage: FiniteGroups()._repr_object_names() + 'finite groups' + sage: AlgebrasWithBasis(QQ)._repr_object_names() + 'algebras with basis over Rational Field' + + TESTS:: sage: Rings() Category of rings + sage: Rings()._repr_object_names() + 'rings' + sage: PrincipalIdealDomains()._repr_object_names() + 'principal ideal domains' """ i = -1 s = self._label - while i < len(s)-1: + while i < len(s) - 1: for i in range(len(s)): if s[i].isupper(): - s = s[:i] + " " + s[i].lower() + s[i+1:] + s = s[:i] + " " + s[i].lower() + s[i + 1:] break return s.lstrip() - def _repr_object_names(self): - """ - Return the name of the objects of this category. - - EXAMPLES:: - - sage: FiniteGroups()._repr_object_names() - 'finite groups' - sage: AlgebrasWithBasis(QQ)._repr_object_names() - 'algebras with basis over Rational Field' - """ - return self.__repr_object_names - def _short_name(self): """ Return a CamelCase name for this category. @@ -1256,7 +1244,7 @@ def structure(self): recursively from the result of :meth:`additional_structure` on the super categories of ``self``. """ - result = { D for C in self.super_categories() for D in C.structure() } + result = {D for C in self.super_categories() for D in C.structure()} if self.additional_structure() is not None: result.add(self) return frozenset(result) @@ -1319,8 +1307,7 @@ def is_full_subcategory(self, other): False """ return self.is_subcategory(other) and \ - len(self.structure()) == \ - len(other.structure()) + len(self.structure()) == len(other.structure()) @cached_method def full_super_categories(self): @@ -1446,27 +1433,26 @@ def _test_category(self, **options): Traceback (most recent call last): ... AssertionError: Category of my objects is not a subcategory of Objects() - """ - from sage.categories.objects import Objects + from sage.categories.objects import Objects from sage.categories.sets_cat import Sets tester = self._tester(**options) tester.assertTrue(isinstance(self.super_categories(), list), - "%s.super_categories() should return a list" % self) + "%s.super_categories() should return a list" % self) tester.assertTrue(self.is_subcategory(Objects()), - "%s is not a subcategory of Objects()" % self) + "%s is not a subcategory of Objects()" % self) tester.assertTrue(isinstance(self.parent_class, type)) tester.assertTrue(all(not isinstance(cat, JoinCategory) for cat in self._super_categories)) if not isinstance(self, JoinCategory): - tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories)) - tester.assertTrue(self.is_subcategory( Category.join(self.super_categories()) )) # Not an obviously passing test with axioms + tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories)) + tester.assertTrue(self.is_subcategory(Category.join(self.super_categories()))) # Not an obviously passing test with axioms for category in self._all_super_categories_proper: if self.is_full_subcategory(category): tester.assertTrue(any(cat.is_subcategory(category) - for cat in self.full_super_categories()), - "Every full super category should be a super category" - "of some immediate full super category") + for cat in self.full_super_categories()), + "Every full super category should be a super category" + "of some immediate full super category") if self.is_subcategory(Sets()): tester.assertTrue(isinstance(self.parent_class, type)) @@ -1588,7 +1574,7 @@ def _make_named_class(self, name, method_provider, cache=False, picklable=True): doccls = cls else: # Otherwise, check XXXMethods - assert inspect.isclass(method_provider_cls),\ + assert inspect.isclass(method_provider_cls), \ "%s.%s should be a class" % (cls.__name__, method_provider) mro = inspect.getmro(method_provider_cls) if len(mro) > 2 or (len(mro) == 2 and mro[1] is not object): @@ -1941,7 +1927,7 @@ def _meet_(self, other): appropriate convention for AB. """ - if self is other: # useful? fast pathway + if self is other: # useful? fast pathway return self elif self.is_subcategory(other): return other @@ -2050,14 +2036,13 @@ def _with_axiom_as_tuple(self, axiom): return (axiom_attribute(self),) warn(("Expecting {}.{} to be a subclass of CategoryWithAxiom to" " implement a category with axiom; got {}; ignoring").format( - self.__class__.__base__.__name__, axiom, axiom_attribute)) + self.__class__.__base__.__name__, axiom, axiom_attribute)) # self does not implement this axiom - result = (self, ) + \ - tuple(cat - for category in self._super_categories - for cat in category._with_axiom_as_tuple(axiom)) - hook = getattr(self, axiom+"_extra_super_categories", None) + result = (self, ) + tuple(cat + for category in self._super_categories + for cat in category._with_axiom_as_tuple(axiom)) + hook = getattr(self, axiom + "_extra_super_categories", None) if hook is not None: assert inspect.ismethod(hook) result += tuple(hook()) @@ -2593,6 +2578,7 @@ def is_Category(x): """ return isinstance(x, Category) + @cached_function def category_sample(): r""" @@ -2606,7 +2592,8 @@ def category_sample(): sage: from sage.categories.category import category_sample sage: sorted(category_sample(), key=str) # needs sage.groups - [Category of G-sets for Symmetric group of order 8! as a permutation group, + [Category of Coxeter groups, + Category of G-sets for Symmetric group of order 8! as a permutation group, Category of Hecke modules over Rational Field, Category of Lie algebras over Rational Field, Category of additive magmas, ..., @@ -2900,6 +2887,7 @@ def _subcategory_hook_(self, C): return False return Unknown + ############################################################# # Join of several categories ############################################################# @@ -2948,11 +2936,11 @@ def __init__(self, super_categories, **kwds): INPUT: - - super_categories -- Categories to join. This category will + - ``super_categories`` -- Categories to join. This category will consist of objects and morphisms that lie in all of these categories. - - name -- An optional name for this category. + - ``name`` -- ignored TESTS:: @@ -2960,17 +2948,13 @@ def __init__(self, super_categories, **kwds): sage: C = JoinCategory((Groups(), CommutativeAdditiveMonoids())); C Join of Category of groups and Category of commutative additive monoids sage: TestSuite(C).run() - """ assert len(super_categories) >= 2 assert all(not isinstance(category, JoinCategory) for category in super_categories) # Use __super_categories to not overwrite the lazy attribute Category._super_categories # Maybe this would not be needed if the flattening/sorting is does consistently? self.__super_categories = list(super_categories) - if 'name' in kwds: - Category.__init__(self, kwds['name']) - else: - Category.__init__(self) + Category.__init__(self) def _make_named_class_key(self, name): r""" diff --git a/src/sage/categories/category_types.py b/src/sage/categories/category_types.py index cb18dcd42c0..3c1aae55c5a 100644 --- a/src/sage/categories/category_types.py +++ b/src/sage/categories/category_types.py @@ -170,6 +170,8 @@ def __init__(self, base, name=None): r""" Initialize ``self``. + The ``name`` parameter is ignored. + EXAMPLES:: sage: S = Spec(ZZ) @@ -182,7 +184,7 @@ def __init__(self, base, name=None): sage: TestSuite(C).run() """ self.__base = base - Category.__init__(self, name) + Category.__init__(self) def _test_category_over_bases(self, **options): """ @@ -527,13 +529,15 @@ def __init__(self, ambient, name=None): """ Initialize ``self``. + The parameter ``name`` is ignored. + EXAMPLES:: sage: C = Ideals(IntegerRing()) sage: TestSuite(C).run() """ self.__ambient = ambient - Category.__init__(self, name) + Category.__init__(self) def ambient(self): """ diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 4775d4e5bf1..bb9dbbe2347 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -269,7 +269,7 @@ class from the base category class:: covers the following examples:: sage: FiniteCoxeterGroups() - Category of finite coxeter groups + Category of finite Coxeter groups sage: FiniteCoxeterGroups() is CoxeterGroups().Finite() True sage: FiniteCoxeterGroups._base_category_class_and_axiom_origin diff --git a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py index 89667bfc237..d3908a8db03 100644 --- a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py +++ b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py @@ -130,7 +130,7 @@ def Irreducible(self): sage: ComplexReflectionGroups().Irreducible() Category of irreducible complex reflection groups sage: CoxeterGroups().Irreducible() - Category of irreducible coxeter groups + Category of irreducible Coxeter groups TESTS:: diff --git a/src/sage/categories/coxeter_groups.py b/src/sage/categories/coxeter_groups.py index b5e5da9ea1a..71285521a5e 100644 --- a/src/sage/categories/coxeter_groups.py +++ b/src/sage/categories/coxeter_groups.py @@ -41,7 +41,7 @@ class CoxeterGroups(Category_singleton): EXAMPLES:: sage: C = CoxeterGroups(); C - Category of coxeter groups + Category of Coxeter groups sage: C.super_categories() [Category of generalized coxeter groups] @@ -128,6 +128,17 @@ def additional_structure(self): Finite = LazyImport('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups') Algebras = LazyImport('sage.categories.coxeter_group_algebras', 'CoxeterGroupAlgebras') + def _repr_object_names(self): + """ + Return the name of the objects of this category. + + EXAMPLES:: + + sage: CoxeterGroups().Finite() + Category of finite Coxeter groups + """ + return "Coxeter groups" + class ParentMethods: @abstract_method def coxeter_matrix(self): diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py index 3ee374b739c..80ff28a90f2 100644 --- a/src/sage/categories/finite_complex_reflection_groups.py +++ b/src/sage/categories/finite_complex_reflection_groups.py @@ -135,7 +135,7 @@ def WellGenerated(self): desired output (well generated does not appear):: sage: CoxeterGroups().Finite() - Category of finite coxeter groups + Category of finite Coxeter groups """ return self._with_axiom('WellGenerated') diff --git a/src/sage/categories/finite_coxeter_groups.py b/src/sage/categories/finite_coxeter_groups.py index 3459135c9c0..4d422a7541f 100644 --- a/src/sage/categories/finite_coxeter_groups.py +++ b/src/sage/categories/finite_coxeter_groups.py @@ -25,10 +25,10 @@ class FiniteCoxeterGroups(CategoryWithAxiom): EXAMPLES:: sage: CoxeterGroups.Finite() - Category of finite coxeter groups + Category of finite Coxeter groups sage: FiniteCoxeterGroups().super_categories() [Category of finite generalized coxeter groups, - Category of coxeter groups] + Category of Coxeter groups] sage: G = CoxeterGroups().Finite().example() sage: G.cayley_graph(side = "right").plot() @@ -55,7 +55,7 @@ def extra_super_categories(self): sage: CoxeterGroups().Finite().super_categories() [Category of finite generalized coxeter groups, - Category of coxeter groups] + Category of Coxeter groups] """ from sage.categories.complex_reflection_groups import ComplexReflectionGroups return [ComplexReflectionGroups().Finite().WellGenerated()] @@ -214,7 +214,7 @@ def bruhat_poset(self, facade=False): handle large / infinite Coxeter groups. """ from sage.combinat.posets.posets import Poset - covers = tuple([u, v] for v in self for u in v.bruhat_lower_covers() ) + covers = tuple([u, v] for v in self for u in v.bruhat_lower_covers()) return Poset((self, covers), cover_relations=True, facade=facade) def shard_poset(self, side='right'): @@ -590,7 +590,7 @@ def m_cambrian_lattice(self, c, m=1, on_roots=False): inv_woc = self.inversion_sequence(sorting_word) S = self.simple_reflections() T = self.reflections_from_w0() - Twords = {t : t.reduced_word() for t in T} + Twords = {t: t.reduced_word() for t in T} elements = set() covers = [] @@ -799,11 +799,12 @@ def coxeter_poset(self): sage: P.rank() 3 - sage: W = CoxeterGroup(['H', 3], implementation="permutation") # optional - gap3 - sage: P = W.coxeter_poset() # optional - gap3 - sage: P # optional - gap3 + sage: # optional - gap3 + sage: W = CoxeterGroup(['H', 3], implementation="permutation") + sage: P = W.coxeter_poset() + sage: P Finite meet-semilattice containing 363 elements - sage: P.rank() # optional - gap3 + sage: P.rank() 3 """ I = self.index_set() @@ -871,11 +872,12 @@ def coxeter_complex(self): sage: C.homology() {0: 0, 1: 0, 2: Z} - sage: W = CoxeterGroup(['H', 3], implementation="permutation") # optional - gap3 - sage: C = W.coxeter_complex() # optional - gap3 - sage: C # optional - gap3 + sage: # optional - gap3 + sage: W = CoxeterGroup(['H', 3], implementation="permutation") + sage: C = W.coxeter_complex() + sage: C Simplicial complex with 62 vertices and 120 facets - sage: C.homology() # optional - gap3 + sage: C.homology() {0: 0, 1: 0, 2: Z} """ I = self.index_set() @@ -898,7 +900,7 @@ def coxeter_complex(self): verts = set() for F in facets.values(): verts.update(F) - labels = {x: i for i,x in enumerate(verts)} + labels = {x: i for i, x in enumerate(verts)} result = [[labels[v] for v in F] for F in facets.values()] from sage.topology.simplicial_complex import SimplicialComplex return SimplicialComplex(result) @@ -938,12 +940,13 @@ def bruhat_upper_covers(self): are those covers of `ws_i` that have a descent at `i`. """ - i = self.first_descent(positive=True,side='right') + i = self.first_descent(positive=True, side='right') if i is not None: - wsi = self.apply_simple_reflection(i,side='right') - return [u.apply_simple_reflection(i,side='right') for u in wsi.bruhat_upper_covers() if u.has_descent(i,side='right')] + [wsi] - else: - return [] + wsi = self.apply_simple_reflection(i, side='right') + return [u.apply_simple_reflection(i, side='right') + for u in wsi.bruhat_upper_covers() + if u.has_descent(i, side='right')] + [wsi] + return [] def coxeter_knuth_neighbor(self, w): r""" @@ -984,7 +987,7 @@ def coxeter_knuth_neighbor(self, w): if not C[0] == 'A': raise NotImplementedError("this has only been implemented in finite type A so far") d = [] - for i in range(2,len(w)): + for i in range(2, len(w)): v = [j for j in w] if w[i-2] == w[i]: if w[i] == w[i-1] - 1: @@ -1046,7 +1049,7 @@ def coxeter_knuth_graph(self): R = [tuple(v) for v in self.reduced_words()] G = Graph() G.add_vertices(R) - G.add_edges([v,vp] for v in R for vp in self.coxeter_knuth_neighbor(v)) + G.add_edges([v, vp] for v in R for vp in self.coxeter_knuth_neighbor(v)) return G def is_coxeter_element(self): diff --git a/src/sage/categories/finite_weyl_groups.py b/src/sage/categories/finite_weyl_groups.py index 4420827c833..4210e2f9feb 100644 --- a/src/sage/categories/finite_weyl_groups.py +++ b/src/sage/categories/finite_weyl_groups.py @@ -20,7 +20,7 @@ class FiniteWeylGroups(CategoryWithAxiom): sage: C Category of finite weyl groups sage: C.super_categories() - [Category of finite coxeter groups, Category of weyl groups] + [Category of finite Coxeter groups, Category of weyl groups] sage: C.example() The symmetric group on {0, ..., 3} diff --git a/src/sage/categories/weyl_groups.py b/src/sage/categories/weyl_groups.py index 1322ecd8499..88879d2b478 100644 --- a/src/sage/categories/weyl_groups.py +++ b/src/sage/categories/weyl_groups.py @@ -26,7 +26,7 @@ class WeylGroups(Category_singleton): sage: WeylGroups() Category of weyl groups sage: WeylGroups().super_categories() - [Category of coxeter groups] + [Category of Coxeter groups] Here are some examples:: @@ -53,7 +53,7 @@ def super_categories(self): EXAMPLES:: sage: WeylGroups().super_categories() - [Category of coxeter groups] + [Category of Coxeter groups] """ return [CoxeterGroups()] From 33205e4a3332f83491f483df6f7366b9c1b3af79 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 26 Oct 2023 23:50:43 +0900 Subject: [PATCH 232/494] Fixes for conda failures --- src/doc/en/a_tour_of_sage/index.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst index debbf5471c1..8f638378130 100644 --- a/src/doc/en/a_tour_of_sage/index.rst +++ b/src/doc/en/a_tour_of_sage/index.rst @@ -94,8 +94,7 @@ digits. :: sage: factorial(100) - 93326215443944152681699238856266700490715968264381621468592963895217599993229915608 - 941463976156518286253697920827223758251185210916864000000000000000000000000 + 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 :: @@ -108,8 +107,7 @@ This computes at least 100 digits of :math:`\pi`. :: sage: N(pi, digits=100) - 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998 - 628034825342117068 + 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 This asks Sage to factor a polynomial in two variables. From 146d1706f315f6202496a7d23b60841922a5b2c7 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 27 Oct 2023 02:45:11 +0900 Subject: [PATCH 233/494] Fix jupyter-sphinx css for dark mode --- .../common/static/custom-jupyter-sphinx.css | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css index 66300e5268a..a68a5cb05aa 100644 --- a/src/doc/common/static/custom-jupyter-sphinx.css +++ b/src/doc/common/static/custom-jupyter-sphinx.css @@ -63,6 +63,10 @@ body[data-theme="dark"] { background-color: black; } + .jupyter_container .highlight { + background-color: black; + } + .thebelab-button { color: #d0d0d0; background-color: #383838; @@ -92,39 +96,43 @@ body[data-theme="dark"] { } @media (prefers-color-scheme: dark) { - body[data-theme="auto"] { /* the same styles with body[data-theme="dark"] */ - .jupyter_container { - color: white; - background-color: black; - } - - .thebelab-button { - color: #d0d0d0; - background-color: #383838; - } - - .thebelab-button:active { - color: #368ce2; - } - - #thebelab-activate-button { - background-color: #383838; - } - - #thebelab-activate-button:active { - color: #368ce2; - } - - .thebelab-cell .jp-OutputArea-output { - color: white; - background-color: black; - } - - .thebelab-cell .jp-OutputArea-output pre { - color: white; - background-color: black; - } + body[data-theme="auto"] { /* the same styles with body[data-theme="dark"] */ + .jupyter_container { + color: white; + background-color: black; + } + + .jupyter_container .highlight { + background-color: black; + } + + .thebelab-button { + color: #d0d0d0; + background-color: #383838; + } + + .thebelab-button:active { + color: #368ce2; + } + + #thebelab-activate-button { + background-color: #383838; + } + + #thebelab-activate-button:active { + color: #368ce2; + } + + .thebelab-cell .jp-OutputArea-output { + color: white; + background-color: black; + } + + .thebelab-cell .jp-OutputArea-output pre { + color: white; + background-color: black; } + } } From 7792961084750045b22c5d0756b82732ff08ee91 Mon Sep 17 00:00:00 2001 From: Gustavo Rama Date: Thu, 11 Sep 2014 08:11:10 -0300 Subject: [PATCH 234/494] Eliminates the use of matrix constructor in internal loop of the function sage.quadratic_forms.ternary._reduced_ternary_form_eisenstein_with_matrix. --- src/sage/quadratic_forms/ternary.pyx | 183 +++++++++++++++++++-------- 1 file changed, 128 insertions(+), 55 deletions(-) diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx index ddcfbfdb6a9..37d2e17105a 100644 --- a/src/sage/quadratic_forms/ternary.pyx +++ b/src/sage/quadratic_forms/ternary.pyx @@ -67,23 +67,31 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): sage: Q(M) == Qr True """ - M = identity_matrix(3) + # M = identity_matrix(3) + # M = matrix(ZZ, 3, [m11, m12, m13, m21, m22, m23, m31, m32, m33]) + m11, m12, m13, m21, m22, m23, m31, m32, m33 = 1, 0, 0, 0, 1, 0, 0, 0, 1 loop = True while loop: # adjust - v = a1+a2+a23+a13+a12 - if v < 0: - M *= matrix(ZZ, 3, [1, 0, 1, 0, 1, 1, 0, 0, 1]) + v = a1 + a2 + a23 + a13 + a12 + if (v < 0): + # M *= matrix(ZZ, 3, [1, 0, 1, 0, 1, 1, 0, 0, 1]) + [m13] = [m11 + m12 + m13] + [m23] = [m21 + m22 + m23] + [m33] = [m31 + m32 + m33] a3 += v - a23 += a12+2*a2 - a13 += a12+2*a1 + a23 += a12 + 2*a2 + a13 += a12 + 2*a1 # cuadred 12 m = red_mfact(a1, a12) - M *= matrix(ZZ, 3, [1, m, 0, 0, 1, 0, 0, 0, 1]) + # M *= matrix(ZZ, 3, [1, m, 0, 0, 1, 0, 0, 0, 1]) + [m12] = [m*m11 + m12] + [m22] = [m*m21 + m22] + [m32] = [m*m31 + m32] t = a1*m a12 += t a2 += a12*m @@ -92,7 +100,10 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): # cuadred 23 m = red_mfact(a2, a23) - M *= matrix(ZZ, 3, [1, 0, 0, 0, 1, m, 0, 0, 1]) + # M *= matrix(ZZ, 3, [1, 0, 0, 0, 1, m, 0, 0, 1]) + [m13] = [m*m12 + m13] + [m23] = [m*m22 + m23] + [m33] = [m*m32 + m33] t = a2*m a23 += t a3 += a23*m @@ -101,7 +112,10 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): # cuadred 13 m = red_mfact(a1, a13) - M *= matrix(ZZ, 3, [1, 0, m, 0, 1, 0, 0, 0, 1]) + # M *= matrix(ZZ, 3, [1, 0, m, 0, 1, 0, 0, 0, 1]) + [m13] = [m*m11 + m13] + [m23] = [m*m21 + m23] + [m33] = [m*m31 + m33] t = a1*m a13 += t a3 += a13*m @@ -110,19 +124,28 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): # order 12 if a1 > a2 or (a1 == a2 and abs(a23) > abs(a13)): - M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + # M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + [m11, m12, m13] = [-m12, -m11, -m13] + [m21, m22, m23] = [-m22, -m21, -m23] + [m31, m32, m33] = [-m32, -m31, -m33] [a1, a2] = [a2, a1] [a13, a23] = [a23, a13] # order 23 if a2 > a3 or (a2 == a3 and abs(a13) > abs(a12)): - M *= matrix(ZZ, 3, [-1, 0, 0, 0, 0, -1, 0, -1, 0]) + # M *= matrix(ZZ, 3, [-1, 0, 0, 0, 0, -1, 0, -1, 0]) + [m11, m12, m13] = [-m11, -m13, -m12] + [m21, m22, m23] = [-m21, -m23, -m22] + [m31, m32, m33] = [-m31, -m33, -m32] [a2, a3] = [a3, a2] [a13, a12] = [a12, a13] # order 12 if a1 > a2 or (a1 == a2 and abs(a23) > abs(a13)): - M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + # M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + [m11, m12, m13] = [-m12, -m11, -m13] + [m21, m22, m23] = [-m22, -m21, -m23] + [m31, m32, m33] = [-m32, -m31, -m33] [a1, a2] = [a2, a1] [a13, a23] = [a23, a13] @@ -130,110 +153,160 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): if a23*a13*a12 > 0: # a23, a13, a12 positive - if a23 < 0: - M *= diagonal_matrix([-1, 1, 1]) + if (a23 < 0): + # M *= diagonal_matrix([-1, 1, 1]) + m11 = -m11 + m21 = -m21 + m31 = -m31 a23 = -a23 - if a13 < 0: - M *= diagonal_matrix([1, -1, 1]) - a13 = -a13 - if a12 < 0: - M *= diagonal_matrix([1, 1, -1]) + if (a13 < 0): + # M *= diagonal_matrix([1, -1, 1]) + m12 = -m12 + m22 = -m22 + m32 = -m32 + a13=-a13 + if (a12 < 0): + # M *= diagonal_matrix([1, 1, -1]) + m13 = -m13 + m23 = -m23 + m33 = -m33 a12 = -a12 else: # a23, a13, a12 nonpositive [s1, s2, s3] = [a23 > 0, a13 > 0, a12 > 0] - if (s1+s2+s3) % 2: + if (s1 + s2 + s3) % 2: if a23 == 0: s1 = 1 else: if a13 == 0: s2 = 1 else: - if a12 == 0: + if (a12 == 0): s3 = 1 if s1: - M *= diagonal_matrix([-1, 1, 1]) - a23 = -a23 + # M *= diagonal_matrix([-1, 1, 1]) + m11 = -m11 + m21 = -m21 + m31 = -m31 + a23 = -a23 if s2: - M *= diagonal_matrix([1, -1, 1]) - a13 = -a13 + # M *= diagonal_matrix([1, -1, 1]) + m12 = -m12 + m22 = -m22 + m32 = -m32 + a13 = -a13 if s3: - M *= diagonal_matrix([1, 1, -1]) - a12 = -a12 + # M *= diagonal_matrix([1, 1, -1]) + m13 = -m13 + m23 = -m23 + m33 = -m33 + a12 = -a12 - loop = not (abs(a23) <= a2 and abs(a13) <= a1 and abs(a12) <= a1 and a1+a2+a23+a13+a12 >= 0) + loop = not (abs(a23) <= a2 and abs(a13) <= a1 and abs(a12) <= a1 and a1 + a2 + a23 + a13 + a12 >= 0) # adj 3 - if a1+a2+a23+a13+a12 == 0 and 2*a1+2*a13+a12 > 0: - M *= matrix(ZZ, 3, [-1, 0, 1, 0, -1, 1, 0, 0, 1]) - # a3 += a1+a2+a23+a13+a12 - a23 = -2*a2-a23-a12 - a13 = -2*a1-a13-a12 + if a1 + a2 + a23 + a13 + a12 == 0 and 2*a1 + 2*a13 + a12 > 0: + # M *= matrix(ZZ, 3, [-1, 0, 1, 0, -1, 1, 0, 0, 1]) + [m11, m12, m13] = [-m11, -m12, m11 + m12 + m13] + [m21, m22, m23] = [-m21, -m22, m21 + m22 + m23] + [m31, m32, m33] = [-m31, -m32, m31 + m32 + m33] + # a3 += a1+a2+a23+a13+a12 = 0 + a23 = -2*a2 - a23 - a12 + a13 = -2*a1 - a13 - a12 # adj 5.12 if a1 == -a12 and a13 != 0: - M *= matrix(ZZ, 3, [-1, -1, 0, 0, -1, 0, 0, 0, 1]) - # a2 += a1+a12 - a23 = -a23-a13 + # M *= matrix(ZZ, 3, [-1, -1, 0, 0, -1, 0, 0, 0, 1]) + [m11, m12] = [-m11, -m11 - m12] + [m21, m22] = [-m21, -m21 - m22] + [m31, m32] = [-m31, -m31 - m32] + # a2 += a1 + a12 = 0 + a23 = -a23 - a13 a13 = -a13 - a12 = -a12 # = 2*a1+a12 + a12 = -a12 # = 2*a1 + a12 # adj 5.13 if a1 == -a13 and a12 != 0: - M *= matrix(ZZ, 3, [-1, 0, -1, 0, 1, 0, 0, 0, -1]) - # a3 += a1+a13 - a23 = -a23-a12 - a13 = -a13 # = 2*a1+a13 + # M *= matrix(ZZ, 3, [-1, 0, -1, 0, 1, 0, 0, 0, -1]) + [m11, m13] = [-m11, -m11 - m13] + [m21, m23] = [-m21, -m21 - m23] + [m31, m33] = [-m31, -m31 - m33] + # a3 += a1 + a13 = 0 + a23 = -a23 - a12 + a13 = -a13 # = 2*a1 + a13 a12 = -a12 # adj 5.23 if a2 == -a23 and a12 != 0: - M *= matrix(ZZ, 3, [1, 0, 0, 0, -1, -1, 0, 0, -1]) - # a3 += a2+a23 - a23 = -a23 # = 2*a2+a23 - a13 = -a13-a12 + # M *= matrix(ZZ, 3, [1, 0, 0, 0, -1, -1, 0, 0, -1]) + [m12, m13] = [-m12, -m12 - m13] + [m22, m23] = [-m22, -m22 - m23] + [m32, m33] = [-m32, -m32 - m33] + # a3 += a2 + a23 = 0 + a23 = -a23 # = 2*a2 + a23 + a13 = -a13 - a12 a12 = -a12 # adj 4.12 if a1 == a12 and a13 > 2*a23: - M *= matrix(ZZ, 3, [-1, -1, 0, 0, 1, 0, 0, 0, -1]) - # a 2 += a1-a12 + # M *= matrix(ZZ, 3, [-1, -1, 0, 0, 1, 0, 0, 0, -1]) + [m11, m12, m13] = [-m11, -m11 + m12, -m13] + [m21, m22, m23] = [-m21, -m21 + m22, -m23] + [m31, m32, m33] = [-m31, -m31 + m32, -m33] + # a2 += a1 - a12 = 0 a23 = -a23 + a13 # a12 = 2*a1 - a12 # adj 4.13 if a1 == a13 and a12 > 2*a23: - M *= matrix(ZZ, 3, [-1, 0, -1, 0, -1, 0, 0, 0, 1]) - # a3 += a1-a13 + # M *= matrix(ZZ, 3, [-1, 0, -1, 0, -1, 0, 0, 0, 1]) + [m11, m12, m13] = [-m11, -m12, -m11 + m13] + [m21, m22, m23] = [-m21, -m22, -m21 + m23] + [m31, m32, m33] = [-m31, -m32, -m31 + m33] + # a3 += a1 - a13 = 0 a23 = -a23 + a12 # a13 = 2*a1 - a13 # adj 4.23 if a2 == a23 and a12 > 2*a13: - M *= matrix(ZZ, 3, [-1, 0, 0, 0, -1, -1, 0, 0, 1]) - # a3 += a2-a23 + # M *= matrix(ZZ, 3, [-1, 0, 0, 0, -1, -1, 0, 0, 1]) + [m11, m12, m13] = [-m11, -m12, -m12 + m13] + [m21, m22, m23] = [-m21, -m22, -m22 + m23] + [m31, m32, m33] = [-m31, -m32, -m32 + m33] + # a3 += a2 - a23 = 0 # a23 = 2*a2 - a23 a13 = -a13 + a12 # order 12 if a1 == a2 and abs(a23) > abs(a13): - M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + # M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + [m11, m12, m13] = [-m12, -m11, -m13] + [m21, m22, m23] = [-m22, -m21, -m23] + [m31, m32, m33] = [-m32, -m31, -m33] [a1, a2] = [a2, a1] [a13, a23] = [a23, a13] # order 23 if a2 == a3 and abs(a13) > abs(a12): - M *= matrix(ZZ, 3, [-1, 0, 0, 0, 0, -1, 0, -1, 0]) + # M *= matrix(ZZ, 3, [-1, 0, 0, 0, 0, -1, 0, -1, 0]) + [m11, m12, m13] = [-m11, -m13, -m12] + [m21, m22, m23] = [-m21, -m23, -m22] + [m31, m32, m33] = [-m31, -m33, -m32] [a13, a12] = [a12, a13] # order 12 if a1 == a2 and abs(a23) > abs(a13): - M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + # M *= matrix(ZZ, 3, [0, -1, 0, -1, 0, 0, 0, 0, -1]) + [m11, m12, m13] = [-m12, -m11, -m13] + [m21, m22, m23] = [-m22, -m21, -m23] + [m31, m32, m33] = [-m32, -m31, -m33] [a13, a23] = [a23, a13] - return (a1, a2, a3, a23, a13, a12), M + return (a1, a2, a3, a23, a13, a12), \ + matrix(ZZ, 3, (m11, m12, m13, m21, m22, m23, m31, m32, m33)) + def _reduced_ternary_form_eisenstein_without_matrix(a1, a2, a3, a23, a13, a12): From 8272fe53250ca6c354749b97c13faba20f25caeb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 26 Oct 2023 11:48:29 -0700 Subject: [PATCH 235/494] src/sage/misc/cython.py: Fix the workaround for setuptools_scm in the runtime env --- src/sage/misc/cython.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 5631cc092e3..c0c803bf943 100644 --- a/src/sage/misc/cython.py +++ b/src/sage/misc/cython.py @@ -421,7 +421,7 @@ def cython(filename, verbose=0, compile_message=False, os.curdir) # This emulates running "setup.py build" with the correct options - dist = Distribution() + # # setuptools plugins considered harmful: # If build isolation is not in use and setuptools_scm is installed, # then its file_finders entry point is invoked, which we don't need. @@ -429,7 +429,12 @@ def cython(filename, verbose=0, compile_message=False, # LookupError: pyproject.toml does not contain a tool.setuptools_scm section # LookupError: setuptools-scm was unable to detect version ... # We just remove all handling of "setuptools.finalize_distribution_options" entry points. - dist._removed = staticmethod(lambda ep: True) + class Distribution_no_finalize_distribution_options(Distribution): + @staticmethod + def _removed(ep): + return True + + dist = Distribution_no_finalize_distribution_options() dist.ext_modules = [ext] dist.include_dirs = includes buildcmd = dist.get_command_obj("build") From 857741c73aaec03fc577c2b794e00a0948532a0d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 27 Oct 2023 08:28:31 +0900 Subject: [PATCH 236/494] Live doc for CI is left for further discussion --- .github/workflows/doc-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index c71e60dae36..dbd8c99ff30 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -102,8 +102,6 @@ jobs: run: | set -ex export SAGE_USE_CDNS=yes - export SAGE_LIVE_DOC=yes - export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env/dev mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc make doc-clean doc-uninstall mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git From e3a46ed56a5edca89d36c3f6b5fe56d995bb927a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 26 Oct 2023 22:29:06 -0300 Subject: [PATCH 237/494] Fix linter in previous commit --- src/sage/quadratic_forms/ternary.pyx | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx index 37d2e17105a..28dd9514c30 100644 --- a/src/sage/quadratic_forms/ternary.pyx +++ b/src/sage/quadratic_forms/ternary.pyx @@ -164,7 +164,7 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): m12 = -m12 m22 = -m22 m32 = -m32 - a13=-a13 + a13 = -a13 if (a12 < 0): # M *= diagonal_matrix([1, 1, -1]) m13 = -m13 @@ -186,23 +186,23 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): if (a12 == 0): s3 = 1 if s1: - # M *= diagonal_matrix([-1, 1, 1]) - m11 = -m11 - m21 = -m21 - m31 = -m31 - a23 = -a23 + # M *= diagonal_matrix([-1, 1, 1]) + m11 = -m11 + m21 = -m21 + m31 = -m31 + a23 = -a23 if s2: - # M *= diagonal_matrix([1, -1, 1]) - m12 = -m12 - m22 = -m22 - m32 = -m32 - a13 = -a13 + # M *= diagonal_matrix([1, -1, 1]) + m12 = -m12 + m22 = -m22 + m32 = -m32 + a13 = -a13 if s3: - # M *= diagonal_matrix([1, 1, -1]) - m13 = -m13 - m23 = -m23 - m33 = -m33 - a12 = -a12 + # M *= diagonal_matrix([1, 1, -1]) + m13 = -m13 + m23 = -m23 + m33 = -m33 + a12 = -a12 loop = not (abs(a23) <= a2 and abs(a13) <= a1 and abs(a12) <= a1 and a1 + a2 + a23 + a13 + a12 >= 0) @@ -308,7 +308,6 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12): matrix(ZZ, 3, (m11, m12, m13, m21, m22, m23, m31, m32, m33)) - def _reduced_ternary_form_eisenstein_without_matrix(a1, a2, a3, a23, a13, a12): """ Find the coefficients of the equivalent unique reduced ternary form according to the conditions From 092186f8cfdf05c2557cdfd3787cdbd4990f610c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 27 Oct 2023 09:16:49 +0200 Subject: [PATCH 238/494] fix failing doctests --- src/sage/combinat/permutation.py | 2 +- src/sage/groups/matrix_gps/coxeter_group.py | 8 ++++---- src/sage/groups/perm_gps/permgroup_named.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 8b3d1899ba0..eb3e451b0ff 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -7268,7 +7268,7 @@ def algebra(self, base_ring, category=None): Symmetric group algebra of order 4 over Rational Field sage: A.category() # optional - sage.combinat sage.modules - Join of Category of coxeter group algebras over Rational Field + Join of Category of Coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field diff --git a/src/sage/groups/matrix_gps/coxeter_group.py b/src/sage/groups/matrix_gps/coxeter_group.py index 27d65a55a37..6b865805298 100644 --- a/src/sage/groups/matrix_gps/coxeter_group.py +++ b/src/sage/groups/matrix_gps/coxeter_group.py @@ -253,11 +253,11 @@ def __init__(self, coxeter_matrix, base_ring, index_set): We check that :trac:`16630` is fixed:: sage: CoxeterGroup(['D',4], base_ring=QQ).category() - Category of finite irreducible coxeter groups + Category of finite irreducible Coxeter groups sage: # needs sage.rings.number_field sage: CoxeterGroup(['H',4], base_ring=QQbar).category() - Category of finite irreducible coxeter groups + Category of finite irreducible Coxeter groups sage: F = CoxeterGroups().Finite() sage: all(CoxeterGroup([letter,i]) in F ....: for i in range(2,5) for letter in ['A','B','D']) @@ -265,9 +265,9 @@ def __init__(self, coxeter_matrix, base_ring, index_set): sage: all(CoxeterGroup(['E',i]) in F for i in range(6,9)) True sage: CoxeterGroup(['F',4]).category() - Category of finite irreducible coxeter groups + Category of finite irreducible Coxeter groups sage: CoxeterGroup(['G',2]).category() - Category of finite irreducible coxeter groups + Category of finite irreducible Coxeter groups sage: all(CoxeterGroup(['H',i]) in F for i in range(3,5)) True sage: all(CoxeterGroup(['I',i]) in F for i in range(2,5)) diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index cc49efd505c..5052880e99e 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -640,7 +640,7 @@ def algebra(self, base_ring, category=None): We illustrate the choice of the category:: sage: A.category() # needs sage.combinat - Join of Category of coxeter group algebras over Rational Field + Join of Category of Coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field From 8aba6092521d403bcacad12aa7086be5ce585a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 27 Oct 2023 09:55:35 +0200 Subject: [PATCH 239/494] refresh the file cluster_algebra --- src/sage/algebras/cluster_algebra.py | 118 ++++++++++++++------------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py index 14669dfed5c..880814feba7 100644 --- a/src/sage/algebras/cluster_algebra.py +++ b/src/sage/algebras/cluster_algebra.py @@ -297,15 +297,16 @@ which might not be a good idea in algebras that are too big. One workaround is to first disable F-polynomials and then recompute only the desired mutations:: - sage: A.reset_exploring_iterator(mutating_F=False) # long time - sage: v = (-1, 1, -2, 2, -1, 1, -1, 1, 1) # long time - sage: seq = A.find_g_vector(v); seq # long time random + sage: # long time + sage: A.reset_exploring_iterator(mutating_F=False) + sage: v = (-1, 1, -2, 2, -1, 1, -1, 1, 1) + sage: seq = A.find_g_vector(v); seq # random [1, 0, 2, 6, 5, 4, 3, 8, 1] - sage: S = A.initial_seed().mutate(seq, inplace=False) # long time - sage: v in S.g_vectors() # long time + sage: S = A.initial_seed().mutate(seq, inplace=False) + sage: v in S.g_vectors() True - sage: A.current_seed().mutate(seq) # long time - sage: A.F_polynomial((-1, 1, -2, 2, -1, 1, -1, 1, 1)) # long time + sage: A.current_seed().mutate(seq) + sage: A.F_polynomial((-1, 1, -2, 2, -1, 1, -1, 1, 1)) u0*u1^2*u2^2*u3*u4*u5*u6*u8 + ... 2*u2 + u4 + u6 + 1 @@ -445,7 +446,7 @@ def _div_(self, other): """ return self.lift() / other.lift() - def d_vector(self): + def d_vector(self) -> tuple: r""" Return the denominator vector of ``self`` as a tuple of integers. @@ -461,7 +462,7 @@ def d_vector(self): minimal = map(min, zip(*monomials)) return tuple(-vector(minimal))[:self.parent().rank()] - def _repr_(self): + def _repr_(self) -> str: r""" Return the string representation of ``self``. @@ -524,7 +525,7 @@ def F_polynomial(self): subs_dict[A.coefficient(i).lift()] = A._U.gen(i) return A._U(self.lift().substitute(subs_dict)) - def is_homogeneous(self): + def is_homogeneous(self) -> bool: r""" Return ``True`` if ``self`` is a homogeneous element of ``self.parent()``. @@ -540,7 +541,7 @@ def is_homogeneous(self): """ return getattr(self, '_is_homogeneous', len(self.homogeneous_components()) == 1) - def homogeneous_components(self): + def homogeneous_components(self) -> dict: r""" Return a dictionary of the homogeneous components of ``self``. @@ -599,10 +600,10 @@ def theta_basis_decomposition(self): A = self.parent() B = A.b_matrix() U = A._U - out = dict() + out = {} zero_A = A(0) zero_U = U(0) - zero_t = (0,)*A.rank() + zero_t = (0,) * A.rank() components = self.homogeneous_components() @@ -612,12 +613,13 @@ def theta_basis_decomposition(self): while f_poly != zero_U: y_exp = min(f_poly.dict()) coeff = f_poly.dict()[y_exp] - g_theta = tuple(g_vect + B*vector(y_exp)) - out[g_theta] = out.get(g_theta, zero_A) + A({zero_t + tuple(y_exp):coeff}) - f_poly -= U({y_exp:coeff}) * A.theta_basis_F_polynomial(g_theta) + g_theta = tuple(g_vect + B * vector(y_exp)) + out[g_theta] = out.get(g_theta, zero_A) + A({zero_t + tuple(y_exp): coeff}) + f_poly -= U({y_exp: coeff}) * A.theta_basis_F_polynomial(g_theta) return out + ############################################################################## # Seeds ############################################################################## @@ -721,7 +723,7 @@ def __eq__(self, other): self.parent() == other.parent() and frozenset(self.g_vectors()) == frozenset(other.g_vectors())) - def __contains__(self, element): + def __contains__(self, element) -> bool: r""" Test whether ``element`` belong to ``self``. @@ -770,7 +772,7 @@ def __hash__(self): """ return hash(frozenset(self.g_vectors())) - def _repr_(self): + def _repr_(self) -> str: r""" Return the string representation of ``self``. @@ -790,12 +792,11 @@ def _repr_(self): and no coefficients over Integer Ring obtained from the initial by mutating along the sequence [0, 1] """ - if self._path == []: + if not self._path: return "The initial seed of a %s" % str(self.parent())[2:] - elif len(self._path) == 1: + if len(self._path) == 1: return "The seed of a %s obtained from the initial by mutating in direction %s" % (str(self.parent())[2:], str(self._path[0])) - else: - return "The seed of a %s obtained from the initial by mutating along the sequence %s" % (str(self.parent())[2:], str(self._path)) + return "The seed of a %s obtained from the initial by mutating along the sequence %s" % (str(self.parent())[2:], str(self._path)) def parent(self): r""" @@ -809,7 +810,7 @@ def parent(self): """ return self._parent - def depth(self): + def depth(self) -> int: r""" Return the length of a mutation sequence from the initial seed of :meth:`parent` to ``self``. @@ -836,7 +837,7 @@ def depth(self): """ return len(self._path) - def path_from_initial_seed(self): + def path_from_initial_seed(self) -> list: r""" Return a mutation sequence from the initial seed of :meth:`parent` to ``self``. @@ -892,7 +893,7 @@ def c_matrix(self): """ return copy(self._C) - def c_vector(self, j): + def c_vector(self, j) -> tuple: r""" Return the ``j``-th c-vector of ``self``. @@ -915,7 +916,7 @@ def c_vector(self, j): """ return tuple(self._C.column(j)) - def c_vectors(self): + def c_vectors(self) -> list[tuple]: r""" Return all the c-vectors of ``self``. @@ -943,7 +944,7 @@ def g_matrix(self): """ return copy(self._G) - def g_vector(self, j): + def g_vector(self, j) -> tuple: r""" Return the ``j``-th g-vector of ``self``. @@ -961,7 +962,7 @@ def g_vector(self, j): """ return tuple(self._G.column(j)) - def g_vectors(self): + def g_vectors(self) -> list[tuple]: r""" Return all the g-vectors of ``self``. @@ -992,7 +993,7 @@ def F_polynomial(self, j): """ return self.parent().F_polynomial(self.g_vector(j)) - def F_polynomials(self): + def F_polynomials(self) -> list: r""" Return all the F-polynomials of ``self``. @@ -1026,7 +1027,7 @@ def cluster_variable(self, j): """ return self.parent().cluster_variable(self.g_vector(j)) - def cluster_variables(self): + def cluster_variables(self) -> list: r""" Return all the cluster variables of ``self``. @@ -1105,7 +1106,7 @@ def mutate(self, direction, **kwargs): for k in seq: if k not in range(n): - raise ValueError('cannot mutate in direction ' + str(k)) + raise ValueError(f'cannot mutate in direction {k}') # store new mutation path if to_mutate._path and to_mutate._path[-1] == k: @@ -1329,8 +1330,9 @@ def __classcall__(self, data, **kwargs): # kwargs['cluster_variable_prefix']+str(j) is not the name of an # initial cluster variable nor a coefficient. This will be used in # mutate_initial to name new cluster variables. - splitnames = map(lambda w: w.partition(kwargs['cluster_variable_prefix']), - kwargs['cluster_variable_names'] + kwargs['coefficient_names']) + splitnames = (w.partition(kwargs['cluster_variable_prefix']) + for w in + kwargs['cluster_variable_names'] + kwargs['coefficient_names']) nfi = 1 + max((int(v) for u, _, v in splitnames if u == '' and v.isdigit()), default=-1) kwargs.setdefault('next_free_index', nfi) @@ -1412,7 +1414,7 @@ def __init__(self, B, **kwargs): embedding = SetMorphism(Hom(self, self.ambient()), lambda x: x.lift()) self._populate_coercion_lists_(embedding=embedding) - def _repr_(self): + def _repr_(self) -> str: r""" Return the string representation of ``self``. @@ -1542,14 +1544,14 @@ def coxeter_element(self): ... ValueError: the initial exchange matrix is not acyclic """ - dg = DiGraph(self.b_matrix().apply_map(lambda x: ZZ(0) if x <= 0 else ZZ(1))) + dg = DiGraph(self.b_matrix().apply_map(lambda x: ZZ.zero() if x <= 0 else ZZ.one())) acyclic, coxeter = dg.is_directed_acyclic(certificate=True) if not acyclic: raise ValueError("the initial exchange matrix is not acyclic") return coxeter @cached_method - def is_acyclic(self): + def is_acyclic(self) -> bool: r""" Return ``True`` if the exchange matrix in the initial seed is acyclic, ``False`` otherwise. @@ -1562,7 +1564,7 @@ def is_acyclic(self): sage: A.is_acyclic() False """ - dg = DiGraph(self.b_matrix().apply_map(lambda x: ZZ(0) if x <= 0 else ZZ(1))) + dg = DiGraph(self.b_matrix().apply_map(lambda x: ZZ.zero() if x <= 0 else ZZ.one())) return dg.is_directed_acyclic() def rank(self): @@ -1667,7 +1669,7 @@ def clear_computed_data(self): self.reset_current_seed() self.reset_exploring_iterator() - def contains_seed(self, seed): + def contains_seed(self, seed) -> bool: r""" Test if ``seed`` is a seed of ``self``. @@ -1741,9 +1743,9 @@ def euler_matrix(self): """ if not self.is_acyclic(): raise ValueError("the initial exchange matrix is not acyclic") - return 1 + self.b_matrix().apply_map(lambda x: min(ZZ(0), x)) + return 1 + self.b_matrix().apply_map(lambda x: min(ZZ.zero(), x)) - def d_vector_to_g_vector(self, d): + def d_vector_to_g_vector(self, d) -> tuple: r""" Return the g-vector of an element of ``self`` having d-vector ``d`` @@ -1765,11 +1767,11 @@ def d_vector_to_g_vector(self, d): sage: A.d_vector_to_g_vector((1,0,-1)) (-1, 1, 2) """ - dm = vector(( x if x < 0 else 0 for x in d)) + dm = vector((x if x < 0 else 0 for x in d)) dp = vector(d) - dm - return tuple(- dm - self.euler_matrix()*dp) + return tuple(- dm - self.euler_matrix() * dp) - def g_vector_to_d_vector(self, g): + def g_vector_to_d_vector(self, g) -> tuple: r""" Return the d-vector of an element of ``self`` having g-vector ``g`` @@ -1797,8 +1799,8 @@ def g_vector_to_d_vector(self, g): g = vector(g) for i in c: dp[i] = -min(g[i], 0) - g += min(g[i],0)*E.column(i) - return tuple(-g+dp) + g += min(g[i], 0) * E.column(i) + return tuple(-g + dp) def g_vectors(self, mutating_F=True): r""" @@ -1872,7 +1874,7 @@ def F_polynomials(self): """ return map(self.F_polynomial, self.g_vectors()) - def g_vectors_so_far(self): + def g_vectors_so_far(self) -> list: r""" Return a list of the g-vectors of cluster variables encountered so far. @@ -1886,7 +1888,7 @@ def g_vectors_so_far(self): """ return list(self._path_dict) - def cluster_variables_so_far(self): + def cluster_variables_so_far(self) -> list: r""" Return a list of the cluster variables encountered so far. @@ -1900,7 +1902,7 @@ def cluster_variables_so_far(self): """ return [self.cluster_variable(v) for v in self.g_vectors_so_far()] - def F_polynomials_so_far(self): + def F_polynomials_so_far(self) -> list: r""" Return a list of the F-polynomials encountered so far. @@ -2120,7 +2122,7 @@ def coefficient(self, j): return self.retract(self.base().gen(j)) @cached_method - def coefficients(self): + def coefficients(self) -> tuple: r""" Return the list of coefficients of ``self``. @@ -2138,7 +2140,7 @@ def coefficients(self): else: return () - def coefficient_names(self): + def coefficient_names(self) -> tuple: r""" Return the list of coefficient names. @@ -2174,7 +2176,7 @@ def initial_cluster_variable(self, j): return self.retract(self.ambient().gen(j)) @cached_method - def initial_cluster_variables(self): + def initial_cluster_variables(self) -> tuple: r""" Return the list of initial cluster variables of ``self``. @@ -2186,7 +2188,7 @@ def initial_cluster_variables(self): """ return tuple(map(self.retract, self.ambient().gens()[:self.rank()])) - def initial_cluster_variable_names(self): + def initial_cluster_variable_names(self) -> tuple: r""" Return the list of initial cluster variable names. @@ -2661,17 +2663,17 @@ def theta_basis_F_polynomial(self, g_vector): raise NotImplementedError("currently only implemented for cluster algebras of rank 2") # extract the part of g_vector not coming from the initial cluster - d = tuple( max(x, 0) for x in self.g_vector_to_d_vector(g_vector) ) + d = tuple(max(x, 0) for x in self.g_vector_to_d_vector(g_vector)) g = self.d_vector_to_g_vector(d) - shifts = ((d[0]+g[0])/self._B0[0, 1], (d[1]+g[1])/self._B0[1, 0] ) + shifts = ((d[0] + g[0]) / self._B0[0, 1], (d[1] + g[1]) / self._B0[1, 0]) signs = (self._B0[0, 1].sign(), self._B0[1, 0].sign()) u = list(self._U.gens()) output = self._U.zero() - for p in range(0, d[1] + 1): - for q in range(0, d[0] + 1): - output += self._greedy_coefficient(d, p, q) * u[1] ** (signs[0]*p - shifts[0]) * u[0] ** (signs[1]*q - shifts[1]) + for p in range(d[1] + 1): + for q in range(d[0] + 1): + output += self._greedy_coefficient(d, p, q) * u[1] ** (signs[0] * p - shifts[0]) * u[0] ** (signs[1] * q - shifts[1]) return output @cached_method @@ -2696,7 +2698,7 @@ def _greedy_coefficient(self, d_vector, p, q): p = Integer(p) q = Integer(q) if p == 0 and q == 0: - return Integer(1) + return ZZ.one() sum1 = 0 for k in range(1, p + 1): bino = 0 From 6ab1f923b500023b9a071a659bad4bf5ef2f751a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Fri, 27 Oct 2023 11:53:49 -0300 Subject: [PATCH 240/494] Revert "disable legacy_implicit_noexcept" This reverts commit 131b74759329d4d48dd8e60f1b3120dd36ff5e04. --- src/sage_setup/cython_options.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage_setup/cython_options.py b/src/sage_setup/cython_options.py index edeb1c43aad..9725ce0e1af 100644 --- a/src/sage_setup/cython_options.py +++ b/src/sage_setup/cython_options.py @@ -20,6 +20,7 @@ def compiler_directives(profile: bool): fast_getattr=True, # Use Python 3 (including source code semantics) for module compilation language_level="3", + legacy_implicit_noexcept=True, # Enable support for late includes (make declarations in Cython code available to C include files) preliminary_late_includes_cy28=True, # Add hooks for Python profilers into the compiled C code From 5152b802d800c7062ba5cc2956f4cc618bd9a86f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 27 Oct 2023 12:14:12 -0700 Subject: [PATCH 241/494] src/doc/en/developer: Describe static typing workflow --- src/doc/en/developer/coding_in_python.rst | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/doc/en/developer/coding_in_python.rst b/src/doc/en/developer/coding_in_python.rst index d96106ecc98..e14ff94660e 100644 --- a/src/doc/en/developer/coding_in_python.rst +++ b/src/doc/en/developer/coding_in_python.rst @@ -585,6 +585,53 @@ by return initialize_big_data() +Static typing +============= + +Python libraries are increasingly annotated with static typing information; +see the `Python reference on typing `. + +For typechecking the Sage library, the project uses :ref:`pyright `; +it automatically runs in the GitHub Actions CI and can also be run locally. + +As of Sage 10.2, the Sage library only contains a minimal set of such type +annotations. Pull requests that add more annotations are generally welcome. + +The Sage library makes very extensive use of Cython (see chapter :ref:`_chapter-cython`). +Although Cython source code often declares static types for the purpose of +compilation to efficient machine code, this typing information is unfortunately +not visible to static checkers such as Pyright. It is necessary to create `type stub +files (".pyi") `_ +that provide this information. Although various +`tools for writing and maintaining type stub files +`_ +are available, creating stub files for Cython files involves manual work. + +For Cython modules of the Sage library, these type stub files should be placed +next to the ``.pyx`` and ``.pxd`` files. + +When importing from other Python libraries that do not provide sufficient typing +information, it is possible to augment the library's typing information for +the purposes of typechecking the Sage library: + +- Create typestub files and place them in the directory ``SAGE_ROOT/src/typings``. + For example, the distribution **pplpy** provides the top-level package :mod:`ppl`, + which publishes no typing information. We can create a typestub file + ``SAGE_ROOT/src/typings/ppl.pyi`` or ``SAGE_ROOT/src/typings/ppl/__init__.pyi``. + +- When these typestub files are working well, it is preferable from the viewpoint + of the Sage project that they are "upstreamed", i.e., contributed to the + project that maintains the library. If a new version of the upstream library + becomes available that provides the necessary typing information, we can + update the package in the Sage distribution and remove the typestub files again + from ``SAGE_ROOT/src/typings``. + +- As a fallback, when neither adding typing annotations to source files + nor adding typestub files is welcomed by the upstream project, it is possible + to `contribute typestubs files instead to the typeshed community project + `_. + + Deprecation =========== From 1e1109655977f19b94480eba247033a25e602239 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 27 Oct 2023 18:29:20 -0700 Subject: [PATCH 242/494] src/doc/en/developer/coding_in_python.rst: Link to https://github.com/cython/cython/pull/5744 --- src/doc/en/developer/coding_in_python.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/doc/en/developer/coding_in_python.rst b/src/doc/en/developer/coding_in_python.rst index e14ff94660e..b0022186a00 100644 --- a/src/doc/en/developer/coding_in_python.rst +++ b/src/doc/en/developer/coding_in_python.rst @@ -606,8 +606,12 @@ that provide this information. Although various `tools for writing and maintaining type stub files `_ are available, creating stub files for Cython files involves manual work. +There is hope that better tools become available soon, see for example +`cython/cython #5744 `_. +Contributing to the development and testing of such tools likely will have a +greater impact than writing the typestub files manually. -For Cython modules of the Sage library, these type stub files should be placed +For Cython modules of the Sage library, these type stub files would be placed next to the ``.pyx`` and ``.pxd`` files. When importing from other Python libraries that do not provide sufficient typing From 82d6fd18257b55d756f98ed9562fe8665981a0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 28 Oct 2023 11:40:47 +0200 Subject: [PATCH 243/494] care for E702 in fast_arith.pyx --- src/sage/rings/fast_arith.pyx | 191 ++++++++++++++++++++++------------ 1 file changed, 124 insertions(+), 67 deletions(-) diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx index 0eca810920e..d4bb8063304 100644 --- a/src/sage/rings/fast_arith.pyx +++ b/src/sage/rings/fast_arith.pyx @@ -148,8 +148,8 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): """ # input to pari.init_primes cannot be greater than 436273290 (hardcoded bound) DEF init_primes_max = 436273290 - DEF small_prime_max = 436273009 # a prime < init_primes_max (preferably the largest) - DEF prime_gap_bound = 250 # upper bound for gap between primes <= small_prime_max + DEF small_prime_max = 436273009 # a prime < init_primes_max (preferably the largest) + DEF prime_gap_bound = 250 # upper bound for gap between primes <= small_prime_max # make sure that start and stop are integers # First try coercing them. If that does not work, then try rounding them. @@ -160,7 +160,8 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): start = Integer(round(float(start))) except (ValueError, TypeError) as real_error: raise TypeError(str(integer_error) - + "\nand argument is also not real: " + str(real_error)) + + "\nand argument is also not real: " + + str(real_error)) if stop is not None: try: stop = Integer(stop) @@ -169,10 +170,11 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): stop = Integer(round(float(stop))) except (ValueError, TypeError) as real_error: raise ValueError(str(integer_error) - + "\nand argument is also not real: " + str(real_error)) + + "\nand argument is also not real: " + + str(real_error)) if algorithm is None: - # if 'stop' is 'None', need to change it to an integer before comparing with 'start' + # if 'stop' is 'None', neEd to change it to an integer before comparing with 'start' if max(start, stop or 0) <= small_prime_max: algorithm = "pari_primes" else: @@ -183,8 +185,8 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): from sage.libs.pari import pari if max(start, stop or 0) > small_prime_max: - raise ValueError('algorithm "pari_primes" is limited to primes larger than' - + ' {}'.format(small_prime_max - 1)) + raise ValueError('algorithm "pari_primes" is limited to primes ' + f'larger than {small_prime_max - 1}') if stop is None: # In this case, "start" is really stop @@ -206,7 +208,7 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): res = pari_prime_range(start, stop, py_ints) - elif (algorithm == "pari_isprime") or (algorithm == "pari_primes"): + elif algorithm == "pari_isprime" or algorithm == "pari_primes": from sage.arith.misc import primes res = list(primes(start, stop)) else: @@ -227,12 +229,14 @@ cdef class arith_int: cdef int c_gcd_int(self, int a, int b) except -1: cdef int c - if a==0: + if a == 0: return self.abs_int(b) - if b==0: + if b == 0: return self.abs_int(a) - if a<0: a=-a - if b<0: b=-b + if a < 0: + a = -a + if b < 0: + b = -b while b: c = a % b a = b @@ -240,7 +244,7 @@ cdef class arith_int: return a def gcd_int(self, int a, int b): - return self.c_gcd_int(a,b) + return self.c_gcd_int(a, b) cdef int c_xgcd_int(self, int a, int b, int* ss, int* tt) except -1: cdef int psign, qsign, p, q, r, s, c, quot, new_r, new_s @@ -255,19 +259,31 @@ cdef class arith_int: tt[0] = 0 return self.abs_int(a) - psign = 1; qsign = 1 + psign = 1 + qsign = 1 - if a<0: a = -a; psign = -1 - if b<0: b = -b; qsign = -1 + if a < 0: + a = -a + psign = -1 + if b < 0: + b = -b + qsign = -1 - p = 1; q = 0; r = 0; s = 1 + p = 1 + q = 0 + r = 0 + s = 1 while b: - c = a % b; quot = a/b - a = b; b = c + c = a % b + quot = a/b + a = b + b = c new_r = p - quot*r new_s = q - quot*s - p = r; q = s - r = new_r; s = new_s + p = r + q = s + r = new_r + s = new_s ss[0] = p*psign tt[0] = q*qsign @@ -276,13 +292,14 @@ cdef class arith_int: def xgcd_int(self, int a, int b): cdef int g, s, t - g = self.c_xgcd_int(a,b, &s, &t) - return (g,s,t) + g = self.c_xgcd_int(a, b, &s, &t) + return (g, s, t) cdef int c_inverse_mod_int(self, int a, int m) except -1: - if a == 1 or m<=1: return a%m # common special case + if a == 1 or m <= 1: + return a % m # common special case cdef int g, s, t - g = self.c_xgcd_int(a,m, &s, &t) + g = self.c_xgcd_int(a, m, &s, &t) if g != 1: raise ArithmeticError("The inverse of %s modulo %s is not defined." % (a, m)) s = s % m @@ -297,19 +314,21 @@ cdef class arith_int: cdef int u, v, u0, u1, u2, v0, v1, v2, q, t0, t1, t2, x, y cdef float bnd - if m>46340: - raise OverflowError("The modulus m(=%s) should be at most 46340"%m) + if m > 46340: + raise OverflowError(f"The modulus m(={m}) should be at most 46340") a = a % m - if a==0 or m == 0: + if a == 0 or m == 0: n[0] = 0 d[0] = 1 return 0 - if m<0: m = -m - if a<0: a = m - a - if a==1: + if m < 0: + m = -m + if a < 0: + a = m - a + if a == 1: n[0] = 1 d[0] = 1 return 0 @@ -317,17 +336,29 @@ cdef class arith_int: u = m v = a bnd = sqrt(m/2.0) - u0=1; u1=0; u2=u - v0=0; v1=1; v2=v + u0 = 1 + u1 = 0 + u2 = u + v0 = 0 + v1 = 1 + v2 = v while self.abs_int(v2) > bnd: q = u2/v2 # floor is implicit - t0=u0-q*v0; t1=u1-q*v1; t2=u2-q*v2 - u0=v0; u1=v1; u2=v2 - v0=t0; v1=t1; v2=t2 - - x = self.abs_int(v1); y = v2 - if v1<0: y = -1*y - if x<=bnd and self.c_gcd_int(x,y)==1: + t0 = u0-q*v0 + t1 = u1-q*v1 + t2 = u2-q*v2 + u0 = v0 + u1 = v1 + u2 = v2 + v0 = t0 + v1 = t1 + v2 = t2 + + x = self.abs_int(v1) + y = v2 + if v1 < 0: + y = -1*y + if x <= bnd and self.c_gcd_int(x, y) == 1: n[0] = y d[0] = x return 0 @@ -342,7 +373,7 @@ cdef class arith_int: """ cdef int n, d self.c_rational_recon_int(a, m, &n, &d) - return (n,d) + return (n, d) # The long long versions are next. @@ -375,7 +406,7 @@ cdef class arith_llong: return a def gcd_longlong(self, long long a, long long b): - return self.c_gcd_longlong(a,b) + return self.c_gcd_longlong(a, b) cdef long long c_xgcd_longlong(self, long long a, long long b, long long *ss, @@ -392,19 +423,31 @@ cdef class arith_llong: tt[0] = 0 return self.abs_longlong(a) - psign = 1; qsign = 1 + psign = 1 + qsign = 1 - if a<0: a = -a; psign = -1 - if b<0: b = -b; qsign = -1 + if a < 0: + a = -a + psign = -1 + if b < 0: + b = -b + qsign = -1 - p = 1; q = 0; r = 0; s = 1 + p = 1 + q = 0 + r = 0 + s = 1 while b: - c = a % b; quot = a/b - a = b; b = c + c = a % b + quot = a/b + a = b + b = c new_r = p - quot*r new_s = q - quot*s - p = r; q = s - r = new_r; s = new_s + p = r + q = s + r = new_r + s = new_s ss[0] = p*psign tt[0] = q*qsign @@ -413,9 +456,9 @@ cdef class arith_llong: cdef long long c_inverse_mod_longlong(self, long long a, long long m) except -1: cdef long long g, s, t - g = self.c_xgcd_longlong(a,m, &s, &t) + g = self.c_xgcd_longlong(a, m, &s, &t) if g != 1: - raise ArithmeticError("The inverse of %s modulo %s is not defined."%(a,m)) + raise ArithmeticError("The inverse of %s modulo %s is not defined." % (a, m)) s = s % m if s < 0: s = s + m @@ -430,18 +473,20 @@ cdef class arith_llong: cdef float bnd if m > 2147483647: - raise OverflowError("The modulus m(=%s) must be at most 2147483647"%m) + raise OverflowError(f"The modulus m(={m}) must be at most 2147483647") a = a % m - if a==0 or m == 0: + if a == 0 or m == 0: n[0] = 0 d[0] = 1 return 0 - if m<0: m = -m - if a<0: a = m - a - if a==1: + if m < 0: + m = -m + if a < 0: + a = m - a + if a == 1: n[0] = 1 d[0] = 1 return 0 @@ -449,17 +494,29 @@ cdef class arith_llong: u = m v = a bnd = sqrt(m/2.0) - u0=1; u1=0; u2=u - v0=0; v1=1; v2=v + u0 = 1 + u1 = 0 + u2 = u + v0 = 0 + v1 = 1 + v2 = v while self.abs_longlong(v2) > bnd: q = u2/v2 # floor is implicit - t0=u0-q*v0; t1=u1-q*v1; t2=u2-q*v2 - u0=v0; u1=v1; u2=v2 - v0=t0; v1=t1; v2=t2 - - x = self.abs_longlong(v1); y = v2 - if v1<0: y = -1*y - if x<=bnd and self.gcd_longlong(x,y)==1: + t0 = u0-q*v0 + t1 = u1-q*v1 + t2 = u2-q*v2 + u0 = v0 + u1 = v1 + u2 = v2 + v0 = t0 + v1 = t1 + v2 = t2 + + x = self.abs_longlong(v1) + y = v2 + if v1 < 0: + y = -1*y + if x <= bnd and self.gcd_longlong(x, y) == 1: n[0] = y d[0] = x return 0 @@ -474,4 +531,4 @@ cdef class arith_llong: """ cdef long long n, d self.c_rational_recon_longlong(a, m, &n, &d) - return (n,d) + return (n, d) From fefe9f539f7f94485c4c6d5d6a141807fd7da0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6ppe?= Date: Sat, 28 Oct 2023 09:11:57 -0700 Subject: [PATCH 244/494] Fix markup Co-authored-by: Eric Gourgoulhon --- src/doc/en/developer/coding_in_python.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/developer/coding_in_python.rst b/src/doc/en/developer/coding_in_python.rst index b0022186a00..f968250f7ac 100644 --- a/src/doc/en/developer/coding_in_python.rst +++ b/src/doc/en/developer/coding_in_python.rst @@ -589,7 +589,7 @@ Static typing ============= Python libraries are increasingly annotated with static typing information; -see the `Python reference on typing `. +see the `Python reference on typing `_. For typechecking the Sage library, the project uses :ref:`pyright `; it automatically runs in the GitHub Actions CI and can also be run locally. From d811ba566fa703874509a4cbc2e7f835c0938d58 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 12:33:27 -0700 Subject: [PATCH 245/494] pkgs/sagemath-objects/pyproject.toml.m4: Move metadata here from setup.cfg.m4 --- m4/pyproject_toml_metadata.m4 | 20 +++++++++++++++ pkgs/sagemath-objects/pyproject.toml.m4 | 34 +++++++++++++++++++++++++ pkgs/sagemath-objects/setup.cfg.m4 | 31 ---------------------- 3 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 m4/pyproject_toml_metadata.m4 delete mode 100644 pkgs/sagemath-objects/setup.cfg.m4 diff --git a/m4/pyproject_toml_metadata.m4 b/m4/pyproject_toml_metadata.m4 new file mode 100644 index 00000000000..2511fac45f7 --- /dev/null +++ b/m4/pyproject_toml_metadata.m4 @@ -0,0 +1,20 @@ +dnl Standard metadata of SageMath distribution packages +dnl +license = {text = "GNU General Public License (GPL) v2 or later"} +authors = [{name = "The Sage Developers", email = "sage-support@googlegroups.com"}] +classifiers = [ + "Development Status :: 6 - Mature", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering :: Mathematics", +] +urls = {Homepage = "https://www.sagemath.org"} +requires-python = ">=3.9, <3.12" diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 index d8fda57a8f8..1db2cee5257 100644 --- a/pkgs/sagemath-objects/pyproject.toml.m4 +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -11,3 +11,37 @@ requires = [ SPKG_INSTALL_REQUIRES_cysignals ] build-backend = "setuptools.build_meta" + +[project] +name = "sagemath-objects" +description = "Sage: Open Source Mathematics Software: Sage objects, elements, parents, categories, coercion, metaclasses" +dependencies = [ + SPKG_INSTALL_REQUIRES_gmpy2 + SPKG_INSTALL_REQUIRES_cysignals +] +dynamic = ["version"] +include(`pyproject_toml_metadata.m4`) + +[project.optional-dependencies] +# Currently we do not use the sage doctester to test sagemath-objects, +# so we do not list sagemath-repl here. +test = [] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.dynamic] +version = {file = ["VERSION.txt"]} + +[tool.setuptools.package-data] +"sage.cpython" = [ + "pyx_visit.h", + "string_impl.h", + "cython_metaclass.h", + "python_debug.h", +] +"sage.rings" = ["integer_fake.h"] diff --git a/pkgs/sagemath-objects/setup.cfg.m4 b/pkgs/sagemath-objects/setup.cfg.m4 deleted file mode 100644 index 894c07b5bbf..00000000000 --- a/pkgs/sagemath-objects/setup.cfg.m4 +++ /dev/null @@ -1,31 +0,0 @@ -# -*- conf-unix -*- -[metadata] -name = sagemath-objects -version = file: VERSION.txt -description = Sage: Open Source Mathematics Software: Sage objects, elements, parents, categories, coercion, metaclasses -long_description = file: README.rst -long_description_content_type = text/x-rst -include(`setup_cfg_metadata.m4')dnl' - -[options] -include(`sage_spkg_versions.m4')dnl' -python_requires = >=3.9, <3.12 -install_requires = - SPKG_INSTALL_REQUIRES_gmpy2 - SPKG_INSTALL_REQUIRES_cysignals - -[options.extras_require] -# Currently we do not use the sage doctester to test sagemath-objects, -# so we do not list sagemath-repl here. -test = - - -[options.package_data] -sage.cpython = - pyx_visit.h - string_impl.h - cython_metaclass.h - python_debug.h - -sage.rings = - integer_fake.h From 24d2da2451a7017fef312461a0b93ac3ef0d93d2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 12:39:29 -0700 Subject: [PATCH 246/494] pkgs/sagemath-categories/pyproject.toml.m4: Move metadata here from setup.cfg.m4 --- pkgs/sagemath-categories/pyproject.toml.m4 | 24 ++++++++++++++++++++++ pkgs/sagemath-categories/setup.cfg.m4 | 16 --------------- 2 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 pkgs/sagemath-categories/setup.cfg.m4 diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 index cf4c97f1fd1..4e4b8582516 100644 --- a/pkgs/sagemath-categories/pyproject.toml.m4 +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -12,3 +12,27 @@ requires = [ SPKG_INSTALL_REQUIRES_cysignals ] build-backend = "setuptools.build_meta" + +[project] +name = "sagemath-categories" +description = "Sage: Open Source Mathematics Software: Sage categories and basic rings" +dependencies = [ + SPKG_INSTALL_REQUIRES_sagemath_objects +] +dynamic = ["version"] +include(`pyproject_toml_metadata.m4`) + +[project.optional-dependencies] +test = [ + SPKG_INSTALL_REQUIRES_sagemath_repl +] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.dynamic] +version = {file = ["VERSION.txt"]} diff --git a/pkgs/sagemath-categories/setup.cfg.m4 b/pkgs/sagemath-categories/setup.cfg.m4 deleted file mode 100644 index f5eb7c72968..00000000000 --- a/pkgs/sagemath-categories/setup.cfg.m4 +++ /dev/null @@ -1,16 +0,0 @@ -include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*- -[metadata] -name = sagemath-categories -version = file: VERSION.txt -description = Sage: Open Source Mathematics Software: Sage categories and basic rings -long_description = file: README.rst -long_description_content_type = text/x-rst -include(`setup_cfg_metadata.m4')dnl' - -[options] -python_requires = >=3.9, <3.12 -install_requires = - SPKG_INSTALL_REQUIRES_sagemath_objects - -[options.extras_require] -test = SPKG_INSTALL_REQUIRES_sagemath_repl From be9f37de7fbb7fe1e048c1c98bf64abf8137ca95 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 13:17:22 -0700 Subject: [PATCH 247/494] pkgs/sagemath-environment/pyproject.toml.m4: Move metadata here from setup.cfg.m4 --- pkgs/sagemath-environment/pyproject.toml.m4 | 54 +++++++++++++++++ pkgs/sagemath-environment/setup.cfg.m4 | 66 --------------------- 2 files changed, 54 insertions(+), 66 deletions(-) delete mode 100644 pkgs/sagemath-environment/setup.cfg.m4 diff --git a/pkgs/sagemath-environment/pyproject.toml.m4 b/pkgs/sagemath-environment/pyproject.toml.m4 index fb2db955ed5..b2afd2277b5 100644 --- a/pkgs/sagemath-environment/pyproject.toml.m4 +++ b/pkgs/sagemath-environment/pyproject.toml.m4 @@ -6,3 +6,57 @@ requires = [ SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" + +[project] +name = "sagemath-environment" +description = "Sage: Open Source Mathematics Software: System and software environment" +dependencies = [] +dynamic = ["version"] +include(`pyproject_toml_metadata.m4`) + +[project.optional-dependencies] +conf = [SPKG_INSTALL_REQUIRES_sage_conf] # sage.env can optionally use sage_conf +docbuild = [SPKG_INSTALL_REQUIRES_sage_docbuild] # For "sage --docbuild" +sage = [SPKG_INSTALL_REQUIRES_sagelib] # For "sage", "sage -t", ... +cython = [SPKG_INSTALL_REQUIRES_cython] # For "sage --cython" +pytest = [SPKG_INSTALL_REQUIRES_pytest] # For "sage --pytest" +rst2ipynb = [SPKG_INSTALL_REQUIRES_rst2ipynb] # For "sage --rst2ipynb" +tox = [SPKG_INSTALL_REQUIRES_tox] # For "sage --tox" +sws2rst = [SPKG_INSTALL_REQUIRES_sage_sws2rst] # For "sage --sws2rst" + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools] +py-modules = [ + "sage.all__sagemath_environment", + "sage.env", + "sage.version", + "sage.misc.all__sagemath_environment", + "sage.misc.package", + "sage.misc.package_dir", + "sage.misc.temporary_file", + "sage.misc.viewer", +] +packages = ["sage.features"] +script-files = [ + # The sage script + "bin/sage", + # Auxiliary scripts for setting up the environment + "bin/sage-env", + "bin/sage-num-threads.py", + "bin/sage-venv-config", + "bin/sage-version.sh", + # Auxiliary script for invoking Python in the Sage environment + "bin/sage-python", + # Not included: + # - bin/sage-env-config -- installed by sage_conf + # - bin/sage-env-config.in -- not to be installed + # - bin/sage-run, bin/sage-runtests, ... -- installed by sagemath-repl + # - bin/sage-ipython -- uses sage.repl, so installed by sagemath-repl +] +include-package-data = false + +[tool.setuptools.dynamic] +version = {file = ["VERSION.txt"]} diff --git a/pkgs/sagemath-environment/setup.cfg.m4 b/pkgs/sagemath-environment/setup.cfg.m4 deleted file mode 100644 index 9e5bb31eeb7..00000000000 --- a/pkgs/sagemath-environment/setup.cfg.m4 +++ /dev/null @@ -1,66 +0,0 @@ -include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*- -[metadata] -name = sagemath-environment -version = file: VERSION.txt -description = Sage: Open Source Mathematics Software: System and software environment -long_description = file: README.rst -long_description_content_type = text/x-rst -include(`setup_cfg_metadata.m4')dnl' - -[options] -python_requires = >=3.9, <3.12 -install_requires = - -py_modules = - sage.all__sagemath_environment - sage.env - sage.version - sage.misc.all__sagemath_environment - sage.misc.package - sage.misc.package_dir - sage.misc.temporary_file - sage.misc.viewer - -packages = - sage.features - -scripts = - # The sage script - bin/sage - # Auxiliary scripts for setting up the environment - bin/sage-env - bin/sage-num-threads.py - bin/sage-venv-config - bin/sage-version.sh - # Auxiliary script for invoking Python in the Sage environment - bin/sage-python - # Not included: - # - bin/sage-env-config -- installed by sage_conf - # - bin/sage-env-config.in -- not to be installed - # - bin/sage-run, bin/sage-runtests, ... -- installed by sagemath-repl - # - bin/sage-ipython -- uses sage.repl, so installed by sagemath-repl - -[options.extras_require] -# sage.env can optionally use sage_conf -conf = SPKG_INSTALL_REQUIRES_sage_conf - -# For "sage --docbuild" -docbuild = SPKG_INSTALL_REQUIRES_sage_docbuild - -# For "sage", "sage -t", ... -sage = SPKG_INSTALL_REQUIRES_sagelib - -# For "sage --cython" -cython = SPKG_INSTALL_REQUIRES_cython - -# For "sage --pytest" -pytest = SPKG_INSTALL_REQUIRES_pytest - -# For "sage --rst2ipynb" -rst2ipynb = SPKG_INSTALL_REQUIRES_rst2ipynb - -# For "sage --tox" -tox = SPKG_INSTALL_REQUIRES_tox - -# For "sage --sws2rst" -sws2rst = SPKG_INSTALL_REQUIRES_sage_sws2rst From 48d7ff9c1e76a801eb809807132b163cc8d87891 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 13:28:35 -0700 Subject: [PATCH 248/494] pkgs/sagemath-repl/pyproject.toml.m4: Move metadata here from setup.cfg.m4 --- pkgs/sagemath-repl/pyproject.toml.m4 | 66 ++++++++++++++++++++++++++++ pkgs/sagemath-repl/setup.cfg.m4 | 64 --------------------------- 2 files changed, 66 insertions(+), 64 deletions(-) delete mode 100644 pkgs/sagemath-repl/setup.cfg.m4 diff --git a/pkgs/sagemath-repl/pyproject.toml.m4 b/pkgs/sagemath-repl/pyproject.toml.m4 index fb2db955ed5..1abe5ec0465 100644 --- a/pkgs/sagemath-repl/pyproject.toml.m4 +++ b/pkgs/sagemath-repl/pyproject.toml.m4 @@ -6,3 +6,69 @@ requires = [ SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" + +[project] +name = "sagemath-repl" +description = "Sage: Open Source Mathematics Software: IPython kernel, Sage preparser, doctester" +dependencies = [ + SPKG_INSTALL_REQUIRES_sagemath_objects + SPKG_INSTALL_REQUIRES_sagemath_environment + SPKG_INSTALL_REQUIRES_ipython + SPKG_INSTALL_REQUIRES_ipywidgets +] +dynamic = ["version"] +include(`pyproject_toml_metadata.m4`) + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools] +py-modules = [ + "sage.all__sagemath_repl", + "sage.misc.all__sagemath_repl", + "sage.misc.banner", + "sage.misc.sagedoc", + "sage.misc.sage_input", + "sage.misc.sage_eval", +] +packages = [ + "sage.doctest", + "sage.repl", + "sage.repl.display", + "sage.repl.ipython_kernel", + "sage.repl.rich_output", +] +script-files = [ + # Other scripts that should be in the path also for OS packaging of sage: + "bin/sage-eval", + # Included because it is useful for doctesting/coverage testing user scripts too: + "bin/sage-runtests", + "bin/sage-fixdoctests", + "bin/sage-coverage", + # Helper scripts invoked by sage script + # (they would actually belong to something like libexec) + "bin/sage-cachegrind", + "bin/sage-callgrind", + "bin/sage-massif", + "bin/sage-omega", + "bin/sage-valgrind", + "bin/sage-cleaner", + # Uncategorized scripts in alphabetical order + "bin/sage-inline-fortran", + "bin/sage-ipynb2rst", + "bin/sage-ipython", + "bin/sage-notebook", + "bin/sage-preparse", + "bin/sage-run", + "bin/sage-run-cython", + "bin/sage-startuptime.py", +] +include-package-data = false + +[tool.setuptools.dynamic] +version = {file = ["VERSION.txt"]} + +[tool.setuptools.package-data] +"sage.doctest" = ["tests/*"] +"sage.repl.rich_output" = ["example*"] diff --git a/pkgs/sagemath-repl/setup.cfg.m4 b/pkgs/sagemath-repl/setup.cfg.m4 deleted file mode 100644 index f71d7bf6c2a..00000000000 --- a/pkgs/sagemath-repl/setup.cfg.m4 +++ /dev/null @@ -1,64 +0,0 @@ -include(`sage_spkg_versions.m4')dnl' -*- conf-unix -*- -[metadata] -name = sagemath-repl -version = file: VERSION.txt -description = Sage: Open Source Mathematics Software: System and software environment -long_description = file: README.rst -long_description_content_type = text/x-rst -include(`setup_cfg_metadata.m4')dnl' - -[options] -python_requires = >=3.9, <3.12 -install_requires = - SPKG_INSTALL_REQUIRES_sagemath_objects - SPKG_INSTALL_REQUIRES_sagemath_environment - SPKG_INSTALL_REQUIRES_ipython - SPKG_INSTALL_REQUIRES_ipywidgets - -py_modules = - sage.all__sagemath_repl - sage.misc.all__sagemath_repl - sage.misc.banner - sage.misc.sagedoc - sage.misc.sage_input - sage.misc.sage_eval - -packages = - sage.doctest - sage.repl - sage.repl.display - sage.repl.ipython_kernel - sage.repl.rich_output - -scripts = - # Other scripts that should be in the path also for OS packaging of sage: - bin/sage-eval - # Included because it is useful for doctesting/coverage testing user scripts too: - bin/sage-runtests - bin/sage-fixdoctests - bin/sage-coverage - # Helper scripts invoked by sage script - # (they would actually belong to something like libexec) - bin/sage-cachegrind - bin/sage-callgrind - bin/sage-massif - bin/sage-omega - bin/sage-valgrind - bin/sage-cleaner - # Uncategorized scripts in alphabetical order - bin/sage-inline-fortran - bin/sage-ipynb2rst - bin/sage-ipython - bin/sage-notebook - bin/sage-preparse - bin/sage-run - bin/sage-run-cython - bin/sage-startuptime.py - -[options.package_data] - -sage.doctest = - tests/* - -sage.repl.rich_output = - example* From 3f236fea961bf2bf9b4276909e7432f661ef3f80 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 14:23:04 -0700 Subject: [PATCH 249/494] Fix m4 syntax --- pkgs/sagemath-categories/pyproject.toml.m4 | 2 +- pkgs/sagemath-environment/pyproject.toml.m4 | 2 +- pkgs/sagemath-objects/pyproject.toml.m4 | 2 +- pkgs/sagemath-repl/pyproject.toml.m4 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 index 4e4b8582516..94277dccc0e 100644 --- a/pkgs/sagemath-categories/pyproject.toml.m4 +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -20,7 +20,7 @@ dependencies = [ SPKG_INSTALL_REQUIRES_sagemath_objects ] dynamic = ["version"] -include(`pyproject_toml_metadata.m4`) +include(`pyproject_toml_metadata.m4')dnl' [project.optional-dependencies] test = [ diff --git a/pkgs/sagemath-environment/pyproject.toml.m4 b/pkgs/sagemath-environment/pyproject.toml.m4 index b2afd2277b5..4061c8c46eb 100644 --- a/pkgs/sagemath-environment/pyproject.toml.m4 +++ b/pkgs/sagemath-environment/pyproject.toml.m4 @@ -12,7 +12,7 @@ name = "sagemath-environment" description = "Sage: Open Source Mathematics Software: System and software environment" dependencies = [] dynamic = ["version"] -include(`pyproject_toml_metadata.m4`) +include(`pyproject_toml_metadata.m4')dnl' [project.optional-dependencies] conf = [SPKG_INSTALL_REQUIRES_sage_conf] # sage.env can optionally use sage_conf diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 index 1db2cee5257..ce80e0fea5d 100644 --- a/pkgs/sagemath-objects/pyproject.toml.m4 +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -20,7 +20,7 @@ dependencies = [ SPKG_INSTALL_REQUIRES_cysignals ] dynamic = ["version"] -include(`pyproject_toml_metadata.m4`) +include(`pyproject_toml_metadata.m4')dnl' [project.optional-dependencies] # Currently we do not use the sage doctester to test sagemath-objects, diff --git a/pkgs/sagemath-repl/pyproject.toml.m4 b/pkgs/sagemath-repl/pyproject.toml.m4 index 1abe5ec0465..dfdfb692c9b 100644 --- a/pkgs/sagemath-repl/pyproject.toml.m4 +++ b/pkgs/sagemath-repl/pyproject.toml.m4 @@ -17,7 +17,7 @@ dependencies = [ SPKG_INSTALL_REQUIRES_ipywidgets ] dynamic = ["version"] -include(`pyproject_toml_metadata.m4`) +include(`pyproject_toml_metadata.m4')dnl' [project.readme] file = "README.rst" From b6c05e0865713fb5fcce558ca31c683b08db82c4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 15:09:12 -0700 Subject: [PATCH 250/494] build/sage_bootstrap/download/mirror_list.py: Use socket timeout of 1s unconditionally, stop when 5 good mirrors are found --- build/sage_bootstrap/download/mirror_list.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/sage_bootstrap/download/mirror_list.py b/build/sage_bootstrap/download/mirror_list.py index a8baa66da2d..4cab19f5d64 100644 --- a/build/sage_bootstrap/download/mirror_list.py +++ b/build/sage_bootstrap/download/mirror_list.py @@ -170,9 +170,7 @@ def _rank_mirrors(self): timed_mirrors = [] import time, socket log.info('Searching fastest mirror') - timeout = socket.getdefaulttimeout() - if timeout is None: - timeout = 1 + timeout = 1 for mirror in self.mirrors: if not mirror.startswith('http'): log.debug('we currently can only handle http, got %s', mirror) @@ -190,6 +188,11 @@ def _rank_mirrors(self): result_ms = int(1000 * result) log.info(str(result_ms).rjust(5) + 'ms: ' + mirror) timed_mirrors.append((result, mirror)) + timed_mirrors.sort() + if len(timed_mirrors) >= 5 and timed_mirrors[4][0] < 0.3: + # We don't need more than 5 decent mirrors + break + if len(timed_mirrors) == 0: # We cannot reach any mirror directly, most likely firewall issue if 'http_proxy' not in os.environ: @@ -197,7 +200,6 @@ def _rank_mirrors(self): raise MirrorListException('Failed to connect to any mirror, probably no internet connection') log.info('Cannot time mirrors via proxy, using default order') else: - timed_mirrors.sort() self._mirrors = [m[1] for m in timed_mirrors] log.info('Fastest mirror: ' + self.fastest) From c7fbd99d39a98107c776a9813aa950f4f2d7bf20 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 19 Oct 2023 11:03:58 +0000 Subject: [PATCH 251/494] Loosen version requirement on fpylll and align its conda version --- build/pkgs/fpylll/distros/conda.txt | 2 +- build/pkgs/fpylll/install-requires.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/fpylll/distros/conda.txt b/build/pkgs/fpylll/distros/conda.txt index 8a3e3a7ecd0..aa483930c7a 100644 --- a/build/pkgs/fpylll/distros/conda.txt +++ b/build/pkgs/fpylll/distros/conda.txt @@ -1 +1 @@ -fpylll +fpylll>=0.5.9 diff --git a/build/pkgs/fpylll/install-requires.txt b/build/pkgs/fpylll/install-requires.txt index c97d0c2c71e..e040e7daa1e 100644 --- a/build/pkgs/fpylll/install-requires.txt +++ b/build/pkgs/fpylll/install-requires.txt @@ -1 +1 @@ -fpylll >=0.5.9, <=0.5.9 +fpylll >=0.5.9 From 2a820e0a5a0271067c53be45bc8696c0c545f9e8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:48:32 -0400 Subject: [PATCH 252/494] build/pkgs/memory_allocator: add standard python spkg-configure.m4 --- build/pkgs/memory_allocator/spkg-configure.m4 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 build/pkgs/memory_allocator/spkg-configure.m4 diff --git a/build/pkgs/memory_allocator/spkg-configure.m4 b/build/pkgs/memory_allocator/spkg-configure.m4 new file mode 100644 index 00000000000..8cd8d87f124 --- /dev/null +++ b/build/pkgs/memory_allocator/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([memory_allocator], [ + SAGE_PYTHON_PACKAGE_CHECK([memory_allocator]) +]) From 7431ab188198e4e9ffb29ed46464cb702b11728b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:50:35 -0400 Subject: [PATCH 253/494] build/pkgs/cysignals: add standard python spkg-configure.m4 --- build/pkgs/cysignals/spkg-configure.m4 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 build/pkgs/cysignals/spkg-configure.m4 diff --git a/build/pkgs/cysignals/spkg-configure.m4 b/build/pkgs/cysignals/spkg-configure.m4 new file mode 100644 index 00000000000..4eeee71f579 --- /dev/null +++ b/build/pkgs/cysignals/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([cysignals], [ + SAGE_PYTHON_PACKAGE_CHECK([cysignals]) +]) From 9c45d45afca40e141bf5aa08b1a6b6770e3de2f1 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:52:17 -0400 Subject: [PATCH 254/494] build/pkgs/fpylll: add standard python spkg-configure.m4 --- build/pkgs/fpylll/spkg-configure.m4 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/pkgs/fpylll/spkg-configure.m4 diff --git a/build/pkgs/fpylll/spkg-configure.m4 b/build/pkgs/fpylll/spkg-configure.m4 new file mode 100644 index 00000000000..bd3c707f82d --- /dev/null +++ b/build/pkgs/fpylll/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([fpylll], [ + SAGE_SPKG_DEPCHECK([cysignals fplll numpy], [ + SAGE_PYTHON_PACKAGE_CHECK([fpylll]) + ]) +]) From 141950785dfdf0b8c7f27ab78e13014658b04a43 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:53:43 -0400 Subject: [PATCH 255/494] build/pkgs/pplpy: add standard python spkg-configure.m4 --- build/pkgs/pplpy/spkg-configure.m4 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/pkgs/pplpy/spkg-configure.m4 diff --git a/build/pkgs/pplpy/spkg-configure.m4 b/build/pkgs/pplpy/spkg-configure.m4 new file mode 100644 index 00000000000..320ca9456f6 --- /dev/null +++ b/build/pkgs/pplpy/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([pplpy], [ + SAGE_SPKG_DEPCHECK([cysignals gmpy2 ppl], [ + SAGE_PYTHON_PACKAGE_CHECK([pplpy]) + ]) +]) From a3497a0614c2cd32628841806d825489072f99d8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:54:48 -0400 Subject: [PATCH 256/494] build/pkgs/primecountpy: add standard python spkg-configure.m4 --- build/pkgs/primecountpy/spkg-configure.m4 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/pkgs/primecountpy/spkg-configure.m4 diff --git a/build/pkgs/primecountpy/spkg-configure.m4 b/build/pkgs/primecountpy/spkg-configure.m4 new file mode 100644 index 00000000000..f1e2d7ce4f5 --- /dev/null +++ b/build/pkgs/primecountpy/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([primecountpy], [ + SAGE_SPKG_DEPCHECK([cysignals primecount], [ + SAGE_PYTHON_PACKAGE_CHECK([primecountpy]) + ]) +]) From ad36caa5542314b0b54c8b989d75add54efa4d13 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 09:55:58 -0400 Subject: [PATCH 257/494] build/pkgs/cypari: add standard python spkg-configure.m4 --- build/pkgs/cypari/spkg-configure.m4 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/pkgs/cypari/spkg-configure.m4 diff --git a/build/pkgs/cypari/spkg-configure.m4 b/build/pkgs/cypari/spkg-configure.m4 new file mode 100644 index 00000000000..12bbfec1de1 --- /dev/null +++ b/build/pkgs/cypari/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([cypari], [ + SAGE_SPKG_DEPCHECK([cysignals pari], [ + SAGE_PYTHON_PACKAGE_CHECK([cypari]) + ]) +]) From 059253dd6433c3f96bfdd94d87adb1b89ce4b1c9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:18:48 -0400 Subject: [PATCH 258/494] build/pkgs/memory_allocator: add Gentoo package information --- build/pkgs/memory_allocator/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/memory_allocator/distros/gentoo.txt diff --git a/build/pkgs/memory_allocator/distros/gentoo.txt b/build/pkgs/memory_allocator/distros/gentoo.txt new file mode 100644 index 00000000000..f259d7be64d --- /dev/null +++ b/build/pkgs/memory_allocator/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/memory_allocator From ac602001b73c7a092230e5d4dc960ce85604d16a Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:19:15 -0400 Subject: [PATCH 259/494] build/pkgs/cysignals: add Gentoo package information --- build/pkgs/cysignals/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/cysignals/distros/gentoo.txt diff --git a/build/pkgs/cysignals/distros/gentoo.txt b/build/pkgs/cysignals/distros/gentoo.txt new file mode 100644 index 00000000000..3d0797368c8 --- /dev/null +++ b/build/pkgs/cysignals/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/cysignals From f6083a5153e6f13cbb3e84d6e224586aae995d24 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:19:50 -0400 Subject: [PATCH 260/494] build/pkgs/primecountpy: add Gentoo package information --- build/pkgs/primecountpy/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/primecountpy/distros/gentoo.txt diff --git a/build/pkgs/primecountpy/distros/gentoo.txt b/build/pkgs/primecountpy/distros/gentoo.txt new file mode 100644 index 00000000000..194fde28b57 --- /dev/null +++ b/build/pkgs/primecountpy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/primecountpy From ce4343e4ba2ea30bc6d2537e7e58cd6402e2c587 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:20:18 -0400 Subject: [PATCH 261/494] build/pkgs/pplpy: add Gentoo package information --- build/pkgs/pplpy/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/pplpy/distros/gentoo.txt diff --git a/build/pkgs/pplpy/distros/gentoo.txt b/build/pkgs/pplpy/distros/gentoo.txt new file mode 100644 index 00000000000..375b6a32c29 --- /dev/null +++ b/build/pkgs/pplpy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pplpy From 983a3f48026e3ac051457751ecfaa8b711bb87b3 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:20:44 -0400 Subject: [PATCH 262/494] build/pkgs/fpylll: add Gentoo package information --- build/pkgs/fpylll/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/fpylll/distros/gentoo.txt diff --git a/build/pkgs/fpylll/distros/gentoo.txt b/build/pkgs/fpylll/distros/gentoo.txt new file mode 100644 index 00000000000..34817e9f233 --- /dev/null +++ b/build/pkgs/fpylll/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/fpylll From 76d1a4a4a6dd7b9d9b89ecb3280f13e84524e336 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Oct 2023 11:21:11 -0400 Subject: [PATCH 263/494] build/pkgs/cypari: add Gentoo package information --- build/pkgs/cypari/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/cypari/distros/gentoo.txt diff --git a/build/pkgs/cypari/distros/gentoo.txt b/build/pkgs/cypari/distros/gentoo.txt new file mode 100644 index 00000000000..e0a57fa8726 --- /dev/null +++ b/build/pkgs/cypari/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/cypari2 From 44dd3c5cabe9856429982b9c6d0d53c71be6a638 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 26 Oct 2023 14:30:19 -0400 Subject: [PATCH 264/494] build/pkgs/memory_allocator: rename the Gentoo package Someone renamed this with a hyphen instead of an underscore a few minutes after I added it. --- build/pkgs/memory_allocator/distros/gentoo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/memory_allocator/distros/gentoo.txt b/build/pkgs/memory_allocator/distros/gentoo.txt index f259d7be64d..cb71f80f6c7 100644 --- a/build/pkgs/memory_allocator/distros/gentoo.txt +++ b/build/pkgs/memory_allocator/distros/gentoo.txt @@ -1 +1 @@ -dev-python/memory_allocator +dev-python/memory-allocator From d1de3bff9370217cb2b6eda810d2a35a514eac2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 29 Oct 2023 08:55:09 +0100 Subject: [PATCH 265/494] suggested details --- .../number_field/number_field_element.pyx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 70d41e866af..d803d41fcb5 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -541,15 +541,16 @@ cdef class NumberFieldElement(NumberFieldElement_base): EXAMPLES:: + sage: # needs sage.libs.gap sage: F = CyclotomicField(8) - sage: F.gen()._libgap_() # needs sage.libs.gap + sage: F.gen()._libgap_() E(8) - sage: libgap(F.gen()) # syntactic sugar # needs sage.libs.gap + sage: libgap(F.gen()) # syntactic sugar E(8) - sage: E8 = F.gen() # needs sage.libs.gap - sage: libgap(E8 + 3/2*E8^2 + 100*E8^7) # needs sage.libs.gap + sage: E8 = F.gen() + sage: libgap(E8 + 3/2*E8^2 + 100*E8^7) E(8)+3/2*E(8)^2-100*E(8)^3 - sage: type(_) # needs sage.libs.gap + sage: type(_) Check that :trac:`15276` is fixed:: @@ -571,7 +572,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): E = libgap(P).GeneratorsOfField()[0] n = P._n() if n % 4 == 2: - E = -E**((n // 2 + 1) // 2) + E = -E**((n//2 + 1)//2) return self.polynomial()(E) def _pari_polynomial(self, name='y'): @@ -980,9 +981,8 @@ cdef class NumberFieldElement(NumberFieldElement_base): Otherwise, it is the numerical absolute value with respect to the first archimedean embedding, to double precision. - This is the ``abs()`` Python function. If you want a - different embedding or precision, use - ``self.abs(...)``. + This is the :func:`abs` Python function. If you want a + different embedding or precision, use ``self.abs(...)``. EXAMPLES:: @@ -1368,10 +1368,10 @@ cdef class NumberFieldElement(NumberFieldElement_base): CCprec = ComplexField(prec) if i is None and CCprec.has_coerce_map_from(self.parent()): return CCprec(self).abs() - else: - i = 0 if i is None else i - P = self.number_field().complex_embeddings(prec)[i] - return P(self).abs() + + i = 0 if i is None else i + P = self.number_field().complex_embeddings(prec)[i] + return P(self).abs() def abs_non_arch(self, P, prec=None): r""" From fb34b66d0e274c81a62c773b8fc25b71e6ef72e6 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Sun, 29 Oct 2023 14:37:19 +0100 Subject: [PATCH 266/494] add method is_geodetic --- src/sage/graphs/convexity_properties.pyx | 147 ++++++++++++++++++++++- src/sage/graphs/generic_graph.py | 2 + 2 files changed, 143 insertions(+), 6 deletions(-) diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index c422d0c3190..0f4e288dcc7 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -13,13 +13,10 @@ the following methods: :meth:`ConvexityProperties.hull` | Return the convex hull of a set of vertices :meth:`ConvexityProperties.hull_number` | Compute the hull number of a graph and a corresponding generating set :meth:`geodetic_closure`| Return the geodetic closure of a set of vertices + :meth:`is_geodetic` | Check whether the input (di)graph is geodetic -These methods can be used through the :class:`ConvexityProperties` object -returned by :meth:`Graph.convexity_properties`. - -AUTHORS: - - - Nathann Cohen +Some of these methods can be used through the :class:`ConvexityProperties` +object returned by :meth:`Graph.convexity_properties`. Methods ------- @@ -674,3 +671,141 @@ def geodetic_closure(G, S): free_short_digraph(sd) return ret + + +def is_geodetic(G): + r""" + Check whether the input (di)graph is geodetic. + + A graph `G` is *geodetic* if there exists only one shortest path between + every pair of its vertices. This can be checked in time `O(nm)` in + unweighted (di)graphs. Examples of geodetic graphs are trees, cliques and + odd cycles. See the :wikipedia:`Geodetic_graph` for more details. + + INPUT: + + - ``G`` -- a Sage graph or digraph + + EXAMPLES: + + Trees, cliques and odd cycles are geodetic:: + + sage: T = graphs.RandomTree(20) + sage: T.is_geodetic() + True + sage: all(graphs.CompleteGraph(n).is_geodetic() for n in range(8)) + True + sage: all(graphs.CycleGraph(n).is_geodetic() for n in range(3, 16, 2)) + True + + Even cycles of order at least 4 are not geodetic:: + + sage: all(graphs.CycleGraph(n).is_geodetic() for n in range(4, 17, 2)) + False + + The Petersen graph is geodetic:: + + sage: P = graphs.PetersenGraph() + sage: P.is_geodetic() + True + + Grid graphs are not geodetic:: + + sage: G = graphs.Grid2dGraph(2, 3) + sage: G.is_geodetic() + False + + This method is also valid for digraphs:: + + sage: G = DiGraph(graphs.PetersenGraph()) + sage: G.is_geodetic() + True + sage: G = digraphs.Path(5) + sage: G.add_path([0, 'a', 'b', 'c', 4]) + sage: G.is_geodetic() + False + + TESTS:: + + sage: all(g.is_geodetic() for g in graphs(3)) + True + sage: all((2*g).is_geodetic() for g in graphs(3)) + True + """ + G._scream_if_not_simple(allow_loops=True) + + if G.order() < 4: + return True + + # Copy the graph as a short digraph + cdef int n = G.order() + cdef short_digraph sd + init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G)) + + # Allocate some data structures + cdef MemoryAllocator mem = MemoryAllocator() + cdef uint32_t * distances = mem.malloc(n * sizeof(uint32_t)) + cdef uint32_t * waiting_list = mem.malloc(n * sizeof(uint32_t)) + if not distances or not waiting_list: + free_short_digraph(sd) + raise MemoryError() + cdef bitset_t seen + bitset_init(seen, n) + + # We now explore geodesics between vertices in S, and we avoid visiting + # twice the geodesics between u and v + + cdef uint32_t source, u, v + cdef uint32_t waiting_beginning + cdef uint32_t waiting_end + cdef uint32_t * p_tmp + cdef uint32_t * end + cdef uint32_t ** p_vertices = sd.neighbors + + for source in range(n): + + # Compute distances from source using BFS + bitset_clear(seen) + bitset_add(seen, source) + distances[source] = 0 + waiting_beginning = 0 + waiting_end = 0 + waiting_list[waiting_beginning] = source + + # For as long as there are vertices left to explore + while waiting_beginning <= waiting_end: + + # We pick the first one + v = waiting_list[waiting_beginning] + p_tmp = p_vertices[v] + end = p_vertices[v + 1] + + # and we iterate over all the outneighbors u of v + while p_tmp < end: + u = p_tmp[0] + + # If we notice one of these neighbors is not seen yet, we set + # its parameters and add it to the queue to be explored later. + # Otherwise, we check whether we have detected a second shortest + # path between source and v. + if not bitset_in(seen, u): + distances[u] = distances[v] + 1 + bitset_add(seen, u) + waiting_end += 1 + waiting_list[waiting_end] = u + elif distances[u] == distances[v] + 1: + # G is not geodetic + bitset_free(seen) + free_short_digraph(sd) + return False + + p_tmp += 1 + + # We go to the next vertex in the queue + waiting_beginning += 1 + + bitset_free(seen) + free_short_digraph(sd) + + # The graph is geodetic + return True diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..f86a10caf53 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -185,6 +185,7 @@ :meth:`~GenericGraph.is_gallai_tree` | Return whether the current graph is a Gallai tree. :meth:`~GenericGraph.is_clique` | Check whether a set of vertices is a clique :meth:`~GenericGraph.is_cycle` | Check whether ``self`` is a (directed) cycle graph. + :meth:`~GenericGraph.is_geodetic` | Check whether the input (di)graph is geodetic. :meth:`~GenericGraph.is_independent_set` | Check whether ``vertices`` is an independent set of ``self`` :meth:`~GenericGraph.is_transitively_reduced` | Test whether the digraph is transitively reduced. :meth:`~GenericGraph.is_equitable` | Check whether the given partition is equitable with respect to self. @@ -24398,6 +24399,7 @@ def is_self_complementary(self): from sage.graphs.traversals import lex_UP from sage.graphs.traversals import lex_DFS from sage.graphs.traversals import lex_DOWN + is_geodetic = LazyImport('sage.graphs.convexity_properties', 'is_geodetic') def katz_matrix(self, alpha, nonedgesonly=False, vertices=None): r""" From cbaed61ac13352ff3367ae176a9d013caf716ae1 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Sun, 29 Oct 2023 14:54:13 +0100 Subject: [PATCH 267/494] deal with loops and multiple edges --- src/sage/graphs/convexity_properties.pyx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index 0f4e288dcc7..9d8a28ed6b8 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -682,6 +682,8 @@ def is_geodetic(G): unweighted (di)graphs. Examples of geodetic graphs are trees, cliques and odd cycles. See the :wikipedia:`Geodetic_graph` for more details. + (Di)graphs with multiple edges are not considered geodetic. + INPUT: - ``G`` -- a Sage graph or digraph @@ -731,8 +733,20 @@ def is_geodetic(G): True sage: all((2*g).is_geodetic() for g in graphs(3)) True + sage: G = graphs.CycleGraph(5) + sage: G.allow_loops(True) + sage: G.add_edges([(u, u) for u in G]) + sage: G.is_geodetic() + True + sage: G.allow_multiple_edges(True) + sage: G.is_geodetic() + True + sage: G.add_edge(G.random_edge()) + sage: G.is_geodetic() + False """ - G._scream_if_not_simple(allow_loops=True) + if G.has_multiple_edges(): + return False if G.order() < 4: return True From 7e098546942112c6bfd875ac42ef989695c59ee0 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 29 Oct 2023 16:26:48 +0000 Subject: [PATCH 268/494] Replace relative imports by absolute ones in structure --- src/sage/structure/all.py | 20 ++++++++++---------- src/sage/structure/coerce.pxd | 4 ++-- src/sage/structure/coerce.pyx | 10 +++++----- src/sage/structure/coerce_actions.pyx | 8 ++++---- src/sage/structure/debug_options.pyx | 2 +- src/sage/structure/element.pxd | 4 ++-- src/sage/structure/element.pyx | 2 +- src/sage/structure/factory.pyx | 4 ++-- src/sage/structure/parent.pyx | 12 ++++++------ src/sage/structure/parent_base.pxd | 2 +- src/sage/structure/parent_base.pyx | 2 +- src/sage/structure/parent_gens.pxd | 2 +- src/sage/structure/parent_old.pyx | 2 +- src/sage/structure/sage_object_test.py | 3 ++- 14 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py index 311bf869ef2..df0114c8382 100644 --- a/src/sage/structure/all.py +++ b/src/sage/structure/all.py @@ -1,12 +1,12 @@ -from .factorization import Factorization +from sage.structure.factorization import Factorization -from .sequence import Sequence, seq +from sage.structure.sequence import Sequence, seq -from .unique_representation import UniqueRepresentation +from sage.structure.unique_representation import UniqueRepresentation -from .sage_object import SageObject +from sage.structure.sage_object import SageObject -from .element import ( +from sage.structure.element import ( canonical_coercion, coercion_model, get_coercion_model, @@ -14,16 +14,16 @@ parent ) -from .parent import Parent +from sage.structure.parent import Parent -from .parent_gens import localvars +from sage.structure.parent_gens import localvars -from .proof import all as proof +from sage.structure.proof import all as proof from sage.misc.lazy_import import lazy_import lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum']) del lazy_import -from .mutability import Mutability +from sage.structure.mutability import Mutability -from .element_wrapper import ElementWrapper +from sage.structure.element_wrapper import ElementWrapper diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd index e070d1c32e4..812cb5d5c7c 100644 --- a/src/sage/structure/coerce.pxd +++ b/src/sage/structure/coerce.pxd @@ -1,5 +1,5 @@ -from .parent cimport Parent -from .coerce_dict cimport TripleDict +from sage.structure.parent cimport Parent +from sage.structure.coerce_dict cimport TripleDict cpdef py_scalar_parent(py_type) cpdef py_scalar_to_element(py) diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index d8c3f684217..8f98085ba8d 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -84,11 +84,11 @@ cimport gmpy2 cdef mul, truediv from operator import mul, truediv -from .richcmp cimport rich_to_bool, revop -from .sage_object cimport SageObject -from .parent cimport Parent_richcmp_element_without_coercion -from .element cimport bin_op_exception, parent, Element -from .coerce_exceptions import CoercionException +from sage.structure.richcmp cimport rich_to_bool, revop +from sage.structure.sage_object cimport SageObject +from sage.structure.parent cimport Parent_richcmp_element_without_coercion +from sage.structure.element cimport bin_op_exception, parent, Element +from sage.structure.coerce_exceptions import CoercionException from sage.rings.integer_fake cimport is_Integer from sage.categories.map cimport Map from sage.categories.morphism import IdentityMorphism diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx index 6df2aec6695..3c17ac858e6 100644 --- a/src/sage/structure/coerce_actions.pyx +++ b/src/sage/structure/coerce_actions.pyx @@ -18,10 +18,10 @@ from cpython.long cimport * from cpython.number cimport * from cysignals.signals cimport sig_check -from .coerce cimport coercion_model -from .element cimport parent, Element, ModuleElement -from .parent cimport Parent -from .coerce_exceptions import CoercionException +from sage.structure.coerce cimport coercion_model +from sage.structure.element cimport parent, Element, ModuleElement +from sage.structure.parent cimport Parent +from sage.structure.coerce_exceptions import CoercionException from sage.categories.action cimport InverseAction, PrecomposedAction from sage.arith.long cimport integer_check_long diff --git a/src/sage/structure/debug_options.pyx b/src/sage/structure/debug_options.pyx index 05d7835f869..361bdf5162c 100644 --- a/src/sage/structure/debug_options.pyx +++ b/src/sage/structure/debug_options.pyx @@ -48,4 +48,4 @@ from cpython.object cimport PyObject cdef extern from *: PyObject* __pyx_d -(__pyx_d)["debug"] = debug +#(__pyx_d)["debug"] = debug diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd index 20c556b985e..6be65bb1f50 100644 --- a/src/sage/structure/element.pxd +++ b/src/sage/structure/element.pxd @@ -1,5 +1,5 @@ -from .sage_object cimport SageObject -from .parent cimport Parent +from sage.structure.sage_object cimport SageObject +from sage.structure.parent cimport Parent from sage.misc.inherit_comparison cimport InheritComparisonMetaclass diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 543506e9a74..8ac847fc7a1 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -4532,7 +4532,7 @@ cpdef bin_op(x, y, op): # Make coercion_model accessible as Python object -globals()["coercion_model"] = coercion_model +globals()["sage.structure.coercion_model"] = coercion_model def get_coercion_model(): diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx index ddb55501d94..af455bd5b3b 100644 --- a/src/sage/structure/factory.pyx +++ b/src/sage/structure/factory.pyx @@ -56,7 +56,7 @@ AUTHORS: import types -from .sage_object cimport SageObject +from sage.structure.sage_object cimport SageObject cdef sage_version from sage.version import version as sage_version @@ -771,4 +771,4 @@ def lookup_global(name): # Old imports required for unpickling old pickles -from sage.structure.test_factory import test_factory +#from sage.structure.test_factory import test_factory diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index 6548d8a3656..d40caa03307 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -119,13 +119,13 @@ from sage.misc.lazy_attribute import lazy_attribute from sage.categories.sets_cat import Sets, EmptySetError from sage.misc.lazy_string cimport _LazyString from sage.sets.pythonclass cimport Set_PythonType_class -from .category_object import CategoryObject -from .coerce cimport coercion_model -from .coerce cimport parent_is_integers -from .coerce_exceptions import CoercionException -from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap, +from sage.structure.category_object import CategoryObject +from sage.structure.coerce cimport coercion_model +from sage.structure.coerce cimport parent_is_integers +from sage.structure.coerce_exceptions import CoercionException +from sage.structure.coerce_maps cimport (NamedConvertMap, DefaultConvertMap, DefaultConvertMap_unique, CallableConvertMap) -from .element cimport parent +from sage.structure.element cimport parent cdef _record_exception(): diff --git a/src/sage/structure/parent_base.pxd b/src/sage/structure/parent_base.pxd index 225fccabcae..8ffac64eff2 100644 --- a/src/sage/structure/parent_base.pxd +++ b/src/sage/structure/parent_base.pxd @@ -6,7 +6,7 @@ # https://www.gnu.org/licenses/ ############################################################################### -from .parent_old cimport Parent as Parent_old +from sage.structure.parent_old cimport Parent as Parent_old cdef class ParentWithBase(Parent_old): pass diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx index dd697f90135..b41175b5bff 100644 --- a/src/sage/structure/parent_base.pyx +++ b/src/sage/structure/parent_base.pyx @@ -12,7 +12,7 @@ Base class for old-style parent objects with a base ring # **************************************************************************** cimport sage.structure.parent as parent -from .coerce_exceptions import CoercionException +from sage.structure.coerce_exceptions import CoercionException cdef inline check_old_coerce(parent.Parent p): if p._element_constructor is not None: diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd index 6ec0e6e83f0..cf3b416317f 100644 --- a/src/sage/structure/parent_gens.pxd +++ b/src/sage/structure/parent_gens.pxd @@ -12,7 +12,7 @@ Parent objects with generators # http://www.gnu.org/licenses/ #***************************************************************************** -from .parent_base cimport ParentWithBase +from sage.structure.parent_base cimport ParentWithBase cdef class ParentWithGens(ParentWithBase): diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx index 77a7888d3b8..82bf9ead04b 100644 --- a/src/sage/structure/parent_old.pyx +++ b/src/sage/structure/parent_old.pyx @@ -27,7 +27,7 @@ This came up in some subtle bug once:: # https://www.gnu.org/licenses/ # **************************************************************************** from sage.misc.superseded import deprecation -from .coerce cimport py_scalar_parent +from sage.structure.coerce cimport py_scalar_parent from sage.ext.stdsage cimport HAS_DICTIONARY from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class diff --git a/src/sage/structure/sage_object_test.py b/src/sage/structure/sage_object_test.py index 0922545a62c..721c1ad7719 100644 --- a/src/sage/structure/sage_object_test.py +++ b/src/sage/structure/sage_object_test.py @@ -1,6 +1,7 @@ import pytest -from .sage_object import SageObject +from sage.structure.sage_object import SageObject + class SageObjectTests: From 460d9671013c3b6ef898c6ddc76c12e318b9655a Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 29 Oct 2023 16:48:48 +0000 Subject: [PATCH 269/494] Revert some of the changes --- src/sage/structure/debug_options.pyx | 2 +- src/sage/structure/element.pyx | 2 +- src/sage/structure/factory.pyx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/structure/debug_options.pyx b/src/sage/structure/debug_options.pyx index 361bdf5162c..05d7835f869 100644 --- a/src/sage/structure/debug_options.pyx +++ b/src/sage/structure/debug_options.pyx @@ -48,4 +48,4 @@ from cpython.object cimport PyObject cdef extern from *: PyObject* __pyx_d -#(__pyx_d)["debug"] = debug +(__pyx_d)["debug"] = debug diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 8ac847fc7a1..543506e9a74 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -4532,7 +4532,7 @@ cpdef bin_op(x, y, op): # Make coercion_model accessible as Python object -globals()["sage.structure.coercion_model"] = coercion_model +globals()["coercion_model"] = coercion_model def get_coercion_model(): diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx index af455bd5b3b..50d5374e79e 100644 --- a/src/sage/structure/factory.pyx +++ b/src/sage/structure/factory.pyx @@ -771,4 +771,4 @@ def lookup_global(name): # Old imports required for unpickling old pickles -#from sage.structure.test_factory import test_factory +from sage.structure.test_factory import test_factory From f6fee14041a5e41863261f27b1db79ef77def042 Mon Sep 17 00:00:00 2001 From: Gustavo Rama Date: Thu, 11 Sep 2014 08:37:17 -0300 Subject: [PATCH 270/494] Add a hash function for the class TernaryQF. --- src/sage/quadratic_forms/ternary_qf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py index 6a08d00f26c..4184c839528 100644 --- a/src/sage/quadratic_forms/ternary_qf.py +++ b/src/sage/quadratic_forms/ternary_qf.py @@ -116,6 +116,20 @@ def coefficients(self): """ return self._a, self._b, self._c, self._r, self._s, self._t + def __hash__(self): + """ + Returns a hash for self. + + EXAMPLES:: + + sage: Q = TernaryQF([1, 2, 3, 4, 5, 6]) + sage: Q.__hash__() + 5881802312257552497 # 64-bit + 1770036893 # 32-bit + """ + + return hash(self.coefficients()) + def coefficient(self, n): r""" Return the `n`-th coefficient of the ternary quadratic form. From 8a946572bb557ca722b2e9dcffdab73094a3493e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 14:23:20 -0700 Subject: [PATCH 271/494] build/pkgs/networkx: Allow networkx 3.2 --- build/pkgs/networkx/distros/conda.txt | 2 +- build/pkgs/networkx/install-requires.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/networkx/distros/conda.txt b/build/pkgs/networkx/distros/conda.txt index 96b0bbb2845..c9c5caa1120 100644 --- a/build/pkgs/networkx/distros/conda.txt +++ b/build/pkgs/networkx/distros/conda.txt @@ -1 +1 @@ -networkx<3.2,>=2.4 +networkx<3.3,>=2.4 diff --git a/build/pkgs/networkx/install-requires.txt b/build/pkgs/networkx/install-requires.txt index ea173da7538..5a7e22a60db 100644 --- a/build/pkgs/networkx/install-requires.txt +++ b/build/pkgs/networkx/install-requires.txt @@ -1 +1 @@ -networkx >=2.4, <3.2 +networkx >=2.4, <3.3 From 5fa0ed4825d3dcbb676a225ba7aa69db87990595 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sun, 29 Oct 2023 23:29:42 +0000 Subject: [PATCH 272/494] add an example of a divisor on a curve --- src/sage/schemes/curves/curve.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/schemes/curves/curve.py b/src/sage/schemes/curves/curve.py index 79fcc820618..0538db66fee 100644 --- a/src/sage/schemes/curves/curve.py +++ b/src/sage/schemes/curves/curve.py @@ -184,7 +184,11 @@ def divisor(self, v, base_ring=None, check=True, reduce=True): sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens() sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) - + sage: p1 = C(0, -1, 1) + sage: p2 = C(0, 0, 1) + sage: p3 = C(0, 1, 0) + sage: C.divisor([(1, p1), (-1, p2), (2, p3)]) + (x, y + z) - (x, y) + 2*(x, z) """ return Divisor_curve(v, check=check, reduce=reduce, parent=self.divisor_group(base_ring)) From 1dc0fab6eb0fed80d64789f3f79a63fdb6ff603e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 17:13:24 -0700 Subject: [PATCH 273/494] src/doc/en/developer/coding_in_python.rst: Fix syntax --- src/doc/en/developer/coding_in_python.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/developer/coding_in_python.rst b/src/doc/en/developer/coding_in_python.rst index f968250f7ac..e39a3f72c4d 100644 --- a/src/doc/en/developer/coding_in_python.rst +++ b/src/doc/en/developer/coding_in_python.rst @@ -597,7 +597,7 @@ it automatically runs in the GitHub Actions CI and can also be run locally. As of Sage 10.2, the Sage library only contains a minimal set of such type annotations. Pull requests that add more annotations are generally welcome. -The Sage library makes very extensive use of Cython (see chapter :ref:`_chapter-cython`). +The Sage library makes very extensive use of Cython (see chapter :ref:`chapter-cython`). Although Cython source code often declares static types for the purpose of compilation to efficient machine code, this typing information is unfortunately not visible to static checkers such as Pyright. It is necessary to create `type stub From 5872337258e0e05cba64cb7693ac8c95489fb995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 12:18:35 +0100 Subject: [PATCH 274/494] Update permutation.py variables en minuscules --- src/sage/combinat/permutation.py | 54 +++++++++++++++----------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 136fefc99ed..74be5244fd4 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5434,7 +5434,7 @@ def nth_roots(self, n): from sage.combinat.partition import Partitions from sage.combinat.set_partition import SetPartitions - from sage.categories.cartesian_product import cartesian_product + from itertools import product from sage.arith.misc import divisors, gcd def merging_cycles(list_of_cycles): @@ -5444,17 +5444,16 @@ def merging_cycles(list_of_cycles): lC = len(list_of_cycles) lperm = len(list_of_cycles[0]) l = lC*lperm - Perm = [0 for i in range(l)] + perm = [0 for i in range(l)] for j in range(lperm): - Perm[j*lC] = list_of_cycles[0][j] + perm[j*lC] = list_of_cycles[0][j] for p in Permutations(lC-1): - for indices in cartesian_product([range(lperm) for _ in range(lC-1)]): - new_Perm = list(Perm) + for indices in product(*[range(lperm) for _ in range(lC-1)]): + new_perm = list(perm) for i in range(lC-1): for j in range(lperm): - new_Perm[(p[i] + (indices[i]+j)*lC) %l] = list_of_cycles[i+1][j] - gamma = Permutation(tuple(new_Perm)) - yield gamma + new_perm[(p[i] + (indices[i]+j)*lC) %l] = list_of_cycles[i+1][j] + yield Permutation(tuple(new_perm)) def rewind(L, n): """ @@ -5463,7 +5462,7 @@ def rewind(L, n): M = [0 for _ in L] m = len(M) for j in range(m): - M[(j*n)%m] = L[j] + M[(j*n) % m] = L[j] return M if n < 1: @@ -5472,17 +5471,17 @@ def rewind(L, n): P = Permutations(self.size()) # Creating dict {length: cycles of this length in the cycle decomposition of Sigma} - Cycles = {} + cycles = {} for c in self.cycle_tuples(singletons=True): lc = len(c) - if lc not in Cycles: - Cycles[lc] = [] - Cycles[lc].append(c) + if lc not in cycles: + cycles[lc] = [] + cycles[lc].append(c) # for each length m, collects all product of cycles which n-th power gives the product prod(Cycles[l]) - Possibilities = {m: [] for m in Cycles} - for m in Cycles: - N = len(Cycles[m]) + Possibilities = {m: [] for m in cycles} + for m in cycles: + N = len(cycles[m]) parts = [x for x in divisors(n) if gcd(m*x, n) == x] b = False for X in Partitions(N, parts_in=parts): @@ -5491,7 +5490,7 @@ def rewind(L, n): poss = [P.identity()] for pa in partition: poss = [p*q for p in poss - for q in merging_cycles([rewind(Cycles[m][i-1], n//len(pa)) for i in pa])] + for q in merging_cycles([rewind(cycles[m][i-1], n//len(pa)) for i in pa])] Possibilities[m] += poss if not b: return @@ -5504,7 +5503,7 @@ def has_nth_root(self, n): r""" Decide if ``self`` has n-th roots. - A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cyclic type of ``self``. @@ -5545,7 +5544,6 @@ def has_nth_root(self, n): ... ValueError: n must be at least 1 """ - from sage.combinat.partition import Partitions from sage.arith.misc import divisors, gcd from sage.rings.integer import Integer @@ -5553,11 +5551,11 @@ def has_nth_root(self, n): if n < 1: raise ValueError('n must be at least 1') - Cycles = self.cycle_type().to_exp_dict() + cycles = self.cycle_type().to_exp_dict() # for each length m, check if the number of m-cycles can come from a n-th power # (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l, n)) - for m, N in Cycles.items(): + for m, N in cycles.items(): N = Integer(N) # I don't know why but ._findfirst doesn't work without parts = [x for x in divisors(n) if gcd(m*x, n) == x] if not Partitions(0, parts_in=[])._findfirst(N, parts): @@ -5568,7 +5566,7 @@ def number_of_nth_roots(self, n): r""" Return the number of n-th roots of ``self``. - A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cyclic type of ``self``. @@ -5620,18 +5618,18 @@ def number_of_nth_roots(self, n): if n < 1: raise ValueError('n must be at least 1') - Cycles = self.cycle_type().to_exp_dict() - Result = 1 - for m, N in Cycles.items(): + cycles = self.cycle_type().to_exp_dict() + result = 1 + for m, N in cycles.items(): parts = [x for x in divisors(n) if gcd(m*x, n) == x] - Result *= sum(SetPartitions(N, pa).cardinality() * + result *= sum(SetPartitions(N, pa).cardinality() * prod(factorial(x-1) * m**(x-1) for x in pa) for pa in Partitions(N, parts_in=parts)) - if not Result: + if not result: return 0 - return Result + return result def _tableau_contribution(T): r""" From e137cab0354fa1a3c99bea6ee894dc5bd151fd59 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 30 Oct 2023 11:59:46 +0000 Subject: [PATCH 275/494] Allow to import cpython module multiple times --- src/sage/cpython/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/cpython/__init__.py b/src/sage/cpython/__init__.py index 5deff221609..cb262984002 100644 --- a/src/sage/cpython/__init__.py +++ b/src/sage/cpython/__init__.py @@ -12,7 +12,8 @@ # Monkey-patch ExtensionFileLoader to allow IPython to find the sources # of Cython files. See https://github.com/sagemath/sage/issues/24681 from importlib.machinery import ExtensionFileLoader as _ExtensionFileLoader -del _ExtensionFileLoader.get_source +if hasattr(_ExtensionFileLoader, 'get_source'): + del _ExtensionFileLoader.get_source del _ExtensionFileLoader # Work around a Cygwin-specific bug caused by sqlite3; see From 437a2228d42696a164b976f0e739d7b6246acac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 13:58:44 +0100 Subject: [PATCH 276/494] Update permutation.py some details --- src/sage/combinat/permutation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 74be5244fd4..225f37796db 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5383,26 +5383,28 @@ def shifted_shuffle(self, other): return self.shifted_concatenation(other, "right").\ right_permutohedron_interval(self.shifted_concatenation(other, "left")) - def nth_roots(self, n): r""" Return all n-th roots of ``self`` (as a generator). A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of n-th roots only depend on the cyclic type of ``self``. + Note that the number of n-th roots only depend on the cycle type of ``self``. EXAMPLES:: sage: Sigma = Permutations(5).identity() sage: list(Sigma.nth_roots(3)) - [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] + [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], + [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], + [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] sage: Sigma = Permutation('(1, 3)') sage: list(Sigma.nth_roots(2)) [] - For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test their n-th power). + For n >= 6, this algorithm begins to be more efficient than naive search + (look at all permutations and test their n-th power). .. SEEALSO:: @@ -5431,7 +5433,6 @@ def nth_roots(self, n): ... ValueError: n must be at least 1 """ - from sage.combinat.partition import Partitions from sage.combinat.set_partition import SetPartitions from itertools import product @@ -5439,12 +5440,13 @@ def nth_roots(self, n): def merging_cycles(list_of_cycles): """ - Generate all l-cycles such that its n-th power is the product of cycles in Cycles (which conctains gcd(l, n) cycles of lenght l/gcd(l, n)) + Generate all l-cycles such that its n-th power is the product + of cycles in 'cycles' (which contains gcd(l, n) cycles of length l/gcd(l, n)) """ lC = len(list_of_cycles) lperm = len(list_of_cycles[0]) l = lC*lperm - perm = [0 for i in range(l)] + perm = [0] for j in range(lperm): perm[j*lC] = list_of_cycles[0][j] for p in Permutations(lC-1): @@ -5546,7 +5548,6 @@ def has_nth_root(self, n): """ from sage.combinat.partition import Partitions from sage.arith.misc import divisors, gcd - from sage.rings.integer import Integer if n < 1: raise ValueError('n must be at least 1') @@ -5556,9 +5557,8 @@ def has_nth_root(self, n): # for each length m, check if the number of m-cycles can come from a n-th power # (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l, n)) for m, N in cycles.items(): - N = Integer(N) # I don't know why but ._findfirst doesn't work without parts = [x for x in divisors(n) if gcd(m*x, n) == x] - if not Partitions(0, parts_in=[])._findfirst(N, parts): + if not Partitions(N, parts_in=parts).is_empty(): return False return True From e319091e50326c3352b09db5fc1820a66a9ebe89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 13:59:16 +0100 Subject: [PATCH 277/494] Update permutation.py --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 225f37796db..13a16535542 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5387,7 +5387,7 @@ def nth_roots(self, n): r""" Return all n-th roots of ``self`` (as a generator). - A n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cycle type of ``self``. From 3a2fcfde1fa817556459b77c4dfe5e26a26469df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 14:00:46 +0100 Subject: [PATCH 278/494] Update permutation.py --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 13a16535542..40eed1df148 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5461,7 +5461,7 @@ def rewind(L, n): """ Construct the list M such that M[(j*n)%(len(M))] == L[j]. """ - M = [0 for _ in L] + M = [0] * len(L) m = len(M) for j in range(m): M[(j*n) % m] = L[j] From 1f00dfcf33eeee438b11c007c880263ab1fa71ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 14:03:34 +0100 Subject: [PATCH 279/494] Update permutation.py --- src/sage/combinat/permutation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 40eed1df148..67759f205ff 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5408,8 +5408,8 @@ def nth_roots(self, n): .. SEEALSO:: - * :meth:`has_nth_root` - * :meth:`number_of_nth_roots` + * :meth:`has_nth_root` + * :meth:`number_of_nth_roots` TESTS: @@ -5521,8 +5521,8 @@ def has_nth_root(self, n): .. SEEALSO:: - * :meth:`nth_roots` - * :meth:`number_of_nth_roots` + * :meth:`nth_roots` + * :meth:`number_of_nth_roots` TESTS: @@ -5582,8 +5582,8 @@ def number_of_nth_roots(self, n): .. SEEALSO:: - * :meth:`nth_roots` - * :meth:`has_nth_root` + * :meth:`nth_roots` + * :meth:`has_nth_root` TESTS: From d533aad1bd4f7e0504fd41972eb7d7569491a3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 14:57:49 +0100 Subject: [PATCH 280/494] Update permutation.py less whitespace --- src/sage/combinat/permutation.py | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 67759f205ff..f008183b192 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5386,23 +5386,23 @@ def shifted_shuffle(self, other): def nth_roots(self, n): r""" Return all n-th roots of ``self`` (as a generator). - + An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cycle type of ``self``. - + EXAMPLES:: - + sage: Sigma = Permutations(5).identity() sage: list(Sigma.nth_roots(3)) [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] - + sage: Sigma = Permutation('(1, 3)') sage: list(Sigma.nth_roots(2)) [] - + For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test their n-th power). @@ -5414,10 +5414,10 @@ def nth_roots(self, n): TESTS: We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`):: - + sage: [len(list(Permutations(n).identity().nth_roots(2))) for n in range(2,8)] [2, 4, 10, 26, 76, 232] - + sage: list(Permutation('(1)').nth_roots(2)) [[1]] @@ -5427,7 +5427,7 @@ def nth_roots(self, n): sage: Sigma = Permutations(6).random_element() sage: list(Sigma.nth_roots(1)) == [Sigma] True - + sage: list(Permutations(4).identity().nth_roots(-1)) Traceback (most recent call last): ... @@ -5446,7 +5446,7 @@ def merging_cycles(list_of_cycles): lC = len(list_of_cycles) lperm = len(list_of_cycles[0]) l = lC*lperm - perm = [0] + perm = [0] * l for j in range(lperm): perm[j*lC] = list_of_cycles[0][j] for p in Permutations(lC-1): @@ -5454,7 +5454,7 @@ def merging_cycles(list_of_cycles): new_perm = list(perm) for i in range(lC-1): for j in range(lperm): - new_perm[(p[i] + (indices[i]+j)*lC) %l] = list_of_cycles[i+1][j] + new_perm[(p[i] + (indices[i]+j)*lC) % l] = list_of_cycles[i+1][j] yield Permutation(tuple(new_perm)) def rewind(L, n): @@ -5466,12 +5466,12 @@ def rewind(L, n): for j in range(m): M[(j*n) % m] = L[j] return M - + if n < 1: raise ValueError('n must be at least 1') - + P = Permutations(self.size()) - + # Creating dict {length: cycles of this length in the cycle decomposition of Sigma} cycles = {} for c in self.cycle_tuples(singletons=True): @@ -5479,9 +5479,9 @@ def rewind(L, n): if lc not in cycles: cycles[lc] = [] cycles[lc].append(c) - + # for each length m, collects all product of cycles which n-th power gives the product prod(Cycles[l]) - Possibilities = {m: [] for m in cycles} + possibilities = [[] for m in cycles] for m in cycles: N = len(cycles[m]) parts = [x for x in divisors(n) if gcd(m*x, n) == x] @@ -5492,13 +5492,13 @@ def rewind(L, n): poss = [P.identity()] for pa in partition: poss = [p*q for p in poss - for q in merging_cycles([rewind(cycles[m][i-1], n//len(pa)) for i in pa])] - Possibilities[m] += poss + for q in merging_cycles([rewind(cycles[m][i-1], n//len(pa)) for i in pa])] + possibilities[m] += poss if not b: return - + #Product of Possibilities (i.e. final result) - for L in cartesian_product(Possibilities.values()): + for L in product(*possibilities): yield P.prod(L) def has_nth_root(self, n): From 2e2b4a56130e73d2d46db223044369a35d8c7a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 15:05:14 +0100 Subject: [PATCH 281/494] Update permutation.py some fixes --- src/sage/combinat/permutation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index f008183b192..f84a31e4f21 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5482,7 +5482,7 @@ def rewind(L, n): # for each length m, collects all product of cycles which n-th power gives the product prod(Cycles[l]) possibilities = [[] for m in cycles] - for m in cycles: + for i, m in enumerate(cycles): N = len(cycles[m]) parts = [x for x in divisors(n) if gcd(m*x, n) == x] b = False @@ -5493,10 +5493,10 @@ def rewind(L, n): for pa in partition: poss = [p*q for p in poss for q in merging_cycles([rewind(cycles[m][i-1], n//len(pa)) for i in pa])] - possibilities[m] += poss + possibilities[i] += poss if not b: return - + #Product of Possibilities (i.e. final result) for L in product(*possibilities): yield P.prod(L) @@ -5558,7 +5558,7 @@ def has_nth_root(self, n): # (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l, n)) for m, N in cycles.items(): parts = [x for x in divisors(n) if gcd(m*x, n) == x] - if not Partitions(N, parts_in=parts).is_empty(): + if Partitions(N, parts_in=parts).is_empty(): return False return True From 1c3aab490b3e6187d50c4a3a3c828448c7734b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 15:20:46 +0100 Subject: [PATCH 282/494] Update permutation.py less whitespace --- src/sage/combinat/permutation.py | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index f84a31e4f21..8803c1e5053 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5398,21 +5398,21 @@ def nth_roots(self, n): [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] - + sage: Sigma = Permutation('(1, 3)') sage: list(Sigma.nth_roots(2)) [] For n >= 6, this algorithm begins to be more efficient than naive search (look at all permutations and test their n-th power). - + .. SEEALSO:: - + * :meth:`has_nth_root` * :meth:`number_of_nth_roots` - + TESTS: - + We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`):: sage: [len(list(Permutations(n).identity().nth_roots(2))) for n in range(2,8)] @@ -5504,33 +5504,33 @@ def rewind(L, n): def has_nth_root(self, n): r""" Decide if ``self`` has n-th roots. - + An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. Note that the number of n-th roots only depend on the cyclic type of ``self``. - + EXAMPLES:: - + sage: Sigma = Permutations(5).identity() sage: Sigma.has_nth_root(3) True - + sage: Sigma = Permutation('(1, 3)') sage: Sigma.has_nth_root(2) False - + .. SEEALSO:: - + * :meth:`nth_roots` * :meth:`number_of_nth_roots` - + TESTS: - + We compute the number of permutations that have square roots (i.e. squares in `S_n`, :oeis:`A003483`):: - + sage: [len([p for p in Permutations(n) if p.has_nth_root(2)]) for n in range(2, 7)] [1, 3, 12, 60, 270] - + sage: Permutation('(1)').has_nth_root(2) True @@ -5540,7 +5540,7 @@ def has_nth_root(self, n): sage: Sigma = Permutations(6).random_element() sage: Sigma.has_nth_root(1) True - + sage: Permutations(4).identity().has_nth_root(-1) Traceback (most recent call last): ... @@ -5551,7 +5551,7 @@ def has_nth_root(self, n): if n < 1: raise ValueError('n must be at least 1') - + cycles = self.cycle_type().to_exp_dict() # for each length m, check if the number of m-cycles can come from a n-th power @@ -5571,11 +5571,11 @@ def number_of_nth_roots(self, n): Note that the number of n-th roots only depend on the cyclic type of ``self``. EXAMPLES:: - + sage: Sigma = Permutations(5).identity() sage: Sigma.number_of_nth_roots(3) 21 - + sage: Sigma = Permutation('(1, 3)') sage: Sigma.number_of_nth_roots(2) 0 @@ -5588,13 +5588,13 @@ def number_of_nth_roots(self, n): TESTS: We compute the number of square roots of the identity (i.e. involutions in `S_n`, :oeis:`A000085`), then the number of cubic roots:: - + sage: [Permutations(n).identity().number_of_nth_roots(2) for n in range(2, 10)] [2, 4, 10, 26, 76, 232, 764, 2620] - + sage: [Permutations(n).identity().number_of_nth_roots(3) for n in range(2, 10)] [1, 3, 9, 21, 81, 351, 1233, 5769] - + sage: Permutation('(1)').number_of_nth_roots(2) 1 @@ -5604,7 +5604,7 @@ def number_of_nth_roots(self, n): sage: Sigma = Permutations(6).random_element() sage: Sigma.number_of_nth_roots(1) 1 - + sage: Permutations(4).identity().number_of_nth_roots(-1) Traceback (most recent call last): ... From 3a07967a35180db5759cbd99342061483d4e003f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 15:47:39 +0100 Subject: [PATCH 283/494] Update permutation.py detail --- src/sage/combinat/permutation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 8803c1e5053..02d63887339 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5507,7 +5507,7 @@ def has_nth_root(self, n): An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of n-th roots only depend on the cyclic type of ``self``. + Note that the number of n-th roots only depend on the cycle type of ``self``. EXAMPLES:: @@ -5568,7 +5568,7 @@ def number_of_nth_roots(self, n): An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. - Note that the number of n-th roots only depend on the cyclic type of ``self``. + Note that the number of n-th roots only depend on the cycle type of ``self``. EXAMPLES:: From 83242ee5da812c6f6fa697c005b56593f213f032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 15:49:19 +0100 Subject: [PATCH 284/494] Update permutation.py detail --- src/sage/combinat/permutation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 02d63887339..ef416e6d0ac 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5459,12 +5459,12 @@ def merging_cycles(list_of_cycles): def rewind(L, n): """ - Construct the list M such that M[(j*n)%(len(M))] == L[j]. + Construct the list M such that ``M[(j * n) % len(M)] == L[j]``. """ M = [0] * len(L) m = len(M) for j in range(m): - M[(j*n) % m] = L[j] + M[(j * n) % m] = L[j] return M if n < 1: @@ -5480,7 +5480,7 @@ def rewind(L, n): cycles[lc] = [] cycles[lc].append(c) - # for each length m, collects all product of cycles which n-th power gives the product prod(Cycles[l]) + # for each length m, collects all product of cycles which n-th power gives the product prod(cycles[l]) possibilities = [[] for m in cycles] for i, m in enumerate(cycles): N = len(cycles[m]) From e40f124ea28c30bc168825cffdabe6e70bc0c3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 16:50:17 +0100 Subject: [PATCH 285/494] Update permutation.py suggested details --- src/sage/combinat/permutation.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index ef416e6d0ac..a78c024a8fa 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5393,14 +5393,14 @@ def nth_roots(self, n): EXAMPLES:: - sage: Sigma = Permutations(5).identity() - sage: list(Sigma.nth_roots(3)) + sage: sigma = Permutations(5).identity() + sage: list(sigma.nth_roots(3)) [[1, 4, 3, 5, 2], [1, 5, 3, 2, 4], [1, 2, 4, 5, 3], [1, 2, 5, 3, 4], [4, 2, 3, 5, 1], [5, 2, 3, 1, 4], [3, 2, 5, 4, 1], [5, 2, 1, 4, 3], [2, 5, 3, 4, 1], [5, 1, 3, 4, 2], [2, 3, 1, 4, 5], [3, 1, 2, 4, 5], [2, 4, 3, 1, 5], [4, 1, 3, 2, 5], [3, 2, 4, 1, 5], [4, 2, 1, 3, 5], [1, 3, 4, 2, 5], [1, 4, 2, 3, 5], [1, 3, 5, 4, 2], [1, 5, 2, 4, 3], [1, 2, 3, 4, 5]] - sage: Sigma = Permutation('(1, 3)') - sage: list(Sigma.nth_roots(2)) + sage: sigma = Permutation('(1, 3)') + sage: list(sigma.nth_roots(2)) [] For n >= 6, this algorithm begins to be more efficient than naive search @@ -5424,8 +5424,8 @@ def nth_roots(self, n): sage: list(Permutation('').nth_roots(2)) [[]] - sage: Sigma = Permutations(6).random_element() - sage: list(Sigma.nth_roots(1)) == [Sigma] + sage: sigma = Permutations(6).random_element() + sage: list(sigma.nth_roots(1)) == [Sigma] True sage: list(Permutations(4).identity().nth_roots(-1)) @@ -5472,7 +5472,7 @@ def rewind(L, n): P = Permutations(self.size()) - # Creating dict {length: cycles of this length in the cycle decomposition of Sigma} + # Creating dict {length: cycles of this length in the cycle decomposition of sigma} cycles = {} for c in self.cycle_tuples(singletons=True): lc = len(c) @@ -5511,12 +5511,12 @@ def has_nth_root(self, n): EXAMPLES:: - sage: Sigma = Permutations(5).identity() - sage: Sigma.has_nth_root(3) + sage: sigma = Permutations(5).identity() + sage: sigma.has_nth_root(3) True - sage: Sigma = Permutation('(1, 3)') - sage: Sigma.has_nth_root(2) + sage: sigma = Permutation('(1, 3)') + sage: sigma.has_nth_root(2) False .. SEEALSO:: @@ -5537,8 +5537,8 @@ def has_nth_root(self, n): sage: Permutation('').has_nth_root(2) True - sage: Sigma = Permutations(6).random_element() - sage: Sigma.has_nth_root(1) + sage: sigma = Permutations(6).random_element() + sage: sigma.has_nth_root(1) True sage: Permutations(4).identity().has_nth_root(-1) @@ -5555,7 +5555,7 @@ def has_nth_root(self, n): cycles = self.cycle_type().to_exp_dict() # for each length m, check if the number of m-cycles can come from a n-th power - # (i.e. if you can partitionate m*Cycles[m] into parts of size l with l = m*gcd(l, n)) + # (i.e. if you can partition m*Cycles[m] into parts of size l with l = m*gcd(l, n)) for m, N in cycles.items(): parts = [x for x in divisors(n) if gcd(m*x, n) == x] if Partitions(N, parts_in=parts).is_empty(): From 4e8246d3521ce03b723e5703a393d03d30e49e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 17:42:31 +0100 Subject: [PATCH 286/494] some cleanup in free algebras --- src/sage/algebras/free_algebra.py | 94 +++++++++++++++++-------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/src/sage/algebras/free_algebra.py b/src/sage/algebras/free_algebra.py index 460b623b877..50793075532 100644 --- a/src/sage/algebras/free_algebra.py +++ b/src/sage/algebras/free_algebra.py @@ -127,7 +127,7 @@ NotImplementedError: polynomials over Free Algebra on 2 generators (a, b) over Integer Ring are not supported in Singular """ -#***************************************************************************** +# *************************************************************************** # Copyright (C) 2005 David Kohel # Copyright (C) 2005,2006 William Stein # Copyright (C) 2011 Simon King @@ -136,8 +136,8 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# *************************************************************************** from sage.categories.rings import Rings @@ -240,9 +240,9 @@ class FreeAlgebraFactory(UniqueFactory): a*b^2*c^3 """ def create_key(self, base_ring, arg1=None, arg2=None, - sparse=None, order=None, - names=None, name=None, - implementation=None, degrees=None): + sparse=None, order=None, + names=None, name=None, + implementation=None, degrees=None): """ Create the key under which a free algebra is stored. @@ -268,7 +268,7 @@ def create_key(self, base_ring, arg1=None, arg2=None, # this is used for pickling if degrees is None: return (base_ring,) - return tuple(degrees),base_ring + return tuple(degrees), base_ring # test if we can use libSingular/letterplace if implementation == "letterplace": if order is None: @@ -321,7 +321,6 @@ def create_object(self, version, key): Free Associative Unital Algebra on 2 generators (x, y) over Rational Field sage: FreeAlgebra.create_object('4.7.1', (QQ['x','y'],)) is FreeAlgebra(QQ,['x','y']) False - """ if len(key) == 1: from sage.algebras.letterplace.free_algebra_letterplace import FreeAlgebra_letterplace @@ -335,7 +334,7 @@ def create_object(self, version, key): FreeAlgebra = FreeAlgebraFactory('FreeAlgebra') -def is_FreeAlgebra(x): +def is_FreeAlgebra(x) -> bool: """ Return True if x is a free algebra; otherwise, return False. @@ -352,10 +351,9 @@ def is_FreeAlgebra(x): True sage: is_FreeAlgebra(FreeAlgebra(ZZ,10,'x',implementation='letterplace', degrees=list(range(1,11)))) True - """ from sage.algebras.letterplace.free_algebra_letterplace import FreeAlgebra_letterplace - return isinstance(x, (FreeAlgebra_generic,FreeAlgebra_letterplace)) + return isinstance(x, (FreeAlgebra_generic, FreeAlgebra_letterplace)) class FreeAlgebra_generic(CombinatorialFreeModule, Algebra): @@ -383,8 +381,7 @@ class FreeAlgebra_generic(CombinatorialFreeModule, Algebra): TESTS: - Free algebras commute with their base ring. - :: + Free algebras commute with their base ring:: sage: K. = FreeAlgebra(QQ) sage: K.is_commutative() @@ -463,9 +460,11 @@ def one_basis(self): """ return self._indices.one() - def is_field(self, proof=True): + def is_field(self, proof=True) -> bool: """ - Return True if this Free Algebra is a field, which is only if the + Return ``True`` if this Free Algebra is a field. + + This happens only if the base ring is a field and there are no generators EXAMPLES:: @@ -481,9 +480,9 @@ def is_field(self, proof=True): return self.base_ring().is_field(proof) return False - def is_commutative(self): + def is_commutative(self) -> bool: """ - Return True if this free algebra is commutative. + Return ``True`` if this free algebra is commutative. EXAMPLES:: @@ -496,7 +495,7 @@ def is_commutative(self): """ return self.__ngens <= 1 and self.base_ring().is_commutative() - def _repr_(self): + def _repr_(self) -> str: """ Text representation of this free algebra. @@ -514,7 +513,7 @@ def _repr_(self): return "Free Algebra on {} generators {} over {}".format( self.__ngens, self.gens(), self.base_ring()) - def _latex_(self): + def _latex_(self) -> str: r""" Return a latex representation of ``self``. @@ -588,9 +587,9 @@ def _element_constructor_(self, x): return x if P is not self.base_ring(): return self.element_class(self, x) - elif hasattr(x,'letterplace_polynomial'): + elif hasattr(x, 'letterplace_polynomial'): P = x.parent() - if self.has_coerce_map_from(P): # letterplace versus generic + if self.has_coerce_map_from(P): # letterplace versus generic ngens = P.ngens() M = self._indices @@ -598,14 +597,15 @@ def exp_to_monomial(T): out = [] for i in range(len(T)): if T[i]: - out.append((i % ngens,T[i])) + out.append((i % ngens, T[i])) return M(out) - return self.element_class(self, {exp_to_monomial(T):c for T,c in x.letterplace_polynomial().dict().items()}) + return self.element_class(self, {exp_to_monomial(T): c + for T, c in x.letterplace_polynomial().dict().items()}) # ok, not a free algebra element (or should not be viewed as one). if isinstance(x, str): from sage.misc.sage_eval import sage_eval G = self.gens() - d = {str(v): G[i] for i,v in enumerate(self.variable_names())} + d = {str(v): G[i] for i, v in enumerate(self.variable_names())} return self(sage_eval(x, locals=d)) R = self.base_ring() # coercion from free monoid @@ -619,7 +619,7 @@ def exp_to_monomial(T): # Check if it's a factorization from sage.structure.factorization import Factorization if isinstance(x, Factorization): - return self.prod(f**i for f,i in x) + return self.prod(f**i for f, i in x) # coercion via base ring x = R(x) @@ -849,38 +849,50 @@ def g_algebra(self, relations, names=None, order='degrevlex', check=True): sage: (x,y,z) = G.gens() sage: y*x -x*y + z + + TESTS:: + + sage: S = FractionField(QQ['t']) + sage: t = S.gen() + sage: F. = FreeAlgebra(S) + sage: K = F.g_algebra({y*x:-x*y+1+y}) + sage: x,y = K.gens() + sage: 1+t*y*x + (-t)*x*y + t*y + (t + 1) """ from sage.matrix.constructor import Matrix base_ring = self.base_ring() + polynomial_ring = PolynomialRing(base_ring, self.gens()) n = self.__ngens cmat = Matrix(base_ring, n) - dmat = Matrix(self, n) + dmat = Matrix(polynomial_ring, n) for i in range(n): for j in range(i + 1, n): - cmat[i,j] = 1 - for (to_commute,commuted) in relations.items(): - #This is dirty, coercion is broken - assert isinstance(to_commute, FreeAlgebraElement), to_commute.__class__ + cmat[i, j] = 1 + for to_commute, commuted in relations.items(): + # This is dirty, coercion is broken + assert isinstance(to_commute, FreeAlgebraElement), to_commute assert isinstance(commuted, FreeAlgebraElement), commuted - ((v1,e1),(v2,e2)) = list(list(to_commute)[0][0]) + (v1, e1), (v2, e2) = next(iter(to_commute))[0] assert e1 == 1 assert e2 == 1 assert v1 > v2 c_coef = None d_poly = None + reverse_monomial = v2 * v1 for m, c in commuted: - if list(m) == [(v2,1),(v1,1)]: + if m == reverse_monomial: c_coef = c # buggy coercion workaround - d_poly = commuted - self(c) * self(m) + d_poly = commuted - c * self.monomial(m) break - assert c_coef is not None, list(m) + assert c_coef is not None, m v2_ind = self.gens().index(v2) v1_ind = self.gens().index(v1) - cmat[v2_ind,v1_ind] = c_coef + cmat[v2_ind, v1_ind] = c_coef if d_poly: - dmat[v2_ind,v1_ind] = d_poly + dmat[v2_ind, v1_ind] = polynomial_ring(d_poly) from sage.rings.polynomial.plural import g_Algebra return g_Algebra(base_ring, cmat, dmat, names=names or self.variable_names(), @@ -920,18 +932,18 @@ def pbw_element(self, elt): return PBW.zero() l = {} - while elt: # != 0 + while elt: # != 0 lst = list(elt) support = [i[0].to_word() for i in lst] min_elt = support[0] - for word in support[1:len(support)-1]: + for word in support[1:len(support) - 1]: if min_elt.lex_less(word): min_elt = word coeff = lst[support.index(min_elt)][1] min_elt = min_elt.to_monoid_element() l[min_elt] = l.get(min_elt, 0) + coeff elt = elt - coeff * self.lie_polynomial(min_elt) - return PBW.sum_of_terms([(k, v) for k,v in l.items() if v != 0], distinct=True) + return PBW.sum_of_terms([(k, v) for k, v in l.items() if v != 0], distinct=True) def lie_polynomial(self, w): """ @@ -1000,10 +1012,10 @@ def lie_polynomial(self, w): if len(factor) == 1: ret = ret * self(M(factor)) continue - x,y = factor.standard_factorization() + x, y = factor.standard_factorization() x = self.lie_polynomial(M(x)) y = self.lie_polynomial(M(y)) - ret = ret * (x*y - y*x) + ret = ret * (x * y - y * x) return ret From 12c99af73e048f3d87784ef6162a550292c74ef5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 15:15:50 -0700 Subject: [PATCH 287/494] Replace relative cimports --- .../polyhedron/combinatorial_polyhedron/base.pxd | 8 ++++---- .../polyhedron/combinatorial_polyhedron/base.pyx | 6 +++--- .../combinatorial_face.pxd | 6 +++--- .../combinatorial_face.pyx | 14 +++++++------- .../combinatorial_polyhedron/conversions.pxd | 3 ++- .../combinatorial_polyhedron/conversions.pyx | 4 ++-- .../combinatorial_polyhedron/face_iterator.pxd | 8 ++++---- .../combinatorial_polyhedron/face_iterator.pyx | 9 ++++----- .../face_list_data_structure.pxd | 2 +- .../combinatorial_polyhedron/list_of_faces.pxd | 2 +- .../combinatorial_polyhedron/list_of_faces.pyx | 2 +- .../polyhedron_face_lattice.pxd | 8 ++++---- .../polyhedron_face_lattice.pyx | 8 ++++---- src/sage/geometry/triangulation/base.pyx | 4 ++-- .../automorphism_group_canonical_label.pxd | 2 +- .../automorphism_group_canonical_label.pyx | 2 +- .../perm_gps/partn_ref/canonical_augmentation.pxd | 6 +++--- .../perm_gps/partn_ref/canonical_augmentation.pyx | 2 +- .../groups/perm_gps/partn_ref/double_coset.pxd | 2 +- .../groups/perm_gps/partn_ref/double_coset.pyx | 2 +- .../perm_gps/partn_ref/refinement_binary.pxd | 4 ++-- .../perm_gps/partn_ref/refinement_binary.pyx | 4 ++-- .../perm_gps/partn_ref/refinement_graphs.pxd | 8 ++++---- .../perm_gps/partn_ref/refinement_graphs.pyx | 4 ++-- .../groups/perm_gps/partn_ref/refinement_lists.pxd | 2 +- .../groups/perm_gps/partn_ref/refinement_lists.pyx | 4 ++-- .../perm_gps/partn_ref/refinement_matrices.pxd | 4 ++-- .../perm_gps/partn_ref/refinement_matrices.pyx | 6 +++--- .../perm_gps/partn_ref/refinement_python.pxd | 2 +- .../perm_gps/partn_ref/refinement_python.pyx | 6 +++--- .../groups/perm_gps/partn_ref/refinement_sets.pxd | 6 +++--- .../groups/perm_gps/partn_ref/refinement_sets.pyx | 4 ++-- src/sage/numerical/backends/cvxopt_backend.pyx | 2 +- src/sage/numerical/backends/cvxopt_sdp_backend.pyx | 2 +- src/sage/numerical/backends/glpk_backend.pxd | 2 +- src/sage/numerical/backends/glpk_exact_backend.pxd | 2 +- src/sage/numerical/backends/matrix_sdp_backend.pxd | 3 ++- src/sage/numerical/backends/matrix_sdp_backend.pyx | 2 +- src/sage/numerical/backends/ppl_backend.pyx | 2 +- src/sage/numerical/backends/scip_backend.pxd | 2 +- src/sage/plot/plot3d/base.pyx | 2 +- src/sage/plot/plot3d/index_face_set.pxd | 8 ++++++-- src/sage/plot/plot3d/index_face_set.pyx | 2 +- src/sage/plot/plot3d/parametric_surface.pxd | 5 +++-- src/sage/plot/plot3d/parametric_surface.pyx | 2 +- src/sage/plot/plot3d/shapes.pxd | 5 ++++- src/sage/plot/plot3d/shapes.pyx | 4 ++-- 47 files changed, 104 insertions(+), 95 deletions(-) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd index 030c9defa45..70755f2206c 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd @@ -1,10 +1,10 @@ cimport cython from sage.data_structures.list_of_pairs cimport ListOfPairs from sage.structure.sage_object cimport SageObject -from .face_iterator cimport FaceIterator, CombinatorialFace -from .list_of_faces cimport ListOfFaces -from .face_data_structure cimport face_t -from .polyhedron_face_lattice cimport PolyhedronFaceLattice +from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator, CombinatorialFace +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice cimport PolyhedronFaceLattice @cython.final cdef class CombinatorialPolyhedron(SageObject): diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index 5a07abb2408..57bd6f1176e 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -98,14 +98,14 @@ from .conversions \ incidence_matrix_to_bit_rep_of_Vrep, \ facets_tuple_to_bit_rep_of_facets, \ facets_tuple_to_bit_rep_of_Vrep -from .conversions cimport Vrep_list_to_bit_rep +from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport Vrep_list_to_bit_rep from sage.misc.cachefunc import cached_method from sage.rings.integer cimport smallInteger from cysignals.signals cimport sig_check -from .face_data_structure cimport face_len_atoms, face_init, face_free -from .face_iterator cimport iter_t, parallel_f_vector +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_len_atoms, face_init, face_free +from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport iter_t, parallel_f_vector cdef extern from "Python.h": diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd index 9193a5417a9..5c80654faf3 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd @@ -1,8 +1,8 @@ cimport cython from sage.structure.sage_object cimport SageObject -from .list_of_faces cimport ListOfFaces -from .face_data_structure cimport face_t -from .face_iterator cimport FaceIterator +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator @cython.final cdef class CombinatorialFace(SageObject): diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx index bf01025707f..5651ff3e6ea 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx @@ -68,13 +68,13 @@ from cysignals.memory cimport check_allocarray, sig_free import numbers from sage.rings.integer cimport smallInteger -from .conversions cimport bit_rep_to_Vrep_list -from .base cimport CombinatorialPolyhedron -from .face_iterator cimport FaceIterator_base, FaceStatus -from .polyhedron_face_lattice cimport PolyhedronFaceLattice -from .face_data_structure cimport face_len_atoms, face_init, face_free, face_copy, face_issubset -from .face_list_data_structure cimport bit_rep_to_coatom_rep -from .list_of_faces cimport face_as_combinatorial_polyhedron +from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport bit_rep_to_Vrep_list +from sage.geometry.polyhedron.combinatorial_polyhedron.base cimport CombinatorialPolyhedron +from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator_base, FaceStatus +from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice cimport PolyhedronFaceLattice +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_len_atoms, face_init, face_free, face_copy, face_issubset +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport bit_rep_to_coatom_rep +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport face_as_combinatorial_polyhedron cdef extern from "Python.h": diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd index 82ac7f6dcb8..2a0e950b469 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd @@ -1,4 +1,5 @@ -from .face_list_data_structure cimport face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport face_t + cdef int Vrep_list_to_bit_rep(tuple Vrep_list, face_t output) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx index baeb8fc4855..26aa92a6575 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx @@ -72,8 +72,8 @@ from memory_allocator cimport MemoryAllocator from sage.matrix.matrix_dense cimport Matrix_dense -from .list_of_faces cimport ListOfFaces -from .face_data_structure cimport face_next_atom, face_add_atom_safe, facet_set_coatom, face_clear +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_next_atom, face_add_atom_safe, facet_set_coatom, face_clear cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd index 1dd74505306..c0fe019cbbb 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd @@ -1,9 +1,9 @@ cimport cython from sage.structure.sage_object cimport SageObject -from .list_of_faces cimport ListOfFaces -from .face_data_structure cimport face_t -from .face_list_data_structure cimport face_list_t -from .combinatorial_face cimport CombinatorialFace +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport face_list_t +from sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face cimport CombinatorialFace cdef enum FaceStatus: NOT_INITIALIZED diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index f03f0f832ff..919dfd080c1 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -176,14 +176,13 @@ AUTHOR: from cython.parallel cimport prange, threadid from cysignals.memory cimport check_allocarray, sig_free +from cysignals.signals cimport sig_check from memory_allocator cimport MemoryAllocator -from cysignals.signals cimport sig_check -from .conversions cimport bit_rep_to_Vrep_list -from .base cimport CombinatorialPolyhedron - +from sage.geometry.polyhedron.combinatorial_polyhedron.base cimport CombinatorialPolyhedron +from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport bit_rep_to_Vrep_list +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport * from sage.geometry.polyhedron.face import combinatorial_face_to_polyhedral_face, PolyhedronFace -from .face_list_data_structure cimport * cdef extern from "Python.h": diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd index 79b319e1982..cd6d6d24333 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd @@ -14,7 +14,7 @@ Inline cython methods for lists of faces. cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython -from .face_data_structure cimport * +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport * from libc.string cimport memset from cysignals.signals cimport sig_check from cysignals.memory cimport check_allocarray, check_calloc, sig_free diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd index d16065979eb..6f2728c99ff 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd @@ -1,5 +1,5 @@ cimport cython -from .face_list_data_structure cimport face_list_t, face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport face_list_t, face_t @cython.final cdef class ListOfFaces: diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx index dffa76036fa..da065bf0d6d 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx @@ -92,7 +92,7 @@ AUTHOR: from sage.matrix.matrix_dense cimport Matrix_dense -from .face_list_data_structure cimport * +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport * cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd index 4e7987b0d7a..9b42c80ab8a 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd @@ -1,8 +1,8 @@ cimport cython -from .list_of_faces cimport ListOfFaces -from .face_data_structure cimport face_t -from .face_list_data_structure cimport face_list_t -from .combinatorial_face cimport CombinatorialFace +from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces +from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_t +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport face_list_t +from sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face cimport CombinatorialFace @cython.final cdef class PolyhedronFaceLattice: diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx index be6ffbda794..05a9e9d1d9a 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx @@ -64,11 +64,11 @@ from .conversions \ import facets_tuple_to_bit_rep_of_facets, \ facets_tuple_to_bit_rep_of_Vrep -from .conversions cimport bit_rep_to_Vrep_list +from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport bit_rep_to_Vrep_list -from .base cimport CombinatorialPolyhedron -from .face_iterator cimport FaceIterator -from .face_list_data_structure cimport * +from sage.geometry.polyhedron.combinatorial_polyhedron.base cimport CombinatorialPolyhedron +from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator +from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport * cdef extern from "Python.h": diff --git a/src/sage/geometry/triangulation/base.pyx b/src/sage/geometry/triangulation/base.pyx index d66186db098..c4d284a12c8 100644 --- a/src/sage/geometry/triangulation/base.pyx +++ b/src/sage/geometry/triangulation/base.pyx @@ -27,8 +27,8 @@ from sage.structure.parent cimport Parent from sage.categories.sets_cat import Sets from sage.matrix.constructor import matrix -from .functions cimport binomial -from .triangulations cimport \ +from sage.geometry.triangulation.functions cimport binomial +from sage.geometry.triangulation.triangulations cimport \ triangulations_ptr, init_triangulations, next_triangulation, delete_triangulations diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd index 5fe1ebd140d..4c24d59a17a 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset cimport bitset_t from sage.rings.integer cimport Integer diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 04d978afef3..da9dfac8285 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -113,7 +113,7 @@ REFERENCE: from libc.string cimport memcmp, memcpy from cysignals.memory cimport sig_malloc, sig_realloc, sig_free -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset_base cimport * cdef inline int agcl_cmp(int a, int b): diff --git a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd index dfcf347df4c..a8ae659a5ac 100644 --- a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd +++ b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd @@ -17,13 +17,13 @@ AUTHORS: # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space, allocate_agcl_output, deallocate_agcl_output, allocate_agcl_work_space, deallocate_agcl_work_space) -from .double_coset cimport (double_coset, +from sage.groups.perm_gps.partn_ref.double_coset cimport (double_coset, dc_work_space, allocate_dc_work_space, deallocate_dc_work_space) diff --git a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx index 680dbf5675d..805c3e3fa63 100644 --- a/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx +++ b/src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx @@ -169,7 +169,7 @@ REFERENCE: from cysignals.memory cimport sig_malloc, sig_free -from .data_structures cimport* +from sage.groups.perm_gps.partn_ref.data_structures cimport* cdef void *canonical_generator_next(void *can_gen_data, int *degree, bint *mem_err): diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pxd b/src/sage/groups/perm_gps/partn_ref/double_coset.pxd index 7db1b7764c3..fcb1880ffd7 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pxd +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset cimport bitset_t from sage.rings.integer cimport Integer diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index e3c7bc75f05..0c4ae28d2ce 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -96,7 +96,7 @@ REFERENCE: from cysignals.memory cimport sig_calloc -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset_base cimport * # Functions diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd index 005142f8bc7..67ea83ef756 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pxd @@ -8,9 +8,9 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space, allocate_agcl_output, deallocate_agcl_output, allocate_agcl_work_space, deallocate_agcl_work_space) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx index 06f548f4b7c..5fdb5803944 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx @@ -28,10 +28,10 @@ REFERENCE: #***************************************************************************** from sage.data_structures.bitset_base cimport * -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.rings.integer cimport Integer from sage.structure.element import is_Matrix -from .double_coset cimport double_coset +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset cdef class LinearBinaryCodeStruct(BinaryCodeStruct): diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pxd index f26580d3010..464ddde015d 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pxd @@ -8,17 +8,17 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.graphs.base.c_graph cimport CGraph -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space, allocate_agcl_output, deallocate_agcl_output, allocate_agcl_work_space, deallocate_agcl_work_space) -from .canonical_augmentation cimport (iterator, +from sage.groups.perm_gps.partn_ref.canonical_augmentation cimport (iterator, canonical_generator_data, allocate_cgd, deallocate_cgd, canonical_generator_next, setup_canonical_generator, start_canonical_generator) -from .refinement_sets cimport (subset, free_subset, all_set_children_are_equivalent, +from sage.groups.perm_gps.partn_ref.refinement_sets cimport (subset, free_subset, all_set_children_are_equivalent, refine_set, compare_sets, generate_child_subsets, apply_subset_aug, canonical_set_parent, allocate_sgd, deallocate_sgd, allocate_subset_gen, free_subset_gen, setup_set_gen, subset_generator_next, subset_generator_data, allocate_subset_gen_2) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index cafe8a26c75..f683be1fe02 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -20,12 +20,12 @@ REFERENCE: # https://www.gnu.org/licenses/ # **************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset_base cimport * from sage.rings.integer cimport Integer from sage.graphs.base.sparse_graph cimport SparseGraph from sage.graphs.base.dense_graph cimport DenseGraph, copy_dense_graph -from .double_coset cimport double_coset +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset def isomorphic(G1, G2, partn, ordering2, dig, use_indicator_function, sparse=False): diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd index 898dfa97528..691dbce64d7 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pxd @@ -9,7 +9,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * # name of the three functions to customize diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx index 5942edd5438..3c2a504ccc1 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx @@ -20,8 +20,8 @@ EXAMPLES:: from cysignals.memory cimport sig_malloc, sig_free -from .data_structures cimport * -from .double_coset cimport double_coset, int_cmp +from sage.groups.perm_gps.partn_ref.data_structures cimport * +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset, int_cmp def is_isomorphic(self, other): diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd index 0273291f014..ac485f81f6c 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pxd @@ -8,9 +8,9 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space, allocate_agcl_output, deallocate_agcl_output, allocate_agcl_work_space, deallocate_agcl_work_space) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx index e2388616a34..3b919fa8928 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx @@ -28,12 +28,12 @@ REFERENCE: from libc.string cimport memcmp -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * from sage.data_structures.bitset_base cimport * from sage.rings.integer cimport Integer from sage.matrix.constructor import Matrix -from .refinement_binary cimport NonlinearBinaryCodeStruct, refine_by_bip_degree -from .double_coset cimport double_coset +from sage.groups.perm_gps.partn_ref.refinement_binary cimport NonlinearBinaryCodeStruct, refine_by_bip_degree +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset cdef class MatrixStruct: diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_python.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_python.pxd index 1c13cb9c337..9f46107a1c1 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_python.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_python.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * +from sage.groups.perm_gps.partn_ref.data_structures cimport * cdef class PythonPartitionStack: diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx index 4d53f3a0332..2fea70526aa 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx @@ -32,11 +32,11 @@ debugger. from cysignals.memory cimport sig_malloc, sig_free -from .data_structures cimport * -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.data_structures cimport * +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, deallocate_agcl_output) -from .double_coset cimport double_coset +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset from sage.rings.integer cimport Integer diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd index 19f60c7f153..981a188918a 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pxd @@ -17,12 +17,12 @@ AUTHORS: # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * -from .automorphism_group_canonical_label cimport ( +from sage.groups.perm_gps.partn_ref.data_structures cimport * +from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport ( get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space, allocate_agcl_output, deallocate_agcl_output, allocate_agcl_work_space, deallocate_agcl_work_space) -from .canonical_augmentation cimport (iterator, +from sage.groups.perm_gps.partn_ref.canonical_augmentation cimport (iterator, canonical_generator_data, allocate_cgd, deallocate_cgd, canonical_generator_next, setup_canonical_generator, start_canonical_generator) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx index 7affe0cd965..0b4dd4b0dd8 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx @@ -26,8 +26,8 @@ REFERENCE: # http://www.gnu.org/licenses/ #***************************************************************************** -from .data_structures cimport * -from .double_coset cimport double_coset +from sage.groups.perm_gps.partn_ref.data_structures cimport * +from sage.groups.perm_gps.partn_ref.double_coset cimport double_coset from sage.data_structures.bitset_base cimport * diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 22bdfd20ea6..372e66e4110 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -18,7 +18,7 @@ AUTHORS: #***************************************************************************** from sage.numerical.mip import MIPSolverException -from .generic_backend cimport GenericBackend +from sage.numerical.backends.generic_backend cimport GenericBackend from copy import copy diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index bb999559ee2..79461a3c33a 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -21,7 +21,7 @@ AUTHORS: from sage.numerical.sdp import SDPSolverException from sage.matrix.constructor import Matrix -from .matrix_sdp_backend cimport MatrixSDPBackend +from sage.numerical.backends.matrix_sdp_backend cimport MatrixSDPBackend cdef class CVXOPTSDPBackend(MatrixSDPBackend): diff --git a/src/sage/numerical/backends/glpk_backend.pxd b/src/sage/numerical/backends/glpk_backend.pxd index 03dbe2c8688..ec263a729e4 100644 --- a/src/sage/numerical/backends/glpk_backend.pxd +++ b/src/sage/numerical/backends/glpk_backend.pxd @@ -9,7 +9,7 @@ #***************************************************************************** from sage.libs.glpk.types cimport glp_prob, glp_iocp, glp_smcp -from .generic_backend cimport GenericBackend +from sage.numerical.backends.generic_backend cimport GenericBackend # search_tree_data_t: diff --git a/src/sage/numerical/backends/glpk_exact_backend.pxd b/src/sage/numerical/backends/glpk_exact_backend.pxd index ed55d9bce3e..8207347ce51 100644 --- a/src/sage/numerical/backends/glpk_exact_backend.pxd +++ b/src/sage/numerical/backends/glpk_exact_backend.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .glpk_backend cimport GLPKBackend +from sage.numerical.backends.glpk_backend cimport GLPKBackend cdef class GLPKExactBackend(GLPKBackend): cpdef int add_variable(self, lower_bound=*, upper_bound=*, binary=*, continuous=*, integer=*, obj=*, name=*) except -1 diff --git a/src/sage/numerical/backends/matrix_sdp_backend.pxd b/src/sage/numerical/backends/matrix_sdp_backend.pxd index 4ebbf01a16d..9038955f83a 100644 --- a/src/sage/numerical/backends/matrix_sdp_backend.pxd +++ b/src/sage/numerical/backends/matrix_sdp_backend.pxd @@ -1,4 +1,5 @@ -from .generic_sdp_backend cimport GenericSDPBackend +from sage.numerical.backends.generic_sdp_backend cimport GenericSDPBackend + cdef class MatrixSDPBackend(GenericSDPBackend): diff --git a/src/sage/numerical/backends/matrix_sdp_backend.pyx b/src/sage/numerical/backends/matrix_sdp_backend.pyx index 7668c64ecc1..dc8588c71ef 100644 --- a/src/sage/numerical/backends/matrix_sdp_backend.pyx +++ b/src/sage/numerical/backends/matrix_sdp_backend.pyx @@ -21,7 +21,7 @@ other classes implementing solvers. #***************************************************************************** from sage.matrix.constructor import Matrix -from .generic_sdp_backend cimport GenericSDPBackend +from sage.numerical.backends.generic_sdp_backend cimport GenericSDPBackend cdef class MatrixSDPBackend(GenericSDPBackend): diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index 03b54b34359..a37c49be597 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -23,7 +23,7 @@ from sage.numerical.mip import MIPSolverException from ppl import MIP_Problem, Variable, Variables_Set, Linear_Expression from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational -from .generic_backend cimport GenericBackend +from sage.numerical.backends.generic_backend cimport GenericBackend from copy import copy diff --git a/src/sage/numerical/backends/scip_backend.pxd b/src/sage/numerical/backends/scip_backend.pxd index dc4981a89c3..0cd0600f955 100644 --- a/src/sage/numerical/backends/scip_backend.pxd +++ b/src/sage/numerical/backends/scip_backend.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .generic_backend cimport GenericBackend +from sage.numerical.backends.generic_backend cimport GenericBackend cdef class SCIPBackend(GenericBackend): diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index 85510d0c33a..bccc3e76b99 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -64,7 +64,7 @@ from sage.misc.fast_methods cimport hash_by_id from sage.modules.free_module_element import vector from sage.rings.real_double import RDF from .texture import Texture -from .transform cimport Transformation, point_c, face_c +from sage.plot.plot3d.transform cimport Transformation, point_c, face_c include "point_c.pxi" from sage.interfaces.tachyon import tachyon_rt diff --git a/src/sage/plot/plot3d/index_face_set.pxd b/src/sage/plot/plot3d/index_face_set.pxd index 3b42507ff62..5a81bd32de1 100644 --- a/src/sage/plot/plot3d/index_face_set.pxd +++ b/src/sage/plot/plot3d/index_face_set.pxd @@ -1,5 +1,6 @@ -from .base cimport PrimitiveObject -from .transform cimport point_c, face_c, color_c +from sage.plot.plot3d.base cimport PrimitiveObject +from sage.plot.plot3d.transform cimport point_c, face_c, color_c + cdef class IndexFaceSet(PrimitiveObject): cdef bint enclosed @@ -13,15 +14,18 @@ cdef class IndexFaceSet(PrimitiveObject): # array used as storage for _faces[i].vertices cdef int* face_indices + cdef class FaceIter: cdef Py_ssize_t i cdef IndexFaceSet set + cdef class EdgeIter: cdef Py_ssize_t i, j cdef object seen cdef IndexFaceSet set + cdef class VertexIter: cdef Py_ssize_t i cdef IndexFaceSet set diff --git a/src/sage/plot/plot3d/index_face_set.pyx b/src/sage/plot/plot3d/index_face_set.pyx index 3968db3ab51..32e7ce935eb 100644 --- a/src/sage/plot/plot3d/index_face_set.pyx +++ b/src/sage/plot/plot3d/index_face_set.pyx @@ -62,7 +62,7 @@ from sage.plot.colors import Color, float_to_integer from sage.plot.plot3d.base import Graphics3dGroup from sage.plot.plot3d.texture import Texture -from .transform cimport Transformation +from sage.plot.plot3d.transform cimport Transformation # -------------------------------------------------------------------- diff --git a/src/sage/plot/plot3d/parametric_surface.pxd b/src/sage/plot/plot3d/parametric_surface.pxd index 47265921622..82ac1164f8a 100644 --- a/src/sage/plot/plot3d/parametric_surface.pxd +++ b/src/sage/plot/plot3d/parametric_surface.pxd @@ -1,5 +1,6 @@ -from .index_face_set cimport IndexFaceSet -from .transform cimport point_c +from sage.plot.plot3d.index_face_set cimport IndexFaceSet +from sage.plot.plot3d.transform cimport point_c + cdef class ParametricSurface(IndexFaceSet): cdef object f diff --git a/src/sage/plot/plot3d/parametric_surface.pyx b/src/sage/plot/plot3d/parametric_surface.pyx index 11676df7dfe..9c09e6e7cb9 100644 --- a/src/sage/plot/plot3d/parametric_surface.pyx +++ b/src/sage/plot/plot3d/parametric_surface.pyx @@ -123,7 +123,7 @@ from sage.rings.real_double import RDF from sage.plot.colors import check_color_data from .base import RenderParams -from .transform cimport point_c, face_c +from sage.plot.plot3d.transform cimport point_c, face_c from sage.ext.interpreters.wrapper_rdf cimport Wrapper_rdf include "point_c.pxi" diff --git a/src/sage/plot/plot3d/shapes.pxd b/src/sage/plot/plot3d/shapes.pxd index 37a85c19223..d01e2a7460d 100644 --- a/src/sage/plot/plot3d/shapes.pxd +++ b/src/sage/plot/plot3d/shapes.pxd @@ -1,4 +1,4 @@ -from .parametric_surface cimport ParametricSurface +from sage.plot.plot3d.parametric_surface cimport ParametricSurface cdef class Cone(ParametricSurface): @@ -6,13 +6,16 @@ cdef class Cone(ParametricSurface): cdef double height cdef bint closed + cdef class Cylinder(ParametricSurface): cdef double radius cdef double height cdef bint closed + cdef class Sphere(ParametricSurface): cdef double radius + cdef class Torus(ParametricSurface): cdef double R, r diff --git a/src/sage/plot/plot3d/shapes.pyx b/src/sage/plot/plot3d/shapes.pyx index f5c98fe3929..73717922468 100644 --- a/src/sage/plot/plot3d/shapes.pyx +++ b/src/sage/plot/plot3d/shapes.pyx @@ -57,8 +57,8 @@ from sage.rings.real_double import RDF from sage.modules.free_module_element import vector from sage.misc.decorators import rename_keyword from .base import Graphics3dGroup -from .index_face_set cimport IndexFaceSet, PrimitiveObject -from .transform cimport point_c +from sage.plot.plot3d.index_face_set cimport IndexFaceSet, PrimitiveObject +from sage.plot.plot3d.transform cimport point_c # Helper function to check that Box input is right From b9b9bc80d9e59a1365766aba5106208cd6d48c0f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:25:37 -0700 Subject: [PATCH 288/494] Replace relative imports in Cython files --- src/sage/groups/matrix_gps/group_element.pyx | 2 +- src/sage/plot/plot3d/base.pyx | 8 ++++---- src/sage/plot/plot3d/index_face_set.pyx | 2 +- src/sage/plot/plot3d/parametric_surface.pyx | 2 +- src/sage/plot/plot3d/shapes.pyx | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 2764e33a7a8..38bf1f03279 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -84,7 +84,7 @@ from sage.structure.richcmp cimport richcmp try: - from .group_element_gap import MatrixGroupElement_gap + from sage.groups.matrix_gps.group_element_gap import MatrixGroupElement_gap except ImportError: MatrixGroupElement_gap = () diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx index bccc3e76b99..253f152130c 100644 --- a/src/sage/plot/plot3d/base.pyx +++ b/src/sage/plot/plot3d/base.pyx @@ -63,7 +63,7 @@ from sage.misc.temporary_file import tmp_filename from sage.misc.fast_methods cimport hash_by_id from sage.modules.free_module_element import vector from sage.rings.real_double import RDF -from .texture import Texture +from sage.plot.plot3d.texture import Texture from sage.plot.plot3d.transform cimport Transformation, point_c, face_c include "point_c.pxi" @@ -502,7 +502,7 @@ cdef class Graphics3d(SageObject): js_options['axesLabelsStyle'] = None if js_options['axesLabelsStyle'] is not None: - from .shapes import _validate_threejs_text_style + from sage.plot.plot3d.shapes import _validate_threejs_text_style style = js_options['axesLabelsStyle'] if isinstance(style, dict): style = _validate_threejs_text_style(style) @@ -1552,7 +1552,7 @@ end_scene""".format( T = [xyz_min[i] - a_min[i] for i in range(3)] X = X.translate(T) if frame: - from .shapes2 import frame3d, frame_labels + from sage.plot.plot3d.shapes2 import frame3d, frame_labels F = frame3d(xyz_min, xyz_max, opacity=0.5, color=(0,0,0), thickness=thickness) if labels: F += frame_labels(xyz_min, xyz_max, a_min_orig, a_max_orig) @@ -1561,7 +1561,7 @@ end_scene""".format( if axes: # draw axes - from .shapes import arrow3d + from sage.plot.plot3d.shapes import arrow3d A = (arrow3d((min(0,a_min[0]),0, 0), (max(0,a_max[0]), 0,0), thickness, color="blue"), arrow3d((0,min(0,a_min[1]), 0), (0, max(0,a_max[1]), 0), diff --git a/src/sage/plot/plot3d/index_face_set.pyx b/src/sage/plot/plot3d/index_face_set.pyx index 32e7ce935eb..6ac24479e67 100644 --- a/src/sage/plot/plot3d/index_face_set.pyx +++ b/src/sage/plot/plot3d/index_face_set.pyx @@ -1550,7 +1550,7 @@ cdef class IndexFaceSet(PrimitiveObject): str(self.fcount + extra_faces), faces] - from .base import flatten_list + from sage.plot.plot3d.base import flatten_list name = render_params.unique_name('obj') all = flatten_list(all) if render_params.output_archive: diff --git a/src/sage/plot/plot3d/parametric_surface.pyx b/src/sage/plot/plot3d/parametric_surface.pyx index 9c09e6e7cb9..fa2fd91b550 100644 --- a/src/sage/plot/plot3d/parametric_surface.pyx +++ b/src/sage/plot/plot3d/parametric_surface.pyx @@ -122,7 +122,7 @@ from math import cos, sin from sage.rings.real_double import RDF from sage.plot.colors import check_color_data -from .base import RenderParams +from sage.plot.plot3d.base import RenderParams from sage.plot.plot3d.transform cimport point_c, face_c from sage.ext.interpreters.wrapper_rdf cimport Wrapper_rdf diff --git a/src/sage/plot/plot3d/shapes.pyx b/src/sage/plot/plot3d/shapes.pyx index 73717922468..e184075b23b 100644 --- a/src/sage/plot/plot3d/shapes.pyx +++ b/src/sage/plot/plot3d/shapes.pyx @@ -56,7 +56,7 @@ from libc.math cimport sqrt, sin, cos, acos, M_PI from sage.rings.real_double import RDF from sage.modules.free_module_element import vector from sage.misc.decorators import rename_keyword -from .base import Graphics3dGroup +from sage.plot.plot3d.base import Graphics3dGroup from sage.plot.plot3d.index_face_set cimport IndexFaceSet, PrimitiveObject from sage.plot.plot3d.transform cimport point_c @@ -245,7 +245,7 @@ def ColorCube(size, colors, opacity=1, **kwds): all = [] kwds['opacity'] = opacity - from .texture import Texture + from sage.plot.plot3d.texture import Texture for k in range(6): all.append(IndexFaceSet([faces[k]], enclosed=True, texture=Texture(colors[k], opacity=opacity), @@ -1330,7 +1330,7 @@ def _validate_threejs_text_style(style): """ default_color = '#000000' # black color = style.get('color', default_color) - from .texture import Texture + from sage.plot.plot3d.texture import Texture try: texture = Texture(color=color) except ValueError: From ec773a7e0e6230d17dc6372c087076f83b773945 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 30 Oct 2023 17:53:41 +0000 Subject: [PATCH 289/494] Relativize header imports --- src/sage/ext/cplusplus.pxd | 2 +- src/sage/libs/ntl/convert.pyx | 2 +- src/sage/modular/arithgroup/farey_symbol.pyx | 4 ++-- src/sage/rings/padics/padic_capped_absolute_element.pyx | 2 +- src/sage/rings/padics/padic_capped_relative_element.pyx | 2 +- src/sage/rings/padics/padic_fixed_mod_element.pyx | 2 +- src/sage/rings/padics/padic_floating_point_element.pyx | 2 +- src/sage/rings/padics/pow_computer_ext.pyx | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/ext/cplusplus.pxd b/src/sage/ext/cplusplus.pxd index e504f0c9fbb..d748bf2347a 100644 --- a/src/sage/ext/cplusplus.pxd +++ b/src/sage/ext/cplusplus.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -cdef extern from "sage/ext/ccobject.h": +cdef extern from "ccobject.h": # Print representation of any C++ object str ccrepr[T](const T& x) diff --git a/src/sage/libs/ntl/convert.pyx b/src/sage/libs/ntl/convert.pyx index d06270d5077..901edf01f72 100644 --- a/src/sage/libs/ntl/convert.pyx +++ b/src/sage/libs/ntl/convert.pyx @@ -23,7 +23,7 @@ Conversion between NTL's ``ZZ`` and various other types from sage.libs.gmp.mpz cimport mpz_init, mpz_clear from sage.libs.gmp.pylong cimport mpz_set_pylong -cdef extern from "sage/libs/ntl/ntlwrap_impl.h": +cdef extern from "ntlwrap_impl.h": void ZZ_to_mpz(mpz_t output, ZZ_c* x) void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x) diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index 863c1d6b654..501211a1ed7 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -43,7 +43,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.richcmp cimport richcmp_not_equal -cdef extern from "sage/modular/arithgroup/sl2z.hpp": +cdef extern from "sl2z.hpp": cppclass cpp_SL2Z "SL2Z": mpz_class a, b, c, d cpp_SL2Z(int, int, int, int) @@ -53,7 +53,7 @@ cdef extern from "sage/modular/arithgroup/sl2z.hpp": mpz_class c() mpz_class d() -cdef extern from "sage/modular/arithgroup/farey.hpp": +cdef extern from "farey.hpp": cppclass is_element_Gamma0: is_element_Gamma0(int) cppclass is_element_Gamma1: diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pyx b/src/sage/rings/padics/padic_capped_absolute_element.pyx index 69d5b474f20..1325b805f7a 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pyx +++ b/src/sage/rings/padics/padic_capped_absolute_element.pyx @@ -25,7 +25,7 @@ include "CA_template.pxi" from sage.libs.pari.convert_gmp cimport new_gen_from_padic from sage.rings.finite_rings.integer_mod import Mod -cdef extern from "sage/rings/padics/transcendantal.c": +cdef extern from "transcendantal.c": cdef void padiclog(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp_Newton(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, unsigned long precinit, const mpz_t modulo) diff --git a/src/sage/rings/padics/padic_capped_relative_element.pyx b/src/sage/rings/padics/padic_capped_relative_element.pyx index 10db90d1342..78240b77151 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pyx +++ b/src/sage/rings/padics/padic_capped_relative_element.pyx @@ -29,7 +29,7 @@ from sage.libs.pari.convert_gmp cimport new_gen_from_padic from sage.rings.finite_rings.integer_mod import Mod from sage.rings.padics.pow_computer cimport PowComputer_class -cdef extern from "sage/rings/padics/transcendantal.c": +cdef extern from "transcendantal.c": cdef void padiclog(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp_Newton(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, unsigned long precinit, const mpz_t modulo) diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pyx b/src/sage/rings/padics/padic_fixed_mod_element.pyx index 2e9e9a1ed3b..6fd8295721c 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pyx +++ b/src/sage/rings/padics/padic_fixed_mod_element.pyx @@ -27,7 +27,7 @@ include "FM_template.pxi" from sage.libs.pari.convert_gmp cimport new_gen_from_padic from sage.rings.finite_rings.integer_mod import Mod -cdef extern from "sage/rings/padics/transcendantal.c": +cdef extern from "transcendantal.c": cdef void padiclog(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp_Newton(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, unsigned long precinit, const mpz_t modulo) diff --git a/src/sage/rings/padics/padic_floating_point_element.pyx b/src/sage/rings/padics/padic_floating_point_element.pyx index 32c8e25cde2..d4294f8452c 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pyx +++ b/src/sage/rings/padics/padic_floating_point_element.pyx @@ -25,7 +25,7 @@ from sage.libs.pari.all import pari from sage.libs.pari.convert_gmp cimport new_gen_from_padic from sage.rings.finite_rings.integer_mod import Mod -cdef extern from "sage/rings/padics/transcendantal.c": +cdef extern from "transcendantal.c": cdef void padicexp(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, const mpz_t modulo) cdef void padicexp_Newton(mpz_t ans, const mpz_t a, unsigned long p, unsigned long prec, unsigned long precinit, const mpz_t modulo) diff --git a/src/sage/rings/padics/pow_computer_ext.pyx b/src/sage/rings/padics/pow_computer_ext.pyx index 3d47d3af2f9..62dc1628494 100644 --- a/src/sage/rings/padics/pow_computer_ext.pyx +++ b/src/sage/rings/padics/pow_computer_ext.pyx @@ -68,7 +68,7 @@ from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ from sage.libs.ntl.ntl_ZZ_pX cimport ntl_ZZ_pX, ntl_ZZ_pX_Modulus from sage.rings.integer cimport Integer -cdef extern from "sage/ext/ccobject.h": +cdef extern from "ccobject.h": ZZ_c* Allocate_ZZ_array "Allocate_array"(size_t n) void Delete_ZZ_array "Delete_array"(ZZ_c* v) ZZ_pX_c* Allocate_ZZ_pX_array "Allocate_array"(size_t n) From bbd8fd2d69447f26bb175b3f99f2bffbeef46ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 30 Oct 2023 19:04:15 +0100 Subject: [PATCH 290/494] Update permutation.py fix doctest --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index a78c024a8fa..1db51dfc4a6 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5425,7 +5425,7 @@ def nth_roots(self, n): [[]] sage: sigma = Permutations(6).random_element() - sage: list(sigma.nth_roots(1)) == [Sigma] + sage: list(sigma.nth_roots(1)) == [sigma] True sage: list(Permutations(4).identity().nth_roots(-1)) From 5251c2fa964b0e510d2043fee805d9c9c95c2781 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Mon, 30 Oct 2023 15:56:20 -0700 Subject: [PATCH 291/494] sage-env: identify the version of command-line tools (OS X) --- src/bin/sage-env | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/sage-env b/src/bin/sage-env index 5c1b4b87ac7..9cdd5db453f 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -277,6 +277,15 @@ export UNAME=`uname | sed 's/CYGWIN.*/CYGWIN/' ` # Mac OS X-specific setup if [ "$UNAME" = "Darwin" ]; then export MACOSX_VERSION=`uname -r | awk -F. '{print $1}'` + # Try to identify command-line tools version. + # See https://apple.stackexchange.com/q/180957/351985. + XCLT_VERSION=`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version: / { print $NF }' | cut -d. -f-1` + # If this didn't produce an integer, set to 0. + case $XCLT_VERSION in + ''|*[!0-9]*) export XCLT_VERSION=0 ;; # bad + *) : ;; # good + esac + export XCLT_VERSION # Work around problems on recent OS X crashing with an error message # "... may have been in progress in another thread when fork() was called" # when objective-C functions are called after fork(). See Issue #25921. From eb8417b6107049f287bb8e77844732659bbe86eb Mon Sep 17 00:00:00 2001 From: Release Manager Date: Tue, 31 Oct 2023 00:08:32 +0100 Subject: [PATCH 292/494] Updated SageMath version to 10.2.beta9 --- CITATION.cff | 4 ++-- VERSION.txt | 2 +- build/pkgs/configure/checksums.ini | 6 +++--- build/pkgs/configure/package-version.txt | 2 +- build/pkgs/sage_conf/install-requires.txt | 2 +- build/pkgs/sage_docbuild/install-requires.txt | 2 +- build/pkgs/sage_setup/install-requires.txt | 2 +- build/pkgs/sage_sws2rst/install-requires.txt | 2 +- build/pkgs/sagelib/install-requires.txt | 2 +- build/pkgs/sagemath_bliss/install-requires.txt | 2 +- build/pkgs/sagemath_categories/install-requires.txt | 2 +- build/pkgs/sagemath_coxeter3/install-requires.txt | 2 +- build/pkgs/sagemath_environment/install-requires.txt | 2 +- build/pkgs/sagemath_mcqd/install-requires.txt | 2 +- build/pkgs/sagemath_meataxe/install-requires.txt | 2 +- build/pkgs/sagemath_objects/install-requires.txt | 2 +- build/pkgs/sagemath_repl/install-requires.txt | 2 +- build/pkgs/sagemath_sirocco/install-requires.txt | 2 +- build/pkgs/sagemath_tdlib/install-requires.txt | 2 +- pkgs/sage-conf/VERSION.txt | 2 +- pkgs/sage-conf_conda/VERSION.txt | 2 +- pkgs/sage-conf_pypi/VERSION.txt | 2 +- pkgs/sage-docbuild/VERSION.txt | 2 +- pkgs/sage-setup/VERSION.txt | 2 +- pkgs/sage-sws2rst/VERSION.txt | 2 +- pkgs/sagemath-bliss/VERSION.txt | 2 +- pkgs/sagemath-categories/VERSION.txt | 2 +- pkgs/sagemath-coxeter3/VERSION.txt | 2 +- pkgs/sagemath-environment/VERSION.txt | 2 +- pkgs/sagemath-mcqd/VERSION.txt | 2 +- pkgs/sagemath-meataxe/VERSION.txt | 2 +- pkgs/sagemath-objects/VERSION.txt | 2 +- pkgs/sagemath-repl/VERSION.txt | 2 +- pkgs/sagemath-sirocco/VERSION.txt | 2 +- pkgs/sagemath-tdlib/VERSION.txt | 2 +- src/VERSION.txt | 2 +- src/bin/sage-version.sh | 6 +++--- src/sage/version.py | 6 +++--- 38 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 59a1b01420e..27438597f31 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.2.beta8 +version: 10.2.beta9 doi: 10.5281/zenodo.593563 -date-released: 2023-10-21 +date-released: 2023-10-30 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index 6c7fa387f09..b2bf34c0be8 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.2.beta8, Release Date: 2023-10-21 +SageMath version 10.2.beta9, Release Date: 2023-10-30 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index 66a56ce7620..5b7360aa36d 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=a47b64722981640bd5c40772a58fbe8a717468a2 -md5=f574973a6324165ff86a354f5c3c536b -cksum=3950593257 +sha1=0f90c993748bfc21ae382ac3ce6c19b434edb36c +md5=b8d9355c732997566f68b60c8a8eb9cc +cksum=2280021929 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index d3646975c4c..d63934749a3 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -460bd3287264ae6a182e305f8de8206c1b646c45 +c0221f90a86e4b4bea4b45ff8de54727313bd755 diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt index af1494990e7..1387216d0d4 100644 --- a/build/pkgs/sage_conf/install-requires.txt +++ b/build/pkgs/sage_conf/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.2b8 +sage-conf ~= 10.2b9 diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt index 3cd4fa3a1cc..530594cb2f7 100644 --- a/build/pkgs/sage_docbuild/install-requires.txt +++ b/build/pkgs/sage_docbuild/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.2b8 +sage-docbuild ~= 10.2b9 diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt index 513270bef9b..5a9a50b1773 100644 --- a/build/pkgs/sage_setup/install-requires.txt +++ b/build/pkgs/sage_setup/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.2b8 +sage-setup ~= 10.2b9 diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt index 59a489617cb..8f0dd4150d7 100644 --- a/build/pkgs/sage_sws2rst/install-requires.txt +++ b/build/pkgs/sage_sws2rst/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.2b8 +sage-sws2rst ~= 10.2b9 diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt index 254cd68ca8b..fe389de2e2e 100644 --- a/build/pkgs/sagelib/install-requires.txt +++ b/build/pkgs/sagelib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.2b8 +sagemath-standard ~= 10.2b9 diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt index eb77a2780ee..dabe7e52643 100644 --- a/build/pkgs/sagemath_bliss/install-requires.txt +++ b/build/pkgs/sagemath_bliss/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.2b8 +sagemath-bliss ~= 10.2b9 diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt index e087dd7435e..eab5b455322 100644 --- a/build/pkgs/sagemath_categories/install-requires.txt +++ b/build/pkgs/sagemath_categories/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.2b8 +sagemath-categories ~= 10.2b9 diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt index 5fbdb88a3e4..c07ca4d5a32 100644 --- a/build/pkgs/sagemath_coxeter3/install-requires.txt +++ b/build/pkgs/sagemath_coxeter3/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.2b8 +sagemath-coxeter3 ~= 10.2b9 diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt index 16b0a20b583..7745d13c50c 100644 --- a/build/pkgs/sagemath_environment/install-requires.txt +++ b/build/pkgs/sagemath_environment/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.2b8 +sagemath-environment ~= 10.2b9 diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt index cc5aee92b75..34d46c650c9 100644 --- a/build/pkgs/sagemath_mcqd/install-requires.txt +++ b/build/pkgs/sagemath_mcqd/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.2b8 +sagemath-mcqd ~= 10.2b9 diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt index 952fc3c6fa8..3012f831c3a 100644 --- a/build/pkgs/sagemath_meataxe/install-requires.txt +++ b/build/pkgs/sagemath_meataxe/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.2b8 +sagemath-meataxe ~= 10.2b9 diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt index 1c578b75a97..35022da8fde 100644 --- a/build/pkgs/sagemath_objects/install-requires.txt +++ b/build/pkgs/sagemath_objects/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.2b8 +sagemath-objects ~= 10.2b9 diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt index b2037903a68..4c33d1b3eb0 100644 --- a/build/pkgs/sagemath_repl/install-requires.txt +++ b/build/pkgs/sagemath_repl/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.2b8 +sagemath-repl ~= 10.2b9 diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt index c62e361e6aa..bd55a958d68 100644 --- a/build/pkgs/sagemath_sirocco/install-requires.txt +++ b/build/pkgs/sagemath_sirocco/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.2b8 +sagemath-sirocco ~= 10.2b9 diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt index 745ea5ccfe1..2e291c70e25 100644 --- a/build/pkgs/sagemath_tdlib/install-requires.txt +++ b/build/pkgs/sagemath_tdlib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.2b8 +sagemath-tdlib ~= 10.2b9 diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-conf_conda/VERSION.txt +++ b/pkgs/sage-conf_conda/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/src/VERSION.txt b/src/VERSION.txt index 66f8b2a93e1..d0cd2bc56e3 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.2.beta8 +10.2.beta9 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index e627d6e96d2..392f585e5de 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.2.beta8' -SAGE_RELEASE_DATE='2023-10-21' -SAGE_VERSION_BANNER='SageMath version 10.2.beta8, Release Date: 2023-10-21' +SAGE_VERSION='10.2.beta9' +SAGE_RELEASE_DATE='2023-10-30' +SAGE_VERSION_BANNER='SageMath version 10.2.beta9, Release Date: 2023-10-30' diff --git a/src/sage/version.py b/src/sage/version.py index ab26727486a..f00a3e839af 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.2.beta8' -date = '2023-10-21' -banner = 'SageMath version 10.2.beta8, Release Date: 2023-10-21' +version = '10.2.beta9' +date = '2023-10-30' +banner = 'SageMath version 10.2.beta9, Release Date: 2023-10-30' From 57f27a05614d1ff04c75b3d55605f74bed6cdd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 30 Oct 2023 19:18:18 -0300 Subject: [PATCH 293/494] Support giac 1.9.0-67 --- src/sage/libs/giac/__init__.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py index 558cd894b13..e7d7bc67d14 100644 --- a/src/sage/libs/giac/__init__.py +++ b/src/sage/libs/giac/__init__.py @@ -172,9 +172,9 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False, sage: from sage.libs.giac import groebner_basis as gb_giac sage: P = PolynomialRing(GF(previous_prime(2**31)), 6, 'x') sage: I = sage.rings.ideal.Cyclic(P) - sage: B=gb_giac(I.gens());B - - // Groebner basis computation time ... + sage: B = gb_giac(I.gens()) + ... + sage: B Polynomial Sequence with 45 Polynomials in 6 Variables sage: B.is_groebner() True @@ -184,8 +184,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False, sage: P = PolynomialRing(GF(previous_prime(2**31)), 5, 'x') sage: I = sage.rings.ideal.Cyclic(P) sage: B = gb_giac(I.gens(), elim_variables=[P.gen(0), P.gen(2)]) - - // Groebner basis computation time ... + ... sage: B.is_groebner() True sage: B.ideal() == I.elimination_ideal([P.gen(0), P.gen(2)]) @@ -201,11 +200,10 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False, ... sage: sage.structure.proof.all.polynomial(True) sage: B2 = gb_giac(I.gens()) # long time (4s) - - // Groebner basis computation time... + ... sage: B1 == B2 # long time True - sage: B1.is_groebner() # long time (20s) + sage: B1.is_groebner() # not tested, too long time (50s) True * multi threaded operations:: @@ -253,9 +251,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False, sage: libgiac.purge('x2'),libgiac.purge('x4') (22, whywouldyoudothis) sage: gb_giac(I) # long time (3s) - - // Groebner basis computation time... - Polynomial Sequence with 74 Polynomials in 8 Variables + ...Polynomial Sequence with 74 Polynomials in 8 Variables sage: I = ideal(P(0),P(0)) sage: I.groebner_basis() == gb_giac(I) From 40296052dcb010b6230b59fbd8b5a4a84437ba4d Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 31 Oct 2023 00:58:44 +0000 Subject: [PATCH 294/494] revert sage/ext/ccobject.h in rings --- src/sage/rings/padics/pow_computer_ext.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/padics/pow_computer_ext.pyx b/src/sage/rings/padics/pow_computer_ext.pyx index 62dc1628494..3d47d3af2f9 100644 --- a/src/sage/rings/padics/pow_computer_ext.pyx +++ b/src/sage/rings/padics/pow_computer_ext.pyx @@ -68,7 +68,7 @@ from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ from sage.libs.ntl.ntl_ZZ_pX cimport ntl_ZZ_pX, ntl_ZZ_pX_Modulus from sage.rings.integer cimport Integer -cdef extern from "ccobject.h": +cdef extern from "sage/ext/ccobject.h": ZZ_c* Allocate_ZZ_array "Allocate_array"(size_t n) void Delete_ZZ_array "Delete_array"(ZZ_c* v) ZZ_pX_c* Allocate_ZZ_pX_array "Allocate_array"(size_t n) From f1368a66ef97b162206d64a41c49bc810b5d8190 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 15:15:50 -0700 Subject: [PATCH 295/494] Replace relative cimports --- .../combinat/designs/orthogonal_arrays_find_recursive.pyx | 2 +- src/sage/graphs/base/c_graph.pxd | 2 +- src/sage/graphs/base/dense_graph.pxd | 2 +- src/sage/graphs/base/graph_backends.pyx | 2 +- src/sage/graphs/base/sparse_graph.pxd | 2 +- src/sage/graphs/base/static_sparse_backend.pxd | 7 +++++-- src/sage/graphs/base/static_sparse_backend.pyx | 2 +- src/sage/graphs/base/static_sparse_graph.pyx | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 6b6bd11dfb1..753a21c8ae9 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -951,7 +951,7 @@ cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept: return False -from .designs_pyx cimport _OA_cache, _OA_cache_size +from sage.combinat.designs.designs_pyx cimport _OA_cache, _OA_cache_size cdef int is_available(int k,int n) except -1: r""" Return whether Sage can build an OA(k,n) diff --git a/src/sage/graphs/base/c_graph.pxd b/src/sage/graphs/base/c_graph.pxd index 1d5fb583eb5..b29cc3c9527 100644 --- a/src/sage/graphs/base/c_graph.pxd +++ b/src/sage/graphs/base/c_graph.pxd @@ -6,7 +6,7 @@ #************************************************************************** from sage.data_structures.bitset cimport bitset_t -from .graph_backends cimport GenericGraphBackend +from sage.graphs.base.graph_backends cimport GenericGraphBackend from libc.stdint cimport uint32_t cdef class CGraph: diff --git a/src/sage/graphs/base/dense_graph.pxd b/src/sage/graphs/base/dense_graph.pxd index f5c194cec8a..6c4145694fe 100644 --- a/src/sage/graphs/base/dense_graph.pxd +++ b/src/sage/graphs/base/dense_graph.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend from sage.data_structures.binary_matrix cimport binary_matrix_t cdef class DenseGraph(CGraph): diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx index c0ffc56533e..a09bb0cd73c 100644 --- a/src/sage/graphs/base/graph_backends.pyx +++ b/src/sage/graphs/base/graph_backends.pyx @@ -57,7 +57,7 @@ Classes and methods # (at your option) any later version. # https://www.gnu.org/licenses/ # **************************************************************************** -from .c_graph cimport CGraphBackend +from sage.graphs.base.c_graph cimport CGraphBackend cdef class GenericGraphBackend(SageObject): diff --git a/src/sage/graphs/base/sparse_graph.pxd b/src/sage/graphs/base/sparse_graph.pxd index b925e9170ec..3795c8ff0f0 100644 --- a/src/sage/graphs/base/sparse_graph.pxd +++ b/src/sage/graphs/base/sparse_graph.pxd @@ -8,7 +8,7 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from .c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend cimport cython cdef struct SparseGraphLLNode: diff --git a/src/sage/graphs/base/static_sparse_backend.pxd b/src/sage/graphs/base/static_sparse_backend.pxd index db62534cb09..fb72a89180b 100644 --- a/src/sage/graphs/base/static_sparse_backend.pxd +++ b/src/sage/graphs/base/static_sparse_backend.pxd @@ -1,7 +1,9 @@ -from .c_graph cimport CGraph, CGraphBackend -from .static_sparse_graph cimport short_digraph, ushort from libc.stdint cimport uint64_t, uint32_t, INT32_MAX, UINT32_MAX + from sage.data_structures.bitset cimport * +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.static_sparse_graph cimport short_digraph, ushort + cdef class StaticSparseCGraph(CGraph): cdef short_digraph g @@ -12,6 +14,7 @@ cdef class StaticSparseCGraph(CGraph): cpdef int out_degree(self, int u) except -1 cpdef int in_degree(self, int u) except -1 + cdef class StaticSparseBackend(CGraphBackend): cdef int _order cdef bint _multiedges diff --git a/src/sage/graphs/base/static_sparse_backend.pyx b/src/sage/graphs/base/static_sparse_backend.pyx index ae76a399240..0d1361c940a 100644 --- a/src/sage/graphs/base/static_sparse_backend.pyx +++ b/src/sage/graphs/base/static_sparse_backend.pyx @@ -43,7 +43,7 @@ from sage.graphs.base.static_sparse_graph cimport (init_short_digraph, has_edge, free_short_digraph, edge_label) -from .c_graph cimport CGraphBackend +from sage.graphs.base.c_graph cimport CGraphBackend from sage.data_structures.bitset cimport FrozenBitset from libc.stdint cimport uint32_t from sage.data_structures.bitset_base cimport * diff --git a/src/sage/graphs/base/static_sparse_graph.pyx b/src/sage/graphs/base/static_sparse_graph.pyx index 90e47b6e069..ddb30927931 100644 --- a/src/sage/graphs/base/static_sparse_graph.pyx +++ b/src/sage/graphs/base/static_sparse_graph.pyx @@ -191,8 +191,8 @@ from memory_allocator cimport MemoryAllocator from sage.data_structures.bitset_base cimport * from sage.graphs.base.c_graph cimport CGraph -from .static_sparse_backend cimport StaticSparseCGraph -from .static_sparse_backend cimport StaticSparseBackend +from sage.graphs.base.static_sparse_backend cimport StaticSparseCGraph +from sage.graphs.base.static_sparse_backend cimport StaticSparseBackend cdef extern from "fenv.h": From d486801a6a2ad28b40427f74a463bd67c9b8501b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:25:37 -0700 Subject: [PATCH 296/494] Replace relative imports in Cython files --- src/sage/coding/ag_code_decoders.pyx | 4 +-- src/sage/combinat/designs/designs_pyx.pyx | 2 +- .../designs/evenly_distributed_sets.pyx | 2 +- .../orthogonal_arrays_find_recursive.pyx | 28 +++++++++---------- src/sage/graphs/base/graph_backends.pyx | 6 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/sage/coding/ag_code_decoders.pyx b/src/sage/coding/ag_code_decoders.pyx index 162c7210fc5..15231e6aa87 100644 --- a/src/sage/coding/ag_code_decoders.pyx +++ b/src/sage/coding/ag_code_decoders.pyx @@ -66,8 +66,8 @@ from sage.rings.function_field.constructor import FunctionField from sage.modules.free_module_element import vector from sage.matrix.constructor import matrix -from .encoder import Encoder -from .decoder import Decoder, DecodingError +from sage.coding.encoder import Encoder +from sage.coding.decoder import Decoder, DecodingError from sage.modules.free_module_element cimport FreeModuleElement from sage.matrix.matrix cimport Matrix diff --git a/src/sage/combinat/designs/designs_pyx.pyx b/src/sage/combinat/designs/designs_pyx.pyx index 027cc00fbb0..d1800d4382e 100644 --- a/src/sage/combinat/designs/designs_pyx.pyx +++ b/src/sage/combinat/designs/designs_pyx.pyx @@ -804,7 +804,7 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False): Column 1 contains 2 empty entries instead of the expected lambda.u=1.1=1 False """ - from .difference_family import group_law + from sage.combinat.designs.difference_family import group_law assert k>=2 assert lmbda >=1 diff --git a/src/sage/combinat/designs/evenly_distributed_sets.pyx b/src/sage/combinat/designs/evenly_distributed_sets.pyx index 36d48d50b30..db567154ab4 100644 --- a/src/sage/combinat/designs/evenly_distributed_sets.pyx +++ b/src/sage/combinat/designs/evenly_distributed_sets.pyx @@ -310,7 +310,7 @@ cdef class EvenlyDistributedSetsBacktracker: xe = self.K.multiplicative_generator() ** (self.e) df = [[xe**j*b for b in B] for j in range((self.q-1)/(2*self.e))] if check: - from .difference_family import is_difference_family + from sage.combinat.designs.difference_family import is_difference_family if not is_difference_family(self.K, df, self.q, self.k, 1): raise RuntimeError("a wrong evenly distributed set was " "produced by the Sage library for the parameters:\n" diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 753a21c8ae9..518c7199a77 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -47,7 +47,7 @@ Functions """ from sage.misc.cachefunc import cached_function -from .orthogonal_arrays import orthogonal_array +from sage.combinat.designs.orthogonal_arrays import orthogonal_array from sage.rings.integer cimport smallInteger from sage.arith.misc import prime_powers @@ -153,7 +153,7 @@ cpdef find_product_decomposition(int k,int n) noexcept: # faster to use that rather than calling the divisors function continue if is_available(k, n1) and is_available(k, n2): - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,n1,n2,(),False) return False @@ -203,7 +203,7 @@ cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n) noexcept: is_available(k ,m+1) and is_available(k+1,r ) and is_available(k ,u )): - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,r,m,(u,),False) return False @@ -266,7 +266,7 @@ cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n) noexcept: r2 = r1_p_r2-r1 if is_available(k,r2): assert n == r*m+r1+r2 - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,r,m,(r1,r2),False) return False @@ -306,7 +306,7 @@ cpdef find_construction_3_3(int k,int n) noexcept: if (is_available(k+i, nn ) and is_available(k , mm+i)): - from .orthogonal_arrays_build_recursive import construction_3_3 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_3 return construction_3_3, (k,nn,mm,i) cpdef find_construction_3_4(int k,int n) noexcept: @@ -349,7 +349,7 @@ cpdef find_construction_3_4(int k,int n) noexcept: if (is_available(k+r+1,nn) and is_available(k , s) and (is_available(k,mm+r) or is_available(k,mm+r+1))): - from .orthogonal_arrays_build_recursive import construction_3_4 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_4 return construction_3_4, (k,nn,mm,r,s) cpdef find_construction_3_5(int k,int n) noexcept: @@ -399,7 +399,7 @@ cpdef find_construction_3_5(int k,int n) noexcept: (r==0 or is_available(k,r)) and (s==0 or is_available(k,s)) and (t==0 or is_available(k,t))): - from .orthogonal_arrays_build_recursive import construction_3_5 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_5 return construction_3_5, (k,nn,mm,r,s,t) cpdef find_construction_3_6(int k,int n) noexcept: @@ -440,7 +440,7 @@ cpdef find_construction_3_6(int k,int n) noexcept: if (is_available(k+i,nn) and smallInteger(nn).is_prime_power()): - from .orthogonal_arrays_build_recursive import construction_3_6 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_6 return construction_3_6, (k,nn,mm,i) cpdef find_q_x(int k,int n) noexcept: @@ -492,7 +492,7 @@ cpdef find_q_x(int k,int n) noexcept: # is_available(k+1,q) and is_available(k, x+2 ) and smallInteger(q).is_prime_power()): - from .orthogonal_arrays_build_recursive import construction_q_x + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_q_x return construction_q_x, (k,q,x) return False @@ -546,7 +546,7 @@ cpdef find_thwart_lemma_3_5(int k,int N) noexcept: sage: for k,n in kn: # not tested -- too long ....: assert designs.orthogonal_array(k,n,existence=True) is True """ - from .orthogonal_arrays_build_recursive import thwart_lemma_3_5 + from sage.combinat.designs.orthogonal_arrays_build_recursive import thwart_lemma_3_5 cdef int n,m,a,b,c,d,NN,na,nb,nc for n in prime_powers(k+2,N-2): # There must exist a OA(k+3,n) thus n>=k+2 @@ -661,7 +661,7 @@ cpdef find_thwart_lemma_4_1(int k,int n) noexcept: not is_available(k,mm+4)): continue - from .orthogonal_arrays_build_recursive import thwart_lemma_4_1 + from sage.combinat.designs.orthogonal_arrays_build_recursive import thwart_lemma_4_1 return thwart_lemma_4_1,(k,nn,mm) return False @@ -706,7 +706,7 @@ cpdef find_three_factor_product(int k,int n) noexcept: not is_available(k,n2) or not is_available(k,n3)): continue - from .orthogonal_arrays_build_recursive import three_factor_product + from sage.combinat.designs.orthogonal_arrays_build_recursive import three_factor_product return three_factor_product,(k-1,n1,n2,n3) return False @@ -731,7 +731,7 @@ cpdef find_brouwer_separable_design(int k,int n) noexcept: sage: find_brouwer_separable_design(5,14) False """ - from .orthogonal_arrays_build_recursive import brouwer_separable_design + from sage.combinat.designs.orthogonal_arrays_build_recursive import brouwer_separable_design cdef int q,x,baer_subplane_size, max_t, min_t, t,e1,e2,e3,e4 for q in prime_powers(2,n): @@ -945,7 +945,7 @@ cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept: values = int_as_sum(remainder, available_multipliers, r) if values is not None: - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return (wilson_construction, (None,k,r,m,[[(x,1) for x in values]])) diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx index a09bb0cd73c..863f61be013 100644 --- a/src/sage/graphs/base/graph_backends.pyx +++ b/src/sage/graphs/base/graph_backends.pyx @@ -722,9 +722,9 @@ cdef class GenericGraphBackend(SageObject): sage: loads(dumps(gi)) == gi True """ - from .static_sparse_backend import StaticSparseBackend - from .sparse_graph import SparseGraphBackend - from .dense_graph import DenseGraphBackend + from sage.graphs.base.static_sparse_backend import StaticSparseBackend + from sage.graphs.base.sparse_graph import SparseGraphBackend + from sage.graphs.base.dense_graph import DenseGraphBackend # implementation, data_structure, multiedges, directed, loops if isinstance(self, CGraphBackend): From 22f6eacb3f89b9373b5f00d8a508e6fd90f2c170 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Oct 2023 18:06:20 -0700 Subject: [PATCH 297/494] Replace relative cimports --- src/sage/matrix/change_ring.pyx | 4 ++-- src/sage/matrix/constructor.pyx | 2 +- src/sage/matrix/matrix.pxd | 2 +- src/sage/matrix/matrix1.pxd | 2 +- src/sage/matrix/matrix2.pxd | 2 +- src/sage/matrix/matrix_complex_ball_dense.pxd | 2 +- src/sage/matrix/matrix_complex_ball_dense.pyx | 2 +- src/sage/matrix/matrix_complex_double_dense.pxd | 2 +- src/sage/matrix/matrix_cyclo_dense.pxd | 4 ++-- src/sage/matrix/matrix_cyclo_dense.pyx | 6 +++--- src/sage/matrix/matrix_dense.pxd | 2 +- src/sage/matrix/matrix_domain_dense.pxd | 2 +- src/sage/matrix/matrix_domain_sparse.pxd | 2 +- src/sage/matrix/matrix_double_dense.pxd | 2 +- src/sage/matrix/matrix_double_sparse.pxd | 3 ++- src/sage/matrix/matrix_double_sparse.pyx | 5 +++-- src/sage/matrix/matrix_gap.pxd | 4 ++-- src/sage/matrix/matrix_gap.pyx | 2 +- src/sage/matrix/matrix_generic_dense.pxd | 3 ++- src/sage/matrix/matrix_generic_dense.pyx | 2 +- src/sage/matrix/matrix_generic_sparse.pxd | 3 ++- src/sage/matrix/matrix_generic_sparse.pyx | 2 +- src/sage/matrix/matrix_gf2e_dense.pxd | 2 +- src/sage/matrix/matrix_gf2e_dense.pyx | 2 +- src/sage/matrix/matrix_integer_dense.pxd | 2 +- src/sage/matrix/matrix_integer_dense.pyx | 12 ++++++------ src/sage/matrix/matrix_integer_sparse.pxd | 2 +- src/sage/matrix/matrix_integer_sparse.pyx | 8 ++++---- src/sage/matrix/matrix_mod2_dense.pyx | 2 +- src/sage/matrix/matrix_modn_dense_template.pxi | 2 +- src/sage/matrix/matrix_modn_sparse.pyx | 1 - src/sage/matrix/matrix_numpy_dense.pxd | 3 ++- src/sage/matrix/matrix_numpy_dense.pyx | 2 +- src/sage/matrix/matrix_numpy_integer_dense.pxd | 2 +- src/sage/matrix/matrix_rational_dense.pxd | 2 +- src/sage/matrix/matrix_rational_dense.pyx | 6 +++--- src/sage/matrix/matrix_rational_sparse.pxd | 2 +- src/sage/matrix/matrix_rational_sparse.pyx | 8 ++++---- src/sage/matrix/matrix_real_double_dense.pxd | 3 ++- src/sage/matrix/matrix_symbolic_dense.pxd | 3 ++- src/sage/matrix/matrix_symbolic_dense.pyx | 2 +- src/sage/matrix/matrix_symbolic_sparse.pxd | 3 ++- src/sage/matrix/matrix_symbolic_sparse.pyx | 2 +- src/sage/matrix/matrix_window.pxd | 3 ++- src/sage/matrix/misc.pyx | 6 +++--- src/sage/matrix/misc_flint.pyx | 4 ++-- src/sage/matrix/misc_mpfr.pyx | 2 +- src/sage/matrix/strassen.pyx | 2 +- src/sage/matrix/template.pxd | 3 ++- src/sage/matroids/basis_exchange_matroid.pxd | 4 ++-- src/sage/matroids/basis_exchange_matroid.pyx | 4 ++-- src/sage/matroids/basis_matroid.pxd | 6 +++--- src/sage/matroids/basis_matroid.pyx | 6 +++--- src/sage/matroids/circuit_closures_matroid.pxd | 3 ++- src/sage/matroids/circuit_closures_matroid.pyx | 4 ++-- src/sage/matroids/extension.pxd | 2 +- src/sage/matroids/extension.pyx | 2 +- src/sage/matroids/linear_matroid.pxd | 6 +++--- src/sage/matroids/matroid.pyx | 4 ++-- src/sage/matroids/union_matroid.pxd | 3 ++- src/sage/matroids/union_matroid.pyx | 2 +- src/sage/matroids/unpickling.pyx | 8 ++++---- src/sage/modules/vector_complex_double_dense.pxd | 3 ++- src/sage/modules/vector_double_dense.pxd | 3 ++- src/sage/modules/vector_integer_dense.pxd | 3 ++- src/sage/modules/vector_modn_dense.pxd | 4 ++-- src/sage/modules/vector_numpy_dense.pxd | 4 +++- src/sage/modules/vector_numpy_integer_dense.pxd | 3 ++- src/sage/modules/vector_rational_dense.pxd | 3 ++- src/sage/modules/vector_real_double_dense.pxd | 4 ++-- .../distributions/discrete_gaussian_integer.pxd | 8 ++++---- .../distributions/discrete_gaussian_integer.pyx | 6 +++--- src/sage/stats/hmm/chmm.pyx | 6 +++--- src/sage/stats/hmm/hmm.pyx | 2 +- 74 files changed, 136 insertions(+), 118 deletions(-) diff --git a/src/sage/matrix/change_ring.pyx b/src/sage/matrix/change_ring.pyx index c14d6540849..53e840b4663 100644 --- a/src/sage/matrix/change_ring.pyx +++ b/src/sage/matrix/change_ring.pyx @@ -3,8 +3,8 @@ Functions for changing the base ring of matrices quickly """ from .matrix_space import MatrixSpace -from .matrix_real_double_dense cimport Matrix_real_double_dense -from .matrix_integer_dense cimport Matrix_integer_dense +from sage.matrix.matrix_real_double_dense cimport Matrix_real_double_dense +from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense from sage.rings.real_double import RDF diff --git a/src/sage/matrix/constructor.pyx b/src/sage/matrix/constructor.pyx index a31543e0795..536fe7bdf29 100644 --- a/src/sage/matrix/constructor.pyx +++ b/src/sage/matrix/constructor.pyx @@ -14,7 +14,7 @@ General matrix Constructor and display options # http://www.gnu.org/licenses/ #***************************************************************************** -from .args cimport MatrixArgs +from sage.matrix.args cimport MatrixArgs from sage.structure.global_options import GlobalOptions diff --git a/src/sage/matrix/matrix.pxd b/src/sage/matrix/matrix.pxd index 72ba0b09531..b67ed5b4969 100644 --- a/src/sage/matrix/matrix.pxd +++ b/src/sage/matrix/matrix.pxd @@ -1 +1 @@ -from .matrix2 cimport Matrix +from sage.matrix.matrix2 cimport Matrix diff --git a/src/sage/matrix/matrix1.pxd b/src/sage/matrix/matrix1.pxd index 666cd4e6240..e3585f9caab 100644 --- a/src/sage/matrix/matrix1.pxd +++ b/src/sage/matrix/matrix1.pxd @@ -1,4 +1,4 @@ -from .matrix0 cimport Matrix as Matrix0 +from sage.matrix.matrix0 cimport Matrix as Matrix0 cdef class Matrix(Matrix0): cdef _stack_impl(self, bottom) noexcept diff --git a/src/sage/matrix/matrix2.pxd b/src/sage/matrix/matrix2.pxd index ad5bf85df04..1fd85c5f082 100644 --- a/src/sage/matrix/matrix2.pxd +++ b/src/sage/matrix/matrix2.pxd @@ -12,7 +12,7 @@ Generic matrices # http://www.gnu.org/licenses/ #***************************************************************************** -from .matrix1 cimport Matrix as Matrix1 +from sage.matrix.matrix1 cimport Matrix as Matrix1 cdef class Matrix(Matrix1): cdef _det_by_minors(self, Py_ssize_t level) noexcept diff --git a/src/sage/matrix/matrix_complex_ball_dense.pxd b/src/sage/matrix/matrix_complex_ball_dense.pxd index 622925a0ee9..9a17089a1c7 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pxd +++ b/src/sage/matrix/matrix_complex_ball_dense.pxd @@ -1,5 +1,5 @@ from sage.libs.arb.types cimport acb_mat_t -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense from sage.structure.parent cimport Parent diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx index 22366b5f1f2..54ce6002d5c 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pyx +++ b/src/sage/matrix/matrix_complex_ball_dense.pyx @@ -40,7 +40,7 @@ from sage.libs.arb.acb cimport * from sage.libs.arb.acb_mat cimport * from sage.libs.gmp.mpz cimport mpz_fits_ulong_p, mpz_get_ui from sage.matrix.constructor import matrix -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.rings.complex_interval cimport ComplexIntervalFieldElement from sage.rings.complex_arb cimport ( ComplexBall, diff --git a/src/sage/matrix/matrix_complex_double_dense.pxd b/src/sage/matrix/matrix_complex_double_dense.pxd index 0ad83958941..a9041564e43 100644 --- a/src/sage/matrix/matrix_complex_double_dense.pxd +++ b/src/sage/matrix/matrix_complex_double_dense.pxd @@ -1,4 +1,4 @@ -from .matrix_double_dense cimport Matrix_double_dense +from sage.matrix.matrix_double_dense cimport Matrix_double_dense cdef class Matrix_complex_double_dense(Matrix_double_dense): pass diff --git a/src/sage/matrix/matrix_cyclo_dense.pxd b/src/sage/matrix/matrix_cyclo_dense.pxd index 1ce4e1e1cfd..d6c8711f862 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pxd +++ b/src/sage/matrix/matrix_cyclo_dense.pxd @@ -1,6 +1,6 @@ from sage.libs.gmp.types cimport mpz_t -from .matrix_dense cimport Matrix_dense -from .matrix_rational_dense cimport Matrix_rational_dense +from sage.matrix.matrix_dense cimport Matrix_dense +from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense cdef class Matrix_cyclo_dense(Matrix_dense): diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx index c3ec3ebf81a..6a048a78edc 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -56,12 +56,12 @@ from sage.libs.flint.fmpz cimport fmpz_init, fmpz_clear, fmpz_set_mpz, fmpz_one, from sage.libs.flint.fmpq cimport fmpq_is_zero, fmpq_set_mpq, fmpq_canonicalise from sage.libs.flint.fmpq_mat cimport fmpq_mat_entry_num, fmpq_mat_entry_den, fmpq_mat_entry -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init from .constructor import matrix from .matrix_space import MatrixSpace -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix from . import matrix_dense -from .matrix_integer_dense cimport _lift_crt +from sage.matrix.matrix_integer_dense cimport _lift_crt from sage.structure.element cimport Matrix as baseMatrix from .misc_flint import matrix_integer_dense_rational_reconstruction diff --git a/src/sage/matrix/matrix_dense.pxd b/src/sage/matrix/matrix_dense.pxd index 3343438682b..30c3effe02a 100644 --- a/src/sage/matrix/matrix_dense.pxd +++ b/src/sage/matrix/matrix_dense.pxd @@ -1,4 +1,4 @@ -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix cdef class Matrix_dense(Matrix): cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept diff --git a/src/sage/matrix/matrix_domain_dense.pxd b/src/sage/matrix/matrix_domain_dense.pxd index 92e37e22afb..8a6e487c493 100644 --- a/src/sage/matrix/matrix_domain_dense.pxd +++ b/src/sage/matrix/matrix_domain_dense.pxd @@ -1,4 +1,4 @@ -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix cdef class Matrix_domain_dense(Matrix): pass diff --git a/src/sage/matrix/matrix_domain_sparse.pxd b/src/sage/matrix/matrix_domain_sparse.pxd index 42eab458643..c5882238632 100644 --- a/src/sage/matrix/matrix_domain_sparse.pxd +++ b/src/sage/matrix/matrix_domain_sparse.pxd @@ -1,4 +1,4 @@ -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix cdef class Matrix_domain_sparse(Matrix): pass diff --git a/src/sage/matrix/matrix_double_dense.pxd b/src/sage/matrix/matrix_double_dense.pxd index db1feffa053..3f2cb525b10 100644 --- a/src/sage/matrix/matrix_double_dense.pxd +++ b/src/sage/matrix/matrix_double_dense.pxd @@ -1,4 +1,4 @@ -from .matrix_numpy_dense cimport Matrix_numpy_dense +from sage.matrix.matrix_numpy_dense cimport Matrix_numpy_dense cdef class Matrix_double_dense(Matrix_numpy_dense): diff --git a/src/sage/matrix/matrix_double_sparse.pxd b/src/sage/matrix/matrix_double_sparse.pxd index ba8b303878b..0a292404338 100644 --- a/src/sage/matrix/matrix_double_sparse.pxd +++ b/src/sage/matrix/matrix_double_sparse.pxd @@ -1,4 +1,5 @@ -from .matrix_generic_sparse cimport Matrix_generic_sparse +from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse + cdef class Matrix_double_sparse(Matrix_generic_sparse): pass diff --git a/src/sage/matrix/matrix_double_sparse.pyx b/src/sage/matrix/matrix_double_sparse.pyx index adf285a311c..c82f6f838ab 100644 --- a/src/sage/matrix/matrix_double_sparse.pyx +++ b/src/sage/matrix/matrix_double_sparse.pyx @@ -1,5 +1,6 @@ -from .matrix2 cimport Matrix -from .matrix_generic_sparse cimport Matrix_generic_sparse +from sage.matrix.matrix2 cimport Matrix +from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse + cdef class Matrix_double_sparse(Matrix_generic_sparse): r""" diff --git a/src/sage/matrix/matrix_gap.pxd b/src/sage/matrix/matrix_gap.pxd index bb4801258cf..da8fe7e1277 100644 --- a/src/sage/matrix/matrix_gap.pxd +++ b/src/sage/matrix/matrix_gap.pxd @@ -1,9 +1,9 @@ -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense from sage.libs.gap.element cimport GapElement + cdef class Matrix_gap(Matrix_dense): cdef GapElement _libgap cpdef GapElement gap(self) noexcept cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept - diff --git a/src/sage/matrix/matrix_gap.pyx b/src/sage/matrix/matrix_gap.pyx index 853cb0626a1..9bdbe54a283 100644 --- a/src/sage/matrix/matrix_gap.pyx +++ b/src/sage/matrix/matrix_gap.pyx @@ -13,7 +13,7 @@ Wrappers on GAP matrices from sage.libs.gap.libgap import libgap from sage.structure.element cimport Matrix -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init cdef class Matrix_gap(Matrix_dense): diff --git a/src/sage/matrix/matrix_generic_dense.pxd b/src/sage/matrix/matrix_generic_dense.pxd index 86963fe05df..839efd22159 100644 --- a/src/sage/matrix/matrix_generic_dense.pxd +++ b/src/sage/matrix/matrix_generic_dense.pxd @@ -1,4 +1,5 @@ -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense + cdef class Matrix_generic_dense(Matrix_dense): cdef list _entries diff --git a/src/sage/matrix/matrix_generic_dense.pyx b/src/sage/matrix/matrix_generic_dense.pyx index 3e51e0d1703..527ef1b48f6 100644 --- a/src/sage/matrix/matrix_generic_dense.pyx +++ b/src/sage/matrix/matrix_generic_dense.pyx @@ -9,7 +9,7 @@ from cpython.ref cimport * cimport sage.matrix.matrix_dense as matrix_dense from . import matrix_dense -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init cimport sage.matrix.matrix as matrix diff --git a/src/sage/matrix/matrix_generic_sparse.pxd b/src/sage/matrix/matrix_generic_sparse.pxd index f4d1465318f..461fb38e18b 100644 --- a/src/sage/matrix/matrix_generic_sparse.pxd +++ b/src/sage/matrix/matrix_generic_sparse.pxd @@ -1,4 +1,5 @@ -from .matrix_sparse cimport Matrix_sparse +from sage.matrix.matrix_sparse cimport Matrix_sparse + cdef class Matrix_generic_sparse(Matrix_sparse): cdef dict _entries diff --git a/src/sage/matrix/matrix_generic_sparse.pyx b/src/sage/matrix/matrix_generic_sparse.pyx index 2570d08b55d..5fa8894c2a9 100644 --- a/src/sage/matrix/matrix_generic_sparse.pyx +++ b/src/sage/matrix/matrix_generic_sparse.pyx @@ -55,7 +55,7 @@ EXAMPLES:: """ cimport sage.matrix.matrix_sparse as matrix_sparse cimport sage.structure.element -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse): diff --git a/src/sage/matrix/matrix_gf2e_dense.pxd b/src/sage/matrix/matrix_gf2e_dense.pxd index 70391868740..485266e517b 100644 --- a/src/sage/matrix/matrix_gf2e_dense.pxd +++ b/src/sage/matrix/matrix_gf2e_dense.pxd @@ -1,6 +1,6 @@ from sage.libs.m4rie cimport mzed_t from sage.libs.m4ri cimport m4ri_word -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense cdef class Matrix_gf2e_dense(Matrix_dense): diff --git a/src/sage/matrix/matrix_gf2e_dense.pyx b/src/sage/matrix/matrix_gf2e_dense.pyx index 25db5315598..c1c3ee3a0c4 100644 --- a/src/sage/matrix/matrix_gf2e_dense.pyx +++ b/src/sage/matrix/matrix_gf2e_dense.pyx @@ -95,7 +95,7 @@ from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.misc.randstate cimport randstate, current_randstate from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.libs.m4ri cimport m4ri_word, mzd_copy from sage.libs.m4rie cimport * diff --git a/src/sage/matrix/matrix_integer_dense.pxd b/src/sage/matrix/matrix_integer_dense.pxd index d606deacc45..dcc69db5d72 100644 --- a/src/sage/matrix/matrix_integer_dense.pxd +++ b/src/sage/matrix/matrix_integer_dense.pxd @@ -1,7 +1,7 @@ from sage.libs.gmp.types cimport * from sage.libs.flint.types cimport fmpz_mat_t -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense from sage.rings.integer cimport Integer from sage.ext.mod_int cimport * diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index 207aa73a592..26e2e766d30 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -86,7 +86,7 @@ from sage.structure.proof.proof import get_flag as get_proof_flag from sage.structure.richcmp cimport rich_to_bool from sage.misc.randstate cimport randstate, current_randstate -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.args cimport SparseEntry, MatrixArgs_init ######################################################### # PARI C library @@ -114,18 +114,18 @@ from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_int from sage.structure.element cimport Element, Vector from sage.structure.element import is_Vector -from .matrix_modn_dense_float cimport Matrix_modn_dense_template -from .matrix_modn_dense_float cimport Matrix_modn_dense_float -from .matrix_modn_dense_double cimport Matrix_modn_dense_double +from sage.matrix.matrix_modn_dense_float cimport Matrix_modn_dense_template +from sage.matrix.matrix_modn_dense_float cimport Matrix_modn_dense_float +from sage.matrix.matrix_modn_dense_double cimport Matrix_modn_dense_double from .matrix_mod2_dense import Matrix_mod2_dense -from .matrix_mod2_dense cimport Matrix_mod2_dense +from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense from sage.rings.finite_rings.finite_field_constructor import GF from .matrix2 import decomp_seq -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix cimport sage.structure.element diff --git a/src/sage/matrix/matrix_integer_sparse.pxd b/src/sage/matrix/matrix_integer_sparse.pxd index d69b4879dc5..fa130f9e680 100644 --- a/src/sage/matrix/matrix_integer_sparse.pxd +++ b/src/sage/matrix/matrix_integer_sparse.pxd @@ -1,6 +1,6 @@ from sage.modules.vector_integer_sparse cimport mpz_vector from sage.ext.mod_int cimport mod_int -from .matrix_sparse cimport Matrix_sparse +from sage.matrix.matrix_sparse cimport Matrix_sparse cdef class Matrix_integer_sparse(Matrix_sparse): cdef mpz_vector* _matrix diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index 0712500e67d..16e577e9b40 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -53,15 +53,15 @@ from sage.libs.gmp.mpz cimport * from sage.rings.integer cimport Integer from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix -from .args cimport SparseEntry, MatrixArgs_init -from .matrix_integer_dense cimport Matrix_integer_dense +from sage.matrix.args cimport SparseEntry, MatrixArgs_init +from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense from sage.libs.flint.fmpz cimport fmpz_set_mpz, fmpz_get_mpz from sage.libs.flint.fmpz_poly cimport fmpz_poly_fit_length, fmpz_poly_set_coeff_mpz, _fmpz_poly_set_length from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry -from .matrix_modn_sparse cimport Matrix_modn_sparse +from sage.matrix.matrix_modn_sparse cimport Matrix_modn_sparse from sage.structure.element cimport Element import sage.matrix.matrix_space as matrix_space diff --git a/src/sage/matrix/matrix_mod2_dense.pyx b/src/sage/matrix/matrix_mod2_dense.pyx index 98708b4e9fb..1db7e22aa1a 100644 --- a/src/sage/matrix/matrix_mod2_dense.pyx +++ b/src/sage/matrix/matrix_mod2_dense.pyx @@ -109,7 +109,7 @@ from cysignals.memory cimport check_malloc, sig_free from cysignals.signals cimport sig_on, sig_str, sig_off cimport sage.matrix.matrix_dense as matrix_dense -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.args cimport SparseEntry, MatrixArgs_init from libc.stdio cimport * from sage.structure.element cimport (Matrix, Vector) from sage.modules.free_module_element cimport FreeModuleElement diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 55cff5b9ac7..afa84130974 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -123,7 +123,7 @@ from sage.structure.proof.proof import get_flag as get_proof_flag from sage.structure.richcmp cimport rich_to_bool from sage.misc.randstate cimport randstate, current_randstate import sage.matrix.matrix_space as matrix_space -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.cpython.string cimport char_to_str diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index 235fc4e7b81..edcd75a1a77 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- r""" Sparse matrices over `\ZZ/n\ZZ` for `n` small diff --git a/src/sage/matrix/matrix_numpy_dense.pxd b/src/sage/matrix/matrix_numpy_dense.pxd index fafc6fda5f7..150f9d59551 100644 --- a/src/sage/matrix/matrix_numpy_dense.pxd +++ b/src/sage/matrix/matrix_numpy_dense.pxd @@ -1,6 +1,7 @@ -from .matrix_dense cimport Matrix_dense cimport numpy as cnumpy +from sage.matrix.matrix_dense cimport Matrix_dense + cdef class Matrix_numpy_dense(Matrix_dense): cdef object _numpy_dtype diff --git a/src/sage/matrix/matrix_numpy_dense.pyx b/src/sage/matrix/matrix_numpy_dense.pyx index d0e55fa927a..262c320197b 100644 --- a/src/sage/matrix/matrix_numpy_dense.pyx +++ b/src/sage/matrix/matrix_numpy_dense.pyx @@ -40,7 +40,7 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init cimport sage.structure.element cimport numpy as cnumpy diff --git a/src/sage/matrix/matrix_numpy_integer_dense.pxd b/src/sage/matrix/matrix_numpy_integer_dense.pxd index c74a2c7511c..3116f89d8e2 100644 --- a/src/sage/matrix/matrix_numpy_integer_dense.pxd +++ b/src/sage/matrix/matrix_numpy_integer_dense.pxd @@ -1,4 +1,4 @@ -from .matrix_numpy_dense cimport Matrix_numpy_dense +from sage.matrix.matrix_numpy_dense cimport Matrix_numpy_dense cdef class Matrix_numpy_integer_dense(Matrix_numpy_dense): diff --git a/src/sage/matrix/matrix_rational_dense.pxd b/src/sage/matrix/matrix_rational_dense.pxd index 64d2c646e51..6a6347f4926 100644 --- a/src/sage/matrix/matrix_rational_dense.pxd +++ b/src/sage/matrix/matrix_rational_dense.pxd @@ -1,5 +1,5 @@ from sage.libs.flint.types cimport fmpz_t, fmpq_mat_t -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense cdef class Matrix_rational_dense(Matrix_dense): cdef fmpq_mat_t _matrix diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index 4f1e5e415e1..dd5118785bb 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -104,9 +104,9 @@ cimport sage.structure.element from sage.structure.richcmp cimport rich_to_bool from sage.rings.rational cimport Rational -from .matrix cimport Matrix -from .args cimport SparseEntry, MatrixArgs_init -from .matrix_integer_dense cimport Matrix_integer_dense, _lift_crt +from sage.matrix.matrix cimport Matrix +from sage.matrix.args cimport SparseEntry, MatrixArgs_init +from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense, _lift_crt from sage.structure.element cimport Element, Vector from sage.rings.integer cimport Integer from sage.rings.ring import is_Ring diff --git a/src/sage/matrix/matrix_rational_sparse.pxd b/src/sage/matrix/matrix_rational_sparse.pxd index 56ff6ff26a3..c754850bee9 100644 --- a/src/sage/matrix/matrix_rational_sparse.pxd +++ b/src/sage/matrix/matrix_rational_sparse.pxd @@ -1,6 +1,6 @@ from sage.libs.gmp.types cimport mpz_t from sage.modules.vector_rational_sparse cimport mpq_vector -from .matrix_sparse cimport Matrix_sparse +from sage.matrix.matrix_sparse cimport Matrix_sparse cdef class Matrix_rational_sparse(Matrix_sparse): diff --git a/src/sage/matrix/matrix_rational_sparse.pyx b/src/sage/matrix/matrix_rational_sparse.pyx index 497c58408b7..41dacbff1c7 100644 --- a/src/sage/matrix/matrix_rational_sparse.pyx +++ b/src/sage/matrix/matrix_rational_sparse.pyx @@ -35,8 +35,8 @@ from cpython.sequence cimport * from sage.rings.rational cimport Rational from sage.rings.integer cimport Integer -from .matrix cimport Matrix -from .args cimport SparseEntry, MatrixArgs_init +from sage.matrix.matrix cimport Matrix +from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.libs.gmp.mpz cimport * from sage.libs.gmp.mpq cimport * @@ -51,8 +51,8 @@ cimport sage.structure.element import sage.matrix.matrix_space -from .matrix_integer_sparse cimport Matrix_integer_sparse -from .matrix_rational_dense cimport Matrix_rational_dense +from sage.matrix.matrix_integer_sparse cimport Matrix_integer_sparse +from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense cdef class Matrix_rational_sparse(Matrix_sparse): diff --git a/src/sage/matrix/matrix_real_double_dense.pxd b/src/sage/matrix/matrix_real_double_dense.pxd index 3be163114c5..d0badf48240 100644 --- a/src/sage/matrix/matrix_real_double_dense.pxd +++ b/src/sage/matrix/matrix_real_double_dense.pxd @@ -1,4 +1,5 @@ -from .matrix_double_dense cimport Matrix_double_dense +from sage.matrix.matrix_double_dense cimport Matrix_double_dense + cdef class Matrix_real_double_dense(Matrix_double_dense): cdef set_unsafe_double(self, Py_ssize_t i, Py_ssize_t j, double value) noexcept diff --git a/src/sage/matrix/matrix_symbolic_dense.pxd b/src/sage/matrix/matrix_symbolic_dense.pxd index 9ae644a8815..aa85e4c6a21 100644 --- a/src/sage/matrix/matrix_symbolic_dense.pxd +++ b/src/sage/matrix/matrix_symbolic_dense.pxd @@ -1,4 +1,5 @@ -from .matrix_generic_dense cimport Matrix_generic_dense +from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense + cdef class Matrix_symbolic_dense(Matrix_generic_dense): pass diff --git a/src/sage/matrix/matrix_symbolic_dense.pyx b/src/sage/matrix/matrix_symbolic_dense.pyx index b4f6f4f748f..c926cde2500 100644 --- a/src/sage/matrix/matrix_symbolic_dense.pyx +++ b/src/sage/matrix/matrix_symbolic_dense.pyx @@ -157,7 +157,7 @@ Check that :trac:`12778` is fixed:: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.structure.factorization import Factorization -from .matrix_generic_dense cimport Matrix_generic_dense +from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense from .constructor import matrix cdef maxima diff --git a/src/sage/matrix/matrix_symbolic_sparse.pxd b/src/sage/matrix/matrix_symbolic_sparse.pxd index 897754c837d..c90e0161119 100644 --- a/src/sage/matrix/matrix_symbolic_sparse.pxd +++ b/src/sage/matrix/matrix_symbolic_sparse.pxd @@ -1,4 +1,5 @@ -from .matrix_generic_sparse cimport Matrix_generic_sparse +from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse + cdef class Matrix_symbolic_sparse(Matrix_generic_sparse): pass diff --git a/src/sage/matrix/matrix_symbolic_sparse.pyx b/src/sage/matrix/matrix_symbolic_sparse.pyx index 29f29a04dd1..766114a1a48 100644 --- a/src/sage/matrix/matrix_symbolic_sparse.pyx +++ b/src/sage/matrix/matrix_symbolic_sparse.pyx @@ -165,7 +165,7 @@ Check that :issue:`35653` is fixed:: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.structure.factorization import Factorization -from .matrix_generic_sparse cimport Matrix_generic_sparse +from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse from .constructor import matrix cdef maxima diff --git a/src/sage/matrix/matrix_window.pxd b/src/sage/matrix/matrix_window.pxd index 523f0d2b235..c33d5d16806 100644 --- a/src/sage/matrix/matrix_window.pxd +++ b/src/sage/matrix/matrix_window.pxd @@ -1,4 +1,5 @@ -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix + cdef class MatrixWindow: cdef Py_ssize_t _row, _col, _nrows, _ncols diff --git a/src/sage/matrix/misc.pyx b/src/sage/matrix/misc.pyx index 1819d45591e..9a51efc1038 100644 --- a/src/sage/matrix/misc.pyx +++ b/src/sage/matrix/misc.pyx @@ -18,9 +18,9 @@ from sage.modules.vector_rational_sparse cimport * from sage.rings.integer cimport Integer from sage.rings.rational_field import QQ -from .matrix0 cimport Matrix -from .matrix_integer_sparse cimport Matrix_integer_sparse -from .matrix_rational_sparse cimport Matrix_rational_sparse +from sage.matrix.matrix0 cimport Matrix +from sage.matrix.matrix_integer_sparse cimport Matrix_integer_sparse +from sage.matrix.matrix_rational_sparse cimport Matrix_rational_sparse matrix_integer_dense_rational_reconstruction = \ LazyImport('sage.matrix.misc_flint', 'matrix_integer_dense_rational_reconstruction', diff --git a/src/sage/matrix/misc_flint.pyx b/src/sage/matrix/misc_flint.pyx index 37d326c9a74..d5ca017f73a 100644 --- a/src/sage/matrix/misc_flint.pyx +++ b/src/sage/matrix/misc_flint.pyx @@ -13,8 +13,8 @@ from sage.libs.flint.fmpz cimport fmpz_set_mpz, fmpz_one from sage.rings.integer cimport Integer from sage.rings.rational_field import QQ -from .matrix_integer_dense cimport Matrix_integer_dense -from .matrix_rational_dense cimport Matrix_rational_dense +from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense +from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense def matrix_integer_dense_rational_reconstruction(Matrix_integer_dense A, Integer N): diff --git a/src/sage/matrix/misc_mpfr.pyx b/src/sage/matrix/misc_mpfr.pyx index 48b6ade6379..91613b16492 100644 --- a/src/sage/matrix/misc_mpfr.pyx +++ b/src/sage/matrix/misc_mpfr.pyx @@ -9,7 +9,7 @@ cimport sage.rings.abc from sage.libs.mpfr cimport * from sage.rings.real_mpfr cimport RealNumber -from .matrix0 cimport Matrix +from sage.matrix.matrix0 cimport Matrix def hadamard_row_bound_mpfr(Matrix A): diff --git a/src/sage/matrix/strassen.pyx b/src/sage/matrix/strassen.pyx index 9e2797c9925..3d083fa6859 100644 --- a/src/sage/matrix/strassen.pyx +++ b/src/sage/matrix/strassen.pyx @@ -15,7 +15,7 @@ multiplication algorithms. # http://www.gnu.org/licenses/ #***************************************************************************** -from .matrix_window cimport MatrixWindow +from sage.matrix.matrix_window cimport MatrixWindow from cysignals.signals cimport sig_on, sig_off diff --git a/src/sage/matrix/template.pxd b/src/sage/matrix/template.pxd index 8c473730dd2..69123a38f2d 100644 --- a/src/sage/matrix/template.pxd +++ b/src/sage/matrix/template.pxd @@ -1,4 +1,5 @@ -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense + cdef class Matrix_generic_dense(Matrix_dense): pass diff --git a/src/sage/matroids/basis_exchange_matroid.pxd b/src/sage/matroids/basis_exchange_matroid.pxd index b762fd9ed9d..5877f62fc09 100644 --- a/src/sage/matroids/basis_exchange_matroid.pxd +++ b/src/sage/matroids/basis_exchange_matroid.pxd @@ -1,8 +1,8 @@ from sage.data_structures.bitset cimport * from sage.data_structures.bitset_base cimport bitset_t, bitset_s -from .matroid cimport Matroid -from .set_system cimport SetSystem +from sage.matroids.matroid cimport Matroid +from sage.matroids.set_system cimport SetSystem cdef class BasisExchangeMatroid(Matroid): cdef long _groundset_size, _matroid_rank, _bitset_size diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index c27a8cba33d..8940bbe5d93 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -38,8 +38,8 @@ Methods # https://www.gnu.org/licenses/ # **************************************************************************** -from .matroid cimport Matroid -from .set_system cimport SetSystem +from sage.matroids.matroid cimport Matroid +from sage.matroids.set_system cimport SetSystem from sage.data_structures.bitset_base cimport * diff --git a/src/sage/matroids/basis_matroid.pxd b/src/sage/matroids/basis_matroid.pxd index a4202bfedac..aeb59fdb66f 100644 --- a/src/sage/matroids/basis_matroid.pxd +++ b/src/sage/matroids/basis_matroid.pxd @@ -1,7 +1,7 @@ from sage.data_structures.bitset cimport bitset_t -from .matroid cimport Matroid -from .basis_exchange_matroid cimport BasisExchangeMatroid -from .set_system cimport SetSystem +from sage.matroids.matroid cimport Matroid +from sage.matroids.basis_exchange_matroid cimport BasisExchangeMatroid +from sage.matroids.set_system cimport SetSystem cdef class BasisMatroid(BasisExchangeMatroid): cdef bitset_t _bb diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index 93cf56ec60c..0610c9a1149 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -74,9 +74,9 @@ Methods from sage.data_structures.bitset_base cimport * from sage.structure.richcmp cimport rich_to_bool -from .matroid cimport Matroid -from .basis_exchange_matroid cimport BasisExchangeMatroid -from .set_system cimport SetSystem +from sage.matroids.matroid cimport Matroid +from sage.matroids.basis_exchange_matroid cimport BasisExchangeMatroid +from sage.matroids.set_system cimport SetSystem from cpython.object cimport Py_EQ, Py_NE from itertools import combinations diff --git a/src/sage/matroids/circuit_closures_matroid.pxd b/src/sage/matroids/circuit_closures_matroid.pxd index 1ec965db0fe..5f4edf109b7 100644 --- a/src/sage/matroids/circuit_closures_matroid.pxd +++ b/src/sage/matroids/circuit_closures_matroid.pxd @@ -1,4 +1,5 @@ -from .matroid cimport Matroid +from sage.matroids.matroid cimport Matroid + cdef class CircuitClosuresMatroid(Matroid): cdef frozenset _groundset # _E diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 1fc11f0c344..bed582b98e8 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -67,8 +67,8 @@ Methods # **************************************************************************** from sage.structure.richcmp cimport rich_to_bool, richcmp -from .matroid cimport Matroid -from .set_system cimport SetSystem +from sage.matroids.matroid cimport Matroid +from sage.matroids.set_system cimport SetSystem from .utilities import setprint_s from cpython.object cimport Py_EQ, Py_NE diff --git a/src/sage/matroids/extension.pxd b/src/sage/matroids/extension.pxd index 34d813eeb7c..6b6d7949794 100644 --- a/src/sage/matroids/extension.pxd +++ b/src/sage/matroids/extension.pxd @@ -1,5 +1,5 @@ from sage.data_structures.bitset cimport bitset_t -from .basis_matroid cimport BasisMatroid +from sage.matroids.basis_matroid cimport BasisMatroid cdef class CutNode: cdef LinearSubclasses _MC diff --git a/src/sage/matroids/extension.pyx b/src/sage/matroids/extension.pyx index 061ba37089e..553869fcf66 100644 --- a/src/sage/matroids/extension.pyx +++ b/src/sage/matroids/extension.pyx @@ -30,7 +30,7 @@ Methods # **************************************************************************** from sage.data_structures.bitset_base cimport * -from .basis_matroid cimport BasisMatroid +from sage.matroids.basis_matroid cimport BasisMatroid cdef class CutNode: diff --git a/src/sage/matroids/linear_matroid.pxd b/src/sage/matroids/linear_matroid.pxd index 663886fa58e..c7e6a402494 100644 --- a/src/sage/matroids/linear_matroid.pxd +++ b/src/sage/matroids/linear_matroid.pxd @@ -1,8 +1,8 @@ from sage.data_structures.bitset cimport bitset_t -from .matroid cimport Matroid -from .basis_exchange_matroid cimport BasisExchangeMatroid -from .lean_matrix cimport LeanMatrix, GenericMatrix, BinaryMatrix, TernaryMatrix, QuaternaryMatrix +from sage.matroids.matroid cimport Matroid +from sage.matroids.basis_exchange_matroid cimport BasisExchangeMatroid +from sage.matroids.lean_matrix cimport LeanMatrix, GenericMatrix, BinaryMatrix, TernaryMatrix, QuaternaryMatrix cdef class LinearMatroid(BasisExchangeMatroid): diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 51692e8f1c1..a1e0e412a5a 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -344,8 +344,8 @@ from sage.structure.sage_object cimport SageObject MixedIntegerLinearProgram = LazyImport('sage.numerical.mip', 'MixedIntegerLinearProgram') -from .lean_matrix cimport BinaryMatrix, TernaryMatrix -from .set_system cimport SetSystem +from sage.matroids.lean_matrix cimport BinaryMatrix, TernaryMatrix +from sage.matroids.set_system cimport SetSystem from .utilities import newlabel, sanitize_contractions_deletions, spanning_forest, spanning_stars diff --git a/src/sage/matroids/union_matroid.pxd b/src/sage/matroids/union_matroid.pxd index 6e3a6e8d96e..a378cfe910d 100644 --- a/src/sage/matroids/union_matroid.pxd +++ b/src/sage/matroids/union_matroid.pxd @@ -1,4 +1,5 @@ -from .matroid cimport Matroid +from sage.matroids.matroid cimport Matroid + cdef class MatroidUnion(Matroid): cdef list matroids diff --git a/src/sage/matroids/union_matroid.pyx b/src/sage/matroids/union_matroid.pyx index 802b8d609f4..bb3dd03a082 100644 --- a/src/sage/matroids/union_matroid.pyx +++ b/src/sage/matroids/union_matroid.pyx @@ -1,5 +1,5 @@ -from .matroid cimport Matroid +from sage.matroids.matroid cimport Matroid cdef class MatroidUnion(Matroid): diff --git a/src/sage/matroids/unpickling.pyx b/src/sage/matroids/unpickling.pyx index 94464ecb9f0..92ca5800204 100644 --- a/src/sage/matroids/unpickling.pyx +++ b/src/sage/matroids/unpickling.pyx @@ -30,10 +30,10 @@ import sage.matroids.matroid import sage.matroids.basis_exchange_matroid from .minor_matroid import MinorMatroid from .dual_matroid import DualMatroid -from .circuit_closures_matroid cimport CircuitClosuresMatroid -from .basis_matroid cimport BasisMatroid -from .linear_matroid cimport LinearMatroid, RegularMatroid, BinaryMatroid, TernaryMatroid, QuaternaryMatroid -from .lean_matrix cimport GenericMatrix, BinaryMatrix, TernaryMatrix, QuaternaryMatrix, PlusMinusOneMatrix, RationalMatrix +from sage.matroids.circuit_closures_matroid cimport CircuitClosuresMatroid +from sage.matroids.basis_matroid cimport BasisMatroid +from sage.matroids.linear_matroid cimport LinearMatroid, RegularMatroid, BinaryMatroid, TernaryMatroid, QuaternaryMatroid +from sage.matroids.lean_matrix cimport GenericMatrix, BinaryMatrix, TernaryMatrix, QuaternaryMatrix, PlusMinusOneMatrix, RationalMatrix from .graphic_matroid import GraphicMatroid from sage.rings.rational cimport Rational diff --git a/src/sage/modules/vector_complex_double_dense.pxd b/src/sage/modules/vector_complex_double_dense.pxd index f26526a1669..955c0a414d2 100644 --- a/src/sage/modules/vector_complex_double_dense.pxd +++ b/src/sage/modules/vector_complex_double_dense.pxd @@ -1,4 +1,5 @@ -from .vector_double_dense cimport Vector_double_dense +from sage.modules.vector_double_dense cimport Vector_double_dense + cdef class Vector_complex_double_dense(Vector_double_dense): pass diff --git a/src/sage/modules/vector_double_dense.pxd b/src/sage/modules/vector_double_dense.pxd index f29b4597d15..f4f1f47cbce 100644 --- a/src/sage/modules/vector_double_dense.pxd +++ b/src/sage/modules/vector_double_dense.pxd @@ -1,4 +1,5 @@ -from .vector_numpy_dense cimport Vector_numpy_dense +from sage.modules.vector_numpy_dense cimport Vector_numpy_dense + cdef class Vector_double_dense(Vector_numpy_dense): pass diff --git a/src/sage/modules/vector_integer_dense.pxd b/src/sage/modules/vector_integer_dense.pxd index 322a10c369b..0db4808be63 100644 --- a/src/sage/modules/vector_integer_dense.pxd +++ b/src/sage/modules/vector_integer_dense.pxd @@ -1,7 +1,8 @@ -from .free_module_element cimport FreeModuleElement from sage.libs.gmp.types cimport mpz_t +from sage.modules.free_module_element cimport FreeModuleElement from sage.structure.parent cimport Parent + cdef class Vector_integer_dense(FreeModuleElement): cdef mpz_t* _entries cdef int _init(self, Py_ssize_t degree, Parent parent) except -1 diff --git a/src/sage/modules/vector_modn_dense.pxd b/src/sage/modules/vector_modn_dense.pxd index 2482f999d37..6e726651ea1 100644 --- a/src/sage/modules/vector_modn_dense.pxd +++ b/src/sage/modules/vector_modn_dense.pxd @@ -1,5 +1,6 @@ -from .free_module_element cimport FreeModuleElement from sage.ext.mod_int cimport mod_int +from sage.modules.free_module_element cimport FreeModuleElement + cdef class Vector_modn_dense(FreeModuleElement): cdef mod_int* _entries @@ -8,4 +9,3 @@ cdef class Vector_modn_dense(FreeModuleElement): cdef _new_c(self) noexcept cdef _init(self, Py_ssize_t degree, parent, mod_int p) noexcept - diff --git a/src/sage/modules/vector_numpy_dense.pxd b/src/sage/modules/vector_numpy_dense.pxd index 6af57a997c5..0cb384222c2 100644 --- a/src/sage/modules/vector_numpy_dense.pxd +++ b/src/sage/modules/vector_numpy_dense.pxd @@ -1,6 +1,8 @@ -from .free_module_element cimport FreeModuleElement cimport numpy +from sage.modules.free_module_element cimport FreeModuleElement + + cdef class Vector_numpy_dense(FreeModuleElement): cdef object _numpy_dtype cdef int _numpy_dtypeint diff --git a/src/sage/modules/vector_numpy_integer_dense.pxd b/src/sage/modules/vector_numpy_integer_dense.pxd index e39b90bbcb9..31bc1cf8f6b 100644 --- a/src/sage/modules/vector_numpy_integer_dense.pxd +++ b/src/sage/modules/vector_numpy_integer_dense.pxd @@ -1,4 +1,5 @@ -from .vector_numpy_dense cimport Vector_numpy_dense +from sage.modules.vector_numpy_dense cimport Vector_numpy_dense + cdef class Vector_numpy_integer_dense(Vector_numpy_dense): diff --git a/src/sage/modules/vector_rational_dense.pxd b/src/sage/modules/vector_rational_dense.pxd index 1bcde479153..4820936580a 100644 --- a/src/sage/modules/vector_rational_dense.pxd +++ b/src/sage/modules/vector_rational_dense.pxd @@ -1,7 +1,8 @@ -from .free_module_element cimport FreeModuleElement from sage.libs.gmp.types cimport mpq_t +from sage.modules.free_module_element cimport FreeModuleElement from sage.structure.parent cimport Parent + cdef class Vector_rational_dense(FreeModuleElement): cdef mpq_t* _entries cdef int _init(self, Py_ssize_t degree, Parent parent) except -1 diff --git a/src/sage/modules/vector_real_double_dense.pxd b/src/sage/modules/vector_real_double_dense.pxd index 6f75ec0c4dd..4dd3b43ab25 100644 --- a/src/sage/modules/vector_real_double_dense.pxd +++ b/src/sage/modules/vector_real_double_dense.pxd @@ -1,5 +1,5 @@ -from .vector_double_dense cimport Vector_double_dense +from sage.modules.vector_double_dense cimport Vector_double_dense + cdef class Vector_real_double_dense(Vector_double_dense): pass - diff --git a/src/sage/stats/distributions/discrete_gaussian_integer.pxd b/src/sage/stats/distributions/discrete_gaussian_integer.pxd index 7235a9397f7..d6edbe88d43 100644 --- a/src/sage/stats/distributions/discrete_gaussian_integer.pxd +++ b/src/sage/stats/distributions/discrete_gaussian_integer.pxd @@ -1,8 +1,8 @@ -from .dgs cimport dgs_disc_gauss_mp_t, dgs_disc_gauss_dp_t - -from sage.structure.sage_object cimport SageObject -from sage.rings.real_mpfr cimport RealNumber from sage.rings.integer cimport Integer +from sage.rings.real_mpfr cimport RealNumber +from sage.stats.distributions.dgs cimport dgs_disc_gauss_mp_t, dgs_disc_gauss_dp_t +from sage.structure.sage_object cimport SageObject + cdef class DiscreteGaussianDistributionIntegerSampler(SageObject): cdef readonly RealNumber sigma diff --git a/src/sage/stats/distributions/discrete_gaussian_integer.pyx b/src/sage/stats/distributions/discrete_gaussian_integer.pyx index 2aa28609180..6d50074102b 100644 --- a/src/sage/stats/distributions/discrete_gaussian_integer.pyx +++ b/src/sage/stats/distributions/discrete_gaussian_integer.pyx @@ -148,9 +148,9 @@ from sage.libs.mpfr cimport mpfr_set, MPFR_RNDN from sage.rings.integer cimport Integer from sage.misc.randstate cimport randstate, current_randstate -from .dgs cimport dgs_disc_gauss_mp_init, dgs_disc_gauss_mp_clear, dgs_disc_gauss_mp_flush_cache -from .dgs cimport dgs_disc_gauss_dp_init, dgs_disc_gauss_dp_clear, dgs_disc_gauss_dp_flush_cache -from .dgs cimport DGS_DISC_GAUSS_UNIFORM_TABLE, DGS_DISC_GAUSS_UNIFORM_ONLINE, DGS_DISC_GAUSS_UNIFORM_LOGTABLE, DGS_DISC_GAUSS_SIGMA2_LOGTABLE +from sage.stats.distributions.dgs cimport dgs_disc_gauss_mp_init, dgs_disc_gauss_mp_clear, dgs_disc_gauss_mp_flush_cache +from sage.stats.distributions.dgs cimport dgs_disc_gauss_dp_init, dgs_disc_gauss_dp_clear, dgs_disc_gauss_dp_flush_cache +from sage.stats.distributions.dgs cimport DGS_DISC_GAUSS_UNIFORM_TABLE, DGS_DISC_GAUSS_UNIFORM_ONLINE, DGS_DISC_GAUSS_UNIFORM_LOGTABLE, DGS_DISC_GAUSS_SIGMA2_LOGTABLE cdef class DiscreteGaussianDistributionIntegerSampler(SageObject): r""" diff --git a/src/sage/stats/hmm/chmm.pyx b/src/sage/stats/hmm/chmm.pyx index aa35b8cefdc..fe09b3f9cfb 100644 --- a/src/sage/stats/hmm/chmm.pyx +++ b/src/sage/stats/hmm/chmm.pyx @@ -28,9 +28,9 @@ from sage.structure.element import is_Matrix from sage.stats.time_series cimport TimeSeries from sage.stats.intlist cimport IntList -from .hmm cimport HiddenMarkovModel -from .util cimport HMM_Util -from .distributions cimport GaussianMixtureDistribution +from sage.stats.hmm.hmm cimport HiddenMarkovModel +from sage.stats.hmm.util cimport HMM_Util +from sage.stats.hmm.distributions cimport GaussianMixtureDistribution cdef HMM_Util util = HMM_Util() diff --git a/src/sage/stats/hmm/hmm.pyx b/src/sage/stats/hmm/hmm.pyx index 86de50cc1a3..fe8ab69cc66 100644 --- a/src/sage/stats/hmm/hmm.pyx +++ b/src/sage/stats/hmm/hmm.pyx @@ -41,7 +41,7 @@ from sage.matrix.constructor import matrix from sage.misc.randstate cimport current_randstate, randstate from cpython.object cimport PyObject_RichCompare -from .util cimport HMM_Util +from sage.stats.hmm.util cimport HMM_Util cdef HMM_Util util = HMM_Util() From 35914d34905abcc5d8299b7ba8087217ce92ee5c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Oct 2023 18:06:58 -0700 Subject: [PATCH 298/494] Replace relative imports in Cython files --- src/sage/matrix/action.pyx | 2 +- src/sage/matrix/args.pyx | 4 +-- src/sage/matrix/change_ring.pyx | 2 +- src/sage/matrix/constructor.pyx | 2 +- src/sage/matrix/matrix0.pyx | 20 ++++++------ src/sage/matrix/matrix2.pyx | 10 +++--- src/sage/matrix/matrix_cyclo_dense.pyx | 10 +++--- src/sage/matrix/matrix_double_dense.pyx | 2 +- src/sage/matrix/matrix_generic_dense.pyx | 2 +- src/sage/matrix/matrix_generic_sparse.pyx | 2 +- src/sage/matrix/matrix_integer_dense.pyx | 32 +++++++++---------- src/sage/matrix/matrix_integer_sparse.pyx | 6 ++-- src/sage/matrix/matrix_modn_sparse.pyx | 4 +-- src/sage/matrix/matrix_rational_dense.pyx | 8 ++--- src/sage/matrix/matrix_rational_sparse.pyx | 2 +- src/sage/matrix/matrix_real_double_dense.pyx | 2 +- src/sage/matrix/matrix_symbolic_dense.pyx | 2 +- src/sage/matrix/matrix_symbolic_sparse.pyx | 2 +- src/sage/matroids/basis_exchange_matroid.pyx | 4 +-- .../matroids/circuit_closures_matroid.pyx | 2 +- src/sage/matroids/matroid.pyx | 26 +++++++-------- src/sage/matroids/unpickling.pyx | 6 ++-- src/sage/modules/free_module_element.pyx | 10 +++--- src/sage/modules/vector_double_dense.pyx | 2 +- src/sage/modules/vector_numpy_dense.pyx | 2 +- 25 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/sage/matrix/action.pyx b/src/sage/matrix/action.pyx index 849163a511f..11e70f977bb 100644 --- a/src/sage/matrix/action.pyx +++ b/src/sage/matrix/action.pyx @@ -62,7 +62,7 @@ AUTHOR: import operator -from .matrix_space import MatrixSpace, is_MatrixSpace +from sage.matrix.matrix_space import MatrixSpace, is_MatrixSpace from sage.modules.free_module import FreeModule, is_FreeModule from sage.structure.coerce cimport coercion_model from sage.categories.homset import Hom, End diff --git a/src/sage/matrix/args.pyx b/src/sage/matrix/args.pyx index bdb6eb796dd..58369f97803 100644 --- a/src/sage/matrix/args.pyx +++ b/src/sage/matrix/args.pyx @@ -982,7 +982,7 @@ cdef class MatrixArgs: if self.space is None: global MatrixSpace if MatrixSpace is None: - from .matrix_space import MatrixSpace + from sage.matrix.matrix_space import MatrixSpace self.space = MatrixSpace(self.base, self.nrows, self.ncols, sparse=self.sparse, **self.kwds) @@ -1113,7 +1113,7 @@ cdef class MatrixArgs: if not (e.flags.c_contiguous is True or e.flags.f_contiguous is True): raise TypeError('numpy matrix must be either c_contiguous or f_contiguous') - from .constructor import matrix + from sage.matrix.constructor import matrix from sage.rings.real_double import RDF from sage.rings.complex_double import CDF diff --git a/src/sage/matrix/change_ring.pyx b/src/sage/matrix/change_ring.pyx index 53e840b4663..f942b753275 100644 --- a/src/sage/matrix/change_ring.pyx +++ b/src/sage/matrix/change_ring.pyx @@ -2,7 +2,7 @@ Functions for changing the base ring of matrices quickly """ -from .matrix_space import MatrixSpace +from sage.matrix.matrix_space import MatrixSpace from sage.matrix.matrix_real_double_dense cimport Matrix_real_double_dense from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense diff --git a/src/sage/matrix/constructor.pyx b/src/sage/matrix/constructor.pyx index 536fe7bdf29..15b22b35f77 100644 --- a/src/sage/matrix/constructor.pyx +++ b/src/sage/matrix/constructor.pyx @@ -654,7 +654,7 @@ def matrix(*args, **kwds): Matrix = matrix -from .special import * +from sage.matrix.special import * @matrix_method diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index d7a0487e6cd..d8c9f0b2809 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -47,7 +47,7 @@ from sage.rings.integer_ring import is_IntegerRing import sage.modules.free_module -from .matrix_misc import row_iterator +from sage.matrix.matrix_misc import row_iterator _Fields = Fields() _IntegralDomains = IntegralDomains() @@ -1750,7 +1750,7 @@ cdef class Matrix(sage.structure.element.Matrix): 100 x 100 dense matrix over Integer Ring] """ - from .constructor import options + from sage.matrix.constructor import options if self._nrows <= options.max_rows() and self._ncols <= options.max_cols(): return self.str() if self.is_sparse(): @@ -2051,7 +2051,7 @@ cdef class Matrix(sage.structure.element.Matrix): # only use floating point formatting for inexact types that have # custom implementation of __format__ - from .constructor import options + from sage.matrix.constructor import options prec = options.precision() if prec is None or callable(rep_mapping) or not entries \ or type(entries[0]).__format__ is Element.__format__ \ @@ -2135,7 +2135,7 @@ cdef class Matrix(sage.structure.element.Matrix): -0.35104242112828943 0.5084492941557279] -0.9541798283979341 -0.8948790563276592] """ - from .constructor import options + from sage.matrix.constructor import options if self._nrows <= options.max_rows() and self._ncols <= options.max_cols(): return self.str(character_art=True) else: @@ -2164,7 +2164,7 @@ cdef class Matrix(sage.structure.element.Matrix): sage: unicode_art(A) 100 x 100 dense matrix over Integer Ring """ - from .constructor import options + from sage.matrix.constructor import options if self._nrows <= options.max_rows() and self._ncols <= options.max_cols(): return self.str(unicode=True, character_art=True) else: @@ -2375,7 +2375,7 @@ cdef class Matrix(sage.structure.element.Matrix): [ 5 25] [125 625] """ - from .constructor import matrix + from sage.matrix.constructor import matrix return matrix(self.nrows(), self.ncols(), [e(*args, **kwargs) for e in self.list()]) ################################################### @@ -3850,7 +3850,7 @@ cdef class Matrix(sage.structure.element.Matrix): raise ValueError("length of v must be at most the number of rows of self") if not self._nrows: return self.parent().row_space().zero_vector() - from .constructor import matrix + from sage.matrix.constructor import matrix v = matrix(list(v)+[0]*(self._nrows-len(v))) return (v * self)[0] @@ -3927,7 +3927,7 @@ cdef class Matrix(sage.structure.element.Matrix): raise ValueError("length of v must be at most the number of columns of self") if not self._ncols: return self.parent().column_space().zero_vector() - from .constructor import matrix + from sage.matrix.constructor import matrix v = matrix(self._ncols, 1, list(v)+[0]*(self._ncols-len(v))) return (self * v).column(0) @@ -6178,7 +6178,7 @@ def set_max_rows(n): """ from sage.misc.superseded import deprecation deprecation(30552, "'set_max_rows' is replaced by 'matrix.options.max_rows'") - from .constructor import options + from sage.matrix.constructor import options options.max_rows = n-1 def set_max_cols(n): @@ -6195,5 +6195,5 @@ def set_max_cols(n): """ from sage.misc.superseded import deprecation deprecation(30552, "'set_max_cols' is replaced by 'matrix.options.max_cols'") - from .constructor import options + from sage.matrix.constructor import options options.max_cols = n-1 diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 8af0889927f..6c02bc09e73 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -99,7 +99,7 @@ from sage.arith.numerical_approx cimport digits_to_bits from copy import copy import sage.modules.free_module -from . import berlekamp_massey +from sage.matrix import berlekamp_massey from sage.modules.free_module_element import is_FreeModuleElement from sage.matrix.matrix_misc import permanental_minor_polynomial @@ -8802,7 +8802,7 @@ cdef class Matrix(Matrix1): output_window = output.matrix_window() - from . import strassen + from sage.matrix import strassen strassen.strassen_window_multiply(output_window, self_window, right_window, cutoff) return output @@ -8840,7 +8840,7 @@ cdef class Matrix(Matrix1): self._echelon_in_place_classical() return - from . import strassen + from sage.matrix import strassen pivots = strassen.strassen_echelon(self.matrix_window(), cutoff) self.cache('pivots', pivots) verbose('done with strassen', tm) @@ -8879,7 +8879,7 @@ cdef class Matrix(Matrix1): ... IndexError: matrix window index out of range """ - from . import matrix_window + from sage.matrix import matrix_window if nrows == -1: nrows = self._nrows - row if ncols == -1: @@ -15084,7 +15084,7 @@ cdef class Matrix(Matrix1): except (OverflowError, TypeError): from sage.rings.real_mpfr import RealField # Try using MPFR, which handles large numbers much better, but is slower. - from .misc_mpfr import hadamard_row_bound_mpfr + from sage.matrix.misc_mpfr import hadamard_row_bound_mpfr R = RealField(53, rnd='RNDU') A = self.change_ring(R) m1 = hadamard_row_bound_mpfr(A) diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx index 6a048a78edc..cb83823c576 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -57,13 +57,13 @@ from sage.libs.flint.fmpq cimport fmpq_is_zero, fmpq_set_mpq, fmpq_canonicalise from sage.libs.flint.fmpq_mat cimport fmpq_mat_entry_num, fmpq_mat_entry_den, fmpq_mat_entry from sage.matrix.args cimport MatrixArgs_init -from .constructor import matrix -from .matrix_space import MatrixSpace +from sage.matrix.constructor import matrix +from sage.matrix.matrix_space import MatrixSpace from sage.matrix.matrix cimport Matrix -from . import matrix_dense +from sage.matrix import matrix_dense from sage.matrix.matrix_integer_dense cimport _lift_crt from sage.structure.element cimport Matrix as baseMatrix -from .misc_flint import matrix_integer_dense_rational_reconstruction +from sage.matrix.misc_flint import matrix_integer_dense_rational_reconstruction from sage.arith.misc import binomial, previous_prime from sage.rings.rational_field import QQ @@ -1535,7 +1535,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense): K = self.base_ring() phi = K.defining_polynomial() from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF - from .constructor import matrix + from sage.matrix.constructor import matrix F = GF(p) aa = [a for a, _ in phi.change_ring(F).roots()] n = K.degree() diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index f4312a479e5..57d3517e6a9 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -70,7 +70,7 @@ import sage.rings.real_double import sage.rings.complex_double from sage.structure.element cimport Vector -from .constructor import matrix +from sage.matrix.constructor import matrix cimport sage.structure.element cimport numpy as cnumpy diff --git a/src/sage/matrix/matrix_generic_dense.pyx b/src/sage/matrix/matrix_generic_dense.pyx index 527ef1b48f6..a4d0615971d 100644 --- a/src/sage/matrix/matrix_generic_dense.pyx +++ b/src/sage/matrix/matrix_generic_dense.pyx @@ -8,7 +8,7 @@ from cpython.number cimport * from cpython.ref cimport * cimport sage.matrix.matrix_dense as matrix_dense -from . import matrix_dense +from sage.matrix import matrix_dense from sage.matrix.args cimport MatrixArgs_init cimport sage.matrix.matrix as matrix diff --git a/src/sage/matrix/matrix_generic_sparse.pyx b/src/sage/matrix/matrix_generic_sparse.pyx index 5fa8894c2a9..bd1f860c167 100644 --- a/src/sage/matrix/matrix_generic_sparse.pyx +++ b/src/sage/matrix/matrix_generic_sparse.pyx @@ -451,7 +451,7 @@ def Matrix_sparse_from_rows(X): if not X: raise ArithmeticError("X must be nonempty") - from . import matrix_space + from sage.matrix import matrix_space entries = {} R = X[0].base_ring() ncols = X[0].degree() diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index 26e2e766d30..5488177dae1 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -118,12 +118,12 @@ from sage.matrix.matrix_modn_dense_float cimport Matrix_modn_dense_template from sage.matrix.matrix_modn_dense_float cimport Matrix_modn_dense_float from sage.matrix.matrix_modn_dense_double cimport Matrix_modn_dense_double -from .matrix_mod2_dense import Matrix_mod2_dense +from sage.matrix.matrix_mod2_dense import Matrix_mod2_dense from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense from sage.rings.finite_rings.finite_field_constructor import GF -from .matrix2 import decomp_seq +from sage.matrix.matrix2 import decomp_seq from sage.matrix.matrix cimport Matrix @@ -1592,8 +1592,8 @@ cdef class Matrix_integer_dense(Matrix_dense): return Matrix_mod2_dense(MS, self, True, True) cdef _mod_int_c(self, mod_int p) noexcept: - from .matrix_modn_dense_float import MAX_MODULUS as MAX_MODULUS_FLOAT - from .matrix_modn_dense_double import MAX_MODULUS as MAX_MODULUS_DOUBLE + from sage.matrix.matrix_modn_dense_float import MAX_MODULUS as MAX_MODULUS_FLOAT + from sage.matrix.matrix_modn_dense_double import MAX_MODULUS as MAX_MODULUS_DOUBLE cdef Py_ssize_t i, j @@ -1626,8 +1626,8 @@ cdef class Matrix_integer_dense(Matrix_dense): raise ValueError("p to big.") def _reduce(self, moduli): - from .matrix_modn_dense_float import MAX_MODULUS as MAX_MODULUS_FLOAT - from .matrix_modn_dense_double import MAX_MODULUS as MAX_MODULUS_DOUBLE + from sage.matrix.matrix_modn_dense_float import MAX_MODULUS as MAX_MODULUS_FLOAT + from sage.matrix.matrix_modn_dense_double import MAX_MODULUS as MAX_MODULUS_DOUBLE if isinstance(moduli, (int, Integer)): return self._mod_int(moduli) @@ -2051,7 +2051,7 @@ cdef class Matrix_integer_dense(Matrix_dense): if transformation: U = U[:r] elif algorithm == "padic": - from . import matrix_integer_dense_hnf + from sage.matrix import matrix_integer_dense_hnf if transformation: H_m, U = matrix_integer_dense_hnf.hnf_with_transformation(self, proof=proof) if not include_zero_rows: @@ -2098,7 +2098,7 @@ cdef class Matrix_integer_dense(Matrix_dense): H_m.set_immutable() if pivots is None: - from .matrix_integer_dense_hnf import pivots_of_hnf_matrix + from sage.matrix.matrix_integer_dense_hnf import pivots_of_hnf_matrix pivots = pivots_of_hnf_matrix(H_m) pivots = tuple(pivots) rank = len(pivots) @@ -2197,7 +2197,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sage: S = A.saturation(max_dets=2) """ proof = get_proof_flag(proof, "linear_algebra") - from .matrix_integer_dense_saturation import saturation + from sage.matrix.matrix_integer_dense_saturation import saturation return saturation(self, p=p, proof=proof, max_dets=max_dets) def index_in_saturation(self, proof=None): @@ -2235,7 +2235,7 @@ cdef class Matrix_integer_dense(Matrix_dense): [1 1 1] """ proof = get_proof_flag(proof, "linear_algebra") - from .matrix_integer_dense_saturation import index_in_saturation + from sage.matrix.matrix_integer_dense_saturation import index_in_saturation return index_in_saturation(self, proof=proof) def pivots(self): @@ -3402,7 +3402,7 @@ cdef class Matrix_integer_dense(Matrix_dense): ... ZeroDivisionError: The modulus cannot be zero """ - from .misc_flint import matrix_integer_dense_rational_reconstruction + from sage.matrix.misc_flint import matrix_integer_dense_rational_reconstruction return matrix_integer_dense_rational_reconstruction(self, N) def randomize(self, density=1, x=None, y=None, distribution=None, @@ -3766,7 +3766,7 @@ cdef class Matrix_integer_dense(Matrix_dense): fmpz_clear(e) d = det elif algorithm == 'padic': - from . import matrix_integer_dense_hnf + from sage.matrix import matrix_integer_dense_hnf d = matrix_integer_dense_hnf.det_padic(self, proof=proof, stabilize=stabilize) elif algorithm == 'linbox': if proof: @@ -4233,7 +4233,7 @@ cdef class Matrix_integer_dense(Matrix_dense): # in the non-full rank case. In any case, we do this for now, # since rank is very fast and infinite loops are evil. if check_rank and self.rank() < self.nrows(): - from .matrix2 import NotFullRankError + from sage.matrix.matrix2 import NotFullRankError raise NotFullRankError if not self.is_square(): @@ -4680,7 +4680,7 @@ cdef class Matrix_integer_dense(Matrix_dense): d = Integer(1) return pivots, nonpivots, X, d - from .matrix_modn_dense_double import MAX_MODULUS + from sage.matrix.matrix_modn_dense_double import MAX_MODULUS A = self # Step 1: Compute the rank @@ -4879,7 +4879,7 @@ cdef class Matrix_integer_dense(Matrix_dense): """ cdef Py_ssize_t i, j, n = self._nrows, m = self._ncols - from .constructor import matrix + from sage.matrix.constructor import matrix # 0. Base case if self.nrows() == 0: @@ -5584,7 +5584,7 @@ cdef class Matrix_integer_dense(Matrix_dense): [ 3.0 5.0] """ if ring == RDF: - from .change_ring import integer_to_real_double_dense + from sage.matrix.change_ring import integer_to_real_double_dense return integer_to_real_double_dense(self) else: raise NotImplementedError diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index 16e577e9b40..27f5cdfac0f 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -421,7 +421,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): ... ZeroDivisionError: The modulus cannot be zero """ - from .misc import matrix_integer_sparse_rational_reconstruction + from sage.matrix.misc import matrix_integer_sparse_rational_reconstruction return matrix_integer_sparse_rational_reconstruction(self, N) def _right_kernel_matrix(self, **kwds): @@ -1037,7 +1037,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): [0 2] """ if check_rank and self.rank() < self.nrows(): - from .matrix2 import NotFullRankError + from sage.matrix.matrix2 import NotFullRankError raise NotFullRankError if self.base_ring() != B.base_ring(): @@ -1230,7 +1230,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): if self._nrows == 0 or self._ncols == 0: raise ValueError("not implemented for nrows=0 or ncols=0") - from .constructor import matrix + from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector cdef Matrix_integer_dense B diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index edcd75a1a77..b6d60d3d586 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -931,7 +931,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): [0 2] """ if check_rank and self.rank() < self.nrows(): - from .matrix2 import NotFullRankError + from sage.matrix.matrix2 import NotFullRankError raise NotFullRankError if self.base_ring() != B.base_ring(): @@ -1110,7 +1110,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): if self._nrows == 0 or self._ncols == 0: raise ValueError("not implemented for nrows=0 or ncols=0") - from .constructor import matrix + from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector cdef Matrix_integer_dense B diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index dd5118785bb..8b72c9c56f2 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -114,7 +114,7 @@ from sage.rings.integer_ring import ZZ, is_IntegerRing import sage.rings.abc from sage.rings.rational_field import QQ -from .matrix2 import decomp_seq +from sage.matrix.matrix2 import decomp_seq from sage.misc.verbose import verbose # ######################################################## @@ -1406,7 +1406,7 @@ cdef class Matrix_rational_dense(Matrix_dense): tm = verbose("computing right kernel matrix over the rationals for %sx%s matrix" % (self.nrows(), self.ncols()),level=1) # _rational_kernel_flint() gets the zero-row case wrong, fix it there if self.nrows()==0: - from .constructor import identity_matrix + from sage.matrix.constructor import identity_matrix K = identity_matrix(QQ, self.ncols()) else: A, _ = self._clear_denom() @@ -1473,7 +1473,7 @@ cdef class Matrix_rational_dense(Matrix_dense): A.subdivide(self.subdivisions()) return A - from .matrix_modn_dense_double import MAX_MODULUS + from sage.matrix.matrix_modn_dense_double import MAX_MODULUS if isinstance(R, sage.rings.abc.IntegerModRing) and R.order() < MAX_MODULUS: b = R.order() A, d = self._clear_denom() @@ -1803,7 +1803,7 @@ cdef class Matrix_rational_dense(Matrix_dense): [ 0 0 1 1 3 0] [ 0 0 0 0 0 1] """ - from .misc import matrix_rational_echelon_form_multimodular + from sage.matrix.misc import matrix_rational_echelon_form_multimodular E, pivots = matrix_rational_echelon_form_multimodular(self, height_guess, proof=proof) self.clear_cache() fmpq_mat_swap(self._matrix, (E)._matrix) diff --git a/src/sage/matrix/matrix_rational_sparse.pyx b/src/sage/matrix/matrix_rational_sparse.pyx index 41dacbff1c7..fcdc75b43d1 100644 --- a/src/sage/matrix/matrix_rational_sparse.pyx +++ b/src/sage/matrix/matrix_rational_sparse.pyx @@ -583,7 +583,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse): - height_guess -- integer or None - proof -- boolean (default: True) """ - from .misc import matrix_rational_echelon_form_multimodular + from sage.matrix.misc import matrix_rational_echelon_form_multimodular cdef Matrix E E, pivots = matrix_rational_echelon_form_multimodular(self, height_guess=height_guess, proof=proof) diff --git a/src/sage/matrix/matrix_real_double_dense.pyx b/src/sage/matrix/matrix_real_double_dense.pyx index 542638ed17d..5a41f75c832 100644 --- a/src/sage/matrix/matrix_real_double_dense.pyx +++ b/src/sage/matrix/matrix_real_double_dense.pyx @@ -60,7 +60,7 @@ cdef class Matrix_real_double_dense(Matrix_double_dense): sage: m**2 [ 7.0 10.0] [15.0 22.0] - sage: n = m^(-1); n # rel tol 1e-15 + sage: n = m^(-1); n # rel tol 1e-15 # needs scipy [-1.9999999999999996 0.9999999999999998] [ 1.4999999999999998 -0.4999999999999999] diff --git a/src/sage/matrix/matrix_symbolic_dense.pyx b/src/sage/matrix/matrix_symbolic_dense.pyx index c926cde2500..e69d977a117 100644 --- a/src/sage/matrix/matrix_symbolic_dense.pyx +++ b/src/sage/matrix/matrix_symbolic_dense.pyx @@ -158,7 +158,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.structure.factorization import Factorization from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense -from .constructor import matrix +from sage.matrix.constructor import matrix cdef maxima diff --git a/src/sage/matrix/matrix_symbolic_sparse.pyx b/src/sage/matrix/matrix_symbolic_sparse.pyx index 766114a1a48..69c36e764fb 100644 --- a/src/sage/matrix/matrix_symbolic_sparse.pyx +++ b/src/sage/matrix/matrix_symbolic_sparse.pyx @@ -166,7 +166,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.structure.factorization import Factorization from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse -from .constructor import matrix +from sage.matrix.constructor import matrix cdef maxima diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index 8940bbe5d93..e5c18e0185b 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -2151,7 +2151,7 @@ cdef class BasisExchangeMatroid(Matroid): True """ if not isinstance(other, BasisExchangeMatroid): - from .basis_matroid import BasisMatroid + from sage.matroids.basis_matroid import BasisMatroid ot = BasisMatroid(other) else: ot = other @@ -2217,7 +2217,7 @@ cdef class BasisExchangeMatroid(Matroid): True """ if not isinstance(other, BasisExchangeMatroid): - from .basis_matroid import BasisMatroid + from sage.matroids.basis_matroid import BasisMatroid other = BasisMatroid(other) if self is other: return {e:e for e in self.groundset()} diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index bed582b98e8..0a25aee80cb 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -69,7 +69,7 @@ Methods from sage.structure.richcmp cimport rich_to_bool, richcmp from sage.matroids.matroid cimport Matroid from sage.matroids.set_system cimport SetSystem -from .utilities import setprint_s +from sage.matroids.utilities import setprint_s from cpython.object cimport Py_EQ, Py_NE diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index a1e0e412a5a..ed971cb8349 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -346,7 +346,7 @@ MixedIntegerLinearProgram = LazyImport('sage.numerical.mip', 'MixedIntegerLinear from sage.matroids.lean_matrix cimport BinaryMatrix, TernaryMatrix from sage.matroids.set_system cimport SetSystem -from .utilities import newlabel, sanitize_contractions_deletions, spanning_forest, spanning_stars +from sage.matroids.utilities import newlabel, sanitize_contractions_deletions, spanning_forest, spanning_stars # On some systems, macros "minor()" and "major()" are defined in system header @@ -1113,7 +1113,7 @@ cdef class Matroid(SageObject): {'e', 'f', 'g', 'h'}}, 4: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}}} """ - from . import minor_matroid + from sage.matroids import minor_matroid return minor_matroid.MinorMatroid(self, contractions, deletions) cpdef _has_minor(self, N, bint certificate=False) noexcept: @@ -1226,7 +1226,7 @@ cdef class Matroid(SageObject): sage: [sorted(C) for C in N.circuits() if len(C) == 3] [[0, 1, 6]] """ - from . import basis_matroid + from sage.matroids import basis_matroid return basis_matroid.BasisMatroid(self)._extension(element, hyperplanes) # ** user-facing methods ** @@ -3610,8 +3610,8 @@ cdef class Matroid(SageObject): sage: M._is_isomorphism(N, morphism) True """ - from . import basis_exchange_matroid - from . import basis_matroid + from sage.matroids import basis_exchange_matroid + from sage.matroids import basis_matroid sf = basis_matroid.BasisMatroid(self) if not isinstance(other, basis_exchange_matroid.BasisExchangeMatroid): ot = basis_matroid.BasisMatroid(other) @@ -3694,7 +3694,7 @@ cdef class Matroid(SageObject): return rich_to_bool(op, 1) # Default implementation: use BasisMatroid - from .basis_matroid import BasisMatroid + from sage.matroids.basis_matroid import BasisMatroid return richcmp(BasisMatroid(left), BasisMatroid(right), op) # Minors and duality @@ -4009,7 +4009,7 @@ cdef class Matroid(SageObject): {'c', 'e', 'g'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}}, 3: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}}}' """ - from . import dual_matroid + from sage.matroids import dual_matroid return dual_matroid.DualMatroid(self) cpdef truncation(self) noexcept: @@ -4505,7 +4505,7 @@ cdef class Matroid(SageObject): sage: len(list(M.linear_subclasses(line_length=5))) 44 """ - from . import extension + from sage.matroids import extension return extension.LinearSubclasses(self, line_length=line_length, subsets=subsets) cpdef extensions(self, element=None, line_length=None, subsets=None) noexcept: @@ -4564,7 +4564,7 @@ cdef class Matroid(SageObject): 5 """ - from . import extension + from sage.matroids import extension if element is None: element = newlabel(self.groundset()) else: @@ -7773,7 +7773,7 @@ cdef class Matroid(SageObject): sage: G.show() # needs sage.plot sage.rings.finite_rings """ - from . import matroids_plot_helpers + from sage.matroids import matroids_plot_helpers if pos_method == 1 and pos_dict is not None: # check sanity of pos_dict and add it to cached info if sane if matroids_plot_helpers.posdict_is_sane(self, pos_dict): @@ -7882,7 +7882,7 @@ cdef class Matroid(SageObject): raise NotImplementedError # check sanity of pos_dict and add it to cached info if sane if pos_dict is not None: - from . import matroids_plot_helpers + from sage.matroids import matroids_plot_helpers if matroids_plot_helpers.posdict_is_sane(self,pos_dict): self._cached_info = {'plot_positions': pos_dict, 'lineorders': lineorders} return @@ -8066,7 +8066,7 @@ cdef class Matroid(SageObject): Binary matroid of rank 3 on 7 elements, type (3, 0) Ternary matroid of rank 3 on 7 elements, type 0- """ - from . import union_matroid + from sage.matroids import union_matroid if isinstance(matroids, Matroid): matroids = [matroids] else: @@ -8116,7 +8116,7 @@ cdef class Matroid(SageObject): sage: len(N.bases()) 2100 """ - from . import union_matroid + from sage.matroids import union_matroid if isinstance(matroids, Matroid): matroids = [matroids] else: diff --git a/src/sage/matroids/unpickling.pyx b/src/sage/matroids/unpickling.pyx index 92ca5800204..77b3f12265c 100644 --- a/src/sage/matroids/unpickling.pyx +++ b/src/sage/matroids/unpickling.pyx @@ -28,13 +28,13 @@ AUTHORS: from sage.data_structures.bitset_base cimport * import sage.matroids.matroid import sage.matroids.basis_exchange_matroid -from .minor_matroid import MinorMatroid -from .dual_matroid import DualMatroid +from sage.matroids.minor_matroid import MinorMatroid +from sage.matroids.dual_matroid import DualMatroid from sage.matroids.circuit_closures_matroid cimport CircuitClosuresMatroid from sage.matroids.basis_matroid cimport BasisMatroid from sage.matroids.linear_matroid cimport LinearMatroid, RegularMatroid, BinaryMatroid, TernaryMatroid, QuaternaryMatroid from sage.matroids.lean_matrix cimport GenericMatrix, BinaryMatrix, TernaryMatrix, QuaternaryMatrix, PlusMinusOneMatrix, RationalMatrix -from .graphic_matroid import GraphicMatroid +from sage.matroids.graphic_matroid import GraphicMatroid from sage.rings.rational cimport Rational from sage.libs.gmp.mpq cimport mpq_set diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index a2c077cc8c8..ef37ffbc1c3 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -554,11 +554,11 @@ def vector(arg0, arg1=None, arg2=None, sparse=None, immutable=False): if isinstance(v, ndarray): if len(v.shape) != 1: raise TypeError("cannot convert %r-dimensional array to a vector" % len(v.shape)) - from .free_module import VectorSpace + from sage.modules.free_module import VectorSpace if (R is None or isinstance(R, RealDoubleField)) and v.dtype.kind == 'f': from sage.rings.real_double import RDF V = VectorSpace(RDF, v.shape[0]) - from .vector_real_double_dense import Vector_real_double_dense + from sage.modules.vector_real_double_dense import Vector_real_double_dense v = Vector_real_double_dense(V, v) if immutable: v.set_immutable() @@ -566,7 +566,7 @@ def vector(arg0, arg1=None, arg2=None, sparse=None, immutable=False): if (R is None or isinstance(R, ComplexDoubleField)) and v.dtype.kind == 'c': from sage.rings.complex_double import CDF V = VectorSpace(CDF, v.shape[0]) - from .vector_complex_double_dense import Vector_complex_double_dense + from sage.modules.vector_complex_double_dense import Vector_complex_double_dense v = Vector_complex_double_dense(V, v) if immutable: v.set_immutable() @@ -1831,7 +1831,7 @@ cdef class FreeModuleElement(Vector): # abstract base class values = [] for n in range(slicelength): values.append(self.get_unsafe(start + n*step)) - from .free_module import FreeModule + from sage.modules.free_module import FreeModule M = FreeModule(self.coordinate_ring(), slicelength, sparse=self.is_sparse()) return M(values, coerce=False, copy=False) else: @@ -5093,7 +5093,7 @@ cdef class FreeModuleElement_generic_sparse(FreeModuleElement): if min <= n <= max and n % step == mod: k = (n - start) // step newentries[k] = x - from .free_module import FreeModule + from sage.modules.free_module import FreeModule M = FreeModule(self.coordinate_ring(), slicelength, sparse=True) return M(newentries, coerce=False, copy=False) diff --git a/src/sage/modules/vector_double_dense.pyx b/src/sage/modules/vector_double_dense.pyx index a47d91a7fdd..9977e91e15b 100644 --- a/src/sage/modules/vector_double_dense.pyx +++ b/src/sage/modules/vector_double_dense.pyx @@ -284,7 +284,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): fft = scipy.fft ifft = scipy.ifft V = CDF ** self._degree - from .vector_complex_double_dense import Vector_complex_double_dense + from sage.modules.vector_complex_double_dense import Vector_complex_double_dense if direction == 'forward': return Vector_complex_double_dense(V, fft(self._vector_numpy)) else: diff --git a/src/sage/modules/vector_numpy_dense.pyx b/src/sage/modules/vector_numpy_dense.pyx index fc14cc4829a..0c7a67dbbd5 100644 --- a/src/sage/modules/vector_numpy_dense.pyx +++ b/src/sage/modules/vector_numpy_dense.pyx @@ -29,7 +29,7 @@ AUTHORS: cimport numpy import numpy -from .free_module_element import FreeModuleElement +from sage.modules.free_module_element import FreeModuleElement # This is for the NumPy C API (the PyArray... functions) to work numpy.import_array() From 4370ea2c67f0dc78ea8b9b6665ed51dc166124bc Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 22:16:45 -0700 Subject: [PATCH 299/494] Clean up cimports --- src/sage/matrix/matrix_modn_sparse.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index b6d60d3d586..2a399790ca3 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -108,6 +108,7 @@ from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.matrix.matrix2 import Matrix as Matrix2 from sage.matrix.matrix_dense cimport Matrix_dense from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense +from sage.matrix.matrix_sparse cimport Matrix_sparse from sage.misc.verbose import verbose, get_verbose from sage.modules.vector_integer_dense cimport Vector_integer_dense from sage.modules.vector_integer_sparse cimport * From 8b0824e1d4b0001f96ced5f9740461e547d4da81 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 17 Aug 2023 12:31:37 -0700 Subject: [PATCH 300/494] sage.matrix: Fix # needs (sage -fixdoctests, manual) --- src/sage/matrix/args.pyx | 1 + src/sage/matrix/matrix0.pyx | 22 ++-- src/sage/matrix/matrix1.pyx | 2 +- src/sage/matrix/matrix2.pyx | 215 ++++++++++++++++++++---------------- 4 files changed, 130 insertions(+), 110 deletions(-) diff --git a/src/sage/matrix/args.pyx b/src/sage/matrix/args.pyx index bdb6eb796dd..3a86f44df7f 100644 --- a/src/sage/matrix/args.pyx +++ b/src/sage/matrix/args.pyx @@ -871,6 +871,7 @@ cdef class MatrixArgs: Check github issue #36065: + sage: # needs sage.rings.number_field sage: class MyAlgebraicNumber(sage.rings.qqbar.AlgebraicNumber): ....: def __bool__(self): ....: raise ValueError diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index d7a0487e6cd..afffb037d11 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -543,11 +543,11 @@ cdef class Matrix(sage.structure.element.Matrix): TESTS:: - sage: class MyAlgebraicNumber(sage.rings.qqbar.AlgebraicNumber): # needs sage.rings.number_fields + sage: class MyAlgebraicNumber(sage.rings.qqbar.AlgebraicNumber): # needs sage.rings.number_field ....: def __bool__(self): ....: raise ValueError - sage: mat = matrix(1, 1, MyAlgebraicNumber(1)) # needs sage.rings.number_fields - sage: bool(mat) # needs sage.rings.number_fields + sage: mat = matrix(1, 1, MyAlgebraicNumber(1)) # needs sage.rings.number_field + sage: bool(mat) # needs sage.rings.number_field Traceback (most recent call last): ... ValueError @@ -4898,7 +4898,7 @@ cdef class Matrix(sage.structure.element.Matrix): Over finite fields:: sage: A = matrix(GF(59), 3, [10,56,39,53,56,33,58,24,55]) - sage: A.multiplicative_order() # needs sage.groups + sage: A.multiplicative_order() # needs sage.libs.pari 580 sage: (A^580).is_one() True @@ -4918,7 +4918,7 @@ cdef class Matrix(sage.structure.element.Matrix): Over `\ZZ`:: sage: m = matrix(ZZ, 2, 2, [-1,1,-1,0]) - sage: m.multiplicative_order() # needs sage.groups + sage: m.multiplicative_order() # needs sage.libs.pari 3 sage: m = posets.ChainPoset(6).coxeter_transformation() # needs sage.combinat sage.graphs @@ -4930,10 +4930,10 @@ cdef class Matrix(sage.structure.element.Matrix): 10 sage: M = matrix(ZZ, 2, 2, [1, 1, 0, 1]) - sage: M.multiplicative_order() # needs sage.groups + sage: M.multiplicative_order() # needs sage.libs.pari +Infinity - sage: for k in range(600): # needs sage.groups + sage: for k in range(600): # needs sage.groups sage.modular ....: m = SL2Z.random_element() ....: o = m.multiplicative_order() ....: if o != Infinity and m**o != SL2Z.one(): @@ -4948,7 +4948,7 @@ cdef class Matrix(sage.structure.element.Matrix): ....: else: ....: return ZZ.random_element(-100,100) sage: rnd = matrix(ZZ, 8, 8, val) - sage: (rnd * m24 * rnd.inverse_of_unit()).multiplicative_order() # needs sage.groups + sage: (rnd * m24 * rnd.inverse_of_unit()).multiplicative_order() # needs sage.libs.pari 24 TESTS:: @@ -5827,9 +5827,9 @@ cdef class Matrix(sage.structure.element.Matrix): Tests for :trac:`28570`:: - sage: P = posets.TamariLattice(7) # needs sage.combinat sage.graphs - sage: M = P._hasse_diagram._leq_matrix # needs sage.combinat sage.graphs - sage: M.inverse_of_unit() # this was very slow, now 1s # needs sage.combinat sage.graphs + sage: P = posets.TamariLattice(7) # needs sage.graphs + sage: M = P._hasse_diagram._leq_matrix # needs sage.graphs + sage: M.inverse_of_unit() # this was very slow, now 1s # needs sage.graphs 429 x 429 sparse matrix over Integer Ring... sage: m = matrix(Zmod(2**2), 1, 1, [1], sparse=True) diff --git a/src/sage/matrix/matrix1.pyx b/src/sage/matrix/matrix1.pyx index 14a8538a535..1193b0a6ca0 100644 --- a/src/sage/matrix/matrix1.pyx +++ b/src/sage/matrix/matrix1.pyx @@ -103,7 +103,7 @@ cdef class Matrix(Matrix0): [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ] sage: g.CharacteristicPolynomial() x_1^3-12*x_1^2-18*x_1 - sage: A.characteristic_polynomial() + sage: A.characteristic_polynomial() # needs sage.libs.pari x^3 - 12*x^2 - 18*x sage: matrix(QQ, g) == A True diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 8af0889927f..a028f087578 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -313,6 +313,7 @@ cdef class Matrix(Matrix1): Over the complex numbers:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[ 0, -1 + 2*I, 1 - 3*I, I], ....: [2 + 4*I, -2 + 3*I, -1 + 2*I, -1 - I], ....: [ 2 + I, 1 - I, -1, 5], @@ -416,6 +417,7 @@ cdef class Matrix(Matrix1): Check that coercions work correctly (:trac:`17405`):: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(RDF, 2, range(4)) sage: b = vector(CDF, [1+I, 2]) sage: A.solve_left(b) @@ -435,7 +437,6 @@ cdef class Matrix(Matrix1): ... ValueError: matrix equation has no solutions - In this case, turning off the ``check`` leads to a wrong result:: sage: A.solve_left(b, check=False) # needs sage.symbolic @@ -694,6 +695,7 @@ cdef class Matrix(Matrix1): Over the complex numbers:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[ 0, -1 + 2*I, 1 - 3*I, I], ....: [2 + 4*I, -2 + 3*I, -1 + 2*I, -1 - I], ....: [ 2 + I, 1 - I, -1, 5], @@ -805,6 +807,7 @@ cdef class Matrix(Matrix1): Check that coercions work correctly (:trac:`17405`):: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(RDF, 2, range(4)) sage: b = vector(CDF, [1+I, 2]) sage: A.solve_right(b) @@ -1542,8 +1545,8 @@ cdef class Matrix(Matrix1): EXAMPLES:: - sage: M = diagonal_matrix(CDF, [0, I, 1+I]) - sage: M + sage: # needs sage.rings.complex_double sage.symbolic + sage: M = diagonal_matrix(CDF, [0, I, 1+I]); M [ 0.0 0.0 0.0] [ 0.0 1.0*I 0.0] [ 0.0 0.0 1.0 + 1.0*I] @@ -1765,7 +1768,7 @@ cdef class Matrix(Matrix1): [1, 8, 20, 16, 4] sage: A.rook_vector(algorithm="Ryser") [1, 8, 20, 16, 4] - sage: A.rook_vector(algorithm="Godsil") # needs sage.graphs + sage: A.rook_vector(algorithm="Godsil") # needs sage.graphs sage.libs.flint [1, 8, 20, 16, 4] When the matrix `A` has more ones then zeroes it is usually faster @@ -1805,17 +1808,17 @@ cdef class Matrix(Matrix1): [1, 0, 0] sage: matrix([[0,0],[0,0]]).rook_vector(algorithm="Ryser") [1, 0, 0] - sage: matrix([[0,0],[0,0]]).rook_vector(algorithm="Godsil") # needs sage.graphs + sage: matrix([[0,0],[0,0]]).rook_vector(algorithm="Godsil") # needs sage.graphs sage.libs.flint [1, 0, 0] sage: matrix.ones(4, 2).rook_vector("Ryser") [1, 8, 12] - sage: matrix.ones(4, 2).rook_vector("Godsil") # needs sage.graphs + sage: matrix.ones(4, 2).rook_vector("Godsil") # needs sage.graphs sage.libs.flint [1, 8, 12] sage: m = matrix(ZZ,4,5) sage: m[:4,:4] = identity_matrix(4) sage: algos = ["Ryser", "ButeraPernici"] sage: algos += ["Godsil"] - sage: for algorithm in algos: # needs sage.graphs + sage: for algorithm in algos: # needs sage.graphs sage.libs.flint ....: v = m.rook_vector(complement=True, use_complement=True, algorithm=algorithm) ....: if v != [1, 16, 78, 128, 53]: ....: print("ERROR with algorithm={} use_complement=True".format(algorithm)) @@ -2062,17 +2065,18 @@ cdef class Matrix(Matrix1): We verify that :trac:`10063` is resolved:: + sage: # needs sage.libs.singular sage: A = GF(2)['x,y,z'] sage: A.inject_variables() Defining x, y, z - sage: R = A.quotient(x^2 + 1).quotient(y^2 + 1).quotient(z^2 + 1) # needs sage.rings.finite_rings - sage: R.inject_variables() # needs sage.rings.finite_rings + sage: R = A.quotient(x^2 + 1).quotient(y^2 + 1).quotient(z^2 + 1) + sage: R.inject_variables() Defining xbarbarbar, ybarbarbar, zbarbarbar - sage: M = matrix([[1, 1, 1, 1], # needs sage.rings.finite_rings + sage: M = matrix([[1, 1, 1, 1], ....: [xbarbarbar, ybarbarbar, 1, 1], ....: [0, 1, zbarbarbar, 1], ....: [xbarbarbar, zbarbarbar, 1, 1]]) - sage: M.determinant() # needs sage.rings.finite_rings + sage: M.determinant() xbarbarbar*ybarbarbar*zbarbarbar + xbarbarbar*ybarbarbar + xbarbarbar*zbarbarbar + ybarbarbar*zbarbarbar + xbarbarbar + ybarbarbar + zbarbarbar + 1 @@ -2448,7 +2452,7 @@ cdef class Matrix(Matrix1): In that case, the definition by perfect matchings is used instead:: - sage: A.pfaffian() # needs sage.combinat sage.rings.finite_rings + sage: A.pfaffian() # needs sage.combinat 2 """ @@ -3014,10 +3018,10 @@ cdef class Matrix(Matrix1): ``S`` in the following example is an integral domain. But the computation of the characteristic polynomial succeeds as follows:: + sage: # needs sage.libs.singular sage: R. = QQ[] sage: S. = R.quo((b^3)) - sage: A = matrix(S, [[x*y^2, 2*x], [2, x^10*y]]) - sage: A + sage: A = matrix(S, [[x*y^2, 2*x], [2, x^10*y]]); A [ x*y^2 2*x] [ 2 x^10*y] sage: A.charpoly('T') @@ -4197,7 +4201,7 @@ cdef class Matrix(Matrix1): [1 0 0 0 0 1] sage: A*DP.transpose() == zero_matrix(GF(2), 3, 4) True - sage: A.right_kernel_matrix(algorithm='pluq', basis='echelon') + sage: A.right_kernel_matrix(algorithm='pluq', basis='echelon') # needs sage.libs.m4ri [1 0 0 0 0 1] [0 1 1 0 0 0] [0 0 0 1 0 0] @@ -4455,7 +4459,8 @@ cdef class Matrix(Matrix1): sage: A.right_kernel_matrix() Traceback (most recent call last): ... - NotImplementedError: Cannot compute a matrix kernel over Quaternion Algebra (-1, -1) with base ring Rational Field + NotImplementedError: Cannot compute a matrix kernel over + Quaternion Algebra (-1, -1) with base ring Rational Field We test error messages for improper choices of the 'algorithm' keyword. :: @@ -4467,15 +4472,18 @@ cdef class Matrix(Matrix1): sage: matrix(GF(2), 2, 2).right_kernel_matrix(algorithm='padic') Traceback (most recent call last): ... - ValueError: 'padic' matrix kernel algorithm only available over the rationals and the integers, not over Finite Field of size 2 + ValueError: 'padic' matrix kernel algorithm only available over + the rationals and the integers, not over Finite Field of size 2 sage: matrix(QQ, 2, 2).right_kernel_matrix(algorithm='pari') Traceback (most recent call last): ... - ValueError: 'pari' matrix kernel algorithm only available over non-trivial number fields and the integers, not over Rational Field - sage: matrix(QQ, 2, 2).right_kernel_matrix(algorithm='pluq') + ValueError: 'pari' matrix kernel algorithm only available over + non-trivial number fields and the integers, not over Rational Field + sage: matrix(QQ, 2, 2).right_kernel_matrix(algorithm='pluq') # needs sage.libs.m4ri Traceback (most recent call last): ... - ValueError: 'pluq' matrix kernel algorithm only available over integers mod 2, not over Rational Field + ValueError: 'pluq' matrix kernel algorithm only available over + integers mod 2, not over Rational Field We test error messages for improper basis format requests. :: @@ -4490,7 +4498,8 @@ cdef class Matrix(Matrix1): sage: matrix(QQ, 2, 2).right_kernel_matrix(basis='LLL') Traceback (most recent call last): ... - ValueError: LLL-reduced basis only available over the integers, not over Rational Field + ValueError: LLL-reduced basis only available over the integers, + not over Rational Field Finally, error messages for the 'proof' keyword. :: @@ -5435,8 +5444,10 @@ cdef class Matrix(Matrix1): [1 0 0] [0 1 0] [0 0 1] - sage: W = MatrixSpace(CC,2,2) - sage: B = W([1, 2+3*I,4+5*I,9]); B + + sage: # needs sage.rings.real_mpfr sage.symbolic + sage: W = MatrixSpace(CC, 2, 2) + sage: B = W([1, 2 + 3*I, 4 + 5*I, 9]); B [ 1.00000000000000 2.00000000000000 + 3.00000000000000*I] [4.00000000000000 + 5.00000000000000*I 9.00000000000000] sage: B.column_space() @@ -6092,7 +6103,7 @@ cdef class Matrix(Matrix1): sage: A._eigenspace_format(None) == 'all' # needs sage.rings.number_field True sage: B = matrix(GF(13), 2, range(4)) - sage: B._eigenspace_format(None) # needs sage.rings.finite_rings + sage: B._eigenspace_format(None) 'all' Subrings are promoted to fraction fields and then checked for the @@ -6373,12 +6384,12 @@ cdef class Matrix(Matrix1): sage: # needs sage.rings.finite_rings sage: F. = FiniteField(11^2) sage: A = matrix(F, [[b + 1, b + 1], [10*b + 4, 5*b + 4]]) - sage: A.eigenspaces_left(format='all') + sage: A.eigenspaces_left(format='all') # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: unable to construct eigenspaces for eigenvalues outside the base field, try the keyword option: format='galois' - sage: A.eigenspaces_left(format='galois') + sage: A.eigenspaces_left(format='galois') # needs sage.rings.number_field [ (a0, Vector space of degree 2 and dimension 1 over Univariate Quotient Polynomial Ring in a0 over @@ -6771,7 +6782,7 @@ cdef class Matrix(Matrix1): sage: M = matrix(QQ, [[0,-1,0], [1,0,0], [0,0,2]]) sage: M.eigenvalues() # needs sage.rings.number_field [2, -1*I, 1*I] - sage: M.eigenvalues(extend=False) # needs sage.rings.number_field + sage: M.eigenvalues(extend=False) # needs sage.libs.pari [2] The method also works for matrices over finite fields:: @@ -7119,23 +7130,25 @@ cdef class Matrix(Matrix1): The matrix `B` in a generalized eigenvalue problem may be singular:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix.identity(CDF, 2) sage: B = matrix(CDF, [[2, 1+I], [4, 2+2*I]]) sage: D, P = A.eigenmatrix_left(B) - sage: D.diagonal() # tol 1e-14 # needs sage.symbolic + sage: D.diagonal() # tol 1e-14 [0.2 - 0.1*I, +infinity] In this case, we can still verify the eigenvector equation for the first eigenvalue and first eigenvector:: - sage: l = D[0, 0] # needs sage.symbolic + sage: # needs sage.rings.complex_double sage.symbolic + sage: l = D[0, 0] sage: v = P[0, :] - sage: (v * A - l * v * B).norm() < 1e-14 # needs sage.symbolic + sage: (v * A - l * v * B).norm() < 1e-14 True The second eigenvector is contained in the left kernel of `B`:: - sage: (P[1, :] * B).norm() < 1e-14 + sage: (P[1, :] * B).norm() < 1e-14 # needs sage.rings.complex_double sage.symbolic True .. SEEALSO:: @@ -7170,6 +7183,7 @@ cdef class Matrix(Matrix1): The following example shows that :trac:`20439` has been resolved:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[-2.53634347567, 2.04801738686, -0.0, -62.166145304], ....: [ 0.7, -0.6, 0.0, 0.0], ....: [0.547271128842, 0.0, -0.3015, -21.7532081652], @@ -7181,6 +7195,7 @@ cdef class Matrix(Matrix1): The following example shows that the fix for :trac:`20439` (conjugating eigenvectors rather than eigenvalues) is the correct one:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = Matrix(CDF,[[I,0],[0,1]]) sage: D, P = A.eigenmatrix_left() sage: (P*A - D*P).norm() < 10^(-2) @@ -7212,6 +7227,7 @@ cdef class Matrix(Matrix1): The following example shows that :trac:`12595` has been resolved:: + sage: # needs sage.rings.complex_double sage: m = Matrix(CDF, 8, [[-1, -1, -1, -1, 1, -3, -1, -1], ....: [1, 1, 1, 1, -1, -1, 1, -3], ....: [-1, 3, -1, -1, 1, 1, -1, -1], @@ -7391,6 +7407,7 @@ cdef class Matrix(Matrix1): The following example shows that :trac:`20439` has been resolved:: + sage: # needs sage.rings.complex_double sage: A = matrix(CDF, [[-2.53634347567, 2.04801738686, -0.0, -62.166145304], ....: [ 0.7, -0.6, 0.0, 0.0], ....: [0.547271128842, 0.0, -0.3015, -21.7532081652], @@ -7402,6 +7419,7 @@ cdef class Matrix(Matrix1): The following example shows that the fix for :trac:`20439` (conjugating eigenvectors rather than eigenvalues) is the correct one:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = Matrix(CDF,[[I,0],[0,1]]) sage: D, P = A.eigenmatrix_right() sage: (A*P - P*D).norm() < 10^(-2) @@ -8449,7 +8467,7 @@ cdef class Matrix(Matrix1): EXAMPLES:: - sage: # needs sage.groups + sage: # needs sage.graphs sage.groups sage: M = matrix(ZZ,[[1,0],[1,0],[0,1]]); M [1 0] [1 0] @@ -8464,7 +8482,7 @@ cdef class Matrix(Matrix1): One can now apply these automorphisms to ``M`` to show that it leaves it invariant:: - sage: all(M.with_permuted_rows_and_columns(*i) == M for i in A) # needs sage.groups + sage: all(M.with_permuted_rows_and_columns(*i) == M for i in A) # needs sage.graphs sage.groups True Check that :trac:`25426` is fixed:: @@ -8474,7 +8492,7 @@ cdef class Matrix(Matrix1): ....: (1, 0, 3, 0, 2), ....: (0, 1, 0, 2, 1), ....: (0, 0, 2, 1, 2)]) - sage: j.automorphisms_of_rows_and_columns() # needs sage.groups + sage: j.automorphisms_of_rows_and_columns() # needs sage.graphs sage.groups [((), ()), ((1,3)(2,5), (1,3)(2,5))] """ from sage.groups.perm_gps.constructor import \ @@ -8699,15 +8717,13 @@ cdef class Matrix(Matrix1): Some examples that are not permutations of each other:: - sage: N = matrix(ZZ, [[1,2,3], [4,5,6], [7,8,9]]) - sage: N + sage: N = matrix(ZZ, [[1,2,3], [4,5,6], [7,8,9]]); N [1 2 3] [4 5 6] [7 8 9] sage: M.is_permutation_of(N) # needs sage.graphs False - sage: N = matrix(ZZ, [[1,2], [3,4]]) - sage: N + sage: N = matrix(ZZ, [[1,2], [3,4]]); N [1 2] [3 4] sage: M.is_permutation_of(N) @@ -8715,9 +8731,8 @@ cdef class Matrix(Matrix1): And for when ``check`` is True:: - sage: # needs sage.graphs - sage: N = matrix(ZZ, [[3,5,3], [2,6,4], [1,2,3]]) - sage: N + sage: # needs sage.graphs sage.groups + sage: N = matrix(ZZ, [[3,5,3], [2,6,4], [1,2,3]]); N [3 5 3] [2 6 4] [1 2 3] @@ -9331,7 +9346,7 @@ cdef class Matrix(Matrix1): sage: D = A.tensor_product(B) sage: D.parent() Full MatrixSpace of 6 by 12 dense matrices over Finite Field of size 23 - sage: E = C.tensor_product(B) # needs sage.rings.finite_rings + sage: E = C.tensor_product(B) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: @@ -9667,9 +9682,9 @@ cdef class Matrix(Matrix1): [0 0 0 1 0] sage: P.is_unitary() True - sage: P.change_ring(GF(3)).is_unitary() # needs sage.rings.finite_rings + sage: P.change_ring(GF(3)).is_unitary() True - sage: P.change_ring(GF(3)).is_unitary() # needs sage.rings.finite_rings + sage: P.change_ring(GF(3)).is_unitary() True A square matrix far from unitary. :: @@ -9902,14 +9917,14 @@ cdef class Matrix(Matrix1): sage: L.append((2, Permutation([1, 4, 2, 3, 5]))) sage: M = sum([c * p.to_matrix() for c, p in L]) sage: from sage.combinat.permutation import bistochastic_as_sum_of_permutations - sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.combinat - sage: print(decomp) # needs sage.combinat + sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.combinat sage.graphs + sage: print(decomp) # needs sage.combinat sage.graphs 2*B[[1, 4, 2, 3, 5]] + 3*B[[3, 1, 4, 2, 5]] + 9*B[[4, 1, 3, 5, 2]] + 6*B[[5, 3, 4, 1, 2]] An exception is raised when the matrix is not bistochastic:: sage: M = Matrix([[2,3],[2,2]]) - sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.combinat + sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.graphs Traceback (most recent call last): ... ValueError: The matrix is not bistochastic @@ -10766,6 +10781,7 @@ cdef class Matrix(Matrix1): First, the inexact rings, ``CDF`` and ``RDF``. :: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[ 0.6454 + 0.7491*I, -0.8662 + 0.1489*I, 0.7656 - 0.00344*I], ....: [-0.2913 + 0.8057*I, 0.8321 + 0.8170*I, -0.6744 + 0.9248*I], ....: [ 0.2554 + 0.3517*I, -0.4454 - 0.1715*I, 0.8325 - 0.6282*I]]) @@ -10799,7 +10815,7 @@ cdef class Matrix(Matrix1): sage: M.round(6).zero_at(10^-6) [1.611147 0.0] [0.958116 0.867778] - sage: (A-M*G).zero_at(10^-12) + sage: (A - M*G).zero_at(10^-12) [0.0 0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0 0.0] sage: (G*G.transpose()).round(6).zero_at(10^-6) @@ -11110,7 +11126,7 @@ cdef class Matrix(Matrix1): EXAMPLES:: - sage: # needs sage.combinat + sage: # needs sage.combinat sage.libs.pari sage: a = matrix(ZZ,4,[1, 0, 0, 0, 0, 1, 0, 0, ....: 1, -1, 1, 0, 1, -1, 1, 2]); a [ 1 0 0 0] @@ -11156,20 +11172,21 @@ cdef class Matrix(Matrix1): If you need the transformation matrix as well as the Jordan form of ``self``, then pass the option ``transformation=True``. For example:: + sage: # needs sage.combinat sage.libs.pari sage: m = matrix([[5,4,2,1], [0,1,-1,-1], [-1,-1,3,0], [1,1,-1,2]]); m [ 5 4 2 1] [ 0 1 -1 -1] [-1 -1 3 0] [ 1 1 -1 2] - sage: jf, p = m.jordan_form(transformation=True) # needs sage.combinat - sage: jf # needs sage.combinat + sage: jf, p = m.jordan_form(transformation=True) + sage: jf [2|0|0 0] [-+-+---] [0|1|0 0] [-+-+---] [0|0|4 1] [0|0|0 4] - sage: ~p * m * p # needs sage.combinat + sage: ~p * m * p [2 0 0 0] [0 1 0 0] [0 0 4 1] @@ -11191,14 +11208,14 @@ cdef class Matrix(Matrix1): [1 1 1] [1 1 1] [1 1 1] - sage: c.jordan_form(subdivide=False) # needs sage.combinat + sage: c.jordan_form(subdivide=False) # needs sage.combinat sage.libs.pari [3 0 0] [0 0 0] [0 0 0] :: - sage: # needs sage.combinat + sage: # needs sage.combinat sage.libs.pari sage: evals = [(i,i) for i in range(1,6)] sage: n = sum(range(1,6)) sage: jf = block_diagonal_matrix([jordan_block(ev,size) for ev,size in evals]) @@ -11215,10 +11232,10 @@ cdef class Matrix(Matrix1): We verify that the bug from :trac:`6942` is fixed:: - sage: # needs sage.combinat - sage: M = Matrix(GF(2),[[1,0,1,0,0,0,1], [1,0,0,1,1,1,0], [1,1,0,1,1,1,1], - ....: [1,1,1,0,1,1,1], [1,1,1,0,0,1,0], [1,1,1,0,1,0,0], - ....: [1,1,1,1,1,1,0]]) + sage: # needs sage.combinat sage.libs.pari + sage: M = Matrix(GF(2), [[1,0,1,0,0,0,1], [1,0,0,1,1,1,0], [1,1,0,1,1,1,1], + ....: [1,1,1,0,1,1,1], [1,1,1,0,0,1,0], [1,1,1,0,1,0,0], + ....: [1,1,1,1,1,1,0]]) sage: J, T = M.jordan_form(transformation=True) sage: J [1 1|0 0|0 0|0] @@ -11247,6 +11264,7 @@ cdef class Matrix(Matrix1): We now go through three `10 \times 10` matrices to exhibit cases where there are multiple blocks of the same size:: + sage: # needs sage.combinat sage.libs.pari sage: A = matrix(QQ, [[15, 37/3, -16, -104/3, -29, -7/3, 0, 2/3, -29/3, -1/3], [2, 9, -1, -6, -6, 0, 0, 0, -2, 0], [24, 74/3, -41, -208/3, -58, -23/3, 0, 4/3, -58/3, -2/3], [-6, -19, 3, 21, 19, 0, 0, 0, 6, 0], [2, 6, 3, -6, -3, 1, 0, 0, -2, 0], [-96, -296/3, 176, 832/3, 232, 101/3, 0, -16/3, 232/3, 8/3], [-4, -2/3, 21, 16/3, 4, 14/3, 3, -1/3, 4/3, -25/3], [20, 26/3, -66, -199/3, -42, -41/3, 0, 13/3, -55/3, -2/3], [18, 57, -9, -54, -57, 0, 0, 0, -15, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 3]]); A [ 15 37/3 -16 -104/3 -29 -7/3 0 2/3 -29/3 -1/3] [ 2 9 -1 -6 -6 0 0 0 -2 0] @@ -11258,7 +11276,7 @@ cdef class Matrix(Matrix1): [ 20 26/3 -66 -199/3 -42 -41/3 0 13/3 -55/3 -2/3] [ 18 57 -9 -54 -57 0 0 0 -15 0] [ 0 0 0 0 0 0 0 0 0 3] - sage: J, T = A.jordan_form(transformation=True); J # needs sage.combinat + sage: J, T = A.jordan_form(transformation=True); J [3 1 0|0 0 0|0 0 0|0] [0 3 1|0 0 0|0 0 0|0] [0 0 3|0 0 0|0 0 0|0] @@ -11272,13 +11290,14 @@ cdef class Matrix(Matrix1): [0 0 0|0 0 0|0 0 3|0] [-----+-----+-----+-] [0 0 0|0 0 0|0 0 0|3] - sage: T * J * T**(-1) == A # needs sage.combinat + sage: T * J * T**(-1) == A True - sage: T.rank() # needs sage.combinat + sage: T.rank() 10 :: + sage: # needs sage.combinat sage.libs.pari sage: A = matrix(QQ, [[15, 37/3, -16, -14/3, -29, -7/3, 0, 2/3, 1/3, 44/3], [2, 9, -1, 0, -6, 0, 0, 0, 0, 3], [24, 74/3, -41, -28/3, -58, -23/3, 0, 4/3, 2/3, 88/3], [-6, -19, 3, 3, 19, 0, 0, 0, 0, -9], [2, 6, 3, 0, -3, 1, 0, 0, 0, 3], [-96, -296/3, 176, 112/3, 232, 101/3, 0, -16/3, -8/3, -352/3], [-4, -2/3, 21, 16/3, 4, 14/3, 3, -1/3, 4/3, -25/3], [20, 26/3, -66, -28/3, -42, -41/3, 0, 13/3, 2/3, 82/3], [18, 57, -9, 0, -57, 0, 0, 0, 3, 28], [0, 0, 0, 0, 0, 0, 0, 0, 0, 3]]); A [ 15 37/3 -16 -14/3 -29 -7/3 0 2/3 1/3 44/3] [ 2 9 -1 0 -6 0 0 0 0 3] @@ -11290,7 +11309,7 @@ cdef class Matrix(Matrix1): [ 20 26/3 -66 -28/3 -42 -41/3 0 13/3 2/3 82/3] [ 18 57 -9 0 -57 0 0 0 3 28] [ 0 0 0 0 0 0 0 0 0 3] - sage: J, T = A.jordan_form(transformation=True); J # needs sage.combinat + sage: J, T = A.jordan_form(transformation=True); J [3 1 0|0 0 0|0 0|0 0] [0 3 1|0 0 0|0 0|0 0] [0 0 3|0 0 0|0 0|0 0] @@ -11304,13 +11323,14 @@ cdef class Matrix(Matrix1): [-----+-----+---+---] [0 0 0|0 0 0|0 0|3 1] [0 0 0|0 0 0|0 0|0 3] - sage: T * J * T**(-1) == A # needs sage.combinat + sage: T * J * T**(-1) == A True - sage: T.rank() # needs sage.combinat + sage: T.rank() 10 :: + sage: # needs sage.combinat sage.libs.pari sage: A = matrix(QQ, [[15, 37/3, -16, -104/3, -29, -7/3, 35, 2/3, -29/3, -1/3], [2, 9, -1, -6, -6, 0, 7, 0, -2, 0], [24, 74/3, -29, -208/3, -58, -14/3, 70, 4/3, -58/3, -2/3], [-6, -19, 3, 21, 19, 0, -21, 0, 6, 0], [2, 6, -1, -6, -3, 0, 7, 0, -2, 0], [-96, -296/3, 128, 832/3, 232, 65/3, -279, -16/3, 232/3, 8/3], [0, 0, 0, 0, 0, 0, 3, 0, 0, 0], [20, 26/3, -30, -199/3, -42, -14/3, 70, 13/3, -55/3, -2/3], [18, 57, -9, -54, -57, 0, 63, 0, -15, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 3]]); A [ 15 37/3 -16 -104/3 -29 -7/3 35 2/3 -29/3 -1/3] [ 2 9 -1 -6 -6 0 7 0 -2 0] @@ -11322,7 +11342,7 @@ cdef class Matrix(Matrix1): [ 20 26/3 -30 -199/3 -42 -14/3 70 13/3 -55/3 -2/3] [ 18 57 -9 -54 -57 0 63 0 -15 0] [ 0 0 0 0 0 0 0 0 0 3] - sage: J, T = A.jordan_form(transformation=True); J # needs sage.combinat + sage: J, T = A.jordan_form(transformation=True); J [3 1 0|0 0|0 0|0 0|0] [0 3 1|0 0|0 0|0 0|0] [0 0 3|0 0|0 0|0 0|0] @@ -11337,15 +11357,15 @@ cdef class Matrix(Matrix1): [0 0 0|0 0|0 0|0 3|0] [-----+---+---+---+-] [0 0 0|0 0|0 0|0 0|3] - sage: T * J * T**(-1) == A # needs sage.combinat + sage: T * J * T**(-1) == A True - sage: T.rank() # needs sage.combinat + sage: T.rank() 10 Verify that we smoothly move to QQ from ZZ (:trac:`12693`), i.e. we work in the vector space over the field:: - sage: # needs sage.combinat + sage: # needs sage.combinat sage.libs.pari sage: M = matrix(((2,2,2), (0,0,0), (-2,-2,-2))) sage: J, P = M.jordan_form(transformation=True) sage: J; P @@ -11603,8 +11623,7 @@ cdef class Matrix(Matrix1): Matrices may fail to be diagonalizable for various reasons:: - sage: A = matrix(QQ, 2, [1,2,3, 4,5,6]) - sage: A + sage: A = matrix(QQ, 2, [1,2,3, 4,5,6]); A [1 2 3] [4 5 6] sage: A.diagonalization() @@ -11612,8 +11631,7 @@ cdef class Matrix(Matrix1): ... TypeError: not a square matrix - sage: B = matrix(ZZ, 2, [1, 2, 3, 4]) - sage: B + sage: B = matrix(ZZ, 2, [1, 2, 3, 4]); B [1 2] [3 4] sage: B.diagonalization() @@ -11621,17 +11639,16 @@ cdef class Matrix(Matrix1): ... ValueError: matrix entries must be from a field - sage: C = matrix(RR, 2, [1., 2., 3., 4.]) - sage: C + sage: C = matrix(RR, 2, [1., 2., 3., 4.]); C [1.00000000000000 2.00000000000000] [3.00000000000000 4.00000000000000] sage: C.diagonalization() Traceback (most recent call last): ... - ValueError: base field must be exact, but Real Field with 53 bits of precision is not + ValueError: base field must be exact, + but Real Field with 53 bits of precision is not - sage: D = matrix(QQ, 2, [0, 2, 1, 0]) - sage: D + sage: D = matrix(QQ, 2, [0, 2, 1, 0]); D [0 2] [1 0] sage: D.diagonalization() # needs sage.libs.pari @@ -11639,15 +11656,14 @@ cdef class Matrix(Matrix1): ... ValueError: not diagonalizable over Rational Field - sage: E = matrix(QQ, 2, [3, 1, 0, 3]) - sage: E + sage: E = matrix(QQ, 2, [3, 1, 0, 3]); E [3 1] [0 3] sage: E.diagonalization() # needs sage.libs.pari Traceback (most recent call last): ... ValueError: not diagonalizable - sage: E.jordan_form() # needs sage.combinat + sage: E.jordan_form() # needs sage.combinat sage.libs.pari [3 1] [0 3] """ @@ -11751,7 +11767,7 @@ cdef class Matrix(Matrix1): ....: [-1, 6, 1, -3, 1]]) sage: A.is_diagonalizable() # needs sage.libs.pari False - sage: A.jordan_form(subdivide=False) # needs sage.libs.pari + sage: A.jordan_form(subdivide=False) # needs sage.combinat sage.libs.pari [-1 1 0 0 0] [ 0 -1 0 0 0] [ 0 0 2 1 0] @@ -11794,7 +11810,7 @@ cdef class Matrix(Matrix1): ....: [ 2*b, 3*b, 4*b + 4, 3*b + 3]]) sage: A.is_diagonalizable() False - sage: A.jordan_form() + sage: A.jordan_form() # needs sage.combinat [ 4 1| 0 0] [ 0 4| 0 0] [---------------+---------------] @@ -11974,7 +11990,7 @@ cdef class Matrix(Matrix1): sage: A.is_similar(B) True - sage: # needs sage.libs.pari + sage: # needs sage.combinat sage.libs.pari sage: _, T = A.is_similar(B, transformation=True) sage: T [ 1.00000000000000? + 0.?e-14*I 0.?e-14 + 0.?e-14*I 0.?e-14 + 0.?e-14*I] @@ -12074,11 +12090,11 @@ cdef class Matrix(Matrix1): sage: D = S.inverse()*C*S sage: C.is_similar(D) True - sage: C.is_similar(D, transformation=True) + sage: C.is_similar(D, transformation=True) # needs sage.combinat Traceback (most recent call last): ... RuntimeError: unable to compute transformation for similar matrices - sage: C.jordan_form() + sage: C.jordan_form() # needs sage.combinat Traceback (most recent call last): ... RuntimeError: Some eigenvalue does not exist in @@ -12126,7 +12142,7 @@ cdef class Matrix(Matrix1): sage: A = matrix(GF(3), 2, 2, range(4)) sage: B = matrix(GF(2), 2, 2, range(4)) - sage: A.is_similar(B, transformation=True) # needs sage.rings.finite_rings + sage: A.is_similar(B, transformation=True) Traceback (most recent call last): ... TypeError: no common canonical parent for objects with parents: @@ -13420,7 +13436,7 @@ cdef class Matrix(Matrix1): [ 0 0 0 0] sage: L.base_ring() # needs sage.combinat Finite Field in a of size 5^2 - sage: C == P*L*U + sage: C == P*L*U # needs sage.combinat True With no pivoting strategy given (i.e. ``pivot=None``) @@ -14472,6 +14488,7 @@ cdef class Matrix(Matrix1): but `P^{T}AP` will ideally be close to `LDL^{*}` in the metric induced by the norm:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, 2, 2, [ [-1.1933, -0.3185 - 1.3553*I], ....: [-0.3185 + 1.3553*I, 1.5729 ] ]) sage: P,L,D = A.block_ldlt() @@ -14759,21 +14776,19 @@ cdef class Matrix(Matrix1): Any of the preceding examples are valid over inexact rings and with complex numbers as well:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [ [ 2, I], ....: [-I, 2] ] ) sage: A.is_positive_semidefinite() True - sage: A = matrix(CDF, [ [ 1, I], ....: [-I, 1] ] ) sage: A.is_positive_semidefinite() True - sage: A = matrix(CDF, [ [0,I], ....: [I,0] ] ) sage: A.is_positive_semidefinite() False - sage: A = matrix(CDF, [ [2,I], ....: [0,0] ]) sage: A.is_positive_semidefinite() @@ -14792,7 +14807,8 @@ cdef class Matrix(Matrix1): a Hermitian matrix (for a non-Hermitian matrix, both "obviously" return ``False``):: - sage: rings = [ZZ, QQ, RDF, CDF] + sage: rings = [ZZ, QQ, RDF] + sage: ring.append(CDF) # needs sage.rings.complex_double sage: rings.append(QuadraticField(-1, 'I')) # needs sage.rings.number_field sage: from sage.misc.prandom import choice sage: ring = choice(rings) @@ -15191,6 +15207,7 @@ cdef class Matrix(Matrix1): EXAMPLES:: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[1+I,1],[0,2*I]]) sage: A.conjugate() [1.0 - 1.0*I 1.0] @@ -15380,7 +15397,7 @@ cdef class Matrix(Matrix1): Faster routines for double precision entries from `RDF` or `CDF` are provided by the :class:`~sage.matrix.matrix_double_dense.Matrix_double_dense` class. :: - sage: # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr sage.symbolic sage: A = matrix(CC, 2, 3, [3*I,4,1-I,1,2,0]) sage: A.norm('frob') 5.656854249492381 @@ -15390,6 +15407,7 @@ cdef class Matrix(Matrix1): 6.0 sage: A.norm(Infinity) 8.414213562373096 + sage: a = matrix([[],[],[],[]]) sage: a.norm() 0.0 @@ -15404,13 +15422,14 @@ cdef class Matrix(Matrix1): 0.0 """ from sage.rings.real_double import RDF - from sage.rings.complex_double import CDF if self._nrows == 0 or self._ncols == 0: return RDF(0) # 2-norm: if p == 2: + from sage.rings.complex_double import CDF + A = self.change_ring(CDF) A = A.conjugate().transpose() * A S = A.SVD()[1] @@ -16738,7 +16757,7 @@ cdef class Matrix(Matrix1): sage: U.inverse()*B*U == Z True - sage: A.jordan_form() == B.jordan_form() # needs sage.combinat + sage: A.jordan_form() == B.jordan_form() # needs sage.combinat sage.libs.pari True Two more examples, illustrating the two extremes of the zig-zag @@ -16799,7 +16818,7 @@ cdef class Matrix(Matrix1): sage: U.inverse()*D*U == Z True - sage: C.jordan_form() == D.jordan_form() # needs sage.combinat + sage: C.jordan_form() == D.jordan_form() # needs sage.combinat sage.libs.pari True ZigZag form is achieved entirely with the operations of the field, so @@ -17117,7 +17136,7 @@ cdef class Matrix(Matrix1): ....: [-155, -3, -55, 45, 50, -245, -27, 65, -328, 77, 365, 583]]) sage: A.characteristic_polynomial().factor() # needs sage.libs.pari (x^2 - 2)^2 * (x^2 + 2*x + 5)^4 - sage: A.eigenvalues(extend=False) # needs sage.rings.number_field + sage: A.eigenvalues(extend=False) # needs sage.libs.pari [] sage: A.rational_form() [ 0 -5| 0 0 0 0| 0 0 0 0 0 0] @@ -17389,7 +17408,7 @@ cdef class Matrix(Matrix1): sage: L = matrix(SR, [ [0, e, 0 ], # needs sage.symbolic ....: [0, 2, pi], ....: [sqrt(2), 0, 0 ] ]) - sage: L.is_positive_operator_on(K) # needs sage.geometry.polyhedron sage.symbolic + sage: L.is_positive_operator_on(K) # needs sage.geometry.polyhedron True Your matrix can be over any exact ring, for example the ring of @@ -17816,7 +17835,7 @@ cdef class Matrix(Matrix1): sage: L = matrix(SR, [ [e, 0, 0 ], # needs sage.symbolic ....: [0, pi, 0 ], ....: [0, 0, sqrt(2)] ]) - sage: L.is_lyapunov_like_on(K) # needs sage.geometry.polyhedron sage.symbolic + sage: L.is_lyapunov_like_on(K) # needs sage.geometry.polyhedron True TESTS: From 1d01569b5a5b2468809148c3a67d1664b13b52f0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 17 Aug 2023 12:47:38 -0700 Subject: [PATCH 301/494] sage -fixdoctests --distribution all --fixed-point --only-tags --probe all --verbose src/sage/matrix; followed by manual fixes --- src/sage/matrix/matrix_double_sparse.pyx | 2 + src/sage/matrix/matrix_gap.pyx | 8 ++- src/sage/matrix/matrix_polynomial_dense.pyx | 14 ++--- src/sage/matrix/matrix_space.py | 64 ++++++++++----------- src/sage/matrix/matrix_sparse.pyx | 2 +- src/sage/matrix/operation_table.py | 4 +- src/sage/matrix/special.py | 2 +- src/sage/matrix/tests.py | 8 +-- 8 files changed, 56 insertions(+), 48 deletions(-) diff --git a/src/sage/matrix/matrix_double_sparse.pyx b/src/sage/matrix/matrix_double_sparse.pyx index adf285a311c..fc7d65a880c 100644 --- a/src/sage/matrix/matrix_double_sparse.pyx +++ b/src/sage/matrix/matrix_double_sparse.pyx @@ -143,6 +143,7 @@ cdef class Matrix_double_sparse(Matrix_generic_sparse): :: + sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[ 2, 4 + 2*I, 6 - 4*I], ....: [ -2*I + 4, 11, 10 - 12*I], ....: [ 4*I + 6, 10 + 12*I, 37]]) @@ -173,6 +174,7 @@ cdef class Matrix_double_sparse(Matrix_generic_sparse): :: + sage: # needs sage.rings.complex_double sage.symbolic sage: n = ZZ.random_element(1,5) sage: A = matrix.random(CDF, n, sparse=True) sage: I = matrix.identity(CDF, n, sparse=True) diff --git a/src/sage/matrix/matrix_gap.pyx b/src/sage/matrix/matrix_gap.pyx index 853cb0626a1..09849b784fb 100644 --- a/src/sage/matrix/matrix_gap.pyx +++ b/src/sage/matrix/matrix_gap.pyx @@ -48,6 +48,7 @@ cdef class Matrix_gap(Matrix_dense): sage: m.transpose().parent() is M True + sage: # needs sage.rings.number_field sage: UCF = UniversalCyclotomicField() sage: M = MatrixSpace(UCF, 3, implementation='gap') sage: m = M([UCF.zeta(i) for i in range(1,10)]) @@ -60,7 +61,9 @@ cdef class Matrix_gap(Matrix_dense): TESTS:: - sage: for ring in [ZZ, QQ, UniversalCyclotomicField(), GF(2), GF(3)]: + sage: rings = [ZZ, QQ, UniversalCyclotomicField(), GF(2), GF(3)] + sage: rings += [UniversalCyclotomicField()] # needs sage.rings.number_field + sage: for ring in rings: ....: M = MatrixSpace(ring, 2, implementation='gap') ....: TestSuite(M).run(skip=['_test_construction']) ....: M = MatrixSpace(ring, 2, 3, implementation='gap') @@ -233,6 +236,7 @@ cdef class Matrix_gap(Matrix_dense): sage: m1 != m3 True + sage: # needs sage.rings.number_field sage: UCF = UniversalCyclotomicField() sage: M = MatrixSpace(UCF, 2, implementation='gap') sage: m1 = M([E(2), E(3), 0, E(4)]) @@ -367,6 +371,7 @@ cdef class Matrix_gap(Matrix_dense): sage: parent(M(1).determinant()) Rational Field + sage: # needs sage.rings.number_field sage: M = MatrixSpace(UniversalCyclotomicField(), 1, implementation='gap') sage: parent(M(1).determinant()) Universal Cyclotomic Field @@ -395,6 +400,7 @@ cdef class Matrix_gap(Matrix_dense): sage: parent(M(1).trace()) Rational Field + sage: # needs sage.rings.number_field sage: M = MatrixSpace(UniversalCyclotomicField(), 1, implementation='gap') sage: parent(M(1).trace()) Universal Cyclotomic Field diff --git a/src/sage/matrix/matrix_polynomial_dense.pyx b/src/sage/matrix/matrix_polynomial_dense.pyx index 10d9a9248b6..b565952024c 100644 --- a/src/sage/matrix/matrix_polynomial_dense.pyx +++ b/src/sage/matrix/matrix_polynomial_dense.pyx @@ -2010,7 +2010,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): Demonstrating the ``ordered`` option:: - sage: P.leading_positions() # needs sage.combinat + sage: P.leading_positions() [2, 1] sage: PP = M.weak_popov_form(ordered=True); PP [ 2 4*x^2 + 2*x + 4 5] @@ -2129,12 +2129,12 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): sage: A = matrix(PF,[[1, a*x^17 + 1 ], ....: [0, a*x^11 + a^2*x^7 + 1 ]]) sage: M = A.__copy__() - sage: U = M._weak_popov_form(transformation=True) # needs sage.combinat - sage: U * A == M # needs sage.combinat + sage: U = M._weak_popov_form(transformation=True) + sage: U * A == M True - sage: M.is_weak_popov() # needs sage.combinat + sage: M.is_weak_popov() True - sage: U.is_invertible() # needs sage.combinat + sage: U.is_invertible() True sage: PF. = QQ[] @@ -3316,7 +3316,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): ....: [ 17, 86, x^2+77*x+16, 76*x+29, 90*x+78], ....: [ 44, 36, 3*x+42, x^2+50*x+26, 85*x+44], ....: [ 2, 22, 54*x+94, 73*x+24, x^2+2*x+25]]) - sage: appbas.is_minimal_approximant_basis( + sage: appbas.is_minimal_approximant_basis( # needs sage.libs.pari ....: pmat, order, shifts, row_wise=True, normal_form=True) True @@ -3326,7 +3326,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): contained in the set of approximants for ``pmat`` at order 8:: sage: M = x^8 * Matrix.identity(pR, 5) - sage: M.is_minimal_approximant_basis(pmat, 8) + sage: M.is_minimal_approximant_basis(pmat, 8) # needs sage.libs.pari False Since ``pmat`` is a single column, with nonzero constant coefficient, diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 279eba44511..278fd272b68 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -112,9 +112,9 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(ZZ, 4, 5, True, None) - sage: get_matrix_class(ZZ, 3, 3, False, 'flint') + sage: get_matrix_class(ZZ, 3, 3, False, 'flint') # needs sage.libs.flint - sage: get_matrix_class(ZZ, 3, 3, False, 'gap') # needs sage.modules + sage: get_matrix_class(ZZ, 3, 3, False, 'gap') # needs sage.libs.gap sage: get_matrix_class(ZZ, 3, 3, False, 'generic') @@ -124,14 +124,13 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(GF(2^17), 3, 3, False, None) # needs sage.rings.finite_rings - sage: # needs sage.rings.finite_rings - sage: get_matrix_class(GF(2), 2, 2, False, 'm4ri') + sage: get_matrix_class(GF(2), 2, 2, False, 'm4ri') # needs sage.libs.m4ri - sage: get_matrix_class(GF(4), 2, 2, False, 'm4ri') + sage: get_matrix_class(GF(4), 2, 2, False, 'm4ri') # needs sage.libs.m4ri sage.rings.finite_rings - sage: get_matrix_class(GF(7), 2, 2, False, 'linbox-float') + sage: get_matrix_class(GF(7), 2, 2, False, 'linbox-float') # needs sage.libs.linbox - sage: get_matrix_class(GF(7), 2, 2, False, 'linbox-double') + sage: get_matrix_class(GF(7), 2, 2, False, 'linbox-double') # needs sage.libs.linbox sage: get_matrix_class(RDF, 2, 2, False, 'numpy') # needs numpy @@ -139,9 +138,9 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(CDF, 2, 3, False, 'numpy') # needs numpy - sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings + sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings - sage: get_matrix_class(IntegerModRing(3), 4, 4, False, 'meataxe') # optional - meataxe + sage: get_matrix_class(IntegerModRing(3), 4, 4, False, 'meataxe') # optional - meataxe sage: get_matrix_class(IntegerModRing(4), 4, 4, False, 'meataxe') Traceback (most recent call last): @@ -159,12 +158,13 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(GF(3), 2, 2, False, 'm4ri') Traceback (most recent call last): ... - ValueError: 'm4ri' matrices are only available for fields of characteristic 2 and order <= 65536 - sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') + ValueError: 'm4ri' matrices are only available + for fields of characteristic 2 and order <= 65536 + sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') # needs sage.libs.linbox Traceback (most recent call last): ... ValueError: 'linbox-float' matrices can only deal with order < 256 - sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-double') + sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-double') # needs sage.libs.linbox Traceback (most recent call last): ... ValueError: 'linbox-double' matrices can only deal with order < 94906266 @@ -173,17 +173,17 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: type(matrix(SR, 2, 2, 0, sparse=True)) # needs sage.symbolic - sage: type(matrix(GF(7), 2, range(4))) # needs sage.rings.finite_rings + sage: type(matrix(GF(7), 2, range(4))) # needs sage.libs.linbox - sage: type(matrix(GF(16007), 2, range(4))) # needs sage.rings.finite_rings + sage: type(matrix(GF(16007), 2, range(4))) # needs sage.libs.linbox sage: type(matrix(CBF, 2, range(4))) # needs sage.libs.flint - sage: type(matrix(GF(2), 2, range(4))) # needs sage.rings.finite_rings + sage: type(matrix(GF(2), 2, range(4))) # needs sage.libs.m4ri - sage: type(matrix(GF(64, 'z'), 2, range(4))) # needs sage.rings.finite_rings + sage: type(matrix(GF(64, 'z'), 2, range(4))) # needs sage.libs.m4ri sage.rings.finite_rings - sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe # needs sage.rings.finite_rings + sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe, needs sage.rings.finite_rings """ @@ -496,29 +496,28 @@ class MatrixSpace(UniqueRepresentation, Parent): Check that different implementations play together as expected:: - sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') sage: M2 = MatrixSpace(ZZ, 2, implementation='generic') - - sage: type(M1(range(4))) # needs sage.libs.flint + sage: type(M1(range(4))) sage: type(M2(range(4))) - - sage: M1(M2.an_element()) # needs sage.libs.flint + sage: M1(M2.an_element()) [ 0 1] [-1 2] - sage: M2(M1.an_element()) # needs sage.libs.flint + sage: M2(M1.an_element()) [ 0 1] [-1 2] - - sage: all((A.get_action(B) is not None) == (A is B) # needs sage.libs.flint + sage: all((A.get_action(B) is not None) == (A is B) ....: for A in [M1, M2] for B in [M1, M2]) True Check that libgap matrices over finite fields are working properly:: - sage: M2 = MatrixSpace(GF(2), 5, implementation='gap') # needs sage.libs.gap sage.rings.finite_rings - sage: M2.one() # needs sage.libs.gap sage.rings.finite_rings + sage: # needs sage.libs.gap + sage: M2 = MatrixSpace(GF(2), 5, implementation='gap') + sage: M2.one() [1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] @@ -526,7 +525,7 @@ class MatrixSpace(UniqueRepresentation, Parent): [0 0 0 0 1] sage: m = M2.random_element() sage: M1 = MatrixSpace(GF(2), 5) - sage: M1(m * m) == M1(m) * M1(m) # needs sage.libs.gap sage.rings.finite_rings + sage: M1(m * m) == M1(m) * M1(m) True """ @@ -648,7 +647,8 @@ def __init__(self, base_ring, nrows, ncols, sparse, implementation): Category of infinite enumerated finite dimensional algebras with basis over (euclidean domains and infinite enumerated sets and metric spaces) sage: MatrixSpace(QQ,10).category() - Category of infinite finite dimensional algebras with basis over (number fields and quotient fields and metric spaces) + Category of infinite finite dimensional algebras with basis over + (number fields and quotient fields and metric spaces) TESTS: @@ -769,7 +769,7 @@ def _has_default_implementation(self): sage: MatrixSpace(ZZ, 2, implementation='generic')._has_default_implementation() False - sage: MatrixSpace(ZZ, 2, implementation='flint')._has_default_implementation() + sage: MatrixSpace(ZZ, 2, implementation='flint')._has_default_implementation() # needs sage.libs.flint True """ default = get_matrix_class(self.base_ring(), self.nrows(), self.ncols(), self.is_sparse(), None) @@ -1159,8 +1159,8 @@ def _coerce_map_from_(self, S): Coercion map: From: General Linear Group of degree 2 over Finite Field of size 3 To: Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 3 - sage: MS.coerce_map_from(GL(2, 2)) # needs sage.rings.finite_rings - sage: MS.coerce_map_from(Gamma1(5)) # needs sage.rings.finite_rings + sage: MS.coerce_map_from(GL(2, 2)) + sage: MS.coerce_map_from(Gamma1(5)) # needs sage.modular Coercion map: From: Congruence Subgroup Gamma1(5) To: Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 3 diff --git a/src/sage/matrix/matrix_sparse.pyx b/src/sage/matrix/matrix_sparse.pyx index a98c6bfe64c..ef707ebe3f8 100644 --- a/src/sage/matrix/matrix_sparse.pyx +++ b/src/sage/matrix/matrix_sparse.pyx @@ -1178,7 +1178,7 @@ cdef class Matrix_sparse(matrix.Matrix): Check that the bug in :trac:`13854` has been fixed:: - sage: # needs sage.combinat + sage: # needs sage.combinat sage.libs.singular sage: A. = FreeAlgebra(QQ, 2) sage: P. = A.g_algebra(relations={y*x: -x*y}, order='lex') sage: M = Matrix([[x]], sparse=True) diff --git a/src/sage/matrix/operation_table.py b/src/sage/matrix/operation_table.py index 4b3f1dc905c..50fe4f257dd 100644 --- a/src/sage/matrix/operation_table.py +++ b/src/sage/matrix/operation_table.py @@ -977,7 +977,7 @@ def color_table(self, element_names=True, cmap=None, **options): EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable - sage: OTa = OperationTable(SymmetricGroup(3), operation=operator.mul) # needs sage.groups sage.plot + sage: OTa = OperationTable(SymmetricGroup(3), operation=operator.mul) # needs sage.groups sage: OTa.color_table() # needs sage.groups sage.plot Graphics object consisting of 37 graphics primitives @@ -1036,7 +1036,7 @@ def gray_table(self, **options): EXAMPLES:: sage: from sage.matrix.operation_table import OperationTable - sage: OTa = OperationTable(SymmetricGroup(3), operation=operator.mul) # needs sage.groups sage.plot + sage: OTa = OperationTable(SymmetricGroup(3), operation=operator.mul) # needs sage.groups sage: OTa.gray_table() # needs sage.groups sage.plot Graphics object consisting of 37 graphics primitives diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index 0b23f80123a..b72daee9802 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -556,7 +556,7 @@ def random_matrix(ring, nrows, ncols=None, algorithm='randomize', implementation True sage: all(x in ZZ for x in (A - (-1)*identity_matrix(5)).rref().list()) True - sage: A.jordan_form() # needs sage.combinat + sage: A.jordan_form() # needs sage.combinat sage.libs.pari [ 2| 0| 0| 0| 0] [--+--+--+--+--] [ 0| 3| 0| 0| 0] diff --git a/src/sage/matrix/tests.py b/src/sage/matrix/tests.py index 9208a5d4d72..b4747bff5c9 100644 --- a/src/sage/matrix/tests.py +++ b/src/sage/matrix/tests.py @@ -48,10 +48,10 @@ sage: matrix(QQ['x,y'], 2, 2, [1, 1, 1, 1]) / x # needs sage.symbolic [1/x 1/x] [1/x 1/x] - sage: A = matrix(CC, 2, 2, [1, 1, 1, 1]) / I; A + sage: A = matrix(CC, 2, 2, [1, 1, 1, 1]) / I; A # needs sage.rings.real_mpfr sage.symbolic [-1.00000000000000*I -1.00000000000000*I] [-1.00000000000000*I -1.00000000000000*I] - sage: A.parent() + sage: A.parent() # needs sage.rings.real_mpfr sage.symbolic Full MatrixSpace of 2 by 2 dense matrices over Complex Field with 53 bits of precision We test an example determinant computation where LinBox gave an incorrect @@ -64,8 +64,8 @@ Test that a certain bug in GP's mathnf was fixed:: - sage: a = gp('Mat([-15,18,-23,-20,-32,11,-19,2,-1,15,22,29,-29,3,-31,25,11,-6,32,7; -31,0,30,-27,-15,13,-21,6,-27,6,3,-4,-4,-28,-30,-16,29,-4,29,-20; -15,-19,-30,9,-18,-31,23,-15,15,-9,20,10,-29,9,18,-6,-1,-20,19,-29; 2,-32,4,-13,17,21,12,-32,12,0,27,-10,-31,-33,-8,-31,-23,25,-18,6; -10,33,4,27,1,25,1,6,31,-7,3,30,23,-4,18,16,-12,21,0,4; -19,20,31,-34,-24,20,-13,-2,18,12,-18,33,22,0,0,10,-25,-29,6,-23; -15,-33,27,-9,-21,-20,5,-20,-31,-11,20,19,31,25,16,20,5,23,-32,-2; 20,18,12,-10,-3,-29,-14,4,-9,21,7,-34,6,16,7,10,11,-21,8,28; 10,-4,-11,-8,-29,33,-23,21,-3,-17,21,7,-28,-10,-16,-1,-29,32,12,16; 13,33,-7,15,-31,20,22,33,21,8,-24,20,27,30,24,20,-29,31,-20,-16; -24,-16,24,-8,7,-22,3,12,-1,-4,-9,10,13,-2,-14,-4,-3,-26,28,-25; 7,-7,19,-26,25,-27,33,12,6,3,31,-30,-14,6,-17,11,-6,5,15,0; 9,-32,-14,9,12,-8,-19,22,20,-23,14,29,-17,-28,-34,-10,4,26,-3,-14; 7,-13,-16,32,-2,11,-2,3,33,-22,-7,-3,12,-24,-7,-7,-1,31,26,22; 8,7,30,29,26,-12,13,21,-18,-5,-27,-33,1,16,-34,-10,-1,8,6,20; 32,-30,27,-21,33,5,14,30,13,24,10,-23,30,-18,13,25,0,-22,18,-19; -4,-6,7,28,-4,9,32,21,29,2,-7,7,-24,-10,2,-9,-23,-18,6,5; 3,19,0,23,-24,-16,-33,-15,-2,16,2,19,28,33,-16,32,-20,-15,28,-18])') - sage: a.mathnf(1)[1][1,] == gp('[4, 2, 1, 0, 3, 1, 1, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 3]') + sage: a = gp('Mat([-15,18,-23,-20,-32,11,-19,2,-1,15,22,29,-29,3,-31,25,11,-6,32,7; -31,0,30,-27,-15,13,-21,6,-27,6,3,-4,-4,-28,-30,-16,29,-4,29,-20; -15,-19,-30,9,-18,-31,23,-15,15,-9,20,10,-29,9,18,-6,-1,-20,19,-29; 2,-32,4,-13,17,21,12,-32,12,0,27,-10,-31,-33,-8,-31,-23,25,-18,6; -10,33,4,27,1,25,1,6,31,-7,3,30,23,-4,18,16,-12,21,0,4; -19,20,31,-34,-24,20,-13,-2,18,12,-18,33,22,0,0,10,-25,-29,6,-23; -15,-33,27,-9,-21,-20,5,-20,-31,-11,20,19,31,25,16,20,5,23,-32,-2; 20,18,12,-10,-3,-29,-14,4,-9,21,7,-34,6,16,7,10,11,-21,8,28; 10,-4,-11,-8,-29,33,-23,21,-3,-17,21,7,-28,-10,-16,-1,-29,32,12,16; 13,33,-7,15,-31,20,22,33,21,8,-24,20,27,30,24,20,-29,31,-20,-16; -24,-16,24,-8,7,-22,3,12,-1,-4,-9,10,13,-2,-14,-4,-3,-26,28,-25; 7,-7,19,-26,25,-27,33,12,6,3,31,-30,-14,6,-17,11,-6,5,15,0; 9,-32,-14,9,12,-8,-19,22,20,-23,14,29,-17,-28,-34,-10,4,26,-3,-14; 7,-13,-16,32,-2,11,-2,3,33,-22,-7,-3,12,-24,-7,-7,-1,31,26,22; 8,7,30,29,26,-12,13,21,-18,-5,-27,-33,1,16,-34,-10,-1,8,6,20; 32,-30,27,-21,33,5,14,30,13,24,10,-23,30,-18,13,25,0,-22,18,-19; -4,-6,7,28,-4,9,32,21,29,2,-7,7,-24,-10,2,-9,-23,-18,6,5; 3,19,0,23,-24,-16,-33,-15,-2,16,2,19,28,33,-16,32,-20,-15,28,-18])') # needs sage.libs.pari + sage: a.mathnf(1)[1][1,] == gp('[4, 2, 1, 0, 3, 1, 1, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 3]') # needs sage.libs.pari True """ From 95d63df81451435432aa53ba7ab8517826b595ad Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 11:51:46 -0700 Subject: [PATCH 302/494] src/sage/matrix/matrix2.pyx (determinant): Fall back when PARI is not available --- src/sage/matrix/matrix2.pyx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index a028f087578..05c836d2ca4 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -2141,10 +2141,15 @@ cdef class Matrix(Matrix1): # word, use PARI. ch = R.characteristic() if ch.is_prime() and ch < (2*sys.maxsize): - d = R(self.__pari__().matdet()) - else: - # Lift to ZZ and compute there. - d = R(self.apply_map(lambda x : x.lift_centered()).det()) + try: + d = R(self.__pari__().matdet()) + except ImportError: + pass + else: + self.cache('det', d) + return d + # Lift to ZZ and compute there. + d = R(self.apply_map(lambda x: x.lift_centered()).det()) self.cache('det', d) return d From 8177e8a5b65a651980b91191b316dca6c6565cca Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 23:46:22 -0700 Subject: [PATCH 303/494] Add # needs --- src/sage/matrix/matrix2.pyx | 2 +- src/sage/matrix/matrix_polynomial_dense.pyx | 1 - src/sage/modules/vector_space_morphism.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 05c836d2ca4..9fe2684eb2d 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -14813,7 +14813,7 @@ cdef class Matrix(Matrix1): return ``False``):: sage: rings = [ZZ, QQ, RDF] - sage: ring.append(CDF) # needs sage.rings.complex_double + sage: rings.append(CDF) # needs sage.rings.complex_double sage: rings.append(QuadraticField(-1, 'I')) # needs sage.rings.number_field sage: from sage.misc.prandom import choice sage: ring = choice(rings) diff --git a/src/sage/matrix/matrix_polynomial_dense.pyx b/src/sage/matrix/matrix_polynomial_dense.pyx index b565952024c..5d9e99a6a4c 100644 --- a/src/sage/matrix/matrix_polynomial_dense.pyx +++ b/src/sage/matrix/matrix_polynomial_dense.pyx @@ -998,7 +998,6 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): (2*x^3 + x^2, 5*x^3 + x^2 + 5*x + 6, 4*x^3 + 6*x^2 + 4*x) sage: B == A*X % x**4 True - sage: B = Matrix(pR, 3, 2, ....: [[5*x^2 + 6*x + 3, 4*x^2 + 6*x + 4], ....: [ x^2 + 4*x + 2, 5*x + 2], diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py index 2685462a74e..764c6ac39e5 100644 --- a/src/sage/modules/vector_space_morphism.py +++ b/src/sage/modules/vector_space_morphism.py @@ -224,7 +224,7 @@ sage: A = graphs.PetersenGraph().adjacency_matrix() sage: V = QQ^10 sage: phi = linear_transformation(V, V, A) - sage: phi.eigenvalues() + sage: phi.eigenvalues() # needs sage.rings.number_field [3, -2, -2, -2, -2, 1, 1, 1, 1, 1] sage: B1 = [V.gen(i) + V.gen(i+1) for i in range(9)] + [V.gen(9)] sage: C = V.subspace_with_basis(B1) From a8a4b8e6c5938e56fa3d10a1268af8c4ca772095 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:13:40 -0700 Subject: [PATCH 304/494] Add # needs --- src/sage/matrix/matrix2.pyx | 90 ++++++++++++----------- src/sage/matrix/matrix_space.py | 3 + src/sage/modules/filtered_vector_space.py | 4 +- src/sage/modules/vector_double_dense.pyx | 3 + 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 9fe2684eb2d..1a3690a466e 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -304,11 +304,11 @@ cdef class Matrix(Matrix1): [ 7.6 2.3 1.0] [ 1.0 2.0 -1.0] sage: b = vector(RDF,[1,2,3]) - sage: x = A.solve_left(b); x.zero_at(2e-17) # fix noisy zeroes + sage: x = A.solve_left(b); x.zero_at(2e-17) # fix noisy zeroes # needs scipy (0.666666666..., 0.0, 0.333333333...) - sage: x.parent() + sage: x.parent() # needs scipy Vector space of dimension 3 over Real Double Field - sage: x*A # tol 1e-14 + sage: x*A # tol 1e-14 # needs scipy (0.9999999999999999, 1.9999999999999998, 3.0) Over the complex numbers:: @@ -319,18 +319,19 @@ cdef class Matrix(Matrix1): ....: [ 2 + I, 1 - I, -1, 5], ....: [ 3*I, -1 - I, -1 + I, -3 + I]]) sage: b = vector(CDF, [2 -3*I, 3, -2 + 3*I, 8]) - sage: x = A.solve_left(b); x - (-1.55765124... - 0.644483985...*I, 0.183274021... + 0.286476868...*I, 0.270818505... + 0.246619217...*I, -1.69003558... - 0.828113879...*I) - sage: x.parent() + sage: x = A.solve_left(b); x # needs scipy + (-1.55765124... - 0.644483985...*I, 0.183274021... + 0.286476868...*I, + 0.270818505... + 0.246619217...*I, -1.69003558... - 0.828113879...*I) + sage: x.parent() # needs scipy Vector space of dimension 4 over Complex Double Field - sage: abs(x*A - b) < 1e-14 + sage: abs(x*A - b) < 1e-14 # needs scipy True If ``b`` is given as a matrix, the result will be a matrix, as well:: sage: A = matrix(RDF, 3, 3, [2, 5, 0, 7, 7, -2, -4.3, 0, 1]) sage: b = matrix(RDF, 2, 3, [2, -4, -5, 1, 1, 0.1]) - sage: A.solve_left(b) # tol 1e-14 + sage: A.solve_left(b) # tol 1e-14 # needs scipy [ -6.495454545454545 4.068181818181818 3.1363636363636354] [ 0.5277272727272727 -0.2340909090909091 -0.36818181818181817] @@ -340,16 +341,16 @@ cdef class Matrix(Matrix1): sage: A = matrix(RDF, 3, 2, [1, 3, 4, 2, 0, -3]) sage: b = vector(RDF, [5, 6]) - sage: x = A.solve_left(b) - sage: (x * A - b).norm() < 1e-14 + sage: x = A.solve_left(b) # needs scipy + sage: (x * A - b).norm() < 1e-14 # needs scipy True For a wide matrix `A`, the error is usually not small:: sage: A = matrix(RDF, 2, 3, [1, 3, 4, 2, 0, -3]) sage: b = vector(RDF, [5, 6, 1]) - sage: x = A.solve_left(b) - sage: (x * A - b).norm() # tol 1e-14 + sage: x = A.solve_left(b) # needs scipy + sage: (x * A - b).norm() # tol 1e-14 # needs scipy 0.9723055853282466 TESTS:: @@ -389,7 +390,7 @@ cdef class Matrix(Matrix1): sage: A = matrix(RDF, 5, range(25)) sage: b = vector(RDF, [1,2,3,4,5]) - sage: A.solve_left(b) + sage: A.solve_left(b) # needs scipy Traceback (most recent call last): ... LinAlgError: Matrix is singular. @@ -398,7 +399,7 @@ cdef class Matrix(Matrix1): sage: A = matrix(RDF, 5, range(25)) sage: b = vector(RDF, [1,2,3,4]) - sage: A.solve_left(b) + sage: A.solve_left(b) # needs scipy Traceback (most recent call last): ... ValueError: number of columns of self must equal degree of @@ -420,10 +421,10 @@ cdef class Matrix(Matrix1): sage: # needs sage.rings.complex_double sage.symbolic sage: A = matrix(RDF, 2, range(4)) sage: b = vector(CDF, [1+I, 2]) - sage: A.solve_left(b) + sage: A.solve_left(b) # needs scipy (0.5 - 1.5*I, 0.5 + 0.5*I) sage: b = vector(QQ[I], [1+I, 2]) - sage: x = A.solve_left(b) + sage: x = A.solve_left(b) # needs scipy Over the inexact ring ``SR``, we can still verify the solution if all of the elements involved were exact to begin with; if @@ -674,7 +675,7 @@ cdef class Matrix(Matrix1): sage: A = matrix(RDF, 3, 2, [1, 3, 4, 2, 0, -3]) sage: b = vector(RDF, [5, 6, 1]) - sage: A.solve_right(b) # tol 1e-14 + sage: A.solve_right(b) # tol 1e-14 # needs scipy (1.4782608695652177, 0.35177865612648235) sage: ~(A.T * A) * A.T * b # closed form solution, tol 1e-14 (1.4782608695652177, 0.35177865612648235) @@ -685,12 +686,12 @@ cdef class Matrix(Matrix1): [ 1.0 2.0 5.0] [ 7.6 2.3 1.0] [ 1.0 2.0 -1.0] - sage: b = vector(RDF,[1,2,3]) - sage: x = A.solve_right(b); x # tol 1e-14 + sage: b = vector(RDF, [1,2,3]) + sage: x = A.solve_right(b); x # tol 1e-14 # needs scipy (-0.1136950904392765, 1.3901808785529717, -0.33333333333333337) - sage: x.parent() + sage: x.parent() # needs scipy Vector space of dimension 3 over Real Double Field - sage: A*x # tol 1e-14 + sage: A*x # tol 1e-14 # needs scipy (1.0, 1.9999999999999996, 3.0000000000000004) Over the complex numbers:: @@ -700,19 +701,20 @@ cdef class Matrix(Matrix1): ....: [2 + 4*I, -2 + 3*I, -1 + 2*I, -1 - I], ....: [ 2 + I, 1 - I, -1, 5], ....: [ 3*I, -1 - I, -1 + I, -3 + I]]) - sage: b = vector(CDF, [2 -3*I, 3, -2 + 3*I, 8]) - sage: x = A.solve_right(b); x - (1.96841637... - 1.07606761...*I, -0.614323843... + 1.68416370...*I, 0.0733985765... + 1.73487544...*I, -1.6018683... + 0.524021352...*I) - sage: x.parent() + sage: b = vector(CDF, [2 - 3*I, 3, -2 + 3*I, 8]) + sage: x = A.solve_right(b); x # needs scipy + (1.96841637... - 1.07606761...*I, -0.614323843... + 1.68416370...*I, + 0.0733985765... + 1.73487544...*I, -1.6018683... + 0.524021352...*I) + sage: x.parent() # needs scipy Vector space of dimension 4 over Complex Double Field - sage: abs(A*x - b) < 1e-14 + sage: abs(A*x - b) < 1e-14 # needs scipy True If ``b`` is given as a matrix, the result will be a matrix, as well:: sage: A = matrix(RDF, 3, 3, [1, 2, 2, 3, 4, 5, 2, 2, 2]) sage: b = matrix(RDF, 3, 2, [3, 2, 3, 2, 3, 2]) - sage: A.solve_right(b) # tol 1e-14 + sage: A.solve_right(b) # tol 1e-14 # needs scipy [ 0.0 0.0] [ 4.5 3.0] [-3.0 -2.0] @@ -723,16 +725,16 @@ cdef class Matrix(Matrix1): sage: A = matrix(RDF, 2, 3, [1, 3, 4, 2, 0, -3]) sage: b = vector(RDF, [5, 6]) - sage: x = A.solve_right(b) - sage: (A * x - b).norm() < 1e-14 + sage: x = A.solve_right(b) # needs scipy + sage: (A * x - b).norm() < 1e-14 # needs scipy True For a tall matrix `A`, the error is usually not small:: sage: A = matrix(RDF, 3, 2, [1, 3, 4, 2, 0, -3]) sage: b = vector(RDF, [5, 6, 1]) - sage: x = A.solve_right(b) - sage: (A * x - b).norm() # tol 1e-14 + sage: x = A.solve_right(b) # needs scipy + sage: (A * x - b).norm() # tol 1e-14 # needs scipy 3.2692119900020438 TESTS: @@ -742,8 +744,9 @@ cdef class Matrix(Matrix1): sage: A = matrix(QQ, 2, [1, 2, 3, 4]) sage: b = vector(RDF, [pi, e]) # needs sage.symbolic - sage: A.solve_right(b) # tol 1e-15 # needs sage.symbolic + sage: A.solve_right(b) # tol 1e-15 # needs scipy sage.symbolic (-3.564903478720541, 3.353248066155167) + sage: R. = ZZ[] sage: b = vector(R, [1, t]) sage: x = A.solve_right(b); x @@ -1572,8 +1575,8 @@ cdef class Matrix(Matrix1): Beware that the ``exact`` algorithm is not numerically stable, but the default ``numpy`` algorithm is:: - sage: M = matrix.hilbert(12,ring=RR) - sage: (~M*M).norm() # a considerable error + sage: M = matrix.hilbert(12, ring=RR) + sage: (~M * M).norm() # a considerable error # needs scipy 1.3... sage: Mx = M.pseudoinverse(algorithm="exact") sage: (Mx*M).norm() # huge error @@ -6361,6 +6364,7 @@ cdef class Matrix(Matrix1): NotImplementedError: eigenspaces cannot be computed reliably for inexact rings such as Real Field with 53 bits of precision, consult numerical or symbolic matrix classes for other options + sage: # needs scipy sage: em = A.change_ring(RDF).eigenmatrix_left() sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13 [13.348469228349522 0.0 0.0] @@ -6642,6 +6646,7 @@ cdef class Matrix(Matrix1): for inexact rings such as Real Field with 53 bits of precision, consult numerical or symbolic matrix classes for other options + sage: # needs scipy sage: em = B.change_ring(RDF).eigenmatrix_right() sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13 [13.348469228349522 0.0 0.0] @@ -7127,6 +7132,7 @@ cdef class Matrix(Matrix1): A generalized eigenvector decomposition:: + sage: # needs scipy sage: A = matrix(RDF, [[1, -2], [3, 4]]) sage: B = matrix(RDF, [[0, 7], [2, -3]]) sage: D, P = A.eigenmatrix_left(B) @@ -7135,7 +7141,7 @@ cdef class Matrix(Matrix1): The matrix `B` in a generalized eigenvalue problem may be singular:: - sage: # needs sage.rings.complex_double sage.symbolic + sage: # needs scipy sage.rings.complex_double sage.symbolic sage: A = matrix.identity(CDF, 2) sage: B = matrix(CDF, [[2, 1+I], [4, 2+2*I]]) sage: D, P = A.eigenmatrix_left(B) @@ -7145,7 +7151,7 @@ cdef class Matrix(Matrix1): In this case, we can still verify the eigenvector equation for the first eigenvalue and first eigenvector:: - sage: # needs sage.rings.complex_double sage.symbolic + sage: # needs scipy sage.rings.complex_double sage.symbolic sage: l = D[0, 0] sage: v = P[0, :] sage: (v * A - l * v * B).norm() < 1e-14 @@ -7353,6 +7359,7 @@ cdef class Matrix(Matrix1): A generalized eigenvector decomposition:: + sage: # needs scipy sage: A = matrix(RDF, [[1, -2], [3, 4]]) sage: B = matrix(RDF, [[0, 7], [2, -3]]) sage: D, P = A.eigenmatrix_right(B) @@ -7361,6 +7368,7 @@ cdef class Matrix(Matrix1): The matrix `B` in a generalized eigenvalue problem may be singular:: + sage: # needs scipy sage: A = matrix.identity(RDF, 2) sage: B = matrix(RDF, [[3, 5], [6, 10]]) sage: D, P = A.eigenmatrix_right(B); D # tol 1e-14 @@ -10786,7 +10794,7 @@ cdef class Matrix(Matrix1): First, the inexact rings, ``CDF`` and ``RDF``. :: - sage: # needs sage.rings.complex_double sage.symbolic + sage: # needs scipy sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, [[ 0.6454 + 0.7491*I, -0.8662 + 0.1489*I, 0.7656 - 0.00344*I], ....: [-0.2913 + 0.8057*I, 0.8321 + 0.8170*I, -0.6744 + 0.9248*I], ....: [ 0.2554 + 0.3517*I, -0.4454 - 0.1715*I, 0.8325 - 0.6282*I]]) @@ -12836,7 +12844,7 @@ cdef class Matrix(Matrix1): sage: L = A.cholesky(); L [ 1.000... 0.000...] [ 2.000... 1.414...] - sage: (L*L.transpose() - A).norm() < 1e-10 + sage: (L*L.transpose() - A).norm() < 1e-10 # needs scipy True Even symbolic matrices can sometimes be factored:: @@ -14823,9 +14831,9 @@ cdef class Matrix(Matrix1): ....: return True ....: return ( A.is_hermitian() and ....: all(v >= 0 for v in A.eigenvalues()) ) - sage: expected = is_positive_semidefinite_naive(A) # needs numpy + sage: expected = is_positive_semidefinite_naive(A) # needs scipy sage: actual = A.is_positive_semidefinite() - sage: actual == expected # needs numpy + sage: actual == expected # needs scipy True We reject matrices whose base fields cannot be coerced to @@ -15390,7 +15398,7 @@ cdef class Matrix(Matrix1): :: sage: Id = identity_matrix(12) - sage: Id.norm(2) + sage: Id.norm(2) # needs scipy 1.0 sage: # needs sage.rings.real_mpfr diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 278fd272b68..cd0dd2e3117 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -2500,10 +2500,13 @@ def _test_trivial_matrices_inverse(ring, sparse=True, implementation=None, check sage: tinv(GF(2), sparse=False) sage: tinv(SR, sparse=True) # needs sage.symbolic sage: tinv(SR, sparse=False) # needs sage.symbolic + + sage: # needs scipy sage: tinv(RDF, sparse=True) sage: tinv(RDF, sparse=False) sage: tinv(CDF, sparse=True) sage: tinv(CDF, sparse=False) + sage: tinv(CyclotomicField(7), sparse=True) # needs sage.rings.number_field sage: tinv(CyclotomicField(7), sparse=False) # needs sage.rings.number_field sage: tinv(QQ['x,y'], sparse=True) diff --git a/src/sage/modules/filtered_vector_space.py b/src/sage/modules/filtered_vector_space.py index f34c0abfe71..c5e4b7058bf 100644 --- a/src/sage/modules/filtered_vector_space.py +++ b/src/sage/modules/filtered_vector_space.py @@ -1002,7 +1002,7 @@ def direct_sum(self, other): sage: v = [(1,0), (0,1)] sage: F1 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=QQ) sage: F2 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=RDF) - sage: F1 + F2 + sage: F1 + F2 # needs scipy RDF^4 >= RDF^2 >= 0 """ from sage.structure.element import get_coercion_model @@ -1067,7 +1067,7 @@ def tensor_product(self, other): sage: v = [(1,0), (0,1)] sage: F1 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=QQ) sage: F2 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=RDF) - sage: F1 * F2 + sage: F1 * F2 # needs scipy RDF^4 >= RDF^3 >= RDF^1 >= 0 """ V = self diff --git a/src/sage/modules/vector_double_dense.pyx b/src/sage/modules/vector_double_dense.pyx index a47d91a7fdd..063b665922c 100644 --- a/src/sage/modules/vector_double_dense.pyx +++ b/src/sage/modules/vector_double_dense.pyx @@ -212,6 +212,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): EXAMPLES:: + sage: # needs scipy sage: v = vector(CDF,[1,2,3,4]) sage: w = v.fft() sage: max(v - w.inv_fft()) < 1e-12 @@ -233,6 +234,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): EXAMPLES:: + sage: # needs scipy sage: v = vector(CDF,[1+2*I,2,3*I,4]) sage: v.fft() (7.0 + 5.0*I, 1.0 + 1.0*I, -5.0 + 5.0*I, 1.0 - 3.0*I) @@ -246,6 +248,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): sage: v (7.0 + 5.0*I, 1.0 + 1.0*I, -5.0 + 5.0*I, 1.0 - 3.0*I) + sage: # needs scipy sage: v = vector(RDF,4,range(4)); v (0.0, 1.0, 2.0, 3.0) sage: v.fft() From bdd0506db8315602ebe22943a88700969eaad464 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:56:02 -0700 Subject: [PATCH 305/494] sage.matrix: Add # needs --- .../matrix/matrix_complex_double_dense.pyx | 8 +- src/sage/matrix/matrix_double_dense.pyx | 76 ++++++++++++++----- src/sage/matrix/matrix_numpy_dense.pyx | 4 +- 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/sage/matrix/matrix_complex_double_dense.pyx b/src/sage/matrix/matrix_complex_double_dense.pyx index 162332eb44e..b86516fd121 100644 --- a/src/sage/matrix/matrix_complex_double_dense.pyx +++ b/src/sage/matrix/matrix_complex_double_dense.pyx @@ -17,6 +17,7 @@ We deal with the case of zero rows or zero columns:: TESTS:: + sage: # needs sage.symbolic sage: a = matrix(CDF,2,[i+(4-i)*I for i in range(4)], sparse=False) sage: TestSuite(a).run() sage: Mat(CDF,0,0).zero_matrix().inverse() @@ -53,6 +54,7 @@ cdef class Matrix_complex_double_dense(Matrix_double_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: m = Matrix(CDF, [[1,2*I],[3+I,4]]) sage: m**2 [-1.0 + 6.0*I 10.0*I] @@ -65,7 +67,7 @@ cdef class Matrix_complex_double_dense(Matrix_double_dense): :meth:`~.Matrix_double_dense.left_eigenvectors` or :meth:`~.Matrix_double_dense.right_eigenvectors`:: - sage: p,e = m.right_eigenvectors() + sage: p,e = m.right_eigenvectors() # needs sage.symbolic The result is a pair ``(p,e)``, where ``p`` is a diagonal matrix of eigenvalues and ``e`` is a matrix whose columns are the @@ -74,8 +76,8 @@ cdef class Matrix_complex_double_dense(Matrix_double_dense): To solve a linear system `Ax = b` where ``A = [[1,2*I],[3+I,4]]`` and ``b = [5,6]``:: - sage: b = vector(CDF,[5,6]) - sage: m.solve_right(b) # abs tol 1e-14 + sage: b = vector(CDF,[5,6]) # needs sage.symbolic + sage: m.solve_right(b) # abs tol 1e-14 # needs sage.symbolic (2.6666666666666665 + 0.6666666666666669*I, -0.3333333333333333 - 1.1666666666666667*I) See the methods :meth:`~.Matrix_double_dense.QR`, diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index f4312a479e5..10239ae77e6 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -624,6 +624,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): And over the complex numbers. :: + sage: # needs sage.symbolic sage: B = matrix(CDF, 2, [[1+I, 2+3*I],[3+4*I,3*I]]); B [1.0 + 1.0*I 2.0 + 3.0*I] [3.0 + 4.0*I 3.0*I] @@ -1144,13 +1145,14 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): sage: m.eigenvalues(algorithm='default') [1.0*I, -1.0*I] - sage: m = matrix(CDF, 2, 2, [I,1,-I,0]) - sage: m.eigenvalues() + sage: m = matrix(CDF, 2, 2, [I,1,-I,0]) # needs sage.symbolic + sage: m.eigenvalues() # needs sage.symbolic [-0.624810533... + 1.30024259...*I, 0.624810533... - 0.30024259...*I] The adjacency matrix of a graph will be symmetric, and the eigenvalues will be real. :: + sage: # needs sage.graphs sage: A = graphs.PetersenGraph().adjacency_matrix() sage: A = A.change_ring(RDF) sage: ev = A.eigenvalues(algorithm='symmetric'); ev # tol 1e-14 @@ -1163,6 +1165,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): the eigenvalues of a Hermitian matrix are real, and the eigenvalues of a positive-definite matrix will be positive. :: + sage: # needs sage.symbolic sage: A = matrix([[ 4*I + 5, 8*I + 1, 7*I + 5, 3*I + 5], ....: [ 7*I - 2, -4*I + 7, -2*I + 4, 8*I + 8], ....: [-2*I + 1, 6*I + 6, 5*I + 5, -I - 4], @@ -1178,19 +1181,19 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): it might split too finely. Too large, and it can go wrong very badly. Use with care. :: + sage: # needs sage.graphs sage: G = graphs.PetersenGraph() sage: G.spectrum() [3, 1, 1, 1, 1, 1, -2, -2, -2, -2] - sage: A = G.adjacency_matrix().change_ring(RDF) sage: A.eigenvalues(algorithm='symmetric', tol=1.0e-5) # tol 1e-15 [(-2.0, 4), (1.0, 5), (3.0, 1)] - sage: A.eigenvalues(algorithm='symmetric', tol=2.5) # tol 1e-15 [(-2.0, 4), (1.3333333333333333, 6)] An (extreme) example of properly grouping similar eigenvalues. :: + sage: # needs sage.graphs sage: G = graphs.HigmanSimsGraph() sage: A = G.adjacency_matrix().change_ring(RDF) sage: A.eigenvalues(algorithm='symmetric', tol=1.0e-5) # tol 2e-15 @@ -1268,6 +1271,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): Test the deprecation:: + sage: # needs sage.graphs sage: A = graphs.PetersenGraph().adjacency_matrix().change_ring(RDF) sage: ev = A.eigenvalues('symmetric', 1e-13) doctest:...: DeprecationWarning: "algorithm" and "tol" should be used @@ -1705,6 +1709,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): TESTS:: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[1, 2], [3, 3+I]]) sage: b = matrix(CDF, [[1, 0], [2, 1]]) sage: x = A._solve_right_nonsingular_square(b) @@ -1830,6 +1835,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[1+I, 3-I], [0, 2*I]]) sage: A.conjugate() [1.0 - 1.0*I 3.0 + 1.0*I] @@ -1837,7 +1843,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): There is a shorthand notation:: - sage: A.conjugate() == A.C + sage: A.conjugate() == A.C # needs sage.symbolic True Conjugates work (trivially) for real matrices:: @@ -2265,6 +2271,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): The QR decomposition will produce a unitary matrix as Q and the SVD decomposition will create two unitary matrices, U and V. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 - I, -3*I, -2 + I, 1, -2 + 3*I], ....: [ 1 - I, -2 + I, 1 + 4*I, 0, 2 + I], ....: [ -1, -5 + I, -2 + I, 1 + I, -5 - 4*I], @@ -2427,6 +2434,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) @@ -2439,6 +2447,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A matrix that is nearly Hermitian, but for one non-real diagonal entry:: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 2, 2-I, 1+4*I], ....: [ 2+I, 3+I, 2-6*I], ....: [1-4*I, 2+6*I, 5]]) @@ -2461,6 +2470,8 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): False A matrix that is skew-Hermitian:: + + sage: # needs sage.symbolic sage: A = matrix(CDF, [[-I, 2.0+I], [-2.0+I, 0.0]]) sage: A._is_hermitian_orthonormal() False @@ -2549,6 +2560,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) @@ -2565,6 +2577,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A matrix that is nearly Hermitian, but for one non-real diagonal entry. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 2, 2-I, 1+4*I], ....: [ 2+I, 3+I, 2-6*I], ....: [1-4*I, 2+6*I, 5]]) @@ -2582,11 +2595,12 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): of entries and may achieve the wrong result (depending on the system):: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) sage: U, _, _ = A.SVD() - sage: B=U*U.conjugate_transpose() + sage: B = U*U.conjugate_transpose() sage: B.is_hermitian(algorithm='naive') True sage: B.is_hermitian(algorithm='naive', tol=1.0e-17) # random @@ -2685,6 +2699,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A matrix that is nearly skew-Hermitian, but for a non-real diagonal entry. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ -I, -1, 1-I], ....: [ 1, 1, -1], ....: [-1-I, 1, -I]]) @@ -2702,11 +2717,12 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): be too strict about the equality of entries and may achieve the wrong result (depending on the system):: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) sage: U, _, _ = A.SVD() - sage: B=1j*U*U.conjugate_transpose() + sage: B = 1j*U*U.conjugate_transpose() sage: B.is_skew_hermitian(algorithm='naive') True sage: B.is_skew_hermitian(algorithm='naive', tol=1.0e-17) # random @@ -2798,6 +2814,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): First over the complexes. ``B`` is Hermitian, hence normal. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) @@ -2816,22 +2833,24 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): Now over the reals. Circulant matrices are normal. :: + sage: # needs sage.graphs sage: G = graphs.CirculantGraph(20, [3, 7]) sage: D = digraphs.Circuit(20) sage: A = 3*D.adjacency_matrix() - 5*G.adjacency_matrix() sage: A = A.change_ring(RDF) sage: A.is_normal() True - sage: A.is_normal(algorithm = 'naive') + sage: A.is_normal(algorithm='naive') True sage: A[19,0] = 4.0 sage: A.is_normal() False - sage: A.is_normal(algorithm = 'naive') + sage: A.is_normal(algorithm='naive') False Skew-Hermitian matrices are normal. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 1 + I, 1 - 6*I, -1 - I], ....: [-3 - I, -4*I, -2], ....: [-1 + I, -2 - 8*I, 2 + I]]) @@ -2856,6 +2875,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): Sage has several fields besides the entire complex numbers where conjugation is non-trivial. :: + sage: # needs sage.rings.number_field sage: F. = QuadraticField(-7) sage: C = matrix(F, [[-2*b - 3, 7*b - 6, -b + 3], ....: [-2*b - 3, -3*b + 2, -2*b], @@ -2991,7 +3011,9 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): First over the complexes. The similar matrix is always upper-triangular in this case. :: - sage: A = matrix(CDF, 4, 4, range(16)) + matrix(CDF, 4, 4, [x^3*I for x in range(0, 16)]) + sage: # needs sage.symbolic + sage: A = matrix(CDF, 4, 4, range(16)) + matrix(CDF, 4, 4, + ....: [x^3*I for x in range(0, 16)]) sage: Q, T = A.schur() sage: (Q*Q.conjugate().transpose()).zero_at(1e-12) # tol 1e-12 [ 0.999999999999999 0.0 0.0 0.0] @@ -3000,7 +3022,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): [ 0.0 0.0 0.0 0.9999999999999999] sage: all(T.zero_at(1.0e-12)[i,j] == 0 for i in range(4) for j in range(i)) True - sage: (Q*T*Q.conjugate().transpose()-A).zero_at(1.0e-11) + sage: (Q*T*Q.conjugate().transpose() - A).zero_at(1.0e-11) [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] @@ -3027,7 +3049,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): Full MatrixSpace of 4 by 4 dense matrices over Complex Double Field sage: all(T.zero_at(1.0e-12)[i,j] == 0 for i in range(4) for j in range(i)) True - sage: (Q*T*Q.conjugate().transpose()-A).zero_at(1.0e-11) + sage: (Q*T*Q.conjugate().transpose() - A).zero_at(1.0e-11) [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] @@ -3054,7 +3076,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): False sage: all(T.zero_at(1.0e-12)[i,j] == 0 for i in range(4) for j in range(i-1)) True - sage: (Q*T*Q.conjugate().transpose()-A).zero_at(1.0e-11) + sage: (Q*T*Q.conjugate().transpose() - A).zero_at(1.0e-11) [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] @@ -3069,6 +3091,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): Starting with complex numbers and requesting a result over the reals will never happen. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, 2, 2, [[2+I, -1+3*I], [5-4*I, 2-7*I]]) sage: A.schur(base_ring=RDF) Traceback (most recent call last): @@ -3095,7 +3118,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): sage: T.round(6) [ 0.5 1.5] [-0.5 0.5] - sage: (Q*T*Q.conjugate().transpose()-B).zero_at(1.0e-11) + sage: (Q*T*Q.conjugate().transpose() - B).zero_at(1.0e-11) [0.0 0.0] [0.0 0.0] @@ -3105,6 +3128,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): of eigenvectors of the matrix. Here that basis is the set of columns of the unitary matrix. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 52, -9*I - 8, 6*I - 187, -188*I + 2], ....: [ 9*I - 8, 12, -58*I + 59, 30*I + 42], ....: [-6*I - 187, 58*I + 59, 2677, 2264*I + 65], @@ -3121,7 +3145,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): [ 0.0 0.9999999999999989 0.0 0.0] [ 0.0 0.0 1.0000000000000002 0.0] [ 0.0 0.0 0.0 0.9999999999999992] - sage: (Q*T*Q.conjugate().transpose()-A).zero_at(1.0e-11) + sage: (Q*T*Q.conjugate().transpose() - A).zero_at(1.0e-11) [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] @@ -3142,14 +3166,15 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): [ 0.4361 0.359 0.7599 0.3217] [ -0.836 0.3945 0.1438 0.3533] sage: T = T.zero_at(10^-12) - sage: all(abs(e) < 10^-4 for e in (T - diagonal_matrix(RDF, [-13.5698, -0.8508, 7.7664, 11.6542])).list()) + sage: all(abs(e) < 10^-4 + ....: for e in (T - diagonal_matrix(RDF, [-13.5698, -0.8508, 7.7664, 11.6542])).list()) True sage: (Q*Q.transpose()) # tol 1e-12 [0.9999999999999998 0.0 0.0 0.0] [ 0.0 1.0 0.0 0.0] [ 0.0 0.0 0.9999999999999998 0.0] [ 0.0 0.0 0.0 0.9999999999999996] - sage: (Q*T*Q.transpose()-A).zero_at(1.0e-11) + sage: (Q*T*Q.transpose() - A).zero_at(1.0e-11) [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] [0.0 0.0 0.0 0.0] @@ -3294,6 +3319,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A complex matrix that is Hermitian and positive definite. :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[ 23, 17*I + 3, 24*I + 25, 21*I], ....: [ -17*I + 3, 38, -69*I + 89, 7*I + 15], ....: [-24*I + 25, 69*I + 89, 976, 24*I + 6], @@ -3332,6 +3358,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): ... ValueError: matrix is not positive definite + sage: # needs sage.symbolic sage: B = matrix(CDF, [[ 2, 4 - 2*I, 2 + 2*I], ....: [4 + 2*I, 8, 10*I], ....: [2 - 2*I, -10*I, -3]]) @@ -3363,6 +3390,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[1+I]]) sage: A.cholesky() Traceback (most recent call last): @@ -3464,6 +3492,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A matrix over ``CDF`` that is positive definite. :: + sage: # needs sage.symbolic sage: C = matrix(CDF, [[ 23, 17*I + 3, 24*I + 25, 21*I], ....: [ -17*I + 3, 38, -69*I + 89, 7*I + 15], ....: [-24*I + 25, 69*I + 89, 976, 24*I + 6], @@ -3495,6 +3524,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): A matrix over ``CDF`` that is not positive definite. :: + sage: # needs sage.symbolic sage: B = matrix(CDF, [[ 2, 4 - 2*I, 2 + 2*I], ....: [4 + 2*I, 8, 10*I], ....: [2 - 2*I, -10*I, -3]]) @@ -3539,6 +3569,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): :: + sage: # needs sage.symbolic sage: A = matrix(CDF, [[1+I]]) sage: A.is_positive_definite() False @@ -3641,10 +3672,10 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): sage: A.exp() # tol 1e-14 [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] - sage: A = matrix(CDF, 2, [1,2+I,3*I,4]); A + sage: A = matrix(CDF, 2, [1,2+I,3*I,4]); A # needs sage.symbolic [ 1.0 2.0 + 1.0*I] [ 3.0*I 4.0] - sage: A.exp() # tol 1.1e-14 + sage: A.exp() # tol 1.1e-14 # needs sage.symbolic [-19.614602953804912 + 12.517743846762578*I 3.7949636449582176 + 28.88379930658099*I] [ -32.383580980922254 + 21.88423595789845*I 2.269633004093535 + 44.901324827684824*I] @@ -3655,8 +3686,8 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] - sage: A = matrix(CDF, 2, [1,2+I,3*I,4]) - sage: A.exp() # tol 3e-14 + sage: A = matrix(CDF, 2, [1,2+I,3*I,4]) # needs sage.symbolic + sage: A.exp() # tol 3e-14 # needs sage.symbolic [-19.614602953804923 + 12.51774384676257*I 3.7949636449582016 + 28.883799306580997*I] [-32.38358098092227 + 21.884235957898433*I 2.2696330040935084 + 44.90132482768484*I] """ @@ -3690,6 +3721,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: a = matrix(CDF, [[1, 1e-4r, 1+1e-100jr], [1e-8+3j, 0, 1e-58r]]) sage: a [ 1.0 0.0001 1.0 + 1e-100*I] @@ -3765,6 +3797,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: a = matrix(CDF, [[1, -2+I, 0, -3*I], [2, 2, -2, 2], [-3, -3, -3, -2]]) sage: a [ 1.0 -2.0 + 1.0*I 0.0 -3.0*I] @@ -3803,6 +3836,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): EXAMPLES:: + sage: # needs sage.symbolic sage: a = matrix(CDF, [[1, 2, -3], [-2+I, 2, -3], [0, -2, -3], [-3*I, 2, -2]]) sage: a [ 1.0 2.0 -3.0] diff --git a/src/sage/matrix/matrix_numpy_dense.pyx b/src/sage/matrix/matrix_numpy_dense.pyx index d0e55fa927a..bd74e424bee 100644 --- a/src/sage/matrix/matrix_numpy_dense.pyx +++ b/src/sage/matrix/matrix_numpy_dense.pyx @@ -134,7 +134,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): [0.0 1.0 2.0] [3.0 4.0 5.0] [6.0 7.0 8.0] - sage: matrix(CDF,2,2,[CDF(1+I)*j for j in range(4)]) + sage: matrix(CDF,2,2,[CDF(1+I)*j for j in range(4)]) # needs sage.symbolic [ 0.0 1.0 + 1.0*I] [2.0 + 2.0*I 3.0 + 3.0*I] """ @@ -308,7 +308,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): Complex entries are supported (:trac:`27831`). :: - sage: a = matrix(CDF, [(21, 0.6 + 18.5*i), (0.6 - 18.5*i, 21)]) + sage: a = matrix(CDF, [(21, 0.6 + 18.5*i), (0.6 - 18.5*i, 21)]) # needs sage.symbolic sage: a.is_symmetric() False """ From d366696f6ae35b6f49d0a87ba533c1bd78665356 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 9 Sep 2023 12:36:27 -0700 Subject: [PATCH 306/494] sage.{matrix,modules}: Update # needs --- src/sage/matrix/matrix2.pyx | 5 +++-- src/sage/modules/free_module_element.pyx | 17 +++++++++-------- src/sage/modules/matrix_morphism.py | 4 +++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 1a3690a466e..68707247ffa 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -7378,9 +7378,10 @@ cdef class Matrix(Matrix1): In this case, we can still verify the eigenvector equation for the first eigenvalue and first eigenvector:: - sage: l = D[0, 0] # needs sage.symbolic + sage: # needs scipy + sage: l = D[0, 0] sage: v = P[:, 0] - sage: (A * v - B * v * l).norm() < 1e-14 # needs sage.symbolic + sage: (A * v - B * v * l).norm() < 1e-14 True The second eigenvector is contained in the right kernel of `B`:: diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index a2c077cc8c8..bffc5762a9c 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -416,8 +416,8 @@ def vector(arg0, arg1=None, arg2=None, sparse=None, immutable=False): Complex numbers can be converted naturally to a sequence of length 2. And then to a vector. :: - sage: c = CDF(2 + 3*I) - sage: v = vector(c); v + sage: c = CDF(2 + 3*I) # needs sage.rings.complex_double sage.symbolic + sage: v = vector(c); v # needs sage.rings.complex_double sage.symbolic (2.0, 3.0) A generator, or other iterable, may also be supplied as input. Anything @@ -3435,8 +3435,7 @@ cdef class FreeModuleElement(Vector): # abstract base class sage: R. = ZZ[] sage: v = vector(R, [12, 24*t]) sage: w = vector(QQ, [1/2, 1/3, 1/4]) - sage: op = v.outer_product(w) - sage: op + sage: op = v.outer_product(w); op [ 6 4 3] [12*t 8*t 6*t] sage: op.base_ring() @@ -3451,7 +3450,7 @@ cdef class FreeModuleElement(Vector): # abstract base class sage: w = vector(GF(5), [1,2]) sage: v = vector(GF(7), [1,2,3,4]) - sage: z = w.outer_product(v) # needs sage.rings.finite_rings + sage: z = w.outer_product(v) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: @@ -3460,8 +3459,8 @@ cdef class FreeModuleElement(Vector): # abstract base class And some inputs don't make any sense at all. :: - sage: w=vector(QQ, [5,10]) - sage: z=w.outer_product(6) + sage: w = vector(QQ, [5,10]) + sage: z = w.outer_product(6) Traceback (most recent call last): ... TypeError: right operand in an outer product must be a vector, @@ -3531,7 +3530,7 @@ cdef class FreeModuleElement(Vector): # abstract base class in each argument (with conjugation on the first scalar), and anti-commutative. :: - sage: # needs sage.symbolic + sage: # needs sage.rings.complex_double sage.symbolic sage: alpha = CDF(5.0 + 3.0*I) sage: u = vector(CDF, [2+4*I, -3+5*I, 2-7*I]) sage: v = vector(CDF, [-1+3*I, 5+4*I, 9-2*I]) @@ -3550,6 +3549,7 @@ cdef class FreeModuleElement(Vector): # abstract base class default for the :meth:`norm` method). The norm squared equals the Hermitian inner product of the vector with itself. :: + sage: # needs sage.rings.complex_double sage.symbolic sage: v = vector(CDF, [-0.66+0.47*I, -0.60+0.91*I, -0.62-0.87*I, 0.53+0.32*I]) sage: abs(v.norm()^2 - v.hermitian_inner_product(v)) < 1.0e-10 True @@ -3560,6 +3560,7 @@ cdef class FreeModuleElement(Vector): # abstract base class which allows for a wide variety of inputs. Any error handling happens there. :: + sage: # needs sage.rings.complex_double sage.symbolic sage: v = vector(CDF, [2+3*I]) sage: w = vector(CDF, [5+2*I, 3+9*I]) sage: v.hermitian_inner_product(w) diff --git a/src/sage/modules/matrix_morphism.py b/src/sage/modules/matrix_morphism.py index b9d45e9755f..d342dc00237 100644 --- a/src/sage/modules/matrix_morphism.py +++ b/src/sage/modules/matrix_morphism.py @@ -212,13 +212,15 @@ def _call_with_args(self, x, args=(), kwds={}): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: V = RR^2 sage: f = V.hom(V.gens()) sage: f._matrix *= I # f is now invalid sage: f((1, 0)) Traceback (most recent call last): ... - TypeError: Unable to coerce entries (=[1.00000000000000*I, 0.000000000000000]) to coefficients in Real Field with 53 bits of precision + TypeError: Unable to coerce entries (=[1.00000000000000*I, 0.000000000000000]) + to coefficients in Real Field with 53 bits of precision sage: f((1, 0), coerce=False) (1.00000000000000*I, 0.000000000000000) From 433eb4154630f52d7aaeceb1a06c9710a6788204 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 16:40:01 -0700 Subject: [PATCH 307/494] sage.matrix: Add # needs --- src/sage/matrix/matrix2.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 68707247ffa..77d52e854b8 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -7386,7 +7386,7 @@ cdef class Matrix(Matrix1): The second eigenvector is contained in the right kernel of `B`:: - sage: (B * P[:, 1]).norm() < 1e-14 + sage: (B * P[:, 1]).norm() < 1e-14 # needs scipy True .. SEEALSO:: From 171adf5d32ce2529cd300704d8d2a098ee5ee0e5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 16:40:29 -0700 Subject: [PATCH 308/494] sage.modules: Update # needs --- src/sage/modules/free_module_element.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index bffc5762a9c..e8903fc9bfe 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -3225,6 +3225,7 @@ cdef class FreeModuleElement(Vector): # abstract base class We test this by building a specialized vector space with a non-standard inner product, and constructing a test vector in this space. :: + sage: # needs sage.rings.complex_double sage.symbolic sage: V = VectorSpace(CDF, 2, inner_product_matrix=[[2,1],[1,5]]) sage: v = vector(CDF, [2-3*I, 4+5*I]) sage: w = V(v) From 4537cb4610fb5fbd32417f2c8da6a69e29a8b1f9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 23:24:30 -0700 Subject: [PATCH 309/494] sage.{matrix,modules}: Update # needs --- src/sage/matrix/matrix_numpy_dense.pyx | 2 +- src/sage/modules/free_module_element.pyx | 4 ++-- src/sage/modules/vector_numpy_dense.pyx | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/matrix/matrix_numpy_dense.pyx b/src/sage/matrix/matrix_numpy_dense.pyx index bd74e424bee..a829b457f3a 100644 --- a/src/sage/matrix/matrix_numpy_dense.pyx +++ b/src/sage/matrix/matrix_numpy_dense.pyx @@ -309,7 +309,7 @@ cdef class Matrix_numpy_dense(Matrix_dense): Complex entries are supported (:trac:`27831`). :: sage: a = matrix(CDF, [(21, 0.6 + 18.5*i), (0.6 - 18.5*i, 21)]) # needs sage.symbolic - sage: a.is_symmetric() + sage: a.is_symmetric() # needs sage.symbolic False """ cdef Py_ssize_t i, j diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index e8903fc9bfe..267624236c2 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -457,9 +457,9 @@ def vector(arg0, arg1=None, arg2=None, sparse=None, immutable=False): sage: v.is_immutable() True - sage: # needs numpy + sage: # needs numpy sage.symbolic sage: import numpy as np - sage: w = np.array([1, 2, pi], float) # needs sage.symbolic + sage: w = np.array([1, 2, pi], float) sage: v = vector(w, immutable=True) sage: v.is_immutable() True diff --git a/src/sage/modules/vector_numpy_dense.pyx b/src/sage/modules/vector_numpy_dense.pyx index fc14cc4829a..884b3a39839 100644 --- a/src/sage/modules/vector_numpy_dense.pyx +++ b/src/sage/modules/vector_numpy_dense.pyx @@ -151,7 +151,7 @@ cdef class Vector_numpy_dense(FreeModuleElement): (0.0, 0.0, 0.0, 0.0) sage: vector(RDF, 4) (0.0, 0.0, 0.0, 0.0) - sage: vector(CDF, [CDF(1+I)*j for j in range(4)]) + sage: vector(CDF, [CDF(1+I)*j for j in range(4)]) # needs sage.symbolic (0.0, 1.0 + 1.0*I, 2.0 + 2.0*I, 3.0 + 3.0*I) sage: vector(RDF, 4, range(4)) (0.0, 1.0, 2.0, 3.0) @@ -211,13 +211,13 @@ cdef class Vector_numpy_dense(FreeModuleElement): """ EXAMPLES:: - sage: v = vector(CDF, [1,CDF(3,2), -1]); v + sage: v = vector(CDF, [1, CDF(3,2), -1]); v (1.0, 3.0 + 2.0*I, -1.0) sage: v[1] = 2 - sage: v[-1] = I - sage: v + sage: v[-1] = I # needs sage.symbolic + sage: v # needs sage.symbolic (1.0, 2.0, 1.0*I) - sage: v[1:3] = [1, 1]; v + sage: v[1:3] = [1, 1]; v # needs sage.symbolic (1.0, 1.0, 1.0) """ # We assume that Py_ssize_t is the same as npy_intp From 23ac349a53f173410d30de57bc422f64b6c65296 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 11 Sep 2023 22:33:43 -0700 Subject: [PATCH 310/494] sage.matrix: Add # needs --- src/sage/matrix/matrix_complex_ball_dense.pyx | 4 ++-- src/sage/matrix/matrix_double_dense.pyx | 2 +- src/sage/matrix/matrix_double_sparse.pyx | 4 ++-- src/sage/matrix/matrix_real_double_dense.pyx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx index 22366b5f1f2..36828fdcf97 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pyx +++ b/src/sage/matrix/matrix_complex_ball_dense.pyx @@ -19,8 +19,8 @@ TESTS:: [8.000000000000000 11.00000000000000] [22.00000000000000 41.00000000000000] - sage: mat = matrix(ComplexBallField(20), 2, 2, list(range(4)))*i/3 - sage: loads(dumps(mat)).identical(mat) + sage: mat = matrix(ComplexBallField(20), 2, 2, list(range(4)))*i/3 # needs sage.symbolic + sage: loads(dumps(mat)).identical(mat) # needs sage.symbolic True """ # **************************************************************************** diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index 10239ae77e6..46fc9b9752d 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -99,7 +99,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): sage: m**2 [ 7.0 10.0] [15.0 22.0] - sage: m^(-1) # rel tol 1e-15 + sage: m^(-1) # rel tol 1e-15 # needs scipy [-1.9999999999999996 0.9999999999999998] [ 1.4999999999999998 -0.4999999999999999] diff --git a/src/sage/matrix/matrix_double_sparse.pyx b/src/sage/matrix/matrix_double_sparse.pyx index fc7d65a880c..9871ee7bba1 100644 --- a/src/sage/matrix/matrix_double_sparse.pyx +++ b/src/sage/matrix/matrix_double_sparse.pyx @@ -169,7 +169,7 @@ cdef class Matrix_double_sparse(Matrix_generic_sparse): sage: (A - L*L.T).norm(1) < 1e-10 True sage: B = A.dense_matrix() - sage: (B.cholesky() - L).norm(1) < 1e-10 + sage: (B.cholesky() - L).norm(1) < 1e-10 # needs scipy True :: @@ -183,7 +183,7 @@ cdef class Matrix_double_sparse(Matrix_generic_sparse): sage: (A - L*L.H).norm(1) < 1e-10 True sage: B = A.dense_matrix() - sage: (B.cholesky() - L).norm(1) < 1e-10 + sage: (B.cholesky() - L).norm(1) < 1e-10 # needs scipy True """ cdef Matrix L # output matrix diff --git a/src/sage/matrix/matrix_real_double_dense.pyx b/src/sage/matrix/matrix_real_double_dense.pyx index 542638ed17d..1d270580ff5 100644 --- a/src/sage/matrix/matrix_real_double_dense.pyx +++ b/src/sage/matrix/matrix_real_double_dense.pyx @@ -70,7 +70,7 @@ cdef class Matrix_real_double_dense(Matrix_double_dense): :: - sage: p,e = m.right_eigenvectors() + sage: p,e = m.right_eigenvectors() # needs scipy The result is a pair ``(p,e)``, where ``p`` is a diagonal matrix of eigenvalues and ``e`` is a matrix whose columns are the @@ -80,7 +80,7 @@ cdef class Matrix_real_double_dense(Matrix_double_dense): `b = [5,6]`:: sage: b = vector(RDF,[5,6]) - sage: m.solve_right(b) # rel tol 1e-15 + sage: m.solve_right(b) # rel tol 1e-15 # needs scipy (-3.9999999999999987, 4.499999999999999) See the methods :meth:`~.Matrix_double_dense.QR`, From 38119de421aeae1771821d95b9164abd572c0a00 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:06:32 -0700 Subject: [PATCH 311/494] sage.matrix: Add # needs --- src/sage/matrix/constructor.pyx | 2 +- src/sage/matrix/matrix2.pyx | 21 +++++++++++-------- .../matrix/matrix_modn_dense_template.pxi | 2 +- src/sage/matrix/matrix_polynomial_dense.pyx | 2 +- src/sage/matrix/matrix_space.py | 4 ++-- src/sage/matrix/special.py | 8 +++---- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/sage/matrix/constructor.pyx b/src/sage/matrix/constructor.pyx index a31543e0795..46f1b95d661 100644 --- a/src/sage/matrix/constructor.pyx +++ b/src/sage/matrix/constructor.pyx @@ -580,7 +580,7 @@ def matrix(*args, **kwds): Check :trac:`24459`:: - sage: # needs sage.libs.flint + sage: # needs sage.libs.linbox sage: Matrix(ZZ, sys.maxsize, sys.maxsize) Traceback (most recent call last): ... diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 77d52e854b8..80d06af7cbe 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -382,7 +382,7 @@ cdef class Matrix(Matrix1): A degenerate case:: sage: A = matrix(RDF, 0, 0, []) - sage: A.solve_left(vector(RDF,[])) + sage: A.solve_left(vector(RDF,[])) # needs scipy () Over an inexact ring like ``RDF``, the coefficient matrix of a @@ -677,7 +677,7 @@ cdef class Matrix(Matrix1): sage: b = vector(RDF, [5, 6, 1]) sage: A.solve_right(b) # tol 1e-14 # needs scipy (1.4782608695652177, 0.35177865612648235) - sage: ~(A.T * A) * A.T * b # closed form solution, tol 1e-14 + sage: ~(A.T * A) * A.T * b # closed form solution, tol 1e-14 # needs scipy (1.4782608695652177, 0.35177865612648235) Over the reals:: @@ -1579,7 +1579,7 @@ cdef class Matrix(Matrix1): sage: (~M * M).norm() # a considerable error # needs scipy 1.3... sage: Mx = M.pseudoinverse(algorithm="exact") - sage: (Mx*M).norm() # huge error + sage: (Mx * M).norm() # huge error # needs scipy 11.5... sage: Mx = M.pseudoinverse(algorithm="numpy") # needs numpy sage: (Mx * M).norm() # still OK @@ -7404,6 +7404,7 @@ cdef class Matrix(Matrix1): Running this test independently, without adjusting the eigenvectors could indicate this situation on your hardware. :: + sage: # needs scipy sage: B = matrix(QQ, 3, 3, range(9)) sage: em = B.change_ring(RDF).eigenmatrix_right() sage: evalues = em[0]; evalues.dense_matrix() # abs tol 1e-13 @@ -7421,7 +7422,7 @@ cdef class Matrix(Matrix1): The following example shows that :trac:`20439` has been resolved:: - sage: # needs sage.rings.complex_double + sage: # needs scipy sage.rings.complex_double sage: A = matrix(CDF, [[-2.53634347567, 2.04801738686, -0.0, -62.166145304], ....: [ 0.7, -0.6, 0.0, 0.0], ....: [0.547271128842, 0.0, -0.3015, -21.7532081652], @@ -7433,7 +7434,7 @@ cdef class Matrix(Matrix1): The following example shows that the fix for :trac:`20439` (conjugating eigenvectors rather than eigenvalues) is the correct one:: - sage: # needs sage.rings.complex_double sage.symbolic + sage: # needs scipy sage.rings.complex_double sage.symbolic sage: A = Matrix(CDF,[[I,0],[0,1]]) sage: D, P = A.eigenmatrix_right() sage: (A*P - P*D).norm() < 10^(-2) @@ -10820,6 +10821,7 @@ cdef class Matrix(Matrix1): A rectangular matrix. Note that the ``orthonormal`` keyword is ignored in these cases. :: + sage: # needs scipy sage: A = matrix(RDF, [[-0.978325, -0.751994, 0.925305, -0.200512, 0.420458], ....: [-0.474877, -0.983403, 0.089836, 0.132218, 0.672965]]) sage: G, M = A.gram_schmidt(orthonormal=False) @@ -10842,6 +10844,7 @@ cdef class Matrix(Matrix1): are treated as being of full rank. Try one of the base rings that provide exact results if you need exact results. :: + sage: # needs scipy sage: entries = [[1,1,2], [2,1,3], [3,1,4]] sage: A = matrix(QQ, entries) sage: A.rank() @@ -14492,7 +14495,7 @@ cdef class Matrix(Matrix1): sage: L*D*L.T [1e-10 1.0] [ 1.0 0.0] - sage: A.block_ldlt() + sage: A.block_ldlt() # needs scipy ( [1.0 0.0] [1.0 0.0] [1e-10 1.0] [0.0 1.0], [0.0 1.0], [ 1.0 2e-10] @@ -14502,7 +14505,7 @@ cdef class Matrix(Matrix1): but `P^{T}AP` will ideally be close to `LDL^{*}` in the metric induced by the norm:: - sage: # needs sage.rings.complex_double sage.symbolic + sage: # needs scipy sage.rings.complex_double sage.symbolic sage: A = matrix(CDF, 2, 2, [ [-1.1933, -0.3185 - 1.3553*I], ....: [-0.3185 + 1.3553*I, 1.5729 ] ]) sage: P,L,D = A.block_ldlt() @@ -14833,7 +14836,7 @@ cdef class Matrix(Matrix1): ....: return ( A.is_hermitian() and ....: all(v >= 0 for v in A.eigenvalues()) ) sage: expected = is_positive_semidefinite_naive(A) # needs scipy - sage: actual = A.is_positive_semidefinite() + sage: actual = A.is_positive_semidefinite() # needs scipy sage: actual == expected # needs scipy True @@ -15402,7 +15405,7 @@ cdef class Matrix(Matrix1): sage: Id.norm(2) # needs scipy 1.0 - sage: # needs sage.rings.real_mpfr + sage: # needs scipy sage.rings.real_mpfr sage: A = matrix(RR, 2, 2, [13,-4,-4,7]) sage: A.norm() # rel tol 2e-16 14.999999999999998 diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 55cff5b9ac7..73e8f708110 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -465,7 +465,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): TESTS:: sage: import gc - sage: for i in range(10): # needs sage.rings.finite_rings + sage: for i in range(10): # needs sage.libs.linbox sage.rings.finite_rings ....: A = random_matrix(GF(7),1000,1000) ....: B = random_matrix(Integers(10),1000,1000) ....: C = random_matrix(GF(16007),1000,1000) diff --git a/src/sage/matrix/matrix_polynomial_dense.pyx b/src/sage/matrix/matrix_polynomial_dense.pyx index 5d9e99a6a4c..31a13cd83d6 100644 --- a/src/sage/matrix/matrix_polynomial_dense.pyx +++ b/src/sage/matrix/matrix_polynomial_dense.pyx @@ -2825,7 +2825,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): [ 6*x + 3 5*x^2 + 6 3] ) - sage: A.right_quo_rem(B[:2,:]) # matrix 2 x 3, full row rank + sage: A.right_quo_rem(B[:2,:]) # matrix 2 x 3, full row rank # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: division of these matrices does not admit a remainder diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index cd0dd2e3117..0d48de627f3 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -138,7 +138,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(CDF, 2, 3, False, 'numpy') # needs numpy - sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings + sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings sage: get_matrix_class(IntegerModRing(3), 4, 4, False, 'meataxe') # optional - meataxe @@ -183,7 +183,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: type(matrix(GF(64, 'z'), 2, range(4))) # needs sage.libs.m4ri sage.rings.finite_rings - sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe, needs sage.rings.finite_rings + sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe # needs sage.rings.finite_rings """ diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index b72daee9802..7233892ce2f 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -356,7 +356,7 @@ def random_matrix(ring, nrows, ncols=None, algorithm='randomize', implementation ....: A = random_matrix(*args, **kwds) ....: density_sum += float(A.density()) - sage: # needs sage.libs.flint (otherwise timeout) + sage: # needs sage.libs.linbox (otherwise timeout) sage: density_sum = 0.0 sage: total_count = 0.0 sage: add_sample(ZZ, 5, x=-10, y=10, density=0.75) @@ -366,14 +366,14 @@ def random_matrix(ring, nrows, ncols=None, algorithm='randomize', implementation sage: while abs(density_sum/total_count - expected_density) > 0.001: ....: add_sample(ZZ, 5, x=-10, y=10, density=0.75) - sage: # needs sage.libs.flint (otherwise timeout) + sage: # needs sage.libs.linbox (otherwise timeout) sage: density_sum = 0.0 sage: total_count = 0.0 sage: add_sample(ZZ, 5, x=20, y=30, density=0.75) sage: while abs(density_sum/total_count - expected_density) > 0.001: ....: add_sample(ZZ, 5, x=20, y=30, density=0.75) - sage: # needs sage.libs.flint (otherwise timeout) + sage: # needs sage.libs.linbox (otherwise timeout) sage: density_sum = 0.0 sage: total_count = 0.0 sage: add_sample(ZZ, 100, x=20, y=30, density=0.75) @@ -396,7 +396,7 @@ def random_matrix(ring, nrows, ncols=None, algorithm='randomize', implementation For algorithm testing you might want to control the number of bits, say 10,000 entries, each limited to 16 bits. :: - sage: # needs sage.libs.flint (otherwise timeout) + sage: # needs sage.libs.linbox (otherwise timeout) sage: A = random_matrix(ZZ, 100, 100, x=2^16); A 100 x 100 dense matrix over Integer Ring (use the '.str()' method to see the entries) From 3cbfb0f410704f484c671b4535141fc06696cc22 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 00:06:40 -0700 Subject: [PATCH 312/494] sage.modules: Update # needs --- src/sage/modules/free_module_integer.py | 2 +- src/sage/modules/vector_double_dense.pyx | 1 + src/sage/modules/vector_real_double_dense.pyx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/modules/free_module_integer.py b/src/sage/modules/free_module_integer.py index c16e747a53f..5f20d55a89c 100644 --- a/src/sage/modules/free_module_integer.py +++ b/src/sage/modules/free_module_integer.py @@ -407,7 +407,7 @@ def BKZ(self, *args, **kwds): EXAMPLES:: - sage: # needs sage.libs.flint (o/w timeout) + sage: # needs sage.libs.linbox (o/w timeout) sage: from sage.modules.free_module_integer import IntegerLattice sage: A = sage.crypto.gen_lattice(type='random', n=1, m=60, q=2^60, seed=42) sage: L = IntegerLattice(A, lll_reduce=False) diff --git a/src/sage/modules/vector_double_dense.pyx b/src/sage/modules/vector_double_dense.pyx index 063b665922c..f0d9a96f41a 100644 --- a/src/sage/modules/vector_double_dense.pyx +++ b/src/sage/modules/vector_double_dense.pyx @@ -558,6 +558,7 @@ cdef class Vector_double_dense(Vector_numpy_dense): EXAMPLES:: + sage: # needs scipy sage: v = vector(RDF, range(9)) sage: w = vector(CDF, [k+(9-k)*I for k in range(9)]) sage: v.stats_kurtosis() # rel tol 5e-15 diff --git a/src/sage/modules/vector_real_double_dense.pyx b/src/sage/modules/vector_real_double_dense.pyx index bf7c75f1605..e05895f0011 100644 --- a/src/sage/modules/vector_real_double_dense.pyx +++ b/src/sage/modules/vector_real_double_dense.pyx @@ -72,7 +72,7 @@ cdef class Vector_real_double_dense(Vector_double_dense): EXAMPLES:: sage: v = vector(RDF, range(9)) - sage: v.stats_skew() + sage: v.stats_skew() # needs scipy 0.0 """ import scipy.stats From 403ece7da214c3cb3fba058aae33cfa961dce0de Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 18:59:26 -0700 Subject: [PATCH 313/494] sage.matrix: Update # needs --- src/sage/matrix/matrix_space.py | 68 ++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 0d48de627f3..a826efa1f27 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -107,12 +107,12 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: from sage.matrix.matrix_space import get_matrix_class - sage: get_matrix_class(ZZ, 4, 5, False, None) + sage: get_matrix_class(ZZ, 4, 5, False, None) # needs sage.libs.linbox - sage: get_matrix_class(ZZ, 4, 5, True, None) + sage: get_matrix_class(ZZ, 4, 5, True, None) # needs sage.libs.linbox - sage: get_matrix_class(ZZ, 3, 3, False, 'flint') # needs sage.libs.flint + sage: get_matrix_class(ZZ, 3, 3, False, 'flint') # needs sage.libs.linbox sage: get_matrix_class(ZZ, 3, 3, False, 'gap') # needs sage.libs.gap @@ -135,10 +135,10 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(RDF, 2, 2, False, 'numpy') # needs numpy - sage: get_matrix_class(CDF, 2, 3, False, 'numpy') # needs numpy + sage: get_matrix_class(CDF, 2, 3, False, 'numpy') # needs numpy sage.rings.complex_double - sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings + sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional - meataxe, needs sage.rings.finite_rings sage: get_matrix_class(IntegerModRing(3), 4, 4, False, 'meataxe') # optional - meataxe @@ -158,9 +158,9 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: get_matrix_class(GF(3), 2, 2, False, 'm4ri') Traceback (most recent call last): ... - ValueError: 'm4ri' matrices are only available - for fields of characteristic 2 and order <= 65536 - sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') # needs sage.libs.linbox + ValueError: 'm4ri' matrices are only available for fields of characteristic 2 + and order <= 65536 + sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') Traceback (most recent call last): ... ValueError: 'linbox-float' matrices can only deal with order < 256 @@ -183,7 +183,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): sage: type(matrix(GF(64, 'z'), 2, range(4))) # needs sage.libs.m4ri sage.rings.finite_rings - sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe # needs sage.rings.finite_rings + sage: type(matrix(GF(125, 'z'), 2, range(4))) # optional - meataxe, needs sage.rings.finite_rings """ @@ -496,7 +496,7 @@ class MatrixSpace(UniqueRepresentation, Parent): Check that different implementations play together as expected:: - sage: # needs sage.libs.flint + sage: # needs sage.libs.linbox sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') sage: M2 = MatrixSpace(ZZ, 2, implementation='generic') sage: type(M1(range(4))) @@ -769,7 +769,7 @@ def _has_default_implementation(self): sage: MatrixSpace(ZZ, 2, implementation='generic')._has_default_implementation() False - sage: MatrixSpace(ZZ, 2, implementation='flint')._has_default_implementation() # needs sage.libs.flint + sage: MatrixSpace(ZZ, 2, implementation='flint')._has_default_implementation() # needs sage.libs.linbox True """ default = get_matrix_class(self.base_ring(), self.nrows(), self.ncols(), self.is_sparse(), None) @@ -806,14 +806,14 @@ def _copy_zero(self): EXAMPLES:: sage: MS = MatrixSpace(GF(2), 20, 20) - sage: MS._copy_zero # needs sage.rings.finite_rings + sage: MS._copy_zero False sage: MS = MatrixSpace(GF(3), 20, 20) - sage: MS._copy_zero # needs sage.rings.finite_rings + sage: MS._copy_zero True sage: MS = MatrixSpace(GF(3), 200, 200) - sage: MS._copy_zero # needs sage.rings.finite_rings + sage: MS._copy_zero False sage: MS = MatrixSpace(ZZ,200,200) @@ -880,8 +880,9 @@ def _element_constructor_(self, entries, **kwds): [1 2] [3 4] + sage: # needs sage.modular sage: MS = MatrixSpace(ZZ, 2) - sage: g = Gamma0(5)([1,1,0,1]) # needs sage.modular + sage: g = Gamma0(5)([1,1,0,1]) sage: MS(g) [1 1] [0 1] @@ -901,11 +902,14 @@ def _element_constructor_(self, entries, **kwds): Ensure that :trac:`12020` is fixed:: - sage: rings = [ZZ, QQ, RealField(100), ComplexField(100), RDF, CDF] + sage: rings = [ZZ, QQ, RDF] + sage: rings.extend([RealField(100), ComplexField(100)] # needs sage.rings.real_mpfr + sage: rings.append(CDF) # needs sage.rings.complex_double sage: rings.append(PolynomialRing(QQ, 'x')) - sage: rings.append(PolynomialRing(CC, 2, 'x')) + sage: rings.append(PolynomialRing(CC, 2, 'x')) # needs sage.rings.real_mpfr sage: rings.append(SR) # needs sage.symbolic - sage: rings.extend([GF(2), GF(11), GF(2^8,'a'), GF(3^19,'a')]) # needs sage.rings.finite_rings + sage: rings.extend([GF(2), GF(11)] + sage: rings.extend([GF(2^8,'a'), GF(3^19,'a')]) # needs sage.rings.finite_rings sage: x = polygen(QQ) sage: rings.extend([NumberField(x^3 + 2, 'a'), CyclotomicField(4)]) # needs sage.rings.number_field sage: for R in rings: @@ -1017,7 +1021,8 @@ def construction(self): sage: A.parent().construction() (MatrixFunctor, Integer Ring) sage: A.parent().construction()[0](QQ['x']) - Full MatrixSpace of 2 by 2 sparse matrices over Univariate Polynomial Ring in x over Rational Field + Full MatrixSpace of 2 by 2 sparse matrices over + Univariate Polynomial Ring in x over Rational Field sage: parent(A/2) Full MatrixSpace of 2 by 2 sparse matrices over Rational Field """ @@ -1202,7 +1207,7 @@ def _coerce_map_from_(self, S): poset):: sage: S = [] - sage: S += [MatrixSpace(ZZ, 3, implementation='flint')] # needs sage.libs.flint + sage: S += [MatrixSpace(ZZ, 3, implementation='flint')] # needs sage.libs.linbox sage: S += [MatrixSpace(ZZ, 3, implementation='generic')] sage: S += [MatrixSpace(ZZ, 3, implementation='gap')] # needs sage.libs.gap sage: S += [MatrixSpace(ZZ, 3, sparse=True)] @@ -1214,7 +1219,7 @@ def _coerce_map_from_(self, S): ....: else: ....: mult += ' ' ....: mult += '\n' - sage: print(mult) # needs sage.libs.flint sage.libs.gap + sage: print(mult) # needs sage.libs.linbox sage.libs.gap XXXX X X XX @@ -1294,7 +1299,7 @@ def _repr_(self): sage: MS Full MatrixSpace of 2 by 4 sparse matrices over Integer Ring - sage: MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.flint + sage: MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.linbox Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: MatrixSpace(ZZ, 2, implementation='generic') Full MatrixSpace of 2 by 2 dense matrices over Integer Ring (using Matrix_generic_dense) @@ -1810,10 +1815,10 @@ def identity_matrix(self): Check different implementations:: - sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.flint + sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.linbox sage: M2 = MatrixSpace(ZZ, 2, implementation='generic') - sage: type(M1.identity_matrix()) # needs sage.libs.flint + sage: type(M1.identity_matrix()) # needs sage.libs.linbox sage: type(M2.identity_matrix()) @@ -1868,10 +1873,10 @@ def diagonal_matrix(self, entries): Check different implementations:: - sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.flint + sage: M1 = MatrixSpace(ZZ, 2, implementation='flint') # needs sage.libs.linbox sage: M2 = MatrixSpace(ZZ, 2, implementation='generic') - sage: type(M1.diagonal_matrix([1, 2])) # needs sage.libs.flint + sage: type(M1.diagonal_matrix([1, 2])) # needs sage.libs.linbox sage: type(M2.diagonal_matrix([1, 2])) @@ -2063,6 +2068,8 @@ def matrix(self, x=None, **kwds): sage: MS([[1],[2]]) [1] [2] + + sage: # needs sage.rings.real_mpfr sage: MS = MatrixSpace(CC, 2, 1) sage: x = polygen(ZZ, 'x') sage: F = NumberField(x^2 + 1, name='x') # needs sage.rings.number_field @@ -2489,10 +2496,10 @@ def _test_trivial_matrices_inverse(ring, sparse=True, implementation=None, check sage: from sage.matrix.matrix_space import _test_trivial_matrices_inverse as tinv sage: tinv(ZZ, sparse=True) - sage: tinv(ZZ, sparse=False, implementation='flint') + sage: tinv(ZZ, sparse=False, implementation='flint') # needs sage.libs.linbox sage: tinv(ZZ, sparse=False, implementation='generic') sage: tinv(QQ, sparse=True) - sage: tinv(QQ, sparse=False, implementation='flint') + sage: tinv(QQ, sparse=False, implementation='flint') # needs sage.libs.linbox sage: tinv(QQ, sparse=False, implementation='generic') sage: tinv(GF(11), sparse=True) sage: tinv(GF(11), sparse=False) @@ -2504,9 +2511,8 @@ def _test_trivial_matrices_inverse(ring, sparse=True, implementation=None, check sage: # needs scipy sage: tinv(RDF, sparse=True) sage: tinv(RDF, sparse=False) - sage: tinv(CDF, sparse=True) - sage: tinv(CDF, sparse=False) - + sage: tinv(CDF, sparse=True) # needs sage.rings.complex_double + sage: tinv(CDF, sparse=False) # needs sage.rings.complex_double sage: tinv(CyclotomicField(7), sparse=True) # needs sage.rings.number_field sage: tinv(CyclotomicField(7), sparse=False) # needs sage.rings.number_field sage: tinv(QQ['x,y'], sparse=True) From fabdf8624a38367e77b4ac7db3264055d55d10c4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 21 Sep 2023 22:27:42 -0700 Subject: [PATCH 314/494] Update # needs --- src/sage/matrix/matrix_space.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index a826efa1f27..a184eb7f708 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -160,7 +160,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): ... ValueError: 'm4ri' matrices are only available for fields of characteristic 2 and order <= 65536 - sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') + sage: get_matrix_class(Zmod(2**30), 2, 2, False, 'linbox-float') # needs sage.libs.linbox Traceback (most recent call last): ... ValueError: 'linbox-float' matrices can only deal with order < 256 @@ -903,7 +903,7 @@ def _element_constructor_(self, entries, **kwds): Ensure that :trac:`12020` is fixed:: sage: rings = [ZZ, QQ, RDF] - sage: rings.extend([RealField(100), ComplexField(100)] # needs sage.rings.real_mpfr + sage: rings.extend([RealField(100), ComplexField(100)]) # needs sage.rings.real_mpfr sage: rings.append(CDF) # needs sage.rings.complex_double sage: rings.append(PolynomialRing(QQ, 'x')) sage: rings.append(PolynomialRing(CC, 2, 'x')) # needs sage.rings.real_mpfr From 119673d6f1e39044f74ad3c5dc1bc4207ddbb0a5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 11:19:28 -0700 Subject: [PATCH 315/494] sage.matrix: Update # needs --- src/sage/matrix/matrix2.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 80d06af7cbe..a40fbdb4eae 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -7460,8 +7460,8 @@ cdef class Matrix(Matrix1): sage: M.eigenvalue_multiplicity(1) 0 - sage: M = posets.DiamondPoset(5).coxeter_transformation() # needs sage.graphs - sage: [M.eigenvalue_multiplicity(x) for x in [-1, 1]] # needs sage.graphs + sage: M = posets.DiamondPoset(5).coxeter_transformation() # needs sage.graphs sage.libs.flint + sage: [M.eigenvalue_multiplicity(x) for x in [-1, 1]] # needs sage.graphs sage.libs.flint [3, 2] TESTS:: From e23670dd13a1139747541d197075008fec990200 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 11:21:39 -0700 Subject: [PATCH 316/494] sage.modules: Update # needs --- .../free_quadratic_module_integer_symmetric.py | 14 +++++++------- src/sage/modules/vector_space_morphism.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py index e4959cc7a55..60f3cc131f6 100644 --- a/src/sage/modules/free_quadratic_module_integer_symmetric.py +++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py @@ -1037,7 +1037,7 @@ def maximal_overlattice(self, p=None): EXAMPLES:: - sage: # needs sage.graphs + sage: # needs sage.graphs sage.libs.pari sage: L = IntegralLattice("A4").twist(25*89) sage: L.maximal_overlattice().determinant() 5 @@ -1048,7 +1048,7 @@ def maximal_overlattice(self, p=None): TESTS:: - sage: # needs sage.libs.flint (otherwise timeout) + sage: # needs sage.libs.flint (otherwise timeout) sage.libs.pari sage: L = IntegralLattice(matrix.diagonal([2,4,4,8])) sage: L.maximal_overlattice().is_even() True @@ -1441,7 +1441,7 @@ def maximum(self): sage: L = IntegralLattice('A2') # needs sage.graphs sage: L.maximum() # needs sage.graphs +Infinity - sage: L.twist(-1).maximum() # needs sage.graphs + sage: L.twist(-1).maximum() # needs sage.graphs sage.libs.pari -2 """ if self.rank() == 0: @@ -1463,7 +1463,7 @@ def LLL(self): EXAMPLES:: sage: L = IntegralLattice('A2') # needs sage.graphs - sage: L.lll() == L # needs sage.graphs + sage: L.lll() == L # needs sage.graphs sage.libs.pari True sage: G = matrix(ZZ, 3, [0,1,0, 1,0,0, 0,0,7]) @@ -1511,9 +1511,9 @@ def short_vectors(self, n, **kwargs): EXAMPLES:: sage: A2 = IntegralLattice('A2') # needs sage.graphs - sage: A2.short_vectors(3) # needs sage.graphs + sage: A2.short_vectors(3) # needs sage.graphs sage.libs.pari [[(0, 0)], [], [(1, 1), (-1, -1), (0, 1), (0, -1), (1, 0), (-1, 0)]] - sage: A2.short_vectors(3,up_to_sign_flag=True) # needs sage.graphs + sage: A2.short_vectors(3, up_to_sign_flag=True) # needs sage.graphs sage.libs.pari [[(0, 0)], [], [(1, 1), (0, 1), (1, 0)]] """ p, m = self.signature_pair() @@ -1602,7 +1602,7 @@ def local_modification(M, G, p, check=True): EXAMPLES:: - sage: # needs sage.graphs + sage: # needs sage.graphs sage.libs.pari sage: from sage.modules.free_quadratic_module_integer_symmetric import local_modification sage: L = IntegralLattice("A3").twist(15) sage: M = L.maximal_overlattice() diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py index 764c6ac39e5..91f8f6f64b2 100644 --- a/src/sage/modules/vector_space_morphism.py +++ b/src/sage/modules/vector_space_morphism.py @@ -265,7 +265,7 @@ [0 0 0 0 0 0 0 1 1 0] [0 0 0 0 0 0 0 0 1 1] [0 0 0 0 0 0 0 0 0 1] - sage: zeta.eigenvalues() + sage: zeta.eigenvalues() # needs sage.rings.number_field [3, -2, -2, -2, -2, 1, 1, 1, 1, 1] Equality From 8402a7b35ef8067d73ff3f105cb6a793dcf288ea Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 14:08:32 -0700 Subject: [PATCH 317/494] src/sage/matrix/matrix_space.py: Fix change to doctest --- src/sage/matrix/matrix_space.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index a184eb7f708..3795ff4b0fa 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -908,7 +908,7 @@ def _element_constructor_(self, entries, **kwds): sage: rings.append(PolynomialRing(QQ, 'x')) sage: rings.append(PolynomialRing(CC, 2, 'x')) # needs sage.rings.real_mpfr sage: rings.append(SR) # needs sage.symbolic - sage: rings.extend([GF(2), GF(11)] + sage: rings.extend([GF(2), GF(11)]) sage: rings.extend([GF(2^8,'a'), GF(3^19,'a')]) # needs sage.rings.finite_rings sage: x = polygen(QQ) sage: rings.extend([NumberField(x^3 + 2, 'a'), CyclotomicField(4)]) # needs sage.rings.number_field From c3b6f2fe3e7a79c65999cf376ad3ca61ea31307d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 14:10:26 -0700 Subject: [PATCH 318/494] src/sage/matrix/matrix2.pyx: Fix doctest dataflow warning --- src/sage/matrix/matrix2.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index a40fbdb4eae..997c8118254 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -7159,7 +7159,7 @@ cdef class Matrix(Matrix1): The second eigenvector is contained in the left kernel of `B`:: - sage: (P[1, :] * B).norm() < 1e-14 # needs sage.rings.complex_double sage.symbolic + sage: (P[1, :] * B).norm() < 1e-14 # needs scipy sage.rings.complex_double sage.symbolic True .. SEEALSO:: From 88dd26df107d17b11105be41b821072920c93300 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 31 May 2023 23:20:33 -0700 Subject: [PATCH 319/494] src/sage/manifolds/calculus_method.py: Do not fail if sympy cannot be imported --- src/sage/manifolds/calculus_method.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py index 303dde6cd13..73b5b6f250a 100644 --- a/src/sage/manifolds/calculus_method.py +++ b/src/sage/manifolds/calculus_method.py @@ -27,7 +27,11 @@ simplify_chain_real_sympy, simplify_chain_generic_sympy,) from sage.misc.latex import latex -import sympy + +try: + import sympy +except ImportError: + pass # Conversion functions From 8eeafd0179a8b360bf2b0007c313f0bf61c21ce0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 19 Jun 2023 00:10:57 -0700 Subject: [PATCH 320/494] sage.manifolds: Import fixes for modularization --- src/sage/manifolds/chart_func.py | 7 ++++++- src/sage/manifolds/differentiable/integrated_curve.py | 5 ++++- src/sage/manifolds/subsets/pullback.py | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sage/manifolds/chart_func.py b/src/sage/manifolds/chart_func.py index d7104cb7f0b..6363ed61841 100644 --- a/src/sage/manifolds/chart_func.py +++ b/src/sage/manifolds/chart_func.py @@ -40,9 +40,14 @@ from sage.categories.commutative_algebras import CommutativeAlgebras from sage.manifolds.utilities import ExpressionNice from sage.misc.cachefunc import cached_method +from sage.misc.lazy_import import lazy_import from sage.symbolic.ring import SR from sage.structure.mutability import Mutability -import sympy + +try: + import sympy +except ImportError: + pass class ChartFunction(AlgebraElement, ModuleElementWithMutability): diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py index 0d01a9afd70..023c91112df 100644 --- a/src/sage/manifolds/differentiable/integrated_curve.py +++ b/src/sage/manifolds/differentiable/integrated_curve.py @@ -116,12 +116,15 @@ from sage.calculus.interpolation import Spline from sage.misc.decorators import options from sage.misc.functional import numerical_approx +from sage.misc.lazy_import import lazy_import from sage.arith.srange import srange from sage.ext.fast_callable import fast_callable from sage.symbolic.ring import SR -from scipy.integrate import ode from random import shuffle +lazy_import('scipy.integrate', 'ode') + + class IntegratedCurve(DifferentiableCurve): r""" Given a chart with coordinates denoted `(x_{1}, \ldots, x_{n})`, diff --git a/src/sage/manifolds/subsets/pullback.py b/src/sage/manifolds/subsets/pullback.py index b28365601f8..26eb087942b 100644 --- a/src/sage/manifolds/subsets/pullback.py +++ b/src/sage/manifolds/subsets/pullback.py @@ -15,6 +15,7 @@ from sage.categories.sets_cat import Sets, EmptySetError from sage.categories.metric_spaces import MetricSpaces +from sage.misc.lazy_import import lazy_import from sage.modules.free_module import is_FreeModule from sage.rings.infinity import infinity, minus_infinity from sage.rings.integer_ring import ZZ @@ -29,7 +30,8 @@ from sage.manifolds.scalarfield import ScalarField from sage.sets.real_set import RealSet import sage.geometry.abc -from sage.geometry.relative_interior import RelativeInterior + +lazy_import('sage.geometry.relative_interior', 'RelativeInterior') class ManifoldSubsetPullback(ManifoldSubset): From 2712768516eb2f4217e4149ec88fe9a43334c963 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 19 Jun 2023 00:11:28 -0700 Subject: [PATCH 321/494] sage.manifolds: Add # optional --- src/sage/manifolds/calculus_method.py | 5 +- src/sage/manifolds/subset.py | 94 +++++++++---------- src/sage/manifolds/subsets/pullback.py | 125 +++++++++++++------------ 3 files changed, 116 insertions(+), 108 deletions(-) diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py index 73b5b6f250a..ddbad8a11ef 100644 --- a/src/sage/manifolds/calculus_method.py +++ b/src/sage/manifolds/calculus_method.py @@ -30,8 +30,9 @@ try: import sympy + from sympy import latex as sympy_latex except ImportError: - pass + sympy_latex = None # Conversion functions @@ -206,7 +207,7 @@ def __init__(self, current=None, base_field_type='real'): self._simplify_dict['SR'] = simplify_chain_generic # The default simplifying functions are saved: self._simplify_dict_default = self._simplify_dict.copy() - self._latex_dict = {'sympy': sympy.latex, 'SR': latex} + self._latex_dict = {'sympy': sympy_latex, 'SR': latex} def simplify(self, expression, method=None): r""" diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py index b92d8a25d82..a360572a0e3 100644 --- a/src/sage/manifolds/subset.py +++ b/src/sage/manifolds/subset.py @@ -899,9 +899,9 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: D = M.subset_digraph(); D + sage: D = M.subset_digraph(); D # optional - sage.graphs Digraph on 4 vertices - sage: D.edges(sort=True, key=lambda e: (e[0]._name, e[1]._name)) + sage: D.edges(sort=True, key=lambda e: (e[0]._name, e[1]._name)) # optional - sage.graphs [(Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {M} of open subsets of the 3-dimensional differentiable manifold M, None), @@ -911,27 +911,27 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= (Set {W} of open subsets of the 3-dimensional differentiable manifold M, Set {M} of open subsets of the 3-dimensional differentiable manifold M, None)] - sage: D.plot(layout='acyclic') + sage: D.plot(layout='acyclic') # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: def label(element): ....: try: ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: D.relabel(label, inplace=False).plot(layout='acyclic') + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: VW = V.union(W) - sage: D = M.subset_digraph(); D + sage: D = M.subset_digraph(); D # optional - sage.graphs Digraph on 5 vertices - sage: D.relabel(label, inplace=False).plot(layout='acyclic') + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot Graphics object consisting of 12 graphics primitives If ``open_covers`` is ``True``, the digraph includes a special vertex for each nontrivial open cover of a subset:: - sage: D = M.subset_digraph(open_covers=True) - sage: D.relabel(label, inplace=False).plot(layout='acyclic') + sage: D = M.subset_digraph(open_covers=True) # optional - sage.graphs + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot Graphics object consisting of 14 graphics primitives .. PLOT:: @@ -1059,33 +1059,33 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: P = M.subset_poset(); P + sage: P = M.subset_poset(); P # optional - sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: element._name for element in P}) + sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: VW = V.union(W) - sage: P = M.subset_poset(); P + sage: P = M.subset_poset(); P # optional - sage.graphs Finite poset containing 5 elements - sage: P.maximal_elements() + sage: P.maximal_elements() # optional - sage.graphs [Set {M} of open subsets of the 3-dimensional differentiable manifold M] - sage: sorted(P.minimal_elements(), key=lambda v: v._name) + sage: sorted(P.minimal_elements(), key=lambda v: v._name) # optional - sage.graphs [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M] sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) + sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) # optional - sage.graphs [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V_union_W} of open subsets of the 3-dimensional differentiable manifold M] - sage: P.plot(element_labels={element: element._name for element in P}) + sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 10 graphics primitives If ``open_covers`` is ``True``, the poset includes a special vertex for each nontrivial open cover of a subset:: - sage: P = M.subset_poset(open_covers=True); P + sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs Finite poset containing 6 elements sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) + sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) # optional - sage.graphs [(Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M), Set {M} of open subsets of the 3-dimensional differentiable manifold M] @@ -1094,7 +1094,7 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 12 graphics primitives .. PLOT:: @@ -1236,7 +1236,7 @@ def superset_digraph(self, loops=False, quotient=False, open_covers=False, point sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') sage: VW = V.union(W) - sage: P = V.superset_digraph(loops=False, upper_bound=VW); P + sage: P = V.superset_digraph(loops=False, upper_bound=VW); P # optional - sage.graphs Digraph on 2 vertices """ @@ -1261,9 +1261,9 @@ def superset_poset(self, open_covers=False, points=False, upper_bound=None): sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') sage: VW = V.union(W) - sage: P = V.superset_poset(); P + sage: P = V.superset_poset(); P # optional - sage.graphs Finite poset containing 3 elements - sage: P.plot(element_labels={element: element._name for element in P}) + sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 6 graphics primitives """ @@ -1369,25 +1369,25 @@ def declare_union(self, *subsets_or_families, disjoint=False): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P = M.subset_poset(open_covers=True); P + sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: AB.declare_union(A, B) sage: A.union(B) Subset AB of the 2-dimensional topological manifold M - sage: P = M.subset_poset(open_covers=True); P + sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: B1 = B.subset('B1', is_open=True) sage: B2 = B.subset('B2', is_open=True) sage: B.declare_union(B1, B2, disjoint=True) - sage: P = M.subset_poset(open_covers=True); P + sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs Finite poset containing 9 elements - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 19 graphics primitives .. PLOT:: @@ -1495,18 +1495,18 @@ def declare_equal(self, *others): sage: Vs = [M.open_subset(f'V{i}') for i in range(2)] sage: UV = U.intersection(V) sage: W = UV.open_subset('W') - sage: P = M.subset_poset() + sage: P = M.subset_poset() # optional - sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 15 graphics primitives sage: V.declare_equal(Vs) - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 11 graphics primitives sage: W.declare_equal(U) - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 6 graphics primitives .. PLOT:: @@ -1557,16 +1557,16 @@ def declare_subset(self, *supersets): Set {M, V} of open subsets of the 2-dimensional differentiable manifold M sage: U1.subset_family() Set {U1} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() + sage: P = M.subset_poset() # optional - sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: V.declare_subset(U1, U2) sage: V.superset_family() Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 9 graphics primitives Subsets in a directed cycle of inclusions are equal:: @@ -1576,8 +1576,8 @@ def declare_subset(self, *supersets): Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M sage: M.equal_subset_family() Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 2 graphics primitives .. PLOT:: @@ -1623,16 +1623,16 @@ def declare_superset(self, *subsets): sage: W = V1.intersection(V2) sage: U.subset_family() Set {U} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() + sage: P = M.subset_poset() # optional - sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 11 graphics primitives sage: U.declare_superset(V1, V2) sage: U.subset_family() Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 11 graphics primitives Subsets in a directed cycle of inclusions are equal:: @@ -1642,8 +1642,8 @@ def declare_superset(self, *subsets): Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M sage: W.equal_subset_family() Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P = M.subset_poset() # optional - sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 4 graphics primitives .. PLOT:: @@ -1726,7 +1726,7 @@ def declare_empty(self): Emptiness is recorded as empty open covers:: - sage: P = M.subset_poset(open_covers=True, points=[b]) + sage: P = M.subset_poset(open_covers=True, points=[b]) # optional - sage.graphs sage: def label(element): ....: if isinstance(element, str): ....: return element @@ -1734,7 +1734,7 @@ def declare_empty(self): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P.plot(element_labels={element: label(element) for element in P}) + sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot Graphics object consisting of 10 graphics primitives .. PLOT:: diff --git a/src/sage/manifolds/subsets/pullback.py b/src/sage/manifolds/subsets/pullback.py index 26eb087942b..43a3d9cbf7c 100644 --- a/src/sage/manifolds/subsets/pullback.py +++ b/src/sage/manifolds/subsets/pullback.py @@ -79,32 +79,33 @@ class ManifoldSubsetPullback(ManifoldSubset): Pulling back a polytope under a chart:: - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [2, 1]]); P + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [2, 1]]); P # optional - sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: S = ManifoldSubsetPullback(c_cart, P); S + sage: S = ManifoldSubsetPullback(c_cart, P); S # optional - sage.geometry.polyhedron Subset x_y_inv_P of the 2-dimensional topological manifold R^2 - sage: M((1, 2)) in S + sage: M((1, 2)) in S # optional - sage.geometry.polyhedron True - sage: M((2, 0)) in S + sage: M((2, 0)) in S # optional - sage.geometry.polyhedron False Pulling back the interior of a polytope under a chart:: - sage: int_P = P.interior(); int_P - Relative interior of a 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: int_S = ManifoldSubsetPullback(c_cart, int_P, name='int_S'); int_S + sage: int_P = P.interior(); int_P # optional - sage.geometry.polyhedron + Relative interior of a + 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices + sage: int_S = ManifoldSubsetPullback(c_cart, int_P, name='int_S'); int_S # optional - sage.geometry.polyhedron Open subset int_S of the 2-dimensional topological manifold R^2 - sage: M((0, 0)) in int_S + sage: M((0, 0)) in int_S # optional - sage.geometry.polyhedron False - sage: M((1, 1)) in int_S + sage: M((1, 1)) in int_S # optional - sage.geometry.polyhedron True Using the embedding map of a submanifold:: sage: M = Manifold(3, 'M', structure="topological") - sage: N = Manifold(2, 'N', ambient=M, structure="topological") - sage: N - 2-dimensional topological submanifold N immersed in the 3-dimensional topological manifold M + sage: N = Manifold(2, 'N', ambient=M, structure="topological"); N + 2-dimensional topological submanifold N + immersed in the 3-dimensional topological manifold M sage: CM. = M.chart() sage: CN. = N.chart() sage: t = var('t') @@ -117,7 +118,9 @@ class ManifoldSubsetPullback(ManifoldSubset): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: S = M.open_subset('S', coord_def={CM: z<1}) - sage: phi_without_t = N.continuous_map(M, {(CN, CM): [expr.subs(t=0) for expr in phi.expr()]}); phi_without_t + sage: phi_without_t = N.continuous_map(M, {(CN, CM): [expr.subs(t=0) + ....: for expr in phi.expr()]}) + sage: phi_without_t Continuous map from the 2-dimensional topological submanifold N embedded in the 3-dimensional topological manifold M @@ -125,7 +128,8 @@ class ManifoldSubsetPullback(ManifoldSubset): sage: phi_without_t.expr() (u, v, u^2 + v^2) sage: D = ManifoldSubsetPullback(phi_without_t, S); D - Subset f_inv_S of the 2-dimensional topological submanifold N embedded in the 3-dimensional topological manifold M + Subset f_inv_S of the 2-dimensional topological submanifold N + embedded in the 3-dimensional topological manifold M sage: N.point((2,0)) in D False @@ -141,11 +145,11 @@ def __classcall_private__(cls, map, codomain_subset, inverse=None, sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: S = ManifoldSubsetPullback(c_cart, P); S + sage: S = ManifoldSubsetPullback(c_cart, P); S # optional - sage.geometry.polyhedron Subset x_y_inv_P of the 2-dimensional topological manifold R^2 - sage: S is ManifoldSubsetPullback(c_cart, P) + sage: S is ManifoldSubsetPullback(c_cart, P) # optional - sage.geometry.polyhedron True """ @@ -245,20 +249,21 @@ def _is_open(codomain_subset): Polyhedra:: - sage: Empty = Polyhedron(ambient_dim=2); Empty + sage: Empty = Polyhedron(ambient_dim=2); Empty # optional - sage.geometry.polyhedron The empty polyhedron in ZZ^2 - sage: ManifoldSubsetPullback._is_open(Empty) + sage: ManifoldSubsetPullback._is_open(Empty) # optional - sage.geometry.polyhedron True - sage: C = polytopes.cube(); C + sage: C = polytopes.cube(); C # optional - sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: ManifoldSubsetPullback._is_open(C) + sage: ManifoldSubsetPullback._is_open(C) # optional - sage.geometry.polyhedron False Interiors of polyhedra:: - sage: int_C = C.interior(); int_C - Relative interior of a 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: ManifoldSubsetPullback._is_open(int_C) + sage: int_C = C.interior(); int_C # optional - sage.geometry.polyhedron + Relative interior of a + 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices + sage: ManifoldSubsetPullback._is_open(int_C) # optional - sage.geometry.polyhedron True PPL polyhedra and not-necessarily-closed polyhedra:: @@ -456,10 +461,10 @@ def _polyhedron_restriction(expr, polyhedron, relint=False): sage: _polyhedron_restriction = ManifoldSubsetPullback._polyhedron_restriction sage: var('x y z') (x, y, z) - sage: c = polytopes.cube() - sage: _polyhedron_restriction((x, y, z), c) + sage: c = polytopes.cube() # optional - sage.geometry.polyhedron + sage: _polyhedron_restriction((x, y, z), c) # optional - sage.geometry.polyhedron [-x + 1 >= 0, -y + 1 >= 0, -z + 1 >= 0, x + 1 >= 0, z + 1 >= 0, y + 1 >= 0] - sage: _polyhedron_restriction((x, y, z), c, relint=True) + sage: _polyhedron_restriction((x, y, z), c, relint=True) # optional - sage.geometry.polyhedron [-x + 1 > 0, -y + 1 > 0, -z + 1 > 0, x + 1 > 0, z + 1 > 0, y + 1 > 0] """ conjunction = [] @@ -512,16 +517,16 @@ def _coord_def(map, codomain_subset): Coordinate definition of an open chart polyhedron:: sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: ri_P = P.relative_interior(); ri_P + sage: ri_P = P.relative_interior(); ri_P # optional - sage.geometry.polyhedron Relative interior of a 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: _coord_def(c_cart, ri_P) + sage: _coord_def(c_cart, ri_P) # optional - sage.geometry.polyhedron {Chart (R^2, (x, y)): [2*x - y > 0, -4*x + 3*y > 0, x - y + 1 > 0]} Coordinate definition of the pullback of an open interval under a scalar field:: - sage: r_squared = M.scalar_field(x^2+y^2) + sage: r_squared = M.scalar_field(x^2 + y^2) sage: I = RealSet((1, 4)); I (1, 4) sage: _coord_def(r_squared, I) @@ -599,19 +604,20 @@ def _an_element_(self): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube + sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = McCube.an_element(); p + sage: p = McCube.an_element(); p # optional - sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: p.coordinates(c_cart) + sage: p.coordinates(c_cart) # optional - sage.geometry.polyhedron (0, 0, 0) - sage: Empty = Polyhedron(ambient_dim=3) - sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty'); McEmpty + sage: Empty = Polyhedron(ambient_dim=3) # optional - sage.geometry.polyhedron + sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') # optional - sage.geometry.polyhedron + sage: McEmpty # optional - sage.geometry.polyhedron Subset McEmpty of the 3-dimensional topological manifold R^3 - sage: McEmpty.an_element() + sage: McEmpty.an_element() # optional - sage.geometry.polyhedron Traceback (most recent call last): ... sage.categories.sets_cat.EmptySetError @@ -630,18 +636,18 @@ def some_elements(self): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube + sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: L = list(McCube.some_elements()); L + sage: L = list(McCube.some_elements()); L # optional - sage.geometry.polyhedron [Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3] - sage: list(p.coordinates(c_cart) for p in L) + sage: list(p.coordinates(c_cart) for p in L) # optional - sage.geometry.polyhedron [(0, 0, 0), (1, -1, -1), (1, 0, -1), @@ -649,10 +655,11 @@ def some_elements(self): (1, -1/4, 1/2), (0, -5/8, 3/4)] - sage: Empty = Polyhedron(ambient_dim=3) - sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty'); McEmpty + sage: Empty = Polyhedron(ambient_dim=3) # optional - sage.geometry.polyhedron + sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') # optional - sage.geometry.polyhedron + sage: McEmpty # optional - sage.geometry.polyhedron Subset McEmpty of the 3-dimensional topological manifold R^3 - sage: list(McEmpty.some_elements()) + sage: list(McEmpty.some_elements()) # optional - sage.geometry.polyhedron [] """ if self._inverse is not None: @@ -675,9 +682,9 @@ def __contains__(self, point): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube + sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: Cube.vertices_list() + sage: Cube.vertices_list() # optional - sage.geometry.polyhedron [[1, -1, -1], [1, 1, -1], [1, 1, 1], @@ -686,15 +693,15 @@ def __contains__(self, point): [-1, -1, -1], [-1, 1, -1], [-1, 1, 1]] - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = M.point((0, 0, 0)); p + sage: p = M.point((0, 0, 0)); p # optional - sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: p in McCube + sage: p in McCube # optional - sage.geometry.polyhedron True - sage: q = M.point((2, 3, 4)); q + sage: q = M.point((2, 3, 4)); q # optional - sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: q in McCube + sage: q in McCube # optional - sage.geometry.polyhedron False """ if super().__contains__(point): @@ -724,13 +731,13 @@ def is_open(self): sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: P.is_open() + sage: P.is_open() # optional - sage.geometry.polyhedron False - sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP + sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # optional - sage.geometry.polyhedron Subset McP of the 2-dimensional topological manifold R^2 - sage: McP.is_open() + sage: McP.is_open() # optional - sage.geometry.polyhedron False """ return super().is_open() @@ -758,11 +765,11 @@ def is_closed(self): The pullback of a (closed convex) polyhedron under a chart is closed:: - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP + sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # optional - sage.geometry.polyhedron Subset McP of the 2-dimensional topological manifold R^2 - sage: McP.is_closed() + sage: McP.is_closed() # optional - sage.geometry.polyhedron True The pullback of real vector subspaces under a chart is closed:: From d1b0ab2b6706db48bdd516b31e7f51618a5c89d1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:18 -0700 Subject: [PATCH 322/494] src/sage/manifolds: sage -fixdoctests --only-tags --- .../characteristic_cohomology_class.py | 9 +- .../differentiable/examples/euclidean.py | 33 ++-- .../differentiable/multivectorfield.py | 18 ++- .../pseudo_riemannian_submanifold.py | 9 +- .../manifolds/differentiable/tensorfield.py | 9 +- src/sage/manifolds/subset.py | 94 ++++++------ src/sage/manifolds/subsets/pullback.py | 141 +++++++++--------- 7 files changed, 164 insertions(+), 149 deletions(-) diff --git a/src/sage/manifolds/differentiable/characteristic_cohomology_class.py b/src/sage/manifolds/differentiable/characteristic_cohomology_class.py index 7289f67b913..91ebbf00ccc 100644 --- a/src/sage/manifolds/differentiable/characteristic_cohomology_class.py +++ b/src/sage/manifolds/differentiable/characteristic_cohomology_class.py @@ -260,10 +260,11 @@ Let us check whether this form represents the Euler class correctly:: - sage: expr = e_class_form[2][[1,2]].expr() # long time - sage: expr = integrate(expr, x, -infinity, infinity) # long time - sage: expr = expr.simplify_full() # long time - sage: integrate(expr, y, -infinity, infinity) # long time + sage: # long time + sage: expr = e_class_form[2][[1,2]].expr() + sage: expr = integrate(expr, x, -infinity, infinity) + sage: expr = expr.simplify_full() + sage: integrate(expr, y, -infinity, infinity) 2 As we can see, the integral coincides with the Euler characteristic of `S^2` so diff --git a/src/sage/manifolds/differentiable/examples/euclidean.py b/src/sage/manifolds/differentiable/examples/euclidean.py index 97e3aa3d875..eb96b6da587 100644 --- a/src/sage/manifolds/differentiable/examples/euclidean.py +++ b/src/sage/manifolds/differentiable/examples/euclidean.py @@ -1879,14 +1879,15 @@ def _transition_spherical_cartesian(self): Tests of the change-of-frame formulas:: - sage: spher = E.spherical_coordinates() # long time - sage: spher_f = E.spherical_frame() # long time - sage: cart_f = E.cartesian_frame() # long time - sage: E.change_of_frame(cart_f, spher_f)[:,spher] # long time + sage: # long time + sage: spher = E.spherical_coordinates() + sage: spher_f = E.spherical_frame() + sage: cart_f = E.cartesian_frame() + sage: E.change_of_frame(cart_f, spher_f)[:,spher] [cos(ph)*sin(th) cos(ph)*cos(th) -sin(ph)] [sin(ph)*sin(th) cos(th)*sin(ph) cos(ph)] [ cos(th) -sin(th) 0] - sage: E.change_of_frame(spher_f, cart_f)[:,spher] # long time + sage: E.change_of_frame(spher_f, cart_f)[:,spher] [cos(ph)*sin(th) sin(ph)*sin(th) cos(th)] [cos(ph)*cos(th) cos(th)*sin(ph) -sin(th)] [ -sin(ph) cos(ph) 0] @@ -1958,14 +1959,15 @@ def _transition_cylindrical_cartesian(self): Tests of the change-of-frame formulas:: - sage: cylind = E.cylindrical_coordinates() # long time - sage: cylind_f = E.cylindrical_frame() # long time - sage: cart_f= E.cartesian_frame() # long time - sage: E.change_of_frame(cart_f, cylind_f)[:,cylind] # long time + sage: # long time + sage: cylind = E.cylindrical_coordinates() + sage: cylind_f = E.cylindrical_frame() + sage: cart_f= E.cartesian_frame() + sage: E.change_of_frame(cart_f, cylind_f)[:,cylind] [ cos(ph) -sin(ph) 0] [ sin(ph) cos(ph) 0] [ 0 0 1] - sage: E.change_of_frame(cylind_f, cart_f)[:,cylind] # long time + sage: E.change_of_frame(cylind_f, cart_f)[:,cylind] [ cos(ph) sin(ph) 0] [-sin(ph) cos(ph) 0] [ 0 0 1] @@ -2035,14 +2037,15 @@ def _transition_spherical_cylindrical(self): Tests of the change-of-frame formulas:: - sage: spher = E.spherical_coordinates() # long time - sage: spher_f = E.spherical_frame() # long time - sage: cylind_f = E.cylindrical_frame() # long time - sage: E.change_of_frame(cylind_f, spher_f)[:, spher] # long time + sage: # long time + sage: spher = E.spherical_coordinates() + sage: spher_f = E.spherical_frame() + sage: cylind_f = E.cylindrical_frame() + sage: E.change_of_frame(cylind_f, spher_f)[:, spher] [ sin(th) cos(th) 0] [ 0 0 1] [ cos(th) -sin(th) 0] - sage: E.change_of_frame(spher_f, cylind_f)[:, spher] # long time + sage: E.change_of_frame(spher_f, cylind_f)[:, spher] [ sin(th) 0 cos(th)] [ cos(th) 0 -sin(th)] [ 0 1 0] diff --git a/src/sage/manifolds/differentiable/multivectorfield.py b/src/sage/manifolds/differentiable/multivectorfield.py index 2590803b0fa..87f68f8b1f0 100644 --- a/src/sage/manifolds/differentiable/multivectorfield.py +++ b/src/sage/manifolds/differentiable/multivectorfield.py @@ -1404,18 +1404,20 @@ def bracket(self, other): Finally let us check the graded Jacobi identity for `p=1`, `q=1` and `r=2`:: - sage: a_bc = a.bracket(b.bracket(c)) # long time - sage: b_ca = b.bracket(c.bracket(a)) # long time - sage: c_ab = c.bracket(a.bracket(b)) # long time - sage: a_bc + b_ca + c_ab == 0 # long time + sage: # long time + sage: a_bc = a.bracket(b.bracket(c)) + sage: b_ca = b.bracket(c.bracket(a)) + sage: c_ab = c.bracket(a.bracket(b)) + sage: a_bc + b_ca + c_ab == 0 True as well as for `p=1`, `q=2` and `r=2`:: - sage: a_cd = a.bracket(c.bracket(d)) # long time - sage: c_da = c.bracket(d.bracket(a)) # long time - sage: d_ac = d.bracket(a.bracket(c)) # long time - sage: a_cd + c_da - d_ac == 0 # long time + sage: # long time + sage: a_cd = a.bracket(c.bracket(d)) + sage: c_da = c.bracket(d.bracket(a)) + sage: d_ac = d.bracket(a.bracket(c)) + sage: a_cd + c_da - d_ac == 0 True """ diff --git a/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py b/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py index 3aef31eb703..b41b8ba4ba8 100644 --- a/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py +++ b/src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py @@ -115,13 +115,14 @@ Let us compute the induced metric (or first fundamental form):: - sage: gamma = N.induced_metric() # long time - sage: gamma.display() # long time + sage: # long time + sage: gamma = N.induced_metric() + sage: gamma.display() gamma = b^2 drh⊗drh + b^2*sinh(rh)^2 dth⊗dth - sage: gamma[:] # long time + sage: gamma[:] [ b^2 0] [ 0 b^2*sinh(rh)^2] - sage: gamma[1,1] # long time + sage: gamma[1,1] b^2 the normal vector:: diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py index 9e302688024..a47bd364436 100644 --- a/src/sage/manifolds/differentiable/tensorfield.py +++ b/src/sage/manifolds/differentiable/tensorfield.py @@ -245,17 +245,18 @@ class TensorField(ModuleElementWithMutability): The vectors can be defined only on subsets of `S^2`, the domain of the result is then the common subset:: - sage: s = t(a.restrict(U), b) ; s # long time + sage: # long time + sage: s = t(a.restrict(U), b) ; s Scalar field t(a,b) on the Open subset U of the 2-dimensional differentiable manifold S^2 - sage: s.display() # long time + sage: s.display() t(a,b): U → ℝ (x, y) ↦ -2*x*y - y^2 - 3*x on W: (u, v) ↦ -(3*u^3 + (3*u + 1)*v^2 + 2*u*v)/(u^4 + 2*u^2*v^2 + v^4) - sage: s = t(a.restrict(U), b.restrict(W)) ; s # long time + sage: s = t(a.restrict(U), b.restrict(W)) ; s Scalar field t(a,b) on the Open subset W of the 2-dimensional differentiable manifold S^2 - sage: s.display() # long time + sage: s.display() t(a,b): W → ℝ (x, y) ↦ -2*x*y - y^2 - 3*x (u, v) ↦ -(3*u^3 + (3*u + 1)*v^2 + 2*u*v)/(u^4 + 2*u^2*v^2 + v^4) diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py index a360572a0e3..4f02cd2e97e 100644 --- a/src/sage/manifolds/subset.py +++ b/src/sage/manifolds/subset.py @@ -899,9 +899,9 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: D = M.subset_digraph(); D # optional - sage.graphs + sage: D = M.subset_digraph(); D # needs sage.graphs Digraph on 4 vertices - sage: D.edges(sort=True, key=lambda e: (e[0]._name, e[1]._name)) # optional - sage.graphs + sage: D.edges(sort=True, key=lambda e: (e[0]._name, e[1]._name)) # needs sage.graphs [(Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {M} of open subsets of the 3-dimensional differentiable manifold M, None), @@ -911,27 +911,27 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= (Set {W} of open subsets of the 3-dimensional differentiable manifold M, Set {M} of open subsets of the 3-dimensional differentiable manifold M, None)] - sage: D.plot(layout='acyclic') # optional - sage.graphs sage.plot + sage: D.plot(layout='acyclic') # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: def label(element): ....: try: ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: VW = V.union(W) - sage: D = M.subset_digraph(); D # optional - sage.graphs + sage: D = M.subset_digraph(); D # needs sage.graphs Digraph on 5 vertices - sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.graphs sage.plot Graphics object consisting of 12 graphics primitives If ``open_covers`` is ``True``, the digraph includes a special vertex for each nontrivial open cover of a subset:: - sage: D = M.subset_digraph(open_covers=True) # optional - sage.graphs - sage: D.relabel(label, inplace=False).plot(layout='acyclic') # optional - sage.graphs sage.plot + sage: D = M.subset_digraph(open_covers=True) # needs sage.graphs + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.graphs sage.plot Graphics object consisting of 14 graphics primitives .. PLOT:: @@ -1059,33 +1059,33 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: P = M.subset_poset(); P # optional - sage.graphs + sage: P = M.subset_poset(); P # needs sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: VW = V.union(W) - sage: P = M.subset_poset(); P # optional - sage.graphs + sage: P = M.subset_poset(); P # needs sage.graphs Finite poset containing 5 elements - sage: P.maximal_elements() # optional - sage.graphs + sage: P.maximal_elements() # needs sage.graphs [Set {M} of open subsets of the 3-dimensional differentiable manifold M] - sage: sorted(P.minimal_elements(), key=lambda v: v._name) # optional - sage.graphs + sage: sorted(P.minimal_elements(), key=lambda v: v._name) # needs sage.graphs [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M] sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) # optional - sage.graphs + sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) # needs sage.graphs [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V_union_W} of open subsets of the 3-dimensional differentiable manifold M] - sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 10 graphics primitives If ``open_covers`` is ``True``, the poset includes a special vertex for each nontrivial open cover of a subset:: - sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs + sage: P = M.subset_poset(open_covers=True); P # needs sage.graphs Finite poset containing 6 elements sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) # optional - sage.graphs + sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) # needs sage.graphs [(Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M), Set {M} of open subsets of the 3-dimensional differentiable manifold M] @@ -1094,7 +1094,7 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 12 graphics primitives .. PLOT:: @@ -1236,7 +1236,7 @@ def superset_digraph(self, loops=False, quotient=False, open_covers=False, point sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') sage: VW = V.union(W) - sage: P = V.superset_digraph(loops=False, upper_bound=VW); P # optional - sage.graphs + sage: P = V.superset_digraph(loops=False, upper_bound=VW); P # needs sage.graphs Digraph on 2 vertices """ @@ -1261,9 +1261,9 @@ def superset_poset(self, open_covers=False, points=False, upper_bound=None): sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') sage: VW = V.union(W) - sage: P = V.superset_poset(); P # optional - sage.graphs + sage: P = V.superset_poset(); P # needs sage.graphs Finite poset containing 3 elements - sage: P.plot(element_labels={element: element._name for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 6 graphics primitives """ @@ -1369,25 +1369,25 @@ def declare_union(self, *subsets_or_families, disjoint=False): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs + sage: P = M.subset_poset(open_covers=True); P # needs sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: AB.declare_union(A, B) sage: A.union(B) Subset AB of the 2-dimensional topological manifold M - sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs + sage: P = M.subset_poset(open_covers=True); P # needs sage.graphs Finite poset containing 4 elements - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: B1 = B.subset('B1', is_open=True) sage: B2 = B.subset('B2', is_open=True) sage: B.declare_union(B1, B2, disjoint=True) - sage: P = M.subset_poset(open_covers=True); P # optional - sage.graphs + sage: P = M.subset_poset(open_covers=True); P # needs sage.graphs Finite poset containing 9 elements - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 19 graphics primitives .. PLOT:: @@ -1495,18 +1495,18 @@ def declare_equal(self, *others): sage: Vs = [M.open_subset(f'V{i}') for i in range(2)] sage: UV = U.intersection(V) sage: W = UV.open_subset('W') - sage: P = M.subset_poset() # optional - sage.graphs + sage: P = M.subset_poset() # needs sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 15 graphics primitives sage: V.declare_equal(Vs) - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 11 graphics primitives sage: W.declare_equal(U) - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 6 graphics primitives .. PLOT:: @@ -1557,16 +1557,16 @@ def declare_subset(self, *supersets): Set {M, V} of open subsets of the 2-dimensional differentiable manifold M sage: U1.subset_family() Set {U1} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs + sage: P = M.subset_poset() # needs sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 8 graphics primitives sage: V.declare_subset(U1, U2) sage: V.superset_family() Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 9 graphics primitives Subsets in a directed cycle of inclusions are equal:: @@ -1576,8 +1576,8 @@ def declare_subset(self, *supersets): Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M sage: M.equal_subset_family() Set {M, U1, U2, V} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 2 graphics primitives .. PLOT:: @@ -1623,16 +1623,16 @@ def declare_superset(self, *subsets): sage: W = V1.intersection(V2) sage: U.subset_family() Set {U} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs + sage: P = M.subset_poset() # needs sage.graphs sage: def label(element): ....: return element._name - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 11 graphics primitives sage: U.declare_superset(V1, V2) sage: U.subset_family() Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 11 graphics primitives Subsets in a directed cycle of inclusions are equal:: @@ -1642,8 +1642,8 @@ def declare_superset(self, *subsets): Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M sage: W.equal_subset_family() Set {U, V1, V1_inter_V2, V2} of open subsets of the 2-dimensional differentiable manifold M - sage: P = M.subset_poset() # optional - sage.graphs - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P = M.subset_poset() # needs sage.graphs + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 4 graphics primitives .. PLOT:: @@ -1726,7 +1726,7 @@ def declare_empty(self): Emptiness is recorded as empty open covers:: - sage: P = M.subset_poset(open_covers=True, points=[b]) # optional - sage.graphs + sage: P = M.subset_poset(open_covers=True, points=[b]) # needs sage.graphs sage: def label(element): ....: if isinstance(element, str): ....: return element @@ -1734,7 +1734,7 @@ def declare_empty(self): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P.plot(element_labels={element: label(element) for element in P}) # optional - sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot Graphics object consisting of 10 graphics primitives .. PLOT:: diff --git a/src/sage/manifolds/subsets/pullback.py b/src/sage/manifolds/subsets/pullback.py index 43a3d9cbf7c..aaa394e48a3 100644 --- a/src/sage/manifolds/subsets/pullback.py +++ b/src/sage/manifolds/subsets/pullback.py @@ -79,25 +79,27 @@ class ManifoldSubsetPullback(ManifoldSubset): Pulling back a polytope under a chart:: - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [2, 1]]); P # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [2, 1]]); P A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: S = ManifoldSubsetPullback(c_cart, P); S # optional - sage.geometry.polyhedron + sage: S = ManifoldSubsetPullback(c_cart, P); S Subset x_y_inv_P of the 2-dimensional topological manifold R^2 - sage: M((1, 2)) in S # optional - sage.geometry.polyhedron + sage: M((1, 2)) in S True - sage: M((2, 0)) in S # optional - sage.geometry.polyhedron + sage: M((2, 0)) in S False Pulling back the interior of a polytope under a chart:: - sage: int_P = P.interior(); int_P # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: int_P = P.interior(); int_P Relative interior of a 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: int_S = ManifoldSubsetPullback(c_cart, int_P, name='int_S'); int_S # optional - sage.geometry.polyhedron + sage: int_S = ManifoldSubsetPullback(c_cart, int_P, name='int_S'); int_S Open subset int_S of the 2-dimensional topological manifold R^2 - sage: M((0, 0)) in int_S # optional - sage.geometry.polyhedron + sage: M((0, 0)) in int_S False - sage: M((1, 1)) in int_S # optional - sage.geometry.polyhedron + sage: M((1, 1)) in int_S True Using the embedding map of a submanifold:: @@ -145,11 +147,11 @@ def __classcall_private__(cls, map, codomain_subset, inverse=None, sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # needs sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: S = ManifoldSubsetPullback(c_cart, P); S # optional - sage.geometry.polyhedron + sage: S = ManifoldSubsetPullback(c_cart, P); S # needs sage.geometry.polyhedron Subset x_y_inv_P of the 2-dimensional topological manifold R^2 - sage: S is ManifoldSubsetPullback(c_cart, P) # optional - sage.geometry.polyhedron + sage: S is ManifoldSubsetPullback(c_cart, P) # needs sage.geometry.polyhedron True """ @@ -249,42 +251,44 @@ def _is_open(codomain_subset): Polyhedra:: - sage: Empty = Polyhedron(ambient_dim=2); Empty # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: Empty = Polyhedron(ambient_dim=2); Empty The empty polyhedron in ZZ^2 - sage: ManifoldSubsetPullback._is_open(Empty) # optional - sage.geometry.polyhedron + sage: ManifoldSubsetPullback._is_open(Empty) True - sage: C = polytopes.cube(); C # optional - sage.geometry.polyhedron + sage: C = polytopes.cube(); C A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: ManifoldSubsetPullback._is_open(C) # optional - sage.geometry.polyhedron + sage: ManifoldSubsetPullback._is_open(C) False Interiors of polyhedra:: - sage: int_C = C.interior(); int_C # optional - sage.geometry.polyhedron + sage: int_C = C.interior(); int_C # needs sage.geometry.polyhedron Relative interior of a 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: ManifoldSubsetPullback._is_open(int_C) # optional - sage.geometry.polyhedron + sage: ManifoldSubsetPullback._is_open(int_C) # needs sage.geometry.polyhedron True PPL polyhedra and not-necessarily-closed polyhedra:: - sage: from ppl import Variable, C_Polyhedron, NNC_Polyhedron, Constraint_System # optional - pplpy - sage: u = Variable(0) # optional - pplpy - sage: v = Variable(1) # optional - pplpy - sage: CS = Constraint_System() # optional - pplpy - sage: CS.insert(0 < u) # optional - pplpy - sage: CS.insert(u < 1) # optional - pplpy - sage: CS.insert(0 < v) # optional - pplpy - sage: CS.insert(v < 1) # optional - pplpy - sage: CS.insert(u + v <= 3) # redundant inequality # optional - pplpy - sage: P = NNC_Polyhedron(CS); P # optional - pplpy + sage: # needs pplpy + sage: from ppl import Variable, C_Polyhedron, NNC_Polyhedron, Constraint_System + sage: u = Variable(0) + sage: v = Variable(1) + sage: CS = Constraint_System() + sage: CS.insert(0 < u) + sage: CS.insert(u < 1) + sage: CS.insert(0 < v) + sage: CS.insert(v < 1) + sage: CS.insert(u + v <= 3) # redundant inequality + sage: P = NNC_Polyhedron(CS); P A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 1 point, 4 closure_points - sage: ManifoldSubsetPullback._is_open(P) # optional - pplpy + sage: ManifoldSubsetPullback._is_open(P) True - sage: CS.insert(u + v <= 1) # optional - pplpy - sage: T = NNC_Polyhedron(CS); T # optional - pplpy + sage: CS.insert(u + v <= 1) + sage: T = NNC_Polyhedron(CS); T A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 1 point, 3 closure_points - sage: ManifoldSubsetPullback._is_open(T) # optional - pplpy + sage: ManifoldSubsetPullback._is_open(T) False """ @@ -461,10 +465,10 @@ def _polyhedron_restriction(expr, polyhedron, relint=False): sage: _polyhedron_restriction = ManifoldSubsetPullback._polyhedron_restriction sage: var('x y z') (x, y, z) - sage: c = polytopes.cube() # optional - sage.geometry.polyhedron - sage: _polyhedron_restriction((x, y, z), c) # optional - sage.geometry.polyhedron + sage: c = polytopes.cube() # needs sage.geometry.polyhedron + sage: _polyhedron_restriction((x, y, z), c) # needs sage.geometry.polyhedron [-x + 1 >= 0, -y + 1 >= 0, -z + 1 >= 0, x + 1 >= 0, z + 1 >= 0, y + 1 >= 0] - sage: _polyhedron_restriction((x, y, z), c, relint=True) # optional - sage.geometry.polyhedron + sage: _polyhedron_restriction((x, y, z), c, relint=True) # needs sage.geometry.polyhedron [-x + 1 > 0, -y + 1 > 0, -z + 1 > 0, x + 1 > 0, z + 1 > 0, y + 1 > 0] """ conjunction = [] @@ -517,11 +521,11 @@ def _coord_def(map, codomain_subset): Coordinate definition of an open chart polyhedron:: sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # needs sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: ri_P = P.relative_interior(); ri_P # optional - sage.geometry.polyhedron + sage: ri_P = P.relative_interior(); ri_P # needs sage.geometry.polyhedron Relative interior of a 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: _coord_def(c_cart, ri_P) # optional - sage.geometry.polyhedron + sage: _coord_def(c_cart, ri_P) # needs sage.geometry.polyhedron {Chart (R^2, (x, y)): [2*x - y > 0, -4*x + 3*y > 0, x - y + 1 > 0]} Coordinate definition of the pullback of an open interval under a scalar field:: @@ -604,20 +608,21 @@ def _an_element_(self): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = McCube.an_element(); p # optional - sage.geometry.polyhedron + sage: p = McCube.an_element(); p # needs sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: p.coordinates(c_cart) # optional - sage.geometry.polyhedron + sage: p.coordinates(c_cart) # needs sage.geometry.polyhedron (0, 0, 0) - sage: Empty = Polyhedron(ambient_dim=3) # optional - sage.geometry.polyhedron - sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') # optional - sage.geometry.polyhedron - sage: McEmpty # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: Empty = Polyhedron(ambient_dim=3) + sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') + sage: McEmpty Subset McEmpty of the 3-dimensional topological manifold R^3 - sage: McEmpty.an_element() # optional - sage.geometry.polyhedron + sage: McEmpty.an_element() Traceback (most recent call last): ... sage.categories.sets_cat.EmptySetError @@ -636,18 +641,18 @@ def some_elements(self): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: L = list(McCube.some_elements()); L # optional - sage.geometry.polyhedron + sage: L = list(McCube.some_elements()); L # needs sage.geometry.polyhedron [Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3] - sage: list(p.coordinates(c_cart) for p in L) # optional - sage.geometry.polyhedron + sage: list(p.coordinates(c_cart) for p in L) # needs sage.geometry.polyhedron [(0, 0, 0), (1, -1, -1), (1, 0, -1), @@ -655,11 +660,12 @@ def some_elements(self): (1, -1/4, 1/2), (0, -5/8, 3/4)] - sage: Empty = Polyhedron(ambient_dim=3) # optional - sage.geometry.polyhedron - sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') # optional - sage.geometry.polyhedron - sage: McEmpty # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: Empty = Polyhedron(ambient_dim=3) + sage: McEmpty = ManifoldSubsetPullback(c_cart, Empty, name='McEmpty') + sage: McEmpty Subset McEmpty of the 3-dimensional topological manifold R^3 - sage: list(McEmpty.some_elements()) # optional - sage.geometry.polyhedron + sage: list(McEmpty.some_elements()) [] """ if self._inverse is not None: @@ -682,9 +688,9 @@ def __contains__(self, point): sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # optional - sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: Cube.vertices_list() # optional - sage.geometry.polyhedron + sage: Cube.vertices_list() # needs sage.geometry.polyhedron [[1, -1, -1], [1, 1, -1], [1, 1, 1], @@ -693,15 +699,15 @@ def __contains__(self, point): [-1, -1, -1], [-1, 1, -1], [-1, 1, 1]] - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # optional - sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = M.point((0, 0, 0)); p # optional - sage.geometry.polyhedron + sage: p = M.point((0, 0, 0)); p # needs sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: p in McCube # optional - sage.geometry.polyhedron + sage: p in McCube # needs sage.geometry.polyhedron True - sage: q = M.point((2, 3, 4)); q # optional - sage.geometry.polyhedron + sage: q = M.point((2, 3, 4)); q # needs sage.geometry.polyhedron Point on the 3-dimensional topological manifold R^3 - sage: q in McCube # optional - sage.geometry.polyhedron + sage: q in McCube # needs sage.geometry.polyhedron False """ if super().__contains__(point): @@ -731,13 +737,14 @@ def is_open(self): sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: P.is_open() # optional - sage.geometry.polyhedron + sage: P.is_open() False - sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # optional - sage.geometry.polyhedron + sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP Subset McP of the 2-dimensional topological manifold R^2 - sage: McP.is_open() # optional - sage.geometry.polyhedron + sage: McP.is_open() False """ return super().is_open() @@ -765,11 +772,11 @@ def is_closed(self): The pullback of a (closed convex) polyhedron under a chart is closed:: - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # optional - sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # needs sage.geometry.polyhedron A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # optional - sage.geometry.polyhedron + sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # needs sage.geometry.polyhedron Subset McP of the 2-dimensional topological manifold R^2 - sage: McP.is_closed() # optional - sage.geometry.polyhedron + sage: McP.is_closed() # needs sage.geometry.polyhedron True The pullback of real vector subspaces under a chart is closed:: From 20c4a73f62ca1b89958cb0785d27a3e0d3940b8b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 23:31:09 -0700 Subject: [PATCH 323/494] sage.manifolds: Add # needs --- src/sage/manifolds/chart.py | 82 +++++++++++-------- src/sage/manifolds/differentiable/curve.py | 2 +- .../differentiable/integrated_curve.py | 58 ++++++++----- .../manifolds/differentiable/vectorfield.py | 26 +++--- src/sage/manifolds/manifold.py | 4 +- src/sage/manifolds/point.py | 27 +++--- src/sage/manifolds/subset.py | 34 ++++---- src/sage/manifolds/utilities.py | 1 + 8 files changed, 135 insertions(+), 99 deletions(-) diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py index 0705d4ecd88..1db4d804fae 100644 --- a/src/sage/manifolds/chart.py +++ b/src/sage/manifolds/chart.py @@ -1165,6 +1165,7 @@ def preimage(self, codomain_subset, name=None, latex_name=None): Pulling back a polytope under a chart:: + sage: # needs sage.geometry.polyhedron sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [2, 1]]); P A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices sage: McP = c_cart.preimage(P); McP @@ -1176,6 +1177,7 @@ def preimage(self, codomain_subset, name=None, latex_name=None): Pulling back the interior of a polytope under a chart:: + sage: # needs sage.geometry.polyhedron sage: int_P = P.interior(); int_P Relative interior of a 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices @@ -1384,6 +1386,7 @@ def zero_function(self): Zero function on a p-adic manifold:: + sage: # needs sage.rings.padics sage: M = Manifold(2, 'M', structure='topological', field=Qp(5)); M 2-dimensional topological manifold M over the 5-adic Field with capped relative precision 20 @@ -1438,6 +1441,7 @@ def one_function(self): One function on a p-adic manifold:: + sage: # needs sage.rings.padics sage: M = Manifold(2, 'M', structure='topological', field=Qp(5)); M 2-dimensional topological manifold M over the 5-adic Field with capped relative precision 20 @@ -2754,10 +2758,9 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, A 2-dimensional chart plotted in terms of itself results in a rectangular grid:: - sage: R2 = Manifold(2, 'R^2', structure='topological') # the Euclidean plane - sage: c_cart. = R2.chart() # Cartesian coordinates - sage: g = c_cart.plot() # equivalent to c_cart.plot(c_cart) - sage: g + sage: R2 = Manifold(2, 'R^2', structure='topological') # the Euclidean plane + sage: c_cart. = R2.chart() # Cartesian coordinates + sage: g = c_cart.plot(); g # equivalent to c_cart.plot(c_cart) # needs sage.plot Graphics object consisting of 18 graphics primitives .. PLOT:: @@ -2770,11 +2773,10 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Grid of polar coordinates in terms of Cartesian coordinates in the Euclidean plane:: - sage: U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)}) # the complement of the segment y=0 and x>0 - sage: c_pol. = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # polar coordinates on U + sage: U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)}) # the complement of the segment y=0 and x>0 + sage: c_pol. = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # polar coordinates on U sage: pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)]) - sage: g = c_pol.plot(c_cart) - sage: g + sage: g = c_pol.plot(c_cart); g # needs sage.plot Graphics object consisting of 18 graphics primitives .. PLOT:: @@ -2789,7 +2791,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Call with non-default values:: - sage: g = c_pol.plot(c_cart, ranges={ph:(pi/4,pi)}, + sage: g = c_pol.plot(c_cart, ranges={ph:(pi/4,pi)}, # needs sage.plot ....: number_values={r:7, ph:17}, ....: color={r:'red', ph:'green'}, ....: style={r:'-', ph:'--'}) @@ -2807,7 +2809,8 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, A single coordinate line can be drawn:: - sage: g = c_pol.plot(c_cart, fixed_coords={r: 2}) # draw a circle of radius r=2 + sage: g = c_pol.plot(c_cart, # draw a circle of radius r=2 # needs sage.plot + ....: fixed_coords={r: 2}) .. PLOT:: @@ -2821,7 +2824,8 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: g = c_pol.plot(c_cart, fixed_coords={ph: pi/4}) # draw a segment at phi=pi/4 + sage: g = c_pol.plot(c_cart, # draw a segment at phi=pi/4 # needs sage.plot + ....: fixed_coords={ph: pi/4}) .. PLOT:: @@ -2838,24 +2842,23 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, argument ``mapping``): 3D plot of the stereographic charts on the 2-sphere:: - sage: S2 = Manifold(2, 'S^2', structure='topological') # the 2-sphere - sage: U = S2.open_subset('U') ; V = S2.open_subset('V') # complement of the North and South pole, respectively + sage: S2 = Manifold(2, 'S^2', structure='topological') # the 2-sphere + sage: U = S2.open_subset('U'); V = S2.open_subset('V') # complement of the North and South pole, respectively sage: S2.declare_union(U,V) - sage: c_xy. = U.chart() # stereographic coordinates from the North pole - sage: c_uv. = V.chart() # stereographic coordinates from the South pole + sage: c_xy. = U.chart() # stereographic coordinates from the North pole + sage: c_uv. = V.chart() # stereographic coordinates from the South pole sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)), ....: intersection_name='W', restrictions1= x^2+y^2!=0, ....: restrictions2= u^2+v^2!=0) sage: uv_to_xy = xy_to_uv.inverse() - sage: R3 = Manifold(3, 'R^3', structure='topological') # the Euclidean space R^3 + sage: R3 = Manifold(3, 'R^3', structure='topological') # the Euclidean space R^3 sage: c_cart. = R3.chart() # Cartesian coordinates on R^3 sage: Phi = S2.continuous_map(R3, {(c_xy, c_cart): [2*x/(1+x^2+y^2), ....: 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)], ....: (c_uv, c_cart): [2*u/(1+u^2+v^2), ....: 2*v/(1+u^2+v^2), (1-u^2-v^2)/(1+u^2+v^2)]}, - ....: name='Phi', latex_name=r'\Phi') # Embedding of S^2 in R^3 - sage: g = c_xy.plot(c_cart, mapping=Phi) - sage: g + ....: name='Phi', latex_name=r'\Phi') # Embedding of S^2 in R^3 + sage: g = c_xy.plot(c_cart, mapping=Phi); g # needs sage.plot Graphics3d Object .. PLOT:: @@ -2885,12 +2888,12 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, The same plot without the ``(X,Y,Z)`` axes labels:: - sage: g = c_xy.plot(c_cart, mapping=Phi, label_axes=False) + sage: g = c_xy.plot(c_cart, mapping=Phi, label_axes=False) # needs sage.plot The North and South stereographic charts on the same plot:: - sage: g2 = c_uv.plot(c_cart, mapping=Phi, color='green') - sage: g + g2 + sage: g2 = c_uv.plot(c_cart, mapping=Phi, color='green') # needs sage.plot + sage: g + g2 # needs sage.plot Graphics3d Object .. PLOT:: @@ -2915,16 +2918,17 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, g2 = c_uv.plot(c_cart, mapping=Phi, color='green') sphinx_plot(g+g2) - South stereographic chart drawned in terms of the North one (we split + South stereographic chart drawn in terms of the North one (we split the plot in four parts to avoid the singularity at `(u,v)=(0,0)`):: + sage: # long time, needs sage.plot sage: W = U.intersection(V) # the subset common to both charts sage: c_uvW = c_uv.restrict(W) # chart (W,(u,v)) - sage: gSN1 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[-6.,-0.02]}) # long time - sage: gSN2 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[0.02,6.]}) # long time - sage: gSN3 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[-6.,-0.02]}) # long time - sage: gSN4 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[0.02,6.]}) # long time - sage: show(gSN1+gSN2+gSN3+gSN4, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5) # long time + sage: gSN1 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[-6.,-0.02]}) + sage: gSN2 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[0.02,6.]}) + sage: gSN3 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[-6.,-0.02]}) + sage: gSN4 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[0.02,6.]}) + sage: show(gSN1+gSN2+gSN3+gSN4, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5) .. PLOT:: @@ -2947,9 +2951,12 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, The coordinate line `u = 1` (red) and the coordinate line `v = 1` (green) on the same plot:: - sage: gu1 = c_uvW.plot(c_xy, fixed_coords={u: 1}, max_range=20, plot_points=300) # long time - sage: gv1 = c_uvW.plot(c_xy, fixed_coords={v: 1}, max_range=20, plot_points=300, color='green') # long time - sage: gu1 + gv1 # long time + sage: # long time, needs sage.plot + sage: gu1 = c_uvW.plot(c_xy, fixed_coords={u: 1}, max_range=20, + ....: plot_points=300) + sage: gv1 = c_uvW.plot(c_xy, fixed_coords={v: 1}, max_range=20, + ....: plot_points=300, color='green') + sage: gu1 + gv1 Graphics object consisting of 2 graphics primitives .. PLOT:: @@ -2975,8 +2982,9 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, A 3-dimensional chart plotted in terms of itself results in a 3D rectangular grid:: - sage: g = c_cart.plot() # equivalent to c_cart.plot(c_cart) # long time - sage: g # long time + sage: # long time, needs sage.plot + sage: g = c_cart.plot() # equivalent to c_cart.plot(c_cart) + sage: g Graphics3d Object .. PLOT:: @@ -2989,10 +2997,11 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, performed for at most 3 coordinates, which must be specified via the argument ``ambient_coords``):: + sage: # long time, needs sage.plot sage: M = Manifold(4, 'M', structure='topological') sage: X. = M.chart() - sage: g = X.plot(ambient_coords=(t,x,y)) # the coordinate z is not depicted # long time - sage: g # long time + sage: g = X.plot(ambient_coords=(t,x,y)) # the coordinate z is not depicted + sage: g Graphics3d Object .. PLOT:: @@ -3004,7 +3013,8 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: g = X.plot(ambient_coords=(t,y)) # the coordinates x and z are not depicted + sage: # needs sage.plot + sage: g = X.plot(ambient_coords=(t,y)) # the coordinates x and z are not depicted sage: g Graphics object consisting of 18 graphics primitives diff --git a/src/sage/manifolds/differentiable/curve.py b/src/sage/manifolds/differentiable/curve.py index fd77c39dfc4..7ea264565ae 100644 --- a/src/sage/manifolds/differentiable/curve.py +++ b/src/sage/manifolds/differentiable/curve.py @@ -94,7 +94,7 @@ class DifferentiableCurve(DiffMap): A graphical view of the curve is provided by the method :meth:`plot`:: - sage: c.plot(aspect_ratio=1) + sage: c.plot(aspect_ratio=1) # needs sage.plot Graphics object consisting of 1 graphics primitive .. PLOT:: diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py index 023c91112df..fe2a6dcb3cc 100644 --- a/src/sage/manifolds/differentiable/integrated_curve.py +++ b/src/sage/manifolds/differentiable/integrated_curve.py @@ -41,11 +41,13 @@ Numerically integrate the geodesic (see :meth:`~IntegratedCurve.solve` for all possible options, including the choice of the numerical algorithm):: - sage: sol = c.solve() + sage: sol = c.solve() # needs scipy Plot the geodesic after interpolating the solution ``sol``:: sage: interp = c.interpolate() + + sage: # needs sage.plot sage: graph = c.plot_integrated() sage: p_plot = p.plot(size=30, label_offset=-0.07, fontsize=20) sage: v_plot = v.plot(label_offset=0.05, fontsize=20) @@ -230,7 +232,7 @@ class IntegratedCurve(DifferentiableCurve): Generate a solution of the system and an interpolation of this solution:: - sage: sol = c.solve(step=0.2, + sage: sol = c.solve(step=0.2, # needs scipy ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}, ....: solution_key='carac time 1', verbose=True) Performing numerical integration with method 'odeint'... @@ -242,7 +244,7 @@ class IntegratedCurve(DifferentiableCurve): The resulting list of points was associated with the key 'carac time 1' (if this key already referred to a former numerical solution, such a solution was erased). - sage: interp = c.interpolate(solution_key='carac time 1', + sage: interp = c.interpolate(solution_key='carac time 1', # needs scipy ....: interpolation_key='interp 1', verbose=True) Performing cubic spline interpolation by default... Interpolation completed and associated with the key 'interp 1' @@ -252,6 +254,7 @@ class IntegratedCurve(DifferentiableCurve): Such an interpolation is required to evaluate the curve and the vector tangent to the curve for any value of the curve parameter:: + sage: # needs scipy sage: p = c(1.9, verbose=True) Evaluating point coordinates from the interpolation associated with the key 'interp 1' by default... @@ -271,7 +274,7 @@ class IntegratedCurve(DifferentiableCurve): Plotting a numerical solution (with or without its tangent vector field) also requires the solution to be interpolated at least once:: - sage: c_plot_2d_1 = c.plot_integrated(ambient_coords=[x1, x2], + sage: c_plot_2d_1 = c.plot_integrated(ambient_coords=[x1, x2], # needs scipy ....: interpolation_key='interp 1', thickness=2.5, ....: display_tangent=True, plot_points=200, ....: plot_points_tangent=10, scale=0.5, @@ -280,7 +283,7 @@ class IntegratedCurve(DifferentiableCurve): A tiny final offset equal to 0.000251256281407035 was introduced for the last point in order to safely compute it from the interpolation. - sage: c_plot_2d_1 + sage: c_plot_2d_1 # needs scipy sage.plot Graphics object consisting of 11 graphics primitives .. PLOT:: @@ -310,22 +313,23 @@ class IntegratedCurve(DifferentiableCurve): An instance of :class:`IntegratedCurve` may store several numerical solutions and interpolations:: + sage: # needs scipy sage: sol = c.solve(step=0.2, ....: parameters_values={B_0:1, m:1, q:1, L:10, T:100}, ....: solution_key='carac time 100') sage: interp = c.interpolate(solution_key='carac time 100', ....: interpolation_key='interp 100') - sage: c_plot_3d_100 = c.plot_integrated(interpolation_key='interp 100', + sage: c_plot_3d_100 = c.plot_integrated(interpolation_key='interp 100', # needs sage.plot ....: thickness=2.5, display_tangent=True, ....: plot_points=200, plot_points_tangent=10, ....: scale=0.5, color='green', ....: color_tangent='orange') - sage: c_plot_3d_1 = c.plot_integrated(interpolation_key='interp 1', + sage: c_plot_3d_1 = c.plot_integrated(interpolation_key='interp 1', # needs sage.plot ....: thickness=2.5, display_tangent=True, ....: plot_points=200, plot_points_tangent=10, ....: scale=0.5, color='blue', ....: color_tangent='red') - sage: c_plot_3d_1 + c_plot_3d_100 + sage: c_plot_3d_1 + c_plot_3d_100 # needs sage.plot Graphics3d Object .. PLOT:: @@ -1004,7 +1008,7 @@ def solve(self, step=None, method='odeint', solution_key=None, sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') - sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, + sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, # needs scipy ....: verbose=True) Performing numerical integration with method 'odeint'... Resulting list of points will be associated with the key @@ -1020,38 +1024,38 @@ def solve(self, step=None, method='odeint', solution_key=None, The first 3 points of the solution, in the form ``[t, x1, x2, x3]``:: - sage: sol[:3] # abs tol 1e-12 + sage: sol[:3] # abs tol 1e-12 # needs scipy [[0.0, 0.0, 0.0, 0.0], [0.05, 0.04999999218759271, -2.083327338392213e-05, 0.05], [0.1, 0.09999975001847655, -0.00016666146190783666, 0.1]] The default is ``verbose=False``:: - sage: sol_mute = c.solve(parameters_values={B_0:1, m:1, q:1, + sage: sol_mute = c.solve(parameters_values={B_0:1, m:1, q:1, # needs scipy ....: L:10, T:1}) - sage: sol_mute == sol + sage: sol_mute == sol # needs scipy True Specifying the relative and absolute error tolerance parameters to be used in :func:`~sage.calculus.desolvers.desolve_odeint`:: - sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, + sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, # needs scipy ....: rtol=1e-12, atol=1e-12) Using a numerical method different from the default one:: - sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, + sage: sol = c.solve(parameters_values={B_0:1, m:1, q:1, L:10, T:1}, # needs scipy ....: method='rk8pd') TESTS:: - sage: sol = c.solve(parameters_values={m:1, q:1, L:10, T:1}) + sage: sol = c.solve(parameters_values={m:1, q:1, L:10, T:1}) # needs scipy Traceback (most recent call last): ... ValueError: numerical values should be provided for each of the parameters [B_0, L, T, m, q] - sage: sol = c.solve(method='my method', + sage: sol = c.solve(method='my method', # needs scipy ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) Traceback (most recent call last): ... @@ -1492,9 +1496,9 @@ def solve_across_charts(self, charts=None, step=None, solution_key=None, mapping:: sage: phi = M.diff_map(M, {(C,C): [x, y], (P,C): [r*cos(th), r*sin(th)]}) - sage: fig = P.plot(number_values=9, chart=C, mapping=phi, + sage: fig = P.plot(number_values=9, chart=C, mapping=phi, # needs sage.plot ....: color='grey', ranges= {r:(2, 6), th:(0,2*pi)}) - sage: fig += C.plot(number_values=13, chart=C, mapping=phi, + sage: fig += C.plot(number_values=13, chart=C, mapping=phi, # needs sage.plot ....: color='grey', ranges= {x:(-3, 3), y:(-3, 3)}) There is a clear non-empty intersection between the two @@ -1562,9 +1566,9 @@ def solve_across_charts(self, charts=None, step=None, solution_key=None, :meth:`plot_integrated` again on each part. Finally, ``color`` can be a list, which will be cycled through:: - sage: fig += c.plot_integrated(mapping=phi, color=["green","red"], + sage: fig += c.plot_integrated(mapping=phi, color=["green","red"], # needs sage.plot ....: thickness=3, plot_points=100, across_charts=True) - sage: fig + sage: fig # needs sage.plot Graphics object consisting of 43 graphics primitives .. PLOT:: @@ -1859,6 +1863,8 @@ def solution(self, solution_key=None, verbose=False): sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') + + sage: # needs scipy sage: sol = c.solve(solution_key='sol_T1', ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) sage: sol_bis = c.solution(verbose=True) @@ -1931,6 +1937,8 @@ def interpolate(self, solution_key=None, method=None, sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') + + sage: # needs scipy sage: sol = c.solve(method='odeint', ....: solution_key='sol_T1', ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) @@ -2060,6 +2068,8 @@ def interpolation(self, interpolation_key=None, verbose=False): sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') + + sage: # needs scipy sage: sol = c.solve(method='odeint', ....: solution_key='sol_T1', ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) @@ -2134,6 +2144,8 @@ def __call__(self, t, interpolation_key=None, sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') + + sage: # needs scipy sage: sol = c.solve(method='odeint', ....: solution_key='sol_T1', ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) @@ -2216,6 +2228,8 @@ def tangent_vector_eval_at(self, t, sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,5), v, name='c') + + sage: # needs scipy sage: sol = c.solve(method='odeint', ....: solution_key='sol_T1', ....: parameters_values={B_0:1, m:1, q:1, L:10, T:1}) @@ -2330,6 +2344,8 @@ def plot_integrated(self, chart=None, ambient_coords=None, sage: Tp = M.tangent_space(p) sage: v = Tp((1,0,1)) sage: c = M.integrated_curve(eqns, D, (t,0,6), v, name='c') + + sage: # needs scipy sage: sol = c.solve() sage: interp = c.interpolate() sage: c_plot_2d = c.plot_integrated(ambient_coords=[x1, x2], @@ -3759,6 +3775,7 @@ class IntegratedGeodesic(IntegratedAutoparallelCurve): Solve, interpolate and prepare the plot for the solutions corresponding to the three initial conditions previously set:: + sage: # needs scipy sage.plot sage: graph3D_embedded_geods = Graphics() sage: for key in dict_params: ....: sol = c.solve(solution_key='sol-'+key, @@ -3773,6 +3790,7 @@ class IntegratedGeodesic(IntegratedAutoparallelCurve): Plot the resulting geodesics on the grid of polar coordinates lines on `\mathbb{S}^{2}` and check that these are great circles:: + sage: # needs scipy sage.plot sage: graph3D_embedded_polar_coords = polar.plot(chart=cart, ....: mapping=euclid_embedding, ....: number_values=15, color='yellow') diff --git a/src/sage/manifolds/differentiable/vectorfield.py b/src/sage/manifolds/differentiable/vectorfield.py index 22b5df5717f..04018ba9916 100644 --- a/src/sage/manifolds/differentiable/vectorfield.py +++ b/src/sage/manifolds/differentiable/vectorfield.py @@ -465,7 +465,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, sage: v = M.vector_field(-y, x, name='v') sage: v.display() v = -y ∂/∂x + x ∂/∂y - sage: v.plot() + sage: v.plot() # needs sage.plot Graphics object consisting of 80 graphics primitives .. PLOT:: @@ -478,7 +478,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Plot with various options:: - sage: v.plot(scale=0.5, color='green', linestyle='--', width=1, + sage: v.plot(scale=0.5, color='green', linestyle='--', width=1, # needs sage.plot ....: arrowsize=6) Graphics object consisting of 80 graphics primitives @@ -492,7 +492,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: v.plot(max_range=4, number_values=5, scale=0.5) + sage: v.plot(max_range=4, number_values=5, scale=0.5) # needs sage.plot Graphics object consisting of 24 graphics primitives .. PLOT:: @@ -506,7 +506,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Plot using parallel computation:: sage: Parallelism().set(nproc=2) - sage: v.plot(scale=0.5, number_values=10, linestyle='--', width=1, + sage: v.plot(scale=0.5, number_values=10, linestyle='--', width=1, # needs sage.plot ....: arrowsize=6) Graphics object consisting of 100 graphics primitives @@ -524,7 +524,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Plots along a line of fixed coordinate:: - sage: v.plot(fixed_coords={x: -2}) + sage: v.plot(fixed_coords={x: -2}) # needs sage.plot Graphics object consisting of 9 graphics primitives .. PLOT:: @@ -537,7 +537,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: v.plot(fixed_coords={y: 1}) + sage: v.plot(fixed_coords={y: 1}) # needs sage.plot Graphics object consisting of 9 graphics primitives .. PLOT:: @@ -566,7 +566,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Rather, we have to select some coordinates for the plot, via the argument ``ambient_coords``. For instance, for a 3D plot:: - sage: v.plot(ambient_coords=(x, y, z), fixed_coords={t: 1}, # long time + sage: v.plot(ambient_coords=(x, y, z), fixed_coords={t: 1}, # long time, needs sage.plot ....: number_values=4) Graphics3d Object @@ -580,7 +580,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: v.plot(ambient_coords=(x, y, t), fixed_coords={z: 0}, # long time + sage: v.plot(ambient_coords=(x, y, t), fixed_coords={z: 0}, # long time, needs sage.plot ....: ranges={x: (-2,2), y: (-2,2), t: (-1, 4)}, ....: number_values=4) Graphics3d Object @@ -596,7 +596,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, or, for a 2D plot:: - sage: v.plot(ambient_coords=(x, y), fixed_coords={t: 1, z: 0}) # long time + sage: v.plot(ambient_coords=(x, y), fixed_coords={t: 1, z: 0}) # long time, needs sage.plot Graphics object consisting of 80 graphics primitives .. PLOT:: @@ -609,7 +609,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: v.plot(ambient_coords=(x, t), fixed_coords={y: 1, z: 0}) # long time + sage: v.plot(ambient_coords=(x, t), fixed_coords={y: 1, z: 0}) # long time, needs sage.plot Graphics object consisting of 72 graphics primitives .. PLOT:: @@ -636,9 +636,9 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, sage: v = XS.frame()[1] ; v # the coordinate vector ∂/∂phi Vector field ∂/∂ph on the Open subset U of the 2-dimensional differentiable manifold S^2 - sage: graph_v = v.plot(chart=X3, mapping=F, label_axes=False) - sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9) - sage: graph_v + graph_S2 + sage: graph_v = v.plot(chart=X3, mapping=F, label_axes=False) # needs sage.plot + sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9) # needs sage.plot + sage: graph_v + graph_S2 # needs sage.plot Graphics3d Object .. PLOT:: diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py index b19177da9e5..0e09530ad54 100644 --- a/src/sage/manifolds/manifold.py +++ b/src/sage/manifolds/manifold.py @@ -455,7 +455,7 @@ class being :class:`~sage.manifolds.point.ManifoldPoint`. A manifold over `\QQ_5`, the field of 5-adic numbers:: - sage: N = Manifold(2, 'N', structure='topological', field=Qp(5)); N + sage: N = Manifold(2, 'N', structure='topological', field=Qp(5)); N # needs sage.rings.padics 2-dimensional topological manifold N over the 5-adic Field with capped relative precision 20 @@ -474,7 +474,7 @@ class being :class:`~sage.manifolds.point.ManifoldPoint`. True sage: M in Manifolds(RR) True - sage: N in Manifolds(Qp(5)) + sage: N in Manifolds(Qp(5)) # needs sage.rings.padics True The corresponding Sage *elements* are points:: diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py index 728269ed5ea..c2f030f6f45 100644 --- a/src/sage/manifolds/point.py +++ b/src/sage/manifolds/point.py @@ -803,6 +803,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Drawing a point on a 2-dimensional manifold:: + sage: # needs sage.plot sage: M = Manifold(2, 'M', structure='topological') sage: X. = M.chart() sage: p = M.point((1,3), name='p') @@ -826,12 +827,14 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, ``p`` has been defined, it can be skipped in the arguments of ``plot``:: + sage: # needs sage.plot sage: g = p.plot() sage: g + gX Graphics object consisting of 20 graphics primitives Call with some options:: + sage: # needs sage.plot sage: g = p.plot(chart=X, size=40, color='green', label='$P$', ....: label_color='blue', fontsize=20, label_offset=0.3) sage: g + gX @@ -851,9 +854,9 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, symbolic variable:: sage: a = var('a') - sage: q = M.point((a,2*a), name='q') - sage: gq = q.plot(parameters={a:-2}, label_offset=0.2) - sage: g + gX + gq + sage: q = M.point((a,2*a), name='q') # needs sage.plot + sage: gq = q.plot(parameters={a:-2}, label_offset=0.2) # needs sage.plot + sage: g + gX + gq # needs sage.plot Graphics object consisting of 22 graphics primitives .. PLOT:: @@ -871,11 +874,12 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, The numerical value is used only for the plot:: - sage: q.coord() + sage: q.coord() # needs sage.plot (a, 2*a) Drawing a point on a 3-dimensional manifold:: + sage: # needs sage.plot sage: M = Manifold(3, 'M', structure='topological') sage: X. = M.chart() sage: p = M.point((2,1,3), name='p') @@ -888,31 +892,32 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Call with some options:: - sage: g = p.plot(chart=X, size=40, color='green', label='P_1', + sage: g = p.plot(chart=X, size=40, color='green', label='P_1', # needs sage.plot ....: label_color='blue', fontsize=20, label_offset=0.3) - sage: g + gX + sage: g + gX # needs sage.plot Graphics3d Object An example of plot via a mapping: plot of a point on a 2-sphere viewed in the 3-dimensional space ``M``:: sage: S2 = Manifold(2, 'S^2', structure='topological') - sage: U = S2.open_subset('U') # the open set covered by spherical coord. + sage: U = S2.open_subset('U') # the open set covered by spherical coord. sage: XS. = U.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi') sage: p = U.point((pi/4, pi/8), name='p') - sage: F = S2.continuous_map(M, {(XS, X): [sin(th)*cos(ph), + sage: F = S2.continuous_map(M, {(XS, X): [sin(th)*cos(ph), # needs sage.plot ....: sin(th)*sin(ph), cos(th)]}, name='F') sage: F.display() F: S^2 → M on U: (th, ph) ↦ (x, y, z) = (cos(ph)*sin(th), sin(ph)*sin(th), cos(th)) - sage: g = p.plot(chart=X, mapping=F) - sage: gS2 = XS.plot(chart=X, mapping=F, number_values=9) - sage: g + gS2 + sage: g = p.plot(chart=X, mapping=F) # needs sage.plot + sage: gS2 = XS.plot(chart=X, mapping=F, number_values=9) # needs sage.plot + sage: g + gS2 # needs sage.plot Graphics3d Object Use of the option ``ambient_coords`` for plots on a 4-dimensional manifold:: + sage: # needs sage.plot sage: M = Manifold(4, 'M', structure='topological') sage: X. = M.chart() sage: p = M.point((1,2,3,4), name='p') diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py index 4f02cd2e97e..cd98b143037 100644 --- a/src/sage/manifolds/subset.py +++ b/src/sage/manifolds/subset.py @@ -897,9 +897,10 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= EXAMPLES:: + sage: # needs sage.graphs sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: D = M.subset_digraph(); D # needs sage.graphs + sage: D = M.subset_digraph(); D Digraph on 4 vertices sage: D.edges(sort=True, key=lambda e: (e[0]._name, e[1]._name)) # needs sage.graphs [(Set {U} of open subsets of the 3-dimensional differentiable manifold M, @@ -911,20 +912,19 @@ def subset_digraph(self, loops=False, quotient=False, open_covers=False, points= (Set {W} of open subsets of the 3-dimensional differentiable manifold M, Set {M} of open subsets of the 3-dimensional differentiable manifold M, None)] - sage: D.plot(layout='acyclic') # needs sage.graphs sage.plot + sage: D.plot(layout='acyclic') # needs sage.plot Graphics object consisting of 8 graphics primitives sage: def label(element): ....: try: ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.graphs sage.plot + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.plot Graphics object consisting of 8 graphics primitives - sage: VW = V.union(W) - sage: D = M.subset_digraph(); D # needs sage.graphs + sage: D = M.subset_digraph(); D Digraph on 5 vertices - sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.graphs sage.plot + sage: D.relabel(label, inplace=False).plot(layout='acyclic') # needs sage.plot Graphics object consisting of 12 graphics primitives If ``open_covers`` is ``True``, the digraph includes a special vertex for @@ -1057,35 +1057,37 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): EXAMPLES:: + sage: # needs sage.graphs sage: M = Manifold(3, 'M') sage: U = M.open_subset('U'); V = M.open_subset('V'); W = M.open_subset('W') - sage: P = M.subset_poset(); P # needs sage.graphs + sage: P = M.subset_poset(); P Finite poset containing 4 elements - sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.graphs sage.plot + sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.plot Graphics object consisting of 8 graphics primitives sage: VW = V.union(W) - sage: P = M.subset_poset(); P # needs sage.graphs + sage: P = M.subset_poset(); P Finite poset containing 5 elements - sage: P.maximal_elements() # needs sage.graphs + sage: P.maximal_elements() [Set {M} of open subsets of the 3-dimensional differentiable manifold M] - sage: sorted(P.minimal_elements(), key=lambda v: v._name) # needs sage.graphs + sage: sorted(P.minimal_elements(), key=lambda v: v._name) [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M] sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) # needs sage.graphs + sage: sorted(P.lower_covers(ManifoldSubsetFiniteFamily([M])), key=str) [Set {U} of open subsets of the 3-dimensional differentiable manifold M, Set {V_union_W} of open subsets of the 3-dimensional differentiable manifold M] - sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.graphs sage.plot + sage: P.plot(element_labels={element: element._name for element in P}) # needs sage.plot Graphics object consisting of 10 graphics primitives If ``open_covers`` is ``True``, the poset includes a special vertex for each nontrivial open cover of a subset:: - sage: P = M.subset_poset(open_covers=True); P # needs sage.graphs + sage: # needs sage.graphs + sage: P = M.subset_poset(open_covers=True); P Finite poset containing 6 elements sage: from sage.manifolds.subset import ManifoldSubsetFiniteFamily - sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) # needs sage.graphs + sage: sorted(P.upper_covers(ManifoldSubsetFiniteFamily([VW])), key=str) [(Set {V} of open subsets of the 3-dimensional differentiable manifold M, Set {W} of open subsets of the 3-dimensional differentiable manifold M), Set {M} of open subsets of the 3-dimensional differentiable manifold M] @@ -1094,7 +1096,7 @@ def subset_poset(self, open_covers=False, points=False, lower_bound=None): ....: return element._name ....: except AttributeError: ....: return '[' + ', '.join(sorted(x._name for x in element)) + ']' - sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.graphs sage.plot + sage: P.plot(element_labels={element: label(element) for element in P}) # needs sage.plot Graphics object consisting of 12 graphics primitives .. PLOT:: diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py index 4b7c21532aa..c15a98ebbce 100644 --- a/src/sage/manifolds/utilities.py +++ b/src/sage/manifolds/utilities.py @@ -1270,6 +1270,7 @@ def set_axes_labels(graph, xlabel, ylabel, zlabel, **kwds): EXAMPLES:: + sage: # needs sage.plot sage: g = sphere() sage: g.all [Graphics3d Object] From 7c4f078213f2eae1b113fc30a2e798982e310949 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 21:48:51 -0700 Subject: [PATCH 324/494] sage.manifolds: Fix # needs --- .../differentiable/tangent_vector.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/sage/manifolds/differentiable/tangent_vector.py b/src/sage/manifolds/differentiable/tangent_vector.py index 5fc2506b1d0..640178b1f64 100644 --- a/src/sage/manifolds/differentiable/tangent_vector.py +++ b/src/sage/manifolds/differentiable/tangent_vector.py @@ -261,12 +261,12 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Plot of the vector alone (arrow + label):: - sage: v.plot() + sage: v.plot() # needs sage.plot Graphics object consisting of 2 graphics primitives Plot atop of the chart grid:: - sage: X.plot() + v.plot() + sage: X.plot() + v.plot() # needs sage.plot Graphics object consisting of 20 graphics primitives .. PLOT:: @@ -280,7 +280,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Plots with various options:: - sage: X.plot() + v.plot(color='green', scale=2, label='V') + sage: X.plot() + v.plot(color='green', scale=2, label='V') # needs sage.plot Graphics object consisting of 20 graphics primitives .. PLOT:: @@ -294,7 +294,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: X.plot() + v.plot(print_label=False) + sage: X.plot() + v.plot(print_label=False) # needs sage.plot Graphics object consisting of 19 graphics primitives .. PLOT:: @@ -308,7 +308,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: X.plot() + v.plot(color='green', label_color='black', + sage: X.plot() + v.plot(color='green', label_color='black', # needs sage.plot ....: fontsize=20, label_offset=0.2) Graphics object consisting of 20 graphics primitives @@ -323,7 +323,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, :: - sage: X.plot() + v.plot(linestyle=':', width=4, arrowsize=8, + sage: X.plot() + v.plot(linestyle=':', width=4, arrowsize=8, # needs sage.plot ....: fontsize=20) Graphics object consisting of 20 graphics primitives @@ -342,7 +342,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, (a, b) sage: v = Tp((1+a, -b^2), name='v') ; v.display() v = (a + 1) ∂/∂x - b^2 ∂/∂y - sage: X.plot() + v.plot(parameters={a: -2, b: 3}) + sage: X.plot() + v.plot(parameters={a: -2, b: 3}) # needs sage.plot Graphics object consisting of 20 graphics primitives Special case of the zero vector:: @@ -350,7 +350,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, sage: v = Tp.zero() ; v Tangent vector zero at Point p on the 2-dimensional differentiable manifold M - sage: X.plot() + v.plot() + sage: X.plot() + v.plot() # needs sage.plot Graphics object consisting of 19 graphics primitives Vector tangent to a 4-dimensional manifold:: @@ -365,7 +365,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, We cannot make a 4D plot directly:: - sage: v.plot() + sage: v.plot() # needs sage.plot Traceback (most recent call last): ... ValueError: the number of coordinates involved in the plot must @@ -375,7 +375,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, the argument ``ambient_coords``. For instance, for a 2-dimensional plot in terms of the coordinates `(x, y)`:: - sage: v.plot(ambient_coords=(x,y)) + sage: v.plot(ambient_coords=(x,y)) # needs sage.plot Graphics object consisting of 2 graphics primitives .. PLOT:: @@ -391,14 +391,14 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, Similarly, for a 3-dimensional plot in terms of the coordinates `(t, x, y)`:: - sage: g = v.plot(ambient_coords=(t,x,z)) - sage: print(g) + sage: g = v.plot(ambient_coords=(t,x,z)) # needs sage.plot + sage: print(g) # needs sage.plot Graphics3d Object This plot involves only the components `v^t`, `v^x` and `v^z` of `v`. A nice 3D view atop the coordinate grid is obtained via:: - sage: (X.plot(ambient_coords=(t,x,z)) # long time + sage: (X.plot(ambient_coords=(t,x,z)) # long time # needs sage.plot ....: + v.plot(ambient_coords=(t,x,z), ....: label_offset=0.5, width=6)) Graphics3d Object @@ -431,8 +431,8 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, sage: v = XS.frame()[1].at(p) ; v # the coordinate vector ∂/∂phi at p Tangent vector ∂/∂ph at Point p on the 2-dimensional differentiable manifold S^2 - sage: graph_v = v.plot(mapping=F) - sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9) # long time + sage: graph_v = v.plot(mapping=F) # needs sage.plot + sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9) # long time, needs sage.plot sage: graph_v + graph_S2 # long time Graphics3d Object From b9cc9d2f38933a0997569d77799503a699db1b13 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 13:48:28 -0700 Subject: [PATCH 325/494] src/sage/manifolds/chart.py: Fix up # long --- src/sage/manifolds/chart.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py index 1db4d804fae..e625299a6cc 100644 --- a/src/sage/manifolds/chart.py +++ b/src/sage/manifolds/chart.py @@ -2997,11 +2997,11 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, performed for at most 3 coordinates, which must be specified via the argument ``ambient_coords``):: - sage: # long time, needs sage.plot + sage: # needs sage.plot sage: M = Manifold(4, 'M', structure='topological') sage: X. = M.chart() - sage: g = X.plot(ambient_coords=(t,x,y)) # the coordinate z is not depicted - sage: g + sage: g = X.plot(ambient_coords=(t,x,y)) # the coordinate z is not depicted # long time + sage: g # long time Graphics3d Object .. PLOT:: From 0251bc7af88f12a757dd20575907e5605fc71b96 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Mar 2023 21:38:40 -0800 Subject: [PATCH 326/494] Add # optional - numpy etc. --- src/sage/numerical/optimize.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index f728b2ad89f..da6c58cd4ef 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -371,9 +371,9 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", sage: def rosen(x): # The Rosenbrock function ....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r) - sage: import numpy - sage: from numpy import zeros - sage: def rosen_der(x): + sage: import numpy # optional - numpy + sage: from numpy import zeros # optional - numpy + sage: def rosen_der(x): # optional - numpy ....: xm = x[1r:-1r] ....: xm_m1 = x[:-2r] ....: xm_p1 = x[2r:] @@ -382,7 +382,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", ....: der[0] = -400r*x[0r]*(x[1r]-x[0r]**2r) - 2r*(1r-x[0]) ....: der[-1] = 200r*(x[-1r]-x[-2r]**2r) ....: return der - sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, algorithm="bfgs") # abs tol 1e-6 + sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, algorithm="bfgs") # abs tol 1e-6 # optional - numpy (1.0, 1.0, 1.0) """ from sage.structure.element import Expression From 9dbe6fda3370cff4269037fc804ae8befe6e9194 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 11 Mar 2023 00:11:54 -0800 Subject: [PATCH 327/494] sage.numerical: More # optional --- src/sage/numerical/backends/ppl_backend.pyx | 3 ++- src/sage/numerical/sdp.pyx | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index f437527e42c..7d55ba35137 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - pplpy """ PPL Backend @@ -61,7 +62,7 @@ cdef class PPLBackend(GenericBackend): Raise an error if a ``base_ring`` is requested that is not supported:: - sage: p = MixedIntegerLinearProgram(solver = "PPL", base_ring=AA) + sage: p = MixedIntegerLinearProgram(solver="PPL", base_ring=AA) # optional - sage.rings.number_field Traceback (most recent call last): ... TypeError: The PPL backend only supports rational data. diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index e7b96a2abef..f0c174f5ed2 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -116,18 +116,18 @@ matrices `C-\sum_k x_k A_k`, cf. (Primal problem) above, available via More interesting example, the :func:`Lovasz theta ` of the 7-gon:: - sage: c=graphs.CycleGraph(7) - sage: c2=c.distance_graph(2).adjacency_matrix() - sage: c3=c.distance_graph(3).adjacency_matrix() - sage: p.=SemidefiniteProgram() - sage: p.add_constraint((1/7)*matrix.identity(7)>=-y[0]*c2-y[1]*c3) - sage: p.set_objective(y[0]*(c2**2).trace()+y[1]*(c3**2).trace()) - sage: x=p.solve(); x+1 # optional - cvxopt + sage: c = graphs.CycleGraph(7) # optional - sage.graphs + sage: c2 = c.distance_graph(2).adjacency_matrix() # optional - sage.graphs + sage: c3 = c.distance_graph(3).adjacency_matrix() # optional - sage.graphs + sage: p. = SemidefiniteProgram() # optional - sage.graphs + sage: p.add_constraint((1/7)*matrix.identity(7)>=-y[0]*c2-y[1]*c3) # optional - sage.graphs + sage: p.set_objective(y[0]*(c2**2).trace()+y[1]*(c3**2).trace()) # optional - sage.graphs + sage: x = p.solve(); x + 1 # optional - cvxopt sage.graphs 3.31766... Unlike in the previous example, the slack variable is very far from 0:: - sage: p.slack(0).trace() # tol 1e-14 # optional - cvxopt + sage: p.slack(0).trace() # tol 1e-14 # optional - cvxopt sage.graphs 1.0 The default CVXOPT backend computes with the Real Double Field, for example:: From 780eba4f05764be4daf3d9bc4da03354d857c291 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 Mar 2023 13:24:53 -0700 Subject: [PATCH 328/494] sage.numerical: More # optional --- .../numerical/interactive_simplex_method.py | 20 +++--- src/sage/numerical/mip.pyx | 64 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py index 184a2c8a434..49f0fe351dc 100644 --- a/src/sage/numerical/interactive_simplex_method.py +++ b/src/sage/numerical/interactive_simplex_method.py @@ -298,9 +298,9 @@ def _latex_product(coefficients, variables, sage: from sage.numerical.interactive_simplex_method import \ ....: _latex_product - sage: var("x, y") + sage: var("x, y") # optional - sage.symbolic (x, y) - sage: print(_latex_product([-1, 3], [x, y])) + sage: print(_latex_product([-1, 3], [x, y])) # optional - sage.symbolic - \mspace{-6mu}&\mspace{-6mu} x \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 3 y """ entries = [] @@ -1534,13 +1534,13 @@ def plot(self, *args, **kwds): sage: b = (1000, 1500) sage: c = (10, 5) sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=") - sage: p = P.plot() # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot() # optional - sage.plot + sage: p.show() # optional - sage.plot In this case the plot works better with the following axes ranges:: - sage: p = P.plot(0, 1000, 0, 1500) # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot(0, 1000, 0, 1500) # optional - sage.plot + sage: p.show() # optional - sage.plot TESTS: @@ -1611,13 +1611,13 @@ def plot_feasible_set(self, xmin=None, xmax=None, ymin=None, ymax=None, sage: b = (1000, 1500) sage: c = (10, 5) sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=") - sage: p = P.plot_feasible_set() # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot_feasible_set() # optional - sage.plot + sage: p.show() # optional - sage.plot In this case the plot works better with the following axes ranges:: - sage: p = P.plot_feasible_set(0, 1000, 0, 1500) # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot_feasible_set(0, 1000, 0, 1500) # optional - sage.plot + sage: p.show() # optional - sage.plot """ if self.n() != 2: raise ValueError("only problems with 2 variables can be plotted") diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 71dc66360da..3751fe34028 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -315,13 +315,13 @@ cdef class MixedIntegerLinearProgram(SageObject): Computation of a maximum stable set in Petersen's graph:: - sage: g = graphs.PetersenGraph() - sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') - sage: b = p.new_variable(binary=True) - sage: p.set_objective(sum([b[v] for v in g])) - sage: for (u,v) in g.edges(sort=False, labels=None): + sage: g = graphs.PetersenGraph() # optional - sage.graphs + sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') # optional - sage.graphs + sage: b = p.new_variable(binary=True) # optional - sage.graphs + sage: p.set_objective(sum([b[v] for v in g])) # optional - sage.graphs + sage: for (u,v) in g.edges(sort=False, labels=None): # optional - sage.graphs ....: p.add_constraint(b[u] + b[v], max=1) - sage: p.solve(objective_only=True) + sage: p.solve(objective_only=True) # optional - sage.graphs 4.0 TESTS: @@ -2629,14 +2629,14 @@ cdef class MixedIntegerLinearProgram(SageObject): Computation of a maximum stable set in Petersen's graph:: - sage: g = graphs.PetersenGraph() - sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') - sage: b = p.new_variable(nonnegative=True) - sage: p.set_objective(sum([b[v] for v in g])) - sage: for (u,v) in g.edges(sort=False, labels=None): + sage: g = graphs.PetersenGraph() # optional - sage.graphs + sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') # optional - sage.graphs + sage: b = p.new_variable(nonnegative=True) # optional - sage.graphs + sage: p.set_objective(sum([b[v] for v in g])) # optional - sage.graphs + sage: for (u,v) in g.edges(sort=False, labels=None): # optional - sage.graphs ....: p.add_constraint(b[u] + b[v], max=1) - sage: p.set_binary(b) - sage: p.solve(objective_only=True) + sage: p.set_binary(b) # optional - sage.graphs + sage: p.solve(objective_only=True) # optional - sage.graphs 4.0 Constraints in the objective function are respected:: @@ -2983,17 +2983,17 @@ cdef class MixedIntegerLinearProgram(SageObject): EXAMPLES:: - sage: g = graphs.CubeGraph(9) - sage: p = MixedIntegerLinearProgram(solver="GLPK") - sage: p.solver_parameter("mip_gap_tolerance",100) - sage: b = p.new_variable(binary=True) - sage: p.set_objective(p.sum(b[v] for v in g)) - sage: for v in g: + sage: g = graphs.CubeGraph(9) # optional - sage.graphs + sage: p = MixedIntegerLinearProgram(solver="GLPK") # optional - sage.graphs + sage: p.solver_parameter("mip_gap_tolerance",100) # optional - sage.graphs + sage: b = p.new_variable(binary=True) # optional - sage.graphs + sage: p.set_objective(p.sum(b[v] for v in g)) # optional - sage.graphs + sage: for v in g: # optional - sage.graphs ....: p.add_constraint(b[v] + p.sum(b[u] for u in g.neighbors(v)) <= 1) - sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution - sage: p.solve() # rel tol 100 + sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution # optional - sage.graphs + sage: p.solve() # rel tol 100 # optional - sage.graphs 1.0 - sage: p.best_known_objective_bound() # random + sage: p.best_known_objective_bound() # random # optional - sage.graphs 48.0 """ return self._backend.best_known_objective_bound() @@ -3017,17 +3017,17 @@ cdef class MixedIntegerLinearProgram(SageObject): EXAMPLES:: - sage: g = graphs.CubeGraph(9) - sage: p = MixedIntegerLinearProgram(solver="GLPK") - sage: p.solver_parameter("mip_gap_tolerance",100) - sage: b = p.new_variable(binary=True) - sage: p.set_objective(p.sum(b[v] for v in g)) - sage: for v in g: + sage: g = graphs.CubeGraph(9) # optional - sage.graphs + sage: p = MixedIntegerLinearProgram(solver="GLPK") # optional - sage.graphs + sage: p.solver_parameter("mip_gap_tolerance",100) # optional - sage.graphs + sage: b = p.new_variable(binary=True) # optional - sage.graphs + sage: p.set_objective(p.sum(b[v] for v in g)) # optional - sage.graphs + sage: for v in g: # optional - sage.graphs ....: p.add_constraint(b[v] + p.sum(b[u] for u in g.neighbors(v)) <= 1) - sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution - sage: p.solve() # rel tol 100 + sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution # optional - sage.graphs + sage: p.solve() # rel tol 100 # optional - sage.graphs 1.0 - sage: p.get_relative_objective_gap() # random + sage: p.get_relative_objective_gap() # random # optional - sage.graphs 46.99999999999999 TESTS: @@ -3035,7 +3035,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Just make sure that the variable *has* been defined, and is not just undefined:: - sage: p.get_relative_objective_gap() > 1 + sage: p.get_relative_objective_gap() > 1 # optional - sage.graphs True """ return self._backend.get_relative_objective_gap() From 1eb68422ebbdd9ef1095e3e63fa8c04c27834c5c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 May 2023 13:20:30 -0700 Subject: [PATCH 329/494] Massive modularization fixes --- src/sage/numerical/gauss_legendre.pyx | 26 +++++++++++++------------- src/sage/numerical/knapsack.py | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/sage/numerical/gauss_legendre.pyx b/src/sage/numerical/gauss_legendre.pyx index 269727c1fdd..d1d83161363 100644 --- a/src/sage/numerical/gauss_legendre.pyx +++ b/src/sage/numerical/gauss_legendre.pyx @@ -79,11 +79,11 @@ def nodes_uncached(degree, prec): sage: from sage.numerical.gauss_legendre import nodes_uncached sage: L1 = nodes_uncached(24, 53) - sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) - sage: Pdif = P.diff() - sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) + sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # optional - sage.symbolic + sage: Pdif = P.diff() # optional - sage.symbolic + sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # optional - sage.symbolic ....: for r, _ in RR['x'](P).roots()] - sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 + sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # optional - sage.symbolic ....: for a, b in zip(L1, L2)) True @@ -188,11 +188,11 @@ def nodes(degree, prec): sage: from sage.numerical.gauss_legendre import nodes sage: L1 = nodes(24, 53) - sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) - sage: Pdif = P.diff() - sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) + sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # optional - sage.symbolic + sage: Pdif = P.diff() # optional - sage.symbolic + sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # optional - sage.symbolic ....: for r, _ in RR['x'](P).roots()] - sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 + sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # optional - sage.symbolic ....: for a, b in zip(L1, L2)) True @@ -343,8 +343,8 @@ def integrate_vector(f, prec, epsilon=None): sage: epsilon = K(2^(-prec + 4)) sage: f = lambda t:V((1 + t^2, 1/(1 + t^2))) sage: I = integrate_vector(f, prec, epsilon=epsilon) - sage: J = V((4/3, pi/4)) - sage: max(c.abs() for c in (I - J)) < epsilon + sage: J = V((4/3, pi/4)) # optional - sage.symbolic + sage: max(c.abs() for c in (I - J)) < epsilon # optional - sage.symbolic True We can also use complex-valued integrands:: @@ -354,10 +354,10 @@ def integrate_vector(f, prec, epsilon=None): sage: K = ComplexField(prec) sage: V = VectorSpace(K, 2) sage: epsilon = Kreal(2^(-prec + 4)) - sage: f = lambda t: V((t, K(exp(2*pi*t*K.0)))) - sage: I = integrate_vector(f, prec, epsilon=epsilon) + sage: f = lambda t: V((t, K(exp(2*pi*t*K.0)))) # optional - sage.symbolic + sage: I = integrate_vector(f, prec, epsilon=epsilon) # optional - sage.symbolic sage: J = V((1/2, 0)) - sage: max(c.abs() for c in (I - J)) < epsilon + sage: max(c.abs() for c in (I - J)) < epsilon # optional - sage.symbolic True """ results = [] diff --git a/src/sage/numerical/knapsack.py b/src/sage/numerical/knapsack.py index 3a5c14474e8..b6d3abe3ce5 100644 --- a/src/sage/numerical/knapsack.py +++ b/src/sage/numerical/knapsack.py @@ -409,13 +409,13 @@ def is_superincreasing(self, seq=None): The sequence must contain only integers:: sage: from sage.numerical.knapsack import Superincreasing - sage: L = [1.0, 2.1, pi, 21, 69, 189, 376, 919] - sage: Superincreasing(L).is_superincreasing() + sage: L = [1.0, 2.1, pi, 21, 69, 189, 376, 919] # optional - sage.symbolic + sage: Superincreasing(L).is_superincreasing() # optional - sage.symbolic Traceback (most recent call last): ... TypeError: Element e (= 1.00000000000000) of seq must be a non-negative integer. - sage: L = [1, 2.1, pi, 21, 69, 189, 376, 919] - sage: Superincreasing(L).is_superincreasing() + sage: L = [1, 2.1, pi, 21, 69, 189, 376, 919] # optional - sage.symbolic + sage: Superincreasing(L).is_superincreasing() # optional - sage.symbolic Traceback (most recent call last): ... TypeError: Element e (= 2.10000000000000) of seq must be a non-negative integer. From 361b3c378a9a6cf1ae20eee44d020cf00f0869de Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 May 2023 18:53:11 -0700 Subject: [PATCH 330/494] More fixes --- src/sage/numerical/optimize.py | 63 ++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index da6c58cd4ef..41b44b1f145 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -341,20 +341,20 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", Minimize a fourth order polynomial in three variables (see the :wikipedia:`Rosenbrock_function`):: - sage: vars = var('x y z') - sage: f = 100*(y-x^2)^2+(1-x)^2+100*(z-y^2)^2+(1-y)^2 - sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 + sage: vars = var('x y z') # optional - sage.symbolic + sage: f = 100*(y-x^2)^2 + (1-x)^2 + 100*(z-y^2)^2 + (1-y)^2 # optional - sage.symbolic + sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 # optional - sage.symbolic (1.0, 1.0, 1.0) Try the newton-conjugate gradient method; the gradient and hessian are computed automatically:: - sage: minimize(f, [.1, .3, .4], algorithm="ncg") # abs tol 1e-6 + sage: minimize(f, [.1, .3, .4], algorithm="ncg") # abs tol 1e-6 # optional - sage.symbolic (1.0, 1.0, 1.0) We get additional convergence information with the `verbose` option:: - sage: minimize(f, [.1, .3, .4], algorithm="ncg", verbose=True) + sage: minimize(f, [.1, .3, .4], algorithm="ncg", verbose=True) # optional - sage.symbolic Optimization terminated successfully. ... (0.9999999..., 0.999999..., 0.999999...) @@ -465,7 +465,6 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) `50x + 24y \leq 2400`, `30x + 33y \leq 2100`, `x \geq 45`, and `y \geq 5`:: - sage: y = var('y') sage: f = lambda p: -p[0]-p[1]+50 sage: c_1 = lambda p: p[0]-45 sage: c_2 = lambda p: p[1]-5 @@ -477,44 +476,47 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) Let's find a minimum of `\sin(xy)`:: - sage: x,y = var('x y') - sage: f(x,y) = sin(x*y) - sage: minimize_constrained(f, [(None,None),(4,10)],[5,5]) + sage: x,y = var('x y') # optional - sage.symbolic + sage: f(x,y) = sin(x*y) # optional - sage.symbolic + sage: minimize_constrained(f, [(None,None),(4,10)],[5,5]) # optional - sage.symbolic (4.8..., 4.8...) Check if L-BFGS-B finds the same minimum:: - sage: minimize_constrained(f, [(None,None),(4,10)],[5,5], algorithm='l-bfgs-b') + sage: minimize_constrained(f, [(None,None),(4,10)],[5,5], # optional - sage.symbolic + ....: algorithm='l-bfgs-b') (4.7..., 4.9...) Rosenbrock function (see the :wikipedia:`Rosenbrock_function`):: sage: from scipy.optimize import rosen, rosen_der - sage: minimize_constrained(rosen, [(-50,-10),(5,10)],[1,1],gradient=rosen_der,algorithm='l-bfgs-b') + sage: minimize_constrained(rosen, [(-50,-10),(5,10)],[1,1], + ....: gradient=rosen_der, algorithm='l-bfgs-b') (-10.0, 10.0) - sage: minimize_constrained(rosen, [(-50,-10),(5,10)],[1,1],algorithm='l-bfgs-b') + sage: minimize_constrained(rosen, [(-50,-10),(5,10)],[1,1], + ....: algorithm='l-bfgs-b') (-10.0, 10.0) TESTS: Check if :trac:`6592` is fixed:: - sage: x, y = var('x y') - sage: f(x,y) = (100 - x) + (1000 - y) - sage: c(x,y) = x + y - 479 # > 0 - sage: minimize_constrained(f, [c], [100, 300]) + sage: x, y = var('x y') # optional - sage.symbolic + sage: f(x,y) = (100 - x) + (1000 - y) # optional - sage.symbolic + sage: c(x,y) = x + y - 479 # > 0 # optional - sage.symbolic + sage: minimize_constrained(f, [c], [100, 300]) # optional - sage.symbolic (805.985..., 1005.985...) - sage: minimize_constrained(f, c, [100, 300]) + sage: minimize_constrained(f, c, [100, 300]) # optional - sage.symbolic (805.985..., 1005.985...) If ``func`` is symbolic, its minimizer should be in the same order as its arguments (:trac:`32511`):: - sage: x,y = SR.var('x,y') - sage: f(y,x) = x - y - sage: c1(y,x) = x - sage: c2(y,x) = 1-y - sage: minimize_constrained(f, [c1, c2], (0,0)) + sage: x,y = SR.var('x,y') # optional - sage.symbolic + sage: f(y,x) = x - y # optional - sage.symbolic + sage: c1(y,x) = x # optional - sage.symbolic + sage: c2(y,x) = 1-y # optional - sage.symbolic + sage: minimize_constrained(f, [c1, c2], (0,0)) # optional - sage.symbolic (1.0, 0.0) """ @@ -719,30 +721,33 @@ def find_fit(data, model, initial_guess=None, parameters=None, variables=None, s perturbations:: sage: set_random_seed(0) - sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) for i in xsrange(0, 4*pi, 0.2)] - sage: var('a, b, c, x') + sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) # optional - sage.symbolic + ....: for i in xsrange(0, 4*pi, 0.2)] + sage: var('a, b, c, x') # optional - sage.symbolic (a, b, c, x) We define a function with free parameters `a`, `b` and `c`:: - sage: model(x) = a * sin(b * x - c) + sage: model(x) = a * sin(b * x - c) # optional - sage.symbolic We search for the parameters that give the best fit to the data:: - sage: find_fit(data, model) + sage: find_fit(data, model) # optional - sage.symbolic [a == 1.21..., b == 0.49..., c == 0.19...] We can also use a Python function for the model:: sage: def f(x, a, b, c): return a * sin(b * x - c) - sage: fit = find_fit(data, f, parameters = [a, b, c], variables = [x], solution_dict = True) - sage: fit[a], fit[b], fit[c] + sage: fit = find_fit(data, f, parameters=[a, b, c], variables=[x], # optional - sage.symbolic + ....: solution_dict = True) + sage: fit[a], fit[b], fit[c] # optional - sage.symbolic (1.21..., 0.49..., 0.19...) We search for a formula for the `n`-th prime number:: sage: dataprime = [(i, nth_prime(i)) for i in range(1, 5000, 100)] - sage: find_fit(dataprime, a * x * log(b * x), parameters = [a, b], variables = [x]) + sage: find_fit(dataprime, a * x * log(b * x), # optional - sage.symbolic + ....: parameters=[a, b], variables=[x]) [a == 1.11..., b == 1.24...] From d1e5fdd72d2e7a30b4a89e17181ed6b56fdbae63 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 20 May 2023 15:38:10 -0700 Subject: [PATCH 331/494] More # optional --- src/sage/numerical/optimize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index 41b44b1f145..0a5cc20841a 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -239,7 +239,7 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): (-3.28837136189098..., 3.42575079030572...) sage: find_local_minimum(f, 1, 5, tol=1e-2, maxfun=10) (-3.28837084598..., 3.4250840220...) - sage: show(plot(f, 0, 20)) + sage: show(plot(f, 0, 20)) # optional - sage.plot sage: find_local_minimum(f, 1, 15) (-9.4772942594..., 9.5293344109...) @@ -262,9 +262,9 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): numerics (observe the small number of decimal places that we actually test):: - sage: plot(f, (x,-2.5, -1)).ymin() + sage: plot(f, (x, -2.5, -1)).ymin() # optional - sage.plot -2.182... - sage: plot(f, (x,-2.5, 2)).ymin() + sage: plot(f, (x, -2.5, 2)).ymin() # optional - sage.plot -2.182... ALGORITHM: From a9d02071948dff4c7e99a611ef75565f6536d0ae Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 11 Jun 2023 23:47:37 -0700 Subject: [PATCH 332/494] More # optional --- src/sage/numerical/optimize.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index 0a5cc20841a..483b424b4db 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - scipy """ Numerical Root Finding and Optimization From 0a001834166a4f0c8b576fc76c093252a3d54156 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:20 -0700 Subject: [PATCH 333/494] src/sage/numerical: sage -fixdoctests --only-tags --- .../numerical/backends/cvxopt_backend.pyx | 408 ++++++------- .../numerical/backends/cvxopt_sdp_backend.pyx | 129 ++--- src/sage/numerical/backends/cvxpy_backend.pyx | 6 +- .../numerical/backends/generic_backend.pyx | 534 ++++++++++-------- .../backends/generic_sdp_backend.pyx | 243 ++++---- .../backends/interactivelp_backend.pyx | 17 +- src/sage/numerical/backends/ppl_backend.pyx | 2 +- src/sage/numerical/gauss_legendre.pyx | 26 +- .../numerical/interactive_simplex_method.py | 24 +- src/sage/numerical/knapsack.py | 9 +- src/sage/numerical/mip.pyx | 93 +-- src/sage/numerical/optimize.py | 85 +-- src/sage/numerical/sdp.pyx | 116 ++-- 13 files changed, 894 insertions(+), 798 deletions(-) diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 4100fb71b76..82eb0c4ccfd 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -30,13 +30,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver="CVXOPT") # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver="CVXOPT") # needs cvxopt TESTS: :trac:`20332`:: - sage: p # optional - cvxopt + sage: p # needs cvxopt Mixed Integer Program (no objective, 0 variables, 0 constraints) """ @@ -62,7 +62,7 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") # needs cvxopt """ @@ -100,16 +100,17 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "CVXOPT") # optional - cvxopt - sage: b = p.new_variable() # optional - cvxopt - sage: p.add_constraint(b[1] + b[2] <= 6) # optional - cvxopt - sage: p.add_constraint(b[2] <= 5) # optional - cvxopt - sage: p.set_objective(b[1] + b[2]) # optional - cvxopt - sage: cp = copy(p.get_backend()) # optional - cvxopt - sage: cp.solve() # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver = "CVXOPT") + sage: b = p.new_variable() + sage: p.add_constraint(b[1] + b[2] <= 6) + sage: p.add_constraint(b[2] <= 5) + sage: p.set_objective(b[1] + b[2]) + sage: cp = copy(p.get_backend()) + sage: cp.solve() 0 - sage: cp.get_objective_value() # optional - cvxopt + sage: cp.get_objective_value() 6.0 """ cdef CVXOPTBackend cp = type(self)() @@ -159,36 +160,37 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.add_variable() # optional - cvxopt + sage: p.add_variable() 0 - sage: p.ncols() # optional - cvxopt + sage: p.ncols() 1 - sage: p.add_variable() # optional - cvxopt + sage: p.add_variable() 1 - sage: p.add_variable(lower_bound=-2.0) # optional - cvxopt + sage: p.add_variable(lower_bound=-2.0) 2 - sage: p.add_variable(continuous=True) # optional - cvxopt + sage: p.add_variable(continuous=True) 3 - sage: p.add_variable(name='x',obj=1.0) # optional - cvxopt + sage: p.add_variable(name='x',obj=1.0) 4 - sage: p.col_name(3) # optional - cvxopt + sage: p.col_name(3) 'x_3' - sage: p.col_name(4) # optional - cvxopt + sage: p.col_name(4) 'x' - sage: p.objective_coefficient(4) # optional - cvxopt + sage: p.objective_coefficient(4) 1.00000000000000 TESTS:: - sage: p.add_variable(integer=True) # optional - cvxopt + sage: p.add_variable(integer=True) # needs cvxopt Traceback (most recent call last): ... RuntimeError: CVXOPT only supports continuous variables - sage: p.add_variable(binary=True) # optional - cvxopt + sage: p.add_variable(binary=True) # needs cvxopt Traceback (most recent call last): ... RuntimeError: CVXOPT only supports continuous variables @@ -210,12 +212,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "cvxopt") # optional - cvxopt - sage: p.add_variables(5) # optional - cvxopt + sage: p = get_solver(solver = "cvxopt") + sage: p.add_variables(5) 4 - sage: p.set_variable_type(3, -1) # optional - cvxopt - sage: p.set_variable_type(3, -2) # optional - cvxopt + sage: p.set_variable_type(3, -1) + sage: p.set_variable_type(3, -2) Traceback (most recent call last): ... ValueError: ... @@ -236,12 +239,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.is_maximization() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - cvxopt - sage: p.is_maximization() # optional - cvxopt + sage: p.set_sense(-1) + sage: p.is_maximization() False """ if sense == 1: @@ -262,14 +266,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variable() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variable() 0 - sage: p.objective_coefficient(0) # optional - cvxopt + sage: p.objective_coefficient(0) 0.0 - sage: p.objective_coefficient(0,2) # optional - cvxopt - sage: p.objective_coefficient(0) # optional - cvxopt + sage: p.objective_coefficient(0,2) + sage: p.objective_coefficient(0) 2.0 """ if coeff is not None: @@ -290,12 +295,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: from sage.numerical.backends.generic_backend import get_solver # optional - cvxopt - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variables(5) # optional - cvxopt + sage: # needs cvxopt + sage: from sage.numerical.backends.generic_backend import get_solver + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variables(5) 4 - sage: p.set_objective([1, 1, 2, 1, 3]) # optional - cvxopt - sage: [p.objective_coefficient(x) for x in range(5)] # optional - cvxopt + sage: p.set_objective([1, 1, 2, 1, 3]) + sage: [p.objective_coefficient(x) for x in range(5)] [1, 1, 2, 1, 3] """ for i in range(len(coeff)): @@ -331,15 +337,16 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.nrows() # optional - cvxopt + sage: p.nrows() 0 - sage: p.add_linear_constraints(5, 0, None) # optional - cvxopt - sage: p.add_col(range(5), range(5)) # optional - cvxopt - sage: p.nrows() # optional - cvxopt + sage: p.add_linear_constraints(5, 0, None) + sage: p.add_col(range(5), range(5)) + sage: p.nrows() 5 """ column = [] @@ -374,17 +381,18 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variables(5) # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) # optional - cvxopt - sage: p.row(0) # optional - cvxopt + sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) + sage: p.row(0) ([1, 2, 3, 4], [1, 2, 3, 4]) - sage: p.row_bounds(0) # optional - cvxopt + sage: p.row_bounds(0) (2.00000000000000, 2.00000000000000) - sage: p.add_linear_constraint(zip(range(5), range(5)), 1.0, 1.0, name='foo') # optional - cvxopt - sage: p.row_name(-1) # optional - cvxopt + sage: p.add_linear_constraint(zip(range(5), range(5)), 1.0, 1.0, name='foo') + sage: p.row_name(-1) 'foo' """ coefficients = list(coefficients) @@ -412,76 +420,77 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x=p.new_variable(nonnegative=True) # optional - cvxopt - sage: p.set_objective(-4*x[0] - 5*x[1]) # optional - cvxopt - sage: p.add_constraint(2*x[0] + x[1] <= 3) # optional - cvxopt - sage: p.add_constraint(2*x[1] + x[0] <= 3) # optional - cvxopt - sage: N(p.solve(), digits=2) # optional - cvxopt + sage: # needs cvxopt + sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) + sage: x=p.new_variable(nonnegative=True) + sage: p.set_objective(-4*x[0] - 5*x[1]) + sage: p.add_constraint(2*x[0] + x[1] <= 3) + sage: p.add_constraint(2*x[1] + x[0] <= 3) + sage: N(p.solve(), digits=2) -9.0 - sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x=p.new_variable(nonnegative=True) # optional - cvxopt - sage: p.set_objective(x[0] + 2*x[1]) # optional - cvxopt - sage: p.add_constraint(-5*x[0] + x[1] <= 7) # optional - cvxopt - sage: p.add_constraint(-5*x[0] + x[1] >= 7) # optional - cvxopt - sage: p.add_constraint(x[0] + x[1] >= 26 ) # optional - cvxopt - sage: p.add_constraint( x[0] >= 3) # optional - cvxopt - sage: p.add_constraint( x[1] >= 4) # optional - cvxopt - sage: N(p.solve(),digits=4) # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) + sage: x=p.new_variable(nonnegative=True) + sage: p.set_objective(x[0] + 2*x[1]) + sage: p.add_constraint(-5*x[0] + x[1] <= 7) + sage: p.add_constraint(-5*x[0] + x[1] >= 7) + sage: p.add_constraint(x[0] + x[1] >= 26 ) + sage: p.add_constraint( x[0] >= 3) + sage: p.add_constraint( x[1] >= 4) + sage: N(p.solve(),digits=4) 48.83 - sage: p = MixedIntegerLinearProgram(solver = "cvxopt") # optional - cvxopt - sage: x=p.new_variable(nonnegative=True) # optional - cvxopt - sage: p.set_objective(x[0] + x[1] + 3*x[2]) # optional - cvxopt - sage: p.solver_parameter("show_progress",True) # optional - cvxopt - sage: p.add_constraint(x[0] + 2*x[1] <= 4) # optional - cvxopt - sage: p.add_constraint(5*x[2] - x[1] <= 8) # optional - cvxopt - sage: N(p.solve(), digits=2) # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver = "cvxopt") + sage: x=p.new_variable(nonnegative=True) + sage: p.set_objective(x[0] + x[1] + 3*x[2]) + sage: p.solver_parameter("show_progress",True) + sage: p.add_constraint(x[0] + 2*x[1] <= 4) + sage: p.add_constraint(5*x[2] - x[1] <= 8) + sage: N(p.solve(), digits=2) pcost dcost gap pres dres k/t ... 8.8 sage: #CVXOPT gives different values for variables compared to the other solvers. - sage: c = MixedIntegerLinearProgram(solver = "cvxopt") # optional - cvxopt - sage: p = MixedIntegerLinearProgram(solver = "ppl") # optional - cvxopt - sage: g = MixedIntegerLinearProgram() # optional - cvxopt - sage: xc=c.new_variable(nonnegative=True) # optional - cvxopt - sage: xp=p.new_variable(nonnegative=True) # optional - cvxopt - sage: xg=g.new_variable(nonnegative=True) # optional - cvxopt - sage: c.set_objective(xc[2]) # optional - cvxopt - sage: p.set_objective(xp[2]) # optional - cvxopt - sage: g.set_objective(xg[2]) # optional - cvxopt + sage: c = MixedIntegerLinearProgram(solver = "cvxopt") + sage: p = MixedIntegerLinearProgram(solver = "ppl") + sage: g = MixedIntegerLinearProgram() + sage: xc=c.new_variable(nonnegative=True) + sage: xp=p.new_variable(nonnegative=True) + sage: xg=g.new_variable(nonnegative=True) + sage: c.set_objective(xc[2]) + sage: p.set_objective(xp[2]) + sage: g.set_objective(xg[2]) sage: #we create a cube for all three solvers - sage: c.add_constraint(xc[0] <= 100) # optional - cvxopt - sage: c.add_constraint(xc[1] <= 100) # optional - cvxopt - sage: c.add_constraint(xc[2] <= 100) # optional - cvxopt - sage: p.add_constraint(xp[0] <= 100) # optional - cvxopt - sage: p.add_constraint(xp[1] <= 100) # optional - cvxopt - sage: p.add_constraint(xp[2] <= 100) # optional - cvxopt - sage: g.add_constraint(xg[0] <= 100) # optional - cvxopt - sage: g.add_constraint(xg[1] <= 100) # optional - cvxopt - sage: g.add_constraint(xg[2] <= 100) # optional - cvxopt - sage: N(c.solve(),digits=4) # optional - cvxopt + sage: c.add_constraint(xc[0] <= 100) + sage: c.add_constraint(xc[1] <= 100) + sage: c.add_constraint(xc[2] <= 100) + sage: p.add_constraint(xp[0] <= 100) + sage: p.add_constraint(xp[1] <= 100) + sage: p.add_constraint(xp[2] <= 100) + sage: g.add_constraint(xg[0] <= 100) + sage: g.add_constraint(xg[1] <= 100) + sage: g.add_constraint(xg[2] <= 100) + sage: N(c.solve(),digits=4) 100.0 - sage: N(c.get_values(xc[0]),digits=3) # optional - cvxopt + sage: N(c.get_values(xc[0]),digits=3) 50.0 - sage: N(c.get_values(xc[1]),digits=3) # optional - cvxopt + sage: N(c.get_values(xc[1]),digits=3) 50.0 - sage: N(c.get_values(xc[2]),digits=4) # optional - cvxopt + sage: N(c.get_values(xc[2]),digits=4) 100.0 - sage: N(p.solve(),digits=4) # optional - cvxopt + sage: N(p.solve(),digits=4) 100.0 - sage: N(p.get_values(xp[0]),2) # optional - cvxopt + sage: N(p.get_values(xp[0]),2) 0.00 - sage: N(p.get_values(xp[1]),2) # optional - cvxopt + sage: N(p.get_values(xp[1]),2) 0.00 - sage: N(p.get_values(xp[2]),digits=4) # optional - cvxopt + sage: N(p.get_values(xp[2]),digits=4) 100.0 - sage: N(g.solve(),digits=4) # optional - cvxopt + sage: N(g.solve(),digits=4) 100.0 - sage: N(g.get_values(xg[0]),2) # optional - cvxopt + sage: N(g.get_values(xg[0]),2) 0.00 - sage: N(g.get_values(xg[1]),2) # optional - cvxopt + sage: N(g.get_values(xg[1]),2) 0.00 - sage: N(g.get_values(xg[2]),digits=4) # optional - cvxopt + sage: N(g.get_values(xg[2]),digits=4) 100.0 """ from cvxopt import matrix, solvers @@ -564,19 +573,20 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "cvxopt") # optional - cvxopt - sage: p.add_variables(2) # optional - cvxopt + sage: p = get_solver(solver = "cvxopt") + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) # optional - cvxopt - sage: p.set_objective([2, 5]) # optional - cvxopt - sage: p.solve() # optional - cvxopt + sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: N(p.get_objective_value(),4) # optional - cvxopt + sage: N(p.get_objective_value(),4) 7.5 - sage: N(p.get_variable_value(0),4) # optional - cvxopt + sage: N(p.get_variable_value(0),4) 3.6e-7 - sage: N(p.get_variable_value(1),4) # optional - cvxopt + sage: N(p.get_variable_value(1),4) 1.5 """ sum = self.obj_constant_term @@ -596,19 +606,20 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variables(2) # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) # optional - cvxopt - sage: p.set_objective([2, 5]) # optional - cvxopt - sage: p.solve() # optional - cvxopt + sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: N(p.get_objective_value(),4) # optional - cvxopt + sage: N(p.get_objective_value(),4) 7.5 - sage: N(p.get_variable_value(0),4) # optional - cvxopt + sage: N(p.get_variable_value(0),4) 3.6e-7 - sage: N(p.get_variable_value(1),4) # optional - cvxopt + sage: N(p.get_variable_value(1),4) 1.5 """ return self.answer['x'][variable] @@ -619,13 +630,14 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.add_variables(2) # optional - cvxopt + sage: p.add_variables(2) 1 - sage: p.ncols() # optional - cvxopt + sage: p.ncols() 2 """ @@ -637,14 +649,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.nrows() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.nrows() 0 - sage: p.add_variables(5) # optional - cvxopt + sage: p.add_variables(5) 4 - sage: p.add_linear_constraints(2, 2.0, None) # optional - cvxopt - sage: p.nrows() # optional - cvxopt + sage: p.add_linear_constraints(2, 2.0, None) + sage: p.nrows() 2 """ return len(self.row_upper_bound) @@ -656,12 +669,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.is_maximization() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - cvxopt - sage: p.is_maximization() # optional - cvxopt + sage: p.set_sense(-1) + sage: p.is_maximization() False """ if self.is_maximize == 1: @@ -680,12 +694,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.problem_name() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.problem_name() '' - sage: p.problem_name("There once was a french fry") # optional - cvxopt - sage: print(p.problem_name()) # optional - cvxopt + sage: p.problem_name("There once was a french fry") + sage: print(p.problem_name()) There once was a french fry """ if name is None: @@ -710,14 +725,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variables(5) # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) # optional - cvxopt - sage: p.row(0) # optional - cvxopt + sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) + sage: p.row(0) ([1, 2, 3, 4], [1, 2, 3, 4]) - sage: p.row_bounds(0) # optional - cvxopt + sage: p.row_bounds(0) (2, 2) """ coeff = [] @@ -747,14 +763,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variables(5) # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) # optional - cvxopt - sage: p.row(0) # optional - cvxopt + sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) + sage: p.row(0) ([1, 2, 3, 4], [1, 2, 3, 4]) - sage: p.row_bounds(0) # optional - cvxopt + sage: p.row_bounds(0) (2, 2) """ return (self.row_lower_bound[index], self.row_upper_bound[index]) @@ -775,14 +792,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variable() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - cvxopt + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_upper_bound(0, 5) # optional - cvxopt - sage: p.col_bounds(0) # optional - cvxopt + sage: p.variable_upper_bound(0, 5) + sage: p.col_bounds(0) (0.0, 5) """ return (self.col_lower_bound[index], self.col_upper_bound[index]) @@ -798,17 +816,18 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.add_variable() # optional - cvxopt + sage: p.add_variable() 0 - sage: p.set_variable_type(0,0) # optional - cvxopt + sage: p.set_variable_type(0,0) Traceback (most recent call last): ... ValueError: ... - sage: p.is_variable_binary(0) # optional - cvxopt + sage: p.is_variable_binary(0) False """ @@ -825,18 +844,19 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.add_variable() # optional - cvxopt + sage: p.add_variable() 0 - sage: p.set_variable_type(0,-1) # optional - cvxopt - sage: p.set_variable_type(0,1) # optional - cvxopt + sage: p.set_variable_type(0,-1) + sage: p.set_variable_type(0,1) Traceback (most recent call last): ... ValueError: ... - sage: p.is_variable_integer(0) # optional - cvxopt + sage: p.is_variable_integer(0) False """ return False @@ -852,19 +872,20 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.ncols() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.ncols() 0 - sage: p.add_variable() # optional - cvxopt + sage: p.add_variable() 0 - sage: p.is_variable_continuous(0) # optional - cvxopt + sage: p.is_variable_continuous(0) True - sage: p.set_variable_type(0,1) # optional - cvxopt + sage: p.set_variable_type(0,1) Traceback (most recent call last): ... ValueError: ... - sage: p.is_variable_continuous(0) # optional - cvxopt + sage: p.is_variable_continuous(0) True """ @@ -881,9 +902,9 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_linear_constraints(1, 2, None, names=["Empty constraint 1"]) # optional - cvxopt - sage: p.row_name(0) # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") # needs cvxopt + sage: p.add_linear_constraints(1, 2, None, names=["Empty constraint 1"]) # needs cvxopt + sage: p.row_name(0) # needs cvxopt 'Empty constraint 1' """ if self.row_name_var[index] is not None: @@ -904,10 +925,10 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variable(name="I am a variable") # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") # needs cvxopt + sage: p.add_variable(name="I am a variable") # needs cvxopt 0 - sage: p.col_name(0) # optional - cvxopt + sage: p.col_name(0) # needs cvxopt 'I am a variable' """ if self.col_name_var[index] is not None: @@ -928,14 +949,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variable() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - cvxopt + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_upper_bound(0, 5) # optional - cvxopt - sage: p.col_bounds(0) # optional - cvxopt + sage: p.variable_upper_bound(0, 5) + sage: p.col_bounds(0) (0.0, 5) """ if value is not False: @@ -957,14 +979,15 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.add_variable() # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - cvxopt + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_lower_bound(0, 5) # optional - cvxopt - sage: p.col_bounds(0) # optional - cvxopt + sage: p.variable_lower_bound(0, 5) + sage: p.col_bounds(0) (5, None) """ if value is not False: @@ -990,12 +1013,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver="CVXOPT") # optional - cvxopt - sage: p.solver_parameter("show_progress") # optional - cvxopt + sage: p = get_solver(solver="CVXOPT") + sage: p.solver_parameter("show_progress") False - sage: p.solver_parameter("show_progress", True) # optional - cvxopt - sage: p.solver_parameter("show_progress") # optional - cvxopt + sage: p.solver_parameter("show_progress", True) + sage: p.solver_parameter("show_progress") True """ if value is None: diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index aefa91439bf..dcad34cdccc 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -36,7 +36,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") # needs cvxopt """ @@ -68,9 +68,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # optional - cvxopt + sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -79,13 +79,13 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a3*x[2] <= a4) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # optional - cvxopt - sage: N(p.solve(), digits=4) # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a3*x[2] <= a4) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt + sage: N(p.solve(), digits=4) # needs cvxopt -3.225 - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # optional - cvxopt + sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -94,9 +94,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # optional - cvxopt - sage: N(p.solve(), digits=4) # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt + sage: N(p.solve(), digits=4) # needs cvxopt -3.154 """ @@ -171,9 +171,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # optional - cvxopt + sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -182,11 +182,11 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # optional - cvxopt - sage: N(p.solve(), digits=4) # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt + sage: N(p.solve(), digits=4) # needs cvxopt -3.154 - sage: N(p.get_backend().get_objective_value(), digits=4) # optional - cvxopt + sage: N(p.get_backend().get_objective_value(), digits=4) # needs cvxopt -3.154 """ sum = self.obj_constant_term @@ -204,20 +204,20 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): TESTS:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1]) # optional - cvxopt + sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1]) # needs cvxopt sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - cvxopt - sage: p.solve(); # tol 1e-08 # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt + sage: p.solve(); # tol 1e-08 # needs cvxopt -3.0 - sage: p.get_backend()._get_answer() # optional - cvxopt + sage: p.get_backend()._get_answer() # needs cvxopt {...} """ return self.answer @@ -232,9 +232,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # optional - cvxopt + sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -243,15 +243,15 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # optional - cvxopt - sage: N(p.solve(), digits=4) # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt + sage: N(p.solve(), digits=4) # needs cvxopt -3.154 - sage: N(p.get_backend().get_variable_value(0), digits=3) # optional - cvxopt + sage: N(p.get_backend().get_variable_value(0), digits=3) # needs cvxopt -0.368 - sage: N(p.get_backend().get_variable_value(1), digits=4) # optional - cvxopt + sage: N(p.get_backend().get_variable_value(1), digits=4) # needs cvxopt 1.898 - sage: N(p.get_backend().get_variable_value(2), digits=3) # optional - cvxopt + sage: N(p.get_backend().get_variable_value(2), digits=3) # needs cvxopt -0.888 """ return self.answer['x'][variable] @@ -270,34 +270,34 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1]) # optional - cvxopt + sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1]) # needs cvxopt sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - cvxopt - sage: p.solve() # tol 1e-08 # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt + sage: p.solve() # tol 1e-08 # needs cvxopt -3.0 - sage: B=p.get_backend() # optional - cvxopt - sage: x=p.get_values(x).values() # optional - cvxopt - sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() # tol 1e-07 # optional - cvxopt + sage: B=p.get_backend() # needs cvxopt + sage: x=p.get_values(x).values() # needs cvxopt + sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() # tol 1e-07 # needs cvxopt -3.0 - sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g # tol 1.5e-08 # optional - cvxopt + sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g # tol 1.5e-08 # needs cvxopt 0.0 TESTS:: - sage: B.dual_variable(7) # optional - cvxopt + sage: B.dual_variable(7) # needs cvxopt Traceback (most recent call last): ... IndexError: list index out of range - sage: abs(g - B._get_answer()['gap']) # tol 1e-22 # optional - cvxopt + sage: abs(g - B._get_answer()['gap']) # tol 1e-22 # needs cvxopt 0.0 """ @@ -320,33 +320,33 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0] - x[1]) # optional - cvxopt + sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0] - x[1]) # needs cvxopt sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - cvxopt - sage: p.solve() # tol 1e-08 # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt + sage: p.solve() # tol 1e-08 # needs cvxopt -3.0 - sage: B = p.get_backend() # optional - cvxopt - sage: B1 = B.slack(1); B1 # tol 1e-08 # optional - cvxopt + sage: B = p.get_backend() # needs cvxopt + sage: B1 = B.slack(1); B1 # tol 1e-08 # needs cvxopt [0.0 0.0] [0.0 0.0] - sage: B1.is_positive_definite() # optional - cvxopt + sage: B1.is_positive_definite() # needs cvxopt True - sage: x = sorted(p.get_values(x).values()) # optional - cvxopt - sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # optional - cvxopt + sage: x = sorted(p.get_values(x).values()) # needs cvxopt + sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # needs cvxopt [0.0 0.0] [0.0 0.0] TESTS:: - sage: B.slack(7) # optional - cvxopt + sage: B.slack(7) # needs cvxopt Traceback (most recent call last): ... IndexError: list index out of range @@ -376,12 +376,13 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: + sage: # needs cvxopt sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # optional - cvxopt - sage: p.solver_parameter("show_progress") # optional - cvxopt + sage: p = get_solver(solver = "CVXOPT") + sage: p.solver_parameter("show_progress") False - sage: p.solver_parameter("show_progress", True) # optional - cvxopt - sage: p.solver_parameter("show_progress") # optional - cvxopt + sage: p.solver_parameter("show_progress", True) + sage: p.solver_parameter("show_progress") True """ if value is None: diff --git a/src/sage/numerical/backends/cvxpy_backend.pyx b/src/sage/numerical/backends/cvxpy_backend.pyx index 7cf5ccc8fb6..1cbba9f6375 100644 --- a/src/sage/numerical/backends/cvxpy_backend.pyx +++ b/src/sage/numerical/backends/cvxpy_backend.pyx @@ -58,11 +58,11 @@ cdef class CVXPYBackend: Open-source solvers provided by optional packages:: - sage: p = MixedIntegerLinearProgram(solver="CVXPY/GLPK"); p.solve() # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver="CVXPY/GLPK"); p.solve() # needs cvxopt 0.0 - sage: p = MixedIntegerLinearProgram(solver="CVXPY/GLPK_MI"); p.solve() # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver="CVXPY/GLPK_MI"); p.solve() # needs cvxopt 0.0 - sage: p = MixedIntegerLinearProgram(solver="CVXPY/CVXOPT"); p.solve() # optional - cvxopt + sage: p = MixedIntegerLinearProgram(solver="CVXPY/CVXOPT"); p.solve() # needs cvxopt 0.0 sage: p = MixedIntegerLinearProgram(solver="CVXPY/GLOP"); p.solve() # optional - ortools 0.0 diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 6d43a6ba958..12e9405c37b 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -69,27 +69,28 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 1 - sage: p.add_variable(binary=True) # optional - Nonexistent_LP_solver + sage: p.add_variable(binary=True) 1 - sage: p.add_variable(lower_bound=-2.0, integer=True) # optional - Nonexistent_LP_solver + sage: p.add_variable(lower_bound=-2.0, integer=True) 2 - sage: p.add_variable(continuous=True, integer=True) # optional - Nonexistent_LP_solver + sage: p.add_variable(continuous=True, integer=True) Traceback (most recent call last): ... ValueError: ... - sage: p.add_variable(name='x',obj=1.0) # optional - Nonexistent_LP_solver + sage: p.add_variable(name='x',obj=1.0) 3 - sage: p.col_name(3) # optional - Nonexistent_LP_solver + sage: p.col_name(3) 'x' - sage: p.objective_coefficient(3) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(3) 1.0 """ raise NotImplementedError() @@ -123,28 +124,30 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p.add_variables(5) 4 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 5 - sage: p.add_variables(2, lower_bound=-2.0, integer=True, names=['a','b']) # optional - Nonexistent_LP_solver + sage: p.add_variables(2, lower_bound=-2.0, integer=True, names=['a','b']) 6 TESTS: Check that arguments are used:: - sage: p.col_bounds(5) # tol 1e-8, optional - Nonexistent_LP_solver + sage: # optional - nonexistent_lp_solver + sage: p.col_bounds(5) (-2.0, None) - sage: p.is_variable_integer(5) # optional - Nonexistent_LP_solver + sage: p.is_variable_integer(5) True - sage: p.col_name(5) # optional - Nonexistent_LP_solver + sage: p.col_name(5) 'a' - sage: p.objective_coefficient(5) # tol 1e-8, optional - Nonexistent_LP_solver + sage: p.objective_coefficient(5) 42.0 """ cdef int i @@ -223,14 +226,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.set_variable_type(0,1) # optional - Nonexistent_LP_solver - sage: p.is_variable_integer(0) # optional - Nonexistent_LP_solver + sage: p.set_variable_type(0,1) + sage: p.is_variable_integer(0) True """ raise NotImplementedError() @@ -248,12 +252,13 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p.set_sense(-1) + sage: p.is_maximization() False """ raise NotImplementedError() @@ -293,14 +298,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variable() 0 - sage: p.objective_coefficient(0) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0) 0.0 - sage: p.objective_coefficient(0,2) # optional - Nonexistent_LP_solver - sage: p.objective_coefficient(0) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0,2) + sage: p.objective_coefficient(0) 2.0 """ raise NotImplementedError() @@ -315,12 +321,13 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.objective_constant_term() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.objective_constant_term() 0.0 - sage: p.objective_constant_term(42) # optional - Nonexistent_LP_solver - sage: p.objective_constant_term() # optional - Nonexistent_LP_solver + sage: p.objective_constant_term(42) + sage: p.objective_constant_term() 42.0 """ if d is None: @@ -341,23 +348,25 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 4 - sage: p.set_objective([1, 1, 2, 1, 3]) # optional - Nonexistent_LP_solver - sage: [p.objective_coefficient(x) for x in range(5)] # optional - Nonexistent_LP_solver + sage: p.set_objective([1, 1, 2, 1, 3]) + sage: [p.objective_coefficient(x) for x in range(5)] [1.0, 1.0, 2.0, 1.0, 3.0] Constants in the objective function are respected:: - sage: p = MixedIntegerLinearProgram(solver='Nonexistent_LP_solver') # optional - Nonexistent_LP_solver - sage: x,y = p[0], p[1] # optional - Nonexistent_LP_solver - sage: p.add_constraint(2*x + 3*y, max = 6) # optional - Nonexistent_LP_solver - sage: p.add_constraint(3*x + 2*y, max = 6) # optional - Nonexistent_LP_solver - sage: p.set_objective(x + y + 7) # optional - Nonexistent_LP_solver - sage: p.set_integer(x); p.set_integer(y) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: # optional - nonexistent_lp_solver + sage: p = MixedIntegerLinearProgram(solver='Nonexistent_LP_solver') + sage: x,y = p[0], p[1] + sage: p.add_constraint(2*x + 3*y, max = 6) + sage: p.add_constraint(3*x + 2*y, max = 6) + sage: p.set_objective(x + y + 7) + sage: p.set_integer(x); p.set_integer(y) + sage: p.solve() 9.0 """ raise NotImplementedError() @@ -388,19 +397,20 @@ cdef class GenericBackend: EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: v = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver - sage: x,y = v[0], v[1] # optional - Nonexistent_LP_solver - sage: p.add_constraint(2*x + 3*y, max = 6) # optional - Nonexistent_LP_solver - sage: p.add_constraint(3*x + 2*y, max = 6) # optional - Nonexistent_LP_solver - sage: p.set_objective(x + y + 7) # optional - Nonexistent_LP_solver - sage: p.set_integer(x); p.set_integer(y) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: # optional - nonexistent_lp_solver + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") + sage: v = p.new_variable(nonnegative=True) + sage: x,y = v[0], v[1] + sage: p.add_constraint(2*x + 3*y, max = 6) + sage: p.add_constraint(3*x + 2*y, max = 6) + sage: p.set_objective(x + y + 7) + sage: p.set_integer(x); p.set_integer(y) + sage: p.solve() 9.0 - sage: p.remove_constraint(0) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.remove_constraint(0) + sage: p.solve() 10.0 - sage: p.get_values([x,y]) # optional - Nonexistent_LP_solver + sage: p.get_values([x,y]) [0.0, 3.0] """ raise NotImplementedError() @@ -415,13 +425,14 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint([(0, 2), (1, 3)], None, 6) # optional - Nonexistent_LP_solver - sage: p.add_linear_constraint([(0, 3), (1, 2)], None, 6) # optional - Nonexistent_LP_solver - sage: p.remove_constraints([0, 1]) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0, 2), (1, 3)], None, 6) + sage: p.add_linear_constraint([(0, 3), (1, 2)], None, 6) + sage: p.remove_constraints([0, 1]) """ if isinstance(constraints, int): self.remove_constraint(constraints) @@ -452,17 +463,18 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint( zip(range(5), range(5)), 2.0, 2.0) # optional - Nonexistent_LP_solver - sage: p.row(0) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint( zip(range(5), range(5)), 2.0, 2.0) + sage: p.row(0) ([0, 1, 2, 3, 4], [0.0, 1.0, 2.0, 3.0, 4.0]) - sage: p.row_bounds(0) # optional - Nonexistent_LP_solver + sage: p.row_bounds(0) (2.0, 2.0) - sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name='foo') # optional - Nonexistent_LP_solver - sage: p.row_name(1) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name='foo') + sage: p.row_name(1) 'foo' """ raise NotImplementedError('add_linear_constraint') @@ -569,15 +581,16 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p.nrows() 0 - sage: p.add_linear_constraints(5, 0, None) # optional - Nonexistent_LP_solver - sage: p.add_col(list(range(5)), list(range(5))) # optional - Nonexistent_LP_solver - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraints(5, 0, None) + sage: p.add_col(list(range(5)), list(range(5))) + sage: p.nrows() 5 """ raise NotImplementedError() @@ -622,14 +635,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 5 - sage: p.add_linear_constraints(5, None, 2) # optional - Nonexistent_LP_solver - sage: p.row(4) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraints(5, None, 2) + sage: p.row(4) ([], []) - sage: p.row_bounds(4) # optional - Nonexistent_LP_solver + sage: p.row_bounds(4) (None, 2.0) """ cdef int i @@ -686,14 +700,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_linear_constraints(5, 0, None) # optional - Nonexistent_LP_solver - sage: p.add_col(list(range(5)), list(range(5))) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_linear_constraints(5, 0, None) + sage: p.add_col(list(range(5)), list(range(5))) + sage: p.solve() 0 - sage: p.objective_coefficient(0,1) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0,1) + sage: p.solve() Traceback (most recent call last): ... MIPSolverException: ... @@ -739,19 +754,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: p.get_objective_value() # optional - Nonexistent_LP_solver + sage: p.get_objective_value() 7.5 - sage: p.get_variable_value(0) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(0) 0.0 - sage: p.get_variable_value(1) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(1) 1.5 """ @@ -774,17 +790,18 @@ cdef class GenericBackend: EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: b = p.new_variable(binary=True) # optional - Nonexistent_LP_solver - sage: for u,v in graphs.CycleGraph(5).edges(labels=False): # optional - Nonexistent_LP_solver + sage: # optional - nonexistent_lp_solver + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") + sage: b = p.new_variable(binary=True) + sage: for u,v in graphs.CycleGraph(5).edges(labels=False): ....: p.add_constraint(b[u]+b[v]<=1) - sage: p.set_objective(p.sum(b[x] for x in range(5))) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.set_objective(p.sum(b[x] for x in range(5))) + sage: p.solve() 2.0 - sage: pb = p.get_backend() # optional - Nonexistent_LP_solver - sage: pb.get_objective_value() # optional - Nonexistent_LP_solver + sage: pb = p.get_backend() + sage: pb.get_objective_value() 2.0 - sage: pb.best_known_objective_bound() # optional - Nonexistent_LP_solver + sage: pb.best_known_objective_bound() 2.0 """ raise NotImplementedError() @@ -809,17 +826,18 @@ cdef class GenericBackend: EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: b = p.new_variable(binary=True) # optional - Nonexistent_LP_solver - sage: for u,v in graphs.CycleGraph(5).edges(labels=False): # optional - Nonexistent_LP_solver + sage: # optional - nonexistent_lp_solver + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") + sage: b = p.new_variable(binary=True) + sage: for u,v in graphs.CycleGraph(5).edges(labels=False): ....: p.add_constraint(b[u]+b[v]<=1) - sage: p.set_objective(p.sum(b[x] for x in range(5))) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.set_objective(p.sum(b[x] for x in range(5))) + sage: p.solve() 2.0 - sage: pb = p.get_backend() # optional - Nonexistent_LP_solver - sage: pb.get_objective_value() # optional - Nonexistent_LP_solver + sage: pb = p.get_backend() + sage: pb.get_objective_value() 2.0 - sage: pb.get_relative_objective_gap() # optional - Nonexistent_LP_solver + sage: pb.get_relative_objective_gap() 0.0 """ raise NotImplementedError() @@ -835,19 +853,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: p.get_objective_value() # optional - Nonexistent_LP_solver + sage: p.get_objective_value() 7.5 - sage: p.get_variable_value(0) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(0) 0.0 - sage: p.get_variable_value(1) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(1) 1.5 """ @@ -859,13 +878,14 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p.add_variables(2) 1 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 2 """ @@ -885,12 +905,13 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.nrows() 0 - sage: p.add_linear_constraints(2, 2.0, None) # optional - Nonexistent_LP_solver - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraints(2, 2.0, None) + sage: p.nrows() 2 """ @@ -902,12 +923,13 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p.set_sense(-1) + sage: p.is_maximization() False """ raise NotImplementedError() @@ -942,14 +964,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 2 - sage: p.add_linear_constraint([(0, 1], (1, 2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: from tempfile import NamedTemporaryFile # optional - Nonexistent_LP_solver - sage: with NamedTemporaryFile(suffix=".lp") as f: # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0, 1], (1, 2)], None, 3) + sage: p.set_objective([2, 5]) + sage: from tempfile import NamedTemporaryFile + sage: with NamedTemporaryFile(suffix=".lp") as f: ....: p.write_lp(f.name) """ raise NotImplementedError() @@ -964,14 +987,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 2 - sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: from tempfile import NamedTemporaryFile # optional - Nonexistent_LP_solver - sage: with NamedTemporaryFile(suffix=".lp") as f: # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3) + sage: p.set_objective([2, 5]) + sage: from tempfile import NamedTemporaryFile + sage: with NamedTemporaryFile(suffix=".lp") as f: ....: p.write_lp(f.name) """ @@ -983,12 +1007,13 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: b = p.new_variable() # optional - Nonexistent_LP_solver - sage: p.add_constraint(b[1] + b[2] <= 6) # optional - Nonexistent_LP_solver - sage: p.set_objective(b[1] + b[2]) # optional - Nonexistent_LP_solver - sage: copy(p).solve() # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: b = p.new_variable() + sage: p.add_constraint(b[1] + b[2] <= 6) + sage: p.set_objective(b[1] + b[2]) + sage: copy(p).solve() 6.0 """ return self.__copy__() @@ -1000,15 +1025,16 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: b = p.new_variable() # optional - Nonexistent_LP_solver - sage: p.add_constraint(b[1] + b[2] <= 6) # optional - Nonexistent_LP_solver - sage: p.set_objective(b[1] + b[2]) # optional - Nonexistent_LP_solver - sage: cp = copy(p.get_backend()) # optional - Nonexistent_LP_solver - sage: cp.solve() # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: b = p.new_variable() + sage: p.add_constraint(b[1] + b[2] <= 6) + sage: p.set_objective(b[1] + b[2]) + sage: cp = copy(p.get_backend()) + sage: cp.solve() 0 - sage: cp.get_objective_value() # optional - Nonexistent_LP_solver + sage: cp.get_objective_value() 6.0 """ raise NotImplementedError() @@ -1019,15 +1045,16 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: b = p.new_variable() # optional - Nonexistent_LP_solver - sage: p.add_constraint(b[1] + b[2] <= 6) # optional - Nonexistent_LP_solver - sage: p.set_objective(b[1] + b[2]) # optional - Nonexistent_LP_solver - sage: cp = deepcopy(p.get_backend()) # optional - Nonexistent_LP_solver - sage: cp.solve() # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: b = p.new_variable() + sage: p.add_constraint(b[1] + b[2] <= 6) + sage: p.set_objective(b[1] + b[2]) + sage: cp = deepcopy(p.get_backend()) + sage: cp.solve() 0 - sage: cp.get_objective_value() # optional - Nonexistent_LP_solver + sage: cp.get_objective_value() 6.0 """ return self.__copy__() @@ -1049,14 +1076,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) # optional - Nonexistent_LP_solver - sage: p.row(0) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) + sage: p.row(0) ([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0]) ## FIXME: Why backwards? - sage: p.row_bounds(0) # optional - Nonexistent_LP_solver + sage: p.row_bounds(0) (2.0, 2.0) """ raise NotImplementedError() @@ -1077,14 +1105,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(list(range(5)), list(range(5)), 2, 2) # optional - Nonexistent_LP_solver - sage: p.row(0) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint(list(range(5)), list(range(5)), 2, 2) + sage: p.row(0) ([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0]) ## FIXME: Why backwards? - sage: p.row_bounds(0) # optional - Nonexistent_LP_solver + sage: p.row_bounds(0) (2.0, 2.0) """ raise NotImplementedError() @@ -1105,14 +1134,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_upper_bound(0, 5) # optional - Nonexistent_LP_solver - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.variable_upper_bound(0, 5) + sage: p.col_bounds(0) (0.0, 5.0) """ raise NotImplementedError() @@ -1127,14 +1157,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.set_variable_type(0,0) # optional - Nonexistent_LP_solver - sage: p.is_variable_binary(0) # optional - Nonexistent_LP_solver + sage: p.set_variable_type(0,0) + sage: p.is_variable_binary(0) True """ @@ -1150,14 +1181,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.set_variable_type(0,1) # optional - Nonexistent_LP_solver - sage: p.is_variable_integer(0) # optional - Nonexistent_LP_solver + sage: p.set_variable_type(0,1) + sage: p.is_variable_integer(0) True """ raise NotImplementedError() @@ -1172,16 +1204,17 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.is_variable_continuous(0) # optional - Nonexistent_LP_solver + sage: p.is_variable_continuous(0) True - sage: p.set_variable_type(0,1) # optional - Nonexistent_LP_solver - sage: p.is_variable_continuous(0) # optional - Nonexistent_LP_solver + sage: p.set_variable_type(0,1) + sage: p.is_variable_continuous(0) False """ @@ -1323,14 +1356,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_upper_bound(0, 5) # optional - Nonexistent_LP_solver - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.variable_upper_bound(0, 5) + sage: p.col_bounds(0) (0.0, 5.0) """ raise NotImplementedError() @@ -1349,14 +1383,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variable() 0 - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.col_bounds(0) (0.0, None) - sage: p.variable_lower_bound(0, 5) # optional - Nonexistent_LP_solver - sage: p.col_bounds(0) # optional - Nonexistent_LP_solver + sage: p.variable_lower_bound(0, 5) + sage: p.col_bounds(0) (5.0, None) """ raise NotImplementedError() @@ -1379,11 +1414,12 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit") # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit", 60) # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.solver_parameter("timelimit") + sage: p.solver_parameter("timelimit", 60) + sage: p.solver_parameter("timelimit") """ raise NotImplementedError() @@ -1400,19 +1436,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver - sage: p.add_constraint(-x[0] + x[1] <= 2) # optional - Nonexistent_LP_solver - sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) # optional - Nonexistent_LP_solver - sage: p.set_objective(5.5 * x[0] - 3 * x[1]) # optional - Nonexistent_LP_solver - sage: b = p.get_backend() # optional - Nonexistent_LP_solver + sage: x = p.new_variable(nonnegative=True) + sage: p.add_constraint(-x[0] + x[1] <= 2) + sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) + sage: p.set_objective(5.5 * x[0] - 3 * x[1]) + sage: b = p.get_backend() sage: # Backend-specific commands to instruct solver to use simplex method here - sage: b.solve() # optional - Nonexistent_LP_solver + sage: b.solve() 0 - sage: b.is_variable_basic(0) # optional - Nonexistent_LP_solver + sage: b.is_variable_basic(0) True - sage: b.is_variable_basic(1) # optional - Nonexistent_LP_solver + sage: b.is_variable_basic(1) False """ raise NotImplementedError() @@ -1430,19 +1467,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver - sage: p.add_constraint(-x[0] + x[1] <= 2) # optional - Nonexistent_LP_solver - sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) # optional - Nonexistent_LP_solver - sage: p.set_objective(5.5 * x[0] - 3 * x[1]) # optional - Nonexistent_LP_solver - sage: b = p.get_backend() # optional - Nonexistent_LP_solver + sage: x = p.new_variable(nonnegative=True) + sage: p.add_constraint(-x[0] + x[1] <= 2) + sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) + sage: p.set_objective(5.5 * x[0] - 3 * x[1]) + sage: b = p.get_backend() sage: # Backend-specific commands to instruct solver to use simplex method here - sage: b.solve() # optional - Nonexistent_LP_solver + sage: b.solve() 0 - sage: b.is_variable_nonbasic_at_lower_bound(0) # optional - Nonexistent_LP_solver + sage: b.is_variable_nonbasic_at_lower_bound(0) False - sage: b.is_variable_nonbasic_at_lower_bound(1) # optional - Nonexistent_LP_solver + sage: b.is_variable_nonbasic_at_lower_bound(1) True """ raise NotImplementedError() @@ -1460,19 +1498,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver - sage: p.add_constraint(-x[0] + x[1] <= 2) # optional - Nonexistent_LP_solver - sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) # optional - Nonexistent_LP_solver - sage: p.set_objective(5.5 * x[0] - 3 * x[1]) # optional - Nonexistent_LP_solver - sage: b = p.get_backend() # optional - Nonexistent_LP_solver + sage: x = p.new_variable(nonnegative=True) + sage: p.add_constraint(-x[0] + x[1] <= 2) + sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) + sage: p.set_objective(5.5 * x[0] - 3 * x[1]) + sage: b = p.get_backend() sage: # Backend-specific commands to instruct solver to use simplex method here - sage: b.solve() # optional - Nonexistent_LP_solver + sage: b.solve() 0 - sage: b.is_slack_variable_basic(0) # optional - Nonexistent_LP_solver + sage: b.is_slack_variable_basic(0) True - sage: b.is_slack_variable_basic(1) # optional - Nonexistent_LP_solver + sage: b.is_slack_variable_basic(1) False """ raise NotImplementedError() @@ -1490,19 +1529,20 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: p = MixedIntegerLinearProgram(maximization=True,\ solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable(nonnegative=True) # optional - Nonexistent_LP_solver - sage: p.add_constraint(-x[0] + x[1] <= 2) # optional - Nonexistent_LP_solver - sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) # optional - Nonexistent_LP_solver - sage: p.set_objective(5.5 * x[0] - 3 * x[1]) # optional - Nonexistent_LP_solver - sage: b = p.get_backend() # optional - Nonexistent_LP_solver + sage: x = p.new_variable(nonnegative=True) + sage: p.add_constraint(-x[0] + x[1] <= 2) + sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) + sage: p.set_objective(5.5 * x[0] - 3 * x[1]) + sage: b = p.get_backend() sage: # Backend-specific commands to instruct solver to use simplex method here - sage: b.solve() # optional - Nonexistent_LP_solver + sage: b.solve() 0 - sage: b.is_slack_variable_nonbasic_at_lower_bound(0) # optional - Nonexistent_LP_solver + sage: b.is_slack_variable_nonbasic_at_lower_bound(0) False - sage: b.is_slack_variable_nonbasic_at_lower_bound(1) # optional - Nonexistent_LP_solver + sage: b.is_slack_variable_nonbasic_at_lower_bound(1) True """ raise NotImplementedError() @@ -1728,18 +1768,18 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba <...sage.numerical.backends.ppl_backend.PPLBackend...> sage: p.base_ring() Rational Field - sage: p = get_solver(base_ring=AA); p # optional - sage.rings.number_field + sage: p = get_solver(base_ring=AA); p # needs sage.rings.number_field <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> - sage: p.base_ring() # optional - sage.rings.number_field + sage: p.base_ring() # needs sage.rings.number_field Algebraic Real Field - sage: d = polytopes.dodecahedron() # optional - sage.rings.number_field - sage: p = get_solver(base_ring=d.base_ring()); p # optional - sage.rings.number_field + sage: d = polytopes.dodecahedron() # needs sage.rings.number_field + sage: p = get_solver(base_ring=d.base_ring()); p # needs sage.rings.number_field <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> - sage: p.base_ring() # optional - sage.rings.number_field + sage: p.base_ring() # needs sage.rings.number_field Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? - sage: p = get_solver(solver='InteractiveLP', base_ring=QQ); p # optional - sage.rings.number_field + sage: p = get_solver(solver='InteractiveLP', base_ring=QQ); p # needs sage.rings.number_field <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> - sage: p.base_ring() # optional - sage.rings.number_field + sage: p.base_ring() # needs sage.rings.number_field Rational Field Passing a callable as the 'solver':: diff --git a/src/sage/numerical/backends/generic_sdp_backend.pyx b/src/sage/numerical/backends/generic_sdp_backend.pyx index bad0e3511e2..599235f808a 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pyx +++ b/src/sage/numerical/backends/generic_sdp_backend.pyx @@ -71,19 +71,20 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p.add_variable() 0 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 1 - sage: p.add_variable(name='x',obj=1.0) # optional - Nonexistent_LP_solver + sage: p.add_variable(name='x',obj=1.0) 3 - sage: p.col_name(3) # optional - Nonexistent_LP_solver + sage: p.col_name(3) 'x' - sage: p.objective_coefficient(3) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(3) 1.0 """ raise NotImplementedError() @@ -107,15 +108,16 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p.add_variables(5) 4 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 5 - sage: p.add_variables(2, lower_bound=-2.0, integer=True, names=['a','b']) # optional - Nonexistent_LP_solver + sage: p.add_variables(2, lower_bound=-2.0, integer=True, names=['a','b']) 6 """ raise NotImplementedError() @@ -133,12 +135,13 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p.set_sense(-1) + sage: p.is_maximization() False """ raise NotImplementedError() @@ -156,14 +159,15 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variable() 1 - sage: p.objective_coefficient(0) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0) 0.0 - sage: p.objective_coefficient(0,2) # optional - Nonexistent_LP_solver - sage: p.objective_coefficient(0) # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0,2) + sage: p.objective_coefficient(0) 2.0 """ raise NotImplementedError() @@ -181,12 +185,13 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 5 - sage: p.set_objective([1, 1, 2, 1, 3]) # optional - Nonexistent_LP_solver - sage: [p.objective_coefficient(x) for x in range(5)] # optional - Nonexistent_LP_solver + sage: p.set_objective([1, 1, 2, 1, 3]) + sage: [p.objective_coefficient(x) for x in range(5)] [1.0, 1.0, 2.0, 1.0, 3.0] Constants in the objective function are respected. @@ -212,17 +217,18 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 4 - sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) # optional - Nonexistent_LP_solver - sage: p.row(0) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) + sage: p.row(0) ([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0]) # optional - Nonexistent_LP_solver - sage: p.row_bounds(0) # optional - Nonexistent_LP_solver + sage: p.row_bounds(0) (2.0, 2.0) - sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name='foo') # optional - Nonexistent_LP_solver - sage: p.row_name(-1) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name='foo') + sage: p.row_name(-1) "foo" """ raise NotImplementedError() @@ -244,14 +250,15 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 5 - sage: p.add_linear_constraints(5, None, 2) # optional - Nonexistent_LP_solver - sage: p.row(4) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraints(5, None, 2) + sage: p.row(4) ([], []) - sage: p.row_bounds(4) # optional - Nonexistent_LP_solver + sage: p.row_bounds(4) (None, 2.0) """ raise NotImplementedError() @@ -268,14 +275,15 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_linear_constraints(5, 0, None) # optional - Nonexistent_LP_solver - sage: p.add_col(range(5), range(5)) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_linear_constraints(5, 0, None) + sage: p.add_col(range(5), range(5)) + sage: p.solve() 0 - sage: p.objective_coefficient(0,1) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.objective_coefficient(0,1) + sage: p.solve() Traceback (most recent call last): ... SDPSolverException: ... @@ -292,19 +300,20 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 2 - sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: p.get_objective_value() # optional - Nonexistent_LP_solver + sage: p.get_objective_value() 7.5 - sage: p.get_variable_value(0) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(0) 0.0 - sage: p.get_variable_value(1) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(1) 1.5 """ @@ -320,19 +329,20 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(2) 2 - sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) # optional - Nonexistent_LP_solver - sage: p.set_objective([2, 5]) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) + sage: p.set_objective([2, 5]) + sage: p.solve() 0 - sage: p.get_objective_value() # optional - Nonexistent_LP_solver + sage: p.get_objective_value() 7.5 - sage: p.get_variable_value(0) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(0) 0.0 - sage: p.get_variable_value(1) # optional - Nonexistent_LP_solver + sage: p.get_variable_value(1) 1.5 """ @@ -344,13 +354,14 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.ncols() 0 - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p.add_variables(2) 2 - sage: p.ncols() # optional - Nonexistent_LP_solver + sage: p.ncols() 2 """ @@ -362,12 +373,13 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.nrows() 0 - sage: p.add_linear_constraints(2, 2.0, None) # optional - Nonexistent_LP_solver - sage: p.nrows() # optional - Nonexistent_LP_solver + sage: p.add_linear_constraints(2, 2.0, None) + sage: p.nrows() 2 """ @@ -379,12 +391,13 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.is_maximization() True - sage: p.set_sense(-1) # optional - Nonexistent_LP_solver - sage: p.is_maximization() # optional - Nonexistent_LP_solver + sage: p.set_sense(-1) + sage: p.is_maximization() False """ raise NotImplementedError() @@ -426,14 +439,15 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variables(5) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.add_variables(5) 5 - sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) # optional - Nonexistent_LP_solver - sage: p.row(0) # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) + sage: p.row(0) ([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0]) - sage: p.row_bounds(0) # optional - Nonexistent_LP_solver + sage: p.row_bounds(0) (2.0, 2.0) """ raise NotImplementedError() @@ -495,24 +509,25 @@ cdef class GenericSDPBackend: EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable() # optional - Nonexistent_LP_solver - sage: p.set_objective(x[0] - x[1]) # optional - Nonexistent_LP_solver - sage: a1 = matrix([[1, 2.], [2., 3.]]) # optional - Nonexistent_LP_solver - sage: a2 = matrix([[3, 4.], [4., 5.]]) # optional - Nonexistent_LP_solver - sage: a3 = matrix([[5, 6.], [6., 7.]]) # optional - Nonexistent_LP_solver - sage: b1 = matrix([[1, 1.], [1., 1.]]) # optional - Nonexistent_LP_solver - sage: b2 = matrix([[2, 2.], [2., 2.]]) # optional - Nonexistent_LP_solver - sage: b3 = matrix([[3, 3.], [3., 3.]]) # optional - Nonexistent_LP_solver - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - Nonexistent_LP_solver - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver # tol ??? + sage: # optional - nonexistent_lp_solver + sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1]) + sage: a1 = matrix([[1, 2.], [2., 3.]]) + sage: a2 = matrix([[3, 4.], [4., 5.]]) + sage: a3 = matrix([[5, 6.], [6., 7.]]) + sage: b1 = matrix([[1, 1.], [1., 1.]]) + sage: b2 = matrix([[2, 2.], [2., 2.]]) + sage: b3 = matrix([[3, 3.], [3., 3.]]) + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: p.solve() -3.0 - sage: B=p.get_backend() # optional - Nonexistent_LP_solver - sage: x=p.get_values(x).values() # optional - Nonexistent_LP_solver - sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() # optional - Nonexistent_LP_solver # tol ??? + sage: B=p.get_backend() + sage: x=p.get_values(x).values() + sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() -3.0 - sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g # optional - Nonexistent_LP_solver # tol ??? + sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g 0.0 TESTS:: @@ -541,27 +556,28 @@ cdef class GenericSDPBackend: EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: x = p.new_variable() # optional - Nonexistent_LP_solver - sage: p.set_objective(x[0] - x[1]) # optional - Nonexistent_LP_solver - sage: a1 = matrix([[1, 2.], [2., 3.]]) # optional - Nonexistent_LP_solver - sage: a2 = matrix([[3, 4.], [4., 5.]]) # optional - Nonexistent_LP_solver - sage: a3 = matrix([[5, 6.], [6., 7.]]) # optional - Nonexistent_LP_solver - sage: b1 = matrix([[1, 1.], [1., 1.]]) # optional - Nonexistent_LP_solver - sage: b2 = matrix([[2, 2.], [2., 2.]]) # optional - Nonexistent_LP_solver - sage: b3 = matrix([[3, 3.], [3., 3.]]) # optional - Nonexistent_LP_solver - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - Nonexistent_LP_solver - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - Nonexistent_LP_solver - sage: p.solve() # optional - Nonexistent_LP_solver # tol ??? + sage: # optional - nonexistent_lp_solver + sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1]) + sage: a1 = matrix([[1, 2.], [2., 3.]]) + sage: a2 = matrix([[3, 4.], [4., 5.]]) + sage: a3 = matrix([[5, 6.], [6., 7.]]) + sage: b1 = matrix([[1, 1.], [1., 1.]]) + sage: b2 = matrix([[2, 2.], [2., 2.]]) + sage: b3 = matrix([[3, 3.], [3., 3.]]) + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: p.solve() -3.0 - sage: B=p.get_backend() # optional - Nonexistent_LP_solver - sage: B1 = B.slack(1); B1 # optional - Nonexistent_LP_solver # tol ??? + sage: B=p.get_backend() + sage: B1 = B.slack(1); B1 [0.0 0.0] [0.0 0.0] - sage: B1.is_positive_definite() # optional - Nonexistent_LP_solver + sage: B1.is_positive_definite() True - sage: x = p.get_values(x).values() # optional - Nonexistent_LP_solver - sage: x[0]*b1 + x[1]*b2 - b3 + B1 # optional - Nonexistent_LP_solver # tol ??? + sage: x = p.get_values(x).values() + sage: x[0]*b1 + x[1]*b2 - b3 + B1 [0.0 0.0] [0.0 0.0] @@ -593,11 +609,12 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit") # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit", 60) # optional - Nonexistent_LP_solver - sage: p.solver_parameter("timelimit") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p.solver_parameter("timelimit") + sage: p.solver_parameter("timelimit", 60) + sage: p.solver_parameter("timelimit") """ raise NotImplementedError() diff --git a/src/sage/numerical/backends/interactivelp_backend.pyx b/src/sage/numerical/backends/interactivelp_backend.pyx index 665631f19de..3062a29eb1f 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pyx +++ b/src/sage/numerical/backends/interactivelp_backend.pyx @@ -53,17 +53,18 @@ cdef class InteractiveLPBackend: This backend can work with irrational algebraic numbers:: - sage: poly = polytopes.dodecahedron(base_ring=AA) # optional - sage.rings.number_field - sage: lp, x = poly.to_linear_program(solver='InteractiveLP', return_variable=True) # optional - sage.rings.number_field - sage: lp.set_objective(x[0] + x[1] + x[2]) # optional - sage.rings.number_field - sage: lp.solve() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: poly = polytopes.dodecahedron(base_ring=AA) + sage: lp, x = poly.to_linear_program(solver='InteractiveLP', return_variable=True) + sage: lp.set_objective(x[0] + x[1] + x[2]) + sage: lp.solve() 2.291796067500631? - sage: lp.get_values(x[0], x[1], x[2]) # optional - sage.rings.number_field + sage: lp.get_values(x[0], x[1], x[2]) [0.763932022500211?, 0.763932022500211?, 0.763932022500211?] - sage: lp.set_objective(x[0] - x[1] - x[2]) # optional - sage.rings.number_field - sage: lp.solve() # optional - sage.rings.number_field + sage: lp.set_objective(x[0] - x[1] - x[2]) + sage: lp.solve() 2.291796067500631? - sage: lp.get_values(x[0], x[1], x[2]) # optional - sage.rings.number_field + sage: lp.get_values(x[0], x[1], x[2]) [0.763932022500211?, -0.763932022500211?, -0.763932022500211?] """ diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index 7d55ba35137..f3ba2f97236 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -62,7 +62,7 @@ cdef class PPLBackend(GenericBackend): Raise an error if a ``base_ring`` is requested that is not supported:: - sage: p = MixedIntegerLinearProgram(solver="PPL", base_ring=AA) # optional - sage.rings.number_field + sage: p = MixedIntegerLinearProgram(solver="PPL", base_ring=AA) # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: The PPL backend only supports rational data. diff --git a/src/sage/numerical/gauss_legendre.pyx b/src/sage/numerical/gauss_legendre.pyx index d1d83161363..81bb5f36af5 100644 --- a/src/sage/numerical/gauss_legendre.pyx +++ b/src/sage/numerical/gauss_legendre.pyx @@ -79,11 +79,11 @@ def nodes_uncached(degree, prec): sage: from sage.numerical.gauss_legendre import nodes_uncached sage: L1 = nodes_uncached(24, 53) - sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # optional - sage.symbolic - sage: Pdif = P.diff() # optional - sage.symbolic - sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # optional - sage.symbolic + sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # needs sage.symbolic + sage: Pdif = P.diff() # needs sage.symbolic + sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # needs sage.symbolic ....: for r, _ in RR['x'](P).roots()] - sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # optional - sage.symbolic + sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # needs sage.symbolic ....: for a, b in zip(L1, L2)) True @@ -188,11 +188,11 @@ def nodes(degree, prec): sage: from sage.numerical.gauss_legendre import nodes sage: L1 = nodes(24, 53) - sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # optional - sage.symbolic - sage: Pdif = P.diff() # optional - sage.symbolic - sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # optional - sage.symbolic + sage: P = RR['x'](sage.functions.orthogonal_polys.legendre_P(24, x)) # needs sage.symbolic + sage: Pdif = P.diff() # needs sage.symbolic + sage: L2 = [((r + 1)/2, 1/(1 - r^2)/Pdif(r)^2) # needs sage.symbolic ....: for r, _ in RR['x'](P).roots()] - sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # optional - sage.symbolic + sage: all((a[0] - b[0]).abs() < 1e-15 and (a[1] - b[1]).abs() < 1e-9 # needs sage.symbolic ....: for a, b in zip(L1, L2)) True @@ -343,8 +343,8 @@ def integrate_vector(f, prec, epsilon=None): sage: epsilon = K(2^(-prec + 4)) sage: f = lambda t:V((1 + t^2, 1/(1 + t^2))) sage: I = integrate_vector(f, prec, epsilon=epsilon) - sage: J = V((4/3, pi/4)) # optional - sage.symbolic - sage: max(c.abs() for c in (I - J)) < epsilon # optional - sage.symbolic + sage: J = V((4/3, pi/4)) # needs sage.symbolic + sage: max(c.abs() for c in (I - J)) < epsilon # needs sage.symbolic True We can also use complex-valued integrands:: @@ -354,10 +354,10 @@ def integrate_vector(f, prec, epsilon=None): sage: K = ComplexField(prec) sage: V = VectorSpace(K, 2) sage: epsilon = Kreal(2^(-prec + 4)) - sage: f = lambda t: V((t, K(exp(2*pi*t*K.0)))) # optional - sage.symbolic - sage: I = integrate_vector(f, prec, epsilon=epsilon) # optional - sage.symbolic + sage: f = lambda t: V((t, K(exp(2*pi*t*K.0)))) # needs sage.symbolic + sage: I = integrate_vector(f, prec, epsilon=epsilon) # needs sage.symbolic sage: J = V((1/2, 0)) - sage: max(c.abs() for c in (I - J)) < epsilon # optional - sage.symbolic + sage: max(c.abs() for c in (I - J)) < epsilon # needs sage.symbolic True """ results = [] diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py index 49f0fe351dc..c2a10d6a4f6 100644 --- a/src/sage/numerical/interactive_simplex_method.py +++ b/src/sage/numerical/interactive_simplex_method.py @@ -64,7 +64,7 @@ Since it has only two variables, we can solve it graphically:: - sage: P.plot() # optional - sage.plot + sage: P.plot() # needs sage.plot Graphics object consisting of 19 graphics primitives @@ -298,9 +298,9 @@ def _latex_product(coefficients, variables, sage: from sage.numerical.interactive_simplex_method import \ ....: _latex_product - sage: var("x, y") # optional - sage.symbolic + sage: var("x, y") # needs sage.symbolic (x, y) - sage: print(_latex_product([-1, 3], [x, y])) # optional - sage.symbolic + sage: print(_latex_product([-1, 3], [x, y])) # needs sage.symbolic - \mspace{-6mu}&\mspace{-6mu} x \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 3 y """ entries = [] @@ -1534,19 +1534,19 @@ def plot(self, *args, **kwds): sage: b = (1000, 1500) sage: c = (10, 5) sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=") - sage: p = P.plot() # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot() # needs sage.plot + sage: p.show() # needs sage.plot In this case the plot works better with the following axes ranges:: - sage: p = P.plot(0, 1000, 0, 1500) # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot(0, 1000, 0, 1500) # needs sage.plot + sage: p.show() # needs sage.plot TESTS: We check that zero objective can be dealt with:: - sage: InteractiveLPProblem(A, b, (0, 0), ["C", "B"], variable_type=">=").plot() # optional - sage.plot + sage: InteractiveLPProblem(A, b, (0, 0), ["C", "B"], variable_type=">=").plot() # needs sage.plot Graphics object consisting of 8 graphics primitives """ FP = self.plot_feasible_set(*args, **kwds) @@ -1611,13 +1611,13 @@ def plot_feasible_set(self, xmin=None, xmax=None, ymin=None, ymax=None, sage: b = (1000, 1500) sage: c = (10, 5) sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=") - sage: p = P.plot_feasible_set() # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot_feasible_set() # needs sage.plot + sage: p.show() # needs sage.plot In this case the plot works better with the following axes ranges:: - sage: p = P.plot_feasible_set(0, 1000, 0, 1500) # optional - sage.plot - sage: p.show() # optional - sage.plot + sage: p = P.plot_feasible_set(0, 1000, 0, 1500) # needs sage.plot + sage: p.show() # needs sage.plot """ if self.n() != 2: raise ValueError("only problems with 2 variables can be plotted") diff --git a/src/sage/numerical/knapsack.py b/src/sage/numerical/knapsack.py index b6d3abe3ce5..3f80f517998 100644 --- a/src/sage/numerical/knapsack.py +++ b/src/sage/numerical/knapsack.py @@ -408,14 +408,15 @@ def is_superincreasing(self, seq=None): The sequence must contain only integers:: + sage: # needs sage.symbolic sage: from sage.numerical.knapsack import Superincreasing - sage: L = [1.0, 2.1, pi, 21, 69, 189, 376, 919] # optional - sage.symbolic - sage: Superincreasing(L).is_superincreasing() # optional - sage.symbolic + sage: L = [1.0, 2.1, pi, 21, 69, 189, 376, 919] + sage: Superincreasing(L).is_superincreasing() Traceback (most recent call last): ... TypeError: Element e (= 1.00000000000000) of seq must be a non-negative integer. - sage: L = [1, 2.1, pi, 21, 69, 189, 376, 919] # optional - sage.symbolic - sage: Superincreasing(L).is_superincreasing() # optional - sage.symbolic + sage: L = [1, 2.1, pi, 21, 69, 189, 376, 919] + sage: Superincreasing(L).is_superincreasing() Traceback (most recent call last): ... TypeError: Element e (= 2.10000000000000) of seq must be a non-negative integer. diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 3751fe34028..5a1520f4304 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -315,13 +315,14 @@ cdef class MixedIntegerLinearProgram(SageObject): Computation of a maximum stable set in Petersen's graph:: - sage: g = graphs.PetersenGraph() # optional - sage.graphs - sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') # optional - sage.graphs - sage: b = p.new_variable(binary=True) # optional - sage.graphs - sage: p.set_objective(sum([b[v] for v in g])) # optional - sage.graphs - sage: for (u,v) in g.edges(sort=False, labels=None): # optional - sage.graphs + sage: # needs sage.graphs + sage: g = graphs.PetersenGraph() + sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') + sage: b = p.new_variable(binary=True) + sage: p.set_objective(sum([b[v] for v in g])) + sage: for (u,v) in g.edges(sort=False, labels=None): ....: p.add_constraint(b[u] + b[v], max=1) - sage: p.solve(objective_only=True) # optional - sage.graphs + sage: p.solve(objective_only=True) 4.0 TESTS: @@ -659,13 +660,13 @@ cdef class MixedIntegerLinearProgram(SageObject): sage: p = MixedIntegerLinearProgram(solver='ppl') sage: p.base_ring() Rational Field - sage: from sage.rings.qqbar import AA # optional - sage.rings.number_field - sage: p = MixedIntegerLinearProgram(solver='InteractiveLP', base_ring=AA) # optional - sage.rings.number_field - sage: p.base_ring() # optional - sage.rings.number_field + sage: from sage.rings.qqbar import AA # needs sage.rings.number_field + sage: p = MixedIntegerLinearProgram(solver='InteractiveLP', base_ring=AA) # needs sage.rings.number_field + sage: p.base_ring() # needs sage.rings.number_field Algebraic Real Field - sage: d = polytopes.dodecahedron() # optional - sage.rings.number_field - sage: p = MixedIntegerLinearProgram(base_ring=d.base_ring()) # optional - sage.rings.number_field - sage: p.base_ring() # optional - sage.rings.number_field + sage: d = polytopes.dodecahedron() # needs sage.rings.number_field + sage: p = MixedIntegerLinearProgram(base_ring=d.base_ring()) # needs sage.rings.number_field + sage: p.base_ring() # needs sage.rings.number_field Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? """ return self._backend.base_ring() @@ -2629,14 +2630,15 @@ cdef class MixedIntegerLinearProgram(SageObject): Computation of a maximum stable set in Petersen's graph:: - sage: g = graphs.PetersenGraph() # optional - sage.graphs - sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') # optional - sage.graphs - sage: b = p.new_variable(nonnegative=True) # optional - sage.graphs - sage: p.set_objective(sum([b[v] for v in g])) # optional - sage.graphs - sage: for (u,v) in g.edges(sort=False, labels=None): # optional - sage.graphs + sage: # needs sage.graphs + sage: g = graphs.PetersenGraph() + sage: p = MixedIntegerLinearProgram(maximization=True, solver='GLPK') + sage: b = p.new_variable(nonnegative=True) + sage: p.set_objective(sum([b[v] for v in g])) + sage: for (u,v) in g.edges(sort=False, labels=None): ....: p.add_constraint(b[u] + b[v], max=1) - sage: p.set_binary(b) # optional - sage.graphs - sage: p.solve(objective_only=True) # optional - sage.graphs + sage: p.set_binary(b) + sage: p.solve(objective_only=True) 4.0 Constraints in the objective function are respected:: @@ -2823,14 +2825,15 @@ cdef class MixedIntegerLinearProgram(SageObject): are not recorded, and we can disable this feature providing an empty filename. This is currently working with CPLEX and Gurobi:: - sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX - sage: p.solver_parameter("logfile") # optional - CPLEX + sage: # optional - cplex + sage: p = MixedIntegerLinearProgram(solver="CPLEX") + sage: p.solver_parameter("logfile") '' - sage: p.solver_parameter("logfile", "/dev/null") # optional - CPLEX - sage: p.solver_parameter("logfile") # optional - CPLEX + sage: p.solver_parameter("logfile", "/dev/null") + sage: p.solver_parameter("logfile") '/dev/null' - sage: p.solver_parameter("logfile", '') # optional - CPLEX - sage: p.solver_parameter("logfile") # optional - CPLEX + sage: p.solver_parameter("logfile", '') + sage: p.solver_parameter("logfile") '' Solver-specific parameters: @@ -2983,17 +2986,18 @@ cdef class MixedIntegerLinearProgram(SageObject): EXAMPLES:: - sage: g = graphs.CubeGraph(9) # optional - sage.graphs - sage: p = MixedIntegerLinearProgram(solver="GLPK") # optional - sage.graphs - sage: p.solver_parameter("mip_gap_tolerance",100) # optional - sage.graphs - sage: b = p.new_variable(binary=True) # optional - sage.graphs - sage: p.set_objective(p.sum(b[v] for v in g)) # optional - sage.graphs - sage: for v in g: # optional - sage.graphs + sage: # needs sage.graphs + sage: g = graphs.CubeGraph(9) + sage: p = MixedIntegerLinearProgram(solver="GLPK") + sage: p.solver_parameter("mip_gap_tolerance",100) + sage: b = p.new_variable(binary=True) + sage: p.set_objective(p.sum(b[v] for v in g)) + sage: for v in g: ....: p.add_constraint(b[v] + p.sum(b[u] for u in g.neighbors(v)) <= 1) - sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution # optional - sage.graphs - sage: p.solve() # rel tol 100 # optional - sage.graphs + sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution + sage: p.solve() # rel tol 100 1.0 - sage: p.best_known_objective_bound() # random # optional - sage.graphs + sage: p.best_known_objective_bound() # random 48.0 """ return self._backend.best_known_objective_bound() @@ -3017,17 +3021,18 @@ cdef class MixedIntegerLinearProgram(SageObject): EXAMPLES:: - sage: g = graphs.CubeGraph(9) # optional - sage.graphs - sage: p = MixedIntegerLinearProgram(solver="GLPK") # optional - sage.graphs - sage: p.solver_parameter("mip_gap_tolerance",100) # optional - sage.graphs - sage: b = p.new_variable(binary=True) # optional - sage.graphs - sage: p.set_objective(p.sum(b[v] for v in g)) # optional - sage.graphs - sage: for v in g: # optional - sage.graphs + sage: # needs sage.graphs + sage: g = graphs.CubeGraph(9) + sage: p = MixedIntegerLinearProgram(solver="GLPK") + sage: p.solver_parameter("mip_gap_tolerance",100) + sage: b = p.new_variable(binary=True) + sage: p.set_objective(p.sum(b[v] for v in g)) + sage: for v in g: ....: p.add_constraint(b[v] + p.sum(b[u] for u in g.neighbors(v)) <= 1) - sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution # optional - sage.graphs - sage: p.solve() # rel tol 100 # optional - sage.graphs + sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution + sage: p.solve() # rel tol 100 1.0 - sage: p.get_relative_objective_gap() # random # optional - sage.graphs + sage: p.get_relative_objective_gap() # random 46.99999999999999 TESTS: @@ -3035,7 +3040,7 @@ cdef class MixedIntegerLinearProgram(SageObject): Just make sure that the variable *has* been defined, and is not just undefined:: - sage: p.get_relative_objective_gap() > 1 # optional - sage.graphs + sage: p.get_relative_objective_gap() > 1 # needs sage.graphs True """ return self._backend.get_relative_objective_gap() diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index 483b424b4db..d5caae0da32 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -240,7 +240,7 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): (-3.28837136189098..., 3.42575079030572...) sage: find_local_minimum(f, 1, 5, tol=1e-2, maxfun=10) (-3.28837084598..., 3.4250840220...) - sage: show(plot(f, 0, 20)) # optional - sage.plot + sage: show(plot(f, 0, 20)) # needs sage.plot sage: find_local_minimum(f, 1, 15) (-9.4772942594..., 9.5293344109...) @@ -263,9 +263,9 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): numerics (observe the small number of decimal places that we actually test):: - sage: plot(f, (x, -2.5, -1)).ymin() # optional - sage.plot + sage: plot(f, (x, -2.5, -1)).ymin() # needs sage.plot -2.182... - sage: plot(f, (x, -2.5, 2)).ymin() # optional - sage.plot + sage: plot(f, (x, -2.5, 2)).ymin() # needs sage.plot -2.182... ALGORITHM: @@ -342,20 +342,20 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", Minimize a fourth order polynomial in three variables (see the :wikipedia:`Rosenbrock_function`):: - sage: vars = var('x y z') # optional - sage.symbolic - sage: f = 100*(y-x^2)^2 + (1-x)^2 + 100*(z-y^2)^2 + (1-y)^2 # optional - sage.symbolic - sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 # optional - sage.symbolic + sage: vars = var('x y z') # needs sage.symbolic + sage: f = 100*(y-x^2)^2 + (1-x)^2 + 100*(z-y^2)^2 + (1-y)^2 # needs sage.symbolic + sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 # needs sage.symbolic (1.0, 1.0, 1.0) Try the newton-conjugate gradient method; the gradient and hessian are computed automatically:: - sage: minimize(f, [.1, .3, .4], algorithm="ncg") # abs tol 1e-6 # optional - sage.symbolic + sage: minimize(f, [.1, .3, .4], algorithm="ncg") # abs tol 1e-6 # needs sage.symbolic (1.0, 1.0, 1.0) We get additional convergence information with the `verbose` option:: - sage: minimize(f, [.1, .3, .4], algorithm="ncg", verbose=True) # optional - sage.symbolic + sage: minimize(f, [.1, .3, .4], algorithm="ncg", verbose=True) # needs sage.symbolic Optimization terminated successfully. ... (0.9999999..., 0.999999..., 0.999999...) @@ -372,9 +372,9 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", sage: def rosen(x): # The Rosenbrock function ....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r) - sage: import numpy # optional - numpy - sage: from numpy import zeros # optional - numpy - sage: def rosen_der(x): # optional - numpy + sage: import numpy # needs numpy + sage: from numpy import zeros # needs numpy + sage: def rosen_der(x): # needs numpy ....: xm = x[1r:-1r] ....: xm_m1 = x[:-2r] ....: xm_p1 = x[2r:] @@ -383,7 +383,8 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", ....: der[0] = -400r*x[0r]*(x[1r]-x[0r]**2r) - 2r*(1r-x[0]) ....: der[-1] = 200r*(x[-1r]-x[-2r]**2r) ....: return der - sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, algorithm="bfgs") # abs tol 1e-6 # optional - numpy + sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, # abs tol 1e-6 # needs numpy + ....: algorithm="bfgs") (1.0, 1.0, 1.0) """ from sage.structure.element import Expression @@ -477,14 +478,14 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) Let's find a minimum of `\sin(xy)`:: - sage: x,y = var('x y') # optional - sage.symbolic - sage: f(x,y) = sin(x*y) # optional - sage.symbolic - sage: minimize_constrained(f, [(None,None),(4,10)],[5,5]) # optional - sage.symbolic + sage: x,y = var('x y') # needs sage.symbolic + sage: f(x,y) = sin(x*y) # needs sage.symbolic + sage: minimize_constrained(f, [(None,None),(4,10)],[5,5]) # needs sage.symbolic (4.8..., 4.8...) Check if L-BFGS-B finds the same minimum:: - sage: minimize_constrained(f, [(None,None),(4,10)],[5,5], # optional - sage.symbolic + sage: minimize_constrained(f, [(None,None),(4,10)],[5,5], # needs sage.symbolic ....: algorithm='l-bfgs-b') (4.7..., 4.9...) @@ -502,22 +503,24 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) Check if :trac:`6592` is fixed:: - sage: x, y = var('x y') # optional - sage.symbolic - sage: f(x,y) = (100 - x) + (1000 - y) # optional - sage.symbolic - sage: c(x,y) = x + y - 479 # > 0 # optional - sage.symbolic - sage: minimize_constrained(f, [c], [100, 300]) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x, y = var('x y') + sage: f(x,y) = (100 - x) + (1000 - y) + sage: c(x,y) = x + y - 479 # > 0 + sage: minimize_constrained(f, [c], [100, 300]) (805.985..., 1005.985...) - sage: minimize_constrained(f, c, [100, 300]) # optional - sage.symbolic + sage: minimize_constrained(f, c, [100, 300]) (805.985..., 1005.985...) If ``func`` is symbolic, its minimizer should be in the same order as its arguments (:trac:`32511`):: - sage: x,y = SR.var('x,y') # optional - sage.symbolic - sage: f(y,x) = x - y # optional - sage.symbolic - sage: c1(y,x) = x # optional - sage.symbolic - sage: c2(y,x) = 1-y # optional - sage.symbolic - sage: minimize_constrained(f, [c1, c2], (0,0)) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x,y = SR.var('x,y') + sage: f(y,x) = x - y + sage: c1(y,x) = x + sage: c2(y,x) = 1-y + sage: minimize_constrained(f, [c1, c2], (0,0)) (1.0, 0.0) """ @@ -619,20 +622,20 @@ def linear_program(c, G, h, A=None, b=None, solver=None): sage: c=vector(RDF,[-4,-5]) sage: G=matrix(RDF,[[2,1],[1,2],[-1,0],[0,-1]]) sage: h=vector(RDF,[3,3,0,0]) - sage: sol=linear_program(c,G,h) # optional - cvxopt + sage: sol=linear_program(c,G,h) # needs cvxopt doctest:warning... DeprecationWarning: linear_program is deprecated; use MixedIntegerLinearProgram instead See https://github.com/sagemath/sage/issues/32226 for details. - sage: sol['x'] # optional - cvxopt + sage: sol['x'] # needs cvxopt (0.999..., 1.000...) Here we solve the same problem with 'glpk' interface to 'cvxopt':: - sage: sol=linear_program(c,G,h,solver='glpk') # optional - cvxopt + sage: sol=linear_program(c,G,h,solver='glpk') # needs cvxopt GLPK Simplex Optimizer... ... OPTIMAL LP SOLUTION FOUND - sage: sol['x'] # optional - cvxopt + sage: sol['x'] # needs cvxopt (1.0, 1.0) Next, we maximize `x+y-50` subject to `50x + 24y \leq 2400`, @@ -641,13 +644,13 @@ def linear_program(c, G, h, A=None, b=None, solver=None): sage: v=vector([-1.0,-1.0,-1.0]) sage: m=matrix([[50.0,24.0,0.0],[30.0,33.0,0.0],[-1.0,0.0,0.0],[0.0,-1.0,0.0],[0.0,0.0,1.0],[0.0,0.0,-1.0]]) sage: h=vector([2400.0,2100.0,-45.0,-5.0,1.0,-1.0]) - sage: sol=linear_program(v,m,h) # optional - cvxopt - sage: sol['x'] # optional - cvxopt + sage: sol=linear_program(v,m,h) # needs cvxopt + sage: sol['x'] # needs cvxopt (45.000000..., 6.2499999..., 1.00000000...) - sage: sol=linear_program(v,m,h,solver='glpk') # optional - cvxopt + sage: sol=linear_program(v,m,h,solver='glpk') # needs cvxopt GLPK Simplex Optimizer... OPTIMAL LP SOLUTION FOUND - sage: sol['x'] # optional - cvxopt + sage: sol['x'] # needs cvxopt (45.0..., 6.25..., 1.0...) """ deprecation(32226, 'linear_program is deprecated; use MixedIntegerLinearProgram instead') @@ -722,32 +725,32 @@ def find_fit(data, model, initial_guess=None, parameters=None, variables=None, s perturbations:: sage: set_random_seed(0) - sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) # optional - sage.symbolic + sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) # needs sage.symbolic ....: for i in xsrange(0, 4*pi, 0.2)] - sage: var('a, b, c, x') # optional - sage.symbolic + sage: var('a, b, c, x') # needs sage.symbolic (a, b, c, x) We define a function with free parameters `a`, `b` and `c`:: - sage: model(x) = a * sin(b * x - c) # optional - sage.symbolic + sage: model(x) = a * sin(b * x - c) # needs sage.symbolic We search for the parameters that give the best fit to the data:: - sage: find_fit(data, model) # optional - sage.symbolic + sage: find_fit(data, model) # needs sage.symbolic [a == 1.21..., b == 0.49..., c == 0.19...] We can also use a Python function for the model:: sage: def f(x, a, b, c): return a * sin(b * x - c) - sage: fit = find_fit(data, f, parameters=[a, b, c], variables=[x], # optional - sage.symbolic + sage: fit = find_fit(data, f, parameters=[a, b, c], variables=[x], # needs sage.symbolic ....: solution_dict = True) - sage: fit[a], fit[b], fit[c] # optional - sage.symbolic + sage: fit[a], fit[b], fit[c] # needs sage.symbolic (1.21..., 0.49..., 0.19...) We search for a formula for the `n`-th prime number:: sage: dataprime = [(i, nth_prime(i)) for i in range(1, 5000, 100)] - sage: find_fit(dataprime, a * x * log(b * x), # optional - sage.symbolic + sage: find_fit(dataprime, a * x * log(b * x), # needs sage.symbolic ....: parameters=[a, b], variables=[x]) [a == 1.11..., b == 1.24...] diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index f0c174f5ed2..197a542e14d 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -72,17 +72,17 @@ The following example shows all these steps:: sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) sage: p.add_constraint(c1*x[0] + c2*x[1] >= matrix.zero(2,2,sparse=True)) - sage: p.solver_parameter("show_progress", True) # optional - cvxopt - sage: opt = p.solve() # optional - cvxopt + sage: p.solver_parameter("show_progress", True) # needs cvxopt + sage: opt = p.solve() # needs cvxopt pcost dcost gap pres dres k/t 0: ... ... Optimal solution found. - sage: print('Objective Value: {}'.format(N(opt,3))) # optional - cvxopt + sage: print('Objective Value: {}'.format(N(opt,3))) # needs cvxopt Objective Value: 1.0 - sage: [N(x, 3) for x in sorted(p.get_values(x).values())] # optional - cvxopt + sage: [N(x, 3) for x in sorted(p.get_values(x).values())] # needs cvxopt [3.0e-8, 1.0] - sage: p.show() # optional - cvxopt + sage: p.show() # needs cvxopt Maximization: x_0 - x_1 Constraints: @@ -97,46 +97,49 @@ of primal and dual problems. Thus we can get the optimizer `X` of the dual probl as follows, as diagonal blocks, one per each constraint, via :meth:`~SemidefiniteProgram.dual_variable`. E.g.:: - sage: p.dual_variable(1) # rel tol 2e-03 # optional - cvxopt + sage: p.dual_variable(1) # rel tol 2e-03 # needs cvxopt [ 85555.0 -85555.0] [-85555.0 85555.0] We can see that the optimal value of the dual is equal (up to numerical noise) to `opt`.:: - sage: opt-((p.dual_variable(0)*a3).trace()+(p.dual_variable(1)*b3).trace()) # tol 8e-08 # optional - cvxopt + sage: opt - ((p.dual_variable(0)*a3).trace() # tol 8e-08 # needs cvxopt + ....: + (p.dual_variable(1)*b3).trace()) 0.0 Dual variable blocks at optimality are orthogonal to "slack variables", that is, matrices `C-\sum_k x_k A_k`, cf. (Primal problem) above, available via :meth:`~SemidefiniteProgram.slack`. E.g.:: - sage: (p.slack(0)*p.dual_variable(0)).trace() # tol 2e-07 # optional - cvxopt + sage: (p.slack(0)*p.dual_variable(0)).trace() # tol 2e-07 # needs cvxopt 0.0 More interesting example, the :func:`Lovasz theta ` of the 7-gon:: - sage: c = graphs.CycleGraph(7) # optional - sage.graphs - sage: c2 = c.distance_graph(2).adjacency_matrix() # optional - sage.graphs - sage: c3 = c.distance_graph(3).adjacency_matrix() # optional - sage.graphs - sage: p. = SemidefiniteProgram() # optional - sage.graphs - sage: p.add_constraint((1/7)*matrix.identity(7)>=-y[0]*c2-y[1]*c3) # optional - sage.graphs - sage: p.set_objective(y[0]*(c2**2).trace()+y[1]*(c3**2).trace()) # optional - sage.graphs - sage: x = p.solve(); x + 1 # optional - cvxopt sage.graphs + sage: # needs sage.graphs + sage: c = graphs.CycleGraph(7) + sage: c2 = c.distance_graph(2).adjacency_matrix() + sage: c3 = c.distance_graph(3).adjacency_matrix() + sage: p. = SemidefiniteProgram() + sage: p.add_constraint((1/7)*matrix.identity(7)>=-y[0]*c2-y[1]*c3) + sage: p.set_objective(y[0]*(c2**2).trace()+y[1]*(c3**2).trace()) + sage: x = p.solve(); x + 1 # needs cvxopt 3.31766... Unlike in the previous example, the slack variable is very far from 0:: - sage: p.slack(0).trace() # tol 1e-14 # optional - cvxopt sage.graphs + sage: p.slack(0).trace() # tol 1e-14 # needs cvxopt sage.graphs 1.0 The default CVXOPT backend computes with the Real Double Field, for example:: - sage: p = SemidefiniteProgram(solver='cvxopt') # optional - cvxopt - sage: p.base_ring() # optional - cvxopt + sage: # needs cvxopt + sage: p = SemidefiniteProgram(solver='cvxopt') + sage: p.base_ring() Real Double Field - sage: x = p.new_variable() # optional - cvxopt - sage: 0.5 + 3/2*x[1] # optional - cvxopt + sage: x = p.new_variable() + sage: 0.5 + 3/2*x[1] 0.5 + 1.5*x_0 For representing an SDP with exact data, there is another backend:: @@ -285,7 +288,7 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: N(p.solve(), 2) # optional - cvxopt + sage: N(p.solve(), 2) # needs cvxopt -3.0 """ @@ -724,19 +727,19 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[3] + a2*x[5] <= a3) sage: p.add_constraint(b1*x[3] + b2*x[5] <= b3) - sage: N(p.solve(),3) # optional - cvxopt + sage: N(p.solve(),3) # needs cvxopt -3.0 To return the optimal value of ``x[3]``:: - sage: N(p.get_values(x[3]),3) # optional - cvxopt + sage: N(p.get_values(x[3]),3) # needs cvxopt -1.0 To get a dictionary identical to ``x`` containing optimal values for the corresponding variables :: - sage: x_sol = p.get_values(x) # optional - cvxopt - sage: sorted(x_sol) # optional - cvxopt + sage: x_sol = p.get_values(x) # needs cvxopt + sage: sorted(x_sol) # needs cvxopt [3, 5] """ @@ -795,10 +798,10 @@ cdef class SemidefiniteProgram(SageObject): sage: a2 = matrix([[1,1],[1,1]]) sage: a3 = matrix([[1,-1],[-1,1]]) sage: p.add_constraint(a1*x[1]+a2*x[2] <= a3) - sage: N(p.solve(),digits=3) # optional - cvxopt + sage: N(p.solve(), digits=3) # needs cvxopt 16.2 sage: p.set_objective(None) - sage: _ = p.solve() # optional - cvxopt + sage: _ = p.solve() # needs cvxopt """ cdef list values = [] @@ -854,7 +857,7 @@ cdef class SemidefiniteProgram(SageObject): sage: a2 = matrix([[1,1],[1,1]]) sage: a3 = matrix([[1,-1],[-1,1]]) sage: p.add_constraint(a1*x[1]+a2*x[2] <= a3) - sage: N(p.solve(),digits=3) # optional - cvxopt + sage: N(p.solve(), digits=3) # needs cvxopt 16.2 One can also define double-bounds or equality using the symbol @@ -867,7 +870,7 @@ cdef class SemidefiniteProgram(SageObject): sage: a2 = matrix([[1,1],[1,1]]) sage: a3 = matrix([[1,-1],[-1,1]]) sage: p.add_constraint(a3 >= a1*x[1] + a2*x[2]) - sage: N(p.solve(),digits=3) # optional - cvxopt + sage: N(p.solve(), digits=3) # needs cvxopt 16.2 TESTS: @@ -947,12 +950,12 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: N(p.solve(),4) # optional - cvxopt + sage: N(p.solve(),4) # needs cvxopt -11. - sage: x = p.get_values(x) # optional - cvxopt - sage: N(x[0],4) # optional - cvxopt + sage: x = p.get_values(x) # needs cvxopt + sage: N(x[0],4) # needs cvxopt -8.0 - sage: N(x[1],4) # optional - cvxopt + sage: N(x[1],4) # needs cvxopt 3.0 """ self._backend.solve() @@ -988,20 +991,20 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: p.solve() # tol 1e-08 # optional - cvxopt + sage: p.solve() # tol 1e-08 # needs cvxopt -3.0 - sage: x = p.get_values(x).values() # optional - cvxopt - sage: -(a3*p.dual_variable(0)).trace()-(b3*p.dual_variable(1)).trace() # tol 1e-07 # optional - cvxopt + sage: x = p.get_values(x).values() # needs cvxopt + sage: -(a3*p.dual_variable(0)).trace()-(b3*p.dual_variable(1)).trace() # tol 1e-07 # needs cvxopt -3.0 Dual variable is orthogonal to the slack :: - sage: g = sum((p.slack(j)*p.dual_variable(j)).trace() for j in range(2)); g # tol 1.2e-08 # optional - cvxopt + sage: g = sum((p.slack(j)*p.dual_variable(j)).trace() for j in range(2)); g # tol 1.2e-08 # needs cvxopt 0.0 TESTS:: - sage: p.dual_variable(7) # optional - cvxopt + sage: p.dual_variable(7) # needs cvxopt Traceback (most recent call last): ... IndexError: list index out of range @@ -1035,21 +1038,21 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: p.solve() # tol 1e-08 # optional - cvxopt + sage: p.solve() # tol 1e-08 # needs cvxopt -3.0 - sage: B1 = p.slack(1); B1 # tol 1e-08 # optional - cvxopt + sage: B1 = p.slack(1); B1 # tol 1e-08 # needs cvxopt [0.0 0.0] [0.0 0.0] - sage: B1.is_positive_definite() # optional - cvxopt + sage: B1.is_positive_definite() # needs cvxopt True - sage: x = sorted(p.get_values(x).values()) # optional - cvxopt - sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # optional - cvxopt + sage: x = sorted(p.get_values(x).values()) # needs cvxopt + sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # needs cvxopt [0.0 0.0] [0.0 0.0] TESTS:: - sage: p.slack(7) # optional - cvxopt + sage: p.slack(7) # needs cvxopt Traceback (most recent call last): ... IndexError: list index out of range @@ -1076,20 +1079,21 @@ cdef class SemidefiniteProgram(SageObject): EXAMPLES:: - sage: p. = SemidefiniteProgram(solver = "cvxopt", maximization = False) # optional - cvxopt - sage: p.solver_parameter("show_progress", True) # optional - cvxopt - sage: p.solver_parameter("show_progress") # optional - cvxopt + sage: p. = SemidefiniteProgram(solver="cvxopt", # needs cvxopt + ....: maximization=False) + sage: p.solver_parameter("show_progress", True) # needs cvxopt + sage: p.solver_parameter("show_progress") # needs cvxopt True - sage: p.set_objective(x[0] - x[1]) # optional - cvxopt + sage: p.set_objective(x[0] - x[1]) # needs cvxopt sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 2.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 1.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # optional - cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # optional - cvxopt - sage: N(p.solve(),4) # optional - cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt + sage: N(p.solve(),4) # needs cvxopt pcost dcost gap pres dres k/t 0: 1... ... @@ -1177,13 +1181,13 @@ class SDPSolverException(RuntimeError): No solution:: - sage: p = SemidefiniteProgram(solver="cvxopt") # optional - cvxopt - sage: x = p.new_variable() # optional - cvxopt - sage: p.set_objective(x[0]) # optional - cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt") # needs cvxopt + sage: x = p.new_variable() # needs cvxopt + sage: p.set_objective(x[0]) # needs cvxopt sage: a = matrix([[1,2],[2,4]]) sage: b = matrix([[1,9],[9,4]]) - sage: p.add_constraint( a*x[0] == b ) # optional - cvxopt - sage: p.solve() # optional - cvxopt + sage: p.add_constraint( a*x[0] == b ) # needs cvxopt + sage: p.solve() # needs cvxopt Traceback (most recent call last): ... SDPSolverException: ... From ed02de0bcc25026835007b1d848870a7c2401884 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:59:32 -0700 Subject: [PATCH 334/494] sage.numerical: Update # needs --- src/sage/numerical/optimize.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index d5caae0da32..5f077b61871 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -192,7 +192,7 @@ def find_local_maximum(f, a, b, tol=1.48e-08, maxfun=500): (0.561096338191..., 0.8603335890...) sage: find_local_maximum(f, 0, 5, tol=0.1, maxfun=10) (0.561090323458..., 0.857926501456...) - sage: find_local_maximum(8*e^(-x)*sin(x) - 1, 0, 7) + sage: find_local_maximum(8*e^(-x)*sin(x) - 1, 0, 7) # needs sage.symbolic (1.579175535558..., 0.7853981...) """ try: @@ -249,12 +249,14 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): :: + sage: # needs sage.symbolic sage: f(x) = -x*sin(x^2) sage: find_local_minimum(f, -2.5, -1) (-2.182769784677722, -2.1945027498534686) Enlarging the interval returns a larger minimum:: + sage: # needs sage.symbolic sage: find_local_minimum(f, -2.5, 2) (-1.3076194129914434, 1.3552111405712108) @@ -263,9 +265,10 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): numerics (observe the small number of decimal places that we actually test):: - sage: plot(f, (x, -2.5, -1)).ymin() # needs sage.plot + sage: # needs sage.plot sage.symbolic + sage: plot(f, (x, -2.5, -1)).ymin() -2.182... - sage: plot(f, (x, -2.5, 2)).ymin() # needs sage.plot + sage: plot(f, (x, -2.5, 2)).ymin() -2.182... ALGORITHM: @@ -749,6 +752,7 @@ def find_fit(data, model, initial_guess=None, parameters=None, variables=None, s We search for a formula for the `n`-th prime number:: + sage: # needs sage.libs.pari sage: dataprime = [(i, nth_prime(i)) for i in range(1, 5000, 100)] sage: find_fit(dataprime, a * x * log(b * x), # needs sage.symbolic ....: parameters=[a, b], variables=[x]) @@ -907,24 +911,24 @@ def binpacking(items, maximum=1, k=None, solver=None, verbose=0, sage: from sage.numerical.optimize import binpacking sage: values = [1/5, 1/3, 2/3, 3/4, 5/7] - sage: bins = binpacking(values) - sage: len(bins) + sage: bins = binpacking(values) # needs sage.numerical.mip + sage: len(bins) # needs sage.numerical.mip 3 Checking the bins are of correct size :: - sage: all(sum(b) <= 1 for b in bins) + sage: all(sum(b) <= 1 for b in bins) # needs sage.numerical.mip True Checking every item is in a bin :: - sage: b1, b2, b3 = bins - sage: all((v in b1 or v in b2 or v in b3) for v in values) + sage: b1, b2, b3 = bins # needs sage.numerical.mip + sage: all((v in b1 or v in b2 or v in b3) for v in values) # needs sage.numerical.mip True And only in one bin :: - sage: sum(len(b) for b in bins) == len(values) + sage: sum(len(b) for b in bins) == len(values) # needs sage.numerical.mip True One way to use only three boxes (which is best possible) is to put @@ -934,7 +938,7 @@ def binpacking(items, maximum=1, k=None, solver=None, verbose=0, Of course, we can also check that there is no solution using only two boxes :: sage: from sage.numerical.optimize import binpacking - sage: binpacking([0.2,0.3,0.8,0.9], k=2) + sage: binpacking([0.2,0.3,0.8,0.9], k=2) # needs sage.numerical.mip Traceback (most recent call last): ... ValueError: this problem has no solution @@ -943,8 +947,8 @@ def binpacking(items, maximum=1, k=None, solver=None, verbose=0, its weight. Then, the bins contain the name of the items inside it :: sage: values = {'a':1/5, 'b':1/3, 'c':2/3, 'd':3/4, 'e':5/7} - sage: bins = binpacking(values) - sage: set(flatten(bins)) == set(values.keys()) + sage: bins = binpacking(values) # needs sage.numerical.mip + sage: set(flatten(bins)) == set(values.keys()) # needs sage.numerical.mip True TESTS: From 5268e1ec1703ed6d90f64270806b0043774c85a1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 17 Sep 2023 10:03:25 -0700 Subject: [PATCH 335/494] src/sage/numerical/backends/glpk*.pyx: Add # needs --- src/sage/numerical/backends/glpk_backend.pyx | 6 +++++- src/sage/numerical/backends/glpk_graph_backend.pyx | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sage/numerical/backends/glpk_backend.pyx b/src/sage/numerical/backends/glpk_backend.pyx index 0fa5c2d3b98..77cab0ff1b5 100644 --- a/src/sage/numerical/backends/glpk_backend.pyx +++ b/src/sage/numerical/backends/glpk_backend.pyx @@ -1097,6 +1097,7 @@ cdef class GLPKBackend(GenericBackend): the result is not optimal. To do this, we try to compute the maximum number of disjoint balls (of diameter 1) in a hypercube:: + sage: # needs sage.graphs sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: p.solver_parameter("mip_gap_tolerance",100) @@ -1110,6 +1111,7 @@ cdef class GLPKBackend(GenericBackend): Same, now with a time limit:: + sage: # needs sage.graphs sage: p.solver_parameter("mip_gap_tolerance",1) sage: p.solver_parameter("timelimit",3.0) sage: p.solve() # rel tol 100 @@ -1197,6 +1199,7 @@ cdef class GLPKBackend(GenericBackend): EXAMPLES:: + sage: # needs sage.graphs sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: p.solver_parameter("mip_gap_tolerance",100) @@ -1231,6 +1234,7 @@ cdef class GLPKBackend(GenericBackend): EXAMPLES:: + sage: # needs sage.graphs sage: g = graphs.CubeGraph(9) sage: p = MixedIntegerLinearProgram(solver="GLPK") sage: p.solver_parameter("mip_gap_tolerance",100) @@ -1250,7 +1254,7 @@ cdef class GLPKBackend(GenericBackend): Just make sure that the variable *has* been defined, and is not just undefined:: - sage: backend.get_relative_objective_gap() > 1 + sage: backend.get_relative_objective_gap() > 1 # needs sage.graphs True """ return self.search_tree_data.mip_gap diff --git a/src/sage/numerical/backends/glpk_graph_backend.pyx b/src/sage/numerical/backends/glpk_graph_backend.pyx index dcc6425d8de..90431f8a481 100644 --- a/src/sage/numerical/backends/glpk_graph_backend.pyx +++ b/src/sage/numerical/backends/glpk_graph_backend.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.graphs """ GLPK Backend for access to GLPK graph functions From c9f9af8748090b1c9f2f138bd7443a8664d8e914 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 19:55:56 -0700 Subject: [PATCH 336/494] Add # needs --- src/sage/numerical/backends/generic_backend.pyx | 12 +++++++----- src/sage/numerical/mip.pyx | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 12e9405c37b..434f4304c62 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -1772,14 +1772,16 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> sage: p.base_ring() # needs sage.rings.number_field Algebraic Real Field - sage: d = polytopes.dodecahedron() # needs sage.rings.number_field - sage: p = get_solver(base_ring=d.base_ring()); p # needs sage.rings.number_field + + sage: # needs sage.groups sage.rings.number_field + sage: d = polytopes.dodecahedron() + sage: p = get_solver(base_ring=d.base_ring()); p <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> - sage: p.base_ring() # needs sage.rings.number_field + sage: p.base_ring() Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? - sage: p = get_solver(solver='InteractiveLP', base_ring=QQ); p # needs sage.rings.number_field + sage: p = get_solver(solver='InteractiveLP', base_ring=QQ); p <...sage.numerical.backends.interactivelp_backend.InteractiveLPBackend...> - sage: p.base_ring() # needs sage.rings.number_field + sage: p.base_ring() Rational Field Passing a callable as the 'solver':: diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 5a1520f4304..1e6e6caa7bd 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -664,9 +664,11 @@ cdef class MixedIntegerLinearProgram(SageObject): sage: p = MixedIntegerLinearProgram(solver='InteractiveLP', base_ring=AA) # needs sage.rings.number_field sage: p.base_ring() # needs sage.rings.number_field Algebraic Real Field - sage: d = polytopes.dodecahedron() # needs sage.rings.number_field - sage: p = MixedIntegerLinearProgram(base_ring=d.base_ring()) # needs sage.rings.number_field - sage: p.base_ring() # needs sage.rings.number_field + + sage: # needs sage.groups sage.rings.number_field + sage: d = polytopes.dodecahedron() + sage: p = MixedIntegerLinearProgram(base_ring=d.base_ring()) + sage: p.base_ring() Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? """ return self._backend.base_ring() From 8303adb1910adf53c90b5b886905c49040c51ce4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 17:46:13 -0700 Subject: [PATCH 337/494] src/sage/numerical/optimize.py: Remove code deprecated in #32226 (2021) --- src/sage/numerical/all.py | 2 +- src/sage/numerical/optimize.py | 118 +-------------------------------- 2 files changed, 4 insertions(+), 116 deletions(-) diff --git a/src/sage/numerical/all.py b/src/sage/numerical/all.py index 06ca1dd1a60..8b69da18652 100644 --- a/src/sage/numerical/all.py +++ b/src/sage/numerical/all.py @@ -1,7 +1,7 @@ from sage.misc.lazy_import import lazy_import lazy_import("sage.numerical.optimize", ["find_fit", "find_local_maximum", "find_local_minimum", - "find_root", "linear_program", "minimize", "minimize_constrained"]) + "find_root", "minimize", "minimize_constrained"]) lazy_import("sage.numerical.mip", ["MixedIntegerLinearProgram"]) lazy_import("sage.numerical.sdp", ["SemidefiniteProgram"]) lazy_import("sage.numerical.backends.generic_backend", ["default_mip_solver"]) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index 5f077b61871..f36e5213943 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -5,14 +5,13 @@ AUTHOR: - William Stein (2007): initial version -- Nathann Cohen (2008) : Bin Packing +- Nathann Cohen (2008): Bin Packing Functions and Methods ---------------------- """ -from sage.misc.superseded import deprecation from sage.modules.free_module_element import vector from sage.rings.real_double import RDF @@ -172,6 +171,7 @@ def find_root(f, a, b, xtol=10e-13, rtol=2.0**-50, maxiter=100, full_output=Fals raise NotImplementedError("Brent's method failed to find a zero for f on the interval") return brentqRes + def find_local_maximum(f, a, b, tol=1.48e-08, maxfun=500): """ Numerically find a local maximum of the expression `f` on the interval @@ -202,6 +202,7 @@ def find_local_maximum(f, a, b, tol=1.48e-08, maxfun=500): minval, x = find_local_minimum(lambda z: -f(z), a=a, b=b, tol=tol, maxfun=maxfun) return -minval, x + def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): """ Numerically find a local minimum of the expression ``f`` on the @@ -572,119 +573,6 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) return vector(RDF, min) -def linear_program(c, G, h, A=None, b=None, solver=None): - r""" - Solve the dual linear programs: - - - Minimize `c'x` subject to `Gx + s = h`, `Ax = b`, and `s \geq 0` where - `'` denotes transpose. - - - Maximize `-h'z - b'y` subject to `G'z + A'y + c = 0` and `z \geq 0`. - - This function is deprecated. Use :class:`MixedIntegerLinearProgram` instead. - - This function depends on the optional package ``cvxopt``. - - INPUT: - - - ``c`` -- a vector - - - ``G`` -- a matrix - - - ``h`` -- a vector - - - ``A`` -- a matrix - - - ``b`` --- a vector - - - ``solver`` (optional) --- solver to use. If None, the cvxopt's lp-solver - is used. If it is 'glpk', then glpk's solver - is used. - - These can be over any field that can be turned into a floating point - number. - - - OUTPUT: - - A dictionary ``sol`` with keys ``x``, ``s``, ``y``, ``z`` corresponding - to the variables above: - - - ``sol['x']`` -- the solution to the linear program - - - ``sol['s']`` -- the slack variables for the solution - - - ``sol['z']``, ``sol['y']`` -- solutions to the dual program - - - EXAMPLES: - - First, we minimize `-4x_1 - 5x_2` subject to `2x_1 + x_2 \leq 3`, - `x_1 + 2x_2 \leq 3`, `x_1 \geq 0`, and `x_2 \geq 0`:: - - sage: c=vector(RDF,[-4,-5]) - sage: G=matrix(RDF,[[2,1],[1,2],[-1,0],[0,-1]]) - sage: h=vector(RDF,[3,3,0,0]) - sage: sol=linear_program(c,G,h) # needs cvxopt - doctest:warning... - DeprecationWarning: linear_program is deprecated; use MixedIntegerLinearProgram instead - See https://github.com/sagemath/sage/issues/32226 for details. - sage: sol['x'] # needs cvxopt - (0.999..., 1.000...) - - Here we solve the same problem with 'glpk' interface to 'cvxopt':: - - sage: sol=linear_program(c,G,h,solver='glpk') # needs cvxopt - GLPK Simplex Optimizer... - ... - OPTIMAL LP SOLUTION FOUND - sage: sol['x'] # needs cvxopt - (1.0, 1.0) - - Next, we maximize `x+y-50` subject to `50x + 24y \leq 2400`, - `30x + 33y \leq 2100`, `x \geq 45`, and `y \geq 5`:: - - sage: v=vector([-1.0,-1.0,-1.0]) - sage: m=matrix([[50.0,24.0,0.0],[30.0,33.0,0.0],[-1.0,0.0,0.0],[0.0,-1.0,0.0],[0.0,0.0,1.0],[0.0,0.0,-1.0]]) - sage: h=vector([2400.0,2100.0,-45.0,-5.0,1.0,-1.0]) - sage: sol=linear_program(v,m,h) # needs cvxopt - sage: sol['x'] # needs cvxopt - (45.000000..., 6.2499999..., 1.00000000...) - sage: sol=linear_program(v,m,h,solver='glpk') # needs cvxopt - GLPK Simplex Optimizer... - OPTIMAL LP SOLUTION FOUND - sage: sol['x'] # needs cvxopt - (45.0..., 6.25..., 1.0...) - """ - deprecation(32226, 'linear_program is deprecated; use MixedIntegerLinearProgram instead') - - from cvxopt.base import matrix as m - from cvxopt import solvers - solvers.options['show_progress'] = False - if solver == 'glpk': - from cvxopt import glpk - glpk.options['LPX_K_MSGLEV'] = 0 - c_ = m(c.base_extend(RDF).numpy()) - G_ = m(G.base_extend(RDF).numpy()) - h_ = m(h.base_extend(RDF).numpy()) - if A is not None and b is not None: - A_ = m(A.base_extend(RDF).numpy()) - b_ = m(b.base_extend(RDF).numpy()) - sol = solvers.lp(c_,G_,h_,A_,b_,solver=solver) - else: - sol = solvers.lp(c_,G_,h_,solver=solver) - status = sol['status'] - if status != 'optimal': - return {'primal objective': None, 'x': None, 's': None, 'y': None, - 'z': None, 'status': status} - x = vector(RDF, list(sol['x'])) - s = vector(RDF, list(sol['s'])) - y = vector(RDF, list(sol['y'])) - z = vector(RDF, list(sol['z'])) - return {'primal objective': sol['primal objective'], - 'x': x, 's': s, 'y': y, 'z': z, 'status': status} - - def find_fit(data, model, initial_guess=None, parameters=None, variables=None, solution_dict=False): r""" Finds numerical estimates for the parameters of the function model to From 4b5b3ca4cadbc5cd443477c91497c6361d108acd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 17:50:30 -0700 Subject: [PATCH 338/494] src/sage/numerical/optimize.py: Docstring cosmetics, more block tags --- src/sage/numerical/optimize.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index f36e5213943..708d440a205 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -217,7 +217,7 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): - ``f`` -- a function of at most one variable. - - ``a``, ``b`` -- endpoints of interval on which to minimize self. + - ``a``, ``b`` -- endpoints of interval on which to minimize `f`. - ``tol`` -- the convergence tolerance @@ -226,10 +226,10 @@ def find_local_minimum(f, a, b, tol=1.48e-08, maxfun=500): OUTPUT: - - ``minval`` -- (float) the minimum value that self takes on in the + - ``minval`` -- (float) the minimum value that `f` takes on in the interval `[a,b]` - - ``x`` -- (float) the point at which self takes on the minimum value + - ``x`` -- (float) the point at which `f` takes on the minimum value EXAMPLES:: @@ -323,15 +323,15 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", ``'default'`` (for Python functions, the simplex method is the default) (for symbolic functions bfgs is the default): - - ``'simplex'`` -- using the downhill simplex algorithm + - ``'simplex'`` -- using the downhill simplex algorithm - - ``'powell'`` -- use the modified Powell algorithm + - ``'powell'`` -- use the modified Powell algorithm - - ``'bfgs'`` -- (Broyden-Fletcher-Goldfarb-Shanno) requires gradient + - ``'bfgs'`` -- (Broyden-Fletcher-Goldfarb-Shanno) requires gradient - - ``'cg'`` -- (conjugate-gradient) requires gradient + - ``'cg'`` -- (conjugate-gradient) requires gradient - - ``'ncg'`` -- (newton-conjugate gradient) requires gradient and hessian + - ``'ncg'`` -- (newton-conjugate gradient) requires gradient and hessian - ``verbose`` -- (optional, default: False) print convergence message @@ -366,7 +366,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", Same example with just Python functions:: - sage: def rosen(x): # The Rosenbrock function + sage: def rosen(x): # The Rosenbrock function ....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r) sage: minimize(rosen, [.1,.3,.4]) # abs tol 3e-5 (1.0, 1.0, 1.0) @@ -374,11 +374,12 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", Same example with a pure Python function and a Python function to compute the gradient:: - sage: def rosen(x): # The Rosenbrock function + sage: # needs numpy + sage: def rosen(x): # The Rosenbrock function ....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r) - sage: import numpy # needs numpy - sage: from numpy import zeros # needs numpy - sage: def rosen_der(x): # needs numpy + sage: import numpy + sage: from numpy import zeros + sage: def rosen_der(x): ....: xm = x[1r:-1r] ....: xm_m1 = x[:-2r] ....: xm_p1 = x[2r:] @@ -387,7 +388,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", ....: der[0] = -400r*x[0r]*(x[1r]-x[0r]**2r) - 2r*(1r-x[0]) ....: der[-1] = 200r*(x[-1r]-x[-2r]**2r) ....: return der - sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, # abs tol 1e-6 # needs numpy + sage: minimize(rosen, [.1,.3,.4], gradient=rosen_der, # abs tol 1e-6 ....: algorithm="bfgs") (1.0, 1.0, 1.0) """ @@ -440,7 +441,7 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args) INPUT: - ``func`` -- Either a symbolic function, or a Python function whose - argument is a tuple with n components + argument is a tuple with `n` components - ``cons`` -- constraints. This should be either a function or list of functions that must be positive. Alternatively, the constraints can From fc9e06e4982fd57a90707e518cff0571f74c938d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 18:03:36 -0700 Subject: [PATCH 339/494] src/sage/numerical/backends/cvxopt_backend.pyx: Docstring/doctest cosmetics --- .../numerical/backends/cvxopt_backend.pyx | 170 ++++++++---------- 1 file changed, 78 insertions(+), 92 deletions(-) diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 82eb0c4ccfd..fe4809d1232 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -1,10 +1,11 @@ +# sage.doctest: needs cvxopt r""" CVXOPT Backend AUTHORS: -- Ingolfur Edvardsson (2014-05) : initial implementation +- Ingolfur Edvardsson (2014-05): initial implementation """ #***************************************************************************** @@ -30,13 +31,13 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: p = MixedIntegerLinearProgram(solver="CVXOPT") # needs cvxopt + sage: p = MixedIntegerLinearProgram(solver="CVXOPT") TESTS: :trac:`20332`:: - sage: p # needs cvxopt + sage: p Mixed Integer Program (no objective, 0 variables, 0 constraints) """ @@ -62,7 +63,7 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # needs cvxopt + sage: p = get_solver(solver="CVXOPT") """ @@ -100,9 +101,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "CVXOPT") + sage: p = MixedIntegerLinearProgram(solver="CVXOPT") sage: b = p.new_variable() sage: p.add_constraint(b[1] + b[2] <= 6) sage: p.add_constraint(b[2] <= 5) @@ -160,9 +160,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.add_variable() @@ -186,11 +185,11 @@ cdef class CVXOPTBackend(GenericBackend): TESTS:: - sage: p.add_variable(integer=True) # needs cvxopt + sage: p.add_variable(integer=True) Traceback (most recent call last): ... RuntimeError: CVXOPT only supports continuous variables - sage: p.add_variable(binary=True) # needs cvxopt + sage: p.add_variable(binary=True) Traceback (most recent call last): ... RuntimeError: CVXOPT only supports continuous variables @@ -212,9 +211,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "cvxopt") + sage: p = get_solver(solver="cvxopt") sage: p.add_variables(5) 4 sage: p.set_variable_type(3, -1) @@ -232,16 +230,15 @@ cdef class CVXOPTBackend(GenericBackend): INPUT: - - ``sense`` (integer) : + - ``sense`` (integer): - * +1 => Maximization - * -1 => Minimization + * `+1` => Maximization + * `-1` => Minimization EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -266,9 +263,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variable() 0 sage: p.objective_coefficient(0) @@ -295,9 +291,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variables(5) 4 sage: p.set_objective([1, 1, 2, 1, 3]) @@ -337,9 +332,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.nrows() @@ -381,9 +375,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) @@ -420,26 +413,27 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt - sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) - sage: x=p.new_variable(nonnegative=True) + sage: p = MixedIntegerLinearProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable(nonnegative=True) sage: p.set_objective(-4*x[0] - 5*x[1]) sage: p.add_constraint(2*x[0] + x[1] <= 3) sage: p.add_constraint(2*x[1] + x[0] <= 3) sage: N(p.solve(), digits=2) -9.0 - sage: p = MixedIntegerLinearProgram(solver = "cvxopt", maximization=False) - sage: x=p.new_variable(nonnegative=True) + + sage: p = MixedIntegerLinearProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable(nonnegative=True) sage: p.set_objective(x[0] + 2*x[1]) - sage: p.add_constraint(-5*x[0] + x[1] <= 7) - sage: p.add_constraint(-5*x[0] + x[1] >= 7) - sage: p.add_constraint(x[0] + x[1] >= 26 ) - sage: p.add_constraint( x[0] >= 3) - sage: p.add_constraint( x[1] >= 4) - sage: N(p.solve(),digits=4) + sage: p.add_constraint(-5*x[0] + x[1] <= 7) + sage: p.add_constraint(-5*x[0] + x[1] >= 7) + sage: p.add_constraint(x[0] + x[1] >= 26) + sage: p.add_constraint(x[0] >= 3) + sage: p.add_constraint(x[1] >= 4) + sage: N(p.solve(), digits=4) 48.83 - sage: p = MixedIntegerLinearProgram(solver = "cvxopt") - sage: x=p.new_variable(nonnegative=True) + + sage: p = MixedIntegerLinearProgram(solver="cvxopt") + sage: x = p.new_variable(nonnegative=True) sage: p.set_objective(x[0] + x[1] + 3*x[2]) sage: p.solver_parameter("show_progress",True) sage: p.add_constraint(x[0] + 2*x[1] <= 4) @@ -448,17 +442,24 @@ cdef class CVXOPTBackend(GenericBackend): pcost dcost gap pres dres k/t ... 8.8 - sage: #CVXOPT gives different values for variables compared to the other solvers. - sage: c = MixedIntegerLinearProgram(solver = "cvxopt") - sage: p = MixedIntegerLinearProgram(solver = "ppl") + + When the optimal solution is not unique, CVXOPT as an interior point solver + gives a different type of solution compared to the solvers that use the + simplex method. + + In the following example, the top face of the cube is optimal, and CVXOPT + gives the center point of the top face, whereas the other tested solvers + return a vertex:: + + sage: c = MixedIntegerLinearProgram(solver="cvxopt") + sage: p = MixedIntegerLinearProgram(solver="ppl") sage: g = MixedIntegerLinearProgram() - sage: xc=c.new_variable(nonnegative=True) - sage: xp=p.new_variable(nonnegative=True) - sage: xg=g.new_variable(nonnegative=True) + sage: xc = c.new_variable(nonnegative=True) + sage: xp = p.new_variable(nonnegative=True) + sage: xg = g.new_variable(nonnegative=True) sage: c.set_objective(xc[2]) sage: p.set_objective(xp[2]) sage: g.set_objective(xg[2]) - sage: #we create a cube for all three solvers sage: c.add_constraint(xc[0] <= 100) sage: c.add_constraint(xc[1] <= 100) sage: c.add_constraint(xc[2] <= 100) @@ -468,29 +469,29 @@ cdef class CVXOPTBackend(GenericBackend): sage: g.add_constraint(xg[0] <= 100) sage: g.add_constraint(xg[1] <= 100) sage: g.add_constraint(xg[2] <= 100) - sage: N(c.solve(),digits=4) + sage: N(c.solve(), digits=4) 100.0 - sage: N(c.get_values(xc[0]),digits=3) + sage: N(c.get_values(xc[0]), digits=3) 50.0 - sage: N(c.get_values(xc[1]),digits=3) + sage: N(c.get_values(xc[1]), digits=3) 50.0 - sage: N(c.get_values(xc[2]),digits=4) + sage: N(c.get_values(xc[2]), digits=4) 100.0 - sage: N(p.solve(),digits=4) + sage: N(p.solve(), digits=4) 100.0 - sage: N(p.get_values(xp[0]),2) + sage: N(p.get_values(xp[0]), 2) 0.00 - sage: N(p.get_values(xp[1]),2) + sage: N(p.get_values(xp[1]), 2) 0.00 - sage: N(p.get_values(xp[2]),digits=4) + sage: N(p.get_values(xp[2]), digits=4) 100.0 - sage: N(g.solve(),digits=4) + sage: N(g.solve(), digits=4) 100.0 - sage: N(g.get_values(xg[0]),2) + sage: N(g.get_values(xg[0]), 2) 0.00 - sage: N(g.get_values(xg[1]),2) + sage: N(g.get_values(xg[1]), 2) 0.00 - sage: N(g.get_values(xg[2]),digits=4) + sage: N(g.get_values(xg[2]), digits=4) 100.0 """ from cvxopt import matrix, solvers @@ -573,9 +574,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "cvxopt") + sage: p = get_solver(solver="cvxopt") sage: p.add_variables(2) 1 sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) @@ -606,9 +606,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variables(2) 1 sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) @@ -630,9 +629,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.add_variables(2) @@ -649,9 +647,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.nrows() 0 sage: p.add_variables(5) @@ -669,9 +666,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -694,9 +690,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.problem_name() '' sage: p.problem_name("There once was a french fry") @@ -725,9 +720,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) @@ -763,9 +757,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2) @@ -792,9 +785,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -816,9 +808,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.add_variable() @@ -844,9 +835,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.add_variable() @@ -872,9 +862,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.ncols() 0 sage: p.add_variable() @@ -902,9 +891,9 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # needs cvxopt - sage: p.add_linear_constraints(1, 2, None, names=["Empty constraint 1"]) # needs cvxopt - sage: p.row_name(0) # needs cvxopt + sage: p = get_solver(solver="CVXOPT") + sage: p.add_linear_constraints(1, 2, None, names=["Empty constraint 1"]) + sage: p.row_name(0) 'Empty constraint 1' """ if self.row_name_var[index] is not None: @@ -925,10 +914,10 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # needs cvxopt - sage: p.add_variable(name="I am a variable") # needs cvxopt + sage: p = get_solver(solver="CVXOPT") + sage: p.add_variable(name="I am a variable") 0 - sage: p.col_name(0) # needs cvxopt + sage: p.col_name(0) 'I am a variable' """ if self.col_name_var[index] is not None: @@ -949,9 +938,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -979,9 +967,8 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -1013,7 +1000,6 @@ cdef class CVXOPTBackend(GenericBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver="CVXOPT") sage: p.solver_parameter("show_progress") From 852c09173529bc23564d1c002a292e8bb5e86837 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Oct 2023 18:09:41 -0700 Subject: [PATCH 340/494] src/sage/numerical/backends/cvxopt_sdp_backend.pyx: Use file tag; doctest cosmetics --- .../numerical/backends/cvxopt_sdp_backend.pyx | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index dcad34cdccc..115e3f504bb 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -1,12 +1,13 @@ +# sage.doctest: needs cvxopt r""" CVXOPT SDP Backend AUTHORS: -- Ingolfur Edvardsson (2014-05) : initial implementation +- Ingolfur Edvardsson (2014-05): initial implementation -- Dima Pasechnik (2015-12) : minor fixes +- Dima Pasechnik (2015-12): minor fixes """ #***************************************************************************** @@ -36,7 +37,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") # needs cvxopt + sage: p = get_solver(solver="CVXOPT") """ @@ -62,15 +63,15 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): .. NOTE:: - This method raises ``SDPSolverException`` exceptions when + This method raises :class:`SDPSolverException` exceptions when the solution cannot be computed for any reason (none exists, or the LP solver was not able to find it, etc...) EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1] + x[2]) sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -79,13 +80,13 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a3*x[2] <= a4) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt - sage: N(p.solve(), digits=4) # needs cvxopt + sage: p.add_constraint(a1*x[0] + a3*x[2] <= a4) + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) + sage: N(p.solve(), digits=4) -3.225 - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1] + x[2]) sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -94,9 +95,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt - sage: N(p.solve(), digits=4) # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) + sage: N(p.solve(), digits=4) -3.154 """ @@ -171,9 +172,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1] + x[2]) sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -182,11 +183,11 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt - sage: N(p.solve(), digits=4) # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) + sage: N(p.solve(), digits=4) -3.154 - sage: N(p.get_backend().get_objective_value(), digits=4) # needs cvxopt + sage: N(p.get_backend().get_objective_value(), digits=4) -3.154 """ sum = self.obj_constant_term @@ -204,20 +205,20 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): TESTS:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1]) # needs cvxopt + sage: p = SemidefiniteProgram(maximization=False, solver='cvxopt') + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt - sage: p.solve(); # tol 1e-08 # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: p.solve(); # tol 1e-08 -3.0 - sage: p.get_backend()._get_answer() # needs cvxopt + sage: p.get_backend()._get_answer() {...} """ return self.answer @@ -232,9 +233,9 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(solver = "cvxopt", maximization=False) # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1] + x[2]) # needs cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt", maximization=False) + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1] + x[2]) sage: a1 = matrix([[-7., -11.], [-11., 3.]]) sage: a2 = matrix([[7., -18.], [-18., 8.]]) sage: a3 = matrix([[-2., -8.], [-8., 1.]]) @@ -243,15 +244,15 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): sage: b2 = matrix([[0., 10., 16.], [10., -10., -10.], [16., -10., 3.]]) sage: b3 = matrix([[-5., 2., -17.], [2., -6., 8.], [-17., 8., 6.]]) sage: b4 = matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) # needs cvxopt - sage: N(p.solve(), digits=4) # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] + a3*x[2] <= a4) + sage: p.add_constraint(b1*x[0] + b2*x[1] + b3*x[2] <= b4) + sage: N(p.solve(), digits=4) -3.154 - sage: N(p.get_backend().get_variable_value(0), digits=3) # needs cvxopt + sage: N(p.get_backend().get_variable_value(0), digits=3) -0.368 - sage: N(p.get_backend().get_variable_value(1), digits=4) # needs cvxopt + sage: N(p.get_backend().get_variable_value(1), digits=4) 1.898 - sage: N(p.get_backend().get_variable_value(2), digits=3) # needs cvxopt + sage: N(p.get_backend().get_variable_value(2), digits=3) -0.888 """ return self.answer['x'][variable] @@ -270,34 +271,34 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1]) # needs cvxopt + sage: p = SemidefiniteProgram(maximization=False, solver='cvxopt') + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt - sage: p.solve() # tol 1e-08 # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: p.solve() # tol 1e-08 -3.0 - sage: B=p.get_backend() # needs cvxopt - sage: x=p.get_values(x).values() # needs cvxopt - sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() # tol 1e-07 # needs cvxopt + sage: B = p.get_backend() + sage: x = p.get_values(x).values() + sage: -(a3*B.dual_variable(0)).trace() - (b3*B.dual_variable(1)).trace() # tol 1e-07 -3.0 - sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g # tol 1.5e-08 # needs cvxopt + sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g # tol 1.5e-08 0.0 TESTS:: - sage: B.dual_variable(7) # needs cvxopt + sage: B.dual_variable(7) Traceback (most recent call last): ... IndexError: list index out of range - sage: abs(g - B._get_answer()['gap']) # tol 1e-22 # needs cvxopt + sage: abs(g - B._get_answer()['gap']) # tol 1e-22 0.0 """ @@ -320,33 +321,33 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0] - x[1]) # needs cvxopt + sage: p = SemidefiniteProgram(maximization = False, solver='cvxopt') + sage: x = p.new_variable() + sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 5.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 2.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt - sage: p.solve() # tol 1e-08 # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: p.solve() # tol 1e-08 -3.0 - sage: B = p.get_backend() # needs cvxopt - sage: B1 = B.slack(1); B1 # tol 1e-08 # needs cvxopt + sage: B = p.get_backend() + sage: B1 = B.slack(1); B1 # tol 1e-08 [0.0 0.0] [0.0 0.0] - sage: B1.is_positive_definite() # needs cvxopt + sage: B1.is_positive_definite() True - sage: x = sorted(p.get_values(x).values()) # needs cvxopt - sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # needs cvxopt + sage: x = sorted(p.get_values(x).values()) + sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 [0.0 0.0] [0.0 0.0] TESTS:: - sage: B.slack(7) # needs cvxopt + sage: B.slack(7) Traceback (most recent call last): ... IndexError: list index out of range @@ -358,7 +359,7 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): return Matrix(n, n, list(self.answer['ss'][i]), sparse=sparse) - cpdef solver_parameter(self, name, value = None) noexcept: + cpdef solver_parameter(self, name, value=None) noexcept: """ Return or define a solver parameter @@ -376,9 +377,8 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): EXAMPLES:: - sage: # needs cvxopt sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "CVXOPT") + sage: p = get_solver(solver="CVXOPT") sage: p.solver_parameter("show_progress") False sage: p.solver_parameter("show_progress", True) From 482201031fea4b326c997d30a3af7996123b53dd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Oct 2023 18:10:09 -0700 Subject: [PATCH 341/494] src/sage/numerical/backends/generic_sdp_backend.pyx: Doctest cosmetics --- .../backends/generic_sdp_backend.pyx | 101 +++++++++--------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/sage/numerical/backends/generic_sdp_backend.pyx b/src/sage/numerical/backends/generic_sdp_backend.pyx index 599235f808a..45bfde5f89b 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pyx +++ b/src/sage/numerical/backends/generic_sdp_backend.pyx @@ -73,14 +73,14 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() 0 sage: p.ncols() 1 - sage: p.add_variable(name='x',obj=1.0) + sage: p.add_variable(name='x', obj=1.0) 3 sage: p.col_name(3) 'x' @@ -110,7 +110,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variables(5) @@ -128,16 +128,16 @@ cdef class GenericSDPBackend: INPUT: - - ``sense`` (integer) : + - ``sense`` (integer): - * +1 => Maximization - * -1 => Minimization + * `+1` => Maximization + * `-1` => Minimization EXAMPLES:: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -161,7 +161,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variable() 1 sage: p.objective_coefficient(0) @@ -187,7 +187,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 5 sage: p.set_objective([1, 1, 2, 1, 3]) @@ -219,7 +219,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) @@ -252,7 +252,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 5 sage: p.add_linear_constraints(5, None, 2) @@ -269,7 +269,7 @@ cdef class GenericSDPBackend: .. NOTE:: - This method raises ``SDPSolverException`` exceptions when + This method raises :class:`SDPSolverException` exceptions when the solution cannot be computed for any reason (none exists, or the LP solver was not able to find it, etc...) @@ -277,7 +277,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_linear_constraints(5, 0, None) sage: p.add_col(range(5), range(5)) sage: p.solve() @@ -302,7 +302,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 2 sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) @@ -316,7 +316,6 @@ cdef class GenericSDPBackend: sage: p.get_variable_value(1) 1.5 """ - raise NotImplementedError() cpdef get_variable_value(self, int variable) noexcept: @@ -331,7 +330,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 2 sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) @@ -356,7 +355,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variables(2) @@ -375,14 +374,13 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.nrows() 0 sage: p.add_linear_constraints(2, 2.0, None) sage: p.nrows() 2 """ - raise NotImplementedError() cpdef bint is_maximization(self) noexcept: @@ -393,7 +391,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -413,10 +411,11 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.problem_name("There once was a french fry") # optional - Nonexistent_LP_solver - sage: print(p.problem_name()) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") + sage: p.problem_name("There once was a french fry") + sage: print(p.problem_name()) There once was a french fry """ @@ -441,7 +440,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 5 sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) @@ -452,8 +451,6 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - - cpdef row_name(self, int index) noexcept: """ Return the ``index`` th row name @@ -464,10 +461,11 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_linear_constraints(1, 2, None, name="Empty constraint 1") # optional - Nonexistent_LP_solver - sage: p.row_name(0) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") + sage: p.add_linear_constraints(1, 2, None, name="Empty constraint 1") + sage: p.row_name(0) 'Empty constraint 1' """ @@ -486,11 +484,12 @@ cdef class GenericSDPBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable(name="I am a variable") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") + sage: p.add_variable(name="I am a variable") 1 - sage: p.col_name(0) # optional - Nonexistent_LP_solver + sage: p.col_name(0) 'I am a variable' """ raise NotImplementedError() @@ -510,7 +509,7 @@ cdef class GenericSDPBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") + sage: p = SemidefiniteProgram(maximization=False, solver="Nonexistent_LP_solver") sage: x = p.new_variable() sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) @@ -523,8 +522,8 @@ cdef class GenericSDPBackend: sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) sage: p.solve() -3.0 - sage: B=p.get_backend() - sage: x=p.get_values(x).values() + sage: B = p.get_backend() + sage: x = p.get_values(x).values() sage: -(a3*B.dual_variable(0)).trace()-(b3*B.dual_variable(1)).trace() -3.0 sage: g = sum((B.slack(j)*B.dual_variable(j)).trace() for j in range(2)); g @@ -557,7 +556,7 @@ cdef class GenericSDPBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = SemidefiniteProgram(maximization = False,solver = "Nonexistent_LP_solver") + sage: p = SemidefiniteProgram(maximization=False, solver="Nonexistent_LP_solver") sage: x = p.new_variable() sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) @@ -570,7 +569,7 @@ cdef class GenericSDPBackend: sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) sage: p.solve() -3.0 - sage: B=p.get_backend() + sage: B = p.get_backend() sage: B1 = B.slack(1); B1 [0.0 0.0] [0.0 0.0] @@ -611,7 +610,7 @@ cdef class GenericSDPBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_sdp_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.solver_parameter("timelimit") sage: p.solver_parameter("timelimit", 60) sage: p.solver_parameter("timelimit") @@ -630,15 +629,15 @@ def default_sdp_solver(solver=None): - ``solver`` -- one of the following: - - the string ``"CVXOPT"``, to make the use of the CVXOPT solver - (see the `CVXOPT `_ web site) the default; + - the string ``"CVXOPT"``, to make the use of the CVXOPT solver + (see the `CVXOPT `_ web site) the default; - - a subclass of - :class:`sage.numerical.backends.generic_sdp_backend.GenericSDPBackend`, - to make it the default; or + - a subclass of + :class:`sage.numerical.backends.generic_sdp_backend.GenericSDPBackend`, + to make it the default; or - - ``None`` (default), in which case the current default solver - (a string or a class) is returned. + - ``None`` (default), in which case the current default solver + (a string or a class) is returned. OUTPUT: @@ -711,14 +710,14 @@ cpdef GenericSDPBackend get_solver(solver=None, base_ring=None) noexcept: - ``solver`` -- one of the following: - - the string ``"CVXOPT"``, designating the use of the CVXOPT solver - (see the `CVXOPT `_ web site); + - the string ``"CVXOPT"``, designating the use of the CVXOPT solver + (see the `CVXOPT `_ web site); - - a subclass of - :class:`sage.numerical.backends.generic_sdp_backend.GenericSDPBackend`; + - a subclass of + :class:`sage.numerical.backends.generic_sdp_backend.GenericSDPBackend`; - - ``None`` (default), in which case the default solver is used (see - :func:`default_sdp_solver`); + - ``None`` (default), in which case the default solver is used (see + :func:`default_sdp_solver`); .. SEEALSO:: From 79a007f077676b886972f365a21502fb07518b53 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Oct 2023 18:10:41 -0700 Subject: [PATCH 342/494] src/sage/numerical/backends/generic_backend.pyx: Doctest/docstring cosmetics --- .../numerical/backends/generic_backend.pyx | 164 +++++++++--------- 1 file changed, 84 insertions(+), 80 deletions(-) diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 434f4304c62..c9a7e149e8d 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -3,7 +3,7 @@ Generic Backend for LP solvers This class only lists the methods that should be defined by any interface with a LP Solver. All these methods immediately raise -``NotImplementedError`` exceptions when called, and are obviously +:class:`NotImplementedError` exceptions when called, and are obviously meant to be replaced by the solver-specific method. This file can also be used as a template to create a new interface : one would only need to replace the occurrences of ``"Nonexistent_LP_solver"`` by the @@ -71,7 +71,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() @@ -86,7 +86,7 @@ cdef class GenericBackend: Traceback (most recent call last): ... ValueError: ... - sage: p.add_variable(name='x',obj=1.0) + sage: p.add_variable(name='x', obj=1.0) 3 sage: p.col_name(3) 'x' @@ -126,7 +126,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variables(5) @@ -218,17 +218,17 @@ cdef class GenericBackend: - ``variable`` (integer) -- the variable's id - - ``vtype`` (integer) : + - ``vtype`` (integer): - * 1 Integer - * 0 Binary - * -1 Continuous + * `1` Integer + * `0` Binary + * `-1` Continuous EXAMPLES:: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() @@ -254,7 +254,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -300,7 +300,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variable() 0 sage: p.objective_coefficient(0) @@ -323,7 +323,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.objective_constant_term() 0.0 sage: p.objective_constant_term(42) @@ -350,7 +350,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 4 sage: p.set_objective([1, 1, 2, 1, 3]) @@ -362,8 +362,8 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: p = MixedIntegerLinearProgram(solver='Nonexistent_LP_solver') sage: x,y = p[0], p[1] - sage: p.add_constraint(2*x + 3*y, max = 6) - sage: p.add_constraint(3*x + 2*y, max = 6) + sage: p.add_constraint(2*x + 3*y, max=6) + sage: p.add_constraint(3*x + 2*y, max=6) sage: p.set_objective(x + y + 7) sage: p.set_integer(x); p.set_integer(y) sage: p.solve() @@ -382,7 +382,7 @@ cdef class GenericBackend: EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: p.set_verbosity(2) # optional - Nonexistent_LP_solver """ raise NotImplementedError() @@ -401,8 +401,8 @@ cdef class GenericBackend: sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") sage: v = p.new_variable(nonnegative=True) sage: x,y = v[0], v[1] - sage: p.add_constraint(2*x + 3*y, max = 6) - sage: p.add_constraint(3*x + 2*y, max = 6) + sage: p.add_constraint(2*x + 3*y, max=6) + sage: p.add_constraint(3*x + 2*y, max=6) sage: p.set_objective(x + y + 7) sage: p.set_integer(x); p.set_integer(y) sage: p.solve() @@ -427,7 +427,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 1 sage: p.add_linear_constraint([(0, 2), (1, 3)], None, 6) @@ -465,7 +465,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 4 sage: p.add_linear_constraint( zip(range(5), range(5)), 2.0, 2.0) @@ -510,14 +510,15 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: coeffs = ([0, vector([1, 2])], [1, vector([2, 3])]) sage: upper = vector([5, 5]) sage: lower = vector([0, 0]) - sage: p.add_variables(2) # optional - Nonexistent_LP_solver + sage: p.add_variables(2) 1 - sage: p.add_linear_constraint_vector(2, coeffs, lower, upper, 'foo') # optional - Nonexistent_LP_solver + sage: p.add_linear_constraint_vector(2, coeffs, lower, upper, 'foo') """ for d in range(degree): coefficients_d = [] @@ -583,7 +584,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.nrows() @@ -637,7 +638,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 5 sage: p.add_linear_constraints(5, None, 2) @@ -702,7 +703,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_linear_constraints(5, 0, None) sage: p.add_col(list(range(5)), list(range(5))) sage: p.solve() @@ -756,7 +757,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 1 sage: p.add_linear_constraint([(0,1), (1,2)], None, 3) @@ -855,7 +856,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 1 sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3) @@ -880,7 +881,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variables(2) @@ -907,7 +908,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.nrows() 0 sage: p.add_linear_constraints(2, 2.0, None) @@ -925,7 +926,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.is_maximization() True sage: p.set_sense(-1) @@ -946,7 +947,7 @@ cdef class GenericBackend: EXAMPLES:: sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver sage: p.problem_name("There once was a french fry") # optional - Nonexistent_LP_solver sage: print(p.problem_name()) # optional - Nonexistent_LP_solver There once was a french fry @@ -966,7 +967,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 2 sage: p.add_linear_constraint([(0, 1], (1, 2)], None, 3) @@ -989,7 +990,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(2) 2 sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3) @@ -1009,7 +1010,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") sage: b = p.new_variable() sage: p.add_constraint(b[1] + b[2] <= 6) sage: p.set_objective(b[1] + b[2]) @@ -1027,7 +1028,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") sage: b = p.new_variable() sage: p.add_constraint(b[1] + b[2] <= 6) sage: p.set_objective(b[1] + b[2]) @@ -1047,7 +1048,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = MixedIntegerLinearProgram(solver = "Nonexistent_LP_solver") + sage: p = MixedIntegerLinearProgram(solver="Nonexistent_LP_solver") sage: b = p.new_variable() sage: p.add_constraint(b[1] + b[2] <= 6) sage: p.set_objective(b[1] + b[2]) @@ -1078,7 +1079,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2) @@ -1107,7 +1108,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variables(5) 4 sage: p.add_linear_constraint(list(range(5)), list(range(5)), 2, 2) @@ -1136,7 +1137,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -1159,7 +1160,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() @@ -1183,7 +1184,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() @@ -1206,7 +1207,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.ncols() 0 sage: p.add_variable() @@ -1230,10 +1231,11 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_linear_constraints(1, 2, None, names=['Empty constraint 1']) # optional - Nonexistent_LP_solver - sage: p.row_name(0) # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") + sage: p.add_linear_constraints(1, 2, None, names=['Empty constraint 1']) + sage: p.row_name(0) 'Empty constraint 1' """ @@ -1252,11 +1254,12 @@ cdef class GenericBackend: EXAMPLES:: + sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver - sage: p.add_variable(name="I am a variable") # optional - Nonexistent_LP_solver + sage: p = get_solver(solver="Nonexistent_LP_solver") + sage: p.add_variable(name="I am a variable") 1 - sage: p.col_name(0) # optional - Nonexistent_LP_solver + sage: p.col_name(0) 'I am a variable' """ raise NotImplementedError() @@ -1358,7 +1361,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -1385,7 +1388,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.add_variable() 0 sage: p.col_bounds(0) @@ -1416,7 +1419,7 @@ cdef class GenericBackend: sage: # optional - nonexistent_lp_solver sage: from sage.numerical.backends.generic_backend import get_solver - sage: p = get_solver(solver = "Nonexistent_LP_solver") + sage: p = get_solver(solver="Nonexistent_LP_solver") sage: p.solver_parameter("timelimit") sage: p.solver_parameter("timelimit", 60) sage: p.solver_parameter("timelimit") @@ -1437,8 +1440,8 @@ cdef class GenericBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = MixedIntegerLinearProgram(maximization=True,\ - solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(maximization=True, + ....: solver="Nonexistent_LP_solver") sage: x = p.new_variable(nonnegative=True) sage: p.add_constraint(-x[0] + x[1] <= 2) sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) @@ -1468,8 +1471,8 @@ cdef class GenericBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = MixedIntegerLinearProgram(maximization=True,\ - solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(maximization=True, + ....: solver="Nonexistent_LP_solver") sage: x = p.new_variable(nonnegative=True) sage: p.add_constraint(-x[0] + x[1] <= 2) sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) @@ -1499,8 +1502,8 @@ cdef class GenericBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = MixedIntegerLinearProgram(maximization=True,\ - solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(maximization=True, + ....: solver="Nonexistent_LP_solver") sage: x = p.new_variable(nonnegative=True) sage: p.add_constraint(-x[0] + x[1] <= 2) sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) @@ -1530,8 +1533,8 @@ cdef class GenericBackend: EXAMPLES:: sage: # optional - nonexistent_lp_solver - sage: p = MixedIntegerLinearProgram(maximization=True,\ - solver="Nonexistent_LP_solver") # optional - Nonexistent_LP_solver + sage: p = MixedIntegerLinearProgram(maximization=True, + ....: solver="Nonexistent_LP_solver") sage: x = p.new_variable(nonnegative=True) sage: p.add_constraint(-x[0] + x[1] <= 2) sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17) @@ -1592,20 +1595,20 @@ def default_mip_solver(solver=None): - ``solver`` -- one of the following: - - a string indicating one of the available solvers - (see :class:`MixedIntegerLinearProgram`); + - a string indicating one of the available solvers + (see :class:`MixedIntegerLinearProgram`); - - a callable (typically a subclass of - :class:`sage.numerical.backends.generic_backend.GenericBackend`); + - a callable (typically a subclass of + :class:`sage.numerical.backends.generic_backend.GenericBackend`); - - ``None`` (default), in which case the current default solver - is returned; this is either a string or a callable. + - ``None`` (default), in which case the current default solver + is returned; this is either a string or a callable. OUTPUT: This function returns the current default solver's name if ``solver = None`` (default). Otherwise, it sets the default solver to the one given. If this - solver does not exist, or is not available, a ``ValueError`` exception is + solver does not exist, or is not available, a :class:`ValueError` exception is raised. EXAMPLES:: @@ -1717,7 +1720,8 @@ def default_mip_solver(solver=None): else: raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'InteractiveLP', a callable, or None.") -cpdef GenericBackend get_solver(constraint_generation = False, solver = None, base_ring = None) noexcept: + +cpdef GenericBackend get_solver(constraint_generation=False, solver=None, base_ring=None) noexcept: """ Return a solver according to the given preferences @@ -1725,22 +1729,22 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba - ``solver`` -- one of the following: - - a string indicating one of the available solvers - (see :class:`MixedIntegerLinearProgram`); + - a string indicating one of the available solvers + (see :class:`MixedIntegerLinearProgram`); - - ``None`` (default), in which case the default solver is used - (see :func:`default_mip_solver`); + - ``None`` (default), in which case the default solver is used + (see :func:`default_mip_solver`); - - or a callable (such as a class), in which case it is called, - and its result is returned. + - or a callable (such as a class), in which case it is called, + and its result is returned. - ``base_ring`` -- If not ``None``, request a solver that works over this - (ordered) field. If ``base_ring`` is not a field, its fraction field - is used. + (ordered) field. If ``base_ring`` is not a field, its fraction field + is used. - For example, is ``base_ring=ZZ`` is provided, the solver will work over - the rational numbers. This is unrelated to whether variables are - constrained to be integers or not. + For example, is ``base_ring=ZZ`` is provided, the solver will work over + the rational numbers. This is unrelated to whether variables are + constrained to be integers or not. - ``constraint_generation`` -- Only used when ``solver=None``. @@ -1784,7 +1788,7 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba sage: p.base_ring() Rational Field - Passing a callable as the 'solver':: + Passing a callable as the ``solver``:: sage: from sage.numerical.backends.glpk_backend import GLPKBackend sage: p = get_solver(solver=GLPKBackend); p From 3e2b9cecdf61f64257ccd4b7479ba87733377e39 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Oct 2023 18:40:58 -0700 Subject: [PATCH 343/494] src/sage/numerical/sdp.pyx: Doctest cosmetics, use block tags --- src/sage/numerical/sdp.pyx | 135 +++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index 197a542e14d..3f5f8a47cfb 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -72,17 +72,19 @@ The following example shows all these steps:: sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) sage: p.add_constraint(c1*x[0] + c2*x[1] >= matrix.zero(2,2,sparse=True)) - sage: p.solver_parameter("show_progress", True) # needs cvxopt - sage: opt = p.solve() # needs cvxopt + + sage: # needs cvxopt + sage: p.solver_parameter("show_progress", True) + sage: opt = p.solve() pcost dcost gap pres dres k/t 0: ... ... Optimal solution found. - sage: print('Objective Value: {}'.format(N(opt,3))) # needs cvxopt + sage: print('Objective Value: {}'.format(N(opt,3))) Objective Value: 1.0 - sage: [N(x, 3) for x in sorted(p.get_values(x).values())] # needs cvxopt + sage: [N(x, 3) for x in sorted(p.get_values(x).values())] [3.0e-8, 1.0] - sage: p.show() # needs cvxopt + sage: p.show() Maximization: x_0 - x_1 Constraints: @@ -304,7 +306,7 @@ cdef class SemidefiniteProgram(SageObject): - CVXOPT (``solver="CVXOPT"``). See the `CVXOPT `_ web site. - -If ``solver=None`` (default), the default solver is used (see + - If ``solver=None`` (default), the default solver is used (see ``default_sdp_solver`` method. - ``maximization`` @@ -338,7 +340,6 @@ cdef class SemidefiniteProgram(SageObject): # Associates an index to the variables self._variables = {} - def linear_functions_parent(self): """ Return the parent for all linear functions. @@ -482,8 +483,8 @@ cdef class SemidefiniteProgram(SageObject): def new_variable(self, name=""): r""" - Returns an instance of ``SDPVariable`` associated - to the current instance of ``SemidefiniteProgram``. + Returns an instance of :class:`SDPVariable` associated + to the current instance of :class:`SemidefiniteProgram`. A new variable ``x`` is defined by:: @@ -507,7 +508,7 @@ cdef class SemidefiniteProgram(SageObject): sage: p = SemidefiniteProgram() sage: x = p.new_variable() sage: a1 = matrix([[1, 2.], [2., 3.]]) - sage: p.add_constraint(a1*x[0]+a1*x[3] <= 0) + sage: p.add_constraint(a1*x[0] + a1*x[3] <= 0) sage: p.show() Maximization: @@ -570,7 +571,7 @@ cdef class SemidefiniteProgram(SageObject): cpdef int number_of_constraints(self) noexcept: r""" - Returns the number of constraints assigned so far. + Return the number of constraints assigned so far. EXAMPLES:: @@ -592,7 +593,7 @@ cdef class SemidefiniteProgram(SageObject): cpdef int number_of_variables(self) noexcept: r""" - Returns the number of variables used so far. + Return the number of variables used so far. EXAMPLES:: @@ -605,11 +606,9 @@ cdef class SemidefiniteProgram(SageObject): """ return self._backend.ncols() - - def show(self): r""" - Displays the ``SemidefiniteProgram`` in a human-readable way. + Display the :class:`SemidefiniteProgram` in a human-readable way. EXAMPLES: @@ -621,7 +620,7 @@ cdef class SemidefiniteProgram(SageObject): sage: a2 = matrix([[2,3],[3,4]]) sage: a3 = matrix([[3,4],[4,5]]) sage: p.set_objective(x[0] - x[1]) - sage: p.add_constraint(a1*x[0]+a2*x[1]<= a3) + sage: p.add_constraint(a1*x[0] + a2*x[1]<= a3) sage: p.show() Maximization: hihi[0] - hihi[1] @@ -695,25 +694,23 @@ cdef class SemidefiniteProgram(SageObject): print(str(varid_name[i]) + ", ", end=" ") print(str(varid_name[b.ncols()-1])) - def get_values(self, *lists): r""" Return values found by the previous call to ``solve()``. INPUT: - - Any instance of ``SDPVariable`` (or one of its elements), + - Any instance of :class:`SDPVariable` (or one of its elements), or lists of them. OUTPUT: - - Each instance of ``SDPVariable`` is replaced by a dictionary + - Each instance of :class:`SDPVariable` is replaced by a dictionary containing the numerical values found for each corresponding variable in the instance. - - Each element of an instance of a ``SDPVariable`` is replaced + - Each element of an instance of a :class:`SDPVariable` is replaced by its corresponding numerical value. - EXAMPLES:: sage: p = SemidefiniteProgram(solver = "cvxopt", maximization = False) @@ -727,7 +724,7 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[3] + a2*x[5] <= a3) sage: p.add_constraint(b1*x[3] + b2*x[5] <= b3) - sage: N(p.solve(),3) # needs cvxopt + sage: N(p.solve(), 3) # needs cvxopt -3.0 To return the optimal value of ``x[3]``:: @@ -768,13 +765,13 @@ cdef class SemidefiniteProgram(SageObject): def set_objective(self, obj): r""" - Sets the objective of the ``SemidefiniteProgram``. + Sets the objective of the :class:`SemidefiniteProgram`. INPUT: - ``obj`` -- A semidefinite function to be optimized. - ( can also be set to ``None`` or ``0`` when just - looking for a feasible solution ) + (can also be set to ``None`` or ``0`` when just + looking for a feasible solution) EXAMPLES: @@ -797,7 +794,7 @@ cdef class SemidefiniteProgram(SageObject): sage: a1 = matrix([[1,2],[2,3]]) sage: a2 = matrix([[1,1],[1,1]]) sage: a3 = matrix([[1,-1],[-1,1]]) - sage: p.add_constraint(a1*x[1]+a2*x[2] <= a3) + sage: p.add_constraint(a1*x[1] + a2*x[2] <= a3) sage: N(p.solve(), digits=3) # needs cvxopt 16.2 sage: p.set_objective(None) @@ -828,11 +825,13 @@ cdef class SemidefiniteProgram(SageObject): INPUT: - ``linear_function`` -- Two different types of arguments are possible: - - A linear function. In this case, arguments ``min`` or ``max`` - have to be specified. - - A linear constraint of the form ``A <= B``, ``A >= B``, - ``A <= B <= C``, ``A >= B >= C`` or ``A == B``. In this - case, arguments ``min`` and ``max`` will be ignored. + + - A linear function. In this case, arguments ``min`` or ``max`` + have to be specified. + - A linear constraint of the form ``A <= B``, ``A >= B``, + ``A <= B <= C``, ``A >= B >= C`` or ``A == B``. In this + case, arguments ``min`` and ``max`` will be ignored. + - ``name`` -- A name for the constraint. EXAMPLES: @@ -856,7 +855,7 @@ cdef class SemidefiniteProgram(SageObject): sage: a1 = matrix([[1,2],[2,3]]) sage: a2 = matrix([[1,1],[1,1]]) sage: a3 = matrix([[1,-1],[-1,1]]) - sage: p.add_constraint(a1*x[1]+a2*x[2] <= a3) + sage: p.add_constraint(a1*x[1] + a2*x[2] <= a3) sage: N(p.solve(), digits=3) # needs cvxopt 16.2 @@ -895,7 +894,6 @@ cdef class SemidefiniteProgram(SageObject): sage: p = SemidefiniteProgram() sage: p.add_constraint(sum([])) - """ if linear_function is 0: return @@ -921,7 +919,7 @@ cdef class SemidefiniteProgram(SageObject): def solve(self, objective_only=False): r""" - Solves the ``SemidefiniteProgram``. + Solve the :class:`SemidefiniteProgram`. INPUT: @@ -950,12 +948,14 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: N(p.solve(),4) # needs cvxopt + + sage: # needs cvxopt + sage: N(p.solve(), 4) -11. - sage: x = p.get_values(x) # needs cvxopt - sage: N(x[0],4) # needs cvxopt + sage: x = p.get_values(x) + sage: N(x[0],4) -8.0 - sage: N(x[1],4) # needs cvxopt + sage: N(x[1],4) 3.0 """ self._backend.solve() @@ -980,7 +980,7 @@ cdef class SemidefiniteProgram(SageObject): Dual objective value is the same as the primal one:: - sage: p = SemidefiniteProgram(maximization = False) + sage: p = SemidefiniteProgram(maximization=False) sage: x = p.new_variable() sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) @@ -991,15 +991,18 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: p.solve() # tol 1e-08 # needs cvxopt + + sage: # needs cvxopt + sage: p.solve() # tol 1e-08 -3.0 - sage: x = p.get_values(x).values() # needs cvxopt - sage: -(a3*p.dual_variable(0)).trace()-(b3*p.dual_variable(1)).trace() # tol 1e-07 # needs cvxopt + sage: x = p.get_values(x).values() + sage: -(a3*p.dual_variable(0)).trace() - (b3*p.dual_variable(1)).trace() # tol 1e-07 -3.0 Dual variable is orthogonal to the slack :: - sage: g = sum((p.slack(j)*p.dual_variable(j)).trace() for j in range(2)); g # tol 1.2e-08 # needs cvxopt + sage: # needs cvxopt + sage: g = sum((p.slack(j)*p.dual_variable(j)).trace() for j in range(2)); g # tol 1.2e-08 0.0 TESTS:: @@ -1038,15 +1041,17 @@ cdef class SemidefiniteProgram(SageObject): sage: b3 = matrix([[3, 3.], [3., 3.]]) sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) - sage: p.solve() # tol 1e-08 # needs cvxopt + + sage: # needs cvxopt + sage: p.solve() # tol 1e-08 -3.0 - sage: B1 = p.slack(1); B1 # tol 1e-08 # needs cvxopt + sage: B1 = p.slack(1); B1 # tol 1e-08 [0.0 0.0] [0.0 0.0] - sage: B1.is_positive_definite() # needs cvxopt + sage: B1.is_positive_definite() True - sage: x = sorted(p.get_values(x).values()) # needs cvxopt - sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 # needs cvxopt + sage: x = sorted(p.get_values(x).values()) + sage: x[0]*b1 + x[1]*b2 - b3 + B1 # tol 1e-09 [0.0 0.0] [0.0 0.0] @@ -1069,7 +1074,6 @@ cdef class SemidefiniteProgram(SageObject): (If you do not know which solver you are using, then you are using CVXOPT). - INPUT: - ``name`` (string) -- the parameter @@ -1079,21 +1083,22 @@ cdef class SemidefiniteProgram(SageObject): EXAMPLES:: - sage: p. = SemidefiniteProgram(solver="cvxopt", # needs cvxopt + sage: # needs cvxopt + sage: p. = SemidefiniteProgram(solver="cvxopt", ....: maximization=False) - sage: p.solver_parameter("show_progress", True) # needs cvxopt - sage: p.solver_parameter("show_progress") # needs cvxopt + sage: p.solver_parameter("show_progress", True) + sage: p.solver_parameter("show_progress") True - sage: p.set_objective(x[0] - x[1]) # needs cvxopt + sage: p.set_objective(x[0] - x[1]) sage: a1 = matrix([[1, 2.], [2., 3.]]) sage: a2 = matrix([[3, 4.], [4., 2.]]) sage: a3 = matrix([[5, 6.], [6., 7.]]) sage: b1 = matrix([[1, 1.], [1., 1.]]) sage: b2 = matrix([[2, 2.], [2., 1.]]) sage: b3 = matrix([[3, 3.], [3., 3.]]) - sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) # needs cvxopt - sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) # needs cvxopt - sage: N(p.solve(),4) # needs cvxopt + sage: p.add_constraint(a1*x[0] + a2*x[1] <= a3) + sage: p.add_constraint(b1*x[0] + b2*x[1] <= b3) + sage: N(p.solve(), 4) pcost dcost gap pres dres k/t 0: 1... ... @@ -1181,13 +1186,14 @@ class SDPSolverException(RuntimeError): No solution:: - sage: p = SemidefiniteProgram(solver="cvxopt") # needs cvxopt - sage: x = p.new_variable() # needs cvxopt - sage: p.set_objective(x[0]) # needs cvxopt + sage: # needs cvxopt + sage: p = SemidefiniteProgram(solver="cvxopt") + sage: x = p.new_variable() + sage: p.set_objective(x[0]) sage: a = matrix([[1,2],[2,4]]) sage: b = matrix([[1,9],[9,4]]) - sage: p.add_constraint( a*x[0] == b ) # needs cvxopt - sage: p.solve() # needs cvxopt + sage: p.add_constraint(a*x[0] == b) + sage: p.solve() Traceback (most recent call last): ... SDPSolverException: ... @@ -1224,7 +1230,6 @@ cdef class SDPVariable(Element): - ``sdp`` -- :class:`SemidefiniteProgram`. The underlying linear program. - - ``name`` -- A name for the ``SDPVariable``. - ``lower_bound``, ``upper_bound`` -- lower bound and upper @@ -1248,7 +1253,7 @@ cdef class SDPVariable(Element): def __getitem__(self, i): r""" - Returns the symbolic variable corresponding to the key. + Return the symbolic variable corresponding to the key. Returns the element asked, otherwise creates it. @@ -1279,8 +1284,8 @@ cdef class SDPVariable(Element): EXAMPLES:: - sage: p=SemidefiniteProgram() - sage: v=p.new_variable() + sage: p = SemidefiniteProgram() + sage: v = p.new_variable() sage: v SDPVariable """ From 1f0c2a2d7ca8c1f5c9724a877cab17675c8af3bc Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Oct 2023 13:31:07 -0700 Subject: [PATCH 344/494] src/sage/numerical/backends/generic_backend.pyx: Restore lost # tol --- src/sage/numerical/backends/generic_backend.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index c9a7e149e8d..c5c7dadc4c1 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -141,13 +141,13 @@ cdef class GenericBackend: Check that arguments are used:: sage: # optional - nonexistent_lp_solver - sage: p.col_bounds(5) + sage: p.col_bounds(5) # tol 1e-8 (-2.0, None) sage: p.is_variable_integer(5) True sage: p.col_name(5) 'a' - sage: p.objective_coefficient(5) + sage: p.objective_coefficient(5) # tol 1e-8 42.0 """ cdef int i From acb42fb9d880bd72df535c9b3d8c54131e3603be Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 16:16:50 -0700 Subject: [PATCH 345/494] build/pkgs/fpylll: Update to 0.6.0 --- build/pkgs/fpylll/checksums.ini | 6 +++--- build/pkgs/fpylll/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/fpylll/checksums.ini b/build/pkgs/fpylll/checksums.ini index 0172ce17065..d94a0bbf30f 100644 --- a/build/pkgs/fpylll/checksums.ini +++ b/build/pkgs/fpylll/checksums.ini @@ -1,5 +1,5 @@ tarball=fpylll-VERSION.tar.gz -sha1=2dcc29155ee11b4460fc79c2d933b6b8230c89f6 -md5=828b3a382594d34d8788e9ff041125bd -cksum=921330875 +sha1=f23835208fc048028c849bb5b566f2fe631df7f4 +md5=c81a1af8ecf57ae740366a110dfbbbaf +cksum=398170701 upstream_url=https://github.com/fplll/fpylll/releases/download/VERSION/fpylll-VERSION.tar.gz diff --git a/build/pkgs/fpylll/package-version.txt b/build/pkgs/fpylll/package-version.txt index 416bfb0a221..a918a2aa18d 100644 --- a/build/pkgs/fpylll/package-version.txt +++ b/build/pkgs/fpylll/package-version.txt @@ -1 +1 @@ -0.5.9 +0.6.0 From b3298c28516dd704215317e27e68b7010b24f315 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 16:47:38 -0700 Subject: [PATCH 346/494] build/pkgs/fplll: Update to 5.4.5 --- build/pkgs/fplll/checksums.ini | 6 +++--- build/pkgs/fplll/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/fplll/checksums.ini b/build/pkgs/fplll/checksums.ini index 22fba10e438..5f9ec9753be 100644 --- a/build/pkgs/fplll/checksums.ini +++ b/build/pkgs/fplll/checksums.ini @@ -1,5 +1,5 @@ tarball=fplll-VERSION.tar.gz -sha1=8353a0db588d891951aa9760fbe490f4e308de8d -md5=7e333d7d0e535d27c591271340e28865 -cksum=2543682321 +sha1=607f5922109d93ddd5a05419682511e26579f9d6 +md5=fa4e1f24994c0345a9530397a3369b27 +cksum=4174005926 upstream_url=https://github.com/fplll/fplll/releases/download/VERSION/fplll-VERSION.tar.gz diff --git a/build/pkgs/fplll/package-version.txt b/build/pkgs/fplll/package-version.txt index 426c1c17944..8ce222e90f7 100644 --- a/build/pkgs/fplll/package-version.txt +++ b/build/pkgs/fplll/package-version.txt @@ -1 +1 @@ -5.4.4 +5.4.5 From f8c36e3a2c6c55db0dd7c0e1419dcd9823fddf54 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 16:49:08 -0700 Subject: [PATCH 347/494] build/pkgs/fplll/spkg-configure.m4: Only accept system fplll 5.4.5 --- build/pkgs/fplll/spkg-configure.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/fplll/spkg-configure.m4 b/build/pkgs/fplll/spkg-configure.m4 index 4e58e636d79..9eca84dc240 100644 --- a/build/pkgs/fplll/spkg-configure.m4 +++ b/build/pkgs/fplll/spkg-configure.m4 @@ -8,7 +8,7 @@ SAGE_SPKG_CONFIGURE([fplll], [ dnl Trac #31025: FPLLL/FPyLLL make no guarantee regarding compatibility dnl other than "whatever versions were released at the same time should work together" PKG_CHECK_MODULES([FPLLL], - [fplll >= 5.4.4 fplll <= 5.4.4], + [fplll >= 5.4.5 fplll <= 5.4.5], [ AC_MSG_CHECKING([whether BKZ default strategy JSON is installed]) AC_LANG_PUSH([C++]) From fcb68f2326d60f31cddb413d44835d00bf176179 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 16:54:20 -0700 Subject: [PATCH 348/494] build/pkgs/fpylll/patches/cython3-legacy.patch: Remove --- .../pkgs/fpylll/patches/cython3-legacy.patch | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 build/pkgs/fpylll/patches/cython3-legacy.patch diff --git a/build/pkgs/fpylll/patches/cython3-legacy.patch b/build/pkgs/fpylll/patches/cython3-legacy.patch deleted file mode 100644 index 808c14e9c1b..00000000000 --- a/build/pkgs/fpylll/patches/cython3-legacy.patch +++ /dev/null @@ -1,37 +0,0 @@ -commit b6e12c2b0648e84b26dcf0aac507a5b4d9dde301 -Author: Gonzalo Tornaría -Date: Wed Jul 19 20:38:01 2023 -0300 - - cython3 support using legacy directives - -diff --git a/setup.py b/setup.py -index 274836f..8fc5af5 100755 ---- a/setup.py -+++ b/setup.py -@@ -123,7 +123,12 @@ class build_ext(_build_ext, object): - self.extensions, - include_path=["src"], - build_dir=self.cythonize_dir, -- compiler_directives={"binding": True, "embedsignature": True, "language_level": 2}, -+ compiler_directives={ -+ "binding": True, -+ "embedsignature": True, -+ "language_level": 2, -+ "legacy_implicit_noexcept": True, -+ }, - ) - super(build_ext, self).run() - -diff --git a/src/fpylll/fplll/enumeration_callback_helper.h b/src/fpylll/fplll/enumeration_callback_helper.h -index c099430..706162f 100644 ---- a/src/fpylll/fplll/enumeration_callback_helper.h -+++ b/src/fpylll/fplll/enumeration_callback_helper.h -@@ -5,7 +5,7 @@ - #include - #include - --extern "C" { -+extern "C++" { - bool evaluator_callback_call_obj(PyObject *obj, int n, double *new_sol_coord); - } - From a3b2f9b68d3dee76a8015f2dd6a97b942f43415f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 17 Oct 2023 19:07:53 -0700 Subject: [PATCH 349/494] build/pkgs/fpylll/checksums.ini: Use pypi URL --- build/pkgs/fpylll/checksums.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/fpylll/checksums.ini b/build/pkgs/fpylll/checksums.ini index d94a0bbf30f..156fc587670 100644 --- a/build/pkgs/fpylll/checksums.ini +++ b/build/pkgs/fpylll/checksums.ini @@ -2,4 +2,4 @@ tarball=fpylll-VERSION.tar.gz sha1=f23835208fc048028c849bb5b566f2fe631df7f4 md5=c81a1af8ecf57ae740366a110dfbbbaf cksum=398170701 -upstream_url=https://github.com/fplll/fpylll/releases/download/VERSION/fpylll-VERSION.tar.gz +upstream_url=https://pypi.io/packages/source/f/fpylll/fpylll-VERSION.tar.gz From 3194af3626c662aff20dcee81635a7928e122fbb Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Tue, 31 Oct 2023 01:27:02 +0000 Subject: [PATCH 350/494] Add max leaf number function --- src/sage/graphs/domination.py | 39 ++++++++++++++++++++++++++++++++ src/sage/graphs/generic_graph.py | 2 ++ 2 files changed, 41 insertions(+) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 0dcab74e90c..5e4ac0348fe 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -17,6 +17,7 @@ :meth:`~is_redundant` | Check whether a set of vertices has redundant vertices (with respect to domination). :meth:`~private_neighbors` | Return the private neighbors of a vertex with respect to other vertices. :meth:`~greedy_dominating_set` | Return a greedy distance-`k` dominating set of the graph. + :meth:`~max_leaf_number` | Return the maximum leaf number of the graph. EXAMPLES: @@ -1284,3 +1285,41 @@ def greedy_dominating_set(G, k=1, vertices=None, ordering=None, return_sets=Fals return dom else: return list(dom) + + +def max_leaf_number(G): + r""" + Return the maximum leaf number of the graph, i.e. the maximum possible number + of leaf nodes a tree produced from the graph can have. + + INPUT: + + - ``G`` -- a Graph + + EXAMPLES: + + Empty graph:: + + sage: G = Graph() + sage: G.max_leaf_number() + 0 + + Petersen graph:: + + sage: G = graphs.PetersenGraph() + sage: G.max_leaf_number() + 6 + + Unconnected graph:: + + sage: G = 2 * graphs.PetersenGraph() + sage: G.max_leaf_number() + Traceback (most recent call last): + ... + ValueError: the graph must be connected + """ + if G.order() < 2: + return 0 + elif not G.is_connected(): + raise ValueError('the graph must be connected') + return G.order() - dominating_set(G, connected=True, value_only=True) \ No newline at end of file diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..b5d8efc0125 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -315,6 +315,7 @@ :meth:`~GenericGraph.disjoint_routed_paths` | Return a set of disjoint routed paths. :meth:`~GenericGraph.dominating_set` | Return a minimum dominating set of the graph :meth:`~GenericGraph.greedy_dominating_set` | Return a greedy distance-`k` dominating set of the graph. + :meth:`~GenericGraph.max_leaf_number` | Return the maximum leaf number of the graph. :meth:`~GenericGraph.subgraph_search` | Return a copy of ``G`` in ``self``. :meth:`~GenericGraph.subgraph_search_count` | Return the number of labelled occurrences of ``G`` in ``self``. :meth:`~GenericGraph.subgraph_search_iterator` | Return an iterator over the labelled copies of ``G`` in ``self``. @@ -24390,6 +24391,7 @@ def is_self_complementary(self): from sage.graphs.domination import dominating_sets from sage.graphs.domination import dominating_set from sage.graphs.domination import greedy_dominating_set + from sage.graphs.domination import max_leaf_number from sage.graphs.base.static_dense_graph import connected_subgraph_iterator rooted_product = LazyImport('sage.graphs.graph_decompositions.graph_products', 'rooted_product') from sage.graphs.path_enumeration import shortest_simple_paths From 736ef3599698006fda8d5fdfd0e17471967a6594 Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Tue, 31 Oct 2023 03:31:28 +0000 Subject: [PATCH 351/494] Minor style fixes --- src/sage/graphs/domination.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 5e4ac0348fe..54fc2ee1f21 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -1287,9 +1287,13 @@ def greedy_dominating_set(G, k=1, vertices=None, ordering=None, return_sets=Fals return list(dom) +# ============================================================================== +# Maximum leaf number +# ============================================================================== + def max_leaf_number(G): r""" - Return the maximum leaf number of the graph, i.e. the maximum possible number + Return the maximum leaf number of the graph, i.e. the maximum possible number of leaf nodes a tree produced from the graph can have. INPUT: @@ -1322,4 +1326,4 @@ def max_leaf_number(G): return 0 elif not G.is_connected(): raise ValueError('the graph must be connected') - return G.order() - dominating_set(G, connected=True, value_only=True) \ No newline at end of file + return G.order() - dominating_set(G, connected=True, value_only=True) From 1fbf59de82faaab6ac6dce5d1f6f78e729cf5d14 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 31 Oct 2023 12:36:35 +0900 Subject: [PATCH 352/494] Doc preview for all languages --- .github/workflows/doc-build-pdf.yml | 4 ++-- .github/workflows/doc-build.yml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index 2128277fbca..de58c143c74 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -67,7 +67,7 @@ jobs: git config --global user.name "Build & Test workflow" .ci/retrofit-worktree.sh worktree-image /sage # Keep track of changes to built HTML - new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") + new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") - name: Download upstream artifact uses: actions/download-artifact@v3 @@ -119,7 +119,7 @@ jobs: # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder mkdir -p ./docs - cp -r -L /sage/local/share/doc/sage/pdf/en/* ./docs + cp -r -L /sage/local/share/doc/sage/pdf/* ./docs # Zip everything for increased performance zip -r docs-pdf.zip docs diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 5eb3998feee..3894c405077 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -63,12 +63,12 @@ jobs: mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)") new_version=$(cat src/VERSION.txt) # Wipe out chronic diffs between old doc and new doc - (cd /sage/local/share/doc/sage/html/en && \ + (cd /sage/local/share/doc/sage/html && \ find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \ -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \ -e '\;; d') # Create git repo from old doc - (cd /sage/local/share/doc/sage/html/en && \ + (cd /sage/local/share/doc/sage/html && \ git init && \ (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \ (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \ @@ -116,9 +116,9 @@ jobs: run: | set -ex export SAGE_USE_CDNS=yes - mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc + mv /sage/local/share/doc/sage/html/.git /sage/.git-doc make doc-clean doc-uninstall - mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git + mkdir -p /sage/local/share/doc/sage/html/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/.git ./config.status && make sagemath_doc_html-no-deps working-directory: ./worktree-image env: @@ -131,9 +131,9 @@ jobs: run: | set -ex mkdir -p ./docs - (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') + (cd /sage/local/share/doc/sage/html && git commit -a -m 'new') # Wipe out chronic diffs between old doc and new doc - (cd /sage/local/share/doc/sage/html/en && \ + (cd /sage/local/share/doc/sage/html && \ find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html echo '' > ./docs/CHANGES.html @@ -162,7 +162,7 @@ jobs: EOF echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt + (cd /sage/local/share/doc/sage/html && git diff HEAD^; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF import re, html with open('./docs/diff.txt', 'r') as f: @@ -182,11 +182,11 @@ jobs: echo '' >> ./docs/CHANGES.html echo '' >>./docs/CHANGES.html rm ./docs/diff.txt ./docs/diff.html - (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) + (cd /sage/local/share/doc/sage/html && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them - cp -r -L /sage/local/share/doc/sage/html/en/* ./docs + cp -r -L /sage/local/share/doc/sage/html/* ./docs # Zip everything for increased performance zip -r docs.zip docs From 446f5a28f8d8657177803faed20a378276363a34 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 31 Oct 2023 05:53:25 +0000 Subject: [PATCH 353/494] Replace relative imports by absolute ones in ntl --- src/sage/libs/ntl/GF2.pxd | 2 +- src/sage/libs/ntl/GF2E.pxd | 2 +- src/sage/libs/ntl/GF2EX.pxd | 2 +- src/sage/libs/ntl/GF2X.pxd | 2 +- src/sage/libs/ntl/ZZ.pxd | 2 +- src/sage/libs/ntl/ZZX.pxd | 2 +- src/sage/libs/ntl/ZZ_p.pxd | 2 +- src/sage/libs/ntl/ZZ_pE.pxd | 2 +- src/sage/libs/ntl/ZZ_pEX.pxd | 2 +- src/sage/libs/ntl/ZZ_pX.pxd | 2 +- src/sage/libs/ntl/__init__.py | 3 ++- src/sage/libs/ntl/conversion.pxd | 2 +- src/sage/libs/ntl/convert.pxd | 2 +- src/sage/libs/ntl/error.pyx | 4 ++-- src/sage/libs/ntl/lzz_p.pxd | 2 +- src/sage/libs/ntl/lzz_pX.pxd | 2 +- src/sage/libs/ntl/mat_GF2.pxd | 2 +- src/sage/libs/ntl/mat_GF2E.pxd | 2 +- src/sage/libs/ntl/mat_ZZ.pxd | 2 +- src/sage/libs/ntl/ntl_GF2.pxd | 2 +- src/sage/libs/ntl/ntl_GF2E.pxd | 4 ++-- src/sage/libs/ntl/ntl_GF2E.pyx | 10 +++++----- src/sage/libs/ntl/ntl_GF2EContext.pxd | 4 ++-- src/sage/libs/ntl/ntl_GF2EX.pxd | 6 +++--- src/sage/libs/ntl/ntl_GF2EX.pyx | 8 ++++---- src/sage/libs/ntl/ntl_GF2X.pxd | 2 +- src/sage/libs/ntl/ntl_GF2X.pyx | 4 ++-- src/sage/libs/ntl/ntl_ZZX.pxd | 2 +- src/sage/libs/ntl/ntl_ZZ_p.pxd | 4 ++-- src/sage/libs/ntl/ntl_ZZ_pContext.pxd | 6 +++--- src/sage/libs/ntl/ntl_ZZ_pE.pxd | 6 +++--- src/sage/libs/ntl/ntl_ZZ_pEContext.pxd | 8 ++++---- src/sage/libs/ntl/ntl_ZZ_pEContext.pyx | 4 ++-- src/sage/libs/ntl/ntl_ZZ_pEX.pxd | 4 ++-- src/sage/libs/ntl/ntl_ZZ_pX.pxd | 2 +- src/sage/libs/ntl/ntl_lzz_p.pxd | 4 ++-- src/sage/libs/ntl/ntl_lzz_pContext.pxd | 2 +- src/sage/libs/ntl/ntl_mat_GF2.pxd | 4 ++-- src/sage/libs/ntl/ntl_mat_GF2.pyx | 2 +- src/sage/libs/ntl/ntl_mat_GF2E.pxd | 6 +++--- src/sage/libs/ntl/ntl_mat_GF2E.pyx | 6 +++--- src/sage/libs/ntl/ntl_mat_ZZ.pxd | 2 +- src/sage/libs/ntl/ntl_mat_ZZ.pyx | 2 +- src/sage/libs/ntl/vec_GF2.pxd | 2 +- src/sage/libs/ntl/vec_GF2E.pxd | 2 +- 45 files changed, 75 insertions(+), 74 deletions(-) diff --git a/src/sage/libs/ntl/GF2.pxd b/src/sage/libs/ntl/GF2.pxd index 9443f143dcf..5be7f496766 100644 --- a/src/sage/libs/ntl/GF2.pxd +++ b/src/sage/libs/ntl/GF2.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2_c +from sage.libs.ntl.types cimport GF2_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/GF2E.pxd b/src/sage/libs/ntl/GF2E.pxd index 352e35330fc..5a72efec6a4 100644 --- a/src/sage/libs/ntl/GF2E.pxd +++ b/src/sage/libs/ntl/GF2E.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2E_c, GF2X_c, GF2_c, GF2XModulus_c, ZZ_c +from sage.libs.ntl.types cimport GF2E_c, GF2X_c, GF2_c, GF2XModulus_c, ZZ_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/GF2EX.pxd b/src/sage/libs/ntl/GF2EX.pxd index c9d272f1c5a..4a0df45c9f1 100644 --- a/src/sage/libs/ntl/GF2EX.pxd +++ b/src/sage/libs/ntl/GF2EX.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2EX_c +from sage.libs.ntl.types cimport GF2EX_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/GF2X.pxd b/src/sage/libs/ntl/GF2X.pxd index 1539a37c93c..9342f63244c 100644 --- a/src/sage/libs/ntl/GF2X.pxd +++ b/src/sage/libs/ntl/GF2X.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2X_c, GF2_c, GF2XModulus_c, vec_GF2_c, ZZ_c +from sage.libs.ntl.types cimport GF2X_c, GF2_c, GF2XModulus_c, vec_GF2_c, ZZ_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ZZ.pxd b/src/sage/libs/ntl/ZZ.pxd index 2ac00565e78..fc8901fc31a 100644 --- a/src/sage/libs/ntl/ZZ.pxd +++ b/src/sage/libs/ntl/ZZ.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport ZZ_c +from sage.libs.ntl.types cimport ZZ_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ZZX.pxd b/src/sage/libs/ntl/ZZX.pxd index d46fce4bbb9..bc2780e3a83 100644 --- a/src/sage/libs/ntl/ZZX.pxd +++ b/src/sage/libs/ntl/ZZX.pxd @@ -1,7 +1,7 @@ # distutils: depends = NTL/ZZ.h from sage.libs.gmp.types cimport mpz_t -from .types cimport ZZ_c, vec_ZZ_c, ZZX_c +from sage.libs.ntl.types cimport ZZ_c, vec_ZZ_c, ZZX_c cdef extern from *: diff --git a/src/sage/libs/ntl/ZZ_p.pxd b/src/sage/libs/ntl/ZZ_p.pxd index 0bee7b282b9..1d7d95e4007 100644 --- a/src/sage/libs/ntl/ZZ_p.pxd +++ b/src/sage/libs/ntl/ZZ_p.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport ZZ_c, ZZ_p_c +from sage.libs.ntl.types cimport ZZ_c, ZZ_p_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ZZ_pE.pxd b/src/sage/libs/ntl/ZZ_pE.pxd index 7d92bae4479..bdfb04cb783 100644 --- a/src/sage/libs/ntl/ZZ_pE.pxd +++ b/src/sage/libs/ntl/ZZ_pE.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport ZZ_c, ZZ_p_c, ZZ_pX_c, ZZ_pE_c +from sage.libs.ntl.types cimport ZZ_c, ZZ_p_c, ZZ_pX_c, ZZ_pE_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ZZ_pEX.pxd b/src/sage/libs/ntl/ZZ_pEX.pxd index 7e2dc5626cd..78be3ee13ea 100644 --- a/src/sage/libs/ntl/ZZ_pEX.pxd +++ b/src/sage/libs/ntl/ZZ_pEX.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport (ZZ_c, ZZ_p_c, ZZ_pContext_c, ZZ_pE_c, vec_ZZ_p_c, +from sage.libs.ntl.types cimport (ZZ_c, ZZ_p_c, ZZ_pContext_c, ZZ_pE_c, vec_ZZ_p_c, vec_ZZ_pE_c, ZZ_pEX_c, ZZ_pEX_Modulus_c) diff --git a/src/sage/libs/ntl/ZZ_pX.pxd b/src/sage/libs/ntl/ZZ_pX.pxd index a48e815d018..8c9f609f1cd 100644 --- a/src/sage/libs/ntl/ZZ_pX.pxd +++ b/src/sage/libs/ntl/ZZ_pX.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport (ZZ_c, ZZX_c, ZZ_p_c, vec_ZZ_p_c, ZZ_pContext_c, +from sage.libs.ntl.types cimport (ZZ_c, ZZX_c, ZZ_p_c, vec_ZZ_p_c, ZZ_pContext_c, ZZ_pX_c, ZZ_pX_Modulus_c, ZZ_pX_Multiplier_c) diff --git a/src/sage/libs/ntl/__init__.py b/src/sage/libs/ntl/__init__.py index 5cdc57e0122..0ab0a2c43e7 100644 --- a/src/sage/libs/ntl/__init__.py +++ b/src/sage/libs/ntl/__init__.py @@ -1,2 +1,3 @@ -from .error import setup_NTL_error_callback +from sage.libs.ntl.error import setup_NTL_error_callback + setup_NTL_error_callback() diff --git a/src/sage/libs/ntl/conversion.pxd b/src/sage/libs/ntl/conversion.pxd index 840e3947ea3..e46cc66284e 100644 --- a/src/sage/libs/ntl/conversion.pxd +++ b/src/sage/libs/ntl/conversion.pxd @@ -23,7 +23,7 @@ conventions for conversion functions # http://www.gnu.org/licenses/ #***************************************************************************** -from .types cimport mat_ZZ_p_c +from sage.libs.ntl.types cimport mat_ZZ_p_c from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class from sage.libs.ntl.ntl_ZZ_p cimport ntl_ZZ_p diff --git a/src/sage/libs/ntl/convert.pxd b/src/sage/libs/ntl/convert.pxd index 1a9532f0aba..58420abb94c 100644 --- a/src/sage/libs/ntl/convert.pxd +++ b/src/sage/libs/ntl/convert.pxd @@ -1,4 +1,4 @@ -from .types cimport ZZ_c +from sage.libs.ntl.types cimport ZZ_c from sage.libs.gmp.types cimport mpz_t, mpz_srcptr cdef void ZZ_to_mpz(mpz_t output, ZZ_c* x) noexcept diff --git a/src/sage/libs/ntl/error.pyx b/src/sage/libs/ntl/error.pyx index ac6cef82910..54443c13597 100644 --- a/src/sage/libs/ntl/error.pyx +++ b/src/sage/libs/ntl/error.pyx @@ -28,8 +28,8 @@ AUTHOR: #***************************************************************************** -from .ntl_tools cimport ErrorMsgCallback -from ...cpython.string cimport char_to_str +from sage.libs.ntl.ntl_tools cimport ErrorMsgCallback +from sage.cpython.string cimport char_to_str class NTLError(RuntimeError): diff --git a/src/sage/libs/ntl/lzz_p.pxd b/src/sage/libs/ntl/lzz_p.pxd index a7f8d5c52b6..14d81bc8ab0 100644 --- a/src/sage/libs/ntl/lzz_p.pxd +++ b/src/sage/libs/ntl/lzz_p.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport zz_p_c +from sage.libs.ntl.types cimport zz_p_c cdef extern from "ntlwrap.h": long zz_p_rep "rep"(zz_p_c x) diff --git a/src/sage/libs/ntl/lzz_pX.pxd b/src/sage/libs/ntl/lzz_pX.pxd index 65995a5c4d2..72905fd1d54 100644 --- a/src/sage/libs/ntl/lzz_pX.pxd +++ b/src/sage/libs/ntl/lzz_pX.pxd @@ -1,6 +1,6 @@ # distutils: depends = NTL/ZZ.h -from .types cimport ZZ_c, zz_p_c, zz_pX_c, zz_pX_Modulus_c +from sage.libs.ntl.types cimport ZZ_c, zz_p_c, zz_pX_c, zz_pX_Modulus_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/mat_GF2.pxd b/src/sage/libs/ntl/mat_GF2.pxd index 89c8252c046..db535d800fc 100644 --- a/src/sage/libs/ntl/mat_GF2.pxd +++ b/src/sage/libs/ntl/mat_GF2.pxd @@ -1,4 +1,4 @@ -from .types cimport mat_GF2_c, vec_GF2_c, GF2_c +from sage.libs.ntl.types cimport mat_GF2_c, vec_GF2_c, GF2_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/mat_GF2E.pxd b/src/sage/libs/ntl/mat_GF2E.pxd index 61250702247..e6c3b5fc622 100644 --- a/src/sage/libs/ntl/mat_GF2E.pxd +++ b/src/sage/libs/ntl/mat_GF2E.pxd @@ -1,4 +1,4 @@ -from .types cimport mat_GF2E_c, vec_GF2E_c, GF2E_c +from sage.libs.ntl.types cimport mat_GF2E_c, vec_GF2E_c, GF2E_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/mat_ZZ.pxd b/src/sage/libs/ntl/mat_ZZ.pxd index b40e51d53de..a676c90fb1b 100644 --- a/src/sage/libs/ntl/mat_ZZ.pxd +++ b/src/sage/libs/ntl/mat_ZZ.pxd @@ -1,4 +1,4 @@ -from .types cimport mat_ZZ_c, ZZ_c, ZZX_c +from sage.libs.ntl.types cimport mat_ZZ_c, ZZ_c, ZZX_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/ntl_GF2.pxd b/src/sage/libs/ntl/ntl_GF2.pxd index 0eff25dd32c..2be873c950c 100644 --- a/src/sage/libs/ntl/ntl_GF2.pxd +++ b/src/sage/libs/ntl/ntl_GF2.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2_c +from sage.libs.ntl.types cimport GF2_c cdef class ntl_GF2(): cdef GF2_c x diff --git a/src/sage/libs/ntl/ntl_GF2E.pxd b/src/sage/libs/ntl/ntl_GF2E.pxd index f634042e7cb..93539cf8abf 100644 --- a/src/sage/libs/ntl/ntl_GF2E.pxd +++ b/src/sage/libs/ntl/ntl_GF2E.pxd @@ -1,5 +1,5 @@ -from .types cimport GF2E_c -from .ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.types cimport GF2E_c +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class cdef class ntl_GF2E(): cdef GF2E_c x diff --git a/src/sage/libs/ntl/ntl_GF2E.pyx b/src/sage/libs/ntl/ntl_GF2E.pyx index 078a3e2e6f7..2e4fec38020 100644 --- a/src/sage/libs/ntl/ntl_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_GF2E.pyx @@ -27,11 +27,11 @@ include 'misc.pxi' include 'decl.pxi' from cpython.object cimport Py_EQ, Py_NE -from .ntl_ZZ cimport ntl_ZZ -from .ntl_GF2 cimport ntl_GF2 -from .ntl_GF2X cimport ntl_GF2X -from .ntl_GF2EContext cimport ntl_GF2EContext_class -from .ntl_GF2EContext import ntl_GF2EContext +from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ +from sage.libs.ntl.ntl_GF2 cimport ntl_GF2 +from sage.libs.ntl.ntl_GF2X cimport ntl_GF2X +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.ntl_GF2EContext import ntl_GF2EContext from sage.libs.ntl.ntl_ZZ import unpickle_class_args from sage.misc.randstate cimport current_randstate diff --git a/src/sage/libs/ntl/ntl_GF2EContext.pxd b/src/sage/libs/ntl/ntl_GF2EContext.pxd index df1f44f87aa..01fc4676e58 100644 --- a/src/sage/libs/ntl/ntl_GF2EContext.pxd +++ b/src/sage/libs/ntl/ntl_GF2EContext.pxd @@ -1,5 +1,5 @@ -from .types cimport GF2EContext_c -from .ntl_GF2X cimport ntl_GF2X +from sage.libs.ntl.types cimport GF2EContext_c +from sage.libs.ntl.ntl_GF2X cimport ntl_GF2X cdef class ntl_GF2EContext_class(): cdef GF2EContext_c x diff --git a/src/sage/libs/ntl/ntl_GF2EX.pxd b/src/sage/libs/ntl/ntl_GF2EX.pxd index e9a98a3afd6..38c96a7fe52 100644 --- a/src/sage/libs/ntl/ntl_GF2EX.pxd +++ b/src/sage/libs/ntl/ntl_GF2EX.pxd @@ -1,6 +1,6 @@ -from .types cimport GF2EX_c -from .ntl_GF2EContext cimport ntl_GF2EContext_class -from .ntl_GF2E cimport ntl_GF2E +from sage.libs.ntl.types cimport GF2EX_c +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.ntl_GF2E cimport ntl_GF2E cdef class ntl_GF2EX(): cdef GF2EX_c x diff --git a/src/sage/libs/ntl/ntl_GF2EX.pyx b/src/sage/libs/ntl/ntl_GF2EX.pyx index 72d18cedd4a..4e1c4324915 100644 --- a/src/sage/libs/ntl/ntl_GF2EX.pyx +++ b/src/sage/libs/ntl/ntl_GF2EX.pyx @@ -27,10 +27,10 @@ include 'misc.pxi' include 'decl.pxi' from cpython.object cimport Py_EQ, Py_NE -from .ntl_ZZ import unpickle_class_args -from .ntl_GF2EContext import ntl_GF2EContext -from .ntl_GF2EContext cimport ntl_GF2EContext_class -from .ntl_GF2E cimport ntl_GF2E +from sage.libs.ntl.ntl_ZZ import unpickle_class_args +from sage.libs.ntl.ntl_GF2EContext import ntl_GF2EContext +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.ntl_GF2E cimport ntl_GF2E ############################################################################## # diff --git a/src/sage/libs/ntl/ntl_GF2X.pxd b/src/sage/libs/ntl/ntl_GF2X.pxd index 5af874d0b9e..8d50c9d17d8 100644 --- a/src/sage/libs/ntl/ntl_GF2X.pxd +++ b/src/sage/libs/ntl/ntl_GF2X.pxd @@ -1,4 +1,4 @@ -from .types cimport GF2X_c +from sage.libs.ntl.types cimport GF2X_c cdef class ntl_GF2X(): cdef GF2X_c x diff --git a/src/sage/libs/ntl/ntl_GF2X.pyx b/src/sage/libs/ntl/ntl_GF2X.pyx index 787169e6dc7..f6781a68c7b 100644 --- a/src/sage/libs/ntl/ntl_GF2X.pyx +++ b/src/sage/libs/ntl/ntl_GF2X.pyx @@ -29,8 +29,8 @@ include 'decl.pxi' from cpython.object cimport Py_EQ, Py_NE from sage.rings.integer cimport Integer -from .ntl_ZZ import unpickle_class_value -from .ntl_GF2 cimport ntl_GF2 +from sage.libs.ntl.ntl_ZZ import unpickle_class_value +from sage.libs.ntl.ntl_GF2 cimport ntl_GF2 ############################################################################## diff --git a/src/sage/libs/ntl/ntl_ZZX.pxd b/src/sage/libs/ntl/ntl_ZZX.pxd index 5f6238f73f1..63e588c1d42 100644 --- a/src/sage/libs/ntl/ntl_ZZX.pxd +++ b/src/sage/libs/ntl/ntl_ZZX.pxd @@ -1,4 +1,4 @@ -from .types cimport ZZX_c +from sage.libs.ntl.types cimport ZZX_c cdef class ntl_ZZX(): cdef ZZX_c x diff --git a/src/sage/libs/ntl/ntl_ZZ_p.pxd b/src/sage/libs/ntl/ntl_ZZ_p.pxd index 08a0a3beb84..a92c9766112 100644 --- a/src/sage/libs/ntl/ntl_ZZ_p.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_p.pxd @@ -1,5 +1,5 @@ -from .types cimport ZZ_p_c -from .ntl_ZZ_pContext cimport ntl_ZZ_pContext_class +from sage.libs.ntl.types cimport ZZ_p_c +from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class cdef class ntl_ZZ_p(): cdef ZZ_p_c x diff --git a/src/sage/libs/ntl/ntl_ZZ_pContext.pxd b/src/sage/libs/ntl/ntl_ZZ_pContext.pxd index 61269d95584..d60cab91d55 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pContext.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pContext.pxd @@ -1,6 +1,6 @@ -from .types cimport ZZ_pContext_c -from .ntl_ZZ cimport ntl_ZZ -from .types cimport ZZ_c +from sage.libs.ntl.types cimport ZZ_pContext_c +from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ +from sage.libs.ntl.types cimport ZZ_c cdef class ntl_ZZ_pContext_class(): diff --git a/src/sage/libs/ntl/ntl_ZZ_pE.pxd b/src/sage/libs/ntl/ntl_ZZ_pE.pxd index cb9efd2279f..b2a1aa70293 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pE.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pE.pxd @@ -1,6 +1,6 @@ -from .types cimport ZZ_pE_c -from .ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class -from .ntl_ZZ_pX cimport ntl_ZZ_pX +from sage.libs.ntl.types cimport ZZ_pE_c +from sage.libs.ntl.ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class +from sage.libs.ntl.ntl_ZZ_pX cimport ntl_ZZ_pX cdef class ntl_ZZ_pE(): cdef ZZ_pE_c x diff --git a/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd b/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd index 027c59465a9..70041817a63 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pEContext.pxd @@ -1,7 +1,7 @@ -from .types cimport ZZ_pContext_c, ZZ_pEContext_c -from .ntl_ZZ_pContext cimport ntl_ZZ_pContext_class -from .ntl_ZZ_pX cimport ntl_ZZ_pX -from .types cimport ZZ_pX_Modulus_c +from sage.libs.ntl.types cimport ZZ_pContext_c, ZZ_pEContext_c +from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class +from sage.libs.ntl.ntl_ZZ_pX cimport ntl_ZZ_pX +from sage.libs.ntl.types cimport ZZ_pX_Modulus_c cdef struct ZZ_pEContext_ptrs: diff --git a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx index affd31d299d..03ff00f21d4 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx @@ -148,7 +148,7 @@ cdef class ntl_ZZ_pEContext_class(): sage: c.ZZ_pE([4,3]) [4 3] """ - from .ntl_ZZ_pE import ntl_ZZ_pE + from sage.libs.ntl.ntl_ZZ_pE import ntl_ZZ_pE return ntl_ZZ_pE(v,modulus=self) def ZZ_pEX(self, v = None): @@ -161,7 +161,7 @@ cdef class ntl_ZZ_pEContext_class(): sage: c.ZZ_pEX([4,3]) [[4] [3]] """ - from .ntl_ZZ_pEX import ntl_ZZ_pEX + from sage.libs.ntl.ntl_ZZ_pEX import ntl_ZZ_pEX return ntl_ZZ_pEX(v, modulus=self) cpdef void _assert_is_current_modulus(self) except *: diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX.pxd b/src/sage/libs/ntl/ntl_ZZ_pEX.pxd index de3e1e54fff..26ef2baf302 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pEX.pxd @@ -1,5 +1,5 @@ -from .types cimport ZZ_pEX_c -from .ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class +from sage.libs.ntl.types cimport ZZ_pEX_c +from sage.libs.ntl.ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class cdef class ntl_ZZ_pEX(): cdef ZZ_pEX_c x diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pxd b/src/sage/libs/ntl/ntl_ZZ_pX.pxd index e414fc5c272..38792bca2d1 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pxd +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pxd @@ -1,4 +1,4 @@ -from .ZZ_pX cimport * +from sage.libs.ntl.ZZ_pX cimport * from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class cdef class ntl_ZZ_pX(): diff --git a/src/sage/libs/ntl/ntl_lzz_p.pxd b/src/sage/libs/ntl/ntl_lzz_p.pxd index 6a1466b62d3..6b4a6b8d3f0 100644 --- a/src/sage/libs/ntl/ntl_lzz_p.pxd +++ b/src/sage/libs/ntl/ntl_lzz_p.pxd @@ -1,5 +1,5 @@ -from .lzz_p cimport * -from .ntl_lzz_pContext cimport ntl_zz_pContext_class +from sage.libs.ntl.lzz_p cimport * +from sage.libs.ntl.ntl_lzz_pContext cimport ntl_zz_pContext_class cdef class ntl_zz_p(): cdef zz_p_c x diff --git a/src/sage/libs/ntl/ntl_lzz_pContext.pxd b/src/sage/libs/ntl/ntl_lzz_pContext.pxd index cffc49f6b4c..3fd7452197d 100644 --- a/src/sage/libs/ntl/ntl_lzz_pContext.pxd +++ b/src/sage/libs/ntl/ntl_lzz_pContext.pxd @@ -1,4 +1,4 @@ -from .types cimport zz_pContext_c +from sage.libs.ntl.types cimport zz_pContext_c cdef class ntl_zz_pContext_class(): cdef zz_pContext_c x diff --git a/src/sage/libs/ntl/ntl_mat_GF2.pxd b/src/sage/libs/ntl/ntl_mat_GF2.pxd index 34176ca530e..4041f9f8f14 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2.pxd +++ b/src/sage/libs/ntl/ntl_mat_GF2.pxd @@ -1,5 +1,5 @@ -from .types cimport mat_GF2_c -from .ntl_GF2 cimport ntl_GF2 +from sage.libs.ntl.types cimport mat_GF2_c +from sage.libs.ntl.ntl_GF2 cimport ntl_GF2 cdef class ntl_mat_GF2(): cdef mat_GF2_c x diff --git a/src/sage/libs/ntl/ntl_mat_GF2.pyx b/src/sage/libs/ntl/ntl_mat_GF2.pyx index 4c7b19a066b..71d4f8b7491 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2.pyx @@ -40,7 +40,7 @@ include 'misc.pxi' include 'decl.pxi' from cpython.object cimport Py_EQ, Py_NE -from .ntl_GF2 cimport ntl_GF2 +from sage.libs.ntl.ntl_GF2 cimport ntl_GF2 from sage.rings.integer cimport Integer from sage.libs.ntl.ntl_ZZ import unpickle_class_args diff --git a/src/sage/libs/ntl/ntl_mat_GF2E.pxd b/src/sage/libs/ntl/ntl_mat_GF2E.pxd index c01392b81db..15415965c66 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2E.pxd +++ b/src/sage/libs/ntl/ntl_mat_GF2E.pxd @@ -1,6 +1,6 @@ -from .types cimport mat_GF2E_c -from .ntl_GF2EContext cimport ntl_GF2EContext_class -from .ntl_GF2E cimport ntl_GF2E +from sage.libs.ntl.types cimport mat_GF2E_c +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.ntl_GF2E cimport ntl_GF2E cdef class ntl_mat_GF2E(): cdef mat_GF2E_c x diff --git a/src/sage/libs/ntl/ntl_mat_GF2E.pyx b/src/sage/libs/ntl/ntl_mat_GF2E.pyx index 24f75c6c026..0588eaaa7a3 100644 --- a/src/sage/libs/ntl/ntl_mat_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_mat_GF2E.pyx @@ -37,9 +37,9 @@ include 'misc.pxi' include 'decl.pxi' from cpython.object cimport Py_EQ, Py_NE -from .ntl_GF2E cimport ntl_GF2E -from .ntl_GF2EContext import ntl_GF2EContext -from .ntl_GF2EContext cimport ntl_GF2EContext_class +from sage.libs.ntl.ntl_GF2E cimport ntl_GF2E +from sage.libs.ntl.ntl_GF2EContext import ntl_GF2EContext +from sage.libs.ntl.ntl_GF2EContext cimport ntl_GF2EContext_class from sage.rings.integer cimport Integer from sage.misc.randstate cimport randstate, current_randstate diff --git a/src/sage/libs/ntl/ntl_mat_ZZ.pxd b/src/sage/libs/ntl/ntl_mat_ZZ.pxd index f766e82c187..472ef698704 100644 --- a/src/sage/libs/ntl/ntl_mat_ZZ.pxd +++ b/src/sage/libs/ntl/ntl_mat_ZZ.pxd @@ -1,4 +1,4 @@ -from .types cimport mat_ZZ_c +from sage.libs.ntl.types cimport mat_ZZ_c cdef class ntl_mat_ZZ(): cdef mat_ZZ_c x diff --git a/src/sage/libs/ntl/ntl_mat_ZZ.pyx b/src/sage/libs/ntl/ntl_mat_ZZ.pyx index 8df56b2632e..349055dc182 100644 --- a/src/sage/libs/ntl/ntl_mat_ZZ.pyx +++ b/src/sage/libs/ntl/ntl_mat_ZZ.pyx @@ -30,7 +30,7 @@ from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ from sage.libs.ntl.ntl_ZZX cimport ntl_ZZX from cpython.object cimport PyObject_RichCompare -from .ntl_ZZ import unpickle_class_args +from sage.libs.ntl.ntl_ZZ import unpickle_class_args cdef inline ntl_ZZ make_ZZ(ZZ_c* x) noexcept: cdef ntl_ZZ y diff --git a/src/sage/libs/ntl/vec_GF2.pxd b/src/sage/libs/ntl/vec_GF2.pxd index fa606dc176a..81a3736b49f 100644 --- a/src/sage/libs/ntl/vec_GF2.pxd +++ b/src/sage/libs/ntl/vec_GF2.pxd @@ -1,4 +1,4 @@ -from .types cimport vec_GF2_c, GF2_c +from sage.libs.ntl.types cimport vec_GF2_c, GF2_c cdef extern from "ntlwrap.h": diff --git a/src/sage/libs/ntl/vec_GF2E.pxd b/src/sage/libs/ntl/vec_GF2E.pxd index 1cfdd7109fa..8e53bad0517 100644 --- a/src/sage/libs/ntl/vec_GF2E.pxd +++ b/src/sage/libs/ntl/vec_GF2E.pxd @@ -1 +1 @@ -from .types cimport vec_GF2E_c +from sage.libs.ntl.types cimport vec_GF2E_c From 13b52c59eafb741581c044ba463fe26f1703cd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 Oct 2023 08:08:07 +0100 Subject: [PATCH 354/494] Update permutation.py fixes in doc --- src/sage/combinat/permutation.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 1db51dfc4a6..dbedc22b294 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5387,9 +5387,9 @@ def nth_roots(self, n): r""" Return all n-th roots of ``self`` (as a generator). - An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation `\sigma` is a permutation `\gamma` such that `\gamma^n = \sigma`. - Note that the number of n-th roots only depend on the cycle type of ``self``. + Note that the number of n-th roots only depends on the cycle type of ``self``. EXAMPLES:: @@ -5497,17 +5497,17 @@ def rewind(L, n): if not b: return - #Product of Possibilities (i.e. final result) + # Product of Possibilities (i.e. final result) for L in product(*possibilities): yield P.prod(L) - def has_nth_root(self, n): + def has_nth_root(self, n) -> bool: r""" Decide if ``self`` has n-th roots. - An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation `\sigma` is a permutation `\gamma` such that `\gamma^n = \sigma`. - Note that the number of n-th roots only depend on the cycle type of ``self``. + Note that the number of n-th roots only depends on the cycle type of ``self``. EXAMPLES:: @@ -5566,9 +5566,9 @@ def number_of_nth_roots(self, n): r""" Return the number of n-th roots of ``self``. - An n-th root of the permutation ``self`` is a permutation `\gamma` such that `\gamma^n == self`. + An n-th root of the permutation `\sigma` is a permutation `\gamma` such that `\gamma^n = \sigma`. - Note that the number of n-th roots only depend on the cycle type of ``self``. + Note that the number of n-th roots only depends on the cycle type of ``self``. EXAMPLES:: From d9eeeaa7842f75c84e2544227972b513a9df9823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 Oct 2023 10:10:03 +0100 Subject: [PATCH 355/494] some changes by ruff UP --- src/sage/env.py | 4 ++-- src/sage/features/__init__.py | 2 +- src/sage/features/latex.py | 3 +-- src/sage/features/pkg_systems.py | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/sage/env.py b/src/sage/env.py index b1fe9a89cd1..4515e90e912 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -417,8 +417,8 @@ def cython_aliases(required_modules=None, elif lib == 'ecl': try: # Determine ecl-specific compiler arguments using the ecl-config script - ecl_cflags = subprocess.run([ECL_CONFIG, "--cflags"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split() - ecl_libs = subprocess.run([ECL_CONFIG, "--libs"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split() + ecl_cflags = subprocess.run([ECL_CONFIG, "--cflags"], check=True, capture_output=True, text=True).stdout.split() + ecl_libs = subprocess.run([ECL_CONFIG, "--libs"], check=True, capture_output=True, text=True).stdout.split() except subprocess.CalledProcessError: if required: raise diff --git a/src/sage/features/__init__.py b/src/sage/features/__init__.py index 89a7b184a4c..cabd63a1a24 100644 --- a/src/sage/features/__init__.py +++ b/src/sage/features/__init__.py @@ -572,7 +572,7 @@ def package_systems(): # Try to use scripts from SAGE_ROOT (or an installation of sage_bootstrap) # to obtain system package advice. try: - proc = run('sage-guess-package-system', shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=True) + proc = run('sage-guess-package-system', shell=True, capture_output=True, text=True, check=True) system_name = proc.stdout.strip() if system_name != 'unknown': _cache_package_systems = [PackageSystem(system_name)] diff --git a/src/sage/features/latex.py b/src/sage/features/latex.py index 48b4576961c..874c5ca7bfb 100644 --- a/src/sage/features/latex.py +++ b/src/sage/features/latex.py @@ -243,8 +243,7 @@ def absolute_filename(self) -> str: from subprocess import run, CalledProcessError, PIPE try: proc = run(['kpsewhich', self.filename], - stdout=PIPE, stderr=PIPE, - universal_newlines=True, check=True) + capture_output=True, text=True, check=True) return proc.stdout.strip() except CalledProcessError: reason = "{filename!r} not found by kpsewhich".format(filename=self.filename) diff --git a/src/sage/features/pkg_systems.py b/src/sage/features/pkg_systems.py index 8485fab0c7d..72ecd494344 100644 --- a/src/sage/features/pkg_systems.py +++ b/src/sage/features/pkg_systems.py @@ -73,11 +73,11 @@ def _spkg_installation_hint(self, spkgs, prompt, feature): system = self.name try: proc = run(f'sage-get-system-packages {system} {spkgs}', - shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=True) + shell=True, capture_output=True, text=True, check=True) system_packages = proc.stdout.strip() print_sys = f'sage-print-system-package-command {system} --verbose --sudo --prompt="{prompt}"' command = f'{print_sys} update && {print_sys} install {system_packages}' - proc = run(command, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=True) + proc = run(command, shell=True, capture_output=True, text=True, check=True) command = proc.stdout.strip() if command: lines.append(f'To install {feature} using the {system} package manager, you can try to run:') From 6e0db5b437e2c49607948d18c3cc46fd266dbd3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 Oct 2023 10:15:01 +0100 Subject: [PATCH 356/494] ruff fix UP027 (list comprehension) --- .../hecke_algebras/cubic_hecke_algebra.py | 4 +-- .../hecke_algebras/cubic_hecke_matrix_rep.py | 2 +- src/sage/calculus/calculus.py | 8 +++--- src/sage/combinat/designs/database.py | 6 ++-- src/sage/combinat/permutation.py | 2 +- .../hyperbolic_space/hyperbolic_geodesic.py | 28 +++++++++---------- .../hyperbolic_space/hyperbolic_isometry.py | 4 +-- src/sage/geometry/polyhedron/base5.py | 2 +- src/sage/geometry/polyhedron/plot.py | 2 +- src/sage/graphs/bipartite_graph.py | 2 +- .../graphs/generators/classical_geometries.py | 8 +++--- src/sage/graphs/generators/random.py | 2 +- src/sage/graphs/generators/smallgraphs.py | 6 ++-- src/sage/graphs/graph_generators.py | 2 +- src/sage/misc/package_dir.py | 2 +- src/sage/modular/local_comp/liftings.py | 4 +-- src/sage/modular/local_comp/local_comp.py | 4 +-- src/sage/plot/contour_plot.py | 6 ++-- src/sage/plot/density_plot.py | 2 +- src/sage/plot/plot3d/plot_field3d.py | 2 +- src/sage/quadratic_forms/binary_qf.py | 2 +- src/sage/quadratic_forms/ternary_qf.py | 2 +- src/sage/rings/number_field/number_field.py | 2 +- .../cyclic_covers/cycliccover_finite_field.py | 4 +-- .../schemes/elliptic_curves/constructor.py | 2 +- .../elliptic_curves/ell_curve_isogeny.py | 4 +-- src/sage/schemes/elliptic_curves/ell_point.py | 2 +- .../elliptic_curves/gal_reps_number_field.py | 2 +- src/sage/schemes/elliptic_curves/height.py | 2 +- .../schemes/elliptic_curves/period_lattice.py | 8 +++--- .../riemann_surfaces/riemann_surface.py | 2 +- src/sage/topology/simplicial_set_examples.py | 2 +- 32 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py b/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py index 29d444e745f..fdc94b13907 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py @@ -1467,7 +1467,7 @@ def _an_element_(self): """ n = self.ngens() + 1 base_ring = self.base_ring() - u, v, w = [base_ring(para) for para in self._cubic_equation_parameters] + u, v, w = (base_ring(para) for para in self._cubic_equation_parameters) const = (u*~w - v) * self.one() gens = self.gens() @@ -1521,7 +1521,7 @@ def chevie(self): from sage.interfaces.gap3 import gap3 gap3_function = gap3(gap3_function_str) - na, nb, nc = ['\"%s\"' % indet for indet in self.extension_ring(generic=True).variable_names()] + na, nb, nc = ('\"%s\"' % indet for indet in self.extension_ring(generic=True).variable_names()) return gap3_function(st_number, na, nb, nc) @cached_method diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py b/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py index ef8ba7316c9..1e8cd3ae0c4 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py @@ -890,7 +890,7 @@ def invert_gen(matr): """ cfs = ch_algebra.cubic_equation(as_coefficients=True, generic=True) fac = - 1 / cfs[0] - cf0, cf1, cf2, cf3 = [original_base_ring(cf * fac) for cf in cfs] + cf0, cf1, cf2, cf3 = (original_base_ring(cf * fac) for cf in cfs) matri = cf1 * matr.parent().one() matri += cf2 * matr diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py index 37807450ac0..dfaafb4353f 100644 --- a/src/sage/calculus/calculus.py +++ b/src/sage/calculus/calculus.py @@ -663,7 +663,7 @@ def symbolic_sum(expression, v, a, b, algorithm='maxima', hold=False): return result.sage() elif algorithm == 'sympy': - expression,v,a,b = [expr._sympy_() for expr in (expression, v, a, b)] + expression,v,a,b = (expr._sympy_() for expr in (expression, v, a, b)) from sympy import summation from sage.interfaces.sympy import sympy_init sympy_init() @@ -920,7 +920,7 @@ def symbolic_product(expression, v, a, b, algorithm='maxima', hold=False): return result.sage() elif algorithm == 'sympy': - expression,v,a,b = [expr._sympy_() for expr in (expression, v, a, b)] + expression,v,a,b = (expr._sympy_() for expr in (expression, v, a, b)) from sympy import product as sproduct from sage.interfaces.sympy import sympy_init sympy_init() @@ -1744,7 +1744,7 @@ def laplace(ex, t, s, algorithm='maxima'): return ex.parent()(ex._maxima_().laplace(var(t), var(s))) elif algorithm == 'sympy': - ex_sy, t, s = [expr._sympy_() for expr in (ex, t, s)] + ex_sy, t, s = (expr._sympy_() for expr in (ex, t, s)) from sympy import laplace_transform from sage.interfaces.sympy import sympy_init sympy_init() @@ -1923,7 +1923,7 @@ def inverse_laplace(ex, s, t, algorithm='maxima'): return ex.parent()(ex._maxima_().ilt(var(s), var(t))) elif algorithm == 'sympy': - ex_sy, s, t = [expr._sympy_() for expr in (ex, s, t)] + ex_sy, s, t = (expr._sympy_() for expr in (ex, s, t)) from sympy import inverse_laplace_transform from sage.interfaces.sympy import sympy_init sympy_init() diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index 5cf09904130..98b8f0e598e 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -2127,7 +2127,7 @@ def QDM_21_5_1_1_1(): [0,14,7,0,None]] for R in zip(*M): - a,b,c,d,e = [G(x) if x is not None else None for x in R] + a,b,c,d,e = (G(x) if x is not None else None for x in R) Mb.append([a,b,c,d,e]) Mb.append([16*c, @@ -2265,7 +2265,7 @@ def QDM_33_6_1_1_1(): times4 = lambda x : None if x is None else 4*x for R in zip(*M): - a,b,c,d,e,f = [None if x is None else G(x) for x in R] + a,b,c,d,e,f = (None if x is None else G(x) for x in R) for i in range(5): Mb.append([a,b,c,d,e,f]) a,b,c,d,e,f = map(times4,[e,a,b,c,d,f]) @@ -3467,7 +3467,7 @@ def DM_39_6_1(): for i in range(3): Mb.append([ a, b, c, d, e, f]) Mb.append([-a,-b,-c,-d,-e,-f]) - a,b,c,d,e,f = [16*x for x in [c,a,b,f,d,e]] + a,b,c,d,e,f = (16*x for x in [c,a,b,f,d,e]) return G,Mb diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index eb3e451b0ff..856b04c6654 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -470,7 +470,7 @@ def __classcall_private__(cls, l, check=True): return RSK_inverse(*l, output='permutation') elif isinstance(l, (tuple, list)) and len(l) == 2 and \ all(isinstance(x, list) for x in l): - P,Q = [Tableau(_) for _ in l] + P,Q = (Tableau(_) for _ in l) return RSK_inverse(P, Q, 'permutation') # if it's a tuple or nonempty list of tuples, also assume cycle # notation diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py index 9f6d5725f68..57354fad4d9 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py @@ -1110,7 +1110,7 @@ def reflection_involution(self): """ - x, y = [real(k.coordinates()) for k in self.ideal_endpoints()] + x, y = (real(k.coordinates()) for k in self.ideal_endpoints()) if x == infinity: M = matrix([[1, -2*y], [0, -1]]) elif y == infinity: @@ -1188,8 +1188,8 @@ def plot(self, boundary=True, **options): opts = {'axes': False, 'aspect_ratio': 1} opts.update(self.graphics_options()) opts.update(options) - end_1, end_2 = [CC(k.coordinates()) for k in self.endpoints()] - bd_1, bd_2 = [CC(k.coordinates()) for k in self.ideal_endpoints()] + end_1, end_2 = (CC(k.coordinates()) for k in self.endpoints()) + bd_1, bd_2 = (CC(k.coordinates()) for k in self.ideal_endpoints()) if (abs(real(end_1) - real(end_2)) < EPSILON) \ or CC(infinity) in [end_1, end_2]: # on same vertical line # If one of the endpoints is infinity, we replace it with a @@ -1224,7 +1224,7 @@ def plot(self, boundary=True, **options): # computations below compute the projection of the # geodesic to the real line, and then draw a little # to the left and right of the projection. - shadow_1, shadow_2 = [real(k) for k in [end_1, end_2]] + shadow_1, shadow_2 = (real(k) for k in [end_1, end_2]) midpoint = (shadow_1 + shadow_2)/2 length = abs(shadow_1 - shadow_2) bd_dict = {'bd_min': midpoint - length, 'bd_max': midpoint + @@ -1479,8 +1479,8 @@ def intersection(self, other): # Get endpoints and ideal endpoints i_start_1, i_end_1 = sorted(self.ideal_endpoints(), key=str) i_start_2, i_end_2 = sorted(other.ideal_endpoints(), key=str) - start_1, end_1 = [CC(x.coordinates()) for x in self.endpoints()] - start_2, end_2 = [CC(x.coordinates()) for x in other.endpoints()] + start_1, end_1 = (CC(x.coordinates()) for x in self.endpoints()) + start_2, end_2 = (CC(x.coordinates()) for x in other.endpoints()) # sort the geodesic endpoints according to start_1.real() < end_1.real() and if start_1.real() == end_1.real() # then start_1.imag() < end_1.imag() if start_1.real() > end_1.real(): # enforce @@ -1934,8 +1934,8 @@ def angle(self, other): # UHP if abs(a2 - a1) < EPSILON or abs(b2 - b1) < EPSILON: raise ValueError("intersecting geodesic is a point") - p1, p2 = [p.coordinates() for p in self.ideal_endpoints()] - q1, q2 = [p.coordinates() for p in other.ideal_endpoints()] + p1, p2 = (p.coordinates() for p in self.ideal_endpoints()) + q1, q2 = (p.coordinates() for p in other.ideal_endpoints()) # Check if both geodesics are lines. All lines intersect at # ``Infinity``, but the angle is always zero. @@ -1979,7 +1979,7 @@ def angle(self, other): # UHP # Transform into a line. t = HyperbolicGeodesicUHP._crossratio_matrix(p1, (p1 + p2) / 2, p2) - q1, q2 = [moebius_transform(t, q) for q in [q1, q2]] + q1, q2 = (moebius_transform(t, q) for q in [q1, q2]) # Calculate the angle. return arccos(abs(q1 + q2) / abs(q2 - q1)) @@ -2246,8 +2246,8 @@ def plot(self, boundary=True, **options): opts = {'axes': False, 'aspect_ratio': 1} opts.update(self.graphics_options()) opts.update(options) - end_1, end_2 = [CC(k.coordinates()) for k in self.endpoints()] - bd_1, bd_2 = [CC(k.coordinates()) for k in self.ideal_endpoints()] + end_1, end_2 = (CC(k.coordinates()) for k in self.endpoints()) + bd_1, bd_2 = (CC(k.coordinates()) for k in self.ideal_endpoints()) # Check to see if it's a line if abs(bd_1 + bd_2) < EPSILON: pic = bezier_path([[(real(end_1), imag(end_1)), (real(end_2), imag(end_2))]], **opts) @@ -2330,7 +2330,7 @@ def map_pt(pt): if pt in CC: return CC(pt) return CC(*pt) - end_1, end_2 = [map_pt(k.coordinates()) for k in self.endpoints()] + end_1, end_2 = (map_pt(k.coordinates()) for k in self.endpoints()) pic = bezier_path([[(real(end_1), imag(end_1)), (real(end_2), imag(end_2))]], **opts) if boundary: @@ -2392,7 +2392,7 @@ def _plot_vertices(self, points=75): from sage.arith.srange import xsrange x = SR.var('x') - v1, u2 = [vector(k.coordinates()) for k in self.endpoints()] + v1, u2 = (vector(k.coordinates()) for k in self.endpoints()) # Lorentzian Gram Shmidt. The original vectors will be # u1, u2 and the orthogonal ones will be v1, v2. Except # v1 = u1, and I don't want to declare another variable, @@ -2436,7 +2436,7 @@ def plot(self, show_hyperboloid=True, **graphics_options): x = SR.var('x') opts = self.graphics_options() opts.update(graphics_options) - v1, u2 = [vector(k.coordinates()) for k in self.endpoints()] + v1, u2 = (vector(k.coordinates()) for k in self.endpoints()) # Lorentzian Gram Shmidt. The original vectors will be # u1, u2 and the orthogonal ones will be v1, v2. Except # v1 = u1, and I don't want to declare another variable, diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py index 2de12812ddc..08d68b2c518 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py @@ -820,10 +820,10 @@ def fixed_point_set(self): # UHP return self.domain().get_geodesic(pt(p_1), pt(p_2)) try: - p, q = [M.eigenvectors_right()[k][1][0] for k in range(2)] + p, q = (M.eigenvectors_right()[k][1][0] for k in range(2)) except IndexError: M = M.change_ring(RDF) - p, q = [M.eigenvectors_right()[k][1][0] for k in range(2)] + p, q = (M.eigenvectors_right()[k][1][0] for k in range(2)) pts = [] if p[1] == 0: diff --git a/src/sage/geometry/polyhedron/base5.py b/src/sage/geometry/polyhedron/base5.py index 89feb2d7b0f..72cb9f349ca 100644 --- a/src/sage/geometry/polyhedron/base5.py +++ b/src/sage/geometry/polyhedron/base5.py @@ -483,7 +483,7 @@ def _test_bipyramid(self, tester=None, **options): R = self.base_ring() a = (R(1),) + tuple(self.center()) b = (R(-1),) + tuple(self.center()) - c, d = [tuple(v) for v in cert] + c, d = (tuple(v) for v in cert) tester.assertEqual(sorted([a, b]), sorted([c, d])) def prism(self): diff --git a/src/sage/geometry/polyhedron/plot.py b/src/sage/geometry/polyhedron/plot.py index 03628f60e22..5c2362cfdda 100644 --- a/src/sage/geometry/polyhedron/plot.py +++ b/src/sage/geometry/polyhedron/plot.py @@ -852,7 +852,7 @@ def defining_equation(): # corresponding to a polygon face_inequalities.append(facet_equation) vertices = cyclic_sort_vertices_2d(vertices) if len(vertices) >= 3: - v0, v1, v2 = [vector(v) for v in vertices[:3]] + v0, v1, v2 = (vector(v) for v in vertices[:3]) normal = (v2 - v0).cross_product(v1 - v0) if normal.dot_product(facet_equation.A()) < 0: vertices.reverse() diff --git a/src/sage/graphs/bipartite_graph.py b/src/sage/graphs/bipartite_graph.py index 8cc866616ce..0a03affa422 100644 --- a/src/sage/graphs/bipartite_graph.py +++ b/src/sage/graphs/bipartite_graph.py @@ -1755,7 +1755,7 @@ def load_afile(self, fname): return None # read header information - num_cols, num_rows = [int(_) for _ in fi.readline().split()] + num_cols, num_rows = (int(_) for _ in fi.readline().split()) # next are max_col_degree, max_row_degree, not used _ = [int(_) for _ in fi.readline().split()] col_degrees = [int(_) for _ in fi.readline().split()] diff --git a/src/sage/graphs/generators/classical_geometries.py b/src/sage/graphs/generators/classical_geometries.py index 1bfe55f0f54..e27f7e11b6d 100644 --- a/src/sage/graphs/generators/classical_geometries.py +++ b/src/sage/graphs/generators/classical_geometries.py @@ -535,12 +535,12 @@ def NonisotropicOrthogonalPolarGraph(m, q, sign="+", perp=None): deg = (q**n - e)*(q**(n - 1) + e) # k S = [libgap.Elements(libgap.Basis(x))[0] for x in libgap.Elements(libgap.Subspaces(W, 1))] - (V,) = [x for x in libgap.Orbits(g, S, libgap.OnLines) - if len(x) == nvert] + (V,) = (x for x in libgap.Orbits(g, S, libgap.OnLines) + if len(x) == nvert) gp = libgap.Action(g, V, libgap.OnLines) # make a permutation group h = libgap.Stabilizer(gp, 1) - (Vh,) = [x for x in libgap.Orbits(h, libgap.Orbit(gp, 1)) - if len(x) == deg] + (Vh,) = (x for x in libgap.Orbits(h, libgap.Orbit(gp, 1)) + if len(x) == deg) Vh = Vh[0] L = libgap.Orbit(gp, [1, Vh], libgap.OnSets) G = Graph() diff --git a/src/sage/graphs/generators/random.py b/src/sage/graphs/generators/random.py index d253633621c..22c1f583f6a 100644 --- a/src/sage/graphs/generators/random.py +++ b/src/sage/graphs/generators/random.py @@ -1957,7 +1957,7 @@ def rotate_word_to_next_occurrence(word): word2 = rotate_word_to_next_occurrence(word) if len(word2) >= 5: word = [word2[0]] + word2[4:] - in1, in2, in3 = [u[1] for u in word2[:3]] + in1, in2, in3 = (u[1] for u in word2[:3]) edges.append([in1, in3]) # edge 'in1,in3' idx = embedding[in1].index(in2) embedding[in1].insert(idx, in3) diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index a4f3e1c05ef..3b47f29f2ff 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -201,7 +201,7 @@ def HarriesGraph(embedding=1): # Vertices from o[1]. These are actually the "edges" of the copies of # Petersen. for v in o[1]: - p1, p2 = [gpos[x] for x in g.neighbors(v) if x in o[0]] + p1, p2 = (gpos[x] for x in g.neighbors(v) if x in o[0]) gpos[v] = ((p1[0] + p2[0])/2, (p1[1] + p2[1])/2) # 15 vertices from o[2] @@ -4816,8 +4816,8 @@ def JankoKharaghaniGraph(v): D = ("--1-11", "-11-1-", "11-1--", "--11-1", "11---1", "1--11-") E = ("-1--11", "1-1--1", "-11-1-", "---111", "1-11--", "11-1--") F = ("-1-1-1", "11--1-", "--111-", "1-11--", "-11--1", "1---11") - B, C, D, E, F = [matrix([map({'1': 1, '-': -1}.get, r) for r in m]) - for m in [B, C, D, E, F]] + B, C, D, E, F = (matrix([map({'1': 1, '-': -1}.get, r) for r in m]) + for m in [B, C, D, E, F]) H = [A, B, C, D, E, F] H = [[-x for x in H[6-i:]] + H[:6-i] for i in range(6)] diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py index b029a9609b2..7e2a2341a46 100644 --- a/src/sage/graphs/graph_generators.py +++ b/src/sage/graphs/graph_generators.py @@ -1171,7 +1171,7 @@ def nauty_genbg(self, options="", debug=False): for s in msg.split(' '): if s.startswith('n='): from sage.rings.integer import Integer - n1, n2 = [Integer(t) for t in s[2:].split('+') if t.isdigit()] + n1, n2 = (Integer(t) for t in s[2:].split('+') if t.isdigit()) partition = [set(range(n1)), set(range(n1, n1 + n2))] break else: diff --git a/src/sage/misc/package_dir.py b/src/sage/misc/package_dir.py index 218949ca11e..9f075b16c31 100644 --- a/src/sage/misc/package_dir.py +++ b/src/sage/misc/package_dir.py @@ -124,7 +124,7 @@ def read_distribution(src_file): line = line[1:].lstrip() kind = "sage_setup:" if line.startswith(kind): - key, _, value = [s.strip() for s in line[len(kind):].partition('=')] + key, _, value = (s.strip() for s in line[len(kind):].partition('=')) if key == "distribution": return value return '' diff --git a/src/sage/modular/local_comp/liftings.py b/src/sage/modular/local_comp/liftings.py index dbe80b59b14..dcb901cc3a1 100644 --- a/src/sage/modular/local_comp/liftings.py +++ b/src/sage/modular/local_comp/liftings.py @@ -64,13 +64,13 @@ def lift_to_gamma1(g, m, n): """ if m == 1: return [ZZ.one(), ZZ.zero(), ZZ.zero(), ZZ.one()] - a, b, c, d = [ZZ(x) for x in g] + a, b, c, d = (ZZ(x) for x in g) det = (a * d - b * c) % m if det != 1: raise ValueError("Determinant is {0} mod {1}, should be 1".format(det, m)) c2 = crt(c, 0, m, n) d2 = crt(d, 1, m, n) - a3,b3,c3,d3 = [ZZ(_) for _ in lift_to_sl2z(c2, d2, m * n)] + a3,b3,c3,d3 = (ZZ(_) for _ in lift_to_sl2z(c2, d2, m * n)) r = (a3*b - b3*a) % m return [a3 + r * c3, b3 + r * d3, c3, d3] diff --git a/src/sage/modular/local_comp/local_comp.py b/src/sage/modular/local_comp/local_comp.py index 765ce805ed9..e8b54a1570f 100644 --- a/src/sage/modular/local_comp/local_comp.py +++ b/src/sage/modular/local_comp/local_comp.py @@ -747,7 +747,7 @@ def characters(self): if len(gs) == 1: # This is always the case if p != 2 - chi1, chi2 = [G.extend_character(n, self.central_character(), [x]) for x in gvals] + chi1, chi2 = (G.extend_character(n, self.central_character(), [x]) for x in gvals) else: # 2-adic cases, conductor >= 64. Here life is complicated # because the quotient (O_K* / p^n)^* / (image of Z_2^*) is not @@ -871,7 +871,7 @@ def characters(self): c1q, c2q = flatten([[x]*e for x,e in theta_poly.roots(G.base_ring())]) if len(qs) == 1: - chi1, chi2 = [G.extend_character(n, self.central_character(), [x]) for x in [c1q, c2q]] + chi1, chi2 = (G.extend_character(n, self.central_character(), [x]) for x in [c1q, c2q]) else: assert p == 3 diff --git a/src/sage/plot/contour_plot.py b/src/sage/plot/contour_plot.py index 9c70ebd3e49..fd175d5eceb 100644 --- a/src/sage/plot/contour_plot.py +++ b/src/sage/plot/contour_plot.py @@ -891,7 +891,7 @@ def f(x,y): return cos(x) + sin(y) F, ranges = setup_for_eval_on_grid(ev, [xrange, yrange], options['plot_points']) h = F[0] - xrange, yrange = [r[:2] for r in ranges] + xrange, yrange = (r[:2] for r in ranges) xy_data_array = [[h(x, y) for x in xsrange(*ranges[0], include_endpoint=True)] @@ -1000,7 +1000,7 @@ def f(x,y): return cos(x) + sin(y) F, ranges = setup_for_eval_on_grid(ev, [xrange, yrange], options['plot_points']) h = F[0] - xrange, yrange = [r[:2] for r in ranges] + xrange, yrange = (r[:2] for r in ranges) # ...and a function whose values are shifted towards # z0 by "tol". @@ -1690,7 +1690,7 @@ def region_plot(f, xrange, yrange, **options): f_all, ranges = setup_for_eval_on_grid(feqs + f, [xrange, yrange], plot_points) - xrange, yrange = [r[:2] for r in ranges] + xrange, yrange = (r[:2] for r in ranges) xy_data_arrays = numpy.asarray([[[func(x, y) for x in xsrange(*ranges[0], diff --git a/src/sage/plot/density_plot.py b/src/sage/plot/density_plot.py index 8d6123ff226..e2ffbb6d453 100644 --- a/src/sage/plot/density_plot.py +++ b/src/sage/plot/density_plot.py @@ -307,7 +307,7 @@ def f(x,y): return x**2 * cos(x*y) from sage.rings.real_double import RDF g, ranges = setup_for_eval_on_grid([f], [xrange, yrange], options['plot_points']) g = g[0] - xrange, yrange = [r[:2] for r in ranges] + xrange, yrange = (r[:2] for r in ranges) xy_data_array = [[RDF(g(x,y)) for x in xsrange(*ranges[0], include_endpoint=True)] for y in xsrange(*ranges[1], include_endpoint=True)] diff --git a/src/sage/plot/plot3d/plot_field3d.py b/src/sage/plot/plot3d/plot_field3d.py index d93d95cba57..a2c04f137a3 100644 --- a/src/sage/plot/plot3d/plot_field3d.py +++ b/src/sage/plot/plot3d/plot_field3d.py @@ -129,7 +129,7 @@ def plot_vector_field3d(functions, xrange, yrange, zrange, Graphics3d Object """ (ff, gg, hh), ranges = setup_for_eval_on_grid(functions, [xrange, yrange, zrange], plot_points) - xpoints, ypoints, zpoints = [srange(*r, include_endpoint=True) for r in ranges] + xpoints, ypoints, zpoints = (srange(*r, include_endpoint=True) for r in ranges) points = [vector((i, j, k)) for i in xpoints for j in ypoints for k in zpoints] vectors = [vector((ff(*point), gg(*point), hh(*point))) for point in points] diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py index 6516888e3ac..0f32bba92ba 100755 --- a/src/sage/quadratic_forms/binary_qf.py +++ b/src/sage/quadratic_forms/binary_qf.py @@ -144,7 +144,7 @@ def __init__(self, a, b=None, c=None): elif (isinstance(a, MPolynomial) and a.is_homogeneous() and a.base_ring() == ZZ 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]] + 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', 't_QFB'): # a has 3 or 4 components a, b, c = a[0], a[1], a[2] diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py index 4184c839528..fa4499566a9 100644 --- a/src/sage/quadratic_forms/ternary_qf.py +++ b/src/sage/quadratic_forms/ternary_qf.py @@ -97,7 +97,7 @@ def __init__(self, v): if len(v) != 6: # Check we have six coefficients raise ValueError("Ternary quadratic form must be given by a list of six coefficients") - self._a, self._b, self._c, self._r, self._s, self._t = [ZZ(x) for x in v] + self._a, self._b, self._c, self._r, self._s, self._t = (ZZ(x) for x in v) self._automorphisms = None self._number_of_automorphisms = None diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 7ffeeca710b..a1fdf8cbc4a 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -12055,7 +12055,7 @@ def __init__(self, polynomial, name=None, latex_name=None, check=True, embedding self._standard_embedding = True # set the generator and element class - c, b, a = [QQ(t) for t in self.defining_polynomial().list()] + c, b, a = (QQ(t) for t in self.defining_polynomial().list()) Dpoly = b*b - 4*a*c D = (Dpoly.numer() * Dpoly.denom()).squarefree_part(bound=10000) self._D = D diff --git a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py index 82583c14cfc..82504873715 100644 --- a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py +++ b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py @@ -733,8 +733,8 @@ def _initialize_fat_horizontal(self, s, L): targets[2 * l] = self._p * l targets[2 * l + 1] = self._p * (l + 1) - d - 1 (m0, m1), (M0, M1) = self._horizontal_matrix_reduction(s) - M0, M1 = [elt.change_ring(self._Zq0) for elt in [M0, M1]] - D0, D1 = [matrix(self._Zq0, [elt]) for elt in [m0, m1]] + M0, M1 = (elt.change_ring(self._Zq0) for elt in [M0, M1]) + D0, D1 = (matrix(self._Zq0, [elt]) for elt in [m0, m1]) MH = interval_products(M0, M1, targets) DH = [elt[0, 0] for elt in interval_products(D0, D1, targets)] if L > N: # Vandermonde interpolation diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index e7a1767cecb..f6f7828cb8e 100644 --- a/src/sage/schemes/elliptic_curves/constructor.py +++ b/src/sage/schemes/elliptic_curves/constructor.py @@ -1132,7 +1132,7 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): if flex_point is not None: # first case: base point is a flex P = flex_point L = tangent_at_smooth_point(C,P) - dx, dy, dz = [L.coefficient(v) for v in R.gens()] + dx, dy, dz = (L.coefficient(v) for v in R.gens()) # find an invertible matrix M such that (0,1,0)M=P and # ML'=(0,0,1)' where L=[dx,dy,dx]. Then the linear transform diff --git a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py index cccfce646b3..75d10d147d6 100644 --- a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py +++ b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py @@ -1745,7 +1745,7 @@ def __set_pre_isomorphism(self, domain, isomorphism): # calculate the isomorphism as a rational map. - u, r, s, t = [self.__base_field(c) for c in isomorphism.tuple()] + u, r, s, t = (self.__base_field(c) for c in isomorphism.tuple()) uinv = 1/u uinv2 = uinv**2 uinv3 = uinv*uinv2 @@ -1787,7 +1787,7 @@ def __set_post_isomorphism(self, codomain, isomorphism): # calculate the isomorphism as a rational map. - u, r, s, t = [self.__base_field(c) for c in isomorphism.tuple()] + u, r, s, t = (self.__base_field(c) for c in isomorphism.tuple()) uinv = 1/u uinv2 = uinv**2 uinv3 = uinv*uinv2 diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 24908b9743e..1e760dcfd6c 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -3035,7 +3035,7 @@ def archimedean_local_height(self, v=None, prec=None, weighted=False): # (with infinite precision) and then trim back to RR or CC. x = RC(v_inf(self[0])) - b2, b4, b6, b8 = [RC(v_inf(b)) for b in E.b_invariants()] + b2, b4, b6, b8 = (RC(v_inf(b)) for b in E.b_invariants()) # The following comes from Silverman Theorem 4.2. Silverman # uses decimal precision d, so his term (5/3)d = 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 8861f643198..48f742a6cd0 100644 --- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py +++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py @@ -877,7 +877,7 @@ def _semistable_reducible_primes(E, verbose=False): last_p = p Px, Py = precomp - x, y = [PP.gens_reduced()[0] for PP in precomp] + x, y = (PP.gens_reduced()[0] for PP in precomp) EmodPx = E.reduction(Px) if d > 1 else E.reduction(x) EmodPy = E.reduction(Py) if d > 1 else E.reduction(y) fxpol = EmodPx.frobenius_polynomial() diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index 64d025a6481..30709dccf96 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -928,7 +928,7 @@ def alpha(self, v, tol=0.01): 0.347263296676126 """ from sage.rings.polynomial.polynomial_ring import polygen - b2, b4, b6, b8 = [v(b) for b in self.E.b_invariants()] + b2, b4, b6, b8 = (v(b) for b in self.E.b_invariants()) x = polygen(v.codomain()) f = 4*x**3 + b2*x**2 + 2*b4*x + b6 g = x**4 - b4*x**2 - 2*b6*x - b8 diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py index a4cd489a34c..c12e3f12cbc 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice.py +++ b/src/sage/schemes/elliptic_curves/period_lattice.py @@ -1427,7 +1427,7 @@ def e_log_RC(self, xP, yP, prec=None, reduce=True): R = RealField(prec2) C = ComplexField(prec2) e1,e2,e3 = self._ei - a1,a2,a3 = [self.embedding(a) for a in self.E.ainvs()[:3]] + a1,a2,a3 = (self.embedding(a) for a in self.E.ainvs()[:3]) wP = 2*yP+a1*xP+a3 @@ -1716,7 +1716,7 @@ def elliptic_logarithm(self, P, prec=None, reduce=True): # Compute the real or complex coordinates of P: - xP, yP = [self.embedding(coord) for coord in P.xy()] + xP, yP = (self.embedding(coord) for coord in P.xy()) # The real work is done over R or C now: @@ -1915,7 +1915,7 @@ def elliptic_exponential(self, z, to_curve=True): # the same precision as the input. x, y = pari(self.basis(prec=prec)).ellwp(z, flag=1) - x, y = [C(t) for t in (x, y)] + x, y = (C(t) for t in (x, y)) if self.real_flag and z_is_real: x = x.real() @@ -1924,7 +1924,7 @@ def elliptic_exponential(self, z, to_curve=True): if to_curve: K = x.parent() v = refine_embedding(self.embedding, Infinity) - a1, a2, a3, a4, a6 = [K(v(a)) for a in self.E.ainvs()] + a1, a2, a3, a4, a6 = (K(v(a)) for a in self.E.ainvs()) b2 = K(v(self.E.b2())) x = x - b2 / 12 y = (y - (a1 * x + a3)) / 2 diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py index 3166cbf11e3..b7e3f1ac8f6 100644 --- a/src/sage/schemes/riemann_surfaces/riemann_surface.py +++ b/src/sage/schemes/riemann_surfaces/riemann_surface.py @@ -282,7 +282,7 @@ def numerical_inverse(C): with mpall.workprec(prec): Cmp = mpall.matrix([mpall.sage_to_mpmath(list(c), prec) for c in C]) PLU = mpall.lu(Cmp) - P, L, U = [R([mpall.mpmath_to_sage(c, prec) for c in M]) for M in PLU] + P, L, U = (R([mpall.mpmath_to_sage(c, prec) for c in M]) for M in PLU) return U.inverse() * L.inverse() * P diff --git a/src/sage/topology/simplicial_set_examples.py b/src/sage/topology/simplicial_set_examples.py index 2bb46ac1f5a..1fc85df3f6e 100644 --- a/src/sage/topology/simplicial_set_examples.py +++ b/src/sage/topology/simplicial_set_examples.py @@ -684,7 +684,7 @@ def simplicial_data_from_kenzo_output(filename): for s in [_.strip() for _ in simplex_string.split('Simplex : ')]: if s: - name, face_str = [_.strip() for _ in s.split('Faces : ')] + name, face_str = (_.strip() for _ in s.split('Faces : ')) face_str = face_str.strip('()') face_str = face_str.split(' Date: Tue, 31 Oct 2023 10:10:28 +0100 Subject: [PATCH 357/494] write Weyl with a capital letter --- src/sage/categories/affine_weyl_groups.py | 19 +++++++++--- src/sage/categories/category.py | 6 ++-- .../categories/examples/finite_weyl_groups.py | 9 +++--- src/sage/categories/finite_weyl_groups.py | 11 +++---- src/sage/categories/weyl_groups.py | 29 +++++++++++++------ .../combinat/root_system/coxeter_group.py | 2 +- src/sage/combinat/root_system/weyl_group.py | 2 +- src/sage/groups/perm_gps/permgroup_named.py | 2 +- src/sage/misc/c3_controlled.pyx | 4 +-- 9 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/sage/categories/affine_weyl_groups.py b/src/sage/categories/affine_weyl_groups.py index 4eeea88b6c3..7ae931201a9 100644 --- a/src/sage/categories/affine_weyl_groups.py +++ b/src/sage/categories/affine_weyl_groups.py @@ -28,16 +28,16 @@ class AffineWeylGroups(Category_singleton): EXAMPLES:: sage: C = AffineWeylGroups(); C - Category of affine weyl groups + Category of affine Weyl groups sage: C.super_categories() - [Category of infinite weyl groups] + [Category of infinite Weyl groups] sage: C.example() NotImplemented sage: W = WeylGroup(["A", 4, 1]); W # needs sage.combinat sage.groups Weyl Group of type ['A', 4, 1] (as a matrix group acting on the root space) sage: W.category() # needs sage.combinat sage.groups - Category of irreducible affine weyl groups + Category of irreducible affine Weyl groups TESTS:: @@ -49,7 +49,7 @@ def super_categories(self): EXAMPLES:: sage: AffineWeylGroups().super_categories() - [Category of infinite weyl groups] + [Category of infinite Weyl groups] """ return [WeylGroups().Infinite()] @@ -71,6 +71,17 @@ def additional_structure(self): """ return None + def _repr_object_names(self): + """ + Return the name of the objects of this category. + + EXAMPLES:: + + sage: AffineWeylGroups() + Category of affine Weyl groups + """ + return "affine Weyl groups" + class ParentMethods: @cached_method diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py index fcf25b75fd4..b200f1a7283 100644 --- a/src/sage/categories/category.py +++ b/src/sage/categories/category.py @@ -42,7 +42,7 @@ sage: G.category() # needs sage.groups Join of Category of finite enumerated permutation groups and - Category of finite weyl groups and + Category of finite Weyl groups and Category of well generated finite irreducible complex reflection groups sage: P = PerfectMatchings(3) # needs sage.combinat @@ -2596,13 +2596,13 @@ def category_sample(): Category of G-sets for Symmetric group of order 8! as a permutation group, Category of Hecke modules over Rational Field, Category of Lie algebras over Rational Field, + Category of Weyl groups, Category of additive magmas, ..., Category of fields, ..., Category of graded hopf algebras with basis over Rational Field, ..., Category of modular abelian varieties over Rational Field, ..., Category of simplicial complexes, ..., - Category of vector spaces over Rational Field, ..., - Category of weyl groups, ... + Category of vector spaces over Rational Field, ... """ import sage.categories.all abstract_classes_for_categories = [Category] diff --git a/src/sage/categories/examples/finite_weyl_groups.py b/src/sage/categories/examples/finite_weyl_groups.py index a8b27cd7ffe..5c87f26c3e3 100644 --- a/src/sage/categories/examples/finite_weyl_groups.py +++ b/src/sage/categories/examples/finite_weyl_groups.py @@ -1,12 +1,12 @@ r""" Examples of finite Weyl groups """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2008-2009 Nicolas M. Thiery # # Distributed under the terms of the GNU General Public License (GPL) -# http://www.gnu.org/licenses/ -#****************************************************************************** +# https://www.gnu.org/licenses/ +# ***************************************************************************** from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent @@ -14,6 +14,7 @@ from sage.categories.finite_weyl_groups import FiniteWeylGroups from sage.structure.unique_representation import UniqueRepresentation + class SymmetricGroup(UniqueRepresentation, Parent): r""" An example of finite Weyl group: the symmetric group, with @@ -30,7 +31,7 @@ class SymmetricGroup(UniqueRepresentation, Parent): sage: S The symmetric group on {0, ..., 3} sage: S.category() - Category of finite irreducible weyl groups + Category of finite irreducible Weyl groups The elements of this group are permutations of the set `\{0,\ldots,3\}`:: diff --git a/src/sage/categories/finite_weyl_groups.py b/src/sage/categories/finite_weyl_groups.py index 4210e2f9feb..8e0346eb5ab 100644 --- a/src/sage/categories/finite_weyl_groups.py +++ b/src/sage/categories/finite_weyl_groups.py @@ -1,15 +1,16 @@ r""" Finite Weyl Groups """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2009 Nicolas M. Thiery # # Distributed under the terms of the GNU General Public License (GPL) -# http://www.gnu.org/licenses/ -#****************************************************************************** +# https://www.gnu.org/licenses/ +# ***************************************************************************** from sage.categories.category_with_axiom import CategoryWithAxiom + class FiniteWeylGroups(CategoryWithAxiom): """ The category of finite Weyl groups. @@ -18,9 +19,9 @@ class FiniteWeylGroups(CategoryWithAxiom): sage: C = FiniteWeylGroups() sage: C - Category of finite weyl groups + Category of finite Weyl groups sage: C.super_categories() - [Category of finite Coxeter groups, Category of weyl groups] + [Category of finite Coxeter groups, Category of Weyl groups] sage: C.example() The symmetric group on {0, ..., 3} diff --git a/src/sage/categories/weyl_groups.py b/src/sage/categories/weyl_groups.py index 88879d2b478..79db1d40001 100644 --- a/src/sage/categories/weyl_groups.py +++ b/src/sage/categories/weyl_groups.py @@ -24,7 +24,7 @@ class WeylGroups(Category_singleton): EXAMPLES:: sage: WeylGroups() - Category of weyl groups + Category of Weyl groups sage: WeylGroups().super_categories() [Category of Coxeter groups] @@ -74,6 +74,17 @@ def additional_structure(self): """ return None + def _repr_object_names(self): + """ + Return the name of the objects of this category. + + EXAMPLES:: + + sage: WeylGroups().Finite() + Category of finite Weyl groups + """ + return "Weyl groups" + Finite = LazyImport('sage.categories.finite_weyl_groups', 'FiniteWeylGroups') class ParentMethods: @@ -276,13 +287,13 @@ def quantum_bruhat_graph(self, index_set=()): NPR = lattice.nonparabolic_positive_roots(index_set) NPR_sum = sum(NPR) NPR_data = {} - double_rho = lattice.sum(lattice.positive_roots()) # = 2 * \rho + double_rho = lattice.sum(lattice.positive_roots()) # = 2 * \rho for alpha in NPR: ref = alpha.associated_reflection() alphacheck = alpha.associated_coroot() - NPR_data[alpha] = [self.from_reduced_word(ref), # the element - len(ref) == double_rho.scalar(alphacheck) - 1, # is_quantum - NPR_sum.scalar(alphacheck)] # the scalar + NPR_data[alpha] = [self.from_reduced_word(ref), # the element + len(ref) == double_rho.scalar(alphacheck) - 1, # is_quantum + NPR_sum.scalar(alphacheck)] # the scalar # We also create a temporary cache of lengths as they are # relatively expensive to compute and needed frequently visited = {} @@ -493,14 +504,14 @@ def stanley_symmetric_function_as_polynomial(self, max_length=None): W = self.parent() pieri_factors = W.pieri_factors() from sage.rings.rational_field import QQ - R = QQ[','.join('x%s' % l for l in range(1, pieri_factors.max_length()+1))] + R = QQ[','.join('x%s' % l for l in range(1, pieri_factors.max_length() + 1))] x = R.gens() if self.is_one(): return R.one() - return R(sum(2**(pieri_factors.stanley_symm_poly_weight(u))*x[u.length()-1] * v.stanley_symmetric_function_as_polynomial(max_length=u.length()) - for (u, v) in self.left_pieri_factorizations(max_length) - if u != W.one())) + return R(sum(2**(pieri_factors.stanley_symm_poly_weight(u)) * x[u.length() - 1] * v.stanley_symmetric_function_as_polynomial(max_length=u.length()) + for (u, v) in self.left_pieri_factorizations(max_length) + if u != W.one())) def stanley_symmetric_function(self): r""" diff --git a/src/sage/combinat/root_system/coxeter_group.py b/src/sage/combinat/root_system/coxeter_group.py index f33003b35f6..83c1c0c7e9e 100644 --- a/src/sage/combinat/root_system/coxeter_group.py +++ b/src/sage/combinat/root_system/coxeter_group.py @@ -73,7 +73,7 @@ def CoxeterGroup(data, implementation="reflection", base_ring=None, index_set=No Permutation Group with generators [(1,4)(2,3)(5,6), (1,3)(2,5)(4,6)] sage: W.category() # optional - gap3 Join of Category of finite enumerated permutation groups - and Category of finite weyl groups + and Category of finite Weyl groups and Category of well generated finite irreducible complex reflection groups sage: W = CoxeterGroup(["A",2], implementation="matrix"); W # needs sage.libs.gap diff --git a/src/sage/combinat/root_system/weyl_group.py b/src/sage/combinat/root_system/weyl_group.py index c2e9b8dc59d..58711f85653 100644 --- a/src/sage/combinat/root_system/weyl_group.py +++ b/src/sage/combinat/root_system/weyl_group.py @@ -583,7 +583,7 @@ class ClassicalWeylSubgroup(WeylGroup_gens): sage: G Parabolic Subgroup of the Weyl Group of type ['A', 3, 1] (as a matrix group acting on the root space) sage: G.category() - Category of finite irreducible weyl groups + Category of finite irreducible Weyl groups sage: G.cardinality() 24 sage: G.index_set() diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index 5052880e99e..f34ee9fcd21 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -236,7 +236,7 @@ class SymmetricGroup(PermutationGroup_symalt): {1, 2, 3, 4} sage: G.category() Join of Category of finite enumerated permutation groups and - Category of finite weyl groups and + Category of finite Weyl groups and Category of well generated finite irreducible complex reflection groups TESTS:: diff --git a/src/sage/misc/c3_controlled.pyx b/src/sage/misc/c3_controlled.pyx index 6e34f0a4ba8..54602cdf1a9 100644 --- a/src/sage/misc/c3_controlled.pyx +++ b/src/sage/misc/c3_controlled.pyx @@ -343,12 +343,12 @@ doctest:: sage: sorted([C for C in category_sample() # needs sage.combinat sage.graphs sage.modules sage.rings.number_field ....: if len(C._super_categories_for_classes) != len(C.super_categories())], ....: key=str) - [Category of affine weyl groups, + [Category of affine Weyl groups, Category of fields, Category of finite dimensional algebras with basis over Rational Field, Category of finite dimensional hopf algebras with basis over Rational Field, Category of finite enumerated permutation groups, - Category of finite weyl groups, + Category of finite Weyl groups, Category of number fields] AUTHOR: From 388fad103bbcdf20f902dc564e775d55e8daff1c Mon Sep 17 00:00:00 2001 From: dcoudert Date: Tue, 31 Oct 2023 11:58:31 +0100 Subject: [PATCH 358/494] avoid using itertools.pairwise --- src/sage/graphs/generic_graph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index a99aa1d5a64..75bae68cf7f 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -5211,7 +5211,6 @@ def cycle_basis(self, output='vertex'): []) from sage.graphs.graph import Graph - from itertools import pairwise T = Graph(self.min_spanning_tree(), multiedges=True, format='list_of_edges') H = self.copy() H.delete_edges(T.edge_iterator()) @@ -5235,7 +5234,8 @@ def cycle_basis(self, output='vertex'): cycle = Q + P[-2::-1] if output == 'edge': - cycle = [e] + [(x, y, T.edge_label(x, y)[0]) for x, y in pairwise(cycle)] + cycle = [e] + [(x, y, T.edge_label(x, y)[0]) + for x, y in zip(cycle[:-1], cycle[1:])] L.append(cycle) return L From 3cb7058819e0e326efe3f16bfab21fe62e493d3a Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 31 Oct 2023 13:49:05 +0000 Subject: [PATCH 359/494] fix the links to msolve spkg --- src/sage/rings/polynomial/msolve.py | 2 +- src/sage/rings/polynomial/multi_polynomial_ideal.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/polynomial/msolve.py b/src/sage/rings/polynomial/msolve.py index 70af8250f58..378177a02d2 100644 --- a/src/sage/rings/polynomial/msolve.py +++ b/src/sage/rings/polynomial/msolve.py @@ -8,7 +8,7 @@ This module provide implementations of some operations on polynomial ideals based on msolve. -Note that the `optional package msolve <../spkg/msolve.html>`_ must be installed. +Note that the `optional package msolve <../../../spkg/msolve.html>`_ must be installed. .. SEEALSO:: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 66dd4a6db3d..893506ef220 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -2585,7 +2585,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True {y: 0.3611030805286474?, x: 2.769292354238632?}, {y: 1, x: 1}] - We can also use the `optional package msolve <../spkg/msolve.html>`_ + We can also use the `optional package msolve <../../../spkg/msolve.html>`_ to compute the variety. See :mod:`~sage.rings.polynomial.msolve` for more information. :: @@ -2667,7 +2667,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True on a toy implementation otherwise. - With ``algorithm`` = ``"msolve"``, uses the - `optional package msolve <../spkg/msolve.html>`_. + `optional package msolve <../../../spkg/msolve.html>`_. Note that msolve uses heuristics and therefore requires setting the ``proof`` flag to ``False``. See :mod:`~sage.rings.polynomial.msolve` for more information. @@ -4275,7 +4275,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available) ``'msolve'`` - `optional package msolve <../spkg/msolve.html>`_ (degrevlex order) + `optional package msolve <../../../spkg/msolve.html>`_ (degrevlex order) ``'magma:GroebnerBasis'`` Magma's ``Groebnerbasis`` command (if available) @@ -4403,7 +4403,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal b*c - 19*c^2 + 10*b + 40*c, a + 2*b + 2*c - 1] Over prime fields of small characteristic, we can also use the - `optional package msolve <../spkg/msolve.html>`_:: + `optional package msolve <../../../spkg/msolve.html>`_:: sage: R. = PolynomialRing(GF(101), 3) sage: I = sage.rings.ideal.Katsura(R,3) # regenerate to prevent caching From 10c7b18ff5e38bcaa9d4a107e0c41c5022afe622 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 10:13:49 -0700 Subject: [PATCH 360/494] .github/workflows/dist.yml: Fix deprecation message 'The inputs have been normalized to use kebab-case' --- .github/workflows/dist.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index fb2229ba7b4..5bf5729039c 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -99,7 +99,7 @@ jobs: with: user: __token__ password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} - skip_existing: true + skip-existing: true verbose: true if: env.CAN_DEPLOY == 'true' @@ -180,7 +180,7 @@ jobs: with: user: __token__ password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} - packages_dir: wheelhouse/ - skip_existing: true + packages-dir: wheelhouse/ + skip-existing: true verbose: true if: env.CAN_DEPLOY == 'true' From c0a33aff42e337d85037def609938a002f04855f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 10:27:19 -0700 Subject: [PATCH 361/494] .github/workflows/doc-build-pdf.yml: Do not build HTML documentation --- .github/workflows/doc-build-pdf.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index 2128277fbca..7549c2934e7 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -66,8 +66,6 @@ jobs: git config --global user.email "ci-sage@example.com" git config --global user.name "Build & Test workflow" .ci/retrofit-worktree.sh worktree-image /sage - # Keep track of changes to built HTML - new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") - name: Download upstream artifact uses: actions/download-artifact@v3 @@ -107,7 +105,7 @@ jobs: id: docbuild if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success') run: | - make doc-clean doc-uninstall; make doc-pdf + make doc-clean doc-uninstall; make sagemath_doc_html-build-deps sagemath_doc_pdf-no-deps working-directory: ./worktree-image env: MAKE: make -j2 --output-sync=recurse From ada9c3479a2523d9888dc34605b9ccd456475ef7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 11:16:04 -0700 Subject: [PATCH 362/494] .github/workflows/ci-linux.yml (standard-pre): Increase max_parallel to 50 --- .github/workflows/ci-linux.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 22df4aa0fd5..cbb4f0dd4ce 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -83,6 +83,9 @@ jobs: tox_packages_factors: >- ["standard"] docker_push_repository: ghcr.io/${{ github.repository }}/ + # Make sure that all "standard-pre" jobs can start simultaneously, + # so that runners are available by the time that "default" starts. + max_parallel: 50 standard: if: ${{ success() || failure() }} From f3f44165be03bcbc2ba70f98bd404b0d6892bcab Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 11:50:32 -0700 Subject: [PATCH 363/494] sage.manifolds: Use more block '# needs' --- .../differentiable/tangent_vector.py | 2 +- src/sage/manifolds/point.py | 9 ++-- src/sage/manifolds/subsets/pullback.py | 47 ++++++++++--------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/sage/manifolds/differentiable/tangent_vector.py b/src/sage/manifolds/differentiable/tangent_vector.py index 640178b1f64..97abcea54e1 100644 --- a/src/sage/manifolds/differentiable/tangent_vector.py +++ b/src/sage/manifolds/differentiable/tangent_vector.py @@ -433,7 +433,7 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, manifold S^2 sage: graph_v = v.plot(mapping=F) # needs sage.plot sage: graph_S2 = XS.plot(chart=X3, mapping=F, number_values=9) # long time, needs sage.plot - sage: graph_v + graph_S2 # long time + sage: graph_v + graph_S2 # long time, needs sage.plot Graphics3d Object .. PLOT:: diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py index c2f030f6f45..ff0009db15b 100644 --- a/src/sage/manifolds/point.py +++ b/src/sage/manifolds/point.py @@ -900,18 +900,19 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, An example of plot via a mapping: plot of a point on a 2-sphere viewed in the 3-dimensional space ``M``:: + sage: # needs sage.plot sage: S2 = Manifold(2, 'S^2', structure='topological') sage: U = S2.open_subset('U') # the open set covered by spherical coord. sage: XS. = U.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi') sage: p = U.point((pi/4, pi/8), name='p') - sage: F = S2.continuous_map(M, {(XS, X): [sin(th)*cos(ph), # needs sage.plot + sage: F = S2.continuous_map(M, {(XS, X): [sin(th)*cos(ph), ....: sin(th)*sin(ph), cos(th)]}, name='F') sage: F.display() F: S^2 → M on U: (th, ph) ↦ (x, y, z) = (cos(ph)*sin(th), sin(ph)*sin(th), cos(th)) - sage: g = p.plot(chart=X, mapping=F) # needs sage.plot - sage: gS2 = XS.plot(chart=X, mapping=F, number_values=9) # needs sage.plot - sage: g + gS2 # needs sage.plot + sage: g = p.plot(chart=X, mapping=F) + sage: gS2 = XS.plot(chart=X, mapping=F, number_values=9) + sage: g + gS2 Graphics3d Object Use of the option ``ambient_coords`` for plots on a 4-dimensional diff --git a/src/sage/manifolds/subsets/pullback.py b/src/sage/manifolds/subsets/pullback.py index aaa394e48a3..452b6a2e008 100644 --- a/src/sage/manifolds/subsets/pullback.py +++ b/src/sage/manifolds/subsets/pullback.py @@ -144,14 +144,15 @@ def __classcall_private__(cls, map, codomain_subset, inverse=None, TESTS:: + sage: # needs sage.geometry.polyhedron sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^2 - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # needs sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: S = ManifoldSubsetPullback(c_cart, P); S # needs sage.geometry.polyhedron + sage: S = ManifoldSubsetPullback(c_cart, P); S Subset x_y_inv_P of the 2-dimensional topological manifold R^2 - sage: S is ManifoldSubsetPullback(c_cart, P) # needs sage.geometry.polyhedron + sage: S is ManifoldSubsetPullback(c_cart, P) True """ @@ -605,16 +606,17 @@ def _an_element_(self): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = McCube.an_element(); p # needs sage.geometry.polyhedron + sage: p = McCube.an_element(); p Point on the 3-dimensional topological manifold R^3 - sage: p.coordinates(c_cart) # needs sage.geometry.polyhedron + sage: p.coordinates(c_cart) (0, 0, 0) sage: # needs sage.geometry.polyhedron @@ -638,21 +640,22 @@ def some_elements(self): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube Subset McCube of the 3-dimensional topological manifold R^3 - sage: L = list(McCube.some_elements()); L # needs sage.geometry.polyhedron + sage: L = list(McCube.some_elements()); L [Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3, Point on the 3-dimensional topological manifold R^3] - sage: list(p.coordinates(c_cart) for p in L) # needs sage.geometry.polyhedron + sage: list(p.coordinates(c_cart) for p in L) [(0, 0, 0), (1, -1, -1), (1, 0, -1), @@ -685,12 +688,13 @@ def __contains__(self, point): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: from sage.manifolds.subsets.pullback import ManifoldSubsetPullback sage: M = Manifold(3, 'R^3', structure='topological') sage: c_cart. = M.chart() # Cartesian coordinates on R^3 - sage: Cube = polytopes.cube(); Cube # needs sage.geometry.polyhedron + sage: Cube = polytopes.cube(); Cube A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: Cube.vertices_list() # needs sage.geometry.polyhedron + sage: Cube.vertices_list() [[1, -1, -1], [1, 1, -1], [1, 1, 1], @@ -699,15 +703,15 @@ def __contains__(self, point): [-1, -1, -1], [-1, 1, -1], [-1, 1, 1]] - sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube # needs sage.geometry.polyhedron + sage: McCube = ManifoldSubsetPullback(c_cart, Cube, name='McCube'); McCube Subset McCube of the 3-dimensional topological manifold R^3 - sage: p = M.point((0, 0, 0)); p # needs sage.geometry.polyhedron + sage: p = M.point((0, 0, 0)); p Point on the 3-dimensional topological manifold R^3 - sage: p in McCube # needs sage.geometry.polyhedron + sage: p in McCube True - sage: q = M.point((2, 3, 4)); q # needs sage.geometry.polyhedron + sage: q = M.point((2, 3, 4)); q Point on the 3-dimensional topological manifold R^3 - sage: q in McCube # needs sage.geometry.polyhedron + sage: q in McCube False """ if super().__contains__(point): @@ -772,11 +776,12 @@ def is_closed(self): The pullback of a (closed convex) polyhedron under a chart is closed:: - sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P # needs sage.geometry.polyhedron + sage: # needs sage.geometry.polyhedron + sage: P = Polyhedron(vertices=[[0, 0], [1, 2], [3, 4]]); P A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices - sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP # needs sage.geometry.polyhedron + sage: McP = ManifoldSubsetPullback(c_cart, P, name='McP'); McP Subset McP of the 2-dimensional topological manifold R^2 - sage: McP.is_closed() # needs sage.geometry.polyhedron + sage: McP.is_closed() True The pullback of real vector subspaces under a chart is closed:: From d4b9c9d26aecfef1ede47111dcf7407e73f4c1c2 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 31 Oct 2023 19:15:57 +0000 Subject: [PATCH 364/494] just remove ../../ things --- src/sage/rings/polynomial/msolve.py | 2 +- src/sage/rings/polynomial/multi_polynomial_ideal.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/polynomial/msolve.py b/src/sage/rings/polynomial/msolve.py index 378177a02d2..7d9a8a7c9b9 100644 --- a/src/sage/rings/polynomial/msolve.py +++ b/src/sage/rings/polynomial/msolve.py @@ -8,7 +8,7 @@ This module provide implementations of some operations on polynomial ideals based on msolve. -Note that the `optional package msolve <../../../spkg/msolve.html>`_ must be installed. +Note that the `optional package msolve `_ must be installed. .. SEEALSO:: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 893506ef220..7c5749044ee 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -2585,7 +2585,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True {y: 0.3611030805286474?, x: 2.769292354238632?}, {y: 1, x: 1}] - We can also use the `optional package msolve <../../../spkg/msolve.html>`_ + We can also use the `optional package msolve `_ to compute the variety. See :mod:`~sage.rings.polynomial.msolve` for more information. :: @@ -2667,7 +2667,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True on a toy implementation otherwise. - With ``algorithm`` = ``"msolve"``, uses the - `optional package msolve <../../../spkg/msolve.html>`_. + `optional package msolve `_. Note that msolve uses heuristics and therefore requires setting the ``proof`` flag to ``False``. See :mod:`~sage.rings.polynomial.msolve` for more information. @@ -4275,7 +4275,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available) ``'msolve'`` - `optional package msolve <../../../spkg/msolve.html>`_ (degrevlex order) + `optional package msolve `_ (degrevlex order) ``'magma:GroebnerBasis'`` Magma's ``Groebnerbasis`` command (if available) @@ -4403,7 +4403,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal b*c - 19*c^2 + 10*b + 40*c, a + 2*b + 2*c - 1] Over prime fields of small characteristic, we can also use the - `optional package msolve <../../../spkg/msolve.html>`_:: + `optional package msolve `_:: sage: R. = PolynomialRing(GF(101), 3) sage: I = sage.rings.ideal.Katsura(R,3) # regenerate to prevent caching From 2b107b2318b053b95e34c61fdcfe39288f0d2f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 Oct 2023 21:19:22 +0100 Subject: [PATCH 365/494] fix doctest --- src/sage/misc/c3_controlled.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/misc/c3_controlled.pyx b/src/sage/misc/c3_controlled.pyx index 54602cdf1a9..4a4c51cbfe7 100644 --- a/src/sage/misc/c3_controlled.pyx +++ b/src/sage/misc/c3_controlled.pyx @@ -345,10 +345,10 @@ doctest:: ....: key=str) [Category of affine Weyl groups, Category of fields, + Category of finite Weyl groups, Category of finite dimensional algebras with basis over Rational Field, Category of finite dimensional hopf algebras with basis over Rational Field, Category of finite enumerated permutation groups, - Category of finite Weyl groups, Category of number fields] AUTHOR: From 7350ac39658777277532bbedac9eb0c61358e22f Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 31 Oct 2023 20:53:59 +0000 Subject: [PATCH 366/494] try more ../ --- src/sage/rings/polynomial/msolve.py | 2 +- src/sage/rings/polynomial/multi_polynomial_ideal.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/polynomial/msolve.py b/src/sage/rings/polynomial/msolve.py index 7d9a8a7c9b9..1905d0a8a57 100644 --- a/src/sage/rings/polynomial/msolve.py +++ b/src/sage/rings/polynomial/msolve.py @@ -8,7 +8,7 @@ This module provide implementations of some operations on polynomial ideals based on msolve. -Note that the `optional package msolve `_ must be installed. +Note that the `optional package msolve <../../../../spkg/msolve.html>`_ must be installed. .. SEEALSO:: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 7c5749044ee..a752af29e75 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -2585,7 +2585,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True {y: 0.3611030805286474?, x: 2.769292354238632?}, {y: 1, x: 1}] - We can also use the `optional package msolve `_ + We can also use the `optional package msolve <../../../../spkg/msolve.html>`_ to compute the variety. See :mod:`~sage.rings.polynomial.msolve` for more information. :: @@ -2667,7 +2667,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True on a toy implementation otherwise. - With ``algorithm`` = ``"msolve"``, uses the - `optional package msolve `_. + `optional package msolve <../../../../spkg/msolve.html>`_. Note that msolve uses heuristics and therefore requires setting the ``proof`` flag to ``False``. See :mod:`~sage.rings.polynomial.msolve` for more information. @@ -4275,7 +4275,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available) ``'msolve'`` - `optional package msolve `_ (degrevlex order) + `optional package msolve <../../../../spkg/msolve.html>`_ (degrevlex order) ``'magma:GroebnerBasis'`` Magma's ``Groebnerbasis`` command (if available) @@ -4403,7 +4403,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal b*c - 19*c^2 + 10*b + 40*c, a + 2*b + 2*c - 1] Over prime fields of small characteristic, we can also use the - `optional package msolve `_:: + `optional package msolve <../../../../spkg/msolve.html>`_:: sage: R. = PolynomialRing(GF(101), 3) sage: I = sage.rings.ideal.Katsura(R,3) # regenerate to prevent caching From dc932ce184664ea2375a62d34b4cce88d04a62a2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 6 Aug 2023 20:45:11 -0700 Subject: [PATCH 367/494] src/sage/modular: Update file-level doctest tag --- src/sage/modular/modsym/p1list_nf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py index 69986c1b8c8..25c68137e0c 100644 --- a/src/sage/modular/modsym/p1list_nf.py +++ b/src/sage/modular/modsym/p1list_nf.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Lists of Manin symbols over number fields, elements of `\mathbb{P}^1(R/N)` From 5c8b34ae71044d10fad13a35dfba4c70709fa751 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:19 -0700 Subject: [PATCH 368/494] src/sage/modular: sage -fixdoctests --only-tags --- src/sage/modular/abvar/lseries.py | 14 +- .../modular/arithgroup/arithgroup_element.pyx | 4 +- src/sage/modular/arithgroup/farey_symbol.pyx | 10 +- src/sage/modular/btquotients/btquotient.py | 4 +- src/sage/modular/dirichlet.py | 8 +- src/sage/modular/modform/element.py | 2 +- .../modform_hecketriangle/analytic_type.py | 12 +- .../modform_hecketriangle/constructor.py | 24 ++-- .../modular/modform_hecketriangle/element.py | 15 ++- .../graded_ring_element.py | 127 +++++++++--------- src/sage/modular/overconvergent/genus0.py | 2 +- src/sage/modular/quasimodform/element.py | 2 +- 12 files changed, 115 insertions(+), 109 deletions(-) diff --git a/src/sage/modular/abvar/lseries.py b/src/sage/modular/abvar/lseries.py index 84823684f03..76387ce34e4 100644 --- a/src/sage/modular/abvar/lseries.py +++ b/src/sage/modular/abvar/lseries.py @@ -99,29 +99,29 @@ def __call__(self, s, prec=53): EXAMPLES:: sage: L = J0(23).lseries() - sage: L(1) + sage: L(1) # needs sage.symbolic 0.248431866590600 - sage: L(1, prec=100) + sage: L(1, prec=100) # needs sage.symbolic 0.24843186659059968120725033931 sage: L = J0(389)[0].lseries() - sage: L(1) # long time (2s) abstol 1e-10 + sage: L(1) # abstol 1e-10 # long time (2s), needs sage.symbolic -1.33139759782370e-19 - sage: L(1, prec=100) # long time (2s) abstol 1e-20 + sage: L(1, prec=100) # abstol 1e-20 # long time (2s), needs sage.symbolic 6.0129758648142797032650287762e-39 sage: L.rational_part() 0 sage: L = J1(23)[0].lseries() - sage: L(1) + sage: L(1) # needs sage.symbolic 0.248431866590600 sage: J = J0(11) * J1(11) - sage: J.lseries()(1) + sage: J.lseries()(1) # needs sage.symbolic 0.0644356903227915 sage: L = JH(17,[2]).lseries() - sage: L(1) + sage: L(1) # needs sage.symbolic 0.386769938387780 """ diff --git a/src/sage/modular/arithgroup/arithgroup_element.pyx b/src/sage/modular/arithgroup/arithgroup_element.pyx index 41b268ea4ef..4addcde2852 100644 --- a/src/sage/modular/arithgroup/arithgroup_element.pyx +++ b/src/sage/modular/arithgroup/arithgroup_element.pyx @@ -334,8 +334,8 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): An example of g acting on a symbolic variable:: - sage: z = var('z') - sage: g.acton(z) + sage: z = var('z') # needs sage.symbolic + sage: g.acton(z) # needs sage.symbolic (z + 2)/(15*z + 31) An example involving the Gaussian numbers:: diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index cd80cb32f3e..99f9e6920b4 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -932,7 +932,7 @@ cdef class Farey: For example, to plot the fundamental domain of `\Gamma_0(11)` with pairings use the following command:: - sage: FareySymbol(Gamma0(11)).fundamental_domain() + sage: FareySymbol(Gamma0(11)).fundamental_domain() # needs sage.plot sage.symbolic Graphics object consisting of 54 graphics primitives indicating that side 1 is paired with side 3 and side 2 is @@ -941,18 +941,20 @@ cdef class Farey: To plot the fundamental domain of `\Gamma(3)` without pairings use the following command:: - sage: FareySymbol(Gamma(3)).fundamental_domain(show_pairing=False) + sage: FareySymbol(Gamma(3)).fundamental_domain(show_pairing=False) # needs sage.plot sage.symbolic Graphics object consisting of 48 graphics primitives Plot the fundamental domain of `\Gamma_0(23)` showing the left coset representatives:: - sage: FareySymbol(Gamma0(23)).fundamental_domain(tesselation='coset') + sage: FareySymbol(Gamma0(23)).fundamental_domain(tesselation='coset') # needs sage.plot sage.symbolic Graphics object consisting of 58 graphics primitives The same as above but with a custom linestyle:: - sage: FareySymbol(Gamma0(23)).fundamental_domain(tesselation='coset', linestyle=':', thickness='2') + sage: FareySymbol(Gamma0(23)).fundamental_domain(tesselation='coset', # needs sage.plot sage.symbolic + ....: linestyle=':', + ....: thickness='2') Graphics object consisting of 58 graphics primitives """ from sage.plot.all import Graphics diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 1bf60ecbefb..3be90544708 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -2127,7 +2127,7 @@ def plot(self, *args, **kwargs): EXAMPLES:: sage: X = BruhatTitsQuotient(7,23) - sage: X.plot() + sage: X.plot() # needs sage.plot Graphics object consisting of 17 graphics primitives """ S = self.get_graph() @@ -2160,7 +2160,7 @@ def plot_fundom(self, *args, **kwargs): EXAMPLES:: sage: X = BruhatTitsQuotient(7,23) - sage: X.plot_fundom() + sage: X.plot_fundom() # needs sage.plot Graphics object consisting of 88 graphics primitives """ S = self.get_fundom_graph() diff --git a/src/sage/modular/dirichlet.py b/src/sage/modular/dirichlet.py index 9785c18963f..978b221cf34 100644 --- a/src/sage/modular/dirichlet.py +++ b/src/sage/modular/dirichlet.py @@ -2361,13 +2361,15 @@ class DirichletGroupFactory(UniqueFactory): If the order of ``zeta`` cannot be determined automatically, we can specify it using ``zeta_order``:: - sage: DirichletGroup(7, CC, zeta=exp(2*pi*I/6)) + sage: DirichletGroup(7, CC, zeta=exp(2*pi*I/6)) # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: order of element not known - sage: DirichletGroup(7, CC, zeta=exp(2*pi*I/6), zeta_order=6) - Group of Dirichlet characters modulo 7 with values in the group of order 6 generated by 0.500000000000000 + 0.866025403784439*I in Complex Field with 53 bits of precision + sage: DirichletGroup(7, CC, zeta=exp(2*pi*I/6), zeta_order=6) # needs sage.symbolic + Group of Dirichlet characters modulo 7 with values in the group of order 6 + generated by 0.500000000000000 + 0.866025403784439*I + in Complex Field with 53 bits of precision If the base ring is not a domain (in which case the group of roots of unity is not necessarily cyclic), some operations still work, diff --git a/src/sage/modular/modform/element.py b/src/sage/modular/modform/element.py index e71c014569f..f03e38ddd83 100644 --- a/src/sage/modular/modform/element.py +++ b/src/sage/modular/modform/element.py @@ -3237,7 +3237,7 @@ def __init__(self, parent, forms_datum): Traceback (most recent call last): ... TypeError: no canonical coercion from Modular Forms space of dimension 1 for Modular Group SL(2,Z) of weight 4 over Rational Field to Rational Field - sage: M([E4, x]) + sage: M([E4, x]) # needs sage.symbolic Traceback (most recent call last): ... TypeError: no canonical coercion from Symbolic Ring to Rational Field diff --git a/src/sage/modular/modform_hecketriangle/analytic_type.py b/src/sage/modular/modform_hecketriangle/analytic_type.py index 0c809b3328c..bdbc34a778a 100644 --- a/src/sage/modular/modform_hecketriangle/analytic_type.py +++ b/src/sage/modular/modform_hecketriangle/analytic_type.py @@ -326,9 +326,9 @@ class AnalyticType(FiniteLatticePoset): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: el = QuasiModularForms(n=3, k=6, ep=-1)(y-z^3) - sage: el.analytic_type() + sage: x,y,z,d = var("x,y,z,d") # needs sage.symbolic + sage: el = QuasiModularForms(n=3, k=6, ep=-1)(y-z^3) # needs sage.symbolic + sage: el.analytic_type() # needs sage.symbolic quasi modular Similarly the type of the ring element ``el2 = E4/Delta - E6/Delta`` is @@ -336,9 +336,9 @@ class AnalyticType(FiniteLatticePoset): a function which is holomorphic at infinity:: sage: from sage.modular.modform_hecketriangle.graded_ring import WeakModularFormsRing - sage: x,y,z,d = var("x,y,z,d") - sage: el2 = WeakModularFormsRing(n=3)(x/(x^3-y^2)-y/(x^3-y^2)) - sage: el2.analytic_type() + sage: x,y,z,d = var("x,y,z,d") # needs sage.symbolic + sage: el2 = WeakModularFormsRing(n=3)(x/(x^3-y^2)-y/(x^3-y^2)) # needs sage.symbolic + sage: el2.analytic_type() # needs sage.symbolic weakly holomorphic modular """ diff --git a/src/sage/modular/modform_hecketriangle/constructor.py b/src/sage/modular/modform_hecketriangle/constructor.py index 845098fe862..9b5b01cbaf3 100644 --- a/src/sage/modular/modform_hecketriangle/constructor.py +++ b/src/sage/modular/modform_hecketriangle/constructor.py @@ -79,7 +79,7 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.constructor import rational_type - sage: (x,y,z,d) = var("x,y,z,d") + sage: (x,y,z,d) = var("x,y,z,d") # needs sage.symbolic sage: rational_type(0, n=4) (True, True, 0, 1, zero) @@ -87,37 +87,37 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): sage: rational_type(1, n=12) (True, True, 0, 1, modular) - sage: rational_type(x^3 - y^2) + sage: rational_type(x^3 - y^2) # needs sage.symbolic (True, True, 12, 1, cuspidal) - sage: rational_type(x * z, n=7) + sage: rational_type(x * z, n=7) # needs sage.symbolic (True, True, 14/5, -1, quasi modular) - sage: rational_type(1/(x^3 - y^2) + z/d) + sage: rational_type(1/(x^3 - y^2) + z/d) # needs sage.symbolic (True, False, None, None, quasi weakly holomorphic modular) - sage: rational_type(x^3/(x^3 - y^2)) + sage: rational_type(x^3/(x^3 - y^2)) # needs sage.symbolic (True, True, 0, 1, weakly holomorphic modular) - sage: rational_type(1/(x + z)) + sage: rational_type(1/(x + z)) # needs sage.symbolic (False, False, None, None, None) - sage: rational_type(1/x + 1/z) + sage: rational_type(1/x + 1/z) # needs sage.symbolic (True, False, None, None, quasi meromorphic modular) - sage: rational_type(d/x, n=10) + sage: rational_type(d/x, n=10) # needs sage.symbolic (True, True, -1/2, 1, meromorphic modular) - sage: rational_type(1.1 * z * (x^8-y^2), n=8, base_ring=CC) + sage: rational_type(1.1 * z * (x^8-y^2), n=8, base_ring=CC) # needs sage.symbolic (True, True, 22/3, -1, quasi cuspidal) - sage: rational_type(x-y^2, n=infinity) + sage: rational_type(x-y^2, n=infinity) # needs sage.symbolic (True, True, 4, 1, modular) - sage: rational_type(x*(x-y^2), n=infinity) + sage: rational_type(x*(x-y^2), n=infinity) # needs sage.symbolic (True, True, 8, 1, cuspidal) - sage: rational_type(1/x, n=infinity) + sage: rational_type(1/x, n=infinity) # needs sage.symbolic (True, True, -4, 1, weakly holomorphic modular) """ diff --git a/src/sage/modular/modform_hecketriangle/element.py b/src/sage/modular/modform_hecketriangle/element.py index 9cb02cb7cde..883a3fee15b 100644 --- a/src/sage/modular/modform_hecketriangle/element.py +++ b/src/sage/modular/modform_hecketriangle/element.py @@ -260,16 +260,17 @@ def lseries(self, num_prec=None, max_imaginary_part=0, max_asymp_coeffs=40): sage: L(10).n(53) -13.0290184579... - sage: f = (ModularForms(n=17, k=24).Delta()^2) # long time - sage: L = f.lseries() # long time - sage: L.check_functional_equation() < 2^(-50) # long time + sage: # long time + sage: f = (ModularForms(n=17, k=24).Delta()^2) + sage: L = f.lseries() + sage: L.check_functional_equation() < 2^(-50) True - sage: L.taylor_series(12, 3) # long time + sage: L.taylor_series(12, 3) 0.000683924755280... - 0.000875942285963...*z + 0.000647618966023...*z^2 + O(z^3) - sage: coeffs = f.q_expansion_vector(min_exp=0, max_exp=20, fix_d=True) # long time - sage: sum([coeffs[k]*k^(-30) for k in range(1,len(coeffs))]).n(53) # long time + sage: coeffs = f.q_expansion_vector(min_exp=0, max_exp=20, fix_d=True) + sage: sum([coeffs[k]*k^(-30) for k in range(1,len(coeffs))]).n(53) 9.31562890589...e-10 - sage: L(30).n(53) # long time + sage: L(30).n(53) 9.31562890589...e-10 sage: f = ModularForms(n=infinity, k=2, ep=-1).f_i() diff --git a/src/sage/modular/modform_hecketriangle/graded_ring_element.py b/src/sage/modular/modform_hecketriangle/graded_ring_element.py index a2ef2a03b04..1d354c9d3a8 100644 --- a/src/sage/modular/modform_hecketriangle/graded_ring_element.py +++ b/src/sage/modular/modform_hecketriangle/graded_ring_element.py @@ -57,9 +57,10 @@ def __classcall__(cls, parent, rat): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.modular.modform_hecketriangle.graded_ring_element import FormsRingElement sage: from sage.modular.modform_hecketriangle.graded_ring import ModularFormsRing - sage: (x,d) = var("x","d") + sage: x, d = var("x","d") sage: el = FormsRingElement(ModularFormsRing(), x*d) sage: el.rat() x*d @@ -101,25 +102,23 @@ def __init__(self, parent, rat): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing - sage: (x,y,z,d)=var("x,y,z,d") + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: MR = QuasiModularFormsRing(n=5) - sage: el = MR(x^3*d + y*z) - sage: el + sage: el = MR(x^3*d + y*z); el # needs sage.symbolic f_rho^3*d + f_i*E2 - sage: el.rat() + sage: el.rat() # needs sage.symbolic x^3*d + y*z - sage: el.parent() + sage: el.parent() # needs sage.symbolic QuasiModularFormsRing(n=5) over Integer Ring - sage: el.rat().parent() + sage: el.rat().parent() # needs sage.symbolic Fraction Field of Multivariate Polynomial Ring in x, y, z, d over Integer Ring sage: MR = QuasiModularFormsRing(n=infinity) - sage: el = MR(d*x*(x-y^2)) - sage: el + sage: el = MR(d*x*(x-y^2)); el # needs sage.symbolic -E4*f_i^2*d + E4^2*d - sage: el.rat() + sage: el.rat() # needs sage.symbolic -x*y^2*d + x^2*d - sage: el.parent() + sage: el.parent() # needs sage.symbolic QuasiModularFormsRing(n=+Infinity) over Integer Ring """ self._rat = rat @@ -172,11 +171,11 @@ def _repr_(self): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing - sage: (x,y,z,d)=var("x,y,z,d") - sage: QuasiModularFormsRing(n=5)(x^3*z-d*y) + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing(n=5)(x^3*z - d*y) # needs sage.symbolic f_rho^3*E2 - f_i*d - sage: QuasiModularFormsRing(n=infinity)(x) + sage: QuasiModularFormsRing(n=infinity)(x) # needs sage.symbolic E4 """ @@ -189,11 +188,11 @@ def _rat_repr(self): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: (x,y,z,d)=var("x,y,z,d") - sage: QuasiModularForms(n=5, k=6, ep=-1)(x^3*z)._rat_repr() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularForms(n=5, k=6, ep=-1)(x^3*z)._rat_repr() # needs sage.symbolic 'f_rho^3*E2' - sage: QuasiModularForms(n=infinity, k=10)(x*(x-y^2)*z)._rat_repr() + sage: QuasiModularForms(n=infinity, k=10)(x*(x-y^2)*z)._rat_repr() # needs sage.symbolic '-E4*f_i^2*E2 + E4^2*E2' """ if self.hecke_n() == infinity: @@ -212,13 +211,13 @@ def _qexp_repr(self): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing - sage: (x,y,z,d)=var("x,y,z,d") + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: MR = QuasiModularFormsRing(n=5) sage: MR.disp_prec(3) - sage: MR(x^3*z-d*y)._qexp_repr() + sage: MR(x^3*z-d*y)._qexp_repr() # needs sage.symbolic '-d + 1 + ((65*d + 33)/(200*d))*q + ((1755*d + 1437)/(320000*d^2))*q^2 + O(q^3)' - sage: QuasiModularFormsRing(n=infinity)(x*(x-y^2)*z)._qexp_repr() + sage: QuasiModularFormsRing(n=infinity)(x*(x-y^2)*z)._qexp_repr() # needs sage.symbolic '64*q - 3840*q^3 - 16384*q^4 + O(q^5)' """ @@ -235,15 +234,15 @@ def _latex_(self): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing - sage: (x,y,z,d)=var("x,y,z,d") - sage: latex(QuasiModularFormsRing(n=5)(x^3*z-d*y)) + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: latex(QuasiModularFormsRing(n=5)(x^3*z - d*y)) # needs sage.symbolic f_{\rho}^{3} E_{2} - f_{i} d sage: from sage.modular.modform_hecketriangle.space import CuspForms - sage: latex(CuspForms(k=12)(x^3-y^2)) + sage: latex(CuspForms(k=12)(x^3 - y^2)) # needs sage.symbolic f_{\rho}^{3} - f_{i}^{2} - sage: latex(QuasiModularFormsRing(n=infinity)(x*(x-y^2)*z)) + sage: latex(QuasiModularFormsRing(n=infinity)(x*(x-y^2)*z)) # needs sage.symbolic -E_{4} f_{i}^{2} E_{2} + E_{4}^{2} E_{2} """ @@ -361,11 +360,11 @@ def is_homogeneous(self): True sage: QuasiModularFormsRing(n=12).Delta().parent().is_homogeneous() False - sage: x,y,z,d=var("x,y,z,d") - sage: QuasiModularFormsRing(n=12)(x^3+y^2+z+d).is_homogeneous() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing(n=12)(x^3+y^2+z+d).is_homogeneous() # needs sage.symbolic False - sage: QuasiModularFormsRing(n=infinity)(x*(x-y^2)+y^4).is_homogeneous() + sage: QuasiModularFormsRing(n=infinity)(x*(x-y^2)+y^4).is_homogeneous() # needs sage.symbolic True """ @@ -379,8 +378,8 @@ def weight(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import ModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiModularFormsRing()(x+y).weight() is None + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing()(x+y).weight() is None # needs sage.symbolic True sage: ModularForms(n=18).f_i().weight() 9/4 @@ -398,8 +397,8 @@ def ep(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import ModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiModularFormsRing()(x+y).ep() is None + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing()(x+y).ep() is None # needs sage.symbolic True sage: ModularForms(n=18).f_i().ep() -1 @@ -419,8 +418,8 @@ def degree(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import ModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiModularFormsRing()(x+y).degree() == (None, None) + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing()(x+y).degree() == (None, None) # needs sage.symbolic True sage: ModularForms(n=18).f_i().degree() (9/4, -1) @@ -438,10 +437,10 @@ def is_modular(self) -> bool: sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiModularFormsRing(n=5)(x^2+y-d).is_modular() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing(n=5)(x^2+y-d).is_modular() # needs sage.symbolic True - sage: QuasiModularFormsRing(n=5)(x^2+y-d+z).is_modular() + sage: QuasiModularFormsRing(n=5)(x^2+y-d+z).is_modular() # needs sage.symbolic False sage: QuasiModularForms(n=18).f_i().is_modular() True @@ -462,16 +461,16 @@ def is_weakly_holomorphic(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiMeromorphicModularFormsRing(n=5)(x/(x^5-y^2)+z).is_weakly_holomorphic() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)(x/(x^5-y^2)+z).is_weakly_holomorphic() # needs sage.symbolic True - sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y/x-d).is_weakly_holomorphic() + sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y/x-d).is_weakly_holomorphic() # needs sage.symbolic False sage: QuasiMeromorphicModularForms(n=18).J_inv().is_weakly_holomorphic() True - sage: QuasiMeromorphicModularForms(n=infinity, k=-4)(1/x).is_weakly_holomorphic() + sage: QuasiMeromorphicModularForms(n=infinity, k=-4)(1/x).is_weakly_holomorphic() # needs sage.symbolic True - sage: QuasiMeromorphicModularForms(n=infinity, k=-2)(1/y).is_weakly_holomorphic() + sage: QuasiMeromorphicModularForms(n=infinity, k=-2)(1/y).is_weakly_holomorphic() # needs sage.symbolic False """ @@ -487,10 +486,10 @@ def is_holomorphic(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).is_holomorphic() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).is_holomorphic() # needs sage.symbolic False - sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d+z).is_holomorphic() + sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d+z).is_holomorphic() # needs sage.symbolic True sage: QuasiMeromorphicModularForms(n=18).J_inv().is_holomorphic() False @@ -512,10 +511,10 @@ def is_cuspidal(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiModularFormsRing(n=5)(y^3-z^5).is_cuspidal() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiModularFormsRing(n=5)(y^3-z^5).is_cuspidal() # needs sage.symbolic False - sage: QuasiModularFormsRing(n=5)(z*x^5-z*y^2).is_cuspidal() + sage: QuasiModularFormsRing(n=5)(z*x^5-z*y^2).is_cuspidal() # needs sage.symbolic True sage: QuasiModularForms(n=18).Delta().is_cuspidal() True @@ -536,7 +535,7 @@ def is_zero(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: x,y,z,d = var("x,y,z,d") + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: QuasiModularFormsRing(n=5)(1).is_zero() False sage: QuasiModularFormsRing(n=5)(0).is_zero() @@ -558,12 +557,12 @@ def analytic_type(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x,y,z,d = var("x,y,z,d") - sage: QuasiMeromorphicModularFormsRing(n=5)(x/z+d).analytic_type() + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)(x/z+d).analytic_type() # needs sage.symbolic quasi meromorphic modular - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).analytic_type() + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).analytic_type() # needs sage.symbolic quasi weakly holomorphic modular - sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d).analytic_type() + sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d).analytic_type() # needs sage.symbolic modular sage: QuasiMeromorphicModularForms(n=18).J_inv().analytic_type() weakly holomorphic modular @@ -585,9 +584,10 @@ def numerator(self): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x,y,z,d = var("x,y,z,d") + sage: x, y, z, d = var("x,y,z,d") sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).numerator() f_rho^5*f_i - f_rho^5*d - E2^5 + f_i^2*d sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).numerator().parent() @@ -619,20 +619,20 @@ def denominator(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x,y,z,d = var("x,y,z,d") + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: QuasiMeromorphicModularFormsRing(n=5).Delta().full_reduce().denominator() 1 + O(q^5) - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator() + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator() # needs sage.symbolic f_rho^5 - f_i^2 - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator().parent() + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator().parent() # needs sage.symbolic QuasiModularFormsRing(n=5) over Integer Ring - sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator() + sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator() # needs sage.symbolic 1 - 13/(40*d)*q - 351/(64000*d^2)*q^2 - 13819/(76800000*d^3)*q^3 - 1163669/(491520000000*d^4)*q^4 + O(q^5) - sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator().parent() + sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator().parent() # needs sage.symbolic QuasiModularForms(n=5, k=10/3, ep=-1) over Integer Ring - sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator() + sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator() # needs sage.symbolic -64*q - 512*q^2 - 768*q^3 + 4096*q^4 + O(q^5) - sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator().parent() + sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator().parent() # needs sage.symbolic QuasiModularForms(n=+Infinity, k=8, ep=1) over Integer Ring """ @@ -1323,10 +1323,10 @@ def order_at(self, tau=infinity): sage: (1/MR.f_inf()^2).order_at(-1) 0 - sage: p = HyperbolicPlane().PD().get_point(I) - sage: MR((x-y)^10).order_at(p) + sage: p = HyperbolicPlane().PD().get_point(I) # needs sage.symbolic + sage: MR((x-y)^10).order_at(p) # needs sage.symbolic 10 - sage: MR.zero().order_at(p) + sage: MR.zero().order_at(p) # needs sage.symbolic +Infinity """ @@ -2123,6 +2123,7 @@ def evaluate(self, tau, prec=None, num_prec=None, check=False): It is possible to evaluate at points of ``HyperbolicPlane()``:: + sage: # needs sage.symbolic sage: p = HyperbolicPlane().PD().get_point(-I/2) sage: bool(p.to_model('UHP').coordinates() == I/3) True diff --git a/src/sage/modular/overconvergent/genus0.py b/src/sage/modular/overconvergent/genus0.py index 62d189e49d5..2037c47511f 100644 --- a/src/sage/modular/overconvergent/genus0.py +++ b/src/sage/modular/overconvergent/genus0.py @@ -1657,7 +1657,7 @@ def valuation_plot(self, rmax=None): sage: o = OverconvergentModularForms(3, 0, 1/2) sage: f = o.eigenfunctions(4)[1] - sage: f.valuation_plot() + sage: f.valuation_plot() # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.plot import plot diff --git a/src/sage/modular/quasimodform/element.py b/src/sage/modular/quasimodform/element.py index b92c31722ac..d5854ffa44c 100644 --- a/src/sage/modular/quasimodform/element.py +++ b/src/sage/modular/quasimodform/element.py @@ -605,7 +605,7 @@ def __getitem__(self, weight): TESTS:: - sage: F[x] + sage: F[x] # needs sage.symbolic Traceback (most recent call last): ... KeyError: 'the weight must be an integer' From 5eb3c8c760605291ffe64cad523c0071af4cfac1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 22:53:30 -0700 Subject: [PATCH 369/494] sage.modular: Add # needs, docstring/doctest cosmetics --- src/sage/modular/abvar/abvar.py | 4 +- src/sage/modular/abvar/abvar_newform.py | 1 + src/sage/modular/abvar/finite_subgroup.py | 73 ++++++++---- src/sage/modular/abvar/homology.py | 18 ++- src/sage/modular/abvar/homspace.py | 7 +- src/sage/modular/abvar/lseries.py | 1 + src/sage/modular/abvar/morphism.py | 1 + src/sage/modular/abvar/torsion_point.py | 14 ++- src/sage/modular/abvar/torsion_subgroup.py | 31 ++--- .../modular/arithgroup/arithgroup_element.pyx | 1 + .../modular/arithgroup/arithgroup_generic.py | 18 +-- .../modular/arithgroup/arithgroup_perm.py | 1 + .../modular/arithgroup/congroup_gamma0.py | 36 ++++-- .../modular/arithgroup/congroup_gamma1.py | 12 +- .../modular/arithgroup/congroup_gammaH.py | 2 +- .../modular/arithgroup/congroup_generic.py | 1 + src/sage/modular/arithgroup/farey_symbol.pyx | 4 +- src/sage/modular/arithgroup/tests.py | 1 + src/sage/modular/btquotients/btquotient.py | 2 +- .../modular/btquotients/pautomorphicform.py | 18 +-- src/sage/modular/buzzard.py | 1 + src/sage/modular/cusps.py | 18 ++- src/sage/modular/dims.py | 3 +- src/sage/modular/dirichlet.py | 23 +++- src/sage/modular/hecke/algebra.py | 1 + src/sage/modular/hecke/ambient_module.py | 1 + src/sage/modular/hecke/degenmap.py | 10 +- src/sage/modular/hecke/element.py | 1 + src/sage/modular/hecke/hecke_operator.py | 1 + src/sage/modular/hecke/homspace.py | 2 + src/sage/modular/hecke/module.py | 1 + src/sage/modular/hecke/morphism.py | 1 + src/sage/modular/hecke/submodule.py | 1 + src/sage/modular/local_comp/local_comp.py | 49 +++++--- src/sage/modular/local_comp/smoothchar.py | 1 + src/sage/modular/local_comp/type_space.py | 1 + src/sage/modular/modform/ambient.py | 2 +- src/sage/modular/modform/ambient_R.py | 17 ++- src/sage/modular/modform/ambient_eps.py | 54 ++++++--- src/sage/modular/modform/ambient_g0.py | 10 +- src/sage/modular/modform/constructor.py | 51 +++++--- .../modular/modform/cuspidal_submodule.py | 60 ++++++---- src/sage/modular/modform/eis_series.py | 14 ++- .../modular/modform/eisenstein_submodule.py | 4 +- src/sage/modular/modform/element.py | 2 +- src/sage/modular/modform/find_generators.py | 1 + .../modular/modform/hecke_operator_on_qexp.py | 13 +- src/sage/modular/modform/j_invariant.py | 1 + src/sage/modular/modform/numerical.py | 1 + src/sage/modular/modform/ring.py | 1 + src/sage/modular/modform/space.py | 12 +- src/sage/modular/modform/submodule.py | 10 +- src/sage/modular/modform/tests.py | 1 + src/sage/modular/modform/vm_basis.py | 1 + src/sage/modular/modform/weight1.py | 1 + .../modform_hecketriangle/constructor.py | 99 +++++++--------- .../modular/modform_hecketriangle/element.py | 17 +-- .../modular/modform_hecketriangle/functors.py | 1 + .../modform_hecketriangle/graded_ring.py | 1 + .../graded_ring_element.py | 19 +-- .../hecke_triangle_group_element.py | 111 ++++++++++-------- .../hecke_triangle_groups.py | 1 + .../modular/modform_hecketriangle/readme.py | 1 + .../series_constructor.py | 1 + .../modular/modform_hecketriangle/space.py | 1 + .../modular/modform_hecketriangle/subspace.py | 1 + src/sage/modular/modsym/ambient.py | 2 +- src/sage/modular/modsym/boundary.py | 2 +- src/sage/modular/modsym/element.py | 1 + src/sage/modular/modsym/ghlist.py | 1 + src/sage/modular/modsym/hecke_operator.py | 1 + src/sage/modular/modsym/manin_symbol.pyx | 2 +- src/sage/modular/modsym/manin_symbol_list.py | 13 ++ src/sage/modular/modsym/modsym.py | 87 +++++++++----- src/sage/modular/modsym/modular_symbols.py | 1 + src/sage/modular/modsym/relation_matrix.py | 1 + src/sage/modular/modsym/space.py | 2 +- src/sage/modular/modsym/subspace.py | 43 ++++--- src/sage/modular/modsym/tests.py | 12 +- src/sage/modular/multiple_zeta.py | 2 +- src/sage/modular/multiple_zeta_F_algebra.py | 2 +- src/sage/modular/overconvergent/genus0.py | 2 +- .../modular/overconvergent/hecke_series.py | 1 + .../modular/pollack_stevens/distributions.py | 2 +- src/sage/modular/pollack_stevens/manin_map.py | 2 +- src/sage/modular/pollack_stevens/space.py | 2 +- src/sage/modular/quasimodform/element.py | 1 + src/sage/modular/ssmod/ssmod.py | 1 + 88 files changed, 667 insertions(+), 386 deletions(-) diff --git a/src/sage/modular/abvar/abvar.py b/src/sage/modular/abvar/abvar.py index 818e7cf1a85..4f23ab768fd 100644 --- a/src/sage/modular/abvar/abvar.py +++ b/src/sage/modular/abvar/abvar.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Base class for modular abelian varieties @@ -317,7 +317,7 @@ def base_extend(self, K): sage: A = J0(37); A Abelian variety J0(37) of dimension 2 - sage: A.base_extend(QQbar) + sage: A.base_extend(QQbar) # needs sage.rings.number_field Abelian variety J0(37) over Algebraic Field of dimension 2 sage: A.base_extend(GF(7)) Abelian variety J0(37) over Finite Field of size 7 of dimension 2 diff --git a/src/sage/modular/abvar/abvar_newform.py b/src/sage/modular/abvar/abvar_newform.py index 67c478511f3..5d4976d5d54 100644 --- a/src/sage/modular/abvar/abvar_newform.py +++ b/src/sage/modular/abvar/abvar_newform.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Abelian varieties attached to newforms diff --git a/src/sage/modular/abvar/finite_subgroup.py b/src/sage/modular/abvar/finite_subgroup.py index 74f7dd6389b..2725e11a387 100644 --- a/src/sage/modular/abvar/finite_subgroup.py +++ b/src/sage/modular/abvar/finite_subgroup.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Finite subgroups of modular abelian varieties @@ -178,7 +179,8 @@ def lattice(self): EXAMPLES:: sage: J = J0(33); C = J[0].cuspidal_subgroup(); C - Finite subgroup with invariants [5] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [5] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) sage: C.lattice() Free module of degree 6 and rank 2 over Integer Ring Echelon basis matrix: @@ -197,7 +199,8 @@ def _relative_basis_matrix(self): sage: A = J0(43)[1]; A Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) sage: C = A.cuspidal_subgroup(); C - Finite subgroup with invariants [7] over QQ of Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) + Finite subgroup with invariants [7] over QQ of + Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) sage: C._relative_basis_matrix() [ 1 0 0 0] [ 0 1/7 6/7 5/7] @@ -262,7 +265,7 @@ def __richcmp__(self, other, op): def is_subgroup(self, other): """ - Return True exactly if self is a subgroup of other, and both are + Return ``True`` exactly if ``self`` is a subgroup of ``other``, and both are defined as subgroups of the same ambient abelian variety. EXAMPLES:: @@ -302,8 +305,9 @@ def __add__(self, other): An example where the parent abelian varieties are different:: - A = J0(48); A[0].cuspidal_subgroup() + A[1].cuspidal_subgroup() - Finite subgroup with invariants [2, 4, 4] over QQ of Abelian subvariety of dimension 2 of J0(48) + sage: A = J0(48); A[0].cuspidal_subgroup() + A[1].cuspidal_subgroup() + Finite subgroup with invariants [2, 4, 4] over QQ of + Abelian subvariety of dimension 2 of J0(48) """ if not isinstance(other, FiniteSubgroup): raise TypeError("only addition of two finite subgroups is defined") @@ -330,7 +334,8 @@ def exponent(self): sage: t = J0(33).hecke_operator(7) sage: G = t.kernel()[0]; G - Finite subgroup with invariants [2, 2, 2, 2, 4, 4] over QQ of Abelian variety J0(33) of dimension 3 + Finite subgroup with invariants [2, 2, 2, 2, 4, 4] over QQ of + Abelian variety J0(33) of dimension 3 sage: G.exponent() 4 """ @@ -343,7 +348,7 @@ def exponent(self): def intersection(self, other): """ - Return the intersection of the finite subgroups self and other. + Return the intersection of the finite subgroups ``self`` and ``other``. INPUT: @@ -358,12 +363,15 @@ def intersection(self, other): sage: E11a0, E11a1, B = J0(33) sage: G = E11a0.torsion_subgroup(6); H = E11a0.torsion_subgroup(9) sage: G.intersection(H) - Finite subgroup with invariants [3, 3] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [3, 3] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) sage: W = E11a1.torsion_subgroup(15) sage: G.intersection(W) - Finite subgroup with invariants [] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) sage: E11a0.intersection(E11a1)[0] - Finite subgroup with invariants [5] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [5] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) We intersect subgroups of different abelian varieties. @@ -372,27 +380,35 @@ def intersection(self, other): sage: E11a0, E11a1, B = J0(33) sage: G = E11a0.torsion_subgroup(5); H = E11a1.torsion_subgroup(5) sage: G.intersection(H) - Finite subgroup with invariants [5] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [5] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) sage: E11a0.intersection(E11a1)[0] - Finite subgroup with invariants [5] over QQ of Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) + Finite subgroup with invariants [5] over QQ of + Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) We intersect abelian varieties with subgroups:: sage: t = J0(33).hecke_operator(7) sage: G = t.kernel()[0]; G - Finite subgroup with invariants [2, 2, 2, 2, 4, 4] over QQ of Abelian variety J0(33) of dimension 3 + Finite subgroup with invariants [2, 2, 2, 2, 4, 4] over QQ of + Abelian variety J0(33) of dimension 3 sage: A = J0(33).old_subvariety() sage: A.intersection(G) - Finite subgroup with invariants [2, 2, 2, 2] over QQ of Abelian subvariety of dimension 2 of J0(33) + Finite subgroup with invariants [2, 2, 2, 2] over QQ of + Abelian subvariety of dimension 2 of J0(33) sage: A.hecke_operator(7).kernel()[0] - Finite subgroup with invariants [2, 2, 2, 2] over QQ of Abelian subvariety of dimension 2 of J0(33) + Finite subgroup with invariants [2, 2, 2, 2] over QQ of + Abelian subvariety of dimension 2 of J0(33) sage: B = J0(33).new_subvariety() sage: B.intersection(G) - Finite subgroup with invariants [4, 4] over QQ of Abelian subvariety of dimension 1 of J0(33) + Finite subgroup with invariants [4, 4] over QQ of + Abelian subvariety of dimension 1 of J0(33) sage: B.hecke_operator(7).kernel()[0] - Finite subgroup with invariants [4, 4] over QQ of Abelian subvariety of dimension 1 of J0(33) + Finite subgroup with invariants [4, 4] over QQ of + Abelian subvariety of dimension 1 of J0(33) sage: A.intersection(B)[0] - Finite subgroup with invariants [3, 3] over QQ of Abelian subvariety of dimension 2 of J0(33) + Finite subgroup with invariants [3, 3] over QQ of + Abelian subvariety of dimension 2 of J0(33) """ from .abvar import is_ModularAbelianVariety A = self.abelian_variety() @@ -736,13 +752,15 @@ def subgroup(self, gens): sage: J = J0(23) sage: G = J.torsion_subgroup(11); G - Finite subgroup with invariants [11, 11, 11, 11] over QQ of Abelian variety J0(23) of dimension 2 + Finite subgroup with invariants [11, 11, 11, 11] over QQ of + Abelian variety J0(23) of dimension 2 We create the subgroup of the 11-torsion subgroup of `J_0(23)` generated by the first `11`-torsion point:: sage: H = G.subgroup([G.0]); H - Finite subgroup with invariants [11] over QQbar of Abelian variety J0(23) of dimension 2 + Finite subgroup with invariants [11] over QQbar of + Abelian variety J0(23) of dimension 2 sage: H.invariants() [11] @@ -773,7 +791,8 @@ def invariants(self): sage: J = J0(38) sage: C = J.cuspidal_subgroup(); C - Finite subgroup with invariants [3, 45] over QQ of Abelian variety J0(38) of dimension 4 + Finite subgroup with invariants [3, 45] over QQ of + Abelian variety J0(38) of dimension 4 sage: v = C.invariants(); v [3, 45] sage: v[0] = 5 @@ -786,12 +805,14 @@ def invariants(self): :: sage: C * 3 - Finite subgroup with invariants [15] over QQ of Abelian variety J0(38) of dimension 4 + Finite subgroup with invariants [15] over QQ of + Abelian variety J0(38) of dimension 4 An example involving another cuspidal subgroup:: sage: C = J0(22).cuspidal_subgroup(); C - Finite subgroup with invariants [5, 5] over QQ of Abelian variety J0(22) of dimension 2 + Finite subgroup with invariants [5, 5] over QQ of + Abelian variety J0(22) of dimension 2 sage: C.lattice() Free module of degree 4 and rank 4 over Integer Ring Echelon basis matrix: @@ -843,7 +864,8 @@ def __init__(self, abvar, lattice, field_of_definition=None, check=True): sage: J = J0(11) sage: G = J.finite_subgroup([[1/3,0], [0,1/5]]); G - Finite subgroup with invariants [15] over QQbar of Abelian variety J0(11) of dimension 1 + Finite subgroup with invariants [15] over QQbar of + Abelian variety J0(11) of dimension 1 """ if field_of_definition is None: from sage.rings.qqbar import QQbar as field_of_definition @@ -868,7 +890,8 @@ def lattice(self): sage: J = J0(11) sage: G = J.finite_subgroup([[1/3,0], [0,1/5]]); G - Finite subgroup with invariants [15] over QQbar of Abelian variety J0(11) of dimension 1 + Finite subgroup with invariants [15] over QQbar of + Abelian variety J0(11) of dimension 1 sage: G.lattice() Free module of degree 2 and rank 2 over Integer Ring Echelon basis matrix: diff --git a/src/sage/modular/abvar/homology.py b/src/sage/modular/abvar/homology.py index 735bb48fb7f..59cc17a77e7 100644 --- a/src/sage/modular/abvar/homology.py +++ b/src/sage/modular/abvar/homology.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari r""" Homology of modular abelian varieties @@ -37,7 +38,8 @@ [-4 0] [ 0 -4] sage: a.T(7) - Hecke operator T_7 on Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3 + Hecke operator T_7 on + Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3 """ # **************************************************************************** @@ -272,7 +274,8 @@ def hecke_matrix(self, n): sage: J = J0(23) sage: J.homology(QQ[I]).hecke_matrix(3).parent() - Full MatrixSpace of 4 by 4 dense matrices over Number Field in I with defining polynomial x^2 + 1 with I = 1*I + Full MatrixSpace of 4 by 4 dense matrices over + Number Field in I with defining polynomial x^2 + 1 with I = 1*I """ raise NotImplementedError @@ -694,16 +697,19 @@ def hecke_bound(self): def hecke_matrix(self, n): """ - Return the matrix of the n-th Hecke operator acting on this + Return the matrix of the `n`-th Hecke operator acting on this homology group. EXAMPLES:: sage: d = J0(125).homology(GF(17)).decomposition(2); d [ - Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8, - Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8, - Submodule of rank 8 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8 + Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 + of Abelian variety J0(125) of dimension 8, + Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 + of Abelian variety J0(125) of dimension 8, + Submodule of rank 8 of Homology with coefficients in Finite Field of size 17 + of Abelian variety J0(125) of dimension 8 ] sage: t = d[0].hecke_matrix(17); t [16 15 15 0] diff --git a/src/sage/modular/abvar/homspace.py b/src/sage/modular/abvar/homspace.py index 06ec268e2ec..964df397a93 100644 --- a/src/sage/modular/abvar/homspace.py +++ b/src/sage/modular/abvar/homspace.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Spaces of homomorphisms between modular abelian varieties @@ -16,7 +17,8 @@ Simple abelian subvariety 37b(1,37) of dimension 1 of J0(37) ] sage: D[0].intersection(D[1]) - (Finite subgroup with invariants [2, 2] over QQ of Simple abelian subvariety 37a(1,37) of dimension 1 of J0(37), + (Finite subgroup with invariants [2, 2] over QQ of + Simple abelian subvariety 37a(1,37) of dimension 1 of J0(37), Simple abelian subvariety of dimension 0 of J0(37)) As an abstract product, since these newforms are distinct, the @@ -218,7 +220,8 @@ def __init__(self, domain, codomain, cat): EXAMPLES:: sage: H = Hom(J0(11), J0(22)); H - Space of homomorphisms from Abelian variety J0(11) of dimension 1 to Abelian variety J0(22) of dimension 2 + Space of homomorphisms from Abelian variety J0(11) of dimension 1 + to Abelian variety J0(22) of dimension 2 sage: Hom(J0(11), J0(11)) Endomorphism ring of Abelian variety J0(11) of dimension 1 sage: type(H) diff --git a/src/sage/modular/abvar/lseries.py b/src/sage/modular/abvar/lseries.py index 76387ce34e4..4d67f7b2dfd 100644 --- a/src/sage/modular/abvar/lseries.py +++ b/src/sage/modular/abvar/lseries.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ `L`-series of modular abelian varieties diff --git a/src/sage/modular/abvar/morphism.py b/src/sage/modular/abvar/morphism.py index f0f3c065577..cc7e5a22ab2 100644 --- a/src/sage/modular/abvar/morphism.py +++ b/src/sage/modular/abvar/morphism.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" Hecke operators and morphisms between modular abelian varieties diff --git a/src/sage/modular/abvar/torsion_point.py b/src/sage/modular/abvar/torsion_point.py index a7cdd54ff3a..6702a231cbb 100644 --- a/src/sage/modular/abvar/torsion_point.py +++ b/src/sage/modular/abvar/torsion_point.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field """ Torsion points on modular abelian varieties @@ -30,10 +31,10 @@ class TorsionPoint(ModuleElement): - ``parent`` -- a finite subgroup of a modular abelian variety - ``element`` -- a `\QQ`-vector space element that represents - this element in terms of the ambient rational homology + this element in terms of the ambient rational homology - ``check`` -- bool (default: ``True``): whether to check that - element is in the appropriate vector space + element is in the appropriate vector space EXAMPLES: @@ -78,7 +79,8 @@ def element(self): sage: J = J0(11) sage: G = J.finite_subgroup([[1/3,0], [0,1/5]]); G - Finite subgroup with invariants [15] over QQbar of Abelian variety J0(11) of dimension 1 + Finite subgroup with invariants [15] over QQbar of + Abelian variety J0(11) of dimension 1 sage: G.0.element() (1/3, 0) @@ -194,7 +196,7 @@ def _richcmp_(self, right, op): INPUT: - ``self, right`` -- elements of the same finite abelian - variety subgroup. + variety subgroup. - ``op`` -- comparison operator (see :mod:`sage.structure.richcmp`) @@ -255,10 +257,12 @@ def _relative_element(self): EXAMPLES:: + sage: # needs sage.libs.flint sage: A = J0(43)[1]; A Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) sage: C = A.cuspidal_subgroup(); C - Finite subgroup with invariants [7] over QQ of Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) + Finite subgroup with invariants [7] over QQ of + Simple abelian subvariety 43b(1,43) of dimension 2 of J0(43) sage: x = C.0; x [(0, 1/7, 0, 6/7, 0, 5/7)] sage: x._relative_element() diff --git a/src/sage/modular/abvar/torsion_subgroup.py b/src/sage/modular/abvar/torsion_subgroup.py index 14a52ba0284..5993a611355 100644 --- a/src/sage/modular/abvar/torsion_subgroup.py +++ b/src/sage/modular/abvar/torsion_subgroup.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Torsion subgroups of modular abelian varieties @@ -176,11 +177,11 @@ def order(self, proof=True): subgroup. The computation of the rational torsion order of J1(p) is conjectural - and will only be used if proof=False. See Section 6.2.3 of [CES2003]_. + and will only be used if ``proof=False``. See Section 6.2.3 of [CES2003]_. INPUT: - - ``proof`` -- a boolean (default: True) + - ``proof`` -- a boolean (default: ``True``) OUTPUT: @@ -202,13 +203,14 @@ def order(self, proof=True): sage: J.rational_torsion_subgroup().order() 19 - Sometimes the order can only be computed with proof=False. :: + Sometimes the order can only be computed with ``proof=False``. :: sage: J = J1(23) sage: J.rational_torsion_subgroup().order() Traceback (most recent call last): ... - RuntimeError: Unable to compute order of torsion subgroup (it is in [408991, 9406793]) + RuntimeError: Unable to compute order of torsion subgroup + (it is in [408991, 9406793]) sage: J.rational_torsion_subgroup().order(proof=False) 408991 @@ -249,7 +251,8 @@ def lattice(self): sage: T.lattice() Traceback (most recent call last): ... - NotImplementedError: unable to compute the rational torsion subgroup in this case (there is no known general algorithm yet) + NotImplementedError: unable to compute the rational torsion subgroup + in this case (there is no known general algorithm yet) The problem is that the multiple of the order obtained by counting points over finite fields is twice the divisor of the order got @@ -278,14 +281,14 @@ def possible_orders(self, proof=True): INPUT: - - ``proof`` -- a boolean (default: True) + - ``proof`` -- a boolean (default: ``True``) OUTPUT: - an array of positive integers The computation of the rational torsion order of J1(p) is conjectural - and will only be used if proof=False. See Section 6.2.3 of [CES2003]_. + and will only be used if ``proof=False``. See Section 6.2.3 of [CES2003]_. EXAMPLES:: @@ -431,7 +434,7 @@ def multiple_of_order(self, maxp=None, proof=True): performance. :: sage: J = J1(23) - sage: J.rational_torsion_subgroup().multiple_of_order() # long time (2s) + sage: J.rational_torsion_subgroup().multiple_of_order() # long time (2s) 9406793 sage: J.rational_torsion_subgroup().multiple_of_order(proof=False) 408991 @@ -680,7 +683,7 @@ def __init__(self, abvar): EXAMPLES:: sage: A = J0(23) - sage: A.qbar_torsion_subgroup() + sage: A.qbar_torsion_subgroup() # needs sage.rings.number_field Group of all torsion points in QQbar on Abelian variety J0(23) of dimension 2 """ self.__abvar = abvar @@ -694,7 +697,7 @@ def _repr_(self): EXAMPLES:: - sage: J0(23).qbar_torsion_subgroup()._repr_() + sage: J0(23).qbar_torsion_subgroup()._repr_() # needs sage.rings.number_field 'Group of all torsion points in QQbar on Abelian variety J0(23) of dimension 2' """ return 'Group of all torsion points in QQbar on %s' % self.__abvar @@ -709,7 +712,7 @@ def field_of_definition(self): EXAMPLES:: - sage: J0(23).qbar_torsion_subgroup().field_of_definition() + sage: J0(23).qbar_torsion_subgroup().field_of_definition() # needs sage.rings.number_field Rational Field """ return self.__abvar.base_field() @@ -726,9 +729,9 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: P = J0(23).qbar_torsion_subgroup()([1,1/2,3/4,2]); P + sage: P = J0(23).qbar_torsion_subgroup()([1,1/2,3/4,2]); P # needs sage.rings.number_field [(1, 1/2, 3/4, 2)] - sage: P.order() + sage: P.order() # needs sage.rings.number_field 4 """ v = self.__abvar.vector_space()(x) @@ -743,7 +746,7 @@ def abelian_variety(self): EXAMPLES:: - sage: J0(23).qbar_torsion_subgroup().abelian_variety() + sage: J0(23).qbar_torsion_subgroup().abelian_variety() # needs sage.rings.number_field Abelian variety J0(23) of dimension 2 """ return self.__abvar diff --git a/src/sage/modular/arithgroup/arithgroup_element.pyx b/src/sage/modular/arithgroup/arithgroup_element.pyx index 4addcde2852..86f2e550d18 100644 --- a/src/sage/modular/arithgroup/arithgroup_element.pyx +++ b/src/sage/modular/arithgroup/arithgroup_element.pyx @@ -340,6 +340,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): An example involving the Gaussian numbers:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: g.acton(i) diff --git a/src/sage/modular/arithgroup/arithgroup_generic.py b/src/sage/modular/arithgroup/arithgroup_generic.py index 093541b9b06..0547901b1f1 100644 --- a/src/sage/modular/arithgroup/arithgroup_generic.py +++ b/src/sage/modular/arithgroup/arithgroup_generic.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Arithmetic subgroups, finite index subgroups of `\SL_2(\ZZ)` """ @@ -683,24 +684,24 @@ def reduce_cusp(self, c): def cusps(self, algorithm='default'): r""" - Return a sorted list of inequivalent cusps for self, i.e. a set of + Return a sorted list of inequivalent cusps for ``self``, i.e. a set of representatives for the orbits of self on `\mathbb{P}^1(\QQ)`. These should be returned in a reduced form where this makes sense. INPUT: - - ``algorithm`` -- which algorithm to use to compute the cusps of self. + - ``algorithm`` -- which algorithm to use to compute the cusps of ``self``. ``'default'`` finds representatives for a known complete set of cusps. ``'modsym'`` computes the boundary map on the space of weight - two modular symbols associated to self, which finds the cusps for - self in the process. + two modular symbols associated to ``self``, which finds the cusps for + ``self`` in the process. EXAMPLES:: sage: Gamma0(36).cusps() [0, 1/18, 1/12, 1/9, 1/6, 1/4, 1/3, 5/12, 1/2, 2/3, 5/6, Infinity] - sage: Gamma0(36).cusps(algorithm='modsym') == Gamma0(36).cusps() + sage: Gamma0(36).cusps(algorithm='modsym') == Gamma0(36).cusps() # needs sage.libs.flint True sage: GammaH(36, [19,29]).cusps() == Gamma0(36).cusps() True @@ -898,8 +899,8 @@ def generalised_level(self): sage: Gamma0(18).generalised_level() 18 - sage: from sage.modular.arithgroup.arithgroup_perm import HsuExample18 - sage: HsuExample18().generalised_level() + sage: from sage.modular.arithgroup.arithgroup_perm import HsuExample18 # needs sage.groups + sage: HsuExample18().generalised_level() # needs sage.groups 24 In the following example, the actual level is twice the generalised @@ -1256,7 +1257,7 @@ def dimension_eis(self, k=2): def as_permutation_group(self): r""" - Return self as an arithmetic subgroup defined in terms of the + Return ``self`` as an arithmetic subgroup defined in terms of the permutation action of `SL(2,\ZZ)` on its right cosets. This method uses Todd-Coxeter enumeration (via the method @@ -1265,6 +1266,7 @@ def as_permutation_group(self): EXAMPLES:: + sage: # needs sage.groups sage: G = Gamma(3) sage: P = G.as_permutation_group(); P Arithmetic subgroup of index 24 diff --git a/src/sage/modular/arithgroup/arithgroup_perm.py b/src/sage/modular/arithgroup/arithgroup_perm.py index 9f7371c1702..eb0e645559a 100644 --- a/src/sage/modular/arithgroup/arithgroup_perm.py +++ b/src/sage/modular/arithgroup/arithgroup_perm.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.groups r""" Arithmetic subgroups defined by permutations of cosets diff --git a/src/sage/modular/arithgroup/congroup_gamma0.py b/src/sage/modular/arithgroup/congroup_gamma0.py index 70d263ebc45..5c57f12a511 100644 --- a/src/sage/modular/arithgroup/congroup_gamma0.py +++ b/src/sage/modular/arithgroup/congroup_gamma0.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Congruence subgroup `\Gamma_0(N)` """ @@ -99,9 +100,11 @@ class Gamma0_class(GammaH_class): Independently compute the dimension 5 above:: - sage: m = ModularSymbols(100, 2,sign=1).cuspidal_subspace() + sage: m = ModularSymbols(100, 2, sign=1).cuspidal_subspace() sage: m.new_subspace(5) - Modular Symbols subspace of dimension 5 of Modular Symbols space of dimension 18 for Gamma_0(100) of weight 2 with sign 1 over Rational Field + Modular Symbols subspace of dimension 5 of + Modular Symbols space of dimension 18 for Gamma_0(100) + of weight 2 with sign 1 over Rational Field """ @@ -225,13 +228,13 @@ def divisor_subgroups(self): sage: Gamma0(24).divisor_subgroups() [Modular Group SL(2,Z), - Congruence Subgroup Gamma0(2), - Congruence Subgroup Gamma0(3), - Congruence Subgroup Gamma0(4), - Congruence Subgroup Gamma0(6), - Congruence Subgroup Gamma0(8), - Congruence Subgroup Gamma0(12), - Congruence Subgroup Gamma0(24)] + Congruence Subgroup Gamma0(2), + Congruence Subgroup Gamma0(3), + Congruence Subgroup Gamma0(4), + Congruence Subgroup Gamma0(6), + Congruence Subgroup Gamma0(8), + Congruence Subgroup Gamma0(12), + Congruence Subgroup Gamma0(24)] """ return [Gamma0_constructor(M) for M in self.level().divisors()] @@ -329,8 +332,8 @@ def generators(self, algorithm="farey"): INPUT: - - ``algorithm`` (string): either ``farey`` (default) or - ``todd-coxeter``. + - ``algorithm`` (string): either ``"farey"`` (default) or + ``"todd-coxeter"``. If ``algorithm`` is set to ``"farey"``, then the generators will be calculated using Farey symbols, which will always return a *minimal* @@ -388,10 +391,17 @@ def gamma_h_subgroups(self): sage: G = Gamma0(11) sage: G.gamma_h_subgroups() - [Congruence Subgroup Gamma0(11), Congruence Subgroup Gamma_H(11) with H generated by [3], Congruence Subgroup Gamma_H(11) with H generated by [10], Congruence Subgroup Gamma1(11)] + [Congruence Subgroup Gamma0(11), + Congruence Subgroup Gamma_H(11) with H generated by [3], + Congruence Subgroup Gamma_H(11) with H generated by [10], + Congruence Subgroup Gamma1(11)] sage: G = Gamma0(12) sage: G.gamma_h_subgroups() - [Congruence Subgroup Gamma0(12), Congruence Subgroup Gamma_H(12) with H generated by [7], Congruence Subgroup Gamma_H(12) with H generated by [11], Congruence Subgroup Gamma_H(12) with H generated by [5], Congruence Subgroup Gamma1(12)] + [Congruence Subgroup Gamma0(12), + Congruence Subgroup Gamma_H(12) with H generated by [7], + Congruence Subgroup Gamma_H(12) with H generated by [11], + Congruence Subgroup Gamma_H(12) with H generated by [5], + Congruence Subgroup Gamma1(12)] """ from .all import GammaH N = self.level() diff --git a/src/sage/modular/arithgroup/congroup_gamma1.py b/src/sage/modular/arithgroup/congroup_gamma1.py index 00dc9e8c0a5..c8bc6fb0320 100644 --- a/src/sage/modular/arithgroup/congroup_gamma1.py +++ b/src/sage/modular/arithgroup/congroup_gamma1.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Congruence subgroup `\Gamma_1(N)` """ @@ -357,10 +357,10 @@ def dimension_modular_forms(self, k=2, eps=None, algorithm="CohenOesterle"): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K = CyclotomicField(3) sage: eps = DirichletGroup(7*43,K).0^2 sage: G = Gamma1(7*43) - sage: G.dimension_modular_forms(2, eps) 32 sage: G.dimension_modular_forms(2, eps, algorithm="Quer") @@ -370,6 +370,7 @@ def dimension_modular_forms(self, k=2, eps=None, algorithm="CohenOesterle"): Check that :trac:`18436` is fixed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + x + 1) sage: G = DirichletGroup(13, base_ring=K) @@ -386,7 +387,7 @@ def dimension_modular_forms(self, k=2, eps=None, algorithm="CohenOesterle"): def dimension_cusp_forms(self, k=2, eps=None, algorithm="CohenOesterle"): r""" - Return the dimension of the space of cusp forms for self, or the + Return the dimension of the space of cusp forms for ``self``, or the dimension of the subspace corresponding to the given character if one is supplied. @@ -409,18 +410,19 @@ def dimension_cusp_forms(self, k=2, eps=None, algorithm="CohenOesterle"): We compute the same dimension in two different ways :: + sage: # needs sage.rings.number_field sage: K = CyclotomicField(3) sage: eps = DirichletGroup(7*43,K).0^2 sage: G = Gamma1(7*43) Via Cohen--Oesterle:: - sage: Gamma1(7*43).dimension_cusp_forms(2, eps) + sage: Gamma1(7*43).dimension_cusp_forms(2, eps) # needs sage.rings.number_field 28 Via Quer's method:: - sage: Gamma1(7*43).dimension_cusp_forms(2, eps, algorithm="Quer") + sage: Gamma1(7*43).dimension_cusp_forms(2, eps, algorithm="Quer") # needs sage.rings.number_field 28 Some more examples:: diff --git a/src/sage/modular/arithgroup/congroup_gammaH.py b/src/sage/modular/arithgroup/congroup_gammaH.py index 20da4f05b3e..c9e53fdf3a8 100644 --- a/src/sage/modular/arithgroup/congroup_gammaH.py +++ b/src/sage/modular/arithgroup/congroup_gammaH.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Congruence subgroup `\Gamma_H(N)` diff --git a/src/sage/modular/arithgroup/congroup_generic.py b/src/sage/modular/arithgroup/congroup_generic.py index edf056784e6..3fd60c06165 100644 --- a/src/sage/modular/arithgroup/congroup_generic.py +++ b/src/sage/modular/arithgroup/congroup_generic.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.gap sage.libs.pari r""" Congruence arithmetic subgroups of `\SL_2(\ZZ)` diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index 99f9e6920b4..7a106543dda 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -1,5 +1,5 @@ # distutils: sources = sage/modular/arithgroup/sl2z.cpp sage/modular/arithgroup/farey.cpp - +# sage.doctest: needs sage.libs.pari r""" Farey symbol for arithmetic subgroups of `\PSL_2(\ZZ)` @@ -731,6 +731,7 @@ cdef class Farey: The unique index 2 even subgroup and index 4 odd subgroup each get handled correctly:: + sage: # needs sage.groups sage: FareySymbol(ArithmeticSubgroup_Permutation(S2="(1,2)", S3="()")).generators() [ [ 0 1] [-1 1] @@ -876,6 +877,7 @@ cdef class Farey: Reduce 11/17 to a cusp of for HsuExample10():: + sage: # needs sage.groups sage: from sage.modular.arithgroup.arithgroup_perm import HsuExample10 sage: f = FareySymbol(HsuExample10()) sage: f.reduce_to_cusp(11/17) diff --git a/src/sage/modular/arithgroup/tests.py b/src/sage/modular/arithgroup/tests.py index be49c7d41d2..d30ead3ac4c 100644 --- a/src/sage/modular/arithgroup/tests.py +++ b/src/sage/modular/arithgroup/tests.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.groups r""" Testing arithmetic subgroup """ diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 3be90544708..5aec1bc78ec 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Quotients of the Bruhat-Tits tree diff --git a/src/sage/modular/btquotients/pautomorphicform.py b/src/sage/modular/btquotients/pautomorphicform.py index 6428c7357da..656c1f42d89 100644 --- a/src/sage/modular/btquotients/pautomorphicform.py +++ b/src/sage/modular/btquotients/pautomorphicform.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari ######################################################################### # Copyright (C) 2011 Cameron Franc and Marc Masdeu # @@ -20,23 +20,23 @@ Create a quotient of the Bruhat-Tits tree:: - sage: X = BruhatTitsQuotient(13,11) + sage: X = BruhatTitsQuotient(13, 11) Declare the corresponding space of harmonic cocycles:: - sage: H = X.harmonic_cocycles(2,prec=5) + sage: H = X.harmonic_cocycles(2, prec=5) And the space of `p`-adic automorphic forms:: - sage: A = X.padic_automorphic_forms(2,prec=5,overconvergent=True) + sage: A = X.padic_automorphic_forms(2, prec=5, overconvergent=True) # needs sage.rings.padics Harmonic cocycles, unlike `p`-adic automorphic forms, can be used to compute a basis:: - sage: a = H.gen(0) + sage: a = H.gen(0) # needs sage.rings.padics This can then be lifted to an overconvergent `p`-adic modular form:: - sage: A.lift(a) # long time + sage: A.lift(a) # long time # needs sage.rings.padics p-adic automorphic form of cohomological weight 0 """ @@ -135,9 +135,9 @@ def eval_dist_at_powseries(phi, f): sage: R. = PowerSeriesRing(ZZ,10) sage: f = (1 - 7*X)^(-1) - sage: D = OverconvergentDistributions(0,7,10) - sage: phi = D(list(range(1,11))) - sage: eval_dist_at_powseries(phi,f) + sage: D = OverconvergentDistributions(0,7,10) # needs sage.rings.padics + sage: phi = D(list(range(1,11))) # needs sage.rings.padics + sage: eval_dist_at_powseries(phi,f) # needs sage.rings.padics 1 + 2*7 + 3*7^2 + 4*7^3 + 5*7^4 + 6*7^5 + 2*7^7 + 3*7^8 + 4*7^9 + O(7^10) """ nmoments = phi.parent().precision_cap() diff --git a/src/sage/modular/buzzard.py b/src/sage/modular/buzzard.py index 99ee6673d2a..72e72e745cc 100644 --- a/src/sage/modular/buzzard.py +++ b/src/sage/modular/buzzard.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Conjectural slopes of Hecke polynomials diff --git a/src/sage/modular/cusps.py b/src/sage/modular/cusps.py index 098c7e52a24..fd8a6d7bc58 100644 --- a/src/sage/modular/cusps.py +++ b/src/sage/modular/cusps.py @@ -742,6 +742,7 @@ def is_gamma_h_equiv(self, other, G): EXAMPLES:: + sage: # needs sage.libs.pari sage: x = Cusp(2,3) sage: y = Cusp(4,5) sage: x.is_gamma_h_equiv(y,GammaH(13,[2])) @@ -758,8 +759,10 @@ def is_gamma_h_equiv(self, other, G): :: - sage: G = GammaH(25,[6]) ; M = G.modular_symbols() ; M - Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) with H generated by [6] of weight 2 with sign 0 over Rational Field + sage: # needs sage.libs.pari + sage: G = GammaH(25,[6]); M = G.modular_symbols(); M + Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) + with H generated by [6] of weight 2 with sign 0 over Rational Field sage: M.cusps() [8/25, 1/3, 6/25, 1/4, 1/15, -7/15, 7/15, 4/15, 1/20, 3/20, 7/20, 9/20] sage: len(M.cusps()) @@ -770,10 +773,13 @@ def is_gamma_h_equiv(self, other, G): :: + sage: # needs sage.libs.pari sage: G.dimension_eis(2) 11 sage: M.cuspidal_subspace() - Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) with H generated by [6] of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 0 of + Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) + with H generated by [6] of weight 2 with sign 0 over Rational Field sage: G.dimension_cusp_forms(2) 0 """ @@ -934,6 +940,7 @@ def galois_action(self, t, N): Here we check that the Galois action is indeed a permutation on the cusps of Gamma1(48) and check that :trac:`13253` is fixed. :: + sage: # needs sage.libs.pari sage: G = Gamma1(48) sage: C = G.cusps() sage: for i in Integers(48).unit_gens(): @@ -943,6 +950,7 @@ def galois_action(self, t, N): We test that Gamma1(19) has 9 rational cusps and check that :trac:`8998` is fixed. :: + sage: # needs sage.libs.pari sage: G = Gamma1(19) sage: [c for c in G.cusps() if c.galois_action(2,19).is_gamma1_equiv(c,19)[0]] [2/19, 3/19, 4/19, 5/19, 6/19, 7/19, 8/19, 9/19, Infinity] @@ -1003,9 +1011,9 @@ def __pari__(self): EXAMPLES:: - sage: Cusp(1, 0).__pari__() + sage: Cusp(1, 0).__pari__() # needs sage.libs.pari +oo - sage: pari(Cusp(3, 2)) + sage: pari(Cusp(3, 2)) # needs sage.libs.pari 3/2 """ b = self.__b diff --git a/src/sage/modular/dims.py b/src/sage/modular/dims.py index f2f63b3433c..ab1f9cbc268 100644 --- a/src/sage/modular/dims.py +++ b/src/sage/modular/dims.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Dimensions of spaces of modular forms @@ -227,6 +227,7 @@ def _lambda(r, s, p): :: + sage: # needs sage.rings.number_field sage: K = CyclotomicField(3) sage: eps = DirichletGroup(7*43, K).0^2 sage: sage.modular.dims.CohenOesterle(eps, 2) diff --git a/src/sage/modular/dirichlet.py b/src/sage/modular/dirichlet.py index 978b221cf34..e752cc36b59 100644 --- a/src/sage/modular/dirichlet.py +++ b/src/sage/modular/dirichlet.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Dirichlet characters @@ -400,6 +400,7 @@ def _richcmp_(self, other, op): EXAMPLES:: + sage: # needs sage.rings.number_field sage: e = DirichletGroup(16)([-1, 1]) sage: f = e.restrict(8) sage: e == e @@ -420,6 +421,7 @@ def __hash__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: e = DirichletGroup(16)([-1, 1]) sage: hash(e) == hash((-1,1)) True @@ -560,6 +562,7 @@ def _latex_(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: G. = DirichletGroup(16) sage: latex(b) # indirect doctest \hbox{Dirichlet character modulo } 16 \hbox{ of conductor } 16 \hbox{ mapping } 15 \mapsto 1,\ 5 \mapsto \zeta_{4} @@ -1124,6 +1127,7 @@ def _pari_init_(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: chi4 = DirichletGroup(4).gen() sage: pari(chi4) [[[4, [0]], [2, [2], [3]], [[2]~, Vecsmall([2])], @@ -1178,6 +1182,7 @@ def conrey_number(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: chi4 = DirichletGroup(4).gen() sage: chi4.conrey_number() 3 @@ -1218,6 +1223,7 @@ def lmfdb_page(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: E = DirichletGroup(4).gen() sage: E.lmfdb_page() # optional -- webbrowser """ @@ -2106,6 +2112,7 @@ def values_on_gens(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: e = DirichletGroup(16)([-1, 1]) sage: e.values_on_gens () (-1, 1) @@ -2162,6 +2169,7 @@ def __setstate__(self, state): TESTS:: + sage: # needs sage.rings.number_field sage: e = DirichletGroup(16)([-1, 1]) sage: loads(dumps(e)) == e True @@ -2497,9 +2505,11 @@ def create_object(self, version, key, **extra_args): TESTS:: + sage: # needs sage.rings.number_field sage: K = CyclotomicField(4) sage: DirichletGroup.create_object(None, (K, 60, K.gen(), 4)) - Group of Dirichlet characters modulo 60 with values in the group of order 4 generated by zeta4 in Cyclotomic Field of order 4 and degree 2 + Group of Dirichlet characters modulo 60 with values in the group of order 4 + generated by zeta4 in Cyclotomic Field of order 4 and degree 2 """ base_ring, modulus, zeta, zeta_order = key @@ -2658,18 +2668,21 @@ def change_ring(self, R, zeta=None, zeta_order=None): sage: G = DirichletGroup(7,QQ); G Group of Dirichlet characters modulo 7 with values in Rational Field - sage: G.change_ring(CyclotomicField(6)) - Group of Dirichlet characters modulo 7 with values in Cyclotomic Field of order 6 and degree 2 + sage: G.change_ring(CyclotomicField(6)) # needs sage.rings.number_field + Group of Dirichlet characters modulo 7 with values in + Cyclotomic Field of order 6 and degree 2 TESTS: We test the case where `R` is a map (:trac:`18072`):: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: f = K.complex_embeddings()[0] sage: D = DirichletGroup(5, K) sage: D.change_ring(f) - Group of Dirichlet characters modulo 5 with values in Complex Field with 53 bits of precision + Group of Dirichlet characters modulo 5 with values in + Complex Field with 53 bits of precision """ if zeta is None and self._zeta is not None: diff --git a/src/sage/modular/hecke/algebra.py b/src/sage/modular/hecke/algebra.py index 0f6f5536a70..4ccc6d0b1bf 100644 --- a/src/sage/modular/hecke/algebra.py +++ b/src/sage/modular/hecke/algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Hecke algebras diff --git a/src/sage/modular/hecke/ambient_module.py b/src/sage/modular/hecke/ambient_module.py index e5ed6158cb5..4d0b4c583ea 100644 --- a/src/sage/modular/hecke/ambient_module.py +++ b/src/sage/modular/hecke/ambient_module.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Ambient Hecke modules """ diff --git a/src/sage/modular/hecke/degenmap.py b/src/sage/modular/hecke/degenmap.py index fad128c0c3c..887506e7559 100644 --- a/src/sage/modular/hecke/degenmap.py +++ b/src/sage/modular/hecke/degenmap.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Degeneracy maps """ @@ -32,7 +33,8 @@ class DegeneracyMap(morphism.HeckeModuleMorphism_matrix): sage: M = ModularSymbols(33) sage: d = M.degeneracy_map(11) sage: d - Hecke module morphism degeneracy map corresponding to f(q) |--> f(q) defined by the matrix + Hecke module morphism degeneracy map corresponding to f(q) |--> f(q) + defined by the matrix [ 1 0 0] [ 0 0 1] [ 0 0 -1] @@ -55,12 +57,14 @@ class DegeneracyMap(morphism.HeckeModuleMorphism_matrix): sage: d = M.degeneracy_map(11,2) Traceback (most recent call last): ... - ValueError: the level of self (=33) must be a divisor or multiple of level (=11) and t (=2) must be a divisor of the quotient + ValueError: the level of self (=33) must be a divisor or multiple + of level (=11) and t (=2) must be a divisor of the quotient Degeneracy maps can also go from lower level to higher level:: sage: M.degeneracy_map(66,2) - Hecke module morphism degeneracy map corresponding to f(q) |--> f(q^2) defined by the matrix + Hecke module morphism degeneracy map corresponding to f(q) |--> f(q^2) + defined by the matrix [ 2 0 0 0 0 0 1 0 0 0 1 -1 0 0 0 -1 1 0 0 0 0 0 0 0 -1] [ 0 0 1 -1 0 -1 1 0 -1 2 0 0 0 -1 0 0 -1 1 2 -2 0 0 0 -1 1] [ 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 -1 1 0 0 -1 1 0 0 0] diff --git a/src/sage/modular/hecke/element.py b/src/sage/modular/hecke/element.py index b91d33b6b8d..d4ecd4b380a 100644 --- a/src/sage/modular/hecke/element.py +++ b/src/sage/modular/hecke/element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Elements of Hecke modules diff --git a/src/sage/modular/hecke/hecke_operator.py b/src/sage/modular/hecke/hecke_operator.py index e0401936daa..a6b3faf2ffc 100644 --- a/src/sage/modular/hecke/hecke_operator.py +++ b/src/sage/modular/hecke/hecke_operator.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Hecke operators """ diff --git a/src/sage/modular/hecke/homspace.py b/src/sage/modular/hecke/homspace.py index 2245067bf99..1e6f55e0838 100644 --- a/src/sage/modular/hecke/homspace.py +++ b/src/sage/modular/hecke/homspace.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Hom spaces between Hecke modules """ @@ -181,6 +182,7 @@ def _an_element_(self): EXAMPLES:: + sage: # needs sage.libs.flint sage: M = ModularSymbols(Gamma0(2), weight=12, sign=1) sage: S = M.cuspidal_subspace() sage: S.Hom(S).an_element() diff --git a/src/sage/modular/hecke/module.py b/src/sage/modular/hecke/module.py index 8e1b699658c..d0d8d5e49d7 100644 --- a/src/sage/modular/hecke/module.py +++ b/src/sage/modular/hecke/module.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Hecke modules """ diff --git a/src/sage/modular/hecke/morphism.py b/src/sage/modular/hecke/morphism.py index 373d2b67298..ac9cfbf4e84 100644 --- a/src/sage/modular/hecke/morphism.py +++ b/src/sage/modular/hecke/morphism.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Morphisms of Hecke modules diff --git a/src/sage/modular/hecke/submodule.py b/src/sage/modular/hecke/submodule.py index c1112d685b6..379daa00f7a 100644 --- a/src/sage/modular/hecke/submodule.py +++ b/src/sage/modular/hecke/submodule.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Submodules of Hecke modules """ diff --git a/src/sage/modular/local_comp/local_comp.py b/src/sage/modular/local_comp/local_comp.py index 765ce805ed9..8c693ea6f7b 100644 --- a/src/sage/modular/local_comp/local_comp.py +++ b/src/sage/modular/local_comp/local_comp.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Local components of modular forms @@ -81,8 +82,10 @@ def LocalComponent(f, p, twist_factor=None): 'Supercuspidal' sage: Pi.characters() [ - Character of unramified extension Q_7(s)* (s^2 + 6*s + 3 = 0), of level 1, mapping s |--> -d, 7 |--> 1, - Character of unramified extension Q_7(s)* (s^2 + 6*s + 3 = 0), of level 1, mapping s |--> d, 7 |--> 1 + Character of unramified extension Q_7(s)* (s^2 + 6*s + 3 = 0), + of level 1, mapping s |--> -d, 7 |--> 1, + Character of unramified extension Q_7(s)* (s^2 + 6*s + 3 = 0), + of level 1, mapping s |--> d, 7 |--> 1 ] """ p = ZZ(p) @@ -643,8 +646,10 @@ def characters(self): sage: Pi = LocalComponent(f, 5) sage: chars = Pi.characters(); chars [ - Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), of level 1, mapping s |--> -d - 1, 5 |--> 1, - Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), of level 1, mapping s |--> d, 5 |--> 1 + Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), + of level 1, mapping s |--> -d - 1, 5 |--> 1, + Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), + of level 1, mapping s |--> d, 5 |--> 1 ] sage: chars[0].base_ring() Number Field in d with defining polynomial x^2 + x + 1 @@ -661,8 +666,10 @@ def characters(self): sage: Pi = LocalComponent(f, 5) sage: Pi.characters() [ - Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), of level 1, mapping s |--> 1/3*j0^2*d - 1/3*j0^3, 5 |--> 5, - Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), of level 1, mapping s |--> -1/3*j0^2*d, 5 |--> 5 + Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), + of level 1, mapping s |--> 1/3*j0^2*d - 1/3*j0^3, 5 |--> 5, + Character of unramified extension Q_5(s)* (s^2 + 4*s + 2 = 0), + of level 1, mapping s |--> -1/3*j0^2*d, 5 |--> 5 ] sage: Pi.characters()[0].base_ring() Number Field in d with defining polynomial x^2 - j0*x + 1/3*j0^2 over its base field @@ -680,21 +687,27 @@ def characters(self): q + j0*q^2 + q^4 - j0*q^5 + O(q^6) sage: LocalComponent(f, 3).characters() # long time (12s on sage.math, 2012) [ - Character of unramified extension Q_3(s)* (s^2 + 2*s + 2 = 0), of level 2, mapping -2*s |--> -2*d + j0, 4 |--> 1, 3*s + 1 |--> -j0*d + 1, 3 |--> 1, - Character of unramified extension Q_3(s)* (s^2 + 2*s + 2 = 0), of level 2, mapping -2*s |--> 2*d - j0, 4 |--> 1, 3*s + 1 |--> j0*d - 2, 3 |--> 1 + Character of unramified extension Q_3(s)* (s^2 + 2*s + 2 = 0), + of level 2, mapping -2*s |--> -2*d + j0, 4 |--> 1, 3*s + 1 |--> -j0*d + 1, 3 |--> 1, + Character of unramified extension Q_3(s)* (s^2 + 2*s + 2 = 0), + of level 2, mapping -2*s |--> 2*d - j0, 4 |--> 1, 3*s + 1 |--> j0*d - 2, 3 |--> 1 ] Some ramified examples:: sage: Newform('27a').local_component(3).characters() [ - Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 2, mapping 2 |--> 1, s + 1 |--> -d, s |--> -1, - Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 2, mapping 2 |--> 1, s + 1 |--> d - 1, s |--> -1 + Character of ramified extension Q_3(s)* (s^2 - 6 = 0), + of level 2, mapping 2 |--> 1, s + 1 |--> -d, s |--> -1, + Character of ramified extension Q_3(s)* (s^2 - 6 = 0), + of level 2, mapping 2 |--> 1, s + 1 |--> d - 1, s |--> -1 ] sage: LocalComponent(Newform('54a'), 3, twist_factor=4).characters() [ - Character of ramified extension Q_3(s)* (s^2 - 3 = 0), of level 2, mapping 2 |--> 1, s + 1 |--> -1/9*d, s |--> -9, - Character of ramified extension Q_3(s)* (s^2 - 3 = 0), of level 2, mapping 2 |--> 1, s + 1 |--> 1/9*d - 1, s |--> -9 + Character of ramified extension Q_3(s)* (s^2 - 3 = 0), + of level 2, mapping 2 |--> 1, s + 1 |--> -1/9*d, s |--> -9, + Character of ramified extension Q_3(s)* (s^2 - 3 = 0), + of level 2, mapping 2 |--> 1, s + 1 |--> 1/9*d - 1, s |--> -9 ] A 2-adic non-example:: @@ -709,13 +722,17 @@ def characters(self): sage: Newforms(DirichletGroup(64, QQ).1, 2, names='a')[0].local_component(2).characters() # long time, random [ - Character of unramified extension Q_2(s)* (s^2 + s + 1 = 0), of level 3, mapping s |--> 1, 2*s + 1 |--> 1/2*a0, 4*s + 1 |--> 1, -1 |--> 1, 2 |--> 1, - Character of unramified extension Q_2(s)* (s^2 + s + 1 = 0), of level 3, mapping s |--> 1, 2*s + 1 |--> 1/2*a0, 4*s + 1 |--> -1, -1 |--> 1, 2 |--> 1 + Character of unramified extension Q_2(s)* (s^2 + s + 1 = 0), of level 3, + mapping s |--> 1, 2*s + 1 |--> 1/2*a0, 4*s + 1 |--> 1, -1 |--> 1, 2 |--> 1, + Character of unramified extension Q_2(s)* (s^2 + s + 1 = 0), of level 3, + mapping s |--> 1, 2*s + 1 |--> 1/2*a0, 4*s + 1 |--> -1, -1 |--> 1, 2 |--> 1 ] sage: Newform('243a',names='a').local_component(3).characters() # long time [ - Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 4, mapping -2*s - 1 |--> -d - 1, 4 |--> 1, 3*s + 1 |--> -d - 1, s |--> 1, - Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 4, mapping -2*s - 1 |--> d, 4 |--> 1, 3*s + 1 |--> d, s |--> 1 + Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 4, + mapping -2*s - 1 |--> -d - 1, 4 |--> 1, 3*s + 1 |--> -d - 1, s |--> 1, + Character of ramified extension Q_3(s)* (s^2 - 6 = 0), of level 4, + mapping -2*s - 1 |--> d, 4 |--> 1, 3*s + 1 |--> d, s |--> 1 ] """ T = self.type_space() diff --git a/src/sage/modular/local_comp/smoothchar.py b/src/sage/modular/local_comp/smoothchar.py index c81677589a9..62d80dc560a 100644 --- a/src/sage/modular/local_comp/smoothchar.py +++ b/src/sage/modular/local_comp/smoothchar.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari sage.rings.number_field r""" Smooth characters of `p`-adic fields diff --git a/src/sage/modular/local_comp/type_space.py b/src/sage/modular/local_comp/type_space.py index e27e4b27137..e3bf9c3bf1b 100644 --- a/src/sage/modular/local_comp/type_space.py +++ b/src/sage/modular/local_comp/type_space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Type spaces of newforms diff --git a/src/sage/modular/modform/ambient.py b/src/sage/modular/modform/ambient.py index b7a963f354d..825b572688d 100644 --- a/src/sage/modular/modform/ambient.py +++ b/src/sage/modular/modform/ambient.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari r""" Ambient spaces of modular forms diff --git a/src/sage/modular/modform/ambient_R.py b/src/sage/modular/modform/ambient_R.py index 95c69eea5be..64188bb3892 100644 --- a/src/sage/modular/modform/ambient_R.py +++ b/src/sage/modular/modform/ambient_R.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Modular forms over a non-minimal base ring """ @@ -24,7 +25,8 @@ def __init__(self, M, base_ring): sage: M = ModularForms(23,2,base_ring=GF(7)) # indirect doctest sage: M - Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 7 + Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) + of weight 2 over Finite Field of size 7 sage: M == loads(dumps(M)) True """ @@ -42,6 +44,7 @@ def modular_symbols(self,sign=0): TESTS:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: chi = DirichletGroup(5, base_ring = K).0 sage: L. = K.extension(x^2 - 402*i) @@ -65,6 +68,7 @@ def _repr_(self): sage: M._repr_() 'Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 7' + sage: # needs sage.rings.number_field sage: chi = DirichletGroup(109).0 ** 36 sage: ModularForms(chi, 2, base_ring = chi.base_ring()) Modular Forms space of dimension 9, character [zeta3] and weight 2 over Cyclotomic Field of order 108 and degree 36 @@ -84,8 +88,8 @@ def _compute_q_expansion_basis(self, prec=None): sage: M = ModularForms(23,2,base_ring=GF(7)) sage: M._compute_q_expansion_basis(10) [q + 6*q^3 + 6*q^4 + 5*q^6 + 2*q^7 + 6*q^8 + 2*q^9 + O(q^10), - q^2 + 5*q^3 + 6*q^4 + 2*q^5 + q^6 + 2*q^7 + 5*q^8 + O(q^10), - 1 + 5*q^3 + 5*q^4 + 5*q^6 + 3*q^8 + 5*q^9 + O(q^10)] + q^2 + 5*q^3 + 6*q^4 + 2*q^5 + q^6 + 2*q^7 + 5*q^8 + O(q^10), + 1 + 5*q^3 + 5*q^4 + 5*q^6 + 3*q^8 + 5*q^9 + O(q^10)] TESTS: @@ -141,7 +145,8 @@ def cuspidal_submodule(self): EXAMPLES:: - sage: C = CuspForms(7, 4, base_ring=CyclotomicField(5)) # indirect doctest + sage: # needs sage.rings.number_field + sage: C = CuspForms(7, 4, base_ring=CyclotomicField(5)) # indirect doctest sage: type(C) """ @@ -153,10 +158,12 @@ def change_ring(self, R): EXAMPLES:: + sage: # needs sage.rings.number_field sage: chi = DirichletGroup(109, CyclotomicField(3)).0 sage: M9 = ModularForms(chi, 2, base_ring = CyclotomicField(9)) sage: M9.change_ring(CyclotomicField(15)) - Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 15 and degree 8 + Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 + over Cyclotomic Field of order 15 and degree 8 sage: M9.change_ring(QQ) Traceback (most recent call last): ... diff --git a/src/sage/modular/modform/ambient_eps.py b/src/sage/modular/modform/ambient_eps.py index 71502963bb8..57bad5752eb 100644 --- a/src/sage/modular/modform/ambient_eps.py +++ b/src/sage/modular/modform/ambient_eps.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari sage.rings.number_field r""" Modular forms with character @@ -6,12 +6,16 @@ sage: eps = DirichletGroup(13).0 sage: M = ModularForms(eps^2, 2); M - Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Modular Forms space of dimension 3, character [zeta6] and weight 2 over + Cyclotomic Field of order 6 and degree 2 sage: S = M.cuspidal_submodule(); S - Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, + character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 sage: S.modular_symbols() - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols subspace of dimension 2 of + Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], + sign 0, over Cyclotomic Field of order 6 and degree 2 We create a spaces associated to Dirichlet characters of modulus 225:: @@ -53,10 +57,12 @@ sage: M.eisenstein_submodule() Eisenstein subspace of dimension 8 of Modular Forms space of - dimension 484, character [1, zeta20] and weight 17 over Cyclotomic Field of order 20 and degree 8 + dimension 484, character [1, zeta20] and weight 17 over + Cyclotomic Field of order 20 and degree 8 sage: M.cuspidal_submodule() - Cuspidal subspace of dimension 476 of Modular Forms space of dimension 484, character [1, zeta20] and weight 17 over Cyclotomic Field of order 20 and degree 8 + Cuspidal subspace of dimension 476 of Modular Forms space of dimension 484, + character [1, zeta20] and weight 17 over Cyclotomic Field of order 20 and degree 8 TESTS:: @@ -113,7 +119,8 @@ def __init__(self, character, weight=2, base_ring=None, eis_only=False): EXAMPLES:: sage: m = ModularForms(DirichletGroup(11).0,3); m - Modular Forms space of dimension 3, character [zeta10] and weight 3 over Cyclotomic Field of order 10 and degree 4 + Modular Forms space of dimension 3, character [zeta10] and weight 3 over + Cyclotomic Field of order 10 and degree 4 sage: type(m) """ @@ -167,9 +174,11 @@ def cuspidal_submodule(self): sage: eps = DirichletGroup(4).0 sage: M = ModularForms(eps, 5); M - Modular Forms space of dimension 3, character [-1] and weight 5 over Rational Field + Modular Forms space of dimension 3, character [-1] and weight 5 + over Rational Field sage: M.cuspidal_submodule() - Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 5 over Rational Field + Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, + character [-1] and weight 5 over Rational Field """ if self.weight() > 1: return cuspidal_submodule.CuspidalSubmodule_eps(self) @@ -185,9 +194,11 @@ def change_ring(self, base_ring): EXAMPLES:: sage: m = ModularForms(DirichletGroup(13).0^2,2); m - Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Modular Forms space of dimension 3, character [zeta6] and weight 2 over + Cyclotomic Field of order 6 and degree 2 sage: m.change_ring(CyclotomicField(12)) - Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 12 and degree 4 + Modular Forms space of dimension 3, character [zeta6] and weight 2 over + Cyclotomic Field of order 12 and degree 4 It must be possible to change the ring of the underlying Dirichlet character:: @@ -210,11 +221,14 @@ def modular_symbols(self, sign=0): sage: eps = DirichletGroup(13).0 sage: M = ModularForms(eps^2, 2) sage: M.modular_symbols() - Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols space of dimension 4 and level 13, weight 2, + character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 sage: M.modular_symbols(1) - Modular Symbols space of dimension 3 and level 13, weight 2, character [zeta6], sign 1, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols space of dimension 3 and level 13, weight 2, + character [zeta6], sign 1, over Cyclotomic Field of order 6 and degree 2 sage: M.modular_symbols(-1) - Modular Symbols space of dimension 1 and level 13, weight 2, character [zeta6], sign -1, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols space of dimension 1 and level 13, weight 2, + character [zeta6], sign -1, over Cyclotomic Field of order 6 and degree 2 sage: M.modular_symbols(2) Traceback (most recent call last): ... @@ -236,9 +250,11 @@ def eisenstein_submodule(self): EXAMPLES:: sage: m = ModularForms(DirichletGroup(13).0^2,2); m - Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Modular Forms space of dimension 3, character [zeta6] and weight 2 over + Cyclotomic Field of order 6 and degree 2 sage: m.eisenstein_submodule() - Eisenstein subspace of dimension 2 of Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Eisenstein subspace of dimension 2 of Modular Forms space of dimension 3, + character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 """ return eisenstein_submodule.EisensteinSubmodule_eps(self) @@ -254,13 +270,15 @@ def hecke_module_of_level(self, N): sage: M = ModularForms(DirichletGroup(15).0, 3); M.character().conductor() 3 sage: M.hecke_module_of_level(3) - Modular Forms space of dimension 2, character [-1] and weight 3 over Rational Field + Modular Forms space of dimension 2, character [-1] and weight 3 + over Rational Field sage: M.hecke_module_of_level(5) Traceback (most recent call last): ... ValueError: conductor(=3) must divide M(=5) sage: M.hecke_module_of_level(30) - Modular Forms space of dimension 16, character [-1, 1] and weight 3 over Rational Field + Modular Forms space of dimension 16, character [-1, 1] and weight 3 + over Rational Field """ from . import constructor if N % self.level() == 0: diff --git a/src/sage/modular/modform/ambient_g0.py b/src/sage/modular/modform/ambient_g0.py index 114718b68b9..0b2ffb8fb83 100644 --- a/src/sage/modular/modform/ambient_g0.py +++ b/src/sage/modular/modform/ambient_g0.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Modular forms for `\Gamma_0(N)` over `\QQ` @@ -39,7 +40,8 @@ def __init__(self, level, weight): EXAMPLES:: sage: m = ModularForms(Gamma0(11),4); m - Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(11) of weight 4 over Rational Field + Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(11) + of weight 4 over Rational Field sage: type(m) """ @@ -73,7 +75,8 @@ def cuspidal_submodule(self): sage: m = ModularForms(Gamma0(33),4) sage: s = m.cuspidal_submodule(); s - Cuspidal subspace of dimension 10 of Modular Forms space of dimension 14 for Congruence Subgroup Gamma0(33) of weight 4 over Rational Field + Cuspidal subspace of dimension 10 of Modular Forms space of dimension 14 + for Congruence Subgroup Gamma0(33) of weight 4 over Rational Field sage: type(s) """ @@ -92,7 +95,8 @@ def eisenstein_submodule(self): sage: m = ModularForms(Gamma0(389),6) sage: m.eisenstein_submodule() - Eisenstein subspace of dimension 2 of Modular Forms space of dimension 163 for Congruence Subgroup Gamma0(389) of weight 6 over Rational Field + Eisenstein subspace of dimension 2 of Modular Forms space of dimension 163 + for Congruence Subgroup Gamma0(389) of weight 6 over Rational Field """ return eisenstein_submodule.EisensteinSubmodule_g0_Q(self) diff --git a/src/sage/modular/modform/constructor.py b/src/sage/modular/modform/constructor.py index b632f6d398c..2adde8bafc3 100644 --- a/src/sage/modular/modform/constructor.py +++ b/src/sage/modular/modform/constructor.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari """ Creating spaces of modular forms @@ -6,7 +6,8 @@ sage: m = ModularForms(Gamma1(4),11) sage: m - Modular Forms space of dimension 6 for Congruence Subgroup Gamma1(4) of weight 11 over Rational Field + Modular Forms space of dimension 6 for + Congruence Subgroup Gamma1(4) of weight 11 over Rational Field sage: m.basis() [ q - 134*q^5 + O(q^6), @@ -195,14 +196,16 @@ def ModularForms(group=1, sage: ModularForms(1,12).dimension() 2 sage: ModularForms(11,4) - Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(11) of weight 4 over Rational Field + Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(11) + of weight 4 over Rational Field We create some spaces for `\Gamma_1(N)`. :: sage: ModularForms(Gamma1(13),2) - Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field + Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) + of weight 2 over Rational Field sage: ModularForms(Gamma1(13),2).dimension() 13 sage: [ModularForms(Gamma1(7),k).dimension() for k in [2,3,4,5]] @@ -212,11 +215,13 @@ def ModularForms(group=1, We create a space with character:: + sage: # needs sage.rings.number_field sage: e = (DirichletGroup(13).0)^2 sage: e.order() 6 sage: M = ModularForms(e, 2); M - Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2 + Modular Forms space of dimension 3, character [zeta6] and weight 2 + over Cyclotomic Field of order 6 and degree 2 sage: f = M.T(2).charpoly('x'); f x^3 + (-2*zeta6 - 2)*x^2 - 2*zeta6*x + 14*zeta6 - 7 sage: f.factor() @@ -227,7 +232,8 @@ def ModularForms(group=1, sage: G = GammaH(30, [11]) sage: M = ModularForms(G, 2); M - Modular Forms space of dimension 20 for Congruence Subgroup Gamma_H(30) with H generated by [11] of weight 2 over Rational Field + Modular Forms space of dimension 20 for Congruence Subgroup Gamma_H(30) + with H generated by [11] of weight 2 over Rational Field sage: M.T(7).charpoly().factor() # long time (7s on sage.math, 2011) (x + 4) * x^2 * (x - 6)^4 * (x + 6)^4 * (x - 8)^7 * (x^2 + 4) @@ -237,7 +243,8 @@ def ModularForms(group=1, Dirichlet character modulo 5 of conductor 5 mapping 2 |--> -1 sage: m = ModularForms(e, 2); m - Modular Forms space of dimension 2, character [-1] and weight 2 over Rational Field + Modular Forms space of dimension 2, character [-1] and weight 2 + over Rational Field sage: m == loads(dumps(m)) True sage: m.T(2).charpoly('x') @@ -250,20 +257,23 @@ def ModularForms(group=1, This came up in a subtle bug (:trac:`5923`):: sage: ModularForms(gp(1), gap(12)) - Modular Forms space of dimension 2 for Modular Group SL(2,Z) of weight 12 over Rational Field + Modular Forms space of dimension 2 for Modular Group SL(2,Z) + of weight 12 over Rational Field This came up in another bug (related to :trac:`8630`):: sage: chi = DirichletGroup(109, CyclotomicField(3)).0 sage: ModularForms(chi, 2, base_ring = CyclotomicField(15)) - Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 15 and degree 8 + Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 + over Cyclotomic Field of order 15 and degree 8 We create some weight 1 spaces. Here modular symbol algorithms do not work. In some small examples we can prove using Riemann--Roch that there are no cusp forms anyway, so the entire space is Eisenstein:: sage: M = ModularForms(Gamma1(11), 1); M - Modular Forms space of dimension 5 for Congruence Subgroup Gamma1(11) of weight 1 over Rational Field + Modular Forms space of dimension 5 for Congruence Subgroup Gamma1(11) + of weight 1 over Rational Field sage: M.basis() [ 1 + 22*q^5 + O(q^6), @@ -281,9 +291,10 @@ def ModularForms(group=1, When this does not work (which happens as soon as the level is more than about 30), we use the Hecke stability algorithm of George Schaeffer:: - sage: M = ModularForms(Gamma1(57), 1); M # long time - Modular Forms space of dimension 38 for Congruence Subgroup Gamma1(57) of weight 1 over Rational Field - sage: M.cuspidal_submodule().basis() # long time + sage: M = ModularForms(Gamma1(57), 1); M # long time + Modular Forms space of dimension 38 for Congruence Subgroup Gamma1(57) + of weight 1 over Rational Field + sage: M.cuspidal_submodule().basis() # long time [ q - q^4 + O(q^6), q^3 - q^4 + O(q^6) @@ -292,8 +303,9 @@ def ModularForms(group=1, The Eisenstein subspace in weight 1 can be computed quickly, without triggering the expensive computation of the cuspidal part:: - sage: E = EisensteinForms(Gamma1(59), 1); E # indirect doctest - Eisenstein subspace of dimension 29 of Modular Forms space for Congruence Subgroup Gamma1(59) of weight 1 over Rational Field + sage: E = EisensteinForms(Gamma1(59), 1); E # indirect doctest + Eisenstein subspace of dimension 29 of Modular Forms space for + Congruence Subgroup Gamma1(59) of weight 1 over Rational Field sage: (E.0 + E.2).q_expansion(40) 1 + q^2 + 196*q^29 - 197*q^30 - q^31 + q^33 + q^34 + q^37 + q^38 - q^39 + O(q^40) @@ -378,7 +390,8 @@ def CuspForms(group=1, EXAMPLES:: sage: CuspForms(11,2) - Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field + Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 + for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field """ return ModularForms(group, weight, base_ring, use_cache=use_cache, prec=prec).cuspidal_submodule() @@ -398,7 +411,8 @@ def EisensteinForms(group=1, EXAMPLES:: sage: EisensteinForms(11,2) - Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field + Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2 + for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field """ if weight == 1: return ModularForms(group, weight, base_ring, @@ -458,7 +472,8 @@ def Newforms(group, weight=2, base_ring=None, names=None): sage: chi = DirichletGroup(109, CyclotomicField(3)).0 sage: CuspForms(chi, 2, base_ring = CyclotomicField(9)) - Cuspidal subspace of dimension 8 of Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 9 and degree 6 + Cuspidal subspace of dimension 8 of Modular Forms space of dimension 10, + character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 9 and degree 6 Check that :trac:`15486` is fixed (this used to take over a day):: diff --git a/src/sage/modular/modform/cuspidal_submodule.py b/src/sage/modular/modform/cuspidal_submodule.py index 954542073dc..19cb7c65d9d 100644 --- a/src/sage/modular/modform/cuspidal_submodule.py +++ b/src/sage/modular/modform/cuspidal_submodule.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ The cuspidal subspace @@ -161,17 +162,21 @@ def modular_symbols(self, sign=0): Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 3 for Gamma_0(1) of weight 12 with sign 0 over Rational Field + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(13).0 sage: S = CuspForms(eps^2, 2) - sage: S.modular_symbols(sign=0) - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 - + Modular Symbols subspace of dimension 2 of Modular Symbols space + of dimension 4 and level 13, weight 2, character [zeta6], sign 0, + over Cyclotomic Field of order 6 and degree 2 sage: S.modular_symbols(sign=1) - Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 and level 13, weight 2, character [zeta6], sign 1, over Cyclotomic Field of order 6 and degree 2 - + Modular Symbols subspace of dimension 1 of Modular Symbols space + of dimension 3 and level 13, weight 2, character [zeta6], sign 1, + over Cyclotomic Field of order 6 and degree 2 sage: S.modular_symbols(sign=-1) - Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 1 and level 13, weight 2, character [zeta6], sign -1, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols subspace of dimension 1 of Modular Symbols space + of dimension 1 and level 13, weight 2, character [zeta6], sign -1, + over Cyclotomic Field of order 6 and degree 2 """ A = self.ambient_module() return A.modular_symbols(sign).cuspidal_submodule() @@ -189,11 +194,16 @@ def change_ring(self, R): EXAMPLES:: + sage: # needs sage.rings.number_field sage: chi = DirichletGroup(109, CyclotomicField(3)).0 sage: S9 = CuspForms(chi, 2, base_ring = CyclotomicField(9)); S9 - Cuspidal subspace of dimension 8 of Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 9 and degree 6 + Cuspidal subspace of dimension 8 of + Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 + over Cyclotomic Field of order 9 and degree 6 sage: S9.change_ring(CyclotomicField(3)) - Cuspidal subspace of dimension 8 of Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 3 and degree 2 + Cuspidal subspace of dimension 8 of + Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 + over Cyclotomic Field of order 3 and degree 2 sage: S9.change_ring(QQ) Traceback (most recent call last): ... @@ -209,6 +219,7 @@ def _compute_q_expansion_basis(self, prec): r""" EXAMPLES:: + sage: # needs sage.rings.number_field sage: CuspForms(Gamma1(13), 2, base_ring=QuadraticField(-7, 'a')).q_expansion_basis() # indirect doctest [ q - 4*q^3 - q^4 + 3*q^5 + O(q^6), @@ -268,12 +279,14 @@ def hecke_polynomial(self, n, var='x'): EXAMPLES:: sage: CuspForms(105, 2).hecke_polynomial(2, 'y') - y^13 + 5*y^12 - 4*y^11 - 52*y^10 - 34*y^9 + 174*y^8 + 212*y^7 - 196*y^6 - 375*y^5 - 11*y^4 + 200*y^3 + 80*y^2 + y^13 + 5*y^12 - 4*y^11 - 52*y^10 - 34*y^9 + 174*y^8 + 212*y^7 + - 196*y^6 - 375*y^5 - 11*y^4 + 200*y^3 + 80*y^2 Check that this gives the same answer as computing the Hecke matrix:: sage: CuspForms(105, 2).hecke_matrix(2).charpoly(var='y') - y^13 + 5*y^12 - 4*y^11 - 52*y^10 - 34*y^9 + 174*y^8 + 212*y^7 - 196*y^6 - 375*y^5 - 11*y^4 + 200*y^3 + 80*y^2 + y^13 + 5*y^12 - 4*y^11 - 52*y^10 - 34*y^9 + 174*y^8 + 212*y^7 + - 196*y^6 - 375*y^5 - 11*y^4 + 200*y^3 + 80*y^2 Check that :trac:`21546` is fixed (this example used to take about 5 hours):: @@ -290,7 +303,9 @@ def new_submodule(self, p=None): EXAMPLES:: sage: CuspForms(55).new_submodule() - Modular Forms subspace of dimension 3 of Modular Forms space of dimension 8 for Congruence Subgroup Gamma0(55) of weight 2 over Rational Field + Modular Forms subspace of dimension 3 of + Modular Forms space of dimension 8 for + Congruence Subgroup Gamma0(55) of weight 2 over Rational Field """ symbs = self.modular_symbols(sign=1).new_subspace(p) bas = [] @@ -347,7 +362,7 @@ def _compute_q_expansion_basis(self, prec=None): EXAMPLES:: - sage: CuspForms(DirichletGroup(23, QQ).0, 1).q_echelon_basis() # indirect doctest + sage: CuspForms(DirichletGroup(23, QQ).0, 1).q_echelon_basis() # indirect doctest [ q - q^2 - q^3 + O(q^6) ] @@ -372,7 +387,7 @@ def _compute_q_expansion_basis(self, prec=None): EXAMPLES:: - sage: CuspForms(GammaH(31, [7]), 1).q_expansion_basis() # indirect doctest + sage: CuspForms(GammaH(31, [7]), 1).q_expansion_basis() # indirect doctest [ q - q^2 - q^5 + O(q^6) ] @@ -447,7 +462,7 @@ def _transformation_matrix(self): sage: CuspForms(GammaH(31, [7]), 1)._transformation_matrix() [1] - sage: CuspForms(GammaH(124, [33]), 1)._transformation_matrix() # long time + sage: CuspForms(GammaH(124, [33]), 1)._transformation_matrix() # long time [ 1 1 0 0 0 0 1] [ 0 0 0 0 0 1 0] [ 1 0 1 1 -1 -1 1] @@ -504,8 +519,10 @@ def _compute_hecke_matrix(self, n): sage: CuspForms(GammaH(31, [7]), 1).hecke_matrix(7) [-1] - sage: C = CuspForms(GammaH(124, [33]), 1) # long time - sage: C.hecke_matrix(2) # long time + + sage: # long time + sage: C = CuspForms(GammaH(124, [33]), 1) + sage: C.hecke_matrix(2) [ 0 0 -1 -1 0 1 0] [ 1 0 0 -1 -1 -1 0] [ 0 0 0 -1 1 1 -1] @@ -513,7 +530,7 @@ def _compute_hecke_matrix(self, n): [ 0 0 -1 0 0 1 1] [ 0 0 0 -1 0 0 -1] [ 0 0 0 0 0 1 0] - sage: C.hecke_matrix(7) # long time + sage: C.hecke_matrix(7) [ 0 1 0 -1 0 0 1] [ 0 -1 0 0 0 0 0] [ 0 1 -1 0 0 0 1] @@ -521,7 +538,7 @@ def _compute_hecke_matrix(self, n): [ 0 1 1 0 0 -1 0] [ 1 0 -1 -1 -1 0 1] [ 0 1 0 0 1 0 0] - sage: C.hecke_matrix(23) == 0 # long time + sage: C.hecke_matrix(23) == 0 True """ @@ -597,7 +614,7 @@ def _compute_diamond_matrix(self, d): r""" EXAMPLES:: - sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest + sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest [ -1 0 0] [ 3 5 -12] [ 1 2 -5] @@ -622,7 +639,8 @@ class CuspidalSubmodule_eps(CuspidalSubmodule_modsym_qexp): EXAMPLES:: sage: S = CuspForms(DirichletGroup(5).0,5); S - Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [zeta4] and weight 5 over Cyclotomic Field of order 4 and degree 2 + Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, + character [zeta4] and weight 5 over Cyclotomic Field of order 4 and degree 2 sage: S.basis() [ @@ -658,7 +676,7 @@ def _convert_matrix_from_modsyms(symbs, T): EXAMPLES:: - sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest + sage: CuspForms(Gamma1(5), 6).diamond_bracket_matrix(3) # indirect doctest [ -1 0 0] [ 3 5 -12] [ 1 2 -5] diff --git a/src/sage/modular/modform/eis_series.py b/src/sage/modular/modform/eis_series.py index 39d78cdc0ea..19bf574dec8 100644 --- a/src/sage/modular/modform/eis_series.py +++ b/src/sage/modular/modform/eis_series.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Eisenstein series """ @@ -177,14 +177,16 @@ def __common_minimal_basering(chi, psi): EXAMPLES:: + sage: # needs sage.rings.number_field sage: sage.modular.modform.eis_series.__common_minimal_basering(DirichletGroup(1)[0], DirichletGroup(1)[0]) - (Dirichlet character modulo 1 of conductor 1, Dirichlet character modulo 1 of conductor 1) - + (Dirichlet character modulo 1 of conductor 1, + Dirichlet character modulo 1 of conductor 1) sage: sage.modular.modform.eis_series.__common_minimal_basering(DirichletGroup(3).0, DirichletGroup(5).0) - (Dirichlet character modulo 3 of conductor 3 mapping 2 |--> -1, Dirichlet character modulo 5 of conductor 5 mapping 2 |--> zeta4) - + (Dirichlet character modulo 3 of conductor 3 mapping 2 |--> -1, + Dirichlet character modulo 5 of conductor 5 mapping 2 |--> zeta4) sage: sage.modular.modform.eis_series.__common_minimal_basering(DirichletGroup(12).0, DirichletGroup(36).0) - (Dirichlet character modulo 12 of conductor 4 mapping 7 |--> -1, 5 |--> 1, Dirichlet character modulo 36 of conductor 4 mapping 19 |--> -1, 29 |--> 1) + (Dirichlet character modulo 12 of conductor 4 mapping 7 |--> -1, 5 |--> 1, + Dirichlet character modulo 36 of conductor 4 mapping 19 |--> -1, 29 |--> 1) """ chi = chi.minimize_base_ring() psi = psi.minimize_base_ring() diff --git a/src/sage/modular/modform/eisenstein_submodule.py b/src/sage/modular/modform/eisenstein_submodule.py index 90370ecf78d..66e3dcca72f 100644 --- a/src/sage/modular/modform/eisenstein_submodule.py +++ b/src/sage/modular/modform/eisenstein_submodule.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari """ The Eisenstein subspace """ @@ -29,7 +29,7 @@ def __init__(self, ambient_space): EXAMPLES:: - sage: E = ModularForms(23,4).eisenstein_subspace() # indirect doctest + sage: E = ModularForms(23,4).eisenstein_subspace() # indirect doctest sage: E Eisenstein subspace of dimension 2 of Modular Forms space of dimension 7 for Congruence Subgroup Gamma0(23) of weight 4 over Rational Field diff --git a/src/sage/modular/modform/element.py b/src/sage/modular/modform/element.py index f03e38ddd83..2c8c1c79616 100644 --- a/src/sage/modular/modform/element.py +++ b/src/sage/modular/modform/element.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Elements of modular forms spaces diff --git a/src/sage/modular/modform/find_generators.py b/src/sage/modular/modform/find_generators.py index 63b4397e3cd..72080237d56 100644 --- a/src/sage/modular/modform/find_generators.py +++ b/src/sage/modular/modform/find_generators.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" This module is now called ``ring.py`` (see :trac:`31559`). Do not import from here as it will generate a deprecation warning. diff --git a/src/sage/modular/modform/hecke_operator_on_qexp.py b/src/sage/modular/modform/hecke_operator_on_qexp.py index 48590ba7d23..52de2f5c54b 100644 --- a/src/sage/modular/modform/hecke_operator_on_qexp.py +++ b/src/sage/modular/modform/hecke_operator_on_qexp.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Hecke operators on `q`-expansions """ @@ -40,14 +41,18 @@ def hecke_operator_on_qexp(f, n, k, eps=None, sage: hecke_operator_on_qexp(M.basis()[0], 1, 12, prec=7) q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 + O(q^7) sage: hecke_operator_on_qexp(M.basis()[0], 1, 12) - q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + O(q^14) + q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 + - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + O(q^14) sage: M.prec(20) 20 sage: hecke_operator_on_qexp(M.basis()[0], 3, 12) 252*q - 6048*q^2 + 63504*q^3 - 370944*q^4 + 1217160*q^5 - 1524096*q^6 + O(q^7) sage: hecke_operator_on_qexp(M.basis()[0], 1, 12) - q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + 401856*q^14 + 1217160*q^15 + 987136*q^16 - 6905934*q^17 + 2727432*q^18 + 10661420*q^19 - 7109760*q^20 + O(q^21) + q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 + - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + + 401856*q^14 + 1217160*q^15 + 987136*q^16 - 6905934*q^17 + 2727432*q^18 + + 10661420*q^19 - 7109760*q^20 + O(q^21) sage: (hecke_operator_on_qexp(M.basis()[0], 1, 12)*252).add_bigoh(7) 252*q - 6048*q^2 + 63504*q^3 - 370944*q^4 + 1217160*q^5 - 1524096*q^6 + O(q^7) @@ -183,7 +188,8 @@ def hecke_operator_on_basis(B, n, k, eps=None, already_echelonized=False): sage: ModularForms(1,12).q_expansion_basis() [ q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6), - 1 + 65520/691*q + 134250480/691*q^2 + 11606736960/691*q^3 + 274945048560/691*q^4 + 3199218815520/691*q^5 + O(q^6) + 1 + 65520/691*q + 134250480/691*q^2 + 11606736960/691*q^3 + + 274945048560/691*q^4 + 3199218815520/691*q^5 + O(q^6) ] sage: hecke_operator_on_basis(ModularForms(1,12).q_expansion_basis(), 3, 12) Traceback (most recent call last): @@ -205,6 +211,7 @@ def hecke_operator_on_basis(B, n, k, eps=None, already_echelonized=False): This shows that empty input is handled sensibly (:trac:`12202`):: + sage: # needs sage.rings.number_field sage: x = hecke_operator_on_basis([], 3, 12); x [] sage: x.parent() diff --git a/src/sage/modular/modform/j_invariant.py b/src/sage/modular/modform/j_invariant.py index 9d53d44d909..48b7c91fcb0 100644 --- a/src/sage/modular/modform/j_invariant.py +++ b/src/sage/modular/modform/j_invariant.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" `q`-expansion of `j`-invariant """ diff --git a/src/sage/modular/modform/numerical.py b/src/sage/modular/modform/numerical.py index f811939ca5f..e5444b25c22 100644 --- a/src/sage/modular/modform/numerical.py +++ b/src/sage/modular/modform/numerical.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Numerical computation of newforms """ diff --git a/src/sage/modular/modform/ring.py b/src/sage/modular/modform/ring.py index 2e98067413e..d7008429b5f 100644 --- a/src/sage/modular/modform/ring.py +++ b/src/sage/modular/modform/ring.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Graded rings of modular forms diff --git a/src/sage/modular/modform/space.py b/src/sage/modular/modform/space.py index 36daef1d17b..80326a77b8c 100644 --- a/src/sage/modular/modform/space.py +++ b/src/sage/modular/modform/space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Generic spaces of modular forms @@ -732,6 +733,7 @@ def _compute_q_expansion_basis(self, prec): """ EXAMPLES:: + sage: # needs sage.rings.number_field sage: sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], QQ)._compute_q_expansion_basis(5) Traceback (most recent call last): ... @@ -1617,10 +1619,11 @@ def new_submodule(self, p=None): EXAMPLES:: - sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], base_ring=QQ); M.new_submodule() - Traceback (most recent call last): - ... - NotImplementedError: computation of new submodule not yet implemented + sage: # needs sage.rings.number_field + sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], base_ring=QQ); M.new_submodule() + Traceback (most recent call last): + ... + NotImplementedError: computation of new submodule not yet implemented """ raise NotImplementedError("computation of new submodule not yet implemented") @@ -1630,6 +1633,7 @@ def new_subspace(self, p=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], base_ring=QQ); M.new_subspace() Traceback (most recent call last): ... diff --git a/src/sage/modular/modform/submodule.py b/src/sage/modular/modform/submodule.py index 441f6d9dd05..f2bc33f5782 100644 --- a/src/sage/modular/modform/submodule.py +++ b/src/sage/modular/modform/submodule.py @@ -1,16 +1,20 @@ +# sage.doctest: needs sage.libs.pari """ Submodules of spaces of modular forms EXAMPLES:: sage: M = ModularForms(Gamma1(13),2); M - Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field + Modular Forms space of dimension 13 for + Congruence Subgroup Gamma1(13) of weight 2 over Rational Field sage: M.eisenstein_subspace() - Eisenstein subspace of dimension 11 of Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field + Eisenstein subspace of dimension 11 of Modular Forms space of dimension 13 for + Congruence Subgroup Gamma1(13) of weight 2 over Rational Field sage: M == loads(dumps(M)) True sage: M.cuspidal_subspace() - Cuspidal subspace of dimension 2 of Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field + Cuspidal subspace of dimension 2 of Modular Forms space of dimension 13 for + Congruence Subgroup Gamma1(13) of weight 2 over Rational Field """ ######################################################################### diff --git a/src/sage/modular/modform/tests.py b/src/sage/modular/modform/tests.py index 87dcf84d1a7..ec831dcc84e 100644 --- a/src/sage/modular/modform/tests.py +++ b/src/sage/modular/modform/tests.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ TESTS: diff --git a/src/sage/modular/modform/vm_basis.py b/src/sage/modular/modform/vm_basis.py index f83c6bbcc1f..e79408d6f93 100644 --- a/src/sage/modular/modform/vm_basis.py +++ b/src/sage/modular/modform/vm_basis.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" The Victor Miller basis diff --git a/src/sage/modular/modform/weight1.py b/src/sage/modular/modform/weight1.py index 4cb34df7513..c2ce006decb 100644 --- a/src/sage/modular/modform/weight1.py +++ b/src/sage/modular/modform/weight1.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" Weight 1 modular forms diff --git a/src/sage/modular/modform_hecketriangle/constructor.py b/src/sage/modular/modform_hecketriangle/constructor.py index 9b5b01cbaf3..3a9e21fa852 100644 --- a/src/sage/modular/modform_hecketriangle/constructor.py +++ b/src/sage/modular/modform_hecketriangle/constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Constructor for spaces of modular forms for Hecke triangle groups based on a type @@ -42,33 +43,30 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): INPUT: - - ``f`` -- A rational function in ``x,y,z,d`` over ``base_ring``. + - ``f`` -- A rational function in ``x,y,z,d`` over ``base_ring``. - - ``n`` -- An integer greater or equal to `3` corresponding - to the ``HeckeTriangleGroup`` with that parameter - (default: `3`). + - ``n`` -- An integer greater or equal to `3` corresponding + to the ``HeckeTriangleGroup`` with that parameter (default: `3`). - - ``base_ring`` -- The base ring of the corresponding forms ring, resp. - polynomial ring (default: ``ZZ``). + - ``base_ring`` -- The base ring of the corresponding forms ring, resp. + polynomial ring (default: ``ZZ``). OUTPUT: A tuple ``(elem, homo, k, ep, analytic_type)`` describing the basic analytic properties of `f` (with the interpretation indicated above). - - ``elem`` -- ``True`` if `f` has a homogeneous denominator. + - ``elem`` -- ``True`` if `f` has a homogeneous denominator. - - ``homo`` -- ``True`` if `f` also has a homogeneous numerator. + - ``homo`` -- ``True`` if `f` also has a homogeneous numerator. - - ``k`` -- ``None`` if `f` is not homogeneous, otherwise - the weight of `f` (which is the first component - of its degree). + - ``k`` -- ``None`` if `f` is not homogeneous, otherwise + the weight of `f` (which is the first component of its degree). - - ``ep`` -- ``None`` if `f` is not homogeneous, otherwise - the multiplier of `f` (which is the second component - of its degree) + - ``ep`` -- ``None`` if `f` is not homogeneous, otherwise + the multiplier of `f` (which is the second component of its degree) - - ``analytic_type`` -- The ``AnalyticType`` of `f`. + - ``analytic_type`` -- The :class:`AnalyticType` of `f`. For the zero function the degree `(0, 1)` is choosen. @@ -79,45 +77,35 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): EXAMPLES:: sage: from sage.modular.modform_hecketriangle.constructor import rational_type - sage: (x,y,z,d) = var("x,y,z,d") # needs sage.symbolic sage: rational_type(0, n=4) (True, True, 0, 1, zero) - sage: rational_type(1, n=12) (True, True, 0, 1, modular) - sage: rational_type(x^3 - y^2) # needs sage.symbolic + sage: # needs sage.symbolic + sage: (x,y,z,d) = var("x,y,z,d") + sage: rational_type(x^3 - y^2) (True, True, 12, 1, cuspidal) - - sage: rational_type(x * z, n=7) # needs sage.symbolic + sage: rational_type(x * z, n=7) (True, True, 14/5, -1, quasi modular) - - sage: rational_type(1/(x^3 - y^2) + z/d) # needs sage.symbolic + sage: rational_type(1/(x^3 - y^2) + z/d) (True, False, None, None, quasi weakly holomorphic modular) - - sage: rational_type(x^3/(x^3 - y^2)) # needs sage.symbolic + sage: rational_type(x^3/(x^3 - y^2)) (True, True, 0, 1, weakly holomorphic modular) - - sage: rational_type(1/(x + z)) # needs sage.symbolic + sage: rational_type(1/(x + z)) (False, False, None, None, None) - - sage: rational_type(1/x + 1/z) # needs sage.symbolic + sage: rational_type(1/x + 1/z) (True, False, None, None, quasi meromorphic modular) - - sage: rational_type(d/x, n=10) # needs sage.symbolic + sage: rational_type(d/x, n=10) (True, True, -1/2, 1, meromorphic modular) - - sage: rational_type(1.1 * z * (x^8-y^2), n=8, base_ring=CC) # needs sage.symbolic + sage: rational_type(1.1 * z * (x^8-y^2), n=8, base_ring=CC) (True, True, 22/3, -1, quasi cuspidal) - - sage: rational_type(x-y^2, n=infinity) # needs sage.symbolic + sage: rational_type(x-y^2, n=infinity) (True, True, 4, 1, modular) - - sage: rational_type(x*(x-y^2), n=infinity) # needs sage.symbolic + sage: rational_type(x*(x-y^2), n=infinity) (True, True, 8, 1, cuspidal) - - sage: rational_type(1/x, n=infinity) # needs sage.symbolic + sage: rational_type(1/x, n=infinity) (True, True, -4, 1, weakly holomorphic modular) """ @@ -222,21 +210,17 @@ def FormsSpace(analytic_type, group=3, base_ring=ZZ, k=QQ(0), ep=None): INPUT: - - ``analytic_type`` -- An element of ``AnalyticType()`` describing - the analytic type of the space. + - ``analytic_type`` -- An element of ``AnalyticType()`` describing + the analytic type of the space. - - ``group`` -- The index of the (Hecke triangle) group of the - space (default: `3`). + - ``group`` -- The index of the (Hecke triangle) group of the space (default: `3`). - - ``base_ring`` -- The base ring of the space - (default: ``ZZ``). + - ``base_ring`` -- The base ring of the space (default: ``ZZ``). - - ``k`` -- The weight of the space, a rational number - (default: ``0``). + - ``k`` -- The weight of the space, a rational number (default: ``0``). - - ``ep`` -- The multiplier of the space, `1`, `-1` - or ``None`` (in case ``ep`` should be - determined from ``k``). Default: ``None``. + - ``ep`` -- The multiplier of the space, `1`, `-1` or ``None`` + (in which case ``ep`` should be determined from ``k``). Default: ``None``. For the variables ``group``, ``base_ring``, ``k``, ``ep`` the same arguments as for the class ``FormsSpace_abstract`` can be used. @@ -340,20 +324,19 @@ def FormsRing(analytic_type, group=3, base_ring=ZZ, red_hom=False): INPUT: - - ``analytic_type`` -- An element of ``AnalyticType()`` describing - the analytic type of the space. + - ``analytic_type`` -- An element of ``AnalyticType()`` describing + the analytic type of the space. - - ``group`` -- The index of the (Hecke triangle) group of the space - (default: 3`). + - ``group`` -- The index of the (Hecke triangle) group of the space + (default: 3`). - - ``base_ring`` -- The base ring of the space - (default: ``ZZ``). + - ``base_ring`` -- The base ring of the space (default: ``ZZ``). - - ``red_hom`` -- The (boolean= variable ``red_hom`` of the space - (default: ``False``). + - ``red_hom`` -- The (boolean) variable ``red_hom`` of the space + (default: ``False``). For the variables ``group``, ``base_ring``, ``red_hom`` - the same arguments as for the class ``FormsRing_abstract`` can be used. + the same arguments as for the class :class:`FormsRing_abstract` can be used. The variables will then be put in canonical form. OUTPUT: diff --git a/src/sage/modular/modform_hecketriangle/element.py b/src/sage/modular/modform_hecketriangle/element.py index 883a3fee15b..b8cac1e9f52 100644 --- a/src/sage/modular/modform_hecketriangle/element.py +++ b/src/sage/modular/modform_hecketriangle/element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Elements of Hecke modular forms spaces @@ -30,10 +31,10 @@ def __init__(self, parent, rat): INPUT: - - ``parent`` -- a modular form space + - ``parent`` -- a modular form space - - ``rat`` -- a rational function which corresponds to a - modular form in the modular form space + - ``rat`` -- a rational function which corresponds to a + modular form in the modular form space OUTPUT: @@ -188,14 +189,14 @@ def lseries(self, num_prec=None, max_imaginary_part=0, max_asymp_coeffs=40): INPUT: - - ``num_prec`` -- An integer denoting the to-be-used numerical precision. - If integer ``num_prec=None`` (default) the default - numerical precision of the parent of ``self`` is used. + - ``num_prec`` -- An integer denoting the to-be-used numerical precision. + If integer ``num_prec=None`` (default) the default + numerical precision of the parent of ``self`` is used. - ``max_imaginary_part`` -- A real number (default: 0), indicating up to which - imaginary part the L-series is going to be studied. + imaginary part the L-series is going to be studied. - - ``max_asymp_coeffs`` -- An integer (default: 40). + - ``max_asymp_coeffs`` -- An integer (default: 40). OUTPUT: diff --git a/src/sage/modular/modform_hecketriangle/functors.py b/src/sage/modular/modform_hecketriangle/functors.py index f06615c823f..3ba9c865231 100644 --- a/src/sage/modular/modform_hecketriangle/functors.py +++ b/src/sage/modular/modform_hecketriangle/functors.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Functor construction for all spaces diff --git a/src/sage/modular/modform_hecketriangle/graded_ring.py b/src/sage/modular/modform_hecketriangle/graded_ring.py index f7153493aac..624341c8dc7 100644 --- a/src/sage/modular/modform_hecketriangle/graded_ring.py +++ b/src/sage/modular/modform_hecketriangle/graded_ring.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Graded rings of modular forms for Hecke triangle groups diff --git a/src/sage/modular/modform_hecketriangle/graded_ring_element.py b/src/sage/modular/modform_hecketriangle/graded_ring_element.py index 1d354c9d3a8..8b173a34acd 100644 --- a/src/sage/modular/modform_hecketriangle/graded_ring_element.py +++ b/src/sage/modular/modform_hecketriangle/graded_ring_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Elements of graded rings of modular forms for Hecke triangle groups @@ -101,24 +102,24 @@ def __init__(self, parent, rat): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: x, y, z, d = var("x,y,z,d") sage: MR = QuasiModularFormsRing(n=5) - sage: el = MR(x^3*d + y*z); el # needs sage.symbolic + sage: el = MR(x^3*d + y*z); el f_rho^3*d + f_i*E2 - sage: el.rat() # needs sage.symbolic + sage: el.rat() x^3*d + y*z - sage: el.parent() # needs sage.symbolic + sage: el.parent() QuasiModularFormsRing(n=5) over Integer Ring - sage: el.rat().parent() # needs sage.symbolic + sage: el.rat().parent() Fraction Field of Multivariate Polynomial Ring in x, y, z, d over Integer Ring - sage: MR = QuasiModularFormsRing(n=infinity) - sage: el = MR(d*x*(x-y^2)); el # needs sage.symbolic + sage: el = MR(d*x*(x-y^2)); el -E4*f_i^2*d + E4^2*d - sage: el.rat() # needs sage.symbolic + sage: el.rat() -x*y^2*d + x^2*d - sage: el.parent() # needs sage.symbolic + sage: el.parent() QuasiModularFormsRing(n=+Infinity) over Integer Ring """ self._rat = rat 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 b0241196107..7fa7b698d14 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap r""" Hecke triangle group elements @@ -40,12 +41,14 @@ def coerce_AA(p): EXAMPLES:: + sage: # needs sage.rings.number_field sage.symbolic sage: from sage.modular.modform_hecketriangle.hecke_triangle_group_element import coerce_AA sage: p = (791264*AA(2*cos(pi/8))^2 - 463492).sqrt() 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 ...? + Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 + with a in ...? """ el = AA(p) el.simplify() @@ -103,17 +106,18 @@ def __init__(self, parent, M, check=True, **kwargs): - ``parent`` -- A ``HeckeTriangleGroup``. - - ``M`` -- A matrix which coerces into the matrix space - of ``parent``. For example with entries in a - polynomial ring over ``ZZ`` with parameter ``lam``. + - ``M`` -- A matrix which coerces into the matrix space + of ``parent``. For example with entries in a + polynomial ring over ``ZZ`` with parameter ``lam``. - ``check`` -- ``True`` (default) or ``False``. If ``True`` - then a (possibly long) check is performed - to see whether ``M`` really corresponds to a - group element of ``parent``. + then a (possibly long) check is performed + to see whether ``M`` really corresponds to a + group element of ``parent``. EXAMPLES:: + sage: sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup, HeckeTriangleGroupElement sage: lam = PolynomialRing(ZZ, 'lam').gen() sage: M = matrix([[-1, 0], [-lam^4 + 5*lam^2 + lam - 5, -1]]) @@ -121,7 +125,8 @@ def __init__(self, parent, M, check=True, **kwargs): sage: G(M) Traceback (most recent call last): ... - TypeError: The matrix is not an element of Hecke triangle group for n = 4, up to equivalence it identifies two nonequivalent points. + TypeError: The matrix is not an element of Hecke triangle group for n = 4, + up to equivalence it identifies two nonequivalent points. sage: G = HeckeTriangleGroup(10) sage: el = G(M) @@ -139,13 +144,16 @@ def __init__(self, parent, M, check=True, **kwargs): [ -1 0] [lam -1] sage: el.matrix().parent() - Full MatrixSpace of 2 by 2 dense matrices over Maximal Order in Number Field in lam with defining polynomial x^4 - 5*x^2 + 5 with lam = 1.902113032590308? + Full MatrixSpace of 2 by 2 dense matrices over + Maximal Order in Number Field in lam with defining polynomial x^4 - 5*x^2 + 5 + with lam = 1.902113032590308? sage: M = matrix([[-1, lam], [0, 1]]) sage: G(M) Traceback (most recent call last): ... - TypeError: The matrix is not an element of Hecke triangle group for n = 10, it has determinant -1 != 1. + TypeError: The matrix is not an element of Hecke triangle group for n = 10, + it has determinant -1 != 1. sage: G.T().inverse() [ 1 -lam] @@ -339,19 +347,21 @@ def string_repr(self, method="default"): INPUT: - - ``method`` -- ``default``: Use the usual representation method for matrix group elements. + - ``method`` -- one of - ``basic``: The representation is given as a word in ``S`` and powers of ``T``. - Note: If ``S, T`` are defined accordingly the output can - be used/evaluated directly to recover ``self``. + - ``default``: Use the usual representation method for matrix group elements. - ``conj``: The conjugacy representative of the element is represented - as a word in powers of the basic blocks, together with - an unspecified conjugation matrix. + - ``basic``: The representation is given as a word in ``S`` and powers of ``T``. + Note: If ``S, T`` are defined accordingly the output can + be used/evaluated directly to recover ``self``. - ``block``: Same as ``conj`` but the conjugation matrix is specified as well. - Note: Assuming ``S, T, U, V`` are defined accordingly the output - can directly be used/evaluated to recover ``self``. + - ``conj``: The conjugacy representative of the element is represented + as a word in powers of the basic blocks, together with + an unspecified conjugation matrix. + + - ``block``: Same as ``conj`` but the conjugation matrix is specified as well. + Note: Assuming ``S, T, U, V`` are defined accordingly the output + can directly be used/evaluated to recover ``self``. Warning: For ``n=infinity`` the methods ``conj`` and ``block`` are not verified at all and are probably wrong! @@ -893,19 +903,19 @@ def primitive_representative(self, method="block"): INPUT: - ``method`` -- ``block`` (default) or ``cf``. The method - used to determine ``P`` and ``R``. If - ``self`` is elliptic this parameter is - ignored and if ``self`` is +- the identity - then the ``block`` method is used. + used to determine ``P`` and ``R``. If + ``self`` is elliptic, this parameter is + ignored, and if ``self`` is +- the identity + then the ``block`` method is used. - With ``block`` the decomposition described - in :meth:`_primitive_block_decomposition_data` is used. + With ``block`` the decomposition described + in :meth:`_primitive_block_decomposition_data` is used. - With ``cf`` a reduced representative from - the lambda-CF of ``self`` is used (see - :meth:`continued_fraction`). In that case - ``P`` corresponds to the period and ``R`` - to the preperiod. + With ``cf`` a reduced representative from + the lambda-CF of ``self`` is used (see + :meth:`continued_fraction`). In that case + ``P`` corresponds to the period and ``R`` + to the preperiod. OUTPUT: @@ -1079,11 +1089,11 @@ def primitive_part(self, method="cf"): INPUT: - ``method`` -- The method used to determine the primitive - part (see :meth:`primitive_representative`), - default: "cf". The parameter is ignored - for elliptic elements or +- the identity. + part (see :meth:`primitive_representative`), + default: "cf". The parameter is ignored + for elliptic elements or +- the identity. - The result should not depend on the method. + The result should not depend on the method. OUTPUT: @@ -1166,7 +1176,7 @@ def reduce(self, primitive=True): INPUT: - ``primitive`` -- If ``True`` (default) then a primitive - representative for ``self`` is returned. + representative for ``self`` is returned. EXAMPLES:: @@ -1278,9 +1288,9 @@ def primitive_power(self, method="cf"): INPUT: - ``method`` -- The method used to determine the primitive - power (see :meth:`primitive_representative`), - default: "cf". The parameter is ignored - for elliptic elements or +- the identity. + power (see :meth:`primitive_representative`), + default: "cf". The parameter is ignored + for elliptic elements or +- the identity. OUTPUT: @@ -1416,8 +1426,8 @@ def block_length(self, primitive=False): INPUT: - ``primitive`` -- If ``True`` then the conjugacy - representative of the primitive part is - used instead, default: ``False``. + representative of the primitive part is + used instead, default: ``False``. OUTPUT: @@ -1778,11 +1788,11 @@ def conjugacy_type(self, ignore_sign=True, primitive=False): INPUT: - ``ignore_sign`` -- If ``True`` (default) then the conjugacy - classes are only considered up to a sign. + classes are only considered up to a sign. - - ``primitive`` -- If ``True`` then the conjugacy class of - the primitive part is considered instead - and the sign is ignored, default: ``False``. + - ``primitive`` -- If ``True`` then the conjugacy class of + the primitive part is considered instead + and the sign is ignored, default: ``False``. OUTPUT: @@ -2379,10 +2389,10 @@ def is_reduced(self, require_primitive=True, require_hyperbolic=True): INPUT: - ``require_primitive`` -- If ``True`` (default) then non-primitive elements - are not considered reduced. + are not considered reduced. - ``require_hyperbolic`` -- If ``True`` (default) then non-hyperbolic elements - are not considered reduced. + are not considered reduced. EXAMPLES:: @@ -2721,7 +2731,8 @@ def linking_number(self): ....: t_const = (2*pi*i/G.lam()).n(num_prec) ....: d = MF.get_d(fix_d=True, d_num_prec=num_prec) ....: q = exp(t_const * z) - ....: return t_const*z + sum([(int_series.coefficients()[m]).subs(d=d) * q**int_series.exponents()[m] for m in range(len(int_series.coefficients()))]) + ....: return t_const*z + sum((int_series.coefficients()[m]).subs(d=d) * q**int_series.exponents()[m] + ....: for m in range(len(int_series.coefficients()))) sage: def M(gamma, z, num_prec=53): ....: a = ComplexField(num_prec)(gamma.a()) @@ -2738,7 +2749,9 @@ def linking_number(self): sage: def num_linking_number(A, z, n=3, prec=10, num_prec=53): ....: z = z.n(num_prec) ....: k = 4 * n / (n - 2) - ....: return (n-2) / (2*pi*i).n(num_prec) * (E2_primitive(A.acton(z), n=n, prec=prec, num_prec=num_prec) - E2_primitive(z, n=n, prec=prec, num_prec=num_prec) - k*M(A, z, num_prec=num_prec)) + ....: return (n-2) / (2*pi*i).n(num_prec) * (E2_primitive(A.acton(z), n=n, prec=prec, num_prec=num_prec) + ....: - E2_primitive(z, n=n, prec=prec, num_prec=num_prec) + ....: - k*M(A, z, num_prec=num_prec)) sage: G = HeckeTriangleGroup(8) sage: z = i diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py index 917ebb0cf02..6c73cc50d40 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap r""" Hecke triangle groups diff --git a/src/sage/modular/modform_hecketriangle/readme.py b/src/sage/modular/modform_hecketriangle/readme.py index b0059725904..ff8a725c15c 100644 --- a/src/sage/modular/modform_hecketriangle/readme.py +++ b/src/sage/modular/modform_hecketriangle/readme.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap r""" Overview of Hecke triangle groups and modular forms for Hecke triangle groups diff --git a/src/sage/modular/modform_hecketriangle/series_constructor.py b/src/sage/modular/modform_hecketriangle/series_constructor.py index dc2cd792a6b..b44f41a09a0 100644 --- a/src/sage/modular/modform_hecketriangle/series_constructor.py +++ b/src/sage/modular/modform_hecketriangle/series_constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap r""" Series constructor for modular forms for Hecke triangle groups diff --git a/src/sage/modular/modform_hecketriangle/space.py b/src/sage/modular/modform_hecketriangle/space.py index 662f1035794..9df1e2d60ba 100644 --- a/src/sage/modular/modform_hecketriangle/space.py +++ b/src/sage/modular/modform_hecketriangle/space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Modular forms for Hecke triangle groups diff --git a/src/sage/modular/modform_hecketriangle/subspace.py b/src/sage/modular/modform_hecketriangle/subspace.py index f89d42affd8..4475f71530a 100644 --- a/src/sage/modular/modform_hecketriangle/subspace.py +++ b/src/sage/modular/modform_hecketriangle/subspace.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Subspaces of modular forms for Hecke triangle groups diff --git a/src/sage/modular/modsym/ambient.py b/src/sage/modular/modsym/ambient.py index 9c1876493f1..a0e40c27785 100644 --- a/src/sage/modular/modsym/ambient.py +++ b/src/sage/modular/modsym/ambient.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari r""" Ambient spaces of modular symbols diff --git a/src/sage/modular/modsym/boundary.py b/src/sage/modular/modsym/boundary.py index 208371b9deb..e90a5d165f6 100644 --- a/src/sage/modular/modsym/boundary.py +++ b/src/sage/modular/modsym/boundary.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari r""" Space of boundary modular symbols diff --git a/src/sage/modular/modsym/element.py b/src/sage/modular/modsym/element.py index df08763459d..80ccb3c4242 100644 --- a/src/sage/modular/modsym/element.py +++ b/src/sage/modular/modsym/element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ A single element of an ambient space of modular symbols """ diff --git a/src/sage/modular/modsym/ghlist.py b/src/sage/modular/modsym/ghlist.py index bd15cc505b5..5df29f52af9 100644 --- a/src/sage/modular/modsym/ghlist.py +++ b/src/sage/modular/modsym/ghlist.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" List of coset representatives for `\Gamma_H(N)` in `\SL_2(\ZZ)` """ diff --git a/src/sage/modular/modsym/hecke_operator.py b/src/sage/modular/modsym/hecke_operator.py index 6d416eca8e3..43e34b57a49 100644 --- a/src/sage/modular/modsym/hecke_operator.py +++ b/src/sage/modular/modsym/hecke_operator.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Sparse action of Hecke operators """ diff --git a/src/sage/modular/modsym/manin_symbol.pyx b/src/sage/modular/modsym/manin_symbol.pyx index 52026160b38..a71533e1b73 100644 --- a/src/sage/modular/modsym/manin_symbol.pyx +++ b/src/sage/modular/modsym/manin_symbol.pyx @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint r""" Manin symbols diff --git a/src/sage/modular/modsym/manin_symbol_list.py b/src/sage/modular/modsym/manin_symbol_list.py index 858fa4a9feb..93fa3f1365b 100644 --- a/src/sage/modular/modsym/manin_symbol_list.py +++ b/src/sage/modular/modsym/manin_symbol_list.py @@ -901,6 +901,7 @@ class ManinSymbolList_character(ManinSymbolList): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -922,6 +923,7 @@ def __init__(self, character, weight): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -955,6 +957,7 @@ def __repr__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -975,6 +978,7 @@ def level(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: ManinSymbolList_character(eps,4).level() @@ -1005,6 +1009,7 @@ def apply(self, j, m): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,4) @@ -1041,6 +1046,7 @@ def apply_S(self, j): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -1065,6 +1071,7 @@ def _apply_S_only_0pm1(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: ManinSymbolList_character(eps,2)._apply_S_only_0pm1() @@ -1090,6 +1097,7 @@ def apply_I(self, j): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -1123,6 +1131,7 @@ def apply_T(self, j): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -1165,6 +1174,7 @@ def apply_TT(self, j): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -1200,6 +1210,7 @@ def character(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,2); m @@ -1229,6 +1240,7 @@ def index(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,4); m @@ -1267,6 +1279,7 @@ def normalize(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: eps = DirichletGroup(4).gen(0) sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character sage: m = ManinSymbolList_character(eps,4); m diff --git a/src/sage/modular/modsym/modsym.py b/src/sage/modular/modsym/modsym.py index d33f61cd928..962e3c168ed 100644 --- a/src/sage/modular/modsym/modsym.py +++ b/src/sage/modular/modsym/modsym.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari r""" Creation of modular symbols spaces @@ -20,25 +20,34 @@ :: - sage: M = ModularSymbols(23,2,base_ring=QQ) + sage: M = ModularSymbols(23,2, base_ring=QQ) sage: M.T(2).charpoly('x').factor() (x - 3) * (x^2 + x - 1)^2 sage: M.decomposition(2) [ - Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Rational Field, - Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 5 + for Gamma_0(23) of weight 2 with sign 0 over Rational Field, + Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 5 + for Gamma_0(23) of weight 2 with sign 0 over Rational Field ] :: - sage: M = ModularSymbols(23,2,base_ring=QuadraticField(5, 'sqrt5')) + sage: # needs sage.rings.number_field + sage: M = ModularSymbols(23,2, base_ring=QuadraticField(5, 'sqrt5')) sage: M.T(2).charpoly('x').factor() (x - 3) * (x - 1/2*sqrt5 + 1/2)^2 * (x + 1/2*sqrt5 + 1/2)^2 sage: M.decomposition(2) [ - Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?, - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?, - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? + Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 5 + for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 + with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?, + Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 + for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 + with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?, + Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 + for Gamma_0(23) of weight 2 with sign 0 over Number Field in sqrt5 + with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790? ] We compute some Hecke operators and do a consistency check:: @@ -52,23 +61,30 @@ sage: G = GammaH(36, [13, 19]) sage: G.modular_symbols() - Modular Symbols space of dimension 13 for Congruence Subgroup Gamma_H(36) with H generated by [13, 19] of weight 2 with sign 0 over Rational Field + Modular Symbols space of dimension 13 for Congruence Subgroup Gamma_H(36) + with H generated by [13, 19] of weight 2 with sign 0 over Rational Field sage: G.modular_symbols().cuspidal_subspace() - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 13 for Congruence Subgroup Gamma_H(36) with H generated by [13, 19] of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 13 for + Congruence Subgroup Gamma_H(36) with H generated by [13, 19] of weight 2 with sign 0 + over Rational Field This test catches a tricky corner case for spaces with character:: sage: ModularSymbols(DirichletGroup(20).1**3, weight=3, sign=1).cuspidal_subspace() - Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 6 and level 20, weight 3, character [1, -zeta4], sign 1, over Cyclotomic Field of order 4 and degree 2 + Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 6 + and level 20, weight 3, character [1, -zeta4], sign 1, + over Cyclotomic Field of order 4 and degree 2 This tests the bugs reported in :trac:`20932`:: sage: chi = kronecker_character(3*34603) - sage: ModularSymbols(chi, 2, sign=1, base_ring=GF(3)) # not tested # long time (600 seconds) - Modular Symbols space of dimension 11535 and level 103809, weight 2, character [2, 2], sign 1, over Finite Field of size 3 + sage: ModularSymbols(chi, 2, sign=1, base_ring=GF(3)) # not tested # long time (600 seconds) + Modular Symbols space of dimension 11535 and level 103809, weight 2, + character [2, 2], sign 1, over Finite Field of size 3 sage: chi = kronecker_character(3*61379) - sage: ModularSymbols(chi, 2, sign=1, base_ring=GF(3)) # not tested # long time (1800 seconds) - Modular Symbols space of dimension 20460 and level 184137, weight 2, character [2, 2], sign 1, over Finite Field of size 3 + sage: ModularSymbols(chi, 2, sign=1, base_ring=GF(3)) # not tested # long time (1800 seconds) + Modular Symbols space of dimension 20460 and level 184137, weight 2, + character [2, 2], sign 1, over Finite Field of size 3 """ # **************************************************************************** @@ -175,7 +191,8 @@ def ModularSymbols_clear_cache(): sage: ModularSymbols_clear_cache() sage: gc.collect() # random 3422 - sage: a = [x for x in gc.get_objects() if isinstance(x,sage.modular.modsym.ambient.ModularSymbolsAmbient_wtk_g1)] + sage: a = [x for x in gc.get_objects() + ....: if isinstance(x,sage.modular.modsym.ambient.ModularSymbolsAmbient_wtk_g1)] sage: a [] """ @@ -221,14 +238,16 @@ def ModularSymbols(group=1, sage: ModularSymbols(1,12,-1).dimension() 1 sage: ModularSymbols(11,4, sign=1) - Modular Symbols space of dimension 4 for Gamma_0(11) of weight 4 with sign 1 over Rational Field + Modular Symbols space of dimension 4 for Gamma_0(11) of weight 4 + with sign 1 over Rational Field We create some spaces for `\Gamma_1(N)`. :: sage: ModularSymbols(Gamma1(13),2) - Modular Symbols space of dimension 15 for Gamma_1(13) of weight 2 with sign 0 over Rational Field + Modular Symbols space of dimension 15 for Gamma_1(13) of weight 2 + with sign 0 over Rational Field sage: ModularSymbols(Gamma1(13),2, sign=1).dimension() 13 sage: ModularSymbols(Gamma1(13),2, sign=-1).dimension() @@ -244,8 +263,12 @@ def ModularSymbols(group=1, sage: M = ModularSymbols(G,2) sage: M.decomposition() [ - Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 for Congruence Subgroup Gamma_H(15) with H generated by [4, 7] of weight 2 with sign 0 over Rational Field, - Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 5 for Congruence Subgroup Gamma_H(15) with H generated by [4, 7] of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 + for Congruence Subgroup Gamma_H(15) with H generated by [4, 7] + of weight 2 with sign 0 over Rational Field, + Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 5 + for Congruence Subgroup Gamma_H(15) with H generated by [4, 7] + of weight 2 with sign 0 over Rational Field ] We create a space with character:: @@ -254,7 +277,8 @@ def ModularSymbols(group=1, sage: e.order() 6 sage: M = ModularSymbols(e, 2); M - Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], + sign 0, over Cyclotomic Field of order 6 and degree 2 sage: f = M.T(2).charpoly('x'); f x^4 + (-zeta6 - 1)*x^3 - 8*zeta6*x^2 + (10*zeta6 - 5)*x + 21*zeta6 - 21 sage: f.factor() @@ -262,8 +286,10 @@ def ModularSymbols(group=1, We create a space with character over a larger base ring than the values of the character:: - sage: ModularSymbols(e, 2, base_ring = CyclotomicField(24)) - Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta24^4], sign 0, over Cyclotomic Field of order 24 and degree 8 + sage: # needs sage.rings.number_field + sage: ModularSymbols(e, 2, base_ring=CyclotomicField(24)) + Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta24^4], + sign 0, over Cyclotomic Field of order 24 and degree 8 More examples of spaces with character:: @@ -271,7 +297,8 @@ def ModularSymbols(group=1, Dirichlet character modulo 5 of conductor 5 mapping 2 |--> -1 sage: m = ModularSymbols(e, 2); m - Modular Symbols space of dimension 2 and level 5, weight 2, character [-1], sign 0, over Rational Field + Modular Symbols space of dimension 2 and level 5, weight 2, character [-1], + sign 0, over Rational Field :: @@ -287,14 +314,18 @@ def ModularSymbols(group=1, :: - sage: G = DirichletGroup(13,GF(4,'a')); G - Group of Dirichlet characters modulo 13 with values in Finite Field in a of size 2^2 + sage: # needs sage.rings.finite_rings + sage: G = DirichletGroup(13, GF(4,'a')); G + Group of Dirichlet characters modulo 13 + with values in Finite Field in a of size 2^2 sage: e = G.list()[2]; e Dirichlet character modulo 13 of conductor 13 mapping 2 |--> a + 1 sage: M = ModularSymbols(e,4); M - Modular Symbols space of dimension 8 and level 13, weight 4, character [a + 1], sign 0, over Finite Field in a of size 2^2 + Modular Symbols space of dimension 8 and level 13, weight 4, + character [a + 1], sign 0, over Finite Field in a of size 2^2 sage: M.basis() - ([X*Y,(1,0)], [X*Y,(1,5)], [X*Y,(1,10)], [X*Y,(1,11)], [X^2,(0,1)], [X^2,(1,10)], [X^2,(1,11)], [X^2,(1,12)]) + ([X*Y,(1,0)], [X*Y,(1,5)], [X*Y,(1,10)], [X*Y,(1,11)], + [X^2,(0,1)], [X^2,(1,10)], [X^2,(1,11)], [X^2,(1,12)]) sage: M.T(2).matrix() [ 0 0 0 0 0 0 1 1] [ 0 0 0 0 0 0 0 0] diff --git a/src/sage/modular/modsym/modular_symbols.py b/src/sage/modular/modsym/modular_symbols.py index e76694d54e2..57dc8f23a2b 100644 --- a/src/sage/modular/modsym/modular_symbols.py +++ b/src/sage/modular/modsym/modular_symbols.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint r""" Modular symbols `\{\alpha`, `\beta\}` diff --git a/src/sage/modular/modsym/relation_matrix.py b/src/sage/modular/modsym/relation_matrix.py index 99b3ebfd7b6..5885812d36c 100644 --- a/src/sage/modular/modsym/relation_matrix.py +++ b/src/sage/modular/modsym/relation_matrix.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Relation matrices for ambient modular symbols spaces diff --git a/src/sage/modular/modsym/space.py b/src/sage/modular/modsym/space.py index 9cf4bf0796f..b8b7197bced 100644 --- a/src/sage/modular/modsym/space.py +++ b/src/sage/modular/modsym/space.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Base class of the space of modular symbols diff --git a/src/sage/modular/modsym/subspace.py b/src/sage/modular/modsym/subspace.py index d1d2a393127..fdc69b18b9a 100644 --- a/src/sage/modular/modsym/subspace.py +++ b/src/sage/modular/modsym/subspace.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Subspace of ambient spaces of modular symbols """ @@ -53,7 +54,8 @@ def __init__(self, ambient_hecke_module, submodule, sage: M = ModularSymbols(15,4) ; S = M.cuspidal_submodule() # indirect doctest sage: S - Modular Symbols subspace of dimension 8 of Modular Symbols space of dimension 12 for Gamma_0(15) of weight 4 with sign 0 over Rational Field + Modular Symbols subspace of dimension 8 of Modular Symbols space of dimension 12 + for Gamma_0(15) of weight 4 with sign 0 over Rational Field sage: S == loads(dumps(S)) True sage: M = ModularSymbols(1,24) @@ -61,7 +63,8 @@ def __init__(self, ambient_hecke_module, submodule, sage: B = A.submodule([ x.element() for x in M.cuspidal_submodule().gens() ]) sage: S = sage.modular.modsym.subspace.ModularSymbolsSubspace(A, B.free_module()) sage: S - Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 5 for Gamma_0(1) of weight 24 with sign 0 over Rational Field + Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 5 + for Gamma_0(1) of weight 24 with sign 0 over Rational Field sage: S == loads(dumps(S)) True """ @@ -96,7 +99,8 @@ def boundary_map(self): EXAMPLES:: sage: M = ModularSymbols(1, 24, sign=1) ; M - Modular Symbols space of dimension 3 for Gamma_0(1) of weight 24 with sign 1 over Rational Field + Modular Symbols space of dimension 3 for Gamma_0(1) of weight 24 + with sign 1 over Rational Field sage: M.basis() ([X^18*Y^4,(0,0)], [X^20*Y^2,(0,0)], [X^22,(0,0)]) sage: M.cuspidal_submodule().basis() @@ -137,11 +141,13 @@ def cuspidal_submodule(self): EXAMPLES:: sage: S = ModularSymbols(42,4).cuspidal_submodule() ; S - Modular Symbols subspace of dimension 40 of Modular Symbols space of dimension 48 for Gamma_0(42) of weight 4 with sign 0 over Rational Field + Modular Symbols subspace of dimension 40 of Modular Symbols space of dimension 48 + for Gamma_0(42) of weight 4 with sign 0 over Rational Field sage: S.is_cuspidal() True sage: S.cuspidal_submodule() - Modular Symbols subspace of dimension 40 of Modular Symbols space of dimension 48 for Gamma_0(42) of weight 4 with sign 0 over Rational Field + Modular Symbols subspace of dimension 40 of Modular Symbols space of dimension 48 + for Gamma_0(42) of weight 4 with sign 0 over Rational Field The cuspidal submodule of the cuspidal submodule is just itself:: @@ -156,7 +162,8 @@ def cuspidal_submodule(self): sage: S = M.eisenstein_submodule() sage: S._set_is_cuspidal(True) sage: S.cuspidal_submodule() - Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 65 for Gamma_0(389) of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 65 + for Gamma_0(389) of weight 2 with sign 0 over Rational Field """ try: return self.__cuspidal_submodule @@ -205,9 +212,11 @@ def eisenstein_subspace(self): EXAMPLES:: sage: ModularSymbols(24,4).eisenstein_subspace() - Modular Symbols subspace of dimension 8 of Modular Symbols space of dimension 24 for Gamma_0(24) of weight 4 with sign 0 over Rational Field + Modular Symbols subspace of dimension 8 of Modular Symbols space of dimension 24 + for Gamma_0(24) of weight 4 with sign 0 over Rational Field sage: ModularSymbols(20,2).cuspidal_subspace().eisenstein_subspace() - Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 7 for Gamma_0(20) of weight 2 with sign 0 over Rational Field + Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 7 + for Gamma_0(20) of weight 2 with sign 0 over Rational Field """ try: return self.__eisenstein_subspace @@ -238,9 +247,12 @@ def factorization(self): sage: M = ModularSymbols(11) sage: D = M.factorization(); D - (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field) * - (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field) * - (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field) + (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 + for Gamma_0(11) of weight 2 with sign 0 over Rational Field) * + (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 + for Gamma_0(11) of weight 2 with sign 0 over Rational Field) * + (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 + for Gamma_0(11) of weight 2 with sign 0 over Rational Field) sage: [A.T(2).matrix() for A, _ in D] [[-2], [3], [-2]] sage: [A.star_eigenvalues() for A, _ in D] @@ -253,14 +265,16 @@ def factorization(self): sage: M = ModularSymbols(22,sign=1) sage: S = M.cuspidal_submodule() sage: S.factorization() - (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 2 for Gamma_0(11) of weight 2 with sign 1 over Rational Field)^2 + (Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 2 + for Gamma_0(11) of weight 2 with sign 1 over Rational Field)^2 :: sage: M = ModularSymbols(Gamma0(22), 2, sign=1) sage: M1 = M.decomposition()[1] sage: M1.factorization() - Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 5 for Gamma_0(22) of weight 2 with sign 1 over Rational Field + Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 5 + for Gamma_0(22) of weight 2 with sign 1 over Rational Field """ try: return self._factorization @@ -404,7 +418,8 @@ def star_involution(self): sage: M = ModularSymbols(1,24) sage: M.star_involution() - Hecke module morphism Star involution on Modular Symbols space of dimension 5 for Gamma_0(1) of weight 24 with sign 0 over Rational Field defined by the matrix + Hecke module morphism Star involution on Modular Symbols space of dimension 5 + for Gamma_0(1) of weight 24 with sign 0 over Rational Field defined by the matrix [ 1 0 0 0 0] [ 0 -1 0 0 0] [ 0 0 1 0 0] diff --git a/src/sage/modular/modsym/tests.py b/src/sage/modular/modsym/tests.py index 737bb66ba62..3af2ffb1d87 100644 --- a/src/sage/modular/modsym/tests.py +++ b/src/sage/modular/modsym/tests.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari """ Testing modular symbols spaces @@ -187,10 +188,13 @@ def _modular_symbols_space_character(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.modular.modsym.tests import Test sage: Test()._modular_symbols_space_character() # random level = 18, weight = 3, sign = 0 - Modular Symbols space of dimension 0 and level 18, weight 3, character [1, zeta6 - 1], sign 0, over Cyclotomic Field of order 6 and degree 2 + Modular Symbols space of dimension 0 + and level 18, weight 3, character [1, zeta6 - 1], sign 0, + over Cyclotomic Field of order 6 and degree 2 """ level, weight, sign = self._level_weight_sign() G = dirichlet.DirichletGroup(level) @@ -270,7 +274,8 @@ def test_cs_dimension(self): sage: Test().test_cs_dimension() # random gamma0 level = 16, weight = 3, sign = -1 - Modular Symbols space of dimension 0 for Gamma_0(16) of weight 3 with sign -1 over Rational Field + Modular Symbols space of dimension 0 for Gamma_0(16) of weight 3 + with sign -1 over Rational Field """ self._modular_symbols_space().cuspidal_submodule() @@ -285,7 +290,8 @@ def test_csnew_dimension(self): sage: Test().test_csnew_dimension() # random gamma0 level = 3, weight = 3, sign = 1 - Modular Symbols space of dimension 0 for Gamma_0(3) of weight 3 with sign 1 over Rational Field + Modular Symbols space of dimension 0 for Gamma_0(3) of weight 3 + with sign 1 over Rational Field """ M = self._modular_symbols_space() V = M.cuspidal_submodule().new_submodule() diff --git a/src/sage/modular/multiple_zeta.py b/src/sage/modular/multiple_zeta.py index 22cabe23344..494d183e805 100644 --- a/src/sage/modular/multiple_zeta.py +++ b/src/sage/modular/multiple_zeta.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat r""" Algebra of motivic multiple zeta values diff --git a/src/sage/modular/multiple_zeta_F_algebra.py b/src/sage/modular/multiple_zeta_F_algebra.py index f8875d4bc51..251310de6b8 100644 --- a/src/sage/modular/multiple_zeta_F_algebra.py +++ b/src/sage/modular/multiple_zeta_F_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat r""" F-algebra for motivic multiple zeta values. diff --git a/src/sage/modular/overconvergent/genus0.py b/src/sage/modular/overconvergent/genus0.py index 2037c47511f..9cfbcb3a39b 100644 --- a/src/sage/modular/overconvergent/genus0.py +++ b/src/sage/modular/overconvergent/genus0.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari sage.rings.padics r""" Overconvergent `p`-adic modular forms for small primes diff --git a/src/sage/modular/overconvergent/hecke_series.py b/src/sage/modular/overconvergent/hecke_series.py index 5183106e458..1e10c6386a9 100644 --- a/src/sage/modular/overconvergent/hecke_series.py +++ b/src/sage/modular/overconvergent/hecke_series.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint sage.libs.pari r""" Atkin/Hecke series for overconvergent modular forms diff --git a/src/sage/modular/pollack_stevens/distributions.py b/src/sage/modular/pollack_stevens/distributions.py index 7aaad3c6f0e..a83121db4fa 100644 --- a/src/sage/modular/pollack_stevens/distributions.py +++ b/src/sage/modular/pollack_stevens/distributions.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" Spaces of distributions for Pollack-Stevens modular symbols diff --git a/src/sage/modular/pollack_stevens/manin_map.py b/src/sage/modular/pollack_stevens/manin_map.py index 4acbecf038b..06aa3496e10 100644 --- a/src/sage/modular/pollack_stevens/manin_map.py +++ b/src/sage/modular/pollack_stevens/manin_map.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" Manin map diff --git a/src/sage/modular/pollack_stevens/space.py b/src/sage/modular/pollack_stevens/space.py index 88b7be6d2cd..6fe7c12b95b 100644 --- a/src/sage/modular/pollack_stevens/space.py +++ b/src/sage/modular/pollack_stevens/space.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" Pollack-Stevens' modular symbols spaces diff --git a/src/sage/modular/quasimodform/element.py b/src/sage/modular/quasimodform/element.py index d5854ffa44c..c096973fadc 100644 --- a/src/sage/modular/quasimodform/element.py +++ b/src/sage/modular/quasimodform/element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.flint """ Elements of quasimodular forms rings diff --git a/src/sage/modular/ssmod/ssmod.py b/src/sage/modular/ssmod/ssmod.py index a23320cecb0..13b6d11fbb6 100644 --- a/src/sage/modular/ssmod/ssmod.py +++ b/src/sage/modular/ssmod/ssmod.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Module of supersingular points From ea8a3e3d6648bc31456634db5f41e61d832ddc36 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 12 Sep 2023 13:28:13 -0700 Subject: [PATCH 370/494] sage.modular: Update # needs --- src/sage/modular/arithgroup/congroup_gamma.py | 4 ++-- src/sage/modular/btquotients/btquotient.py | 11 +++++++---- src/sage/modular/modform/space.py | 2 ++ .../modular/modform_hecketriangle/abstract_space.py | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/sage/modular/arithgroup/congroup_gamma.py b/src/sage/modular/arithgroup/congroup_gamma.py index a9eeb2a5769..47d5390b8f4 100644 --- a/src/sage/modular/arithgroup/congroup_gamma.py +++ b/src/sage/modular/arithgroup/congroup_gamma.py @@ -105,7 +105,7 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: Gamma(3) == SymmetricGroup(8) + sage: Gamma(3) == SymmetricGroup(8) # needs sage.groups False sage: Gamma(3) == Gamma1(3) False @@ -113,7 +113,7 @@ def __richcmp__(self, other, op): True sage: Gamma(5) == Gamma(5) True - sage: Gamma(3) == Gamma(3).as_permutation_group() + sage: Gamma(3) == Gamma(3).as_permutation_group() # needs sage.groups True """ if is_Gamma(other): diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 5aec1bc78ec..3c7bceb0aa3 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -539,8 +539,8 @@ def lift(a): EXAMPLES:: - sage: x = Zp(3)(-17) - sage: lift(x) + sage: x = Zp(3)(-17) # needs sage.rings.padics + sage: lift(x) # needs sage.rings.padics 3486784384 """ try: @@ -600,6 +600,7 @@ def vertex(self, M): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.modular.btquotients.btquotient import BruhatTitsTree sage: p = 5 sage: T = BruhatTitsTree(p) @@ -961,6 +962,7 @@ def find_containing_affinoid(self, z): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.modular.btquotients.btquotient import BruhatTitsTree sage: T = BruhatTitsTree(5) sage: K. = Qq(5^2,20) @@ -976,9 +978,9 @@ def find_containing_affinoid(self, z): affinoid. That is, it is a `p`-adic unit and its reduction modulo `p` is not in `\GF{p}`:: - sage: gz = (v[0,0]*z+v[0,1])/(v[1,0]*z+v[1,1]); gz + sage: gz = (v[0,0]*z+v[0,1])/(v[1,0]*z+v[1,1]); gz # needs sage.rings.padics (a + 1) + O(5^19) - sage: gz.valuation() == 0 + sage: gz.valuation() == 0 # needs sage.rings.padics True """ # Assume z belongs to some extension of QQp. @@ -1062,6 +1064,7 @@ def find_covering(self, z1, z2, level=0): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.modular.btquotients.btquotient import BruhatTitsTree sage: p = 3 sage: K. = Qq(p^2) diff --git a/src/sage/modular/modform/space.py b/src/sage/modular/modform/space.py index 80326a77b8c..de2b0e74cda 100644 --- a/src/sage/modular/modform/space.py +++ b/src/sage/modular/modform/space.py @@ -1651,6 +1651,7 @@ def eisenstein_series(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], base_ring=QQ); M.eisenstein_series() Traceback (most recent call last): ... @@ -1837,6 +1838,7 @@ def modular_symbols(self, sign=0): EXAMPLES:: + sage: # needs sage.rings.number_field sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11), 2, DirichletGroup(1)[0], base_ring=QQ); M.modular_symbols() Traceback (most recent call last): ... diff --git a/src/sage/modular/modform_hecketriangle/abstract_space.py b/src/sage/modular/modform_hecketriangle/abstract_space.py index d1e23066aff..e0c4506122d 100644 --- a/src/sage/modular/modform_hecketriangle/abstract_space.py +++ b/src/sage/modular/modform_hecketriangle/abstract_space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs r""" Modular forms for Hecke triangle groups From a4513e8216fce03cdfc04ada6b3c61a53197ad81 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 11 Jun 2023 14:37:23 -0700 Subject: [PATCH 371/494] More # optional --- src/sage/combinat/quickref.py | 41 +++++++++++++++++++---------------- src/sage/combinat/sf/schur.py | 4 +++- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/sage/combinat/quickref.py b/src/sage/combinat/quickref.py index 351563cec6c..fcee7a8def6 100644 --- a/src/sage/combinat/quickref.py +++ b/src/sage/combinat/quickref.py @@ -3,9 +3,10 @@ Integer Sequences:: - sage: s = oeis([1,3,19,211]); s # optional - internet - 0: A000275: Coefficients of a Bessel function (reciprocal of J_0(z)); also pairs of permutations with rise/rise forbidden. - sage: s[0].programs() # optional - internet + sage: s = oeis([1,3,19,211]); s # optional - internet + 0: A000275: Coefficients of a Bessel function (reciprocal of J_0(z)); + also pairs of permutations with rise/rise forbidden. + sage: s[0].programs() # optional - internet [('maple', ...), ('mathematica', ...), ('pari', @@ -13,14 +14,14 @@ Combinatorial objects:: - sage: S = Subsets([1,2,3,4]); S.list(); S. # not tested - sage: P = Partitions(10000); P.cardinality() + sage: S = Subsets([1,2,3,4]); S.list(); S. # not tested + sage: P = Partitions(10000); P.cardinality() # optional - sage.libs.flint 3616...315650422081868605887952568754066420592310556052906916435144 - sage: Combinations([1,3,7]).random_element() # random - sage: Compositions(5, max_part = 3).unrank(3) + sage: Combinations([1,3,7]).random_element() # random + sage: Compositions(5, max_part=3).unrank(3) [2, 2, 1] - sage: DyckWord([1,0,1,0,1,1,0,0]).to_binary_tree() + sage: DyckWord([1,0,1,0,1,1,0,0]).to_binary_tree() # optional - sage.graphs [., [., [[., .], .]]] sage: Permutation([3,1,4,2]).robinson_schensted() [[[1, 2], [3, 4]], [[1, 3], [2, 4]]] @@ -30,7 +31,9 @@ Constructions and Species:: sage: for (p, s) in cartesian_product([P,S]): print((p, s)) # not tested - sage: DisjointUnionEnumeratedSets(Family(lambda n: IntegerVectors(n, 3), NonNegativeIntegers)) # not tested + sage: def IV_3(n): + ....: return IntegerVectors(n, 3) + sage: DisjointUnionEnumeratedSets(Family(IV_3, NonNegativeIntegers)) # not tested Words:: @@ -45,34 +48,34 @@ Polytopes:: sage: points = random_matrix(ZZ, 6, 3, x=7).rows() - sage: L = LatticePolytope(points) - sage: L.npoints(); L.plot3d() # random # optional - sage.plot + sage: L = LatticePolytope(points) # optional - sage.geometry.polyhedron + sage: L.npoints(); L.plot3d() # random # optional - sage.geometry.polyhedron sage.plot :ref:`Root systems, Coxeter and Weyl groups `:: - sage: WeylGroup(["B",3]).bruhat_poset() + sage: WeylGroup(["B",3]).bruhat_poset() # optional - sage.graphs sage.modules Finite poset containing 48 elements - sage: RootSystem(["A",2,1]).weight_lattice().plot() # not tested + sage: RootSystem(["A",2,1]).weight_lattice().plot() # not tested # optional - sage.graphs sage.modules sage.plot :ref:`Crystals `:: - sage: CrystalOfTableaux(["A",3], shape = [3,2]).some_flashy_feature() # not tested + sage: CrystalOfTableaux(["A",3], shape=[3,2]).some_flashy_feature() # not tested :mod:`Symmetric functions and combinatorial Hopf algebras `:: - sage: Sym = SymmetricFunctions(QQ); Sym.inject_shorthands(verbose=False) - sage: m( ( h[2,1] * (1 + 3 * p[2,1]) ) + s[2](s[3]) ) + sage: Sym = SymmetricFunctions(QQ); Sym.inject_shorthands(verbose=False) # optional - sage.sage.modules + sage: m( ( h[2,1] * (1 + 3 * p[2,1]) ) + s[2](s[3]) ) # optional - sage.sage.modules 3*m[1, 1, 1] + ... + 10*m[5, 1] + 4*m[6] :ref:`Discrete groups, Permutation groups `:: - sage: S = SymmetricGroup(4) + sage: S = SymmetricGroup(4) # optional - sage.groups sage: M = PolynomialRing(QQ, 'x0,x1,x2,x3') - sage: M.an_element() * S.an_element() + sage: M.an_element() * S.an_element() # optional - sage.groups x0 Graph theory, posets, lattices (:ref:`sage.graphs`, :ref:`sage.combinat.posets.all`):: - sage: Poset({1: [2,3], 2: [4], 3: [4]}).linear_extensions().cardinality() + sage: Poset({1: [2,3], 2: [4], 3: [4]}).linear_extensions().cardinality() # optional - sage.graphs sage.modules 2 """ diff --git a/src/sage/combinat/sf/schur.py b/src/sage/combinat/sf/schur.py index 283a43001a7..e6bb052c408 100644 --- a/src/sage/combinat/sf/schur.py +++ b/src/sage/combinat/sf/schur.py @@ -19,14 +19,16 @@ # **************************************************************************** from . import classical -import sage.libs.lrcalc.lrcalc as lrcalc from sage.misc.misc_c import prod +from sage.misc.lazy_import import lazy_import from sage.data_structures.blas_dict import convert_remove_zeroes from sage.rings.infinity import infinity from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.arith.misc import factorial from sage.combinat.tableau import StandardTableaux +lazy_import('sage.libs.lrcalc', 'lrcalc') + class SymmetricFunctionAlgebra_schur(classical.SymmetricFunctionAlgebra_classical): def __init__(self, Sym): From 0c7ac916be229d2d871622c059838abec3fafcce Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 17 Jun 2023 08:55:25 -0700 Subject: [PATCH 372/494] src/sage/combinat/crystals/affine_factorization.py: Fix import --- src/sage/combinat/crystals/affine_factorization.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/combinat/crystals/affine_factorization.py b/src/sage/combinat/crystals/affine_factorization.py index b1d820032af..1e6ea23eded 100644 --- a/src/sage/combinat/crystals/affine_factorization.py +++ b/src/sage/combinat/crystals/affine_factorization.py @@ -10,6 +10,7 @@ #****************************************************************************** from sage.misc.lazy_attribute import lazy_attribute +from sage.misc.lazy_import import lazy_import from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper from sage.structure.unique_representation import UniqueRepresentation From f5342b62f49dc5c3438b2e7446f9160efa862e23 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 17 Jun 2023 11:09:33 -0700 Subject: [PATCH 373/494] src/sage/combinat/crystals/littelmann_path.py: Fix import --- src/sage/combinat/crystals/littelmann_path.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index a90a61cb4c9..719f25e7071 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -27,6 +27,7 @@ # *************************************************************************** from sage.misc.cachefunc import cached_in_parent_method, cached_method +from sage.misc.lazy_import import lazy_import from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper from sage.structure.parent import Parent From d145d3ee4b6078d47be58baa58ccdfcfc09d1d71 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 30 Jun 2023 12:39:36 -0700 Subject: [PATCH 374/494] ./sage -fixdoctests --only-tags src/sage/combinat/permutation.py --- src/sage/combinat/permutation.py | 552 +++++++++++++++---------------- 1 file changed, 276 insertions(+), 276 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index eb3e451b0ff..00cf325805f 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -396,8 +396,8 @@ class Permutation(CombinatorialElement): We construct a :class:`Permutation` from a :class:`PermutationGroupElement`:: - sage: g = PermutationGroupElement([2,1,3]) # optional - sage.groups - sage: Permutation(g) # optional - sage.groups + sage: g = PermutationGroupElement([2,1,3]) # needs sage.groups + sage: Permutation(g) # needs sage.groups [2, 1, 3] From a pair of tableaux of the same shape. This uses the inverse @@ -405,15 +405,15 @@ class Permutation(CombinatorialElement): sage: p = [[1, 4, 7], [2, 5], [3], [6]] sage: q = [[1, 2, 5], [3, 6], [4], [7]] - sage: P = Tableau(p) # optional - sage.combinat - sage: Q = Tableau(q) # optional - sage.combinat - sage: Permutation( (p, q) ) # optional - sage.combinat + sage: P = Tableau(p) # needs sage.combinat + sage: Q = Tableau(q) # needs sage.combinat + sage: Permutation( (p, q) ) # needs sage.combinat [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( [p, q] ) # optional - sage.combinat + sage: Permutation( [p, q] ) # needs sage.combinat [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( (P, Q) ) # optional - sage.combinat + sage: Permutation( (P, Q) ) # needs sage.combinat [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( [P, Q] ) # optional - sage.combinat + sage: Permutation( [P, Q] ) # needs sage.combinat [3, 6, 5, 2, 7, 4, 1] TESTS:: @@ -429,9 +429,9 @@ class Permutation(CombinatorialElement): From a pair of empty tableaux :: - sage: Permutation( ([], []) ) # optional - sage.combinat + sage: Permutation( ([], []) ) # needs sage.combinat [] - sage: Permutation( [[], []] ) # optional - sage.combinat + sage: Permutation( [[], []] ) # needs sage.combinat [] """ @staticmethod @@ -702,11 +702,11 @@ def _gap_(self, gap): EXAMPLES:: - sage: gap(Permutation([1,2,3])) # optional - sage.libs.gap + sage: gap(Permutation([1,2,3])) # needs sage.libs.gap () - sage: gap(Permutation((1,2,3))) # optional - sage.libs.gap + sage: gap(Permutation((1,2,3))) # needs sage.libs.gap (1,2,3) - sage: type(_) # optional - sage.libs.gap + sage: type(_) # needs sage.libs.gap """ return self.to_permutation_group_element()._gap_(gap) @@ -870,9 +870,9 @@ def to_tableau_by_shape(self, shape): EXAMPLES:: - sage: T = Permutation([3,4,1,2,5]).to_tableau_by_shape([3,2]); T # optional - sage.combinat + sage: T = Permutation([3,4,1,2,5]).to_tableau_by_shape([3,2]); T # needs sage.combinat [[1, 2, 5], [3, 4]] - sage: T.reading_word_permutation() # optional - sage.combinat + sage: T.reading_word_permutation() # needs sage.combinat [3, 4, 1, 2, 5] """ if sum(shape) != len(self): @@ -1141,9 +1141,9 @@ def to_permutation_group_element(self): EXAMPLES:: - sage: Permutation([2,1,4,3]).to_permutation_group_element() # optional - sage.groups + sage: Permutation([2,1,4,3]).to_permutation_group_element() # needs sage.groups (1,2)(3,4) - sage: Permutation([1,2,3]).to_permutation_group_element() # optional - sage.groups + sage: Permutation([1,2,3]).to_permutation_group_element() # needs sage.groups () """ grp = SymmetricGroup(len(self)) @@ -1192,14 +1192,14 @@ def to_matrix(self): EXAMPLES:: - sage: Permutation([1,2,3]).to_matrix() # optional - sage.modules + sage: Permutation([1,2,3]).to_matrix() # needs sage.modules [1 0 0] [0 1 0] [0 0 1] Alternatively:: - sage: matrix(Permutation([1,3,2])) # optional - sage.modules + sage: matrix(Permutation([1,3,2])) # needs sage.modules [1 0 0] [0 0 1] [0 1 0] @@ -1212,16 +1212,16 @@ def to_matrix(self): sage: Permutations.options.mult='r2l' sage: p = Permutation([2,1,3]) sage: q = Permutation([3,1,2]) - sage: (p*q).to_matrix() # optional - sage.modules + sage: (p*q).to_matrix() # needs sage.modules [0 0 1] [0 1 0] [1 0 0] - sage: p.to_matrix()*q.to_matrix() # optional - sage.modules + sage: p.to_matrix()*q.to_matrix() # needs sage.modules [0 0 1] [0 1 0] [1 0 0] sage: Permutations.options.mult='l2r' - sage: (p*q).to_matrix() # optional - sage.modules + sage: (p*q).to_matrix() # needs sage.modules [1 0 0] [0 0 1] [0 1 0] @@ -1242,11 +1242,11 @@ def to_alternating_sign_matrix(self): EXAMPLES:: - sage: m = Permutation([1,2,3]).to_alternating_sign_matrix(); m # optional - sage.combinat sage.modules + sage: m = Permutation([1,2,3]).to_alternating_sign_matrix(); m # needs sage.combinat sage.modules [1 0 0] [0 1 0] [0 0 1] - sage: parent(m) # optional - sage.combinat sage.modules + sage: parent(m) # needs sage.combinat sage.modules Alternating sign matrices of size 3 """ from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix @@ -1256,12 +1256,12 @@ def __mul__(self, rp): """ TESTS:: - sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat sage.modules - sage: SM = SGA.specht_module([2,1]) # optional - sage.combinat sage.modules - sage: p213 = Permutations(3)([2,1,3]) # optional - sage.combinat sage.modules - sage: p213 * SGA.an_element() # optional - sage.combinat sage.modules + sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.modules + sage: SM = SGA.specht_module([2,1]) # needs sage.combinat sage.modules + sage: p213 = Permutations(3)([2,1,3]) # needs sage.combinat sage.modules + sage: p213 * SGA.an_element() # needs sage.combinat sage.modules 3*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 2*[3, 1, 2] - sage: p213 * SM.an_element() # optional - sage.combinat sage.modules + sage: p213 * SM.an_element() # needs sage.combinat sage.modules 2*B[0] - 4*B[1] """ if not isinstance(rp, Permutation) and isinstance(rp, Element): @@ -1301,8 +1301,8 @@ def __rmul__(self, lp) -> Permutation: [3, 2, 1] sage: Permutations.options.mult='l2r' - sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat sage.modules - sage: SGA.an_element() * Permutations(3)(p213) # optional - sage.combinat sage.modules + sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.modules + sage: SGA.an_element() * Permutations(3)(p213) # needs sage.combinat sage.modules 3*[1, 2, 3] + [2, 1, 3] + 2*[2, 3, 1] + [3, 2, 1] """ if not isinstance(lp, Permutation) and isinstance(lp, Element): @@ -1682,19 +1682,19 @@ def to_digraph(self) -> DiGraph: EXAMPLES:: - sage: d = Permutation([3, 1, 2]).to_digraph() # optional - sage.graphs - sage: d.edges(sort=True, labels=False) # optional - sage.graphs + sage: d = Permutation([3, 1, 2]).to_digraph() # needs sage.graphs + sage: d.edges(sort=True, labels=False) # needs sage.graphs [(1, 3), (2, 1), (3, 2)] sage: P = Permutations(range(1, 10)) - sage: d = Permutation(P.random_element()).to_digraph() # optional - sage.graphs - sage: all(c.is_cycle() # optional - sage.graphs + sage: d = Permutation(P.random_element()).to_digraph() # needs sage.graphs + sage: all(c.is_cycle() # needs sage.graphs ....: for c in d.strongly_connected_components_subgraphs()) True TESTS:: - sage: d = Permutation([1]).to_digraph() # optional - sage.graphs - sage: d.edges(sort=True, labels=False) # optional - sage.graphs + sage: d = Permutation([1]).to_digraph() # needs sage.graphs + sage: d.edges(sort=True, labels=False) # needs sage.graphs [(1, 1)] """ return DiGraph([self, enumerate(self, start=1)], @@ -1726,10 +1726,10 @@ def show(self, representation="cycles", orientation="landscape", **args): EXAMPLES:: sage: P20 = Permutations(20) - sage: P20.random_element().show(representation="cycles") # optional - sage.graphs sage.plot - sage: P20.random_element().show(representation="chord-diagram") # optional - sage.graphs sage.plot - sage: P20.random_element().show(representation="braid") # optional - sage.plot - sage: P20.random_element().show(representation="braid", # optional - sage.plot + sage: P20.random_element().show(representation="cycles") # needs sage.graphs sage.plot + sage: P20.random_element().show(representation="chord-diagram") # needs sage.graphs sage.plot + sage: P20.random_element().show(representation="braid") # needs sage.plot + sage: P20.random_element().show(representation="braid", # needs sage.plot ....: orientation='portrait') TESTS:: @@ -1913,7 +1913,7 @@ def absolute_length(self) -> Integer: EXAMPLES:: - sage: Permutation([4,2,3,1]).absolute_length() # optional - sage.combinat + sage: Permutation([4,2,3,1]).absolute_length() # needs sage.combinat 1 """ return self.size() - len(self.cycle_type()) @@ -2222,7 +2222,7 @@ def longest_increasing_subsequence_length(self) -> Integer: sage: Permutation([2,3,1,4]).longest_increasing_subsequence_length() 3 - sage: all(i.longest_increasing_subsequence_length() == len(RSK(i)[0][0]) # optional - sage.combinat + sage: all(i.longest_increasing_subsequence_length() == len(RSK(i)[0][0]) # needs sage.combinat ....: for i in Permutations(5)) True sage: Permutation([]).longest_increasing_subsequence_length() @@ -2254,9 +2254,9 @@ def longest_increasing_subsequences(self): EXAMPLES:: - sage: Permutation([2,3,4,1]).longest_increasing_subsequences() # optional - sage.graphs + sage: Permutation([2,3,4,1]).longest_increasing_subsequences() # needs sage.graphs [[2, 3, 4]] - sage: Permutation([5, 7, 1, 2, 6, 4, 3]).longest_increasing_subsequences() # optional - sage.graphs + sage: Permutation([5, 7, 1, 2, 6, 4, 3]).longest_increasing_subsequences() # needs sage.graphs [[1, 2, 6], [1, 2, 4], [1, 2, 3]] .. NOTE:: @@ -2324,7 +2324,7 @@ def longest_increasing_subsequences_number(self): 120770 sage: p = Permutations(50).random_element() - sage: (len(p.longest_increasing_subsequences()) == # optional - sage.graphs + sage: (len(p.longest_increasing_subsequences()) == # needs sage.graphs ....: p.longest_increasing_subsequences_number()) True """ @@ -2363,7 +2363,7 @@ def cycle_type(self): EXAMPLES:: - sage: Permutation([3,1,2,4]).cycle_type() # optional - sage.combinat + sage: Permutation([3,1,2,4]).cycle_type() # needs sage.combinat [3, 1] """ cycle_type = [len(c) for c in self.to_cycles()] @@ -2421,9 +2421,9 @@ def forget_cycles(self): results as a poset under the Bruhat order:: sage: l = [p.forget_cycles().inverse() for p in l] - sage: B = Poset([l, lambda x,y: x.bruhat_lequal(y)]) # optional - sage.combinat sage.graphs + sage: B = Poset([l, lambda x,y: x.bruhat_lequal(y)]) # needs sage.combinat sage.graphs sage: R. = QQ[] - sage: sum(q^B.rank_function()(x) for x in B) # optional - sage.combinat sage.graphs + sage: sum(q^B.rank_function()(x) for x in B) # needs sage.combinat sage.graphs q^5 + 2*q^4 + 3*q^3 + 3*q^2 + 2*q + 1 We check the statement in [CC2013]_ that the posets @@ -2431,8 +2431,8 @@ def forget_cycles(self): sage: l2 = [p for p in P if [len(t) for t in p.to_cycles()] == [1,3,1,1]] sage: l2 = [p.forget_cycles().inverse() for p in l2] - sage: B2 = Poset([l2, lambda x,y: x.bruhat_lequal(y)]) # optional - sage.combinat sage.graphs - sage: B.is_isomorphic(B2) # optional - sage.combinat sage.graphs + sage: B2 = Poset([l2, lambda x,y: x.bruhat_lequal(y)]) # needs sage.combinat sage.graphs + sage: B.is_isomorphic(B2) # needs sage.combinat sage.graphs True .. SEEALSO:: @@ -2758,7 +2758,7 @@ def destandardize(self, weight, ordered_alphabet=None): EXAMPLES:: sage: p = Permutation([1,2,5,3,6,4]) - sage: p.destandardize([3,1,2]) # optional - sage.combinat + sage: p.destandardize([3,1,2]) # needs sage.combinat word: 113132 sage: p = Permutation([2,1,3]) sage: p.destandardize([2,1]) @@ -2769,7 +2769,7 @@ def destandardize(self, weight, ordered_alphabet=None): TESTS:: sage: p = Permutation([4,1,2,3,5,6]) - sage: p.destandardize([2,1,3], ordered_alphabet = [1,'a',3]) # optional - sage.combinat + sage: p.destandardize([2,1,3], ordered_alphabet = [1,'a',3]) # needs sage.combinat word: 311a33 sage: p.destandardize([2,1,3], ordered_alphabet = [1,'a']) Traceback (most recent call last): @@ -3028,9 +3028,9 @@ def rothe_diagram(self): EXAMPLES:: sage: p = Permutation([4,2,1,3]) - sage: D = p.rothe_diagram(); D # optional - sage.combinat + sage: D = p.rothe_diagram(); D # needs sage.combinat [(0, 0), (0, 1), (0, 2), (1, 0)] - sage: D.pp() # optional - sage.combinat + sage: D.pp() # needs sage.combinat O O O . O . . . . . . . @@ -3047,7 +3047,7 @@ def number_of_reduced_words(self): EXAMPLES:: sage: p = Permutation([6,4,2,5,1,8,3,7]) - sage: len(p.reduced_words()) == p.number_of_reduced_words() # optional - sage.combinat + sage: len(p.reduced_words()) == p.number_of_reduced_words() # needs sage.combinat True """ Tx = self.rothe_diagram().peelable_tableaux() @@ -4231,7 +4231,7 @@ def right_permutohedron_interval_iterator(self, other): EXAMPLES:: sage: p = Permutation([2, 1, 4, 5, 3]); q = Permutation([2, 5, 4, 1, 3]) - sage: p.right_permutohedron_interval(q) # indirect doctest # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: p.right_permutohedron_interval(q) # indirect doctest # needs sage.graphs sage.modules [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] """ @@ -4258,27 +4258,27 @@ def right_permutohedron_interval(self, other): EXAMPLES:: sage: p = Permutation([2, 1, 4, 5, 3]); q = Permutation([2, 5, 4, 1, 3]) - sage: p.right_permutohedron_interval(q) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: p.right_permutohedron_interval(q) # needs sage.graphs sage.modules [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] TESTS:: - sage: Permutation([]).right_permutohedron_interval(Permutation([])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([]).right_permutohedron_interval(Permutation([])) # needs sage.graphs sage.modules [[]] - sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) # needs sage.graphs sage.modules [[3, 1, 2]] - sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) # needs sage.graphs sage.modules [[3, 1, 4, 2], [3, 4, 1, 2], [3, 4, 2, 1], [1, 3, 4, 2], [1, 3, 2, 4], [3, 2, 4, 1], [3, 2, 1, 4], [3, 1, 2, 4]] - sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # needs sage.graphs sage.modules [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] - sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.graphs sage.modules Traceback (most recent call last): ... ValueError: [2, 5, 4, 1, 3] must be lower or equal than [2, 1, 4, 5, 3] for the right permutohedron order - sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.graphs sage.modules Traceback (most recent call last): ... ValueError: len([2, 4, 1, 3]) and len([2, 1, 4, 5, 3]) must be equal @@ -4517,7 +4517,7 @@ def has_pattern(self, patt) -> bool: EXAMPLES:: - sage: Permutation([3,5,1,4,6,2]).has_pattern([1,3,2]) # optional - sage.combinat + sage: Permutation([3,5,1,4,6,2]).has_pattern([1,3,2]) # needs sage.combinat True """ p = self @@ -4537,11 +4537,11 @@ def avoids(self, patt) -> bool: EXAMPLES:: - sage: Permutation([6,2,5,4,3,1]).avoids([4,2,3,1]) # optional - sage.combinat + sage: Permutation([6,2,5,4,3,1]).avoids([4,2,3,1]) # needs sage.combinat False - sage: Permutation([6,1,2,5,4,3]).avoids([4,2,3,1]) # optional - sage.combinat + sage: Permutation([6,1,2,5,4,3]).avoids([4,2,3,1]) # needs sage.combinat True - sage: Permutation([6,1,2,5,4,3]).avoids([3,4,1,2]) # optional - sage.combinat + sage: Permutation([6,1,2,5,4,3]).avoids([3,4,1,2]) # needs sage.combinat True """ return not self.has_pattern(patt) @@ -4553,7 +4553,7 @@ def pattern_positions(self, patt) -> list: EXAMPLES:: - sage: Permutation([3,5,1,4,6,2]).pattern_positions([1,3,2]) # optional - sage.combinat + sage: Permutation([3,5,1,4,6,2]).pattern_positions([1,3,2]) # needs sage.combinat [[0, 1, 3], [2, 3, 5], [2, 4, 5]] """ p = self @@ -4578,7 +4578,7 @@ def simion_schmidt(self, avoid=[1,2,3]): sage: P = Permutations(6) sage: p = P([4,5,1,6,3,2]) sage: pl = [ [1,2,3], [1,3,2], [3,1,2], [3,2,1] ] - sage: for q in pl: # optional - sage.combinat + sage: for q in pl: # needs sage.combinat ....: s = p.simion_schmidt(q) ....: print("{} {}".format(s, s.has_pattern(q))) [4, 6, 1, 5, 3, 2] False @@ -4662,23 +4662,23 @@ def permutation_poset(self): EXAMPLES:: - sage: Permutation([3,1,5,4,2]).permutation_poset().cover_relations() # optional - sage.combinat sage.graphs + sage: Permutation([3,1,5,4,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs [[(2, 1), (5, 2)], [(2, 1), (3, 5)], [(2, 1), (4, 4)], [(1, 3), (3, 5)], [(1, 3), (4, 4)]] - sage: Permutation([]).permutation_poset().cover_relations() # optional - sage.combinat sage.graphs + sage: Permutation([]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs [] - sage: Permutation([1,3,2]).permutation_poset().cover_relations() # optional - sage.combinat sage.graphs + sage: Permutation([1,3,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs [[(1, 1), (2, 3)], [(1, 1), (3, 2)]] - sage: Permutation([1,2]).permutation_poset().cover_relations() # optional - sage.combinat sage.graphs + sage: Permutation([1,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs [[(1, 1), (2, 2)]] - sage: P = Permutation([1,5,2,4,3]) # optional - sage.combinat sage.graphs + sage: P = Permutation([1,5,2,4,3]) # needs sage.combinat sage.graphs This should hold for any `P`:: - sage: P.permutation_poset().greene_shape() == P.RS_partition() # optional - sage.combinat sage.graphs + sage: P.permutation_poset().greene_shape() == P.RS_partition() # needs sage.combinat sage.graphs True """ from sage.combinat.posets.posets import Poset @@ -4750,7 +4750,7 @@ def robinson_schensted(self): EXAMPLES:: - sage: Permutation([6,2,3,1,7,5,4]).robinson_schensted() # optional - sage.combinat + sage: Permutation([6,2,3,1,7,5,4]).robinson_schensted() # needs sage.combinat [[[1, 3, 4], [2, 5], [6, 7]], [[1, 3, 5], [2, 6], [4, 7]]] """ return RSK(self, check_standard=True) @@ -4782,7 +4782,7 @@ def left_tableau(self): EXAMPLES:: - sage: Permutation([1,4,3,2]).left_tableau() # optional - sage.combinat + sage: Permutation([1,4,3,2]).left_tableau() # needs sage.combinat [[1, 2], [3], [4]] """ return RSK(self, check_standard=True)[0] @@ -4795,7 +4795,7 @@ def right_tableau(self): EXAMPLES:: - sage: Permutation([1,4,3,2]).right_tableau() # optional - sage.combinat + sage: Permutation([1,4,3,2]).right_tableau() # needs sage.combinat [[1, 2], [3], [4]] """ return RSK(self, check_standard=True)[1] @@ -4806,17 +4806,17 @@ def increasing_tree(self, compare=min): EXAMPLES:: - sage: Permutation([1,4,3,2]).increasing_tree() # optional - sage.graphs + sage: Permutation([1,4,3,2]).increasing_tree() # needs sage.graphs 1[., 2[3[4[., .], .], .]] - sage: Permutation([4,1,3,2]).increasing_tree() # optional - sage.graphs + sage: Permutation([4,1,3,2]).increasing_tree() # needs sage.graphs 1[4[., .], 2[3[., .], .]] By passing the option ``compare=max`` one can have the decreasing tree instead:: - sage: Permutation([2,3,4,1]).increasing_tree(max) # optional - sage.graphs + sage: Permutation([2,3,4,1]).increasing_tree(max) # needs sage.graphs 4[3[2[., .], .], 1[., .]] - sage: Permutation([2,3,1,4]).increasing_tree(max) # optional - sage.graphs + sage: Permutation([2,3,1,4]).increasing_tree(max) # needs sage.graphs 4[3[2[., .], 1[., .]], .] """ from sage.combinat.binary_tree import LabelledBinaryTree as LBT @@ -4837,17 +4837,17 @@ def increasing_tree_shape(self, compare=min): EXAMPLES:: - sage: Permutation([1,4,3,2]).increasing_tree_shape() # optional - sage.graphs + sage: Permutation([1,4,3,2]).increasing_tree_shape() # needs sage.graphs [., [[[., .], .], .]] - sage: Permutation([4,1,3,2]).increasing_tree_shape() # optional - sage.graphs + sage: Permutation([4,1,3,2]).increasing_tree_shape() # needs sage.graphs [[., .], [[., .], .]] By passing the option ``compare=max`` one can have the decreasing tree instead:: - sage: Permutation([2,3,4,1]).increasing_tree_shape(max) # optional - sage.graphs + sage: Permutation([2,3,4,1]).increasing_tree_shape(max) # needs sage.graphs [[[., .], .], [., .]] - sage: Permutation([2,3,1,4]).increasing_tree_shape(max) # optional - sage.graphs + sage: Permutation([2,3,1,4]).increasing_tree_shape(max) # needs sage.graphs [[[., .], [., .]], .] """ return self.increasing_tree(compare).shape() @@ -4873,22 +4873,22 @@ def binary_search_tree(self, left_to_right=True): EXAMPLES:: - sage: Permutation([1,4,3,2]).binary_search_tree() # optional - sage.graphs + sage: Permutation([1,4,3,2]).binary_search_tree() # needs sage.graphs 1[., 4[3[2[., .], .], .]] - sage: Permutation([4,1,3,2]).binary_search_tree() # optional - sage.graphs + sage: Permutation([4,1,3,2]).binary_search_tree() # needs sage.graphs 4[1[., 3[2[., .], .]], .] By passing the option ``left_to_right=False`` one can have the insertion going from right to left:: - sage: Permutation([1,4,3,2]).binary_search_tree(False) # optional - sage.graphs + sage: Permutation([1,4,3,2]).binary_search_tree(False) # needs sage.graphs 2[1[., .], 3[., 4[., .]]] - sage: Permutation([4,1,3,2]).binary_search_tree(False) # optional - sage.graphs + sage: Permutation([4,1,3,2]).binary_search_tree(False) # needs sage.graphs 2[1[., .], 3[., 4[., .]]] TESTS:: - sage: Permutation([]).binary_search_tree() # optional - sage.graphs + sage: Permutation([]).binary_search_tree() # needs sage.graphs . """ from sage.combinat.binary_tree import LabelledBinaryTree as LBT @@ -4909,17 +4909,17 @@ def binary_search_tree_shape(self, left_to_right=True): EXAMPLES:: - sage: Permutation([1,4,3,2]).binary_search_tree_shape() # optional - sage.graphs + sage: Permutation([1,4,3,2]).binary_search_tree_shape() # needs sage.graphs [., [[[., .], .], .]] - sage: Permutation([4,1,3,2]).binary_search_tree_shape() # optional - sage.graphs + sage: Permutation([4,1,3,2]).binary_search_tree_shape() # needs sage.graphs [[., [[., .], .]], .] By passing the option ``left_to_right=False`` one can have the insertion going from right to left:: - sage: Permutation([1,4,3,2]).binary_search_tree_shape(False) # optional - sage.graphs + sage: Permutation([1,4,3,2]).binary_search_tree_shape(False) # needs sage.graphs [[., .], [., [., .]]] - sage: Permutation([4,1,3,2]).binary_search_tree_shape(False) # optional - sage.graphs + sage: Permutation([4,1,3,2]).binary_search_tree_shape(False) # needs sage.graphs [[., .], [., [., .]]] """ from sage.combinat.binary_tree import binary_search_tree_shape @@ -4966,7 +4966,7 @@ def sylvester_class(self, left_to_right=False): The sylvester class of a permutation in `S_5`:: sage: p = Permutation([3, 5, 1, 2, 4]) - sage: sorted(p.sylvester_class()) # optional - sage.combinat + sage: sorted(p.sylvester_class()) # needs sage.combinat sage.graphs [[1, 3, 2, 5, 4], [1, 3, 5, 2, 4], [1, 5, 3, 2, 4], @@ -4978,20 +4978,20 @@ def sylvester_class(self, left_to_right=False): The sylvester class of a permutation `p` contains `p`:: - sage: all(p in p.sylvester_class() for p in Permutations(4)) # optional - sage.combinat sage.graphs + sage: all(p in p.sylvester_class() for p in Permutations(4)) # needs sage.combinat sage.graphs True Small cases:: - sage: list(Permutation([]).sylvester_class()) # optional - sage.combinat sage.graphs + sage: list(Permutation([]).sylvester_class()) # needs sage.combinat sage.graphs [[]] - sage: list(Permutation([1]).sylvester_class()) # optional - sage.combinat sage.graphs + sage: list(Permutation([1]).sylvester_class()) # needs sage.combinat sage.graphs [[1]] The sylvester classes in `S_3`:: - sage: [sorted(p.sylvester_class()) for p in Permutations(3)] # optional - sage.combinat sage.graphs + sage: [sorted(p.sylvester_class()) for p in Permutations(3)] # needs sage.combinat sage.graphs [[[1, 2, 3]], [[1, 3, 2], [3, 1, 2]], [[2, 1, 3]], @@ -5001,7 +5001,7 @@ def sylvester_class(self, left_to_right=False): The left sylvester classes in `S_3`:: - sage: [sorted(p.sylvester_class(left_to_right=True)) # optional - sage.combinat sage.graphs + sage: [sorted(p.sylvester_class(left_to_right=True)) # needs sage.combinat sage.graphs ....: for p in Permutations(3)] [[[1, 2, 3]], [[1, 3, 2]], @@ -5013,7 +5013,7 @@ def sylvester_class(self, left_to_right=False): A left sylvester class in `S_5`:: sage: p = Permutation([4, 2, 1, 5, 3]) - sage: sorted(p.sylvester_class(left_to_right=True)) # optional - sage.combinat sage.graphs + sage: sorted(p.sylvester_class(left_to_right=True)) # needs sage.combinat sage.graphs [[4, 2, 1, 3, 5], [4, 2, 1, 5, 3], [4, 2, 3, 1, 5], @@ -5036,7 +5036,7 @@ def RS_partition(self): EXAMPLES:: - sage: Permutation([1,4,3,2]).RS_partition() # optional - sage.combinat + sage: Permutation([1,4,3,2]).RS_partition() # needs sage.combinat [2, 1, 1] """ return RSK(self)[1].shape() @@ -5259,15 +5259,15 @@ def hyperoctahedral_double_coset_type(self): EXAMPLES:: sage: p = Permutation([3, 4, 6, 1, 5, 7, 2, 8]) - sage: p.hyperoctahedral_double_coset_type() # optional - sage.combinat + sage: p.hyperoctahedral_double_coset_type() # needs sage.combinat [3, 1] - sage: all(p.hyperoctahedral_double_coset_type() == # optional - sage.combinat + sage: all(p.hyperoctahedral_double_coset_type() == # needs sage.combinat ....: p.inverse().hyperoctahedral_double_coset_type() ....: for p in Permutations(4)) True - sage: Permutation([]).hyperoctahedral_double_coset_type() # optional - sage.combinat + sage: Permutation([]).hyperoctahedral_double_coset_type() # needs sage.combinat [] - sage: Permutation([3,1,2]).hyperoctahedral_double_coset_type() # optional - sage.combinat + sage: Permutation([3,1,2]).hyperoctahedral_double_coset_type() # needs sage.combinat Traceback (most recent call last): ... ValueError: [3, 1, 2] is a permutation of odd size and has no coset-type @@ -5344,23 +5344,23 @@ def shifted_shuffle(self, other): EXAMPLES:: - sage: Permutation([]).shifted_shuffle(Permutation([])) # optional - sage.graphs + sage: Permutation([]).shifted_shuffle(Permutation([])) # needs sage.graphs [[]] - sage: Permutation([1, 2, 3]).shifted_shuffle(Permutation([1])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([1, 2, 3]).shifted_shuffle(Permutation([1])) # needs sage.graphs sage.modules [[4, 1, 2, 3], [1, 2, 3, 4], [1, 2, 4, 3], [1, 4, 2, 3]] - sage: Permutation([1, 2]).shifted_shuffle(Permutation([2, 1])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([1, 2]).shifted_shuffle(Permutation([2, 1])) # needs sage.graphs sage.modules [[4, 1, 3, 2], [4, 3, 1, 2], [1, 4, 3, 2], [1, 4, 2, 3], [1, 2, 4, 3], [4, 1, 2, 3]] - sage: Permutation([1]).shifted_shuffle([1]) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutation([1]).shifted_shuffle([1]) # needs sage.graphs sage.modules [[2, 1], [1, 2]] sage: p = Permutation([3, 1, 5, 4, 2]) - sage: len(p.shifted_shuffle(Permutation([2, 1, 4, 3]))) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: len(p.shifted_shuffle(Permutation([2, 1, 4, 3]))) # needs sage.graphs sage.modules 126 The shifted shuffle product is associative. We can test this on an admittedly toy example:: - sage: all( all( all( sorted(flatten([abs.shifted_shuffle(c) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: all( all( all( sorted(flatten([abs.shifted_shuffle(c) # needs sage.graphs sage.modules ....: for abs in a.shifted_shuffle(b)])) ....: == sorted(flatten([a.shifted_shuffle(bcs) ....: for bcs in b.shifted_shuffle(c)])) @@ -5373,7 +5373,7 @@ def shifted_shuffle(self, other): permutations as the ``shifted_shuffle`` method on words (but is faster):: - sage: all( all( sorted(p1.shifted_shuffle(p2)) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: all( all( sorted(p1.shifted_shuffle(p2)) # needs sage.graphs sage.modules sage.rings.finite_rings ....: == sorted([Permutation(p) for p in ....: Word(p1).shifted_shuffle(Word(p2))]) ....: for p2 in Permutations(3) ) @@ -5390,9 +5390,9 @@ def _tableau_contribution(T): EXAMPLES:: - sage: T = Tableau([[1,1,1],[2]]) # optional - sage.combinat + sage: T = Tableau([[1,1,1],[2]]) # needs sage.combinat sage: from sage.combinat.permutation import _tableau_contribution - sage: _tableau_contribution(T) # optional - sage.combinat + sage: _tableau_contribution(T) # needs sage.combinat 3 """ from sage.combinat.tableau import StandardTableaux @@ -5482,7 +5482,7 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations(['c', 'a', 't'], 2); p Permutations of the set ['c', 'a', 't'] of length 2 - sage: p.list() # optional - sage.libs.gap + sage: p.list() # needs sage.libs.gap [['c', 'a'], ['c', 't'], ['a', 'c'], ['a', 't'], ['t', 'c'], ['t', 'a']] :: @@ -5496,14 +5496,14 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations([1,1,2], 2); p Permutations of the multi-set [1, 1, 2] of length 2 - sage: p.list() # optional - sage.libs.gap + sage: p.list() # needs sage.libs.gap [[1, 1], [1, 2], [2, 1]] :: sage: p = Permutations(descents=([1], 4)); p Standard permutations of 4 with descents [1] - sage: p.list() # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: p.list() # needs sage.graphs sage.modules [[2, 4, 1, 3], [3, 4, 1, 2], [1, 4, 2, 3], [1, 3, 2, 4], [2, 3, 1, 4]] :: @@ -5526,28 +5526,28 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations(recoils_finer=[2,1]); p Standard permutations whose recoils composition is finer than [2, 1] - sage: p.list() # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: p.list() # needs sage.graphs sage.modules [[3, 1, 2], [1, 2, 3], [1, 3, 2]] :: sage: p = Permutations(recoils_fatter=[2,1]); p Standard permutations whose recoils composition is fatter than [2, 1] - sage: p.list() # optional - sage.graphs + sage: p.list() # needs sage.graphs sage.modules [[3, 1, 2], [3, 2, 1], [1, 3, 2]] :: sage: p = Permutations(recoils=[2,1]); p Standard permutations whose recoils composition is [2, 1] - sage: p.list() # optional - sage.graphs + sage: p.list() # needs sage.graphs sage.modules [[3, 1, 2], [1, 3, 2]] :: sage: p = Permutations(4, avoiding=[1,3,2]); p Standard permutations of 4 avoiding [[1, 3, 2]] - sage: p.list() # optional - sage.combinat + sage: p.list() # needs sage.combinat [[4, 1, 2, 3], [4, 2, 1, 3], [4, 2, 3, 1], @@ -5567,9 +5567,9 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations(5, avoiding=[[3,4,1,2], [4,2,3,1]]); p Standard permutations of 5 avoiding [[3, 4, 1, 2], [4, 2, 3, 1]] - sage: p.cardinality() # optional - sage.combinat + sage: p.cardinality() # needs sage.combinat 88 - sage: p.random_element().parent() is p # optional - sage.combinat + sage: p.random_element().parent() is p # needs sage.combinat True """ @staticmethod @@ -5916,14 +5916,14 @@ class Permutations_mset(Permutations): [2, 2, 1, 1, 2], [2, 2, 1, 2, 1], [2, 2, 2, 1, 1]] - sage: MS = MatrixSpace(GF(2), 2, 2) # optional - sage.modules sage.rings.finite_rings - sage: A = MS([1,0,1,1]) # optional - sage.modules sage.rings.finite_rings - sage: rows = A.rows() # optional - sage.modules sage.rings.finite_rings - sage: rows[0].set_immutable() # optional - sage.modules sage.rings.finite_rings - sage: rows[1].set_immutable() # optional - sage.modules sage.rings.finite_rings - sage: P = Permutations_mset(rows); P # optional - sage.modules sage.rings.finite_rings + sage: MS = MatrixSpace(GF(2), 2, 2) # needs sage.modules + sage: A = MS([1,0,1,1]) # needs sage.modules + sage: rows = A.rows() # needs sage.modules + sage: rows[0].set_immutable() # needs sage.modules + sage: rows[1].set_immutable() # needs sage.modules + sage: P = Permutations_mset(rows); P # needs sage.modules Permutations of the multi-set [(1, 0), (1, 1)] - sage: sorted(P) # optional - sage.modules sage.rings.finite_rings + sage: sorted(P) # needs sage.modules [[(1, 0), (1, 1)], [(1, 1), (1, 0)]] """ @staticmethod @@ -6433,7 +6433,7 @@ def __init__(self, mset, k): TESTS:: sage: P = Permutations([1,2,2],2) - sage: TestSuite(P).run() # optional - sage.libs.gap + sage: TestSuite(P).run() # needs sage.libs.gap """ Permutations_mset.__init__(self, mset) self._k = k @@ -6477,7 +6477,7 @@ def cardinality(self): EXAMPLES:: - sage: Permutations([1,2,2], 2).cardinality() # optional - sage.libs.gap + sage: Permutations([1,2,2], 2).cardinality() # needs sage.libs.gap 3 """ return ZZ.sum(1 for z in self) @@ -6486,7 +6486,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations([1,2,2], 2).list() # optional - sage.libs.gap + sage: Permutations([1,2,2], 2).list() # needs sage.libs.gap [[1, 2], [2, 1], [2, 2]] """ mset = self.mset @@ -6595,7 +6595,7 @@ class Arrangements(Permutations): EXAMPLES:: sage: mset = [1,1,2,3,4,4,5] - sage: Arrangements(mset, 2).list() # optional - sage.libs.gap + sage: Arrangements(mset, 2).list() # needs sage.libs.gap [[1, 1], [1, 2], [1, 3], @@ -6618,11 +6618,11 @@ class Arrangements(Permutations): [5, 2], [5, 3], [5, 4]] - sage: Arrangements(mset, 2).cardinality() # optional - sage.libs.gap + sage: Arrangements(mset, 2).cardinality() # needs sage.libs.gap 22 - sage: Arrangements( ["c","a","t"], 2 ).list() # optional - sage.libs.gap + sage: Arrangements( ["c","a","t"], 2 ).list() # needs sage.libs.gap [['c', 'a'], ['c', 't'], ['a', 'c'], ['a', 't'], ['t', 'c'], ['t', 'a']] - sage: Arrangements( ["c","a","t"], 3 ).list() # optional - sage.libs.gap + sage: Arrangements( ["c","a","t"], 3 ).list() # needs sage.libs.gap [['c', 'a', 't'], ['c', 't', 'a'], ['a', 'c', 't'], @@ -6654,7 +6654,7 @@ def cardinality(self): EXAMPLES:: sage: A = Arrangements([1,1,2,3,4,4,5], 2) - sage: A.cardinality() # optional - sage.libs.gap + sage: A.cardinality() # needs sage.libs.gap 22 """ one = ZZ.one() @@ -6820,21 +6820,21 @@ def _element_constructor_(self, x, check=True): sage: P([2,3,1]) [2, 3, 1, 4, 5] - sage: G = SymmetricGroup(4) # optional - sage.groups + sage: G = SymmetricGroup(4) # needs sage.groups sage: P = Permutations(4) - sage: x = G([4,3,1,2]); x # optional - sage.groups + sage: x = G([4,3,1,2]); x # needs sage.groups (1,4,2,3) - sage: P(x) # optional - sage.groups + sage: P(x) # needs sage.groups [4, 3, 1, 2] - sage: G(P(x)) # optional - sage.groups + sage: G(P(x)) # needs sage.groups (1,4,2,3) - sage: P = PermutationGroup([[(1,3,5),(2,4)],[(1,3)]]) # optional - sage.groups - sage: x = P([(3,5),(2,4)]); x # optional - sage.groups + sage: P = PermutationGroup([[(1,3,5),(2,4)],[(1,3)]]) # needs sage.groups + sage: x = P([(3,5),(2,4)]); x # needs sage.groups (2,4)(3,5) - sage: Permutations(6)(SymmetricGroup(6)(x)) # optional - sage.groups + sage: Permutations(6)(SymmetricGroup(6)(x)) # needs sage.groups [1, 4, 5, 2, 3, 6] - sage: Permutations(6)(x) # known bug # optional - sage.groups + sage: Permutations(6)(x) # optional - bug, needs sage.groups [1, 4, 5, 2, 3, 6] """ if len(x) < self.n: @@ -6925,20 +6925,20 @@ def _coerce_map_from_(self, G): EXAMPLES:: sage: P = Permutations(6) - sage: P.has_coerce_map_from(SymmetricGroup(6)) # optional - sage.groups + sage: P.has_coerce_map_from(SymmetricGroup(6)) # needs sage.groups True - sage: P.has_coerce_map_from(SymmetricGroup(5)) # optional - sage.groups + sage: P.has_coerce_map_from(SymmetricGroup(5)) # needs sage.groups True - sage: P.has_coerce_map_from(SymmetricGroup(7)) # optional - sage.groups + sage: P.has_coerce_map_from(SymmetricGroup(7)) # needs sage.groups False sage: P.has_coerce_map_from(Permutations(5)) True sage: P.has_coerce_map_from(Permutations(7)) False - sage: P.has_coerce_map_from(groups.misc.Cactus(5)) # optional - sage.groups + sage: P.has_coerce_map_from(groups.misc.Cactus(5)) # needs sage.groups True - sage: P.has_coerce_map_from(groups.misc.Cactus(7)) # optional - sage.groups + sage: P.has_coerce_map_from(groups.misc.Cactus(7)) # needs sage.groups False """ if isinstance(G, SymmetricGroup): @@ -6959,9 +6959,9 @@ def _from_permutation_group_element(self, x): TESTS:: sage: P = Permutations(4) - sage: G = SymmetricGroup(4) # optional - sage.groups - sage: x = G([4,3,1,2]) # optional - sage.groups - sage: P._from_permutation_group_element(x) # optional - sage.groups + sage: G = SymmetricGroup(4) # needs sage.groups + sage: x = G([4,3,1,2]) # needs sage.groups + sage: P._from_permutation_group_element(x) # needs sage.groups [4, 3, 1, 2] """ return self(x.domain()) @@ -6972,11 +6972,11 @@ def _from_cactus_group_element(self, x): EXAMPLES:: - sage: J3 = groups.misc.Cactus(3) # optional - sage.groups - sage: s12,s13,s23 = J3.gens() # optional - sage.groups - sage: elt = s12 * s23 * s13 # optional - sage.groups - sage: P5 = Permutations(5) # optional - sage.groups - sage: P5._from_cactus_group_element(elt) # optional - sage.groups + sage: J3 = groups.misc.Cactus(3) # needs sage.groups + sage: s12,s13,s23 = J3.gens() # needs sage.groups + sage: elt = s12 * s23 * s13 # needs sage.groups + sage: P5 = Permutations(5) # needs sage.groups + sage: P5._from_cactus_group_element(elt) # needs sage.groups [1, 3, 2, 4, 5] """ return self(x.to_permutation()) @@ -6988,11 +6988,11 @@ def as_permutation_group(self): EXAMPLES:: sage: P = Permutations(4) - sage: PG = P.as_permutation_group(); PG # optional - sage.groups + sage: PG = P.as_permutation_group(); PG # needs sage.groups Symmetric group of order 4! as a permutation group - sage: G = SymmetricGroup(4) # optional - sage.groups - sage: PG is G # optional - sage.groups + sage: G = SymmetricGroup(4) # needs sage.groups + sage: PG is G # needs sage.groups True """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup @@ -7141,7 +7141,7 @@ def element_in_conjugacy_classes(self, nu): EXAMPLES:: sage: PP = Permutations(5) - sage: PP.element_in_conjugacy_classes([2,2]) # optional - sage.combinat + sage: PP.element_in_conjugacy_classes([2,2]) # needs sage.combinat [2, 1, 4, 3, 5] sage: PP.element_in_conjugacy_classes([5, 5]) Traceback (most recent call last): @@ -7177,7 +7177,7 @@ def conjugacy_classes_representatives(self): EXAMPLES:: sage: G = Permutations(5) - sage: G.conjugacy_classes_representatives() # optional - sage.combinat + sage: G.conjugacy_classes_representatives() # needs sage.combinat sage.libs.flint [[1, 2, 3, 4, 5], [2, 1, 3, 4, 5], [2, 1, 4, 3, 5], @@ -7191,10 +7191,10 @@ def conjugacy_classes_representatives(self): Check some border cases:: sage: S = Permutations(0) - sage: S.conjugacy_classes_representatives() # optional - sage.combinat + sage: S.conjugacy_classes_representatives() # needs sage.combinat sage.libs.flint [[]] sage: S = Permutations(1) - sage: S.conjugacy_classes_representatives() # optional - sage.combinat + sage: S.conjugacy_classes_representatives() # needs sage.combinat sage.libs.flint [[1]] """ from sage.combinat.partition import Partitions_n @@ -7208,7 +7208,7 @@ def conjugacy_classes_iterator(self): EXAMPLES:: sage: G = Permutations(4) - sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() # optional - sage.combinat sage.graphs + sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() # needs sage.combinat sage.graphs sage.groups True """ from sage.combinat.partition import Partitions_n @@ -7223,7 +7223,7 @@ def conjugacy_classes(self): EXAMPLES:: sage: G = Permutations(4) - sage: G.conjugacy_classes() # optional - sage.combinat sage.graphs + sage: G.conjugacy_classes() # needs sage.combinat sage.graphs sage.groups [Conjugacy class of cycle type [1, 1, 1, 1] in Standard permutations of 4, Conjugacy class of cycle type [2, 1, 1] in Standard permutations of 4, Conjugacy class of cycle type [2, 2] in Standard permutations of 4, @@ -7244,9 +7244,9 @@ def conjugacy_class(self, g): sage: G = Permutations(5) sage: g = G([2,3,4,1,5]) - sage: G.conjugacy_class(g) # optional - sage.combinat sage.graphs + sage: G.conjugacy_class(g) # needs sage.combinat sage.graphs sage.groups Conjugacy class of cycle type [4, 1] in Standard permutations of 5 - sage: G.conjugacy_class(Partition([2, 1, 1, 1])) # optional - sage.combinat sage.graphs + sage: G.conjugacy_class(Partition([2, 1, 1, 1])) # needs sage.combinat sage.graphs sage.groups Conjugacy class of cycle type [2, 1, 1, 1] in Standard permutations of 5 """ from sage.groups.perm_gps.symgp_conjugacy_class import PermutationsConjugacyClass @@ -7264,16 +7264,16 @@ def algebra(self, base_ring, category=None): EXAMPLES:: sage: P = Permutations(4) - sage: A = P.algebra(QQ); A # optional - sage.combinat sage.modules + sage: A = P.algebra(QQ); A # needs sage.combinat sage.modules Symmetric group algebra of order 4 over Rational Field - sage: A.category() # optional - sage.combinat sage.modules - Join of Category of Coxeter group algebras over Rational Field + sage: A.category() # needs sage.combinat sage.modules + Join of Category of coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field - sage: A = P.algebra(QQ, category=Monoids()) # optional - sage.combinat sage.modules - sage: A.category() # optional - sage.combinat sage.modules + sage: A = P.algebra(QQ, category=Monoids()) # needs sage.combinat sage.modules + sage: A.category() # needs sage.combinat sage.modules Category of finite dimensional cellular monoid algebras over Rational Field """ from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra @@ -7302,9 +7302,9 @@ def cartan_type(self): EXAMPLES:: - sage: A = SymmetricGroup([2,3,7]); A.cartan_type() # optional - sage.combinat sage.groups + sage: A = SymmetricGroup([2,3,7]); A.cartan_type() # needs sage.combinat sage.groups ['A', 2] - sage: A = SymmetricGroup([]); A.cartan_type() # optional - sage.combinat sage.groups + sage: A = SymmetricGroup([]); A.cartan_type() # needs sage.combinat sage.groups ['A', 0] """ from sage.combinat.root_system.cartan_type import CartanType @@ -7569,8 +7569,8 @@ def from_permutation_group_element(pge, parent=None): EXAMPLES:: sage: import sage.combinat.permutation as permutation - sage: pge = PermutationGroupElement([(1,2),(3,4)]) # optional - sage.groups - sage: permutation.from_permutation_group_element(pge) # optional - sage.groups + sage: pge = PermutationGroupElement([(1,2),(3,4)]) # needs sage.groups + sage: permutation.from_permutation_group_element(pge) # needs sage.groups [2, 1, 4, 3] """ if not isinstance(pge, PermutationGroupElement): @@ -7879,26 +7879,26 @@ def bistochastic_as_sum_of_permutations(M, check=True): sage: L.append((6,Permutation([5, 3, 4, 1, 2]))) sage: L.append((3,Permutation([3, 1, 4, 2, 5]))) sage: L.append((2,Permutation([1, 4, 2, 3, 5]))) - sage: M = sum([c * p.to_matrix() for (c,p) in L]) # optional - sage.modules - sage: decomp = bistochastic_as_sum_of_permutations(M) # optional - sage.graphs sage.modules - sage: print(decomp) # optional - sage.graphs sage.modules + sage: M = sum([c * p.to_matrix() for (c,p) in L]) # needs sage.modules + sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.graphs sage.modules + sage: print(decomp) # needs sage.graphs sage.modules 2*B[[1, 4, 2, 3, 5]] + 3*B[[3, 1, 4, 2, 5]] + 9*B[[4, 1, 3, 5, 2]] + 6*B[[5, 3, 4, 1, 2]] An exception is raised when the matrix is not positive and bistochastic:: - sage: M = Matrix([[2,3],[2,2]]) # optional - sage.modules - sage: decomp = bistochastic_as_sum_of_permutations(M) # optional - sage.graphs sage.modules + sage: M = Matrix([[2,3],[2,2]]) # needs sage.modules + sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.graphs sage.modules Traceback (most recent call last): ... ValueError: The matrix is not bistochastic - sage: bistochastic_as_sum_of_permutations(Matrix(GF(7), 2, [2,1,1,2])) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: bistochastic_as_sum_of_permutations(Matrix(GF(7), 2, [2,1,1,2])) # needs sage.graphs sage.modules Traceback (most recent call last): ... ValueError: The base ring of the matrix must have a coercion map to RR - sage: bistochastic_as_sum_of_permutations(Matrix(ZZ, 2, [2,-1,-1,2])) # optional - sage.graphs sage.modules + sage: bistochastic_as_sum_of_permutations(Matrix(ZZ, 2, [2,-1,-1,2])) # needs sage.graphs sage.modules Traceback (most recent call last): ... ValueError: The matrix should have nonnegative entries @@ -7965,12 +7965,12 @@ def bounded_affine_permutation(A): EXAMPLES:: sage: from sage.combinat.permutation import bounded_affine_permutation - sage: A = Matrix(ZZ, [[1,0,0,0], [0,1,0,0]]) # optional - sage.modules - sage: bounded_affine_permutation(A) # optional - sage.modules + sage: A = Matrix(ZZ, [[1,0,0,0], [0,1,0,0]]) # needs sage.modules + sage: bounded_affine_permutation(A) # needs sage.libs.flint sage.modules [5, 6, 3, 4] - sage: A = Matrix(ZZ, [[0,1,0,1,0], [0,0,1,1,0]]) # optional - sage.modules - sage: bounded_affine_permutation(A) # optional - sage.modules + sage: A = Matrix(ZZ, [[0,1,0,1,0], [0,0,1,1,0]]) # needs sage.modules + sage: bounded_affine_permutation(A) # needs sage.libs.flint sage.modules [1, 4, 7, 8, 5] REFERENCES: @@ -8030,7 +8030,7 @@ def __init__(self, d, n): TESTS:: sage: P = Permutations(descents=([1,0,2], 5)) - sage: TestSuite(P).run() # optional - sage.graphs + sage: TestSuite(P).run() # needs sage.graphs """ StandardPermutations_n_abstract.__init__(self, n) self._d = d @@ -8068,13 +8068,13 @@ def cardinality(self): sage: def P(D, n): ....: return Permutations(descents=(D, n + 1)) - sage: all(P(D, n).cardinality() == len(P(D, n).list()) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: all(P(D, n).cardinality() == len(P(D, n).list()) # needs sage.graphs sage.modules ....: for n in range(5) for D in subsets(range(n))) True sage: n = 20 sage: D = [6, 8, 10, 11, 12, 13, 14, 15, 17, 19] - sage: P(D, n).cardinality() # optional - sage.graphs + sage: P(D, n).cardinality() # needs sage.graphs 125291047596 """ @@ -8133,7 +8133,7 @@ def __iter__(self): EXAMPLES:: - sage: Permutations(descents=([2,0],5)).list() # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutations(descents=([2,0],5)).list() # needs sage.graphs sage.modules [[5, 2, 4, 1, 3], [5, 3, 4, 1, 2], [4, 3, 5, 1, 2], @@ -8162,7 +8162,7 @@ def descents_composition_list(dc): EXAMPLES:: sage: import sage.combinat.permutation as permutation - sage: permutation.descents_composition_list([1,2,2]) # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: permutation.descents_composition_list([1,2,2]) # needs sage.graphs sage.modules [[5, 2, 4, 1, 3], [5, 3, 4, 1, 2], [4, 3, 5, 1, 2], @@ -8255,7 +8255,7 @@ def __init__(self, recoils): TESTS:: sage: P = Permutations(recoils_finer=[2,2]) - sage: TestSuite(P).run() # optional - sage.graphs + sage: TestSuite(P).run() # needs sage.graphs """ Permutations.__init__(self, category=FiniteEnumeratedSets()) self.recoils = recoils @@ -8276,7 +8276,7 @@ def __iter__(self): EXAMPLES:: - sage: Permutations(recoils_finer=[2,2]).list() # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutations(recoils_finer=[2,2]).list() # needs sage.graphs sage.modules [[3, 1, 4, 2], [3, 4, 1, 2], [1, 3, 4, 2], @@ -8323,7 +8323,7 @@ def __init__(self, recoils): TESTS:: sage: P = Permutations(recoils_fatter=[2,2]) - sage: TestSuite(P).run() # optional - sage.graphs + sage: TestSuite(P).run() # needs sage.graphs """ Permutations.__init__(self, category=FiniteEnumeratedSets()) self.recoils = recoils @@ -8344,7 +8344,7 @@ def __iter__(self): EXAMPLES:: - sage: Permutations(recoils_fatter=[2,2]).list() # optional - sage.graphs sage.modules sage.rings.finite_rings + sage: Permutations(recoils_fatter=[2,2]).list() # needs sage.graphs sage.modules [[4, 3, 2, 1], [3, 2, 1, 4], [3, 2, 4, 1], @@ -8398,7 +8398,7 @@ def __init__(self, recoils): TESTS:: sage: P = Permutations(recoils=[2,2]) - sage: TestSuite(P).run() # optional - sage.graphs + sage: TestSuite(P).run() # needs sage.graphs """ Permutations.__init__(self, category=FiniteEnumeratedSets()) self.recoils = recoils @@ -8419,7 +8419,7 @@ def __iter__(self): EXAMPLES:: - sage: Permutations(recoils=[2,2]).list() # optional - sage.graphs + sage: Permutations(recoils=[2,2]).list() # needs sage.graphs [[3, 1, 4, 2], [3, 4, 1, 2], [1, 3, 4, 2], [1, 3, 2, 4], [3, 1, 2, 4]] """ recoils = self.recoils @@ -8725,15 +8725,15 @@ def to_standard(p, key=None): EXAMPLES:: sage: import sage.combinat.permutation as permutation - sage: permutation.to_standard([4,2,7]) # optional - sage.combinat + sage: permutation.to_standard([4,2,7]) # needs sage.combinat [2, 1, 3] - sage: permutation.to_standard([1,2,3]) # optional - sage.combinat + sage: permutation.to_standard([1,2,3]) # needs sage.combinat [1, 2, 3] - sage: permutation.to_standard([]) # optional - sage.combinat + sage: permutation.to_standard([]) # needs sage.combinat [] - sage: permutation.to_standard([1,2,3], key=lambda x: -x) # optional - sage.combinat + sage: permutation.to_standard([1,2,3], key=lambda x: -x) # needs sage.combinat [3, 2, 1] - sage: permutation.to_standard([5,8,2,5], key=lambda x: -x) # optional - sage.combinat + sage: permutation.to_standard([5,8,2,5], key=lambda x: -x) # needs sage.combinat [2, 1, 4, 3] TESTS: @@ -8741,7 +8741,7 @@ def to_standard(p, key=None): Does not mutate the list:: sage: a = [1,2,4] - sage: permutation.to_standard(a) # optional - sage.combinat + sage: permutation.to_standard(a) # needs sage.combinat [1, 2, 3] sage: a [1, 2, 4] @@ -8760,8 +8760,8 @@ def to_standard(p, key=None): ....: i += 1 ....: c[smallest_index] = biggest ....: return Permutations()(s) - sage: p = list(Words(100, 1000).random_element()) # optional - sage.combinat - sage: std(p) == permutation.to_standard(p) # optional - sage.combinat + sage: p = list(Words(100, 1000).random_element()) # needs sage.combinat + sage: std(p) == permutation.to_standard(p) # needs sage.combinat True """ ev_dict = evaluation_dict(p) @@ -8791,14 +8791,14 @@ class CyclicPermutations(Permutations_mset): EXAMPLES:: - sage: CyclicPermutations(range(4)).list() # optional - sage.combinat + sage: CyclicPermutations(range(4)).list() # needs sage.combinat [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], [0, 3, 2, 1]] - sage: CyclicPermutations([1,1,1]).list() # optional - sage.combinat + sage: CyclicPermutations([1,1,1]).list() # needs sage.combinat [[1, 1, 1]] """ @staticmethod @@ -8833,16 +8833,16 @@ def __iter__(self, distinct=False): """ EXAMPLES:: - sage: CyclicPermutations(range(4)).list() # indirect doctest # optional - sage.combinat + sage: CyclicPermutations(range(4)).list() # indirect doctest # needs sage.combinat [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], [0, 3, 2, 1]] - sage: CyclicPermutations([1,1,1]).list() # optional - sage.combinat + sage: CyclicPermutations([1,1,1]).list() # needs sage.combinat [[1, 1, 1]] - sage: CyclicPermutations([1,1,1]).list(distinct=True) # optional - sage.combinat + sage: CyclicPermutations([1,1,1]).list(distinct=True) # needs sage.combinat [[1, 1, 1], [1, 1, 1]] """ if distinct: @@ -8863,7 +8863,7 @@ def list(self, distinct=False): """ EXAMPLES:: - sage: CyclicPermutations(range(4)).list() # optional - sage.combinat + sage: CyclicPermutations(range(4)).list() # needs sage.combinat [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], @@ -8884,7 +8884,7 @@ class CyclicPermutationsOfPartition(Permutations): EXAMPLES:: - sage: CyclicPermutationsOfPartition([[1,2,3,4],[5,6,7]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3,4],[5,6,7]]).list() # needs sage.combinat [[[1, 2, 3, 4], [5, 6, 7]], [[1, 2, 4, 3], [5, 6, 7]], [[1, 3, 2, 4], [5, 6, 7]], @@ -8900,7 +8900,7 @@ class CyclicPermutationsOfPartition(Permutations): :: - sage: CyclicPermutationsOfPartition([[1,2,3,4],[4,4,4]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3,4],[4,4,4]]).list() # needs sage.combinat [[[1, 2, 3, 4], [4, 4, 4]], [[1, 2, 4, 3], [4, 4, 4]], [[1, 3, 2, 4], [4, 4, 4]], @@ -8910,12 +8910,12 @@ class CyclicPermutationsOfPartition(Permutations): :: - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]]] :: - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]], [[1, 2, 3], [4, 4, 4]], @@ -8943,7 +8943,7 @@ def __init__(self, partition): sage: CP = CyclicPermutationsOfPartition([[1,2,3,4],[5,6,7]]) sage: CP Cyclic permutations of partition [[1, 2, 3, 4], [5, 6, 7]] - sage: TestSuite(CP).run() # optional - sage.combinat + sage: TestSuite(CP).run() # needs sage.combinat """ self.partition = partition Permutations.__init__(self, category=FiniteEnumeratedSets()) @@ -8960,8 +8960,8 @@ def check(self): EXAMPLES:: sage: CP = CyclicPermutationsOfPartition([[1,2,3,4],[5,6,7]]) - sage: elt = CP[0] # optional - sage.combinat - sage: elt.check() # optional - sage.combinat + sage: elt = CP[0] # needs sage.combinat + sage: elt.check() # needs sage.combinat """ if [sorted(_) for _ in self] != [sorted(_) for _ in self.parent().partition]: raise ValueError("Invalid cyclic permutation of the partition" % self.parent().partition) @@ -8984,7 +8984,7 @@ def __iter__(self, distinct=False): EXAMPLES:: - sage: CyclicPermutationsOfPartition([[1,2,3,4], # indirect doctest # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3,4], # indirect doctest # needs sage.combinat ....: [5,6,7]]).list() [[[1, 2, 3, 4], [5, 6, 7]], [[1, 2, 4, 3], [5, 6, 7]], @@ -9001,7 +9001,7 @@ def __iter__(self, distinct=False): :: - sage: CyclicPermutationsOfPartition([[1,2,3,4],[4,4,4]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3,4],[4,4,4]]).list() # needs sage.combinat [[[1, 2, 3, 4], [4, 4, 4]], [[1, 2, 4, 3], [4, 4, 4]], [[1, 3, 2, 4], [4, 4, 4]], @@ -9011,12 +9011,12 @@ def __iter__(self, distinct=False): :: - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]]] :: - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]], [[1, 2, 3], [4, 4, 4]], @@ -9036,9 +9036,9 @@ def list(self, distinct=False): """ EXAMPLES:: - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list() # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]]] - sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # optional - sage.combinat + sage: CyclicPermutationsOfPartition([[1,2,3],[4,4,4]]).list(distinct=True) # needs sage.combinat [[[1, 2, 3], [4, 4, 4]], [[1, 3, 2], [4, 4, 4]], [[1, 2, 3], [4, 4, 4]], @@ -9074,7 +9074,7 @@ def __init__(self, a): TESTS:: sage: P = Permutations(avoiding=[[2,1,3],[1,2,3]]) - sage: TestSuite(P).run(max_runs=25) # optional - sage.combinat + sage: TestSuite(P).run(max_runs=25) # needs sage.combinat """ Permutations.__init__(self, category=InfiniteEnumeratedSets()) self._a = a @@ -9104,13 +9104,13 @@ def __contains__(self, x): """ TESTS:: - sage: [1,3,2] in Permutations(avoiding=[1,3,2]) # optional - sage.combinat + sage: [1,3,2] in Permutations(avoiding=[1,3,2]) # needs sage.combinat False - sage: [1,3,2] in Permutations(avoiding=[[1,3,2]]) # optional - sage.combinat + sage: [1,3,2] in Permutations(avoiding=[[1,3,2]]) # needs sage.combinat False - sage: [2,1,3] in Permutations(avoiding=[[1,3,2],[1,2,3]]) # optional - sage.combinat + sage: [2,1,3] in Permutations(avoiding=[[1,3,2],[1,2,3]]) # needs sage.combinat True - sage: [2,1,3] in Permutations(avoiding=[]) # optional - sage.combinat + sage: [2,1,3] in Permutations(avoiding=[]) # needs sage.combinat True """ if not super().__contains__(x): @@ -9125,7 +9125,7 @@ def __iter__(self): TESTS:: sage: it = iter(Permutations(avoiding=[[2,1,3],[1,2,3]])) - sage: [next(it) for i in range(10)] # optional - sage.combinat + sage: [next(it) for i in range(10)] # needs sage.combinat [[], [1], [1, 2], @@ -9170,7 +9170,7 @@ def __init__(self, n, a): EXAMPLES:: sage: P = Permutations(3, avoiding=[[2,1,3],[1,2,3]]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat sage: type(P) """ @@ -9211,13 +9211,13 @@ def __contains__(self, x): """ TESTS:: - sage: [1,3,2] in Permutations(3, avoiding=[1,3,2]) # optional - sage.combinat + sage: [1,3,2] in Permutations(3, avoiding=[1,3,2]) # needs sage.combinat False - sage: [1,3,2] in Permutations(3, avoiding=[[1,3,2]]) # optional - sage.combinat + sage: [1,3,2] in Permutations(3, avoiding=[[1,3,2]]) # needs sage.combinat False - sage: [2,1,3] in Permutations(3, avoiding=[[1,3,2],[1,2,3]]) # optional - sage.combinat + sage: [2,1,3] in Permutations(3, avoiding=[[1,3,2],[1,2,3]]) # needs sage.combinat True - sage: [2,1,3] in Permutations(3, avoiding=[]) # optional - sage.combinat + sage: [2,1,3] in Permutations(3, avoiding=[]) # needs sage.combinat True """ if not super().__contains__(x): @@ -9238,9 +9238,9 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[[2, 1, 3],[1,2,3]]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[[2, 1, 3],[1,2,3]]).list() # needs sage.combinat [[1, 3, 2], [3, 1, 2], [2, 3, 1], [3, 2, 1]] - sage: Permutations(0, avoiding=[[2, 1, 3],[1,2,3]]).list() # optional - sage.combinat + sage: Permutations(0, avoiding=[[2, 1, 3],[1,2,3]]).list() # needs sage.combinat [[]] """ if self.n > 0: @@ -9254,7 +9254,7 @@ def cardinality(self): EXAMPLES:: sage: P = Permutations(3, avoiding=[[2, 1, 3],[1,2,3]]) - sage: P.cardinality() # optional - sage.combinat + sage: P.cardinality() # needs sage.combinat 4 """ one = ZZ.one() @@ -9267,7 +9267,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[1, 2]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([1, 2]),)) @@ -9275,7 +9275,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1,2]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[1,2]).list() # needs sage.combinat [[3, 2, 1]] """ yield self.element_class(self, range(self.n, 0, -1), check=False) @@ -9287,7 +9287,7 @@ def cardinality(self): EXAMPLES:: sage: P = Permutations(3, avoiding=[1, 2]) - sage: P.cardinality() # optional - sage.combinat + sage: P.cardinality() # needs sage.combinat 1 """ return ZZ.one() @@ -9299,7 +9299,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[2, 1]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([2, 1]),)) @@ -9307,7 +9307,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2,1]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[2,1]).list() # needs sage.combinat [[1, 2, 3]] """ yield self.element_class(self, range(1, self.n+1), check=False) @@ -9319,7 +9319,7 @@ def cardinality(self): EXAMPLES:: sage: P = Permutations(3, avoiding=[2, 1]) - sage: P.cardinality() # optional - sage.combinat + sage: P.cardinality() # needs sage.combinat 1 """ return ZZ.one() @@ -9331,7 +9331,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[1, 3, 2]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([1, 3, 2]),)) @@ -9341,7 +9341,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[1, 3, 2]).cardinality() 42 - sage: len( Permutations(5, avoiding=[1, 3, 2]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[1, 3, 2]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9350,9 +9350,9 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1,3,2]).list() # indirect doctest # optional - sage.combinat + sage: Permutations(3, avoiding=[1,3,2]).list() # indirect doctest # needs sage.combinat [[1, 2, 3], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] - sage: Permutations(4, avoiding=[1,3,2]).list() # optional - sage.combinat + sage: Permutations(4, avoiding=[1,3,2]).list() # needs sage.combinat [[4, 1, 2, 3], [4, 2, 1, 3], [4, 2, 3, 1], @@ -9408,7 +9408,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[2, 1, 3]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([1, 2, 3]),)) @@ -9416,9 +9416,9 @@ def cardinality(self) -> Integer: """ EXAMPLES:: - sage: Permutations(5, avoiding=[1, 2, 3]).cardinality() # optional - sage.combinat + sage: Permutations(5, avoiding=[1, 2, 3]).cardinality() # needs sage.combinat 42 - sage: len( Permutations(5, avoiding=[1, 2, 3]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[1, 2, 3]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9427,11 +9427,11 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1, 2, 3]).list() # indirect doctest # optional - sage.combinat + sage: Permutations(3, avoiding=[1, 2, 3]).list() # indirect doctest # needs sage.combinat [[1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] - sage: Permutations(2, avoiding=[1, 2, 3]).list() # optional - sage.combinat + sage: Permutations(2, avoiding=[1, 2, 3]).list() # needs sage.combinat [[1, 2], [2, 1]] - sage: Permutations(3, avoiding=[1, 2, 3]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[1, 2, 3]).list() # needs sage.combinat [[1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] """ if self.n == 0: @@ -9480,7 +9480,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[3, 2, 1]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([3, 2, 1]),)) @@ -9488,9 +9488,9 @@ def cardinality(self): """ EXAMPLES:: - sage: Permutations(5, avoiding=[3, 2, 1]).cardinality() # optional - sage.combinat + sage: Permutations(5, avoiding=[3, 2, 1]).cardinality() # needs sage.combinat 42 - sage: len( Permutations(5, avoiding=[3, 2, 1]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[3, 2, 1]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9499,7 +9499,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[3, 2, 1]).list() # indirect doctest # optional - sage.combinat + sage: Permutations(3, avoiding=[3, 2, 1]).list() # indirect doctest # needs sage.combinat [[2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]] """ for p in StandardPermutations_avoiding_123(self.n): @@ -9512,7 +9512,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[2, 3, 1]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([2, 3, 1]),)) @@ -9520,9 +9520,9 @@ def cardinality(self): """ EXAMPLES:: - sage: Permutations(5, avoiding=[2, 3, 1]).cardinality() # optional - sage.combinat + sage: Permutations(5, avoiding=[2, 3, 1]).cardinality() # needs sage.combinat 42 - sage: len( Permutations(5, avoiding=[2, 3, 1]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[2, 3, 1]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9531,7 +9531,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2, 3, 1]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[2, 3, 1]).list() # needs sage.combinat [[3, 2, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]] """ for p in StandardPermutations_avoiding_132(self.n): @@ -9544,7 +9544,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[3, 1, 2]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([3, 1, 2]),)) @@ -9554,7 +9554,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[3, 1, 2]).cardinality() 42 - sage: len( Permutations(5, avoiding=[3, 1, 2]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[3, 1, 2]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9563,7 +9563,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[3, 1, 2]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[3, 1, 2]).list() # needs sage.combinat [[3, 2, 1], [2, 3, 1], [2, 1, 3], [1, 3, 2], [1, 2, 3]] """ for p in StandardPermutations_avoiding_132(self.n): @@ -9576,7 +9576,7 @@ def __init__(self, n): TESTS:: sage: P = Permutations(3, avoiding=[2, 1, 3]) - sage: TestSuite(P).run() # optional - sage.combinat + sage: TestSuite(P).run() # needs sage.combinat """ super().__init__(n, (Permutations()([2, 1, 3]),)) @@ -9586,7 +9586,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[2, 1, 3]).cardinality() 42 - sage: len( Permutations(5, avoiding=[2, 1, 3]).list() ) # optional - sage.combinat + sage: len( Permutations(5, avoiding=[2, 1, 3]).list() ) # needs sage.combinat 42 """ return catalan_number(self.n) @@ -9595,7 +9595,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2, 1, 3]).list() # optional - sage.combinat + sage: Permutations(3, avoiding=[2, 1, 3]).list() # needs sage.combinat [[1, 2, 3], [1, 3, 2], [3, 1, 2], [2, 3, 1], [3, 2, 1]] """ for p in StandardPermutations_avoiding_132(self.n): @@ -9624,7 +9624,7 @@ def _rec(self, obj, state): sage: from sage.combinat.permutation import PatternAvoider sage: P = Permutations(4) sage: p = PatternAvoider(P, [[1,2]]) - sage: list(p._rec([1], 2)) # optional - sage.combinat + sage: list(p._rec([1], 2)) # needs sage.combinat [([2, 1], 3, False)] """ i = state From 2a0603479a80664e574bca448b0aa08188852bf8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 1 Jul 2023 15:42:59 -0700 Subject: [PATCH 375/494] Update # optional / # needs --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 00cf325805f..2ea6d222dc6 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -6834,7 +6834,7 @@ def _element_constructor_(self, x, check=True): (2,4)(3,5) sage: Permutations(6)(SymmetricGroup(6)(x)) # needs sage.groups [1, 4, 5, 2, 3, 6] - sage: Permutations(6)(x) # optional - bug, needs sage.groups + sage: Permutations(6)(x) # known bug # needs sage.groups [1, 4, 5, 2, 3, 6] """ if len(x) < self.n: From c3f31404cc4a4e54e6e2af1085973af8ee8f809c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 2 Jul 2023 00:58:45 -0700 Subject: [PATCH 376/494] sage.combinat: Update # optional / # needs --- src/sage/combinat/cartesian_product.py | 24 ++++----- src/sage/combinat/integer_vector.py | 68 ++++++++++++------------ src/sage/combinat/permutation.py | 72 +++++++++++++------------- src/sage/combinat/ranker.py | 2 +- src/sage/combinat/subset.py | 12 ++--- src/sage/combinat/tuple.py | 12 ++--- 6 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/sage/combinat/cartesian_product.py b/src/sage/combinat/cartesian_product.py index cbe219ef169..832c5f1075d 100644 --- a/src/sage/combinat/cartesian_product.py +++ b/src/sage/combinat/cartesian_product.py @@ -51,27 +51,27 @@ class for ``cartesian_product``; sage: F1 = ['a', 'b'] sage: F2 = [1, 2, 3, 4] - sage: F3 = Permutations(3) # optional - sage.combinat + sage: F3 = Permutations(3) sage: from sage.combinat.cartesian_product import CartesianProduct_iters - sage: C = CartesianProduct_iters(F1, F2, F3) # optional - sage.combinat - sage: c = cartesian_product([F1, F2, F3]) # optional - sage.combinat + sage: C = CartesianProduct_iters(F1, F2, F3) + sage: c = cartesian_product([F1, F2, F3]) - sage: type(C.an_element()) # optional - sage.combinat + sage: type(C.an_element()) - sage: type(c.an_element()) # optional - sage.combinat + sage: type(c.an_element()) - sage: l = ['a', 1, Permutation([3,2,1])] # optional - sage.combinat - sage: l in C # optional - sage.combinat + sage: l = ['a', 1, Permutation([3,2,1])] + sage: l in C True - sage: l in c # optional - sage.combinat + sage: l in c False - sage: elt = c(l) # optional - sage.combinat - sage: elt # optional - sage.combinat + sage: elt = c(l) + sage: elt ('a', 1, [3, 2, 1]) - sage: elt in c # optional - sage.combinat + sage: elt in c True - sage: elt.parent() is c # optional - sage.combinat + sage: elt.parent() is c True """ diff --git a/src/sage/combinat/integer_vector.py b/src/sage/combinat/integer_vector.py index 65eb4dfc4e9..94a09c7474f 100644 --- a/src/sage/combinat/integer_vector.py +++ b/src/sage/combinat/integer_vector.py @@ -92,11 +92,11 @@ def is_gale_ryser(r,s): EXAMPLES:: sage: from sage.combinat.integer_vector import is_gale_ryser - sage: is_gale_ryser([4,2,2], [3,3,1,1]) # optional - sage.combinat + sage: is_gale_ryser([4,2,2], [3,3,1,1]) # needs sage.combinat True - sage: is_gale_ryser([4,2,1,1], [3,3,1,1]) # optional - sage.combinat + sage: is_gale_ryser([4,2,1,1], [3,3,1,1]) # needs sage.combinat True - sage: is_gale_ryser([3,2,1,1], [3,3,1,1]) # optional - sage.combinat + sage: is_gale_ryser([3,2,1,1], [3,3,1,1]) # needs sage.combinat False REMARK: In the literature, what we are calling a @@ -207,14 +207,14 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", sage: from sage.combinat.integer_vector import gale_ryser_theorem sage: p1 = [2,2,1] sage: p2 = [2,2,1] - sage: print(gale_ryser_theorem(p1, p2)) # not tested # optional - sage.combinat + sage: print(gale_ryser_theorem(p1, p2)) # not tested # needs sage.combinat sage.modules [1 1 0] [1 0 1] [0 1 0] - sage: A = gale_ryser_theorem(p1, p2) # optional - sage.combinat - sage: rs = [sum(x) for x in A.rows()] # optional - sage.combinat - sage: cs = [sum(x) for x in A.columns()] # optional - sage.combinat - sage: p1 == rs; p2 == cs # optional - sage.combinat + sage: A = gale_ryser_theorem(p1, p2) # needs sage.combinat sage.modules + sage: rs = [sum(x) for x in A.rows()] # needs sage.combinat sage.modules + sage: cs = [sum(x) for x in A.columns()] # needs sage.combinat sage.modules + sage: p1 == rs; p2 == cs # needs sage.combinat sage.modules True True @@ -224,27 +224,27 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", sage: from sage.combinat.integer_vector import gale_ryser_theorem sage: p1 = [3,3,1,1] sage: p2 = [3,3,1,1] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules [1 1 1 0] [1 1 0 1] [1 0 0 0] [0 1 0 0] sage: p1 = [4,2,2] sage: p2 = [3,3,1,1] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules [1 1 1 1] [1 1 0 0] [1 1 0 0] sage: p1 = [4,2,2,0] sage: p2 = [3,3,1,1,0,0] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules [1 1 1 1 0 0] [1 1 0 0 0 0] [1 1 0 0 0 0] [0 0 0 0 0 0] sage: p1 = [3,3,2,1] sage: p2 = [3,2,2,1,1] - sage: print(gale_ryser_theorem(p1, p2, algorithm="gale")) # not tested # optional - sage.combinat + sage: print(gale_ryser_theorem(p1, p2, algorithm="gale")) # not tested, needs sage.combinat sage.modules [1 1 1 0 0] [1 1 0 0 1] [1 0 1 0 0] @@ -253,7 +253,7 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", With `0` in the sequences, and with unordered inputs:: sage: from sage.combinat.integer_vector import gale_ryser_theorem - sage: gale_ryser_theorem([3,3,0,1,1,0], [3,1,3,1,0], algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem([3,3,0,1,1,0], [3,1,3,1,0], algorithm="ryser") # needs sage.combinat sage.modules [1 1 1 0 0] [1 0 1 1 0] [0 0 0 0 0] @@ -261,7 +261,7 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", [0 0 1 0 0] [0 0 0 0 0] sage: p1 = [3,1,1,1,1]; p2 = [3,2,2,0] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules [1 1 1 0] [1 0 0 0] [1 0 0 0] @@ -288,17 +288,17 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", ....: print("Algorithm %s failed with this input:" % algorithm) ....: print(s1, s2) - sage: for algorithm in ["gale", "ryser"]: # long time # optional - sage.combinat + sage: for algorithm in ["gale", "ryser"]: # long time # needs sage.combinat sage.modules ....: for i in range(50): ....: test_algorithm(algorithm, 3, 10) Null matrix:: - sage: gale_ryser_theorem([0,0,0],[0,0,0,0], algorithm="gale") # optional - sage.combinat + sage: gale_ryser_theorem([0,0,0],[0,0,0,0], algorithm="gale") # needs sage.combinat sage.modules [0 0 0 0] [0 0 0 0] [0 0 0 0] - sage: gale_ryser_theorem([0,0,0],[0,0,0,0], algorithm="ryser") # optional - sage.combinat + sage: gale_ryser_theorem([0,0,0],[0,0,0,0], algorithm="ryser") # needs sage.combinat sage.modules [0 0 0 0] [0 0 0 0] [0 0 0 0] @@ -517,10 +517,10 @@ def specht_module(self, base_ring=None): EXAMPLES:: - sage: SM = IntegerVectors()([2,0,1,0,2]).specht_module(QQ); SM # optional - sage.combinat + sage: SM = IntegerVectors()([2,0,1,0,2]).specht_module(QQ); SM # needs sage.combinat sage.modules Specht module of [(0, 0), (0, 1), (2, 0), (4, 0), (4, 1)] over Rational Field - sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat - sage: s(SM.frobenius_image()) # optional - sage.combinat + sage: s = SymmetricFunctions(QQ).s() # needs sage.combinat sage.modules + sage: s(SM.frobenius_image()) # needs sage.combinat sage.modules s[2, 2, 1] """ from sage.combinat.specht_module import SpechtModule @@ -541,9 +541,9 @@ def specht_module_dimension(self, base_ring=None): EXAMPLES:: - sage: IntegerVectors()([2,0,1,0,2]).specht_module_dimension() # optional - sage.combinat + sage: IntegerVectors()([2,0,1,0,2]).specht_module_dimension() # needs sage.combinat sage.modules 5 - sage: IntegerVectors()([2,0,1,0,2]).specht_module_dimension(GF(2)) # optional - sage.combinat sage.rings.finite_rings + sage: IntegerVectors()([2,0,1,0,2]).specht_module_dimension(GF(2)) # needs sage.combinat sage.modules sage.rings.finite_rings 5 """ from sage.combinat.specht_module import specht_module_rank @@ -594,7 +594,7 @@ class IntegerVectors(Parent, metaclass=ClasscallMetaclass): Note that trailing zeros are ignored so that ``[3, 0]`` does not show up in the following list (since ``[3]`` does):: - sage: IntegerVectors(3, max_length=2).list() # optional - sage.combinat + sage: IntegerVectors(3, max_length=2).list() [[3], [2, 1], [1, 2], [0, 3]] If ``n`` and ``k`` are both specified, then it returns the class @@ -666,9 +666,9 @@ class IntegerVectors(Parent, metaclass=ClasscallMetaclass): An example showing the same output by using IntegerListsLex:: - sage: IntegerVectors(4, max_length=2).list() # optional - sage.combinat + sage: IntegerVectors(4, max_length=2).list() [[4], [3, 1], [2, 2], [1, 3], [0, 4]] - sage: list(IntegerListsLex(4, max_length=2)) # optional - sage.combinat + sage: list(IntegerListsLex(4, max_length=2)) [[4], [3, 1], [2, 2], [1, 3], [0, 4]] .. SEEALSO:: @@ -1391,12 +1391,12 @@ def __contains__(self, x): """ TESTS:: - sage: [3,2,2,1] in IntegerVectors(8, 4, min_part=1) # optional - sage.combinat + sage: [3,2,2,1] in IntegerVectors(8, 4, min_part=1) # needs sage.combinat True - sage: [3,2,2,1] in IntegerVectors(8, 4, min_part=2) # optional - sage.combinat + sage: [3,2,2,1] in IntegerVectors(8, 4, min_part=2) # needs sage.combinat False - sage: [0,3,0,1,2] in IntegerVectors(6, max_length=3) # optional - sage.combinat + sage: [0,3,0,1,2] in IntegerVectors(6, max_length=3) # needs sage.combinat False """ if isinstance(x, IntegerVector) and x.parent() is self: @@ -1420,17 +1420,17 @@ def cardinality(self): EXAMPLES:: - sage: IntegerVectors(3, 3, min_part=1).cardinality() # optional - sage.combinat + sage: IntegerVectors(3, 3, min_part=1).cardinality() 1 - sage: IntegerVectors(5, 3, min_part=1).cardinality() # optional - sage.combinat + sage: IntegerVectors(5, 3, min_part=1).cardinality() 6 - sage: IntegerVectors(13, 4, max_part=4).cardinality() # optional - sage.combinat + sage: IntegerVectors(13, 4, max_part=4).cardinality() 20 - sage: IntegerVectors(k=4, max_part=3).cardinality() # optional - sage.combinat + sage: IntegerVectors(k=4, max_part=3).cardinality() 256 - sage: IntegerVectors(k=3, min_part=2, max_part=4).cardinality() # optional - sage.combinat + sage: IntegerVectors(k=3, min_part=2, max_part=4).cardinality() 27 - sage: IntegerVectors(13, 4, min_part=2, max_part=4).cardinality() # optional - sage.combinat + sage: IntegerVectors(13, 4, min_part=2, max_part=4).cardinality() 16 """ if self.k is None: diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 2ea6d222dc6..6723ad4b1af 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -1258,7 +1258,7 @@ def __mul__(self, rp): sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.modules sage: SM = SGA.specht_module([2,1]) # needs sage.combinat sage.modules - sage: p213 = Permutations(3)([2,1,3]) # needs sage.combinat sage.modules + sage: p213 = Permutations(3)([2,1,3]) # needs sage.modules sage: p213 * SGA.an_element() # needs sage.combinat sage.modules 3*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 2*[3, 1, 2] sage: p213 * SM.an_element() # needs sage.combinat sage.modules @@ -4274,11 +4274,11 @@ def right_permutohedron_interval(self, other): sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # needs sage.graphs sage.modules [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] - sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.graphs sage.modules + sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.modules Traceback (most recent call last): ... ValueError: [2, 5, 4, 1, 3] must be lower or equal than [2, 1, 4, 5, 3] for the right permutohedron order - sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.graphs sage.modules + sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.modules Traceback (most recent call last): ... ValueError: len([2, 4, 1, 3]) and len([2, 1, 4, 5, 3]) must be equal @@ -4674,7 +4674,7 @@ def permutation_poset(self): [[(1, 1), (2, 3)], [(1, 1), (3, 2)]] sage: Permutation([1,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs [[(1, 1), (2, 2)]] - sage: P = Permutation([1,5,2,4,3]) # needs sage.combinat sage.graphs + sage: P = Permutation([1,5,2,4,3]) This should hold for any `P`:: @@ -5482,7 +5482,7 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations(['c', 'a', 't'], 2); p Permutations of the set ['c', 'a', 't'] of length 2 - sage: p.list() # needs sage.libs.gap + sage: p.list() [['c', 'a'], ['c', 't'], ['a', 'c'], ['a', 't'], ['t', 'c'], ['t', 'a']] :: @@ -5547,7 +5547,7 @@ class Permutations(UniqueRepresentation, Parent): sage: p = Permutations(4, avoiding=[1,3,2]); p Standard permutations of 4 avoiding [[1, 3, 2]] - sage: p.list() # needs sage.combinat + sage: p.list() [[4, 1, 2, 3], [4, 2, 1, 3], [4, 2, 3, 1], @@ -6620,9 +6620,9 @@ class Arrangements(Permutations): [5, 4]] sage: Arrangements(mset, 2).cardinality() # needs sage.libs.gap 22 - sage: Arrangements( ["c","a","t"], 2 ).list() # needs sage.libs.gap + sage: Arrangements( ["c","a","t"], 2 ).list() [['c', 'a'], ['c', 't'], ['a', 'c'], ['a', 't'], ['t', 'c'], ['t', 'a']] - sage: Arrangements( ["c","a","t"], 3 ).list() # needs sage.libs.gap + sage: Arrangements( ["c","a","t"], 3 ).list() [['c', 'a', 't'], ['c', 't', 'a'], ['a', 'c', 't'], @@ -6834,7 +6834,7 @@ def _element_constructor_(self, x, check=True): (2,4)(3,5) sage: Permutations(6)(SymmetricGroup(6)(x)) # needs sage.groups [1, 4, 5, 2, 3, 6] - sage: Permutations(6)(x) # known bug # needs sage.groups + sage: Permutations(6)(x) # known bug, needs sage.groups [1, 4, 5, 2, 3, 6] """ if len(x) < self.n: @@ -6975,7 +6975,7 @@ def _from_cactus_group_element(self, x): sage: J3 = groups.misc.Cactus(3) # needs sage.groups sage: s12,s13,s23 = J3.gens() # needs sage.groups sage: elt = s12 * s23 * s13 # needs sage.groups - sage: P5 = Permutations(5) # needs sage.groups + sage: P5 = Permutations(5) sage: P5._from_cactus_group_element(elt) # needs sage.groups [1, 3, 2, 4, 5] """ @@ -8074,7 +8074,7 @@ def cardinality(self): sage: n = 20 sage: D = [6, 8, 10, 11, 12, 13, 14, 15, 17, 19] - sage: P(D, n).cardinality() # needs sage.graphs + sage: P(D, n).cardinality() 125291047596 """ @@ -9110,7 +9110,7 @@ def __contains__(self, x): False sage: [2,1,3] in Permutations(avoiding=[[1,3,2],[1,2,3]]) # needs sage.combinat True - sage: [2,1,3] in Permutations(avoiding=[]) # needs sage.combinat + sage: [2,1,3] in Permutations(avoiding=[]) True """ if not super().__contains__(x): @@ -9217,7 +9217,7 @@ def __contains__(self, x): False sage: [2,1,3] in Permutations(3, avoiding=[[1,3,2],[1,2,3]]) # needs sage.combinat True - sage: [2,1,3] in Permutations(3, avoiding=[]) # needs sage.combinat + sage: [2,1,3] in Permutations(3, avoiding=[]) True """ if not super().__contains__(x): @@ -9240,7 +9240,7 @@ def __iter__(self): sage: Permutations(3, avoiding=[[2, 1, 3],[1,2,3]]).list() # needs sage.combinat [[1, 3, 2], [3, 1, 2], [2, 3, 1], [3, 2, 1]] - sage: Permutations(0, avoiding=[[2, 1, 3],[1,2,3]]).list() # needs sage.combinat + sage: Permutations(0, avoiding=[[2, 1, 3],[1,2,3]]).list() [[]] """ if self.n > 0: @@ -9275,7 +9275,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1,2]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[1,2]).list() [[3, 2, 1]] """ yield self.element_class(self, range(self.n, 0, -1), check=False) @@ -9287,7 +9287,7 @@ def cardinality(self): EXAMPLES:: sage: P = Permutations(3, avoiding=[1, 2]) - sage: P.cardinality() # needs sage.combinat + sage: P.cardinality() 1 """ return ZZ.one() @@ -9307,7 +9307,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2,1]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[2,1]).list() [[1, 2, 3]] """ yield self.element_class(self, range(1, self.n+1), check=False) @@ -9319,7 +9319,7 @@ def cardinality(self): EXAMPLES:: sage: P = Permutations(3, avoiding=[2, 1]) - sage: P.cardinality() # needs sage.combinat + sage: P.cardinality() 1 """ return ZZ.one() @@ -9341,7 +9341,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[1, 3, 2]).cardinality() 42 - sage: len( Permutations(5, avoiding=[1, 3, 2]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[1, 3, 2]).list() ) 42 """ return catalan_number(self.n) @@ -9350,9 +9350,9 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1,3,2]).list() # indirect doctest # needs sage.combinat + sage: Permutations(3, avoiding=[1,3,2]).list() # indirect doctest [[1, 2, 3], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] - sage: Permutations(4, avoiding=[1,3,2]).list() # needs sage.combinat + sage: Permutations(4, avoiding=[1,3,2]).list() [[4, 1, 2, 3], [4, 2, 1, 3], [4, 2, 3, 1], @@ -9416,9 +9416,9 @@ def cardinality(self) -> Integer: """ EXAMPLES:: - sage: Permutations(5, avoiding=[1, 2, 3]).cardinality() # needs sage.combinat + sage: Permutations(5, avoiding=[1, 2, 3]).cardinality() 42 - sage: len( Permutations(5, avoiding=[1, 2, 3]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[1, 2, 3]).list() ) 42 """ return catalan_number(self.n) @@ -9427,11 +9427,11 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[1, 2, 3]).list() # indirect doctest # needs sage.combinat + sage: Permutations(3, avoiding=[1, 2, 3]).list() # indirect doctest [[1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] - sage: Permutations(2, avoiding=[1, 2, 3]).list() # needs sage.combinat + sage: Permutations(2, avoiding=[1, 2, 3]).list() [[1, 2], [2, 1]] - sage: Permutations(3, avoiding=[1, 2, 3]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[1, 2, 3]).list() [[1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] """ if self.n == 0: @@ -9488,9 +9488,9 @@ def cardinality(self): """ EXAMPLES:: - sage: Permutations(5, avoiding=[3, 2, 1]).cardinality() # needs sage.combinat + sage: Permutations(5, avoiding=[3, 2, 1]).cardinality() 42 - sage: len( Permutations(5, avoiding=[3, 2, 1]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[3, 2, 1]).list() ) 42 """ return catalan_number(self.n) @@ -9499,7 +9499,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[3, 2, 1]).list() # indirect doctest # needs sage.combinat + sage: Permutations(3, avoiding=[3, 2, 1]).list() # indirect doctest [[2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]] """ for p in StandardPermutations_avoiding_123(self.n): @@ -9520,9 +9520,9 @@ def cardinality(self): """ EXAMPLES:: - sage: Permutations(5, avoiding=[2, 3, 1]).cardinality() # needs sage.combinat + sage: Permutations(5, avoiding=[2, 3, 1]).cardinality() 42 - sage: len( Permutations(5, avoiding=[2, 3, 1]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[2, 3, 1]).list() ) 42 """ return catalan_number(self.n) @@ -9531,7 +9531,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2, 3, 1]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[2, 3, 1]).list() [[3, 2, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]] """ for p in StandardPermutations_avoiding_132(self.n): @@ -9554,7 +9554,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[3, 1, 2]).cardinality() 42 - sage: len( Permutations(5, avoiding=[3, 1, 2]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[3, 1, 2]).list() ) 42 """ return catalan_number(self.n) @@ -9563,7 +9563,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[3, 1, 2]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[3, 1, 2]).list() [[3, 2, 1], [2, 3, 1], [2, 1, 3], [1, 3, 2], [1, 2, 3]] """ for p in StandardPermutations_avoiding_132(self.n): @@ -9586,7 +9586,7 @@ def cardinality(self): sage: Permutations(5, avoiding=[2, 1, 3]).cardinality() 42 - sage: len( Permutations(5, avoiding=[2, 1, 3]).list() ) # needs sage.combinat + sage: len( Permutations(5, avoiding=[2, 1, 3]).list() ) 42 """ return catalan_number(self.n) @@ -9595,7 +9595,7 @@ def __iter__(self): """ EXAMPLES:: - sage: Permutations(3, avoiding=[2, 1, 3]).list() # needs sage.combinat + sage: Permutations(3, avoiding=[2, 1, 3]).list() [[1, 2, 3], [1, 3, 2], [3, 1, 2], [2, 3, 1], [3, 2, 1]] """ for p in StandardPermutations_avoiding_132(self.n): diff --git a/src/sage/combinat/ranker.py b/src/sage/combinat/ranker.py index 68ae91baba3..c370800bf22 100644 --- a/src/sage/combinat/ranker.py +++ b/src/sage/combinat/ranker.py @@ -207,7 +207,7 @@ def unrank(L, i): Enumerated sets:: - sage: unrank(GF(7), 2) # optional - sage.rings.finite_rings + sage: unrank(GF(7), 2) 2 sage: unrank(IntegerModRing(29), 10) 10 diff --git a/src/sage/combinat/subset.py b/src/sage/combinat/subset.py index add81ab8707..65dd76b8490 100644 --- a/src/sage/combinat/subset.py +++ b/src/sage/combinat/subset.py @@ -185,11 +185,11 @@ class Subsets_s(Parent): {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}] - sage: S = Subsets(Subsets(Subsets(GF(3)))); S # optional - sage.rings.finite_rings + sage: S = Subsets(Subsets(Subsets(GF(3)))); S Subsets of Subsets of Subsets of Finite Field of size 3 - sage: S.cardinality() # optional - sage.rings.finite_rings + sage: S.cardinality() 115792089237316195423570985008687907853269984665640564039457584007913129639936 - sage: S.unrank(3149254230) # random # optional - sage.rings.finite_rings + sage: S.unrank(3149254230) # random {{{1}, {0, 2}}, {{0, 1, 2}, {0, 1}, {1}, {1, 2}}, {{2}, {1, 2}, {0, 1, 2}, {0, 2}, {1}, {}}, {{1, 2}, {0}}, @@ -247,7 +247,7 @@ def underlying_set(self): EXAMPLES:: - sage: Subsets(GF(13)).underlying_set() # optional - sage.rings.finite_rings + sage: Subsets(GF(13)).underlying_set() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} """ return self.element_class(self._s) @@ -549,10 +549,10 @@ def lattice(self): EXAMPLES:: sage: X = Subsets([7,8,9]) - sage: X.lattice() # optional - sage.combinat sage.graphs + sage: X.lattice() # needs sage.combinat sage.graphs Finite lattice containing 8 elements sage: Y = Subsets(0) - sage: Y.lattice() # optional - sage.combinat sage.graphs + sage: Y.lattice() # needs sage.combinat sage.graphs Finite lattice containing 1 elements """ diff --git a/src/sage/combinat/tuple.py b/src/sage/combinat/tuple.py index 8336fb4cbb6..63bedcb509a 100644 --- a/src/sage/combinat/tuple.py +++ b/src/sage/combinat/tuple.py @@ -48,9 +48,9 @@ class Tuples(Parent, UniqueRepresentation): :: - sage: K. = GF(4, 'a') # optional - sage.rings.finite_rings - sage: mset = [x for x in K if x != 0] # optional - sage.rings.finite_rings - sage: Tuples(mset,2).list() # optional - sage.rings.finite_rings + sage: K. = GF(4, 'a') # needs sage.rings.finite_rings + sage: mset = [x for x in K if x != 0] # needs sage.rings.finite_rings + sage: Tuples(mset,2).list() # needs sage.rings.finite_rings [(a, a), (a + 1, a), (1, a), (a, a + 1), (a + 1, a + 1), (1, a + 1), (a, 1), (a + 1, 1), (1, 1)] """ @@ -116,10 +116,10 @@ def cardinality(self): EXAMPLES:: sage: S = [1,2,3,4,5] - sage: Tuples(S,2).cardinality() # optional - sage.libs.gap + sage: Tuples(S,2).cardinality() 25 sage: S = [1,1,2,3,4,5] - sage: Tuples(S,2).cardinality() # optional - sage.libs.gap + sage: Tuples(S,2).cardinality() 25 """ return ZZ(len(self._index_list)).__pow__(self.k) @@ -201,7 +201,7 @@ def cardinality(self): EXAMPLES:: sage: S = [1,2,3,4,5] - sage: UnorderedTuples(S,2).cardinality() # optional - sage.libs.gap + sage: UnorderedTuples(S,2).cardinality() 15 """ return binomial(len(self._index_list) + self.k - 1, self.k) From a770279e484a3735881ac7ddfc53835f88288afe Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 12 Jul 2023 17:59:24 -0700 Subject: [PATCH 377/494] ./sage -fixdoctests --distribution sagemath-categories --only-tags src/sage/combinat --- src/sage/combinat/backtrack.py | 2 +- src/sage/combinat/baxter_permutations.py | 7 +- .../combinat/binary_recurrence_sequences.py | 14 +- src/sage/combinat/binary_tree.py | 143 +++---- src/sage/combinat/colored_permutations.py | 29 +- src/sage/combinat/combinat.py | 267 ++++++------- src/sage/combinat/combinat_cython.pyx | 2 +- src/sage/combinat/combination.py | 12 +- src/sage/combinat/combinatorial_map.py | 4 +- src/sage/combinat/composition.py | 65 ++-- src/sage/combinat/core.py | 32 +- src/sage/combinat/crystals/crystals.py | 2 +- src/sage/combinat/crystals/letters.pyx | 6 +- src/sage/combinat/crystals/mv_polytopes.py | 4 +- src/sage/combinat/degree_sequences.pyx | 10 +- src/sage/combinat/diagram_algebras.py | 62 ++-- src/sage/combinat/dlx.py | 17 +- src/sage/combinat/dyck_word.py | 64 ++-- src/sage/combinat/e_one_star.py | 18 +- src/sage/combinat/finite_state_machine.py | 166 ++++----- .../finite_state_machine_generators.py | 140 +++---- src/sage/combinat/free_module.py | 146 ++++---- .../combinat/fully_commutative_elements.py | 2 +- src/sage/combinat/fully_packed_loop.py | 12 +- src/sage/combinat/integer_lists/invlex.pyx | 2 +- src/sage/combinat/interval_posets.py | 144 +++---- src/sage/combinat/matrices/dancing_links.pyx | 30 +- src/sage/combinat/matrices/dlxcpp.py | 17 +- .../multiset_partition_into_sets_ordered.py | 124 +++---- src/sage/combinat/necklace.py | 2 +- src/sage/combinat/nu_dyck_word.py | 2 +- src/sage/combinat/ordered_tree.py | 42 +-- src/sage/combinat/parallelogram_polyomino.py | 20 +- src/sage/combinat/parking_functions.py | 16 +- src/sage/combinat/partition.py | 350 +++++++++--------- src/sage/combinat/partition_tuple.py | 87 ++--- src/sage/combinat/path_tableaux/frieze.py | 48 +-- .../combinat/path_tableaux/path_tableau.py | 4 +- .../combinat/path_tableaux/semistandard.py | 5 +- src/sage/combinat/perfect_matching.py | 24 +- src/sage/combinat/permutation.py | 46 +-- src/sage/combinat/plane_partition.py | 110 +++--- src/sage/combinat/q_analogues.py | 16 +- src/sage/combinat/q_bernoulli.pyx | 5 +- src/sage/combinat/quickref.py | 24 +- src/sage/combinat/restricted_growth.py | 4 +- src/sage/combinat/ribbon_shaped_tableau.py | 22 +- src/sage/combinat/ribbon_tableau.py | 14 +- .../rigged_configurations/kleber_tree.py | 2 +- src/sage/combinat/rooted_tree.py | 18 +- src/sage/combinat/set_partition.py | 95 ++--- src/sage/combinat/set_partition_iterator.pyx | 4 +- src/sage/combinat/sf/elementary.py | 4 +- src/sage/combinat/sf/homogeneous.py | 4 +- src/sage/combinat/sf/monomial.py | 4 +- src/sage/combinat/sf/ns_macdonald.py | 14 +- src/sage/combinat/sf/powersum.py | 10 +- src/sage/combinat/sf/schur.py | 6 +- src/sage/combinat/sf/sfa.py | 12 +- src/sage/combinat/shuffle.py | 14 +- src/sage/combinat/sine_gordon.py | 2 +- src/sage/combinat/six_vertex_model.py | 22 +- src/sage/combinat/skew_partition.py | 80 ++-- src/sage/combinat/skew_tableau.py | 35 +- src/sage/combinat/subsets_hereditary.py | 12 +- src/sage/combinat/subword_complex.py | 14 +- .../symmetric_group_representations.py | 60 +-- src/sage/combinat/tableau.py | 299 +++++++-------- src/sage/combinat/tableau_tuple.py | 206 ++++++----- src/sage/combinat/tiling.py | 52 +-- src/sage/combinat/triangles_FHM.py | 46 +-- src/sage/combinat/yang_baxter_graph.py | 86 ++--- 72 files changed, 1766 insertions(+), 1719 deletions(-) diff --git a/src/sage/combinat/backtrack.py b/src/sage/combinat/backtrack.py index 777e511531f..d0669580484 100644 --- a/src/sage/combinat/backtrack.py +++ b/src/sage/combinat/backtrack.py @@ -63,7 +63,7 @@ def __iter__(self): sage: from sage.combinat.permutation import PatternAvoider sage: p = PatternAvoider(Permutations(4), [[1,3,2]]) - sage: len(list(p)) # optional - sage.combinat + sage: len(list(p)) # needs sage.combinat 14 """ # Initialize the stack of generators with the initial data. diff --git a/src/sage/combinat/baxter_permutations.py b/src/sage/combinat/baxter_permutations.py index c4f34c073f5..460969c062c 100644 --- a/src/sage/combinat/baxter_permutations.py +++ b/src/sage/combinat/baxter_permutations.py @@ -332,11 +332,12 @@ def to_pair_of_twin_binary_trees(self, p): EXAMPLES:: - sage: BaxterPermutations().to_pair_of_twin_binary_trees(Permutation([])) + sage: BP = BaxterPermutations() + sage: BP.to_pair_of_twin_binary_trees(Permutation([])) # needs sage.graphs (., .) - sage: BaxterPermutations().to_pair_of_twin_binary_trees(Permutation([1, 2, 3])) + sage: BP.to_pair_of_twin_binary_trees(Permutation([1, 2, 3])) # needs sage.graphs (1[., 2[., 3[., .]]], 3[2[1[., .], .], .]) - sage: BaxterPermutations().to_pair_of_twin_binary_trees(Permutation([3, 4, 1, 2])) + sage: BP.to_pair_of_twin_binary_trees(Permutation([3, 4, 1, 2])) # needs sage.graphs (3[1[., 2[., .]], 4[., .]], 2[1[., .], 4[3[., .], .]]) """ from sage.combinat.binary_tree import LabelledBinaryTree diff --git a/src/sage/combinat/binary_recurrence_sequences.py b/src/sage/combinat/binary_recurrence_sequences.py index b0e1309e189..9c1b9bdf931 100644 --- a/src/sage/combinat/binary_recurrence_sequences.py +++ b/src/sage/combinat/binary_recurrence_sequences.py @@ -35,7 +35,7 @@ True sage: T.is_geometric() True - sage: T.pthpowers(7, 10**30) # optional - sage.symbolic + sage: T.pthpowers(7, 10**30) # needs sage.symbolic Traceback (most recent call last): ... ValueError: the degenerate binary recurrence sequence is geometric or quasigeometric @@ -548,7 +548,7 @@ def pthpowers(self, p, Bound): True sage: T.is_geometric() True - sage: T.pthpowers(7, 10**30) # optional - sage.symbolic + sage: T.pthpowers(7, 10**30) # needs sage.symbolic Traceback (most recent call last): ... ValueError: the degenerate binary recurrence sequence is geometric or @@ -559,7 +559,7 @@ def pthpowers(self, p, Bound): [2, 2, 2^3, 2^5, 2^7, 2^9, 2^11, 2^13, 2^15, 2^17] sage: L.is_quasigeometric() True - sage: L.pthpowers(2, 10**30) # optional - sage.symbolic + sage: L.pthpowers(2, 10**30) # needs sage.symbolic [] .. NOTE:: @@ -1057,7 +1057,7 @@ def _estimated_time(M2, M1, length, p): EXAMPLES:: sage: from sage.combinat.binary_recurrence_sequences import _estimated_time - sage: _estimated_time(2**4*3**2*5*7*11*13*17, 2**4*3**2*5*7*11*13, 20, 7) # optional - sage.symbolic + sage: _estimated_time(2**4*3**2*5*7*11*13*17, 2**4*3**2*5*7*11*13, 20, 7) # needs sage.symbolic 106.211159309421 """ @@ -1093,7 +1093,7 @@ def _find_cong1(p, R, ell): EXAMPLES:: sage: R = BinaryRecurrenceSequence(1,1) - sage: sage.combinat.binary_recurrence_sequences._find_cong1(7, R, 29) # optional - sage.rings.finite_rings + sage: sage.combinat.binary_recurrence_sequences._find_cong1(7, R, 29) # needs sage.rings.finite_rings ([0, 1, 2, 12, 13], 14) """ F = GF(ell) @@ -1143,9 +1143,9 @@ def _is_p_power(a, p): EXAMPLES:: - sage: sage.combinat.binary_recurrence_sequences._is_p_power(2**7, 7) # optional - sage.symbolic + sage: sage.combinat.binary_recurrence_sequences._is_p_power(2**7, 7) # needs sage.symbolic True - sage: sage.combinat.binary_recurrence_sequences._is_p_power(2**7*3**2, 7) # optional - sage.symbolic + sage: sage.combinat.binary_recurrence_sequences._is_p_power(2**7*3**2, 7) # needs sage.symbolic False """ return int(a**(1/p))**p == a diff --git a/src/sage/combinat/binary_tree.py b/src/sage/combinat/binary_tree.py index ce60b4f8c9e..6e39535c6d5 100644 --- a/src/sage/combinat/binary_tree.py +++ b/src/sage/combinat/binary_tree.py @@ -868,7 +868,7 @@ def show(self, with_leaves=False): TESTS:: sage: t1 = BinaryTree([[], [[], None]]) - sage: t1.show() # optional - sage.plot + sage: t1.show() # needs sage.plot """ try: self.graph(with_leaves=with_leaves).show(layout='tree', tree_root=0, tree_orientation="down") @@ -989,13 +989,13 @@ def to_dyck_word_tamari(self): EXAMPLES:: - sage: BinaryTree().to_dyck_word_tamari() # optional - sage.combinat + sage: BinaryTree().to_dyck_word_tamari() # needs sage.combinat [] - sage: BinaryTree([]).to_dyck_word_tamari() # optional - sage.combinat + sage: BinaryTree([]).to_dyck_word_tamari() # needs sage.combinat [1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word_tamari() # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word_tamari() # needs sage.combinat [1, 1, 0, 0, 1, 0] - sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word_tamari() # optional - sage.combinat + sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word_tamari() # needs sage.combinat [1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0] """ return self.to_dyck_word("L1R0") @@ -1129,9 +1129,9 @@ def tamari_join(self, other): ....: return True sage: all( test_uni_join(p, q) for p in BinaryTrees(3) for q in BinaryTrees(3) ) True - sage: p = BinaryTrees(6).random_element() # optional - sage.combinat - sage: q = BinaryTrees(6).random_element() # optional - sage.combinat - sage: test_uni_join(p, q) # optional - sage.combinat + sage: p = BinaryTrees(6).random_element() # needs sage.combinat + sage: q = BinaryTrees(6).random_element() # needs sage.combinat + sage: test_uni_join(p, q) # needs sage.combinat True Border cases:: @@ -1218,9 +1218,9 @@ def tamari_meet(self, other, side="right"): ....: return True sage: all( test_uni_meet(p, q) for p in BinaryTrees(3) for q in BinaryTrees(3) ) True - sage: p = BinaryTrees(6).random_element() # optional - sage.combinat - sage: q = BinaryTrees(6).random_element() # optional - sage.combinat - sage: test_uni_meet(p, q) # optional - sage.combinat + sage: p = BinaryTrees(6).random_element() # needs sage.combinat + sage: q = BinaryTrees(6).random_element() # needs sage.combinat + sage: test_uni_meet(p, q) # needs sage.combinat True Border cases:: @@ -1256,21 +1256,21 @@ def to_dyck_word(self, usemap="1L0R"): EXAMPLES:: - sage: BinaryTree().to_dyck_word() # optional - sage.combinat + sage: BinaryTree().to_dyck_word() # needs sage.combinat [] - sage: BinaryTree([]).to_dyck_word() # optional - sage.combinat + sage: BinaryTree([]).to_dyck_word() # needs sage.combinat [1, 0] - sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word() # optional - sage.combinat + sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word() # needs sage.combinat [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word() # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word() # needs sage.combinat [1, 1, 0, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("1R0L") # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("1R0L") # needs sage.combinat [1, 0, 1, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("L1R0") # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("L1R0") # needs sage.combinat [1, 1, 0, 0, 1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("R1L0") # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("R1L0") # needs sage.combinat [1, 1, 0, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("R10L") # optional - sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("R10L") # needs sage.combinat Traceback (most recent call last): ... ValueError: R10L is not a correct map @@ -1278,13 +1278,13 @@ def to_dyck_word(self, usemap="1L0R"): TESTS:: sage: bt = BinaryTree([[[], [[], None]], [[], []]]) - sage: bt == bt.to_dyck_word().to_binary_tree() # optional - sage.combinat + sage: bt == bt.to_dyck_word().to_binary_tree() # needs sage.combinat True - sage: bt == bt.to_dyck_word("1R0L").to_binary_tree("1R0L") # optional - sage.combinat + sage: bt == bt.to_dyck_word("1R0L").to_binary_tree("1R0L") # needs sage.combinat True - sage: bt == bt.to_dyck_word("L1R0").to_binary_tree("L1R0") # optional - sage.combinat + sage: bt == bt.to_dyck_word("L1R0").to_binary_tree("L1R0") # needs sage.combinat True - sage: bt == bt.to_dyck_word("R1L0").to_binary_tree("R1L0") # optional - sage.combinat + sage: bt == bt.to_dyck_word("R1L0").to_binary_tree("R1L0") # needs sage.combinat True """ from sage.combinat.dyck_word import DyckWord @@ -1448,9 +1448,9 @@ def tamari_sorting_tuple(self, reverse=False): ((1, 0, 0), 3), ((0, 0, 0), 3)] - sage: t = BinaryTrees(10).random_element() # optional - sage.combinat - sage: u = t.left_right_symmetry() # optional - sage.combinat - sage: t.tamari_sorting_tuple(True) == u.tamari_sorting_tuple() # optional - sage.combinat + sage: t = BinaryTrees(10).random_element() # needs sage.combinat + sage: u = t.left_right_symmetry() # needs sage.combinat + sage: t.tamari_sorting_tuple(True) == u.tamari_sorting_tuple() # needs sage.combinat True REFERENCES: @@ -1617,9 +1617,9 @@ def to_tilting(self): [(0, 1), (2, 3), (4, 5), (6, 7), (4, 7), (8, 9), (10, 11), (8, 11), (4, 11), (12, 13), (4, 13), (2, 13), (0, 13)] - sage: w = DyckWord([1,1,1,1,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,1,0,0,0,0,0,0]) # optional - sage.combinat - sage: t2 = w.to_binary_tree() # optional - sage.combinat - sage: len(t2.to_tilting()) == t2.node_number() # optional - sage.combinat + sage: w = DyckWord([1,1,1,1,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,1,0,0,0,0,0,0]) # needs sage.combinat + sage: t2 = w.to_binary_tree() # needs sage.combinat + sage: len(t2.to_tilting()) == t2.node_number() # needs sage.combinat True """ if not self: @@ -2833,36 +2833,36 @@ def q_hook_length_fraction(self, q=None, q_factor=False): only one vertex (which is a leaf):: sage: b = BinaryTree() - sage: b.q_hook_length_fraction() # optional - sage.combinat + sage: b.q_hook_length_fraction() # needs sage.combinat 1 - sage: b.q_hook_length_fraction(q_factor=True) # optional - sage.combinat + sage: b.q_hook_length_fraction(q_factor=True) # needs sage.combinat 1 Nothing different for a tree with one node and two leaves:: sage: b = BinaryTree([]); b [., .] - sage: b.q_hook_length_fraction() # optional - sage.combinat + sage: b.q_hook_length_fraction() # needs sage.combinat 1 - sage: b.q_hook_length_fraction(q_factor=True) # optional - sage.combinat + sage: b.q_hook_length_fraction(q_factor=True) # needs sage.combinat 1 Let us get to a more interesting tree:: sage: b = BinaryTree([[[],[]],[[],None]]); b [[[., .], [., .]], [[., .], .]] - sage: b.q_hook_length_fraction()(q=1) # optional - sage.combinat + sage: b.q_hook_length_fraction()(q=1) # needs sage.combinat 20 - sage: b.q_hook_length_fraction() # optional - sage.combinat + sage: b.q_hook_length_fraction() # needs sage.combinat q^7 + 2*q^6 + 3*q^5 + 4*q^4 + 4*q^3 + 3*q^2 + 2*q + 1 - sage: b.q_hook_length_fraction(q_factor=True) # optional - sage.combinat + sage: b.q_hook_length_fraction(q_factor=True) # needs sage.combinat q^10 + 2*q^9 + 3*q^8 + 4*q^7 + 4*q^6 + 3*q^5 + 2*q^4 + q^3 - sage: b.q_hook_length_fraction(q=2) # optional - sage.combinat + sage: b.q_hook_length_fraction(q=2) # needs sage.combinat 465 - sage: b.q_hook_length_fraction(q=2, q_factor=True) # optional - sage.combinat + sage: b.q_hook_length_fraction(q=2, q_factor=True) # needs sage.combinat 3720 sage: q = PolynomialRing(ZZ, 'q').gen() - sage: b.q_hook_length_fraction(q=q**2) # optional - sage.combinat + sage: b.q_hook_length_fraction(q=q**2) # needs sage.combinat q^14 + 2*q^12 + 3*q^10 + 4*q^8 + 4*q^6 + 3*q^4 + 2*q^2 + 1 Let us check the fact that `f_{q} (T)` is the generating function @@ -2881,7 +2881,7 @@ def q_hook_length_fraction(self, q=None, q_factor=False): ....: return all( q_hook_length_fraction_2(T) ....: == T.q_hook_length_fraction(q_factor=True) ....: for T in BinaryTrees(i) ) - sage: test_genfun(4) # optional - sage.combinat + sage: test_genfun(4) # needs sage.combinat True """ from sage.combinat.q_analogues import q_binomial @@ -3400,29 +3400,29 @@ def dendriform_shuffle(self, other): sage: l = BinaryTree([g, u]) sage: r = BinaryTree([u, g]) - sage: list(g.dendriform_shuffle(g)) # optional - sage.combinat + sage: list(g.dendriform_shuffle(g)) # needs sage.combinat [[[., .], .], [., [., .]]] - sage: list(l.dendriform_shuffle(l)) # optional - sage.combinat + sage: list(l.dendriform_shuffle(l)) # needs sage.combinat [[[[[., .], .], .], .], [[[., .], [., .]], .], [[., .], [[., .], .]]] - sage: list(l.dendriform_shuffle(r)) # optional - sage.combinat + sage: list(l.dendriform_shuffle(r)) # needs sage.combinat [[[[., .], .], [., .]], [[., .], [., [., .]]]] TESTS:: - sage: list(u.dendriform_shuffle(u)) # optional - sage.combinat + sage: list(u.dendriform_shuffle(u)) # needs sage.combinat [.] - sage: list(u.dendriform_shuffle(g)) # optional - sage.combinat + sage: list(u.dendriform_shuffle(g)) # needs sage.combinat [[., .]] - sage: list(u.dendriform_shuffle(l)) # optional - sage.combinat + sage: list(u.dendriform_shuffle(l)) # needs sage.combinat [[[., .], .]] - sage: list(u.dendriform_shuffle(r)) # optional - sage.combinat + sage: list(u.dendriform_shuffle(r)) # needs sage.combinat [[., [., .]]] - sage: list(r.dendriform_shuffle(u)) # optional - sage.combinat + sage: list(r.dendriform_shuffle(u)) # needs sage.combinat [[., [., .]]] - sage: list(l.dendriform_shuffle(u)) # optional - sage.combinat + sage: list(l.dendriform_shuffle(u)) # needs sage.combinat [[[., .], .]] """ from sage.combinat.words.shuffle_product import ShuffleProduct_w1w2 @@ -3532,32 +3532,33 @@ def sylvester_class(self, left_to_right=False): ....: if not BinaryTree(tree) == t: ....: return False ....: return True - sage: test_bst_of_sc(4, False) # optional - sage.combinat + sage: test_bst_of_sc(4, False) # needs sage.combinat True - sage: test_bst_of_sc(5, False) # long time # optional - sage.combinat + sage: test_bst_of_sc(5, False) # long time # needs sage.combinat True The same with the left-to-right version of binary search:: - sage: test_bst_of_sc(4, True) # optional - sage.combinat + sage: test_bst_of_sc(4, True) # needs sage.combinat True - sage: test_bst_of_sc(5, True) # long time # optional - sage.combinat + sage: test_bst_of_sc(5, True) # long time # needs sage.combinat True Checking that the sylvester class is the set of linear extensions of the poset of the tree:: - sage: all( sorted(t.canonical_labelling().sylvester_class()) # optional - sage.combinat - ....: == sorted(list(v) for v in t.canonical_labelling().to_poset().linear_extensions()) - ....: for t in BinaryTrees(4) ) + sage: all(sorted(t.canonical_labelling().sylvester_class()) # needs sage.combinat sage.modules + ....: == sorted(list(v) + ....: for v in t.canonical_labelling().to_poset().linear_extensions()) + ....: for t in BinaryTrees(4)) True TESTS:: - sage: list(BinaryTree([[],[]]).sylvester_class()) # optional - sage.combinat + sage: list(BinaryTree([[],[]]).sylvester_class()) # needs sage.combinat [[1, 3, 2], [3, 1, 2]] sage: bt = BinaryTree([[[],None],[[],[]]]) - sage: l = list(bt.sylvester_class()); l # optional - sage.combinat + sage: l = list(bt.sylvester_class()); l # needs sage.combinat [[1, 2, 4, 6, 5, 3], [1, 4, 2, 6, 5, 3], [1, 4, 6, 2, 5, 3], @@ -3578,14 +3579,14 @@ def sylvester_class(self, left_to_right=False): [6, 4, 1, 2, 5, 3], [6, 4, 1, 5, 2, 3], [6, 4, 5, 1, 2, 3]] - sage: len(l) == Integer(bt.q_hook_length_fraction()(q=1)) # optional - sage.combinat + sage: len(l) == Integer(bt.q_hook_length_fraction()(q=1)) # needs sage.combinat True Border cases:: - sage: list(BinaryTree().sylvester_class()) # optional - sage.combinat + sage: list(BinaryTree().sylvester_class()) # needs sage.combinat [[]] - sage: list(BinaryTree([]).sylvester_class()) # optional - sage.combinat + sage: list(BinaryTree([]).sylvester_class()) # needs sage.combinat [[1]] """ if self.is_empty(): @@ -4051,8 +4052,8 @@ def from_tamari_sorting_tuple(key): EXAMPLES:: sage: from sage.combinat.binary_tree import from_tamari_sorting_tuple - sage: t = BinaryTrees(60).random_element() # optional - sage.combinat - sage: from_tamari_sorting_tuple(t.tamari_sorting_tuple()[0]) == t # optional - sage.combinat + sage: t = BinaryTrees(60).random_element() # needs sage.combinat + sage: from_tamari_sorting_tuple(t.tamari_sorting_tuple()[0]) == t # needs sage.combinat True """ if not key: @@ -4256,16 +4257,16 @@ def random_element(self): EXAMPLES:: - sage: BinaryTrees(5).random_element() # random # optional - sage.combinat + sage: BinaryTrees(5).random_element() # random # needs sage.combinat [., [., [., [., [., .]]]]] - sage: BinaryTrees(0).random_element() # optional - sage.combinat + sage: BinaryTrees(0).random_element() # needs sage.combinat . - sage: BinaryTrees(1).random_element() # optional - sage.combinat + sage: BinaryTrees(1).random_element() # needs sage.combinat [., .] TESTS:: - sage: all(BinaryTrees(10).random_element() in BinaryTrees(10) # optional - sage.combinat + sage: all(BinaryTrees(10).random_element() in BinaryTrees(10) # needs sage.combinat ....: for i in range(20)) True """ @@ -4511,17 +4512,17 @@ def random_element(self): EXAMPLES:: - sage: BinaryTrees(5, full=True).random_element() # random # optional - sage.combinat + sage: BinaryTrees(5, full=True).random_element() # random # needs sage.combinat [[], [[], []]] - sage: BinaryTrees(0, full=True).random_element() # optional - sage.combinat + sage: BinaryTrees(0, full=True).random_element() # needs sage.combinat . - sage: BinaryTrees(1, full=True).random_element() # optional - sage.combinat + sage: BinaryTrees(1, full=True).random_element() # needs sage.combinat [., .] TESTS:: sage: B = BinaryTrees(19, full=True) - sage: all(B.random_element() in B for i in range(20)) # optional - sage.combinat + sage: all(B.random_element() in B for i in range(20)) # needs sage.combinat True """ from sage.combinat.dyck_word import CompleteDyckWords_size diff --git a/src/sage/combinat/colored_permutations.py b/src/sage/combinat/colored_permutations.py index ff9a67e3083..2d6a6c31aaa 100644 --- a/src/sage/combinat/colored_permutations.py +++ b/src/sage/combinat/colored_permutations.py @@ -259,14 +259,14 @@ def to_matrix(self): sage: s1,s2,t = C.gens() sage: x = s1*s2*t*s2; x.one_line_form() [(1, 2), (0, 1), (0, 3)] - sage: M = x.to_matrix(); M + sage: M = x.to_matrix(); M # needs sage.rings.number_field [ 0 1 0] [zeta4 0 0] [ 0 0 1] The matrix multiplication is in the *opposite* order:: - sage: M == s2.to_matrix()*t.to_matrix()*s2.to_matrix()*s1.to_matrix() + sage: M == s2.to_matrix()*t.to_matrix()*s2.to_matrix()*s1.to_matrix() # needs sage.rings.number_field True """ Cp = CyclotomicField(self.parent()._m) @@ -541,14 +541,14 @@ def coxeter_matrix(self): EXAMPLES:: sage: C = ColoredPermutations(3, 4) - sage: C.coxeter_matrix() + sage: C.coxeter_matrix() # needs sage.modules [1 3 2 2] [3 1 3 2] [2 3 1 4] [2 2 4 1] sage: C = ColoredPermutations(1, 4) - sage: C.coxeter_matrix() + sage: C.coxeter_matrix() # needs sage.modules [1 3 2] [3 1 3] [2 3 1] @@ -556,7 +556,7 @@ def coxeter_matrix(self): TESTS:: sage: S = SignedPermutations(4) - sage: S.coxeter_matrix() + sage: S.coxeter_matrix() # needs sage.modules [1 3 2 2] [3 1 3 2] [2 3 1 4] @@ -676,7 +676,7 @@ def matrix_group(self): EXAMPLES:: sage: C = ColoredPermutations(4, 3) - sage: C.matrix_group() + sage: C.matrix_group() # needs sage.modules Matrix group over Cyclotomic Field of order 4 and degree 2 with 3 generators ( [0 1 0] [1 0 0] [ 1 0 0] [1 0 0] [0 0 1] [ 0 1 0] @@ -693,7 +693,7 @@ def as_permutation_group(self): EXAMPLES:: sage: C = ColoredPermutations(4, 3) - sage: C.as_permutation_group() + sage: C.as_permutation_group() # needs sage.groups Complex reflection group G(4, 1, 3) as a permutation group """ from sage.groups.perm_gps.permgroup_named import ComplexReflectionGroup @@ -896,8 +896,8 @@ def codegrees(self): sage: C = ColoredPermutations(3, 2) sage: f = prod(q - ds - 1 for ds in C.codegrees()) sage: d = lambda x: sum(1 for e in x.to_matrix().eigenvalues() if e == 1) - sage: g = sum(det(x.to_matrix()) * q**d(x) for x in C) - sage: f == g + sage: g = sum(det(x.to_matrix()) * q**d(x) for x in C) # needs sage.modules sage.rings.number_field + sage: f == g # needs sage.modules sage.rings.number_field True """ # Special case for the usual symmetric group @@ -1156,7 +1156,7 @@ def to_matrix(self): sage: S = SignedPermutations(4) sage: s1,s2,s3,s4 = S.gens() sage: x = s4*s1*s2*s3*s4 - sage: M = x.to_matrix(); M + sage: M = x.to_matrix(); M # needs sage.modules [ 0 1 0 0] [ 0 0 1 0] [ 0 0 0 -1] @@ -1164,8 +1164,8 @@ def to_matrix(self): The matrix multiplication is in the *opposite* order:: - sage: m1,m2,m3,m4 = [g.to_matrix() for g in S.gens()] - sage: M == m4 * m3 * m2 * m1 * m4 + sage: m1,m2,m3,m4 = [g.to_matrix() for g in S.gens()] # needs sage.modules + sage: M == m4 * m3 * m2 * m1 * m4 # needs sage.modules True """ return self._perm.to_matrix() * diagonal_matrix(self._colors) @@ -1344,8 +1344,9 @@ class SignedPermutations(ColoredPermutations): This is a finite Coxeter group of type `B_n`:: - sage: S.canonical_representation() - Finite Coxeter group over Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? with Coxeter matrix: + sage: S.canonical_representation() # needs sage.modules + Finite Coxeter group over Number Field in a with defining polynomial x^2 - 2 + with a = 1.414213562373095? with Coxeter matrix: [1 3 2 2] [3 1 3 2] [2 3 1 4] diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 4c182f7c0da..8583ffa89ca 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -319,17 +319,18 @@ def bell_number(n, algorithm='flint', **options) -> Integer: EXAMPLES:: - sage: bell_number(10) # optional - sage.libs.flint + sage: # needs sage.libs.flint + sage: bell_number(10) 115975 - sage: bell_number(2) # optional - sage.libs.flint + sage: bell_number(2) 2 - sage: bell_number(-10) # optional - sage.libs.flint + sage: bell_number(-10) Traceback (most recent call last): ... ArithmeticError: Bell numbers not defined for negative indices - sage: bell_number(1) # optional - sage.libs.flint + sage: bell_number(1) 1 - sage: bell_number(1/3) # optional - sage.libs.flint + sage: bell_number(1/3) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer @@ -339,17 +340,17 @@ def bell_number(n, algorithm='flint', **options) -> Integer: first time, we deem the precision too low, we use our guess to (temporarily) raise mpmath's precision and the Bell number is recomputed. :: - sage: k = bell_number(30, 'mpmath'); k # optional - mpmath + sage: k = bell_number(30, 'mpmath'); k # needs mpmath 846749014511809332450147 - sage: k == bell_number(30) # optional - mpmath sage.libs.flint + sage: k == bell_number(30) # needs mpmath sage.libs.flint True If you knows what precision is necessary before computing the Bell number, you can use the ``prec`` option:: - sage: k2 = bell_number(30, 'mpmath', prec=30); k2 # optional - mpmath + sage: k2 = bell_number(30, 'mpmath', prec=30); k2 # needs mpmath 846749014511809332450147 - sage: k == k2 # optional - mpmath + sage: k == k2 # needs mpmath True .. WARNING:: @@ -357,18 +358,18 @@ def bell_number(n, algorithm='flint', **options) -> Integer: Running mpmath with the precision set too low can result in incorrect results:: - sage: k = bell_number(30, 'mpmath', prec=15); k # optional - mpmath + sage: k = bell_number(30, 'mpmath', prec=15); k # needs mpmath 846749014511809388871680 - sage: k == bell_number(30) # optional - mpmath sage.libs.flint + sage: k == bell_number(30) # needs mpmath sage.libs.flint False TESTS:: - sage: all(bell_number(n) == bell_number(n,'dobinski') for n in range(100)) # optional - sage.libs.flint + sage: all(bell_number(n) == bell_number(n,'dobinski') for n in range(100)) # needs sage.libs.flint True - sage: all(bell_number(n) == bell_number(n,'gap') for n in range(100)) # optional - sage.libs.flint sage.libs.gap + sage: all(bell_number(n) == bell_number(n,'gap') for n in range(100)) # needs sage.libs.flint sage.libs.gap True - sage: all(bell_number(n) == bell_number(n,'mpmath', prec=500) # optional - mpmath sage.libs.flint + sage: all(bell_number(n) == bell_number(n,'mpmath', prec=500) # needs mpmath sage.libs.flint ....: for n in range(200, 220)) True @@ -548,12 +549,12 @@ def euler_number(n, algorithm='flint') -> Integer: EXAMPLES:: - sage: [euler_number(i) for i in range(10)] # optional - sage.libs.flint + sage: [euler_number(i) for i in range(10)] # needs sage.libs.flint [1, 0, -1, 0, 5, 0, -61, 0, 1385, 0] sage: x = PowerSeriesRing(QQ, 'x').gen().O(10) - sage: 2/(exp(x)+exp(-x)) # optional - sage.symbolic + sage: 2/(exp(x)+exp(-x)) # needs sage.symbolic 1 - 1/2*x^2 + 5/24*x^4 - 61/720*x^6 + 277/8064*x^8 + O(x^10) - sage: [euler_number(i)/factorial(i) for i in range(11)] # optional - sage.libs.flint + sage: [euler_number(i)/factorial(i) for i in range(11)] # needs sage.libs.flint [1, 0, -1/2, 0, 5/24, 0, -61/720, 0, 277/8064, 0, -50521/3628800] sage: euler_number(-1) Traceback (most recent call last): @@ -562,7 +563,7 @@ def euler_number(n, algorithm='flint') -> Integer: TESTS:: - sage: euler_number(6, 'maxima') # optional - sage.symbolic + sage: euler_number(6, 'maxima') # needs sage.symbolic -61 REFERENCES: @@ -706,21 +707,21 @@ def fibonacci(n, algorithm="pari") -> Integer: EXAMPLES:: - sage: fibonacci(10) # optional - sage.libs.pari + sage: fibonacci(10) # needs sage.libs.pari 55 - sage: fibonacci(10, algorithm='gap') # optional - sage.libs.gap + sage: fibonacci(10, algorithm='gap') # needs sage.libs.gap 55 :: - sage: fibonacci(-100) # optional - sage.libs.pari + sage: fibonacci(-100) # needs sage.libs.pari -354224848179261915075 - sage: fibonacci(100) # optional - sage.libs.pari + sage: fibonacci(100) # needs sage.libs.pari 354224848179261915075 :: - sage: fibonacci(0) # optional - sage.libs.pari + sage: fibonacci(0) # needs sage.libs.pari 0 sage: fibonacci(1/2) Traceback (most recent call last): @@ -759,17 +760,18 @@ def lucas_number1(n, P, Q): EXAMPLES:: - sage: lucas_number1(5,1,-1) # optional - sage.libs.gap + sage: # needs sage.libs.gap + sage: lucas_number1(5,1,-1) 5 - sage: lucas_number1(6,1,-1) # optional - sage.libs.gap + sage: lucas_number1(6,1,-1) 8 - sage: lucas_number1(7,1,-1) # optional - sage.libs.gap + sage: lucas_number1(7,1,-1) 13 - sage: lucas_number1(7,1,-2) # optional - sage.libs.gap + sage: lucas_number1(7,1,-2) 43 - sage: lucas_number1(5,2,3/5) # optional - sage.libs.gap + sage: lucas_number1(5,2,3/5) 229/25 - sage: lucas_number1(5,2,1.5) # optional - sage.libs.gap + sage: lucas_number1(5,2,1.5) 1/4 There was a conjecture that the sequence `L_n` defined by @@ -779,7 +781,7 @@ def lucas_number1(n, P, Q): sage: def lucas(n): ....: return Integer((5/2)*lucas_number1(n,1,-1) + (1/2)*lucas_number2(n,1,-1)) - sage: [[lucas(n), is_prime(lucas(n)), n+1, is_prime(n+1)] for n in range(15)] # optional - sage.libs.gap + sage: [[lucas(n), is_prime(lucas(n)), n+1, is_prime(n+1)] for n in range(15)] # needs sage.libs.gap [[1, False, 1, False], [3, True, 2, True], [4, False, 3, True], @@ -827,26 +829,27 @@ def lucas_number2(n, P, Q): EXAMPLES:: - sage: [lucas_number2(i,1,-1) for i in range(10)] # optional - sage.libs.gap + sage: [lucas_number2(i,1,-1) for i in range(10)] # needs sage.libs.gap [2, 1, 3, 4, 7, 11, 18, 29, 47, 76] - sage: [fibonacci(i-1)+fibonacci(i+1) for i in range(10)] # optional - sage.libs.pari + sage: [fibonacci(i-1)+fibonacci(i+1) for i in range(10)] # needs sage.libs.pari [2, 1, 3, 4, 7, 11, 18, 29, 47, 76] :: - sage: n = lucas_number2(5,2,3); n # optional - sage.libs.gap + sage: # needs sage.libs.gap + sage: n = lucas_number2(5,2,3); n 2 - sage: type(n) # optional - sage.libs.gap + sage: type(n) - sage: n = lucas_number2(5,2,-3/9); n # optional - sage.libs.gap + sage: n = lucas_number2(5,2,-3/9); n 418/9 - sage: type(n) # optional - sage.libs.gap + sage: type(n) The case `P=1`, `Q=-1` is the Lucas sequence in Brualdi's Introductory Combinatorics, 4th ed., Prentice-Hall, 2004:: - sage: [lucas_number2(n,1,-1) for n in range(10)] # optional - sage.libs.gap + sage: [lucas_number2(n,1,-1) for n in range(10)] # needs sage.libs.gap [2, 1, 3, 4, 7, 11, 18, 29, 47, 76] """ n = ZZ(n) @@ -875,20 +878,21 @@ def stirling_number1(n, k, algorithm="gap") -> Integer: EXAMPLES:: - sage: stirling_number1(3,2) # optional - sage.libs.gap + sage: # needs sage.libs.gap + sage: stirling_number1(3,2) 3 - sage: stirling_number1(5,2) # optional - sage.libs.gap + sage: stirling_number1(5,2) 50 - sage: 9*stirling_number1(9,5) + stirling_number1(9,4) # optional - sage.libs.gap + sage: 9*stirling_number1(9,5) + stirling_number1(9,4) 269325 - sage: stirling_number1(10,5) # optional - sage.libs.gap + sage: stirling_number1(10,5) 269325 Indeed, `S_1(n,k) = S_1(n-1,k-1) + (n-1)S_1(n-1,k)`. TESTS:: - sage: stirling_number1(10,5, algorithm='flint') # optional - sage.libs.flint + sage: stirling_number1(10,5, algorithm='flint') # needs sage.libs.flint 269325 sage: s_sage = stirling_number1(50,3, algorithm="mutta") @@ -981,13 +985,13 @@ def stirling_number2(n, k, algorithm=None) -> Integer: 1900842429486 sage: type(n) - sage: n = stirling_number2(20, 11, algorithm='gap'); n # optional - sage.libs.gap + sage: n = stirling_number2(20, 11, algorithm='gap'); n # needs sage.libs.gap 1900842429486 - sage: type(n) # optional - sage.libs.gap + sage: type(n) # needs sage.libs.gap - sage: n = stirling_number2(20, 11, algorithm='flint'); n # optional - sage.libs.flint + sage: n = stirling_number2(20, 11, algorithm='flint'); n # needs sage.libs.flint 1900842429486 - sage: type(n) # optional - sage.libs.flint + sage: type(n) # needs sage.libs.flint Sage's implementation splitting the computation of the Stirling @@ -996,7 +1000,7 @@ def stirling_number2(n, k, algorithm=None) -> Integer: For `n<200`:: - sage: for n in Subsets(range(100,200), 5).random_element(): # optional - sage.libs.flint sage.libs.gap + sage: for n in Subsets(range(100,200), 5).random_element(): # needs sage.libs.flint sage.libs.gap ....: for k in Subsets(range(n), 5).random_element(): ....: s_sage = stirling_number2(n,k) ....: s_flint = stirling_number2(n,k, algorithm = "flint") @@ -1006,7 +1010,7 @@ def stirling_number2(n, k, algorithm=None) -> Integer: For `n\geq 200`:: - sage: for n in Subsets(range(200,300), 5).random_element(): # optional - sage.libs.flint sage.libs.gap + sage: for n in Subsets(range(200,300), 5).random_element(): # needs sage.libs.flint sage.libs.gap ....: for k in Subsets(range(n), 5).random_element(): ....: s_sage = stirling_number2(n,k) ....: s_flint = stirling_number2(n,k, algorithm = "flint") @@ -1014,7 +1018,7 @@ def stirling_number2(n, k, algorithm=None) -> Integer: ....: if not (s_sage == s_flint and s_sage == s_gap): ....: print("Error with n<200") - sage: stirling_number2(20, 3, algorithm="maxima") # optional - sage.symbolic + sage: stirling_number2(20, 3, algorithm="maxima") # needs sage.symbolic 580606446 sage: s_sage = stirling_number2(5, 3, algorithm="namba") @@ -1173,11 +1177,12 @@ def __init__(self, l, copy=True): Test indirectly that we copy the input (see :trac:`18184`):: - sage: L = IntegerListsLex(element_class=Partition) # optional - sage.combinat - sage: x = [3, 2, 1] # optional - sage.combinat - sage: P = L(x) # optional - sage.combinat - sage: x[0] = 5 # optional - sage.combinat - sage: list(P) # optional - sage.combinat + sage: # needs sage.combinat + sage: L = IntegerListsLex(element_class=Partition) + sage: x = [3, 2, 1] + sage: P = L(x) + sage: x[0] = 5 + sage: list(P) [3, 2, 1] """ if copy: @@ -1511,13 +1516,14 @@ class CombinatorialElement(CombinatorialObject, Element, EXAMPLES:: + sage: # needs sage.combinat sage: from sage.combinat.combinat import CombinatorialElement - sage: e = CombinatorialElement(Partitions(6), [3,2,1]) # optional - sage.combinat - sage: e == loads(dumps(e)) # optional - sage.combinat + sage: e = CombinatorialElement(Partitions(6), [3,2,1]) + sage: e == loads(dumps(e)) True - sage: parent(e) # optional - sage.combinat + sage: parent(e) Partitions of the integer 6 - sage: list(e) # optional - sage.combinat + sage: list(e) [3, 2, 1] Check classcalls:: @@ -1615,7 +1621,7 @@ def is_finite(self) -> bool: EXAMPLES:: - sage: Partitions(5).is_finite() # optional - sage.combinat + sage: Partitions(5).is_finite() # needs sage.combinat True sage: Permutations().is_finite() False @@ -1649,7 +1655,7 @@ def __str__(self) -> str: EXAMPLES:: - sage: str(Partitions(5)) # optional - sage.combinat + sage: str(Partitions(5)) # needs sage.combinat 'Partitions of the integer 5' """ return repr(self) @@ -1658,7 +1664,7 @@ def _repr_(self) -> str: """ EXAMPLES:: - sage: repr(Partitions(5)) # indirect doctest # optional - sage.combinat + sage: repr(Partitions(5)) # indirect doctest # needs sage.combinat 'Partitions of the integer 5' """ if hasattr(self, '_name') and self._name: @@ -1681,7 +1687,7 @@ def __contains__(self, x) -> bool: EXAMPLES:: sage: C = CombinatorialClass() - sage: x in C # optional - sage.symbolic + sage: x in C # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError @@ -1696,11 +1702,12 @@ def __eq__(self, other): EXAMPLES:: - sage: p5 = Partitions(5) # optional - sage.combinat - sage: p6 = Partitions(6) # optional - sage.combinat - sage: repr(p5) == repr(p6) # optional - sage.combinat + sage: # needs sage.combinat + sage: p5 = Partitions(5) + sage: p6 = Partitions(6) + sage: repr(p5) == repr(p6) False - sage: p5 == p6 # optional - sage.combinat + sage: p5 == p6 False """ return repr(self) == repr(other) @@ -1711,9 +1718,9 @@ def __ne__(self, other): EXAMPLES:: - sage: p5 = Partitions(5) # optional - sage.combinat - sage: p6 = Partitions(6) # optional - sage.combinat - sage: p5 != p6 # optional - sage.combinat + sage: p5 = Partitions(5) # needs sage.combinat + sage: p6 = Partitions(6) # needs sage.combinat + sage: p5 != p6 # needs sage.combinat True """ return not (self == other) @@ -1765,14 +1772,15 @@ def __call__(self, x): EXAMPLES:: - sage: p5 = Partitions(5) # optional - sage.combinat - sage: a = [2,2,1] # optional - sage.combinat - sage: type(a) # optional - sage.combinat + sage: # needs sage.combinat + sage: p5 = Partitions(5) + sage: a = [2,2,1] + sage: type(a) - sage: a = p5(a) # optional - sage.combinat - sage: type(a) # optional - sage.combinat + sage: a = p5(a) + sage: type(a) - sage: p5([2,1]) # optional - sage.combinat + sage: p5([2,1]) Traceback (most recent call last): ... ValueError: [2, 1] is not an element of Partitions of the integer 5 @@ -1794,8 +1802,8 @@ def element_class(self): TESTS:: - sage: P5 = Partitions(5) # optional - sage.combinat - sage: P5.element_class # optional - sage.combinat + sage: P5 = Partitions(5) # needs sage.combinat + sage: P5.element_class # needs sage.combinat """ # assert not isinstance(self, Parent) # Raises an alert if we override the proper definition from Parent @@ -1810,9 +1818,9 @@ def _element_constructor_(self, x): TESTS:: - sage: P5 = Partitions(5) # optional - sage.combinat - sage: p = P5([3,2]) # indirect doctest # optional - sage.combinat - sage: type(p) # optional - sage.combinat + sage: P5 = Partitions(5) # needs sage.combinat + sage: p = P5([3,2]) # indirect doctest # needs sage.combinat + sage: type(p) # needs sage.combinat """ # assert not isinstance(self, Parent) # Raises an alert if we override the proper definition from Parent @@ -1947,8 +1955,8 @@ def __iter__(self): EXAMPLES:: - sage: p5 = Partitions(5) # optional - sage.combinat - sage: [i for i in p5] # optional - sage.combinat + sage: p5 = Partitions(5) # needs sage.combinat + sage: [i for i in p5] # needs sage.combinat [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] sage: C = CombinatorialClass() sage: iter(C) @@ -2115,7 +2123,7 @@ def filter(self, f, name=None): sage: from sage.combinat.combinat import Permutations_CC sage: P = Permutations_CC(3).filter(lambda x: x.avoids([1,2])) - sage: P.list() # optional - sage.combinat + sage: P.list() # needs sage.combinat [[3, 2, 1]] """ return FilteredCombinatorialClass(self, f, name=name) @@ -2160,15 +2168,15 @@ class by `f`, as a combinatorial class. If the function is not injective, then there may be repeated elements:: - sage: P = Partitions(4) # optional - sage.combinat - sage: P.list() # optional - sage.combinat + sage: P = Partitions(4) # needs sage.combinat + sage: P.list() # needs sage.combinat [[4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1]] - sage: P.map(len).list() # optional - sage.combinat + sage: P.map(len).list() # needs sage.combinat [1, 2, 2, 3, 4] Use ``is_injective=False`` to get a correct result in this case:: - sage: P.map(len, is_injective=False).list() # optional - sage.combinat + sage: P.map(len, is_injective=False).list() # needs sage.combinat [1, 2, 3, 4] TESTS:: @@ -2224,9 +2232,9 @@ def __contains__(self, x) -> bool: False sage: [4,3,2,1] in P False - sage: Permutation([1,2,3]) in P # optional - sage.combinat + sage: Permutation([1,2,3]) in P # needs sage.combinat False - sage: Permutation([3,2,1]) in P # optional - sage.combinat + sage: Permutation([3,2,1]) in P # needs sage.combinat True """ return x in self.combinatorial_class and self.f(x) @@ -2237,7 +2245,7 @@ def cardinality(self) -> Integer: sage: from sage.combinat.combinat import Permutations_CC sage: P = Permutations_CC(3).filter(lambda x: x.avoids([1,2])) - sage: P.cardinality() # optional - sage.combinat + sage: P.cardinality() # needs sage.combinat 1 """ c = 0 @@ -2251,7 +2259,7 @@ def __iter__(self) -> Iterator: sage: from sage.combinat.combinat import Permutations_CC sage: P = Permutations_CC(3).filter(lambda x: x.avoids([1,2])) - sage: list(P) # optional - sage.combinat + sage: list(P) # needs sage.combinat [[3, 2, 1]] """ for x in self.combinatorial_class: @@ -2480,13 +2488,14 @@ class MapCombinatorialClass(ImageSubobject, CombinatorialClass): EXAMPLES:: - sage: R = SymmetricGroup(10).map(attrcall('reduced_word')) # optional - sage.groups - sage: R.an_element() # optional - sage.groups + sage: # needs sage.groups + sage: R = SymmetricGroup(10).map(attrcall('reduced_word')) + sage: R.an_element() [9, 8, 7, 6, 5, 4, 3, 2] - sage: R.cardinality() # optional - sage.groups + sage: R.cardinality() 3628800 - sage: i = iter(R) # optional - sage.groups - sage: next(i), next(i), next(i) # optional - sage.groups + sage: i = iter(R) + sage: next(i), next(i), next(i) ([], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1]) """ @@ -2494,7 +2503,7 @@ def __init__(self, cc, f, name=None, *, is_injective=True): """ TESTS:: - sage: Partitions(3).map(attrcall('conjugate')) # optional - sage.combinat + sage: Partitions(3).map(attrcall('conjugate')) # needs sage.combinat Image of Partitions of the integer 3 by The map *.conjugate() from Partitions of the integer 3 """ @@ -2623,9 +2632,9 @@ def tuples(S, k, algorithm='itertools'): :: - sage: K. = GF(4, 'a') # optional - sage.rings.finite_rings - sage: mset = [x for x in K if x != 0] # optional - sage.rings.finite_rings - sage: tuples(mset, 2) # optional - sage.rings.finite_rings + sage: K. = GF(4, 'a') # needs sage.rings.finite_rings + sage: mset = [x for x in K if x != 0] # needs sage.rings.finite_rings + sage: tuples(mset, 2) # needs sage.rings.finite_rings [(a, a), (a, a + 1), (a, 1), (a + 1, a), (a + 1, a + 1), (a + 1, 1), (1, a), (1, a + 1), (1, 1)] @@ -2709,16 +2718,16 @@ def number_of_tuples(S, k, algorithm='naive') -> Integer: sage: S = [1,2,3,4,5] sage: number_of_tuples(S,2) 25 - sage: number_of_tuples(S,2, algorithm="gap") # optional - sage.libs.gap + sage: number_of_tuples(S,2, algorithm="gap") # needs sage.libs.gap 25 sage: S = [1,1,2,3,4,5] sage: number_of_tuples(S,2) 25 - sage: number_of_tuples(S,2, algorithm="gap") # optional - sage.libs.gap + sage: number_of_tuples(S,2, algorithm="gap") # needs sage.libs.gap 25 sage: number_of_tuples(S,0) 1 - sage: number_of_tuples(S,0, algorithm="gap") # optional - sage.libs.gap + sage: number_of_tuples(S,0, algorithm="gap") # needs sage.libs.gap 1 """ if algorithm == 'naive': @@ -2770,7 +2779,7 @@ def unordered_tuples(S, k, algorithm='itertools'): We check that this agrees with GAP:: - sage: unordered_tuples(S, 3, algorithm='gap') # optional - sage.libs.gap + sage: unordered_tuples(S, 3, algorithm='gap') # needs sage.libs.gap [(1, 1, 1), (1, 1, 2), (1, 2, 2), (2, 2, 2)] We check the result on strings:: @@ -2778,13 +2787,13 @@ def unordered_tuples(S, k, algorithm='itertools'): sage: S = ["a","b","c"] sage: unordered_tuples(S, 2) [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')] - sage: unordered_tuples(S, 2, algorithm='gap') # optional - sage.libs.gap + sage: unordered_tuples(S, 2, algorithm='gap') # needs sage.libs.gap [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')] Lastly we check on a multiset:: sage: S = [1,1,2] - sage: unordered_tuples(S, 3) == unordered_tuples(S, 3, 'gap') # optional - sage.libs.gap + sage: unordered_tuples(S, 3) == unordered_tuples(S, 3, 'gap') # needs sage.libs.gap True sage: unordered_tuples(S, 3) [(1, 1, 1), (1, 1, 2), (1, 2, 2), (2, 2, 2)] @@ -2825,16 +2834,16 @@ def number_of_unordered_tuples(S, k, algorithm='naive') -> Integer: sage: S = [1,2,3,4,5] sage: number_of_unordered_tuples(S,2) 15 - sage: number_of_unordered_tuples(S,2, algorithm="gap") # optional - sage.libs.gap + sage: number_of_unordered_tuples(S,2, algorithm="gap") # needs sage.libs.gap 15 sage: S = [1,1,2,3,4,5] sage: number_of_unordered_tuples(S,2) 15 - sage: number_of_unordered_tuples(S,2, algorithm="gap") # optional - sage.libs.gap + sage: number_of_unordered_tuples(S,2, algorithm="gap") # needs sage.libs.gap 15 sage: number_of_unordered_tuples(S,0) 1 - sage: number_of_unordered_tuples(S,0, algorithm="gap") # optional - sage.libs.gap + sage: number_of_unordered_tuples(S,0, algorithm="gap") # needs sage.libs.gap 1 """ if algorithm == 'naive': @@ -2934,19 +2943,19 @@ def bell_polynomial(n: Integer, k: Integer): EXAMPLES:: - sage: bell_polynomial(6,2) # optional - sage.combinat + sage: bell_polynomial(6,2) # needs sage.combinat 10*x2^2 + 15*x1*x3 + 6*x0*x4 - sage: bell_polynomial(6,3) # optional - sage.combinat + sage: bell_polynomial(6,3) # needs sage.combinat 15*x1^3 + 60*x0*x1*x2 + 15*x0^2*x3 TESTS: Check that :trac:`18338` is fixed:: - sage: bell_polynomial(0,0).parent() # optional - sage.combinat + sage: bell_polynomial(0,0).parent() # needs sage.combinat Multivariate Polynomial Ring in x over Integer Ring - sage: for n in (0..4): # optional - sage.combinat + sage: for n in (0..4): # needs sage.combinat ....: print([bell_polynomial(n,k).coefficients() for k in (0..n)]) [[1]] [[], [1]] @@ -2997,12 +3006,12 @@ def fibonacci_sequence(start, stop=None, algorithm=None) -> Iterator: EXAMPLES:: - sage: fibs = [i for i in fibonacci_sequence(10, 20)]; fibs # optional - sage.libs.pari + sage: fibs = [i for i in fibonacci_sequence(10, 20)]; fibs # needs sage.libs.pari [55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181] :: - sage: sum([i for i in fibonacci_sequence(100, 110)]) # optional - sage.libs.pari + sage: sum([i for i in fibonacci_sequence(100, 110)]) # needs sage.libs.pari 69919376923075308730013 .. SEEALSO:: @@ -3036,25 +3045,25 @@ def fibonacci_xrange(start, stop=None, algorithm='pari') -> Iterator: EXAMPLES:: - sage: fibs_in_some_range = [i for i in fibonacci_xrange(10^7, 10^8)] # optional - sage.libs.pari - sage: len(fibs_in_some_range) # optional - sage.libs.pari + sage: fibs_in_some_range = [i for i in fibonacci_xrange(10^7, 10^8)] # needs sage.libs.pari + sage: len(fibs_in_some_range) # needs sage.libs.pari 4 - sage: fibs_in_some_range # optional - sage.libs.pari + sage: fibs_in_some_range # needs sage.libs.pari [14930352, 24157817, 39088169, 63245986] :: - sage: fibs = [i for i in fibonacci_xrange(10, 100)]; fibs # optional - sage.libs.pari + sage: fibs = [i for i in fibonacci_xrange(10, 100)]; fibs # needs sage.libs.pari [13, 21, 34, 55, 89] :: - sage: list(fibonacci_xrange(13, 34)) # optional - sage.libs.pari + sage: list(fibonacci_xrange(13, 34)) # needs sage.libs.pari [13, 21] A solution to the second Project Euler problem:: - sage: sum([i for i in fibonacci_xrange(10^6) if is_even(i)]) # optional - sage.libs.pari + sage: sum([i for i in fibonacci_xrange(10^6) if is_even(i)]) # needs sage.libs.pari 1089154 .. SEEALSO:: @@ -3112,30 +3121,30 @@ def bernoulli_polynomial(x, n: Integer): EXAMPLES:: sage: y = QQ['y'].0 - sage: bernoulli_polynomial(y, 5) # optional - sage.libs.flint + sage: bernoulli_polynomial(y, 5) # needs sage.libs.flint y^5 - 5/2*y^4 + 5/3*y^3 - 1/6*y - sage: bernoulli_polynomial(y, 5)(12) # optional - sage.libs.flint + sage: bernoulli_polynomial(y, 5)(12) # needs sage.libs.flint 199870 - sage: bernoulli_polynomial(12, 5) # optional - sage.libs.flint + sage: bernoulli_polynomial(12, 5) # needs sage.libs.flint 199870 - sage: bernoulli_polynomial(y^2 + 1, 5) # optional - sage.libs.flint + sage: bernoulli_polynomial(y^2 + 1, 5) # needs sage.libs.flint y^10 + 5/2*y^8 + 5/3*y^6 - 1/6*y^2 sage: P. = ZZ[] - sage: p = bernoulli_polynomial(t, 6) # optional - sage.libs.flint - sage: p.parent() # optional - sage.libs.flint + sage: p = bernoulli_polynomial(t, 6) # needs sage.libs.flint + sage: p.parent() # needs sage.libs.flint Univariate Polynomial Ring in t over Rational Field We verify an instance of the formula which is the origin of the Bernoulli polynomials (and numbers):: sage: power_sum = sum(k^4 for k in range(10)) - sage: 5*power_sum == bernoulli_polynomial(10, 5) - bernoulli(5) # optional - sage.libs.flint + sage: 5*power_sum == bernoulli_polynomial(10, 5) - bernoulli(5) # needs sage.libs.flint True TESTS:: sage: x = polygen(QQ, 'x') - sage: bernoulli_polynomial(x, 0).parent() # optional - sage.libs.flint + sage: bernoulli_polynomial(x, 0).parent() # needs sage.libs.flint Univariate Polynomial Ring in x over Rational Field REFERENCES: diff --git a/src/sage/combinat/combinat_cython.pyx b/src/sage/combinat/combinat_cython.pyx index 68a7de2498e..3b8fb7aefa3 100644 --- a/src/sage/combinat/combinat_cython.pyx +++ b/src/sage/combinat/combinat_cython.pyx @@ -308,7 +308,7 @@ def set_partition_composition(tuple sp1, tuple sp2): sage: sp1 = ((1,-2),(2,-1)) sage: sp2 = ((1,-2),(2,-1)) sage: p, c = set_partition_composition(sp1, sp2) - sage: (SetPartition(p), c) == (SetPartition([[1,-1],[2,-2]]), 0) # optional - sage.combinat + sage: (SetPartition(p), c) == (SetPartition([[1,-1],[2,-2]]), 0) # needs sage.combinat True """ cdef int num_loops = 0 # The number of loops removed diff --git a/src/sage/combinat/combination.py b/src/sage/combinat/combination.py index dca90c2a4e3..8561935b403 100644 --- a/src/sage/combinat/combination.py +++ b/src/sage/combinat/combination.py @@ -148,15 +148,15 @@ class of combinations of ``mset`` of size ``k``. It is possible to take combinations of Sage objects:: - sage: Combinations([vector([1,1]), vector([2,2]), vector([3,3])], 2).list() # optional - sage.modules + sage: Combinations([vector([1,1]), vector([2,2]), vector([3,3])], 2).list() # needs sage.modules [[(1, 1), (2, 2)], [(1, 1), (3, 3)], [(2, 2), (3, 3)]] TESTS: We check that the code works even for non mutable objects:: - sage: l = [vector((0,0)), vector((0,1))] # optional - sage.modules - sage: Combinations(l).list() # optional - sage.modules + sage: l = [vector((0,0)), vector((0,1))] # needs sage.modules + sage: Combinations(l).list() # needs sage.modules [[], [(0, 0)], [(0, 1)], [(0, 0), (0, 1)]] """ # Check to see if everything in mset is unique @@ -269,7 +269,7 @@ def cardinality(self): sage: Combinations([1,2,3]).cardinality() 8 - sage: Combinations(['a','a','b']).cardinality() # optional - sage.libs.gap + sage: Combinations(['a','a','b']).cardinality() # needs sage.libs.gap 6 """ c = 0 @@ -431,7 +431,7 @@ def cardinality(self): EXAMPLES:: sage: mset = [1,1,2,3,4,4,5] - sage: Combinations(mset,2).cardinality() # optional - sage.libs.gap + sage: Combinations(mset,2).cardinality() # needs sage.libs.gap 12 """ from sage.libs.gap.libgap import libgap @@ -656,7 +656,7 @@ def from_rank(r, n, k): ....: for i in range(k): ....: comb[i] = (n - 1) - comb[i] ....: return tuple(comb) - sage: all(from_rank(r, n, k) == from_rank_comb_largest(r, n, k) + sage: all(from_rank(r, n, k) == from_rank_comb_largest(r, n, k) # needs sage.symbolic ....: for n in range(10) for k in range(n+1) for r in range(binomial(n,k))) True """ diff --git a/src/sage/combinat/combinatorial_map.py b/src/sage/combinat/combinatorial_map.py index 0ff4ffe34bc..5ec7871821c 100644 --- a/src/sage/combinat/combinatorial_map.py +++ b/src/sage/combinat/combinatorial_map.py @@ -302,9 +302,9 @@ def __call__(self, *args, **kwds): sage: p = Permutation([1,3,2,4]) sage: cm = type(p).left_tableau; cm Combinatorial map: Robinson-Schensted insertion tableau - sage: cm(p) # optional - sage.combinat + sage: cm(p) # needs sage.combinat [[1, 2, 4], [3]] - sage: cm(Permutation([4,3,2,1])) # optional - sage.combinat + sage: cm(Permutation([4,3,2,1])) # needs sage.combinat [[1], [2], [3], [4]] """ if self._inst is not None: diff --git a/src/sage/combinat/composition.py b/src/sage/combinat/composition.py index 829ba9e8a8e..66a03049c34 100644 --- a/src/sage/combinat/composition.py +++ b/src/sage/combinat/composition.py @@ -172,18 +172,19 @@ def _ascii_art_(self): """ TESTS:: - sage: ascii_art(Compositions(4).list()) # optional - sage.combinat + sage: # needs sage.combinat + sage: ascii_art(Compositions(4).list()) [ * ] [ * ** * * ] [ * * ** *** * ** * ] [ *, * , * , * , **, ** , ***, **** ] - sage: Partitions.options(diagram_str='#', convention="French") # optional - sage.combinat - sage: ascii_art(Compositions(4).list()) # optional - sage.combinat + sage: Partitions.options(diagram_str='#', convention="French") + sage: ascii_art(Compositions(4).list()) [ # ] [ # # # ## ] [ # # ## # # ## ### ] [ #, ##, #, ###, #, ##, #, #### ] - sage: Partitions.options._reset() # optional - sage.combinat + sage: Partitions.options._reset() """ from sage.typeset.ascii_art import ascii_art return ascii_art(self.to_skew_partition()) @@ -192,20 +193,21 @@ def _unicode_art_(self): """ TESTS:: - sage: unicode_art(Compositions(4).list()) # optional - sage.combinat + sage: # needs sage.combinat + sage: unicode_art(Compositions(4).list()) ⎡ ┌┐ ⎤ ⎢ ├┤ ┌┬┐ ┌┐ ┌┐ ⎥ ⎢ ├┤ ├┼┘ ┌┼┤ ┌┬┬┐ ├┤ ┌┬┐ ┌┐ ⎥ ⎢ ├┤ ├┤ ├┼┘ ├┼┴┘ ┌┼┤ ┌┼┼┘ ┌┬┼┤ ┌┬┬┬┐ ⎥ ⎣ └┘, └┘ , └┘ , └┘ , └┴┘, └┴┘ , └┴┴┘, └┴┴┴┘ ⎦ - sage: Partitions.options(diagram_str='#', convention="French") # optional - sage.combinat - sage: unicode_art(Compositions(4).list()) # optional - sage.combinat + sage: Partitions.options(diagram_str='#', convention="French") + sage: unicode_art(Compositions(4).list()) ⎡ ┌┐ ⎤ ⎢ ├┤ ┌┐ ┌┐ ┌┬┐ ⎥ ⎢ ├┤ ├┤ ├┼┐ ┌┐ └┼┤ ┌┬┐ ┌┬┬┐ ⎥ ⎢ ├┤ ├┼┐ └┼┤ ├┼┬┐ ├┤ └┼┼┐ └┴┼┤ ┌┬┬┬┐ ⎥ ⎣ └┘, └┴┘, └┘, └┴┴┘, └┘, └┴┘, └┘, └┴┴┴┘ ⎦ - sage: Partitions.options._reset() # optional - sage.combinat + sage: Partitions.options._reset() """ from sage.typeset.unicode_art import unicode_art return unicode_art(self.to_skew_partition()) @@ -254,7 +256,7 @@ def conjugate(self) -> Composition: The ribbon shape of the conjugate of `I` is the conjugate of the ribbon shape of `I`:: - sage: all( I.conjugate().to_skew_partition() # optional - sage.combinat + sage: all( I.conjugate().to_skew_partition() # needs sage.combinat ....: == I.to_skew_partition().conjugate() ....: for I in Compositions(4) ) True @@ -1178,11 +1180,11 @@ def to_partition(self): EXAMPLES:: - sage: Composition([2,1,3]).to_partition() # optional - sage.combinat + sage: Composition([2,1,3]).to_partition() # needs sage.combinat [3, 2, 1] - sage: Composition([4,2,2]).to_partition() # optional - sage.combinat + sage: Composition([4,2,2]).to_partition() # needs sage.combinat [4, 2, 2] - sage: Composition([]).to_partition() # optional - sage.combinat + sage: Composition([]).to_partition() # needs sage.combinat [] """ from sage.combinat.partition import Partition @@ -1202,15 +1204,16 @@ def to_skew_partition(self, overlap=1): EXAMPLES:: - sage: Composition([3,4,1]).to_skew_partition() # optional - sage.combinat + sage: # needs sage.combinat + sage: Composition([3,4,1]).to_skew_partition() [6, 6, 3] / [5, 2] - sage: Composition([3,4,1]).to_skew_partition(overlap=0) # optional - sage.combinat + sage: Composition([3,4,1]).to_skew_partition(overlap=0) [8, 7, 3] / [7, 3] - sage: Composition([]).to_skew_partition() # optional - sage.combinat + sage: Composition([]).to_skew_partition() [] / [] - sage: Composition([1,2]).to_skew_partition() # optional - sage.combinat + sage: Composition([1,2]).to_skew_partition() [2, 1] / [] - sage: Composition([2,1]).to_skew_partition() # optional - sage.combinat + sage: Composition([2,1]).to_skew_partition() [2, 2] / [1] """ from sage.combinat.skew_partition import SkewPartition @@ -1264,9 +1267,9 @@ def shuffle_product(self, other, overlap=False): sage: alph = Composition([2,2]) sage: beta = Composition([1,1,3]) - sage: S = alph.shuffle_product(beta); S # optional - sage.combinat + sage: S = alph.shuffle_product(beta); S # needs sage.combinat Shuffle product of [2, 2] and [1, 1, 3] - sage: S.list() # optional - sage.combinat + sage: S.list() # needs sage.combinat [[2, 2, 1, 1, 3], [2, 1, 2, 1, 3], [2, 1, 1, 2, 3], [2, 1, 1, 3, 2], [1, 2, 2, 1, 3], [1, 2, 1, 2, 3], [1, 2, 1, 3, 2], [1, 1, 2, 2, 3], [1, 1, 2, 3, 2], [1, 1, 3, 2, 2]] @@ -1275,9 +1278,9 @@ def shuffle_product(self, other, overlap=False): sage: alph = Composition([2,2]) sage: beta = Composition([1,1,3]) - sage: O = alph.shuffle_product(beta, overlap=True); O # optional - sage.combinat + sage: O = alph.shuffle_product(beta, overlap=True); O # needs sage.combinat Overlapping shuffle product of [2, 2] and [1, 1, 3] - sage: O.list() # optional - sage.combinat + sage: O.list() # needs sage.combinat [[2, 2, 1, 1, 3], [2, 1, 2, 1, 3], [2, 1, 1, 2, 3], [2, 1, 1, 3, 2], [1, 2, 2, 1, 3], [1, 2, 1, 2, 3], [1, 2, 1, 3, 2], [1, 1, 2, 2, 3], [1, 1, 2, 3, 2], [1, 1, 3, 2, 2], @@ -1291,19 +1294,19 @@ def shuffle_product(self, other, overlap=False): compositions in several ways. For example:: sage: w1 = Composition([1]) - sage: S = w1.shuffle_product(w1); S # optional - sage.combinat + sage: S = w1.shuffle_product(w1); S # needs sage.combinat Shuffle product of [1] and [1] - sage: S.list() # optional - sage.combinat + sage: S.list() # needs sage.combinat [[1, 1], [1, 1]] - sage: O = w1.shuffle_product(w1, overlap=True); O # optional - sage.combinat + sage: O = w1.shuffle_product(w1, overlap=True); O # needs sage.combinat Overlapping shuffle product of [1] and [1] - sage: O.list() # optional - sage.combinat + sage: O.list() # needs sage.combinat [[1, 1], [1, 1], [2]] TESTS:: sage: empty = Composition([]) - sage: empty.shuffle_product(empty).list() # optional - sage.combinat + sage: empty.shuffle_product(empty).list() # needs sage.combinat [[]] """ if overlap: @@ -1400,10 +1403,10 @@ def specht_module(self, base_ring=None): EXAMPLES:: - sage: SM = Composition([1,2,2]).specht_module(QQ); SM # optional - sage.combinat sage.modules + sage: SM = Composition([1,2,2]).specht_module(QQ); SM # needs sage.combinat sage.modules Specht module of [(0, 0), (1, 0), (1, 1), (2, 0), (2, 1)] over Rational Field - sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat sage.modules - sage: s(SM.frobenius_image()) # optional - sage.combinat sage.modules + sage: s = SymmetricFunctions(QQ).s() # needs sage.combinat sage.modules + sage: s(SM.frobenius_image()) # needs sage.combinat sage.modules s[2, 2, 1] """ from sage.combinat.specht_module import SpechtModule @@ -1428,9 +1431,9 @@ def specht_module_dimension(self, base_ring=None): EXAMPLES:: - sage: Composition([1,2,2]).specht_module_dimension() # optional - sage.combinat sage.modules + sage: Composition([1,2,2]).specht_module_dimension() # needs sage.combinat sage.modules 5 - sage: Composition([1,2,2]).specht_module_dimension(GF(2)) # optional - sage.combinat sage.modules sage.rings.finite_rings + sage: Composition([1,2,2]).specht_module_dimension(GF(2)) # needs sage.combinat sage.modules sage.rings.finite_rings 5 """ from sage.combinat.specht_module import specht_module_rank diff --git a/src/sage/combinat/core.py b/src/sage/combinat/core.py index 88461d33986..41265d793db 100644 --- a/src/sage/combinat/core.py +++ b/src/sage/combinat/core.py @@ -256,7 +256,7 @@ def length(self): sage: c = Core([4,2],3); c.length() 4 - sage: c.to_grassmannian().length() + sage: c.to_grassmannian().length() # needs sage.modules 4 sage: Core([9,5,3,2,1,1], 5).length() @@ -275,17 +275,17 @@ def to_grassmannian(self): EXAMPLES:: sage: c = Core([3,1,1],3) - sage: w = c.to_grassmannian(); w + sage: w = c.to_grassmannian(); w # needs sage.modules [-1 1 1] [-2 2 1] [-2 1 2] sage: c.parent() 3-Cores of length 4 - sage: w.parent() + sage: w.parent() # needs sage.modules Weyl Group of type ['A', 2, 1] (as a matrix group acting on the root space) sage: c = Core([],3) - sage: c.to_grassmannian() + sage: c.to_grassmannian() # needs sage.modules [1 0 0] [0 1 0] [0 0 1] @@ -304,23 +304,25 @@ def affine_symmetric_group_simple_action(self, i): EXAMPLES:: sage: c = Core([4,2],3) - sage: c.affine_symmetric_group_simple_action(0) + sage: c.affine_symmetric_group_simple_action(0) # needs sage.modules [3, 1] - sage: c.affine_symmetric_group_simple_action(1) + sage: c.affine_symmetric_group_simple_action(1) # needs sage.modules [5, 3, 1] - sage: c.affine_symmetric_group_simple_action(2) + sage: c.affine_symmetric_group_simple_action(2) # needs sage.modules [4, 2] This action corresponds to the left action by the `i`-th simple reflection in the affine symmetric group:: sage: c = Core([4,2],3) - sage: W = c.to_grassmannian().parent() + sage: W = c.to_grassmannian().parent() # needs sage.modules sage: i = 0 - sage: c.affine_symmetric_group_simple_action(i).to_grassmannian() == W.simple_reflection(i)*c.to_grassmannian() + sage: (c.affine_symmetric_group_simple_action(i).to_grassmannian() # needs sage.modules + ....: == W.simple_reflection(i)*c.to_grassmannian()) True sage: i = 1 - sage: c.affine_symmetric_group_simple_action(i).to_grassmannian() == W.simple_reflection(i)*c.to_grassmannian() + sage: (c.affine_symmetric_group_simple_action(i).to_grassmannian() # needs sage.modules + ....: == W.simple_reflection(i)*c.to_grassmannian()) True """ mu = self.to_partition() @@ -431,13 +433,13 @@ def weak_le(self, other): sage: c = Core([4,2],3) sage: x = Core([5,3,1],3) - sage: c.weak_le(x) + sage: c.weak_le(x) # needs sage.modules True - sage: c.weak_le([5,3,1]) + sage: c.weak_le([5,3,1]) # needs sage.modules True sage: x = Core([4,2,2,1,1],3) - sage: c.weak_le(x) + sage: c.weak_le(x) # needs sage.modules False sage: x = Core([5,3,1],6) @@ -462,11 +464,11 @@ def weak_covers(self): EXAMPLES:: sage: c = Core([1],3) - sage: c.weak_covers() + sage: c.weak_covers() # needs sage.modules [[1, 1], [2]] sage: c = Core([4,2],3) - sage: c.weak_covers() + sage: c.weak_covers() # needs sage.modules [[5, 3, 1]] """ w = self.to_grassmannian() diff --git a/src/sage/combinat/crystals/crystals.py b/src/sage/combinat/crystals/crystals.py index 5c345fe61d3..fb8f150e479 100644 --- a/src/sage/combinat/crystals/crystals.py +++ b/src/sage/combinat/crystals/crystals.py @@ -104,7 +104,7 @@ One can get (currently) crude plotting via:: - sage: Tab.plot() # optional - sage.plot + sage: Tab.plot() # needs sage.plot Graphics object consisting of 52 graphics primitives If dot2tex is installed, one can obtain nice latex pictures via:: diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx index cf8d25587d8..368dce3a9fd 100644 --- a/src/sage/combinat/crystals/letters.pyx +++ b/src/sage/combinat/crystals/letters.pyx @@ -1495,7 +1495,7 @@ cdef class Crystal_of_letters_type_E6_element(LetterTuple): sage: all(b.e(i).f(i) == b for i in C.index_set() for b in C if b.e(i) is not None) True sage: G = C.digraph() - sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # optional - sage.plot + sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # needs sage.plot """ def _repr_(self): @@ -1752,7 +1752,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple): sage: all(b.e(i).f(i) == b for i in C.index_set() for b in C if b.e(i) is not None) True sage: G = C.digraph() - sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # optional - sage.plot + sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # needs sage.plot """ def _repr_(self): @@ -1912,7 +1912,7 @@ cdef class Crystal_of_letters_type_E7_element(LetterTuple): sage: all(b.e(i).f(i) == b for i in C.index_set() for b in C if b.e(i) is not None) True sage: G = C.digraph() - sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # optional - sage.plot + sage: G.show(edge_labels=true, figsize=12, vertex_size=1) # needs sage.plot """ def weight(self): diff --git a/src/sage/combinat/crystals/mv_polytopes.py b/src/sage/combinat/crystals/mv_polytopes.py index 67967f88bd0..341ad417443 100644 --- a/src/sage/combinat/crystals/mv_polytopes.py +++ b/src/sage/combinat/crystals/mv_polytopes.py @@ -85,7 +85,7 @@ def _latex_(self): sage: MV = crystals.infinity.MVPolytopes(['A',2]) sage: u = MV.highest_weight_vector() sage: b = u.f_string([1,2,2,1]) - sage: latex(b) # optional - sage.symbolic + sage: latex(b) # needs sage.symbolic \begin{tikzpicture} \draw (0, 0) -- (3/2, -989/1142) -- (3/2, -2967/1142) -- (0, -1978/571); \draw (0, 0) -- (-3/2, -989/1142) -- (-3/2, -2967/1142) -- (0, -1978/571); @@ -218,7 +218,7 @@ def plot(self, P=None, **options): sage: MV = crystals.infinity.MVPolytopes(['C', 2]) sage: b = MV.highest_weight_vector().f_string([1,2,1,2,2,2,1,1,1,1,2,1]) - sage: b.plot() # optional - sage.plot + sage: b.plot() # needs sage.plot Graphics object consisting of 12 graphics primitives Here is the above example placed inside the ambient space diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx index 2052677a4a4..fa155acdd15 100644 --- a/src/sage/combinat/degree_sequences.pyx +++ b/src/sage/combinat/degree_sequences.pyx @@ -40,8 +40,8 @@ With the object ``DegreeSequences(n)``, one can: For instance:: sage: ds = [3, 3, 2, 2, 2, 2, 2, 1, 1, 0] - sage: g = graphs.DegreeSequence(ds) - sage: g.degree_sequence() + sage: g = graphs.DegreeSequence(ds) # needs networkx sage.graphs + sage: g.degree_sequence() # needs networkx sage.graphs [3, 3, 2, 2, 2, 2, 2, 1, 1, 0] Definitions @@ -236,16 +236,16 @@ The sequences produced by random graphs *are* degree sequences:: sage: n = 30 sage: DS = DegreeSequences(30) - sage: for i in range(10): + sage: for i in range(10): # needs networkx sage.graphs ....: g = graphs.RandomGNP(n,.2) ....: if not g.degree_sequence() in DS: ....: print("Something is very wrong !") Checking that we indeed enumerate *all* the degree sequences for `n=5`:: - sage: ds1 = Set([tuple(g.degree_sequence()) for g in graphs(5)]) + sage: ds1 = Set([tuple(g.degree_sequence()) for g in graphs(5)]) # needs sage.graphs sage: ds2 = Set(map(tuple,list(DegreeSequences(5)))) - sage: ds1 == ds2 + sage: ds1 == ds2 # needs sage.graphs True Checking the consistency of enumeration and test:: diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 11d96acced8..ecc794e27d2 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -2054,9 +2054,9 @@ def order(self): EXAMPLES:: - sage: q = var('q') # optional - sage.symbolic - sage: PA = PartitionAlgebra(2, q) # optional - sage.symbolic - sage: PA.order() # optional - sage.symbolic + sage: q = var('q') # needs sage.symbolic + sage: PA = PartitionAlgebra(2, q) # needs sage.symbolic + sage: PA.order() # needs sage.symbolic 2 """ return self._k @@ -2413,24 +2413,24 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): :: - sage: q = var('q') # optional - sage.symbolic - sage: PA = PartitionAlgebra(2, q); PA # optional - sage.symbolic + sage: q = var('q') # needs sage.symbolic + sage: PA = PartitionAlgebra(2, q); PA # needs sage.symbolic Partition Algebra of rank 2 with parameter q over Symbolic Ring - sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]]) # optional - sage.symbolic + sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]]) # needs sage.symbolic True - sage: ((PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 # optional - sage.symbolic + sage: ((PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 # needs sage.symbolic ....: == (4*q-4)*PA([[1, 2], [-2, -1]]) + PA([[2, -2], [1, -1]])) True The identity element of the partition algebra is the set partition `\{\{1,-1\}, \{2,-2\}, \ldots, \{k,-k\}\}`:: - sage: P = PA.basis().list() # optional - sage.symbolic - sage: PA.one() # optional - sage.symbolic + sage: P = PA.basis().list() # needs sage.symbolic + sage: PA.one() # needs sage.symbolic P{{-2, 2}, {-1, 1}} - sage: PA.one() * P[7] == P[7] # optional - sage.symbolic + sage: PA.one() * P[7] == P[7] # needs sage.symbolic True - sage: P[7] * PA.one() == P[7] # optional - sage.symbolic + sage: P[7] * PA.one() == P[7] # needs sage.symbolic True We now give some further examples of the use of the other arguments. @@ -2455,14 +2455,14 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): of the partition algebra (e.g., ``BrauerAlgebra`` and ``TemperleyLiebAlgebra``) can also be coerced into the partition algebra:: - sage: S = SymmetricGroupAlgebra(SR, 2) # optional - sage.symbolic - sage: B = BrauerAlgebra(2, x, SR) # optional - sage.symbolic - sage: A = PartitionAlgebra(2, x, SR) # optional - sage.symbolic - sage: S([2,1]) * A([[1,-1],[2,-2]]) # optional - sage.symbolic + sage: S = SymmetricGroupAlgebra(SR, 2) # needs sage.symbolic + sage: B = BrauerAlgebra(2, x, SR) # needs sage.symbolic + sage: A = PartitionAlgebra(2, x, SR) # needs sage.symbolic + sage: S([2,1]) * A([[1,-1],[2,-2]]) # needs sage.symbolic P{{-2, 1}, {-1, 2}} - sage: B([[-1,-2],[2,1]]) * A([[1],[-1],[2,-2]]) # optional - sage.symbolic + sage: B([[-1,-2],[2,1]]) * A([[1],[-1],[2,-2]]) # needs sage.symbolic P{{-2}, {-1}, {1, 2}} - sage: A([[1],[-1],[2,-2]]) * B([[-1,-2],[2,1]]) # optional - sage.symbolic + sage: A([[1],[-1],[2,-2]]) * B([[-1,-2],[2,1]]) # needs sage.symbolic P{{-2, -1}, {1}, {2}} The same is true if the elements come from a subalgebra of a partition @@ -2493,21 +2493,21 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): Shorthands for working with basis elements are as follows:: sage: S = SymmetricGroupAlgebra(ZZ, 3) - sage: A = PartitionAlgebra(3, x, SR) # optional - sage.symbolic + sage: A = PartitionAlgebra(3, x, SR) # needs sage.symbolic - sage: A([[1,3],[-1],[-3]]) # pair up the omitted nodes as `{-i, i}`, if possible # optional - sage.symbolic + sage: A([[1,3],[-1],[-3]]) # pair up the omitted nodes as `{-i, i}`, if possible # needs sage.symbolic P{{-3}, {-2, 2}, {-1}, {1, 3}} - sage: A([[1,3],[-1],[-3]]) == A[[1,3],[-1],[-3]] # optional - sage.symbolic + sage: A([[1,3],[-1],[-3]]) == A[[1,3],[-1],[-3]] # needs sage.symbolic True - sage: A([[1,2]]) # optional - sage.symbolic + sage: A([[1,2]]) # needs sage.symbolic P{{-3, 3}, {-2}, {-1}, {1, 2}} - sage: A([[1,2]]) == A[[1,2]] # optional - sage.symbolic + sage: A([[1,2]]) == A[[1,2]] # needs sage.symbolic True - sage: A([2,3,1]) # permutations in one-line notation are imported as well # optional - sage.symbolic + sage: A([2,3,1]) # permutations in one-line notation are imported as well # needs sage.symbolic P{{-3, 2}, {-2, 1}, {-1, 3}} - sage: A([2,3,1]) == A(S([2,3,1])) # optional - sage.symbolic + sage: A([2,3,1]) == A(S([2,3,1])) # needs sage.symbolic True """ @staticmethod @@ -3595,9 +3595,9 @@ def ambient(self): EXAMPLES:: - sage: x = var('x') # optional - sage.symbolic - sage: BA = BrauerAlgebra(2, x) # optional - sage.symbolic - sage: BA.ambient() # optional - sage.symbolic + sage: x = var('x') # needs sage.symbolic + sage: BA = BrauerAlgebra(2, x) # needs sage.symbolic + sage: BA.ambient() # needs sage.symbolic Partition Algebra of rank 2 with parameter x over Symbolic Ring """ return self.lift.codomain() @@ -3836,11 +3836,11 @@ def jucys_murphy(self, j): EXAMPLES:: - sage: z = var('z') # optional - sage.symbolic - sage: B = BrauerAlgebra(3,z) # optional - sage.symbolic - sage: B.jucys_murphy(1) # optional - sage.symbolic + sage: z = var('z') # needs sage.symbolic + sage: B = BrauerAlgebra(3,z) # needs sage.symbolic + sage: B.jucys_murphy(1) # needs sage.symbolic (1/2*z-1/2)*B{{-3, 3}, {-2, 2}, {-1, 1}} - sage: B.jucys_murphy(3) # optional - sage.symbolic + sage: B.jucys_murphy(3) # needs sage.symbolic -B{{-3, -2}, {-1, 1}, {2, 3}} - B{{-3, -1}, {-2, 2}, {1, 3}} + B{{-3, 1}, {-2, 2}, {-1, 3}} + B{{-3, 2}, {-2, 3}, {-1, 1}} + (1/2*z-1/2)*B{{-3, 3}, {-2, 2}, {-1, 1}} diff --git a/src/sage/combinat/dlx.py b/src/sage/combinat/dlx.py index 25990fe55fe..58bb1bc624f 100644 --- a/src/sage/combinat/dlx.py +++ b/src/sage/combinat/dlx.py @@ -474,11 +474,12 @@ def AllExactCovers(M): EXAMPLES:: - sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers # optional - sage.modules - sage: for cover in AllExactCovers(M): # optional - sage.modules + sage: # needs sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers + sage: for cover in AllExactCovers(M): ....: print(cover) - sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers # optional - sage.modules - sage: for cover in AllExactCovers(M): # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers + sage: for cover in AllExactCovers(M): ....: print(cover) [(1, 1, 0), (0, 0, 1)] [(1, 0, 1), (0, 1, 0)] @@ -503,11 +504,11 @@ def OneExactCover(M): EXAMPLES:: - sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers # optional - sage.modules - sage: OneExactCover(M) # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers # needs sage.modules + sage: OneExactCover(M) # needs sage.modules - sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers # optional - sage.modules - sage: OneExactCover(M) # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers # needs sage.modules + sage: OneExactCover(M) # needs sage.modules [(1, 1, 0), (0, 0, 1)] """ for s in AllExactCovers(M): diff --git a/src/sage/combinat/dyck_word.py b/src/sage/combinat/dyck_word.py index 36573003830..b40b9dcc6d8 100644 --- a/src/sage/combinat/dyck_word.py +++ b/src/sage/combinat/dyck_word.py @@ -957,7 +957,7 @@ def plot(self, **kwds): EXAMPLES:: sage: w = DyckWords(100).random_element() - sage: w.plot() # optional - sage.plot + sage: w.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.plot import list_plot @@ -1695,24 +1695,24 @@ def to_binary_tree(self, usemap="1L0R"): EXAMPLES:: sage: dw = DyckWord([1,0]) - sage: dw.to_binary_tree() + sage: dw.to_binary_tree() # needs sage.graphs [., .] sage: dw = DyckWord([]) - sage: dw.to_binary_tree() + sage: dw.to_binary_tree() # needs sage.graphs . sage: dw = DyckWord([1,0,1,1,0,0]) - sage: dw.to_binary_tree() + sage: dw.to_binary_tree() # needs sage.graphs [., [[., .], .]] - sage: dw.to_binary_tree("L1R0") + sage: dw.to_binary_tree("L1R0") # needs sage.graphs [[., .], [., .]] sage: dw = DyckWord([1,0,1,1,0,0,1,1,1,0,1,0,0,0]) - sage: dw.to_binary_tree() == dw.to_binary_tree("1R0L").left_right_symmetry() + sage: dw.to_binary_tree() == dw.to_binary_tree("1R0L").left_right_symmetry() # needs sage.graphs True - sage: dw.to_binary_tree() == dw.to_binary_tree("L1R0").left_border_symmetry() + sage: dw.to_binary_tree() == dw.to_binary_tree("L1R0").left_border_symmetry() # needs sage.graphs False - sage: dw.to_binary_tree("1R0L") == dw.to_binary_tree("L1R0").left_border_symmetry() + sage: dw.to_binary_tree("1R0L") == dw.to_binary_tree("L1R0").left_border_symmetry() # needs sage.graphs True - sage: dw.to_binary_tree("R1L0") == dw.to_binary_tree("L1R0").left_right_symmetry() + sage: dw.to_binary_tree("R1L0") == dw.to_binary_tree("L1R0").left_right_symmetry() # needs sage.graphs True sage: dw.to_binary_tree("R10L") Traceback (most recent call last): @@ -1754,11 +1754,11 @@ def to_binary_tree_tamari(self): EXAMPLES:: - sage: DyckWord([1,0]).to_binary_tree_tamari() + sage: DyckWord([1,0]).to_binary_tree_tamari() # needs sage.graphs [., .] - sage: DyckWord([1,0,1,1,0,0]).to_binary_tree_tamari() + sage: DyckWord([1,0,1,1,0,0]).to_binary_tree_tamari() # needs sage.graphs [[., .], [., .]] - sage: DyckWord([1,0,1,0,1,0]).to_binary_tree_tamari() + sage: DyckWord([1,0,1,0,1,0]).to_binary_tree_tamari() # needs sage.graphs [[[., .], .], .] """ # return self.to_binary_tree("L1R0") # slower and recursive @@ -1788,22 +1788,22 @@ def tamari_interval(self, other): EXAMPLES:: sage: dw = DyckWord([1, 1, 0, 1, 0, 0, 1, 0]) - sage: ip = dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 1, 0, 0])); ip + sage: ip = dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 1, 0, 0])); ip # needs sage.graphs The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (3, 1), (2, 1)] - sage: ip.lower_dyck_word() + sage: ip.lower_dyck_word() # needs sage.graphs [1, 1, 0, 1, 0, 0, 1, 0] - sage: ip.upper_dyck_word() + sage: ip.upper_dyck_word() # needs sage.graphs [1, 1, 1, 0, 0, 1, 0, 0] - sage: ip.interval_cardinality() + sage: ip.interval_cardinality() # needs sage.graphs 4 - sage: ip.number_of_tamari_inversions() + sage: ip.number_of_tamari_inversions() # needs sage.graphs 2 - sage: list(ip.dyck_words()) + sage: list(ip.dyck_words()) # needs sage.graphs [[1, 1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 0, 1, 0]] - sage: dw.tamari_interval(DyckWord([1,1,0,0,1,1,0,0])) + sage: dw.tamari_interval(DyckWord([1,1,0,0,1,1,0,0])) # needs sage.graphs Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice @@ -2065,9 +2065,10 @@ def characteristic_symmetric_function(self, q=None, sage: R = QQ['q','t'].fraction_field() sage: (q,t) = R.gens() - sage: f = sum(t**D.area()*D.characteristic_symmetric_function() for D in DyckWords(3)); f + sage: f = sum(t**D.area() * D.characteristic_symmetric_function() # needs sage.modules + ....: for D in DyckWords(3)); f (q^3+q^2*t+q*t^2+t^3+q*t)*s[1, 1, 1] + (q^2+q*t+t^2+q+t)*s[2, 1] + s[3] - sage: f.nabla(power=-1) + sage: f.nabla(power=-1) # needs sage.modules s[1, 1, 1] """ from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions @@ -2483,22 +2484,22 @@ def to_ordered_tree(self): EXAMPLES:: sage: D = DyckWord([1,1,0,0]) - sage: D.to_ordered_tree() + sage: D.to_ordered_tree() # needs sage.graphs [[[]]] sage: D = DyckWord([1,0,1,0]) - sage: D.to_ordered_tree() + sage: D.to_ordered_tree() # needs sage.graphs [[], []] sage: D = DyckWord([1, 0, 1, 1, 0, 0]) - sage: D.to_ordered_tree() + sage: D.to_ordered_tree() # needs sage.graphs [[], [[]]] sage: D = DyckWord([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0]) - sage: D.to_ordered_tree() + sage: D.to_ordered_tree() # needs sage.graphs [[], [[], []], [[], [[]]]] TESTS:: sage: D = DyckWord([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0]) - sage: D == D.to_ordered_tree().to_dyck_word() + sage: D == D.to_ordered_tree().to_dyck_word() # needs sage.graphs True """ from sage.combinat.ordered_tree import OrderedTree @@ -2587,12 +2588,11 @@ def to_triangulation_as_graph(self): EXAMPLES:: - sage: g = DyckWord([1, 1, 0, 0, 1, 0]).to_triangulation_as_graph() - sage: g + sage: g = DyckWord([1, 1, 0, 0, 1, 0]).to_triangulation_as_graph(); g # needs sage.graphs Graph on 5 vertices - sage: g.edges(sort=True, labels=False) + sage: g.edges(sort=True, labels=False) # needs sage.graphs [(0, 1), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (3, 4)] - sage: g.show() # not tested + sage: g.show() # not tested # needs sage.graphs """ n = self.number_of_open_symbols() edges = self.to_triangulation() @@ -3177,12 +3177,12 @@ def to_alternating_sign_matrix(self): EXAMPLES:: - sage: DyckWord([1,1,1,0,1,0,0,0]).to_alternating_sign_matrix() + sage: DyckWord([1,1,1,0,1,0,0,0]).to_alternating_sign_matrix() # needs sage.modules [ 0 0 1 0] [ 1 0 -1 1] [ 0 1 0 0] [ 0 0 1 0] - sage: DyckWord([1,0,1,0,1,1,0,0]).to_alternating_sign_matrix() + sage: DyckWord([1,0,1,0,1,1,0,0]).to_alternating_sign_matrix() # needs sage.modules [1 0 0 0] [0 1 0 0] [0 0 0 1] diff --git a/src/sage/combinat/e_one_star.py b/src/sage/combinat/e_one_star.py index 72cff3d147b..a7b9c50b732 100644 --- a/src/sage/combinat/e_one_star.py +++ b/src/sage/combinat/e_one_star.py @@ -160,9 +160,9 @@ sage: P = Patch([Face([0,0], 1), Face([0,0], 2)]) sage: E = E1Star(WordMorphism({1:[1,2],2:[1]})) sage: F = E1Star(WordMorphism({1:[1,1,2],2:[2,1]})) - sage: E(P,5).plot() # optional - sage.plot + sage: E(P,5).plot() # needs sage.plot Graphics object consisting of 21 graphics primitives - sage: F(P,3).plot() # optional - sage.plot + sage: F(P,3).plot() # needs sage.plot Graphics object consisting of 34 graphics primitives Everything works in any dimension (except for the plotting features @@ -491,12 +491,12 @@ def _plot(self, projmat, face_contour, opacity) -> Graphics: sage: face_contour[1] = map(vector, [(0,0,0),(0,1,0),(0,1,1),(0,0,1)]) sage: face_contour[2] = map(vector, [(0,0,0),(0,0,1),(1,0,1),(1,0,0)]) sage: face_contour[3] = map(vector, [(0,0,0),(1,0,0),(1,1,0),(0,1,0)]) - sage: G = f._plot(projmat, face_contour, 0.75) # optional - sage.plot + sage: G = f._plot(projmat, face_contour, 0.75) # needs sage.plot :: sage: f = Face((0,0), 2) - sage: f._plot(None, None, 1) # optional - sage.plot + sage: f._plot(None, None, 1) # needs sage.plot Graphics object consisting of 1 graphics primitive """ v = self.vector() @@ -1103,7 +1103,7 @@ def plot(self, projmat=None, opacity=0.75) -> Graphics: sage: from sage.combinat.e_one_star import E1Star, Face, Patch sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]]) - sage: P.plot() # optional - sage.plot + sage: P.plot() # needs sage.plot Graphics object consisting of 3 graphics primitives :: @@ -1112,7 +1112,7 @@ def plot(self, projmat=None, opacity=0.75) -> Graphics: sage: E = E1Star(sigma) sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]]) sage: P = E(P, 5) - sage: P.plot() # optional - sage.plot + sage: P.plot() # needs sage.plot Graphics object consisting of 57 graphics primitives Plot with a different projection matrix:: @@ -1122,7 +1122,7 @@ def plot(self, projmat=None, opacity=0.75) -> Graphics: sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]]) sage: M = matrix(2, 3, [1,0,-1,0.3,1,-3]) sage: P = E(P, 3) - sage: P.plot(projmat=M) # optional - sage.plot + sage: P.plot(projmat=M) # needs sage.plot Graphics object consisting of 17 graphics primitives Plot patches made of unit segments:: @@ -1130,9 +1130,9 @@ def plot(self, projmat=None, opacity=0.75) -> Graphics: sage: P = Patch([Face([0,0], 1), Face([0,0], 2)]) sage: E = E1Star(WordMorphism({1:[1,2],2:[1]})) sage: F = E1Star(WordMorphism({1:[1,1,2],2:[2,1]})) - sage: E(P,5).plot() # optional - sage.plot + sage: E(P,5).plot() # needs sage.plot Graphics object consisting of 21 graphics primitives - sage: F(P,3).plot() # optional - sage.plot + sage: F(P,3).plot() # needs sage.plot Graphics object consisting of 34 graphics primitives """ if self.dimension() == 2: diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 8bfddfaf76a..fb5b19ff83e 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -984,12 +984,12 @@ def full_group_by(l, key=None): EXAMPLES:: sage: from sage.combinat.finite_state_machine import full_group_by - sage: t = [2/x, 1/x, 2/x] # optional - sage.symbolic - sage: r = full_group_by([0, 1, 2], key=lambda i: t[i]) # optional - sage.symbolic - sage: sorted(r, key=lambda p: p[1]) # optional - sage.symbolic + sage: t = [2/x, 1/x, 2/x] # needs sage.symbolic + sage: r = full_group_by([0, 1, 2], key=lambda i: t[i]) # needs sage.symbolic + sage: sorted(r, key=lambda p: p[1]) # needs sage.symbolic [(2/x, [0, 2]), (1/x, [1])] sage: from itertools import groupby - sage: for k, elements in groupby(sorted([0, 1, 2], # optional - sage.symbolic + sage: for k, elements in groupby(sorted([0, 1, 2], # needs sage.symbolic ....: key=lambda i:t[i]), ....: key=lambda i:t[i]): ....: print("{} {}".format(k, list(elements))) @@ -4122,17 +4122,17 @@ def is_Markov_chain(self, is_zero=None): If the probabilities are variables in the symbolic ring, :func:`~sage.symbolic.assumptions.assume` will do the trick:: - sage: var('p q') # optional - sage.symbolic + sage: var('p q') # needs sage.symbolic (p, q) - sage: F = Transducer([(0, 0, p, 1), (0, 0, q, 0)], # optional - sage.symbolic + sage: F = Transducer([(0, 0, p, 1), (0, 0, q, 0)], # needs sage.symbolic ....: on_duplicate_transition=duplicate_transition_add_input) - sage: assume(p + q == 1) # optional - sage.symbolic - sage: (p + q - 1).is_zero() # optional - sage.symbolic + sage: assume(p + q == 1) # needs sage.symbolic + sage: (p + q - 1).is_zero() # needs sage.symbolic True - sage: F.is_Markov_chain() # optional - sage.symbolic + sage: F.is_Markov_chain() # needs sage.symbolic True - sage: forget() # optional - sage.symbolic - sage: del(p, q) # optional - sage.symbolic + sage: forget() # needs sage.symbolic + sage: del(p, q) # needs sage.symbolic If the probabilities are variables in some polynomial ring, the parameter ``is_zero`` can be used:: @@ -4326,9 +4326,9 @@ def default_format_transition_label(self, word): #. In the example above, ``'a'`` and ``'alpha'`` should perhaps be symbols:: - sage: var('a alpha a_1') # optional - sage.symbolic + sage: var('a alpha a_1') # needs sage.symbolic (a, alpha, a_1) - sage: print(T.default_format_transition_label([a, alpha, a_1])) # optional - sage.symbolic + sage: print(T.default_format_transition_label([a, alpha, a_1])) # needs sage.symbolic a \alpha a_{1} #. Example of an empty word:: @@ -5039,7 +5039,7 @@ def _matrix_(self, R=None): ....: 3:{'a':(0, 1), 2:(1, 1)}, ....: 4:{4:(1, 1), 3:(0, 1)}}, ....: initial_states=[0]) - sage: B._matrix_() # optional - sage.symbolic + sage: B._matrix_() # needs sage.symbolic [1 1 0 0 0] [0 0 1 1 0] [x 0 0 0 1] @@ -5081,7 +5081,7 @@ def adjacency_matrix(self, input=None, ....: 3:{'a':(0, 1), 2:(1, 1)}, ....: 4:{4:(1, 1), 3:(0, 1)}}, ....: initial_states=[0]) - sage: B.adjacency_matrix() # optional - sage.symbolic + sage: B.adjacency_matrix() # needs sage.symbolic [1 1 0 0 0] [0 0 1 1 0] [x 0 0 0 1] @@ -5090,7 +5090,7 @@ def adjacency_matrix(self, input=None, This is equivalent to:: - sage: matrix(B) # optional - sage.symbolic + sage: matrix(B) # needs sage.symbolic [1 1 0 0 0] [0 0 1 1 0] [x 0 0 0 1] @@ -5105,9 +5105,9 @@ def adjacency_matrix(self, input=None, [1 0 0 0 1] [0 1 1 0 0] [0 0 0 1 1] - sage: var('t') # optional - sage.symbolic + sage: var('t') # needs sage.symbolic t - sage: B.adjacency_matrix(1, entry=(lambda transition: # optional - sage.symbolic + sage: B.adjacency_matrix(1, entry=(lambda transition: # needs sage.symbolic ....: exp(I*transition.word_out[0]*t))) [ 0 1 0 0 0] [ 0 0 0 1 0] @@ -5120,7 +5120,7 @@ def adjacency_matrix(self, input=None, ....: (2, 1, 0)], ....: initial_states=[0], ....: final_states=[0]) - sage: a.adjacency_matrix() # optional - sage.symbolic + sage: a.adjacency_matrix() # needs sage.symbolic [0 1 0] [0 0 1] [1 1 0] @@ -9707,7 +9707,7 @@ def plot(self): TESTS:: - sage: FiniteStateMachine([('A', 'A', 0)]).plot() # optional - sage.plot + sage: FiniteStateMachine([('A', 'A', 0)]).plot() # needs sage.plot Graphics object consisting of 3 graphics primitives """ return self.graph(edge_labels='words_in_out').plot() @@ -9792,9 +9792,9 @@ def number_of_words(self, variable=None, ....: (0, 1, -1), (1, 0, 0)], ....: initial_states=[0], ....: final_states=[0, 1]) - sage: N = NAFpm.number_of_words(); N # optional - sage.symbolic + sage: N = NAFpm.number_of_words(); N # needs sage.symbolic 4/3*2^n - 1/3*(-1)^n - sage: all(len(list(NAFpm.language(s))) # optional - sage.symbolic + sage: all(len(list(NAFpm.language(s))) # needs sage.symbolic ....: - len(list(NAFpm.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9806,10 +9806,10 @@ def number_of_words(self, variable=None, sage: NAFp = Automaton([(0, 0, 0), (0, 1, 1), (1, 0, 0)], ....: initial_states=[0], ....: final_states=[0, 1]) - sage: N = NAFp.number_of_words(); N # optional - sage.symbolic + sage: N = NAFp.number_of_words(); N # needs sage.symbolic 1.170820393249937?*1.618033988749895?^n - 0.1708203932499369?*(-0.618033988749895?)^n - sage: all(len(list(NAFp.language(s))) # optional - sage.symbolic + sage: all(len(list(NAFp.language(s))) # needs sage.symbolic ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9820,13 +9820,13 @@ def number_of_words(self, variable=None, roots. :: sage: M = NAFp.adjacency_matrix(entry=lambda t: 1) - sage: M.characteristic_polynomial() # optional - sage.symbolic + sage: M.characteristic_polynomial() # needs sage.symbolic x^2 - x - 1 - sage: R. = NumberField(x^2-x-1, embedding=1.6) # optional - sage.symbolic - sage: N = NAFp.number_of_words(base_ring=R); N # optional - sage.symbolic + sage: R. = NumberField(x^2-x-1, embedding=1.6) # needs sage.symbolic + sage: N = NAFp.number_of_words(base_ring=R); N # needs sage.symbolic 1/2*(1/2*sqrt(5) + 1/2)^n*(3*sqrt(1/5) + 1) - 1/2*(-1/2*sqrt(5) + 1/2)^n*(3*sqrt(1/5) - 1) - sage: all(len(list(NAFp.language(s))) # optional - sage.symbolic + sage: all(len(list(NAFp.language(s))) # needs sage.symbolic ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9834,11 +9834,11 @@ def number_of_words(self, variable=None, In this special case, we might also use the constant :class:`golden_ratio `:: - sage: R. = NumberField(x^2-x-1, embedding=golden_ratio) # optional - sage.symbolic - sage: N = NAFp.number_of_words(base_ring=R); N # optional - sage.symbolic + sage: R. = NumberField(x^2-x-1, embedding=golden_ratio) # needs sage.symbolic + sage: N = NAFp.number_of_words(base_ring=R); N # needs sage.symbolic 1/5*(3*golden_ratio + 1)*golden_ratio^n - 1/5*(3*golden_ratio - 4)*(-golden_ratio + 1)^n - sage: all(len(list(NAFp.language(s))) # optional - sage.symbolic + sage: all(len(list(NAFp.language(s))) # needs sage.symbolic ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9856,9 +9856,9 @@ def number_of_words(self, variable=None, [4 1 0] [0 4 1] [0 0 4] - sage: N = J3.number_of_words(); N # optional - sage.symbolic + sage: N = J3.number_of_words(); N # needs sage.symbolic 1/2*4^(n - 2)*(n - 1)*n + 4^(n - 1)*n + 4^n - sage: all(len(list(J3.language(s))) # optional - sage.symbolic + sage: all(len(list(J3.language(s))) # needs sage.symbolic ....: - len(list(J3.language(s-1))) == N.subs(n=s) ....: for s in range(1, 6)) True @@ -9868,14 +9868,14 @@ def number_of_words(self, variable=None, sage: A = Automaton([(j, j+1, 0) for j in range(3)], ....: initial_states=[0], ....: final_states=list(range(3))) - sage: A.number_of_words() # optional - sage.symbolic + sage: A.number_of_words() # needs sage.symbolic 1/2*0^(n - 2)*(n - 1)*n + 0^(n - 1)*n + 0^n TESTS:: sage: A = Automaton([(0, 0, 0), (0, 1, 0)], ....: initial_states=[0]) - sage: A.number_of_words() # optional - sage.symbolic + sage: A.number_of_words() # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: Finite State Machine must be deterministic. @@ -9966,12 +9966,12 @@ def asymptotic_moments(self, variable=None): ....: final_states=[0]) sage: T([0, 1, 1]) [0, -1, -1] - sage: moments = T.asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = T.asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic -1/2*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 1/4*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic -1/4*n + Order(1) #. For the case of the Hamming weight of the non-adjacent-form @@ -10034,12 +10034,12 @@ def asymptotic_moments(self, variable=None): Now, we actually compute the asymptotic moments:: - sage: moments = NAFweight.asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = NAFweight.asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic 1/3*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 2/27*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic Order(1) #. This is Example 3.16 in [HKW2015]_, where a transducer with @@ -10050,17 +10050,17 @@ def asymptotic_moments(self, variable=None): :: - sage: var('a_1, a_2, a_3, a_4') # optional - sage.symbolic + sage: var('a_1, a_2, a_3, a_4') # needs sage.symbolic (a_1, a_2, a_3, a_4) - sage: T = Transducer([[0, 0, 0, a_1], [0, 1, 1, a_3], # optional - sage.symbolic + sage: T = Transducer([[0, 0, 0, a_1], [0, 1, 1, a_3], # needs sage.symbolic ....: [1, 0, 0, a_4], [1, 1, 1, a_2]], ....: initial_states=[0], final_states=[0, 1]) - sage: moments = T.asymptotic_moments() # optional - sage.symbolic + sage: moments = T.asymptotic_moments() # needs sage.symbolic verbose 0 (...) Non-integer output weights lead to significant performance degradation. - sage: moments['expectation'] # optional - sage.symbolic + sage: moments['expectation'] # needs sage.symbolic 1/4*(a_1 + a_2 + a_3 + a_4)*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic -1/4*(a_1 - a_2)*n + Order(1) Therefore, the asymptotic covariance vanishes if and only if @@ -10072,12 +10072,12 @@ def asymptotic_moments(self, variable=None): :ref:`example on Gray code `):: - sage: moments = transducers.GrayCode().asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = transducers.GrayCode().asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic 1/2*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 1/4*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic Order(1) #. This is the first part of Example 4.4 in [HKW2015]_, @@ -10093,12 +10093,12 @@ def asymptotic_moments(self, variable=None): Transition from () to (1,): 1|0, Transition from (1,) to (): 0|1, Transition from (1,) to (1,): 1|0] - sage: moments = block10.asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = block10.asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic 1/4*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 1/16*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic Order(1) #. This is the second part of Example 4.4 in [HKW2015]_, @@ -10114,16 +10114,16 @@ def asymptotic_moments(self, variable=None): Transition from () to (1,): 1|0, Transition from (1,) to (): 0|0, Transition from (1,) to (1,): 1|1] - sage: var('N') # optional - sage.symbolic + sage: var('N') # needs sage.symbolic N - sage: moments = block11.asymptotic_moments(N) # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = block11.asymptotic_moments(N) # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic 1/4*N + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 5/16*N + Order(1) - sage: correlation = (moments['covariance'].coefficient(N) / # optional - sage.symbolic + sage: correlation = (moments['covariance'].coefficient(N) / # needs sage.symbolic ....: (1/2 * sqrt(moments['variance'].coefficient(N)))) - sage: correlation # optional - sage.symbolic + sage: correlation # needs sage.symbolic 2/5*sqrt(5) #. This is Example 4.5 in [HKW2015]_, counting the number of @@ -10144,12 +10144,12 @@ def asymptotic_moments(self, variable=None): Transition from 1 to 0: 1|0, Transition from 2 to 2: 0|0, Transition from 2 to 0: 1|1] - sage: moments = T.asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = T.asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic Order(1) #. The finite state machine must have a unique final component:: @@ -10224,26 +10224,26 @@ def asymptotic_moments(self, variable=None): sage: T = Transducer([[0, 0, 0, 0], [0, 0, 1, -1/2]], ....: initial_states=[0], final_states=[0]) - sage: moments = T.asymptotic_moments() # optional - sage.symbolic + sage: moments = T.asymptotic_moments() # needs sage.symbolic verbose 0 (...) Non-integer output weights lead to significant performance degradation. - sage: moments['expectation'] # optional - sage.symbolic + sage: moments['expectation'] # needs sage.symbolic -1/4*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 1/16*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic -1/8*n + Order(1) This warning can be silenced by :func:`~sage.misc.verbose.set_verbose`:: sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1, "finite_state_machine.py") - sage: moments = T.asymptotic_moments() # optional - sage.symbolic - sage: moments['expectation'] # optional - sage.symbolic + sage: moments = T.asymptotic_moments() # needs sage.symbolic + sage: moments['expectation'] # needs sage.symbolic -1/4*n + Order(1) - sage: moments['variance'] # optional - sage.symbolic + sage: moments['variance'] # needs sage.symbolic 1/16*n + Order(1) - sage: moments['covariance'] # optional - sage.symbolic + sage: moments['covariance'] # needs sage.symbolic -1/8*n + Order(1) sage: set_verbose(0, "finite_state_machine.py") @@ -10258,7 +10258,7 @@ def asymptotic_moments(self, variable=None): ....: initial_states=[s], final_states=[s]) sage: T([0, 0]) [2, 1, 2, 1, 2] - sage: T.asymptotic_moments()['expectation'] # optional - sage.symbolic + sage: T.asymptotic_moments()['expectation'] # needs sage.symbolic 3*n + Order(1) The same test for non-integer output:: @@ -10267,7 +10267,7 @@ def asymptotic_moments(self, variable=None): sage: s = FSMState(0, word_out=2/3) sage: T = Transducer([(s, s, 0, 1/2)], ....: initial_states=[s], final_states=[s]) - sage: T.asymptotic_moments()['expectation'] # optional - sage.symbolic + sage: T.asymptotic_moments()['expectation'] # needs sage.symbolic verbose 0 (...) Non-integer output weights lead to significant performance degradation. 7/6*n + Order(1) @@ -10436,11 +10436,11 @@ def moments_waiting_time(self, test=bool, is_zero=None, and the variance are `\sum_{k\ge 1} k2^{-k}=2` and `\sum_{k\ge 1} (k-2)^2 2^{-k}=2`:: - sage: var('k') # optional - sage.symbolic + sage: var('k') # needs sage.symbolic k - sage: sum(k * 2^(-k), k, 1, infinity) # optional - sage.symbolic + sage: sum(k * 2^(-k), k, 1, infinity) # needs sage.symbolic 2 - sage: sum((k-2)^2 * 2^(-k), k, 1, infinity) # optional - sage.symbolic + sage: sum((k-2)^2 * 2^(-k), k, 1, infinity) # needs sage.symbolic 2 We now compute the same expectation and variance by using a @@ -11845,13 +11845,13 @@ def shannon_parry_markov_chain(self): sage: NAF = Automaton([(0, 0, 0), (0, 1, 1), (0, 1, -1), ....: (1, 0, 0)], initial_states=[0], ....: final_states=[0, 1]) - sage: P_NAF = NAF.shannon_parry_markov_chain() # optional - sage.symbolic - sage: P_NAF.transitions() # optional - sage.symbolic + sage: P_NAF = NAF.shannon_parry_markov_chain() # needs sage.symbolic + sage: P_NAF.transitions() # needs sage.symbolic [Transition from 0 to 0: 1/2|0, Transition from 0 to 1: 1/4|1, Transition from 0 to 1: 1/4|-1, Transition from 1 to 0: 1|0] - sage: for s in P_NAF.iter_states(): # optional - sage.symbolic + sage: for s in P_NAF.iter_states(): # needs sage.symbolic ....: print(s.color) 3/4 3/2 @@ -11859,7 +11859,7 @@ def shannon_parry_markov_chain(self): The stationary distribution is also computed and saved as the initial probabilities of the returned Markov chain:: - sage: for s in P_NAF.states(): # optional - sage.symbolic + sage: for s in P_NAF.states(): # needs sage.symbolic ....: print("{} {}".format(s, s.initial_probability)) 0 2/3 1 1/3 diff --git a/src/sage/combinat/finite_state_machine_generators.py b/src/sage/combinat/finite_state_machine_generators.py index 24d027c03d0..827de1f054a 100644 --- a/src/sage/combinat/finite_state_machine_generators.py +++ b/src/sage/combinat/finite_state_machine_generators.py @@ -1079,15 +1079,15 @@ def _parse_recursion_equation_(self, equation, base, function, var, EXAMPLES:: - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: transducers._parse_recursion_equation_( # optional - sage.symbolic + sage: transducers._parse_recursion_equation_( # needs sage.symbolic ....: f(8*n + 7) == f(2*n + 3) + 5, ....: 2, f, n) RecursionRule(K=3, r=7, k=1, s=3, t=[5]) - sage: transducers._parse_recursion_equation_( # optional - sage.symbolic + sage: transducers._parse_recursion_equation_( # needs sage.symbolic ....: f(42) == 5, ....: 2, f, n) {42: [5]} @@ -1096,14 +1096,14 @@ def _parse_recursion_equation_(self, equation, base, function, var, The following tests check that the equations are well-formed:: - sage: transducers._parse_recursion_equation_(f(4*n + 1), 2, f, n) # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(4*n + 1), 2, f, n) # needs sage.symbolic Traceback (most recent call last): ... ValueError: f(4*n + 1) is not an equation with ==. :: - sage: transducers._parse_recursion_equation_(f(n) + 1 == f(2*n), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(n) + 1 == f(2*n), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1111,7 +1111,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n, 5) == 3, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n, 5) == 3, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1119,7 +1119,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(1/n) == f(n) + 3, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(1/n) == f(n) + 3, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1127,7 +1127,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(n^2 + 5) == 3, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(n^2 + 5) == 3, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1135,7 +1135,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(3*n + 5) == f(n) + 7, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(3*n + 5) == f(n) + 7, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1143,7 +1143,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(n + 5) == f(n) + 7, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(n + 5) == f(n) + 7, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1151,7 +1151,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_( # optional - sage.symbolic + sage: transducers._parse_recursion_equation_( # needs sage.symbolic ....: f(2*n + 1) == f(n + 1) + f(n) + 2, ....: 2, f, n) Traceback (most recent call last): @@ -1161,7 +1161,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == sin(n) + 2, # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == sin(n) + 2, # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1170,7 +1170,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_( # optional - sage.symbolic + sage: transducers._parse_recursion_equation_( # needs sage.symbolic ....: f(2*n + 1) == f(n) + n + 2, ....: 2, f, n) Traceback (most recent call last): @@ -1179,7 +1179,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == sin(n), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == sin(n), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1187,7 +1187,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(n, 2), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(n, 2), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1195,7 +1195,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(1/n), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(1/n), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1203,7 +1203,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(n^2 + 5), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(n^2 + 5), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1211,7 +1211,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(3*n + 5), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(3*n + 5), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1219,7 +1219,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_( # optional - sage.symbolic + sage: transducers._parse_recursion_equation_( # needs sage.symbolic ....: f(2*n + 1) == f((1/2)*n + 5), ....: QQ(2), f, n) Traceback (most recent call last): @@ -1228,7 +1228,7 @@ def _parse_recursion_equation_(self, equation, base, function, var, :: - sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(2*n + 5), # optional - sage.symbolic + sage: transducers._parse_recursion_equation_(f(2*n + 1) == f(2*n + 5), # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1434,17 +1434,17 @@ def Recursion(self, recursions, base, function=None, var=None, - The following example computes the Hamming weight of the ternary expansion of integers. :: - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(3*n + 1) == f(n) + 1, ....: f(3*n + 2) == f(n) + 1, ....: f(3*n) == f(n), ....: f(0) == 0], ....: 3, f, n) - sage: T.transitions() # optional - sage.symbolic + sage: T.transitions() # needs sage.symbolic [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (0, 0): 1|1, Transition from (0, 0) to (0, 0): 2|1] @@ -1452,13 +1452,13 @@ def Recursion(self, recursions, base, function=None, var=None, To illustrate what this transducer does, we consider the example of `n=601`:: - sage: ternary_expansion = 601.digits(base=3) # optional - sage.symbolic - sage: ternary_expansion # optional - sage.symbolic + sage: ternary_expansion = 601.digits(base=3) # needs sage.symbolic + sage: ternary_expansion # needs sage.symbolic [1, 2, 0, 1, 1, 2] - sage: weight_sequence = T(ternary_expansion) # optional - sage.symbolic - sage: weight_sequence # optional - sage.symbolic + sage: weight_sequence = T(ternary_expansion) # needs sage.symbolic + sage: weight_sequence # needs sage.symbolic [1, 1, 1, 1, 1] - sage: sum(weight_sequence) # optional - sage.symbolic + sage: sum(weight_sequence) # needs sage.symbolic 5 Note that the digit zero does not show up in the output because @@ -1468,24 +1468,24 @@ def Recursion(self, recursions, base, function=None, var=None, - The following example computes the Hamming weight of the non-adjacent form, cf. the :wikipedia:`Non-adjacent_form`. :: - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(4*n + 1) == f(n) + 1, ....: f(4*n - 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 0], ....: 2, f, n) - sage: T.transitions() # optional - sage.symbolic + sage: T.transitions() # needs sage.symbolic [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (0, 0): 0|1, Transition from (1, 1) to (1, 0): 1|1, Transition from (1, 0) to (1, 1): 0|-, Transition from (1, 0) to (1, 0): 1|-] - sage: [(s.label(), s.final_word_out) # optional - sage.symbolic + sage: [(s.label(), s.final_word_out) # needs sage.symbolic ....: for s in T.iter_final_states()] [((0, 0), []), ((1, 1), [1]), @@ -1507,9 +1507,9 @@ def Recursion(self, recursions, base, function=None, var=None, sage: binary_expansion = 29.digits(base=2) sage: binary_expansion [1, 0, 1, 1, 1] - sage: T(binary_expansion) # optional - sage.symbolic + sage: T(binary_expansion) # needs sage.symbolic [1, 1, 1] - sage: sum(T(binary_expansion)) # optional - sage.symbolic + sage: sum(T(binary_expansion)) # needs sage.symbolic 3 Indeed, the given non-adjacent form has three non-zero @@ -1535,11 +1535,11 @@ def Recursion(self, recursions, base, function=None, var=None, the point of view of this method---is a contradicting recursion. We override this by the parameter ``is_zero``. :: - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: function('f w') # optional - sage.symbolic + sage: function('f w') # needs sage.symbolic (f, w) - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(2*n) == f(n) + w(0), ....: f(4*n + 1) == f(n) + w(1, 0), ....: f(4*n - 1) == f(n) + w(-1, 0), @@ -1547,14 +1547,14 @@ def Recursion(self, recursions, base, function=None, var=None, ....: 2, f, n, ....: word_function=w, ....: is_zero=lambda x: sum(x).is_zero()) - sage: T.transitions() # optional - sage.symbolic + sage: T.transitions() # needs sage.symbolic [Transition from (0, 0) to (0, 0): 0|0, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (0, 0): 0|1,0, Transition from (1, 1) to (1, 0): 1|-1,0, Transition from (1, 0) to (1, 1): 0|-, Transition from (1, 0) to (1, 0): 1|0] - sage: for s in T.iter_states(): # optional - sage.symbolic + sage: for s in T.iter_states(): # needs sage.symbolic ....: print("{} {}".format(s, s.final_word_out)) (0, 0) [] (1, 1) [1, 0] @@ -1562,7 +1562,7 @@ def Recursion(self, recursions, base, function=None, var=None, We again consider the example of `n=29`:: - sage: T(29.digits(base=2)) # optional - sage.symbolic + sage: T(29.digits(base=2)) # needs sage.symbolic [1, 0, -1, 0, 0, 1, 0] The same transducer can also be entered bypassing the @@ -1576,22 +1576,22 @@ def Recursion(self, recursions, base, function=None, var=None, ....: (0, [])], ....: 2, ....: is_zero=lambda x: sum(x).is_zero()) - sage: TR == T # optional - sage.symbolic + sage: TR == T # needs sage.symbolic True - Here is an artificial example where some of the `s` are negative:: - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(2*n + 1) == f(n-1) + 1, ....: f(2*n) == f(n), ....: f(1) == 1, ....: f(0) == 0], 2, f, n) - sage: T.transitions() # optional - sage.symbolic + sage: T.transitions() # needs sage.symbolic [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (-1, 1): 0|1, @@ -1602,7 +1602,7 @@ def Recursion(self, recursions, base, function=None, var=None, Transition from (-1, 2) to (0, 0): 1|1, Transition from (1, 2) to (-1, 2): 0|1, Transition from (1, 2) to (1, 2): 1|1] - sage: [(s.label(), s.final_word_out) # optional - sage.symbolic + sage: [(s.label(), s.final_word_out) # needs sage.symbolic ....: for s in T.iter_final_states()] [((0, 0), []), ((1, 1), [1]), @@ -1613,7 +1613,7 @@ def Recursion(self, recursions, base, function=None, var=None, - Abelian complexity of the paperfolding sequence (cf. [HKP2015]_, Example 2.8):: - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(4*n) == f(2*n), ....: f(4*n+2) == f(2*n+1)+1, ....: f(16*n+1) == f(8*n+1), @@ -1623,7 +1623,7 @@ def Recursion(self, recursions, base, function=None, var=None, ....: f(1) == 2, f(0) == 0] ....: + [f(16*n+jj) == f(2*n+1)+2 for jj in [3,7,9,13]], ....: 2, f, n) - sage: T.transitions() # optional - sage.symbolic + sage: T.transitions() # needs sage.symbolic [Transition from (0, 0) to (0, 1): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (0, 1) to (0, 1): 0|-, @@ -1644,7 +1644,7 @@ def Recursion(self, recursions, base, function=None, var=None, Transition from (7, 3) to (2, 1): 1|1, Transition from (2, 1) to (1, 1): 0|1, Transition from (2, 1) to (2, 1): 1|-] - sage: for s in T.iter_states(): # optional - sage.symbolic + sage: for s in T.iter_states(): # needs sage.symbolic ....: print("{} {}".format(s, s.final_word_out)) (0, 0) [] (0, 1) [] @@ -1656,52 +1656,52 @@ def Recursion(self, recursions, base, function=None, var=None, (3, 3) [2, 2] (7, 3) [2, 2] (2, 1) [1, 2] - sage: list(sum(T(n.bits())) for n in srange(1, 21)) # optional - sage.symbolic + sage: list(sum(T(n.bits())) for n in srange(1, 21)) # needs sage.symbolic [2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 4, 5, 6, 5] - We now demonstrate the use of the ``output_rings`` parameter. If no ``output_rings`` are specified, the output labels are converted into ``ZZ``:: - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(2*n + 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 2], ....: 2, f, n) - sage: for t in T.transitions(): # optional - sage.symbolic + sage: for t in T.transitions(): # needs sage.symbolic ....: print([x.parent() for x in t.word_out]) [] [Integer Ring] - sage: [x.parent() for x in T.states()[0].final_word_out] # optional - sage.symbolic + sage: [x.parent() for x in T.states()[0].final_word_out] # needs sage.symbolic [Integer Ring] In contrast, if ``output_rings`` is set to the empty list, the results are not converted:: - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(2*n + 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 2], ....: 2, f, n, output_rings=[]) - sage: for t in T.transitions(): # optional - sage.symbolic + sage: for t in T.transitions(): # needs sage.symbolic ....: print([x.parent() for x in t.word_out]) [] [Symbolic Ring] - sage: [x.parent() for x in T.states()[0].final_word_out] # optional - sage.symbolic + sage: [x.parent() for x in T.states()[0].final_word_out] # needs sage.symbolic [Symbolic Ring] Finally, we use a somewhat questionable conversion:: - sage: T = transducers.Recursion([ # optional - sage.rings.finite_rings sage.symbolic + sage: T = transducers.Recursion([ # needs sage.rings.finite_rings sage.symbolic ....: f(2*n + 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 0], ....: 2, f, n, output_rings=[GF(5)]) - sage: for t in T.transitions(): # optional - sage.rings.finite_rings sage.symbolic + sage: for t in T.transitions(): # needs sage.rings.finite_rings sage.symbolic ....: print([x.parent() for x in t.word_out]) [] [Finite Field of size 5] @@ -1728,11 +1728,11 @@ def Recursion(self, recursions, base, function=None, var=None, The following tests fail due to missing or superfluous recursions or initial conditions. :: - sage: var('n') # optional - sage.symbolic + sage: var('n') # needs sage.symbolic n - sage: function('f') # optional - sage.symbolic + sage: function('f') # needs sage.symbolic f - sage: transducers.Recursion([f(2*n) == f(n)], # optional - sage.symbolic + sage: transducers.Recursion([f(2*n) == f(n)], # needs sage.symbolic ....: 2, f, n) Traceback (most recent call last): ... @@ -1741,7 +1741,7 @@ def Recursion(self, recursions, base, function=None, var=None, :: - sage: transducers.Recursion([f(2*n + 1) == f(n), # optional - sage.symbolic + sage: transducers.Recursion([f(2*n + 1) == f(n), # needs sage.symbolic ....: f(4*n) == f(2*n) + 1, ....: f(2*n) == f(n) + 1], ....: 2, f, n) @@ -1751,7 +1751,7 @@ def Recursion(self, recursions, base, function=None, var=None, :: - sage: transducers.Recursion([f(2*n + 1) == f(n) + 1, # optional - sage.symbolic + sage: transducers.Recursion([f(2*n + 1) == f(n) + 1, # needs sage.symbolic ....: f(2*n) == f(n), ....: f(0) == 0, ....: f(42) == 42], 2, f, n) @@ -1761,7 +1761,7 @@ def Recursion(self, recursions, base, function=None, var=None, :: - sage: transducers.Recursion([f(2*n + 1) == f(n) + 1, # optional - sage.symbolic + sage: transducers.Recursion([f(2*n + 1) == f(n) + 1, # needs sage.symbolic ....: f(2*n) == f(n - 2) + 4, ....: f(0) == 0], 2, f, n) Traceback (most recent call last): @@ -1771,7 +1771,7 @@ def Recursion(self, recursions, base, function=None, var=None, Here is an example of a transducer with a conflicting rule (it cannot hold for `n = 0`):: - sage: T = transducers.Recursion([ # optional - sage.symbolic + sage: T = transducers.Recursion([ # needs sage.symbolic ....: f(2*n + 1) == f(n - 1), ....: f(2*n) == f(n) + 1, ....: f(1) == 1, diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 14711e8713e..f425c56c97d 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -151,7 +151,7 @@ class CombinatorialFreeModule(UniqueRepresentation, Module, IndexedGenerators): The constructed module is in the category of modules with basis over the base ring:: - sage: CombinatorialFreeModule(QQ, Partitions()).category() # optional - sage.combinat + sage: CombinatorialFreeModule(QQ, Partitions()).category() # needs sage.combinat Category of vector spaces with basis over Rational Field If furthermore the index set is finite (i.e. in the category @@ -160,7 +160,7 @@ class CombinatorialFreeModule(UniqueRepresentation, Module, IndexedGenerators): sage: CombinatorialFreeModule(QQ, [1,2,3,4]).category() Category of finite dimensional vector spaces with basis over Rational Field - sage: CombinatorialFreeModule(QQ, Partitions(3), # optional - sage.combinat + sage: CombinatorialFreeModule(QQ, Partitions(3), # needs sage.combinat ....: category=Algebras(QQ).WithBasis()).category() Category of finite dimensional algebras with basis over Rational Field @@ -252,11 +252,11 @@ class CombinatorialFreeModule(UniqueRepresentation, Module, IndexedGenerators): TESTS:: - sage: XQ = SchubertPolynomialRing(QQ) # optional - sage.combinat - sage: XZ = SchubertPolynomialRing(ZZ) # optional - sage.combinat - sage: XQ == XZ # optional - sage.combinat + sage: XQ = SchubertPolynomialRing(QQ) # needs sage.combinat + sage: XZ = SchubertPolynomialRing(ZZ) # needs sage.combinat + sage: XQ == XZ # needs sage.combinat False - sage: XQ == XQ # optional - sage.combinat + sage: XQ == XQ # needs sage.combinat True We check that issue :trac:`28681` is fixed:: @@ -347,21 +347,21 @@ def element_class(self): EXAMPLES:: - sage: A = Algebras(QQ).WithBasis().example(); A # optional - sage.combinat + sage: A = Algebras(QQ).WithBasis().example(); A # needs sage.combinat An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field - sage: A.element_class.mro() # optional - sage.combinat + sage: A.element_class.mro() # needs sage.combinat [, , ...] - sage: a,b,c = A.algebra_generators() # optional - sage.combinat - sage: a * b # optional - sage.combinat + sage: a,b,c = A.algebra_generators() # needs sage.combinat + sage: a * b # needs sage.combinat B[word: ab] TESTS:: - sage: A.__class__.element_class.__module__ # optional - sage.combinat + sage: A.__class__.element_class.__module__ # needs sage.combinat 'sage.combinat.free_module' """ return self.__make_element_class__(self.Element, @@ -385,9 +385,9 @@ def __init__(self, R, basis_keys=None, element_class=None, category=None, sage: F.category() Category of finite dimensional algebras with basis over Rational Field - sage: F = CombinatorialFreeModule(GF(3), ['a','b','c'], # optional - sage.rings.finite_rings + sage: F = CombinatorialFreeModule(GF(3), ['a','b','c'], # needs sage.rings.finite_rings ....: category=(Modules(GF(3)).WithBasis(), Semigroups())) - sage: F.category() # optional - sage.rings.finite_rings + sage: F.category() # needs sage.rings.finite_rings Join of Category of finite semigroups and Category of finite dimensional vector spaces with basis over Finite Field of size 3 @@ -519,8 +519,8 @@ def _ascii_art_term(self, m): TESTS:: - sage: R = NonCommutativeSymmetricFunctions(QQ).R() # optional - sage.combinat - sage: ascii_art(R.one()) # indirect doctest # optional - sage.combinat + sage: R = NonCommutativeSymmetricFunctions(QQ).R() # needs sage.combinat + sage: ascii_art(R.one()) # indirect doctest # needs sage.combinat 1 """ try: @@ -536,8 +536,8 @@ def _unicode_art_term(self, m): TESTS:: - sage: R = NonCommutativeSymmetricFunctions(QQ).R() # optional - sage.combinat - sage: unicode_art(R.one()) # indirect doctest # optional - sage.combinat + sage: R = NonCommutativeSymmetricFunctions(QQ).R() # needs sage.combinat + sage: unicode_art(R.one()) # indirect doctest # needs sage.combinat 1 """ try: @@ -627,20 +627,20 @@ def _element_constructor_(self, x): Do not rely on the following feature which may be removed in the future:: - sage: QS3 = SymmetricGroupAlgebra(QQ,3) # optional - sage.combinat - sage: QS3([2,3,1]) # indirect doctest # optional - sage.combinat + sage: QS3 = SymmetricGroupAlgebra(QQ,3) # needs sage.combinat + sage: QS3([2,3,1]) # indirect doctest # needs sage.combinat [2, 3, 1] instead, use:: - sage: P = QS3.basis().keys() # optional - sage.combinat - sage: QS3.monomial(P([2,3,1])) # indirect doctest # optional - sage.combinat + sage: P = QS3.basis().keys() # needs sage.combinat + sage: QS3.monomial(P([2,3,1])) # indirect doctest # needs sage.combinat [2, 3, 1] or:: - sage: B = QS3.basis() # optional - sage.combinat - sage: B[P([2,3,1])] # optional - sage.combinat + sage: B = QS3.basis() # needs sage.combinat + sage: B[P([2,3,1])] # needs sage.combinat [2, 3, 1] TODO: The symmetric group algebra (and in general, @@ -692,10 +692,10 @@ def _element_constructor_(self, x): Here is a real life example illustrating that this yielded mathematically wrong results:: - sage: S = SymmetricFunctions(QQ) # optional - sage.combinat - sage: s = S.s(); p = S.p() # optional - sage.combinat - sage: ss = tensor([s,s]); pp = tensor([p,p]) # optional - sage.combinat - sage: a = tensor((s[2],s[2])) # optional - sage.combinat + sage: S = SymmetricFunctions(QQ) # needs sage.combinat + sage: s = S.s(); p = S.p() # needs sage.combinat + sage: ss = tensor([s,s]); pp = tensor([p,p]) # needs sage.combinat + sage: a = tensor((s[2],s[2])) # needs sage.combinat The following originally used to yield ``p[[2]] # p[[2]]``, and if there was no natural coercion between ``s`` and ``p``, this would @@ -703,7 +703,7 @@ def _element_constructor_(self, x): Since :trac:`15305`, this takes the coercion between ``s`` and ``p`` and lifts it to the tensor product. :: - sage: pp(a) # optional - sage.combinat + sage: pp(a) # needs sage.combinat 1/4*p[1, 1] # p[1, 1] + 1/4*p[1, 1] # p[2] + 1/4*p[2] # p[1, 1] + 1/4*p[2] # p[2] General extensions of the ground ring should probably be reintroduced @@ -717,8 +717,8 @@ def _element_constructor_(self, x): Conversion from the ground ring is implemented for algebras:: - sage: QS3 = SymmetricGroupAlgebra(QQ,3) # optional - sage.combinat - sage: QS3(2) # optional - sage.combinat + sage: QS3 = SymmetricGroupAlgebra(QQ,3) # needs sage.combinat + sage: QS3(2) # needs sage.combinat 2*[1, 2, 3] """ R = self.base_ring() @@ -799,8 +799,8 @@ def _first_ngens(self, n): sage: C._first_ngens(3) (B[0], B[1], B[-1]) - sage: R. = FreeAlgebra(QQ, 2) # optional - sage.combinat - sage: x,y # optional - sage.combinat + sage: R. = FreeAlgebra(QQ, 2) # needs sage.combinat + sage: x,y # needs sage.combinat (x, y) """ try: @@ -836,13 +836,13 @@ def _coerce_map_from_(self, R): sage: C.has_coerce_map_from(CQ) False - sage: CF2 = CombinatorialFreeModule(GF(2), Set([1,2])) # optional - sage.rings.finite_rings - sage: CF2.has_coerce_map_from(C) # optional - sage.rings.finite_rings + sage: CF2 = CombinatorialFreeModule(GF(2), Set([1,2])) # needs sage.rings.finite_rings + sage: CF2.has_coerce_map_from(C) # needs sage.rings.finite_rings True - sage: c = C.monomial(1) # optional - sage.rings.finite_rings - sage: CF2(2*c) # optional - sage.rings.finite_rings + sage: c = C.monomial(1) # needs sage.rings.finite_rings + sage: CF2(2*c) # needs sage.rings.finite_rings 0 - sage: CF2(3*c) # optional - sage.rings.finite_rings + sage: CF2(3*c) # needs sage.rings.finite_rings B[1] """ if isinstance(R, CombinatorialFreeModule): @@ -878,8 +878,8 @@ def dimension(self): :: - sage: s = SymmetricFunctions(QQ).schur() # optional - sage.combinat - sage: s.dimension() # optional - sage.combinat + sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat + sage: s.dimension() # needs sage.combinat +Infinity """ return self._indices.cardinality() @@ -894,11 +894,11 @@ def is_exact(self): EXAMPLES:: - sage: GroupAlgebra(GL(3, GF(7))).is_exact() # optional - sage.groups sage.rings.finite_rings + sage: GroupAlgebra(GL(3, GF(7))).is_exact() # needs sage.groups sage.rings.finite_rings True - sage: GroupAlgebra(GL(3, GF(7)), RR).is_exact() # optional - sage.groups sage.rings.finite_rings + sage: GroupAlgebra(GL(3, GF(7)), RR).is_exact() # needs sage.groups sage.rings.finite_rings False - sage: GroupAlgebra(GL(3, pAdicRing(7))).is_exact() # not implemented correctly (not my fault)! # optional - sage.groups sage.rings.padics + sage: GroupAlgebra(GL(3, pAdicRing(7))).is_exact() # not implemented, needs sage.groups sage.rings.padics False """ # The index set may not have a check for exactness @@ -928,11 +928,11 @@ def set_order(self, order): EXAMPLES:: - sage: QS2 = SymmetricGroupAlgebra(QQ,2) # optional - sage.combinat - sage: b = list(QS2.basis().keys()) # optional - sage.combinat - sage: b.reverse() # optional - sage.combinat - sage: QS2.set_order(b) # optional - sage.combinat - sage: QS2.get_order() # optional - sage.combinat + sage: QS2 = SymmetricGroupAlgebra(QQ,2) # needs sage.combinat + sage: b = list(QS2.basis().keys()) # needs sage.combinat + sage: b.reverse() # needs sage.combinat + sage: QS2.set_order(b) # needs sage.combinat + sage: QS2.get_order() # needs sage.combinat [[2, 1], [1, 2]] """ self._order = order @@ -946,8 +946,8 @@ def get_order(self): EXAMPLES:: - sage: QS2 = SymmetricGroupAlgebra(QQ,2) # optional - sage.combinat - sage: QS2.get_order() # note: order changed on 2009-03-13 # optional - sage.combinat + sage: QS2 = SymmetricGroupAlgebra(QQ,2) # needs sage.combinat + sage: QS2.get_order() # note: order changed on 2009-03-13 # needs sage.combinat [[2, 1], [1, 2]] """ if self._order is None: @@ -1003,11 +1003,11 @@ def from_vector(self, vector, order=None, coerce=True): EXAMPLES:: - sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat - sage: b = QS3.from_vector(vector((2, 0, 0, 0, 0, 4))); b # optional - sage.combinat + sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat + sage: b = QS3.from_vector(vector((2, 0, 0, 0, 0, 4))); b # needs sage.combinat 2*[1, 2, 3] + 4*[3, 2, 1] - sage: a = 2*QS3([1,2,3]) + 4*QS3([3,2,1]) # optional - sage.combinat - sage: a == b # optional - sage.combinat + sage: a = 2*QS3([1,2,3]) + 4*QS3([3,2,1]) # needs sage.combinat + sage: a == b # needs sage.combinat True """ if order is None: @@ -1134,8 +1134,8 @@ def _sum_of_monomials(self, indices): sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) sage: F._sum_of_monomials(['a', 'b', 'b']) B['a'] + 2*B['b'] - sage: F = CombinatorialFreeModule(GF(3), ['a', 'b', 'c']) # optional - sage.rings.finite_rings - sage: F._sum_of_monomials(['a', 'b', 'b', 'b']) # optional - sage.rings.finite_rings + sage: F = CombinatorialFreeModule(GF(3), ['a', 'b', 'c']) # needs sage.rings.finite_rings + sage: F._sum_of_monomials(['a', 'b', 'b', 'b']) # needs sage.rings.finite_rings B['a'] """ R = self.base_ring() @@ -1210,26 +1210,26 @@ def _from_dict(self, d, coerce=False, remove_zeros=True): EXAMPLES:: - sage: e = SymmetricFunctions(QQ).elementary() # optional - sage.combinat - sage: s = SymmetricFunctions(QQ).schur() # optional - sage.combinat - sage: a = e([2,1]) + e([1,1,1]); a # optional - sage.combinat + sage: e = SymmetricFunctions(QQ).elementary() # needs sage.combinat + sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat + sage: a = e([2,1]) + e([1,1,1]); a # needs sage.combinat e[1, 1, 1] + e[2, 1] - sage: s._from_dict(a.monomial_coefficients()) # optional - sage.combinat + sage: s._from_dict(a.monomial_coefficients()) # needs sage.combinat s[1, 1, 1] + s[2, 1] If the optional argument ``coerce`` is ``True``, then the coefficients are coerced into the base ring of ``self``:: - sage: part = Partition([2,1]) # optional - sage.combinat - sage: d = {part: 1} # optional - sage.combinat - sage: a = s._from_dict(d, coerce=True); a # optional - sage.combinat + sage: part = Partition([2,1]) # needs sage.combinat + sage: d = {part: 1} # needs sage.combinat + sage: a = s._from_dict(d, coerce=True); a # needs sage.combinat s[2, 1] - sage: a.coefficient(part).parent() # optional - sage.combinat + sage: a.coefficient(part).parent() # needs sage.combinat Rational Field With ``remove_zeros=True``, zero coefficients are removed:: - sage: s._from_dict({part: 0}) # optional - sage.combinat + sage: s._from_dict({part: 0}) # needs sage.combinat 0 .. WARNING:: @@ -1238,7 +1238,7 @@ def _from_dict(self, d, coerce=False, remove_zeros=True): coefficient of the dictionary is zero. Otherwise, this may lead to illegal results:: - sage: list(s._from_dict({part: 0}, remove_zeros=False)) # optional - sage.combinat + sage: list(s._from_dict({part: 0}, remove_zeros=False)) # needs sage.combinat [([2, 1], 0)] """ assert isinstance(d, dict) @@ -1428,9 +1428,9 @@ def _ascii_art_(self, term): """ TESTS:: - sage: R = NonCommutativeSymmetricFunctions(QQ).R() # optional - sage.combinat - sage: Partitions.options(diagram_str="#", convention="french") # optional - sage.combinat - sage: s = ascii_art(tensor((R[1,2], R[3,1,2]))); s # optional - sage.combinat + sage: R = NonCommutativeSymmetricFunctions(QQ).R() # needs sage.combinat + sage: Partitions.options(diagram_str="#", convention="french") # needs sage.combinat + sage: s = ascii_art(tensor((R[1,2], R[3,1,2]))); s # needs sage.combinat R # R # ### ## # @@ -1438,7 +1438,7 @@ def _ascii_art_(self, term): Check that the breakpoints are correct (:trac:`29202`):: - sage: s._breakpoints # optional - sage.combinat + sage: s._breakpoints # needs sage.combinat [6] """ if hasattr(self, "_print_options"): @@ -1457,9 +1457,9 @@ def _unicode_art_(self, term): """ TESTS:: - sage: R = NonCommutativeSymmetricFunctions(QQ).R() # optional - sage.combinat - sage: Partitions.options(diagram_str="#", convention="french") # optional - sage.combinat - sage: s = unicode_art(tensor((R[1,2], R[3,1,2]))); s # optional - sage.combinat + sage: R = NonCommutativeSymmetricFunctions(QQ).R() # needs sage.combinat + sage: Partitions.options(diagram_str="#", convention="french") # needs sage.combinat + sage: s = unicode_art(tensor((R[1,2], R[3,1,2]))); s # needs sage.combinat R ⊗ R ┌┐ ┌┬┬┐ ├┼┐ └┴┼┤ @@ -1468,7 +1468,7 @@ def _unicode_art_(self, term): Check that the breakpoints are correct (:trac:`29202`):: - sage: s._breakpoints # optional - sage.combinat + sage: s._breakpoints # needs sage.combinat [7] """ if hasattr(self, "_print_options"): diff --git a/src/sage/combinat/fully_commutative_elements.py b/src/sage/combinat/fully_commutative_elements.py index 285bd370fb1..c6d072eb432 100644 --- a/src/sage/combinat/fully_commutative_elements.py +++ b/src/sage/combinat/fully_commutative_elements.py @@ -248,7 +248,7 @@ def plot_heap(self): EXAMPLES:: sage: FC = CoxeterGroup(['B', 5]).fully_commutative_elements() - sage: FC([3,2,4,3,1]).plot_heap() # optional - sage.plot + sage: FC([3,2,4,3,1]).plot_heap() # needs sage.plot Graphics object consisting of 15 graphics primitives .. PLOT:: diff --git a/src/sage/combinat/fully_packed_loop.py b/src/sage/combinat/fully_packed_loop.py index ca4bf09b1b0..949ee9c6504 100644 --- a/src/sage/combinat/fully_packed_loop.py +++ b/src/sage/combinat/fully_packed_loop.py @@ -158,7 +158,7 @@ class FullyPackedLoop(Element, metaclass=InheritComparisonClasscallMetaclass): The class also has a plot method:: - sage: fpl.plot() # optional - sage.plot + sage: fpl.plot() # needs sage.plot Graphics object consisting of 3 graphics primitives which gives: @@ -782,7 +782,7 @@ def plot(self, **options): sage: A = AlternatingSignMatrix([[0, 1, 0], [1, -1, 1], [0, 1, 0]]) sage: fpl = FullyPackedLoop(A) - sage: fpl.plot() # optional - sage.plot + sage: fpl.plot() # needs sage.plot Graphics object consisting of 3 graphics primitives The resulting graphics is as follows @@ -799,7 +799,7 @@ def plot(self, **options): sage: A = AlternatingSignMatrix([[0, 1, 0], [1, -1, 1], [0, 1, 0]]) sage: fpl = FullyPackedLoop(A) - sage: fpl.plot(link_color_map='rainbow') # optional - sage.plot + sage: fpl.plot(link_color_map='rainbow') # needs sage.plot Graphics object consisting of 3 graphics primitives .. PLOT:: @@ -812,9 +812,9 @@ def plot(self, **options): You can plot the 42 fully packed loops of size `4 \times 4` using:: - sage: G = [fpl.plot(link_color_map='winter', loop_color='black') # optional - sage.plot + sage: G = [fpl.plot(link_color_map='winter', loop_color='black') # needs sage.plot ....: for fpl in FullyPackedLoops(4)] - sage: graphics_array(G, 7, 6) # optional - sage.plot + sage: graphics_array(G, 7, 6) # needs sage.plot Graphics Array of size 7 x 6 .. PLOT:: @@ -835,7 +835,7 @@ def plot(self, **options): ....: 00000000+-0000+00000000000000+0000000000" sage: a = matrix(20, [{'0':0, '+':1, '-': -1}[i] for i in s]) sage: fpl = FullyPackedLoop(a) - sage: fpl.plot(loop_fill=True, loop_color_map='rainbow') # optional - sage.plot + sage: fpl.plot(loop_fill=True, loop_color_map='rainbow') # needs sage.plot Graphics object consisting of 27 graphics primitives .. PLOT:: diff --git a/src/sage/combinat/integer_lists/invlex.pyx b/src/sage/combinat/integer_lists/invlex.pyx index f78c5d3b467..b517a108479 100644 --- a/src/sage/combinat/integer_lists/invlex.pyx +++ b/src/sage/combinat/integer_lists/invlex.pyx @@ -560,7 +560,7 @@ class IntegerListsLex(IntegerLists, metaclass=ClasscallMetaclass): :: - sage: Partitions(2, max_slope=-1, length=2).list() # optional - sage.combinat + sage: Partitions(2, max_slope=-1, length=2).list() # needs sage.combinat [] sage: list(IntegerListsLex(0, floor=ConstantFunction(1), min_slope=0)) [[]] diff --git a/src/sage/combinat/interval_posets.py b/src/sage/combinat/interval_posets.py index 2440843bac1..9a1dc86457f 100644 --- a/src/sage/combinat/interval_posets.py +++ b/src/sage/combinat/interval_posets.py @@ -437,13 +437,13 @@ def plot(self, **kwds): EXAMPLES:: sage: ti = TamariIntervalPosets(4)[2] - sage: ti.plot() # optional - sage.plot + sage: ti.plot() # needs sage.plot Graphics object consisting of 6 graphics primitives TESTS:: sage: ti = TamariIntervalPoset(3, [[2,1], [2,3]]) - sage: ti.plot() # optional - sage.plot + sage: ti.plot() # needs sage.plot Graphics object consisting of 6 graphics primitives """ c0 = 'blue' # self.latex_options()["color_increasing"] @@ -611,11 +611,11 @@ def factor(self) -> list[TamariIntervalPoset]: TESTS:: - sage: T = TamariIntervalPosets(20).random_element() # optional - sage.combinat - sage: facs = factor(T) # optional - sage.combinat - sage: all(U.is_connected() for U in facs) # optional - sage.combinat + sage: T = TamariIntervalPosets(20).random_element() # needs sage.combinat + sage: facs = factor(T) # needs sage.combinat + sage: all(U.is_connected() for U in facs) # needs sage.combinat True - sage: T == prod(facs) # optional - sage.combinat + sage: T == prod(facs) # needs sage.combinat True """ hasse = self.poset().hasse_diagram() @@ -1030,10 +1030,10 @@ def cubical_coordinates(self) -> tuple[int, ...]: sage: ip = TamariIntervalPoset(3,[]) sage: ip.cubical_coordinates() (0, 0) - sage: ip = TamariIntervalPosets(10).random_element() # optional - sage.combinat - sage: len(ip.cubical_coordinates()) # optional - sage.combinat + sage: ip = TamariIntervalPosets(10).random_element() # needs sage.combinat + sage: len(ip.cubical_coordinates()) # needs sage.combinat 9 - sage: sorted(ip.cubical_coordinates() for ip in TamariIntervalPosets(2)) # optional - sage.combinat + sage: sorted(ip.cubical_coordinates() for ip in TamariIntervalPosets(2)) # needs sage.combinat [(-1,), (0,), (1,)] REFERENCES: @@ -1136,7 +1136,7 @@ def rise_contact_involution(self) -> TIP: (4, 3), (3, 2), (2, 1)] sage: t.rise_contact_involution() == tip True - sage: (tip.lower_dyck_word().number_of_touch_points() # optional - sage.combinat + sage: (tip.lower_dyck_word().number_of_touch_points() # needs sage.combinat ....: == t.upper_dyck_word().number_of_initial_rises()) True sage: tip.number_of_tamari_inversions() == t.number_of_tamari_inversions() @@ -1233,7 +1233,7 @@ def insertion(self, i) -> TIP: ....: print(T, i) ....: return False ....: return True - sage: test_equivalence(3) # optional - sage.combinat + sage: test_equivalence(3) # needs sage.combinat True sage: ti = TamariIntervalPosets(3).an_element() @@ -1675,17 +1675,17 @@ def contains_dyck_word(self, dyck_word) -> bool: EXAMPLES:: sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]) - sage: ip.contains_dyck_word(DyckWord([1,1,1,0,0,0,1,0])) # optional - sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,1,1,0,0,0,1,0])) # needs sage.combinat True - sage: ip.contains_dyck_word(DyckWord([1,1,0,1,0,1,0,0])) # optional - sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,1,0,1,0,1,0,0])) # needs sage.combinat True - sage: ip.contains_dyck_word(DyckWord([1,0,1,1,0,1,0,0])) # optional - sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,0,1,1,0,1,0,0])) # needs sage.combinat False - sage: ip.contains_dyck_word(ip.lower_dyck_word()) # optional - sage.combinat + sage: ip.contains_dyck_word(ip.lower_dyck_word()) # needs sage.combinat True - sage: ip.contains_dyck_word(ip.upper_dyck_word()) # optional - sage.combinat + sage: ip.contains_dyck_word(ip.upper_dyck_word()) # needs sage.combinat True - sage: all(ip.contains_dyck_word(bt) for bt in ip.dyck_words()) # optional - sage.combinat + sage: all(ip.contains_dyck_word(bt) for bt in ip.dyck_words()) # needs sage.combinat True """ return self.contains_binary_tree(dyck_word.to_binary_tree_tamari()) @@ -1780,14 +1780,14 @@ def is_initial_interval(self) -> bool: sage: ip = TamariIntervalPoset(4, [(1, 2), (2, 4), (3, 4)]) sage: ip.is_initial_interval() True - sage: ip.lower_dyck_word() # optional - sage.combinat + sage: ip.lower_dyck_word() # needs sage.combinat [1, 0, 1, 0, 1, 0, 1, 0] sage: ip = TamariIntervalPoset(4, [(1, 2), (2, 4), (3, 4), (3, 2)]) sage: ip.is_initial_interval() False - sage: ip.lower_dyck_word() # optional - sage.combinat + sage: ip.lower_dyck_word() # needs sage.combinat [1, 0, 1, 1, 0, 0, 1, 0] - sage: all(DyckWord([1,0,1,0,1,0]).tamari_interval(dw) # optional - sage.combinat + sage: all(DyckWord([1,0,1,0,1,0]).tamari_interval(dw) # needs sage.combinat ....: .is_initial_interval() ....: for dw in DyckWords(3)) True @@ -1810,14 +1810,14 @@ def is_final_interval(self) -> bool: sage: ip = TamariIntervalPoset(4, [(4, 3), (3, 1), (2, 1)]) sage: ip.is_final_interval() True - sage: ip.upper_dyck_word() # optional - sage.combinat + sage: ip.upper_dyck_word() # needs sage.combinat [1, 1, 1, 1, 0, 0, 0, 0] sage: ip = TamariIntervalPoset(4, [(4, 3), (3, 1), (2, 1), (2, 3)]) sage: ip.is_final_interval() False - sage: ip.upper_dyck_word() # optional - sage.combinat + sage: ip.upper_dyck_word() # needs sage.combinat [1, 1, 0, 1, 1, 0, 0, 0] - sage: all(dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 0])) # optional - sage.combinat + sage: all(dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 0])) # needs sage.combinat ....: .is_final_interval() ....: for dw in DyckWords(3)) True @@ -1862,12 +1862,12 @@ def lower_dyck_word(self): sage: ip = TamariIntervalPoset(6, [(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - sage: ip.lower_dyck_word() # optional - sage.combinat + sage: ip.lower_dyck_word() # needs sage.combinat [1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0] - sage: ldw_ff = TamariIntervalPosets.final_forest(ip.lower_dyck_word()) # optional - sage.combinat - sage: ldw_ff == ip.final_forest() # optional - sage.combinat + sage: ldw_ff = TamariIntervalPosets.final_forest(ip.lower_dyck_word()) # needs sage.combinat + sage: ldw_ff == ip.final_forest() # needs sage.combinat True - sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # optional - sage.combinat + sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # needs sage.combinat ....: ip.upper_dyck_word()) True """ @@ -1911,12 +1911,12 @@ def upper_dyck_word(self): sage: ip = TamariIntervalPoset(6,[(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - sage: ip.upper_dyck_word() # optional - sage.combinat + sage: ip.upper_dyck_word() # needs sage.combinat [1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0] - sage: udw_if = TamariIntervalPosets.initial_forest(ip.upper_dyck_word()) # optional - sage.combinat - sage: udw_if == ip.initial_forest() # optional - sage.combinat + sage: udw_if = TamariIntervalPosets.initial_forest(ip.upper_dyck_word()) # needs sage.combinat + sage: udw_if == ip.initial_forest() # needs sage.combinat True - sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # optional - sage.combinat + sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # needs sage.combinat ....: ip.upper_dyck_word()) True """ @@ -2086,10 +2086,10 @@ def linear_extensions(self) -> Iterator[Permutation]: EXAMPLES:: sage: ip = TamariIntervalPoset(3, [(1,2),(3,2)]) - sage: list(ip.linear_extensions()) # optional - sage.rings.finite_rings sage.modules + sage: list(ip.linear_extensions()) # needs sage.modules sage.rings.finite_rings [[3, 1, 2], [1, 3, 2]] sage: ip = TamariIntervalPoset(4, [(1,2),(2,3),(4,3)]) - sage: list(ip.linear_extensions()) # optional - sage.rings.finite_rings sage.modules + sage: list(ip.linear_extensions()) # needs sage.modules sage.rings.finite_rings [[4, 1, 2, 3], [1, 2, 4, 3], [1, 4, 2, 3]] """ for ext in self._poset.linear_extensions(): @@ -2226,12 +2226,12 @@ def dyck_words(self) -> Iterator: EXAMPLES:: - sage: list(TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]).dyck_words()) # optional - sage.combinat + sage: list(TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]).dyck_words()) # needs sage.combinat [[1, 1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 0, 1, 0]] - sage: set(TamariIntervalPoset(4,[]).dyck_words()) == set(DyckWords(4)) # optional - sage.combinat + sage: set(TamariIntervalPoset(4,[]).dyck_words()) == set(DyckWords(4)) # needs sage.combinat True """ for ip in self.lower_contained_intervals(): @@ -2308,10 +2308,10 @@ def maximal_chain_dyck_words(self) -> Iterator: EXAMPLES:: sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]) - sage: list(ip.maximal_chain_dyck_words()) # optional - sage.combinat + sage: list(ip.maximal_chain_dyck_words()) # needs sage.combinat [[1, 1, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 1, 0, 0]] sage: ip = TamariIntervalPoset(4,[]) - sage: list(ip.maximal_chain_dyck_words()) # optional - sage.combinat + sage: list(ip.maximal_chain_dyck_words()) # needs sage.combinat [[1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1, 0], @@ -2377,11 +2377,11 @@ def tamari_inversions(self) -> list[tuple[int, int]]: sage: ip = TamariIntervalPoset(4,[]) sage: ip.tamari_inversions() [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)] - sage: all(not TamariIntervalPosets.from_binary_trees(bt,bt) # optional - sage.combinat + sage: all(not TamariIntervalPosets.from_binary_trees(bt,bt) # needs sage.combinat ....: .tamari_inversions() ....: for bt in BinaryTrees(3)) True - sage: all(not TamariIntervalPosets.from_binary_trees(bt,bt) # optional - sage.combinat + sage: all(not TamariIntervalPosets.from_binary_trees(bt,bt) # needs sage.combinat ....: .tamari_inversions() ....: for bt in BinaryTrees(4)) True @@ -2504,18 +2504,18 @@ def new_decomposition(self) -> list[TIP]: sage: ex = TamariIntervalPosets(4)[11] sage: ex.number_of_new_components() 3 - sage: ex.new_decomposition() # optional - sage.combinat + sage: ex.new_decomposition() # needs sage.combinat [The Tamari interval of size 1 induced by relations [], The Tamari interval of size 2 induced by relations [], The Tamari interval of size 1 induced by relations []] TESTS:: - sage: ex = TamariIntervalPosets(4).random_element() # optional - sage.combinat - sage: dec = ex.new_decomposition() # optional - sage.combinat - sage: len(dec) == ex.number_of_new_components() # optional - sage.combinat + sage: ex = TamariIntervalPosets(4).random_element() # needs sage.combinat + sage: dec = ex.new_decomposition() # needs sage.combinat + sage: len(dec) == ex.number_of_new_components() # needs sage.combinat True - sage: all(u.is_new() for u in dec) # optional - sage.combinat + sage: all(u.is_new() for u in dec) # needs sage.combinat True """ from sage.combinat.binary_tree import BinaryTree @@ -3036,11 +3036,11 @@ def final_forest(element) -> TIP: From Dyck words:: - sage: dw = DyckWord([1,0]) # optional - sage.combinat - sage: TamariIntervalPosets.final_forest(dw) # optional - sage.combinat + sage: dw = DyckWord([1,0]) # needs sage.combinat + sage: TamariIntervalPosets.final_forest(dw) # needs sage.combinat The Tamari interval of size 1 induced by relations [] - sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # optional - sage.combinat - sage: TamariIntervalPosets.final_forest(dw) # optional - sage.combinat + sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # needs sage.combinat + sage: TamariIntervalPosets.final_forest(dw) # needs sage.combinat The Tamari interval of size 5 induced by relations [(5, 4), (3, 1), (2, 1)] TESTS:: @@ -3149,11 +3149,11 @@ def initial_forest(element) -> TIP: from Dyck words:: - sage: dw = DyckWord([1,0]) # optional - sage.combinat - sage: TamariIntervalPosets.initial_forest(dw) # optional - sage.combinat + sage: dw = DyckWord([1,0]) # needs sage.combinat + sage: TamariIntervalPosets.initial_forest(dw) # needs sage.combinat The Tamari interval of size 1 induced by relations [] - sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # optional - sage.combinat - sage: TamariIntervalPosets.initial_forest(dw) # optional - sage.combinat + sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # needs sage.combinat + sage: TamariIntervalPosets.initial_forest(dw) # needs sage.combinat The Tamari interval of size 5 induced by relations [(1, 4), (2, 3), (3, 4)] TESTS:: @@ -3274,27 +3274,27 @@ def from_dyck_words(dw1, dw2) -> TIP: EXAMPLES:: - sage: dw1 = DyckWord([1,0,1,0]) # optional - sage.combinat - sage: dw2 = DyckWord([1,1,0,0]) # optional - sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1, dw2) # optional - sage.combinat + sage: dw1 = DyckWord([1,0,1,0]) # needs sage.combinat + sage: dw2 = DyckWord([1,1,0,0]) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1, dw2) # needs sage.combinat The Tamari interval of size 2 induced by relations [] - sage: TamariIntervalPosets.from_dyck_words(dw1,dw1) # optional - sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,dw1) # needs sage.combinat The Tamari interval of size 2 induced by relations [(1, 2)] - sage: TamariIntervalPosets.from_dyck_words(dw2,dw2) # optional - sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw2,dw2) # needs sage.combinat The Tamari interval of size 2 induced by relations [(2, 1)] - sage: dw1 = DyckWord([1,0,1,1,1,0,0,1,1,0,0,0]) # optional - sage.combinat - sage: dw2 = DyckWord([1,1,1,1,0,1,1,0,0,0,0,0]) # optional - sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1,dw2) # optional - sage.combinat + sage: dw1 = DyckWord([1,0,1,1,1,0,0,1,1,0,0,0]) # needs sage.combinat + sage: dw2 = DyckWord([1,1,1,1,0,1,1,0,0,0,0,0]) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,dw2) # needs sage.combinat The Tamari interval of size 6 induced by relations [(4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - sage: dw3 = DyckWord([1,1,1,0,1,1,1,0,0,0,0,0]) # optional - sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1,dw3) # optional - sage.combinat + sage: dw3 = DyckWord([1,1,1,0,1,1,1,0,0,0,0,0]) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,dw3) # needs sage.combinat Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice - sage: TamariIntervalPosets.from_dyck_words(dw1,DyckWord([1,0])) # optional - sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,DyckWord([1,0])) # needs sage.combinat Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice @@ -3403,7 +3403,7 @@ def from_minimal_schnyder_wood(graph) -> TIP: sage: TIP = TamariIntervalPosets sage: G = DiGraph([(0,-1,0),(0,-2,1),(0,-3,2)], format='list_of_edges') sage: G.set_embedding({-1:[0],-2:[0],-3:[0],0:[-1,-2,-3]}) - sage: TIP.from_minimal_schnyder_wood(G) # optional - sage.combinat + sage: TIP.from_minimal_schnyder_wood(G) # needs sage.combinat The Tamari interval of size 1 induced by relations [] An example from page 14 of [BeBo2009]_:: @@ -3421,7 +3421,7 @@ def from_minimal_schnyder_wood(graph) -> TIP: sage: for k in range(6): ....: embed[k] = data_emb[k] sage: G.set_embedding(embed) - sage: TIP.from_minimal_schnyder_wood(G) # optional - sage.combinat + sage: TIP.from_minimal_schnyder_wood(G) # needs sage.combinat The Tamari interval of size 6 induced by relations [(1, 4), (2, 4), (3, 4), (5, 6), (6, 4), (5, 4), (3, 1), (2, 1)] @@ -3440,7 +3440,7 @@ def from_minimal_schnyder_wood(graph) -> TIP: sage: for k in range(6): ....: embed[k] = data_emb[k] sage: G.set_embedding(embed) - sage: TIP.from_minimal_schnyder_wood(G) # optional - sage.combinat + sage: TIP.from_minimal_schnyder_wood(G) # needs sage.combinat The Tamari interval of size 6 induced by relations [(1, 3), (2, 3), (4, 5), (5, 3), (4, 3), (2, 1)] @@ -3458,7 +3458,7 @@ def from_minimal_schnyder_wood(graph) -> TIP: sage: for k in range(3): ....: embed[k] = data_emb[k] sage: G.set_embedding(embed) - sage: TIP.from_minimal_schnyder_wood(G) # optional - sage.combinat + sage: TIP.from_minimal_schnyder_wood(G) # needs sage.combinat The Tamari interval of size 3 induced by relations [(2, 3), (2, 1)] """ from sage.combinat.dyck_word import DyckWord @@ -3822,14 +3822,14 @@ def random_element(self) -> TIP: EXAMPLES:: - sage: T = TamariIntervalPosets(4).random_element() # optional - sage.combinat - sage: T.parent() # optional - sage.combinat + sage: T = TamariIntervalPosets(4).random_element() # needs sage.combinat + sage: T.parent() # needs sage.combinat Interval-posets - sage: u = T.lower_dyck_word(); u # random # optional - sage.combinat + sage: u = T.lower_dyck_word(); u # random # needs sage.combinat [1, 1, 0, 1, 0, 0, 1, 0] - sage: v = T.lower_dyck_word(); v # random # optional - sage.combinat + sage: v = T.lower_dyck_word(); v # random # needs sage.combinat [1, 1, 0, 1, 0, 0, 1, 0] - sage: len(u) # optional - sage.combinat + sage: len(u) # needs sage.combinat 8 """ from sage.graphs.schnyder import minimal_schnyder_wood diff --git a/src/sage/combinat/matrices/dancing_links.pyx b/src/sage/combinat/matrices/dancing_links.pyx index f0ecfeacd17..0a00801030d 100644 --- a/src/sage/combinat/matrices/dancing_links.pyx +++ b/src/sage/combinat/matrices/dancing_links.pyx @@ -920,11 +920,11 @@ cdef class dancing_linksWrapper: sage: from sage.combinat.matrices.dancing_links import dlx_solver sage: rows = [[0,1,2], [0,2], [1], [3]] sage: x = dlx_solver(rows) - sage: s = x.to_sat_solver() + sage: s = x.to_sat_solver() # needs sage.sat Using some optional SAT solvers:: - sage: x.to_sat_solver('cryptominisat') # optional - pycryptosat + sage: x.to_sat_solver('cryptominisat') # optional - pycryptosat # needs sage.sat CryptoMiniSat solver: 4 variables, 7 clauses. """ @@ -979,20 +979,20 @@ cdef class dancing_linksWrapper: sage: rows = [[0,1,2], [3,4,5], [0,1], [2,3,4,5], [0], [1,2,3,4,5]] sage: d = dlx_solver(rows) sage: solutions = [[0,1], [2,3], [4,5]] - sage: d.one_solution_using_sat_solver() in solutions + sage: d.one_solution_using_sat_solver() in solutions # needs sage.sat True Using optional solvers:: - sage: s = d.one_solution_using_sat_solver('glucose') # optional - glucose - sage: s in solutions # optional - glucose + sage: s = d.one_solution_using_sat_solver('glucose') # optional - glucose, needs sage.sat + sage: s in solutions # optional - glucose, needs sage.sat True When no solution is found:: sage: rows = [[0,1,2], [2,3,4,5], [0,1,2,3]] sage: d = dlx_solver(rows) - sage: d.one_solution_using_sat_solver() is None + sage: d.one_solution_using_sat_solver() is None # needs sage.sat True """ sat_solver = self.to_sat_solver(solver) @@ -1026,16 +1026,16 @@ cdef class dancing_linksWrapper: sage: from sage.combinat.matrices.dancing_links import dlx_solver sage: rows = [[0,1,2], [0,2], [1], [3]] sage: d = dlx_solver(rows) - sage: p,x = d.to_milp() - sage: p + sage: p,x = d.to_milp() # needs sage.numerical.mip + sage: p # needs sage.numerical.mip Boolean Program (no objective, 4 variables, ... constraints) - sage: x + sage: x # needs sage.numerical.mip MIPVariable with 4 binary components In the reduction, the boolean variable x_i is True if and only if the i-th row is in the solution:: - sage: p.show() + sage: p.show() # needs sage.numerical.mip Maximization: @@ -1052,7 +1052,7 @@ cdef class dancing_linksWrapper: Using some optional MILP solvers:: - sage: d.to_milp('gurobi') # optional - gurobi sage_numerical_backends_gurobi + sage: d.to_milp('gurobi') # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip (Boolean Program (no objective, 4 variables, 4 constraints), MIPVariable with 4 binary components) @@ -1106,20 +1106,20 @@ cdef class dancing_linksWrapper: sage: rows = [[0,1,2], [3,4,5], [0,1], [2,3,4,5], [0], [1,2,3,4,5]] sage: d = dlx_solver(rows) sage: solutions = [[0,1], [2,3], [4,5]] - sage: d.one_solution_using_milp_solver() in solutions + sage: d.one_solution_using_milp_solver() in solutions # needs sage.numerical.mip True Using optional solvers:: - sage: s = d.one_solution_using_milp_solver('gurobi') # optional - gurobi sage_numerical_backends_gurobi - sage: s in solutions # optional - gurobi sage_numerical_backends_gurobi + sage: s = d.one_solution_using_milp_solver('gurobi') # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip + sage: s in solutions # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip True When no solution is found:: sage: rows = [[0,1,2], [2,3,4,5], [0,1,2,3]] sage: d = dlx_solver(rows) - sage: d.one_solution_using_milp_solver() is None + sage: d.one_solution_using_milp_solver() is None # needs sage.numerical.mip True """ from sage.numerical.mip import MIPSolverException diff --git a/src/sage/combinat/matrices/dlxcpp.py b/src/sage/combinat/matrices/dlxcpp.py index fce16e7d2ad..3cdc3774d76 100644 --- a/src/sage/combinat/matrices/dlxcpp.py +++ b/src/sage/combinat/matrices/dlxcpp.py @@ -94,14 +94,14 @@ def AllExactCovers(M): EXAMPLES: No exact covers:: - sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # optional - sage.modules - sage: [cover for cover in AllExactCovers(M)] # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # needs sage.modules + sage: [cover for cover in AllExactCovers(M)] # needs sage.modules [] Two exact covers:: - sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # optional - sage.modules - sage: [cover for cover in AllExactCovers(M)] # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # needs sage.modules + sage: [cover for cover in AllExactCovers(M)] # needs sage.modules [[(1, 1, 0), (0, 0, 1)], [(1, 0, 1), (0, 1, 0)]] """ rows = [] @@ -122,11 +122,12 @@ def OneExactCover(M): EXAMPLES:: - sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers # optional - sage.modules - sage: print(OneExactCover(M)) # optional - sage.modules + sage: # needs sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) # no exact covers + sage: print(OneExactCover(M)) None - sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers # optional - sage.modules - sage: OneExactCover(M) # optional - sage.modules + sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) # two exact covers + sage: OneExactCover(M) [(1, 1, 0), (0, 0, 1)] """ diff --git a/src/sage/combinat/multiset_partition_into_sets_ordered.py b/src/sage/combinat/multiset_partition_into_sets_ordered.py index 7bcdfbb92a5..decfc60aa45 100755 --- a/src/sage/combinat/multiset_partition_into_sets_ordered.py +++ b/src/sage/combinat/multiset_partition_into_sets_ordered.py @@ -45,7 +45,7 @@ Crystal of ordered multiset partitions into sets on the alphabet `\{1,2,3\}` with 4 letters divided into 2 blocks:: - sage: crystals.Minimaj(3, 4, 2).list() # optional - sage.modules + sage: crystals.Minimaj(3, 4, 2).list() # needs sage.modules [((2, 3, 1), (1,)), ((2, 3), (1, 2)), ((2, 3), (1, 3)), ((2, 1), (1, 2)), ((3, 1), (1, 2)), ((3, 1, 2), (2,)), ((3, 1), (1, 3)), ((3, 1), (2, 3)), ((3, 2), (2, 3)), ((2, 1), (1, 3)), ((2,), (1, 2, 3)), ((3,), (1, 2, 3)), @@ -3197,14 +3197,14 @@ class MinimajCrystal(UniqueRepresentation, Parent): EXAMPLES:: - sage: list(crystals.Minimaj(2,3,2)) # optional - sage.modules + sage: list(crystals.Minimaj(2,3,2)) # needs sage.modules [((2, 1), (1,)), ((2,), (1, 2)), ((1,), (1, 2)), ((1, 2), (2,))] - sage: b = crystals.Minimaj(3, 5, 2).an_element(); b # optional - sage.modules + sage: b = crystals.Minimaj(3, 5, 2).an_element(); b # needs sage.modules ((2, 3, 1), (1, 2)) - sage: b.f(2) # optional - sage.modules + sage: b.f(2) # needs sage.modules ((2, 3, 1), (1, 3)) - sage: b.e(2) # optional - sage.modules + sage: b.e(2) # needs sage.modules """ def __init__(self, n, ell, k): @@ -3213,17 +3213,17 @@ def __init__(self, n, ell, k): TESTS:: - sage: B = crystals.Minimaj(2,3,2) # optional - sage.modules - sage: TestSuite(B).run() # optional - sage.modules + sage: B = crystals.Minimaj(2,3,2) # needs sage.modules + sage: TestSuite(B).run() # needs sage.modules - sage: B = crystals.Minimaj(3, 5, 2) # optional - sage.modules - sage: TestSuite(B).run() # optional - sage.modules + sage: B = crystals.Minimaj(3, 5, 2) # needs sage.modules + sage: TestSuite(B).run() # needs sage.modules - sage: list(crystals.Minimaj(2,6,3)) # optional - sage.modules + sage: list(crystals.Minimaj(2,6,3)) # needs sage.modules [((1, 2), (2, 1), (1, 2))] - sage: list(crystals.Minimaj(2,5,2)) # blocks too fat for alphabet # optional - sage.modules + sage: list(crystals.Minimaj(2,5,2)) # blocks too fat for alphabet # needs sage.modules [] - sage: list(crystals.Minimaj(4,2,3)) # more blocks than letters # optional - sage.modules + sage: list(crystals.Minimaj(4,2,3)) # more blocks than letters # needs sage.modules Traceback (most recent call last): ... ValueError: n (=4), ell (=2), and k (=3) must all be positive integers @@ -3256,7 +3256,7 @@ def _repr_(self): EXAMPLES:: - sage: B = crystals.Minimaj(3,4,2); B # optional - sage.modules + sage: B = crystals.Minimaj(3,4,2); B # needs sage.modules Minimaj Crystal of type A_2 of words of length 4 into 2 blocks """ return ("Minimaj Crystal of type A_%s of words of length %s into %s blocks" @@ -3268,14 +3268,14 @@ def _an_element_(self): EXAMPLES:: - sage: B = crystals.Minimaj(4,5,3) # optional - sage.modules - sage: B.an_element() # optional - sage.modules + sage: B = crystals.Minimaj(4,5,3) # needs sage.modules + sage: B.an_element() # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: B = crystals.Minimaj(2,2,1) # optional - sage.modules - sage: B.an_element() # optional - sage.modules + sage: B = crystals.Minimaj(2,2,1) # needs sage.modules + sage: B.an_element() # needs sage.modules ((1, 2),) - sage: B = crystals.Minimaj(1,2,1) # optional - sage.modules - sage: B.an_element() # optional - sage.modules + sage: B = crystals.Minimaj(1,2,1) # needs sage.modules + sage: B.an_element() # needs sage.modules Traceback (most recent call last): ... EmptySetError @@ -3291,14 +3291,14 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: B1 = crystals.Minimaj(4,5,3); b = B1.an_element(); b # optional - sage.modules + sage: B1 = crystals.Minimaj(4,5,3); b = B1.an_element(); b # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: B1._element_constructor_(list(b)) # optional - sage.modules + sage: B1._element_constructor_(list(b)) # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: B1._element_constructor_([[1,2,3], [2], [2]]) # optional - sage.modules + sage: B1._element_constructor_([[1,2,3], [2], [2]]) # needs sage.modules ((3, 1, 2), (2,), (2,)) - sage: B2 = crystals.Minimaj(5,5,3) # optional - sage.modules - sage: B2._element_constructor_(b) # optional - sage.modules + sage: B2 = crystals.Minimaj(5,5,3) # needs sage.modules + sage: B2._element_constructor_(b) # needs sage.modules ((2, 3, 1), (1,), (1,)) """ # Allow ``x`` to be either of: @@ -3322,17 +3322,17 @@ def __contains__(self, x): EXAMPLES:: - sage: B1 = crystals.Minimaj(2,5,3); b1 = B1.an_element(); b1 # optional - sage.modules + sage: B1 = crystals.Minimaj(2,5,3); b1 = B1.an_element(); b1 # needs sage.modules ((1, 2), (2, 1), (1,)) - sage: B2 = crystals.Minimaj(5,5,3); b2 = B2.an_element(); b2 # optional - sage.modules + sage: B2 = crystals.Minimaj(5,5,3); b2 = B2.an_element(); b2 # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: b2a = B2(((1,2), (1,), (1,2))); b2a # optional - sage.modules + sage: b2a = B2(((1,2), (1,), (1,2))); b2a # needs sage.modules ((2, 1), (1,), (1, 2)) - sage: b1 in B2 # optional - sage.modules + sage: b1 in B2 # needs sage.modules True - sage: b2 in B1 # optional - sage.modules + sage: b2 in B1 # needs sage.modules False - sage: b2a in B1 # optional - sage.modules + sage: b2a in B1 # needs sage.modules True """ if isinstance(x, MinimajCrystal.Element): @@ -3353,24 +3353,24 @@ def from_tableau(self, t): EXAMPLES:: - sage: B = crystals.Minimaj(3,6,3) # optional - sage.modules - sage: b = B.an_element(); b # optional - sage.modules + sage: B = crystals.Minimaj(3,6,3) # needs sage.modules + sage: b = B.an_element(); b # needs sage.modules ((3, 1, 2), (2, 1), (1,)) - sage: t = b.to_tableaux_words(); t # optional - sage.modules + sage: t = b.to_tableaux_words(); t # needs sage.modules [[1], [2, 1], [], [3, 2, 1]] - sage: B.from_tableau(t) # optional - sage.modules + sage: B.from_tableau(t) # needs sage.modules ((3, 1, 2), (2, 1), (1,)) - sage: B.from_tableau(t) == b # optional - sage.modules + sage: B.from_tableau(t) == b # needs sage.modules True TESTS:: - sage: B = crystals.Minimaj(3,6,3) # optional - sage.modules - sage: all(mu == B.from_tableau(mu.to_tableaux_words()) for mu in B) # optional - sage.modules + sage: B = crystals.Minimaj(3,6,3) # needs sage.modules + sage: all(mu == B.from_tableau(mu.to_tableaux_words()) for mu in B) # needs sage.modules True - sage: t = B.an_element().to_tableaux_words() # optional - sage.modules - sage: B1 = crystals.Minimaj(3,6,2) # optional - sage.modules - sage: B1.from_tableau(t) # optional - sage.modules + sage: t = B.an_element().to_tableaux_words() # needs sage.modules + sage: B1 = crystals.Minimaj(3,6,2) # needs sage.modules + sage: B1.from_tableau(t) # needs sage.modules Traceback (most recent call last): ... ValueError: ((3, 1, 2), (2, 1), (1,)) is not an element of @@ -3390,8 +3390,8 @@ def val(self, q='q'): Verifying Example 4.5 from [BCHOPSY2017]_:: - sage: B = crystals.Minimaj(3, 4, 2) # for `Val_{4,1}^{(3)}` # optional - sage.modules - sage: B.val() # optional - sage.modules + sage: B = crystals.Minimaj(3, 4, 2) # for `Val_{4,1}^{(3)}` # needs sage.modules + sage: B.val() # needs sage.modules (q^2+q+1)*s[2, 1, 1] + q*s[2, 2] """ H = [self._OMPs(list(b)) for b in self.highest_weight_vectors()] @@ -3425,7 +3425,7 @@ def _repr_(self): EXAMPLES:: - sage: crystals.Minimaj(4,5,3).an_element() # optional - sage.modules + sage: crystals.Minimaj(4,5,3).an_element() # needs sage.modules ((2, 3, 1), (1,), (1,)) """ return repr(self._minimaj_blocks_from_word_pair()) @@ -3436,11 +3436,11 @@ def __iter__(self): EXAMPLES:: - sage: b = crystals.Minimaj(4,5,3).an_element(); b # optional - sage.modules + sage: b = crystals.Minimaj(4,5,3).an_element(); b # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: b.value # optional - sage.modules + sage: b.value # needs sage.modules ([1, 3, 2, 1, 1], (0, 1, 2, 5)) - sage: list(b) # optional - sage.modules + sage: list(b) # needs sage.modules [(2, 3, 1), (1,), (1,)] """ return self._minimaj_blocks_from_word_pair().__iter__() @@ -3451,9 +3451,9 @@ def _latex_(self): EXAMPLES:: - sage: b = crystals.Minimaj(4,5,3).an_element(); b # optional - sage.modules + sage: b = crystals.Minimaj(4,5,3).an_element(); b # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: latex(b) # optional - sage.modules + sage: latex(b) # needs sage.modules \left(\left(2, 3, 1\right), \left(1\right), \left(1\right)\right) """ return latex(self._minimaj_blocks_from_word_pair()) @@ -3465,10 +3465,10 @@ def _minimaj_blocks_from_word_pair(self): EXAMPLES:: - sage: B = crystals.Minimaj(4,5,3) # optional - sage.modules - sage: b = B.an_element(); b.value # optional - sage.modules + sage: B = crystals.Minimaj(4,5,3) # needs sage.modules + sage: b = B.an_element(); b.value # needs sage.modules ([1, 3, 2, 1, 1], (0, 1, 2, 5)) - sage: b._minimaj_blocks_from_word_pair() # optional - sage.modules + sage: b._minimaj_blocks_from_word_pair() # needs sage.modules ((2, 3, 1), (1,), (1,)) """ return _to_minimaj_blocks(self.to_tableaux_words()) @@ -3480,15 +3480,15 @@ def to_tableaux_words(self): EXAMPLES:: - sage: B = crystals.Minimaj(4,5,3) # optional - sage.modules - sage: b = B.an_element(); b # optional - sage.modules + sage: B = crystals.Minimaj(4,5,3) # needs sage.modules + sage: b = B.an_element(); b # needs sage.modules ((2, 3, 1), (1,), (1,)) - sage: b.to_tableaux_words() # optional - sage.modules + sage: b.to_tableaux_words() # needs sage.modules [[1], [3], [2, 1, 1]] - sage: b = B([[1,3,4], [3], [3]]); b # optional - sage.modules + sage: b = B([[1,3,4], [3], [3]]); b # needs sage.modules ((4, 1, 3), (3,), (3,)) - sage: b.to_tableaux_words() # optional - sage.modules + sage: b.to_tableaux_words() # needs sage.modules [[3, 1], [], [4, 3, 3]] """ w, breaks = self.value @@ -3501,10 +3501,10 @@ def e(self, i): EXAMPLES:: - sage: B = crystals.Minimaj(4,3,2) # optional - sage.modules - sage: b = B([[2,3], [3]]); b # optional - sage.modules + sage: B = crystals.Minimaj(4,3,2) # needs sage.modules + sage: b = B([[2,3], [3]]); b # needs sage.modules ((2, 3), (3,)) - sage: [b.e(i) for i in range(1,4)] # optional - sage.modules + sage: [b.e(i) for i in range(1,4)] # needs sage.modules [((1, 3), (3,)), ((2,), (2, 3)), None] """ P = self.parent() @@ -3520,10 +3520,10 @@ def f(self,i): EXAMPLES:: - sage: B = crystals.Minimaj(4,3,2) # optional - sage.modules - sage: b = B([[2,3], [3]]); b # optional - sage.modules + sage: B = crystals.Minimaj(4,3,2) # needs sage.modules + sage: b = B([[2,3], [3]]); b # needs sage.modules ((2, 3), (3,)) - sage: [b.f(i) for i in range(1,4)] # optional - sage.modules + sage: [b.f(i) for i in range(1,4)] # needs sage.modules [None, None, ((2, 3), (4,))] """ P = self.parent() diff --git a/src/sage/combinat/necklace.py b/src/sage/combinat/necklace.py index 32d345c7e11..0a2ad690c34 100644 --- a/src/sage/combinat/necklace.py +++ b/src/sage/combinat/necklace.py @@ -212,7 +212,7 @@ def cardinality(self) -> Integer: sage: comps = [[],[2,2],[3,2,7],[4,2],[0,4,2],[2,0,4]]+Compositions(4).list() sage: ns = [Necklaces(comp) for comp in comps] - sage: all(n.cardinality() == len(n.list()) for n in ns) + sage: all(n.cardinality() == len(n.list()) for n in ns) # needs sage.libs.pari True """ evaluation = self._content diff --git a/src/sage/combinat/nu_dyck_word.py b/src/sage/combinat/nu_dyck_word.py index 213fb05efc0..ddc54a03612 100644 --- a/src/sage/combinat/nu_dyck_word.py +++ b/src/sage/combinat/nu_dyck_word.py @@ -873,7 +873,7 @@ def plot(self, **kwds): EXAMPLES:: sage: NDW = NuDyckWord('010','010') - sage: NDW.plot() # optional - sage.plot + sage: NDW.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.plot import list_plot diff --git a/src/sage/combinat/ordered_tree.py b/src/sage/combinat/ordered_tree.py index 0b2fa87e3c7..9d7ee8fb1e3 100644 --- a/src/sage/combinat/ordered_tree.py +++ b/src/sage/combinat/ordered_tree.py @@ -360,20 +360,20 @@ def to_parallelogram_polyomino(self, bijection=None): EXAMPLES:: sage: T = OrderedTree([[[], [[], [[]]]], [], [[[],[]]], [], []]) - sage: T.to_parallelogram_polyomino(bijection='Boussicault-Socci') # optional - sage.combinat + sage: T.to_parallelogram_polyomino(bijection='Boussicault-Socci') # needs sage.combinat sage.modules [[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0]] sage: T = OrderedTree( [] ) - sage: T.to_parallelogram_polyomino() # optional - sage.combinat + sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules [[1], [1]] sage: T = OrderedTree( [[]] ) - sage: T.to_parallelogram_polyomino() # optional - sage.combinat + sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules [[0, 1], [1, 0]] sage: T = OrderedTree( [[],[]] ) - sage: T.to_parallelogram_polyomino() # optional - sage.combinat + sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules [[0, 1, 1], [1, 1, 0]] sage: T = OrderedTree( [[[]]] ) - sage: T.to_parallelogram_polyomino() # optional - sage.combinat + sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules [[0, 0, 1], [1, 0, 0]] """ if (bijection is None) or (bijection == 'Boussicault-Socci'): @@ -392,19 +392,19 @@ def _to_parallelogram_polyomino_Boussicault_Socci(self): sage: T = OrderedTree( ....: [[[], [[], [[]]]], [], [[[],[]]], [], []] ....: ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # optional - sage.combinat + sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules [[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0]] sage: T = OrderedTree( [] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # optional - sage.combinat + sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules [[1], [1]] sage: T = OrderedTree( [[]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # optional - sage.combinat + sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules [[0, 1], [1, 0]] sage: T = OrderedTree( [[],[]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # optional - sage.combinat + sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules [[0, 1, 1], [1, 1, 0]] sage: T = OrderedTree( [[[]]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # optional - sage.combinat + sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules [[0, 0, 1], [1, 0, 0]] """ from sage.combinat.parallelogram_polyomino import ParallelogramPolyomino @@ -501,13 +501,13 @@ def to_dyck_word(self): EXAMPLES:: sage: T = OrderedTree([[],[]]) - sage: T.to_dyck_word() # optional - sage.combinat + sage: T.to_dyck_word() # needs sage.combinat [1, 0, 1, 0] sage: T = OrderedTree([[],[[]]]) - sage: T.to_dyck_word() # optional - sage.combinat + sage: T.to_dyck_word() # needs sage.combinat [1, 0, 1, 1, 0, 0] sage: T = OrderedTree([[], [[], []], [[], [[]]]]) - sage: T.to_dyck_word() # optional - sage.combinat + sage: T.to_dyck_word() # needs sage.combinat [1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0] """ word = [] @@ -597,14 +597,14 @@ def to_poset(self, root_to_leaf=False): sage: t.to_poset() Finite poset containing 1 elements sage: p = OrderedTree([[[]],[],[]]).to_poset() - sage: p.height(), p.width() + sage: p.height(), p.width() # needs networkx (3, 3) If the tree is labelled, we use its labelling to label the poset. Otherwise, we use the poset canonical labelling:: sage: t = OrderedTree([[[]],[],[]]).canonical_labelling().to_poset() - sage: t.height(), t.width() + sage: t.height(), t.width() # needs networkx (3, 3) """ if self in LabelledOrderedTrees(): @@ -675,7 +675,7 @@ def plot(self): o o o | o - sage: p.plot() # optional - sage.plot + sage: p.plot() # needs sage.plot Graphics object consisting of 10 graphics primitives .. PLOT:: @@ -692,7 +692,7 @@ def plot(self): 2 3 5 | 4 - sage: g.plot() # optional - sage.plot + sage: g.plot() # needs sage.plot Graphics object consisting of 10 graphics primitives .. PLOT:: @@ -1088,18 +1088,18 @@ def random_element(self): EXAMPLES:: - sage: OrderedTrees(5).random_element() # random # optional - sage.combinat + sage: OrderedTrees(5).random_element() # random # needs sage.combinat [[[], []], []] - sage: OrderedTrees(0).random_element() # optional - sage.combinat + sage: OrderedTrees(0).random_element() # needs sage.combinat Traceback (most recent call last): ... EmptySetError: there are no ordered trees of size 0 - sage: OrderedTrees(1).random_element() # optional - sage.combinat + sage: OrderedTrees(1).random_element() # needs sage.combinat [] TESTS:: - sage: all(OrderedTrees(10).random_element() in OrderedTrees(10) # optional - sage.combinat + sage: all(OrderedTrees(10).random_element() in OrderedTrees(10) # needs sage.combinat ....: for i in range(20)) True """ diff --git a/src/sage/combinat/parallelogram_polyomino.py b/src/sage/combinat/parallelogram_polyomino.py index bdba16ab252..190eeedef72 100644 --- a/src/sage/combinat/parallelogram_polyomino.py +++ b/src/sage/combinat/parallelogram_polyomino.py @@ -3703,14 +3703,14 @@ def _plot_diagram(self): sage: pp = ParallelogramPolyomino( ....: [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0]] ....: ) - sage: pp._plot_diagram() # optional - sage.plot + sage: pp._plot_diagram() # needs sage.plot Graphics object consisting of 7 graphics primitives sage: pp = ParallelogramPolyomino([ ....: [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], ....: [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0] ....: ]) - sage: pp._plot_diagram() # optional - sage.plot + sage: pp._plot_diagram() # needs sage.plot Graphics object consisting of 25 graphics primitives """ G = Graphics() @@ -3755,14 +3755,14 @@ def _plot_bounce(self, directions=None): sage: pp = ParallelogramPolyomino( ....: [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0]] ....: ) - sage: pp._plot_bounce(directions=[1]) # optional - sage.plot + sage: pp._plot_bounce(directions=[1]) # needs sage.plot Graphics object consisting of 1 graphics primitive sage: pp = ParallelogramPolyomino([ ....: [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], ....: [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0] ....: ]) - sage: pp._plot_bounce(directions=[0,1]) # optional - sage.plot + sage: pp._plot_bounce(directions=[0,1]) # needs sage.plot Graphics object consisting of 9 graphics primitives """ @@ -3798,14 +3798,14 @@ def _plot_bounce_values(self, bounce=0): sage: pp = ParallelogramPolyomino( ....: [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0]] ....: ) - sage: pp._plot_bounce_values() # optional - sage.plot + sage: pp._plot_bounce_values() # needs sage.plot Graphics object consisting of 4 graphics primitives sage: pp = ParallelogramPolyomino([ ....: [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], ....: [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0] ....: ]) - sage: pp._plot_bounce_values(bounce=1) # optional - sage.plot + sage: pp._plot_bounce_values(bounce=1) # needs sage.plot Graphics object consisting of 10 graphics primitives """ G = Graphics() @@ -3847,14 +3847,14 @@ def _plot_tree(self): sage: pp = ParallelogramPolyomino( ....: [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0]] ....: ) - sage: pp._plot_tree() # optional - sage.plot + sage: pp._plot_tree() # needs sage.plot Graphics object consisting of 2 graphics primitives sage: pp = ParallelogramPolyomino([ ....: [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], ....: [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0] ....: ]) - sage: pp._plot_tree() # optional - sage.plot + sage: pp._plot_tree() # needs sage.plot Graphics object consisting of 2 graphics primitives """ G = Graphics() @@ -3869,7 +3869,7 @@ def plot(self): EXAMPLES:: sage: pp = ParallelogramPolyomino([[0,1],[1,0]]) - sage: pp.plot() # optional - sage.plot + sage: pp.plot() # needs sage.plot Graphics object consisting of 4 graphics primitives sage: pp.set_options( ....: drawing_components=dict( @@ -3879,7 +3879,7 @@ def plot(self): ....: bounce_values=0, ....: ) ....: ) - sage: pp.plot() # optional - sage.plot + sage: pp.plot() # needs sage.plot Graphics object consisting of 7 graphics primitives """ G = Graphics() diff --git a/src/sage/combinat/parking_functions.py b/src/sage/combinat/parking_functions.py index d356cedb2b7..b47bdb5a01b 100644 --- a/src/sage/combinat/parking_functions.py +++ b/src/sage/combinat/parking_functions.py @@ -1024,21 +1024,23 @@ def characteristic_quasisymmetric_function(self, q=None, sage: R = QQ['q','t'].fraction_field() sage: (q,t) = R.gens() - sage: cqf = sum(t**PF.area()*PF.characteristic_quasisymmetric_function() for PF in ParkingFunctions(3)); cqf - (q^3+q^2*t+q*t^2+t^3+q*t)*F[1, 1, 1] + (q^2+q*t+t^2+q+t)*F[1, 2] + (q^2+q*t+t^2+q+t)*F[2, 1] + F[3] - sage: s = SymmetricFunctions(R).s() - sage: s(cqf.to_symmetric_function()) + sage: cqf = sum(t**PF.area() * PF.characteristic_quasisymmetric_function() # needs sage.modules + ....: for PF in ParkingFunctions(3)); cqf + (q^3+q^2*t+q*t^2+t^3+q*t)*F[1, 1, 1] + (q^2+q*t+t^2+q+t)*F[1, 2] + + (q^2+q*t+t^2+q+t)*F[2, 1] + F[3] + sage: s = SymmetricFunctions(R).s() # needs sage.modules + sage: s(cqf.to_symmetric_function()) # needs sage.modules (q^3+q^2*t+q*t^2+t^3+q*t)*s[1, 1, 1] + (q^2+q*t+t^2+q+t)*s[2, 1] + s[3] - sage: s(cqf.to_symmetric_function()).nabla(power = -1) + sage: s(cqf.to_symmetric_function()).nabla(power=-1) # needs sage.modules s[1, 1, 1] :: sage: p = ParkingFunction([3, 1, 2]) - sage: p.characteristic_quasisymmetric_function() + sage: p.characteristic_quasisymmetric_function() # needs sage.modules q*F[2, 1] sage: pf = ParkingFunction([1,2,7,2,1,2,3,2,1]) - sage: pf.characteristic_quasisymmetric_function() + sage: pf.characteristic_quasisymmetric_function() # needs sage.modules q^2*F[1, 1, 1, 2, 1, 3] """ from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 488315254ef..1473d00959e 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -67,7 +67,7 @@ There are `5` partitions of the integer `4`:: - sage: Partitions(4).cardinality() + sage: Partitions(4).cardinality() # needs sage.libs.flint 5 sage: Partitions(4).list() [[4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1]] @@ -1088,14 +1088,14 @@ def power(self, k): Now let us compare this to the power map on `S_8`:: - sage: G = SymmetricGroup(8) # optional - sage.groups - sage: g = G([(1,2,3,4,5),(6,7,8)]); g # optional - sage.groups + sage: G = SymmetricGroup(8) # needs sage.groups + sage: g = G([(1,2,3,4,5),(6,7,8)]); g # needs sage.groups (1,2,3,4,5)(6,7,8) - sage: g^2 # optional - sage.groups + sage: g^2 # needs sage.groups (1,3,5,2,4)(6,8,7) - sage: g^3 # optional - sage.groups + sage: g^3 # needs sage.groups (1,4,2,5,3) - sage: g^4 # optional - sage.groups + sage: g^4 # needs sage.groups (1,5,4,3,2)(6,7,8) :: @@ -1214,10 +1214,10 @@ def sign(self): :: - sage: F = GF(11) # optional - sage.rings.finite_rings - sage: a = F.multiplicative_generator();a # optional - sage.rings.finite_rings + sage: F = GF(11) # needs sage.rings.finite_rings + sage: a = F.multiplicative_generator();a # needs sage.rings.finite_rings 2 - sage: plist = [int(a*F(x)) for x in range(1,11)]; plist # optional - sage.rings.finite_rings + sage: plist = [int(a*F(x)) for x in range(1,11)]; plist # needs sage.rings.finite_rings [2, 4, 6, 8, 10, 1, 3, 5, 7, 9] This corresponds to the permutation (1, 2, 4, 8, 5, 10, 9, 7, 3, 6) @@ -1226,8 +1226,8 @@ def sign(self): :: - sage: p = PermutationGroupElement('(1, 2, 4, 8, 5, 10, 9, 7, 3, 6)') # optional - sage.groups - sage: p.sign() # optional - sage.groups + sage: p = PermutationGroupElement('(1, 2, 4, 8, 5, 10, 9, 7, 3, 6)') # needs sage.groups + sage: p.sign() # needs sage.groups -1 sage: Partition([10]).sign() -1 @@ -1236,12 +1236,12 @@ def sign(self): Now replace `2` by `3`:: - sage: plist = [int(F(3*x)) for x in range(1,11)]; plist # optional - sage.rings.finite_rings + sage: plist = [int(F(3*x)) for x in range(1,11)]; plist # needs sage.rings.finite_rings [3, 6, 9, 1, 4, 7, 10, 2, 5, 8] sage: list(range(1, 11)) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - sage: p = PermutationGroupElement('(3,4,8,7,9)') # optional - sage.groups - sage: p.sign() # optional - sage.groups + sage: p = PermutationGroupElement('(3,4,8,7,9)') # needs sage.groups + sage: p.sign() # needs sage.groups 1 sage: kronecker_symbol(3,11) 1 @@ -1884,55 +1884,55 @@ def cell_poset(self, orientation="SE"): EXAMPLES:: sage: p = Partition([3,3,1]) - sage: Q = p.cell_poset(); Q # optional - sage.graphs + sage: Q = p.cell_poset(); Q # needs sage.graphs Finite poset containing 7 elements - sage: sorted(Q) # optional - sage.graphs + sage: sorted(Q) # needs sage.graphs [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: sorted(Q.maximal_elements()) # optional - sage.graphs + sage: sorted(Q.maximal_elements()) # needs sage.graphs [(1, 2), (2, 0)] - sage: Q.minimal_elements() # optional - sage.graphs + sage: Q.minimal_elements() # needs sage.graphs [(0, 0)] - sage: sorted(Q.upper_covers((1, 0))) # optional - sage.graphs + sage: sorted(Q.upper_covers((1, 0))) # needs sage.graphs [(1, 1), (2, 0)] - sage: Q.upper_covers((1, 1)) # optional - sage.graphs + sage: Q.upper_covers((1, 1)) # needs sage.graphs [(1, 2)] - sage: P = p.cell_poset(orientation="NW"); P # optional - sage.graphs + sage: P = p.cell_poset(orientation="NW"); P # needs sage.graphs Finite poset containing 7 elements - sage: sorted(P) # optional - sage.graphs + sage: sorted(P) # needs sage.graphs [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: sorted(P.minimal_elements()) # optional - sage.graphs + sage: sorted(P.minimal_elements()) # needs sage.graphs [(1, 2), (2, 0)] - sage: P.maximal_elements() # optional - sage.graphs + sage: P.maximal_elements() # needs sage.graphs [(0, 0)] - sage: P.upper_covers((2, 0)) # optional - sage.graphs + sage: P.upper_covers((2, 0)) # needs sage.graphs [(1, 0)] - sage: sorted(P.upper_covers((1, 2))) # optional - sage.graphs + sage: sorted(P.upper_covers((1, 2))) # needs sage.graphs [(0, 2), (1, 1)] - sage: sorted(P.upper_covers((1, 1))) # optional - sage.graphs + sage: sorted(P.upper_covers((1, 1))) # needs sage.graphs [(0, 1), (1, 0)] - sage: sorted([len(P.upper_covers(v)) for v in P]) # optional - sage.graphs + sage: sorted([len(P.upper_covers(v)) for v in P]) # needs sage.graphs [0, 1, 1, 1, 1, 2, 2] - sage: R = p.cell_poset(orientation="NE"); R # optional - sage.graphs + sage: R = p.cell_poset(orientation="NE"); R # needs sage.graphs Finite poset containing 7 elements - sage: sorted(R) # optional - sage.graphs + sage: sorted(R) # needs sage.graphs [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: R.maximal_elements() # optional - sage.graphs + sage: R.maximal_elements() # needs sage.graphs [(0, 2)] - sage: R.minimal_elements() # optional - sage.graphs + sage: R.minimal_elements() # needs sage.graphs [(2, 0)] - sage: sorted([len(R.upper_covers(v)) for v in R]) # optional - sage.graphs + sage: sorted([len(R.upper_covers(v)) for v in R]) # needs sage.graphs [0, 1, 1, 1, 1, 2, 2] - sage: R.is_isomorphic(P) # optional - sage.graphs + sage: R.is_isomorphic(P) # needs sage.graphs False - sage: R.is_isomorphic(P.dual()) # optional - sage.graphs + sage: R.is_isomorphic(P.dual()) # needs sage.graphs False Linear extensions of ``p.cell_poset()`` are in 1-to-1 correspondence with standard Young tableaux of shape `p`:: - sage: all( len(p.cell_poset().linear_extensions()) # optional - sage.graphs + sage: all( len(p.cell_poset().linear_extensions()) # needs sage.graphs ....: == len(p.standard_tableaux()) ....: for n in range(8) for p in Partitions(n) ) True @@ -1940,7 +1940,7 @@ def cell_poset(self, orientation="SE"): This is not the case for northeast orientation:: sage: q = Partition([3, 1]) - sage: q.cell_poset(orientation="NE").is_chain() # optional - sage.graphs + sage: q.cell_poset(orientation="NE").is_chain() # needs sage.graphs True TESTS: @@ -1957,7 +1957,7 @@ def cell_poset(self, orientation="SE"): ....: and c[1] >= d[1]): ....: return False ....: return True - sage: all( check_NW(n) for n in range(8) ) # optional - sage.graphs + sage: all( check_NW(n) for n in range(8) ) # needs sage.graphs True sage: def check_NE(n): @@ -1969,7 +1969,7 @@ def cell_poset(self, orientation="SE"): ....: and c[1] <= d[1]): ....: return False ....: return True - sage: all( check_NE(n) for n in range(8) ) # optional - sage.graphs + sage: all( check_NE(n) for n in range(8) ) # needs sage.graphs True sage: def test_duality(n, ori1, ori2): @@ -1981,11 +1981,11 @@ def cell_poset(self, orientation="SE"): ....: if P.lt(c, d) != Q.lt(d, c): ....: return False ....: return True - sage: all( test_duality(n, "NW", "SE") for n in range(8) ) # optional - sage.graphs + sage: all( test_duality(n, "NW", "SE") for n in range(8) ) # needs sage.graphs True - sage: all( test_duality(n, "NE", "SW") for n in range(8) ) # optional - sage.graphs + sage: all( test_duality(n, "NE", "SW") for n in range(8) ) # needs sage.graphs True - sage: all( test_duality(n, "NE", "SE") for n in range(4) ) # optional - sage.graphs + sage: all( test_duality(n, "NE", "SE") for n in range(4) ) # needs sage.graphs False """ from sage.combinat.posets.posets import Poset @@ -2852,7 +2852,7 @@ def young_subgroup(self): EXAMPLES:: - sage: Partition([4,2]).young_subgroup() # optional - sage.groups + sage: Partition([4,2]).young_subgroup() # needs sage.groups Permutation Group with generators [(), (5,6), (3,4), (2,3), (1,2)] """ gens = [] @@ -3278,9 +3278,9 @@ def hook_product(self, a): EXAMPLES:: - sage: Partition([3,2,1]).hook_product(x) # optional - sage.symbolic + sage: Partition([3,2,1]).hook_product(x) # needs sage.symbolic (2*x + 3)*(x + 2)^2 - sage: Partition([2,2]).hook_product(x) # optional - sage.symbolic + sage: Partition([2,2]).hook_product(x) # needs sage.symbolic 2*(x + 2)*(x + 1) """ @@ -3421,7 +3421,7 @@ def upper_hook(self, i, j, alpha): 3 sage: p.hook_length(0,0) 3 - sage: [ p.upper_hook(i,j,x) for i,j in p.cells() ] # optional - sage.symbolic + sage: [ p.upper_hook(i,j,x) for i,j in p.cells() ] # needs sage.symbolic [2*x + 1, x, x] """ p = self @@ -3443,7 +3443,7 @@ def upper_hook_lengths(self, alpha): EXAMPLES:: - sage: Partition([3,2,1]).upper_hook_lengths(x) # optional - sage.symbolic + sage: Partition([3,2,1]).upper_hook_lengths(x) # needs sage.symbolic [[3*x + 2, 2*x + 1, x], [2*x + 1, x], [x]] sage: Partition([3,2,1]).upper_hook_lengths(1) [[5, 3, 1], [3, 1], [1]] @@ -3473,7 +3473,7 @@ def lower_hook(self, i, j, alpha): 3 sage: p.hook_length(0,0) 3 - sage: [ p.lower_hook(i,j,x) for i,j in p.cells() ] # optional - sage.symbolic + sage: [ p.lower_hook(i,j,x) for i,j in p.cells() ] # needs sage.symbolic [x + 2, 1, 1] """ p = self @@ -3495,7 +3495,7 @@ def lower_hook_lengths(self, alpha): EXAMPLES:: - sage: Partition([3,2,1]).lower_hook_lengths(x) # optional - sage.symbolic + sage: Partition([3,2,1]).lower_hook_lengths(x) # needs sage.symbolic [[2*x + 3, x + 2, 1], [x + 2, 1], [1]] sage: Partition([3,2,1]).lower_hook_lengths(1) [[5, 3, 1], [3, 1], [1]] @@ -4623,12 +4623,12 @@ def from_kbounded_to_grassmannian(self, k): EXAMPLES:: sage: p = Partition([2,1,1]) - sage: p.from_kbounded_to_grassmannian(2) # optional - sage.modules + sage: p.from_kbounded_to_grassmannian(2) # needs sage.modules [-1 1 1] [-2 2 1] [-2 1 2] sage: p = Partition([]) - sage: p.from_kbounded_to_grassmannian(2) # optional - sage.modules + sage: p.from_kbounded_to_grassmannian(2) # needs sage.modules [1 0 0] [0 1 0] [0 0 1] @@ -5069,15 +5069,15 @@ def jacobi_trudi(self): EXAMPLES:: sage: part = Partition([3,2,1]) - sage: jt = part.jacobi_trudi(); jt # optional - sage.modules + sage: jt = part.jacobi_trudi(); jt # needs sage.modules [h[3] h[1] 0] [h[4] h[2] h[]] [h[5] h[3] h[1]] - sage: s = SymmetricFunctions(QQ).schur() # optional - sage.modules - sage: h = SymmetricFunctions(QQ).homogeneous() # optional - sage.modules - sage: h( s(part) ) # optional - sage.modules + sage: s = SymmetricFunctions(QQ).schur() # needs sage.modules + sage: h = SymmetricFunctions(QQ).homogeneous() # needs sage.modules + sage: h( s(part) ) # needs sage.modules h[3, 2, 1] - h[3, 3] - h[4, 1, 1] + h[5, 1] - sage: jt.det() # optional - sage.modules + sage: jt.det() # needs sage.modules h[3, 2, 1] - h[3, 3] - h[4, 1, 1] + h[5, 1] """ return SkewPartition([ self, [] ]).jacobi_trudi() @@ -5108,11 +5108,11 @@ def character_polynomial(self): EXAMPLES:: - sage: Partition([1]).character_polynomial() # optional - sage.modules + sage: Partition([1]).character_polynomial() # needs sage.modules x - 1 - sage: Partition([1,1]).character_polynomial() # optional - sage.modules + sage: Partition([1,1]).character_polynomial() # needs sage.modules 1/2*x0^2 - 3/2*x0 - x1 + 1 - sage: Partition([2,1]).character_polynomial() # optional - sage.modules + sage: Partition([2,1]).character_polynomial() # needs sage.modules 1/3*x0^3 - 2*x0^2 + 8/3*x0 - x2 """ # Create the polynomial ring we will use @@ -5310,23 +5310,23 @@ def outline(self, variable=None): EXAMPLES:: - sage: [Partition([5,4]).outline()(x=i) for i in range(-10,11)] # optional - sage.symbolic + sage: [Partition([5,4]).outline()(x=i) for i in range(-10,11)] # needs sage.symbolic [10, 9, 8, 7, 6, 5, 6, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10] - sage: Partition([]).outline() # optional - sage.symbolic + sage: Partition([]).outline() # needs sage.symbolic abs(x) - sage: Partition([1]).outline() # optional - sage.symbolic + sage: Partition([1]).outline() # needs sage.symbolic abs(x + 1) + abs(x - 1) - abs(x) - sage: y = SR.var("y") # optional - sage.symbolic - sage: Partition([6,5,1]).outline(variable=y) # optional - sage.symbolic + sage: y = SR.var("y") # needs sage.symbolic + sage: Partition([6,5,1]).outline(variable=y) # needs sage.symbolic abs(y + 6) - abs(y + 5) + abs(y + 4) - abs(y + 3) + abs(y - 1) - abs(y - 2) + abs(y - 3) TESTS:: - sage: integrate(Partition([1]).outline()-abs(x),(x,-10,10)) # optional - sage.symbolic + sage: integrate(Partition([1]).outline()-abs(x),(x,-10,10)) # needs sage.symbolic 2 """ if variable is None: @@ -5390,16 +5390,16 @@ def dual_equivalence_graph(self, directed=False, coloring=None): EXAMPLES:: sage: P = Partition([3,1,1]) - sage: G = P.dual_equivalence_graph() # optional - sage.graphs - sage: G.edges(sort=True) # optional - sage.graphs + sage: G = P.dual_equivalence_graph() # needs sage.graphs + sage: G.edges(sort=True) # needs sage.graphs [([[1, 2, 3], [4], [5]], [[1, 2, 4], [3], [5]], 3), ([[1, 2, 4], [3], [5]], [[1, 2, 5], [3], [4]], 4), ([[1, 2, 4], [3], [5]], [[1, 3, 4], [2], [5]], 2), ([[1, 2, 5], [3], [4]], [[1, 3, 5], [2], [4]], 2), ([[1, 3, 4], [2], [5]], [[1, 3, 5], [2], [4]], 4), ([[1, 3, 5], [2], [4]], [[1, 4, 5], [2], [3]], 3)] - sage: G = P.dual_equivalence_graph(directed=True) # optional - sage.graphs - sage: G.edges(sort=True) # optional - sage.graphs + sage: G = P.dual_equivalence_graph(directed=True) # needs sage.graphs + sage: G.edges(sort=True) # needs sage.graphs [([[1, 2, 4], [3], [5]], [[1, 2, 3], [4], [5]], 3), ([[1, 2, 5], [3], [4]], [[1, 2, 4], [3], [5]], 4), ([[1, 3, 4], [2], [5]], [[1, 2, 4], [3], [5]], 2), @@ -5409,20 +5409,20 @@ def dual_equivalence_graph(self, directed=False, coloring=None): TESTS:: - sage: G = Partition([1]).dual_equivalence_graph() # optional - sage.graphs - sage: G.vertices(sort=False) # optional - sage.graphs + sage: G = Partition([1]).dual_equivalence_graph() # needs sage.graphs + sage: G.vertices(sort=False) # needs sage.graphs [[[1]]] - sage: G = Partition([]).dual_equivalence_graph() # optional - sage.graphs - sage: G.vertices(sort=False) # optional - sage.graphs + sage: G = Partition([]).dual_equivalence_graph() # needs sage.graphs + sage: G.vertices(sort=False) # needs sage.graphs [[]] sage: P = Partition([3,1,1]) - sage: G = P.dual_equivalence_graph(coloring=lambda x: 'red') # optional - sage.graphs - sage: G2 = P.dual_equivalence_graph(coloring={2: 'black', 3: 'blue', # optional - sage.graphs + sage: G = P.dual_equivalence_graph(coloring=lambda x: 'red') # needs sage.graphs + sage: G2 = P.dual_equivalence_graph(coloring={2: 'black', 3: 'blue', # needs sage.graphs ....: 4: 'cyan', 5: 'grey'}) - sage: G is G2 # optional - sage.graphs + sage: G is G2 # needs sage.graphs False - sage: G == G2 # optional - sage.graphs + sage: G == G2 # needs sage.graphs True """ # We do some custom caching to not recreate the graph, but to make @@ -5491,10 +5491,10 @@ def specht_module(self, base_ring=None): EXAMPLES:: - sage: SM = Partition([2,2,1]).specht_module(QQ); SM # optional - sage.modules + sage: SM = Partition([2,2,1]).specht_module(QQ); SM # needs sage.modules Specht module of [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0)] over Rational Field - sage: s = SymmetricFunctions(QQ).s() # optional - sage.modules - sage: s(SM.frobenius_image()) # optional - sage.modules + sage: s = SymmetricFunctions(QQ).s() # needs sage.modules + sage: s(SM.frobenius_image()) # needs sage.modules s[2, 2, 1] """ from sage.combinat.specht_module import SpechtModule @@ -5520,7 +5520,7 @@ def specht_module_dimension(self, base_ring=None): sage: Partition([2,2,1]).specht_module_dimension() 5 - sage: Partition([2,2,1]).specht_module_dimension(GF(2)) # optional - sage.rings.finite_rings + sage: Partition([2,2,1]).specht_module_dimension(GF(2)) # needs sage.rings.finite_rings 5 """ from sage.categories.fields import Fields @@ -5643,7 +5643,7 @@ class Partitions(UniqueRepresentation, Parent): sage: def test(n): ....: return (Partitions(n, max_slope=-1).cardinality() ....: == Partitions(n, parts_in=[1,3..n]).cardinality()) - sage: all(test(n) for n in [10..20]) # optional - sage.libs.gap + sage: all(test(n) for n in [10..20]) # needs sage.libs.gap True The number of partitions of `n` into distinct parts that differ by @@ -5653,7 +5653,7 @@ class Partitions(UniqueRepresentation, Parent): sage: def test(n): ....: return (Partitions(n, max_slope=-2).cardinality() ....: == Partitions(n, parts_in=([1,6..n] + [4,9..n])).cardinality()) - sage: all(test(n) for n in [10..20]) # optional - sage.libs.gap + sage: all(test(n) for n in [10..20]) # needs sage.libs.gap True Here are some more examples illustrating ``min_part``, ``max_part``, @@ -5746,9 +5746,9 @@ class Partitions(UniqueRepresentation, Parent): TESTS:: - sage: TestSuite(Partitions(0)).run() - sage: TestSuite(Partitions(5)).run() - sage: TestSuite(Partitions(5, min_part=2)).run() + sage: TestSuite(Partitions(0)).run() # needs sage.libs.flint + sage: TestSuite(Partitions(5)).run() # needs sage.libs.flint + sage: TestSuite(Partitions(5, min_part=2)).run() # needs sage.libs.flint sage: repr( Partitions(5, min_part=2) ) 'Partitions of the integer 5 satisfying constraints min_part=2' @@ -6517,8 +6517,8 @@ class Partitions_n(Partitions): TESTS:: - sage: TestSuite( sage.combinat.partition.Partitions_n(0) ).run() - sage: TestSuite( sage.combinat.partition.Partitions_n(0) ).run() + sage: TestSuite( sage.combinat.partition.Partitions_n(0) ).run() # needs sage.libs.flint + sage: TestSuite( sage.combinat.partition.Partitions_n(0) ).run() # needs sage.libs.flint """ def __init__(self, n): @@ -6606,28 +6606,28 @@ def cardinality(self, algorithm='flint'): [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] sage: len(v) 7 - sage: Partitions(5).cardinality(algorithm='gap') + sage: Partitions(5).cardinality(algorithm='gap') # needs sage.libs.gap 7 - sage: Partitions(5).cardinality(algorithm='pari') + sage: Partitions(5).cardinality(algorithm='pari') # needs sage.libs.pari 7 - sage: number_of_partitions(5, algorithm='flint') + sage: number_of_partitions(5, algorithm='flint') # needs sage.libs.flint 7 :: - sage: Partitions(10).cardinality() + sage: Partitions(10).cardinality() # needs sage.libs.flint 42 - sage: Partitions(3).cardinality() + sage: Partitions(3).cardinality() # needs sage.libs.flint 3 - sage: Partitions(10).cardinality() + sage: Partitions(10).cardinality() # needs sage.libs.flint 42 - sage: Partitions(3).cardinality(algorithm='pari') + sage: Partitions(3).cardinality(algorithm='pari') # needs sage.libs.pari 3 - sage: Partitions(10).cardinality(algorithm='pari') + sage: Partitions(10).cardinality(algorithm='pari') # needs sage.libs.pari 42 - sage: Partitions(40).cardinality() + sage: Partitions(40).cardinality() # needs sage.libs.flint 37338 - sage: Partitions(100).cardinality() + sage: Partitions(100).cardinality() # needs sage.libs.flint 190569292 A generating function for `p_n` is given by the reciprocal of @@ -6643,12 +6643,13 @@ def cardinality(self, algorithm='flint'): sage: q = PowerSeriesRing(QQ, 'q', default_prec=9).gen() sage: prod([(1-q^k)^(-1) for k in range(1,9)]) # partial product of 1 + q + 2*q^2 + 3*q^3 + 5*q^4 + 7*q^5 + 11*q^6 + 15*q^7 + 22*q^8 + O(q^9) - sage: [Partitions(k).cardinality() for k in range(2,10)] + sage: [Partitions(k).cardinality() for k in range(2,10)] # needs sage.libs.flint [2, 3, 5, 7, 11, 15, 22, 30] Another consistency test for ``n`` up to 500:: - sage: len([n for n in [1..500] if Partitions(n).cardinality() != Partitions(n).cardinality(algorithm='pari')]) + sage: len([n for n in [1..500] # needs sage.libs.flint sage.libs.pari + ....: if Partitions(n).cardinality() != Partitions(n).cardinality(algorithm='pari')]) 0 For negative inputs, the result is zero (the algorithm is ignored):: @@ -6691,9 +6692,9 @@ def random_element(self, measure='uniform'): EXAMPLES:: - sage: Partitions(5).random_element() # random + sage: Partitions(5).random_element() # random # needs sage.libs.flint [2, 1, 1, 1] - sage: Partitions(5).random_element(measure='Plancherel') # random + sage: Partitions(5).random_element(measure='Plancherel') # random # needs sage.libs.flint [2, 1, 1, 1] """ if measure == 'uniform': @@ -6709,22 +6710,22 @@ def random_element_uniform(self): EXAMPLES:: - sage: Partitions(5).random_element_uniform() # random + sage: Partitions(5).random_element_uniform() # random # needs sage.libs.flint [2, 1, 1, 1] - sage: Partitions(20).random_element_uniform() # random + sage: Partitions(20).random_element_uniform() # random # needs sage.libs.flint [9, 3, 3, 2, 2, 1] TESTS:: - sage: all(Part.random_element_uniform() in Part + sage: all(Part.random_element_uniform() in Part # needs sage.libs.flint ....: for Part in map(Partitions, range(10))) True Check that :trac:`18752` is fixed:: sage: P = Partitions(5) - sage: la = P.random_element_uniform() - sage: la.parent() is P + sage: la = P.random_element_uniform() # needs sage.libs.flint + sage: la.parent() is P # needs sage.libs.flint True ALGORITHM: @@ -7003,7 +7004,7 @@ def __iter__(self): [[]] sage: from sage.combinat.partition import number_of_partitions_length - sage: all( len(Partitions(n, length=k).list()) + sage: all( len(Partitions(n, length=k).list()) # needs sage.libs.flint ....: == number_of_partitions_length(n, k) ....: for n in range(9) for k in range(n+2) ) True @@ -7059,23 +7060,23 @@ def cardinality(self, algorithm='hybrid'): Further examples:: - sage: Partitions(5, length=3).cardinality() + sage: Partitions(5, length=3).cardinality() # needs sage.libs.flint 2 - sage: Partitions(6, length=3).cardinality() + sage: Partitions(6, length=3).cardinality() # needs sage.libs.flint 3 - sage: Partitions(8, length=4).cardinality() + sage: Partitions(8, length=4).cardinality() # needs sage.libs.flint 5 - sage: Partitions(8, length=5).cardinality() + sage: Partitions(8, length=5).cardinality() # needs sage.libs.flint 3 - sage: Partitions(15, length=6).cardinality() + sage: Partitions(15, length=6).cardinality() # needs sage.libs.flint 26 - sage: Partitions(0, length=0).cardinality() + sage: Partitions(0, length=0).cardinality() # needs sage.libs.flint 1 - sage: Partitions(0, length=1).cardinality() + sage: Partitions(0, length=1).cardinality() # needs sage.libs.flint 0 - sage: Partitions(1, length=0).cardinality() + sage: Partitions(1, length=0).cardinality() # needs sage.libs.flint 0 - sage: Partitions(1, length=4).cardinality() + sage: Partitions(1, length=4).cardinality() # needs sage.libs.flint 0 TESTS: @@ -7084,11 +7085,12 @@ def cardinality(self, algorithm='hybrid'): sage: N = [0, 1, 2, 3, 5, 10, 20, 500, 850] sage: K = [0, 1, 2, 3, 5, 10, 11, 20, 21, 250, 499, 500] - sage: all(Partitions(n,length=k).cardinality() == Partitions(n,length=k).cardinality('gap') + sage: all(Partitions(n, length=k).cardinality() # needs sage.libs.flint + ....: == Partitions(n,length=k).cardinality('gap') ....: for n in N for k in K) True sage: P = Partitions(4562, length=2800) - sage: P.cardinality() == P.cardinality('gap') + sage: P.cardinality() == P.cardinality('gap') # needs sage.libs.flint True """ return number_of_partitions_length(self.n, self.k, algorithm) @@ -7117,7 +7119,7 @@ class Partitions_parts_in(Partitions): TESTS:: - sage: TestSuite( sage.combinat.partition.Partitions_parts_in(6, parts=[2,1]) ).run() # optional - sage.libs.gap + sage: TestSuite( sage.combinat.partition.Partitions_parts_in(6, parts=[2,1]) ).run() # needs sage.libs.gap """ @staticmethod @@ -7141,7 +7143,7 @@ def __init__(self, n, parts): TESTS:: - sage: TestSuite(Partitions(5, parts_in=[1,2,3])).run() # optional - sage.libs.gap + sage: TestSuite(Partitions(5, parts_in=[1,2,3])).run() # needs sage.libs.gap """ Partitions.__init__(self) self.n = n @@ -7176,12 +7178,12 @@ def cardinality(self): EXAMPLES:: - sage: Partitions(15, parts_in=[2,3,7]).cardinality() # optional - sage.libs.gap + sage: Partitions(15, parts_in=[2,3,7]).cardinality() # needs sage.libs.gap 5 If you can use all parts 1 through `n`, we'd better get `p(n)`:: - sage: (Partitions(20, parts_in=[1..20]).cardinality() # optional - sage.libs.gap + sage: (Partitions(20, parts_in=[1..20]).cardinality() # needs sage.libs.gap ....: == Partitions(20).cardinality()) True @@ -7191,19 +7193,19 @@ def cardinality(self): algorithm that actually generates the partitions:: sage: ps = Partitions(15, parts_in=[1,2,3]) - sage: ps.cardinality() == len(ps.list()) # optional - sage.libs.gap + sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap True sage: ps = Partitions(15, parts_in=[]) - sage: ps.cardinality() == len(ps.list()) # optional - sage.libs.gap + sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap True sage: ps = Partitions(3000, parts_in=[50,100,500,1000]) - sage: ps.cardinality() == len(ps.list()) # optional - sage.libs.gap + sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap True sage: ps = Partitions(10, parts_in=[3,6,9]) - sage: ps.cardinality() == len(ps.list()) # optional - sage.libs.gap + sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap True sage: ps = Partitions(0, parts_in=[1,2]) - sage: ps.cardinality() == len(ps.list()) # optional - sage.libs.gap + sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap True """ # GAP complains if you give it an empty list @@ -8288,12 +8290,12 @@ def cardinality(self): EXAMPLES:: sage: P = Partitions(5, regular=3) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 5 sage: P = Partitions(5, regular=6) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 7 - sage: P.cardinality() == Partitions(5).cardinality() + sage: P.cardinality() == Partitions(5).cardinality() # needs sage.libs.flint True TESTS: @@ -8301,16 +8303,16 @@ def cardinality(self): Check the corner case:: sage: P = Partitions(0, regular=3) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 1 Check for 1-regular partitions:: sage: P = Partitions(0, regular=1) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 1 sage: P = Partitions(5, regular=1) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 0 """ @@ -8366,16 +8368,16 @@ class OrderedPartitions(Partitions): sage: OrderedPartitions(3) Ordered partitions of 3 - sage: OrderedPartitions(3).list() # optional - sage.libs.gap + sage: OrderedPartitions(3).list() # needs sage.libs.gap [[3], [2, 1], [1, 2], [1, 1, 1]] sage: OrderedPartitions(3,2) Ordered partitions of 3 of length 2 - sage: OrderedPartitions(3,2).list() # optional - sage.libs.gap + sage: OrderedPartitions(3,2).list() # needs sage.libs.gap [[2, 1], [1, 2]] - sage: OrderedPartitions(10, k=2).list() # optional - sage.libs.gap + sage: OrderedPartitions(10, k=2).list() # needs sage.libs.gap [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]] - sage: OrderedPartitions(4).list() # optional - sage.libs.gap + sage: OrderedPartitions(4).list() # needs sage.libs.gap [[4], [3, 1], [2, 2], [2, 1, 1], [1, 3], [1, 2, 1], [1, 1, 2], [1, 1, 1, 1]] """ @@ -8406,7 +8408,7 @@ def __init__(self, n, k): TESTS:: - sage: TestSuite( OrderedPartitions(5,3) ).run() # optional - sage.libs.gap + sage: TestSuite( OrderedPartitions(5,3) ).run() # needs sage.libs.gap """ Partitions.__init__(self) self.n = n @@ -8451,9 +8453,9 @@ def list(self): EXAMPLES:: - sage: OrderedPartitions(3).list() # optional - sage.libs.gap + sage: OrderedPartitions(3).list() # needs sage.libs.gap [[3], [2, 1], [1, 2], [1, 1, 1]] - sage: OrderedPartitions(3,2).list() # optional - sage.libs.gap + sage: OrderedPartitions(3,2).list() # needs sage.libs.gap [[2, 1], [1, 2]] """ from sage.libs.gap.libgap import libgap @@ -8473,13 +8475,13 @@ def cardinality(self): EXAMPLES:: - sage: OrderedPartitions(3).cardinality() # optional - sage.libs.gap + sage: OrderedPartitions(3).cardinality() # needs sage.libs.gap 4 - sage: OrderedPartitions(3,2).cardinality() # optional - sage.libs.gap + sage: OrderedPartitions(3,2).cardinality() # needs sage.libs.gap 2 - sage: OrderedPartitions(10,2).cardinality() # optional - sage.libs.gap + sage: OrderedPartitions(10,2).cardinality() # needs sage.libs.gap 9 - sage: OrderedPartitions(15).cardinality() # optional - sage.libs.gap + sage: OrderedPartitions(15).cardinality() # needs sage.libs.gap 16384 """ from sage.libs.gap.libgap import libgap @@ -8553,12 +8555,12 @@ def cardinality(self): EXAMPLES:: - sage: PartitionsGreatestLE(9, 5).cardinality() # optional - sage.libs.gap + sage: PartitionsGreatestLE(9, 5).cardinality() # needs sage.libs.gap 23 TESTS:: - sage: all(PartitionsGreatestLE(n, a).cardinality() == # optional - sage.libs.gap + sage: all(PartitionsGreatestLE(n, a).cardinality() == # needs sage.libs.gap ....: len(PartitionsGreatestLE(n, a).list()) ....: for n in range(20) for a in range(6)) True @@ -8648,7 +8650,7 @@ def cardinality(self): TESTS:: - sage: all(PartitionsGreatestEQ(n, a).cardinality() == + sage: all(PartitionsGreatestEQ(n, a).cardinality() == # needs sage.libs.flint ....: len(PartitionsGreatestEQ(n, a).list()) ....: for n in range(20) for a in range(6)) True @@ -8906,12 +8908,12 @@ def cardinality(self): EXAMPLES:: sage: P = Partitions(5, restricted=3) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 5 sage: P = Partitions(5, restricted=6) - sage: P.cardinality() + sage: P.cardinality() # needs sage.libs.flint 7 - sage: P.cardinality() == Partitions(5).cardinality() + sage: P.cardinality() == Partitions(5).cardinality() # needs sage.libs.flint True """ if self._ell > self.n: @@ -8980,17 +8982,17 @@ def number_of_partitions(n, algorithm='default'): :: - sage: number_of_partitions(10) + sage: number_of_partitions(10) # needs sage.libs.flint 42 - sage: number_of_partitions(3) + sage: number_of_partitions(3) # needs sage.libs.flint 3 - sage: number_of_partitions(10) + sage: number_of_partitions(10) # needs sage.libs.flint 42 - sage: number_of_partitions(40) + sage: number_of_partitions(40) # needs sage.libs.flint 37338 - sage: number_of_partitions(100) + sage: number_of_partitions(100) # needs sage.libs.flint 190569292 - sage: number_of_partitions(100000) + sage: number_of_partitions(100000) # needs sage.libs.flint 27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519 A generating function for the number of partitions `p_n` is given by the @@ -9007,7 +9009,7 @@ def number_of_partitions(n, algorithm='default'): sage: q = PowerSeriesRing(QQ, 'q', default_prec=9).gen() sage: prod([(1-q^k)^(-1) for k in range(1,9)]) # partial product of 1 + q + 2*q^2 + 3*q^3 + 5*q^4 + 7*q^5 + 11*q^6 + 15*q^7 + 22*q^8 + O(q^9) - sage: [number_of_partitions(k) for k in range(2,10)] + sage: [number_of_partitions(k) for k in range(2,10)] # needs sage.libs.flint [2, 3, 5, 7, 11, 15, 22, 30] REFERENCES: @@ -9017,31 +9019,31 @@ def number_of_partitions(n, algorithm='default'): TESTS:: sage: n = 500 + randint(0,500) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1500 + randint(0,1500) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint True sage: n = 100000000 + randint(0,100000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # long time (4s on sage.math, 2011) + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # long time (4s on sage.math, 2011), needs sage.libs.flint True """ @@ -9069,19 +9071,19 @@ def number_of_partitions_length(n, k, algorithm='hybrid'): EXAMPLES:: sage: from sage.combinat.partition import number_of_partitions_length - sage: number_of_partitions_length(5, 2) # optional - sage.libs.gap + sage: number_of_partitions_length(5, 2) # needs sage.libs.gap 2 - sage: number_of_partitions_length(10, 2) # optional - sage.libs.gap + sage: number_of_partitions_length(10, 2) # needs sage.libs.gap 5 - sage: number_of_partitions_length(10, 4) # optional - sage.libs.gap + sage: number_of_partitions_length(10, 4) # needs sage.libs.gap 9 - sage: number_of_partitions_length(10, 0) # optional - sage.libs.gap + sage: number_of_partitions_length(10, 0) # needs sage.libs.gap 0 - sage: number_of_partitions_length(10, 1) # optional - sage.libs.gap + sage: number_of_partitions_length(10, 1) # needs sage.libs.gap 1 - sage: number_of_partitions_length(0, 0) # optional - sage.libs.gap + sage: number_of_partitions_length(0, 0) # needs sage.libs.gap 1 - sage: number_of_partitions_length(0, 1) # optional - sage.libs.gap + sage: number_of_partitions_length(0, 1) # needs sage.libs.gap 0 """ if algorithm == 'hybrid': diff --git a/src/sage/combinat/partition_tuple.py b/src/sage/combinat/partition_tuple.py index 5766027efbc..86ac2400397 100644 --- a/src/sage/combinat/partition_tuple.py +++ b/src/sage/combinat/partition_tuple.py @@ -105,7 +105,7 @@ class of modules for the algebras, which are generalisations of the Specht ([1], [1], [1], [1], [1]) sage: PartitionTuples(4,5).an_element() ([1], [], [], [4]) - sage: PartitionTuples(3,2)[:] + sage: PartitionTuples(3,2)[:] # needs sage.libs.flint [([2], [], []), ([1, 1], [], []), ([1], [1], []), @@ -115,7 +115,7 @@ class of modules for the algebras, which are generalisations of the Specht ([], [1], [1]), ([], [], [2]), ([], [], [1, 1])] - sage: PartitionTuples(2,3).list() + sage: PartitionTuples(2,3).list() # needs sage.libs.flint [([3], []), ([2, 1], []), ([1, 1, 1], []), @@ -237,9 +237,10 @@ class of modules for the algebras, which are generalisations of the Specht Attached to a partition tuple is the corresponding Young, or parabolic, subgroup:: - sage: mu.young_subgroup() - Permutation Group with generators [(), (12,13), (11,12), (8,9), (6,7), (3,4), (2,3), (1,2)] - sage: mu.young_subgroup_generators() + sage: mu.young_subgroup() # needs sage.groups + Permutation Group with generators + [(), (12,13), (11,12), (8,9), (6,7), (3,4), (2,3), (1,2)] + sage: mu.young_subgroup_generators() # needs sage.groups [1, 2, 3, 6, 8, 11, 12] """ @@ -1474,7 +1475,7 @@ def to_list(self): TESTS:: - sage: all(mu==PartitionTuple(mu.to_list()) for mu in PartitionTuples(4,4)) + sage: all(mu==PartitionTuple(mu.to_list()) for mu in PartitionTuples(4,4)) # needs sage.libs.flint True """ return [mu.to_list() for mu in self] @@ -1486,7 +1487,7 @@ def young_subgroup(self): EXAMPLES:: - sage: PartitionTuple([[2,1],[4,2],[1]]).young_subgroup() + sage: PartitionTuple([[2,1],[4,2],[1]]).young_subgroup() # needs sage.groups Permutation Group with generators [(), (8,9), (6,7), (5,6), (4,5), (1,2)] """ gens = [] @@ -1955,7 +1956,7 @@ def __contains__(self, mu): True sage: PartitionTuple([[2,1],[],[1,1],[],[3]]) in PartitionTuples() True - sage: all(mu in PartitionTuples() for mu in PartitionTuples(3,8)) + sage: all(mu in PartitionTuples() for mu in PartitionTuples(3,8)) # needs sage.libs.flint True sage: [5,1,1] in PartitionTuples() True @@ -1990,7 +1991,7 @@ def __getitem__(self, r): EXAMPLES:: - sage: PartitionTuples()[10:20] + sage: PartitionTuples()[10:20] # needs sage.libs.flint [([1, 1, 1]), ([2], []), ([1, 1], []), @@ -2074,7 +2075,7 @@ def __init__(self): EXAMPLES:: - sage: TestSuite( PartitionTuples() ).run() + sage: TestSuite( PartitionTuples() ).run() # needs sage.libs.flint """ super().__init__(category=InfiniteEnumeratedSets()) @@ -2096,7 +2097,7 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples()[:20] + sage: PartitionTuples()[:20] # needs sage.libs.flint [([]), ([1]), ([], []), @@ -2151,7 +2152,7 @@ def __init__(self, level, category=None): Partition tuples of level 4 sage: PartitionTuples(level=6) Partition tuples of level 6 - sage: TestSuite( PartitionTuples(level=4) ).run() + sage: TestSuite( PartitionTuples(level=4) ).run() # needs sage.libs.flint """ if level not in NN: raise ValueError('level must be a non-negative integer') @@ -2185,7 +2186,7 @@ def __contains__(self, mu): True sage: PartitionTuple([[2,2,1],[],[2]]) in PartitionTuples(level=2) False - sage: all(mu in PartitionTuples(3) for mu in PartitionTuples(3,8)) + sage: all(mu in PartitionTuples(3) for mu in PartitionTuples(3,8)) # needs sage.libs.flint True Check that :trac:`14145` is fixed:: @@ -2202,8 +2203,8 @@ def __iter__(self): EXAMPLES:: - sage: parts=PartitionTuples(3) - sage: [parts[k] for k in range(20)] + sage: parts = PartitionTuples(3) + sage: [parts[k] for k in range(20)] # needs sage.libs.flint [([], [], []), ([1], [], []), ([], [1], []), @@ -2257,7 +2258,7 @@ def __init__(self, size): sage: PartitionTuples(size=6) Partition tuples of size 6 - sage: TestSuite( PartitionTuples(size=6) ).run() + sage: TestSuite( PartitionTuples(size=6) ).run() # needs sage.libs.flint """ if size not in NN: raise ValueError('size must be a non-negative integer') @@ -2289,7 +2290,7 @@ def __contains__(self, mu): True sage: PartitionTuple([[2,1],[],[1,1],[],[3]]) in PartitionTuples(size=7) False - sage: all(mu in PartitionTuples(size=8) for mu in PartitionTuples(3,8)) + sage: all(mu in PartitionTuples(size=8) for mu in PartitionTuples(3,8)) # needs sage.libs.flint True sage: [3, 2, 1] in PartitionTuples(size=7) False @@ -2309,7 +2310,7 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(size=3)[:20] + sage: PartitionTuples(size=3)[:20] # needs sage.libs.flint [([3]), ([2, 1]), ([1, 1, 1]), @@ -2358,8 +2359,8 @@ def __init__(self, level, size): EXAMPLES:: - sage: TestSuite( PartitionTuples(4,2) ).run() - sage: TestSuite( PartitionTuples(level=4, size=5) ).run() + sage: TestSuite( PartitionTuples(4,2) ).run() # needs sage.libs.flint sage.libs.pari + sage: TestSuite( PartitionTuples(level=4, size=5) ).run() # needs sage.libs.flint sage.libs.pari """ if not (level in NN and size in NN): raise ValueError('n and level must be non-negative integers') @@ -2394,7 +2395,7 @@ def __contains__(self, mu): True sage: PartitionTuple([[2,1],[],[1,1],[],[3]]) in PartitionTuples(2,8) False - sage: all(mu in PartitionTuples(3,8) for mu in PartitionTuples(3,8)) + sage: all(mu in PartitionTuples(3,8) for mu in PartitionTuples(3,8)) # needs sage.libs.flint True Check that :trac:`14145` is fixed:: @@ -2415,13 +2416,13 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(2,0).list() #indirect doctest + sage: PartitionTuples(2,0).list() #indirect doctest # needs sage.libs.flint [([], [])] - sage: PartitionTuples(2,1).list() #indirect doctest + sage: PartitionTuples(2,1).list() #indirect doctest # needs sage.libs.flint [([1], []), ([], [1])] - sage: PartitionTuples(2,2).list() #indirect doctest + sage: PartitionTuples(2,2).list() #indirect doctest # needs sage.libs.flint [([2], []), ([1, 1], []), ([1], [1]), ([], [2]), ([], [1, 1])] - sage: PartitionTuples(3,2).list() #indirect doctest + sage: PartitionTuples(3,2).list() #indirect doctest # needs sage.libs.flint [([2], [], []), ([1, 1], [], []), ([1], [1], []), @@ -2463,22 +2464,22 @@ def cardinality(self): EXAMPLES:: - sage: PartitionTuples(2,3).cardinality() + sage: PartitionTuples(2,3).cardinality() # needs sage.libs.pari 10 - sage: PartitionTuples(2,8).cardinality() + sage: PartitionTuples(2,8).cardinality() # needs sage.libs.pari 185 TESTS: The following calls used to fail (:trac:`11476`):: - sage: PartitionTuples(17,2).cardinality() + sage: PartitionTuples(17,2).cardinality() # needs sage.libs.pari 170 - sage: PartitionTuples(2,17).cardinality() + sage: PartitionTuples(2,17).cardinality() # needs sage.libs.pari 8470 - sage: PartitionTuples(100,13).cardinality() + sage: PartitionTuples(100,13).cardinality() # needs sage.libs.pari 110320020147886800 - sage: PartitionTuples(13,90).cardinality() + sage: PartitionTuples(13,90).cardinality() # needs sage.libs.pari 91506473741200186152352843611 These answers were checked against Gap4 (the last of which takes an @@ -2523,7 +2524,7 @@ def __init__(self, regular, **kwds): TESTS:: sage: RPT = PartitionTuples(regular=3) - sage: TestSuite(RPT).run() + sage: TestSuite(RPT).run() # needs sage.libs.flint """ if regular not in ZZ or regular < 1: raise ValueError("regular must be an integer greater than 1") @@ -2599,7 +2600,7 @@ def __init__(self, regular): EXAMPLES:: sage: RPT = PartitionTuples(regular=3) - sage: TestSuite(RPT).run() + sage: TestSuite(RPT).run() # needs sage.libs.flint """ RegularPartitionTuples.__init__(self, regular, category=InfiniteEnumeratedSets()) @@ -2620,7 +2621,7 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(regular=2)[:20] + sage: PartitionTuples(regular=2)[:20] # needs sage.libs.flint [([]), ([], []), ([1]), @@ -2668,7 +2669,7 @@ class RegularPartitionTuples_level(PartitionTuples_level): EXAMPLES:: sage: RPT = PartitionTuples(level=4, regular=(2,3,0,2)) - sage: RPT[:24] + sage: RPT[:24] # needs sage.libs.flint [([], [], [], []), ([1], [], [], []), ([], [1], [], []), @@ -2711,7 +2712,7 @@ def __init__(self, level, regular): sage: RPT.category() Category of infinite enumerated sets sage: RPT = PartitionTuples(level=4, regular=3) - sage: TestSuite(RPT).run() + sage: TestSuite(RPT).run() # needs sage.libs.flint """ if level not in NN: raise ValueError('level must be a non-negative integer') @@ -2814,7 +2815,7 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(level=3, regular=(2,1,4))[:24] + sage: PartitionTuples(level=3, regular=(2,1,4))[:24] # needs sage.libs.flint [([], [], []), ([1], [], []), ([], [], [1]), @@ -2839,7 +2840,7 @@ def __iter__(self): ([1], [], [3]), ([1], [], [2, 1]), ([1], [], [1, 1, 1])] - sage: PartitionTuples(level=4, regular=2)[:20] + sage: PartitionTuples(level=4, regular=2)[:20] # needs sage.libs.flint [([], [], [], []), ([1], [], [], []), ([], [1], [], []), @@ -2878,7 +2879,7 @@ def __init__(self, size, regular): EXAMPLES:: sage: RPT = PartitionTuples(size=4, regular=3) - sage: TestSuite(RPT).run() + sage: TestSuite(RPT).run() # needs sage.libs.flint """ if size not in NN: raise ValueError('size must be a non-negative integer') @@ -2936,7 +2937,7 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(size=4, regular=2)[:10] + sage: PartitionTuples(size=4, regular=2)[:10] # needs sage.libs.flint [([4]), ([3, 1]), ([4], []), @@ -2974,7 +2975,7 @@ class RegularPartitionTuples_level_size(PartitionTuples_level_size): EXAMPLES:: - sage: PartitionTuples(level=3, size=7, regular=(2,1,3))[0:24] + sage: PartitionTuples(level=3, size=7, regular=(2,1,3))[0:24] # needs sage.libs.flint [([7], [], []), ([6, 1], [], []), ([5, 2], [], []), @@ -3008,7 +3009,7 @@ def __init__(self, level, size, regular): TESTS:: sage: RPT = PartitionTuples(4,2,3) - sage: TestSuite(RPT).run() + sage: TestSuite(RPT).run() # needs sage.libs.flint sage.libs.pari """ if size not in NN: raise ValueError('size must be a non-negative integer') @@ -3082,7 +3083,7 @@ def __iter__(self): EXAMPLES:: - sage: list(PartitionTuples(3,3,2)) + sage: list(PartitionTuples(3,3,2)) # needs sage.libs.pari [([3], [], []), ([2, 1], [], []), ([2], [1], []), diff --git a/src/sage/combinat/path_tableaux/frieze.py b/src/sage/combinat/path_tableaux/frieze.py index 23ff179039c..7ed6346efc5 100644 --- a/src/sage/combinat/path_tableaux/frieze.py +++ b/src/sage/combinat/path_tableaux/frieze.py @@ -85,9 +85,9 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): This constructs the examples from [HJ18]_:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: t = path_tableaux.FriezePattern([1,sqrt3,2,sqrt3,1,1], field=K) # optional - sage.rings.number_field - sage: path_tableaux.CylindricalDiagram(t) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field + sage: t = path_tableaux.FriezePattern([1,sqrt3,2,sqrt3,1,1], field=K) # needs sage.rings.number_field + sage: path_tableaux.CylindricalDiagram(t) # needs sage.rings.number_field [ 0, 1, sqrt3, 2, sqrt3, 1, 1, 0] [ , 0, 1, sqrt3, 2, sqrt3, sqrt3 + 1, 1, 0] [ , , 0, 1, sqrt3, 2, sqrt3 + 2, sqrt3, 1, 0] @@ -97,12 +97,12 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): [ , , , , , , 0, 1, sqrt3 + 1, sqrt3 + 2, sqrt3 + 2, sqrt3 + 1, 1, 0] [ , , , , , , , 0, 1, sqrt3, 2, sqrt3, 1, 1, 0] - sage: TestSuite(t).run() # optional - sage.rings.number_field + sage: TestSuite(t).run() # needs sage.rings.number_field - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: t = path_tableaux.FriezePattern([1,sqrt2,1,sqrt2,3,2*sqrt2,5,3*sqrt2,1], # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) # needs sage.rings.number_field + sage: t = path_tableaux.FriezePattern([1,sqrt2,1,sqrt2,3,2*sqrt2,5,3*sqrt2,1], # needs sage.rings.number_field ....: field=K) - sage: path_tableaux.CylindricalDiagram(t) # optional - sage.rings.number_field + sage: path_tableaux.CylindricalDiagram(t) # needs sage.rings.number_field [ 0, 1, sqrt2, 1, sqrt2, 3, 2*sqrt2, 5, 3*sqrt2, 1, 0] [ , 0, 1, sqrt2, 3, 5*sqrt2, 7, 9*sqrt2, 11, 2*sqrt2, 1, 0] [ , , 0, 1, 2*sqrt2, 7, 5*sqrt2, 13, 8*sqrt2, 3, sqrt2, 1, 0] @@ -115,7 +115,7 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): [ , , , , , , , , , 0, 1, 2*sqrt2, 3, sqrt2, 1, sqrt2, 1, sqrt2, 1, 0] [ , , , , , , , , , , 0, 1, sqrt2, 1, sqrt2, 3, 2*sqrt2, 5, 3*sqrt2, 1, 0] - sage: TestSuite(t).run() # optional - sage.rings.number_field + sage: TestSuite(t).run() # needs sage.rings.number_field """ @staticmethod def __classcall_private__(cls, fp, field=QQ): @@ -135,8 +135,8 @@ def __classcall_private__(cls, fp, field=QQ): ValueError: invalid input 2 sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: t = path_tableaux.FriezePattern([1,sqrt3,2,sqrt3,1,1]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field + sage: t = path_tableaux.FriezePattern([1,sqrt3,2,sqrt3,1,1]) # needs sage.rings.number_field Traceback (most recent call last): ... ValueError: [1, sqrt3, 2, sqrt3, 1, 1] is not a sequence in the field Rational Field @@ -278,8 +278,8 @@ def is_positive(self): False sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: path_tableaux.FriezePattern([1,sqrt3,1], K).is_positive() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field + sage: path_tableaux.FriezePattern([1,sqrt3,1], K).is_positive() # needs sage.rings.number_field True """ return all(a > 0 for a in self[1:-1]) @@ -316,16 +316,16 @@ def triangulation(self): EXAMPLES:: - sage: path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]).triangulation() # optional - sage.plot sage.symbolic + sage: path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]).triangulation() # needs sage.plot sage.symbolic Graphics object consisting of 25 graphics primitives - sage: path_tableaux.FriezePattern([1,2,1/7,5,3]).triangulation() # optional - sage.plot sage.symbolic + sage: path_tableaux.FriezePattern([1,2,1/7,5,3]).triangulation() # needs sage.plot sage.symbolic Graphics object consisting of 12 graphics primitives sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: path_tableaux.FriezePattern([1,sqrt2,1,sqrt2,3,2*sqrt2,5,3*sqrt2,1], # optional - sage.plot sage.rings.number_field sage.symbolic + sage: K. = NumberField(x^2 - 2) # needs sage.rings.number_field + sage: path_tableaux.FriezePattern([1,sqrt2,1,sqrt2,3,2*sqrt2,5,3*sqrt2,1], # needs sage.plot sage.rings.number_field sage.symbolic ....: field=K).triangulation() Graphics object consisting of 24 graphics primitives """ @@ -379,17 +379,17 @@ def plot(self, model='UHP'): EXAMPLES:: sage: t = path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]) - sage: t.plot() # optional - sage.plot sage.symbolic + sage: t.plot() # needs sage.plot sage.symbolic Graphics object consisting of 18 graphics primitives - sage: t.plot(model='UHP') # optional - sage.plot sage.symbolic + sage: t.plot(model='UHP') # needs sage.plot sage.symbolic Graphics object consisting of 18 graphics primitives - sage: t.plot(model='PD') # optional - sage.plot sage.symbolic + sage: t.plot(model='PD') # needs sage.plot sage.symbolic Traceback (most recent call last): ... TypeError: '>' not supported between instances of 'NotANumber' and 'Pi' - sage: t.plot(model='KM') # optional - sage.plot sage.symbolic + sage: t.plot(model='KM') # needs sage.plot sage.symbolic Graphics object consisting of 18 graphics primitives """ from sage.geometry.hyperbolic_space.hyperbolic_interface import HyperbolicPlane @@ -419,10 +419,12 @@ def change_ring(self, R): EXAMPLES:: - sage: path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]).change_ring(RealField()) - [0.000000000000000, 1.00000000000000, ... 4.00000000000000, 1.00000000000000, 0.000000000000000] + sage: fp = path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]) + sage: fp.change_ring(RealField()) # needs sage.rings.real_mpfr + [0.000000000000000, 1.00000000000000, ... + 4.00000000000000, 1.00000000000000, 0.000000000000000] - sage: path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]).change_ring(GF(7)) + sage: fp.FriezePattern([1,2,7,5,3,7,4,1]).change_ring(GF(7)) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: no base extension defined diff --git a/src/sage/combinat/path_tableaux/path_tableau.py b/src/sage/combinat/path_tableaux/path_tableau.py index e0d612b8f87..66bec5fe5d2 100644 --- a/src/sage/combinat/path_tableaux/path_tableau.py +++ b/src/sage/combinat/path_tableaux/path_tableau.py @@ -389,7 +389,7 @@ def dual_equivalence_graph(self): EXAMPLES:: sage: s = path_tableaux.DyckPath([0,1,2,3,2,3,2,1,0]) - sage: s.dual_equivalence_graph().adjacency_matrix() + sage: s.dual_equivalence_graph().adjacency_matrix() # needs sage.graphs sage.modules [0 1 1 1 0 1 0 1 1 0 0 0 0 0] [1 0 1 1 1 1 1 0 1 0 0 1 1 0] [1 1 0 1 1 1 0 1 0 1 1 1 0 0] @@ -405,7 +405,7 @@ def dual_equivalence_graph(self): [0 1 0 1 1 1 0 1 1 1 1 1 0 1] [0 0 0 0 1 0 1 0 0 1 1 1 1 0] sage: s = path_tableaux.DyckPath([0,1,2,3,2,1,0]) - sage: s.dual_equivalence_graph().edges(sort=True) + sage: s.dual_equivalence_graph().edges(sort=True) # needs sage.graphs [([0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 2, 1, 0], '4,7'), ([0, 1, 0, 1, 0, 1, 0], [0, 1, 2, 1, 0, 1, 0], '2,5'), ([0, 1, 0, 1, 0, 1, 0], [0, 1, 2, 1, 2, 1, 0], '2,7'), diff --git a/src/sage/combinat/path_tableaux/semistandard.py b/src/sage/combinat/path_tableaux/semistandard.py index f92dfcdd6c8..559571e798a 100644 --- a/src/sage/combinat/path_tableaux/semistandard.py +++ b/src/sage/combinat/path_tableaux/semistandard.py @@ -393,8 +393,9 @@ def to_tableau(self): TESTS:: - sage: SST = SemistandardTableaux(shape=[5,5,3],eval=[2,2,3,4,2]) - sage: all(st == path_tableaux.SemistandardPathTableau(st).to_tableau() for st in SST) + sage: SST = SemistandardTableaux(shape=[5,5,3], eval=[2,2,3,4,2]) + sage: all(st == path_tableaux.SemistandardPathTableau(st).to_tableau() # needs sage.modules + ....: for st in SST) True """ from sage.combinat.tableau import from_chain diff --git a/src/sage/combinat/perfect_matching.py b/src/sage/combinat/perfect_matching.py index c9cc93fd7b3..70c8652841c 100644 --- a/src/sage/combinat/perfect_matching.py +++ b/src/sage/combinat/perfect_matching.py @@ -224,7 +224,7 @@ def _latex_(self): EXAMPLES:: sage: P = PerfectMatching([(1,3),(2,5),(4,6)]) - sage: latex(P) # random # optional - sage.graphs + sage: latex(P) # random # needs sage.graphs sage.plot \begin{tikzpicture} ... \end{tikzpicture} @@ -234,7 +234,7 @@ def _latex_(self): Above we added ``random`` since warnings might be displayed once. The second time, there should be no warnings:: - sage: print(P._latex_()) # optional - sage.graphs + sage: print(P._latex_()) # needs sage.graphs sage.plot \begin{tikzpicture} ... \end{tikzpicture} @@ -377,9 +377,9 @@ def loops(self, other=None): sage: loops = sorted(loops, key=len) sage: sorted(loops[0]) ['d', 'f'] - sage: G = SymmetricGroup(4) # optional - sage.groups - sage: g = G([(1,2,3,4)]) # optional - sage.groups - sage: ((loops[1] in [permutation_action(g**i, ['a', 'e', 'c', 'b']) # optional - sage.groups + sage: G = SymmetricGroup(4) # needs sage.groups + sage: g = G([(1,2,3,4)]) # needs sage.groups + sage: ((loops[1] in [permutation_action(g**i, ['a', 'e', 'c', 'b']) # needs sage.groups ....: for i in range(4)]) ....: or (loops[1] in [permutation_action(g**i, ['a', 'b', 'c', 'e']) ....: for i in range(4)])) @@ -455,11 +455,11 @@ def Weingarten_function(self, d, other=None): EXAMPLES:: - sage: var('N') # optional - sage.symbolic + sage: var('N') # needs sage.symbolic N sage: m = PerfectMatching([(1,3),(2,4)]) sage: n = PerfectMatching([(1,2),(3,4)]) - sage: factor(m.Weingarten_function(N, n)) # optional - sage.symbolic + sage: factor(m.Weingarten_function(N, n)) # needs sage.symbolic -1/((N + 2)*(N - 1)*N) """ if other is None: @@ -477,13 +477,13 @@ def to_graph(self): EXAMPLES:: - sage: PerfectMatching([[1,3], [4,2]]).to_graph().edges(sort=True, # optional - sage.graphs + sage: PerfectMatching([[1,3], [4,2]]).to_graph().edges(sort=True, # needs sage.graphs ....: labels=False) [(1, 3), (2, 4)] - sage: PerfectMatching([[1,4], [3,2]]).to_graph().edges(sort=True, # optional - sage.graphs + sage: PerfectMatching([[1,4], [3,2]]).to_graph().edges(sort=True, # needs sage.graphs ....: labels=False) [(1, 4), (2, 3)] - sage: PerfectMatching([]).to_graph().edges(sort=True, labels=False) # optional - sage.graphs + sage: PerfectMatching([]).to_graph().edges(sort=True, labels=False) # needs sage.graphs [] """ from sage.graphs.graph import Graph @@ -768,8 +768,8 @@ def Weingarten_matrix(self, N): EXAMPLES:: - sage: M = PerfectMatchings(4).Weingarten_matrix(var('N')) # optional - sage.symbolic - sage: N*(N-1)*(N+2)*M.apply_map(factor) # optional - sage.symbolic + sage: M = PerfectMatchings(4).Weingarten_matrix(var('N')) # needs sage.symbolic + sage: N*(N-1)*(N+2)*M.apply_map(factor) # needs sage.symbolic [N + 1 -1 -1] [ -1 N + 1 -1] [ -1 -1 N + 1] diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 6723ad4b1af..d3bcdc3e2f0 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -1256,12 +1256,13 @@ def __mul__(self, rp): """ TESTS:: - sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.modules - sage: SM = SGA.specht_module([2,1]) # needs sage.combinat sage.modules - sage: p213 = Permutations(3)([2,1,3]) # needs sage.modules - sage: p213 * SGA.an_element() # needs sage.combinat sage.modules + sage: # needs sage.modules + sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat + sage: SM = SGA.specht_module([2,1]) # needs sage.combinat + sage: p213 = Permutations(3)([2,1,3]) + sage: p213 * SGA.an_element() # needs sage.combinat 3*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 2*[3, 1, 2] - sage: p213 * SM.an_element() # needs sage.combinat sage.modules + sage: p213 * SM.an_element() # needs sage.combinat 2*B[0] - 4*B[1] """ if not isinstance(rp, Permutation) and isinstance(rp, Element): @@ -1863,7 +1864,7 @@ def number_of_noninversions(self, k) -> Integer: The number of `2`-noninversions of a permutation `p \in S_n` is `\binom{n}{2}` minus its number of inversions:: - sage: b = binomial(5, 2) + sage: b = binomial(5, 2) # needs sage.symbolic sage: all( x.number_of_noninversions(2) == b - x.number_of_inversions() ....: for x in Permutations(5) ) True @@ -4264,21 +4265,22 @@ def right_permutohedron_interval(self, other): TESTS:: - sage: Permutation([]).right_permutohedron_interval(Permutation([])) # needs sage.graphs sage.modules + sage: # needs sage.modules + sage: Permutation([]).right_permutohedron_interval(Permutation([])) # needs sage.graphs [[]] - sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) # needs sage.graphs sage.modules + sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) # needs sage.graphs [[3, 1, 2]] - sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) # needs sage.graphs sage.modules + sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) # needs sage.graphs [[3, 1, 4, 2], [3, 4, 1, 2], [3, 4, 2, 1], [1, 3, 4, 2], [1, 3, 2, 4], [3, 2, 4, 1], [3, 2, 1, 4], [3, 1, 2, 4]] - sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # needs sage.graphs sage.modules + sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # needs sage.graphs [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] - sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.modules + sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) Traceback (most recent call last): ... ValueError: [2, 5, 4, 1, 3] must be lower or equal than [2, 1, 4, 5, 3] for the right permutohedron order - sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) # needs sage.modules + sage: Permutation([2, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) Traceback (most recent call last): ... ValueError: len([2, 4, 1, 3]) and len([2, 1, 4, 5, 3]) must be equal @@ -6829,12 +6831,13 @@ def _element_constructor_(self, x, check=True): sage: G(P(x)) # needs sage.groups (1,4,2,3) - sage: P = PermutationGroup([[(1,3,5),(2,4)],[(1,3)]]) # needs sage.groups - sage: x = P([(3,5),(2,4)]); x # needs sage.groups + sage: # needs sage.groups + sage: P = PermutationGroup([[(1,3,5),(2,4)],[(1,3)]]) + sage: x = P([(3,5),(2,4)]); x (2,4)(3,5) - sage: Permutations(6)(SymmetricGroup(6)(x)) # needs sage.groups + sage: Permutations(6)(SymmetricGroup(6)(x)) [1, 4, 5, 2, 3, 6] - sage: Permutations(6)(x) # known bug, needs sage.groups + sage: Permutations(6)(x) # known bug [1, 4, 5, 2, 3, 6] """ if len(x) < self.n: @@ -8724,16 +8727,17 @@ def to_standard(p, key=None): EXAMPLES:: + sage: # needs sage.combinat sage: import sage.combinat.permutation as permutation - sage: permutation.to_standard([4,2,7]) # needs sage.combinat + sage: permutation.to_standard([4,2,7]) [2, 1, 3] - sage: permutation.to_standard([1,2,3]) # needs sage.combinat + sage: permutation.to_standard([1,2,3]) [1, 2, 3] - sage: permutation.to_standard([]) # needs sage.combinat + sage: permutation.to_standard([]) [] - sage: permutation.to_standard([1,2,3], key=lambda x: -x) # needs sage.combinat + sage: permutation.to_standard([1,2,3], key=lambda x: -x) [3, 2, 1] - sage: permutation.to_standard([5,8,2,5], key=lambda x: -x) # needs sage.combinat + sage: permutation.to_standard([5,8,2,5], key=lambda x: -x) [2, 1, 4, 3] TESTS: diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index d18177aac00..e8fdb063a73 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -544,7 +544,7 @@ def _repr_svg_(self) -> str: EXAMPLES:: sage: PP = PlanePartition([[2, 1, 1], [1, 1]]) - sage: PP._repr_svg_() + sage: PP._repr_svg_() # needs sage.modules '' """ colors = ["snow", "tomato", "steelblue"] @@ -621,7 +621,7 @@ def _latex_(self, show_box=False, EXAMPLES:: sage: PP = PlanePartition([[1]]) - sage: latex(PP) + sage: latex(PP) # needs sage.graphs \begin{tikzpicture} \draw[fill=white,shift={(210:0)},shift={(-30:0)},shift={(90:1)}] (0,0)--(-30:1)--(0,-1)--(210:1)--(0,0); @@ -669,7 +669,7 @@ def plot(self, show_box=False, colors=None): EXAMPLES:: sage: PP = PlanePartition([[4,3,3,1],[2,1,1],[1,1]]) - sage: PP.plot() # optional - sage.plot + sage: PP.plot() # needs sage.plot Graphics object consisting of 27 graphics primitives """ from sage.functions.trig import cos, sin @@ -766,7 +766,7 @@ def plot3d(self, colors=None): EXAMPLES:: sage: PP = PlanePartition([[4,3,3,1],[2,1,1],[1,1]]) - sage: PP.plot3d() # optional - sage.plot + sage: PP.plot3d() # needs sage.plot Graphics3d Object """ if colors is None: @@ -1101,9 +1101,10 @@ def to_order_ideal(self): EXAMPLES:: - sage: PlanePartition([[3,2,1],[2,2],[2]]).to_order_ideal() - [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 0), (0, 1, 1), (0, 2, 0), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1), (2, 0, 0), (2, 0, 1)] - sage: PlanePartition([[2,1],[1],[1]]).to_order_ideal() + sage: PlanePartition([[3,2,1],[2,2],[2]]).to_order_ideal() # needs sage.graphs sage.modules + [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 0), (0, 1, 1), (0, 2, 0), + (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1), (2, 0, 0), (2, 0, 1)] + sage: PlanePartition([[2,1],[1],[1]]).to_order_ideal() # needs sage.graphs sage.modules [(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0), (2, 0, 0)] """ from sage.combinat.posets.poset_examples import posets @@ -1160,12 +1161,12 @@ def cyclically_rotate(self, preserve_parent=False) -> PP: Plane partition [[3, 1, 1, 1], [1]] sage: PP == PP.cyclically_rotate().cyclically_rotate().cyclically_rotate() True - sage: PP = PlanePartitions([4,3,2]).random_element() - sage: PP.cyclically_rotate().parent() + sage: PP = PlanePartitions([4,3,2]).random_element() # needs sage.graphs sage.modules + sage: PP.cyclically_rotate().parent() # needs sage.graphs sage.modules Plane partitions inside a 2 x 4 x 3 box - sage: PP = PlanePartitions([3,4,2])([[2,2,2,2],[2,2,2,2],[2,2,2,2]]) - sage: PP_rotated = PP.cyclically_rotate(preserve_parent=True) - sage: PP_rotated in PP_rotated.parent() + sage: PP = PlanePartitions([3,4,2])([[2,2,2,2],[2,2,2,2],[2,2,2,2]]) # needs sage.graphs sage.modules + sage: PP_rotated = PP.cyclically_rotate(preserve_parent=True) # needs sage.graphs sage.modules + sage: PP_rotated in PP_rotated.parent() # needs sage.graphs sage.modules False """ b = self._max_y @@ -1400,7 +1401,7 @@ def __init__(self, box_size=None, symmetry=None, category=None): TESTS:: sage: PP = PlanePartitions(box_size=[2,2,1]) - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.modules """ if box_size is not None and len(box_size) != 3: raise ValueError("invalid box size") @@ -1545,7 +1546,7 @@ def __init__(self, box_size): EXAMPLES:: sage: PP = PlanePartitions([4,3,2]) - sage: TestSuite(PP).run() # long time + sage: TestSuite(PP).run() # long time, needs sage.modules """ super().__init__(box_size, category=FiniteEnumeratedSets()) @@ -1585,7 +1586,7 @@ def to_poset(self): EXAMPLES:: - sage: PlanePartitions([2,2,2]).to_poset() + sage: PlanePartitions([2,2,2]).to_poset() # needs sage.graphs sage.modules Finite lattice containing 8 elements """ a = self._box[0] @@ -1601,8 +1602,9 @@ def from_order_ideal(self, I) -> PP: EXAMPLES:: - sage: I = [(1, 0, 0), (1, 0, 1), (1, 1, 0), (0, 1, 0), (0, 0, 0), (0, 0, 1), (0, 1, 1)] - sage: PlanePartitions([2,2,2]).from_order_ideal(I) + sage: I = [(1, 0, 0), (1, 0, 1), (1, 1, 0), (0, 1, 0), + ....: (0, 0, 0), (0, 0, 1), (0, 1, 1)] + sage: PlanePartitions([2,2,2]).from_order_ideal(I) # needs sage.graphs sage.modules Plane partition [[2, 2], [2, 1]] """ return self.from_antichain(self.to_poset().order_ideal_generators(I)) @@ -1654,7 +1656,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([1,2,1])) + sage: list(PlanePartitions([1,2,1])) # needs sage.modules [Plane partition [], Plane partition [[1]], Plane partition [[1, 1]]] TESTS:: @@ -1721,7 +1723,7 @@ def random_element(self) -> PP: EXAMPLES:: sage: P = PlanePartitions([4,3,5]) - sage: P.random_element() # random + sage: P.random_element() # random # needs sage.graphs sage.modules Plane partition [[4, 3, 3], [4], [2]] """ Z = self.from_order_ideal(self.to_poset().random_order_ideal()) @@ -1871,7 +1873,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([3,3,2], symmetry='SPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.graphs sage.modules sage: PlanePartitions([4,3,2], symmetry='SPP') Traceback (most recent call last): ... @@ -1916,9 +1918,9 @@ def to_poset(self): EXAMPLES:: sage: PP = PlanePartitions([3,3,2], symmetry='SPP') - sage: PP.to_poset() + sage: PP.to_poset() # needs sage.graphs Finite poset containing 12 elements - sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() + sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings True """ a = self._box[0] @@ -1941,7 +1943,7 @@ def from_order_ideal(self, I) -> PP: sage: PP = PlanePartitions([3,3,2], symmetry='SPP') sage: I = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (2, 0, 0)] - sage: PP.from_order_ideal(I) + sage: PP.from_order_ideal(I) # needs sage.graphs Plane partition [[1, 1, 1], [1, 1], [1]] """ return self.from_antichain(self.to_poset().order_ideal_generators(I)) @@ -1993,7 +1995,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([2,2,1], symmetry='SPP')) + sage: list(PlanePartitions([2,2,1], symmetry='SPP')) # needs sage.graphs sage.modules sage.rings.finite_rings [Plane partition [], Plane partition [[1, 1], [1, 1]], Plane partition [[1, 1], [1]], @@ -2053,7 +2055,7 @@ def random_element(self) -> PP: EXAMPLES:: sage: PP = PlanePartitions([3,3,2], symmetry='SPP') - sage: PP.random_element() # random + sage: PP.random_element() # random # needs sage.graphs Plane partition [[2, 2, 2], [2, 2], [2]] """ Z = self.from_order_ideal(self.to_poset().random_order_ideal()) @@ -2074,7 +2076,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([3,3,3], symmetry='CSPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.graphs sage.modules sage.rings.finite_rings sage: PlanePartitions([4,3,2], symmetry='CSPP') Traceback (most recent call last): ... @@ -2119,9 +2121,9 @@ def to_poset(self): EXAMPLES:: sage: PP = PlanePartitions([3,3,3], symmetry='CSPP') - sage: PP.to_poset() + sage: PP.to_poset() # needs sage.graphs Finite poset containing 11 elements - sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() + sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() # needs sage.graphs True """ a = self._box[0] @@ -2193,7 +2195,7 @@ def from_order_ideal(self, I) -> PP: sage: PP = PlanePartitions([3,3,3], symmetry='CSPP') sage: I = [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 1), (0, 1, 2), ....: (1, 0, 2), (0, 2, 2), (1, 1, 1), (1, 1, 2), (1, 2, 2)] - sage: PP.from_order_ideal(I) + sage: PP.from_order_ideal(I) # needs sage.graphs Plane partition [[3, 3, 3], [3, 3, 3], [3, 3, 2]] """ return self.from_antichain(self.to_poset().order_ideal_generators(I)) @@ -2212,7 +2214,7 @@ def random_element(self) -> PP: EXAMPLES:: sage: PP = PlanePartitions([3,3,3], symmetry='CSPP') - sage: PP.random_element() # random + sage: PP.random_element() # random # needs sage.graphs Plane partition [[3, 2, 2], [3, 1], [1, 1]] """ Z = self.from_order_ideal(self.to_poset().random_order_ideal()) @@ -2224,7 +2226,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([2,2,2], symmetry='CSPP')) + sage: list(PlanePartitions([2,2,2], symmetry='CSPP')) # needs sage.graphs sage.modules [Plane partition [], Plane partition [[2, 2], [2, 2]], Plane partition [[2, 2], [2, 1]], @@ -2281,7 +2283,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([3,3,3], symmetry='TSPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.graphs sage.modules sage: PlanePartitions([4,3,2], symmetry='TSPP') Traceback (most recent call last): ... @@ -2325,9 +2327,10 @@ def to_poset(self): EXAMPLES:: sage: PP = PlanePartitions([3,3,3], symmetry='TSPP') - sage: PP.to_poset() + sage: PP.to_poset() # needs sage.graphs Finite poset containing 10 elements - sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() + sage: (PP.to_poset().order_ideals_lattice().cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings + ....: == PP.cardinality()) True """ a = self._box[0] @@ -2396,7 +2399,7 @@ def from_order_ideal(self, I) -> PP: sage: PP = PlanePartitions([3,3,3], symmetry='TSPP') sage: I = [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 1)] - sage: PP.from_order_ideal(I) + sage: PP.from_order_ideal(I) # needs sage.graphs Plane partition [[3, 2, 1], [2, 1], [1]] """ return self.from_antichain(self.to_poset().order_ideal_generators(I)) @@ -2407,7 +2410,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([2,2,2], symmetry='TSPP')) + sage: list(PlanePartitions([2,2,2], symmetry='TSPP')) # needs sage.graphs sage.modules [Plane partition [], Plane partition [[2, 2], [2, 2]], Plane partition [[2, 2], [2, 1]], @@ -2739,7 +2742,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([3,3,2], symmetry='TCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.graphs sage.modules sage: PlanePartitions([3,3,3], symmetry='TCPP') Traceback (most recent call last): @@ -2773,7 +2776,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([3,3,2], symmetry='TCPP')) + sage: list(PlanePartitions([3,3,2], symmetry='TCPP')) # needs sage.modules [Plane partition [[2, 2, 1], [2, 1], [1]], Plane partition [[2, 1, 1], [2, 1, 1], [1]], Plane partition [[2, 2, 1], [1, 1], [1, 1]], @@ -2825,10 +2828,10 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([2, 2, 4], symmetry='SSCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.modules sage: PP = PlanePartitions([4, 4, 2], symmetry='SSCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # long time # needs sage.modules sage: PlanePartitions([4, 2, 2], symmetry='SSCPP') Traceback (most recent call last): @@ -2862,8 +2865,8 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([4,4,2], symmetry='SSCPP')) - [Plane partition [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], + sage: list(PlanePartitions([4,4,2], symmetry='SSCPP')) # needs sage.modules + [Plane partition [[2, 2, 2, 1], [2, 2, 1], [2, 1], [1]], Plane partition [[2, 2, 2, 1], [2, 1, 1], [2, 1, 1], [1]], Plane partition [[2, 2, 1, 1], [2, 2, 1, 1], [1, 1], [1, 1]], Plane partition [[2, 2, 2, 1], [2, 2, 1], [2, 1], [1]], @@ -2934,7 +2937,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([2,2,2], symmetry='CSTCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.modules sage: PlanePartitions([4,3,2], symmetry='CSTCPP') Traceback (most recent call last): @@ -2968,7 +2971,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([2,2,2], symmetry='CSTCPP')) + sage: list(PlanePartitions([2,2,2], symmetry='CSTCPP')) # needs sage.modules [Plane partition [[2, 1], [1]]] TESTS:: @@ -3020,7 +3023,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([2,2,2], symmetry='CSSCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.modules sage: PlanePartitions([4,3,2], symmetry='CSSCPP') Traceback (most recent call last): ... @@ -3052,7 +3055,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([2,2,2], symmetry='CSSCPP')) + sage: list(PlanePartitions([2,2,2], symmetry='CSSCPP')) # needs sage.modules [Plane partition [[2, 1], [1]]] """ # any CSSCPP is a SCPP and an CSPP, there are much fewer CSPP @@ -3095,7 +3098,7 @@ def __init__(self, box_size): TESTS:: sage: PP = PlanePartitions([4,4,4], symmetry='TSSCPP') - sage: TestSuite(PP).run() + sage: TestSuite(PP).run() # needs sage.modules sage: PlanePartitions([4,3,2], symmetry='TSSCPP') Traceback (most recent call last): ... @@ -3129,9 +3132,9 @@ def to_poset(self): EXAMPLES:: sage: PP = PlanePartitions([6,6,6], symmetry='TSSCPP') - sage: PP.to_poset() + sage: PP.to_poset() # needs sage.graphs sage.modules Finite poset containing 4 elements - sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() + sage: PP.to_poset().order_ideals_lattice().cardinality() == PP.cardinality() # needs sage.graphs sage.modules True """ from sage.combinat.posets.posets import Poset @@ -3250,10 +3253,11 @@ def from_order_ideal(self, I) -> PP: EXAMPLES:: - sage: PP = PlanePartitions([6,6,6], symmetry='TSSCPP') + sage: PP = PlanePartitions([6,6,6], symmetry='TSSCPP') # needs sage.graphs sage: I = [(0, 0, 0), (0, 1, 0), (1, 1, 0)] - sage: PP.from_order_ideal(I) - Plane partition [[6, 6, 6, 5, 5, 3], [6, 5, 5, 3, 3, 1], [6, 5, 5, 3, 3, 1], [5, 3, 3, 1, 1], [5, 3, 3, 1, 1], [3, 1, 1]] + sage: PP.from_order_ideal(I) # needs sage.graphs + Plane partition [[6, 6, 6, 5, 5, 3], [6, 5, 5, 3, 3, 1], [6, 5, 5, 3, 3, 1], + [5, 3, 3, 1, 1], [5, 3, 3, 1, 1], [3, 1, 1]] """ return self.from_antichain(self.to_poset().order_ideal_generators(I)) @@ -3263,7 +3267,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: - sage: list(PlanePartitions([4,4,4], symmetry='TSSCPP')) + sage: list(PlanePartitions([4,4,4], symmetry='TSSCPP')) # needs sage.graphs sage.modules [Plane partition [[4, 4, 2, 2], [4, 4, 2, 2], [2, 2], [2, 2]], Plane partition [[4, 4, 3, 2], [4, 3, 2, 1], [3, 2, 1], [2, 1]]] diff --git a/src/sage/combinat/q_analogues.py b/src/sage/combinat/q_analogues.py index ec4fb594470..358b60ff322 100644 --- a/src/sage/combinat/q_analogues.py +++ b/src/sage/combinat/q_analogues.py @@ -247,18 +247,18 @@ def q_binomial(n, k, q=None, algorithm='auto'): This also works for variables in the symbolic ring:: - sage: z = var('z') # optional - sage.symbolic - sage: factor(q_binomial(4, 2, z)) # optional - sage.symbolic + sage: z = var('z') # needs sage.symbolic + sage: factor(q_binomial(4, 2, z)) # needs sage.symbolic (z^2 + z + 1)*(z^2 + 1) This also works for complex roots of unity:: - sage: q_binomial(10, 4, QQbar(I)) # optional - sage.rings.number_field + sage: q_binomial(10, 4, QQbar(I)) # needs sage.rings.number_field 2 Note that the symbolic computation works (see :trac:`14982`):: - sage: q_binomial(10, 4, I) # optional - sage.rings.number_field + sage: q_binomial(10, 4, I) # needs sage.rings.number_field 2 Check that the algorithm does not matter:: @@ -589,7 +589,7 @@ def q_pochhammer(n, a, q=None): 1 sage: q_pochhammer(0, 1) 1 - sage: q_pochhammer(0, var('a')) # optional - sage.symbolic + sage: q_pochhammer(0, var('a')) # needs sage.symbolic 1 We check that :trac:`25715` is fixed:: @@ -648,7 +648,7 @@ def q_jordan(t, q=None): [615195, 40635, 5643, 2331, 1491, 515, 147, 87, 47, 11, 1] sage: q_jordan([3,2,1]) 16*q^4 + 24*q^3 + 14*q^2 + 5*q + 1 - sage: q_jordan([2,1], x) # optional - sage.symbolic + sage: q_jordan([2,1], x) # needs sage.symbolic 2*x + 1 If the partition is trivial (i.e. has only one part), we get @@ -876,13 +876,13 @@ def q_stirling_number1(n, k, q=None): sage: q_stirling_number1(4,2) q^3 + 3*q^2 + 4*q + 3 - sage: all(stirling_number1(6,k) == q_stirling_number1(6,k)(1) + sage: all(stirling_number1(6,k) == q_stirling_number1(6,k)(1) # needs sage.libs.gap ....: for k in range(1,6)) True sage: x = polygen(QQ['q'],'x') sage: S = sum(q_stirling_number1(5,k)*x**k for k in range(1, 6)) - sage: factor(S) + sage: factor(S) # needs sage.libs.singular x * (x + 1) * (x + q + 1) * (x + q^2 + q + 1) * (x + q^3 + q^2 + q + 1) TESTS:: diff --git a/src/sage/combinat/q_bernoulli.pyx b/src/sage/combinat/q_bernoulli.pyx index 6f899a4cf1e..271a04487fb 100644 --- a/src/sage/combinat/q_bernoulli.pyx +++ b/src/sage/combinat/q_bernoulli.pyx @@ -36,7 +36,7 @@ def q_bernoulli(m, p=None): -1/(q + 1) sage: q_bernoulli(2) q/(q^3 + 2*q^2 + 2*q + 1) - sage: all(q_bernoulli(i)(q=1) == bernoulli(i) for i in range(12)) + sage: all(q_bernoulli(i)(q=1) == bernoulli(i) for i in range(12)) # needs sage.libs.flint True One can evaluate the rational function by giving a second argument:: @@ -101,7 +101,8 @@ def q_bernoulli_polynomial(m): sage: q_bernoulli_polynomial(1) (2/(q + 1))*x - 1/(q + 1) sage: x = q_bernoulli_polynomial(1).parent().gen() - sage: all(q_bernoulli_polynomial(i)(q=1)==bernoulli_polynomial(x,i) for i in range(12)) + sage: all(q_bernoulli_polynomial(i)(q=1) == bernoulli_polynomial(x,i) # needs sage.libs.flint + ....: for i in range(12)) True sage: all(q_bernoulli_polynomial(i)(x=0)==q_bernoulli(i) for i in range(12)) True diff --git a/src/sage/combinat/quickref.py b/src/sage/combinat/quickref.py index fcee7a8def6..b811069f903 100644 --- a/src/sage/combinat/quickref.py +++ b/src/sage/combinat/quickref.py @@ -15,13 +15,13 @@ Combinatorial objects:: sage: S = Subsets([1,2,3,4]); S.list(); S. # not tested - sage: P = Partitions(10000); P.cardinality() # optional - sage.libs.flint + sage: P = Partitions(10000); P.cardinality() # needs sage.libs.flint 3616...315650422081868605887952568754066420592310556052906916435144 sage: Combinations([1,3,7]).random_element() # random sage: Compositions(5, max_part=3).unrank(3) [2, 2, 1] - sage: DyckWord([1,0,1,0,1,1,0,0]).to_binary_tree() # optional - sage.graphs + sage: DyckWord([1,0,1,0,1,1,0,0]).to_binary_tree() # needs sage.graphs [., [., [[., .], .]]] sage: Permutation([3,1,4,2]).robinson_schensted() [[[1, 2], [3, 4]], [[1, 3], [2, 4]]] @@ -47,15 +47,15 @@ Polytopes:: - sage: points = random_matrix(ZZ, 6, 3, x=7).rows() - sage: L = LatticePolytope(points) # optional - sage.geometry.polyhedron - sage: L.npoints(); L.plot3d() # random # optional - sage.geometry.polyhedron sage.plot + sage: points = random_matrix(ZZ, 6, 3, x=7).rows() # needs sage.modules + sage: L = LatticePolytope(points) # needs sage.geometry.polyhedron + sage: L.npoints(); L.plot3d() # random # needs sage.geometry.polyhedron sage.plot :ref:`Root systems, Coxeter and Weyl groups `:: - sage: WeylGroup(["B",3]).bruhat_poset() # optional - sage.graphs sage.modules + sage: WeylGroup(["B",3]).bruhat_poset() # needs sage.graphs sage.modules Finite poset containing 48 elements - sage: RootSystem(["A",2,1]).weight_lattice().plot() # not tested # optional - sage.graphs sage.modules sage.plot + sage: RootSystem(["A",2,1]).weight_lattice().plot() # not tested # needs sage.graphs sage.modules sage.plot :ref:`Crystals `:: @@ -63,19 +63,19 @@ :mod:`Symmetric functions and combinatorial Hopf algebras `:: - sage: Sym = SymmetricFunctions(QQ); Sym.inject_shorthands(verbose=False) # optional - sage.sage.modules - sage: m( ( h[2,1] * (1 + 3 * p[2,1]) ) + s[2](s[3]) ) # optional - sage.sage.modules + sage: Sym = SymmetricFunctions(QQ); Sym.inject_shorthands(verbose=False) # needs sage.sage.modules + sage: m( ( h[2,1] * (1 + 3 * p[2,1]) ) + s[2](s[3]) ) # needs sage.sage.modules 3*m[1, 1, 1] + ... + 10*m[5, 1] + 4*m[6] :ref:`Discrete groups, Permutation groups `:: - sage: S = SymmetricGroup(4) # optional - sage.groups + sage: S = SymmetricGroup(4) # needs sage.groups sage: M = PolynomialRing(QQ, 'x0,x1,x2,x3') - sage: M.an_element() * S.an_element() # optional - sage.groups + sage: M.an_element() * S.an_element() # needs sage.groups x0 Graph theory, posets, lattices (:ref:`sage.graphs`, :ref:`sage.combinat.posets.all`):: - sage: Poset({1: [2,3], 2: [4], 3: [4]}).linear_extensions().cardinality() # optional - sage.graphs sage.modules + sage: Poset({1: [2,3], 2: [4], 3: [4]}).linear_extensions().cardinality() # needs sage.graphs sage.modules 2 """ diff --git a/src/sage/combinat/restricted_growth.py b/src/sage/combinat/restricted_growth.py index 98c1214b392..b638356e4db 100644 --- a/src/sage/combinat/restricted_growth.py +++ b/src/sage/combinat/restricted_growth.py @@ -33,7 +33,7 @@ def __init__(self, n): sage: R = RestrictedGrowthArrays(3) sage: R == loads(dumps(R)) True - sage: TestSuite(R).run(skip=['_test_an_element', + sage: TestSuite(R).run(skip=['_test_an_element', # needs sage.libs.flint ....: '_test_enumerated_set_contains', '_test_some_elements']) """ self._n = n @@ -74,7 +74,7 @@ def cardinality(self): sage: from sage.combinat.restricted_growth import RestrictedGrowthArrays sage: R = RestrictedGrowthArrays(6) - sage: R.cardinality() + sage: R.cardinality() # needs sage.libs.flint 203 """ return bell_number(self._n) diff --git a/src/sage/combinat/ribbon_shaped_tableau.py b/src/sage/combinat/ribbon_shaped_tableau.py index 4115a6a13aa..582761eac6d 100644 --- a/src/sage/combinat/ribbon_shaped_tableau.py +++ b/src/sage/combinat/ribbon_shaped_tableau.py @@ -199,8 +199,8 @@ def __init__(self, category=None): EXAMPLES:: - sage: S = RibbonShapedTableaux() - sage: TestSuite(S).run() + sage: S = RibbonShapedTableaux() # needs sage.graphs + sage: TestSuite(S).run() # needs sage.graphs """ if category is None: category = Sets() @@ -270,8 +270,8 @@ def __init__(self, category=None): EXAMPLES:: - sage: S = StandardRibbonShapedTableaux() - sage: TestSuite(S).run() + sage: S = StandardRibbonShapedTableaux() # needs sage.graphs + sage: TestSuite(S).run() # needs sage.graphs sage.modules sage.rings.finite_rings """ if category is None: category = InfiniteEnumeratedSets() @@ -293,8 +293,8 @@ def __iter__(self): EXAMPLES:: - sage: it = StandardRibbonShapedTableaux().__iter__() - sage: [next(it) for x in range(10)] + sage: it = StandardRibbonShapedTableaux().__iter__() # needs sage.graphs + sage: [next(it) for x in range(10)] # needs sage.graphs sage.modules sage.rings.finite_rings [[], [[1]], [[1, 2]], @@ -376,15 +376,15 @@ class StandardRibbonShapedTableaux_shape(StandardRibbonShapedTableaux): [[None, 2, 4], [1, 3]] sage: StandardRibbonShapedTableaux([2,2]).last() [[None, 1, 2], [3, 4]] - sage: StandardRibbonShapedTableaux([2,2]).cardinality() + sage: StandardRibbonShapedTableaux([2,2]).cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings 5 - sage: StandardRibbonShapedTableaux([2,2]).list() + sage: StandardRibbonShapedTableaux([2,2]).list() # needs sage.graphs sage.modules sage.rings.finite_rings [[[None, 1, 3], [2, 4]], [[None, 1, 2], [3, 4]], [[None, 2, 3], [1, 4]], [[None, 2, 4], [1, 3]], [[None, 1, 4], [2, 3]]] - sage: StandardRibbonShapedTableaux([3,2,2]).cardinality() + sage: StandardRibbonShapedTableaux([3,2,2]).cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings 155 """ @staticmethod @@ -406,7 +406,7 @@ def __init__(self, shape): TESTS:: sage: S = StandardRibbonShapedTableaux([2,2]) - sage: TestSuite(S).run() + sage: TestSuite(S).run() # needs sage.graphs sage.rings.finite_rings """ self.shape = shape StandardRibbonShapedTableaux.__init__(self, FiniteEnumeratedSets()) @@ -448,7 +448,7 @@ def __iter__(self): EXAMPLES:: - sage: [t for t in StandardRibbonShapedTableaux([2,2])] + sage: [t for t in StandardRibbonShapedTableaux([2,2])] # needs sage.graphs sage.rings.finite_rings [[[None, 1, 3], [2, 4]], [[None, 1, 2], [3, 4]], [[None, 2, 3], [1, 4]], diff --git a/src/sage/combinat/ribbon_tableau.py b/src/sage/combinat/ribbon_tableau.py index 843626c4752..b363666d8bf 100644 --- a/src/sage/combinat/ribbon_tableau.py +++ b/src/sage/combinat/ribbon_tableau.py @@ -664,19 +664,19 @@ def spin_polynomial(part, weight, length): EXAMPLES:: sage: from sage.combinat.ribbon_tableau import spin_polynomial - sage: spin_polynomial([6,6,6],[4,2],3) # optional - sage.symbolic + sage: spin_polynomial([6,6,6],[4,2],3) # needs sage.symbolic t^6 + t^5 + 2*t^4 + t^3 + t^2 - sage: spin_polynomial([6,6,6],[4,1,1],3) # optional - sage.symbolic + sage: spin_polynomial([6,6,6],[4,1,1],3) # needs sage.symbolic t^6 + 2*t^5 + 3*t^4 + 2*t^3 + t^2 - sage: spin_polynomial([3,3,3,2,1], [2,2], 3) # optional - sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [2,2], 3) # needs sage.symbolic t^(7/2) + t^(5/2) - sage: spin_polynomial([3,3,3,2,1], [2,1,1], 3) # optional - sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [2,1,1], 3) # needs sage.symbolic 2*t^(7/2) + 2*t^(5/2) + t^(3/2) - sage: spin_polynomial([3,3,3,2,1], [1,1,1,1], 3) # optional - sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [1,1,1,1], 3) # needs sage.symbolic 3*t^(7/2) + 5*t^(5/2) + 3*t^(3/2) + sqrt(t) - sage: spin_polynomial([5,4,3,2,1,1,1], [2,2,1], 3) # optional - sage.symbolic + sage: spin_polynomial([5,4,3,2,1,1,1], [2,2,1], 3) # needs sage.symbolic 2*t^(9/2) + 6*t^(7/2) + 2*t^(5/2) - sage: spin_polynomial([[6]*6, [3,3]], [4,4,2], 3) # optional - sage.symbolic + sage: spin_polynomial([[6]*6, [3,3]], [4,4,2], 3) # needs sage.symbolic 3*t^9 + 5*t^8 + 9*t^7 + 6*t^6 + 3*t^5 """ from sage.symbolic.ring import SR diff --git a/src/sage/combinat/rigged_configurations/kleber_tree.py b/src/sage/combinat/rigged_configurations/kleber_tree.py index b4a57e365f6..f6082658969 100644 --- a/src/sage/combinat/rigged_configurations/kleber_tree.py +++ b/src/sage/combinat/rigged_configurations/kleber_tree.py @@ -1044,7 +1044,7 @@ def plot(self, **options): sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree sage: KT = KleberTree(['D', 4, 1], [[2, 2]]) - sage: print(KT.plot()) # optional - sage.plot + sage: print(KT.plot()) # needs sage.plot Graphics object consisting of 8 graphics primitives """ return self.digraph().plot(edge_labels=True, vertex_size=0, **options) diff --git a/src/sage/combinat/rooted_tree.py b/src/sage/combinat/rooted_tree.py index e8a44b1b163..9bb17754233 100644 --- a/src/sage/combinat/rooted_tree.py +++ b/src/sage/combinat/rooted_tree.py @@ -522,10 +522,10 @@ def __init__(self): """ TESTS:: - sage: sum(x**len(t) # optional - sage.symbolic + sage: sum(x**len(t) # needs sage.symbolic ....: for t in set(RootedTree(t) for t in OrderedTrees(6))) x^5 + x^4 + 3*x^3 + 6*x^2 + 9*x - sage: sum(x**len(t) for t in RootedTrees(6)) # optional - sage.symbolic + sage: sum(x**len(t) for t in RootedTrees(6)) # needs sage.symbolic x^5 + x^4 + 3*x^3 + 6*x^2 + 9*x sage: TestSuite(RootedTrees()).run() # long time @@ -625,14 +625,14 @@ class RootedTrees_size(RootedTrees): TESTS:: sage: from sage.combinat.rooted_tree import RootedTrees_size - sage: for i in range(1, 6): TestSuite(RootedTrees_size(i)).run() # optional - sage.combinat + sage: for i in range(1, 6): TestSuite(RootedTrees_size(i)).run() # needs sage.combinat """ def __init__(self, n): """ TESTS:: - sage: for i in range(1, 6): # optional - sage.combinat + sage: for i in range(1, 6): # needs sage.combinat ....: TestSuite(RootedTrees(i)).run() """ super().__init__(category=FiniteEnumeratedSets()) @@ -663,7 +663,7 @@ def _an_element_(self): """ TESTS:: - sage: RootedTrees(4).an_element() # indirect doctest # optional - sage.combinat + sage: RootedTrees(4).an_element() # indirect doctest # needs sage.combinat [[[[]]]] """ return self.first() @@ -681,11 +681,11 @@ def __iter__(self): sage: from sage.combinat.rooted_tree import * sage: RootedTrees(1).list() [[]] - sage: RootedTrees(2).list() # optional - sage.combinat + sage: RootedTrees(2).list() # needs sage.combinat [[[]]] - sage: RootedTrees(3).list() # optional - sage.combinat + sage: RootedTrees(3).list() # needs sage.combinat [[[[]]], [[], []]] - sage: RootedTrees(4).list() # optional - sage.combinat + sage: RootedTrees(4).list() # needs sage.combinat [[[[[]]]], [[[], []]], [[], [[]]], [[], [], []]] """ if self._n == 1: @@ -757,7 +757,7 @@ def element_class(self): sage: S = RootedTrees(3) sage: S.element_class - sage: S.first().__class__ == RootedTrees().first().__class__ # optional - sage.combinat + sage: S.first().__class__ == RootedTrees().first().__class__ # needs sage.combinat True """ return self._parent_for.element_class diff --git a/src/sage/combinat/set_partition.py b/src/sage/combinat/set_partition.py index 4fda6338b57..0f8867b2f38 100644 --- a/src/sage/combinat/set_partition.py +++ b/src/sage/combinat/set_partition.py @@ -381,7 +381,7 @@ def standard_form(self): EXAMPLES:: - sage: [x.standard_form() for x in SetPartitions(4, [2,2])] + sage: [x.standard_form() for x in SetPartitions(4, [2,2])] # needs sage.graphs sage.rings.finite_rings [[[1, 2], [3, 4]], [[1, 4], [2, 3]], [[1, 3], [2, 4]]] TESTS:: @@ -466,13 +466,13 @@ def max_block_size(self): EXAMPLES:: - sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams - sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]]) - sage: pd.max_block_size() + sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams # needs sage.modules + sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]]) # needs sage.modules + sage: pd.max_block_size() # needs sage.modules 3 - sage: sorted(d.max_block_size() for d in PartitionDiagrams(2)) + sage: sorted(d.max_block_size() for d in PartitionDiagrams(2)) # needs sage.modules [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4] - sage: sorted(sp.max_block_size() for sp in SetPartitions(3)) + sage: sorted(sp.max_block_size() for sp in SetPartitions(3)) # needs sage.modules [1, 2, 2, 2, 3] """ return max(len(block) for block in self) @@ -562,18 +562,18 @@ class SetPartition(AbstractSetPartition, There are 5 set partitions of the set `\{1,2,3\}`:: - sage: SetPartitions(3).cardinality() + sage: SetPartitions(3).cardinality() # needs sage.libs.flint 5 Here is the list of them:: - sage: SetPartitions(3).list() + sage: SetPartitions(3).list() # needs sage.graphs [{{1, 2, 3}}, {{1, 2}, {3}}, {{1, 3}, {2}}, {{1}, {2, 3}}, {{1}, {2}, {3}}] There are 6 set partitions of `\{1,2,3,4\}` whose underlying partition is `[2, 1, 1]`:: - sage: SetPartitions(4, [2,1,1]).list() + sage: SetPartitions(4, [2,1,1]).list() # needs sage.graphs sage.rings.finite_rings [{{1}, {2, 4}, {3}}, {{1}, {2}, {3, 4}}, {{1, 4}, {2}, {3}}, @@ -1798,14 +1798,14 @@ def refinements(self): EXAMPLES:: - sage: SetPartition([[1,3],[2,4]]).refinements() + sage: SetPartition([[1,3],[2,4]]).refinements() # needs sage.graphs sage.libs.flint [{{1, 3}, {2, 4}}, {{1, 3}, {2}, {4}}, {{1}, {2, 4}, {3}}, {{1}, {2}, {3}, {4}}] - sage: SetPartition([[1],[2,4],[3]]).refinements() + sage: SetPartition([[1],[2,4],[3]]).refinements() # needs sage.graphs sage.libs.flint [{{1}, {2, 4}, {3}}, {{1}, {2}, {3}, {4}}] - sage: SetPartition([]).refinements() + sage: SetPartition([]).refinements() # needs sage.graphs sage.libs.flint [{}] """ L = [SetPartitions(part) for part in self] @@ -1893,7 +1893,7 @@ def plot(self, angle=None, color='black', base_set_dict=None): EXAMPLES:: sage: p = SetPartition([[1,10,11],[2,3,7],[4,5,6],[8,9]]) - sage: p.plot() # optional - sage.plot sage.symbolic + sage: p.plot() # needs sage.plot sage.symbolic Graphics object consisting of 29 graphics primitives .. PLOT:: @@ -1904,7 +1904,7 @@ def plot(self, angle=None, color='black', base_set_dict=None): :: sage: p = SetPartition([[1,3,4],[2,5]]) - sage: print(p.plot().description()) # optional - sage.plot sage.symbolic + sage: print(p.plot().description()) # needs sage.plot sage.symbolic Point set defined by 1 point(s): [(0.0, 0.0)] Point set defined by 1 point(s): [(1.0, 0.0)] Point set defined by 1 point(s): [(2.0, 0.0)] @@ -1922,7 +1922,7 @@ def plot(self, angle=None, color='black', base_set_dict=None): Arc with center (2.5,-1.5) radii (2.1213203435...,2.1213203435...) angle 0.0 inside the sector (0.785398163397...,2.35619449019...) sage: p = SetPartition([['a','c'],['b','d'],['e']]) - sage: print(p.plot().description()) # optional - sage.plot sage.symbolic + sage: print(p.plot().description()) # needs sage.plot sage.symbolic Point set defined by 1 point(s): [(0.0, 0.0)] Point set defined by 1 point(s): [(1.0, 0.0)] Point set defined by 1 point(s): [(2.0, 0.0)] @@ -1938,7 +1938,7 @@ def plot(self, angle=None, color='black', base_set_dict=None): Arc with center (2.0,-1.0) radii (1.41421356237...,1.41421356237...) angle 0.0 inside the sector (0.785398163397...,2.35619449019...) sage: p = SetPartition([['a','c'],['b','d'],['e']]) - sage: print(p.plot(base_set_dict={'a':0,'b':1,'c':2, # optional - sage.plot sage.symbolic + sage: print(p.plot(base_set_dict={'a':0,'b':1,'c':2, # needs sage.plot sage.symbolic ....: 'd':-2.3,'e':5.4}).description()) Point set defined by 1 point(s): [(-2.3, 0.0)] Point set defined by 1 point(s): [(0.0, 0.0)] @@ -2020,17 +2020,17 @@ class SetPartitions(UniqueRepresentation, Parent): sage: S = [1,2,3,4] sage: SetPartitions(S, 2) Set partitions of {1, 2, 3, 4} with 2 parts - sage: SetPartitions([1,2,3,4], [3,1]).list() + sage: SetPartitions([1,2,3,4], [3,1]).list() # needs sage.graphs sage.rings.finite_rings [{{1}, {2, 3, 4}}, {{1, 2, 3}, {4}}, {{1, 2, 4}, {3}}, {{1, 3, 4}, {2}}] - sage: SetPartitions(7, [3,3,1]).cardinality() + sage: SetPartitions(7, [3,3,1]).cardinality() # needs sage.libs.flint 70 In strings, repeated letters are not considered distinct as of :trac:`14140`:: - sage: SetPartitions('abcde').cardinality() + sage: SetPartitions('abcde').cardinality() # needs sage.libs.flint 52 - sage: SetPartitions('aabcd').cardinality() + sage: SetPartitions('aabcd').cardinality() # needs sage.libs.flint 15 REFERENCES: @@ -2080,13 +2080,13 @@ def __contains__(self, x): sage: S = SetPartitions(4, [2,2]) sage: SA = SetPartitions() - sage: all(sp in SA for sp in S) + sage: all(sp in SA for sp in S) # needs sage.graphs sage.modules sage.rings.finite_rings True - sage: Set([Set([1,2]),Set([3,7])]) in SA + sage: Set([Set([1,2]),Set([3,7])]) in SA # needs sage.graphs True - sage: Set([Set([1,2]),Set([2,3])]) in SA + sage: Set([Set([1,2]),Set([2,3])]) in SA # needs sage.graphs False - sage: Set([]) in SA + sage: Set([]) in SA # needs sage.graphs True """ # x must be a set @@ -2750,13 +2750,13 @@ def __contains__(self, x): TESTS:: sage: S = SetPartitions(4, [2,2]) - sage: all(sp in S for sp in S) + sage: all(sp in S for sp in S) # needs sage.graphs sage.rings.finite_rings True - sage: SetPartition([[1,3],[2,4]]) in SetPartitions(3) + sage: SetPartition([[1,3],[2,4]]) in SetPartitions(3) # needs sage.graphs False - sage: SetPartition([[1,3],[2,4]]) in SetPartitions(4, [3,1]) + sage: SetPartition([[1,3],[2,4]]) in SetPartitions(4, [3,1]) # needs sage.graphs False - sage: SetPartition([[2],[1,3,4]]) in SetPartitions(4, [3,1]) + sage: SetPartition([[2],[1,3,4]]) in SetPartitions(4, [3,1]) # needs sage.graphs True """ # Must pass the general check @@ -2780,16 +2780,16 @@ def random_element(self): EXAMPLES:: sage: S = SetPartitions(10) - sage: s = S.random_element() - sage: s.parent() is S + sage: s = S.random_element() # needs sage.symbolic + sage: s.parent() is S # needs sage.symbolic True - sage: assert s in S, s + sage: assert s in S, s # needs sage.symbolic sage: S = SetPartitions(["a", "b", "c"]) - sage: s = S.random_element() - sage: s.parent() is S + sage: s = S.random_element() # needs sage.symbolic + sage: s.parent() is S # needs sage.symbolic True - sage: assert s in S, s + sage: assert s in S, s # needs sage.symbolic """ base_set = list(self.base_set()) N = len(base_set) @@ -2818,13 +2818,13 @@ def cardinality(self): EXAMPLES:: - sage: SetPartitions([1,2,3,4]).cardinality() + sage: SetPartitions([1,2,3,4]).cardinality() # needs sage.libs.flint 15 - sage: SetPartitions(3).cardinality() + sage: SetPartitions(3).cardinality() # needs sage.libs.flint 5 - sage: SetPartitions(3,2).cardinality() + sage: SetPartitions(3,2).cardinality() # needs sage.libs.flint 3 - sage: SetPartitions([]).cardinality() + sage: SetPartitions([]).cardinality() # needs sage.libs.flint 1 """ return bell_number(len(self._set)) @@ -2905,7 +2905,7 @@ def __init__(self, s, parts): TESTS:: sage: S = SetPartitions(4, [2,2]) - sage: TestSuite(S).run() + sage: TestSuite(S).run() # needs sage.graphs sage.libs.flint """ SetPartitions_set.__init__(self, s) self._parts = parts @@ -2959,7 +2959,8 @@ def cardinality(self): sage: all((len(SetPartitions(size, part)) == SetPartitions(size, part).cardinality() for size in range(8) for part in Partitions(size))) True - sage: sum((SetPartitions(13, p).cardinality() for p in Partitions(13))) == SetPartitions(13).cardinality() + sage: sum((SetPartitions(13, p).cardinality() # needs sage.libs.flint + ....: for p in Partitions(13))) == SetPartitions(13).cardinality() True """ from sage.misc.misc_c import prod @@ -2983,12 +2984,13 @@ def _set_partition_poset(self): TESTS:: - sage: P = SetPartitions(["a", "b", "c", "d", "e"], [2,2,1])._set_partition_poset() - sage: P.cover_relations() + sage: P = SetPartitions(["a", "b", "c", "d", "e"], # needs sage.graphs + ....: [2,2,1])._set_partition_poset() + sage: P.cover_relations() # needs sage.graphs [(1, 2), (1, 3), (3, 4)] sage: n = 9 - sage: all(SetPartitions(n, mu).cardinality() == + sage: all(SetPartitions(n, mu).cardinality() == # needs sage.graphs sage.modules ....: len(list(SetPartitions(n, mu)._set_partition_poset().linear_extensions())) ....: for mu in Partitions(n)) True @@ -3023,16 +3025,17 @@ def __iter__(self): EXAMPLES:: - sage: SetPartitions(3, [2,1]).list() + sage: SetPartitions(3, [2,1]).list() # needs sage.graphs sage.rings.finite_rings [{{1}, {2, 3}}, {{1, 2}, {3}}, {{1, 3}, {2}}] - sage: SetPartitions(["a", "b", "c"], [2,1]).list() + sage: SetPartitions(["a", "b", "c"], [2,1]).list() # needs sage.graphs sage.rings.finite_rings [{{'a'}, {'b', 'c'}}, {{'a', 'b'}, {'c'}}, {{'a', 'c'}, {'b'}}] TESTS:: sage: n = 8 - sage: all(SetPartitions(n, mu).cardinality() == len(list(SetPartitions(n, mu))) for mu in Partitions(n)) + sage: all(SetPartitions(n, mu).cardinality() # needs sage.graphs sage.rings.finite_rings + ....: == len(list(SetPartitions(n, mu))) for mu in Partitions(n)) True """ # Ruskey, Combinatorial Generation, sec. 5.10.1 and Knuth TAOCP 4A 7.2.1.5, Exercise 6 diff --git a/src/sage/combinat/set_partition_iterator.pyx b/src/sage/combinat/set_partition_iterator.pyx index 47667561a71..7c9bc0eaaf5 100644 --- a/src/sage/combinat/set_partition_iterator.pyx +++ b/src/sage/combinat/set_partition_iterator.pyx @@ -31,7 +31,7 @@ def set_partition_iterator(base_set): EXAMPLES:: sage: from sage.combinat.set_partition_iterator import set_partition_iterator - sage: list(set_partition_iterator([1,-1,x])) # optional - sage.symbolic + sage: list(set_partition_iterator([1,-1,x])) # needs sage.symbolic [[[1, -1, x]], [[1, -1], [x]], [[1, x], [-1]], @@ -122,7 +122,7 @@ def set_partition_iterator_blocks(base_set, Py_ssize_t k): EXAMPLES:: sage: from sage.combinat.set_partition_iterator import set_partition_iterator_blocks - sage: list(set_partition_iterator_blocks([1,-1,x], 2)) # optional - sage.symbolic + sage: list(set_partition_iterator_blocks([1,-1,x], 2)) # needs sage.symbolic [[[1, x], [-1]], [[1], [-1, x]], [[1, -1], [x]]] """ cdef list base = list(base_set) diff --git a/src/sage/combinat/sf/elementary.py b/src/sage/combinat/sf/elementary.py index ce9cae6cdc8..f0942314323 100644 --- a/src/sage/combinat/sf/elementary.py +++ b/src/sage/combinat/sf/elementary.py @@ -371,7 +371,7 @@ def principal_specialization(self, n=infinity, q=None): By default, we return a rational functions in `q`. Sometimes it is better to obtain an element of the symbolic ring:: - sage: x.principal_specialization(q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(q=var("q")) # needs sage.symbolic -3*q/((q^2 - 1)*(q - 1)^2) - 5/(q - 1)^3 + 1 TESTS:: @@ -469,7 +469,7 @@ def exponential_specialization(self, t=None, q=1): sage: x.exponential_specialization() 1/12*t^5 sage: x = 5*e[2] + 3*e[1] + 1 - sage: x.exponential_specialization(t=var("t"), q=var("q")) # optional - sage.symbolic + sage: x.exponential_specialization(t=var("t"), q=var("q")) # needs sage.symbolic 5*q*t^2/(q + 1) + 3*t + 1 TESTS:: diff --git a/src/sage/combinat/sf/homogeneous.py b/src/sage/combinat/sf/homogeneous.py index e83dd16861e..29cf294ea80 100644 --- a/src/sage/combinat/sf/homogeneous.py +++ b/src/sage/combinat/sf/homogeneous.py @@ -281,7 +281,7 @@ def principal_specialization(self, n=infinity, q=None): sage: x.principal_specialization(3) q^6 + 2*q^5 + 4*q^4 + 4*q^3 + 4*q^2 + 2*q + 1 sage: x = 3*h[2] + 2*h[1] + 1 - sage: x.principal_specialization(3, q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic 2*(q^3 - 1)/(q - 1) + 3*(q^4 - 1)*(q^3 - 1)/((q^2 - 1)*(q - 1)) + 1 TESTS:: @@ -385,7 +385,7 @@ def exponential_specialization(self, t=None, q=1): We also support the `q`-exponential_specialization:: - sage: factor(h[3].exponential_specialization(q=var("q"), t=var("t"))) # optional - sage.symbolic + sage: factor(h[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic t^3/((q^2 + q + 1)*(q + 1)) TESTS:: diff --git a/src/sage/combinat/sf/monomial.py b/src/sage/combinat/sf/monomial.py index 6c910527fc9..583008830af 100644 --- a/src/sage/combinat/sf/monomial.py +++ b/src/sage/combinat/sf/monomial.py @@ -366,7 +366,7 @@ def principal_specialization(self, n=infinity, q=None): q^7 + q^6 + q^5 + q^3 + q^2 + q sage: x = 5*m[2] + 3*m[1] + 1 - sage: x.principal_specialization(3, q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic -10*(q^3 - 1)*q/(q - 1) + 5*(q^3 - 1)^2/(q - 1)^2 + 3*(q^3 - 1)/(q - 1) + 1 TESTS:: @@ -452,7 +452,7 @@ def exponential_specialization(self, t=None, q=1): We also support the `q`-exponential_specialization:: - sage: factor(m[3].exponential_specialization(q=var("q"), t=var("t"))) # optional - sage.symbolic + sage: factor(m[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic (q - 1)^2*t^3/(q^2 + q + 1) TESTS:: diff --git a/src/sage/combinat/sf/ns_macdonald.py b/src/sage/combinat/sf/ns_macdonald.py index 8807bd95b87..a2340ab5f68 100644 --- a/src/sage/combinat/sf/ns_macdonald.py +++ b/src/sage/combinat/sf/ns_macdonald.py @@ -534,8 +534,8 @@ def coeff(self, q, t): EXAMPLES:: sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]]) - sage: q,t = var('q,t') # optional - sage.symbolic - sage: a.coeff(q,t) # optional - sage.symbolic + sage: q,t = var('q,t') # needs sage.symbolic + sage: a.coeff(q,t) # needs sage.symbolic (t - 1)^4/((q^2*t^3 - 1)^2*(q*t^2 - 1)^2) """ res = 1 @@ -555,8 +555,8 @@ def coeff_integral(self, q, t): EXAMPLES:: sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]]) - sage: q,t = var('q,t') # optional - sage.symbolic - sage: a.coeff_integral(q,t) # optional - sage.symbolic + sage: q,t = var('q,t') # needs sage.symbolic + sage: a.coeff_integral(q,t) # needs sage.symbolic (q^2*t^3 - 1)^2*(q*t^2 - 1)^2*(t - 1)^4 """ res = 1 @@ -807,15 +807,15 @@ def _check_muqt(mu, q, t, pi=None): :: - sage: q,t = var('q,t') # optional - sage.symbolic - sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,None) # optional - sage.symbolic + sage: q,t = var('q,t') # needs sage.symbolic + sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,None) # needs sage.symbolic Traceback (most recent call last): ... ValueError: you must specify either both q and t or neither of them :: - sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,2) # optional - sage.symbolic + sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,2) # needs sage.symbolic Traceback (most recent call last): ... ValueError: the parents of q and t must be the same diff --git a/src/sage/combinat/sf/powersum.py b/src/sage/combinat/sf/powersum.py index bb20adf9941..8d7f744e75f 100644 --- a/src/sage/combinat/sf/powersum.py +++ b/src/sage/combinat/sf/powersum.py @@ -761,11 +761,11 @@ def principal_specialization(self, n=infinity, q=None): sage: p = SymmetricFunctions(QQ).p() sage: x = p[8,7,3,1] - sage: x.principal_specialization(3, q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic (q^24 - 1)*(q^21 - 1)*(q^9 - 1)/((q^8 - 1)*(q^7 - 1)*(q - 1)) sage: x = 5*p[1,1,1] + 3*p[2,1] + 1 - sage: x.principal_specialization(3, q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic 5*(q^3 - 1)^3/(q - 1)^3 + 3*(q^6 - 1)*(q^3 - 1)/((q^2 - 1)*(q - 1)) + 1 By default, we return a rational function in `q`:: @@ -775,7 +775,7 @@ def principal_specialization(self, n=infinity, q=None): If ``n`` is not given we return the stable principal specialization:: - sage: x.principal_specialization(q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(q=var("q")) # needs sage.symbolic 3/((q^2 - 1)*(q - 1)) - 5/(q - 1)^3 + 1 TESTS:: @@ -882,12 +882,12 @@ def exponential_specialization(self, t=None, q=1): sage: x.exponential_specialization() 0 sage: x = p[3] + 5*p[1,1] + 2*p[1] + 1 - sage: x.exponential_specialization(t=var("t")) # optional - sage.symbolic + sage: x.exponential_specialization(t=var("t")) # needs sage.symbolic 5*t^2 + 2*t + 1 We also support the `q`-exponential_specialization:: - sage: factor(p[3].exponential_specialization(q=var("q"), t=var("t"))) # optional - sage.symbolic + sage: factor(p[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic (q - 1)^2*t^3/(q^2 + q + 1) TESTS:: diff --git a/src/sage/combinat/sf/schur.py b/src/sage/combinat/sf/schur.py index e6bb052c408..40e1de75812 100644 --- a/src/sage/combinat/sf/schur.py +++ b/src/sage/combinat/sf/schur.py @@ -664,10 +664,10 @@ def principal_specialization(self, n=infinity, q=None): q^4 + q^3 + 2*q^2 + q + 1 sage: x = 3*s[2,2] + 2*s[1] + 1 - sage: x.principal_specialization(3, q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic 3*(q^4 - 1)*(q^3 - 1)*q^2/((q^2 - 1)*(q - 1)) + 2*(q^3 - 1)/(q - 1) + 1 - sage: x.principal_specialization(q=var("q")) # optional - sage.symbolic + sage: x.principal_specialization(q=var("q")) # needs sage.symbolic -2/(q - 1) + 3*q^2/((q^3 - 1)*(q^2 - 1)^2*(q - 1)) + 1 TESTS:: @@ -808,7 +808,7 @@ def exponential_specialization(self, t=None, q=1): We also support the `q`-exponential_specialization:: - sage: factor(s[3].exponential_specialization(q=var("q"), t=var("t"))) # optional - sage.symbolic + sage: factor(s[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic t^3/((q^2 + q + 1)*(q + 1)) TESTS:: diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py index 3e9ac55bd70..9a5d8fb70a3 100644 --- a/src/sage/combinat/sf/sfa.py +++ b/src/sage/combinat/sf/sfa.py @@ -4916,8 +4916,8 @@ def scalar_qt(self, x, q=None, t=None): -q^3 + 2*q^2 - 2*q + 1 sage: a.scalar_qt(a,5,7) # q=5 and t=7 490/1539 - sage: (x,y) = var('x,y') # optional - sage.symbolic - sage: a.scalar_qt(a, q=x, t=y) # optional - sage.symbolic + sage: (x,y) = var('x,y') # needs sage.symbolic + sage: a.scalar_qt(a, q=x, t=y) # needs sage.symbolic 1/3*(x^3 - 1)/(y^3 - 1) + 2/3*(x - 1)^3/(y - 1)^3 sage: Rn = QQ['q','t','y','z'].fraction_field() sage: (q,t,y,z) = Rn.gens() @@ -6030,7 +6030,7 @@ def principal_specialization(self, n=infinity, q=None): it is better to obtain an element of the symbolic ring:: sage: h = SymmetricFunctions(QQ).h() - sage: (h[3]+h[2]).principal_specialization(q=var("q")) # optional - sage.symbolic + sage: (h[3]+h[2]).principal_specialization(q=var("q")) # needs sage.symbolic 1/((q^2 - 1)*(q - 1)) - 1/((q^3 - 1)*(q^2 - 1)*(q - 1)) In case ``q`` is in the base ring, it must be passed explicitly:: @@ -6291,11 +6291,11 @@ def exponential_specialization(self, t=None, q=1): sage: x = m[3]+m[2,1]+m[1,1,1] sage: d = x.homogeneous_degree() - sage: var("q t") # optional - sage.symbolic + sage: var("q t") # needs sage.symbolic (q, t) - sage: factor((x.principal_specialization()*(1-q)^d*t^d)) # optional - sage.symbolic + sage: factor((x.principal_specialization()*(1-q)^d*t^d)) # needs sage.symbolic t^3/((q^2 + q + 1)*(q + 1)) - sage: factor(x.exponential_specialization(q=q, t=t)) # optional - sage.symbolic + sage: factor(x.exponential_specialization(q=q, t=t)) # needs sage.symbolic t^3/((q^2 + q + 1)*(q + 1)) TESTS:: diff --git a/src/sage/combinat/shuffle.py b/src/sage/combinat/shuffle.py index 8bae3eda267..50618a6388f 100644 --- a/src/sage/combinat/shuffle.py +++ b/src/sage/combinat/shuffle.py @@ -254,7 +254,7 @@ def _ascii_art_(self): TESTS:: sage: from sage.combinat.shuffle import SetShuffleProduct - sage: ascii_art(SetShuffleProduct([[BinaryTree()], [BinaryTree([]), BinaryTree([[],[]])]], + sage: ascii_art(SetShuffleProduct([[BinaryTree()], [BinaryTree([]), BinaryTree([[],[]])]], # needs sage.graphs ....: [[1,4]])) Set shuffle product of: [ [ o, o ] ] @@ -376,8 +376,8 @@ def _repr_(self): sage: from sage.combinat.shuffle import ShuffleProduct sage: ShuffleProduct([1,2,3],[4,5]) Shuffle product of: [1, 2, 3] and [4, 5] - sage: B = BinaryTree - sage: ShuffleProduct([B(), B([[],[]])], []) + sage: B = BinaryTree # needs sage.graphs + sage: ShuffleProduct([B(), B([[],[]])], []) # needs sage.graphs Shuffle product of: [., [[., .], [., .]]] and [] """ return "Shuffle product of: %s and %s" % (self._l1, self._l2) @@ -390,8 +390,8 @@ def _ascii_art_(self): sage: ascii_art(ShuffleProduct([1,2,3],[4,5])) Shuffle product of: [ 1, 2, 3 ] and [ 4, 5 ] - sage: B = BinaryTree - sage: ascii_art(ShuffleProduct([B([]), B([[],[]])], + sage: B = BinaryTree # needs sage.graphs + sage: ascii_art(ShuffleProduct([B([]), B([[],[]])], # needs sage.graphs ....: [B([[[],[]],[[],None]])])) Shuffle product of: [ __o__ ] @@ -417,8 +417,8 @@ def __iter__(self): sage: list(ShuffleProduct([1,2,3],[4,5])) [[1, 2, 3, 4, 5], [1, 4, 2, 3, 5], [4, 1, 2, 3, 5], [1, 2, 4, 3, 5], [1, 4, 5, 2, 3], [4, 1, 5, 2, 3], [4, 5, 1, 2, 3], [1, 4, 2, 5, 3], [4, 1, 2, 5, 3], [1, 2, 4, 5, 3]] - sage: B = BinaryTree - sage: ascii_art(list(ShuffleProduct([B([]), B([[],[]])], + sage: B = BinaryTree # needs sage.graphs + sage: ascii_art(list(ShuffleProduct([B([]), B([[],[]])], # needs sage.graphs ....: [B([[[],[]],[[],None]])]))) [ [ o, o , __o__ ] [ __o__ , o, o ] [ [ / \ / \ ] [ / \ / \ ] diff --git a/src/sage/combinat/sine_gordon.py b/src/sage/combinat/sine_gordon.py index e98c393ea08..209acd4486e 100644 --- a/src/sage/combinat/sine_gordon.py +++ b/src/sage/combinat/sine_gordon.py @@ -463,7 +463,7 @@ def plot(self, **kwds): EXAMPLES:: sage: Y = SineGordonYsystem('A',(6,4,3)) - sage: Y.plot() # long time 2s + sage: Y.plot() # long time (2s) # needs sage.plot Graphics object consisting of 219 graphics primitives """ # Set up plotting options diff --git a/src/sage/combinat/six_vertex_model.py b/src/sage/combinat/six_vertex_model.py index cec485f23c7..11b3267eb61 100644 --- a/src/sage/combinat/six_vertex_model.py +++ b/src/sage/combinat/six_vertex_model.py @@ -111,7 +111,7 @@ def to_signed_matrix(self): EXAMPLES:: sage: M = SixVertexModel(3, boundary_conditions='ice') - sage: [x.to_signed_matrix() for x in M] + sage: [x.to_signed_matrix() for x in M] # needs sage.modules [ [1 0 0] [1 0 0] [ 0 1 0] [0 1 0] [0 1 0] [0 0 1] [0 0 1] [0 1 0] [0 0 1] [ 1 -1 1] [1 0 0] [0 0 1] [1 0 0] [0 1 0] @@ -149,7 +149,7 @@ def plot(self, color='sign'): EXAMPLES:: sage: M = SixVertexModel(2, boundary_conditions='ice') - sage: print(M[0].plot().description()) # optional - sage.plot + sage: print(M[0].plot().description()) # needs sage.plot Arrow from (-1.0,0.0) to (0.0,0.0) Arrow from (-1.0,1.0) to (0.0,1.0) Arrow from (0.0,0.0) to (0.0,-1.0) @@ -392,7 +392,7 @@ class SixVertexModel(UniqueRepresentation, Parent): sage: M = SixVertexModel(4, boundary_conditions='ice') sage: len(M) 42 - sage: all(len(SixVertexModel(n, boundary_conditions='ice')) + sage: all(len(SixVertexModel(n, boundary_conditions='ice')) # needs sage.modules ....: == AlternatingSignMatrices(n).cardinality() for n in range(1, 7)) True @@ -650,7 +650,7 @@ def partition_function(self, beta, epsilon): EXAMPLES:: sage: M = SixVertexModel(3, boundary_conditions='ice') - sage: M.partition_function(2, [1,2,1,2,1,2]) # optional - sage.symbolic + sage: M.partition_function(2, [1,2,1,2,1,2]) # needs sage.symbolic e^(-24) + 2*e^(-28) + e^(-30) + 2*e^(-32) + e^(-36) REFERENCES: @@ -693,8 +693,8 @@ def from_alternating_sign_matrix(self, asm): EXAMPLES:: sage: M = SixVertexModel(3, boundary_conditions='ice') - sage: asm = AlternatingSignMatrix([[0,1,0],[1,-1,1],[0,1,0]]) - sage: M.from_alternating_sign_matrix(asm) + sage: asm = AlternatingSignMatrix([[0,1,0],[1,-1,1],[0,1,0]]) # needs sage.modules + sage: M.from_alternating_sign_matrix(asm) # needs sage.modules ^ ^ ^ | | | --> # -> # <- # <-- @@ -710,11 +710,11 @@ def from_alternating_sign_matrix(self, asm): TESTS:: sage: M = SixVertexModel(5, boundary_conditions='ice') - sage: ASM = AlternatingSignMatrices(5) - sage: all(M.from_alternating_sign_matrix(x.to_alternating_sign_matrix()) == x + sage: ASM = AlternatingSignMatrices(5) # needs sage.modules + sage: all(M.from_alternating_sign_matrix(x.to_alternating_sign_matrix()) == x # needs sage.modules ....: for x in M) True - sage: all(M.from_alternating_sign_matrix(x).to_alternating_sign_matrix() == x + sage: all(M.from_alternating_sign_matrix(x).to_alternating_sign_matrix() == x # needs sage.modules ....: for x in ASM) True """ @@ -766,12 +766,12 @@ def to_alternating_sign_matrix(self): EXAMPLES:: sage: M = SixVertexModel(4, boundary_conditions='ice') - sage: M[6].to_alternating_sign_matrix() + sage: M[6].to_alternating_sign_matrix() # needs sage.modules [1 0 0 0] [0 0 0 1] [0 0 1 0] [0 1 0 0] - sage: M[7].to_alternating_sign_matrix() + sage: M[7].to_alternating_sign_matrix() # needs sage.modules [ 0 1 0 0] [ 1 -1 1 0] [ 0 1 -1 1] diff --git a/src/sage/combinat/skew_partition.py b/src/sage/combinat/skew_partition.py index 4c2239fd6a1..a5959214243 100644 --- a/src/sage/combinat/skew_partition.py +++ b/src/sage/combinat/skew_partition.py @@ -108,7 +108,7 @@ :: - sage: SkewPartition([[4,3,1],[2]]).jacobi_trudi() + sage: SkewPartition([[4,3,1],[2]]).jacobi_trudi() # needs sage.modules [h[2] h[] 0] [h[5] h[3] h[]] [h[6] h[4] h[1]] @@ -845,41 +845,41 @@ def cell_poset(self, orientation="SE"): EXAMPLES:: sage: p = SkewPartition([[3,3,1], [2,1]]) - sage: Q = p.cell_poset(); Q + sage: Q = p.cell_poset(); Q # needs sage.graphs Finite poset containing 4 elements - sage: sorted(Q) + sage: sorted(Q) # needs sage.graphs [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: sorted(Q.maximal_elements()) + sage: sorted(Q.maximal_elements()) # needs sage.graphs [(1, 2), (2, 0)] - sage: sorted(Q.minimal_elements()) + sage: sorted(Q.minimal_elements()) # needs sage.graphs [(0, 2), (1, 1), (2, 0)] - sage: sorted(Q.upper_covers((1, 1))) + sage: sorted(Q.upper_covers((1, 1))) # needs sage.graphs [(1, 2)] - sage: sorted(Q.upper_covers((0, 2))) + sage: sorted(Q.upper_covers((0, 2))) # needs sage.graphs [(1, 2)] - sage: P = p.cell_poset(orientation="NW"); P + sage: P = p.cell_poset(orientation="NW"); P # needs sage.graphs Finite poset containing 4 elements - sage: sorted(P) + sage: sorted(P) # needs sage.graphs [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: sorted(P.minimal_elements()) + sage: sorted(P.minimal_elements()) # needs sage.graphs [(1, 2), (2, 0)] - sage: sorted(P.maximal_elements()) + sage: sorted(P.maximal_elements()) # needs sage.graphs [(0, 2), (1, 1), (2, 0)] - sage: sorted(P.upper_covers((1, 2))) + sage: sorted(P.upper_covers((1, 2))) # needs sage.graphs [(0, 2), (1, 1)] - sage: R = p.cell_poset(orientation="NE"); R + sage: R = p.cell_poset(orientation="NE"); R # needs sage.graphs Finite poset containing 4 elements - sage: sorted(R) + sage: sorted(R) # needs sage.graphs [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: R.maximal_elements() + sage: R.maximal_elements() # needs sage.graphs [(0, 2)] - sage: R.minimal_elements() + sage: R.minimal_elements() # needs sage.graphs [(2, 0)] - sage: R.upper_covers((2, 0)) + sage: R.upper_covers((2, 0)) # needs sage.graphs [(1, 1)] - sage: sorted([len(R.upper_covers(v)) for v in R]) + sage: sorted([len(R.upper_covers(v)) for v in R]) # needs sage.graphs [0, 1, 1, 1] TESTS: @@ -896,7 +896,7 @@ def cell_poset(self, orientation="SE"): ....: and c[1] >= d[1]): ....: return False ....: return True - sage: all( check_NW(n) for n in range(7) ) + sage: all( check_NW(n) for n in range(7) ) # needs sage.graphs True sage: def check_NE(n): @@ -908,7 +908,7 @@ def cell_poset(self, orientation="SE"): ....: and c[1] <= d[1]): ....: return False ....: return True - sage: all( check_NE(n) for n in range(7) ) + sage: all( check_NE(n) for n in range(7) ) # needs sage.graphs True sage: def test_duality(n, ori1, ori2): @@ -920,11 +920,11 @@ def cell_poset(self, orientation="SE"): ....: if P.lt(c, d) != Q.lt(d, c): ....: return False ....: return True - sage: all( test_duality(n, "NW", "SE") for n in range(7) ) + sage: all( test_duality(n, "NW", "SE") for n in range(7) ) # needs sage.graphs True - sage: all( test_duality(n, "NE", "SW") for n in range(7) ) + sage: all( test_duality(n, "NE", "SW") for n in range(7) ) # needs sage.graphs True - sage: all( test_duality(n, "NE", "SE") for n in range(4) ) + sage: all( test_duality(n, "NE", "SE") for n in range(4) ) # needs sage.graphs False """ from sage.combinat.posets.posets import Poset @@ -1068,18 +1068,18 @@ def to_dag(self, format="string"): EXAMPLES:: - sage: dag = SkewPartition([[3, 3, 1], [1, 1]]).to_dag() # optional - sage.graphs - sage: dag.edges(sort=True) # optional - sage.graphs + sage: dag = SkewPartition([[3, 3, 1], [1, 1]]).to_dag() # needs sage.graphs + sage: dag.edges(sort=True) # needs sage.graphs [('0,1', '0,2', None), ('0,1', '1,1', None), ('0,2', '1,2', None), ('1,1', '1,2', None)] - sage: dag.vertices(sort=True) # optional - sage.graphs + sage: dag.vertices(sort=True) # needs sage.graphs ['0,1', '0,2', '1,1', '1,2', '2,0'] - sage: dag = SkewPartition([[3, 2, 1], [1, 1]]).to_dag(format="tuple") # optional - sage.graphs - sage: dag.edges(sort=True) # optional - sage.graphs + sage: dag = SkewPartition([[3, 2, 1], [1, 1]]).to_dag(format="tuple") # needs sage.graphs + sage: dag.edges(sort=True) # needs sage.graphs [((0, 1), (0, 2), None), ((0, 1), (1, 1), None)] - sage: dag.vertices(sort=True) # optional - sage.graphs + sage: dag.vertices(sort=True) # needs sage.graphs [(0, 1), (0, 2), (1, 1), (2, 0)] """ outer = list(self.outer()) @@ -1216,11 +1216,11 @@ def jacobi_trudi(self): EXAMPLES:: - sage: SkewPartition([[3,2,1],[2,1]]).jacobi_trudi() + sage: SkewPartition([[3,2,1],[2,1]]).jacobi_trudi() # needs sage.modules [h[1] 0 0] [h[3] h[1] 0] [h[5] h[3] h[1]] - sage: SkewPartition([[4,3,2],[2,1]]).jacobi_trudi() + sage: SkewPartition([[4,3,2],[2,1]]).jacobi_trudi() # needs sage.modules [h[2] h[] 0] [h[4] h[2] h[]] [h[6] h[4] h[2]] @@ -1282,24 +1282,24 @@ def specht_module(self, base_ring=None): EXAMPLES:: sage: mu = SkewPartition([[3,2,1], [2]]) - sage: SM = mu.specht_module(QQ) - sage: s = SymmetricFunctions(QQ).s() - sage: s(SM.frobenius_image()) + sage: SM = mu.specht_module(QQ) # needs sage.modules + sage: s = SymmetricFunctions(QQ).s() # needs sage.modules + sage: s(SM.frobenius_image()) # needs sage.modules s[2, 1, 1] + s[2, 2] + s[3, 1] We verify that the Frobenius image is the corresponding skew Schur function:: - sage: s[3,2,1].skew_by(s[2]) + sage: s[3,2,1].skew_by(s[2]) # needs sage.modules s[2, 1, 1] + s[2, 2] + s[3, 1] :: sage: mu = SkewPartition([[4,2,1], [2,1]]) - sage: SM = mu.specht_module(QQ) - sage: s(SM.frobenius_image()) + sage: SM = mu.specht_module(QQ) # needs sage.modules + sage: s(SM.frobenius_image()) # needs sage.modules s[2, 1, 1] + s[2, 2] + 2*s[3, 1] + s[4] - sage: s(mu) + sage: s(mu) # needs sage.modules s[2, 1, 1] + s[2, 2] + 2*s[3, 1] + s[4] """ from sage.combinat.specht_module import SpechtModule @@ -1320,9 +1320,9 @@ def specht_module_dimension(self, base_ring=None): EXAMPLES:: sage: mu = SkewPartition([[3,2,1], [2]]) - sage: mu.specht_module_dimension() + sage: mu.specht_module_dimension() # needs sage.modules 8 - sage: mu.specht_module_dimension(GF(2)) + sage: mu.specht_module_dimension(GF(2)) # needs sage.modules sage.rings.finite_rings 8 """ from sage.categories.fields import Fields diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index 3c5282eae8e..43ae3fa5db6 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -605,7 +605,7 @@ def weight(self): sage: by_word(t) == t.weight() True sage: SST = SemistandardTableaux(shape=[3,1,1]) - sage: all(by_word(t) == SkewTableau(t).weight() for t in SST) + sage: all(by_word(t) == SkewTableau(t).weight() for t in SST) # needs sage.modules True """ if (not self) or all(c is None for row in self for c in row): @@ -1288,8 +1288,9 @@ def standardization(self, check=True): Standard skew tableaux are fixed under standardization:: sage: p = Partition([4,3,3,2]) - sage: q = Partitions(3).random_element() - sage: all((t == t.standardization() for t in StandardSkewTableaux([p, q]))) + sage: q = Partitions(3).random_element() # needs sage.libs.flint + sage: all(t == t.standardization() # needs sage.libs.flint + ....: for t in StandardSkewTableaux([p, q])) True The reading word of the standardization is the @@ -1951,12 +1952,12 @@ class StandardSkewTableaux(SkewTableaux): sage: S = StandardSkewTableaux(2); S Standard skew tableaux of size 2 - sage: S.cardinality() # optional - sage.modules + sage: S.cardinality() # needs sage.modules 4 :: - sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() + sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() # needs sage.graphs sage.rings.finite_rings [[[None, 2, 3], [None, 4], [1]], [[None, 1, 2], [None, 3], [4]], [[None, 1, 2], [None, 4], [3]], @@ -2016,7 +2017,7 @@ def __init__(self): EXAMPLES:: sage: s = StandardSkewTableaux() - sage: TestSuite(s).run() # optional - sage.graphs + sage: TestSuite(s).run() # needs sage.graphs sage.rings.finite_rings """ StandardSkewTableaux.__init__(self, category=InfiniteEnumeratedSets()) @@ -2038,7 +2039,7 @@ def __iter__(self): EXAMPLES:: sage: it = StandardSkewTableaux().__iter__() - sage: [next(it) for x in range(10)] # optional - sage.graphs + sage: [next(it) for x in range(10)] # needs sage.graphs sage.modules sage.rings.finite_rings [[], [[1]], [[1, 2]], [[1], [2]], [[None, 2], [1]], [[None, 1], [2]], @@ -2061,7 +2062,7 @@ def __init__(self, n): EXAMPLES:: sage: S = StandardSkewTableaux(3) - sage: TestSuite(S).run() # optional - sage.graphs + sage: TestSuite(S).run() # needs sage.graphs sage.modules sage.rings.finite_rings """ self.n = n StandardSkewTableaux.__init__(self, category=FiniteEnumeratedSets()) @@ -2079,13 +2080,13 @@ def cardinality(self): """ EXAMPLES:: - sage: StandardSkewTableaux(1).cardinality() # optional - sage.modules + sage: StandardSkewTableaux(1).cardinality() # needs sage.modules 1 - sage: StandardSkewTableaux(2).cardinality() # optional - sage.modules + sage: StandardSkewTableaux(2).cardinality() # needs sage.modules 4 - sage: StandardSkewTableaux(3).cardinality() # optional - sage.modules + sage: StandardSkewTableaux(3).cardinality() # needs sage.modules 24 - sage: StandardSkewTableaux(4).cardinality() # optional - sage.modules + sage: StandardSkewTableaux(4).cardinality() # needs sage.modules 194 """ count = 0 @@ -2102,10 +2103,10 @@ def __iter__(self): EXAMPLES:: - sage: StandardSkewTableaux(2).list() # optional - sage.graphs + sage: StandardSkewTableaux(2).list() # needs sage.graphs sage.modules sage.rings.finite_rings [[[1, 2]], [[1], [2]], [[None, 2], [1]], [[None, 1], [2]]] - sage: StandardSkewTableaux(3).list() # optional - sage.graphs + sage: StandardSkewTableaux(3).list() # needs sage.graphs sage.modules sage.rings.finite_rings [[[1, 2, 3]], [[1, 2], [3]], [[1, 3], [2]], [[None, 2, 3], [1]], [[None, 1, 2], [3]], [[None, 1, 3], [2]], @@ -2150,7 +2151,7 @@ def __init__(self, skp): TESTS:: sage: S = StandardSkewTableaux([[3, 2, 1], [1, 1]]) - sage: TestSuite(S).run() # optional - sage.graphs sage.modules + sage: TestSuite(S).run() # needs sage.graphs sage.modules """ self.skp = skp StandardSkewTableaux.__init__(self, category=FiniteEnumeratedSets()) @@ -2174,7 +2175,7 @@ def cardinality(self): EXAMPLES:: - sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).cardinality() # optional - sage.modules + sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).cardinality() # needs sage.modules 8 """ outer, inner = self.skp @@ -2201,7 +2202,7 @@ def __iter__(self): EXAMPLES:: - sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() # optional - sage.graphs + sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() # needs sage.graphs sage.modules sage.rings.finite_rings [[[None, 2, 3], [None, 4], [1]], [[None, 1, 2], [None, 3], [4]], [[None, 1, 2], [None, 4], [3]], diff --git a/src/sage/combinat/subsets_hereditary.py b/src/sage/combinat/subsets_hereditary.py index 7a9e238679c..e40f66178c6 100644 --- a/src/sage/combinat/subsets_hereditary.py +++ b/src/sage/combinat/subsets_hereditary.py @@ -73,22 +73,22 @@ def subsets_with_hereditary_property(f, X, max_obstruction_size=None, ncpus=1): number of calls to `f` from 91 to 56:: sage: num_calls = 0 - sage: g = graphs.PetersenGraph() # optional - sage.graphs + sage: g = graphs.PetersenGraph() # needs sage.graphs sage: def is_independent_set(S): ....: global num_calls ....: num_calls += 1 ....: return g.subgraph(S).size() == 0 - sage: l1 = list(subsets_with_hereditary_property(is_independent_set, # optional - sage.graphs + sage: l1 = list(subsets_with_hereditary_property(is_independent_set, # needs sage.graphs ....: g.vertices(sort=False))) - sage: num_calls # optional - sage.graphs + sage: num_calls # needs sage.graphs 91 sage: num_calls = 0 - sage: l2 = list(subsets_with_hereditary_property(is_independent_set, # optional - sage.graphs + sage: l2 = list(subsets_with_hereditary_property(is_independent_set, # needs sage.graphs ....: g.vertices(sort=False), ....: max_obstruction_size=2)) - sage: num_calls # optional - sage.graphs + sage: num_calls # needs sage.graphs 56 - sage: l1 == l2 # optional - sage.graphs + sage: l1 == l2 # needs sage.graphs True TESTS:: diff --git a/src/sage/combinat/subword_complex.py b/src/sage/combinat/subword_complex.py index 1a1b05dbf17..a3ae554fd85 100644 --- a/src/sage/combinat/subword_complex.py +++ b/src/sage/combinat/subword_complex.py @@ -84,13 +84,13 @@ sage: W = CoxeterGroup(['A',3]); I = list(W.index_set()) sage: Q = I + W.w0.coxeter_sorting_word(I) sage: S = SubwordComplex(Q,W.w0) - sage: S.brick_polytope() # optional - sage.geometry.polyhedron + sage: S.brick_polytope() # needs sage.geometry.polyhedron A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 14 vertices sage: W = CoxeterGroup(['H',3]); I = list(W.index_set()) sage: Q = I + W.w0.coxeter_sorting_word(I) sage: S = SubwordComplex(Q,W.w0) - sage: S.brick_polytope() # optional - sage.geometry.polyhedron + sage: S.brick_polytope() # needs sage.geometry.polyhedron doctest:...: RuntimeWarning: the polytope is built with rational vertices A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices @@ -755,20 +755,20 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14, sage: W = ReflectionGroup(['A',2]) # optional - gap3 sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F.plot() # optional - gap3 sage.plot + sage: F = SC([1,2]); F.plot() # optional - gap3, needs sage.plot Graphics object consisting of 26 graphics primitives sage: W = CoxeterGroup(['A',2]) sage: w = W.from_reduced_word([1,2,1]) sage: SC = SubwordComplex([1,2,1,2,1],w) - sage: F = SC([1,2]); F.plot() # optional - sage.plot + sage: F = SC([1,2]); F.plot() # needs sage.plot Graphics object consisting of 26 graphics primitives sage: W = ReflectionGroup(['B',3]) # optional - gap3 sage: c = W.from_reduced_word([1,2,3]) # optional - gap3 sage: Q = c.reduced_word()*2 + W.w0.coxeter_sorting_word(c) # optional - gap3 sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 - sage: F = SC[15]; F.plot() # optional - gap3 sage.plot + sage: F = SC[15]; F.plot() # optional - gap3, needs sage.plot Graphics object consisting of 53 graphics primitives TESTS:: @@ -777,7 +777,7 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14, sage: c = W.from_reduced_word([1,2,3,4]) # optional - gap3 sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) # optional - gap3 sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 - sage: F = SC[1]; F.plot() # optional - gap3 sage.plot + sage: F = SC[1]; F.plot() # optional - gap3, needs sage.plot Traceback (most recent call last): ... ValueError: plotting is currently only implemented for irreducibles types A, B, and C. @@ -786,7 +786,7 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14, sage: c = W.from_reduced_word([1,2,3,4]) sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) sage: SC = SubwordComplex(Q, W.w0) - sage: F = SC[1]; F.plot() # optional - sage.plot + sage: F = SC[1]; F.plot() # needs sage.plot Traceback (most recent call last): ... ValueError: plotting is currently only implemented for irreducibles types A, B, and C. diff --git a/src/sage/combinat/symmetric_group_representations.py b/src/sage/combinat/symmetric_group_representations.py index a684702119c..1591768c494 100644 --- a/src/sage/combinat/symmetric_group_representations.py +++ b/src/sage/combinat/symmetric_group_representations.py @@ -76,28 +76,28 @@ def SymmetricGroupRepresentation(partition, implementation="specht", :: - sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal"); orth # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal"); orth # needs sage.symbolic Orthogonal representation of the symmetric group corresponding to [2, 1] - sage: all(a*a.transpose() == a.parent().identity_matrix() for a in orth) # optional - sage.symbolic + sage: all(a*a.transpose() == a.parent().identity_matrix() for a in orth) # needs sage.symbolic True :: - sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal"); orth # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal"); orth # needs sage.symbolic Orthogonal representation of the symmetric group corresponding to [3, 2] - sage: orth([2,1,3,4,5]) # optional - sage.symbolic + sage: orth([2,1,3,4,5]) # needs sage.symbolic [ 1 0 0 0 0] [ 0 1 0 0 0] [ 0 0 -1 0 0] [ 0 0 0 1 0] [ 0 0 0 0 -1] - sage: orth([1,3,2,4,5]) # optional - sage.symbolic + sage: orth([1,3,2,4,5]) # needs sage.symbolic [ 1 0 0 0 0] [ 0 -1/2 1/2*sqrt(3) 0 0] [ 0 1/2*sqrt(3) 1/2 0 0] [ 0 0 0 -1/2 1/2*sqrt(3)] [ 0 0 0 1/2*sqrt(3) 1/2] - sage: orth([1,2,4,3,5]) # optional - sage.symbolic + sage: orth([1,2,4,3,5]) # needs sage.symbolic [ -1/3 2/3*sqrt(2) 0 0 0] [2/3*sqrt(2) 1/3 0 0 0] [ 0 0 1 0 0] @@ -201,13 +201,13 @@ def SymmetricGroupRepresentations(n, implementation="specht", ring=None, :: - sage: orth = SymmetricGroupRepresentations(3, "orthogonal"); orth # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentations(3, "orthogonal"); orth # needs sage.symbolic Orthogonal representations of the symmetric group of order 3! over Symbolic Ring - sage: orth.list() # optional - sage.symbolic + sage: orth.list() # needs sage.symbolic [Orthogonal representation of the symmetric group corresponding to [3], Orthogonal representation of the symmetric group corresponding to [2, 1], Orthogonal representation of the symmetric group corresponding to [1, 1, 1]] - sage: orth([2,1])([1,2,3]) # optional - sage.symbolic + sage: orth([2,1])([1,2,3]) # needs sage.symbolic [1 0] [0 1] @@ -517,8 +517,8 @@ def __iter__(self): EXAMPLES:: - sage: orth = SymmetricGroupRepresentations(3, "orthogonal") # optional - sage.symbolic - sage: for x in orth: print(x) # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentations(3, "orthogonal") # needs sage.symbolic + sage: for x in orth: print(x) # needs sage.symbolic Orthogonal representation of the symmetric group corresponding to [3] Orthogonal representation of the symmetric group corresponding to [2, 1] Orthogonal representation of the symmetric group corresponding to [1, 1, 1] @@ -541,8 +541,8 @@ def _yang_baxter_graph(self): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # optional - sage.symbolic - sage: orth._yang_baxter_graph # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # needs sage.symbolic + sage: orth._yang_baxter_graph # needs sage.symbolic Yang-Baxter graph of [3, 2], with top vertex (0, -1, 2, 1, 0) """ Y = YangBaxterGraph_partition(self._partition) @@ -566,8 +566,8 @@ def _tableau_dict(self): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # optional - sage.symbolic - sage: orth._tableau_dict # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # needs sage.symbolic + sage: orth._tableau_dict # needs sage.symbolic {(0, -1, 2, 1, 0): [[1, 2, 3], [4, 5]], (0, 2, -1, 1, 0): [[1, 2, 4], [3, 5]], (0, 2, 1, -1, 0): [[1, 3, 4], [2, 5]], @@ -592,8 +592,8 @@ def _word_dict(self): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # optional - sage.symbolic - sage: orth._word_dict # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal") # needs sage.symbolic + sage: orth._word_dict # needs sage.symbolic {(0, -1, 2, 1, 0): (4, 5, 1, 2, 3), (0, 2, -1, 1, 0): (3, 5, 1, 2, 4), (0, 2, 1, -1, 0): (2, 5, 1, 3, 4), @@ -611,11 +611,11 @@ def representation_matrix_for_simple_transposition(self, i): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # optional - sage.symbolic - sage: orth.representation_matrix_for_simple_transposition(1) # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # needs sage.symbolic + sage: orth.representation_matrix_for_simple_transposition(1) # needs sage.symbolic [ 1 0] [ 0 -1] - sage: orth.representation_matrix_for_simple_transposition(2) # optional - sage.symbolic + sage: orth.representation_matrix_for_simple_transposition(2) # needs sage.symbolic [ -1/2 1/2*sqrt(3)] [1/2*sqrt(3) 1/2] @@ -664,11 +664,11 @@ def _representation_matrix_uncached(self, permutation): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # optional - sage.symbolic - sage: orth._representation_matrix_uncached(Permutation([2,1,3])) # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # needs sage.symbolic + sage: orth._representation_matrix_uncached(Permutation([2,1,3])) # needs sage.symbolic [ 1 0] [ 0 -1] - sage: orth._representation_matrix_uncached(Permutation([1,3,2])) # optional - sage.symbolic + sage: orth._representation_matrix_uncached(Permutation([1,3,2])) # needs sage.symbolic [ -1/2 1/2*sqrt(3)] [1/2*sqrt(3) 1/2] @@ -697,11 +697,11 @@ def representation_matrix(self, permutation): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # optional - sage.symbolic - sage: orth.representation_matrix(Permutation([2,1,3])) # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # needs sage.symbolic + sage: orth.representation_matrix(Permutation([2,1,3])) # needs sage.symbolic [ 1 0] [ 0 -1] - sage: orth.representation_matrix(Permutation([1,3,2])) # optional - sage.symbolic + sage: orth.representation_matrix(Permutation([1,3,2])) # needs sage.symbolic [ -1/2 1/2*sqrt(3)] [1/2*sqrt(3) 1/2] @@ -780,7 +780,7 @@ def _repr_(self): EXAMPLES:: - sage: SymmetricGroupRepresentation([2,1], "orthogonal") # optional - sage.symbolic + sage: SymmetricGroupRepresentation([2,1], "orthogonal") # needs sage.symbolic Orthogonal representation of the symmetric group corresponding to [2, 1] """ return "Orthogonal representation of the symmetric group corresponding to {}".format(self._partition) @@ -797,8 +797,8 @@ def _2x2_matrix_entries(self, beta): EXAMPLES:: - sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # optional - sage.symbolic - sage: orth._2x2_matrix_entries(1/2) # optional - sage.symbolic + sage: orth = SymmetricGroupRepresentation([2,1], "orthogonal") # needs sage.symbolic + sage: orth._2x2_matrix_entries(1/2) # needs sage.symbolic (-1/2, 1/2*sqrt(3), 1/2*sqrt(3), 1/2) """ return (-beta, sqrt(1 - beta**2), sqrt(1 - beta**2), beta) @@ -816,7 +816,7 @@ def _repr_(self): EXAMPLES:: sage: from sage.combinat.symmetric_group_representations import YoungRepresentations_Orthogonal - sage: YoungRepresentations_Orthogonal(3) # optional - sage.symbolic + sage: YoungRepresentations_Orthogonal(3) # needs sage.symbolic Orthogonal representations of the symmetric group of order 3! over Symbolic Ring """ return "Orthogonal representations of the symmetric group of order %s! over %s" % (self._n, self._ring) diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index f7e58a15c20..1477b00e6b8 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -1006,15 +1006,15 @@ def plot(self, descents=False): EXAMPLES:: sage: t = Tableau([[1,2,4],[3]]) - sage: t.plot() # optional - sage.plot + sage: t.plot() # needs sage.plot Graphics object consisting of 11 graphics primitives - sage: t.plot(descents=True) # optional - sage.plot + sage: t.plot(descents=True) # needs sage.plot Graphics object consisting of 12 graphics primitives sage: t = Tableau([[2,2,4],[3]]) - sage: t.plot() # optional - sage.plot + sage: t.plot() # needs sage.plot Graphics object consisting of 11 graphics primitives - sage: t.plot(descents=True) # optional - sage.plot + sage: t.plot(descents=True) # needs sage.plot Traceback (most recent call last): ... ValueError: the tableau must be standard for 'descents=True' @@ -1276,19 +1276,19 @@ def to_sign_matrix(self, max_entry=None): EXAMPLES:: sage: t = SemistandardTableau([[1,1,1,2,4],[3,3,4],[4,5],[6,6]]) - sage: t.to_sign_matrix(6) # optional - sage.modules + sage: t.to_sign_matrix(6) # needs sage.modules [ 0 0 0 1 0 0] [ 0 1 0 -1 0 0] [ 1 -1 0 1 0 0] [ 0 0 1 -1 1 1] [ 0 0 0 1 -1 0] sage: t = Tableau([[1,2,4],[3,5]]) - sage: t.to_sign_matrix(7) # optional - sage.modules + sage: t.to_sign_matrix(7) # needs sage.modules [ 0 0 0 1 0 0 0] [ 0 1 0 -1 1 0 0] [ 1 -1 1 0 -1 0 0] sage: t = Tableau([(4,5,4,3),(2,1,3)]) - sage: t.to_sign_matrix(5) # optional - sage.modules + sage: t.to_sign_matrix(5) # needs sage.modules [ 0 0 1 0 0] [ 0 0 0 1 0] [ 1 0 -1 -1 1] @@ -1558,24 +1558,29 @@ def bender_knuth_involution(self, k, rows=None, check=True): The Bender--Knuth involution is an involution:: sage: T = SemistandardTableaux(shape=[3,1,1], max_entry=4) - sage: all(all(t.bender_knuth_involution(k).bender_knuth_involution(k) == t for k in range(1,5)) for t in T) + sage: all(t.bender_knuth_involution(k).bender_knuth_involution(k) == t # needs sage.modules + ....: for k in range(1, 5) for t in T) True The same holds for the single switches:: - sage: all(all(t.bender_knuth_involution(k, j).bender_knuth_involution(k, j) == t for k in range(1,5) for j in range(1, 5)) for t in T) + sage: all(t.bender_knuth_involution(k, j).bender_knuth_involution(k, j) == t # needs sage.modules + ....: for k in range(1, 5) for j in range(1, 5) for t in T) True Locality of the Bender--Knuth involutions:: - sage: all(all(t.bender_knuth_involution(k).bender_knuth_involution(l) == t.bender_knuth_involution(l).bender_knuth_involution(k) for k in range(1,5) for l in range(1,5) if abs(k - l) > 1) for t in T) + sage: all(t.bender_knuth_involution(k).bender_knuth_involution(l) # needs sage.modules + ....: == t.bender_knuth_involution(l).bender_knuth_involution(k) + ....: for k in range(1, 5) for l in range(1, 5) if abs(k - l) > 1 + ....: for t in T) True Berenstein and Kirillov [KB1995]_ have shown that `(s_1 s_2)^6 = id` (for tableaux of straight shape):: sage: p = lambda t, k: t.bender_knuth_involution(k).bender_knuth_involution(k + 1) - sage: all(p(p(p(p(p(p(t,1),1),1),1),1),1) == t for t in T) + sage: all(p(p(p(p(p(p(t,1),1),1),1),1),1) == t for t in T) # needs sage.modules True However, `(s_2 s_3)^6 = id` is false:: @@ -1687,7 +1692,7 @@ def weight(self): sage: by_word(t) == t.weight() True sage: SST = SemistandardTableaux(shape=[3,1,1]) - sage: all(by_word(t) == t.weight() for t in SST) + sage: all(by_word(t) == t.weight() for t in SST) # needs sage.modules True """ if len(self) == 0: @@ -2943,26 +2948,26 @@ def row_stabilizer(self): EXAMPLES:: - sage: rs = Tableau([[1,2,3],[4,5]]).row_stabilizer() # optional - sage.groups - sage: rs.order() == factorial(3)*factorial(2) # optional - sage.groups + sage: rs = Tableau([[1,2,3],[4,5]]).row_stabilizer() # needs sage.groups + sage: rs.order() == factorial(3)*factorial(2) # needs sage.groups True - sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs # optional - sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs # needs sage.groups True - sage: PermutationGroupElement([(1,4)]) in rs # optional - sage.groups + sage: PermutationGroupElement([(1,4)]) in rs # needs sage.groups False - sage: rs = Tableau([[1, 2],[3]]).row_stabilizer() # optional - sage.groups - sage: PermutationGroupElement([(1,2),(3,)]) in rs # optional - sage.groups + sage: rs = Tableau([[1, 2],[3]]).row_stabilizer() # needs sage.groups + sage: PermutationGroupElement([(1,2),(3,)]) in rs # needs sage.groups True - sage: rs.one().domain() # optional - sage.groups + sage: rs.one().domain() # needs sage.groups [1, 2, 3] - sage: rs = Tableau([[1],[2],[3]]).row_stabilizer() # optional - sage.groups - sage: rs.order() # optional - sage.groups + sage: rs = Tableau([[1],[2],[3]]).row_stabilizer() # needs sage.groups + sage: rs.order() # needs sage.groups 1 - sage: rs = Tableau([[2,4,5],[1,3]]).row_stabilizer() # optional - sage.groups - sage: rs.order() # optional - sage.groups + sage: rs = Tableau([[2,4,5],[1,3]]).row_stabilizer() # needs sage.groups + sage: rs.order() # needs sage.groups 12 - sage: rs = Tableau([]).row_stabilizer() # optional - sage.groups - sage: rs.order() # optional - sage.groups + sage: rs = Tableau([]).row_stabilizer() # needs sage.groups + sage: rs.order() # needs sage.groups 1 """ # Ensure that the permutations involve all elements of the @@ -2984,12 +2989,12 @@ def column_stabilizer(self): EXAMPLES:: - sage: cs = Tableau([[1,2,3],[4,5]]).column_stabilizer() # optional - sage.groups - sage: cs.order() == factorial(2)*factorial(2) # optional - sage.groups + sage: cs = Tableau([[1,2,3],[4,5]]).column_stabilizer() # needs sage.groups + sage: cs.order() == factorial(2)*factorial(2) # needs sage.groups True - sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs # optional - sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs # needs sage.groups False - sage: PermutationGroupElement([(1,4)]) in cs # optional - sage.groups + sage: PermutationGroupElement([(1,4)]) in cs # needs sage.groups True """ return self.conjugate().row_stabilizer() @@ -3046,7 +3051,7 @@ def last_letter_lequal(self, tab2): sage: st = StandardTableaux([3,2]) sage: f = lambda b: 1 if b else 0 - sage: matrix([[f(t1.last_letter_lequal(t2)) for t2 in st] for t1 in st]) # optional - sage.modules + sage: matrix([[f(t1.last_letter_lequal(t2)) for t2 in st] for t1 in st]) # needs sage.modules [1 1 1 1 1] [0 1 1 1 1] [0 0 1 1 1] @@ -3807,9 +3812,9 @@ def _segments(self): sage: sorted(t._segments().items()) [((0, 2), 2), ((0, 3), 3), ((0, 5), 4), ((1, 3), 1), ((1, 5), 2), ((2, 4), 1)] - sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # optional - sage.modules - sage: t = B[31].to_tableau() # optional - sage.modules - sage: sorted(t._segments().items()) # optional - sage.modules + sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # needs sage.modules + sage: t = B[31].to_tableau() # needs sage.modules + sage: sorted(t._segments().items()) # needs sage.modules [((0, 5), 3), ((1, 4), 2), ((2, 4), 1)] """ segments = {} @@ -3839,9 +3844,9 @@ def seg(self): sage: t.seg() 6 - sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # optional - sage.modules - sage: t = B[31].to_tableau() # optional - sage.modules - sage: t.seg() # optional - sage.modules + sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # needs sage.modules + sage: t = B[31].to_tableau() # needs sage.modules + sage: t.seg() # needs sage.modules 3 """ return len(self._segments()) @@ -3867,9 +3872,9 @@ def flush(self): sage: t.flush() 3 - sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # optional - sage.modules - sage: t = B[32].to_tableau() # optional - sage.modules - sage: t.flush() # optional - sage.modules + sage: B = crystals.Tableaux("A4", shape=[4,3,2,1]) # needs sage.modules + sage: t = B[32].to_tableau() # needs sage.modules + sage: t.flush() # needs sage.modules 4 """ for i in range(len(self)-1): @@ -3992,11 +3997,11 @@ def residue_sequence(self, e, multicharge=(0,)): EXAMPLES:: - sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(2) # optional - sage.groups + sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(2) # needs sage.groups 2-residue sequence (0,1,1,0) with multicharge (0) - sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(3) # optional - sage.groups + sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(3) # needs sage.groups 3-residue sequence (0,1,2,0) with multicharge (0) - sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(4) # optional - sage.groups + sage: StandardTableauTuple([[1,2],[3,4]]).residue_sequence(4) # needs sage.groups 4-residue sequence (0,1,3,0) with multicharge (0) """ res = [0] * self.size() @@ -4030,9 +4035,9 @@ def degree(self, e, multicharge=(0,)): EXAMPLES:: - sage: StandardTableau([[1,2,5],[3,4]]).degree(3) # optional - sage.groups + sage: StandardTableau([[1,2,5],[3,4]]).degree(3) # needs sage.groups 0 - sage: StandardTableau([[1,2,5],[3,4]]).degree(4) # optional - sage.groups + sage: StandardTableau([[1,2,5],[3,4]]).degree(4) # needs sage.groups 1 """ n = self.size() @@ -4075,11 +4080,11 @@ def codegree(self, e, multicharge=(0,)): EXAMPLES:: - sage: StandardTableau([[1,3,5],[2,4]]).codegree(3) # optional - sage.groups + sage: StandardTableau([[1,3,5],[2,4]]).codegree(3) # needs sage.groups 0 - sage: StandardTableau([[1,2,5],[3,4]]).codegree(3) # optional - sage.groups + sage: StandardTableau([[1,2,5],[3,4]]).codegree(3) # needs sage.groups 1 - sage: StandardTableau([[1,2,5],[3,4]]).codegree(4) # optional - sage.groups + sage: StandardTableau([[1,2,5],[3,4]]).codegree(4) # needs sage.groups 0 """ if not self: # the trivial case @@ -5874,7 +5879,7 @@ class SemistandardTableaux(Tableaux): sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] and maximum entry 3 - sage: SST.list() + sage: SST.list() # needs sage.modules [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], @@ -5886,7 +5891,7 @@ class SemistandardTableaux(Tableaux): sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 and maximum entry 3 - sage: SST.list() + sage: SST.list() # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], @@ -5909,7 +5914,7 @@ class SemistandardTableaux(Tableaux): sage: SST = SemistandardTableaux(3, max_entry=2); SST Semistandard tableaux of size 3 and maximum entry 2 - sage: SST.list() + sage: SST.list() # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 2, 2]], @@ -5919,13 +5924,13 @@ class SemistandardTableaux(Tableaux): sage: SST = SemistandardTableaux(3, max_entry=oo); SST Semistandard tableaux of size 3 - sage: SST[123] + sage: SST[123] # needs sage.modules [[3, 4], [6]] - sage: SemistandardTableaux(max_entry=2)[11] + sage: SemistandardTableaux(max_entry=2)[11] # needs sage.modules [[1, 1], [2]] - sage: SemistandardTableaux()[0] + sage: SemistandardTableaux()[0] # needs sage.modules [] .. SEEALSO:: @@ -6124,7 +6129,7 @@ def __init__(self, **kwds): EXAMPLES:: sage: S = SemistandardTableaux() - sage: TestSuite(S).run() + sage: TestSuite(S).run() # needs sage.modules """ if 'max_entry' in kwds: self.max_entry = kwds['max_entry'] @@ -6152,51 +6157,51 @@ def __getitem__(self, r): [[1, 4, 8, 12], [2, 5, 10], [3, 7, 11], [6, 9]], [[1, 3, 8, 12], [2, 5, 10], [4, 7, 11], [6, 9]]] - sage: SemistandardTableaux(size=2, max_entry=oo)[5] + sage: SemistandardTableaux(size=2, max_entry=oo)[5] # needs sage.modules [[2, 3]] - sage: SemistandardTableaux([2,1], max_entry=oo)[3] + sage: SemistandardTableaux([2,1], max_entry=oo)[3] # needs sage.modules [[1, 2], [3]] - sage: SemistandardTableaux(3, max_entry=2)[0:5] # indirect doctest + sage: SemistandardTableaux(3, max_entry=2)[0:5] # indirect doctest # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 2, 2]], [[2, 2, 2]], [[1, 1], [2]]] - sage: SemistandardTableaux([2,2], [2, 1, 1])[0] # indirect doctest + sage: SemistandardTableaux([2,2], [2, 1, 1])[0] # indirect doctest # needs sage.modules [[1, 1], [2, 3]] - sage: SemistandardTableaux([1,1,1], max_entry=4)[0:4] + sage: SemistandardTableaux([1,1,1], max_entry=4)[0:4] # needs sage.modules [[[1], [2], [3]], [[1], [2], [4]], [[1], [3], [4]], [[2], [3], [4]]] - sage: SemistandardTableaux(3, [2,1])[1] # indirect doctest + sage: SemistandardTableaux(3, [2,1])[1] # indirect doctest # needs sage.modules [[1, 1], [2]] - sage: StandardTableaux(3)[:] # indirect doctest + sage: StandardTableaux(3)[:] # indirect doctest # needs sage.modules [[[1, 2, 3]], [[1, 3], [2]], [[1, 2], [3]], [[1], [2], [3]]] - sage: StandardTableaux([2,2])[1] # indirect doctest + sage: StandardTableaux([2,2])[1] # indirect doctest # needs sage.modules [[1, 2], [3, 4]] TESTS:: - sage: SemistandardTableaux()[5] + sage: SemistandardTableaux()[5] # needs sage.modules [[1], [2]] - sage: SemistandardTableaux(max_entry=2)[5] + sage: SemistandardTableaux(max_entry=2)[5] # needs sage.modules [[2, 2]] - sage: SemistandardTableaux()[:] + sage: SemistandardTableaux()[:] # needs sage.modules Traceback (most recent call last): ... ValueError: infinite set - sage: SemistandardTableaux(size=2, max_entry=oo)[:] + sage: SemistandardTableaux(size=2, max_entry=oo)[:] # needs sage.modules Traceback (most recent call last): ... ValueError: infinite set @@ -6290,10 +6295,10 @@ def __init__(self, max_entry=None): TESTS:: sage: T = sage.combinat.tableau.SemistandardTableaux_all() - sage: TestSuite(T).run() + sage: TestSuite(T).run() # needs sage.modules sage: T = sage.combinat.tableau.SemistandardTableaux_all(max_entry=3) - sage: TestSuite(T).run() # long time + sage: TestSuite(T).run() # long time # needs sage.modules """ if max_entry is not PlusInfinity(): self.max_entry = max_entry @@ -6350,7 +6355,7 @@ def __init__(self, n): TESTS:: sage: T = sage.combinat.tableau.SemistandardTableaux_size_inf(3) - sage: TestSuite(T).run() + sage: TestSuite(T).run() # needs sage.modules """ super().__init__(category=InfiniteEnumeratedSets()) self.size = n @@ -6394,15 +6399,15 @@ def __iter__(self): EXAMPLES:: sage: sst = SemistandardTableaux(3, max_entry=oo) - sage: [sst[t] for t in range(5)] + sage: [sst[t] for t in range(5)] # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 2, 2]], [[2, 2, 2]], [[1, 1], [2]]] - sage: sst[1000] + sage: sst[1000] # needs sage.modules [[2, 12], [7]] - sage: sst[0].parent() is sst + sage: sst[0].parent() is sst # needs sage.modules True """ from sage.combinat.partition import Partitions @@ -6453,7 +6458,7 @@ def __init__(self, p): sage: SST = SemistandardTableaux([2,1], max_entry=oo) sage: type(SST) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules """ super().__init__(category=InfiniteEnumeratedSets()) self.shape = p @@ -6494,15 +6499,15 @@ def __iter__(self): EXAMPLES:: sage: SST = SemistandardTableaux([3, 1], max_entry=oo) - sage: SST[1000] + sage: SST[1000] # needs sage.modules [[1, 1, 10], [6]] - sage: [ SST[t] for t in range(5) ] + sage: [ SST[t] for t in range(5) ] # needs sage.modules [[[1, 1, 1], [2]], [[1, 1, 2], [2]], [[1, 2, 2], [2]], [[1, 1, 1], [3]], [[1, 1, 2], [3]]] - sage: SST[0].parent() is SST + sage: SST[0].parent() is SST # needs sage.modules True """ # Iterates through with maximum entry as order @@ -6541,12 +6546,12 @@ def __init__(self, n, max_entry=None): Semistandard tableaux of size 3 and maximum entry 3 sage: type(SST) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules sage: SST = SemistandardTableaux(3, max_entry=6) sage: type(SST) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules """ if max_entry is None: @@ -6578,7 +6583,7 @@ def __contains__(self, x): sage: [[1,2],[3,3]] in SemistandardTableaux(4, max_entry=2) False sage: SST = SemistandardTableaux(4) - sage: all(sst in SST for sst in SST) + sage: all(sst in SST for sst in SST) # needs sage.modules True Check that :trac:`14145` is fixed:: @@ -6616,9 +6621,9 @@ def random_element(self): EXAMPLES:: - sage: SemistandardTableaux(6).random_element() # random # optional - sage.modules + sage: SemistandardTableaux(6).random_element() # random # needs sage.modules [[1, 1, 2], [3, 5, 5]] - sage: SemistandardTableaux(6, max_entry=7).random_element() # random # optional - sage.modules + sage: SemistandardTableaux(6, max_entry=7).random_element() # random # needs sage.modules [[2, 4, 4, 6, 6, 6]] """ from sage.rings.integer_ring import ZZ @@ -6662,7 +6667,7 @@ def cardinality(self): 4225 sage: ns = list(range(1, 6)) sage: ssts = [ SemistandardTableaux(n) for n in ns ] - sage: all(sst.cardinality() == len(sst.list()) for sst in ssts) + sage: all(sst.cardinality() == len(sst.list()) for sst in ssts) # needs sage.modules True """ from sage.combinat.partition import Partitions @@ -6675,9 +6680,9 @@ def __iter__(self): """ EXAMPLES:: - sage: [ t for t in SemistandardTableaux(2) ] + sage: [ t for t in SemistandardTableaux(2) ] # needs sage.modules [[[1, 1]], [[1, 2]], [[2, 2]], [[1], [2]]] - sage: [ t for t in SemistandardTableaux(3) ] + sage: [ t for t in SemistandardTableaux(3) ] # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], @@ -6698,7 +6703,7 @@ def __iter__(self): [[2, 3], [3]], [[1], [2], [3]]] - sage: [ t for t in SemistandardTableaux(3, max_entry=2) ] + sage: [ t for t in SemistandardTableaux(3, max_entry=2) ] # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 2, 2]], @@ -6707,7 +6712,7 @@ def __iter__(self): [[1, 2], [2]]] sage: sst = SemistandardTableaux(3) - sage: sst[0].parent() is sst + sage: sst[0].parent() is sst # needs sage.modules True """ from sage.combinat.partition import Partitions @@ -6743,10 +6748,10 @@ def __init__(self, p, max_entry=None): TESTS:: sage: SST = SemistandardTableaux([2,1]) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules sage: SST = SemistandardTableaux([2,1], max_entry=5) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules """ if max_entry is None: max_entry = sum(p) @@ -6761,7 +6766,7 @@ def __iter__(self): EXAMPLES:: - sage: [ t for t in SemistandardTableaux([3]) ] + sage: [ t for t in SemistandardTableaux([3]) ] # needs sage.modules [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], @@ -6772,7 +6777,7 @@ def __iter__(self): [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]]] - sage: [ t for t in SemistandardTableaux([2,1]) ] + sage: [ t for t in SemistandardTableaux([2,1]) ] # needs sage.modules [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], @@ -6781,17 +6786,17 @@ def __iter__(self): [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] - sage: [ t for t in SemistandardTableaux([1,1,1]) ] + sage: [ t for t in SemistandardTableaux([1,1,1]) ] # needs sage.modules [[[1], [2], [3]]] - sage: [ t for t in SemistandardTableaux([1,1,1], max_entry=4) ] + sage: [ t for t in SemistandardTableaux([1,1,1], max_entry=4) ] # needs sage.modules [[[1], [2], [3]], [[1], [2], [4]], [[1], [3], [4]], [[2], [3], [4]]] sage: sst = SemistandardTableaux([3]) - sage: sst[0].parent() is sst + sage: sst[0].parent() is sst # needs sage.modules True """ for c in integer_vectors_nk_fast_iter(sum(self.shape), self.max_entry): @@ -6803,15 +6808,15 @@ def __contains__(self, x): EXAMPLES:: sage: SST = SemistandardTableaux([2,1]) - sage: all(sst in SST for sst in SST) + sage: all(sst in SST for sst in SST) # needs sage.modules True - sage: len([x for x in SemistandardTableaux(3) if x in SST]) + sage: len([x for x in SemistandardTableaux(3) if x in SST]) # needs sage.modules 8 sage: SST.cardinality() 8 sage: SST = SemistandardTableaux([2,1], max_entry=4) - sage: all(sst in SST for sst in SST) + sage: all(sst in SST for sst in SST) # needs sage.modules True sage: SST.cardinality() 20 @@ -6905,7 +6910,7 @@ def cardinality(self, algorithm='hook'): 8 sage: SemistandardTableaux([2,2,1]).cardinality() 75 - sage: SymmetricFunctions(QQ).schur()([2,2,1]).expand(5)(1,1,1,1,1) # cross check + sage: SymmetricFunctions(QQ).schur()([2,2,1]).expand(5)(1,1,1,1,1) # cross check # needs sage.modules 75 sage: SemistandardTableaux([5]).cardinality() 126 @@ -6916,7 +6921,7 @@ def cardinality(self, algorithm='hook'): sage: SemistandardTableaux([6,5,4,3,2,1], max_entry=30).cardinality() 208361017592001331200 sage: ssts = [SemistandardTableaux(p, max_entry=6) for p in Partitions(5)] - sage: all(sst.cardinality() == sst.cardinality(algorithm='sum') + sage: all(sst.cardinality() == sst.cardinality(algorithm='sum') # needs sage.modules ....: for sst in ssts) True """ @@ -6955,7 +6960,7 @@ def __init__(self, p, mu): TESTS:: sage: SST = SemistandardTableaux([2,1], [2,1]) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules """ super().__init__(p, len(mu)) self.weight = mu @@ -6974,11 +6979,11 @@ def __contains__(self, x): EXAMPLES:: sage: SST = SemistandardTableaux([2,1], [2,1]) - sage: all(sst in SST for sst in SST) + sage: all(sst in SST for sst in SST) # needs sage.modules True - sage: len([x for x in SemistandardTableaux(3) if x in SST]) + sage: len([x for x in SemistandardTableaux(3) if x in SST]) # needs sage.modules 1 - sage: SST.cardinality() + sage: SST.cardinality() # needs sage.modules 1 """ if x not in SemistandardTableaux_shape(self.shape, self.max_entry): @@ -7009,13 +7014,13 @@ def cardinality(self): EXAMPLES:: - sage: SemistandardTableaux([2,2], [2, 1, 1]).cardinality() + sage: SemistandardTableaux([2,2], [2, 1, 1]).cardinality() # needs sage.modules 1 - sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).cardinality() + sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).cardinality() # needs sage.modules 1 - sage: SemistandardTableaux([2,2,2], [2, 2, 2]).cardinality() + sage: SemistandardTableaux([2,2,2], [2, 2, 2]).cardinality() # needs sage.modules 1 - sage: SemistandardTableaux([3,2,1], [2, 2, 2]).cardinality() + sage: SemistandardTableaux([3,2,1], [2, 2, 2]).cardinality() # needs sage.modules 2 """ return symmetrica.kostka_number(self.shape, self.weight) @@ -7025,9 +7030,9 @@ def __iter__(self): TESTS:: sage: sst = SemistandardTableaux([3,1],[2,1,1]) - sage: [sst[i] for i in range(2)] + sage: [sst[i] for i in range(2)] # needs sage.modules [[[1, 1, 2], [3]], [[1, 1, 3], [2]]] - sage: sst[0].parent() is sst + sage: sst[0].parent() is sst # needs sage.modules True """ for t in symmetrica.kostka_tab(self.shape, self.weight): @@ -7040,13 +7045,13 @@ def list(self): EXAMPLES:: - sage: SemistandardTableaux([2,2], [2, 1, 1]).list() + sage: SemistandardTableaux([2,2], [2, 1, 1]).list() # needs sage.modules [[[1, 1], [2, 3]]] - sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).list() + sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).list() # needs sage.modules [[[1, 1], [2, 2], [3, 4]]] - sage: SemistandardTableaux([2,2,2], [2, 2, 2]).list() + sage: SemistandardTableaux([2,2,2], [2, 2, 2]).list() # needs sage.modules [[[1, 1], [2, 2], [3, 3]]] - sage: SemistandardTableaux([3,2,1], [2, 2, 2]).list() + sage: SemistandardTableaux([3,2,1], [2, 2, 2]).list() # needs sage.modules [[[1, 1, 2], [2, 3], [3]], [[1, 1, 3], [2, 2], [3]]] """ return symmetrica.kostka_tab(self.shape, self.weight) @@ -7070,7 +7075,7 @@ def __init__(self, n, mu): TESTS:: sage: SST = SemistandardTableaux(3, [2,1]) - sage: TestSuite(SST).run() + sage: TestSuite(SST).run() # needs sage.modules """ super().__init__(max_entry=len(mu), category=FiniteEnumeratedSets()) @@ -7090,12 +7095,12 @@ def __iter__(self): """ EXAMPLES:: - sage: [ t for t in SemistandardTableaux(3, [2,1]) ] + sage: [ t for t in SemistandardTableaux(3, [2,1]) ] # needs sage.modules [[[1, 1, 2]], [[1, 1], [2]]] - sage: [ t for t in SemistandardTableaux(4, [2,2]) ] + sage: [ t for t in SemistandardTableaux(4, [2,2]) ] # needs sage.modules [[[1, 1, 2, 2]], [[1, 1, 2], [2]], [[1, 1], [2, 2]]] - sage: sst = SemistandardTableaux(4, [2,2]) - sage: sst[0].parent() is sst + sage: sst = SemistandardTableaux(4, [2,2]) # needs sage.modules + sage: sst[0].parent() is sst # needs sage.modules True """ from sage.combinat.partition import Partitions @@ -7109,9 +7114,9 @@ def cardinality(self): EXAMPLES:: - sage: SemistandardTableaux(3, [2,1]).cardinality() + sage: SemistandardTableaux(3, [2,1]).cardinality() # needs sage.modules 2 - sage: SemistandardTableaux(4, [2,2]).cardinality() + sage: SemistandardTableaux(4, [2,2]).cardinality() # needs sage.modules 3 """ from sage.combinat.partition import Partitions @@ -7125,9 +7130,9 @@ def __contains__(self, x): TESTS:: sage: SST = SemistandardTableaux(6, [2,2,2]) - sage: all(sst in SST for sst in SST) + sage: all(sst in SST for sst in SST) # needs sage.modules True - sage: all(sst in SST for sst in SemistandardTableaux([3,2,1],[2,2,2])) + sage: all(sst in SST for sst in SemistandardTableaux([3,2,1],[2,2,2])) # needs sage.modules True """ from sage.combinat.partition import Partition @@ -7167,13 +7172,13 @@ class RowStandardTableaux(Tableaux): sage: ST = RowStandardTableaux(3); ST Row standard tableaux of size 3 - sage: ST.first() # optional - sage.graphs + sage: ST.first() # needs sage.graphs [[1, 2, 3]] - sage: ST.last() # optional - sage.graphs + sage: ST.last() # needs sage.graphs sage.modules [[3], [1], [2]] - sage: ST.cardinality() # optional - sage.graphs + sage: ST.cardinality() # needs sage.graphs sage.modules 10 - sage: ST.list() # optional - sage.graphs + sage: ST.list() # needs sage.graphs sage.modules [[[1, 2, 3]], [[2, 3], [1]], [[1, 2], [3]], @@ -7200,13 +7205,13 @@ class RowStandardTableaux(Tableaux): [] sage: ST = RowStandardTableaux([2,2]); ST Row standard tableaux of shape [2, 2] - sage: ST.first() # optional - sage.graphs + sage: ST.first() # needs sage.graphs [[2, 4], [1, 3]] - sage: ST.last() # optional - sage.graphs + sage: ST.last() # needs sage.graphs sage.modules [[2, 3], [1, 4]] - sage: ST.cardinality() # optional - sage.graphs + sage: ST.cardinality() # needs sage.graphs sage.modules 6 - sage: ST.list() # optional - sage.graphs + sage: ST.list() # needs sage.graphs sage.modules [[[2, 4], [1, 3]], [[3, 4], [1, 2]], [[1, 4], [2, 3]], @@ -7318,7 +7323,7 @@ def __init__(self): TESTS:: sage: ST = RowStandardTableaux() - sage: TestSuite(ST).run() + sage: TestSuite(ST).run() # needs sage.graphs """ RowStandardTableaux.__init__(self) DisjointUnionEnumeratedSets.__init__(self, @@ -7341,11 +7346,11 @@ class RowStandardTableaux_size(RowStandardTableaux, DisjointUnionEnumeratedSets) EXAMPLES:: - sage: [t for t in RowStandardTableaux(1)] # optional - sage.graphs + sage: [t for t in RowStandardTableaux(1)] # needs sage.graphs [[[1]]] - sage: [t for t in RowStandardTableaux(2)] # optional - sage.graphs + sage: [t for t in RowStandardTableaux(2)] # needs sage.graphs [[[1, 2]], [[2], [1]], [[1], [2]]] - sage: list(RowStandardTableaux(3)) # optional - sage.graphs + sage: list(RowStandardTableaux(3)) # needs sage.graphs [[[1, 2, 3]], [[2, 3], [1]], [[1, 2], [3]], @@ -7359,13 +7364,13 @@ class RowStandardTableaux_size(RowStandardTableaux, DisjointUnionEnumeratedSets) TESTS:: - sage: TestSuite( RowStandardTableaux(4) ).run() + sage: TestSuite(RowStandardTableaux(4)).run() # needs sage.graphs - sage: RowStandardTableaux(3).cardinality() + sage: RowStandardTableaux(3).cardinality() # needs sage.libs.flint 10 sage: ns = [1,2,3,4,5,6] sage: sts = [RowStandardTableaux(n) for n in ns] - sage: all(st.cardinality() == len(st.list()) for st in sts) # optional - sage.graphs + sage: all(st.cardinality() == len(st.list()) for st in sts) # needs sage.graphs True sage: RowStandardTableaux(40).cardinality() # not tested, too long 2063837185739279909309355007659204891024472174278 @@ -7382,8 +7387,8 @@ def __init__(self, n): TESTS:: - sage: TestSuite(RowStandardTableaux(0)).run() # optional - sage.graphs - sage: TestSuite(RowStandardTableaux(3)).run() # optional - sage.graphs + sage: TestSuite(RowStandardTableaux(0)).run() # needs sage.graphs + sage: TestSuite(RowStandardTableaux(3)).run() # needs sage.graphs """ RowStandardTableaux.__init__(self) from sage.combinat.partition import Partitions_n @@ -7406,10 +7411,10 @@ def __contains__(self, x): TESTS:: sage: ST3 = RowStandardTableaux(3) - sage: all(st in ST3 for st in ST3) # optional - sage.graphs + sage: all(st in ST3 for st in ST3) # needs sage.graphs True sage: ST4 = RowStandardTableaux(4) - sage: [x for x in ST4 if x in ST3] # optional - sage.graphs + sage: [x for x in ST4 if x in ST3] # needs sage.graphs [] Check that :trac:`14145` is fixed:: @@ -7452,7 +7457,7 @@ def __init__(self, p): TESTS:: - sage: TestSuite( RowStandardTableaux([2,1,1]) ).run() # optional - sage.graphs + sage: TestSuite( RowStandardTableaux([2,1,1]) ).run() # needs sage.graphs """ super().__init__(category=FiniteEnumeratedSets()) self.shape = p @@ -7462,9 +7467,9 @@ def __contains__(self, x): EXAMPLES:: sage: ST = RowStandardTableaux([2,1,1]) - sage: all(st in ST for st in ST) # optional - sage.graphs + sage: all(st in ST for st in ST) # needs sage.graphs True - sage: len([x for x in RowStandardTableaux(4) if x in ST]) # optional - sage.graphs + sage: len([x for x in RowStandardTableaux(4) if x in ST]) # needs sage.graphs 12 sage: ST.cardinality() 12 @@ -7487,14 +7492,14 @@ def __iter__(self): EXAMPLES:: - sage: [t for t in RowStandardTableaux([2,2])] # optional - sage.graphs + sage: [t for t in RowStandardTableaux([2,2])] # needs sage.graphs [[[2, 4], [1, 3]], [[3, 4], [1, 2]], [[1, 4], [2, 3]], [[1, 3], [2, 4]], [[1, 2], [3, 4]], [[2, 3], [1, 4]]] - sage: [t for t in RowStandardTableaux([3,2])] # optional - sage.graphs + sage: [t for t in RowStandardTableaux([3,2])] # needs sage.graphs [[[2, 4, 5], [1, 3]], [[3, 4, 5], [1, 2]], [[1, 4, 5], [2, 3]], @@ -7506,7 +7511,7 @@ def __iter__(self): [[2, 3, 4], [1, 5]], [[2, 3, 5], [1, 4]]] sage: st = RowStandardTableaux([2,1]) - sage: st[0].parent() is st # optional - sage.graphs + sage: st[0].parent() is st # needs sage.graphs True """ partial_sums = [sum(self.shape[:i]) for i in range(len(self.shape)+1)] @@ -7613,7 +7618,7 @@ class StandardTableaux(SemistandardTableaux): 2 sage: ST.list() [[[1, 3], [2, 4]], [[1, 2], [3, 4]]] - sage: StandardTableau([[1,2,3],[4,5]]).residue_sequence(3).standard_tableaux() # optional - sage.groups + sage: StandardTableau([[1,2,3],[4,5]]).residue_sequence(3).standard_tableaux() # needs sage.groups Standard tableaux with 3-residue sequence (0,1,2,2,0) and multicharge (0) """ @staticmethod diff --git a/src/sage/combinat/tableau_tuple.py b/src/sage/combinat/tableau_tuple.py index 889f5ee9bc4..ae17b0e3978 100644 --- a/src/sage/combinat/tableau_tuple.py +++ b/src/sage/combinat/tableau_tuple.py @@ -130,7 +130,7 @@ iterators must have the correct parents, so in this one case 1-tuples of tableaux are different from :class:`Tableaux`:: - sage: StandardTableauTuples()[:10] + sage: StandardTableauTuples()[:10] # needs sage.libs.flint [(), ([[1]]), ([], []), @@ -1072,14 +1072,15 @@ def row_stabilizer(self): EXAMPLES:: - sage: rs = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]).row_stabilizer() - sage: rs.order() + sage: t = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]) + sage: rs = t.row_stabilizer() # needs sage.groups + sage: rs.order() # needs sage.groups 24 - sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs + sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs # needs sage.groups True - sage: PermutationGroupElement([(1,4)]) in rs + sage: PermutationGroupElement([(1,4)]) in rs # needs sage.groups False - sage: rs.one().domain() + sage: rs.one().domain() # needs sage.groups [1, 2, 3, 4, 5, 6, 7, 8, 9] """ # Ensure that the permutations involve all elements of the @@ -1100,12 +1101,13 @@ def column_stabilizer(self): EXAMPLES:: - sage: cs = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]).column_stabilizer() - sage: cs.order() + sage: t = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]) + sage: cs = t.column_stabilizer() # needs sage.groups + sage: cs.order() # needs sage.groups 8 - sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs + sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs # needs sage.groups False - sage: PermutationGroupElement([(1,4)]) in cs + sage: PermutationGroupElement([(1,4)]) in cs # needs sage.groups True """ @@ -1507,7 +1509,7 @@ def __classcall_private__(self, t): sage: RowStandardTableauTuples(level=2)(t).parent() Row standard tableau tuples of level 2 - sage: RowStandardTableauTuples(level=2,size=6)(t).parent() + sage: RowStandardTableauTuples(level=2, size=6)(t).parent() # needs sage.libs.flint Row standard tableau tuples of level 2 and size 6 """ if isinstance(t, (RowStandardTableau, RowStandardTableauTuple)): @@ -1894,7 +1896,7 @@ def __classcall_private__(self, t): sage: StandardTableauTuples(level=2)(t).parent() Standard tableau tuples of level 2 - sage: StandardTableauTuples(level=2,size=6)(t).parent() + sage: StandardTableauTuples(level=2, size=6)(t).parent() # needs sage.libs.flint Standard tableau tuples of level 2 and size 6 """ if isinstance(t, (StandardTableau, StandardTableauTuple)): @@ -2712,7 +2714,7 @@ class RowStandardTableauTuples(TableauTuples): Row standard tableau tuples of shape ([2], [1, 1]) sage: tabs.cardinality() 12 - sage: tabs[:] + sage: tabs[:] # needs sage.graphs sage.rings.finite_rings [([[3, 4]], [[2], [1]]), ([[2, 4]], [[3], [1]]), ([[1, 4]], [[3], [2]]), @@ -2728,26 +2730,26 @@ class RowStandardTableauTuples(TableauTuples): sage: tabs = RowStandardTableauTuples(level=3); tabs Row standard tableau tuples of level 3 - sage: tabs[100] + sage: tabs[100] # needs sage.libs.flint ([], [], [[2, 3], [1]]) - sage: RowStandardTableauTuples()[0] + sage: RowStandardTableauTuples()[0] # needs sage.libs.flint ([]) TESTS:: - sage: TestSuite( RowStandardTableauTuples() ).run() - sage: TestSuite( RowStandardTableauTuples(level=1) ).run() - sage: TestSuite( RowStandardTableauTuples(level=4) ).run() - sage: TestSuite( RowStandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs - sage: TestSuite( RowStandardTableauTuples(size=6) ).run() - sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() - sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() - sage: TestSuite( RowStandardTableauTuples(level=1, size=10) ).run() - sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() - sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() - sage: TestSuite( RowStandardTableauTuples(level=4, size=10) ).run() # long time - sage: TestSuite( RowStandardTableauTuples(shape=[[1],[3,1],[],[2,1]]) ).run() + sage: TestSuite( RowStandardTableauTuples() ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=1) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=4) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(size=6) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=1, size=10) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(level=4, size=10) ).run() # long time, needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples(shape=[[1],[3,1],[],[2,1]]) ).run() # needs sage.libs.flint .. SEEALSO:: @@ -2772,9 +2774,9 @@ def __classcall_private__(cls, *args, **kwargs): Row standard tableau tuples sage: RowStandardTableauTuples(4) Row standard tableau tuples of level 4 - sage: RowStandardTableauTuples(4,3) + sage: RowStandardTableauTuples(4,3) # needs sage.libs.flint Row standard tableau tuples of level 4 and size 3 - sage: RowStandardTableauTuples([ [2,1],[1],[1,1,1],[3,2] ]) + sage: RowStandardTableauTuples([ [2,1],[1],[1,1,1],[3,2] ]) # needs sage.libs.flint Row standard tableau tuples of shape ([2, 1], [1], [1, 1, 1], [3, 2]) TESTS:: @@ -2787,7 +2789,7 @@ def __classcall_private__(cls, *args, **kwargs): sage: P = PartitionTuples() sage: pt = P([[1]]); pt ([1]) - sage: RowStandardTableauTuples(pt) + sage: RowStandardTableauTuples(pt) # needs sage.libs.flint Row standard tableaux of shape [1] """ from sage.combinat.partition_tuple import PartitionTuple @@ -2874,7 +2876,7 @@ def __getitem__(self, r): EXAMPLES:: - sage: RowStandardTableauTuples()[10:20] + sage: RowStandardTableauTuples()[10:20] # needs sage.libs.flint [([[2, 3], [1]]), ([[1, 2], [3]]), ([[1, 3], [2]]), @@ -2993,7 +2995,7 @@ def __init__(self): EXAMPLES:: sage: RSTT = RowStandardTableauTuples() - sage: TestSuite(RSTT).run() + sage: TestSuite(RSTT).run() # needs sage.libs.flint """ RowStandardTableauTuples.__init__(self) from sage.combinat.partition_tuple import PartitionTuples @@ -3046,7 +3048,7 @@ def __init__(self, level): sage: RowStandardTableauTuples(3) Row standard tableau tuples of level 3 - sage: RowStandardTableauTuples(3)[:10] + sage: RowStandardTableauTuples(3)[:10] # needs sage.libs.flint [([], [], []), ([[1]], [], []), ([], [[1]], []), @@ -3144,7 +3146,7 @@ def __init__(self, size): sage: RowStandardTableauTuples(size=3) # indirect doctest Row standard tableau tuples of size 3 - sage: RowStandardTableauTuples(size=2)[:10] + sage: RowStandardTableauTuples(size=2)[:10] # needs sage.libs.flint [([[1, 2]]), ([[2], [1]]), ([[1], [2]]), @@ -3242,11 +3244,11 @@ def __init__(self, level, size): EXAMPLES:: - sage: RowStandardTableauTuples(size=4,level=3) + sage: RSTT43 = RowStandardTableauTuples(size=4, level=3); RSTT43 # needs sage.libs.flint Row standard tableau tuples of level 3 and size 4 - sage: RowStandardTableauTuples(size=4,level=3) is RowStandardTableauTuples(3,4) + sage: RSTT43 is RowStandardTableauTuples(3,4) # needs sage.libs.flint True - sage: RowStandardTableauTuples(level=3, size=2)[:] + sage: RowStandardTableauTuples(level=3, size=2)[:] # needs sage.libs.flint [([[1, 2]], [], []), ([[2], [1]], [], []), ([[1], [2]], [], []), @@ -3262,7 +3264,7 @@ def __init__(self, level, size): ([], [], [[1, 2]]), ([], [], [[2], [1]]), ([], [], [[1], [2]])] - sage: RowStandardTableauTuples(3,2).cardinality() + sage: RowStandardTableauTuples(3,2).cardinality() # needs sage.libs.flint 15 """ RowStandardTableauTuples.__init__(self) @@ -3281,7 +3283,7 @@ def _repr_(self): EXAMPLES:: - sage: RowStandardTableauTuples(3, 4) + sage: RowStandardTableauTuples(3, 4) # needs sage.libs.flint Row standard tableau tuples of level 3 and size 4 """ return f"Row standard tableau tuples of level {self.level()} and size {self.size()}" @@ -3293,18 +3295,18 @@ def __contains__(self, t): EXAMPLES:: - sage: tabs = RowStandardTableauTuples(level=4, size=4); tabs + sage: tabs = RowStandardTableauTuples(level=4, size=4); tabs # needs sage.libs.flint Row standard tableau tuples of level 4 and size 4 - sage: [[[2,4],[1]],[],[[3]],[]] in tabs + sage: [[[2,4],[1]],[],[[3]],[]] in tabs # needs sage.libs.flint True - sage: tabs([[[1,2]],[],[[4],[3]],[]]) == RowStandardTableauTuple([[[1,2]],[],[[4],[3]],[]]) + sage: tabs([[[1,2]],[],[[4],[3]],[]]) == RowStandardTableauTuple([[[1,2]],[],[[4],[3]],[]]) # needs sage.libs.flint True - sage: RowStandardTableauTuple([[[2, 3]], [[1]]]) in tabs + sage: RowStandardTableauTuple([[[2, 3]], [[1]]]) in tabs # needs sage.libs.flint False Check that :trac:`14145` is fixed:: - sage: 1 in RowStandardTableauTuples(level=4, size=3) + sage: 1 in RowStandardTableauTuples(level=4, size=3) # needs sage.libs.flint False """ if isinstance(t, self.element_class): @@ -3323,9 +3325,9 @@ def an_element(self): EXAMPLES:: - sage: RowStandardTableauTuples(5,size=2).an_element() + sage: RowStandardTableauTuples(5, size=2).an_element() # needs sage.libs.flint ([], [], [], [], [[1], [2]]) - sage: RowStandardTableauTuples(2,size=4).an_element() + sage: RowStandardTableauTuples(2, size=4).an_element() # needs sage.libs.flint ([[1]], [[2, 3], [4]]) """ if self.size() == 0: @@ -3423,14 +3425,14 @@ def __iter__(self): EXAMPLES:: - sage: RowStandardTableauTuples([[1],[1],[1]]).list() + sage: RowStandardTableauTuples([[1],[1],[1]]).list() # needs sage.graphs sage.modules sage.rings.finite_rings [([[3]], [[2]], [[1]]), ([[2]], [[3]], [[1]]), ([[1]], [[3]], [[2]]), ([[1]], [[2]], [[3]]), ([[2]], [[1]], [[3]]), ([[3]], [[1]], [[2]])] - sage: RowStandardTableauTuples([[2,1],[2]]).list() + sage: RowStandardTableauTuples([[2,1],[2]]).list() # needs sage.graphs sage.modules sage.rings.finite_rings [([[4, 5], [2]], [[1, 3]]), ([[4, 5], [3]], [[1, 2]]), ([[3, 5], [4]], [[1, 2]]), @@ -3464,10 +3466,10 @@ def __iter__(self): TESTS:: - sage: def check(mu): + sage: def check(mu): # needs sage.graphs sage.modules sage.rings.finite_rings ....: return (RowStandardTableauTuples(mu).cardinality() ....: == len(RowStandardTableauTuples(mu).list())) - sage: all(check(mu) for mu in PartitionTuples(4,4)) + sage: all(check(mu) for mu in PartitionTuples(4,4)) # needs sage.graphs sage.modules sage.rings.finite_rings True """ mu = self.shape() @@ -3536,9 +3538,9 @@ def an_element(self): EXAMPLES:: - sage: RowStandardTableauTuples([[2],[2,1]]).an_element() + sage: RowStandardTableauTuples([[2],[2,1]]).an_element() # needs sage.graphs ([[4, 5]], [[1, 3], [2]]) - sage: RowStandardTableauTuples([[10],[],[]]).an_element() + sage: RowStandardTableauTuples([[10],[],[]]).an_element() # needs sage.graphs ([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [], []) """ c = self.cardinality() @@ -3641,7 +3643,7 @@ def __iter__(self): EXAMPLES:: sage: R = RowStandardTableauTuple([[[4, 5], [3]],[[1,2]]]).residue_sequence(3, (0,1)) - sage: R.row_standard_tableaux()[:] + sage: R.row_standard_tableaux()[:] # needs sage.libs.flint [([[4, 5], [3]], [[1, 2]]), ([[4, 5], [2]], [[1, 3]]), ([[4], [3], [5]], [[1, 2]]), @@ -3651,7 +3653,7 @@ def __iter__(self): ([], [[1, 3], [4], [2], [5]]), ([], [[1, 2], [4], [3], [5]])] sage: R = RowStandardTableauTuple([[[2,4],[1]],[[3]]]).residue_sequence(3,(0,1)) - sage: R.row_standard_tableaux()[:] + sage: R.row_standard_tableaux()[:] # needs sage.libs.flint [([[2, 4], [1], [3]], []), ([[2, 3], [1], [4]], []), ([[2, 4], [1]], [[3]]), @@ -3774,8 +3776,8 @@ def an_element(self): [[2, 3], [1]] sage: StandardTableau([[1,3],[2]]).residue_sequence(3).row_standard_tableaux().an_element() [[1, 3], [2]] - sage: RowStandardTableauTuple([[[4]],[[2,3],[1]]]).residue_sequence(3,(0,1)).row_standard_tableaux().an_element() - sage: StandardTableauTuple([[[4]],[[1,3],[2]]]).residue_sequence(3,(0,1)).row_standard_tableaux().an_element() + sage: RowStandardTableauTuple([[[4]],[[2,3],[1]]]).residue_sequence(3,(0,1)).row_standard_tableaux().an_element() # needs sage.libs.flint + sage: StandardTableauTuple([[[4]],[[1,3],[2]]]).residue_sequence(3,(0,1)).row_standard_tableaux().an_element() # needs sage.libs.flint ([[4], [3], [1], [2]], []) """ try: @@ -4017,24 +4019,24 @@ class StandardTableauTuples(RowStandardTableauTuples): sage: tabs=StandardTableauTuples(level=3); tabs Standard tableau tuples of level 3 - sage: tabs[100] + sage: tabs[100] # needs sage.libs.flint ([[1, 2], [3]], [], [[4]]) - sage: StandardTableauTuples()[0] + sage: StandardTableauTuples()[0] # needs sage.libs.flint () TESTS:: - sage: TestSuite( StandardTableauTuples() ).run() - sage: TestSuite( StandardTableauTuples(level=1) ).run() - sage: TestSuite( StandardTableauTuples(level=4) ).run() - sage: TestSuite( StandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs - sage: TestSuite( StandardTableauTuples(size=6) ).run() - sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() - sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() - sage: TestSuite( StandardTableauTuples(level=1, size=10) ).run() - sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() - sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() + sage: TestSuite( StandardTableauTuples() ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=1) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=4) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(size=6) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=1, size=10) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint .. SEEALSO:: @@ -4061,14 +4063,14 @@ def __classcall_private__(cls, *args, **kwargs): Standard tableau tuples sage: StandardTableauTuples(4) Standard tableau tuples of level 4 - sage: StandardTableauTuples(4,3) + sage: StandardTableauTuples(4,3) # needs sage.libs.flint Standard tableau tuples of level 4 and size 3 - sage: StandardTableauTuples([ [2,1],[1],[1,1,1],[3,2] ]) + sage: StandardTableauTuples([ [2,1],[1],[1,1,1],[3,2] ]) # needs sage.libs.flint Standard tableau tuples of shape ([2, 1], [1], [1, 1, 1], [3, 2]) TESTS:: - sage: StandardTableauTuples([ [2,1],[1],[1,1,1],[3,2,3] ]) + sage: StandardTableauTuples([ [2,1],[1],[1,1,1],[3,2,3] ]) # needs sage.libs.flint Traceback (most recent call last): ... ValueError: the shape must be a partition tuple @@ -4076,7 +4078,7 @@ def __classcall_private__(cls, *args, **kwargs): sage: P = PartitionTuples() sage: pt = P([[1]]); pt ([1]) - sage: StandardTableauTuples(pt) + sage: StandardTableauTuples(pt) # needs sage.libs.flint Standard tableaux of shape [1] """ from sage.combinat.partition_tuple import PartitionTuple @@ -4162,7 +4164,7 @@ def __getitem__(self, r): EXAMPLES:: - sage: StandardTableauTuples()[10:20] + sage: StandardTableauTuples()[10:20] # needs sage.libs.flint [([[1, 2], [3]]), ([[1], [2], [3]]), ([[1, 2]], []), @@ -4317,7 +4319,7 @@ def __iter__(self): EXAMPLES:: sage: stt = StandardTableauTuples() - sage: stt[0:8] + sage: stt[0:8] # needs sage.libs.flint [(), ([[1]]), ([], []), @@ -4326,11 +4328,11 @@ def __iter__(self): ([[1]], []), ([], [[1]]), ([], [], [])] - sage: stt[5] + sage: stt[5] # needs sage.libs.flint ([[1]], []) - sage: stt[50] + sage: stt[50] # needs sage.libs.flint ([], [[1, 3], [2]]) - sage: stt[47].parent() is stt + sage: stt[47].parent() is stt # needs sage.libs.flint True """ from sage.combinat.partition_tuple import PartitionTuples @@ -4418,7 +4420,7 @@ def __iter__(self): EXAMPLES:: sage: stt = StandardTableauTuples(3) - sage: stt[0:8] + sage: stt[0:8] # needs sage.libs.flint [([], [], []), ([[1]], [], []), ([], [[1]], []), @@ -4427,9 +4429,9 @@ def __iter__(self): ([[1], [2]], [], []), ([[1]], [[2]], []), ([[2]], [[1]], [])] - sage: stt[50] + sage: stt[50] # needs sage.libs.flint ([], [[1, 2, 3]], []) - sage: stt[0].parent() is stt + sage: stt[0].parent() is stt # needs sage.libs.flint True """ # Iterate through the PartitionTuples and then the tableaux @@ -4540,7 +4542,7 @@ def __iter__(self): EXAMPLES:: sage: stt = StandardTableauTuples(size=3) - sage: stt[0:8] + sage: stt[0:8] # needs sage.libs.flint [([[1, 2, 3]]), ([[1, 3], [2]]), ([[1, 2], [3]]), @@ -4549,9 +4551,9 @@ def __iter__(self): ([[1, 2], [3]], []), ([[1, 3], [2]], []), ([[1], [2], [3]], [])] - sage: stt[50] + sage: stt[50] # needs sage.libs.flint ([[3]], [[1]], [[2]]) - sage: stt[0].parent() is stt + sage: stt[0].parent() is stt # needs sage.libs.flint True """ # Iterate through the PartitionTuples and then the tableaux @@ -4597,9 +4599,9 @@ def __init__(self, level, size): EXAMPLES:: - sage: StandardTableauTuples(size=4,level=3) + sage: StandardTableauTuples(size=4, level=3) # needs sage.libs.flint Standard tableau tuples of level 3 and size 4 - sage: StandardTableauTuples(size=4,level=3) is StandardTableauTuples(3,4) + sage: StandardTableauTuples(size=4, level=3) is StandardTableauTuples(3,4) # needs sage.libs.flint True """ StandardTableauTuples.__init__(self) @@ -4617,7 +4619,7 @@ def _repr_(self): EXAMPLES:: - sage: StandardTableauTuples(3, 4) # indirect doctest + sage: StandardTableauTuples(3, 4) # indirect doctest # needs sage.libs.flint Standard tableau tuples of level 3 and size 4 """ return f"Standard tableau tuples of level {self.level()} and size {self.size()}" @@ -4629,20 +4631,20 @@ def __contains__(self, t): EXAMPLES:: - sage: tabs = StandardTableauTuples(level=4, size=3); tabs + sage: tabs = StandardTableauTuples(level=4, size=3); tabs # needs sage.libs.flint Standard tableau tuples of level 4 and size 3 - sage: [[[1,2]],[],[[3]],[]] in tabs + sage: [[[1,2]],[],[[3]],[]] in tabs # needs sage.libs.flint True - sage: tabs([[[1,2]],[],[[3]],[]]) == StandardTableauTuple([[[1,2]],[],[[3]],[]]) + sage: tabs([[[1,2]],[],[[3]],[]]) == StandardTableauTuple([[[1,2]],[],[[3]],[]]) # needs sage.libs.flint True - sage: StandardTableauTuple([[[1, 2]], [[3]]]) in tabs + sage: StandardTableauTuple([[[1, 2]], [[3]]]) in tabs # needs sage.libs.flint False - sage: Tableau([[1]]) in tabs + sage: Tableau([[1]]) in tabs # needs sage.libs.flint False Check that :trac:`14145` is fixed:: - sage: 1 in StandardTableauTuples(level=4, size=3) + sage: 1 in StandardTableauTuples(level=4, size=3) # needs sage.libs.flint False """ if isinstance(t, self.element_class): @@ -4661,9 +4663,9 @@ def cardinality(self): EXAMPLES:: - sage: StandardTableauTuples(3,2).cardinality() + sage: StandardTableauTuples(3,2).cardinality() # needs sage.libs.flint 12 - sage: StandardTableauTuples(4,6).cardinality() + sage: StandardTableauTuples(4,6).cardinality() # needs sage.libs.flint 31936 """ from sage.combinat.partition_tuple import PartitionTuples @@ -4680,8 +4682,8 @@ def __iter__(self): EXAMPLES:: - sage: stt = StandardTableauTuples(3,3) - sage: stt[0:8] + sage: stt = StandardTableauTuples(3, 3) # needs sage.libs.flint + sage: stt[0:8] # needs sage.libs.flint [([[1, 2, 3]], [], []), ([[1, 2], [3]], [], []), ([[1, 3], [2]], [], []), @@ -4690,9 +4692,9 @@ def __iter__(self): ([[1, 3]], [[2]], []), ([[2, 3]], [[1]], []), ([[1], [2]], [[3]], [])] - sage: stt[40] + sage: stt[40] # needs sage.libs.flint ([], [[2, 3]], [[1]]) - sage: stt[0].parent() is stt + sage: stt[0].parent() is stt # needs sage.libs.flint True """ # Iterate through the PartitionTuples and then the tableaux @@ -4707,9 +4709,9 @@ def an_element(self): EXAMPLES:: - sage: StandardTableauTuples(5,size=2).an_element() + sage: StandardTableauTuples(5, size=2).an_element() # needs sage.libs.flint ([], [], [], [], [[1], [2]]) - sage: StandardTableauTuples(2,size=4).an_element() + sage: StandardTableauTuples(2, size=4).an_element() # needs sage.libs.flint ([[1]], [[2, 3], [4]]) """ if self.size() == 0: @@ -4823,8 +4825,8 @@ def __iter__(self): TESTS:: - sage: correct_number=lambda mu : StandardTableauTuples(mu).cardinality()==len(StandardTableauTuples(mu).list()) - sage: all(correct_number(mu) for mu in PartitionTuples(4,4)) + sage: correct_number = lambda mu: StandardTableauTuples(mu).cardinality()==len(StandardTableauTuples(mu).list()) + sage: all(correct_number(mu) for mu in PartitionTuples(4,4)) # needs sage.libs.flint True """ mu = self.shape() diff --git a/src/sage/combinat/tiling.py b/src/sage/combinat/tiling.py index aaa9a7227b8..60de0696d3e 100644 --- a/src/sage/combinat/tiling.py +++ b/src/sage/combinat/tiling.py @@ -109,8 +109,8 @@ Showing one solution:: sage: solution = next(T.solve()) # long time - sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time # optional - sage.plot - sage: G.show(aspect_ratio=1, axes=False) # long time # optional - sage.plot + sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time, needs sage.plot + sage: G.show(aspect_ratio=1, axes=False) # long time # needs sage.plot 1d Easy Example --------------- @@ -162,8 +162,8 @@ sage: T = TilingSolver(L, box=(8,8), reflection=True) sage: solution = next(T.solve()) # long time (7s) - sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time (<1s) # optional - sage.plot - sage: G.show(aspect_ratio=1, axes=False) # long time (2s) # optional - sage.plot + sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time (<1s), needs sage.plot + sage: G.show(aspect_ratio=1, axes=False) # long time (2s) # needs sage.plot Compute the number of solutions:: @@ -198,8 +198,8 @@ sage: T = TilingSolver(L, box=(8,8,1)) sage: solution = next(T.solve()) # long time (8s) - sage: G = sum([p.show3d(size=0.85) for p in solution], Graphics()) # long time (<1s) - sage: G.show(aspect_ratio=1, viewer='tachyon') # long time (2s) + sage: G = sum([p.show3d(size=0.85) for p in solution], Graphics()) # long time (<1s), needs sage.plot + sage: G.show(aspect_ratio=1, viewer='tachyon') # long time (2s) # needs sage.plot Let us compute the number of solutions:: @@ -218,8 +218,8 @@ sage: T.number_of_solutions() 10 sage: solution = next(T.solve()) - sage: G = sum([p.show2d() for p in solution], Graphics()) # optional - sage.plot - sage: G.show(aspect_ratio=1) # long time (2s) # optional - sage.plot + sage: G = sum([p.show2d() for p in solution], Graphics()) # needs sage.plot + sage: G.show(aspect_ratio=1) # long time (2s) # needs sage.plot :: @@ -240,15 +240,15 @@ sage: from sage.combinat.tiling import Polyomino, TilingSolver sage: Y = Polyomino([(0,0),(1,0),(2,0),(3,0),(2,1)], color='yellow') sage: T = TilingSolver([Y], box=(15,15), reusable=True, reflection=True) - sage: a = T.animate(stop=40); a # long time # optional -- ImageMagick sage.plot + sage: a = T.animate(stop=40); a # long time, optional - imagemagick, needs sage.plot Animation with 40 frames Incremental animation of the solutions (one piece is removed/added at a time):: - sage: a = T.animate('incremental', stop=40) # long time # optional -- ImageMagick sage.plot - sage: a # long time # optional -- ImageMagick sage.plot + sage: a = T.animate('incremental', stop=40) # long time, optional - imagemagick, needs sage.plot + sage: a # long time, optional - imagemagick, needs sage.plot Animation with 40 frames - sage: a.show(delay=50, iterations=1) # long time # optional -- ImageMagick sage.plot + sage: a.show(delay=50, iterations=1) # long time, optional - imagemagick, needs sage.plot 5d Easy Example --------------- @@ -1387,7 +1387,7 @@ def show3d(self, size=1): sage: from sage.combinat.tiling import Polyomino sage: p = Polyomino([(0,0,0), (0,1,0), (1,1,0), (1,1,1)], color='blue') - sage: p.show3d() # long time (2s) # optional -- sage.plot + sage: p.show3d() # long time (2s) # needs sage.plot Graphics3d Object """ assert self._dimension == 3, "Dimension of the polyomino must be 3." @@ -1420,7 +1420,7 @@ def show2d(self, size=0.7, color='black', thickness=1): sage: from sage.combinat.tiling import Polyomino sage: p = Polyomino([(0,0),(1,0),(1,1),(1,2)], color='deeppink') - sage: p.show2d() # long time (0.5s) # optional -- sage.plot + sage: p.show2d() # long time (0.5s) # needs sage.plot Graphics object consisting of 17 graphics primitives """ assert self._dimension == 2, "Dimension of the polyomino must be 2." @@ -1471,12 +1471,12 @@ def self_surrounding(self, radius, remove_incomplete_copies=True, ....: (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, 0), (2, 2), ....: (2, 3), (2, 5), (2, 6), (2, 8)]) sage: solution = H.self_surrounding(8) - sage: G = sum([p.show2d() for p in solution], Graphics()) # optional - sage.plot + sage: G = sum([p.show2d() for p in solution], Graphics()) # needs sage.plot :: sage: solution = H.self_surrounding(8, remove_incomplete_copies=False) - sage: G = sum([p.show2d() for p in solution], Graphics()) # optional - sage.plot + sage: G = sum([p.show2d() for p in solution], Graphics()) # needs sage.plot """ # Define the box to tile @@ -2423,38 +2423,38 @@ def animate(self, partial=None, stop=None, size=0.75, axes=False): sage: from sage.combinat.tiling import Polyomino, TilingSolver sage: y = Polyomino([(0,0),(1,0),(2,0),(3,0),(2,1)], color='cyan') sage: T = TilingSolver([y], box=(5,10), reusable=True, reflection=True) - sage: a = T.animate() # optional - sage.plot - sage: a # optional -- ImageMagick # long time # optional - sage.plot + sage: a = T.animate() # needs sage.plot + sage: a # long time, optional - imagemagick, needs sage.plot Animation with 10 frames Include partial solutions (common prefix between two consecutive solutions):: - sage: a = T.animate('common_prefix') # optional - sage.plot - sage: a # optional -- ImageMagick # long time # optional - sage.plot + sage: a = T.animate('common_prefix') # needs sage.plot + sage: a # long time, optional - imagemagick, needs sage.plot Animation with 19 frames Incremental solutions (one piece removed or added at a time):: - sage: a = T.animate('incremental') # long time (2s) # optional - sage.plot - sage: a # long time (2s) # optional -- ImageMagick sage.plot + sage: a = T.animate('incremental') # long time (2s) # needs sage.plot + sage: a # long time (2s), optional - imagemagick, needs sage.plot Animation with 123 frames :: - sage: a.show() # optional -- ImageMagick # long time # optional - sage.plot + sage: a.show() # long time, optional - imagemagick, needs sage.plot The ``show`` function takes arguments to specify the delay between frames (measured in hundredths of a second, default value 20) and the number of iterations (default value 0, which means to iterate forever). To iterate 4 times with half a second between each frame:: - sage: a.show(delay=50, iterations=4) # optional -- ImageMagick # long time # optional - sage.plot + sage: a.show(delay=50, iterations=4) # long time, optional - imagemagick, needs sage.plot Limit the number of frames:: - sage: a = T.animate('incremental', stop=13) # not tested # optional - sage.plot - sage: a # not tested # optional - sage.plot + sage: a = T.animate('incremental', stop=13) # not tested # needs sage.plot + sage: a # not tested # needs sage.plot Animation with 13 frames """ dimension = self._box._dimension diff --git a/src/sage/combinat/triangles_FHM.py b/src/sage/combinat/triangles_FHM.py index 43f2947a51b..bb197442c33 100644 --- a/src/sage/combinat/triangles_FHM.py +++ b/src/sage/combinat/triangles_FHM.py @@ -12,11 +12,11 @@ The M-triangle class is motivated by the generating series of Möbius numbers for graded posets. A typical example is:: - sage: W = SymmetricGroup(4) # optional - sage.groups - sage: posets.NoncrossingPartitions(W).M_triangle() # optional - sage.graphs sage.groups + sage: W = SymmetricGroup(4) # needs sage.groups + sage: posets.NoncrossingPartitions(W).M_triangle() # needs sage.graphs sage.groups M: x^3*y^3 - 6*x^2*y^3 + 6*x^2*y^2 + 10*x*y^3 - 16*x*y^2 - 5*y^3 + 6*x*y + 10*y^2 - 6*y + 1 - sage: unicode_art(_) # optional - sage.graphs sage.modules sage.groups + sage: unicode_art(_) # needs sage.graphs sage.groups sage.modules ⎛ -5 10 -6 1⎞ ⎜ 10 -16 6 0⎟ ⎜ -6 6 0 0⎟ @@ -27,11 +27,11 @@ think about complete fans endowed with a distinguished maximal cone. A typical example is:: - sage: C = ClusterComplex(['A',3]) - sage: f = C.greedy_facet() - sage: C.F_triangle(f) + sage: C = ClusterComplex(['A',3]) # needs sage.graphs sage.modules + sage: f = C.greedy_facet() # needs sage.graphs sage.modules + sage: C.F_triangle(f) # needs sage.graphs sage.modules F: 5*x^3 + 5*x^2*y + 3*x*y^2 + y^3 + 10*x^2 + 8*x*y + 3*y^2 + 6*x + 3*y + 1 - sage: unicode_art(_) # optional - sage.modules + sage: unicode_art(_) # needs sage.graphs sage.modules ⎛ 1 0 0 0⎞ ⎜ 3 3 0 0⎟ ⎜ 3 8 5 0⎟ @@ -67,7 +67,7 @@ def _matrix_display(self, variables=None): sage: from sage.combinat.triangles_FHM import _matrix_display sage: x, y = PolynomialRing(QQ,['x', 'y']).gens() - sage: _matrix_display(x**2+x*y+y**3) # optional - sage.modules + sage: _matrix_display(x**2+x*y+y**3) # needs sage.modules [1 0 0] [0 0 0] [0 1 0] @@ -76,10 +76,10 @@ def _matrix_display(self, variables=None): With a specific choice of variables:: sage: x, y, z = PolynomialRing(QQ,['x','y','z']).gens() - sage: _matrix_display(x**2+z*x*y+z*y**3+z*x,[y,z]) # optional - sage.modules + sage: _matrix_display(x**2+z*x*y+z*y**3+z*x,[y,z]) # needs sage.modules [ x x 0 1] [x^2 0 0 0] - sage: _matrix_display(x**2+z*x*y+z*y**3+z*x,[x,z]) # optional - sage.modules + sage: _matrix_display(x**2+z*x*y+z*y**3+z*x,[x,z]) # needs sage.modules [ y^3 y + 1 0] [ 0 0 1] """ @@ -124,7 +124,7 @@ class Triangle(SageObject): sage: from sage.combinat.triangles_FHM import Triangle sage: x, y = polygens(ZZ, 'x,y') sage: ht = Triangle(1+4*x+2*x*y) - sage: unicode_art(ht) # optional - sage.modules + sage: unicode_art(ht) # needs sage.modules ⎛0 2⎞ ⎝1 4⎠ """ @@ -136,7 +136,7 @@ def __init__(self, poly, variables=None): sage: from sage.combinat.triangles_FHM import Triangle sage: x, y = polygens(ZZ, 'x,y') sage: ht = Triangle(1+2*x*y) - sage: unicode_art(ht) # optional - sage.modules + sage: unicode_art(ht) # needs sage.modules ⎛0 2⎞ ⎝1 0⎠ """ @@ -156,7 +156,7 @@ def _ascii_art_(self): sage: from sage.combinat.triangles_FHM import H_triangle sage: x, y = polygens(ZZ, 'x,y') sage: ht = H_triangle(1+2*x*y) - sage: ascii_art(ht) # optional - sage.modules + sage: ascii_art(ht) # needs sage.modules [0 2] [1 0] """ @@ -171,7 +171,7 @@ def _unicode_art_(self): sage: from sage.combinat.triangles_FHM import H_triangle sage: x, y = polygens(ZZ, 'x,y') sage: ht = H_triangle(1+2*x*y) - sage: unicode_art(ht) # optional - sage.modules + sage: unicode_art(ht) # needs sage.modules ⎛0 2⎞ ⎝1 0⎠ """ @@ -200,7 +200,7 @@ def _latex_(self): sage: from sage.combinat.triangles_FHM import H_triangle sage: x, y = polygens(ZZ, 'x,y') sage: ht = H_triangle(1+2*x*y) - sage: latex(ht) # optional - sage.modules + sage: latex(ht) # needs sage.modules \left(\begin{array}{rr} 0 & 2 \\ 1 & 0 @@ -296,7 +296,7 @@ def matrix(self): sage: from sage.combinat.triangles_FHM import H_triangle sage: x, y = polygens(ZZ, 'x,y') sage: h = H_triangle(1+2*x*y) - sage: h.matrix() # optional - sage.modules + sage: h.matrix() # needs sage.modules [0 2] [1 0] """ @@ -350,8 +350,8 @@ class M_triangle(Triangle): EXAMPLES:: sage: x, y = polygens(ZZ, 'x,y') - sage: P = Poset({2:[1]}) - sage: P.M_triangle() + sage: P = Poset({2: [1]}) # needs sage.graphs + sage: P.M_triangle() # needs sage.graphs M: x*y - y + 1 """ _prefix = 'M' @@ -398,9 +398,9 @@ def transmute(self): sage: x, y = polygens(ZZ, 'x,y') sage: nc3 = x^2*y^2 - 3*x*y^2 + 3*x*y + 2*y^2 - 3*y + 1 sage: m = M_triangle(nc3) - sage: m2 = m.transmute(); m2 + sage: m2 = m.transmute(); m2 # needs sage.libs.flint M: 2*x^2*y^2 - 3*x*y^2 + 2*x*y + y^2 - 2*y + 1 - sage: m2.transmute() == m + sage: m2.transmute() == m # needs sage.libs.flint True """ return self.h().transpose().m() @@ -557,9 +557,9 @@ def gamma(self): sage: H_triangle(ht).gamma() Γ: y^2 + x - sage: W = SymmetricGroup(5) # optional - sage.groups - sage: P = posets.NoncrossingPartitions(W) # optional - sage.graphs - sage: P.M_triangle().h().gamma() # optional - sage.graphs sage.groups + sage: W = SymmetricGroup(5) # needs sage.groups + sage: P = posets.NoncrossingPartitions(W) # needs sage.graphs + sage: P.M_triangle().h().gamma() # needs sage.graphs sage.groups Γ: y^4 + 3*x*y^2 + 2*x^2 + 2*x*y + x """ x, y = self._vars diff --git a/src/sage/combinat/yang_baxter_graph.py b/src/sage/combinat/yang_baxter_graph.py index 306e8063f63..519724d36f7 100644 --- a/src/sage/combinat/yang_baxter_graph.py +++ b/src/sage/combinat/yang_baxter_graph.py @@ -68,7 +68,7 @@ def YangBaxterGraph(partition=None, root=None, operators=None): The ``partition`` keyword is a shorthand for the above construction:: - sage: Y = YangBaxterGraph(partition=[3,1]); Y # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]); Y # needs sage.combinat Yang-Baxter graph of [3, 1], with top vertex (0, 2, 1, 0) sage: Y.vertices(sort=True) [(0, 2, 1, 0), (2, 0, 1, 0), (2, 1, 0, 0)] @@ -79,25 +79,25 @@ def YangBaxterGraph(partition=None, root=None, operators=None): sage: swappers = [SwapIncreasingOperator(i) for i in range(3)] sage: Y = YangBaxterGraph(root=(1,2,3,4), operators=swappers); Y Yang-Baxter graph with root vertex (1, 2, 3, 4) - sage: Y.plot() # optional - sage.plot + sage: Y.plot() # needs sage.plot Graphics object consisting of 97 graphics primitives The Cayley graph of a finite group can be realized as a Yang-Baxter graph:: sage: def left_multiplication_by(g): ....: return lambda h: h*g - sage: G = CyclicPermutationGroup(4) # optional - sage.groups - sage: operators = [ left_multiplication_by(gen) for gen in G.gens() ] # optional - sage.groups - sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # optional - sage.groups + sage: G = CyclicPermutationGroup(4) # needs sage.groups + sage: operators = [ left_multiplication_by(gen) for gen in G.gens() ] # needs sage.groups + sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # needs sage.groups Yang-Baxter graph with root vertex () - sage: Y.plot(edge_labels=False) # optional - sage.groups sage.plot + sage: Y.plot(edge_labels=False) # needs sage.groups sage.plot Graphics object consisting of 9 graphics primitives - sage: G = SymmetricGroup(4) # optional - sage.groups - sage: operators = [left_multiplication_by(gen) for gen in G.gens()] # optional - sage.groups - sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # optional - sage.groups + sage: G = SymmetricGroup(4) # needs sage.groups + sage: operators = [left_multiplication_by(gen) for gen in G.gens()] # needs sage.groups + sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # needs sage.groups Yang-Baxter graph with root vertex () - sage: Y.plot(edge_labels=False) # optional - sage.groups sage.plot + sage: Y.plot(edge_labels=False) # needs sage.groups sage.plot Graphics object consisting of 96 graphics primitives AUTHORS: @@ -361,7 +361,7 @@ def root(self): sage: Y = YangBaxterGraph(root=(1,0,3,2,1,0), operators=ops) sage: Y.root() (1, 0, 3, 2, 1, 0) - sage: Y = YangBaxterGraph(partition=[3,2]) # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]) # needs sage.combinat sage: Y.root() (1, 0, 2, 1, 0) """ @@ -392,9 +392,9 @@ def plot(self, *args, **kwds): sage: from sage.combinat.yang_baxter_graph import SwapIncreasingOperator sage: ops = [SwapIncreasingOperator(i) for i in range(4)] sage: Y = YangBaxterGraph(root=(1,0,2,1,0), operators=ops) - sage: Y.plot() # optional - sage.plot + sage: Y.plot() # needs sage.plot Graphics object consisting of 16 graphics primitives - sage: Y.plot(edge_labels=False) # optional - sage.plot + sage: Y.plot(edge_labels=False) # needs sage.plot Graphics object consisting of 11 graphics primitives """ if "edge_labels" not in kwds: @@ -572,9 +572,9 @@ def __init__(self, partition): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2,1]); Y # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2,1]); Y # needs sage.combinat Yang-Baxter graph of [3, 2, 1], with top vertex (0, 1, 0, 2, 1, 0) - sage: loads(dumps(Y)) == Y # optional - sage.combinat + sage: loads(dumps(Y)) == Y # needs sage.combinat True AUTHORS: @@ -592,8 +592,8 @@ def __repr__(self): r""" EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2]) # optional - sage.combinat - sage: Y.__repr__() # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]) # needs sage.combinat + sage: Y.__repr__() # needs sage.combinat 'Yang-Baxter graph of [3, 2], with top vertex (1, 0, 2, 1, 0)' """ return "Yang-Baxter graph of %s, with top vertex %s" % (self._partition, self._root) @@ -604,13 +604,13 @@ def __copy__(self): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2]); Y # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]); Y # needs sage.combinat Yang-Baxter graph of [3, 2], with top vertex (1, 0, 2, 1, 0) - sage: B = copy(Y); B # optional - sage.combinat + sage: B = copy(Y); B # needs sage.combinat Yang-Baxter graph of [3, 2], with top vertex (1, 0, 2, 1, 0) - sage: Y is B # optional - sage.combinat + sage: Y is B # needs sage.combinat False - sage: Y == B # optional - sage.combinat + sage: Y == B # needs sage.combinat True """ from copy import copy @@ -626,10 +626,10 @@ def _digraph(self): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[2,1]) # optional - sage.combinat - sage: Y._digraph # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[2,1]) # needs sage.combinat + sage: Y._digraph # needs sage.combinat Digraph on 2 vertices - sage: Y.edges() # optional - sage.combinat + sage: Y.edges() # needs sage.combinat [((0, 1, 0), (1, 0, 0), Swap positions 0 and 1)] """ digraph = super()._digraph @@ -645,8 +645,8 @@ def _vertex_ordering(self): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2]) # optional - sage.combinat - sage: Y._vertex_ordering # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]) # needs sage.combinat + sage: Y._vertex_ordering # needs sage.combinat [(1, 0, 2, 1, 0), (1, 2, 0, 1, 0), (1, 2, 1, 0, 0), (2, 1, 0, 1, 0), (2, 1, 1, 0, 0)] """ return self._digraph.vertices(sort=True) @@ -661,8 +661,8 @@ def __iter__(self): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2]) # optional - sage.combinat - sage: list(Y.__iter__()) # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]) # needs sage.combinat + sage: list(Y.__iter__()) # needs sage.combinat [(1, 0, 2, 1, 0), (1, 2, 0, 1, 0), (1, 2, 1, 0, 0), (2, 1, 0, 1, 0), (2, 1, 1, 0, 0)] """ yield from self._vertex_ordering @@ -679,14 +679,14 @@ def _swap_operator(self, operator, u): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,1]) # optional - sage.combinat - sage: from sage.combinat.yang_baxter_graph import SwapOperator # optional - sage.combinat - sage: ops = [SwapOperator(i) for i in range(3)] # optional - sage.combinat - sage: [Y._swap_operator(op, (1,2,3,4)) for op in ops] # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]) # needs sage.combinat + sage: from sage.combinat.yang_baxter_graph import SwapOperator # needs sage.combinat + sage: ops = [SwapOperator(i) for i in range(3)] # needs sage.combinat + sage: [Y._swap_operator(op, (1,2,3,4)) for op in ops] # needs sage.combinat [(2, 1, 3, 4), (1, 3, 2, 4), (1, 2, 4, 3)] - sage: [Y._swap_operator(op, [4,3,2,1]) for op in ops] # optional - sage.combinat + sage: [Y._swap_operator(op, [4,3,2,1]) for op in ops] # needs sage.combinat [[3, 4, 2, 1], [4, 2, 3, 1], [4, 3, 1, 2]] - sage: [Y._swap_operator(op, Permutation([1,2,3,4])) for op in ops] # optional - sage.combinat + sage: [Y._swap_operator(op, Permutation([1,2,3,4])) for op in ops] # needs sage.combinat [[2, 1, 3, 4], [1, 3, 2, 4], [1, 2, 4, 3]] """ return operator(u) @@ -709,12 +709,12 @@ def vertex_relabelling_dict(self, v): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,1]) # optional - sage.combinat - sage: Y.vertex_relabelling_dict((1,2,3,4)) # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]) # needs sage.combinat + sage: Y.vertex_relabelling_dict((1,2,3,4)) # needs sage.combinat {(0, 2, 1, 0): (1, 2, 3, 4), (2, 0, 1, 0): (2, 1, 3, 4), (2, 1, 0, 0): (2, 3, 1, 4)} - sage: Y.vertex_relabelling_dict((4,3,2,1)) # optional - sage.combinat + sage: Y.vertex_relabelling_dict((4,3,2,1)) # needs sage.combinat {(0, 2, 1, 0): (4, 3, 2, 1), (2, 0, 1, 0): (3, 4, 2, 1), (2, 1, 0, 0): (3, 2, 4, 1)} @@ -736,14 +736,14 @@ def relabel_vertices(self, v, inplace=True): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,1]); Y # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]); Y # needs sage.combinat Yang-Baxter graph of [3, 1], with top vertex (0, 2, 1, 0) - sage: d = Y.relabel_vertices((1,2,3,4), inplace=False); d # optional - sage.combinat + sage: d = Y.relabel_vertices((1,2,3,4), inplace=False); d # needs sage.combinat Digraph on 3 vertices - sage: Y.vertices(sort=True) # optional - sage.combinat + sage: Y.vertices(sort=True) # needs sage.combinat [(0, 2, 1, 0), (2, 0, 1, 0), (2, 1, 0, 0)] - sage: e = Y.relabel_vertices((1,2,3,4)); e # optional - sage.combinat - sage: Y.vertices(sort=True) # optional - sage.combinat + sage: e = Y.relabel_vertices((1,2,3,4)); e # needs sage.combinat + sage: Y.vertices(sort=True) # needs sage.combinat [(1, 2, 3, 4), (2, 1, 3, 4), (2, 3, 1, 4)] """ relabelling = self.vertex_relabelling_dict(v) @@ -910,7 +910,7 @@ def __call__(self, u): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[2,2]) # optional - sage.combinat + sage: Y = YangBaxterGraph(partition=[2,2]) # needs sage.combinat sage: from sage.combinat.yang_baxter_graph import SwapIncreasingOperator sage: operators = [SwapIncreasingOperator(i) for i in range(3)] sage: [op((1,2,3,4)) for op in operators] From d804ab15926e1778f9d4eace27570fcb1b97ef90 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 12 Jul 2023 23:37:44 -0700 Subject: [PATCH 378/494] Update # needs --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index d3bcdc3e2f0..32d985f29b9 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -1865,7 +1865,7 @@ def number_of_noninversions(self, k) -> Integer: is `\binom{n}{2}` minus its number of inversions:: sage: b = binomial(5, 2) # needs sage.symbolic - sage: all( x.number_of_noninversions(2) == b - x.number_of_inversions() + sage: all( x.number_of_noninversions(2) == b - x.number_of_inversions() # needs sage.symbolic ....: for x in Permutations(5) ) True From 6367a85daea806c69246eca60f32f2ff2cf9bfa9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 13 Jul 2023 23:27:04 -0700 Subject: [PATCH 379/494] sage.combinat: Update # needs --- src/sage/combinat/binary_tree.py | 39 +- src/sage/combinat/combinat.py | 2 +- src/sage/combinat/diagram_algebras.py | 40 +- src/sage/combinat/finite_state_machine.py | 53 ++- .../finite_state_machine_generators.py | 82 ++-- src/sage/combinat/free_module.py | 67 +-- src/sage/combinat/interval_posets.py | 58 ++- .../multiset_partition_into_sets_ordered.py | 59 +-- src/sage/combinat/partition.py | 108 +++-- src/sage/combinat/partition_tuple.py | 18 +- src/sage/combinat/quickref.py | 2 +- src/sage/combinat/ribbon_tableau.py | 15 +- src/sage/combinat/set_partition.py | 20 +- src/sage/combinat/skew_partition.py | 37 +- src/sage/combinat/skew_tableau.py | 9 +- src/sage/combinat/subword_complex.py | 447 ++++++++++-------- src/sage/combinat/subword_complex_c.pyx | 13 +- .../symmetric_group_representations.py | 9 +- src/sage/combinat/tableau.py | 63 +-- src/sage/combinat/tableau_tuple.py | 84 ++-- src/sage/combinat/triangles_FHM.py | 11 +- src/sage/combinat/yang_baxter_graph.py | 51 +- 22 files changed, 702 insertions(+), 585 deletions(-) diff --git a/src/sage/combinat/binary_tree.py b/src/sage/combinat/binary_tree.py index 6e39535c6d5..4b65fd72145 100644 --- a/src/sage/combinat/binary_tree.py +++ b/src/sage/combinat/binary_tree.py @@ -989,13 +989,14 @@ def to_dyck_word_tamari(self): EXAMPLES:: - sage: BinaryTree().to_dyck_word_tamari() # needs sage.combinat + sage: # needs sage.combinat + sage: BinaryTree().to_dyck_word_tamari() [] - sage: BinaryTree([]).to_dyck_word_tamari() # needs sage.combinat + sage: BinaryTree([]).to_dyck_word_tamari() [1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word_tamari() # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word_tamari() [1, 1, 0, 0, 1, 0] - sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word_tamari() # needs sage.combinat + sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word_tamari() [1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0] """ return self.to_dyck_word("L1R0") @@ -1256,21 +1257,22 @@ def to_dyck_word(self, usemap="1L0R"): EXAMPLES:: - sage: BinaryTree().to_dyck_word() # needs sage.combinat + sage: # needs sage.combinat + sage: BinaryTree().to_dyck_word() [] - sage: BinaryTree([]).to_dyck_word() # needs sage.combinat + sage: BinaryTree([]).to_dyck_word() [1, 0] - sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word() # needs sage.combinat + sage: BinaryTree([[[], [[], None]], [[], []]]).to_dyck_word() [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word() # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word() [1, 1, 0, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("1R0L") # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("1R0L") [1, 0, 1, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("L1R0") # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("L1R0") [1, 1, 0, 0, 1, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("R1L0") # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("R1L0") [1, 1, 0, 1, 0, 0] - sage: BinaryTree([[None,[]],None]).to_dyck_word("R10L") # needs sage.combinat + sage: BinaryTree([[None,[]],None]).to_dyck_word("R10L") Traceback (most recent call last): ... ValueError: R10L is not a correct map @@ -3412,17 +3414,18 @@ def dendriform_shuffle(self, other): TESTS:: - sage: list(u.dendriform_shuffle(u)) # needs sage.combinat + sage: # needs sage.combinat + sage: list(u.dendriform_shuffle(u)) [.] - sage: list(u.dendriform_shuffle(g)) # needs sage.combinat + sage: list(u.dendriform_shuffle(g)) [[., .]] - sage: list(u.dendriform_shuffle(l)) # needs sage.combinat + sage: list(u.dendriform_shuffle(l)) [[[., .], .]] - sage: list(u.dendriform_shuffle(r)) # needs sage.combinat + sage: list(u.dendriform_shuffle(r)) [[., [., .]]] - sage: list(r.dendriform_shuffle(u)) # needs sage.combinat + sage: list(r.dendriform_shuffle(u)) [[., [., .]]] - sage: list(l.dendriform_shuffle(u)) # needs sage.combinat + sage: list(l.dendriform_shuffle(u)) [[[., .], .]] """ from sage.combinat.words.shuffle_product import ShuffleProduct_w1w2 diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 8583ffa89ca..5796f8ee9bc 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -1528,7 +1528,7 @@ class CombinatorialElement(CombinatorialObject, Element, Check classcalls:: - sage: class Foo(CombinatorialElement): + sage: class Foo(CombinatorialElement): # needs sage.combinat ....: @staticmethod ....: def __classcall__(cls, x): ....: return x diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index ecc794e27d2..775db86da77 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -2413,24 +2413,26 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): :: - sage: q = var('q') # needs sage.symbolic - sage: PA = PartitionAlgebra(2, q); PA # needs sage.symbolic + sage: # needs sage.symbolic + sage: q = var('q') + sage: PA = PartitionAlgebra(2, q); PA Partition Algebra of rank 2 with parameter q over Symbolic Ring - sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]]) # needs sage.symbolic + sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]]) True - sage: ((PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 # needs sage.symbolic + sage: ((PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 ....: == (4*q-4)*PA([[1, 2], [-2, -1]]) + PA([[2, -2], [1, -1]])) True The identity element of the partition algebra is the set partition `\{\{1,-1\}, \{2,-2\}, \ldots, \{k,-k\}\}`:: - sage: P = PA.basis().list() # needs sage.symbolic - sage: PA.one() # needs sage.symbolic + sage: # needs sage.symbolic + sage: P = PA.basis().list() + sage: PA.one() P{{-2, 2}, {-1, 1}} - sage: PA.one() * P[7] == P[7] # needs sage.symbolic + sage: PA.one() * P[7] == P[7] True - sage: P[7] * PA.one() == P[7] # needs sage.symbolic + sage: P[7] * PA.one() == P[7] True We now give some further examples of the use of the other arguments. @@ -2455,14 +2457,15 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): of the partition algebra (e.g., ``BrauerAlgebra`` and ``TemperleyLiebAlgebra``) can also be coerced into the partition algebra:: - sage: S = SymmetricGroupAlgebra(SR, 2) # needs sage.symbolic - sage: B = BrauerAlgebra(2, x, SR) # needs sage.symbolic - sage: A = PartitionAlgebra(2, x, SR) # needs sage.symbolic - sage: S([2,1]) * A([[1,-1],[2,-2]]) # needs sage.symbolic + sage: # needs sage.symbolic + sage: S = SymmetricGroupAlgebra(SR, 2) + sage: B = BrauerAlgebra(2, x, SR) + sage: A = PartitionAlgebra(2, x, SR) + sage: S([2,1]) * A([[1,-1],[2,-2]]) P{{-2, 1}, {-1, 2}} - sage: B([[-1,-2],[2,1]]) * A([[1],[-1],[2,-2]]) # needs sage.symbolic + sage: B([[-1,-2],[2,1]]) * A([[1],[-1],[2,-2]]) P{{-2}, {-1}, {1, 2}} - sage: A([[1],[-1],[2,-2]]) * B([[-1,-2],[2,1]]) # needs sage.symbolic + sage: A([[1],[-1],[2,-2]]) * B([[-1,-2],[2,1]]) P{{-2, -1}, {1}, {2}} The same is true if the elements come from a subalgebra of a partition @@ -3836,11 +3839,12 @@ def jucys_murphy(self, j): EXAMPLES:: - sage: z = var('z') # needs sage.symbolic - sage: B = BrauerAlgebra(3,z) # needs sage.symbolic - sage: B.jucys_murphy(1) # needs sage.symbolic + sage: # needs sage.symbolic + sage: z = var('z') + sage: B = BrauerAlgebra(3,z) + sage: B.jucys_murphy(1) (1/2*z-1/2)*B{{-3, 3}, {-2, 2}, {-1, 1}} - sage: B.jucys_murphy(3) # needs sage.symbolic + sage: B.jucys_murphy(3) -B{{-3, -2}, {-1, 1}, {2, 3}} - B{{-3, -1}, {-2, 2}, {1, 3}} + B{{-3, 1}, {-2, 2}, {-1, 3}} + B{{-3, 2}, {-2, 3}, {-1, 1}} + (1/2*z-1/2)*B{{-3, 3}, {-2, 2}, {-1, 1}} diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index fb5b19ff83e..78ee1b6ff1a 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -983,13 +983,14 @@ def full_group_by(l, key=None): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.combinat.finite_state_machine import full_group_by - sage: t = [2/x, 1/x, 2/x] # needs sage.symbolic - sage: r = full_group_by([0, 1, 2], key=lambda i: t[i]) # needs sage.symbolic - sage: sorted(r, key=lambda p: p[1]) # needs sage.symbolic + sage: t = [2/x, 1/x, 2/x] + sage: r = full_group_by([0, 1, 2], key=lambda i: t[i]) + sage: sorted(r, key=lambda p: p[1]) [(2/x, [0, 2]), (1/x, [1])] sage: from itertools import groupby - sage: for k, elements in groupby(sorted([0, 1, 2], # needs sage.symbolic + sage: for k, elements in groupby(sorted([0, 1, 2], ....: key=lambda i:t[i]), ....: key=lambda i:t[i]): ....: print("{} {}".format(k, list(elements))) @@ -4122,17 +4123,18 @@ def is_Markov_chain(self, is_zero=None): If the probabilities are variables in the symbolic ring, :func:`~sage.symbolic.assumptions.assume` will do the trick:: - sage: var('p q') # needs sage.symbolic + sage: # needs sage.symbolic + sage: var('p q') (p, q) - sage: F = Transducer([(0, 0, p, 1), (0, 0, q, 0)], # needs sage.symbolic + sage: F = Transducer([(0, 0, p, 1), (0, 0, q, 0)], ....: on_duplicate_transition=duplicate_transition_add_input) - sage: assume(p + q == 1) # needs sage.symbolic - sage: (p + q - 1).is_zero() # needs sage.symbolic + sage: assume(p + q == 1) + sage: (p + q - 1).is_zero() True - sage: F.is_Markov_chain() # needs sage.symbolic + sage: F.is_Markov_chain() True - sage: forget() # needs sage.symbolic - sage: del(p, q) # needs sage.symbolic + sage: forget() + sage: del(p, q) If the probabilities are variables in some polynomial ring, the parameter ``is_zero`` can be used:: @@ -10034,12 +10036,13 @@ def asymptotic_moments(self, variable=None): Now, we actually compute the asymptotic moments:: - sage: moments = NAFweight.asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + sage: # needs sage.symbolic + sage: moments = NAFweight.asymptotic_moments() + sage: moments['expectation'] 1/3*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 2/27*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] Order(1) #. This is Example 3.16 in [HKW2015]_, where a transducer with @@ -10050,17 +10053,18 @@ def asymptotic_moments(self, variable=None): :: - sage: var('a_1, a_2, a_3, a_4') # needs sage.symbolic + sage: # needs sage.symbolic + sage: var('a_1, a_2, a_3, a_4') (a_1, a_2, a_3, a_4) - sage: T = Transducer([[0, 0, 0, a_1], [0, 1, 1, a_3], # needs sage.symbolic + sage: T = Transducer([[0, 0, 0, a_1], [0, 1, 1, a_3], ....: [1, 0, 0, a_4], [1, 1, 1, a_2]], ....: initial_states=[0], final_states=[0, 1]) - sage: moments = T.asymptotic_moments() # needs sage.symbolic + sage: moments = T.asymptotic_moments() verbose 0 (...) Non-integer output weights lead to significant performance degradation. - sage: moments['expectation'] # needs sage.symbolic + sage: moments['expectation'] 1/4*(a_1 + a_2 + a_3 + a_4)*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] -1/4*(a_1 - a_2)*n + Order(1) Therefore, the asymptotic covariance vanishes if and only if @@ -10072,12 +10076,13 @@ def asymptotic_moments(self, variable=None): :ref:`example on Gray code `):: - sage: moments = transducers.GrayCode().asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + sage: # needs sage.symbolic + sage: moments = transducers.GrayCode().asymptotic_moments() + sage: moments['expectation'] 1/2*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 1/4*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] Order(1) #. This is the first part of Example 4.4 in [HKW2015]_, diff --git a/src/sage/combinat/finite_state_machine_generators.py b/src/sage/combinat/finite_state_machine_generators.py index 827de1f054a..aacc520999a 100644 --- a/src/sage/combinat/finite_state_machine_generators.py +++ b/src/sage/combinat/finite_state_machine_generators.py @@ -1079,15 +1079,16 @@ def _parse_recursion_equation_(self, equation, base, function, var, EXAMPLES:: - sage: var('n') # needs sage.symbolic + sage: # needs sage.symbolic + sage: var('n') n - sage: function('f') # needs sage.symbolic + sage: function('f') f - sage: transducers._parse_recursion_equation_( # needs sage.symbolic + sage: transducers._parse_recursion_equation_( ....: f(8*n + 7) == f(2*n + 3) + 5, ....: 2, f, n) RecursionRule(K=3, r=7, k=1, s=3, t=[5]) - sage: transducers._parse_recursion_equation_( # needs sage.symbolic + sage: transducers._parse_recursion_equation_( ....: f(42) == 5, ....: 2, f, n) {42: [5]} @@ -1434,17 +1435,18 @@ def Recursion(self, recursions, base, function=None, var=None, - The following example computes the Hamming weight of the ternary expansion of integers. :: - sage: function('f') # needs sage.symbolic + sage: # needs sage.symbolic + sage: function('f') f - sage: var('n') # needs sage.symbolic + sage: var('n') n - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(3*n + 1) == f(n) + 1, ....: f(3*n + 2) == f(n) + 1, ....: f(3*n) == f(n), ....: f(0) == 0], ....: 3, f, n) - sage: T.transitions() # needs sage.symbolic + sage: T.transitions() [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (0, 0): 1|1, Transition from (0, 0) to (0, 0): 2|1] @@ -1452,13 +1454,14 @@ def Recursion(self, recursions, base, function=None, var=None, To illustrate what this transducer does, we consider the example of `n=601`:: - sage: ternary_expansion = 601.digits(base=3) # needs sage.symbolic - sage: ternary_expansion # needs sage.symbolic + sage: # needs sage.symbolic + sage: ternary_expansion = 601.digits(base=3) + sage: ternary_expansion [1, 2, 0, 1, 1, 2] - sage: weight_sequence = T(ternary_expansion) # needs sage.symbolic - sage: weight_sequence # needs sage.symbolic + sage: weight_sequence = T(ternary_expansion) + sage: weight_sequence [1, 1, 1, 1, 1] - sage: sum(weight_sequence) # needs sage.symbolic + sage: sum(weight_sequence) 5 Note that the digit zero does not show up in the output because @@ -1468,24 +1471,25 @@ def Recursion(self, recursions, base, function=None, var=None, - The following example computes the Hamming weight of the non-adjacent form, cf. the :wikipedia:`Non-adjacent_form`. :: - sage: function('f') # needs sage.symbolic + sage: # needs sage.symbolic + sage: function('f') f - sage: var('n') # needs sage.symbolic + sage: var('n') n - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(4*n + 1) == f(n) + 1, ....: f(4*n - 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 0], ....: 2, f, n) - sage: T.transitions() # needs sage.symbolic + sage: T.transitions() [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (0, 0): 0|1, Transition from (1, 1) to (1, 0): 1|1, Transition from (1, 0) to (1, 1): 0|-, Transition from (1, 0) to (1, 0): 1|-] - sage: [(s.label(), s.final_word_out) # needs sage.symbolic + sage: [(s.label(), s.final_word_out) ....: for s in T.iter_final_states()] [((0, 0), []), ((1, 1), [1]), @@ -1535,11 +1539,12 @@ def Recursion(self, recursions, base, function=None, var=None, the point of view of this method---is a contradicting recursion. We override this by the parameter ``is_zero``. :: - sage: var('n') # needs sage.symbolic + sage: # needs sage.symbolic + sage: var('n') n - sage: function('f w') # needs sage.symbolic + sage: function('f w') (f, w) - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(2*n) == f(n) + w(0), ....: f(4*n + 1) == f(n) + w(1, 0), ....: f(4*n - 1) == f(n) + w(-1, 0), @@ -1547,14 +1552,14 @@ def Recursion(self, recursions, base, function=None, var=None, ....: 2, f, n, ....: word_function=w, ....: is_zero=lambda x: sum(x).is_zero()) - sage: T.transitions() # needs sage.symbolic + sage: T.transitions() [Transition from (0, 0) to (0, 0): 0|0, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (0, 0): 0|1,0, Transition from (1, 1) to (1, 0): 1|-1,0, Transition from (1, 0) to (1, 1): 0|-, Transition from (1, 0) to (1, 0): 1|0] - sage: for s in T.iter_states(): # needs sage.symbolic + sage: for s in T.iter_states(): ....: print("{} {}".format(s, s.final_word_out)) (0, 0) [] (1, 1) [1, 0] @@ -1582,16 +1587,17 @@ def Recursion(self, recursions, base, function=None, var=None, - Here is an artificial example where some of the `s` are negative:: - sage: function('f') # needs sage.symbolic + sage: # needs sage.symbolic + sage: function('f') f - sage: var('n') # needs sage.symbolic + sage: var('n') n - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(2*n + 1) == f(n-1) + 1, ....: f(2*n) == f(n), ....: f(1) == 1, ....: f(0) == 0], 2, f, n) - sage: T.transitions() # needs sage.symbolic + sage: T.transitions() [Transition from (0, 0) to (0, 0): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (1, 1) to (-1, 1): 0|1, @@ -1602,7 +1608,7 @@ def Recursion(self, recursions, base, function=None, var=None, Transition from (-1, 2) to (0, 0): 1|1, Transition from (1, 2) to (-1, 2): 0|1, Transition from (1, 2) to (1, 2): 1|1] - sage: [(s.label(), s.final_word_out) # needs sage.symbolic + sage: [(s.label(), s.final_word_out) ....: for s in T.iter_final_states()] [((0, 0), []), ((1, 1), [1]), @@ -1613,7 +1619,8 @@ def Recursion(self, recursions, base, function=None, var=None, - Abelian complexity of the paperfolding sequence (cf. [HKP2015]_, Example 2.8):: - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(4*n) == f(2*n), ....: f(4*n+2) == f(2*n+1)+1, ....: f(16*n+1) == f(8*n+1), @@ -1623,7 +1630,7 @@ def Recursion(self, recursions, base, function=None, var=None, ....: f(1) == 2, f(0) == 0] ....: + [f(16*n+jj) == f(2*n+1)+2 for jj in [3,7,9,13]], ....: 2, f, n) - sage: T.transitions() # needs sage.symbolic + sage: T.transitions() [Transition from (0, 0) to (0, 1): 0|-, Transition from (0, 0) to (1, 1): 1|-, Transition from (0, 1) to (0, 1): 0|-, @@ -1644,7 +1651,7 @@ def Recursion(self, recursions, base, function=None, var=None, Transition from (7, 3) to (2, 1): 1|1, Transition from (2, 1) to (1, 1): 0|1, Transition from (2, 1) to (2, 1): 1|-] - sage: for s in T.iter_states(): # needs sage.symbolic + sage: for s in T.iter_states(): ....: print("{} {}".format(s, s.final_word_out)) (0, 0) [] (0, 1) [] @@ -1656,27 +1663,28 @@ def Recursion(self, recursions, base, function=None, var=None, (3, 3) [2, 2] (7, 3) [2, 2] (2, 1) [1, 2] - sage: list(sum(T(n.bits())) for n in srange(1, 21)) # needs sage.symbolic + sage: list(sum(T(n.bits())) for n in srange(1, 21)) [2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 4, 5, 6, 5] - We now demonstrate the use of the ``output_rings`` parameter. If no ``output_rings`` are specified, the output labels are converted into ``ZZ``:: - sage: function('f') # needs sage.symbolic + sage: # needs sage.symbolic + sage: function('f') f - sage: var('n') # needs sage.symbolic + sage: var('n') n - sage: T = transducers.Recursion([ # needs sage.symbolic + sage: T = transducers.Recursion([ ....: f(2*n + 1) == f(n) + 1, ....: f(2*n) == f(n), ....: f(0) == 2], ....: 2, f, n) - sage: for t in T.transitions(): # needs sage.symbolic + sage: for t in T.transitions(): ....: print([x.parent() for x in t.word_out]) [] [Integer Ring] - sage: [x.parent() for x in T.states()[0].final_word_out] # needs sage.symbolic + sage: [x.parent() for x in T.states()[0].final_word_out] [Integer Ring] In contrast, if ``output_rings`` is set to the empty list, the diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index f425c56c97d..75bc46be1e8 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -252,11 +252,12 @@ class CombinatorialFreeModule(UniqueRepresentation, Module, IndexedGenerators): TESTS:: - sage: XQ = SchubertPolynomialRing(QQ) # needs sage.combinat - sage: XZ = SchubertPolynomialRing(ZZ) # needs sage.combinat - sage: XQ == XZ # needs sage.combinat + sage: # needs sage.combinat + sage: XQ = SchubertPolynomialRing(QQ) + sage: XZ = SchubertPolynomialRing(ZZ) + sage: XQ == XZ False - sage: XQ == XQ # needs sage.combinat + sage: XQ == XQ True We check that issue :trac:`28681` is fixed:: @@ -692,10 +693,11 @@ def _element_constructor_(self, x): Here is a real life example illustrating that this yielded mathematically wrong results:: - sage: S = SymmetricFunctions(QQ) # needs sage.combinat - sage: s = S.s(); p = S.p() # needs sage.combinat - sage: ss = tensor([s,s]); pp = tensor([p,p]) # needs sage.combinat - sage: a = tensor((s[2],s[2])) # needs sage.combinat + sage: # needs sage.combinat + sage: S = SymmetricFunctions(QQ) + sage: s = S.s(); p = S.p() + sage: ss = tensor([s,s]); pp = tensor([p,p]) + sage: a = tensor((s[2],s[2])) The following originally used to yield ``p[[2]] # p[[2]]``, and if there was no natural coercion between ``s`` and ``p``, this would @@ -836,13 +838,14 @@ def _coerce_map_from_(self, R): sage: C.has_coerce_map_from(CQ) False - sage: CF2 = CombinatorialFreeModule(GF(2), Set([1,2])) # needs sage.rings.finite_rings - sage: CF2.has_coerce_map_from(C) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: CF2 = CombinatorialFreeModule(GF(2), Set([1,2])) + sage: CF2.has_coerce_map_from(C) True - sage: c = C.monomial(1) # needs sage.rings.finite_rings - sage: CF2(2*c) # needs sage.rings.finite_rings + sage: c = C.monomial(1) + sage: CF2(2*c) 0 - sage: CF2(3*c) # needs sage.rings.finite_rings + sage: CF2(3*c) B[1] """ if isinstance(R, CombinatorialFreeModule): @@ -928,11 +931,12 @@ def set_order(self, order): EXAMPLES:: - sage: QS2 = SymmetricGroupAlgebra(QQ,2) # needs sage.combinat - sage: b = list(QS2.basis().keys()) # needs sage.combinat - sage: b.reverse() # needs sage.combinat - sage: QS2.set_order(b) # needs sage.combinat - sage: QS2.get_order() # needs sage.combinat + sage: # needs sage.combinat + sage: QS2 = SymmetricGroupAlgebra(QQ,2) + sage: b = list(QS2.basis().keys()) + sage: b.reverse() + sage: QS2.set_order(b) + sage: QS2.get_order() [[2, 1], [1, 2]] """ self._order = order @@ -1003,11 +1007,12 @@ def from_vector(self, vector, order=None, coerce=True): EXAMPLES:: - sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat - sage: b = QS3.from_vector(vector((2, 0, 0, 0, 0, 4))); b # needs sage.combinat + sage: # needs sage.combinat + sage: QS3 = SymmetricGroupAlgebra(QQ, 3) + sage: b = QS3.from_vector(vector((2, 0, 0, 0, 0, 4))); b 2*[1, 2, 3] + 4*[3, 2, 1] - sage: a = 2*QS3([1,2,3]) + 4*QS3([3,2,1]) # needs sage.combinat - sage: a == b # needs sage.combinat + sage: a = 2*QS3([1,2,3]) + 4*QS3([3,2,1]) + sage: a == b True """ if order is None: @@ -1210,21 +1215,23 @@ def _from_dict(self, d, coerce=False, remove_zeros=True): EXAMPLES:: - sage: e = SymmetricFunctions(QQ).elementary() # needs sage.combinat - sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat - sage: a = e([2,1]) + e([1,1,1]); a # needs sage.combinat + sage: # needs sage.combinat + sage: e = SymmetricFunctions(QQ).elementary() + sage: s = SymmetricFunctions(QQ).schur() + sage: a = e([2,1]) + e([1,1,1]); a e[1, 1, 1] + e[2, 1] - sage: s._from_dict(a.monomial_coefficients()) # needs sage.combinat + sage: s._from_dict(a.monomial_coefficients()) s[1, 1, 1] + s[2, 1] If the optional argument ``coerce`` is ``True``, then the coefficients are coerced into the base ring of ``self``:: - sage: part = Partition([2,1]) # needs sage.combinat - sage: d = {part: 1} # needs sage.combinat - sage: a = s._from_dict(d, coerce=True); a # needs sage.combinat + sage: # needs sage.combinat + sage: part = Partition([2,1]) + sage: d = {part: 1} + sage: a = s._from_dict(d, coerce=True); a s[2, 1] - sage: a.coefficient(part).parent() # needs sage.combinat + sage: a.coefficient(part).parent() Rational Field With ``remove_zeros=True``, zero coefficients are removed:: diff --git a/src/sage/combinat/interval_posets.py b/src/sage/combinat/interval_posets.py index 9a1dc86457f..dc104833cd1 100644 --- a/src/sage/combinat/interval_posets.py +++ b/src/sage/combinat/interval_posets.py @@ -611,11 +611,12 @@ def factor(self) -> list[TamariIntervalPoset]: TESTS:: - sage: T = TamariIntervalPosets(20).random_element() # needs sage.combinat - sage: facs = factor(T) # needs sage.combinat - sage: all(U.is_connected() for U in facs) # needs sage.combinat + sage: # needs sage.combinat + sage: T = TamariIntervalPosets(20).random_element() + sage: facs = factor(T) + sage: all(U.is_connected() for U in facs) True - sage: T == prod(facs) # needs sage.combinat + sage: T == prod(facs) True """ hasse = self.poset().hasse_diagram() @@ -2511,11 +2512,12 @@ def new_decomposition(self) -> list[TIP]: TESTS:: - sage: ex = TamariIntervalPosets(4).random_element() # needs sage.combinat - sage: dec = ex.new_decomposition() # needs sage.combinat - sage: len(dec) == ex.number_of_new_components() # needs sage.combinat + sage: # needs sage.combinat + sage: ex = TamariIntervalPosets(4).random_element() + sage: dec = ex.new_decomposition() + sage: len(dec) == ex.number_of_new_components() True - sage: all(u.is_new() for u in dec) # needs sage.combinat + sage: all(u.is_new() for u in dec) True """ from sage.combinat.binary_tree import BinaryTree @@ -3036,11 +3038,12 @@ def final_forest(element) -> TIP: From Dyck words:: - sage: dw = DyckWord([1,0]) # needs sage.combinat - sage: TamariIntervalPosets.final_forest(dw) # needs sage.combinat + sage: # needs sage.combinat + sage: dw = DyckWord([1,0]) + sage: TamariIntervalPosets.final_forest(dw) The Tamari interval of size 1 induced by relations [] - sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # needs sage.combinat - sage: TamariIntervalPosets.final_forest(dw) # needs sage.combinat + sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) + sage: TamariIntervalPosets.final_forest(dw) The Tamari interval of size 5 induced by relations [(5, 4), (3, 1), (2, 1)] TESTS:: @@ -3149,11 +3152,12 @@ def initial_forest(element) -> TIP: from Dyck words:: - sage: dw = DyckWord([1,0]) # needs sage.combinat - sage: TamariIntervalPosets.initial_forest(dw) # needs sage.combinat + sage: # needs sage.combinat + sage: dw = DyckWord([1,0]) + sage: TamariIntervalPosets.initial_forest(dw) The Tamari interval of size 1 induced by relations [] - sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) # needs sage.combinat - sage: TamariIntervalPosets.initial_forest(dw) # needs sage.combinat + sage: dw = DyckWord([1,1,0,1,0,0,1,1,0,0]) + sage: TamariIntervalPosets.initial_forest(dw) The Tamari interval of size 5 induced by relations [(1, 4), (2, 3), (3, 4)] TESTS:: @@ -3274,13 +3278,14 @@ def from_dyck_words(dw1, dw2) -> TIP: EXAMPLES:: - sage: dw1 = DyckWord([1,0,1,0]) # needs sage.combinat - sage: dw2 = DyckWord([1,1,0,0]) # needs sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1, dw2) # needs sage.combinat + sage: # needs sage.combinat + sage: dw1 = DyckWord([1,0,1,0]) + sage: dw2 = DyckWord([1,1,0,0]) + sage: TamariIntervalPosets.from_dyck_words(dw1, dw2) The Tamari interval of size 2 induced by relations [] - sage: TamariIntervalPosets.from_dyck_words(dw1,dw1) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,dw1) The Tamari interval of size 2 induced by relations [(1, 2)] - sage: TamariIntervalPosets.from_dyck_words(dw2,dw2) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw2,dw2) The Tamari interval of size 2 induced by relations [(2, 1)] sage: dw1 = DyckWord([1,0,1,1,1,0,0,1,1,0,0,0]) # needs sage.combinat @@ -3822,14 +3827,15 @@ def random_element(self) -> TIP: EXAMPLES:: - sage: T = TamariIntervalPosets(4).random_element() # needs sage.combinat - sage: T.parent() # needs sage.combinat + sage: # needs sage.combinat + sage: T = TamariIntervalPosets(4).random_element() + sage: T.parent() Interval-posets - sage: u = T.lower_dyck_word(); u # random # needs sage.combinat + sage: u = T.lower_dyck_word(); u # random [1, 1, 0, 1, 0, 0, 1, 0] - sage: v = T.lower_dyck_word(); v # random # needs sage.combinat + sage: v = T.lower_dyck_word(); v # random [1, 1, 0, 1, 0, 0, 1, 0] - sage: len(u) # needs sage.combinat + sage: len(u) 8 """ from sage.graphs.schnyder import minimal_schnyder_wood diff --git a/src/sage/combinat/multiset_partition_into_sets_ordered.py b/src/sage/combinat/multiset_partition_into_sets_ordered.py index decfc60aa45..10ce01e8cc5 100755 --- a/src/sage/combinat/multiset_partition_into_sets_ordered.py +++ b/src/sage/combinat/multiset_partition_into_sets_ordered.py @@ -3268,14 +3268,15 @@ def _an_element_(self): EXAMPLES:: - sage: B = crystals.Minimaj(4,5,3) # needs sage.modules - sage: B.an_element() # needs sage.modules + sage: # needs sage.modules + sage: B = crystals.Minimaj(4,5,3) + sage: B.an_element() ((2, 3, 1), (1,), (1,)) - sage: B = crystals.Minimaj(2,2,1) # needs sage.modules - sage: B.an_element() # needs sage.modules + sage: B = crystals.Minimaj(2,2,1) + sage: B.an_element() ((1, 2),) - sage: B = crystals.Minimaj(1,2,1) # needs sage.modules - sage: B.an_element() # needs sage.modules + sage: B = crystals.Minimaj(1,2,1) + sage: B.an_element() Traceback (most recent call last): ... EmptySetError @@ -3291,14 +3292,15 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: B1 = crystals.Minimaj(4,5,3); b = B1.an_element(); b # needs sage.modules + sage: # needs sage.modules + sage: B1 = crystals.Minimaj(4,5,3); b = B1.an_element(); b ((2, 3, 1), (1,), (1,)) - sage: B1._element_constructor_(list(b)) # needs sage.modules + sage: B1._element_constructor_(list(b)) ((2, 3, 1), (1,), (1,)) - sage: B1._element_constructor_([[1,2,3], [2], [2]]) # needs sage.modules + sage: B1._element_constructor_([[1,2,3], [2], [2]]) ((3, 1, 2), (2,), (2,)) - sage: B2 = crystals.Minimaj(5,5,3) # needs sage.modules - sage: B2._element_constructor_(b) # needs sage.modules + sage: B2 = crystals.Minimaj(5,5,3) + sage: B2._element_constructor_(b) ((2, 3, 1), (1,), (1,)) """ # Allow ``x`` to be either of: @@ -3322,17 +3324,18 @@ def __contains__(self, x): EXAMPLES:: - sage: B1 = crystals.Minimaj(2,5,3); b1 = B1.an_element(); b1 # needs sage.modules + sage: # needs sage.modules + sage: B1 = crystals.Minimaj(2,5,3); b1 = B1.an_element(); b1 ((1, 2), (2, 1), (1,)) - sage: B2 = crystals.Minimaj(5,5,3); b2 = B2.an_element(); b2 # needs sage.modules + sage: B2 = crystals.Minimaj(5,5,3); b2 = B2.an_element(); b2 ((2, 3, 1), (1,), (1,)) - sage: b2a = B2(((1,2), (1,), (1,2))); b2a # needs sage.modules + sage: b2a = B2(((1,2), (1,), (1,2))); b2a ((2, 1), (1,), (1, 2)) - sage: b1 in B2 # needs sage.modules + sage: b1 in B2 True - sage: b2 in B1 # needs sage.modules + sage: b2 in B1 False - sage: b2a in B1 # needs sage.modules + sage: b2a in B1 True """ if isinstance(x, MinimajCrystal.Element): @@ -3353,24 +3356,26 @@ def from_tableau(self, t): EXAMPLES:: - sage: B = crystals.Minimaj(3,6,3) # needs sage.modules - sage: b = B.an_element(); b # needs sage.modules + sage: # needs sage.modules + sage: B = crystals.Minimaj(3,6,3) + sage: b = B.an_element(); b ((3, 1, 2), (2, 1), (1,)) - sage: t = b.to_tableaux_words(); t # needs sage.modules + sage: t = b.to_tableaux_words(); t [[1], [2, 1], [], [3, 2, 1]] - sage: B.from_tableau(t) # needs sage.modules + sage: B.from_tableau(t) ((3, 1, 2), (2, 1), (1,)) - sage: B.from_tableau(t) == b # needs sage.modules + sage: B.from_tableau(t) == b True TESTS:: - sage: B = crystals.Minimaj(3,6,3) # needs sage.modules - sage: all(mu == B.from_tableau(mu.to_tableaux_words()) for mu in B) # needs sage.modules + sage: # needs sage.modules + sage: B = crystals.Minimaj(3,6,3) + sage: all(mu == B.from_tableau(mu.to_tableaux_words()) for mu in B) True - sage: t = B.an_element().to_tableaux_words() # needs sage.modules - sage: B1 = crystals.Minimaj(3,6,2) # needs sage.modules - sage: B1.from_tableau(t) # needs sage.modules + sage: t = B.an_element().to_tableaux_words() + sage: B1 = crystals.Minimaj(3,6,2) + sage: B1.from_tableau(t) Traceback (most recent call last): ... ValueError: ((3, 1, 2), (2, 1), (1,)) is not an element of diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 1473d00959e..39726dec694 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -1088,14 +1088,15 @@ def power(self, k): Now let us compare this to the power map on `S_8`:: - sage: G = SymmetricGroup(8) # needs sage.groups - sage: g = G([(1,2,3,4,5),(6,7,8)]); g # needs sage.groups + sage: # needs sage.groups + sage: G = SymmetricGroup(8) + sage: g = G([(1,2,3,4,5),(6,7,8)]); g (1,2,3,4,5)(6,7,8) - sage: g^2 # needs sage.groups + sage: g^2 (1,3,5,2,4)(6,8,7) - sage: g^3 # needs sage.groups + sage: g^3 (1,4,2,5,3) - sage: g^4 # needs sage.groups + sage: g^4 (1,5,4,3,2)(6,7,8) :: @@ -1897,36 +1898,38 @@ def cell_poset(self, orientation="SE"): sage: Q.upper_covers((1, 1)) # needs sage.graphs [(1, 2)] - sage: P = p.cell_poset(orientation="NW"); P # needs sage.graphs + sage: # needs sage.graphs + sage: P = p.cell_poset(orientation="NW"); P Finite poset containing 7 elements - sage: sorted(P) # needs sage.graphs + sage: sorted(P) [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: sorted(P.minimal_elements()) # needs sage.graphs + sage: sorted(P.minimal_elements()) [(1, 2), (2, 0)] - sage: P.maximal_elements() # needs sage.graphs + sage: P.maximal_elements() [(0, 0)] - sage: P.upper_covers((2, 0)) # needs sage.graphs + sage: P.upper_covers((2, 0)) [(1, 0)] - sage: sorted(P.upper_covers((1, 2))) # needs sage.graphs + sage: sorted(P.upper_covers((1, 2))) [(0, 2), (1, 1)] - sage: sorted(P.upper_covers((1, 1))) # needs sage.graphs + sage: sorted(P.upper_covers((1, 1))) [(0, 1), (1, 0)] - sage: sorted([len(P.upper_covers(v)) for v in P]) # needs sage.graphs + sage: sorted([len(P.upper_covers(v)) for v in P]) [0, 1, 1, 1, 1, 2, 2] - sage: R = p.cell_poset(orientation="NE"); R # needs sage.graphs + sage: # needs sage.graphs + sage: R = p.cell_poset(orientation="NE"); R Finite poset containing 7 elements - sage: sorted(R) # needs sage.graphs + sage: sorted(R) [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: R.maximal_elements() # needs sage.graphs + sage: R.maximal_elements() [(0, 2)] - sage: R.minimal_elements() # needs sage.graphs + sage: R.minimal_elements() [(2, 0)] - sage: sorted([len(R.upper_covers(v)) for v in R]) # needs sage.graphs + sage: sorted([len(R.upper_covers(v)) for v in R]) [0, 1, 1, 1, 1, 2, 2] - sage: R.is_isomorphic(P) # needs sage.graphs + sage: R.is_isomorphic(P) False - sage: R.is_isomorphic(P.dual()) # needs sage.graphs + sage: R.is_isomorphic(P.dual()) False Linear extensions of ``p.cell_poset()`` are in 1-to-1 correspondence @@ -5409,11 +5412,12 @@ def dual_equivalence_graph(self, directed=False, coloring=None): TESTS:: - sage: G = Partition([1]).dual_equivalence_graph() # needs sage.graphs - sage: G.vertices(sort=False) # needs sage.graphs + sage: # needs sage.graphs + sage: G = Partition([1]).dual_equivalence_graph() + sage: G.vertices(sort=False) [[[1]]] - sage: G = Partition([]).dual_equivalence_graph() # needs sage.graphs - sage: G.vertices(sort=False) # needs sage.graphs + sage: G = Partition([]).dual_equivalence_graph() + sage: G.vertices(sort=False) [[]] sage: P = Partition([3,1,1]) @@ -7060,23 +7064,24 @@ def cardinality(self, algorithm='hybrid'): Further examples:: - sage: Partitions(5, length=3).cardinality() # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: Partitions(5, length=3).cardinality() 2 - sage: Partitions(6, length=3).cardinality() # needs sage.libs.flint + sage: Partitions(6, length=3).cardinality() 3 - sage: Partitions(8, length=4).cardinality() # needs sage.libs.flint + sage: Partitions(8, length=4).cardinality() 5 - sage: Partitions(8, length=5).cardinality() # needs sage.libs.flint + sage: Partitions(8, length=5).cardinality() 3 - sage: Partitions(15, length=6).cardinality() # needs sage.libs.flint + sage: Partitions(15, length=6).cardinality() 26 - sage: Partitions(0, length=0).cardinality() # needs sage.libs.flint + sage: Partitions(0, length=0).cardinality() 1 - sage: Partitions(0, length=1).cardinality() # needs sage.libs.flint + sage: Partitions(0, length=1).cardinality() 0 - sage: Partitions(1, length=0).cardinality() # needs sage.libs.flint + sage: Partitions(1, length=0).cardinality() 0 - sage: Partitions(1, length=4).cardinality() # needs sage.libs.flint + sage: Partitions(1, length=4).cardinality() 0 TESTS: @@ -8475,13 +8480,14 @@ def cardinality(self): EXAMPLES:: - sage: OrderedPartitions(3).cardinality() # needs sage.libs.gap + sage: # needs sage.libs.gap + sage: OrderedPartitions(3).cardinality() 4 - sage: OrderedPartitions(3,2).cardinality() # needs sage.libs.gap + sage: OrderedPartitions(3,2).cardinality() 2 - sage: OrderedPartitions(10,2).cardinality() # needs sage.libs.gap + sage: OrderedPartitions(10,2).cardinality() 9 - sage: OrderedPartitions(15).cardinality() # needs sage.libs.gap + sage: OrderedPartitions(15).cardinality() 16384 """ from sage.libs.gap.libgap import libgap @@ -8982,17 +8988,18 @@ def number_of_partitions(n, algorithm='default'): :: - sage: number_of_partitions(10) # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: number_of_partitions(10) 42 - sage: number_of_partitions(3) # needs sage.libs.flint + sage: number_of_partitions(3) 3 - sage: number_of_partitions(10) # needs sage.libs.flint + sage: number_of_partitions(10) 42 - sage: number_of_partitions(40) # needs sage.libs.flint + sage: number_of_partitions(40) 37338 - sage: number_of_partitions(100) # needs sage.libs.flint + sage: number_of_partitions(100) 190569292 - sage: number_of_partitions(100000) # needs sage.libs.flint + sage: number_of_partitions(100000) 27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519 A generating function for the number of partitions `p_n` is given by the @@ -9070,20 +9077,21 @@ def number_of_partitions_length(n, k, algorithm='hybrid'): EXAMPLES:: + sage: # needs sage.libs.gap sage: from sage.combinat.partition import number_of_partitions_length - sage: number_of_partitions_length(5, 2) # needs sage.libs.gap + sage: number_of_partitions_length(5, 2) 2 - sage: number_of_partitions_length(10, 2) # needs sage.libs.gap + sage: number_of_partitions_length(10, 2) 5 - sage: number_of_partitions_length(10, 4) # needs sage.libs.gap + sage: number_of_partitions_length(10, 4) 9 - sage: number_of_partitions_length(10, 0) # needs sage.libs.gap + sage: number_of_partitions_length(10, 0) 0 - sage: number_of_partitions_length(10, 1) # needs sage.libs.gap + sage: number_of_partitions_length(10, 1) 1 - sage: number_of_partitions_length(0, 0) # needs sage.libs.gap + sage: number_of_partitions_length(0, 0) 1 - sage: number_of_partitions_length(0, 1) # needs sage.libs.gap + sage: number_of_partitions_length(0, 1) 0 """ if algorithm == 'hybrid': diff --git a/src/sage/combinat/partition_tuple.py b/src/sage/combinat/partition_tuple.py index 86ac2400397..ac41cf4d473 100644 --- a/src/sage/combinat/partition_tuple.py +++ b/src/sage/combinat/partition_tuple.py @@ -2416,13 +2416,14 @@ def __iter__(self): EXAMPLES:: - sage: PartitionTuples(2,0).list() #indirect doctest # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: PartitionTuples(2,0).list() #indirect doctest [([], [])] - sage: PartitionTuples(2,1).list() #indirect doctest # needs sage.libs.flint + sage: PartitionTuples(2,1).list() #indirect doctest [([1], []), ([], [1])] - sage: PartitionTuples(2,2).list() #indirect doctest # needs sage.libs.flint + sage: PartitionTuples(2,2).list() #indirect doctest [([2], []), ([1, 1], []), ([1], [1]), ([], [2]), ([], [1, 1])] - sage: PartitionTuples(3,2).list() #indirect doctest # needs sage.libs.flint + sage: PartitionTuples(3,2).list() #indirect doctest [([2], [], []), ([1, 1], [], []), ([1], [1], []), @@ -2473,13 +2474,14 @@ def cardinality(self): The following calls used to fail (:trac:`11476`):: - sage: PartitionTuples(17,2).cardinality() # needs sage.libs.pari + sage: # needs sage.libs.pari + sage: PartitionTuples(17,2).cardinality() 170 - sage: PartitionTuples(2,17).cardinality() # needs sage.libs.pari + sage: PartitionTuples(2,17).cardinality() 8470 - sage: PartitionTuples(100,13).cardinality() # needs sage.libs.pari + sage: PartitionTuples(100,13).cardinality() 110320020147886800 - sage: PartitionTuples(13,90).cardinality() # needs sage.libs.pari + sage: PartitionTuples(13,90).cardinality() 91506473741200186152352843611 These answers were checked against Gap4 (the last of which takes an diff --git a/src/sage/combinat/quickref.py b/src/sage/combinat/quickref.py index b811069f903..87068331980 100644 --- a/src/sage/combinat/quickref.py +++ b/src/sage/combinat/quickref.py @@ -48,7 +48,7 @@ Polytopes:: sage: points = random_matrix(ZZ, 6, 3, x=7).rows() # needs sage.modules - sage: L = LatticePolytope(points) # needs sage.geometry.polyhedron + sage: L = LatticePolytope(points) # needs sage.geometry.polyhedron sage.modules sage: L.npoints(); L.plot3d() # random # needs sage.geometry.polyhedron sage.plot :ref:`Root systems, Coxeter and Weyl groups `:: diff --git a/src/sage/combinat/ribbon_tableau.py b/src/sage/combinat/ribbon_tableau.py index b363666d8bf..db82cbfd660 100644 --- a/src/sage/combinat/ribbon_tableau.py +++ b/src/sage/combinat/ribbon_tableau.py @@ -663,20 +663,21 @@ def spin_polynomial(part, weight, length): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.combinat.ribbon_tableau import spin_polynomial - sage: spin_polynomial([6,6,6],[4,2],3) # needs sage.symbolic + sage: spin_polynomial([6,6,6],[4,2],3) t^6 + t^5 + 2*t^4 + t^3 + t^2 - sage: spin_polynomial([6,6,6],[4,1,1],3) # needs sage.symbolic + sage: spin_polynomial([6,6,6],[4,1,1],3) t^6 + 2*t^5 + 3*t^4 + 2*t^3 + t^2 - sage: spin_polynomial([3,3,3,2,1], [2,2], 3) # needs sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [2,2], 3) t^(7/2) + t^(5/2) - sage: spin_polynomial([3,3,3,2,1], [2,1,1], 3) # needs sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [2,1,1], 3) 2*t^(7/2) + 2*t^(5/2) + t^(3/2) - sage: spin_polynomial([3,3,3,2,1], [1,1,1,1], 3) # needs sage.symbolic + sage: spin_polynomial([3,3,3,2,1], [1,1,1,1], 3) 3*t^(7/2) + 5*t^(5/2) + 3*t^(3/2) + sqrt(t) - sage: spin_polynomial([5,4,3,2,1,1,1], [2,2,1], 3) # needs sage.symbolic + sage: spin_polynomial([5,4,3,2,1,1,1], [2,2,1], 3) 2*t^(9/2) + 6*t^(7/2) + 2*t^(5/2) - sage: spin_polynomial([[6]*6, [3,3]], [4,4,2], 3) # needs sage.symbolic + sage: spin_polynomial([[6]*6, [3,3]], [4,4,2], 3) 3*t^9 + 5*t^8 + 9*t^7 + 6*t^6 + 3*t^5 """ from sage.symbolic.ring import SR diff --git a/src/sage/combinat/set_partition.py b/src/sage/combinat/set_partition.py index 0f8867b2f38..c7d5e98ea33 100644 --- a/src/sage/combinat/set_partition.py +++ b/src/sage/combinat/set_partition.py @@ -466,13 +466,14 @@ def max_block_size(self): EXAMPLES:: - sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams # needs sage.modules - sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]]) # needs sage.modules - sage: pd.max_block_size() # needs sage.modules + sage: # needs sage.modules + sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams + sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]]) + sage: pd.max_block_size() 3 - sage: sorted(d.max_block_size() for d in PartitionDiagrams(2)) # needs sage.modules + sage: sorted(d.max_block_size() for d in PartitionDiagrams(2)) [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4] - sage: sorted(sp.max_block_size() for sp in SetPartitions(3)) # needs sage.modules + sage: sorted(sp.max_block_size() for sp in SetPartitions(3)) [1, 2, 2, 2, 3] """ return max(len(block) for block in self) @@ -2818,13 +2819,14 @@ def cardinality(self): EXAMPLES:: - sage: SetPartitions([1,2,3,4]).cardinality() # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: SetPartitions([1,2,3,4]).cardinality() 15 - sage: SetPartitions(3).cardinality() # needs sage.libs.flint + sage: SetPartitions(3).cardinality() 5 - sage: SetPartitions(3,2).cardinality() # needs sage.libs.flint + sage: SetPartitions(3,2).cardinality() 3 - sage: SetPartitions([]).cardinality() # needs sage.libs.flint + sage: SetPartitions([]).cardinality() 1 """ return bell_number(len(self._set)) diff --git a/src/sage/combinat/skew_partition.py b/src/sage/combinat/skew_partition.py index a5959214243..38685dc7513 100644 --- a/src/sage/combinat/skew_partition.py +++ b/src/sage/combinat/skew_partition.py @@ -858,28 +858,30 @@ def cell_poset(self, orientation="SE"): sage: sorted(Q.upper_covers((0, 2))) # needs sage.graphs [(1, 2)] - sage: P = p.cell_poset(orientation="NW"); P # needs sage.graphs + sage: # needs sage.graphs + sage: P = p.cell_poset(orientation="NW"); P Finite poset containing 4 elements - sage: sorted(P) # needs sage.graphs + sage: sorted(P) [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: sorted(P.minimal_elements()) # needs sage.graphs + sage: sorted(P.minimal_elements()) [(1, 2), (2, 0)] - sage: sorted(P.maximal_elements()) # needs sage.graphs + sage: sorted(P.maximal_elements()) [(0, 2), (1, 1), (2, 0)] - sage: sorted(P.upper_covers((1, 2))) # needs sage.graphs + sage: sorted(P.upper_covers((1, 2))) [(0, 2), (1, 1)] - sage: R = p.cell_poset(orientation="NE"); R # needs sage.graphs + sage: # needs sage.graphs + sage: R = p.cell_poset(orientation="NE"); R Finite poset containing 4 elements - sage: sorted(R) # needs sage.graphs + sage: sorted(R) [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: R.maximal_elements() # needs sage.graphs + sage: R.maximal_elements() [(0, 2)] - sage: R.minimal_elements() # needs sage.graphs + sage: R.minimal_elements() [(2, 0)] - sage: R.upper_covers((2, 0)) # needs sage.graphs + sage: R.upper_covers((2, 0)) [(1, 1)] - sage: sorted([len(R.upper_covers(v)) for v in R]) # needs sage.graphs + sage: sorted([len(R.upper_covers(v)) for v in R]) [0, 1, 1, 1] TESTS: @@ -1068,18 +1070,19 @@ def to_dag(self, format="string"): EXAMPLES:: - sage: dag = SkewPartition([[3, 3, 1], [1, 1]]).to_dag() # needs sage.graphs - sage: dag.edges(sort=True) # needs sage.graphs + sage: # needs sage.graphs + sage: dag = SkewPartition([[3, 3, 1], [1, 1]]).to_dag() + sage: dag.edges(sort=True) [('0,1', '0,2', None), ('0,1', '1,1', None), ('0,2', '1,2', None), ('1,1', '1,2', None)] - sage: dag.vertices(sort=True) # needs sage.graphs + sage: dag.vertices(sort=True) ['0,1', '0,2', '1,1', '1,2', '2,0'] - sage: dag = SkewPartition([[3, 2, 1], [1, 1]]).to_dag(format="tuple") # needs sage.graphs - sage: dag.edges(sort=True) # needs sage.graphs + sage: dag = SkewPartition([[3, 2, 1], [1, 1]]).to_dag(format="tuple") + sage: dag.edges(sort=True) [((0, 1), (0, 2), None), ((0, 1), (1, 1), None)] - sage: dag.vertices(sort=True) # needs sage.graphs + sage: dag.vertices(sort=True) [(0, 1), (0, 2), (1, 1), (2, 0)] """ outer = list(self.outer()) diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index 43ae3fa5db6..7bc3ffbd89a 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -2080,13 +2080,14 @@ def cardinality(self): """ EXAMPLES:: - sage: StandardSkewTableaux(1).cardinality() # needs sage.modules + sage: # needs sage.modules + sage: StandardSkewTableaux(1).cardinality() 1 - sage: StandardSkewTableaux(2).cardinality() # needs sage.modules + sage: StandardSkewTableaux(2).cardinality() 4 - sage: StandardSkewTableaux(3).cardinality() # needs sage.modules + sage: StandardSkewTableaux(3).cardinality() 24 - sage: StandardSkewTableaux(4).cardinality() # needs sage.modules + sage: StandardSkewTableaux(4).cardinality() 194 """ count = 0 diff --git a/src/sage/combinat/subword_complex.py b/src/sage/combinat/subword_complex.py index a3ae554fd85..e92ad8ea237 100644 --- a/src/sage/combinat/subword_complex.py +++ b/src/sage/combinat/subword_complex.py @@ -133,10 +133,11 @@ class SubwordComplexFacet(Simplex, Element): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: F = SC[0]; F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: F = SC[0]; F (0, 1) sage: W = CoxeterGroup(['A',2]) @@ -210,12 +211,13 @@ def _extended_root_configuration_indices(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: F = SC([1,2]); F (1, 2) - sage: F._extended_root_configuration_indices() # optional - gap3 + sage: F._extended_root_configuration_indices() [0, 2, 3, 2, 1] sage: W = CoxeterGroup(['A',2]) @@ -250,12 +252,13 @@ def _root_configuration_indices(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: F = SC([1,2]); F (1, 2) - sage: F._root_configuration_indices() # optional - gap3 + sage: F._root_configuration_indices() [2, 3] sage: W = CoxeterGroup(['A',2]) @@ -289,12 +292,13 @@ def extended_root_configuration(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.extended_root_configuration() # optional - gap3 + sage: F.extended_root_configuration() [(1, 0), (1, 1), (-1, 0), (1, 1), (0, 1)] sage: W = CoxeterGroup(['A',2]) @@ -323,12 +327,13 @@ def root_configuration(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.root_configuration() # optional - gap3 + sage: F.root_configuration() [(1, 1), (-1, 0)] sage: W = CoxeterGroup(['A',2]) @@ -411,20 +416,22 @@ def is_vertex(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',1]) # optional - gap3 - sage: w = W.from_reduced_word([1]) # optional - gap3 - sage: SC = SubwordComplex([1,1,1],w) # optional - gap3 - sage: F = SC([0,1]); F.is_vertex() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',1]) + sage: w = W.from_reduced_word([1]) + sage: SC = SubwordComplex([1,1,1],w) + sage: F = SC([0,1]); F.is_vertex() True - sage: F = SC([0,2]); F.is_vertex() # optional - gap3 + sage: F = SC([0,2]); F.is_vertex() False - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1,2,1],w) # optional - gap3 - sage: F = SC([0,1,2,3]); F.is_vertex() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1,2,1],w) + sage: F = SC([0,1,2,3]); F.is_vertex() True - sage: F = SC([0,1,2,6]); F.is_vertex() # optional - gap3 + sage: F = SC([0,1,2,6]); F.is_vertex() False sage: W = CoxeterGroup(['A',2]) @@ -452,10 +459,11 @@ def root_cone(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',1]) # optional - gap3 - sage: w = W.from_reduced_word([1]) # optional - gap3 - sage: SC = SubwordComplex([1,1,1],w) # optional - gap3 - sage: F = SC([0,2]); F.root_cone() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',1]) + sage: w = W.from_reduced_word([1]) + sage: SC = SubwordComplex([1,1,1],w) + sage: F = SC([0,2]); F.root_cone() 1-d cone in 1-d lattice N sage: W = CoxeterGroup(['A',1]) @@ -472,14 +480,15 @@ def upper_root_configuration(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.root_configuration() # optional - gap3 + sage: F.root_configuration() [(1, 1), (-1, 0)] - sage: F.upper_root_configuration() # optional - gap3 + sage: F.upper_root_configuration() [(1, 0)] sage: W = CoxeterGroup(['A',2]) @@ -523,13 +532,14 @@ def extended_weight_configuration(self, coefficients=None): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]) # optional - gap3 - sage: F.extended_weight_configuration() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]) + sage: F.extended_weight_configuration() [(2/3, 1/3), (1/3, 2/3), (-1/3, 1/3), (1/3, 2/3), (-1/3, 1/3)] - sage: F.extended_weight_configuration(coefficients=(1,2)) # optional - gap3 + sage: F.extended_weight_configuration(coefficients=(1,2)) [(2/3, 1/3), (2/3, 4/3), (-1/3, 1/3), (2/3, 4/3), (-1/3, 1/3)] sage: W = CoxeterGroup(['A',2]) @@ -578,12 +588,13 @@ def weight_configuration(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.weight_configuration() # optional - gap3 + sage: F.weight_configuration() [(1/3, 2/3), (-1/3, 1/3)] sage: W = CoxeterGroup(['A',2]) @@ -609,14 +620,15 @@ def weight_cone(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: WC = F.weight_cone(); WC # optional - gap3 + sage: WC = F.weight_cone(); WC 2-d cone in 2-d lattice N - sage: WC.rays() # optional - gap3 + sage: WC.rays() N( 1, 2), N(-1, 1) in 2-d lattice N @@ -649,16 +661,17 @@ def brick_vector(self, coefficients=None): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.extended_weight_configuration() # optional - gap3 + sage: F.extended_weight_configuration() [(2/3, 1/3), (1/3, 2/3), (-1/3, 1/3), (1/3, 2/3), (-1/3, 1/3)] - sage: F.brick_vector() # optional - gap3 + sage: F.brick_vector() (2/3, 7/3) - sage: F.brick_vector(coefficients=[1,2]) # optional - gap3 + sage: F.brick_vector(coefficients=[1,2]) (4/3, 11/3) sage: W = CoxeterGroup(['A',2]) @@ -691,14 +704,15 @@ def flip(self, i, return_position=False): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F (1, 2) - sage: F.flip(1) # optional - gap3 + sage: F.flip(1) (2, 3) - sage: F.flip(1, return_position=True) # optional - gap3 + sage: F.flip(1, return_position=True) ((2, 3), 3) sage: W = CoxeterGroup(['A',2]) @@ -752,10 +766,11 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14, EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F.plot() # optional - gap3, needs sage.plot + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F.plot() # needs sage.plot Graphics object consisting of 26 graphics primitives sage: W = CoxeterGroup(['A',2]) @@ -764,20 +779,22 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14, sage: F = SC([1,2]); F.plot() # needs sage.plot Graphics object consisting of 26 graphics primitives - sage: W = ReflectionGroup(['B',3]) # optional - gap3 - sage: c = W.from_reduced_word([1,2,3]) # optional - gap3 - sage: Q = c.reduced_word()*2 + W.w0.coxeter_sorting_word(c) # optional - gap3 - sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 - sage: F = SC[15]; F.plot() # optional - gap3, needs sage.plot + sage: # optional - gap3 + sage: W = ReflectionGroup(['B',3]) + sage: c = W.from_reduced_word([1,2,3]) + sage: Q = c.reduced_word()*2 + W.w0.coxeter_sorting_word(c) + sage: SC = SubwordComplex(Q, W.w0) + sage: F = SC[15]; F.plot() # needs sage.plot Graphics object consisting of 53 graphics primitives TESTS:: - sage: W = ReflectionGroup(['D',4]) # optional - gap3 - sage: c = W.from_reduced_word([1,2,3,4]) # optional - gap3 - sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) # optional - gap3 - sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 - sage: F = SC[1]; F.plot() # optional - gap3, needs sage.plot + sage: # optional - gap3 + sage: W = ReflectionGroup(['D',4]) + sage: c = W.from_reduced_word([1,2,3,4]) + sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) + sage: SC = SubwordComplex(Q, W.w0) + sage: F = SC[1]; F.plot() # needs sage.plot Traceback (most recent call last): ... ValueError: plotting is currently only implemented for irreducibles types A, B, and C. @@ -971,10 +988,11 @@ def show(self, *kwds, **args): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 - sage: F = SC([1,2]); F.show() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1],w) + sage: F = SC([1,2]); F.show() """ return self.plot().show(*kwds, **args) @@ -1005,11 +1023,12 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex): :: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w); SC # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w); SC Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] - sage: SC.facets() # optional - gap3 + sage: SC.facets() [(0, 1), (0, 4), (1, 2), (2, 3), (3, 4)] sage: W = CoxeterGroup(['A',2]) @@ -1023,11 +1042,12 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex): TESTS:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC1 = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC2 = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC1 == SC2 # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC1 = SubwordComplex([1,2,1,2,1], w) + sage: SC2 = SubwordComplex([1,2,1,2,1], w) + sage: SC1 == SC2 True sage: W = CoxeterGroup(['A',2]) @@ -1047,10 +1067,11 @@ def __classcall__(cls, Q, w, algorithm="inductive"): TESTS:: - sage: W = ReflectionGroup(['B',2]) # optional - gap3 - sage: S = SubwordComplex((1,2)*3,W.w0) # optional - gap3 - sage: T = SubwordComplex([1,2]*3,W.w0) # optional - gap3 - sage: S is T # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['B',2]) + sage: S = SubwordComplex((1,2)*3,W.w0) + sage: T = SubwordComplex([1,2]*3,W.w0) + sage: S is T True sage: W = CoxeterGroup(['B',2]) @@ -1077,11 +1098,12 @@ def __init__(self, Q, w, algorithm="inductive"): EXAMPLES:: - sage: W = ReflectionGroup(['A',3]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,3,1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,3,1,2,3,1,2,1], w); SC # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',3]) + sage: w = W.from_reduced_word([1,2,3,1,2,1]) + sage: SC = SubwordComplex([1,2,3,1,2,3,1,2,1], w); SC Subword complex of type ['A', 3] for Q = (1, 2, 3, 1, 2, 3, 1, 2, 1) and pi = [1, 2, 1, 3, 2, 1] - sage: len(SC) # optional - gap3 + sage: len(SC) 14 sage: W = CoxeterGroup(['A',3]) @@ -1095,10 +1117,11 @@ def __init__(self, Q, w, algorithm="inductive"): Check for methods from the enumerated sets category:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: list(SC) # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: list(SC) [(0, 1), (0, 4), (1, 2), (2, 3), (3, 4)] sage: W = CoxeterGroup(['A',2]) @@ -1208,20 +1231,21 @@ def __contains__(self, F): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.facets() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.facets() [(0, 1), (0, 4), (1, 2), (2, 3), (3, 4)] - sage: [0,1] in SC # optional - gap3 + sage: [0,1] in SC True - sage: [0,2] in SC # optional - gap3 + sage: [0,2] in SC False - sage: [0,1,5] in SC # optional - gap3 + sage: [0,1,5] in SC False - sage: [0] in SC # optional - gap3 + sage: [0] in SC False - sage: ['a','b'] in SC # optional - gap3 + sage: ['a','b'] in SC False sage: W = CoxeterGroup(['A',2]) @@ -1255,10 +1279,11 @@ def group(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.group() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.group() Irreducible real reflection group of rank 2 and type A2 sage: W = CoxeterGroup(['A',2]) @@ -1277,10 +1302,11 @@ def cartan_type(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.cartan_type() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.cartan_type() ['A', 2] sage: W = CoxeterGroup(['A',2]) @@ -1300,10 +1326,11 @@ def word(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.word() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.word() (1, 2, 1, 2, 1) sage: W = CoxeterGroup(['A',2]) @@ -1320,10 +1347,11 @@ def pi(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.pi().reduced_word() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.pi().reduced_word() [1, 2, 1] sage: W = CoxeterGroup(['A',2]) @@ -1340,10 +1368,11 @@ def facets(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.facets() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.facets() [(0, 1), (0, 4), (1, 2), (2, 3), (3, 4)] sage: W = CoxeterGroup(['A',2]) @@ -1363,10 +1392,11 @@ def __iter__(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: for I in SC: print(I) # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: for I in SC: print(I) (0, 1) (0, 4) (1, 2) @@ -1393,12 +1423,13 @@ def greedy_facet(self, side="positive"): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.greedy_facet(side="positive") # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.greedy_facet(side="positive") (0, 1) - sage: SC.greedy_facet(side="negative") # optional - gap3 + sage: SC.greedy_facet(side="negative") (3, 4) sage: W = CoxeterGroup(['A',2]) @@ -1420,10 +1451,11 @@ def is_sphere(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',3]) # optional - gap3 - sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 - sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 - sage: SC.is_sphere() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',3]) + sage: w = W.from_reduced_word([2,3,2]) + sage: SC = SubwordComplex([3,2,3,2,3], w) + sage: SC.is_sphere() True sage: SC = SubwordComplex([3,2,1,3,2,3], w) # optional - gap3 @@ -1448,10 +1480,11 @@ def is_ball(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',3]) # optional - gap3 - sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 - sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 - sage: SC.is_ball() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',3]) + sage: w = W.from_reduced_word([2,3,2]) + sage: SC = SubwordComplex([3,2,3,2,3], w) + sage: SC.is_ball() False sage: SC = SubwordComplex([3,2,1,3,2,3], w) # optional - gap3 @@ -1472,10 +1505,11 @@ def is_pure(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',3]) # optional - gap3 - sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 - sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 - sage: SC.is_pure() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',3]) + sage: w = W.from_reduced_word([2,3,2]) + sage: SC = SubwordComplex([3,2,3,2,3], w) + sage: SC.is_pure() True sage: W = CoxeterGroup(['A',3]) @@ -1544,10 +1578,11 @@ def is_double_root_free(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.is_double_root_free() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.is_double_root_free() True sage: SC = SubwordComplex([1,1,2,2,1,1], w) # optional - gap3 @@ -1583,11 +1618,12 @@ def kappa_preimages(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: kappa = SC.kappa_preimages() # optional - gap3 - sage: for F in SC: print("{} {}".format(F, [w.reduced_word() for w in kappa[F]])) # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: kappa = SC.kappa_preimages() + sage: for F in SC: print("{} {}".format(F, [w.reduced_word() for w in kappa[F]])) (0, 1) [[]] (0, 4) [[2], [2, 1]] (1, 2) [[1]] @@ -1621,10 +1657,11 @@ def brick_fan(self): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: SC.brick_fan() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: SC.brick_fan() Rational polyhedral fan in 2-d lattice N sage: W = CoxeterGroup(['A',2]) @@ -1653,11 +1690,12 @@ def brick_vectors(self, coefficients=None): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 - sage: SC.brick_vectors() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: SC = SubwordComplex([1,2,1,2,1], W.w0) + sage: SC.brick_vectors() [(5/3, 7/3), (5/3, 1/3), (2/3, 7/3), (-1/3, 4/3), (-1/3, 1/3)] - sage: SC.brick_vectors(coefficients=(1,2)) # optional - gap3 + sage: SC.brick_vectors(coefficients=(1,2)) [(7/3, 11/3), (7/3, 2/3), (4/3, 11/3), (-2/3, 5/3), (-2/3, 2/3)] sage: W = CoxeterGroup(['A',2]) @@ -1733,10 +1771,11 @@ def brick_polytope(self, coefficients=None): sage: X = SC.brick_polytope(); X A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices - sage: W = ReflectionGroup(['H',3]) # optional - gap3 - sage: c = W.index_set(); Q = c + tuple(W.w0.coxeter_sorting_word(c)) # optional - gap3 - sage: SC = SubwordComplex(Q,W.w0) # optional - gap3 - sage: SC.brick_polytope() # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['H',3]) + sage: c = W.index_set(); Q = c + tuple(W.w0.coxeter_sorting_word(c)) + sage: SC = SubwordComplex(Q,W.w0) + sage: SC.brick_polytope() doctest:...: RuntimeWarning: the polytope is built with rational vertices A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices @@ -1870,10 +1909,11 @@ def interval(self, I, J): EXAMPLES:: - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 - sage: F = SC([1,2]) # optional - gap3 - sage: SC.interval(F, F) # optional - gap3 + sage: # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: SC = SubwordComplex([1,2,1,2,1], W.w0) + sage: F = SC([1,2]) + sage: SC.interval(F, F) {(1, 2)} sage: W = CoxeterGroup(['A',2]) @@ -1935,11 +1975,12 @@ def _greedy_facet(Q, w, side="negative", n=None, pos=0, l=None, elems=[]): EXAMPLES:: + sage: # optional - gap3 sage: from sage.combinat.subword_complex import _greedy_facet - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: Q = [1,2,1,2,1] # optional - gap3 - sage: w = W.from_reduced_word([1, 2, 1]) # optional - gap3 - sage: _greedy_facet(Q, w) # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: Q = [1,2,1,2,1] + sage: w = W.from_reduced_word([1, 2, 1]) + sage: _greedy_facet(Q, w) {3, 4} sage: W = CoxeterGroup(['A',2]) @@ -2000,13 +2041,14 @@ def _extended_root_configuration_indices(W, Q, F): EXAMPLES:: + sage: # optional - gap3 sage: from sage.combinat.subword_complex import _extended_root_configuration_indices - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: Q = [1,2,1,2,1] # optional - gap3 - sage: SC = SubwordComplex(Q, w) # optional - gap3 - sage: F = SC([1,2]) # optional - gap3 - sage: _extended_root_configuration_indices(W, Q, F) # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: Q = [1,2,1,2,1] + sage: SC = SubwordComplex(Q, w) + sage: F = SC([1,2]) + sage: _extended_root_configuration_indices(W, Q, F) [0, 2, 3, 2, 1] sage: W = CoxeterGroup(['A',2]) @@ -2040,11 +2082,12 @@ def _greedy_flip_algorithm(Q, w): EXAMPLES:: + sage: # optional - gap3 sage: from sage.combinat.subword_complex import _greedy_flip_algorithm - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: Q = [1,2,1,2,1] # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: _greedy_flip_algorithm(Q, w) # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: Q = [1,2,1,2,1] + sage: w = W.from_reduced_word([1,2,1]) + sage: _greedy_flip_algorithm(Q, w) ([{0, 1}, [1, 2], [2, 3], [3, 4], [0, 4]], [[0, 1, 0, 2, 1], [0, 2, 3, 2, 1], diff --git a/src/sage/combinat/subword_complex_c.pyx b/src/sage/combinat/subword_complex_c.pyx index ec85790c133..2e1a17e907d 100644 --- a/src/sage/combinat/subword_complex_c.pyx +++ b/src/sage/combinat/subword_complex_c.pyx @@ -19,14 +19,15 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices, EXAMPLES:: + sage: # optional - gap3 sage: from sage.combinat.subword_complex_c import _flip_c - sage: W = ReflectionGroup(['A',2]) # optional - gap3 - sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 - sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 - sage: F = SC([0, 1]) # optional - gap3 - sage: _flip_c(W, set([0,1]), F._extended_root_configuration_indices(), 1) # optional - gap3 + sage: W = ReflectionGroup(['A',2]) + sage: w = W.from_reduced_word([1,2,1]) + sage: SC = SubwordComplex([1,2,1,2,1], w) + sage: F = SC([0, 1]) + sage: _flip_c(W, set([0,1]), F._extended_root_configuration_indices(), 1) 4 - sage: _flip_c(W, set([0,1]), F._extended_root_configuration_indices(), 0) # optional - gap3 + sage: _flip_c(W, set([0,1]), F._extended_root_configuration_indices(), 0) 3 sage: W = CoxeterGroup(['A',2]) diff --git a/src/sage/combinat/symmetric_group_representations.py b/src/sage/combinat/symmetric_group_representations.py index 1591768c494..7c975919a75 100644 --- a/src/sage/combinat/symmetric_group_representations.py +++ b/src/sage/combinat/symmetric_group_representations.py @@ -83,21 +83,22 @@ def SymmetricGroupRepresentation(partition, implementation="specht", :: - sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal"); orth # needs sage.symbolic + sage: # needs sage.symbolic + sage: orth = SymmetricGroupRepresentation([3,2], "orthogonal"); orth Orthogonal representation of the symmetric group corresponding to [3, 2] - sage: orth([2,1,3,4,5]) # needs sage.symbolic + sage: orth([2,1,3,4,5]) [ 1 0 0 0 0] [ 0 1 0 0 0] [ 0 0 -1 0 0] [ 0 0 0 1 0] [ 0 0 0 0 -1] - sage: orth([1,3,2,4,5]) # needs sage.symbolic + sage: orth([1,3,2,4,5]) [ 1 0 0 0 0] [ 0 -1/2 1/2*sqrt(3) 0 0] [ 0 1/2*sqrt(3) 1/2 0 0] [ 0 0 0 -1/2 1/2*sqrt(3)] [ 0 0 0 1/2*sqrt(3) 1/2] - sage: orth([1,2,4,3,5]) # needs sage.symbolic + sage: orth([1,2,4,3,5]) [ -1/3 2/3*sqrt(2) 0 0 0] [2/3*sqrt(2) 1/3 0 0 0] [ 0 0 1 0 0] diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 1477b00e6b8..938de77f5d4 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -2948,26 +2948,27 @@ def row_stabilizer(self): EXAMPLES:: - sage: rs = Tableau([[1,2,3],[4,5]]).row_stabilizer() # needs sage.groups - sage: rs.order() == factorial(3)*factorial(2) # needs sage.groups + sage: # needs sage.groups + sage: rs = Tableau([[1,2,3],[4,5]]).row_stabilizer() + sage: rs.order() == factorial(3)*factorial(2) True - sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs # needs sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs True - sage: PermutationGroupElement([(1,4)]) in rs # needs sage.groups + sage: PermutationGroupElement([(1,4)]) in rs False - sage: rs = Tableau([[1, 2],[3]]).row_stabilizer() # needs sage.groups - sage: PermutationGroupElement([(1,2),(3,)]) in rs # needs sage.groups + sage: rs = Tableau([[1, 2],[3]]).row_stabilizer() + sage: PermutationGroupElement([(1,2),(3,)]) in rs True - sage: rs.one().domain() # needs sage.groups + sage: rs.one().domain() [1, 2, 3] - sage: rs = Tableau([[1],[2],[3]]).row_stabilizer() # needs sage.groups - sage: rs.order() # needs sage.groups + sage: rs = Tableau([[1],[2],[3]]).row_stabilizer() + sage: rs.order() 1 - sage: rs = Tableau([[2,4,5],[1,3]]).row_stabilizer() # needs sage.groups - sage: rs.order() # needs sage.groups + sage: rs = Tableau([[2,4,5],[1,3]]).row_stabilizer() + sage: rs.order() 12 - sage: rs = Tableau([]).row_stabilizer() # needs sage.groups - sage: rs.order() # needs sage.groups + sage: rs = Tableau([]).row_stabilizer() + sage: rs.order() 1 """ # Ensure that the permutations involve all elements of the @@ -2989,12 +2990,13 @@ def column_stabilizer(self): EXAMPLES:: - sage: cs = Tableau([[1,2,3],[4,5]]).column_stabilizer() # needs sage.groups - sage: cs.order() == factorial(2)*factorial(2) # needs sage.groups + sage: # needs sage.groups + sage: cs = Tableau([[1,2,3],[4,5]]).column_stabilizer() + sage: cs.order() == factorial(2)*factorial(2) True - sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs # needs sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs False - sage: PermutationGroupElement([(1,4)]) in cs # needs sage.groups + sage: PermutationGroupElement([(1,4)]) in cs True """ return self.conjugate().row_stabilizer() @@ -7014,13 +7016,14 @@ def cardinality(self): EXAMPLES:: - sage: SemistandardTableaux([2,2], [2, 1, 1]).cardinality() # needs sage.modules + sage: # needs sage.modules + sage: SemistandardTableaux([2,2], [2, 1, 1]).cardinality() 1 - sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).cardinality() # needs sage.modules + sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).cardinality() 1 - sage: SemistandardTableaux([2,2,2], [2, 2, 2]).cardinality() # needs sage.modules + sage: SemistandardTableaux([2,2,2], [2, 2, 2]).cardinality() 1 - sage: SemistandardTableaux([3,2,1], [2, 2, 2]).cardinality() # needs sage.modules + sage: SemistandardTableaux([3,2,1], [2, 2, 2]).cardinality() 2 """ return symmetrica.kostka_number(self.shape, self.weight) @@ -7045,13 +7048,14 @@ def list(self): EXAMPLES:: - sage: SemistandardTableaux([2,2], [2, 1, 1]).list() # needs sage.modules + sage: # needs sage.modules + sage: SemistandardTableaux([2,2], [2, 1, 1]).list() [[[1, 1], [2, 3]]] - sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).list() # needs sage.modules + sage: SemistandardTableaux([2,2,2], [2, 2, 1,1]).list() [[[1, 1], [2, 2], [3, 4]]] - sage: SemistandardTableaux([2,2,2], [2, 2, 2]).list() # needs sage.modules + sage: SemistandardTableaux([2,2,2], [2, 2, 2]).list() [[[1, 1], [2, 2], [3, 3]]] - sage: SemistandardTableaux([3,2,1], [2, 2, 2]).list() # needs sage.modules + sage: SemistandardTableaux([3,2,1], [2, 2, 2]).list() [[[1, 1, 2], [2, 3], [3]], [[1, 1, 3], [2, 2], [3]]] """ return symmetrica.kostka_tab(self.shape, self.weight) @@ -7095,12 +7099,13 @@ def __iter__(self): """ EXAMPLES:: - sage: [ t for t in SemistandardTableaux(3, [2,1]) ] # needs sage.modules + sage: # needs sage.modules + sage: [ t for t in SemistandardTableaux(3, [2,1]) ] [[[1, 1, 2]], [[1, 1], [2]]] - sage: [ t for t in SemistandardTableaux(4, [2,2]) ] # needs sage.modules + sage: [ t for t in SemistandardTableaux(4, [2,2]) ] [[[1, 1, 2, 2]], [[1, 1, 2], [2]], [[1, 1], [2, 2]]] - sage: sst = SemistandardTableaux(4, [2,2]) # needs sage.modules - sage: sst[0].parent() is sst # needs sage.modules + sage: sst = SemistandardTableaux(4, [2,2]) + sage: sst[0].parent() is sst True """ from sage.combinat.partition import Partitions diff --git a/src/sage/combinat/tableau_tuple.py b/src/sage/combinat/tableau_tuple.py index ae17b0e3978..202682bf6cc 100644 --- a/src/sage/combinat/tableau_tuple.py +++ b/src/sage/combinat/tableau_tuple.py @@ -2738,18 +2738,19 @@ class RowStandardTableauTuples(TableauTuples): TESTS:: - sage: TestSuite( RowStandardTableauTuples() ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=1) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=4) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(size=6) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=1, size=10) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(level=4, size=10) ).run() # long time, needs sage.libs.flint - sage: TestSuite( RowStandardTableauTuples(shape=[[1],[3,1],[],[2,1]]) ).run() # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: TestSuite( RowStandardTableauTuples() ).run() + sage: TestSuite( RowStandardTableauTuples(level=1) ).run() + sage: TestSuite( RowStandardTableauTuples(level=4) ).run() + sage: TestSuite( RowStandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs + sage: TestSuite( RowStandardTableauTuples(size=6) ).run() + sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() + sage: TestSuite( RowStandardTableauTuples(level=1, size=0) ).run() + sage: TestSuite( RowStandardTableauTuples(level=1, size=10) ).run() + sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() + sage: TestSuite( RowStandardTableauTuples(level=4, size=0) ).run() + sage: TestSuite( RowStandardTableauTuples(level=4, size=10) ).run() # long time + sage: TestSuite( RowStandardTableauTuples(shape=[[1],[3,1],[],[2,1]]) ).run() .. SEEALSO:: @@ -3244,11 +3245,12 @@ def __init__(self, level, size): EXAMPLES:: - sage: RSTT43 = RowStandardTableauTuples(size=4, level=3); RSTT43 # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: RSTT43 = RowStandardTableauTuples(size=4, level=3); RSTT43 Row standard tableau tuples of level 3 and size 4 - sage: RSTT43 is RowStandardTableauTuples(3,4) # needs sage.libs.flint + sage: RSTT43 is RowStandardTableauTuples(3,4) True - sage: RowStandardTableauTuples(level=3, size=2)[:] # needs sage.libs.flint + sage: RowStandardTableauTuples(level=3, size=2)[:] [([[1, 2]], [], []), ([[2], [1]], [], []), ([[1], [2]], [], []), @@ -3264,7 +3266,7 @@ def __init__(self, level, size): ([], [], [[1, 2]]), ([], [], [[2], [1]]), ([], [], [[1], [2]])] - sage: RowStandardTableauTuples(3,2).cardinality() # needs sage.libs.flint + sage: RowStandardTableauTuples(3,2).cardinality() 15 """ RowStandardTableauTuples.__init__(self) @@ -3295,13 +3297,14 @@ def __contains__(self, t): EXAMPLES:: - sage: tabs = RowStandardTableauTuples(level=4, size=4); tabs # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: tabs = RowStandardTableauTuples(level=4, size=4); tabs Row standard tableau tuples of level 4 and size 4 - sage: [[[2,4],[1]],[],[[3]],[]] in tabs # needs sage.libs.flint + sage: [[[2,4],[1]],[],[[3]],[]] in tabs True - sage: tabs([[[1,2]],[],[[4],[3]],[]]) == RowStandardTableauTuple([[[1,2]],[],[[4],[3]],[]]) # needs sage.libs.flint + sage: tabs([[[1,2]],[],[[4],[3]],[]]) == RowStandardTableauTuple([[[1,2]],[],[[4],[3]],[]]) True - sage: RowStandardTableauTuple([[[2, 3]], [[1]]]) in tabs # needs sage.libs.flint + sage: RowStandardTableauTuple([[[2, 3]], [[1]]]) in tabs False Check that :trac:`14145` is fixed:: @@ -4027,16 +4030,17 @@ class StandardTableauTuples(RowStandardTableauTuples): TESTS:: - sage: TestSuite( StandardTableauTuples() ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=1) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=4) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(size=6) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=1, size=10) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint - sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: TestSuite( StandardTableauTuples() ).run() + sage: TestSuite( StandardTableauTuples(level=1) ).run() + sage: TestSuite( StandardTableauTuples(level=4) ).run() + sage: TestSuite( StandardTableauTuples(size=0) ).run(max_runs=50) # recursion depth exceeded with default max_runs + sage: TestSuite( StandardTableauTuples(size=6) ).run() + sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() + sage: TestSuite( StandardTableauTuples(level=1, size=0) ).run() + sage: TestSuite( StandardTableauTuples(level=1, size=10) ).run() + sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() + sage: TestSuite( StandardTableauTuples(level=4, size=0) ).run() .. SEEALSO:: @@ -4631,15 +4635,16 @@ def __contains__(self, t): EXAMPLES:: - sage: tabs = StandardTableauTuples(level=4, size=3); tabs # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: tabs = StandardTableauTuples(level=4, size=3); tabs Standard tableau tuples of level 4 and size 3 - sage: [[[1,2]],[],[[3]],[]] in tabs # needs sage.libs.flint + sage: [[[1,2]],[],[[3]],[]] in tabs True - sage: tabs([[[1,2]],[],[[3]],[]]) == StandardTableauTuple([[[1,2]],[],[[3]],[]]) # needs sage.libs.flint + sage: tabs([[[1,2]],[],[[3]],[]]) == StandardTableauTuple([[[1,2]],[],[[3]],[]]) True - sage: StandardTableauTuple([[[1, 2]], [[3]]]) in tabs # needs sage.libs.flint + sage: StandardTableauTuple([[[1, 2]], [[3]]]) in tabs False - sage: Tableau([[1]]) in tabs # needs sage.libs.flint + sage: Tableau([[1]]) in tabs False Check that :trac:`14145` is fixed:: @@ -4682,8 +4687,9 @@ def __iter__(self): EXAMPLES:: - sage: stt = StandardTableauTuples(3, 3) # needs sage.libs.flint - sage: stt[0:8] # needs sage.libs.flint + sage: # needs sage.libs.flint + sage: stt = StandardTableauTuples(3, 3) + sage: stt[0:8] [([[1, 2, 3]], [], []), ([[1, 2], [3]], [], []), ([[1, 3], [2]], [], []), @@ -4692,9 +4698,9 @@ def __iter__(self): ([[1, 3]], [[2]], []), ([[2, 3]], [[1]], []), ([[1], [2]], [[3]], [])] - sage: stt[40] # needs sage.libs.flint + sage: stt[40] ([], [[2, 3]], [[1]]) - sage: stt[0].parent() is stt # needs sage.libs.flint + sage: stt[0].parent() is stt True """ # Iterate through the PartitionTuples and then the tableaux diff --git a/src/sage/combinat/triangles_FHM.py b/src/sage/combinat/triangles_FHM.py index bb197442c33..8e3399d4da4 100644 --- a/src/sage/combinat/triangles_FHM.py +++ b/src/sage/combinat/triangles_FHM.py @@ -27,11 +27,12 @@ think about complete fans endowed with a distinguished maximal cone. A typical example is:: - sage: C = ClusterComplex(['A',3]) # needs sage.graphs sage.modules - sage: f = C.greedy_facet() # needs sage.graphs sage.modules - sage: C.F_triangle(f) # needs sage.graphs sage.modules + sage: # needs sage.graphs sage.modules + sage: C = ClusterComplex(['A',3]) + sage: f = C.greedy_facet() + sage: C.F_triangle(f) F: 5*x^3 + 5*x^2*y + 3*x*y^2 + y^3 + 10*x^2 + 8*x*y + 3*y^2 + 6*x + 3*y + 1 - sage: unicode_art(_) # needs sage.graphs sage.modules + sage: unicode_art(_) ⎛ 1 0 0 0⎞ ⎜ 3 3 0 0⎟ ⎜ 3 8 5 0⎟ @@ -558,7 +559,7 @@ def gamma(self): Γ: y^2 + x sage: W = SymmetricGroup(5) # needs sage.groups - sage: P = posets.NoncrossingPartitions(W) # needs sage.graphs + sage: P = posets.NoncrossingPartitions(W) # needs sage.graphs sage.groups sage: P.M_triangle().h().gamma() # needs sage.graphs sage.groups Γ: y^4 + 3*x*y^2 + 2*x^2 + 2*x*y + x """ diff --git a/src/sage/combinat/yang_baxter_graph.py b/src/sage/combinat/yang_baxter_graph.py index 519724d36f7..f20dda9170e 100644 --- a/src/sage/combinat/yang_baxter_graph.py +++ b/src/sage/combinat/yang_baxter_graph.py @@ -84,20 +84,22 @@ def YangBaxterGraph(partition=None, root=None, operators=None): The Cayley graph of a finite group can be realized as a Yang-Baxter graph:: + sage: # needs sage.groups sage: def left_multiplication_by(g): ....: return lambda h: h*g - sage: G = CyclicPermutationGroup(4) # needs sage.groups - sage: operators = [ left_multiplication_by(gen) for gen in G.gens() ] # needs sage.groups - sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # needs sage.groups + sage: G = CyclicPermutationGroup(4) + sage: operators = [ left_multiplication_by(gen) for gen in G.gens() ] + sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y Yang-Baxter graph with root vertex () - sage: Y.plot(edge_labels=False) # needs sage.groups sage.plot + sage: Y.plot(edge_labels=False) # needs sage.plot Graphics object consisting of 9 graphics primitives - sage: G = SymmetricGroup(4) # needs sage.groups - sage: operators = [left_multiplication_by(gen) for gen in G.gens()] # needs sage.groups - sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y # needs sage.groups + sage: # needs sage.groups + sage: G = SymmetricGroup(4) + sage: operators = [left_multiplication_by(gen) for gen in G.gens()] + sage: Y = YangBaxterGraph(root=G.identity(), operators=operators); Y Yang-Baxter graph with root vertex () - sage: Y.plot(edge_labels=False) # needs sage.groups sage.plot + sage: Y.plot(edge_labels=False) # needs sage.plot Graphics object consisting of 96 graphics primitives AUTHORS: @@ -604,13 +606,14 @@ def __copy__(self): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,2]); Y # needs sage.combinat + sage: # needs sage.combinat + sage: Y = YangBaxterGraph(partition=[3,2]); Y Yang-Baxter graph of [3, 2], with top vertex (1, 0, 2, 1, 0) - sage: B = copy(Y); B # needs sage.combinat + sage: B = copy(Y); B Yang-Baxter graph of [3, 2], with top vertex (1, 0, 2, 1, 0) - sage: Y is B # needs sage.combinat + sage: Y is B False - sage: Y == B # needs sage.combinat + sage: Y == B True """ from copy import copy @@ -679,14 +682,15 @@ def _swap_operator(self, operator, u): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,1]) # needs sage.combinat - sage: from sage.combinat.yang_baxter_graph import SwapOperator # needs sage.combinat - sage: ops = [SwapOperator(i) for i in range(3)] # needs sage.combinat - sage: [Y._swap_operator(op, (1,2,3,4)) for op in ops] # needs sage.combinat + sage: # needs sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]) + sage: from sage.combinat.yang_baxter_graph import SwapOperator + sage: ops = [SwapOperator(i) for i in range(3)] + sage: [Y._swap_operator(op, (1,2,3,4)) for op in ops] [(2, 1, 3, 4), (1, 3, 2, 4), (1, 2, 4, 3)] - sage: [Y._swap_operator(op, [4,3,2,1]) for op in ops] # needs sage.combinat + sage: [Y._swap_operator(op, [4,3,2,1]) for op in ops] [[3, 4, 2, 1], [4, 2, 3, 1], [4, 3, 1, 2]] - sage: [Y._swap_operator(op, Permutation([1,2,3,4])) for op in ops] # needs sage.combinat + sage: [Y._swap_operator(op, Permutation([1,2,3,4])) for op in ops] [[2, 1, 3, 4], [1, 3, 2, 4], [1, 2, 4, 3]] """ return operator(u) @@ -736,14 +740,15 @@ def relabel_vertices(self, v, inplace=True): EXAMPLES:: - sage: Y = YangBaxterGraph(partition=[3,1]); Y # needs sage.combinat + sage: # needs sage.combinat + sage: Y = YangBaxterGraph(partition=[3,1]); Y Yang-Baxter graph of [3, 1], with top vertex (0, 2, 1, 0) - sage: d = Y.relabel_vertices((1,2,3,4), inplace=False); d # needs sage.combinat + sage: d = Y.relabel_vertices((1,2,3,4), inplace=False); d Digraph on 3 vertices - sage: Y.vertices(sort=True) # needs sage.combinat + sage: Y.vertices(sort=True) [(0, 2, 1, 0), (2, 0, 1, 0), (2, 1, 0, 0)] - sage: e = Y.relabel_vertices((1,2,3,4)); e # needs sage.combinat - sage: Y.vertices(sort=True) # needs sage.combinat + sage: e = Y.relabel_vertices((1,2,3,4)); e + sage: Y.vertices(sort=True) [(1, 2, 3, 4), (2, 1, 3, 4), (2, 3, 1, 4)] """ relabelling = self.vertex_relabelling_dict(v) From ba19b1eb9011c44cd600901228f0b6475b9c4c8f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 15 Jul 2023 23:56:09 -0700 Subject: [PATCH 380/494] Update # needs --- src/sage/combinat/combinat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 5796f8ee9bc..7ea0a64b6b2 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -1532,7 +1532,7 @@ class CombinatorialElement(CombinatorialObject, Element, ....: @staticmethod ....: def __classcall__(cls, x): ....: return x - sage: Foo(17) + sage: Foo(17) # needs sage.combinat 17 """ @@ -3144,7 +3144,7 @@ def bernoulli_polynomial(x, n: Integer): TESTS:: sage: x = polygen(QQ, 'x') - sage: bernoulli_polynomial(x, 0).parent() # needs sage.libs.flint + sage: bernoulli_polynomial(x, 0).parent() Univariate Polynomial Ring in x over Rational Field REFERENCES: From 7a993645f1cac6594640ba8154d48ba1924383f6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 6 Aug 2023 18:32:37 -0700 Subject: [PATCH 381/494] sage.combinat: Update # needs --- src/sage/combinat/tuple.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/combinat/tuple.py b/src/sage/combinat/tuple.py index 63bedcb509a..54d1caf9181 100644 --- a/src/sage/combinat/tuple.py +++ b/src/sage/combinat/tuple.py @@ -49,10 +49,11 @@ class Tuples(Parent, UniqueRepresentation): :: sage: K. = GF(4, 'a') # needs sage.rings.finite_rings - sage: mset = [x for x in K if x != 0] # needs sage.rings.finite_rings - sage: Tuples(mset,2).list() # needs sage.rings.finite_rings - [(a, a), (a + 1, a), (1, a), (a, a + 1), (a + 1, a + 1), (1, a + 1), - (a, 1), (a + 1, 1), (1, 1)] + sage: mset = sorted((x for x in K if x != 0), key=str) # needs sage.rings.finite_rings + sage: Tuples(mset, 2).list() # needs sage.rings.finite_rings + [(1, 1), (a, 1), (a + 1, 1), + (1, a), (a, a), (a + 1, a), + (1, a + 1), (a, a + 1), (a + 1, a + 1)] """ @staticmethod def __classcall_private__(cls, S, k): From 11f2bc3a4d37bb0389bf28aa8a8144a3cce6ea51 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:10 -0700 Subject: [PATCH 382/494] src/sage/combinat: sage -fixdoctests --only-tags --- .../cluster_algebra_quiver/mutation_class.py | 51 ++++++++++--------- .../cluster_algebra_quiver/mutation_type.py | 15 ++++-- .../quiver_mutation_type.py | 32 +++++------- src/sage/combinat/ordered_tree.py | 2 +- src/sage/combinat/quickref.py | 2 +- 5 files changed, 52 insertions(+), 50 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py index 33b33087899..fc6ec540395 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py @@ -76,10 +76,10 @@ def _digraph_mutate(dg, k, frozen=None): sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_mutate sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver - sage: dg = ClusterQuiver(['A',4]).digraph() - sage: dg.edges(sort=True) + sage: dg = ClusterQuiver(['A',4]).digraph() # needs sage.modules + sage: dg.edges(sort=True) # needs sage.modules [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -1))] - sage: _digraph_mutate(dg,2).edges(sort=True) + sage: _digraph_mutate(dg,2).edges(sort=True) # needs sage.modules [(0, 1, (1, -1)), (1, 2, (1, -1)), (3, 2, (1, -1))] TESTS:: @@ -208,31 +208,31 @@ def _dg_canonical_form(dg, frozen=None): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dg_canonical_form - sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges(sort=True) + sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges(sort=True) # needs sage.modules [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -2))] - sage: _dg_canonical_form(dg); dg.edges(sort=True) + sage: _dg_canonical_form(dg); dg.edges(sort=True) # needs sage.modules ({0: 0, 1: 3, 2: 1, 3: 2}, [[0], [3], [1], [2]]) [(0, 3, (1, -1)), (1, 2, (1, -2)), (1, 3, (1, -1))] TESTS:: - sage: dg2 = ClusterQuiver(DiGraph({0:[1,2]})).digraph() - sage: _dg_canonical_form(dg2); dg2.edges(sort=True) + sage: dg2 = ClusterQuiver(DiGraph({0:[1,2]})).digraph() # needs sage.modules + sage: _dg_canonical_form(dg2); dg2.edges(sort=True) # needs sage.modules ({0: 0, 1: 1, 2: 2}, [[0], [1, 2]]) [(0, 1, (1, -1)), (0, 2, (1, -1))] - sage: dg2 = ClusterQuiver(DiGraph({0:[1,2]})).digraph() - sage: _dg_canonical_form(dg2, frozen=[0]); dg2.edges(sort=True) + sage: dg2 = ClusterQuiver(DiGraph({0:[1,2]})).digraph() # needs sage.modules + sage: _dg_canonical_form(dg2, frozen=[0]); dg2.edges(sort=True) # needs sage.modules ({0: 2, 1: 0, 2: 1}, [[2], [0, 1]]) [(2, 0, (1, -1)), (2, 1, (1, -1))] - sage: dg3 = ClusterQuiver(DiGraph({0:[1,2],1:[3]})).digraph() - sage: _dg_canonical_form(dg3, frozen=[0,3]); dg3.edges(sort=True) + sage: dg3 = ClusterQuiver(DiGraph({0:[1,2],1:[3]})).digraph() # needs sage.modules + sage: _dg_canonical_form(dg3, frozen=[0,3]); dg3.edges(sort=True) # needs sage.modules ({0: 2, 1: 1, 2: 0, 3: 3}, [[2], [1], [0], [3]]) [(1, 3, (1, -1)), (2, 0, (1, -1)), (2, 1, (1, -1))] - sage: dg3 = ClusterQuiver(DiGraph({2:[1,3],1:[0],3:[4]})).digraph() - sage: _dg_canonical_form(dg3, frozen=[4,0]); dg3.edges(sort=True) + sage: dg3 = ClusterQuiver(DiGraph({2:[1,3],1:[0],3:[4]})).digraph() # needs sage.modules + sage: _dg_canonical_form(dg3, frozen=[4,0]); dg3.edges(sort=True) # needs sage.modules ({0: 4, 1: 1, 2: 0, 3: 2, 4: 3}, [[4, 3], [1, 2], [0]]) [(0, 1, (1, -1)), (0, 2, (1, -1)), (1, 4, (1, -1)), (2, 3, (1, -1))] """ @@ -292,6 +292,7 @@ def _mutation_class_iter( dg, n, m, depth=infinity, return_dig6=False, show_dept EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _mutation_class_iter sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',[1,2],1]).digraph() @@ -392,8 +393,8 @@ def _digraph_to_dig6( dg, hashable=False ): sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6 sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver - sage: dg = ClusterQuiver(['A',4]).digraph() - sage: _digraph_to_dig6(dg) + sage: dg = ClusterQuiver(['A',4]).digraph() # needs sage.modules + sage: _digraph_to_dig6(dg) # needs sage.modules ('COD?', {}) """ dig6 = dg.dig6_string() @@ -416,6 +417,7 @@ def _dig6_to_digraph( dig6 ): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6 sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dig6_to_digraph sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver @@ -451,8 +453,8 @@ def _dig6_to_matrix( dig6 ): sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6, _dig6_to_matrix sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver - sage: dg = ClusterQuiver(['A',4]).digraph() - sage: data = _digraph_to_dig6(dg) + sage: dg = ClusterQuiver(['A',4]).digraph() # needs sage.modules + sage: data = _digraph_to_dig6(dg) # needs sage.modules sage: _dig6_to_matrix(data) # needs sage.modules [ 0 1 0 0] [-1 0 -1 0] @@ -474,14 +476,15 @@ def _dg_is_sink_source( dg, v ): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dg_is_sink_source sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',[1,2],1]).digraph() - sage: _dg_is_sink_source(dg, 0 ) + sage: _dg_is_sink_source(dg, 0) True - sage: _dg_is_sink_source(dg, 1 ) + sage: _dg_is_sink_source(dg, 1) True - sage: _dg_is_sink_source(dg, 2 ) + sage: _dg_is_sink_source(dg, 2) False """ in_edges = [ edge for edge in dg._backend.iterator_in_edges([v],True) ] @@ -504,9 +507,9 @@ def _graph_without_edge_labels(dg, vertices): sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _graph_without_edge_labels sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver - sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges(sort=True) + sage: dg = ClusterQuiver(['B',4]).digraph(); dg.edges(sort=True) # needs sage.modules [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -2))] - sage: _graph_without_edge_labels(dg, range(4)); dg.edges(sort=True) + sage: _graph_without_edge_labels(dg, range(4)); dg.edges(sort=True) # needs sage.modules ([[4]], ((1, -2),)) [(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 4, (1, -1)), (4, 3, (1, -1))] """ @@ -542,10 +545,10 @@ def _has_two_cycles( dg ): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _has_two_cycles - sage: _has_two_cycles( DiGraph([[0,1],[1,0]])) + sage: _has_two_cycles(DiGraph([[0,1],[1,0]])) True sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver - sage: _has_two_cycles( ClusterQuiver(['A',3]).digraph() ) + sage: _has_two_cycles(ClusterQuiver(['A',3]).digraph()) # needs sage.modules False """ edge_set = dg.edges(sort=True, labels=False) diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py index 524c95a80df..32f9ccc52d7 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py @@ -55,14 +55,15 @@ def is_mutation_finite(M, nr_of_checks=None): sage: from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite - sage: Q = ClusterQuiver(['A',10]) + sage: Q = ClusterQuiver(['A',10]) # needs sage.modules sage: M = Q.b_matrix() # needs sage.modules sage: is_mutation_finite(M) # needs sage.modules (True, None) + sage: # needs sage.modules sage: Q = ClusterQuiver([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(2,9)]) - sage: M = Q.b_matrix() # needs sage.modules - sage: is_mutation_finite(M) # random # needs sage.modules + sage: M = Q.b_matrix() + sage: is_mutation_finite(M) # random (False, [9, 6, 9, 8, 9, 4, 0, 4, 5, 2, 1, 0, 1, 0, 7, 1, 9, 2, 5, 7, 8, 6, 3, 0, 2, 5, 4, 2, 6, 9, 2, 7, 3, 5, 3, 7, 9, 5, 9, 0, 2, 7, 9, 2, 4, 2, 1, 6, 9, 4, 3, 5, 0, 8, 2, 9, 5, 3, 7, 0, 1, 8, 3, 7, 2, 7, 3, 4, 8, 0, 4, 9, 5, 2, 8, 4, 8, 1, 7, 8, 9, 1, 5, 0, 8, 7, 4, 8, 9, 8, 0, 7, 4, 7, 1, 2, 8, 6, 1, 3, 9, 3, 9, 1, 3, 2, 4, 9, 5, 1, 2, 9, 4, 8, 5, 3, 4, 6, 8, 9, 2, 5, 9, 4, 6, 2, 1, 4, 9, 6, 0, 9, 8, 0, 4, 7, 9, 2, 1, 6]) Check that :trac:`19495` is fixed:: @@ -100,6 +101,7 @@ def _triangles(dg): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _triangles sage: Q = ClusterQuiver(['A',3]) sage: _triangles(Q.digraph()) @@ -154,6 +156,7 @@ def _all_induced_cycles_iter( dg ): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _all_induced_cycles_iter sage: Q = ClusterQuiver(['A',[6,0],1]); Q Quiver on 6 vertices of type ['D', 6] @@ -220,6 +223,7 @@ def _reset_dg(dg, vertices, dict_in_out, del_vertices): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _reset_dg sage: dg = ClusterQuiver(['A',[2,2],1]).digraph(); dg Digraph on 4 vertices @@ -326,6 +330,7 @@ def _connected_mutation_type(dg): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _connected_mutation_type sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',3]).digraph(); _connected_mutation_type( dg ) @@ -820,15 +825,14 @@ def _connected_mutation_type_AAtildeD(dg, ret_conn_vert=False): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _connected_mutation_type_AAtildeD sage: Q = ClusterQuiver(['A',[7,0],1]); Q.mutate([0,1,4]) sage: _connected_mutation_type_AAtildeD(Q.digraph(),ret_conn_vert=True) [['D', 7], [0, 4]] - sage: Q2 = ClusterQuiver(['A',[5,2],1]); Q2.mutate([4,5]) sage: _connected_mutation_type_AAtildeD(Q2.digraph() ) ['A', [2, 5], 1] - sage: Q3 = ClusterQuiver(['E',6]); Q3.mutate([5,2,1]) sage: _connected_mutation_type_AAtildeD(Q3.digraph(),ret_conn_vert=True) 'unknown' @@ -1305,6 +1309,7 @@ def _mutation_type_from_data( n, dig6, compute_if_necessary=True ): EXAMPLES:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6 sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _mutation_type_from_data sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 60e9e78c3bf..2e36b619716 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -669,7 +669,7 @@ def _repr_(self): EXAMPLES:: - sage: QuiverMutationType(['A', 2]) # indirect doctest + sage: QuiverMutationType(['A', 2]) # indirect doctest ['A', 2] """ return self._description @@ -816,22 +816,22 @@ def standard_quiver(self): sage: mut_type = QuiverMutationType( ['A',5] ); mut_type ['A', 5] - sage: mut_type.standard_quiver() + sage: mut_type.standard_quiver() # needs sage.modules Quiver on 5 vertices of type ['A', 5] sage: mut_type = QuiverMutationType( ['A',[5,3], 1] ); mut_type ['A', [3, 5], 1] - sage: mut_type.standard_quiver() + sage: mut_type.standard_quiver() # needs sage.modules Quiver on 8 vertices of type ['A', [3, 5], 1] sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.standard_quiver() + sage: mut_type.standard_quiver() # needs sage.modules Quiver on 6 vertices of type [ ['A', 3], ['B', 3] ] sage: mut_type = QuiverMutationType(['A',3],['B',3],['X',6]); mut_type [ ['A', 3], ['B', 3], ['X', 6] ] - sage: mut_type.standard_quiver() + sage: mut_type.standard_quiver() # needs sage.modules Quiver on 12 vertices of type [ ['A', 3], ['B', 3], ['X', 6] ] """ from .quiver import ClusterQuiver @@ -2237,31 +2237,28 @@ def _save_data_dig6(n, types='ClassicalExceptional', verbose=False): TESTS:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import save_quiver_data - sage: save_quiver_data(2) # indirect doctest + sage: save_quiver_data(2) # indirect doctest The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', 1)] The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] - - sage: save_quiver_data(2,up_to=False) # indirect doctest + sage: save_quiver_data(2, up_to=False) # indirect doctest The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] - - sage: save_quiver_data(2,up_to=False, types='Classical') # indirect doctest + sage: save_quiver_data(2, up_to=False, types='Classical') # indirect doctest The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1)] - - sage: save_quiver_data(2,up_to=False, types='Exceptional') # indirect doctest + sage: save_quiver_data(2, up_to=False, types='Exceptional') # indirect doctest The following types are saved to file ... and will now be used to determine quiver mutation types: [('G', 2)] - - sage: save_quiver_data(2,up_to=False, verbose=False) # indirect doctest + sage: save_quiver_data(2, up_to=False, verbose=False) # indirect doctest """ data = {} possible_types = ['Classical', 'ClassicalExceptional', 'Exceptional'] @@ -2311,6 +2308,7 @@ def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True): TESTS:: + sage: # needs sage.modules sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import save_quiver_data sage: save_quiver_data(2) @@ -2319,22 +2317,18 @@ def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True): The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] - sage: save_quiver_data(2,up_to=False) The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1), ('G', 2)] - sage: save_quiver_data(2,up_to=False, types='Classical') The following types are saved to file ... and will now be used to determine quiver mutation types: [('A', (1, 1), 1), ('A', 2), ('B', 2), ('BC', 1, 1)] - sage: save_quiver_data(2,up_to=False, types='Exceptional') The following types are saved to file ... and will now be used to determine quiver mutation types: [('G', 2)] - sage: save_quiver_data(2,up_to=False, verbose=False) """ from sage.combinat.cluster_algebra_quiver.mutation_type import load_data @@ -2398,7 +2392,7 @@ def _mutation_type_error(data): EXAMPLES:: - sage: QuiverMutationType( 'Christian', 'Stump' ) # indirect doctest + sage: QuiverMutationType( 'Christian', 'Stump' ) # indirect doctest Traceback (most recent call last): ... ValueError: ['Christian', 'Stump'] is not a valid quiver mutation type diff --git a/src/sage/combinat/ordered_tree.py b/src/sage/combinat/ordered_tree.py index 9d7ee8fb1e3..5028d36fb04 100644 --- a/src/sage/combinat/ordered_tree.py +++ b/src/sage/combinat/ordered_tree.py @@ -1090,7 +1090,7 @@ def random_element(self): sage: OrderedTrees(5).random_element() # random # needs sage.combinat [[[], []], []] - sage: OrderedTrees(0).random_element() # needs sage.combinat + sage: OrderedTrees(0).random_element() Traceback (most recent call last): ... EmptySetError: there are no ordered trees of size 0 diff --git a/src/sage/combinat/quickref.py b/src/sage/combinat/quickref.py index 87068331980..ee7d9ca8ec1 100644 --- a/src/sage/combinat/quickref.py +++ b/src/sage/combinat/quickref.py @@ -49,7 +49,7 @@ sage: points = random_matrix(ZZ, 6, 3, x=7).rows() # needs sage.modules sage: L = LatticePolytope(points) # needs sage.geometry.polyhedron sage.modules - sage: L.npoints(); L.plot3d() # random # needs sage.geometry.polyhedron sage.plot + sage: L.npoints(); L.plot3d() # random # needs sage.geometry.polyhedron sage.modules sage.plot :ref:`Root systems, Coxeter and Weyl groups `:: From d45c3fabc33739b6ea63b55f2acb575b688ff9b5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 27 Aug 2023 13:40:12 -0700 Subject: [PATCH 383/494] sage.combinat: Update # needs --- src/sage/combinat/permutation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 32d985f29b9..15a2bf26c67 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -8033,7 +8033,7 @@ def __init__(self, d, n): TESTS:: sage: P = Permutations(descents=([1,0,2], 5)) - sage: TestSuite(P).run() # needs sage.graphs + sage: TestSuite(P).run() # needs sage.graphs sage.modules """ StandardPermutations_n_abstract.__init__(self, n) self._d = d @@ -8422,7 +8422,7 @@ def __iter__(self): EXAMPLES:: - sage: Permutations(recoils=[2,2]).list() # needs sage.graphs + sage: Permutations(recoils=[2,2]).list() # needs sage.graphs sage.modules [[3, 1, 4, 2], [3, 4, 1, 2], [1, 3, 4, 2], [1, 3, 2, 4], [3, 1, 2, 4]] """ recoils = self.recoils From d1612b34b833d093df8eabb06a66a49b9f948713 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 12:48:51 -0700 Subject: [PATCH 384/494] sage.combinat: Update # needs --- src/sage/combinat/combinat.py | 12 ++++++------ src/sage/combinat/integer_lists/base.pyx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 7ea0a64b6b2..2fc8d554628 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -552,7 +552,7 @@ def euler_number(n, algorithm='flint') -> Integer: sage: [euler_number(i) for i in range(10)] # needs sage.libs.flint [1, 0, -1, 0, 5, 0, -61, 0, 1385, 0] sage: x = PowerSeriesRing(QQ, 'x').gen().O(10) - sage: 2/(exp(x)+exp(-x)) # needs sage.symbolic + sage: 2/(exp(x)+exp(-x)) 1 - 1/2*x^2 + 5/24*x^4 - 61/720*x^6 + 277/8064*x^8 + O(x^10) sage: [euler_number(i)/factorial(i) for i in range(11)] # needs sage.libs.flint [1, 0, -1/2, 0, 5/24, 0, -61/720, 0, 277/8064, 0, -50521/3628800] @@ -985,13 +985,13 @@ def stirling_number2(n, k, algorithm=None) -> Integer: 1900842429486 sage: type(n) - sage: n = stirling_number2(20, 11, algorithm='gap'); n # needs sage.libs.gap + sage: n_gap = stirling_number2(20, 11, algorithm='gap'); n_gap # needs sage.libs.gap 1900842429486 - sage: type(n) # needs sage.libs.gap + sage: type(n_gap) # needs sage.libs.gap - sage: n = stirling_number2(20, 11, algorithm='flint'); n # needs sage.libs.flint + sage: n_flint = stirling_number2(20, 11, algorithm='flint'); n_flint # needs sage.libs.flint 1900842429486 - sage: type(n) # needs sage.libs.flint + sage: type(n_flint) # needs sage.libs.flint Sage's implementation splitting the computation of the Stirling @@ -1096,7 +1096,7 @@ def polygonal_number(s, n): A non-integer input returns an error:: - sage: polygonal_number(3.5, 1) + sage: polygonal_number(3.5, 1) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer diff --git a/src/sage/combinat/integer_lists/base.pyx b/src/sage/combinat/integer_lists/base.pyx index c39937c3ac6..6da2125396e 100644 --- a/src/sage/combinat/integer_lists/base.pyx +++ b/src/sage/combinat/integer_lists/base.pyx @@ -61,7 +61,7 @@ cdef class IntegerListsBackend(): sage: from sage.combinat.integer_lists.base import IntegerListsBackend sage: C = IntegerListsBackend(2, length=3) - sage: C = IntegerListsBackend(min_sum=1.4) + sage: C = IntegerListsBackend(min_sum=1.4) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer From 3d26a52fe80d31b861bd95d3913700cf3f6eb3f8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 18:14:28 -0700 Subject: [PATCH 385/494] sage.combinat: Update # needs --- src/sage/combinat/growth.py | 24 ++++++++++++++-------- src/sage/combinat/ribbon_shaped_tableau.py | 22 ++++++++++++-------- src/sage/combinat/skew_tableau.py | 23 +++++++++++++-------- src/sage/combinat/tableau.py | 1 + 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py index 23b7a279fdc..951d774931e 100644 --- a/src/sage/combinat/growth.py +++ b/src/sage/combinat/growth.py @@ -487,7 +487,10 @@ from sage.combinat.core import Core, Cores from sage.combinat.k_tableau import WeakTableau, StrongTableau from sage.combinat.shifted_primed_tableau import ShiftedPrimedTableau -from sage.graphs.digraph import DiGraph +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.graphs.digraph', 'DiGraph') +lazy_import('sage.combinat.posets.posets', 'Poset') def _make_partition(l): @@ -619,8 +622,8 @@ class GrowthDiagram(SageObject): Passing the permutation matrix instead gives the same result:: - sage: G = GrowthDiagram(RuleRSK, pi.to_matrix()) - sage: ascii_art([G.P_symbol(), G.Q_symbol()]) + sage: G = GrowthDiagram(RuleRSK, pi.to_matrix()) # needs sage.modules + sage: ascii_art([G.P_symbol(), G.Q_symbol()]) # needs sage.modules [ 1 2 3 1 3 4 ] [ 4 , 2 ] @@ -1358,10 +1361,10 @@ def _process_filling_and_shape(self, filling, shape): ``filling`` is a matrix:: - sage: G = GrowthDiagram(RuleRSK, pi.to_matrix()) # indirect doctest - sage: G._filling + sage: G = GrowthDiagram(RuleRSK, pi.to_matrix()) # indirect doctest # needs sage.modules + sage: G._filling # needs sage.modules {(0, 1): 1, (1, 2): 1, (2, 0): 1, (3, 5): 1, (4, 3): 1, (5, 4): 1} - sage: G.shape() + sage: G.shape() # needs sage.modules [6, 6, 6, 6, 6, 6] / [] ``filling`` is a permutation:: @@ -1390,7 +1393,8 @@ def _process_filling_and_shape(self, filling, shape): ``filling`` is a list of lists and shape is given:: - sage: G = GrowthDiagram(RuleRSK, [[1,0,1],[0,1]], shape=SkewPartition([[3,2],[1]])) # indirect doctest + sage: G = GrowthDiagram(RuleRSK, [[1,0,1],[0,1]], # indirect doctest + ....: shape=SkewPartition([[3,2],[1]])) sage: G._filling {(0, 0): 1, (1, 1): 1, (2, 0): 1} sage: G.shape() @@ -2028,7 +2032,8 @@ def P_symbol(self, P_chain): . 4' 5 sage: Shifted = GrowthDiagram.rules.ShiftedShapes() - sage: labels = [mu if is_even(i) else 0 for i, mu in enumerate(T.to_chain()[::-1])] + U.to_chain()[1:] + sage: labels = [mu if is_even(i) else 0 + ....: for i, mu in enumerate(T.to_chain()[::-1])] + U.to_chain()[1:] sage: G = Shifted({(1,2):1, (2,1):1}, shape=[5,5,5,5,5], labels=labels) sage: G.P_symbol().pp() . . . . 2 @@ -2080,7 +2085,8 @@ def Q_symbol(self, Q_chain): . 4' 5 sage: Shifted = GrowthDiagram.rules.ShiftedShapes() - sage: labels = [mu if is_even(i) else 0 for i, mu in enumerate(T.to_chain()[::-1])] + U.to_chain()[1:] + sage: labels = [mu if is_even(i) else 0 + ....: for i, mu in enumerate(T.to_chain()[::-1])] + U.to_chain()[1:] sage: G = Shifted({(1,2):1, (2,1):1}, shape=[5,5,5,5,5], labels=labels) sage: G.Q_symbol().pp() . . . . 2 diff --git a/src/sage/combinat/ribbon_shaped_tableau.py b/src/sage/combinat/ribbon_shaped_tableau.py index 582761eac6d..84458d104f3 100644 --- a/src/sage/combinat/ribbon_shaped_tableau.py +++ b/src/sage/combinat/ribbon_shaped_tableau.py @@ -270,8 +270,9 @@ def __init__(self, category=None): EXAMPLES:: - sage: S = StandardRibbonShapedTableaux() # needs sage.graphs - sage: TestSuite(S).run() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: # needs sage.graphs sage.modules + sage: S = StandardRibbonShapedTableaux() + sage: TestSuite(S).run() """ if category is None: category = InfiniteEnumeratedSets() @@ -293,8 +294,9 @@ def __iter__(self): EXAMPLES:: - sage: it = StandardRibbonShapedTableaux().__iter__() # needs sage.graphs - sage: [next(it) for x in range(10)] # needs sage.graphs sage.modules sage.rings.finite_rings + sage: # needs sage.graphs sage.modules + sage: it = StandardRibbonShapedTableaux().__iter__() + sage: [next(it) for x in range(10)] [[], [[1]], [[1, 2]], @@ -376,15 +378,17 @@ class StandardRibbonShapedTableaux_shape(StandardRibbonShapedTableaux): [[None, 2, 4], [1, 3]] sage: StandardRibbonShapedTableaux([2,2]).last() [[None, 1, 2], [3, 4]] - sage: StandardRibbonShapedTableaux([2,2]).cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings + + sage: # needs sage.graphs sage.modules + sage: StandardRibbonShapedTableaux([2,2]).cardinality() 5 - sage: StandardRibbonShapedTableaux([2,2]).list() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: StandardRibbonShapedTableaux([2,2]).list() [[[None, 1, 3], [2, 4]], [[None, 1, 2], [3, 4]], [[None, 2, 3], [1, 4]], [[None, 2, 4], [1, 3]], [[None, 1, 4], [2, 3]]] - sage: StandardRibbonShapedTableaux([3,2,2]).cardinality() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: StandardRibbonShapedTableaux([3,2,2]).cardinality() 155 """ @staticmethod @@ -406,7 +410,7 @@ def __init__(self, shape): TESTS:: sage: S = StandardRibbonShapedTableaux([2,2]) - sage: TestSuite(S).run() # needs sage.graphs sage.rings.finite_rings + sage: TestSuite(S).run() # needs sage.graphs """ self.shape = shape StandardRibbonShapedTableaux.__init__(self, FiniteEnumeratedSets()) @@ -448,7 +452,7 @@ def __iter__(self): EXAMPLES:: - sage: [t for t in StandardRibbonShapedTableaux([2,2])] # needs sage.graphs sage.rings.finite_rings + sage: [t for t in StandardRibbonShapedTableaux([2,2])] # needs sage.graphs [[[None, 1, 3], [2, 4]], [[None, 1, 2], [3, 4]], [[None, 2, 3], [1, 4]], diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index 7bc3ffbd89a..f3703af3d92 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -1957,7 +1957,8 @@ class StandardSkewTableaux(SkewTableaux): :: - sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() # needs sage.graphs sage.rings.finite_rings + sage: # needs sage.graphs sage.modules + sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() [[[None, 2, 3], [None, 4], [1]], [[None, 1, 2], [None, 3], [4]], [[None, 1, 2], [None, 4], [3]], @@ -2017,7 +2018,7 @@ def __init__(self): EXAMPLES:: sage: s = StandardSkewTableaux() - sage: TestSuite(s).run() # needs sage.graphs sage.rings.finite_rings + sage: TestSuite(s).run() # needs sage.graphs """ StandardSkewTableaux.__init__(self, category=InfiniteEnumeratedSets()) @@ -2038,8 +2039,9 @@ def __iter__(self): EXAMPLES:: + sage: # needs sage.graphs sage.modules sage: it = StandardSkewTableaux().__iter__() - sage: [next(it) for x in range(10)] # needs sage.graphs sage.modules sage.rings.finite_rings + sage: [next(it) for x in range(10)] [[], [[1]], [[1, 2]], [[1], [2]], [[None, 2], [1]], [[None, 1], [2]], @@ -2061,8 +2063,9 @@ def __init__(self, n): """ EXAMPLES:: + sage: # needs sage.graphs sage.modules sage: S = StandardSkewTableaux(3) - sage: TestSuite(S).run() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: TestSuite(S).run() """ self.n = n StandardSkewTableaux.__init__(self, category=FiniteEnumeratedSets()) @@ -2104,10 +2107,10 @@ def __iter__(self): EXAMPLES:: - sage: StandardSkewTableaux(2).list() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: # needs sage.graphs sage.modules + sage: StandardSkewTableaux(2).list() [[[1, 2]], [[1], [2]], [[None, 2], [1]], [[None, 1], [2]]] - - sage: StandardSkewTableaux(3).list() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: StandardSkewTableaux(3).list() [[[1, 2, 3]], [[1, 2], [3]], [[1, 3], [2]], [[None, 2, 3], [1]], [[None, 1, 2], [3]], [[None, 1, 3], [2]], @@ -2151,8 +2154,9 @@ def __init__(self, skp): """ TESTS:: + sage" # needs sage.graphs sage.modules sage: S = StandardSkewTableaux([[3, 2, 1], [1, 1]]) - sage: TestSuite(S).run() # needs sage.graphs sage.modules + sage: TestSuite(S).run() """ self.skp = skp StandardSkewTableaux.__init__(self, category=FiniteEnumeratedSets()) @@ -2203,7 +2207,8 @@ def __iter__(self): EXAMPLES:: - sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() # needs sage.graphs sage.modules sage.rings.finite_rings + sage: # needs sage.graphs sage.modules + sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list() [[[None, 2, 3], [None, 4], [1]], [[None, 1, 2], [None, 3], [4]], [[None, 1, 2], [None, 4], [3]], diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 938de77f5d4..cf44091d16d 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -6014,6 +6014,7 @@ def __classcall_private__(cls, *args, **kwargs): ... ValueError: the maximum entry must match the weight + sage: # needs sage.modules sage: SemistandardTableaux([[1]]) Traceback (most recent call last): ... From 83ed6a3d79e3dbd45f6496e01eb17ccbd929a469 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 9 Sep 2023 16:52:48 -0700 Subject: [PATCH 386/494] sage.combinat: Update # needs --- .../combinat/cluster_algebra_quiver/quiver.py | 8 ++--- src/sage/combinat/finite_state_machine.py | 22 +++++++++----- src/sage/combinat/permutation.py | 29 ++++++++++--------- src/sage/combinat/yang_baxter_graph.py | 2 +- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py index 028f8abb797..3c4f1c65a87 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py @@ -2150,18 +2150,17 @@ def d_vector_fan(self): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage.libs.singular sage: Fd = ClusterQuiver([[1,2]]).d_vector_fan(); Fd Rational polyhedral fan in 2-d lattice N sage: Fd.ngenerating_cones() 5 - sage: Fd = ClusterQuiver([[1,2],[2,3]]).d_vector_fan(); Fd Rational polyhedral fan in 3-d lattice N sage: Fd.ngenerating_cones() 14 sage: Fd.is_smooth() True - sage: Fd = ClusterQuiver([[1,2],[2,3],[3,1]]).d_vector_fan(); Fd Rational polyhedral fan in 3-d lattice N sage: Fd.ngenerating_cones() @@ -2176,12 +2175,13 @@ def d_vector_fan(self): ... ValueError: only makes sense for quivers of finite type """ + if not(self.is_finite()): + raise ValueError('only makes sense for quivers of finite type') + from .cluster_seed import ClusterSeed from sage.geometry.fan import Fan from sage.geometry.cone import Cone - if not (self.is_finite()): - raise ValueError('only makes sense for quivers of finite type') seed = ClusterSeed(self) return Fan([Cone(s.d_matrix().columns()) for s in seed.mutation_class()]) diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 78ee1b6ff1a..60410b886e4 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -384,6 +384,7 @@ We can also let an automaton act on a :doc:`word `:: + sage: # needs sage.combinat sage: W = Words([-1, 0, 1]); W Finite and infinite words over {-1, 0, 1} sage: w = W([1, 0, 1, 0, -1]); w @@ -3676,6 +3677,7 @@ def __call__(self, *args, **kwargs): We can also let them act on :doc:`words `:: + sage: # needs sage.combinat sage: W = Words([0, 1]); W Finite and infinite words over {0, 1} sage: binary_inverter(W([0, 1, 1, 0, 1, 1])) @@ -3683,6 +3685,7 @@ def __call__(self, *args, **kwargs): Infinite words work as well:: + sage: # needs sage.combinat sage: words.FibonacciWord() word: 0100101001001010010100100101001001010010... sage: binary_inverter(words.FibonacciWord()) @@ -4147,7 +4150,7 @@ def is_Markov_chain(self, is_zero=None): sage: F.state(0).initial_probability = p + q sage: F.is_Markov_chain() False - sage: F.is_Markov_chain(is_zero_polynomial) + sage: F.is_Markov_chain(is_zero_polynomial) # needs sage.libs.singular True """ def default_is_zero(expression): @@ -6251,6 +6254,8 @@ def iter_process(self, input_tape=None, initial_state=None, sage: inverter = Transducer({'A': [('A', 0, 1), ('A', 1, 0)]}, ....: initial_states=['A'], final_states=['A']) + + sage: # needs sage.combinat sage: words.FibonacciWord() word: 0100101001001010010100100101001001010010... sage: it = inverter.iter_process( @@ -6260,19 +6265,20 @@ def iter_process(self, input_tape=None, initial_state=None, This can also be done by:: - sage: inverter.iter_process(words.FibonacciWord(), + sage: inverter.iter_process(words.FibonacciWord(), # needs sage.combinat ....: iterator_type='simple', ....: automatic_output_type=True) word: 1011010110110101101011011010110110101101... or even simpler by:: - sage: inverter(words.FibonacciWord()) + sage: inverter(words.FibonacciWord()) # needs sage.combinat word: 1011010110110101101011011010110110101101... To see what is going on, we use :meth:`iter_process` without arguments:: + sage: # needs sage.combinat sage: from itertools import islice sage: it = inverter.iter_process(words.FibonacciWord()) sage: for current in islice(it, 4r): @@ -6401,9 +6407,9 @@ def _iter_process_simple_(self, iterator): sage: inverter = Transducer({'A': [('A', 0, 1), ('A', 1, 0)]}, ....: initial_states=['A'], final_states=['A']) - sage: it = inverter.iter_process(words.FibonacciWord()[:10]) - sage: it_simple = inverter._iter_process_simple_(it) - sage: list(it_simple) + sage: it = inverter.iter_process(words.FibonacciWord()[:10]) # needs sage.combinat + sage: it_simple = inverter._iter_process_simple_(it) # needs sage.combinat + sage: list(it_simple) # needs sage.combinat [1, 0, 1, 1, 0, 1, 0, 1, 1, 0] .. SEEALSO:: @@ -10525,6 +10531,7 @@ def moments_waiting_time(self, test=bool, is_zero=None, :: + sage: # needs sage.libs.singular sage: def test(h, r): ....: R = PolynomialRing( ....: QQ, @@ -12779,6 +12786,7 @@ class is created and is used during the processing. This can also be used with words as input:: + sage: # needs sage.combinat sage: W = Words([0, 1]); W Finite and infinite words over {0, 1} sage: w = W([0, 1, 0, 0, 1, 1]); w @@ -12789,7 +12797,7 @@ class is created and is used during the processing. In this case it is automatically determined that the output is a word. The call above is equivalent to:: - sage: binary_inverter.process(w, + sage: binary_inverter.process(w, # needs sage.combinat ....: full_output=False, ....: list_of_outputs=False, ....: automatic_output_type=True) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 15a2bf26c67..b255d328b84 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -5375,7 +5375,7 @@ def shifted_shuffle(self, other): permutations as the ``shifted_shuffle`` method on words (but is faster):: - sage: all( all( sorted(p1.shifted_shuffle(p2)) # needs sage.graphs sage.modules sage.rings.finite_rings + sage: all( all( sorted(p1.shifted_shuffle(p2)) # needs sage.combinat sage.graphs sage.modules sage.rings.finite_rings ....: == sorted([Permutation(p) for p in ....: Word(p1).shifted_shuffle(Word(p2))]) ....: for p2 in Permutations(3) ) @@ -7876,40 +7876,36 @@ def bistochastic_as_sum_of_permutations(M, check=True): We create a bistochastic matrix from a convex sum of permutations, then try to deduce the decomposition from the matrix:: + sage: # needs networkx sage.graphs sage.modules sage: from sage.combinat.permutation import bistochastic_as_sum_of_permutations sage: L = [] sage: L.append((9,Permutation([4, 1, 3, 5, 2]))) sage: L.append((6,Permutation([5, 3, 4, 1, 2]))) sage: L.append((3,Permutation([3, 1, 4, 2, 5]))) sage: L.append((2,Permutation([1, 4, 2, 3, 5]))) - sage: M = sum([c * p.to_matrix() for (c,p) in L]) # needs sage.modules - sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.graphs sage.modules - sage: print(decomp) # needs sage.graphs sage.modules + sage: M = sum([c * p.to_matrix() for (c,p) in L]) + sage: decomp = bistochastic_as_sum_of_permutations(M) + sage: print(decomp) 2*B[[1, 4, 2, 3, 5]] + 3*B[[3, 1, 4, 2, 5]] + 9*B[[4, 1, 3, 5, 2]] + 6*B[[5, 3, 4, 1, 2]] An exception is raised when the matrix is not positive and bistochastic:: - sage: M = Matrix([[2,3],[2,2]]) # needs sage.modules - sage: decomp = bistochastic_as_sum_of_permutations(M) # needs sage.graphs sage.modules + sage: # needs sage.modules + sage: M = Matrix([[2,3],[2,2]]) + sage: decomp = bistochastic_as_sum_of_permutations(M) Traceback (most recent call last): ... ValueError: The matrix is not bistochastic - - sage: bistochastic_as_sum_of_permutations(Matrix(GF(7), 2, [2,1,1,2])) # needs sage.graphs sage.modules + sage: bistochastic_as_sum_of_permutations(Matrix(GF(7), 2, [2,1,1,2])) Traceback (most recent call last): ... ValueError: The base ring of the matrix must have a coercion map to RR - - sage: bistochastic_as_sum_of_permutations(Matrix(ZZ, 2, [2,-1,-1,2])) # needs sage.graphs sage.modules + sage: bistochastic_as_sum_of_permutations(Matrix(ZZ, 2, [2,-1,-1,2])) Traceback (most recent call last): ... ValueError: The matrix should have nonnegative entries """ - from sage.graphs.bipartite_graph import BipartiteGraph - from sage.combinat.free_module import CombinatorialFreeModule - from sage.rings.real_mpfr import RR - n = M.nrows() if n != M.ncols(): @@ -7921,9 +7917,14 @@ def bistochastic_as_sum_of_permutations(M, check=True): if check and not M.is_bistochastic(normalized=False): raise ValueError("The matrix is not bistochastic") + from sage.rings.real_mpfr import RR + if not RR.has_coerce_map_from(M.base_ring()): raise ValueError("The base ring of the matrix must have a coercion map to RR") + from sage.graphs.bipartite_graph import BipartiteGraph + from sage.combinat.free_module import CombinatorialFreeModule + CFM = CombinatorialFreeModule(M.base_ring(), Permutations(n)) value = 0 diff --git a/src/sage/combinat/yang_baxter_graph.py b/src/sage/combinat/yang_baxter_graph.py index f20dda9170e..451bdc9e82e 100644 --- a/src/sage/combinat/yang_baxter_graph.py +++ b/src/sage/combinat/yang_baxter_graph.py @@ -364,7 +364,7 @@ def root(self): sage: Y.root() (1, 0, 3, 2, 1, 0) sage: Y = YangBaxterGraph(partition=[3,2]) # needs sage.combinat - sage: Y.root() + sage: Y.root() # needs sage.combinat (1, 0, 2, 1, 0) """ return self._root From c323d7961325252176160c3432059593934e440c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 9 Sep 2023 23:52:22 -0700 Subject: [PATCH 387/494] src/sage/combinat/symmetric_group_algebra.py: Use lazy_import --- src/sage/combinat/symmetric_group_algebra.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py index 3e8b27e9210..84b29a770b2 100644 --- a/src/sage/combinat/symmetric_group_algebra.py +++ b/src/sage/combinat/symmetric_group_algebra.py @@ -25,9 +25,12 @@ from sage.arith.misc import factorial from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector -from sage.groups.perm_gps.permgroup_element import PermutationGroupElement +from sage.misc.lazy_import import lazy_import from sage.misc.persist import register_unpickle_override +lazy_import('sage.groups.perm_gps.permgroup_element', 'PermutationGroupElement') + + # TODO: Remove this function and replace it with the class # TODO: Create parents for other bases (such as the seminormal basis) From c9a4c5b79aa0925bd6b288c41b8aefbd661684bd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 16:39:46 -0700 Subject: [PATCH 388/494] sage.combinat: Update # needs --- src/sage/combinat/permutation.py | 27 ++++++++++++++------------- src/sage/combinat/skew_tableau.py | 2 +- src/sage/combinat/specht_module.py | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index b255d328b84..8183818d557 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -1256,13 +1256,13 @@ def __mul__(self, rp): """ TESTS:: - sage: # needs sage.modules - sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat - sage: SM = SGA.specht_module([2,1]) # needs sage.combinat + sage: # needs sage.groups sage.modules + sage: SGA = SymmetricGroupAlgebra(QQ, 3) + sage: SM = SGA.specht_module([2,1]) sage: p213 = Permutations(3)([2,1,3]) - sage: p213 * SGA.an_element() # needs sage.combinat + sage: p213 * SGA.an_element() 3*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 2*[3, 1, 2] - sage: p213 * SM.an_element() # needs sage.combinat + sage: p213 * SM.an_element() 2*B[0] - 4*B[1] """ if not isinstance(rp, Permutation) and isinstance(rp, Element): @@ -1302,8 +1302,8 @@ def __rmul__(self, lp) -> Permutation: [3, 2, 1] sage: Permutations.options.mult='l2r' - sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.modules - sage: SGA.an_element() * Permutations(3)(p213) # needs sage.combinat sage.modules + sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.groups sage.modules + sage: SGA.an_element() * Permutations(3)(p213) # needs sage.groups sage.modules 3*[1, 2, 3] + [2, 1, 3] + 2*[2, 3, 1] + [3, 2, 1] """ if not isinstance(lp, Permutation) and isinstance(lp, Element): @@ -7266,17 +7266,17 @@ def algebra(self, base_ring, category=None): EXAMPLES:: + sage: # needs sage.groups sage.modules sage: P = Permutations(4) - sage: A = P.algebra(QQ); A # needs sage.combinat sage.modules + sage: A = P.algebra(QQ); A Symmetric group algebra of order 4 over Rational Field - - sage: A.category() # needs sage.combinat sage.modules + sage: A.category() Join of Category of coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field - sage: A = P.algebra(QQ, category=Monoids()) # needs sage.combinat sage.modules - sage: A.category() # needs sage.combinat sage.modules + sage: A = P.algebra(QQ, category=Monoids()) + sage: A.category() Category of finite dimensional cellular monoid algebras over Rational Field """ from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra @@ -7876,8 +7876,9 @@ def bistochastic_as_sum_of_permutations(M, check=True): We create a bistochastic matrix from a convex sum of permutations, then try to deduce the decomposition from the matrix:: - sage: # needs networkx sage.graphs sage.modules sage: from sage.combinat.permutation import bistochastic_as_sum_of_permutations + + sage: # needs networkx sage.graphs sage.modules sage: L = [] sage: L.append((9,Permutation([4, 1, 3, 5, 2]))) sage: L.append((6,Permutation([5, 3, 4, 1, 2]))) diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py index f3703af3d92..4718f29f199 100644 --- a/src/sage/combinat/skew_tableau.py +++ b/src/sage/combinat/skew_tableau.py @@ -2154,7 +2154,7 @@ def __init__(self, skp): """ TESTS:: - sage" # needs sage.graphs sage.modules + sage: # needs sage.graphs sage.modules sage: S = StandardSkewTableaux([[3, 2, 1], [1, 1]]) sage: TestSuite(S).run() """ diff --git a/src/sage/combinat/specht_module.py b/src/sage/combinat/specht_module.py index 9db20d0b184..209890c1bd1 100644 --- a/src/sage/combinat/specht_module.py +++ b/src/sage/combinat/specht_module.py @@ -1,4 +1,4 @@ -# sage.doctest: needs sage.combinat sage.modules +# sage.doctest: needs sage.combinat sage.groups sage.modules r""" Specht Modules From 9c4029682456723e6e84869bc3df0201dd994d54 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 16 Sep 2023 15:14:04 -0700 Subject: [PATCH 389/494] sage.combinat: Update # needs --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 8183818d557..88e82bd8302 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -7146,7 +7146,7 @@ def element_in_conjugacy_classes(self, nu): sage: PP = Permutations(5) sage: PP.element_in_conjugacy_classes([2,2]) # needs sage.combinat [2, 1, 4, 3, 5] - sage: PP.element_in_conjugacy_classes([5, 5]) + sage: PP.element_in_conjugacy_classes([5, 5]) # needs sage.combinat Traceback (most recent call last): ... ValueError: the size of the partition (=10) should be at most the size of the permutations (=5) From 4e335395f581fbc3e9d15aac8f84787446368c60 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 20:22:13 -0700 Subject: [PATCH 390/494] src/sage/modular/modform_hecketriangle/graded_ring_element.py: More block tags, docstring cosmetics --- .../graded_ring_element.py | 157 +++++++++--------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/src/sage/modular/modform_hecketriangle/graded_ring_element.py b/src/sage/modular/modform_hecketriangle/graded_ring_element.py index 8b173a34acd..0de1562677b 100644 --- a/src/sage/modular/modform_hecketriangle/graded_ring_element.py +++ b/src/sage/modular/modform_hecketriangle/graded_ring_element.py @@ -460,18 +460,19 @@ def is_weakly_holomorphic(self): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic - sage: QuasiMeromorphicModularFormsRing(n=5)(x/(x^5-y^2)+z).is_weakly_holomorphic() # needs sage.symbolic + sage: x, y, z, d = var("x,y,z,d") + sage: QuasiMeromorphicModularFormsRing(n=5)(x/(x^5-y^2)+z).is_weakly_holomorphic() True - sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y/x-d).is_weakly_holomorphic() # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y/x-d).is_weakly_holomorphic() False sage: QuasiMeromorphicModularForms(n=18).J_inv().is_weakly_holomorphic() True - sage: QuasiMeromorphicModularForms(n=infinity, k=-4)(1/x).is_weakly_holomorphic() # needs sage.symbolic + sage: QuasiMeromorphicModularForms(n=infinity, k=-4)(1/x).is_weakly_holomorphic() True - sage: QuasiMeromorphicModularForms(n=infinity, k=-2)(1/y).is_weakly_holomorphic() # needs sage.symbolic + sage: QuasiMeromorphicModularForms(n=infinity, k=-2)(1/y).is_weakly_holomorphic() False """ @@ -487,7 +488,7 @@ def is_holomorphic(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).is_holomorphic() # needs sage.symbolic False sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d+z).is_holomorphic() # needs sage.symbolic @@ -536,7 +537,6 @@ def is_zero(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiModularForms - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic sage: QuasiModularFormsRing(n=5)(1).is_zero() False sage: QuasiModularFormsRing(n=5)(0).is_zero() @@ -558,13 +558,16 @@ def analytic_type(self): sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic - sage: QuasiMeromorphicModularFormsRing(n=5)(x/z+d).analytic_type() # needs sage.symbolic + + sage: # needs sage.symbolic + sage: x, y, z, d = var("x,y,z,d") + sage: QuasiMeromorphicModularFormsRing(n=5)(x/z+d).analytic_type() quasi meromorphic modular - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).analytic_type() # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).analytic_type() quasi weakly holomorphic modular - sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d).analytic_type() # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)(x^2+y-d).analytic_type() modular + sage: QuasiMeromorphicModularForms(n=18).J_inv().analytic_type() weakly holomorphic modular sage: QuasiMeromorphicModularForms(n=18).f_inf().analytic_type() @@ -618,22 +621,23 @@ def denominator(self): EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.modular.modform_hecketriangle.graded_ring import QuasiMeromorphicModularFormsRing sage: from sage.modular.modform_hecketriangle.space import QuasiMeromorphicModularForms - sage: x, y, z, d = var("x,y,z,d") # needs sage.symbolic + sage: x, y, z, d = var("x,y,z,d") sage: QuasiMeromorphicModularFormsRing(n=5).Delta().full_reduce().denominator() 1 + O(q^5) - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator() # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator() f_rho^5 - f_i^2 - sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator().parent() # needs sage.symbolic + sage: QuasiMeromorphicModularFormsRing(n=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator().parent() QuasiModularFormsRing(n=5) over Integer Ring - sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator() # needs sage.symbolic + sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator() 1 - 13/(40*d)*q - 351/(64000*d^2)*q^2 - 13819/(76800000*d^3)*q^3 - 1163669/(491520000000*d^4)*q^4 + O(q^5) - sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator().parent() # needs sage.symbolic + sage: QuasiMeromorphicModularForms(n=5, k=-2, ep=-1)(x/y).denominator().parent() QuasiModularForms(n=5, k=10/3, ep=-1) over Integer Ring - sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator() # needs sage.symbolic + sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator() -64*q - 512*q^2 - 768*q^3 + 4096*q^4 + O(q^5) - sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator().parent() # needs sage.symbolic + sage: (QuasiMeromorphicModularForms(n=infinity, k=-6, ep=-1)(y/(x*(x-y^2)))).denominator().parent() QuasiModularForms(n=+Infinity, k=8, ep=1) over Integer Ring """ @@ -1011,22 +1015,21 @@ def diff_op(self, op, new_parent=None): INPUT: - - ``op`` -- An element of ``self.parent().diff_alg()``. - I.e. an element of the algebra over ``QQ`` - of differential operators generated - by ``X, Y, Z, dX, dY, DZ``, where e.g. ``X`` - corresponds to the multiplication by ``x`` - (resp. ``f_rho``) and ``dX`` corresponds to ``d/dx``. + - ``op`` -- An element of ``self.parent().diff_alg()``. + I.e. an element of the algebra over ``QQ`` + of differential operators generated + by ``X, Y, Z, dX, dY, DZ``, where e.g. ``X`` + corresponds to the multiplication by ``x`` + (resp. ``f_rho``) and ``dX`` corresponds to ``d/dx``. - To expect a homogeneous result after applying - the operator to a homogeneous element it should - should be homogeneous operator (with respect - to the usual, special grading). + To expect a homogeneous result after applying + the operator to a homogeneous element it should + should be homogeneous operator (with respect + to the usual, special grading). - ``new_parent`` -- Try to convert the result to the specified - ``new_parent``. If ``new_parent == None`` (default) - then the parent is extended to a - "quasi meromorphic" ring. + ``new_parent``. If ``new_parent == None`` (default) + then the parent is extended to a "quasi meromorphic" ring. OUTPUT: @@ -1587,31 +1590,31 @@ def _q_expansion_cached(self, prec, fix_d, subs_d, d_num_prec, fix_prec=False): def q_expansion(self, prec=None, fix_d=False, d_num_prec=None, fix_prec=False): """ - Returns the Fourier expansion of self. + Return the Fourier expansion of ``self``. INPUT: - - ``prec`` -- An integer, the desired output precision O(q^prec). - Default: ``None`` in which case the default precision - of ``self.parent()`` is used. + - ``prec`` -- An integer, the desired output precision O(q^prec). + Default: ``None`` in which case the default precision + of ``self.parent()`` is used. - - ``fix_d`` -- If ``False`` (default) a formal parameter is used for ``d``. - If ``True`` then the numerical value of ``d`` is used - (resp. an exact value if the group is arithmetic). - Otherwise the given value is used for ``d``. + - ``fix_d`` -- If ``False`` (default) a formal parameter is used for ``d``. + If ``True`` then the numerical value of ``d`` is used + (resp. an exact value if the group is arithmetic). + Otherwise the given value is used for ``d``. - ``d_num_prec`` -- The precision to be used if a numerical value for ``d`` is substituted. - Default: ``None`` in which case the default - numerical precision of ``self.parent()`` is used. + Default: ``None`` in which case the default + numerical precision of ``self.parent()`` is used. - - ``fix_prec`` -- If ``fix_prec`` is not ``False`` (default) - then the precision of the ``MFSeriesConstructor`` is - increased such that the output has exactly the specified - precision O(q^prec). + - ``fix_prec`` -- If ``fix_prec`` is not ``False`` (default) + then the precision of the ``MFSeriesConstructor`` is + increased such that the output has exactly the specified + precision O(q^prec). OUTPUT: - The Fourier expansion of self as a ``FormalPowerSeries`` or ``FormalLaurentSeries``. + The Fourier expansion of ``self`` as a ``FormalPowerSeries`` or ``FormalLaurentSeries``. EXAMPLES:: @@ -1691,24 +1694,24 @@ def q_expansion(self, prec=None, fix_d=False, d_num_prec=None, fix_prec=False): def q_expansion_fixed_d(self, prec=None, d_num_prec=None, fix_prec=False): """ - Returns the Fourier expansion of self. + Return the Fourier expansion of ``self``. + The numerical (or exact) value for ``d`` is substituted. INPUT: - - ``prec`` -- An integer, the desired output precision O(q^prec). - Default: ``None`` in which case the default precision - of ``self.parent()`` is used. + - ``prec`` -- An integer, the desired output precision O(q^prec). + Default: ``None`` in which case the default precision of ``self.parent()`` is used. - ``d_num_prec`` -- The precision to be used if a numerical value for ``d`` is substituted. - Default: ``None`` in which case the default - numerical precision of ``self.parent()`` is used. + Default: ``None`` in which case the default + numerical precision of ``self.parent()`` is used. - - ``fix_prec`` -- If ``fix_prec`` is not ``False`` (default) - then the precision of the ``MFSeriesConstructor`` is - increased such that the output has exactly the specified - precision O(q^prec). + - ``fix_prec`` -- If ``fix_prec`` is not ``False`` (default) + then the precision of the ``MFSeriesConstructor`` is + increased such that the output has exactly the specified + precision O(q^prec). OUTPUT: @@ -1758,20 +1761,19 @@ def q_expansion_vector(self, min_exp=None, max_exp=None, prec=None, **kwargs): INPUT: - ``min_exp`` -- An integer, specifying the first coefficient to be - used for the vector. Default: ``None``, meaning that - the first non-trivial coefficient is used. + used for the vector. Default: ``None``, meaning that + the first non-trivial coefficient is used. - - ``max_exp`` -- An integer, specifying the last coefficient to be - used for the vector. Default: ``None``, meaning that - the default precision + 1 is used. + - ``max_exp`` -- An integer, specifying the last coefficient to be + used for the vector. Default: ``None``, meaning that + the default precision + 1 is used. - - ``prec`` -- An integer, specifying the precision of the underlying - Laurent series. Default: ``None``, meaning that - ``max_exp + 1`` is used. + - ``prec`` -- An integer, specifying the precision of the underlying + Laurent series. Default: ``None``, meaning that ``max_exp + 1`` is used. OUTPUT: - A vector of size ``max_exp - min_exp`` over the coefficient ring of self, + A vector of size ``max_exp - min_exp`` over the coefficient ring of ``self``, determined by the corresponding Laurent series coefficients. EXAMPLES:: @@ -1841,22 +1843,21 @@ def evaluate(self, tau, prec=None, num_prec=None, check=False): INPUT: - - ``tau`` -- ``infinity`` or an element of the upper - half plane. E.g. with parent ``AA`` or ``CC``. + - ``tau`` -- ``infinity`` or an element of the upper + half plane. E.g. with parent ``AA`` or ``CC``. - - ``prec`` -- An integer, namely the precision used for the - Fourier expansion. If ``prec == None`` (default) - then the default precision of ``self.parent()`` - is used. + - ``prec`` -- An integer, namely the precision used for the + Fourier expansion. If ``prec == None`` (default) + then the default precision of ``self.parent()`` is used. - - ``num_prec`` -- An integer, namely the minimal numerical precision - used for ``tau`` and ``d``. If ``num_prec == None`` - (default) then the default numerical precision of - ``self.parent()`` is used. + - ``num_prec`` -- An integer, namely the minimal numerical precision + used for ``tau`` and ``d``. If ``num_prec == None`` + (default) then the default numerical precision of + ``self.parent()`` is used. - - ``check`` -- If ``True`` then the order of ``tau`` is checked. - Otherwise the order is only considered for - ``tau = infinity, i, rho, -1/rho``. Default: ``False``. + - ``check`` -- If ``True`` then the order of ``tau`` is checked. + Otherwise the order is only considered for + ``tau = infinity, i, rho, -1/rho``. Default: ``False``. OUTPUT: From 075be5a73e0b3fc1b937ac101fddffc46a1cd721 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 1 Nov 2023 13:38:53 +0900 Subject: [PATCH 391/494] diff only .html files --- .github/workflows/doc-build-pdf.yml | 2 +- .github/workflows/doc-build.yml | 5 +++-- .github/workflows/doc-publish.yml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index de58c143c74..9a266560dc0 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -119,7 +119,7 @@ jobs: # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder mkdir -p ./docs - cp -r -L /sage/local/share/doc/sage/pdf/* ./docs + cp -r -L /sage/local/share/doc/sage/pdf ./docs # Zip everything for increased performance zip -r docs-pdf.zip docs diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 3894c405077..2cb9501eed8 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -162,7 +162,7 @@ jobs: EOF echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html && git diff HEAD^; rm -rf .git) > ./docs/diff.txt + (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF import re, html with open('./docs/diff.txt', 'r') as f: @@ -186,7 +186,8 @@ jobs: # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them - cp -r -L /sage/local/share/doc/sage/html/* ./docs + cp -r -L /sage/local/share/doc/sage/html ./docs + cp /sage/local/share/doc/sage/index.html ./docs # Zip everything for increased performance zip -r docs.zip docs diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 14337131420..10a2d6487c5 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -72,7 +72,7 @@ jobs: header: preview-comment recreate: true message: | - [Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! :tada: + [Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/html/en) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! :tada: - name: Update deployment status PR check uses: myrotvorets/set-commit-status-action@v2.0.0 From f800cf8a2e58701ad671994133c8a8ec0cea8d77 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 23:19:49 -0700 Subject: [PATCH 392/494] .github/workflows/build.yml: Fix configuration of coverage upload action --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ac9c6154d0..5f466d3a285 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -193,11 +193,12 @@ jobs: run: | ./venv/bin/python3 -m coverage combine src/.coverage/ ./venv/bin/python3 -m coverage xml - find . -name *coverage* + mkdir -p coverage-report + mv coverage.xml coverage-report/ working-directory: ./worktree-image - name: Upload coverage to codecov if: always() && steps.build.outcome == 'success' uses: codecov/codecov-action@v3 with: - files: ./worktree-image/coverage.xml + directory: ./worktree-image/coverage-report From cc9ff2006f2b1f3aff781d92aa8adaf3a4decc6d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 1 Nov 2023 15:44:14 +0900 Subject: [PATCH 393/494] Remove dangling part from sageinspect.py --- src/sage/misc/sageinspect.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index bbd03bcb24c..8c734ecd36d 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1806,6 +1806,7 @@ def formatannotation(annotation, base_module=None): return annotation.__module__ + '.' + annotation.__qualname__ return repr(annotation) +_formatannotation = formatannotation def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults=None, annotations={}, @@ -1814,7 +1815,7 @@ def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, formatvarkw=None, formatvalue=None, formatreturns=None, - formatannotation=formatannotation): + formatannotation=None): """ Format an argument spec from the values returned by getfullargspec. @@ -1851,6 +1852,8 @@ def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, formatvalue = lambda value: '=' + repr(value) if formatreturns is None: formatreturns = lambda text: ' -> ' + text + if formatannotation is None: + formatannotation = _formatannotation def formatargandannotation(arg): result = formatarg(arg) From 3394eecc309e3c0b9baf892b788bb0bd18bfcb5a Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 1 Nov 2023 15:55:28 +0900 Subject: [PATCH 394/494] Fix path for diffsite --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 2cb9501eed8..67a29b7c60f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -172,7 +172,7 @@ jobs: for block in diff_blocks: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: - path = match.group(1) + path = 'html' + match.group(1) out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: From b4e7f601200fe1691e54cedf709c566b55ca55f1 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 1 Nov 2023 18:27:18 +0900 Subject: [PATCH 395/494] Fix path --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 67a29b7c60f..188e6b816b9 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -172,7 +172,7 @@ jobs: for block in diff_blocks: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: - path = 'html' + match.group(1) + path = 'html/' + match.group(1) out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: From c2880a216b99a5f6828bbdec5de344eb123579f5 Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Wed, 1 Nov 2023 09:36:55 +0000 Subject: [PATCH 396/494] Add suggested changes --- src/sage/graphs/domination.py | 61 ++++++++++++++++++++++++-------- src/sage/graphs/generic_graph.py | 4 +-- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 54fc2ee1f21..582dd67d3bb 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -17,7 +17,7 @@ :meth:`~is_redundant` | Check whether a set of vertices has redundant vertices (with respect to domination). :meth:`~private_neighbors` | Return the private neighbors of a vertex with respect to other vertices. :meth:`~greedy_dominating_set` | Return a greedy distance-`k` dominating set of the graph. - :meth:`~max_leaf_number` | Return the maximum leaf number of the graph. + :meth:`~maximum_leaf_number` | Return the maximum leaf number of the graph. EXAMPLES: @@ -1287,43 +1287,76 @@ def greedy_dominating_set(G, k=1, vertices=None, ordering=None, return_sets=Fals return list(dom) -# ============================================================================== -# Maximum leaf number -# ============================================================================== - -def max_leaf_number(G): +def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): r""" - Return the maximum leaf number of the graph, i.e. the maximum possible number - of leaf nodes a tree produced from the graph can have. + Return the maximum leaf number of the graph. + + The maximum leaf number is the maximum possible number of leaves of a + spanning tree of `G`. This is also the cardinality of the complement of a + minimum connected dominating set. + See the :wikipedia:`Connected_dominating_set`. INPUT: - ``G`` -- a Graph + - ``solver`` -- string (default: ``None``); specify a Mixed Integer Linear + Programming (MILP) solver to be used. If set to ``None``, the default one + is used. For more information on MILP solvers and which default solver is + used, see the method :meth:`solve + ` of the class + :class:`MixedIntegerLinearProgram + `. + + - ``verbose`` -- integer (default: ``0``); sets the level of verbosity. Set + to 0 by default, which means quiet. + + - ``integrality_tolerance`` -- float; parameter for use with MILP solvers + over an inexact base ring; see + :meth:`MixedIntegerLinearProgram.get_values`. + EXAMPLES: Empty graph:: sage: G = Graph() - sage: G.max_leaf_number() + sage: G.maximum_leaf_number() 0 Petersen graph:: sage: G = graphs.PetersenGraph() - sage: G.max_leaf_number() + sage: G.maximum_leaf_number() 6 + TESTS: + + One vertex:: + + sage: G = graphs.Graph(1) + sage: G.maximum_leaf_number() + 1 + + Two vertices:: + + sage: G = graphs.PathGraph(2) + sage: G.maximum_leaf_number() + 2 + Unconnected graph:: - sage: G = 2 * graphs.PetersenGraph() - sage: G.max_leaf_number() + sage: G = Graph(2) + sage: G.maximum_leaf_number() Traceback (most recent call last): ... ValueError: the graph must be connected """ - if G.order() < 2: + # The MLN of a graph with less than 2 vertices is 0, while the + # MLN of a connected graph with 2 or 3 vertices is 1 or 2 respectively. + if G.order() <= 1: return 0 elif not G.is_connected(): raise ValueError('the graph must be connected') - return G.order() - dominating_set(G, connected=True, value_only=True) + elif G.order() <= 3: + return G.order() - 1 + return G.order() - dominating_set(G, connected=True, value_only=True, solver=solver, verbose=verbose, integrality_tolerance=integrality_tolerance) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index b5a79b5f3c7..a9129a62e7d 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -315,7 +315,7 @@ :meth:`~GenericGraph.disjoint_routed_paths` | Return a set of disjoint routed paths. :meth:`~GenericGraph.dominating_set` | Return a minimum dominating set of the graph :meth:`~GenericGraph.greedy_dominating_set` | Return a greedy distance-`k` dominating set of the graph. - :meth:`~GenericGraph.max_leaf_number` | Return the maximum leaf number of the graph. + :meth:`~GenericGraph.maximum_leaf_number` | Return the maximum leaf number of the graph. :meth:`~GenericGraph.subgraph_search` | Return a copy of ``G`` in ``self``. :meth:`~GenericGraph.subgraph_search_count` | Return the number of labelled occurrences of ``G`` in ``self``. :meth:`~GenericGraph.subgraph_search_iterator` | Return an iterator over the labelled copies of ``G`` in ``self``. @@ -24408,7 +24408,7 @@ def is_self_complementary(self): from sage.graphs.domination import dominating_sets from sage.graphs.domination import dominating_set from sage.graphs.domination import greedy_dominating_set - from sage.graphs.domination import max_leaf_number + from sage.graphs.domination import maximum_leaf_number from sage.graphs.base.static_dense_graph import connected_subgraph_iterator rooted_product = LazyImport('sage.graphs.graph_decompositions.graph_products', 'rooted_product') from sage.graphs.path_enumeration import shortest_simple_paths From 0ac47fd8015b23eecd0966598d31d18ff5590801 Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Wed, 1 Nov 2023 09:50:51 +0000 Subject: [PATCH 397/494] Fix whitespace --- src/sage/graphs/domination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 582dd67d3bb..861b9f6e52d 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -1351,7 +1351,7 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): ... ValueError: the graph must be connected """ - # The MLN of a graph with less than 2 vertices is 0, while the + # The MLN of a graph with less than 2 vertices is 0, while the # MLN of a connected graph with 2 or 3 vertices is 1 or 2 respectively. if G.order() <= 1: return 0 From f67d073b112c3c87c8cd02634cb740e5fd225b6b Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Wed, 1 Nov 2023 11:33:16 +0000 Subject: [PATCH 398/494] Fix tests and add recommended changes --- src/sage/graphs/domination.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 861b9f6e52d..94d95fa82d0 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -1296,6 +1296,9 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): minimum connected dominating set. See the :wikipedia:`Connected_dominating_set`. + The MLN of a graph with less than 2 vertices is 0, while the MLN of a connected + graph with 2 or 3 vertices is 1 or 2 respectively. + INPUT: - ``G`` -- a Graph @@ -1329,19 +1332,19 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): sage: G.maximum_leaf_number() 6 - TESTS: + Tests: One vertex:: - sage: G = graphs.Graph(1) + sage: G = Graph(1) sage: G.maximum_leaf_number() - 1 + 0 Two vertices:: sage: G = graphs.PathGraph(2) sage: G.maximum_leaf_number() - 2 + 1 Unconnected graph:: @@ -1351,12 +1354,10 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): ... ValueError: the graph must be connected """ - # The MLN of a graph with less than 2 vertices is 0, while the - # MLN of a connected graph with 2 or 3 vertices is 1 or 2 respectively. if G.order() <= 1: return 0 - elif not G.is_connected(): + if not G.is_connected(): raise ValueError('the graph must be connected') - elif G.order() <= 3: + if G.order() <= 3: return G.order() - 1 return G.order() - dominating_set(G, connected=True, value_only=True, solver=solver, verbose=verbose, integrality_tolerance=integrality_tolerance) From 5997da9410d169d83f19bdffac265bde0ccd999b Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Wed, 1 Nov 2023 13:25:14 +0000 Subject: [PATCH 399/494] RSA primes must be odd --- src/sage/tests/book_stein_ent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/tests/book_stein_ent.py b/src/sage/tests/book_stein_ent.py index c056e43aa55..af4f77eb566 100644 --- a/src/sage/tests/book_stein_ent.py +++ b/src/sage/tests/book_stein_ent.py @@ -193,7 +193,7 @@ ....: proof=proof) ....: q = next_prime(ZZ.random_element(2**(bits//2 +1)), ....: proof=proof) -....: if (p != q): break +....: if (p != q and p > 2 and q > 2): break ....: n = p * q ....: phi_n = (p-1) * (q-1) ....: while True: From 1a50a80cc00d28f61ac57f0d0d5d3a1897b6c5b0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 15:15:50 -0700 Subject: [PATCH 400/494] Replace relative cimports --- src/sage/libs/arb/arith.pyx | 8 +- src/sage/libs/arb/bernoulli.pxd | 2 +- src/sage/libs/coxeter3/coxeter.pxd | 2 +- src/sage/libs/coxeter3/coxeter.pyx | 2 +- src/sage/libs/eclib/homspace.pxd | 2 +- src/sage/libs/eclib/homspace.pyx | 4 +- src/sage/libs/eclib/mat.pxd | 6 +- src/sage/libs/eclib/mat.pyx | 2 +- src/sage/libs/eclib/newforms.pxd | 2 +- src/sage/libs/eclib/newforms.pyx | 2 +- src/sage/libs/flint/arith.pyx | 4 +- src/sage/libs/flint/ntl_interface.pxd | 2 +- src/sage/libs/gap/element.pxd | 2 +- src/sage/libs/gap/element.pyx | 4 +- src/sage/libs/gap/libgap.pyx | 6 +- src/sage/libs/gap/util.pxd | 2 +- src/sage/libs/gap/util.pyx | 4 +- src/sage/libs/glpk/error.pyx | 2 +- src/sage/libs/gmp/all.pxd | 10 +- src/sage/libs/gmp/binop.pxd | 6 +- src/sage/libs/gmp/mpf.pxd | 2 +- src/sage/libs/gmp/mpn.pxd | 2 +- src/sage/libs/gmp/mpq.pxd | 2 +- src/sage/libs/gmp/mpz.pxd | 2 +- src/sage/libs/gmp/pylong.pyx | 2 +- src/sage/libs/gmp/random.pxd | 2 +- src/sage/libs/gsl/airy.pxd | 2 +- src/sage/libs/gsl/all.pxd | 122 +++++++++--------- src/sage/libs/gsl/bessel.pxd | 2 +- src/sage/libs/gsl/blas.pxd | 2 +- src/sage/libs/gsl/block.pxd | 2 +- src/sage/libs/gsl/chebyshev.pxd | 2 +- src/sage/libs/gsl/clausen.pxd | 2 +- src/sage/libs/gsl/combination.pxd | 2 +- src/sage/libs/gsl/complex.pxd | 2 +- src/sage/libs/gsl/coulomb.pxd | 2 +- src/sage/libs/gsl/coupling.pxd | 2 +- src/sage/libs/gsl/dawson.pxd | 2 +- src/sage/libs/gsl/debye.pxd | 2 +- src/sage/libs/gsl/dilog.pxd | 2 +- src/sage/libs/gsl/eigen.pxd | 2 +- src/sage/libs/gsl/elementary.pxd | 2 +- src/sage/libs/gsl/ellint.pxd | 2 +- src/sage/libs/gsl/erf.pxd | 2 +- src/sage/libs/gsl/exp.pxd | 2 +- src/sage/libs/gsl/expint.pxd | 2 +- src/sage/libs/gsl/fermi_dirac.pxd | 2 +- src/sage/libs/gsl/fft.pxd | 2 +- src/sage/libs/gsl/gamma.pxd | 2 +- src/sage/libs/gsl/gegenbauer.pxd | 2 +- src/sage/libs/gsl/histogram.pxd | 2 +- src/sage/libs/gsl/hyperg.pxd | 2 +- src/sage/libs/gsl/integration.pxd | 2 +- src/sage/libs/gsl/laguerre.pxd | 2 +- src/sage/libs/gsl/lambert.pxd | 2 +- src/sage/libs/gsl/legendre.pxd | 2 +- src/sage/libs/gsl/linalg.pxd | 2 +- src/sage/libs/gsl/log.pxd | 2 +- src/sage/libs/gsl/math.pxd | 2 +- src/sage/libs/gsl/matrix.pxd | 2 +- src/sage/libs/gsl/matrix_complex.pxd | 2 +- src/sage/libs/gsl/min.pxd | 2 +- src/sage/libs/gsl/monte.pxd | 2 +- src/sage/libs/gsl/ntuple.pxd | 2 +- src/sage/libs/gsl/permutation.pxd | 2 +- src/sage/libs/gsl/poly.pxd | 2 +- src/sage/libs/gsl/pow_int.pxd | 2 +- src/sage/libs/gsl/psi.pxd | 2 +- src/sage/libs/gsl/random.pxd | 2 +- src/sage/libs/gsl/rng.pxd | 2 +- src/sage/libs/gsl/roots.pxd | 2 +- src/sage/libs/gsl/sort.pxd | 2 +- src/sage/libs/gsl/synchrotron.pxd | 2 +- src/sage/libs/gsl/transport.pxd | 2 +- src/sage/libs/gsl/trig.pxd | 2 +- src/sage/libs/gsl/types.pxd | 2 +- src/sage/libs/gsl/vector.pxd | 2 +- src/sage/libs/gsl/vector_complex.pxd | 2 +- src/sage/libs/gsl/wavelet.pxd | 2 +- src/sage/libs/gsl/zeta.pxd | 2 +- src/sage/libs/linbox/conversion.pxd | 4 +- src/sage/libs/linbox/fflas.pxd | 4 +- src/sage/libs/linbox/linbox.pxd | 2 +- .../libs/linbox/linbox_flint_interface.pyx | 2 +- src/sage/libs/mpmath/ext_libmp.pyx | 2 +- src/sage/libs/mpmath/ext_main.pxd | 2 +- src/sage/libs/mpmath/ext_main.pyx | 2 +- src/sage/libs/pari/convert_flint.pyx | 2 +- src/sage/libs/pari/convert_sage.pyx | 2 +- 89 files changed, 166 insertions(+), 170 deletions(-) diff --git a/src/sage/libs/arb/arith.pyx b/src/sage/libs/arb/arith.pyx index 3b32fe7e8ed..69281d916ce 100644 --- a/src/sage/libs/arb/arith.pyx +++ b/src/sage/libs/arb/arith.pyx @@ -12,10 +12,10 @@ Arithmetic functions using the arb library # http://www.gnu.org/licenses/ #***************************************************************************** -from ..flint.types cimport ulong -from ..flint.fmpq cimport fmpq_t, fmpq_init, fmpq_clear, fmpq_get_mpq -from .bernoulli cimport bernoulli_fmpq_ui -from .acb_modular cimport acb_modular_hilbert_class_poly +from sage.libs.flint.types cimport ulong +from sage.libs.flint.fmpq cimport fmpq_t, fmpq_init, fmpq_clear, fmpq_get_mpq +from sage.libs.arb.bernoulli cimport bernoulli_fmpq_ui +from sage.libs.arb.acb_modular cimport acb_modular_hilbert_class_poly from sage.rings.rational cimport Rational from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd index 375b2b9bbcf..f859ebfb8d7 100644 --- a/src/sage/libs/arb/bernoulli.pxd +++ b/src/sage/libs/arb/bernoulli.pxd @@ -1,7 +1,7 @@ # distutils: libraries = gmp flint ARB_LIBRARY # distutils: depends = bernoulli.h -from ..flint.types cimport fmpq_t, ulong +from sage.libs.flint.types cimport fmpq_t, ulong # bernoulli.h cdef extern from "arb_wrap.h": diff --git a/src/sage/libs/coxeter3/coxeter.pxd b/src/sage/libs/coxeter3/coxeter.pxd index c30ca1925b8..e8a89458e78 100644 --- a/src/sage/libs/coxeter3/coxeter.pxd +++ b/src/sage/libs/coxeter3/coxeter.pxd @@ -8,7 +8,7 @@ #***************************************************************************** from sage.structure.sage_object cimport SageObject -from .decl cimport * +from sage.libs.coxeter3.decl cimport * cdef class String: cdef c_String x diff --git a/src/sage/libs/coxeter3/coxeter.pyx b/src/sage/libs/coxeter3/coxeter.pyx index 1b21b010481..83cd1dccaee 100644 --- a/src/sage/libs/coxeter3/coxeter.pyx +++ b/src/sage/libs/coxeter3/coxeter.pyx @@ -17,7 +17,7 @@ Low level part of the interface to Fokko Ducloux's Coxeter 3 library # https://www.gnu.org/licenses/ # **************************************************************************** -from .decl cimport * +from sage.libs.coxeter3.decl cimport * from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.cpython.string cimport str_to_bytes, bytes_to_str diff --git a/src/sage/libs/eclib/homspace.pxd b/src/sage/libs/eclib/homspace.pxd index bf315f40ca9..d3600547f1e 100644 --- a/src/sage/libs/eclib/homspace.pxd +++ b/src/sage/libs/eclib/homspace.pxd @@ -1,4 +1,4 @@ -from ..eclib cimport homspace +from sage.libs.eclib cimport homspace cdef class ModularSymbols: cdef homspace* H diff --git a/src/sage/libs/eclib/homspace.pyx b/src/sage/libs/eclib/homspace.pyx index dc52b144328..735de8787e2 100644 --- a/src/sage/libs/eclib/homspace.pyx +++ b/src/sage/libs/eclib/homspace.pyx @@ -4,8 +4,8 @@ from cysignals.signals cimport sig_on, sig_off from cython.operator cimport dereference as deref from cython.operator cimport preincrement as inc -from ..eclib cimport svec, mat, smat -from .mat cimport MatrixFactory +from sage.libs.eclib cimport svec, mat, smat +from sage.libs.eclib.mat cimport MatrixFactory from sage.matrix.matrix_space import MatrixSpace from sage.rings.integer_ring import ZZ diff --git a/src/sage/libs/eclib/mat.pxd b/src/sage/libs/eclib/mat.pxd index 0bba3eb62d5..de8d9e81ad3 100644 --- a/src/sage/libs/eclib/mat.pxd +++ b/src/sage/libs/eclib/mat.pxd @@ -1,11 +1,7 @@ -from ..eclib cimport mat +from sage.libs.eclib cimport mat cdef class Matrix: cdef mat* M cdef class MatrixFactory: cdef new_matrix(self, mat M) noexcept - - - - diff --git a/src/sage/libs/eclib/mat.pyx b/src/sage/libs/eclib/mat.pyx index 24c5ce55fb2..b83cd76b5a5 100644 --- a/src/sage/libs/eclib/mat.pyx +++ b/src/sage/libs/eclib/mat.pyx @@ -2,7 +2,7 @@ Cremona matrices """ -from ..eclib cimport scalar, addscalar +from sage.libs.eclib cimport scalar, addscalar from sage.matrix.matrix_space import MatrixSpace from sage.rings.integer_ring import ZZ diff --git a/src/sage/libs/eclib/newforms.pxd b/src/sage/libs/eclib/newforms.pxd index 9cd1b23a034..7f78a4f9f63 100644 --- a/src/sage/libs/eclib/newforms.pxd +++ b/src/sage/libs/eclib/newforms.pxd @@ -1,4 +1,4 @@ -from ..eclib cimport newforms +from sage.libs.eclib cimport newforms cdef class ECModularSymbol: cdef newforms* nfs diff --git a/src/sage/libs/eclib/newforms.pyx b/src/sage/libs/eclib/newforms.pyx index 2d35716c4db..210c1d9e2c0 100644 --- a/src/sage/libs/eclib/newforms.pyx +++ b/src/sage/libs/eclib/newforms.pyx @@ -13,7 +13,7 @@ Modular symbols using eclib newforms from cysignals.signals cimport sig_on, sig_off -from ..eclib cimport * +from sage.libs.eclib cimport * from sage.libs.gmp.mpq cimport mpq_numref from sage.libs.ntl.convert cimport mpz_to_ZZ from sage.rings.rational_field import QQ diff --git a/src/sage/libs/flint/arith.pyx b/src/sage/libs/flint/arith.pyx index f24446b4ae4..fefe5f07efd 100644 --- a/src/sage/libs/flint/arith.pyx +++ b/src/sage/libs/flint/arith.pyx @@ -15,8 +15,8 @@ FLINT Arithmetic Functions from cysignals.signals cimport sig_on, sig_off -from .fmpz cimport * -from .fmpq cimport * +from sage.libs.flint.fmpz cimport * +from sage.libs.flint.fmpq cimport * from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/ntl_interface.pxd b/src/sage/libs/flint/ntl_interface.pxd index d3ba446d8d3..d6112383330 100644 --- a/src/sage/libs/flint/ntl_interface.pxd +++ b/src/sage/libs/flint/ntl_interface.pxd @@ -2,7 +2,7 @@ # distutils: libraries = flint # distutils: depends = flint/NTL-interface.h -from .types cimport fmpz_t, fmpz_poly_t +from sage.libs.flint.types cimport fmpz_t, fmpz_poly_t from sage.libs.ntl.ZZ cimport ZZ_c from sage.libs.ntl.ZZX cimport ZZX_c diff --git a/src/sage/libs/gap/element.pxd b/src/sage/libs/gap/element.pxd index 7882414df20..329001e72f5 100644 --- a/src/sage/libs/gap/element.pxd +++ b/src/sage/libs/gap/element.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .gap_includes cimport Obj, UInt +from sage.libs.gap.gap_includes cimport Obj, UInt from sage.structure.sage_object cimport SageObject from sage.structure.element cimport Element, ModuleElement, RingElement diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx index a5f0dfcd24c..d698fc6bce7 100644 --- a/src/sage/libs/gap/element.pyx +++ b/src/sage/libs/gap/element.pyx @@ -18,9 +18,9 @@ elements. For general information about GAP, you should read the from cpython.object cimport Py_EQ, Py_NE, Py_LE, Py_GE, Py_LT, Py_GT from cysignals.signals cimport sig_on, sig_off -from .gap_includes cimport * +from sage.libs.gap.gap_includes cimport * from .libgap import libgap -from .util cimport * +from sage.libs.gap.util cimport * from .util import GAPError from sage.cpython.string cimport str_to_bytes, char_to_str from sage.rings.integer_ring import ZZ diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx index 33a17cff528..3803f32b191 100644 --- a/src/sage/libs/gap/libgap.pyx +++ b/src/sage/libs/gap/libgap.pyx @@ -213,9 +213,9 @@ AUTHORS: from pathlib import Path -from .gap_includes cimport * -from .util cimport * -from .element cimport * +from sage.libs.gap.gap_includes cimport * +from sage.libs.gap.util cimport * +from sage.libs.gap.element cimport * from sage.cpython.string cimport str_to_bytes from sage.structure.parent cimport Parent diff --git a/src/sage/libs/gap/util.pxd b/src/sage/libs/gap/util.pxd index e7b499a7b5a..8b4a7aadce7 100644 --- a/src/sage/libs/gap/util.pxd +++ b/src/sage/libs/gap/util.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .gap_includes cimport Obj +from sage.libs.gap.gap_includes cimport Obj ############################################################################ ### Hooking into the GAP memory management ################################# diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index f4f18589e14..177e30fa06a 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -24,8 +24,8 @@ import os import warnings import sage.env -from .gap_includes cimport * -from .element cimport * +from sage.libs.gap.gap_includes cimport * +from sage.libs.gap.element cimport * from sage.cpython.string import FS_ENCODING from sage.cpython.string cimport str_to_bytes, char_to_str from sage.interfaces.gap_workspace import prepare_workspace_dir diff --git a/src/sage/libs/glpk/error.pyx b/src/sage/libs/glpk/error.pyx index 1d265f3ef65..da5595a7709 100644 --- a/src/sage/libs/glpk/error.pyx +++ b/src/sage/libs/glpk/error.pyx @@ -14,7 +14,7 @@ Error handler for the GLPK library from cysignals.signals cimport sig_error -from .env cimport * +from sage.libs.glpk.env cimport * from cpython.exc cimport PyErr_SetObject from sage.cpython.string cimport char_to_str from sage.numerical.mip import MIPSolverException diff --git a/src/sage/libs/gmp/all.pxd b/src/sage/libs/gmp/all.pxd index c9b26912094..cf1f3fa6417 100644 --- a/src/sage/libs/gmp/all.pxd +++ b/src/sage/libs/gmp/all.pxd @@ -1,5 +1,5 @@ -from .types cimport * -from .random cimport * -from .mpz cimport * -from .mpq cimport * -from .pylong cimport * +from sage.libs.gmp.types cimport * +from sage.libs.gmp.random cimport * +from sage.libs.gmp.mpz cimport * +from sage.libs.gmp.mpq cimport * +from sage.libs.gmp.pylong cimport * diff --git a/src/sage/libs/gmp/binop.pxd b/src/sage/libs/gmp/binop.pxd index 983e6de5214..6b56c24a1b5 100644 --- a/src/sage/libs/gmp/binop.pxd +++ b/src/sage/libs/gmp/binop.pxd @@ -2,9 +2,9 @@ r""" Fast binary operations for basic types """ -from .types cimport mpz_t, mpq_t -from .mpz cimport mpz_set, mpz_add, mpz_mul -from .mpq cimport mpq_canonicalize, mpq_numref, mpq_denref, mpq_add +from sage.libs.gmp.types cimport mpz_t, mpq_t +from sage.libs.gmp.mpz cimport mpz_set, mpz_add, mpz_mul +from sage.libs.gmp.mpq cimport mpq_canonicalize, mpq_numref, mpq_denref, mpq_add cdef inline void mpq_add_z(mpq_t res, mpq_t op1, mpz_t op2) noexcept: mpz_mul(mpq_numref(res), mpq_denref(op1), op2) diff --git a/src/sage/libs/gmp/mpf.pxd b/src/sage/libs/gmp/mpf.pxd index 7095c51073a..b63d84009c0 100644 --- a/src/sage/libs/gmp/mpf.pxd +++ b/src/sage/libs/gmp/mpf.pxd @@ -1,6 +1,6 @@ # distutils: libraries = gmp -from .types cimport * +from sage.libs.gmp.types cimport * cdef extern from "gmp.h": diff --git a/src/sage/libs/gmp/mpn.pxd b/src/sage/libs/gmp/mpn.pxd index 6bc40ff0150..890c5b63da7 100644 --- a/src/sage/libs/gmp/mpn.pxd +++ b/src/sage/libs/gmp/mpn.pxd @@ -1,6 +1,6 @@ # distutils: libraries = gmp -from .types cimport * +from sage.libs.gmp.types cimport * cdef extern from "gmp.h": diff --git a/src/sage/libs/gmp/mpq.pxd b/src/sage/libs/gmp/mpq.pxd index 6b7d9929620..d865630aee0 100644 --- a/src/sage/libs/gmp/mpq.pxd +++ b/src/sage/libs/gmp/mpq.pxd @@ -1,6 +1,6 @@ # distutils: libraries = gmp -from .types cimport * +from sage.libs.gmp.types cimport * cdef extern from "gmp.h": diff --git a/src/sage/libs/gmp/mpz.pxd b/src/sage/libs/gmp/mpz.pxd index 91e35963300..71d1e5e3069 100644 --- a/src/sage/libs/gmp/mpz.pxd +++ b/src/sage/libs/gmp/mpz.pxd @@ -1,6 +1,6 @@ # distutils: libraries = gmp -from .types cimport * +from sage.libs.gmp.types cimport * from libc.stdio cimport FILE from libc.stdint cimport intmax_t, uintmax_t diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx index 833d44c9bc9..406f2703c1f 100644 --- a/src/sage/libs/gmp/pylong.pyx +++ b/src/sage/libs/gmp/pylong.pyx @@ -30,7 +30,7 @@ from cpython.long cimport PyLong_FromLong from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative, _PyLong_DigitCount, _PyLong_SetSignAndDigitCount) -from .mpz cimport * +from sage.libs.gmp.mpz cimport * cdef extern from *: """ diff --git a/src/sage/libs/gmp/random.pxd b/src/sage/libs/gmp/random.pxd index 6c1a529dbd4..a50657454ca 100644 --- a/src/sage/libs/gmp/random.pxd +++ b/src/sage/libs/gmp/random.pxd @@ -1,6 +1,6 @@ # distutils: libraries = gmp -from .types cimport * +from sage.libs.gmp.types cimport * cdef extern from "gmp.h": diff --git a/src/sage/libs/gsl/airy.pxd b/src/sage/libs/gsl/airy.pxd index f9983ef0d79..7e996d5af81 100644 --- a/src/sage/libs/gsl/airy.pxd +++ b/src/sage/libs/gsl/airy.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_airy.h": diff --git a/src/sage/libs/gsl/all.pxd b/src/sage/libs/gsl/all.pxd index 34e93ea2535..099399d9f3f 100644 --- a/src/sage/libs/gsl/all.pxd +++ b/src/sage/libs/gsl/all.pxd @@ -1,65 +1,65 @@ -from .types cimport * +from sage.libs.gsl.types cimport * -from .math cimport * -from .complex cimport * -from .poly cimport * -from .airy cimport * -from .bessel cimport * -from .clausen cimport * -from .coulomb cimport * -from .coupling cimport * -from .dawson cimport * -from .debye cimport * -from .dilog cimport * -from .elementary cimport * -from .ellint cimport * -from .elljac cimport * -from .erf cimport * -from .exp cimport * -from .expint cimport * -from .fermi_dirac cimport * -from .gamma cimport * -from .gegenbauer cimport * -from .hyperg cimport * -from .laguerre cimport * -from .lambert cimport * -from .legendre cimport * -from .log cimport * -from .pow_int cimport * -from .psi cimport * -from .synchrotron cimport * -from .transport cimport * -from .trig cimport * -from .wavelet cimport * -from .zeta cimport * +from sage.libs.gsl.math cimport * +from sage.libs.gsl.complex cimport * +from sage.libs.gsl.poly cimport * +from sage.libs.gsl.airy cimport * +from sage.libs.gsl.bessel cimport * +from sage.libs.gsl.clausen cimport * +from sage.libs.gsl.coulomb cimport * +from sage.libs.gsl.coupling cimport * +from sage.libs.gsl.dawson cimport * +from sage.libs.gsl.debye cimport * +from sage.libs.gsl.dilog cimport * +from sage.libs.gsl.elementary cimport * +from sage.libs.gsl.ellint cimport * +from sage.libs.gsl.elljac cimport * +from sage.libs.gsl.erf cimport * +from sage.libs.gsl.exp cimport * +from sage.libs.gsl.expint cimport * +from sage.libs.gsl.fermi_dirac cimport * +from sage.libs.gsl.gamma cimport * +from sage.libs.gsl.gegenbauer cimport * +from sage.libs.gsl.hyperg cimport * +from sage.libs.gsl.laguerre cimport * +from sage.libs.gsl.lambert cimport * +from sage.libs.gsl.legendre cimport * +from sage.libs.gsl.log cimport * +from sage.libs.gsl.pow_int cimport * +from sage.libs.gsl.psi cimport * +from sage.libs.gsl.synchrotron cimport * +from sage.libs.gsl.transport cimport * +from sage.libs.gsl.trig cimport * +from sage.libs.gsl.wavelet cimport * +from sage.libs.gsl.zeta cimport * -from .block cimport * -from .vector cimport * -from .vector_complex cimport * -from .matrix cimport * -from .matrix_complex cimport * +from sage.libs.gsl.block cimport * +from sage.libs.gsl.vector cimport * +from sage.libs.gsl.vector_complex cimport * +from sage.libs.gsl.matrix cimport * +from sage.libs.gsl.matrix_complex cimport * -from .permutation cimport * -from .combination cimport * -from .sort cimport * +from sage.libs.gsl.permutation cimport * +from sage.libs.gsl.combination cimport * +from sage.libs.gsl.sort cimport * -from .blas cimport * -from .linalg cimport * -from .eigen cimport * -from .fft cimport * -from .integration cimport * -from .rng cimport * -from .qrng cimport * -from .random cimport * -from .statistics cimport * -from .histogram cimport * -from .ntuple cimport * -from .monte cimport * -from .odeiv cimport * -from .interp cimport * -from .chebyshev cimport * -from .sum cimport * -from .roots cimport * -from .min cimport * -from .fit cimport * -from .errno cimport * +from sage.libs.gsl.blas cimport * +from sage.libs.gsl.linalg cimport * +from sage.libs.gsl.eigen cimport * +from sage.libs.gsl.fft cimport * +from sage.libs.gsl.integration cimport * +from sage.libs.gsl.rng cimport * +from sage.libs.gsl.qrng cimport * +from sage.libs.gsl.random cimport * +from sage.libs.gsl.statistics cimport * +from sage.libs.gsl.histogram cimport * +from sage.libs.gsl.ntuple cimport * +from sage.libs.gsl.monte cimport * +from sage.libs.gsl.odeiv cimport * +from sage.libs.gsl.interp cimport * +from sage.libs.gsl.chebyshev cimport * +from sage.libs.gsl.sum cimport * +from sage.libs.gsl.roots cimport * +from sage.libs.gsl.min cimport * +from sage.libs.gsl.fit cimport * +from sage.libs.gsl.errno cimport * diff --git a/src/sage/libs/gsl/bessel.pxd b/src/sage/libs/gsl/bessel.pxd index e03a0e4866e..8a0a521aa3d 100644 --- a/src/sage/libs/gsl/bessel.pxd +++ b/src/sage/libs/gsl/bessel.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_bessel.h": diff --git a/src/sage/libs/gsl/blas.pxd b/src/sage/libs/gsl/blas.pxd index 509e9639594..7b195751993 100644 --- a/src/sage/libs/gsl/blas.pxd +++ b/src/sage/libs/gsl/blas.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_blas.h": diff --git a/src/sage/libs/gsl/block.pxd b/src/sage/libs/gsl/block.pxd index 76f928736a6..69ee5251dda 100644 --- a/src/sage/libs/gsl/block.pxd +++ b/src/sage/libs/gsl/block.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_block_double.h": diff --git a/src/sage/libs/gsl/chebyshev.pxd b/src/sage/libs/gsl/chebyshev.pxd index c713974b125..06d2da41732 100644 --- a/src/sage/libs/gsl/chebyshev.pxd +++ b/src/sage/libs/gsl/chebyshev.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_chebyshev.h": diff --git a/src/sage/libs/gsl/clausen.pxd b/src/sage/libs/gsl/clausen.pxd index bb34bc5000f..2f92518e171 100644 --- a/src/sage/libs/gsl/clausen.pxd +++ b/src/sage/libs/gsl/clausen.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_clausen.h": diff --git a/src/sage/libs/gsl/combination.pxd b/src/sage/libs/gsl/combination.pxd index a3a2851452d..6072fb2417a 100644 --- a/src/sage/libs/gsl/combination.pxd +++ b/src/sage/libs/gsl/combination.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_combination.h": diff --git a/src/sage/libs/gsl/complex.pxd b/src/sage/libs/gsl/complex.pxd index b6e0a16fbb1..87fd3957b62 100644 --- a/src/sage/libs/gsl/complex.pxd +++ b/src/sage/libs/gsl/complex.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_complex.h": double GSL_REAL(gsl_complex z) diff --git a/src/sage/libs/gsl/coulomb.pxd b/src/sage/libs/gsl/coulomb.pxd index 39fb4bdc54f..7941dff093d 100644 --- a/src/sage/libs/gsl/coulomb.pxd +++ b/src/sage/libs/gsl/coulomb.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_coulomb.h": diff --git a/src/sage/libs/gsl/coupling.pxd b/src/sage/libs/gsl/coupling.pxd index 72052d9db7f..cd5f4d301a6 100644 --- a/src/sage/libs/gsl/coupling.pxd +++ b/src/sage/libs/gsl/coupling.pxd @@ -2,7 +2,7 @@ # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR # distutils: extra_compile_args = -DGSL_DISABLE_DEPRECATED -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_coupling.h": diff --git a/src/sage/libs/gsl/dawson.pxd b/src/sage/libs/gsl/dawson.pxd index 8988a68df7f..9eccc6c4485 100644 --- a/src/sage/libs/gsl/dawson.pxd +++ b/src/sage/libs/gsl/dawson.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_dawson.h": diff --git a/src/sage/libs/gsl/debye.pxd b/src/sage/libs/gsl/debye.pxd index c6e5c86d2ab..ca6d5722e56 100644 --- a/src/sage/libs/gsl/debye.pxd +++ b/src/sage/libs/gsl/debye.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_debye.h": diff --git a/src/sage/libs/gsl/dilog.pxd b/src/sage/libs/gsl/dilog.pxd index 79adc6c28e9..30f633dd5d2 100644 --- a/src/sage/libs/gsl/dilog.pxd +++ b/src/sage/libs/gsl/dilog.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_dilog.h": diff --git a/src/sage/libs/gsl/eigen.pxd b/src/sage/libs/gsl/eigen.pxd index 0ad97189a56..a0568b1f464 100644 --- a/src/sage/libs/gsl/eigen.pxd +++ b/src/sage/libs/gsl/eigen.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_eigen.h": diff --git a/src/sage/libs/gsl/elementary.pxd b/src/sage/libs/gsl/elementary.pxd index f3a026c201f..66e3d39b1e9 100644 --- a/src/sage/libs/gsl/elementary.pxd +++ b/src/sage/libs/gsl/elementary.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_elementary.h": diff --git a/src/sage/libs/gsl/ellint.pxd b/src/sage/libs/gsl/ellint.pxd index d1156a3b285..2c6cdfb9662 100644 --- a/src/sage/libs/gsl/ellint.pxd +++ b/src/sage/libs/gsl/ellint.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_ellint.h": diff --git a/src/sage/libs/gsl/erf.pxd b/src/sage/libs/gsl/erf.pxd index 50cce929848..3035944ae47 100644 --- a/src/sage/libs/gsl/erf.pxd +++ b/src/sage/libs/gsl/erf.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_erf.h": diff --git a/src/sage/libs/gsl/exp.pxd b/src/sage/libs/gsl/exp.pxd index 61d253236f6..875f5564053 100644 --- a/src/sage/libs/gsl/exp.pxd +++ b/src/sage/libs/gsl/exp.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_exp.h": diff --git a/src/sage/libs/gsl/expint.pxd b/src/sage/libs/gsl/expint.pxd index f4155af974c..66e2e7b2091 100644 --- a/src/sage/libs/gsl/expint.pxd +++ b/src/sage/libs/gsl/expint.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_expint.h": diff --git a/src/sage/libs/gsl/fermi_dirac.pxd b/src/sage/libs/gsl/fermi_dirac.pxd index cf23826b800..367fe60f293 100644 --- a/src/sage/libs/gsl/fermi_dirac.pxd +++ b/src/sage/libs/gsl/fermi_dirac.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_fermi_dirac.h": diff --git a/src/sage/libs/gsl/fft.pxd b/src/sage/libs/gsl/fft.pxd index d45e866f82c..8d0bbff58c1 100644 --- a/src/sage/libs/gsl/fft.pxd +++ b/src/sage/libs/gsl/fft.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_fft.h": cdef enum gsl_fft_direction: diff --git a/src/sage/libs/gsl/gamma.pxd b/src/sage/libs/gsl/gamma.pxd index 43f297a08ad..59bcced37be 100644 --- a/src/sage/libs/gsl/gamma.pxd +++ b/src/sage/libs/gsl/gamma.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_gamma.h": diff --git a/src/sage/libs/gsl/gegenbauer.pxd b/src/sage/libs/gsl/gegenbauer.pxd index 4990ea7cd1c..8b3c802a9b9 100644 --- a/src/sage/libs/gsl/gegenbauer.pxd +++ b/src/sage/libs/gsl/gegenbauer.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_gegenbauer.h": diff --git a/src/sage/libs/gsl/histogram.pxd b/src/sage/libs/gsl/histogram.pxd index 794f60a9f89..6e83a5e48a8 100644 --- a/src/sage/libs/gsl/histogram.pxd +++ b/src/sage/libs/gsl/histogram.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_histogram.h": gsl_histogram * gsl_histogram_alloc (size_t n) diff --git a/src/sage/libs/gsl/hyperg.pxd b/src/sage/libs/gsl/hyperg.pxd index e1279e8bb28..3e85ebfb0e4 100644 --- a/src/sage/libs/gsl/hyperg.pxd +++ b/src/sage/libs/gsl/hyperg.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_hyperg.h": diff --git a/src/sage/libs/gsl/integration.pxd b/src/sage/libs/gsl/integration.pxd index 24b3e7d3e9f..0a584a90ecd 100644 --- a/src/sage/libs/gsl/integration.pxd +++ b/src/sage/libs/gsl/integration.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_integration.h": diff --git a/src/sage/libs/gsl/laguerre.pxd b/src/sage/libs/gsl/laguerre.pxd index f40b5907201..14a2bcbee83 100644 --- a/src/sage/libs/gsl/laguerre.pxd +++ b/src/sage/libs/gsl/laguerre.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_laguerre.h": diff --git a/src/sage/libs/gsl/lambert.pxd b/src/sage/libs/gsl/lambert.pxd index 03a511880db..e30e41f0bd9 100644 --- a/src/sage/libs/gsl/lambert.pxd +++ b/src/sage/libs/gsl/lambert.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_lambert.h": diff --git a/src/sage/libs/gsl/legendre.pxd b/src/sage/libs/gsl/legendre.pxd index 982c3a5aee7..f9a69910bc2 100644 --- a/src/sage/libs/gsl/legendre.pxd +++ b/src/sage/libs/gsl/legendre.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_legendre.h": diff --git a/src/sage/libs/gsl/linalg.pxd b/src/sage/libs/gsl/linalg.pxd index 6441b3a3bf8..389ec2e7997 100644 --- a/src/sage/libs/gsl/linalg.pxd +++ b/src/sage/libs/gsl/linalg.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_linalg.h": diff --git a/src/sage/libs/gsl/log.pxd b/src/sage/libs/gsl/log.pxd index 2077b7d2296..35798b2b150 100644 --- a/src/sage/libs/gsl/log.pxd +++ b/src/sage/libs/gsl/log.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_log.h": diff --git a/src/sage/libs/gsl/math.pxd b/src/sage/libs/gsl/math.pxd index 11087d78ca9..0f0a27a58e1 100644 --- a/src/sage/libs/gsl/math.pxd +++ b/src/sage/libs/gsl/math.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_math.h": bint gsl_isnan(double x) diff --git a/src/sage/libs/gsl/matrix.pxd b/src/sage/libs/gsl/matrix.pxd index bf6df93b29b..e1e2009b609 100644 --- a/src/sage/libs/gsl/matrix.pxd +++ b/src/sage/libs/gsl/matrix.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_matrix_double.h": # Allocation diff --git a/src/sage/libs/gsl/matrix_complex.pxd b/src/sage/libs/gsl/matrix_complex.pxd index 5a2366479a5..6cbc983a45e 100644 --- a/src/sage/libs/gsl/matrix_complex.pxd +++ b/src/sage/libs/gsl/matrix_complex.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_matrix_complex_double.h": # Allocation diff --git a/src/sage/libs/gsl/min.pxd b/src/sage/libs/gsl/min.pxd index 0843984a476..25a9770eba0 100644 --- a/src/sage/libs/gsl/min.pxd +++ b/src/sage/libs/gsl/min.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_min.h": diff --git a/src/sage/libs/gsl/monte.pxd b/src/sage/libs/gsl/monte.pxd index 05879875c20..92142abdbcc 100644 --- a/src/sage/libs/gsl/monte.pxd +++ b/src/sage/libs/gsl/monte.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_monte.h": ctypedef struct gsl_monte_function: diff --git a/src/sage/libs/gsl/ntuple.pxd b/src/sage/libs/gsl/ntuple.pxd index 13827e8903f..c47ab38d289 100644 --- a/src/sage/libs/gsl/ntuple.pxd +++ b/src/sage/libs/gsl/ntuple.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_ntuple.h": ctypedef struct gsl_ntuple diff --git a/src/sage/libs/gsl/permutation.pxd b/src/sage/libs/gsl/permutation.pxd index 5bf7cd6ba68..49b10e0611d 100644 --- a/src/sage/libs/gsl/permutation.pxd +++ b/src/sage/libs/gsl/permutation.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_permutation.h": # Allocation diff --git a/src/sage/libs/gsl/poly.pxd b/src/sage/libs/gsl/poly.pxd index 997ecd24eca..ae172cbf07f 100644 --- a/src/sage/libs/gsl/poly.pxd +++ b/src/sage/libs/gsl/poly.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_poly.h": diff --git a/src/sage/libs/gsl/pow_int.pxd b/src/sage/libs/gsl/pow_int.pxd index 0056cc9d402..af5de0263b8 100644 --- a/src/sage/libs/gsl/pow_int.pxd +++ b/src/sage/libs/gsl/pow_int.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_pow_int.h": diff --git a/src/sage/libs/gsl/psi.pxd b/src/sage/libs/gsl/psi.pxd index 4740ebd62a5..fd33ccd636c 100644 --- a/src/sage/libs/gsl/psi.pxd +++ b/src/sage/libs/gsl/psi.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_psi.h": diff --git a/src/sage/libs/gsl/random.pxd b/src/sage/libs/gsl/random.pxd index 80ac3c2016f..21f531265bc 100644 --- a/src/sage/libs/gsl/random.pxd +++ b/src/sage/libs/gsl/random.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_randist.h": unsigned int gsl_ran_bernoulli ( gsl_rng * r, double p) diff --git a/src/sage/libs/gsl/rng.pxd b/src/sage/libs/gsl/rng.pxd index 88ccf7d7a78..b1ab233715e 100644 --- a/src/sage/libs/gsl/rng.pxd +++ b/src/sage/libs/gsl/rng.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_rng.h": cdef gsl_rng_type *gsl_rng_borosh13 diff --git a/src/sage/libs/gsl/roots.pxd b/src/sage/libs/gsl/roots.pxd index 841f94dbc82..2bf1ccf9403 100644 --- a/src/sage/libs/gsl/roots.pxd +++ b/src/sage/libs/gsl/roots.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_roots.h": diff --git a/src/sage/libs/gsl/sort.pxd b/src/sage/libs/gsl/sort.pxd index 892e7a22304..68493a8a1a8 100644 --- a/src/sage/libs/gsl/sort.pxd +++ b/src/sage/libs/gsl/sort.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_heapsort.h": diff --git a/src/sage/libs/gsl/synchrotron.pxd b/src/sage/libs/gsl/synchrotron.pxd index 28581337097..a02c9964fc2 100644 --- a/src/sage/libs/gsl/synchrotron.pxd +++ b/src/sage/libs/gsl/synchrotron.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_synchrotron.h": diff --git a/src/sage/libs/gsl/transport.pxd b/src/sage/libs/gsl/transport.pxd index 389da93e607..6700511a9c9 100644 --- a/src/sage/libs/gsl/transport.pxd +++ b/src/sage/libs/gsl/transport.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_transport.h": diff --git a/src/sage/libs/gsl/trig.pxd b/src/sage/libs/gsl/trig.pxd index 71ae2be0199..c9da72206af 100644 --- a/src/sage/libs/gsl/trig.pxd +++ b/src/sage/libs/gsl/trig.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_trig.h": diff --git a/src/sage/libs/gsl/types.pxd b/src/sage/libs/gsl/types.pxd index 217738be893..7076e2f8861 100644 --- a/src/sage/libs/gsl/types.pxd +++ b/src/sage/libs/gsl/types.pxd @@ -4,7 +4,7 @@ from libc.stdio cimport FILE cdef enum: GSL_SUCCESS -from .blas_types cimport * +from sage.libs.gsl.blas_types cimport * cdef extern from "gsl/gsl_mode.h": ctypedef unsigned int gsl_mode_t diff --git a/src/sage/libs/gsl/vector.pxd b/src/sage/libs/gsl/vector.pxd index fdbdc7c10e5..30960a2d1ef 100644 --- a/src/sage/libs/gsl/vector.pxd +++ b/src/sage/libs/gsl/vector.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_vector.h": # Allocation diff --git a/src/sage/libs/gsl/vector_complex.pxd b/src/sage/libs/gsl/vector_complex.pxd index f712c493962..a784c32880a 100644 --- a/src/sage/libs/gsl/vector_complex.pxd +++ b/src/sage/libs/gsl/vector_complex.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_vector_complex_double.h": # Allocation diff --git a/src/sage/libs/gsl/wavelet.pxd b/src/sage/libs/gsl/wavelet.pxd index 43fcfd50c07..c74052e8bfc 100644 --- a/src/sage/libs/gsl/wavelet.pxd +++ b/src/sage/libs/gsl/wavelet.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_wavelet.h": diff --git a/src/sage/libs/gsl/zeta.pxd b/src/sage/libs/gsl/zeta.pxd index 58143b1d3ee..9b6edbd74b9 100644 --- a/src/sage/libs/gsl/zeta.pxd +++ b/src/sage/libs/gsl/zeta.pxd @@ -1,7 +1,7 @@ # distutils: libraries = GSL_LIBRARIES # distutils: library_dirs = GSL_LIBDIR # distutils: include_dirs = GSL_INCDIR -from .types cimport * +from sage.libs.gsl.types cimport * cdef extern from "gsl/gsl_sf_zeta.h": diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd index f140a0fc321..a4cdd09711d 100644 --- a/src/sage/libs/linbox/conversion.pxd +++ b/src/sage/libs/linbox/conversion.pxd @@ -29,8 +29,8 @@ from libcpp.vector cimport vector as cppvector from sage.libs.gmp.mpz cimport mpz_set -from .givaro cimport Modular_uint64, ZRing, Integer -from .linbox cimport SparseMatrix_Modular_uint64, SparseMatrix_integer, DenseVector_integer +from sage.libs.linbox.givaro cimport Modular_uint64, ZRing, Integer +from sage.libs.linbox.linbox cimport SparseMatrix_Modular_uint64, SparseMatrix_integer, DenseVector_integer from sage.matrix.matrix_modn_sparse cimport Matrix_modn_sparse from sage.matrix.matrix_integer_sparse cimport Matrix_integer_sparse diff --git a/src/sage/libs/linbox/fflas.pxd b/src/sage/libs/linbox/fflas.pxd index f7ca98c614c..d5b077cf045 100644 --- a/src/sage/libs/linbox/fflas.pxd +++ b/src/sage/libs/linbox/fflas.pxd @@ -13,8 +13,8 @@ # distutils: extra_link_args = FFLASFFPACK_LIBEXTRA # distutils: language = c++ -from .givaro cimport Modular_double, Modular_float, Dense, Sparse -from .givaro cimport givvector, Poly1Dom +from sage.libs.linbox.givaro cimport Modular_double, Modular_float, Dense, Sparse +from sage.libs.linbox.givaro cimport givvector, Poly1Dom from libcpp.vector cimport vector from libcpp cimport bool ctypedef Poly1Dom[Modular_double, Dense] PolynomialRing_Modular_double diff --git a/src/sage/libs/linbox/linbox.pxd b/src/sage/libs/linbox/linbox.pxd index bfeda4b6042..6792e260a34 100644 --- a/src/sage/libs/linbox/linbox.pxd +++ b/src/sage/libs/linbox/linbox.pxd @@ -8,7 +8,7 @@ from libc.stdint cimport uint32_t, uint64_t from libcpp.vector cimport vector as cppvector -from .givaro cimport * +from sage.libs.linbox.givaro cimport * cdef extern from "linbox/matrix/dense-matrix.h": ## template ::Dense > diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx index dabd375c2b8..1979ac0f0a4 100644 --- a/src/sage/libs/linbox/linbox_flint_interface.pyx +++ b/src/sage/libs/linbox/linbox_flint_interface.pyx @@ -40,7 +40,7 @@ from sage.libs.flint.fmpz_poly cimport fmpz_poly_set_coeff_mpz, fmpz_poly_fit_le cimport sage.libs.linbox.givaro as givaro cimport sage.libs.linbox.linbox as linbox -from .linbox cimport PolynomialRing_integer +from sage.libs.linbox.linbox cimport PolynomialRing_integer cdef void fmpz_mat_get_linbox(linbox.DenseMatrix_integer& A, fmpz_mat_t m) noexcept: diff --git a/src/sage/libs/mpmath/ext_libmp.pyx b/src/sage/libs/mpmath/ext_libmp.pyx index 5dccf596a91..b0899439fd5 100644 --- a/src/sage/libs/mpmath/ext_libmp.pyx +++ b/src/sage/libs/mpmath/ext_libmp.pyx @@ -1,7 +1,7 @@ """ Faster versions of some key functions in mpmath.libmp """ -from .ext_impl cimport * +from sage.libs.mpmath.ext_impl cimport * from sage.libs.gmp.all cimport * # the next line is used by mpmath diff --git a/src/sage/libs/mpmath/ext_main.pxd b/src/sage/libs/mpmath/ext_main.pxd index d810e75f544..8a3bf740b0e 100644 --- a/src/sage/libs/mpmath/ext_main.pxd +++ b/src/sage/libs/mpmath/ext_main.pxd @@ -1 +1 @@ -from .ext_impl cimport * +from sage.libs.mpmath.ext_impl cimport * diff --git a/src/sage/libs/mpmath/ext_main.pyx b/src/sage/libs/mpmath/ext_main.pyx index a00c5ee4831..4b717bb3860 100644 --- a/src/sage/libs/mpmath/ext_main.pyx +++ b/src/sage/libs/mpmath/ext_main.pyx @@ -38,7 +38,7 @@ DEF S_INF = 3 DEF S_NINF = 4 DEF S_NAN = 5 -from .ext_impl cimport * +from sage.libs.mpmath.ext_impl cimport * import mpmath.rational as rationallib import mpmath.libmp as libmp diff --git a/src/sage/libs/pari/convert_flint.pyx b/src/sage/libs/pari/convert_flint.pyx index 340e72c13bb..c8e1ddb00cf 100644 --- a/src/sage/libs/pari/convert_flint.pyx +++ b/src/sage/libs/pari/convert_flint.pyx @@ -28,7 +28,7 @@ from sage.libs.flint.fmpq_mat cimport fmpq_mat_nrows, fmpq_mat_ncols, fmpq_mat_e from cypari2.paridecl cimport * from cypari2.stack cimport new_gen -from .convert_gmp cimport _new_GEN_from_mpz_t +from sage.libs.pari.convert_gmp cimport _new_GEN_from_mpz_t cdef inline GEN _new_GEN_from_fmpz_t(fmpz_t value) noexcept: diff --git a/src/sage/libs/pari/convert_sage.pyx b/src/sage/libs/pari/convert_sage.pyx index 500ed520312..7ee32b27b28 100644 --- a/src/sage/libs/pari/convert_sage.pyx +++ b/src/sage/libs/pari/convert_sage.pyx @@ -22,7 +22,7 @@ from cypari2.types cimport (GEN, typ, t_INT, t_FRAC, t_REAL, t_COMPLEX, lg, precp) from cypari2.paridecl cimport * from cypari2.stack cimport new_gen -from .convert_gmp cimport INT_to_mpz, new_gen_from_mpz_t, new_gen_from_mpq_t, INTFRAC_to_mpq +from sage.libs.pari.convert_gmp cimport INT_to_mpz, new_gen_from_mpz_t, new_gen_from_mpq_t, INTFRAC_to_mpq from sage.ext.stdsage cimport PY_NEW from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_sgn, mpz_get_ui, mpz_set, mpz_set_si, mpz_set_ui From 486508dc70e09f3107f1308cea80dc304c33e3eb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:25:37 -0700 Subject: [PATCH 401/494] Replace relative imports in Cython files --- src/sage/libs/gap/element.pyx | 4 ++-- src/sage/libs/gap/util.pyx | 2 +- src/sage/libs/mpmath/ext_libmp.pyx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx index d698fc6bce7..e522bf5bc03 100644 --- a/src/sage/libs/gap/element.pyx +++ b/src/sage/libs/gap/element.pyx @@ -19,9 +19,9 @@ from cpython.object cimport Py_EQ, Py_NE, Py_LE, Py_GE, Py_LT, Py_GT from cysignals.signals cimport sig_on, sig_off from sage.libs.gap.gap_includes cimport * -from .libgap import libgap +from sage.libs.gap.libgap import libgap from sage.libs.gap.util cimport * -from .util import GAPError +from sage.libs.gap.util import GAPError from sage.cpython.string cimport str_to_bytes, char_to_str from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index 177e30fa06a..d37fe84f029 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -240,7 +240,7 @@ cdef initialize() noexcept: argv[11] = s1 argv[4] = s1 - from .saved_workspace import workspace + from sage.libs.gap.saved_workspace import workspace workspace, workspace_is_up_to_date = workspace() ws = str_to_bytes(workspace, FS_ENCODING, "surrogateescape") if workspace_is_up_to_date: diff --git a/src/sage/libs/mpmath/ext_libmp.pyx b/src/sage/libs/mpmath/ext_libmp.pyx index b0899439fd5..10d1b32eb36 100644 --- a/src/sage/libs/mpmath/ext_libmp.pyx +++ b/src/sage/libs/mpmath/ext_libmp.pyx @@ -5,7 +5,7 @@ from sage.libs.mpmath.ext_impl cimport * from sage.libs.gmp.all cimport * # the next line is used by mpmath -from .ext_impl import exp_fixed, cos_sin_fixed, log_int_fixed +from sage.libs.mpmath.ext_impl import exp_fixed, cos_sin_fixed, log_int_fixed # Note: not thread-safe cdef MPF tmp1 From 35910e2fa72e4b50fc7c30f14da417879b22ae52 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 10:55:53 -0700 Subject: [PATCH 402/494] .github/workflows/ci-linux.yml: Reduce 'standard', 'minimal-pre' to 25 parallel jobs --- .github/workflows/ci-linux.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index cbb4f0dd4ce..374824d83ab 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -104,6 +104,8 @@ jobs: tox_packages_factors: >- ["standard"] docker_push_repository: ghcr.io/${{ github.repository }}/ + # Reduce from 30 to 25 because it runs in parallel with 'standard-sitepackages' below + max_parallel: 25 standard-sitepackages: if: ${{ success() || failure() }} @@ -167,6 +169,8 @@ jobs: tox_packages_factors: >- ["minimal"] docker_push_repository: ghcr.io/${{ github.repository }}/ + # Reduce from 30 to 25 because it may run in parallel with 'standard-sitepackages' above + max_parallel: 25 minimal: if: ${{ success() || failure() }} From 3bd7f38eebd936c735bc5f36bae418cc1d5debbe Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 22 Oct 2023 19:16:29 -0700 Subject: [PATCH 403/494] .github/workflows/doc-build-pdf.yml: Actually upload the built docs --- .github/workflows/doc-build-pdf.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index 7549c2934e7..aedee3a54a7 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -112,6 +112,7 @@ jobs: SAGE_NUM_THREADS: 2 - name: Copy docs + id: copy if: always() && steps.docbuild.outcome == 'success' run: | # For some reason the deploy step below cannot find /sage/... From 2a623b5e55c0e083c9f07b1d255340703039c610 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Wed, 1 Nov 2023 23:08:32 +0100 Subject: [PATCH 404/494] review comments --- src/sage/graphs/convexity_properties.pyx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/graphs/convexity_properties.pyx b/src/sage/graphs/convexity_properties.pyx index 570559c5146..7024324f362 100644 --- a/src/sage/graphs/convexity_properties.pyx +++ b/src/sage/graphs/convexity_properties.pyx @@ -679,14 +679,15 @@ def is_geodetic(G): A graph `G` is *geodetic* if there exists only one shortest path between every pair of its vertices. This can be checked in time `O(nm)` in - unweighted (di)graphs. Examples of geodetic graphs are trees, cliques and - odd cycles. See the :wikipedia:`Geodetic_graph` for more details. + unweighted (di)graphs with `n` nodes and `m` edges. Examples of geodetic + graphs are trees, cliques and odd cycles. See the + :wikipedia:`Geodetic_graph` for more details. (Di)graphs with multiple edges are not considered geodetic. INPUT: - - ``G`` -- a Sage graph or digraph + - ``G`` -- a graph or a digraph EXAMPLES: From b953ed059a56e149f5558677ed30d671984bdfb0 Mon Sep 17 00:00:00 2001 From: Jared Smith Date: Thu, 2 Nov 2023 00:01:16 +0000 Subject: [PATCH 405/494] Minor changes --- src/sage/graphs/domination.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sage/graphs/domination.py b/src/sage/graphs/domination.py index 94d95fa82d0..7f631fcfe28 100644 --- a/src/sage/graphs/domination.py +++ b/src/sage/graphs/domination.py @@ -1332,7 +1332,7 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): sage: G.maximum_leaf_number() 6 - Tests: + TESTS: One vertex:: @@ -1360,4 +1360,6 @@ def maximum_leaf_number(G, solver=None, verbose=0, integrality_tolerance=1e-3): raise ValueError('the graph must be connected') if G.order() <= 3: return G.order() - 1 - return G.order() - dominating_set(G, connected=True, value_only=True, solver=solver, verbose=verbose, integrality_tolerance=integrality_tolerance) + return G.order() - dominating_set(G, connected=True, value_only=True, + solver=solver, verbose=verbose, + integrality_tolerance=integrality_tolerance) From 90241976bd0cab2de669f586001823c124a976c7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 19:25:55 -0700 Subject: [PATCH 406/494] .github/workflows/ci-linux.yml (default): Build in one job, do not test --- .github/workflows/ci-linux.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 22df4aa0fd5..1f2d469851c 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -34,39 +34,20 @@ permissions: jobs: - # standard-pre for the default platform (used by build.yml etc.) - default-pre: + # standard-pre and standard (without ptest) for the default platform (used by build.yml etc.) + default: uses: ./.github/workflows/docker.yml with: # Build from scratch - docker_targets: "with-system-packages configured with-targets-pre" + docker_targets: "with-system-packages configured with-targets-pre with-targets" # FIXME: duplicated from env.TARGETS targets_pre: all-sage-local - tox_system_factors: >- - ["ubuntu-focal"] - tox_packages_factors: >- - ["standard"] - docker_push_repository: ghcr.io/${{ github.repository }}/ - - # standard for the default platform (used by build.yml etc.) - default: - if: ${{ success() || failure() }} - needs: [default-pre] - uses: ./.github/workflows/docker.yml - with: - # Build incrementally from previous stage (pre) - incremental: true - free_disk_space: true - from_docker_repository: ghcr.io/${{ github.repository }}/ - from_docker_target: "with-targets-pre" - docker_targets: "with-targets with-targets-optional" - # FIXME: duplicated from env.TARGETS targets: build doc-html targets_optional: ptest tox_system_factors: >- ["ubuntu-focal"] tox_packages_factors: >- - ["standard"] + ["standard"] docker_push_repository: ghcr.io/${{ github.repository }}/ # All platforms. This duplicates the default platform, but why not, From af12b88d35ac05c5d4c922fa68465a6d51c43b99 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 19:45:34 -0700 Subject: [PATCH 407/494] .github/workflows/ci-linux.yml: Unleash minimal-pre jobs for more constructive clogging --- .github/workflows/ci-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 1f2d469851c..a016f1ea80c 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -134,8 +134,6 @@ jobs: minimal-pre: if: ${{ success() || failure() }} - # It does not really "need" it. - needs: [standard] uses: ./.github/workflows/docker.yml with: # Build from scratch @@ -145,6 +143,8 @@ jobs: tox_packages_factors: >- ["minimal"] docker_push_repository: ghcr.io/${{ github.repository }}/ + # Calibrated for clogging the job pipeline until the "default" job has finished + max_parallel: 20 minimal: if: ${{ success() || failure() }} From 2341fb400fa20b673422c56337ba03d9befed48e Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Wed, 1 Nov 2023 21:39:31 -0700 Subject: [PATCH 408/494] Set LDFLAGS depending on version of OS X command-line tools --- src/bin/sage-env | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index 9cdd5db453f..72aa454bf4a 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -383,7 +383,11 @@ if [ -n "$PYTHONHOME" ]; then fi if [ -n "$SAGE_LOCAL" ]; then - LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS" + if [ "$UNAME" = "Darwin" ] && [ "$XCLT_VERSION" -ge 15 ]; then + LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-ld_classic,-rpath,$SAGE_LOCAL/lib $LDFLAGS" + else + LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS" + fi if [ "$UNAME" = "Linux" ]; then LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS" fi From 0d47115ef51b312b8dbdda9d1df657b838580ade Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 20:52:40 -0700 Subject: [PATCH 409/494] tox.ini (centos-7): Download mirror_list using http, not https --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 6293831c44f..ad3d833eeef 100644 --- a/tox.ini +++ b/tox.ini @@ -308,6 +308,7 @@ setenv = centos: BASE_IMAGE=centos centos: IGNORE_MISSING_SYSTEM_PACKAGES=yes centos-7: BASE_TAG=centos7 + centos-7: BOOTSTRAP=sed -i.bak s/https/http/ .upstream.d/*_mirror_list; ./bootstrap centos-stream: BASE_IMAGE=quay.io/centos/centos centos-stream: BASE_TAG=stream centos-stream-8: BASE_TAG=stream8 From 5f29842a5a57fafb3338277683518dc31a95e03c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 20:53:12 -0700 Subject: [PATCH 410/494] .github/workflows/docker.yml: Remove gentoo-python3.12 for now --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c12ec820f83..a3986899a7d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -51,7 +51,6 @@ on: "almalinux-9-python3.11", "gentoo-python3.10", "gentoo-python3.11", - "gentoo-python3.12", "archlinux-latest", "opensuse-15.3-gcc_11-python3.9", "opensuse-15.4-gcc_11-python3.10", From fc7427d67be7efae323852ef49bcb9a525d53966 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 21:04:15 -0700 Subject: [PATCH 411/494] tox.ini (centos-7): Download mirror_list using http, not https (fixup) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ad3d833eeef..c039103f422 100644 --- a/tox.ini +++ b/tox.ini @@ -308,7 +308,7 @@ setenv = centos: BASE_IMAGE=centos centos: IGNORE_MISSING_SYSTEM_PACKAGES=yes centos-7: BASE_TAG=centos7 - centos-7: BOOTSTRAP=sed -i.bak s/https/http/ .upstream.d/*_mirror_list; ./bootstrap + centos-7: BOOTSTRAP=sed -i.bak s/https/http/ .upstream.d/*mirror_list; ./bootstrap centos-stream: BASE_IMAGE=quay.io/centos/centos centos-stream: BASE_TAG=stream centos-stream-8: BASE_TAG=stream8 From d862f7c71f68edf5b176ada4211e0a67a5731837 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 22:53:39 -0700 Subject: [PATCH 412/494] build/pkgs/_python3.*/distros/conda.txt: New --- build/pkgs/_python3.10/distros/conda.txt | 1 + build/pkgs/_python3.11/distros/conda.txt | 1 + build/pkgs/_python3.12/distros/conda.txt | 1 + build/pkgs/_python3.9/distros/conda.txt | 1 + 4 files changed, 4 insertions(+) create mode 100644 build/pkgs/_python3.10/distros/conda.txt create mode 100644 build/pkgs/_python3.11/distros/conda.txt create mode 100644 build/pkgs/_python3.12/distros/conda.txt create mode 100644 build/pkgs/_python3.9/distros/conda.txt diff --git a/build/pkgs/_python3.10/distros/conda.txt b/build/pkgs/_python3.10/distros/conda.txt new file mode 100644 index 00000000000..0e2312f6abf --- /dev/null +++ b/build/pkgs/_python3.10/distros/conda.txt @@ -0,0 +1 @@ +python==3.10 diff --git a/build/pkgs/_python3.11/distros/conda.txt b/build/pkgs/_python3.11/distros/conda.txt new file mode 100644 index 00000000000..875818d94e8 --- /dev/null +++ b/build/pkgs/_python3.11/distros/conda.txt @@ -0,0 +1 @@ +python==3.11 diff --git a/build/pkgs/_python3.12/distros/conda.txt b/build/pkgs/_python3.12/distros/conda.txt new file mode 100644 index 00000000000..08c4473f336 --- /dev/null +++ b/build/pkgs/_python3.12/distros/conda.txt @@ -0,0 +1 @@ +python==3.12 diff --git a/build/pkgs/_python3.9/distros/conda.txt b/build/pkgs/_python3.9/distros/conda.txt new file mode 100644 index 00000000000..ca224649651 --- /dev/null +++ b/build/pkgs/_python3.9/distros/conda.txt @@ -0,0 +1 @@ +python==3.9 From 1d2231b9f77ce9bf09a5eddd6bc7c88756ef7678 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 22:54:27 -0700 Subject: [PATCH 413/494] CI Linux: Switch conda-forge to conda-forge-python3.11 --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a3986899a7d..4b579562876 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -57,7 +57,7 @@ on: "opensuse-15.5-gcc_11-python3.11", "opensuse-tumbleweed-python3.10", "opensuse-tumbleweed", - "conda-forge", + "conda-forge-python3.11", "ubuntu-bionic-gcc_8-i386", "debian-bullseye-i386", ] From 94e4dc475ac2f9de75a7c13db366de77f59e2cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Nov 2023 08:20:05 +0100 Subject: [PATCH 414/494] suggested details --- src/sage/rings/fast_arith.pyx | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx index 9b6e24eee35..d3695ebb69f 100644 --- a/src/sage/rings/fast_arith.pyx +++ b/src/sage/rings/fast_arith.pyx @@ -174,7 +174,7 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False) noexcept + str(real_error)) if algorithm is None: - # if 'stop' is 'None', neEd to change it to an integer before comparing with 'start' + # if 'stop' is 'None', need to change it to an integer before comparing with 'start' if max(start, stop or 0) <= small_prime_max: algorithm = "pari_primes" else: @@ -275,18 +275,18 @@ cdef class arith_int: s = 1 while b: c = a % b - quot = a/b + quot = a / b a = b b = c - new_r = p - quot*r - new_s = q - quot*s + new_r = p - quot * r + new_s = q - quot * s p = r q = s r = new_r s = new_s - ss[0] = p*psign - tt[0] = q*qsign + ss[0] = p * psign + tt[0] = q * qsign return a @@ -343,10 +343,10 @@ cdef class arith_int: v1 = 1 v2 = v while self.abs_int(v2) > bnd: - q = u2/v2 # floor is implicit - t0 = u0-q*v0 - t1 = u1-q*v1 - t2 = u2-q*v2 + q = u2 / v2 # floor is implicit + t0 = u0 - q * v0 + t1 = u1 - q * v1 + t2 = u2 - q * v2 u0 = v0 u1 = v1 u2 = v2 @@ -439,18 +439,18 @@ cdef class arith_llong: s = 1 while b: c = a % b - quot = a/b + quot = a / b a = b b = c - new_r = p - quot*r - new_s = q - quot*s + new_r = p - quot * r + new_s = q - quot * s p = r q = s r = new_r s = new_s - ss[0] = p*psign - tt[0] = q*qsign + ss[0] = p * psign + tt[0] = q * qsign return a @@ -501,10 +501,10 @@ cdef class arith_llong: v1 = 1 v2 = v while self.abs_longlong(v2) > bnd: - q = u2/v2 # floor is implicit - t0 = u0-q*v0 - t1 = u1-q*v1 - t2 = u2-q*v2 + q = u2 / v2 # floor is implicit + t0 = u0 - q * v0 + t1 = u1 - q * v1 + t2 = u2 - q * v2 u0 = v0 u1 = v1 u2 = v2 From e49fb85d465153075daebfc3b9cc08be3af7922c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Nov 2023 10:33:03 +0100 Subject: [PATCH 415/494] some simplifications in doctest/ folder (ruff C4) --- src/sage/doctest/control.py | 25 +++++++++++++------------ src/sage/doctest/forker.py | 30 +++++++++++++++--------------- src/sage/doctest/parsing.py | 8 ++++---- src/sage/doctest/reporting.py | 18 +++++++++--------- src/sage/doctest/sources.py | 19 +++++++++++-------- src/sage/doctest/util.py | 6 +++--- 6 files changed, 55 insertions(+), 51 deletions(-) diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index 4a4e8a44737..8583d7a447d 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -36,7 +36,6 @@ import sys import time import json -import re import shlex import types import sage.misc.flatten @@ -66,6 +65,7 @@ except ImportError: pass + class DocTestDefaults(SageObject): """ This class is used for doctesting the Sage doctest module. @@ -145,7 +145,7 @@ def __init__(self, **kwds): # automatically anyway. However, this default is still used for # displaying user-defined optional tags and we don't want to see # the auto_optional_tags there. - self.optional = set(['sage']) | auto_optional_tags + self.optional = {'sage'} | auto_optional_tags self.hide = '' self.probe = '' @@ -224,6 +224,7 @@ def skipdir(dirname): return True return False + def skipfile(filename, tested_optional_tags=False, *, if_installed=False, log=None): """ @@ -317,8 +318,8 @@ def skipfile(filename, tested_optional_tags=False, *, return file_tag_string elif tested_optional_tags is not True: - extra = set(tag for tag in file_optional_tags - if tag not in tested_optional_tags) + extra = {tag for tag in file_optional_tags + if tag not in tested_optional_tags} if extra: file_tag_string = unparse_optional_tags(file_optional_tags, prefix='') if log: @@ -445,7 +446,7 @@ def __init__(self, options, args): options.hidden_features = set() if isinstance(options.hide, str): if not len(options.hide): - options.hide = set([]) + options.hide = set() else: s = options.hide.lower() options.hide = set(s.split(',')) @@ -455,12 +456,12 @@ def __init__(self, options, args): if 'all' in options.hide: options.hide.discard('all') from sage.features.all import all_features - feature_names = set([f.name for f in all_features() if not f.is_standard()]) + feature_names = {f.name for f in all_features() if not f.is_standard()} options.hide = options.hide.union(feature_names) if 'optional' in options.hide: options.hide.discard('optional') from sage.features.all import all_features - feature_names = set([f.name for f in all_features() if f.is_optional()]) + feature_names = {f.name for f in all_features() if f.is_optional()} options.hide = options.hide.union(feature_names) options.disabled_optional = set() @@ -1085,7 +1086,7 @@ def sort_sources(self): """ if self.options.nthreads > 1 and len(self.sources) > self.options.nthreads: self.log("Sorting sources by runtime so that slower doctests are run first....") - default = dict(walltime=0) + default = {'walltime': 0} def sort_key(source): basename = source.basename @@ -1153,7 +1154,7 @@ def run_doctests(self): self.cleanup(False) else: self.log("No files to doctest") - self.reporter = DictAsObject(dict(error_status=0, stats={})) + self.reporter = DictAsObject({'error_status': 0, 'stats': {}}) def cleanup(self, final=True): """ @@ -1315,9 +1316,9 @@ def run_val_gdb(self, testing=False): flags = os.getenv("SAGE_MEMCHECK_FLAGS") if flags is None: flags = "--leak-resolution=high --leak-check=full --num-callers=25 " - flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind","pyalloc.supp")) - flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind","sage.supp")) - flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind","sage-additional.supp")) + flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind", "pyalloc.supp")) + flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind", "sage.supp")) + flags += '''--suppressions="%s" ''' % (os.path.join(SAGE_EXTCODE,"valgrind", "sage-additional.supp")) elif opt.massif: toolname = "massif" flags = os.getenv("SAGE_MASSIF_FLAGS", "--depth=6 ") diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 6c3b0b225ac..05bd5d0fd8e 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -687,10 +687,10 @@ def compiler(example): # findlinestarts() returns pairs (index, lineno) where # "index" is the index in the bytecode where the line # number changes to "lineno". - linenumbers1 = set(lineno for (index, lineno) - in findlinestarts(code)) - linenumbers2 = set(lineno for (index, lineno) - in findlinestarts(execcode)) + linenumbers1 = {lineno for (index, lineno) + in findlinestarts(code)} + linenumbers2 = {lineno for (index, lineno) + in findlinestarts(execcode)} if linenumbers1 != linenumbers2: raise SyntaxError("doctest is not a single statement") @@ -1726,7 +1726,7 @@ def serial_dispatch(self): with tempfile.TemporaryFile() as outtmpfile: result = DocTestTask(source)(self.controller.options, - outtmpfile, self.controller.logger) + outtmpfile, self.controller.logger) outtmpfile.seek(0) output = bytes_to_str(outtmpfile.read()) @@ -2334,7 +2334,7 @@ def save_result_output(self): try: self.result = self.result_queue.get(block=False) except Empty: - self.result = (0, DictAsObject(dict(err='noresult'))) + self.result = (0, DictAsObject({'err': 'noresult'})) del self.result_queue self.outtmpfile.seek(0) @@ -2536,17 +2536,17 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None): result = None try: runner = SageDocTestRunner( - SageOutputChecker(), - verbose=options.verbose, - outtmpfile=outtmpfile, - msgfile=msgfile, - sage_options=options, - optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS) + SageOutputChecker(), + verbose=options.verbose, + outtmpfile=outtmpfile, + msgfile=msgfile, + sage_options=options, + optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS) runner.basename = self.source.basename runner.filename = self.source.path N = options.file_iterations - results = DictAsObject(dict(walltime=[], cputime=[], - err=None, walltime_skips=0)) + results = DictAsObject({'walltime': [], 'cputime': [], + 'err': None, 'walltime_skips': 0}) # multiprocessing.Process instances don't run exit # functions, so we run the functions added by doctests @@ -2571,7 +2571,7 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None): except BaseException: exc_info = sys.exc_info() tb = "".join(traceback.format_exception(*exc_info)) - result = (0, DictAsObject(dict(err=exc_info[0], tb=tb))) + result = (0, DictAsObject({'err': exc_info[0], 'tb': tb})) if result_queue is not None: result_queue.put(result, False) diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index 5c37ea1422b..cd3c3dc1cfd 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -1140,8 +1140,8 @@ def update_tag_counts(optional_tags): def check_and_clear_tag_counts(): if (num_examples := tag_count_within_block['']) >= 4: - if overused_tags := set(tag for tag, count in tag_count_within_block.items() - if tag and count >= num_examples): + if overused_tags := {tag for tag, count in tag_count_within_block.items() + if tag and count >= num_examples}: overused_tags.update(persistent_optional_tags) overused_tags.difference_update(self.file_optional_tags) suggested = unparse_optional_tags(overused_tags, prefix='sage: # ') @@ -1210,10 +1210,10 @@ def check_and_clear_tag_counts(): continue if self.optional_tags is not True: - extra = set(tag + extra = {tag for tag in optional_tags if (tag not in self.optional_tags - and tag not in available_software)) + and tag not in available_software)} if extra: if any(tag in external_software for tag in extra): # never probe "external" software diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py index 5ef3e29a0a6..a86153ce326 100644 --- a/src/sage/doctest/reporting.py +++ b/src/sage/doctest/reporting.py @@ -116,7 +116,7 @@ def __init__(self, controller): sage: DTR = DocTestReporter(DC) """ self.controller = controller - self.postscript = dict(lines=[], cputime=0, walltime=0) + self.postscript = {"lines": [], "cputime": 0, "walltime": 0} self.sources_completed = 0 self.stats = {} self.error_status = 0 @@ -408,7 +408,7 @@ def report(self, source, timeout, return_code, results, output, pid=None): ntests, result_dict = results except (TypeError, ValueError): ntests = 0 - result_dict = DictAsObject(dict(err='badresult')) + result_dict = DictAsObject({"err": 'badresult'}) if timeout: fail_msg = "Timed out" if ntests > 0: @@ -429,7 +429,7 @@ def report(self, source, timeout, return_code, results, output, pid=None): log(output) log("*"*70) postscript['lines'].append(cmd + " # %s" % fail_msg) - stats[basename] = dict(failed=True, walltime=1e6, ntests=ntests) + stats[basename] = {"failed": True, "walltime": 1e6, "ntests": ntests} if not the_baseline_stats.get('failed', False): self.error_status |= 4 elif return_code: @@ -445,7 +445,7 @@ def report(self, source, timeout, return_code, results, output, pid=None): log(output) log("*"*70) postscript['lines'].append(cmd + " # %s" % fail_msg) - stats[basename] = dict(failed=True, walltime=1e6, ntests=ntests) + stats[basename] = {"failed": True, "walltime": 1e6, "ntests": ntests} if not the_baseline_stats.get('failed', False): self.error_status |= (8 if return_code > 0 else 16) else: @@ -501,9 +501,9 @@ def report(self, source, timeout, return_code, results, output, pid=None): if hasattr(result_dict, 'tb'): log(result_dict.tb) if hasattr(result_dict, 'walltime'): - stats[basename] = dict(failed=True, walltime=wall, ntests=ntests) + stats[basename] = {"failed": True, "walltime": wall, "ntests": ntests} else: - stats[basename] = dict(failed=True, walltime=1e6, ntests=ntests) + stats[basename] = {"failed": True, "walltime": 1e6, "ntests": ntests} self.error_status |= 64 if result_dict.err is None or result_dict.err == 'tab': f = result_dict.failures @@ -515,16 +515,16 @@ def report(self, source, timeout, return_code, results, output, pid=None): if not the_baseline_stats.get('failed', False): self.error_status |= 1 if f or result_dict.err == 'tab': - stats[basename] = dict(failed=True, walltime=wall, ntests=ntests) + stats[basename] = {"failed": True, "walltime": wall, "ntests": ntests} else: - stats[basename] = dict(walltime=wall, ntests=ntests) + stats[basename] = {"walltime": wall, "ntests": ntests} postscript['cputime'] += cpu postscript['walltime'] += wall try: optionals = result_dict.optionals except AttributeError: - optionals = dict() + optionals = {} for tag in sorted(optionals): nskipped = optionals[tag] if tag == "long time": diff --git a/src/sage/doctest/sources.py b/src/sage/doctest/sources.py index 5064496052b..8c7b29bf1d4 100644 --- a/src/sage/doctest/sources.py +++ b/src/sage/doctest/sources.py @@ -233,7 +233,7 @@ def _process_doc(self, doctests, doc, namespace, start): new_doctests = self.parse_docstring(docstring, namespace, start) sig_on_count_doc_doctest = "sig_on_count() # check sig_on/off pairings (virtual doctest)\n" for dt in new_doctests: - if len(dt.examples) > 0 and not (hasattr(dt.examples[-1],'sage_source') + if len(dt.examples) > 0 and not (hasattr(dt.examples[-1], 'sage_source') and dt.examples[-1].sage_source == sig_on_count_doc_doctest): # Line number refers to the end of the docstring sigon = doctest.Example(sig_on_count_doc_doctest, "0\n", lineno=docstring.count("\n")) @@ -305,7 +305,7 @@ def _create_doctests(self, namespace, tab_okay=None): False """ if tab_okay is None: - tab_okay = isinstance(self,TexSource) + tab_okay = isinstance(self, TexSource) self._init() self.line_shift = 0 self.parser = SageDocTestParser(self.options.optional, @@ -371,9 +371,9 @@ def _create_doctests(self, namespace, tab_okay=None): if unparsed_doc: self._process_doc(doctests, doc, namespace, start) - extras = dict(tab=not tab_okay and tab_locations, - line_number=contains_line_number, - optionals=self.parser.optionals) + extras = {"tab": not tab_okay and tab_locations, + "line_number": contains_line_number, + "optionals": self.parser.optionals} if self.options.randorder is not None and self.options.randorder is not False: # we want to randomize even when self.randorder = 0 random.seed(self.options.randorder) @@ -569,13 +569,13 @@ def __init__(self, path, options): base, ext = os.path.splitext(path) valid_code_ext = ('.py', '.pyx', '.pxd', '.pxi', '.sage', '.spyx') if ext in valid_code_ext: - self.__class__ = dynamic_class('PythonFileSource',(FileDocTestSource,PythonSource)) + self.__class__ = dynamic_class('PythonFileSource', (FileDocTestSource, PythonSource)) self.encoding = "utf-8" elif ext == '.tex': - self.__class__ = dynamic_class('TexFileSource',(FileDocTestSource,TexSource)) + self.__class__ = dynamic_class('TexFileSource', (FileDocTestSource, TexSource)) self.encoding = "utf-8" elif ext == '.rst' or ext == '.rst.txt': - self.__class__ = dynamic_class('RestFileSource',(FileDocTestSource,RestSource)) + self.__class__ = dynamic_class('RestFileSource', (FileDocTestSource, RestSource)) self.encoding = "utf-8" else: valid_ext = ", ".join(valid_code_ext + ('.tex', '.rst', '.rst.txt')) @@ -955,6 +955,7 @@ def parse_docstring(self, docstring, namespace, start): return [self.parser.get_doctest(docstring, namespace, str(self.qualified_name), self.printpath, start + 1)] + class PythonSource(SourceLanguage): """ This class defines the functions needed for the extraction of doctests from python sources. @@ -1252,6 +1253,7 @@ def _neutralize_doctests(self, reindent): neutralized.append(" "*reindent + line) return "".join(neutralized) + class TexSource(SourceLanguage): """ This class defines the functions needed for the extraction of @@ -1628,6 +1630,7 @@ def parse_docstring(self, docstring, namespace, start): self.printpath, start + 1) return [outer_doctest] + inner_doctests + class DictAsObject(dict): """ A simple subclass of dict that inserts the items from the initializing dictionary into attributes. diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py index c7774a6472b..b68068a0ce1 100644 --- a/src/sage/doctest/util.py +++ b/src/sage/doctest/util.py @@ -81,7 +81,7 @@ def dict_difference(self, other): sage: dict_difference(D2.__dict__, D1.__dict__) {'foobar': 'hello', 'timeout': 100} """ - D = dict() + D = {} for k, v in self.items(): try: if other[k] == v: @@ -275,8 +275,8 @@ def start(self): sage: D.start(); D.set set() """ - self.set = set([]) - self.got = set([]) + self.set = set() + self.got = set() def __getitem__(self, name): """ From ecbd9ac701c5c98bc3ea8635b44ca70184cfae27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Nov 2023 10:37:53 +0100 Subject: [PATCH 416/494] fine details --- src/sage/doctest/parsing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index cd3c3dc1cfd..32d15b4c720 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -94,7 +94,7 @@ def fake_RIFtol(*args): ansi_escape_sequence = re.compile(r'(\x1b[@-Z\\-~]|\x1b\[.*?[@-~]|\x9b.*?[@-~])') special_optional_regex = 'arb216|arb218|py2|long time|not implemented|not tested|known bug' -tag_with_explanation_regex = fr'((?:\w|[.])+)\s*(?:\((.*?)\))?' +tag_with_explanation_regex = r'((?:\w|[.])+)\s*(?:\((.*?)\))?' optional_regex = re.compile(fr'(?P{special_optional_regex})\s*(?:\((?P.*?)\))?|' fr'[^ a-z]\s*(optional|needs)(?:\s|[:-])*(?P(?:(?:{tag_with_explanation_regex})\s*)*)', re.IGNORECASE) @@ -470,7 +470,7 @@ def update_optional_tags(line, tags=None, *, add_tags=None, remove_tags=None, fo | V V V V V V v v v v | sage: # optional - magma, needs sage.symbolic """ - if not (m := re.match('( *sage: *)(.*)', line)): + if not re.match('( *sage: *)(.*)', line): raise ValueError(f'line must start with a sage: prompt, got: {line}') current_tags, line_sans_tags, is_persistent = parse_optional_tags(line.rstrip(), return_string_sans_tags=True) @@ -1141,7 +1141,7 @@ def update_tag_counts(optional_tags): def check_and_clear_tag_counts(): if (num_examples := tag_count_within_block['']) >= 4: if overused_tags := {tag for tag, count in tag_count_within_block.items() - if tag and count >= num_examples}: + if tag and count >= num_examples}: overused_tags.update(persistent_optional_tags) overused_tags.difference_update(self.file_optional_tags) suggested = unparse_optional_tags(overused_tags, prefix='sage: # ') @@ -1211,9 +1211,9 @@ def check_and_clear_tag_counts(): if self.optional_tags is not True: extra = {tag - for tag in optional_tags - if (tag not in self.optional_tags - and tag not in available_software)} + for tag in optional_tags + if (tag not in self.optional_tags + and tag not in available_software)} if extra: if any(tag in external_software for tag in extra): # never probe "external" software From 114ed8ae4a755e09f5793cdb737fa7e7b74ebf0a Mon Sep 17 00:00:00 2001 From: ymusleh Date: Thu, 2 Nov 2023 11:19:55 -0400 Subject: [PATCH 417/494] Updated documentation for motive algorithm in frobenius_charpoly --- .../drinfeld_modules/finite_drinfeld_module.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 9410fd42230..76c49e429dc 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -332,8 +332,19 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): By default, this method uses the so-called *crystalline* algorithm which computes the characteristic polynomial of the Frobenius acting on the crystalline cohomology of the Drinfeld - module. For further details, see [Ang1997]_. Other options - include the *motive* method. + module. For further details, see [Ang1997]_. + + The available options for 'algorithm' are: + + - `crystalline` Computes the characteristic polynomial of the + Frobenius endomorphism on the crystalline cohomology + of a Drinfeld module. + + - `motive` Based on computing the characteristic polynomial of + the Frobenius endomorphism on the motive of a + Drinfeld module. This instantiates the Frobenius + as a morphism object and calls its + 'characteristic_polynomial' method. """ # Throw an error if the user asks for an unimplemented algorithm # even if the char poly has already been computed From 4bd91fd4174d3d83602de94be79162f20b227fd0 Mon Sep 17 00:00:00 2001 From: ymusleh Date: Thu, 2 Nov 2023 12:02:06 -0400 Subject: [PATCH 418/494] Updated documentation for motive algorithm in frobenius_charpoly --- .../drinfeld_modules/finite_drinfeld_module.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 76c49e429dc..86cb9c1bbd9 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -336,15 +336,15 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): The available options for 'algorithm' are: - - `crystalline` Computes the characteristic polynomial of the + - ``'crystalline'`` -- Computes the characteristic polynomial of the Frobenius endomorphism on the crystalline cohomology of a Drinfeld module. - - `motive` Based on computing the characteristic polynomial of - the Frobenius endomorphism on the motive of a - Drinfeld module. This instantiates the Frobenius - as a morphism object and calls its - 'characteristic_polynomial' method. + - ``'motive'`` -- Based on computing the characteristic polynomial of + the Frobenius endomorphism on the motive of a + Drinfeld module. This instantiates the Frobenius + as a morphism object and calls its + ``'characteristic_polynomial'`` method. """ # Throw an error if the user asks for an unimplemented algorithm # even if the char poly has already been computed From e9e8859151d25409fea09c8d5dcc35eba8a69d23 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 23 Sep 2023 11:10:58 -0700 Subject: [PATCH 419/494] sage.combinat: Update # needs --- src/sage/combinat/enumeration_mod_permgroup.pyx | 1 + src/sage/combinat/finite_state_machine.py | 7 ++++--- src/sage/combinat/permutation.py | 13 +++++++------ src/sage/combinat/tamari_lattices.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/sage/combinat/enumeration_mod_permgroup.pyx b/src/sage/combinat/enumeration_mod_permgroup.pyx index 0da6b2d2638..742202d04ad 100644 --- a/src/sage/combinat/enumeration_mod_permgroup.pyx +++ b/src/sage/combinat/enumeration_mod_permgroup.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat r""" Tools for enumeration modulo the action of a permutation group """ diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 60410b886e4..24454f07c9b 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -3862,11 +3862,11 @@ def __call__(self, *args, **kwargs): sage: from itertools import islice sage: inverter = Transducer({'A': [('A', 0, 1), ('A', 1, 0)]}, ....: initial_states=['A'], final_states=['A']) - sage: inverter(words.FibonacciWord()) + sage: inverter(words.FibonacciWord()) # needs sage.combinat word: 1011010110110101101011011010110110101101... - sage: inverter(words.FibonacciWord(), automatic_output_type=True) + sage: inverter(words.FibonacciWord(), automatic_output_type=True) # needs sage.combinat word: 1011010110110101101011011010110110101101... - sage: tuple(islice(inverter(words.FibonacciWord(), + sage: tuple(islice(inverter(words.FibonacciWord(), # needs sage.combinat ....: automatic_output_type=False), 10r)) (1, 0, 1, 1, 0, 1, 0, 1, 1, 0) sage: type(inverter((1, 0, 1, 1, 0, 1, 0, 1, 1, 0), @@ -10586,6 +10586,7 @@ def moments_waiting_time(self, test=bool, is_zero=None, The expectation of `B_j` is given in [FHP2015]_, Theorem 2. Here, we verify this result by using transducers:: + sage: # needs sage.libs.singular sage: def test(h, r, j): ....: R = PolynomialRing( ....: QQ, diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 88e82bd8302..5c57f0af88d 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -6939,9 +6939,9 @@ def _coerce_map_from_(self, G): sage: P.has_coerce_map_from(Permutations(7)) False - sage: P.has_coerce_map_from(groups.misc.Cactus(5)) # needs sage.groups + sage: P.has_coerce_map_from(groups.misc.Cactus(5)) # needs sage.graphs sage.groups True - sage: P.has_coerce_map_from(groups.misc.Cactus(7)) # needs sage.groups + sage: P.has_coerce_map_from(groups.misc.Cactus(7)) # needs sage.graphs sage.groups False """ if isinstance(G, SymmetricGroup): @@ -6975,11 +6975,12 @@ def _from_cactus_group_element(self, x): EXAMPLES:: - sage: J3 = groups.misc.Cactus(3) # needs sage.groups - sage: s12,s13,s23 = J3.gens() # needs sage.groups - sage: elt = s12 * s23 * s13 # needs sage.groups + sage: # needs sage.graphs sage.groups + sage: J3 = groups.misc.Cactus(3) + sage: s12,s13,s23 = J3.gens() + sage: elt = s12 * s23 * s13 sage: P5 = Permutations(5) - sage: P5._from_cactus_group_element(elt) # needs sage.groups + sage: P5._from_cactus_group_element(elt) [1, 3, 2, 4, 5] """ return self(x.to_permutation()) diff --git a/src/sage/combinat/tamari_lattices.py b/src/sage/combinat/tamari_lattices.py index e7ac12e1ca3..43191540d71 100644 --- a/src/sage/combinat/tamari_lattices.py +++ b/src/sage/combinat/tamari_lattices.py @@ -207,7 +207,7 @@ def GeneralizedTamariLattice(a, b, m=1, check=True): TESTS:: - sage: P.coxeter_transformation()**18 == 1 + sage: P.coxeter_transformation()**18 == 1 # needs sage.libs.flint True REFERENCES: From f18a745b038797a7e3f71384ac5b186cc3116fc8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 21:09:24 -0700 Subject: [PATCH 420/494] sage.combinat: Use more block tags --- src/sage/combinat/composition.py | 9 +- .../combinat/crystals/affine_factorization.py | 1 - src/sage/combinat/diagram_algebras.py | 18 ++-- src/sage/combinat/dyck_word.py | 24 +++--- src/sage/combinat/finite_state_machine.py | 82 +++++++++++-------- src/sage/combinat/integer_vector.py | 22 ++--- src/sage/combinat/matrices/dancing_links.pyx | 5 +- src/sage/combinat/parking_functions.py | 9 +- src/sage/combinat/path_tableaux/frieze.py | 31 ++++--- 9 files changed, 108 insertions(+), 93 deletions(-) diff --git a/src/sage/combinat/composition.py b/src/sage/combinat/composition.py index 66a03049c34..4d98a25108d 100644 --- a/src/sage/combinat/composition.py +++ b/src/sage/combinat/composition.py @@ -1293,14 +1293,15 @@ def shuffle_product(self, other, overlap=False): composition more than once since a composition can be a shuffle of two compositions in several ways. For example:: + sage: # needs sage.combinat sage: w1 = Composition([1]) - sage: S = w1.shuffle_product(w1); S # needs sage.combinat + sage: S = w1.shuffle_product(w1); S Shuffle product of [1] and [1] - sage: S.list() # needs sage.combinat + sage: S.list() [[1, 1], [1, 1]] - sage: O = w1.shuffle_product(w1, overlap=True); O # needs sage.combinat + sage: O = w1.shuffle_product(w1, overlap=True); O Overlapping shuffle product of [1] and [1] - sage: O.list() # needs sage.combinat + sage: O.list() [[1, 1], [1, 1], [2]] TESTS:: diff --git a/src/sage/combinat/crystals/affine_factorization.py b/src/sage/combinat/crystals/affine_factorization.py index 1e6ea23eded..b1d820032af 100644 --- a/src/sage/combinat/crystals/affine_factorization.py +++ b/src/sage/combinat/crystals/affine_factorization.py @@ -10,7 +10,6 @@ #****************************************************************************** from sage.misc.lazy_attribute import lazy_attribute -from sage.misc.lazy_import import lazy_import from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper from sage.structure.unique_representation import UniqueRepresentation diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 775db86da77..2838d1e38df 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -2495,22 +2495,20 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin): Shorthands for working with basis elements are as follows:: + sage: # needs sage.symbolic sage: S = SymmetricGroupAlgebra(ZZ, 3) - sage: A = PartitionAlgebra(3, x, SR) # needs sage.symbolic - - sage: A([[1,3],[-1],[-3]]) # pair up the omitted nodes as `{-i, i}`, if possible # needs sage.symbolic + sage: A = PartitionAlgebra(3, x, SR) + sage: A([[1,3],[-1],[-3]]) # pair up the omitted nodes as `{-i, i}`, if possible P{{-3}, {-2, 2}, {-1}, {1, 3}} - sage: A([[1,3],[-1],[-3]]) == A[[1,3],[-1],[-3]] # needs sage.symbolic + sage: A([[1,3],[-1],[-3]]) == A[[1,3],[-1],[-3]] True - - sage: A([[1,2]]) # needs sage.symbolic + sage: A([[1,2]]) P{{-3, 3}, {-2}, {-1}, {1, 2}} - sage: A([[1,2]]) == A[[1,2]] # needs sage.symbolic + sage: A([[1,2]]) == A[[1,2]] True - - sage: A([2,3,1]) # permutations in one-line notation are imported as well # needs sage.symbolic + sage: A([2,3,1]) # permutations in one-line notation are imported as well P{{-3, 2}, {-2, 1}, {-1, 3}} - sage: A([2,3,1]) == A(S([2,3,1])) # needs sage.symbolic + sage: A([2,3,1]) == A(S([2,3,1])) True """ @staticmethod diff --git a/src/sage/combinat/dyck_word.py b/src/sage/combinat/dyck_word.py index b40b9dcc6d8..8d46a55aede 100644 --- a/src/sage/combinat/dyck_word.py +++ b/src/sage/combinat/dyck_word.py @@ -1787,23 +1787,24 @@ def tamari_interval(self, other): EXAMPLES:: + sage: # needs sage.graphs sage: dw = DyckWord([1, 1, 0, 1, 0, 0, 1, 0]) - sage: ip = dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 1, 0, 0])); ip # needs sage.graphs + sage: ip = dw.tamari_interval(DyckWord([1, 1, 1, 0, 0, 1, 0, 0])); ip The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (3, 1), (2, 1)] - sage: ip.lower_dyck_word() # needs sage.graphs + sage: ip.lower_dyck_word() [1, 1, 0, 1, 0, 0, 1, 0] - sage: ip.upper_dyck_word() # needs sage.graphs + sage: ip.upper_dyck_word() [1, 1, 1, 0, 0, 1, 0, 0] - sage: ip.interval_cardinality() # needs sage.graphs + sage: ip.interval_cardinality() 4 - sage: ip.number_of_tamari_inversions() # needs sage.graphs + sage: ip.number_of_tamari_inversions() 2 - sage: list(ip.dyck_words()) # needs sage.graphs + sage: list(ip.dyck_words()) [[1, 1, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 0, 1, 0]] - sage: dw.tamari_interval(DyckWord([1,1,0,0,1,1,0,0])) # needs sage.graphs + sage: dw.tamari_interval(DyckWord([1,1,0,0,1,1,0,0])) Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice @@ -2483,17 +2484,18 @@ def to_ordered_tree(self): EXAMPLES:: + sage: # needs sage.graphs sage: D = DyckWord([1,1,0,0]) - sage: D.to_ordered_tree() # needs sage.graphs + sage: D.to_ordered_tree() [[[]]] sage: D = DyckWord([1,0,1,0]) - sage: D.to_ordered_tree() # needs sage.graphs + sage: D.to_ordered_tree() [[], []] sage: D = DyckWord([1, 0, 1, 1, 0, 0]) - sage: D.to_ordered_tree() # needs sage.graphs + sage: D.to_ordered_tree() [[], [[]]] sage: D = DyckWord([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0]) - sage: D.to_ordered_tree() # needs sage.graphs + sage: D.to_ordered_tree() [[], [[], []], [[], [[]]]] TESTS:: diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index 24454f07c9b..a76958e6e73 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -9814,10 +9814,10 @@ def number_of_words(self, variable=None, sage: NAFp = Automaton([(0, 0, 0), (0, 1, 1), (1, 0, 0)], ....: initial_states=[0], ....: final_states=[0, 1]) - sage: N = NAFp.number_of_words(); N # needs sage.symbolic + sage: N = NAFp.number_of_words(); N # needs sage.rings.number_field sage.symbolic 1.170820393249937?*1.618033988749895?^n - 0.1708203932499369?*(-0.618033988749895?)^n - sage: all(len(list(NAFp.language(s))) # needs sage.symbolic + sage: all(len(list(NAFp.language(s))) # needs sage.rings.number_field sage.symbolic ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9827,14 +9827,15 @@ def number_of_words(self, variable=None, polynomial and then construct a number field generated by its roots. :: + sage: # needs sage.rings.number_field sage.symbolic sage: M = NAFp.adjacency_matrix(entry=lambda t: 1) - sage: M.characteristic_polynomial() # needs sage.symbolic + sage: M.characteristic_polynomial() x^2 - x - 1 - sage: R. = NumberField(x^2-x-1, embedding=1.6) # needs sage.symbolic - sage: N = NAFp.number_of_words(base_ring=R); N # needs sage.symbolic + sage: R. = NumberField(x^2 - x - 1, embedding=1.6) + sage: N = NAFp.number_of_words(base_ring=R); N 1/2*(1/2*sqrt(5) + 1/2)^n*(3*sqrt(1/5) + 1) - 1/2*(-1/2*sqrt(5) + 1/2)^n*(3*sqrt(1/5) - 1) - sage: all(len(list(NAFp.language(s))) # needs sage.symbolic + sage: all(len(list(NAFp.language(s))) ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9842,11 +9843,12 @@ def number_of_words(self, variable=None, In this special case, we might also use the constant :class:`golden_ratio `:: - sage: R. = NumberField(x^2-x-1, embedding=golden_ratio) # needs sage.symbolic - sage: N = NAFp.number_of_words(base_ring=R); N # needs sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: R. = NumberField(x^2-x-1, embedding=golden_ratio) + sage: N = NAFp.number_of_words(base_ring=R); N 1/5*(3*golden_ratio + 1)*golden_ratio^n - 1/5*(3*golden_ratio - 4)*(-golden_ratio + 1)^n - sage: all(len(list(NAFp.language(s))) # needs sage.symbolic + sage: all(len(list(NAFp.language(s))) ....: - len(list(NAFp.language(s-1))) == N.subs(n=s) ....: for s in srange(1, 6)) True @@ -9974,12 +9976,14 @@ def asymptotic_moments(self, variable=None): ....: final_states=[0]) sage: T([0, 1, 1]) [0, -1, -1] - sage: moments = T.asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + + sage: # needs sage.symbolic + sage: moments = T.asymptotic_moments() + sage: moments['expectation'] -1/2*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 1/4*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] -1/4*n + Order(1) #. For the case of the Hamming weight of the non-adjacent-form @@ -10104,12 +10108,14 @@ def asymptotic_moments(self, variable=None): Transition from () to (1,): 1|0, Transition from (1,) to (): 0|1, Transition from (1,) to (1,): 1|0] - sage: moments = block10.asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + + sage: # needs sage.symbolic + sage: moments = block10.asymptotic_moments() + sage: moments['expectation'] 1/4*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 1/16*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] Order(1) #. This is the second part of Example 4.4 in [HKW2015]_, @@ -10125,16 +10131,18 @@ def asymptotic_moments(self, variable=None): Transition from () to (1,): 1|0, Transition from (1,) to (): 0|0, Transition from (1,) to (1,): 1|1] - sage: var('N') # needs sage.symbolic + + sage: # needs sage.symbolic + sage: var('N') N - sage: moments = block11.asymptotic_moments(N) # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + sage: moments = block11.asymptotic_moments(N) + sage: moments['expectation'] 1/4*N + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 5/16*N + Order(1) - sage: correlation = (moments['covariance'].coefficient(N) / # needs sage.symbolic + sage: correlation = (moments['covariance'].coefficient(N) / ....: (1/2 * sqrt(moments['variance'].coefficient(N)))) - sage: correlation # needs sage.symbolic + sage: correlation 2/5*sqrt(5) #. This is Example 4.5 in [HKW2015]_, counting the number of @@ -10155,12 +10163,14 @@ def asymptotic_moments(self, variable=None): Transition from 1 to 0: 1|0, Transition from 2 to 2: 0|0, Transition from 2 to 0: 1|1] - sage: moments = T.asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + + sage: # needs sage.symbolic + sage: moments = T.asymptotic_moments() + sage: moments['expectation'] Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] Order(1) #. The finite state machine must have a unique final component:: @@ -10233,28 +10243,30 @@ def asymptotic_moments(self, variable=None): #. Non-integer input or output labels lead to a warning:: + sage: # needs sage.symbolic sage: T = Transducer([[0, 0, 0, 0], [0, 0, 1, -1/2]], ....: initial_states=[0], final_states=[0]) - sage: moments = T.asymptotic_moments() # needs sage.symbolic + sage: moments = T.asymptotic_moments() verbose 0 (...) Non-integer output weights lead to significant performance degradation. - sage: moments['expectation'] # needs sage.symbolic + sage: moments['expectation'] -1/4*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 1/16*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] -1/8*n + Order(1) This warning can be silenced by :func:`~sage.misc.verbose.set_verbose`:: + sage: # needs sage.symbolic sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1, "finite_state_machine.py") - sage: moments = T.asymptotic_moments() # needs sage.symbolic - sage: moments['expectation'] # needs sage.symbolic + sage: moments = T.asymptotic_moments() + sage: moments['expectation'] -1/4*n + Order(1) - sage: moments['variance'] # needs sage.symbolic + sage: moments['variance'] 1/16*n + Order(1) - sage: moments['covariance'] # needs sage.symbolic + sage: moments['covariance'] -1/8*n + Order(1) sage: set_verbose(0, "finite_state_machine.py") diff --git a/src/sage/combinat/integer_vector.py b/src/sage/combinat/integer_vector.py index 94a09c7474f..456eea36f44 100644 --- a/src/sage/combinat/integer_vector.py +++ b/src/sage/combinat/integer_vector.py @@ -204,47 +204,49 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", Computing the matrix for `p_1=p_2=2+2+1`:: + sage: # needs sage.combinat sage.modules sage: from sage.combinat.integer_vector import gale_ryser_theorem sage: p1 = [2,2,1] sage: p2 = [2,2,1] - sage: print(gale_ryser_theorem(p1, p2)) # not tested # needs sage.combinat sage.modules + sage: print(gale_ryser_theorem(p1, p2)) # not tested [1 1 0] [1 0 1] [0 1 0] - sage: A = gale_ryser_theorem(p1, p2) # needs sage.combinat sage.modules - sage: rs = [sum(x) for x in A.rows()] # needs sage.combinat sage.modules - sage: cs = [sum(x) for x in A.columns()] # needs sage.combinat sage.modules - sage: p1 == rs; p2 == cs # needs sage.combinat sage.modules + sage: A = gale_ryser_theorem(p1, p2) + sage: rs = [sum(x) for x in A.rows()] + sage: cs = [sum(x) for x in A.columns()] + sage: p1 == rs; p2 == cs True True Or for a non-square matrix with `p_1=3+3+2+1` and `p_2=3+2+2+1+1`, using Ryser's algorithm:: + sage: # needs sage.combinat sage.modules sage: from sage.combinat.integer_vector import gale_ryser_theorem sage: p1 = [3,3,1,1] sage: p2 = [3,3,1,1] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") [1 1 1 0] [1 1 0 1] [1 0 0 0] [0 1 0 0] sage: p1 = [4,2,2] sage: p2 = [3,3,1,1] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") [1 1 1 1] [1 1 0 0] [1 1 0 0] sage: p1 = [4,2,2,0] sage: p2 = [3,3,1,1,0,0] - sage: gale_ryser_theorem(p1, p2, algorithm="ryser") # needs sage.combinat sage.modules + sage: gale_ryser_theorem(p1, p2, algorithm="ryser") [1 1 1 1 0 0] [1 1 0 0 0 0] [1 1 0 0 0 0] [0 0 0 0 0 0] sage: p1 = [3,3,2,1] sage: p2 = [3,2,2,1,1] - sage: print(gale_ryser_theorem(p1, p2, algorithm="gale")) # not tested, needs sage.combinat sage.modules + sage: print(gale_ryser_theorem(p1, p2, algorithm="gale")) # not tested [1 1 1 0 0] [1 1 0 0 1] [1 0 1 0 0] @@ -276,7 +278,7 @@ def gale_ryser_theorem(p1, p2, algorithm="gale", ``gale_ryser_theorem`` is then called on these sequences, and the output checked for correction.:: - sage: def test_algorithm(algorithm, low = 10, high = 50): + sage: def test_algorithm(algorithm, low=10, high=50): ....: n,m = randint(low,high), randint(low,high) ....: g = graphs.RandomBipartite(n, m, .3) ....: s1 = sorted(g.degree([(0,i) for i in range(n)]), reverse = True) diff --git a/src/sage/combinat/matrices/dancing_links.pyx b/src/sage/combinat/matrices/dancing_links.pyx index 0a00801030d..99dc42b3477 100644 --- a/src/sage/combinat/matrices/dancing_links.pyx +++ b/src/sage/combinat/matrices/dancing_links.pyx @@ -1111,8 +1111,9 @@ cdef class dancing_linksWrapper: Using optional solvers:: - sage: s = d.one_solution_using_milp_solver('gurobi') # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip - sage: s in solutions # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip + sage: # optional - gurobi sage_numerical_backends_gurobi, needs sage.numerical.mip + sage: s = d.one_solution_using_milp_solver('gurobi') + sage: s in solutions True When no solution is found:: diff --git a/src/sage/combinat/parking_functions.py b/src/sage/combinat/parking_functions.py index b47bdb5a01b..39feb8aa80f 100644 --- a/src/sage/combinat/parking_functions.py +++ b/src/sage/combinat/parking_functions.py @@ -1022,16 +1022,17 @@ def characteristic_quasisymmetric_function(self, q=None, EXAMPLES:: + sage: # needs sage.modules sage: R = QQ['q','t'].fraction_field() sage: (q,t) = R.gens() - sage: cqf = sum(t**PF.area() * PF.characteristic_quasisymmetric_function() # needs sage.modules + sage: cqf = sum(t**PF.area() * PF.characteristic_quasisymmetric_function() ....: for PF in ParkingFunctions(3)); cqf (q^3+q^2*t+q*t^2+t^3+q*t)*F[1, 1, 1] + (q^2+q*t+t^2+q+t)*F[1, 2] + (q^2+q*t+t^2+q+t)*F[2, 1] + F[3] - sage: s = SymmetricFunctions(R).s() # needs sage.modules - sage: s(cqf.to_symmetric_function()) # needs sage.modules + sage: s = SymmetricFunctions(R).s() + sage: s(cqf.to_symmetric_function()) (q^3+q^2*t+q*t^2+t^3+q*t)*s[1, 1, 1] + (q^2+q*t+t^2+q+t)*s[2, 1] + s[3] - sage: s(cqf.to_symmetric_function()).nabla(power=-1) # needs sage.modules + sage: s(cqf.to_symmetric_function()).nabla(power=-1) s[1, 1, 1] :: diff --git a/src/sage/combinat/path_tableaux/frieze.py b/src/sage/combinat/path_tableaux/frieze.py index 7ed6346efc5..1a09c1283fa 100644 --- a/src/sage/combinat/path_tableaux/frieze.py +++ b/src/sage/combinat/path_tableaux/frieze.py @@ -84,10 +84,11 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): This constructs the examples from [HJ18]_:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field - sage: t = path_tableaux.FriezePattern([1,sqrt3,2,sqrt3,1,1], field=K) # needs sage.rings.number_field - sage: path_tableaux.CylindricalDiagram(t) # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 3) + sage: t = path_tableaux.FriezePattern([1, sqrt3, 2, sqrt3, 1, 1], field=K) + sage: path_tableaux.CylindricalDiagram(t) [ 0, 1, sqrt3, 2, sqrt3, 1, 1, 0] [ , 0, 1, sqrt3, 2, sqrt3, sqrt3 + 1, 1, 0] [ , , 0, 1, sqrt3, 2, sqrt3 + 2, sqrt3, 1, 0] @@ -96,13 +97,13 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): [ , , , , , 0, 1, 1, sqrt3, 2, sqrt3, 1, 0] [ , , , , , , 0, 1, sqrt3 + 1, sqrt3 + 2, sqrt3 + 2, sqrt3 + 1, 1, 0] [ , , , , , , , 0, 1, sqrt3, 2, sqrt3, 1, 1, 0] + sage: TestSuite(t).run() - sage: TestSuite(t).run() # needs sage.rings.number_field - - sage: K. = NumberField(x^2 - 2) # needs sage.rings.number_field - sage: t = path_tableaux.FriezePattern([1,sqrt2,1,sqrt2,3,2*sqrt2,5,3*sqrt2,1], # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: t = path_tableaux.FriezePattern([1, sqrt2, 1, sqrt2, 3, 2*sqrt2, 5, 3*sqrt2, 1], ....: field=K) - sage: path_tableaux.CylindricalDiagram(t) # needs sage.rings.number_field + sage: path_tableaux.CylindricalDiagram(t) [ 0, 1, sqrt2, 1, sqrt2, 3, 2*sqrt2, 5, 3*sqrt2, 1, 0] [ , 0, 1, sqrt2, 3, 5*sqrt2, 7, 9*sqrt2, 11, 2*sqrt2, 1, 0] [ , , 0, 1, 2*sqrt2, 7, 5*sqrt2, 13, 8*sqrt2, 3, sqrt2, 1, 0] @@ -114,8 +115,7 @@ class FriezePattern(PathTableau, metaclass=InheritComparisonClasscallMetaclass): [ , , , , , , , , 0, 1, 3*sqrt2, 11, 8*sqrt2, 5, 2*sqrt2, 3, sqrt2, 1, 0] [ , , , , , , , , , 0, 1, 2*sqrt2, 3, sqrt2, 1, sqrt2, 1, sqrt2, 1, 0] [ , , , , , , , , , , 0, 1, sqrt2, 1, sqrt2, 3, 2*sqrt2, 5, 3*sqrt2, 1, 0] - - sage: TestSuite(t).run() # needs sage.rings.number_field + sage: TestSuite(t).run() """ @staticmethod def __classcall_private__(cls, fp, field=QQ): @@ -378,18 +378,17 @@ def plot(self, model='UHP'): EXAMPLES:: + sage: # needs sage.plot sage.symbolic sage: t = path_tableaux.FriezePattern([1,2,7,5,3,7,4,1]) - sage: t.plot() # needs sage.plot sage.symbolic + sage: t.plot() Graphics object consisting of 18 graphics primitives - - sage: t.plot(model='UHP') # needs sage.plot sage.symbolic + sage: t.plot(model='UHP') Graphics object consisting of 18 graphics primitives - - sage: t.plot(model='PD') # needs sage.plot sage.symbolic + sage: t.plot(model='PD') Traceback (most recent call last): ... TypeError: '>' not supported between instances of 'NotANumber' and 'Pi' - sage: t.plot(model='KM') # needs sage.plot sage.symbolic + sage: t.plot(model='KM') Graphics object consisting of 18 graphics primitives """ from sage.geometry.hyperbolic_space.hyperbolic_interface import HyperbolicPlane From da93fef708f5797fd45009ee8bae3d570c479664 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 31 Oct 2023 22:03:06 -0700 Subject: [PATCH 421/494] sage.combinat: Use even more block tags --- src/sage/combinat/binary_tree.py | 22 +++--- src/sage/combinat/combinat.py | 13 +-- src/sage/combinat/crystals/littelmann_path.py | 1 - src/sage/combinat/dyck_word.py | 17 ++-- src/sage/combinat/free_module.py | 10 +-- src/sage/combinat/interval_posets.py | 45 ++++++----- .../multiset_partition_into_sets_ordered.py | 29 ++++--- src/sage/combinat/ordered_tree.py | 22 +++--- src/sage/combinat/partition.py | 79 ++++++++++--------- src/sage/combinat/permutation.py | 77 ++++++++++-------- src/sage/combinat/plane_partition.py | 12 +-- src/sage/combinat/skew_partition.py | 13 +-- src/sage/combinat/subsets_hereditary.py | 13 +-- src/sage/combinat/tableau_tuple.py | 29 ++++--- src/sage/combinat/tiling.py | 30 ++++--- 15 files changed, 216 insertions(+), 196 deletions(-) diff --git a/src/sage/combinat/binary_tree.py b/src/sage/combinat/binary_tree.py index 4b65fd72145..3f7b8ae2fc5 100644 --- a/src/sage/combinat/binary_tree.py +++ b/src/sage/combinat/binary_tree.py @@ -1279,14 +1279,15 @@ def to_dyck_word(self, usemap="1L0R"): TESTS:: + sage: # needs sage.combinat sage: bt = BinaryTree([[[], [[], None]], [[], []]]) - sage: bt == bt.to_dyck_word().to_binary_tree() # needs sage.combinat + sage: bt == bt.to_dyck_word().to_binary_tree() True - sage: bt == bt.to_dyck_word("1R0L").to_binary_tree("1R0L") # needs sage.combinat + sage: bt == bt.to_dyck_word("1R0L").to_binary_tree("1R0L") True - sage: bt == bt.to_dyck_word("L1R0").to_binary_tree("L1R0") # needs sage.combinat + sage: bt == bt.to_dyck_word("L1R0").to_binary_tree("L1R0") True - sage: bt == bt.to_dyck_word("R1L0").to_binary_tree("R1L0") # needs sage.combinat + sage: bt == bt.to_dyck_word("R1L0").to_binary_tree("R1L0") True """ from sage.combinat.dyck_word import DyckWord @@ -2851,20 +2852,21 @@ def q_hook_length_fraction(self, q=None, q_factor=False): Let us get to a more interesting tree:: + sage: # needs sage.combinat sage: b = BinaryTree([[[],[]],[[],None]]); b [[[., .], [., .]], [[., .], .]] - sage: b.q_hook_length_fraction()(q=1) # needs sage.combinat + sage: b.q_hook_length_fraction()(q=1) 20 - sage: b.q_hook_length_fraction() # needs sage.combinat + sage: b.q_hook_length_fraction() q^7 + 2*q^6 + 3*q^5 + 4*q^4 + 4*q^3 + 3*q^2 + 2*q + 1 - sage: b.q_hook_length_fraction(q_factor=True) # needs sage.combinat + sage: b.q_hook_length_fraction(q_factor=True) q^10 + 2*q^9 + 3*q^8 + 4*q^7 + 4*q^6 + 3*q^5 + 2*q^4 + q^3 - sage: b.q_hook_length_fraction(q=2) # needs sage.combinat + sage: b.q_hook_length_fraction(q=2) 465 - sage: b.q_hook_length_fraction(q=2, q_factor=True) # needs sage.combinat + sage: b.q_hook_length_fraction(q=2, q_factor=True) 3720 sage: q = PolynomialRing(ZZ, 'q').gen() - sage: b.q_hook_length_fraction(q=q**2) # needs sage.combinat + sage: b.q_hook_length_fraction(q=q**2) q^14 + 2*q^12 + 3*q^10 + 4*q^8 + 4*q^6 + 3*q^4 + 2*q^2 + 1 Let us check the fact that `f_{q} (T)` is the generating function diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 2fc8d554628..451f8093393 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -3120,18 +3120,19 @@ def bernoulli_polynomial(x, n: Integer): EXAMPLES:: + sage: # needs sage.libs.flint sage: y = QQ['y'].0 - sage: bernoulli_polynomial(y, 5) # needs sage.libs.flint + sage: bernoulli_polynomial(y, 5) y^5 - 5/2*y^4 + 5/3*y^3 - 1/6*y - sage: bernoulli_polynomial(y, 5)(12) # needs sage.libs.flint + sage: bernoulli_polynomial(y, 5)(12) 199870 - sage: bernoulli_polynomial(12, 5) # needs sage.libs.flint + sage: bernoulli_polynomial(12, 5) 199870 - sage: bernoulli_polynomial(y^2 + 1, 5) # needs sage.libs.flint + sage: bernoulli_polynomial(y^2 + 1, 5) y^10 + 5/2*y^8 + 5/3*y^6 - 1/6*y^2 sage: P. = ZZ[] - sage: p = bernoulli_polynomial(t, 6) # needs sage.libs.flint - sage: p.parent() # needs sage.libs.flint + sage: p = bernoulli_polynomial(t, 6) + sage: p.parent() Univariate Polynomial Ring in t over Rational Field We verify an instance of the formula which is the origin of diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index 719f25e7071..a90a61cb4c9 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -27,7 +27,6 @@ # *************************************************************************** from sage.misc.cachefunc import cached_in_parent_method, cached_method -from sage.misc.lazy_import import lazy_import from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper from sage.structure.parent import Parent diff --git a/src/sage/combinat/dyck_word.py b/src/sage/combinat/dyck_word.py index 8d46a55aede..41a3c199599 100644 --- a/src/sage/combinat/dyck_word.py +++ b/src/sage/combinat/dyck_word.py @@ -1694,25 +1694,26 @@ def to_binary_tree(self, usemap="1L0R"): EXAMPLES:: + sage: # needs sage.graphs sage: dw = DyckWord([1,0]) - sage: dw.to_binary_tree() # needs sage.graphs + sage: dw.to_binary_tree() [., .] sage: dw = DyckWord([]) - sage: dw.to_binary_tree() # needs sage.graphs + sage: dw.to_binary_tree() . sage: dw = DyckWord([1,0,1,1,0,0]) - sage: dw.to_binary_tree() # needs sage.graphs + sage: dw.to_binary_tree() [., [[., .], .]] - sage: dw.to_binary_tree("L1R0") # needs sage.graphs + sage: dw.to_binary_tree("L1R0") [[., .], [., .]] sage: dw = DyckWord([1,0,1,1,0,0,1,1,1,0,1,0,0,0]) - sage: dw.to_binary_tree() == dw.to_binary_tree("1R0L").left_right_symmetry() # needs sage.graphs + sage: dw.to_binary_tree() == dw.to_binary_tree("1R0L").left_right_symmetry() True - sage: dw.to_binary_tree() == dw.to_binary_tree("L1R0").left_border_symmetry() # needs sage.graphs + sage: dw.to_binary_tree() == dw.to_binary_tree("L1R0").left_border_symmetry() False - sage: dw.to_binary_tree("1R0L") == dw.to_binary_tree("L1R0").left_border_symmetry() # needs sage.graphs + sage: dw.to_binary_tree("1R0L") == dw.to_binary_tree("L1R0").left_border_symmetry() True - sage: dw.to_binary_tree("R1L0") == dw.to_binary_tree("L1R0").left_right_symmetry() # needs sage.graphs + sage: dw.to_binary_tree("R1L0") == dw.to_binary_tree("L1R0").left_right_symmetry() True sage: dw.to_binary_tree("R10L") Traceback (most recent call last): diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 75bc46be1e8..3c77ac6ef16 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -348,16 +348,16 @@ def element_class(self): EXAMPLES:: - sage: A = Algebras(QQ).WithBasis().example(); A # needs sage.combinat + sage: # needs sage.combinat + sage: A = Algebras(QQ).WithBasis().example(); A An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field - - sage: A.element_class.mro() # needs sage.combinat + sage: A.element_class.mro() [, , ...] - sage: a,b,c = A.algebra_generators() # needs sage.combinat - sage: a * b # needs sage.combinat + sage: a,b,c = A.algebra_generators() + sage: a * b B[word: ab] TESTS:: diff --git a/src/sage/combinat/interval_posets.py b/src/sage/combinat/interval_posets.py index dc104833cd1..c9f1e99984d 100644 --- a/src/sage/combinat/interval_posets.py +++ b/src/sage/combinat/interval_posets.py @@ -1675,18 +1675,19 @@ def contains_dyck_word(self, dyck_word) -> bool: EXAMPLES:: + sage: # needs sage.combinat sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)]) - sage: ip.contains_dyck_word(DyckWord([1,1,1,0,0,0,1,0])) # needs sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,1,1,0,0,0,1,0])) True - sage: ip.contains_dyck_word(DyckWord([1,1,0,1,0,1,0,0])) # needs sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,1,0,1,0,1,0,0])) True - sage: ip.contains_dyck_word(DyckWord([1,0,1,1,0,1,0,0])) # needs sage.combinat + sage: ip.contains_dyck_word(DyckWord([1,0,1,1,0,1,0,0])) False - sage: ip.contains_dyck_word(ip.lower_dyck_word()) # needs sage.combinat + sage: ip.contains_dyck_word(ip.lower_dyck_word()) True - sage: ip.contains_dyck_word(ip.upper_dyck_word()) # needs sage.combinat + sage: ip.contains_dyck_word(ip.upper_dyck_word()) True - sage: all(ip.contains_dyck_word(bt) for bt in ip.dyck_words()) # needs sage.combinat + sage: all(ip.contains_dyck_word(bt) for bt in ip.dyck_words()) True """ return self.contains_binary_tree(dyck_word.to_binary_tree_tamari()) @@ -1860,15 +1861,16 @@ def lower_dyck_word(self): EXAMPLES:: + sage: # needs sage.combinat sage: ip = TamariIntervalPoset(6, [(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - sage: ip.lower_dyck_word() # needs sage.combinat + sage: ip.lower_dyck_word() [1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0] - sage: ldw_ff = TamariIntervalPosets.final_forest(ip.lower_dyck_word()) # needs sage.combinat - sage: ldw_ff == ip.final_forest() # needs sage.combinat + sage: ldw_ff = TamariIntervalPosets.final_forest(ip.lower_dyck_word()) + sage: ldw_ff == ip.final_forest() True - sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # needs sage.combinat + sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), ....: ip.upper_dyck_word()) True """ @@ -1909,15 +1911,16 @@ def upper_dyck_word(self): EXAMPLES:: + sage: # needs sage.combinat sage: ip = TamariIntervalPoset(6,[(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - sage: ip.upper_dyck_word() # needs sage.combinat + sage: ip.upper_dyck_word() [1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0] - sage: udw_if = TamariIntervalPosets.initial_forest(ip.upper_dyck_word()) # needs sage.combinat - sage: udw_if == ip.initial_forest() # needs sage.combinat + sage: udw_if = TamariIntervalPosets.initial_forest(ip.upper_dyck_word()) + sage: udw_if == ip.initial_forest() True - sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), # needs sage.combinat + sage: ip == TamariIntervalPosets.from_dyck_words(ip.lower_dyck_word(), ....: ip.upper_dyck_word()) True """ @@ -3288,18 +3291,18 @@ def from_dyck_words(dw1, dw2) -> TIP: sage: TamariIntervalPosets.from_dyck_words(dw2,dw2) The Tamari interval of size 2 induced by relations [(2, 1)] - sage: dw1 = DyckWord([1,0,1,1,1,0,0,1,1,0,0,0]) # needs sage.combinat - sage: dw2 = DyckWord([1,1,1,1,0,1,1,0,0,0,0,0]) # needs sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1,dw2) # needs sage.combinat + sage: # needs sage.combinat + sage: dw1 = DyckWord([1,0,1,1,1,0,0,1,1,0,0,0]) + sage: dw2 = DyckWord([1,1,1,1,0,1,1,0,0,0,0,0]) + sage: TamariIntervalPosets.from_dyck_words(dw1,dw2) The Tamari interval of size 6 induced by relations [(4, 5), (6, 5), (5, 2), (4, 3), (3, 2)] - - sage: dw3 = DyckWord([1,1,1,0,1,1,1,0,0,0,0,0]) # needs sage.combinat - sage: TamariIntervalPosets.from_dyck_words(dw1,dw3) # needs sage.combinat + sage: dw3 = DyckWord([1,1,1,0,1,1,1,0,0,0,0,0]) + sage: TamariIntervalPosets.from_dyck_words(dw1,dw3) Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice - sage: TamariIntervalPosets.from_dyck_words(dw1,DyckWord([1,0])) # needs sage.combinat + sage: TamariIntervalPosets.from_dyck_words(dw1,DyckWord([1,0])) Traceback (most recent call last): ... ValueError: the two Dyck words are not comparable on the Tamari lattice diff --git a/src/sage/combinat/multiset_partition_into_sets_ordered.py b/src/sage/combinat/multiset_partition_into_sets_ordered.py index 10ce01e8cc5..a8855beb412 100755 --- a/src/sage/combinat/multiset_partition_into_sets_ordered.py +++ b/src/sage/combinat/multiset_partition_into_sets_ordered.py @@ -3213,17 +3213,16 @@ def __init__(self, n, ell, k): TESTS:: - sage: B = crystals.Minimaj(2,3,2) # needs sage.modules - sage: TestSuite(B).run() # needs sage.modules - - sage: B = crystals.Minimaj(3, 5, 2) # needs sage.modules - sage: TestSuite(B).run() # needs sage.modules - - sage: list(crystals.Minimaj(2,6,3)) # needs sage.modules + sage: # needs sage.modules + sage: B = crystals.Minimaj(2,3,2) + sage: TestSuite(B).run() + sage: B = crystals.Minimaj(3, 5, 2) + sage: TestSuite(B).run() + sage: list(crystals.Minimaj(2,6,3)) [((1, 2), (2, 1), (1, 2))] - sage: list(crystals.Minimaj(2,5,2)) # blocks too fat for alphabet # needs sage.modules + sage: list(crystals.Minimaj(2,5,2)) # blocks too fat for alphabet [] - sage: list(crystals.Minimaj(4,2,3)) # more blocks than letters # needs sage.modules + sage: list(crystals.Minimaj(4,2,3)) # more blocks than letters Traceback (most recent call last): ... ValueError: n (=4), ell (=2), and k (=3) must all be positive integers @@ -3485,15 +3484,15 @@ def to_tableaux_words(self): EXAMPLES:: - sage: B = crystals.Minimaj(4,5,3) # needs sage.modules - sage: b = B.an_element(); b # needs sage.modules + sage: # needs sage.modules + sage: B = crystals.Minimaj(4,5,3) + sage: b = B.an_element(); b ((2, 3, 1), (1,), (1,)) - sage: b.to_tableaux_words() # needs sage.modules + sage: b.to_tableaux_words() [[1], [3], [2, 1, 1]] - - sage: b = B([[1,3,4], [3], [3]]); b # needs sage.modules + sage: b = B([[1,3,4], [3], [3]]); b ((4, 1, 3), (3,), (3,)) - sage: b.to_tableaux_words() # needs sage.modules + sage: b.to_tableaux_words() [[3, 1], [], [4, 3, 3]] """ w, breaks = self.value diff --git a/src/sage/combinat/ordered_tree.py b/src/sage/combinat/ordered_tree.py index 5028d36fb04..59f4a4ad115 100644 --- a/src/sage/combinat/ordered_tree.py +++ b/src/sage/combinat/ordered_tree.py @@ -359,21 +359,22 @@ def to_parallelogram_polyomino(self, bijection=None): EXAMPLES:: + sage: # needs sage.combinat sage.modules sage: T = OrderedTree([[[], [[], [[]]]], [], [[[],[]]], [], []]) - sage: T.to_parallelogram_polyomino(bijection='Boussicault-Socci') # needs sage.combinat sage.modules + sage: T.to_parallelogram_polyomino(bijection='Boussicault-Socci') [[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0]] sage: T = OrderedTree( [] ) - sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules + sage: T.to_parallelogram_polyomino() [[1], [1]] sage: T = OrderedTree( [[]] ) - sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules + sage: T.to_parallelogram_polyomino() [[0, 1], [1, 0]] sage: T = OrderedTree( [[],[]] ) - sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules + sage: T.to_parallelogram_polyomino() [[0, 1, 1], [1, 1, 0]] sage: T = OrderedTree( [[[]]] ) - sage: T.to_parallelogram_polyomino() # needs sage.combinat sage.modules + sage: T.to_parallelogram_polyomino() [[0, 0, 1], [1, 0, 0]] """ if (bijection is None) or (bijection == 'Boussicault-Socci'): @@ -389,22 +390,23 @@ def _to_parallelogram_polyomino_Boussicault_Socci(self): EXAMPLES:: + sage: # needs sage.combinat sage.modules sage: T = OrderedTree( ....: [[[], [[], [[]]]], [], [[[],[]]], [], []] ....: ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules + sage: T._to_parallelogram_polyomino_Boussicault_Socci() [[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0]] sage: T = OrderedTree( [] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules + sage: T._to_parallelogram_polyomino_Boussicault_Socci() [[1], [1]] sage: T = OrderedTree( [[]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules + sage: T._to_parallelogram_polyomino_Boussicault_Socci() [[0, 1], [1, 0]] sage: T = OrderedTree( [[],[]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules + sage: T._to_parallelogram_polyomino_Boussicault_Socci() [[0, 1, 1], [1, 1, 0]] sage: T = OrderedTree( [[[]]] ) - sage: T._to_parallelogram_polyomino_Boussicault_Socci() # needs sage.combinat sage.modules + sage: T._to_parallelogram_polyomino_Boussicault_Socci() [[0, 0, 1], [1, 0, 0]] """ from sage.combinat.parallelogram_polyomino import ParallelogramPolyomino diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 39726dec694..5b8ea5220e2 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -1884,18 +1884,19 @@ def cell_poset(self, orientation="SE"): EXAMPLES:: + sage: # needs sage.graphs sage: p = Partition([3,3,1]) - sage: Q = p.cell_poset(); Q # needs sage.graphs + sage: Q = p.cell_poset(); Q Finite poset containing 7 elements - sage: sorted(Q) # needs sage.graphs + sage: sorted(Q) [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0)] - sage: sorted(Q.maximal_elements()) # needs sage.graphs + sage: sorted(Q.maximal_elements()) [(1, 2), (2, 0)] - sage: Q.minimal_elements() # needs sage.graphs + sage: Q.minimal_elements() [(0, 0)] - sage: sorted(Q.upper_covers((1, 0))) # needs sage.graphs + sage: sorted(Q.upper_covers((1, 0))) [(1, 1), (2, 0)] - sage: Q.upper_covers((1, 1)) # needs sage.graphs + sage: Q.upper_covers((1, 1)) [(1, 2)] sage: # needs sage.graphs @@ -5071,16 +5072,17 @@ def jacobi_trudi(self): EXAMPLES:: + sage: # needs sage.modules sage: part = Partition([3,2,1]) - sage: jt = part.jacobi_trudi(); jt # needs sage.modules + sage: jt = part.jacobi_trudi(); jt [h[3] h[1] 0] [h[4] h[2] h[]] [h[5] h[3] h[1]] - sage: s = SymmetricFunctions(QQ).schur() # needs sage.modules - sage: h = SymmetricFunctions(QQ).homogeneous() # needs sage.modules - sage: h( s(part) ) # needs sage.modules + sage: s = SymmetricFunctions(QQ).schur() + sage: h = SymmetricFunctions(QQ).homogeneous() + sage: h( s(part) ) h[3, 2, 1] - h[3, 3] - h[4, 1, 1] + h[5, 1] - sage: jt.det() # needs sage.modules + sage: jt.det() h[3, 2, 1] - h[3, 3] - h[4, 1, 1] + h[5, 1] """ return SkewPartition([ self, [] ]).jacobi_trudi() @@ -5313,17 +5315,15 @@ def outline(self, variable=None): EXAMPLES:: - sage: [Partition([5,4]).outline()(x=i) for i in range(-10,11)] # needs sage.symbolic + sage: # needs sage.symbolic + sage: [Partition([5,4]).outline()(x=i) for i in range(-10,11)] [10, 9, 8, 7, 6, 5, 6, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10] - - sage: Partition([]).outline() # needs sage.symbolic + sage: Partition([]).outline() abs(x) - - sage: Partition([1]).outline() # needs sage.symbolic + sage: Partition([1]).outline() abs(x + 1) + abs(x - 1) - abs(x) - - sage: y = SR.var("y") # needs sage.symbolic - sage: Partition([6,5,1]).outline(variable=y) # needs sage.symbolic + sage: y = SR.var("y") + sage: Partition([6,5,1]).outline(variable=y) abs(y + 6) - abs(y + 5) + abs(y + 4) - abs(y + 3) + abs(y - 1) - abs(y - 2) + abs(y - 3) @@ -5392,17 +5392,18 @@ def dual_equivalence_graph(self, directed=False, coloring=None): EXAMPLES:: + sage: # needs sage.graphs sage: P = Partition([3,1,1]) - sage: G = P.dual_equivalence_graph() # needs sage.graphs - sage: G.edges(sort=True) # needs sage.graphs + sage: G = P.dual_equivalence_graph() + sage: G.edges(sort=True) [([[1, 2, 3], [4], [5]], [[1, 2, 4], [3], [5]], 3), ([[1, 2, 4], [3], [5]], [[1, 2, 5], [3], [4]], 4), ([[1, 2, 4], [3], [5]], [[1, 3, 4], [2], [5]], 2), ([[1, 2, 5], [3], [4]], [[1, 3, 5], [2], [4]], 2), ([[1, 3, 4], [2], [5]], [[1, 3, 5], [2], [4]], 4), ([[1, 3, 5], [2], [4]], [[1, 4, 5], [2], [3]], 3)] - sage: G = P.dual_equivalence_graph(directed=True) # needs sage.graphs - sage: G.edges(sort=True) # needs sage.graphs + sage: G = P.dual_equivalence_graph(directed=True) + sage: G.edges(sort=True) [([[1, 2, 4], [3], [5]], [[1, 2, 3], [4], [5]], 3), ([[1, 2, 5], [3], [4]], [[1, 2, 4], [3], [5]], 4), ([[1, 3, 4], [2], [5]], [[1, 2, 4], [3], [5]], 2), @@ -5419,14 +5420,13 @@ def dual_equivalence_graph(self, directed=False, coloring=None): sage: G = Partition([]).dual_equivalence_graph() sage: G.vertices(sort=False) [[]] - sage: P = Partition([3,1,1]) - sage: G = P.dual_equivalence_graph(coloring=lambda x: 'red') # needs sage.graphs - sage: G2 = P.dual_equivalence_graph(coloring={2: 'black', 3: 'blue', # needs sage.graphs + sage: G = P.dual_equivalence_graph(coloring=lambda x: 'red') + sage: G2 = P.dual_equivalence_graph(coloring={2: 'black', 3: 'blue', ....: 4: 'cyan', 5: 'grey'}) - sage: G is G2 # needs sage.graphs + sage: G is G2 False - sage: G == G2 # needs sage.graphs + sage: G == G2 True """ # We do some custom caching to not recreate the graph, but to make @@ -5495,9 +5495,9 @@ def specht_module(self, base_ring=None): EXAMPLES:: - sage: SM = Partition([2,2,1]).specht_module(QQ); SM # needs sage.modules + sage: SM = Partition([2,2,1]).specht_module(QQ); SM Specht module of [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0)] over Rational Field - sage: s = SymmetricFunctions(QQ).s() # needs sage.modules + sage: s = SymmetricFunctions(QQ).s() sage: s(SM.frobenius_image()) # needs sage.modules s[2, 2, 1] """ @@ -9025,32 +9025,33 @@ def number_of_partitions(n, algorithm='default'): TESTS:: + sage: # needs sage.libs.flint sage: n = 500 + randint(0,500) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1500 + randint(0,1500) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 1000000 + randint(0,1000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 True sage: n = 100000000 + randint(0,100000000) - sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # long time (4s on sage.math, 2011), needs sage.libs.flint + sage: number_of_partitions( n - (n % 385) + 369) % 385 == 0 # long time (4s on sage.math, 2011) True """ diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 5c57f0af88d..0504d42c56a 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -403,17 +403,18 @@ class Permutation(CombinatorialElement): From a pair of tableaux of the same shape. This uses the inverse of the Robinson-Schensted algorithm:: + sage: # needs sage.combinat sage: p = [[1, 4, 7], [2, 5], [3], [6]] sage: q = [[1, 2, 5], [3, 6], [4], [7]] - sage: P = Tableau(p) # needs sage.combinat - sage: Q = Tableau(q) # needs sage.combinat - sage: Permutation( (p, q) ) # needs sage.combinat + sage: P = Tableau(p) + sage: Q = Tableau(q) + sage: Permutation( (p, q) ) [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( [p, q] ) # needs sage.combinat + sage: Permutation( [p, q] ) [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( (P, Q) ) # needs sage.combinat + sage: Permutation( (P, Q) ) [3, 6, 5, 2, 7, 4, 1] - sage: Permutation( [P, Q] ) # needs sage.combinat + sage: Permutation( [P, Q] ) [3, 6, 5, 2, 7, 4, 1] TESTS:: @@ -4265,15 +4266,15 @@ def right_permutohedron_interval(self, other): TESTS:: - sage: # needs sage.modules - sage: Permutation([]).right_permutohedron_interval(Permutation([])) # needs sage.graphs + sage: # needs sage.graphs sage.modules + sage: Permutation([]).right_permutohedron_interval(Permutation([])) [[]] - sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) # needs sage.graphs + sage: Permutation([3, 1, 2]).right_permutohedron_interval(Permutation([3, 1, 2])) [[3, 1, 2]] - sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) # needs sage.graphs + sage: Permutation([1, 3, 2, 4]).right_permutohedron_interval(Permutation([3, 4, 2, 1])) [[3, 1, 4, 2], [3, 4, 1, 2], [3, 4, 2, 1], [1, 3, 4, 2], [1, 3, 2, 4], [3, 2, 4, 1], [3, 2, 1, 4], [3, 1, 2, 4]] - sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) # needs sage.graphs + sage: Permutation([2, 1, 4, 5, 3]).right_permutohedron_interval(Permutation([2, 5, 4, 1, 3])) [[2, 4, 5, 1, 3], [2, 4, 1, 5, 3], [2, 1, 4, 5, 3], [2, 1, 5, 4, 3], [2, 5, 1, 4, 3], [2, 5, 4, 1, 3]] sage: Permutation([2, 5, 4, 1, 3]).right_permutohedron_interval(Permutation([2, 1, 4, 5, 3])) @@ -4664,17 +4665,18 @@ def permutation_poset(self): EXAMPLES:: - sage: Permutation([3,1,5,4,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs + sage: # needs sage.combinat sage.graphs + sage: Permutation([3,1,5,4,2]).permutation_poset().cover_relations() [[(2, 1), (5, 2)], [(2, 1), (3, 5)], [(2, 1), (4, 4)], [(1, 3), (3, 5)], [(1, 3), (4, 4)]] - sage: Permutation([]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs + sage: Permutation([]).permutation_poset().cover_relations() [] - sage: Permutation([1,3,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs + sage: Permutation([1,3,2]).permutation_poset().cover_relations() [[(1, 1), (2, 3)], [(1, 1), (3, 2)]] - sage: Permutation([1,2]).permutation_poset().cover_relations() # needs sage.combinat sage.graphs + sage: Permutation([1,2]).permutation_poset().cover_relations() [[(1, 1), (2, 2)]] sage: P = Permutation([1,5,2,4,3]) @@ -5260,16 +5262,17 @@ def hyperoctahedral_double_coset_type(self): EXAMPLES:: + sage: # needs sage.combinat sage: p = Permutation([3, 4, 6, 1, 5, 7, 2, 8]) - sage: p.hyperoctahedral_double_coset_type() # needs sage.combinat + sage: p.hyperoctahedral_double_coset_type() [3, 1] - sage: all(p.hyperoctahedral_double_coset_type() == # needs sage.combinat + sage: all(p.hyperoctahedral_double_coset_type() == ....: p.inverse().hyperoctahedral_double_coset_type() ....: for p in Permutations(4)) True - sage: Permutation([]).hyperoctahedral_double_coset_type() # needs sage.combinat + sage: Permutation([]).hyperoctahedral_double_coset_type() [] - sage: Permutation([3,1,2]).hyperoctahedral_double_coset_type() # needs sage.combinat + sage: Permutation([3,1,2]).hyperoctahedral_double_coset_type() Traceback (most recent call last): ... ValueError: [3, 1, 2] is a permutation of odd size and has no coset-type @@ -5346,17 +5349,18 @@ def shifted_shuffle(self, other): EXAMPLES:: - sage: Permutation([]).shifted_shuffle(Permutation([])) # needs sage.graphs + sage: # needs sage.graphs sage.modules + sage: Permutation([]).shifted_shuffle(Permutation([])) [[]] - sage: Permutation([1, 2, 3]).shifted_shuffle(Permutation([1])) # needs sage.graphs sage.modules + sage: Permutation([1, 2, 3]).shifted_shuffle(Permutation([1])) [[4, 1, 2, 3], [1, 2, 3, 4], [1, 2, 4, 3], [1, 4, 2, 3]] - sage: Permutation([1, 2]).shifted_shuffle(Permutation([2, 1])) # needs sage.graphs sage.modules + sage: Permutation([1, 2]).shifted_shuffle(Permutation([2, 1])) [[4, 1, 3, 2], [4, 3, 1, 2], [1, 4, 3, 2], [1, 4, 2, 3], [1, 2, 4, 3], [4, 1, 2, 3]] - sage: Permutation([1]).shifted_shuffle([1]) # needs sage.graphs sage.modules + sage: Permutation([1]).shifted_shuffle([1]) [[2, 1], [1, 2]] sage: p = Permutation([3, 1, 5, 4, 2]) - sage: len(p.shifted_shuffle(Permutation([2, 1, 4, 3]))) # needs sage.graphs sage.modules + sage: len(p.shifted_shuffle(Permutation([2, 1, 4, 3]))) 126 The shifted shuffle product is associative. We can test this on an @@ -5918,14 +5922,16 @@ class Permutations_mset(Permutations): [2, 2, 1, 1, 2], [2, 2, 1, 2, 1], [2, 2, 2, 1, 1]] - sage: MS = MatrixSpace(GF(2), 2, 2) # needs sage.modules - sage: A = MS([1,0,1,1]) # needs sage.modules - sage: rows = A.rows() # needs sage.modules - sage: rows[0].set_immutable() # needs sage.modules - sage: rows[1].set_immutable() # needs sage.modules - sage: P = Permutations_mset(rows); P # needs sage.modules + + sage: # needs sage.modules + sage: MS = MatrixSpace(GF(2), 2, 2) + sage: A = MS([1,0,1,1]) + sage: rows = A.rows() + sage: rows[0].set_immutable() + sage: rows[1].set_immutable() + sage: P = Permutations_mset(rows); P Permutations of the multi-set [(1, 0), (1, 1)] - sage: sorted(P) # needs sage.modules + sage: sorted(P) [[(1, 0), (1, 1)], [(1, 1), (1, 0)]] """ @staticmethod @@ -6822,13 +6828,14 @@ def _element_constructor_(self, x, check=True): sage: P([2,3,1]) [2, 3, 1, 4, 5] - sage: G = SymmetricGroup(4) # needs sage.groups + sage: # needs sage.groups + sage: G = SymmetricGroup(4) sage: P = Permutations(4) - sage: x = G([4,3,1,2]); x # needs sage.groups + sage: x = G([4,3,1,2]); x (1,4,2,3) - sage: P(x) # needs sage.groups + sage: P(x) [4, 3, 1, 2] - sage: G(P(x)) # needs sage.groups + sage: G(P(x)) (1,4,2,3) sage: # needs sage.groups diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index e8fdb063a73..bad0c68576d 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -1161,12 +1161,14 @@ def cyclically_rotate(self, preserve_parent=False) -> PP: Plane partition [[3, 1, 1, 1], [1]] sage: PP == PP.cyclically_rotate().cyclically_rotate().cyclically_rotate() True - sage: PP = PlanePartitions([4,3,2]).random_element() # needs sage.graphs sage.modules - sage: PP.cyclically_rotate().parent() # needs sage.graphs sage.modules + + sage: # needs sage.graphs sage.modules + sage: PP = PlanePartitions([4,3,2]).random_element() + sage: PP.cyclically_rotate().parent() Plane partitions inside a 2 x 4 x 3 box - sage: PP = PlanePartitions([3,4,2])([[2,2,2,2],[2,2,2,2],[2,2,2,2]]) # needs sage.graphs sage.modules - sage: PP_rotated = PP.cyclically_rotate(preserve_parent=True) # needs sage.graphs sage.modules - sage: PP_rotated in PP_rotated.parent() # needs sage.graphs sage.modules + sage: PP = PlanePartitions([3,4,2])([[2,2,2,2],[2,2,2,2],[2,2,2,2]]) + sage: PP_rotated = PP.cyclically_rotate(preserve_parent=True) + sage: PP_rotated in PP_rotated.parent() False """ b = self._max_y diff --git a/src/sage/combinat/skew_partition.py b/src/sage/combinat/skew_partition.py index 38685dc7513..484b4ceb7f3 100644 --- a/src/sage/combinat/skew_partition.py +++ b/src/sage/combinat/skew_partition.py @@ -844,18 +844,19 @@ def cell_poset(self, orientation="SE"): EXAMPLES:: + sage: # needs sage.graphs sage: p = SkewPartition([[3,3,1], [2,1]]) - sage: Q = p.cell_poset(); Q # needs sage.graphs + sage: Q = p.cell_poset(); Q Finite poset containing 4 elements - sage: sorted(Q) # needs sage.graphs + sage: sorted(Q) [(0, 2), (1, 1), (1, 2), (2, 0)] - sage: sorted(Q.maximal_elements()) # needs sage.graphs + sage: sorted(Q.maximal_elements()) [(1, 2), (2, 0)] - sage: sorted(Q.minimal_elements()) # needs sage.graphs + sage: sorted(Q.minimal_elements()) [(0, 2), (1, 1), (2, 0)] - sage: sorted(Q.upper_covers((1, 1))) # needs sage.graphs + sage: sorted(Q.upper_covers((1, 1))) [(1, 2)] - sage: sorted(Q.upper_covers((0, 2))) # needs sage.graphs + sage: sorted(Q.upper_covers((0, 2))) [(1, 2)] sage: # needs sage.graphs diff --git a/src/sage/combinat/subsets_hereditary.py b/src/sage/combinat/subsets_hereditary.py index e40f66178c6..33b576e3cf1 100644 --- a/src/sage/combinat/subsets_hereditary.py +++ b/src/sage/combinat/subsets_hereditary.py @@ -72,23 +72,24 @@ def subsets_with_hereditary_property(f, X, max_obstruction_size=None, ncpus=1): have size 2. We can thus set ``max_obstruction_size=2``, which reduces the number of calls to `f` from 91 to 56:: + sage: # needs sage.graphs sage: num_calls = 0 - sage: g = graphs.PetersenGraph() # needs sage.graphs + sage: g = graphs.PetersenGraph() sage: def is_independent_set(S): ....: global num_calls ....: num_calls += 1 ....: return g.subgraph(S).size() == 0 - sage: l1 = list(subsets_with_hereditary_property(is_independent_set, # needs sage.graphs + sage: l1 = list(subsets_with_hereditary_property(is_independent_set, ....: g.vertices(sort=False))) - sage: num_calls # needs sage.graphs + sage: num_calls 91 sage: num_calls = 0 - sage: l2 = list(subsets_with_hereditary_property(is_independent_set, # needs sage.graphs + sage: l2 = list(subsets_with_hereditary_property(is_independent_set, ....: g.vertices(sort=False), ....: max_obstruction_size=2)) - sage: num_calls # needs sage.graphs + sage: num_calls 56 - sage: l1 == l2 # needs sage.graphs + sage: l1 == l2 True TESTS:: diff --git a/src/sage/combinat/tableau_tuple.py b/src/sage/combinat/tableau_tuple.py index 202682bf6cc..96fc0f0c51c 100644 --- a/src/sage/combinat/tableau_tuple.py +++ b/src/sage/combinat/tableau_tuple.py @@ -1072,15 +1072,16 @@ def row_stabilizer(self): EXAMPLES:: + sage: # needs sage.groups sage: t = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]) - sage: rs = t.row_stabilizer() # needs sage.groups - sage: rs.order() # needs sage.groups + sage: rs = t.row_stabilizer() + sage: rs.order() 24 - sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs # needs sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in rs True - sage: PermutationGroupElement([(1,4)]) in rs # needs sage.groups + sage: PermutationGroupElement([(1,4)]) in rs False - sage: rs.one().domain() # needs sage.groups + sage: rs.one().domain() [1, 2, 3, 4, 5, 6, 7, 8, 9] """ # Ensure that the permutations involve all elements of the @@ -1101,13 +1102,14 @@ def column_stabilizer(self): EXAMPLES:: + sage: # needs sage.groups sage: t = TableauTuple([[[1,2,3],[4,5]],[[6,7]],[[8],[9]]]) - sage: cs = t.column_stabilizer() # needs sage.groups - sage: cs.order() # needs sage.groups + sage: cs = t.column_stabilizer() + sage: cs.order() 8 - sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs # needs sage.groups + sage: PermutationGroupElement([(1,3,2),(4,5)]) in cs False - sage: PermutationGroupElement([(1,4)]) in cs # needs sage.groups + sage: PermutationGroupElement([(1,4)]) in cs True """ @@ -4322,8 +4324,9 @@ def __iter__(self): EXAMPLES:: + sage: # needs sage.libs.flint sage: stt = StandardTableauTuples() - sage: stt[0:8] # needs sage.libs.flint + sage: stt[0:8] [(), ([[1]]), ([], []), @@ -4332,11 +4335,11 @@ def __iter__(self): ([[1]], []), ([], [[1]]), ([], [], [])] - sage: stt[5] # needs sage.libs.flint + sage: stt[5] ([[1]], []) - sage: stt[50] # needs sage.libs.flint + sage: stt[50] ([], [[1, 3], [2]]) - sage: stt[47].parent() is stt # needs sage.libs.flint + sage: stt[47].parent() is stt True """ from sage.combinat.partition_tuple import PartitionTuples diff --git a/src/sage/combinat/tiling.py b/src/sage/combinat/tiling.py index 60de0696d3e..a543b50461d 100644 --- a/src/sage/combinat/tiling.py +++ b/src/sage/combinat/tiling.py @@ -108,9 +108,9 @@ Showing one solution:: - sage: solution = next(T.solve()) # long time + sage: solution = next(T.solve()) # long time sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time, needs sage.plot - sage: G.show(aspect_ratio=1, axes=False) # long time # needs sage.plot + sage: G.show(aspect_ratio=1, axes=False) # long time, needs sage.plot 1d Easy Example --------------- @@ -154,20 +154,20 @@ there are no solution for tiling a `8 \times 8` rectangular box:: sage: T = TilingSolver(L, box=(8,8)) - sage: T.number_of_solutions() # long time (2.5 s) + sage: T.number_of_solutions() # long time (2.5s) 0 If reflections are allowed, there are solutions. Solve the puzzle and show one solution:: sage: T = TilingSolver(L, box=(8,8), reflection=True) - sage: solution = next(T.solve()) # long time (7s) + sage: solution = next(T.solve()) # long time (7s) sage: G = sum([piece.show2d() for piece in solution], Graphics()) # long time (<1s), needs sage.plot - sage: G.show(aspect_ratio=1, axes=False) # long time (2s) # needs sage.plot + sage: G.show(aspect_ratio=1, axes=False) # long time (2s), needs sage.plot Compute the number of solutions:: - sage: T.number_of_solutions() # long time (2.6s) + sage: T.number_of_solutions() # long time (2.6s) 328 Create a animation of all the solutions:: @@ -197,13 +197,13 @@ Solve the puzzle and show one solution:: sage: T = TilingSolver(L, box=(8,8,1)) - sage: solution = next(T.solve()) # long time (8s) + sage: solution = next(T.solve()) # long time (8s) sage: G = sum([p.show3d(size=0.85) for p in solution], Graphics()) # long time (<1s), needs sage.plot - sage: G.show(aspect_ratio=1, viewer='tachyon') # long time (2s) # needs sage.plot + sage: G.show(aspect_ratio=1, viewer='tachyon') # long time (2s), needs sage.plot Let us compute the number of solutions:: - sage: T.number_of_solutions() # long time (3s) + sage: T.number_of_solutions() # long time (3s) 328 Donald Knuth example : the Y pentamino @@ -219,7 +219,7 @@ 10 sage: solution = next(T.solve()) sage: G = sum([p.show2d() for p in solution], Graphics()) # needs sage.plot - sage: G.show(aspect_ratio=1) # long time (2s) # needs sage.plot + sage: G.show(aspect_ratio=1) # long time (2s), needs sage.plot :: @@ -240,15 +240,14 @@ sage: from sage.combinat.tiling import Polyomino, TilingSolver sage: Y = Polyomino([(0,0),(1,0),(2,0),(3,0),(2,1)], color='yellow') sage: T = TilingSolver([Y], box=(15,15), reusable=True, reflection=True) - sage: a = T.animate(stop=40); a # long time, optional - imagemagick, needs sage.plot + sage: a = T.animate(stop=40); a # long time, optional - imagemagick, needs sage.plot Animation with 40 frames Incremental animation of the solutions (one piece is removed/added at a time):: - sage: a = T.animate('incremental', stop=40) # long time, optional - imagemagick, needs sage.plot - sage: a # long time, optional - imagemagick, needs sage.plot + sage: a = T.animate('incremental', stop=40); a # long time, optional - imagemagick, needs sage.plot Animation with 40 frames - sage: a.show(delay=50, iterations=1) # long time, optional - imagemagick, needs sage.plot + sage: a.show(delay=50, iterations=1) # long time, optional - imagemagick, needs sage.plot 5d Easy Example --------------- @@ -2453,8 +2452,7 @@ def animate(self, partial=None, stop=None, size=0.75, axes=False): Limit the number of frames:: - sage: a = T.animate('incremental', stop=13) # not tested # needs sage.plot - sage: a # not tested # needs sage.plot + sage: a = T.animate('incremental', stop=13); a # not tested # needs sage.plot Animation with 13 frames """ dimension = self._box._dimension From 59b2fbe3b50954bcd7826792f4c4bb1b2b218f0a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 11:58:26 -0700 Subject: [PATCH 422/494] src/sage/combinat/permutation.py: Fix up cherry-pick --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 0504d42c56a..7606cda659d 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -7279,7 +7279,7 @@ def algebra(self, base_ring, category=None): sage: A = P.algebra(QQ); A Symmetric group algebra of order 4 over Rational Field sage: A.category() - Join of Category of coxeter group algebras over Rational Field + Join of Category of Coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field From 9d26e03da0b817226fc57fcb81d56c564b6a8575 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 12:00:39 -0700 Subject: [PATCH 423/494] src/sage/combinat/path_tableaux/frieze.py: Fix doctest fix --- src/sage/combinat/path_tableaux/frieze.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/combinat/path_tableaux/frieze.py b/src/sage/combinat/path_tableaux/frieze.py index 1a09c1283fa..7e667743e4a 100644 --- a/src/sage/combinat/path_tableaux/frieze.py +++ b/src/sage/combinat/path_tableaux/frieze.py @@ -412,8 +412,9 @@ def plot(self, model='UHP'): def change_ring(self, R): r""" - Return ``self`` as a frieze pattern with coefficients in ``R`` - assuming there is a canonical coerce map from the base ring of ``self`` + Return ``self`` as a frieze pattern with coefficients in ``R``. + + This assumes that there is a canonical coerce map from the base ring of ``self`` to ``R``. EXAMPLES:: @@ -422,8 +423,7 @@ def change_ring(self, R): sage: fp.change_ring(RealField()) # needs sage.rings.real_mpfr [0.000000000000000, 1.00000000000000, ... 4.00000000000000, 1.00000000000000, 0.000000000000000] - - sage: fp.FriezePattern([1,2,7,5,3,7,4,1]).change_ring(GF(7)) # needs sage.rings.finite_rings + sage: fp.change_ring(GF(7)) Traceback (most recent call last): ... TypeError: no base extension defined From 108a6f8f1cfc811cdda754dd563b88b6f5214dde Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 12:07:10 -0700 Subject: [PATCH 424/494] src/sage/combinat/plane_partition.py: Fix cherry pick --- src/sage/combinat/plane_partition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index bad0c68576d..21b8bb84334 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -2868,7 +2868,7 @@ def __iter__(self) -> Iterator: EXAMPLES:: sage: list(PlanePartitions([4,4,2], symmetry='SSCPP')) # needs sage.modules - [Plane partition [[2, 2, 2, 1], [2, 2, 1], [2, 1], [1]], + [Plane partition [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], Plane partition [[2, 2, 2, 1], [2, 1, 1], [2, 1, 1], [1]], Plane partition [[2, 2, 1, 1], [2, 2, 1, 1], [1, 1], [1, 1]], Plane partition [[2, 2, 2, 1], [2, 2, 1], [2, 1], [1]], From a5e34371855141622e158e379259b0ab5dad31c4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 1 Nov 2023 12:07:23 -0700 Subject: [PATCH 425/494] src/sage/combinat/subword_complex*.p*: Fix placement of '# optional' --- src/sage/combinat/subword_complex.py | 33 ++++++++++++++----------- src/sage/combinat/subword_complex_c.pyx | 16 ++++++------ 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/sage/combinat/subword_complex.py b/src/sage/combinat/subword_complex.py index e92ad8ea237..117f5599f70 100644 --- a/src/sage/combinat/subword_complex.py +++ b/src/sage/combinat/subword_complex.py @@ -1961,13 +1961,13 @@ def _greedy_facet(Q, w, side="negative", n=None, pos=0, l=None, elems=[]): INPUT: - - `Q` -- a word - - `w` -- an element in the Coxeter group - - side -- optional, either 'negative' (default) or 'positive' - - n -- an integer (optional, defaults to the length of Q) - - pos -- an integer (optional, default 0) - - l -- an integer (optional, defaults to the length of w) - - elems -- a list (optional) + - ``Q`` -- a word + - ``w`` -- an element in the Coxeter group + - ``side`` -- optional, either ``'negative'`` (default) or ``'positive'`` + - ``n`` -- an integer (optional, defaults to the length of `Q`) + - ``pos`` -- an integer (optional, default 0) + - ``l`` -- an integer (optional, defaults to the length of `w`) + - ``elems`` -- a list (optional) OUTPUT: @@ -1975,8 +1975,9 @@ def _greedy_facet(Q, w, side="negative", n=None, pos=0, l=None, elems=[]): EXAMPLES:: - sage: # optional - gap3 sage: from sage.combinat.subword_complex import _greedy_facet + + sage: # optional - gap3 sage: W = ReflectionGroup(['A',2]) sage: Q = [1,2,1,2,1] sage: w = W.from_reduced_word([1, 2, 1]) @@ -2031,9 +2032,9 @@ def _extended_root_configuration_indices(W, Q, F): INPUT: - - `W` -- a Coxeter group - - `Q` -- a word representing an element of `W` - - `F` -- a facet of the subword complex + - ``W`` -- a Coxeter group + - ``Q`` -- a word representing an element of `W` + - ``F`` -- a facet of the subword complex OUTPUT: @@ -2041,8 +2042,9 @@ def _extended_root_configuration_indices(W, Q, F): EXAMPLES:: - sage: # optional - gap3 sage: from sage.combinat.subword_complex import _extended_root_configuration_indices + + sage: # optional - gap3 sage: W = ReflectionGroup(['A',2]) sage: w = W.from_reduced_word([1,2,1]) sage: Q = [1,2,1,2,1] @@ -2073,8 +2075,8 @@ def _greedy_flip_algorithm(Q, w): """ INPUT: - - Q -- a word in a Coxeter group W - - w -- an element of W + - ``Q`` -- a word in a Coxeter group `W` + - ``w`` -- an element of `W` OUTPUT: @@ -2082,8 +2084,9 @@ def _greedy_flip_algorithm(Q, w): EXAMPLES:: - sage: # optional - gap3 sage: from sage.combinat.subword_complex import _greedy_flip_algorithm + + sage: # optional - gap3 sage: W = ReflectionGroup(['A',2]) sage: Q = [1,2,1,2,1] sage: w = W.from_reduced_word([1,2,1]) diff --git a/src/sage/combinat/subword_complex_c.pyx b/src/sage/combinat/subword_complex_c.pyx index 2e1a17e907d..31a985f8675 100644 --- a/src/sage/combinat/subword_complex_c.pyx +++ b/src/sage/combinat/subword_complex_c.pyx @@ -7,20 +7,21 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices, INPUT: - - W -- a Coxeter group - - positions -- the positions of the elements of the facet - - extended_root_conf_indices -- also attached to the facet ? - - i -- the position where to flip - - side -- optional, can be 'positive', 'negative' or 'both' (default) + - ``W`` -- a Coxeter group + - ``positions`` -- the positions of the elements of the facet + - ``extended_root_conf_indices`` -- also attached to the facet ? + - ``i`` -- the position where to flip + - ``side`` -- optional, can be ``'positive'``, ``'negative'`` or ``'both'`` (default) OUTPUT: - the new position j that has replaced i + the new position `j` that has replaced `i` EXAMPLES:: - sage: # optional - gap3 sage: from sage.combinat.subword_complex_c import _flip_c + + sage: # optional - gap3 sage: W = ReflectionGroup(['A',2]) sage: w = W.from_reduced_word([1,2,1]) sage: SC = SubwordComplex([1,2,1,2,1], w) @@ -61,6 +62,7 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices, extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k], side="left") return j + cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1) noexcept: r""" Return the list of facets of the subword complex associated to the From 51928653d51d3056b8bc800b2475b7ea6fb6e784 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 2 Nov 2023 11:54:19 -0700 Subject: [PATCH 426/494] src/sage/combinat/partition.py: Reorder some doctests for more block tags --- src/sage/combinat/partition.py | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 5b8ea5220e2..9966a174cb1 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -6612,28 +6612,31 @@ def cardinality(self, algorithm='flint'): 7 sage: Partitions(5).cardinality(algorithm='gap') # needs sage.libs.gap 7 - sage: Partitions(5).cardinality(algorithm='pari') # needs sage.libs.pari - 7 - sage: number_of_partitions(5, algorithm='flint') # needs sage.libs.flint - 7 :: - sage: Partitions(10).cardinality() # needs sage.libs.flint - 42 - sage: Partitions(3).cardinality() # needs sage.libs.flint - 3 - sage: Partitions(10).cardinality() # needs sage.libs.flint - 42 - sage: Partitions(3).cardinality(algorithm='pari') # needs sage.libs.pari + sage: # needs sage.libs.flint + sage: Partitions(3).cardinality() 3 - sage: Partitions(10).cardinality(algorithm='pari') # needs sage.libs.pari + sage: number_of_partitions(5, algorithm='flint') + 7 + sage: Partitions(10).cardinality() 42 - sage: Partitions(40).cardinality() # needs sage.libs.flint + sage: Partitions(40).cardinality() 37338 - sage: Partitions(100).cardinality() # needs sage.libs.flint + sage: Partitions(100).cardinality() 190569292 + :: + + sage: # needs sage.libs.pari + sage: Partitions(3).cardinality(algorithm='pari') + 3 + sage: Partitions(5).cardinality(algorithm='pari') + 7 + sage: Partitions(10).cardinality(algorithm='pari') + 42 + A generating function for `p_n` is given by the reciprocal of Euler's function: @@ -7197,20 +7200,21 @@ def cardinality(self): Let's check the consistency of GAP's function and our own algorithm that actually generates the partitions:: + sage: # needs sage.libs.gap sage: ps = Partitions(15, parts_in=[1,2,3]) - sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap + sage: ps.cardinality() == len(ps.list()) True sage: ps = Partitions(15, parts_in=[]) - sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap + sage: ps.cardinality() == len(ps.list()) True sage: ps = Partitions(3000, parts_in=[50,100,500,1000]) - sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap + sage: ps.cardinality() == len(ps.list()) True sage: ps = Partitions(10, parts_in=[3,6,9]) - sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap + sage: ps.cardinality() == len(ps.list()) True sage: ps = Partitions(0, parts_in=[1,2]) - sage: ps.cardinality() == len(ps.list()) # needs sage.libs.gap + sage: ps.cardinality() == len(ps.list()) True """ # GAP complains if you give it an empty list From 0a8106440a6ab6dbef424b8ed2dc078451d12c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 27 Oct 2023 20:18:40 +0200 Subject: [PATCH 427/494] some fixes for pycodestyle E221 --- src/sage/crypto/lwe.py | 18 +-- src/sage/crypto/mq/sr.py | 6 +- src/sage/crypto/sboxes.py | 150 +++++++++--------- src/sage/databases/cremona.py | 2 +- src/sage/databases/findstat.py | 74 ++++----- src/sage/databases/knotinfo_db.py | 8 +- src/sage/interacts/library.py | 10 +- src/sage/interfaces/gap.py | 2 +- src/sage/interfaces/octave.py | 4 +- src/sage/interfaces/singular.py | 2 +- src/sage/interfaces/tides.py | 89 +++++------ src/sage/knots/knotinfo.py | 30 ++-- src/sage/knots/link.py | 18 +-- src/sage/manifolds/differentiable/chart.py | 2 +- .../differentiable/scalarfield_algebra.py | 3 +- src/sage/manifolds/scalarfield_algebra.py | 2 +- src/sage/sat/solvers/dimacs.py | 2 +- src/sage/structure/factorization_integer.py | 4 +- .../tensor/modules/tensor_free_submodule.py | 2 +- 19 files changed, 213 insertions(+), 215 deletions(-) diff --git a/src/sage/crypto/lwe.py b/src/sage/crypto/lwe.py index db675ebafaa..25bb2a3fb47 100644 --- a/src/sage/crypto/lwe.py +++ b/src/sage/crypto/lwe.py @@ -312,10 +312,10 @@ def __init__(self, n, q, D, secret_dist='uniform', m=None): ... IndexError: Number of available samples exhausted. """ - self.n = ZZ(n) + self.n = ZZ(n) self.m = m self.__i = 0 - self.K = IntegerModRing(q) + self.K = IntegerModRing(q) self.FM = FreeModule(self.K, n) self.D = D @@ -443,7 +443,7 @@ def __init__(self, n, delta=0.01, m=None): s = sqrt(s_t_bound*floor(q/4)) # Transform s into stddev stddev = s/sqrt(2*pi.n()) - D = DiscreteGaussianDistributionIntegerSampler(stddev) + D = DiscreteGaussianDistributionIntegerSampler(stddev) LWE.__init__(self, n=n, q=q, D=D, secret_dist='noise', m=m) @@ -484,11 +484,11 @@ def __init__(self, n, instance='key', m=None): raise TypeError("Parameter too small") n2 = n - C = 4/sqrt(2*pi) + C = 4/sqrt(2*pi) kk = floor((n2-2*log(n2, 2)**2)/5) n1 = (3*n2-5*kk) // 2 ke = floor((n1-2*log(n1, 2)**2)/5) - l = (3*n1-5*ke) // 2 - n2 + l = (3*n1-5*ke) // 2 - n2 sk = ceil((C*(n1+n2))**(ZZ(3)/2)) se = ceil((C*(n1+n2+l))**(ZZ(3)/2)) q = next_prime(max(ceil((4*sk)**(ZZ(n1+n2)/n1)), @@ -499,12 +499,12 @@ def __init__(self, n, instance='key', m=None): raise TypeError("Parameter too small") if instance == 'key': - D = UniformSampler(0, sk-1) + D = UniformSampler(0, sk-1) if m is None: m = n1 LWE.__init__(self, n=n2, q=q, D=D, secret_dist='noise', m=m) elif instance == 'encrypt': - D = UniformSampler(0, se-1) + D = UniformSampler(0, se-1) if m is None: m = n2+l LWE.__init__(self, n=n1, q=q, D=D, secret_dist='noise', m=m) @@ -544,11 +544,11 @@ def __init__(self, N, q, D, poly=None, secret_dist='uniform', m=None): sage: RingLWE(N=20, q=next_prime(800), D=D) # needs sage.libs.pari RingLWE(20, 809, Discrete Gaussian sampler for polynomials of degree < 8 with σ=3.000000 in each component, x^8 - x^6 + x^4 - x^2 + 1, 'uniform', None) """ - self.N = ZZ(N) + self.N = ZZ(N) self.n = euler_phi(N) self.m = m self.__i = 0 - self.K = IntegerModRing(q) + self.K = IntegerModRing(q) if self.n != D.n: raise ValueError("Noise distribution has dimensions %d != %d" % (D.n, self.n)) diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index f4ddf5c1844..c4293c5a0e2 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -1947,7 +1947,7 @@ def key_schedule_polynomials(self, i): si = Matrix(R, r*e, 1, self.vars("s", i-1, r, e)) rc = Matrix(R, r*e, 1, self.phi([a**(i-1)] + [k(0)]*(r-1)) ) - d = Matrix(R, r*e, 1, self.phi([self.sbox_constant()]*r) ) + d = Matrix(R, r*e, 1, self.phi([self.sbox_constant()]*r) ) sbox = [] @@ -3123,8 +3123,8 @@ def _inversion_polynomials_single_sbox(self, x=None, w=None, biaffine_only=None, l.append( (Cw * x + o).list()[:-1] ) else: l.append( (Cw * x + o).list() ) - l.append( (Cw * S * x + x).list() ) - l.append( (Cx * S * w + w).list() ) + l.append( (Cw * S * x + x).list() ) + l.append( (Cx * S * w + w).list() ) if not biaffine_only: l.append( ((Cw * S**2 + Cx*S)*x).list() ) l.append( ((Cx * S**2 + Cw*S)*w).list() ) diff --git a/src/sage/crypto/sboxes.py b/src/sage/crypto/sboxes.py index 27ca13fbcc3..749593c401b 100644 --- a/src/sage/crypto/sboxes.py +++ b/src/sage/crypto/sboxes.py @@ -220,8 +220,8 @@ def carlet_tang_tang_liao(n, c=None, bf=None): if n < 6 or n % 2: raise TypeError("n >= 6 has to be even") - K = GF(2**(n-1)) - L = GF(2**n) + K = GF((2, n - 1)) + L = GF((2, n)) if c is None: c = K.random_element() @@ -392,7 +392,7 @@ def monomial_function(n, e): from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.finite_rings.finite_field_constructor import GF - base_ring = GF(2**n, name='x') + base_ring = GF((2, n), name='x') R = PolynomialRing(base_ring, name='X') X = R.gen() return SBox(X**e) @@ -516,18 +516,18 @@ def monomial_function(n, e): 112,130, 44,236,179, 39,192,229,228,133, 87, 53,234, 12,174, 65, 35,239,107,147, 69, 25,165, 33,237, 14, 79, 78, 29,101,146,189, 134,184,175,143,124,235, 31,206, 62, 48,220, 95, 94,197, 11, 26, - 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, + 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, 139, 13,154,102,251,204,176, 45,116, 18, 43, 32,240,177,132,153, - 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, + 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, 20, 88, 58, 97,222, 27, 17, 28, 50, 15,156, 22, 83, 24,242, 34, - 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, + 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, 170,208,160,125,161,137, 98,151, 84, 91, 30,149,224,255,100,210, - 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, - 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, + 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, + 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, 82,155,216, 38,200, 55,198, 59,129,150,111, 75, 19,190, 99, 46, 233,121,167,140,159,110,188,142, 41,245,249,182, 47,253,180, 89, - 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, - 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, + 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, + 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, 64, 40,211,123,187,201, 67,193, 21,227,173,244,119,199,128,158]) # source: https://www.schneier.com/academic/paperfiles/paper-cmea.pdf @@ -1063,20 +1063,20 @@ def monomial_function(n, e): newDES = SBox([ 32,137,239,188,102,125,221, 72,212, 68, 81, 37, 86,237,147,149, 70,229, 17,124,115,207, 33, 20,122,143, 25,215, 51,183,138,142, - 146,211,110,173, 1,228,189, 14,103, 78,162, 36,253,167,116,255, - 158, 45,185, 50, 98,168,250,235, 54,141,195,247,240, 63,148, 2, + 146,211,110,173, 1,228,189, 14,103, 78,162, 36,253,167,116,255, + 158, 45,185, 50, 98,168,250,235, 54,141,195,247,240, 63,148, 2, 224,169,214,180, 62, 22,117,108, 19,172,161,159,160, 47, 43,171, - 194,175,178, 56,196,112, 23,220, 89, 21,164,130,157, 8, 85,251, + 194,175,178, 56,196,112, 23,220, 89, 21,164,130,157, 8, 85,251, 216, 44, 94,179,226, 38, 90,119, 40,202, 34,206, 35, 69,231,246, - 29,109, 74, 71,176, 6, 60,145, 65, 13, 77,151, 12,127, 95,199, - 57,101, 5,232,150,210,129, 24,181, 10,121,187, 48,193,139,252, + 29,109, 74, 71,176, 6, 60,145, 65, 13, 77,151, 12,127, 95,199, + 57,101, 5,232,150,210,129, 24,181, 10,121,187, 48,193,139,252, 219, 64, 88,233, 96,128, 80, 53,191,144,218, 11,106,132,155,104, 91,136, 31, 42,243, 66,126,135, 30, 26, 87,186,182,154,242,123, 82,166,208, 39,152,190,113,205,114,105,225, 84, 73,163, 99,111, - 204, 61,200,217,170, 15,198, 28,192,254,134,234,222, 7,236,248, - 201, 41,177,156, 92,131, 67,249,245,184,203, 9,241, 0, 27, 46, - 133,174, 75, 18, 93,209,100,120, 76,213, 16, 83, 4,107,140, 52, - 58, 55, 3,244, 97,197,238,227,118, 49, 79,230,223,165,153, 59]) + 204, 61,200,217,170, 15,198, 28,192,254,134,234,222, 7,236,248, + 201, 41,177,156, 92,131, 67,249,245,184,203, 9,241, 0, 27, 46, + 133,174, 75, 18, 93,209,100,120, 76,213, 16, 83, 4,107,140, 52, + 58, 55, 3,244, 97,197,238,227,118, 49, 79,230,223,165,153, 59]) Picaro = SBox([ 0x08,0x0c,0x03,0x06,0x06,0x04,0x05,0x06,0x05,0x04,0x0c,0x0c,0x04,0x03,0x05,0x03, @@ -1097,22 +1097,22 @@ def monomial_function(n, e): 0x01,0xfd,0x75,0x8a,0xea,0x1c,0x9f,0x6a,0x5f,0xac,0x2d,0xdd,0xbc,0x45,0xcf,0x35]) Safer = SBox([ - 1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63, - 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247, - 64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, - 255, 167, 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, - 241, 51, 239, 218, 44, 181, 178, 43, 136, 209, 153, 203, 140, 132, 29, 20, - 129, 151, 113, 202, 95, 163, 139, 87, 60, 130, 196, 82, 92, 28, 232, 160, - 4, 180, 133, 74, 246, 19, 84, 182, 223, 12, 26, 142, 222, 224, 57, 252, - 32, 155, 36, 78, 169, 152, 158, 171, 242, 96, 208, 108, 234, 250, 199, 217, - 0, 212, 31, 110, 67, 188, 236, 83, 137, 254, 122, 93, 73, 201, 50, 194, - 249, 154, 248, 109, 22, 219, 89, 150, 68, 233, 205, 230, 70, 66, 143, 10, - 193, 204, 185, 101, 176, 210, 198, 172, 30, 65, 98, 41, 46, 14, 116, 80, - 2, 90, 195, 37, 123, 138, 42, 91, 240, 6, 13, 71, 111, 112, 157, 126, - 16, 206, 18, 39, 213, 76, 79, 214, 121, 48, 104, 54, 117, 125, 228, 237, - 128, 106, 144, 55, 162, 94, 118, 170, 197, 127, 61, 175, 165, 229, 25, 97, - 253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5, - 225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40]) + 1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63, + 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247, + 64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, + 255, 167, 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, + 241, 51, 239, 218, 44, 181, 178, 43, 136, 209, 153, 203, 140, 132, 29, 20, + 129, 151, 113, 202, 95, 163, 139, 87, 60, 130, 196, 82, 92, 28, 232, 160, + 4, 180, 133, 74, 246, 19, 84, 182, 223, 12, 26, 142, 222, 224, 57, 252, + 32, 155, 36, 78, 169, 152, 158, 171, 242, 96, 208, 108, 234, 250, 199, 217, + 0, 212, 31, 110, 67, 188, 236, 83, 137, 254, 122, 93, 73, 201, 50, 194, + 249, 154, 248, 109, 22, 219, 89, 150, 68, 233, 205, 230, 70, 66, 143, 10, + 193, 204, 185, 101, 176, 210, 198, 172, 30, 65, 98, 41, 46, 14, 116, 80, + 2, 90, 195, 37, 123, 138, 42, 91, 240, 6, 13, 71, 111, 112, 157, 126, + 16, 206, 18, 39, 213, 76, 79, 214, 121, 48, 104, 54, 117, 125, 228, 237, + 128, 106, 144, 55, 162, 94, 118, 170, 197, 127, 61, 175, 165, 229, 25, 97, + 253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5, + 225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40]) Scream = SBox([ 0x20,0x8D,0xB2,0xDA,0x33,0x35,0xA6,0xFF,0x7A,0x52,0x6A,0xC6,0xA4,0xA8,0x51,0x23, @@ -1433,8 +1433,8 @@ def monomial_function(n, e): 20,26,7,31,19,12,10,15,22,30,13,14,4,24,9, 18,27,11,1,21,6,16,2,28,23,5,8,3,0,17,29,25]) -Shamash = SBox([16, 14, 13, 2, 11, 17, 21, 30, 7, 24, 18, 28, 26, 1, 12, 6, - 31, 25, 0, 23, 20, 22, 8, 27, 4, 3, 19, 5, 9, 10, 29, 15]) +Shamash = SBox([16, 14, 13, 2, 11, 17, 21, 30, 7, 24, 18, 28, 26, 1, 12, 6, + 31, 25, 0, 23, 20, 22, 8, 27, 4, 3, 19, 5, 9, 10, 29, 15]) SYCON = SBox([8, 19, 30, 7, 6, 25, 16, 13, 22, 15, 3, 24, 17, 12, 4, 27, 11, 0, 29, 20, 1, 14, 23, 26, 28, 21, 9, 2, 31, 18, 10, 5]) @@ -1444,8 +1444,8 @@ def monomial_function(n, e): Elephant = SBox([0xE, 0xD, 0xB, 0x0, 0x2, 0x1, 0x4, 0xF, 0x7, 0xA, 0x8, 0x5, 0x9, 0xC, 0x3, 0x6]) -KNOT = SBox([0x4, 0x0, 0xA, 0x7, 0xB, 0xE, 0x1, 0xD, 0x9, 0xF, 0x6, 0x8, - 0x5, 0x2, 0xC, 0x3]) +KNOT = SBox([0x4, 0x0, 0xA, 0x7, 0xB, 0xE, 0x1, 0xD, 0x9, 0xF, 0x6, 0x8, + 0x5, 0x2, 0xC, 0x3]) Pyjamask_4 = SBox([0x2, 0xd, 0x3, 0x9, 0x7, 0xb, 0xa, 0x6, 0xe, 0x0, 0xf, 0x4, 0x8, 0x5, 0x1, 0xc]) SATURNIN_0 = SBox([0x0, 0x6, 0xE, 0x1, 0xF, 0x4, 0x7, 0xD, 0x9, 0x8, 0xC, 0x5, @@ -1457,9 +1457,9 @@ def monomial_function(n, e): Clyde = Spook Shadow = Spook TRIFLE = SBox([0x0, 0xC, 0x9, 0x7, 0x3, 0x5, 0xE, 0x4, 0x6, 0xB, 0xA, 0x2, - 0xD, 0x1, 0x8, 0xF]) + 0xD, 0x1, 0x8, 0xF]) Yarara = SBox([0x4, 0x7, 0x1, 0xC, 0x2, 0x8, 0xF, 0x3, 0xD, 0xA, 0xe, 0x9, 0xB, - 0x6, 0x5, 0x0]) + 0x6, 0x5, 0x0]) Coral = Yarara # DES @@ -1570,44 +1570,44 @@ def monomial_function(n, e): SERPENT_S7 = SBox([1,13,15,0,14,8,2,11,7,4,12,10,9,3,5,6]) # Other Block ciphers -KLEIN = SBox([0x7,0x4,0xA,0x9,0x1,0xF,0xB,0x0,0xC,0x3,0x2,0x6,0x8,0xE,0xD,0x5]) -MIBS = SBox([4,15,3,8,13,10,12,0,11,5,7,14,2,6,1,9]) -Midori_Sb0 = SBox([0xc,0xa,0xd,0x3,0xe,0xb,0xf,0x7,0x8,0x9,0x1,0x5,0x0,0x2,0x4,0x6]) +KLEIN = SBox([0x7,0x4,0xA,0x9,0x1,0xF,0xB,0x0,0xC,0x3,0x2,0x6,0x8,0xE,0xD,0x5]) +MIBS = SBox([4,15,3,8,13,10,12,0,11,5,7,14,2,6,1,9]) +Midori_Sb0 = SBox([0xc,0xa,0xd,0x3,0xe,0xb,0xf,0x7,0x8,0x9,0x1,0x5,0x0,0x2,0x4,0x6]) MANTIS = Midori_Sb0 CRAFT = Midori_Sb0 -Midori_Sb1 = SBox([0x1,0x0,0x5,0x3,0xe,0x2,0xf,0x7,0xd,0xa,0x9,0xb,0xc,0x8,0x4,0x6]) -Noekeon = SBox([0x7,0xA,0x2,0xC,0x4,0x8,0xF,0x0,0x5,0x9,0x1,0xE,0x3,0xD,0xB,0x6]) -Piccolo = SBox([0xe,0x4,0xb,0x2,0x3,0x8,0x0,0x9,0x1,0xa,0x7,0xf,0x6,0xc,0x5,0xd]) -Panda = SBox([0x0,0x1,0x3,0x2,0xf,0xc,0x9,0xb,0xa,0x6,0x8,0x7,0x5,0xe,0xd,0x4]) -PRESENT = SBox([0xC,0x5,0x6,0xB,0x9,0x0,0xA,0xD,0x3,0xE,0xF,0x8,0x4,0x7,0x1,0x2]) -CiliPadi = PRESENT -PHOTON = PRESENT -ORANGE = PHOTON -GIFT = SBox([0x1,0xa,0x4,0xc,0x6,0xf,0x3,0x9,0x2,0xd,0xb,0x7,0x5,0x0,0x8,0xe]) -HYENA = GIFT -Fountain_1 = GIFT -TGIF = GIFT -Fountain_2 = SBox([0x9, 0x5, 0x6, 0xD, 0x8, 0xA, 0x7, 0x2, 0xE, 0x4, 0xC, - 0x1, 0xF, 0x0, 0xB, 0x3]) -Fountain_3 = SBox([0x9, 0xD, 0xE, 0x5, 0x8, 0xA, 0xF, 0x2, 0x6, 0xC, 0x4, - 0x1, 0x7, 0x0, 0xB, 0x3]) -Fountain_4 = SBox([0xB, 0xF, 0xE, 0x8, 0x7, 0xA, 0x2, 0xD, 0x9, 0x3, 0x4, - 0xC, 0x5, 0x0, 0x6, 0x1]) -Pride = SBox([0x0,0x4,0x8,0xf,0x1,0x5,0xe,0x9,0x2,0x7,0xa,0xc,0xb,0xd,0x6,0x3]) -PRINCE = SBox([0xB,0xF,0x3,0x2,0xA,0xC,0x9,0x1,0x6,0x7,0x8,0x0,0xE,0x5,0xD,0x4]) -Prost = Pride +Midori_Sb1 = SBox([0x1,0x0,0x5,0x3,0xe,0x2,0xf,0x7,0xd,0xa,0x9,0xb,0xc,0x8,0x4,0x6]) +Noekeon = SBox([0x7,0xA,0x2,0xC,0x4,0x8,0xF,0x0,0x5,0x9,0x1,0xE,0x3,0xD,0xB,0x6]) +Piccolo = SBox([0xe,0x4,0xb,0x2,0x3,0x8,0x0,0x9,0x1,0xa,0x7,0xf,0x6,0xc,0x5,0xd]) +Panda = SBox([0x0,0x1,0x3,0x2,0xf,0xc,0x9,0xb,0xa,0x6,0x8,0x7,0x5,0xe,0xd,0x4]) +PRESENT = SBox([0xC,0x5,0x6,0xB,0x9,0x0,0xA,0xD,0x3,0xE,0xF,0x8,0x4,0x7,0x1,0x2]) +CiliPadi = PRESENT +PHOTON = PRESENT +ORANGE = PHOTON +GIFT = SBox([0x1,0xa,0x4,0xc,0x6,0xf,0x3,0x9,0x2,0xd,0xb,0x7,0x5,0x0,0x8,0xe]) +HYENA = GIFT +Fountain_1 = GIFT +TGIF = GIFT +Fountain_2 = SBox([0x9, 0x5, 0x6, 0xD, 0x8, 0xA, 0x7, 0x2, 0xE, 0x4, 0xC, + 0x1, 0xF, 0x0, 0xB, 0x3]) +Fountain_3 = SBox([0x9, 0xD, 0xE, 0x5, 0x8, 0xA, 0xF, 0x2, 0x6, 0xC, 0x4, + 0x1, 0x7, 0x0, 0xB, 0x3]) +Fountain_4 = SBox([0xB, 0xF, 0xE, 0x8, 0x7, 0xA, 0x2, 0xD, 0x9, 0x3, 0x4, + 0xC, 0x5, 0x0, 0x6, 0x1]) +Pride = SBox([0x0,0x4,0x8,0xf,0x1,0x5,0xe,0x9,0x2,0x7,0xa,0xc,0xb,0xd,0x6,0x3]) +PRINCE = SBox([0xB,0xF,0x3,0x2,0xA,0xC,0x9,0x1,0x6,0x7,0x8,0x0,0xE,0x5,0xD,0x4]) +Prost = Pride Qarma_sigma0 = SBox([0, 14, 2, 10, 9, 15, 8, 11, 6, 4, 3, 7, 13, 12, 1, 5]) Qarma_sigma1 = SBox([10, 13, 14, 6, 15, 7, 3, 5, 9, 8, 0, 12, 11, 1, 2, 4]) -Qameleon = Qarma_sigma1 +Qameleon = Qarma_sigma1 Qarma_sigma2 = SBox([11, 6, 8, 15, 12, 0, 9, 14, 3, 7, 4, 5, 13, 2, 1, 10]) -REC_0 = SBox([0x9,0x4,0xF,0xA,0xE,0x1,0x0,0x6,0xC,0x7,0x3,0x8,0x2,0xB,0x5,0xD]) -Rectangle = SBox([0x6,0x5,0xC,0xA,0x1,0xE,0x7,0x9,0xB,0x0,0x3,0xD,0x8,0xF,0x4,0x2]) -SC2000_4 = SBox([2,5,10,12,7,15,1,11,13,6,0,9,4,8,3,14]) -SKINNY_4 = SBox([0xc,0x6,0x9,0x0,0x1,0xa,0x2,0xb,0x3,0x8,0x5,0xd,0x4,0xe,0x7,0xf]) +REC_0 = SBox([0x9,0x4,0xF,0xA,0xE,0x1,0x0,0x6,0xC,0x7,0x3,0x8,0x2,0xB,0x5,0xD]) +Rectangle = SBox([0x6,0x5,0xC,0xA,0x1,0xE,0x7,0x9,0xB,0x0,0x3,0xD,0x8,0xF,0x4,0x2]) +SC2000_4 = SBox([2,5,10,12,7,15,1,11,13,6,0,9,4,8,3,14]) +SKINNY_4 = SBox([0xc,0x6,0x9,0x0,0x1,0xa,0x2,0xb,0x3,0x8,0x5,0xd,0x4,0xe,0x7,0xf]) ForkSkinny_4 = SKINNY_4 -Remus_4 = SKINNY_4 +Remus_4 = SKINNY_4 -TWINE = SBox([0xC,0x0,0xF,0xA,0x2,0xB,0x9,0x5,0x8,0x3,0xD,0x7,0x1,0xE,0x6,0x4]) +TWINE = SBox([0xC,0x0,0xF,0xA,0x2,0xB,0x9,0x5,0x8,0x3,0xD,0x7,0x1,0xE,0x6,0x4]) # Sub-components of hash functions Luffa_v1 = SBox([0x7,0xd,0xb,0xa,0xc,0x4,0x8,0x3,0x5,0xf,0x6,0x0,0x9,0x1,0x2,0xe]) @@ -1654,10 +1654,10 @@ def monomial_function(n, e): Twofish_Q1_T1 = SBox([0x1,0xE,0x2,0xB,0x4,0xC,0x3,0x7,0x6,0xD,0xA,0x5,0xF,0x9,0x0,0x8]) Twofish_Q1_T2 = SBox([0x4,0xC,0x7,0x5,0x1,0x6,0x9,0xA,0x0,0xE,0xD,0x8,0x2,0xB,0x3,0xF]) Twofish_Q1_T3 = SBox([0xB,0x9,0x5,0x1,0xC,0x3,0xD,0xE,0x6,0x4,0x7,0xF,0x2,0x0,0x8,0xA]) -Kuznyechik_nu0 = SBox([0x2,0x5,0x3,0xb,0x6,0x9,0xe,0xa,0x0,0x4,0xf,0x1,0x8,0xd,0xc,0x7]) -Kuznyechik_nu1 = SBox([0x7,0x6,0xc,0x9,0x0,0xf,0x8,0x1,0x4,0x5,0xb,0xe,0xd,0x2,0x3,0xa]) +Kuznyechik_nu0 = SBox([0x2,0x5,0x3,0xb,0x6,0x9,0xe,0xa,0x0,0x4,0xf,0x1,0x8,0xd,0xc,0x7]) +Kuznyechik_nu1 = SBox([0x7,0x6,0xc,0x9,0x0,0xf,0x8,0x1,0x4,0x5,0xb,0xe,0xd,0x2,0x3,0xa]) Kuznyechik_sigma = SBox([0xc,0xd,0x0,0x4,0x8,0xb,0xa,0xe,0x3,0x9,0x5,0x2,0xf,0x1,0x6,0x7]) -Kuznyechik_phi = SBox([0xb,0x2,0xb,0x8,0xc,0x4,0x1,0xc,0x6,0x3,0x5,0x8,0xe,0x3,0x6,0xb]) +Kuznyechik_phi = SBox([0xb,0x2,0xb,0x8,0xc,0x4,0x1,0xc,0x6,0x3,0x5,0x8,0xe,0x3,0x6,0xb]) Optimal_S0 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 12, 9, 3, 14, 10, 5]) Optimal_S1 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 5, 9, 10, 12]) Optimal_S2 = SBox([0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 10, 12, 5, 9]) diff --git a/src/sage/databases/cremona.py b/src/sage/databases/cremona.py index a74eeac74d2..3e1615e5fd4 100644 --- a/src/sage/databases/cremona.py +++ b/src/sage/databases/cremona.py @@ -1623,7 +1623,7 @@ def _init_allbsd(self, ftpdata, largest_conductor=0): curve_data = [] class_data = [] for L in open(ftpdata + "/" + F).readlines(): - N, iso, num, eqn, rank, tor, cp, om, L, reg, sha = L.split() + N, iso, num, eqn, rank, tor, cp, om, L, reg, sha = L.split() if largest_conductor and int(N) > largest_conductor: break cls = N+iso diff --git a/src/sage/databases/findstat.py b/src/sage/databases/findstat.py index 86ab944744a..5b8455a49a2 100644 --- a/src/sage/databases/findstat.py +++ b/src/sage/databases/findstat.py @@ -263,20 +263,20 @@ def mapping(sigma): ###################################################################### # the FindStat URLs -FINDSTAT_URL = 'https://www.findstat.org/' -FINDSTAT_API = FINDSTAT_URL + "api/" -FINDSTAT_API_COLLECTIONS = FINDSTAT_API + 'CollectionsDatabase/' -FINDSTAT_API_STATISTICS = FINDSTAT_API + 'StatisticsDatabase/' -FINDSTAT_API_MAPS = FINDSTAT_API + 'MapsDatabase/' - -FINDSTAT_URL_LOGIN = FINDSTAT_URL + "?action=login" -FINDSTAT_URL_COLLECTIONS = FINDSTAT_URL + 'CollectionsDatabase/' -FINDSTAT_URL_STATISTICS = FINDSTAT_URL + 'StatisticsDatabase/' +FINDSTAT_URL = 'https://www.findstat.org/' +FINDSTAT_API = FINDSTAT_URL + "api/" +FINDSTAT_API_COLLECTIONS = FINDSTAT_API + 'CollectionsDatabase/' +FINDSTAT_API_STATISTICS = FINDSTAT_API + 'StatisticsDatabase/' +FINDSTAT_API_MAPS = FINDSTAT_API + 'MapsDatabase/' + +FINDSTAT_URL_LOGIN = FINDSTAT_URL + "?action=login" +FINDSTAT_URL_COLLECTIONS = FINDSTAT_URL + 'CollectionsDatabase/' +FINDSTAT_URL_STATISTICS = FINDSTAT_URL + 'StatisticsDatabase/' FINDSTAT_URL_EDIT_STATISTIC = FINDSTAT_URL + 'EditStatistic/' -FINDSTAT_URL_NEW_STATISTIC = FINDSTAT_URL + 'NewStatistic/' -FINDSTAT_URL_MAPS = FINDSTAT_URL + 'MapsDatabase/' -FINDSTAT_URL_EDIT_MAP = FINDSTAT_URL + 'EditMap/' -FINDSTAT_URL_NEW_MAP = FINDSTAT_URL + 'NewMap/' +FINDSTAT_URL_NEW_STATISTIC = FINDSTAT_URL + 'NewStatistic/' +FINDSTAT_URL_MAPS = FINDSTAT_URL + 'MapsDatabase/' +FINDSTAT_URL_EDIT_MAP = FINDSTAT_URL + 'EditMap/' +FINDSTAT_URL_NEW_MAP = FINDSTAT_URL + 'NewMap/' ###################################################################### # the number of values FindStat allows to search for at most @@ -297,9 +297,9 @@ def mapping(sigma): FINDSTAT_STATISTIC_REGEXP = '^St[0-9]{6}$' FINDSTAT_MAP_REGEXP = '^Mp[0-9]{5}$' FINDSTAT_COLLECTION_REGEXP = '^Cc[0-9]{4}$' -FINDSTAT_STATISTIC_PADDED_IDENTIFIER = "St%06d" -FINDSTAT_MAP_PADDED_IDENTIFIER = "Mp%05d" -FINDSTAT_COLLECTION_PADDED_IDENTIFIER = "Cc%04d" +FINDSTAT_STATISTIC_PADDED_IDENTIFIER = "St%06d" +FINDSTAT_MAP_PADDED_IDENTIFIER = "Mp%05d" +FINDSTAT_COLLECTION_PADDED_IDENTIFIER = "Cc%04d" ###################################################################### @@ -333,7 +333,7 @@ def __init__(self): The Combinatorial Statistic Finder (https://www.findstat.org/) """ # user credentials if provided - self._user_name = "" + self._user_name = "" self._user_email = "" self._allow_execution = False @@ -384,7 +384,7 @@ def set_user(self, name=None, email=None): raise ValueError("the given name (%s) should be a string" % name) if not isinstance(email, str): raise ValueError("the given email (%s) should be a string" % email) - self._user_name = name + self._user_name = name self._user_email = email def user_name(self): @@ -2375,14 +2375,14 @@ def submit(self, max_values=FINDSTAT_MAX_SUBMISSION_VALUES): """ args = {} args["OriginalStatistic"] = self.id_str() - args["Domain"] = self.domain().id_str() - args["Values"] = self.first_terms_str(max_values=max_values) - args["Description"] = self.description() - args["References"] = self.references_raw() - args["Code"] = self.code() - args["SageCode"] = self.sage_code() - args["CurrentAuthor"] = FindStat().user_name() - args["CurrentEmail"] = FindStat().user_email() + args["Domain"] = self.domain().id_str() + args["Values"] = self.first_terms_str(max_values=max_values) + args["Description"] = self.description() + args["References"] = self.references_raw() + args["Code"] = self.code() + args["SageCode"] = self.sage_code() + args["CurrentAuthor"] = FindStat().user_name() + args["CurrentEmail"] = FindStat().user_email() if not self.id(): url = FINDSTAT_NEWSTATISTIC_FORM_HEADER % FINDSTAT_URL_NEW_STATISTIC @@ -3212,16 +3212,16 @@ def submit(self): sage: s.reset() # optional -- internet """ args = dict() - args["OriginalMap"] = self.id_str() - args["Domain"] = self.domain().id_str() - args["Codomain"] = self.codomain().id_str() - args["Name"] = self.name() - args["Description"] = self.description() - args["References"] = self.references_raw() - args["Properties"] = self.properties_raw() - args["SageCode"] = self.sage_code() - args["CurrentAuthor"] = FindStat().user_name() - args["CurrentEmail"] = FindStat().user_email() + args["OriginalMap"] = self.id_str() + args["Domain"] = self.domain().id_str() + args["Codomain"] = self.codomain().id_str() + args["Name"] = self.name() + args["Description"] = self.description() + args["References"] = self.references_raw() + args["Properties"] = self.properties_raw() + args["SageCode"] = self.sage_code() + args["CurrentAuthor"] = FindStat().user_name() + args["CurrentEmail"] = FindStat().user_email() if not self.id(): url = FINDSTAT_NEWMAP_FORM_HEADER % FINDSTAT_URL_NEW_MAP @@ -3930,7 +3930,7 @@ def _finite_irreducible_cartan_types_by_rank(n): sage: _finite_irreducible_cartan_types_by_rank(2) [['A', 2], ['B', 2], ['G', 2]] """ - cartan_types = [CartanType(['A',n])] + cartan_types = [CartanType(['A',n])] if n >= 2: cartan_types += [CartanType(['B',n])] if n >= 3: diff --git a/src/sage/databases/knotinfo_db.py b/src/sage/databases/knotinfo_db.py index 2828c3ace45..df0b8310456 100644 --- a/src/sage/databases/knotinfo_db.py +++ b/src/sage/databases/knotinfo_db.py @@ -350,18 +350,18 @@ def __init__(self, install=False): 'linkinfo_data_complete']> """ # some constants - self._names_column = 'name' + self._names_column = 'name' self._components_column = 'components' - self._knot_prefix = 'K' + self._knot_prefix = 'K' self._knot_list = None self._link_list = None - self._demo = None + self._demo = None self._num_knots = None from sage.features.databases import DatabaseKnotInfo from sage.env import DOT_SAGE - self._feature = DatabaseKnotInfo() + self._feature = DatabaseKnotInfo() self._sobj_path = os.path.join(DOT_SAGE, 'knotinfo') def create_filecache(self, force=False): diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py index 83b5a93c006..16fadc5b594 100644 --- a/src/sage/interacts/library.py +++ b/src/sage/interacts/library.py @@ -218,11 +218,11 @@ def taylor_polynomial(title, f, order: int): 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) """ - x0 = 0 - p = plot(f,(x,-1,5), thickness=2) - dot = point((x0,f(x=x0)),pointsize=80,rgbcolor=(1,0,0)) - ft = f.taylor(x,x0,order) - pt = plot(ft,(-1, 5), color='green', thickness=2) + x0 = 0 + p = plot(f, (x, -1, 5), thickness=2) + dot = point((x0, f(x=x0)), pointsize=80, rgbcolor=(1, 0, 0)) + ft = f.taylor(x, x0, order) + pt = plot(ft, (-1, 5), color='green', thickness=2) html(r'$f(x)\;=\;%s$' % latex(f)) html(r'$\hat{f}(x;%s)\;=\;%s+\mathcal{O}(x^{%s})$' % (x0, latex(ft), order + 1)) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index 8c4ba93a25f..3a2ed434091 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1699,7 +1699,7 @@ def gfq_gap_to_sage(x, F): return F(0) i1 = s.index("(") i2 = s.index(")") - q = eval(s[i1+1:i2].replace('^','**')) + q = eval(s[i1+1:i2].replace('^','**')) if not F.cardinality().is_power_of(q): raise ValueError('%r has no subfield of size %r' % (F, q)) if s.find(')^') == -1: diff --git a/src/sage/interfaces/octave.py b/src/sage/interfaces/octave.py index a1a9ba50582..d0f5694c8bc 100644 --- a/src/sage/interfaces/octave.py +++ b/src/sage/interfaces/octave.py @@ -511,7 +511,7 @@ def solve_linear_system(self, A, b): from sage.matrix.matrix_space import MatrixSpace from sage.rings.rational_field import QQ MS = MatrixSpace(QQ,m,1) - b = MS(list(b)) # converted b to a "column vector" + b = MS(list(b)) # converted b to a "column vector" sA = self.sage2octave_matrix_string(A) sb = self.sage2octave_matrix_string(b) self.eval("a = " + sA ) @@ -520,7 +520,7 @@ def solve_linear_system(self, A, b): soln = soln.replace("\n\n ","[") soln = soln.rstrip() + "]" soln = soln.replace("\n",",") - sol = soln[3:] + sol = soln[3:] return eval(sol) def sage2octave_matrix_string(self, A): diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index 331d698d3ab..c5a50438f03 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -410,7 +410,7 @@ def __init__(self, maxread=None, script_subdirectory=None, verbose_start=False, logfile=logfile, eval_using_file_cutoff=100 if os.uname()[0] == "SunOS" else 1000) - self.__libs = [] + self.__libs = [] self._prompt_wait = prompt self.__to_clear = [] # list of variable names that need to be cleared. self._seed = seed diff --git a/src/sage/interfaces/tides.py b/src/sage/interfaces/tides.py index 765b8bd3cb4..f70a2357cd3 100644 --- a/src/sage/interfaces/tides.py +++ b/src/sage/interfaces/tides.py @@ -532,13 +532,13 @@ def genfiles_mintides(integrator, driver, f, ics, initial, final, delta, elif el[0] == 'div_c': string += "inv_mc("+el[2]+","+el[1]+",XX[{}], i);".format(i+n) elif el[0] == 'log': - string += "log_mc("+el[1]+",XX[{}], i);".format(i+n) + string += "log_mc(" + el[1] + ",XX[{}], i);".format(i+n) elif el[0] == 'exp': - string += "exp_mc("+el[1]+",XX[{}], i);".format(i+n) + string += "exp_mc(" + el[1] + ",XX[{}], i);".format(i+n) elif el[0] == 'sin': - string += "sin_mc("+el[1]+",XX[{}], i);".format(i+n+1) + string += "sin_mc(" + el[1] + ",XX[{}], i);".format(i+n+1) elif el[0] == 'cos': - string += "cos_mc("+el[1]+",XX[{}], i);".format(i+n-1) + string += "cos_mc(" + el[1] + ",XX[{}], i);".format(i+n-1) res.append(string) @@ -583,7 +583,7 @@ def genfiles_mintides(integrator, driver, f, ics, initial, final, delta, for(i=0;i 11 and co > 1: @@ -3873,7 +3873,7 @@ def _knotinfo_matching_list(self): if cr > 12: cr = 12 - Hp = self.homfly_polynomial(normalization='vz') + Hp = self.homfly_polynomial(normalization='vz') det = None if cr > 6: @@ -3902,7 +3902,7 @@ def _knotinfo_matching_list(self): ln = Sn.lower_list(oriented=True, comp=co, det=det, homfly=Hp) l = sorted(list(set(la + ln))) - br = self.braid() + br = self.braid() br_ind = br.strands() res = [] diff --git a/src/sage/manifolds/differentiable/chart.py b/src/sage/manifolds/differentiable/chart.py index 6ea06b662ed..a40ebb8e5b2 100644 --- a/src/sage/manifolds/differentiable/chart.py +++ b/src/sage/manifolds/differentiable/chart.py @@ -1155,7 +1155,7 @@ def __init__(self, chart1, chart2, *transformations): """ CoordChange.__init__(self, chart1, chart2, *transformations) # Jacobian matrix: - self._jacobian = self._transf.jacobian() + self._jacobian = self._transf.jacobian() # If the two charts are on the same open subset, the Jacobian matrix is # added to the dictionary of changes of frame: if chart1.domain() == chart2.domain(): diff --git a/src/sage/manifolds/differentiable/scalarfield_algebra.py b/src/sage/manifolds/differentiable/scalarfield_algebra.py index 7bbf5a39146..44e6e16bff4 100644 --- a/src/sage/manifolds/differentiable/scalarfield_algebra.py +++ b/src/sage/manifolds/differentiable/scalarfield_algebra.py @@ -465,12 +465,11 @@ def _latex_(self): 'C^{\\infty}\\left(M\\right)' sage: latex(CM) # indirect doctest C^{\infty}\left(M\right) - """ degree = self._domain.diff_degree() if degree == infinity: latex_degree = r"\infty" # to skip the "+" in latex(infinity) else: latex_degree = "{}".format(degree) - return r"C^{" + latex_degree + r"}\left(" + self._domain._latex_() + \ + return r"C^{" + latex_degree + r"}\left(" + self._domain._latex_() + \ r"\right)" diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py index 52c89fd9959..d7941fad08c 100644 --- a/src/sage/manifolds/scalarfield_algebra.py +++ b/src/sage/manifolds/scalarfield_algebra.py @@ -568,7 +568,7 @@ def _latex_(self): C^0 \left(M\right) """ - return r"C^0 \left(" + self._domain._latex_() + r"\right)" + return r"C^0 \left(" + self._domain._latex_() + r"\right)" @cached_method def zero(self): diff --git a/src/sage/sat/solvers/dimacs.py b/src/sage/sat/solvers/dimacs.py index f9688ecd8d6..cfe3c7cd4ed 100644 --- a/src/sage/sat/solvers/dimacs.py +++ b/src/sage/sat/solvers/dimacs.py @@ -93,7 +93,7 @@ def __init__(self, command=None, filename=None, verbosity=0, **kwds): else: self._command = self.__class__.command - self._tail = open(tmp_filename(),'w') + self._tail = open(tmp_filename(), 'w') self._var = 0 self._lit = 0 diff --git a/src/sage/structure/factorization_integer.py b/src/sage/structure/factorization_integer.py index 2ea04be826e..4d01cea5a6f 100644 --- a/src/sage/structure/factorization_integer.py +++ b/src/sage/structure/factorization_integer.py @@ -69,9 +69,9 @@ def __init__(self, x, unit=None, cr=False, sort=True, simplify=True, else: self._Factorization__unit = unit - self._Factorization__x = x + self._Factorization__x = x self._Factorization__universe = ZZ - self._Factorization__cr = cr + self._Factorization__cr = cr if sort: self.sort() diff --git a/src/sage/tensor/modules/tensor_free_submodule.py b/src/sage/tensor/modules/tensor_free_submodule.py index 177eb1f3248..6503c310a91 100644 --- a/src/sage/tensor/modules/tensor_free_submodule.py +++ b/src/sage/tensor/modules/tensor_free_submodule.py @@ -152,7 +152,7 @@ def power_name(op, s, latex=False): if latex: superscript = r'\{' + superscript + r'\}' else: - superscript = '{' + superscript + '}' + superscript = '{' + superscript + '}' if latex: if len(superscript) != 1: superscript = '{' + superscript + '}' From 09b96f49ea5fe887968275a7e02bc3b3c9a9a101 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 2 Nov 2023 15:42:01 -0700 Subject: [PATCH 428/494] .ci/merge-fixes.sh: Reduce output --- .ci/merge-fixes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/merge-fixes.sh b/.ci/merge-fixes.sh index 1fb8267df0e..a8cb7a0507c 100755 --- a/.ci/merge-fixes.sh +++ b/.ci/merge-fixes.sh @@ -17,7 +17,7 @@ else echo "::group::Merging PR https://github.com/$REPO/pull/$a" git tag -f test_head $GH pr checkout -b pr-$a $a - git fetch --unshallow --all + git fetch --unshallow --all > /dev/null 2>&1 && echo "Unshallowed." git checkout -q test_head if git merge --no-edit --squash -q pr-$a; then echo "::endgroup::" From 3eb8408fd0a15ddac597199dd11840e3e74b4950 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 2 Nov 2023 15:49:18 -0700 Subject: [PATCH 429/494] .ci/merge-fixes.sh: Unshallow quietly before running 'gh' --- .ci/merge-fixes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/merge-fixes.sh b/.ci/merge-fixes.sh index a8cb7a0507c..8ee138660ec 100755 --- a/.ci/merge-fixes.sh +++ b/.ci/merge-fixes.sh @@ -14,10 +14,10 @@ else git tag -f test_base git commit -q -m "Uncommitted changes" --no-allow-empty -a for a in $PRs; do + git fetch --unshallow --all > /dev/null 2>&1 && echo "Unshallowed." echo "::group::Merging PR https://github.com/$REPO/pull/$a" git tag -f test_head $GH pr checkout -b pr-$a $a - git fetch --unshallow --all > /dev/null 2>&1 && echo "Unshallowed." git checkout -q test_head if git merge --no-edit --squash -q pr-$a; then echo "::endgroup::" From edb121f4d023202b233c6a66aa3e68936edf3ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 2 Nov 2023 14:48:19 +0100 Subject: [PATCH 430/494] case of empty matrices --- src/sage/matrix/matrix2.pyx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 8af0889927f..e8a4748ca89 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -8548,9 +8548,18 @@ cdef class Matrix(Matrix1): [5 4 3] [4 5 3] [1 0 2] + sage: M = matrix(ZZ, 0, 0, []) + sage: M.permutation_normal_form() # needs sage.graphs + [] """ nrows = self.nrows() ncols = self.ncols() + if not nrows or not ncols: + if not check: + return self + from sage.groups.perm_gps.permgroup_named import SymmetricGroup + return (self, (SymmetricGroup(nrows).one(), + SymmetricGroup(ncols).one())) # A helper def new_sorted_matrix(m): From ac9251c76afc4b78c3c14560a4eadb2781c11c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 3 Nov 2023 09:53:29 +0100 Subject: [PATCH 431/494] clean the file hexad.py --- src/sage/games/hexad.py | 262 ++++++++++++++++++++-------------------- 1 file changed, 130 insertions(+), 132 deletions(-) diff --git a/src/sage/games/hexad.py b/src/sage/games/hexad.py index 7b3af6f49d7..9986bab2bb2 100644 --- a/src/sage/games/hexad.py +++ b/src/sage/games/hexad.py @@ -1,5 +1,5 @@ r""" -Hexads in S(5,6,12) +Hexads in S(5, 6, 12) This module completes a 5-element subset of a 12-set `X` into a hexad in a Steiner system `S(5, 6, 12)` using Curtis @@ -34,13 +34,13 @@ The corresponding MINIMOG is:: - +-----+-----+-----+-----+ - | 6 | 3 | 0 | 9 | - +-----+-----+-----+-----+ - | 5 | 2 | 7 | 10 | - +-----+-----+-----+-----+ - | 4 | 1 | 8 | 11 | - +-----+-----+-----+-----+ + ┌─────┬─────┬─────┬─────┐ + │ 6 │ 3 │ 0 │ 9 │ + ├─────┼─────┼─────┼─────┤ + │ 5 │ 2 │ 7 │ 10 │ + ├─────┼─────┼─────┼─────┤ + │ 4 │ 1 │ 8 │ 11 │ + └─────┴─────┴─────┴─────┘ which is specified by the global variable ``minimog_shuffle``. @@ -61,7 +61,7 @@ - [KR2001]_ -Some details are also online at: http://www.permutationpuzzles.org/hexad/ +Some details are also online at: https://www.permutationpuzzles.org/hexad/ """ # **************************************************************************** # Copyright (C) 2005 David Joyner @@ -104,7 +104,7 @@ def view_list(L): [1 1 0] [1 1 0] """ - return matrix(GF(2), 3, 3, lambda x, y: 1 if (x,y) in L else 0) + return matrix(GF(2), 3, 3, lambda x, y: 1 if (x, y) in L else 0) def picture_set(A, L): @@ -120,10 +120,10 @@ def picture_set(A, L): sage: picture_set(M.picture02, M.square[7]) {2, 3, 5, 8} """ - return set([A[x] for x in L]) + return {A[x] for x in L} -class Minimog(): +class Minimog: r""" This implements the Conway/Curtis minimog idea for describing the Steiner triple system `S(5, 6, 12)`. @@ -141,9 +141,9 @@ class Minimog(): """ def __init__(self, type="shuffle"): self.type = type - MS34 = MatrixSpace(SR,3,4) - minimog_modulo11 = MS34([[0,3,infinity,2],[5,9,8,10],[4,1,6,7]]) - minimog_shuffle = MS34([[6,3,0,9],[5,2,7,10],[4,1,8,11]]) + MS34 = MatrixSpace(SR, 3, 4) + minimog_modulo11 = MS34([[0, 3, infinity, 2], [5, 9, 8, 10], [4, 1, 6, 7]]) + minimog_shuffle = MS34([[6, 3, 0, 9], [5, 2, 7, 10], [4, 1, 8, 11]]) if type == "shuffle": self.minimog = minimog_shuffle elif type == "modulo11": @@ -151,72 +151,72 @@ def __init__(self, type="shuffle"): else: raise ValueError("that Minimog type is not implemented") # This initializes the variables in the game. - MS34 = MatrixSpace(SR,3,4) + MS34 = MatrixSpace(SR, 3, 4) A = self.minimog - MS33 = MatrixSpace(SR,3,3) - self.picture00 = MS33([[A[(1,0)],A[(2,3)],A[(0,1)]],[A[(2,2)],A[(1,1)],A[(2,0)]],[A[(0,3)],A[(1,3)],A[(1,2)]]]) - ####### self.picture00 is the "picture at 6" - self.picture02 = MS33([[A[(1,0)],A[(2,3)],A[(0,1)]],[A[(1,1)],A[(2,0)],A[(2,2)]],[A[(1,2)],A[(0,3)],A[(1,3)]]]) - ####### self.picture02 is the "picture at 1" - self.picture21 = MS33([[A[(2,2)],A[(1,3)],A[(0,1)]],[A[(0,3)],A[(2,3)],A[(2,0)]],[A[(1,0)],A[(1,1)],A[(1,2)]]]) - ####### self.picture21 is the "picture at 0" + MS33 = MatrixSpace(SR, 3, 3) + self.picture00 = MS33([[A[(1, 0)], A[(2, 3)], A[(0, 1)]], [A[(2, 2)], A[(1, 1)], A[(2, 0)]], [A[(0, 3)], A[(1, 3)], A[(1, 2)]]]) + # self.picture00 is the "picture at 6" + self.picture02 = MS33([[A[(1, 0)], A[(2, 3)], A[(0, 1)]], [A[(1, 1)], A[(2, 0)], A[(2, 2)]], [A[(1, 2)], A[(0, 3)], A[(1, 3)]]]) + # self.picture02 is the "picture at 1" + self.picture21 = MS33([[A[(2, 2)], A[(1, 3)], A[(0, 1)]], [A[(0, 3)], A[(2, 3)], A[(2, 0)]], [A[(1, 0)], A[(1, 1)], A[(1, 2)]]]) + # self.picture21 is the "picture at 0" self.line = list(range(12)) - self.line[0] = set([(0,0),(0,1),(0,2)]) - self.line[1] = set([(1,0),(1,1),(1,2)]) - self.line[2] = set([(2,0),(2,1),(2,2)]) - self.line[3] = set([(0,2),(1,2),(2,2)]) - self.line[4] = set([(0,1),(1,1),(2,1)]) - self.line[5] = set([(0,0),(1,0),(2,0)]) - self.line[6] = set([(0,0),(1,1),(2,2)]) - self.line[7] = set([(2,0),(0,1),(1,2)]) - self.line[8] = set([(0,2),(1,0),(2,1)]) - self.line[9] = set([(2,0),(1,1),(0,2)]) - self.line[10] = set([(0,0),(1,2),(2,1)]) - self.line[11] = set([(1,0),(0,1),(2,2)]) + self.line[0] = {(0, 0), (0, 1), (0, 2)} + self.line[1] = {(1, 0), (1, 1), (1, 2)} + self.line[2] = {(2, 0), (2, 1), (2, 2)} + self.line[3] = {(0, 2), (1, 2), (2, 2)} + self.line[4] = {(0, 1), (1, 1), (2, 1)} + self.line[5] = {(0, 0), (1, 0), (2, 0)} + self.line[6] = {(0, 0), (1, 1), (2, 2)} + self.line[7] = {(2, 0), (0, 1), (1, 2)} + self.line[8] = {(0, 2), (1, 0), (2, 1)} + self.line[9] = {(2, 0), (1, 1), (0, 2)} + self.line[10] = {(0, 0), (1, 2), (2, 1)} + self.line[11] = {(1, 0), (0, 1), (2, 2)} self.cross = list(range(18)) - self.cross[0] = set([(0,0),(0,1),(0,2),(1,0),(2,0)]) - self.cross[1] = set([(0,0),(0,1),(0,2),(1,2),(2,2)]) - self.cross[2] = set([(0,0),(1,0),(2,0),(2,1),(2,2)]) - self.cross[3] = set([(2,0),(2,1),(2,2),(0,2),(1,2)]) - self.cross[4] = set([(0,0),(0,1),(0,2),(1,1),(2,1)]) - self.cross[5] = set([(0,0),(1,0),(2,0),(1,1),(1,2)]) - self.cross[6] = set([(1,0),(1,1),(1,2),(0,2),(2,2)]) - self.cross[7] = set([(0,1),(1,1),(2,1),(2,0),(2,2)]) - self.cross[8] = set([(0,0),(0,1),(1,0),(1,1),(2,2)]) - self.cross[9] = set([(0,0),(1,1),(1,2),(2,1),(2,2)]) - self.cross[10] = set([(2,0),(2,1),(1,0),(1,1),(0,2)]) - self.cross[11] = set([(0,1),(0,2),(1,1),(1,2),(2,0)]) - self.cross[12] = set([(0,0),(1,0),(0,2),(1,2),(2,1)]) - self.cross[13] = set([(1,0),(0,1),(0,2),(2,1),(2,2)]) - self.cross[14] = set([(0,1),(1,0),(1,2),(2,0),(2,2)]) - self.cross[15] = set([(0,0),(0,1),(1,2),(2,0),(2,1)]) - self.cross[16] = set([(1,0),(1,1),(1,2),(0,1),(2,1)]) - self.cross[17] = set([(0,0),(0,2),(1,1),(2,0),(2,2)]) - self.box = set([(i,j) for i in range(3) for j in range(3)]) - self.square = [set([]) for i in range(18)] + self.cross[0] = {(0, 0), (0, 1), (0, 2), (1, 0), (2, 0)} + self.cross[1] = {(0, 0), (0, 1), (0, 2), (1, 2), (2, 2)} + self.cross[2] = {(0, 0), (1, 0), (2, 0), (2, 1), (2, 2)} + self.cross[3] = {(2, 0), (2, 1), (2, 2), (0, 2), (1, 2)} + self.cross[4] = {(0, 0), (0, 1), (0, 2), (1, 1), (2, 1)} + self.cross[5] = {(0, 0), (1, 0), (2, 0), (1, 1), (1, 2)} + self.cross[6] = {(1, 0), (1, 1), (1, 2), (0, 2), (2, 2)} + self.cross[7] = {(0, 1), (1, 1), (2, 1), (2, 0), (2, 2)} + self.cross[8] = {(0, 0), (0, 1), (1, 0), (1, 1), (2, 2)} + self.cross[9] = {(0, 0), (1, 1), (1, 2), (2, 1), (2, 2)} + self.cross[10] = {(2, 0), (2, 1), (1, 0), (1, 1), (0, 2)} + self.cross[11] = {(0, 1), (0, 2), (1, 1), (1, 2), (2, 0)} + self.cross[12] = {(0, 0), (1, 0), (0, 2), (1, 2), (2, 1)} + self.cross[13] = {(1, 0), (0, 1), (0, 2), (2, 1), (2, 2)} + self.cross[14] = {(0, 1), (1, 0), (1, 2), (2, 0), (2, 2)} + self.cross[15] = {(0, 0), (0, 1), (1, 2), (2, 0), (2, 1)} + self.cross[16] = {(1, 0), (1, 1), (1, 2), (0, 1), (2, 1)} + self.cross[17] = {(0, 0), (0, 2), (1, 1), (2, 0), (2, 2)} + self.box = {(i, j) for i in range(3) for j in range(3)} + self.square = [set() for i in range(18)] for i in range(18): self.square[i] = self.box - self.cross[i] MS34_GF3 = MatrixSpace(GF(2), 3, 4) cols = {} - cols[1] = MS34_GF3([[1,0,0,0],[1,0,0,0],[1,0,0,0]]) - cols[2] = MS34_GF3([[0,1,0,0],[0,1,0,0],[0,1,0,0]]) - cols[3] = MS34_GF3([[0,0,1,0],[0,0,1,0],[0,0,1,0]]) - cols[4] = MS34_GF3([[0,0,0,1],[0,0,0,1],[0,0,0,1]]) + cols[1] = MS34_GF3([[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]]) + cols[2] = MS34_GF3([[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]]) + cols[3] = MS34_GF3([[0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0]]) + cols[4] = MS34_GF3([[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]) self.col = cols tets = {} - tets[1] = MS34_GF3([[1,1,1,1],[0,0,0,0],[0,0,0,0]]) - tets[2] = MS34_GF3([[1,0,0,0],[0,1,1,1],[0,0,0,0]]) - tets[3] = MS34_GF3([[1,0,0,0],[0,0,0,0],[0,1,1,1]]) - tets[4] = MS34_GF3([[0,1,0,0],[1,0,1,0],[0,0,0,1]]) - tets[5] = MS34_GF3([[0,0,0,1],[1,1,0,0],[0,0,1,0]]) - tets[6] = MS34_GF3([[0,0,1,0],[1,0,0,1],[0,1,0,0]]) - tets[7] = MS34_GF3([[0,1,0,0],[0,0,0,1],[1,0,1,0]]) - tets[8] = MS34_GF3([[0,0,1,0],[0,1,0,0],[1,0,0,1]]) - tets[9] = MS34_GF3([[0,0,0,1],[0,0,1,0],[1,1,0,0]]) + tets[1] = MS34_GF3([[1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]]) + tets[2] = MS34_GF3([[1, 0, 0, 0], [0, 1, 1, 1], [0, 0, 0, 0]]) + tets[3] = MS34_GF3([[1, 0, 0, 0], [0, 0, 0, 0], [0, 1, 1, 1]]) + tets[4] = MS34_GF3([[0, 1, 0, 0], [1, 0, 1, 0], [0, 0, 0, 1]]) + tets[5] = MS34_GF3([[0, 0, 0, 1], [1, 1, 0, 0], [0, 0, 1, 0]]) + tets[6] = MS34_GF3([[0, 0, 1, 0], [1, 0, 0, 1], [0, 1, 0, 0]]) + tets[7] = MS34_GF3([[0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 1, 0]]) + tets[8] = MS34_GF3([[0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 1]]) + tets[9] = MS34_GF3([[0, 0, 0, 1], [0, 0, 1, 0], [1, 1, 0, 0]]) self.tet = tets def __repr__(self): @@ -243,8 +243,7 @@ def __str__(self): [ 4 1 6 7] """ - return "Minimog of type %s associated to\n %s" % (self.type, - self.minimog) + return f"Minimog of type {self.type} associated to\n {self.minimog}" def _latex_(self): r""" @@ -262,8 +261,7 @@ def _latex_(self): \end{array}\right)$ """ from sage.misc.latex import latex - return "Minimog of type %s associated to\n $%s$" % (self.type, - latex(self.minimog)) + return f"Minimog of type {self.type} associated to\n ${latex(self.minimog)}$" def print_kitten(self): """ @@ -298,15 +296,15 @@ def print_kitten(self): """ MINIMOG = self.minimog - kitten = ' {}'.format(MINIMOG[0][2]) + kitten = f' {MINIMOG[0][2]}' kitten += '\n ' - kitten += '\n {}'.format(MINIMOG[2][2]) - kitten += '\n {} {}'.format(MINIMOG[0][3], MINIMOG[1][3]) - kitten += '\n {} {} {}'.format(MINIMOG[1][0], MINIMOG[2][3], MINIMOG[0][1]) + kitten += f'\n {MINIMOG[2][2]}' + kitten += f'\n {MINIMOG[0][3]} {MINIMOG[1][3]}' + kitten += f'\n {MINIMOG[1][0]} {MINIMOG[2][3]} {MINIMOG[0][1]}' kitten += '\n {0} {1} {2} {0}'.format(MINIMOG[2][2], MINIMOG[1][1], MINIMOG[2][0]) kitten += '\n {0} {1} {2} {0} {1}'.format(MINIMOG[0][3], MINIMOG[1][3], MINIMOG[1][2]) kitten += '\n \n' - kitten += '{} {}'.format(MINIMOG[0][0], MINIMOG[2][1]) + kitten += f'{MINIMOG[0][0]} {MINIMOG[2][1]}' print(kitten) def find_hexad0(self, pts): @@ -332,13 +330,13 @@ def find_hexad0(self, pts): sage: from sage.games.hexad import * sage: M = Minimog(type="shuffle") - sage: M.find_hexad0(set([2,4])) + sage: M.find_hexad0(set([2, 4])) ([0, 1, 2, 4, 6, 8], ['line 1', 'picture 1']) """ MINIMOG = self.minimog L = set(pts) - H = set([MINIMOG[0][2], MINIMOG[2][1], MINIMOG[0][0]]) + H = {MINIMOG[0][2], MINIMOG[2][1], MINIMOG[0][0]} for i in range(12): if L <= picture_set(self.picture02, self.line[i]): WHAT = ["line " + str(i), "picture " + str(1)] @@ -376,7 +374,7 @@ def find_hexad1(self, pts): sage: from sage.games.hexad import * sage: M = Minimog(type="shuffle") - sage: M.find_hexad1(set([2,3,4,5,8])) + sage: M.find_hexad1(set([2, 3, 4, 5, 8])) ([2, 3, 4, 5, 8, 11], ['lines (1, 2)', 'picture 1']) """ H = set(pts) @@ -386,19 +384,19 @@ def find_hexad1(self, pts): for x in linez: x1 = int(x[0] - 1) x2 = int(x[1] - 1) # (recall | is union) - if L <= (picture_set(self.picture02, self.line[x1]) | picture_set(self.picture02,self.line[x2])): + if L <= (picture_set(self.picture02, self.line[x1]) | picture_set(self.picture02, self.line[x2])): WHAT = ["lines " + str(x), "picture " + str(1)] - H = picture_set(self.picture02, self.line[x1]) | picture_set(self.picture02,self.line[x2]) + H = picture_set(self.picture02, self.line[x1]) | picture_set(self.picture02, self.line[x2]) return list(H), WHAT - if L <= (picture_set(self.picture21, self.line[x1]) | picture_set(self.picture21,self.line[x2])): + if L <= (picture_set(self.picture21, self.line[x1]) | picture_set(self.picture21, self.line[x2])): WHAT = ["lines " + str(x), "picture " + str(0)] - H = picture_set(self.picture21, self.line[x1]) | picture_set(self.picture21,self.line[x2]) + H = picture_set(self.picture21, self.line[x1]) | picture_set(self.picture21, self.line[x2]) return list(H), WHAT - if L <= (picture_set(self.picture00, self.line[x1]) | picture_set(self.picture00,self.line[x2])): + if L <= (picture_set(self.picture00, self.line[x1]) | picture_set(self.picture00, self.line[x2])): WHAT = ["lines " + str(x), "picture " + str(6)] - H = picture_set(self.picture00, self.line[x1]) | picture_set(self.picture00,self.line[x2]) + H = picture_set(self.picture00, self.line[x1]) | picture_set(self.picture00, self.line[x2]) return list(H), WHAT - return [],[] + return [], [] def find_hexad2(self, pts, x0): r""" @@ -418,33 +416,33 @@ def find_hexad2(self, pts, x0): sage: from sage.games.hexad import * sage: M = Minimog(type="shuffle") - sage: M.find_hexad2([2,3,4,5],1) + sage: M.find_hexad2([2, 3, 4, 5], 1) ([], []) The above output indicates that there is no hexad of type 2 - containing `\{2,3,4,5\}`. However, there is one containing - `\{2,3,4,8\}`:: + containing `\{2, 3, 4, 5\}`. However, there is one containing + `\{2, 3, 4, 8\}`:: - sage: M.find_hexad2([2,3,4,8],0) + sage: M.find_hexad2([2, 3, 4, 8], 0) ([0, 2, 3, 4, 8, 9], ['cross 12', 'picture 0']) """ MINIMOG = self.minimog L = set(pts) - H = set([x0]) + H = {x0} for i in range(18): - if (x0 == MINIMOG[2][1] and L <= picture_set(self.picture02,self.cross[i])): + if (x0 == MINIMOG[2][1] and L <= picture_set(self.picture02, self.cross[i])): WHAT = ["cross " + str(i), "picture " + str(1)] H = H | picture_set(self.picture02, self.cross[i]) return list(H), WHAT - if (x0 == MINIMOG[0][2] and L <= picture_set(self.picture21,self.cross[i])): + if (x0 == MINIMOG[0][2] and L <= picture_set(self.picture21, self.cross[i])): WHAT = ["cross " + str(i), "picture " + str(MINIMOG[0][2])] H = H | picture_set(self.picture21, self.cross[i]) return list(H), WHAT - if (x0 == MINIMOG[0][0] and L <= picture_set(self.picture00,self.cross[i])): + if (x0 == MINIMOG[0][0] and L <= picture_set(self.picture00, self.cross[i])): WHAT = ["cross " + str(i), "picture " + str(6)] H = H | picture_set(self.picture00, self.cross[i]) return list(H), WHAT - return [],[] + return [], [] def find_hexad3(self, pts, x0, x1): r""" @@ -459,20 +457,20 @@ def find_hexad3(self, pts, x0, x1): OUTPUT: - hexad containing pts union \{x0,x1\} of type 3 (square at + hexad containing pts union \{x0, x1\} of type 3 (square at picture of "omitted point at infinity") EXAMPLES:: sage: from sage.games.hexad import * sage: M = Minimog(type="shuffle") - sage: M.find_hexad3([2,3,4],0,1) + sage: M.find_hexad3([2, 3, 4], 0, 1) ([0, 1, 2, 3, 4, 11], ['square 2', 'picture 6']) """ MINIMOG = self.minimog L = set(pts) - H = set([x0, x1]) + H = {x0, x1} for i in range(18): if (not (MINIMOG[0][2] in H) and L <= picture_set(self.picture21, self.square[i])): WHAT = ["square " + str(i), "picture " + str(MINIMOG[0][2])] @@ -518,22 +516,22 @@ def find_hexad(self, pts): More precisely, there are 132 such hexads (12 of type 0, 12 of type 1, 54 of type 2, and 54 of type 3). - They form a Steiner system of type `(5,6,12)`. + They form a Steiner system of type `(5, 6, 12)`. EXAMPLES:: sage: from sage.games.hexad import * sage: M = Minimog(type="shuffle") - sage: M.find_hexad([0,1,2,3,4]) + sage: M.find_hexad([0, 1, 2, 3, 4]) ([0, 1, 2, 3, 4, 11], ['square 2', 'picture 6']) - sage: M.find_hexad([1,2,3,4,5]) + sage: M.find_hexad([1, 2, 3, 4, 5]) ([1, 2, 3, 4, 5, 6], ['square 8', 'picture 0']) - sage: M.find_hexad([2,3,4,5,8]) + sage: M.find_hexad([2, 3, 4, 5, 8]) ([2, 3, 4, 5, 8, 11], ['lines (1, 2)', 'picture 1']) - sage: M.find_hexad([0,1,2,4,6]) + sage: M.find_hexad([0, 1, 2, 4, 6]) ([0, 1, 2, 4, 6, 8], ['line 1', 'picture 1']) sage: M = Minimog(type="modulo11") - sage: M.find_hexad([1,2,3,4,SR(infinity)]) # random (machine dependent?) order + sage: M.find_hexad([1, 2, 3, 4, SR(infinity)]) # random (machine dependent?) order ([+Infinity, 2, 3, 4, 1, 10], ['square 8', 'picture 0']) AUTHOR: @@ -545,7 +543,7 @@ def find_hexad(self, pts): MINIMOG = self.minimog L = set(pts) LL = L.copy() - pts_at_infty = set([MINIMOG[0][2],MINIMOG[2][1],MINIMOG[0][0]]) + pts_at_infty = {MINIMOG[0][2], MINIMOG[2][1], MINIMOG[0][0]} # recall & means intersection L2 = LL & pts_at_infty if len(L2) == 3: # must be type 0 (line + pts at infty) @@ -553,31 +551,31 @@ def find_hexad(self, pts): return H, WHAT if len(L2) == 2: # type 0 or 3 if (MINIMOG[0][2] in LL and MINIMOG[2][1] in LL): - H, WHAT = self.find_hexad3(LL - set([MINIMOG[0][2],MINIMOG[2][1]]), + H, WHAT = self.find_hexad3(LL - {MINIMOG[0][2], MINIMOG[2][1]}, MINIMOG[0][2], MINIMOG[2][1]) - if H != []: # must be type 3 + if H: # must be type 3 return list(H), WHAT if H == []: # could be type 0 H, WHAT = self.find_hexad0(LL - L2) - if H != []: # must be type 0 + if H: # must be type 0 return list(H), WHAT if (MINIMOG[2][1] in LL and MINIMOG[0][0] in LL): - H, WHAT = self.find_hexad3(LL - set([MINIMOG[2][1],MINIMOG[0][0]]), + H, WHAT = self.find_hexad3(LL - {MINIMOG[2][1], MINIMOG[0][0]}, MINIMOG[2][1], MINIMOG[0][0]) - if H != []: # must be type 3 + if H: # must be type 3 return list(H), WHAT if H == []: # could be type 0 H, WHAT = self.find_hexad0(LL - L2) - if H != []: # must be type 0 + if H: # must be type 0 return list(H), WHAT if (MINIMOG[0][2] in LL and MINIMOG[0][0] in LL): - H, WHAT = self.find_hexad3(LL - set([MINIMOG[0][2],MINIMOG[0][0]]), + H, WHAT = self.find_hexad3(LL - {MINIMOG[0][2], MINIMOG[0][0]}, MINIMOG[0][2], MINIMOG[0][0]) - if H != []: # must be type 3 + if H: # must be type 3 return list(H), WHAT if H == []: # could be type 0 H, WHAT = self.find_hexad0(LL - L2) - if H != []: # must be type 0 + if H: # must be type 0 return list(H), WHAT if len(L2) == 1: H, WHAT = self.find_hexad2(LL - L2, list(L2)[0]) @@ -585,37 +583,37 @@ def find_hexad(self, pts): if list(L2)[0] == MINIMOG[2][1]: L1 = LL - L2 H, WHAT = self.find_hexad3(L1, MINIMOG[0][0], MINIMOG[2][1]) - if H != []: + if H: return list(H), WHAT L1 = LL - L2 H, WHAT = self.find_hexad3(L1, MINIMOG[0][2], MINIMOG[2][1]) - if H != []: + if H: return list(H), WHAT if list(L2)[0] == MINIMOG[0][0]: L1 = (LL - L2) H, WHAT = self.find_hexad3(L1, MINIMOG[0][0], MINIMOG[2][1]) - if H != []: + if H: return list(H), WHAT L1 = (LL - L2) H, WHAT = self.find_hexad3(L1, MINIMOG[0][0], MINIMOG[0][2]) - if H != []: + if H: return list(H), WHAT if list(L2)[0] == MINIMOG[0][2]: L1 = (LL - L2) H, WHAT = self.find_hexad3(L1, MINIMOG[0][0], MINIMOG[0][2]) - if H != []: + if H: return list(H), WHAT L1 = (LL - L2) H, WHAT = self.find_hexad3(L1, MINIMOG[2][1], MINIMOG[0][2]) - if H != []: + if H: return list(H), WHAT return list(H), WHAT # a cross in a pic at infty if not L2: # L is either a union of 2 lines or a cross for i in LL: for j in pts_at_infty: - H, WHAT = self.find_hexad2(LL - set([i]),j) - if (H != [] and i in H): + H, WHAT = self.find_hexad2(LL - {i}, j) + if (H and i in H): return list(H), WHAT # L is in a cross H, WHAT = self.find_hexad1(LL) # L is a union of lines return H, WHAT @@ -650,7 +648,7 @@ def blackjack_move(self, L0): under 21 loses. The winning strategy (given below) for this game is due to - Conway and Ryba. There is a Steiner system `S(5,6,12)` of hexads + Conway and Ryba. There is a Steiner system `S(5, 6, 12)` of hexads in the set `\{0, 1, ..., 11\}`. This Steiner system is associated to the MINIMOG of in the "shuffle numbering" rather than the "modulo `11` labeling". @@ -662,32 +660,32 @@ def blackjack_move(self, L0): EXAMPLES:: sage: M = Minimog(type="modulo11") - sage: M.blackjack_move([0,2,3,6,1,10]) + sage: M.blackjack_move([0, 2, 3, 6, 1, 10]) '6 --> 5. The total went from 22 to 21.' sage: M = Minimog(type="shuffle") - sage: M.blackjack_move([0,2,4,6,7,11]) + sage: M.blackjack_move([0, 2, 4, 6, 7, 11]) '4 --> 3. The total went from 30 to 29.' Is this really a hexad? :: - sage: M.find_hexad([11,2,3,6,7]) + sage: M.find_hexad([11, 2, 3, 6, 7]) ([0, 2, 3, 6, 7, 11], ['square 9', 'picture 1']) So, yes it is, but here is further confirmation:: - sage: M.blackjack_move([0,2,3,6,7,11]) + sage: M.blackjack_move([0, 2, 3, 6, 7, 11]) This is a hexad. There is no winning move, so make a random legal move. [0, 2, 3, 6, 7, 11] Now, suppose player 2 replaced the 11 by a 9. Your next move:: - sage: M.blackjack_move([0,2,3,6,7,9]) + sage: M.blackjack_move([0, 2, 3, 6, 7, 9]) '7 --> 1. The total went from 27 to 21.' You have now won. Sage will even tell you so:: - sage: M.blackjack_move([0,2,3,6,1,9]) + sage: M.blackjack_move([0, 2, 3, 6, 1, 9]) 'No move possible. Shuffle the deck and redeal.' AUTHOR: @@ -701,11 +699,11 @@ def blackjack_move(self, L0): return "No move possible. Shuffle the deck and redeal." L = set(L0) for x in L: - h, WHAT = self.find_hexad(L - set([x])) + h, WHAT = self.find_hexad(L - {x}) if list(L0) == list(h): print(" This is a hexad. \n There is no winning move, so make a random legal move.") return L0 - y = list(set(h) - (L - set([x])))[0] + y = list(set(h) - (L - {x}))[0] if y < x: return str(x) + ' --> ' + str(y) + ". The total went from " + str(total) + " to " + str(total - x + y) + "." print("This is a hexad. \n There is no winning move, so make a random legal move.") From 22fa20a9b3031954c050830287b51ba73ef21782 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 3 Nov 2023 18:46:15 +0900 Subject: [PATCH 432/494] Deploy live doc --- .github/workflows/doc-build.yml | 33 +++++++++++++++++ .github/workflows/doc-publish.yml | 61 +++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 5eb3998feee..0495f4d3b19 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -196,3 +196,36 @@ jobs: with: name: docs path: docs.zip + + - name: Build live doc + id: buildlivedoc + if: always() && steps.copy.outcome == 'success' && github.ref == 'refs/heads/develop' + run: | + set -ex + export SAGE_USE_CDNS=yes + export SAGE_LIVE_DOC=yes + export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env/dev + make doc-clean doc-uninstall + ./config.status && make sagemath_doc_html-no-deps + working-directory: ./worktree-image + env: + MAKE: make -j2 --output-sync=recurse + SAGE_NUM_THREADS: 2 + + - name: Copy live doc + id: copylivedoc + if: always() && steps.buildlivedoc.outcome == 'success' + run: | + set -ex + mkdir -p ./livedoc + cp -r -L /sage/local/share/doc/sage/html ./livedoc + cp /sage/local/share/doc/sage/index.html ./livedoc + zip -r livedoc.zip livedoc + + - name: Upload live doc + if: always() && steps.copylivedoc.outcome == 'success' + uses: actions/upload-artifact@v3 + with: + name: livedoc + path: livedoc.zip + diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 14337131420..1a1598ad37a 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -1,5 +1,4 @@ -# Triggers after the documentation build has finished, -# taking the artifact and uploading it to netlify +# Publish the built documentation by taking the artifact and uploading it to Netlify. name: Publish documentation on: @@ -14,7 +13,7 @@ permissions: pull-requests: write jobs: - upload-docs: + publish-docs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' steps: @@ -25,8 +24,10 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} sourceRunId: ${{ github.event.workflow_run.id }} - # Once https://github.com/actions/download-artifact/issues/172 and/or https://github.com/actions/download-artifact/issues/60 is implemented, we can use the official download-artifact action - # For now use the solution from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow + # Once https://github.com/actions/download-artifact/issues/172 and/or + # https://github.com/actions/download-artifact/issues/60 is implemented, + # we can use the official download-artifact action. For now, we use the solution from + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow - name: Download docs uses: actions/github-script@v6.4.0 with: @@ -63,8 +64,9 @@ jobs: NETLIFY_MESSAGE: ${{ steps.source-run-info.outputs.pullRequestNumber }} NETLIFY_ALIAS: deploy-preview-${{ steps.source-run-info.outputs.pullRequestNumber }} - # Add deployment as status check, PR comment and annotation - # we could use the nwtgck/actions-netlify action for that, except for that it is not (yet) working in workflow_run context: https://github.com/nwtgck/actions-netlify/issues/545 + # Add deployment as status check, PR comment and annotation we could use + # the nwtgck/actions-netlify action for that, except for that it is not + # (yet) working in workflow_run context: # https://github.com/nwtgck/actions-netlify/issues/545 - name: Add/Update deployment status PR comment uses: marocchino/sticky-pull-request-comment@v2 with: @@ -90,5 +92,48 @@ jobs: - name: Report deployment url run: | - echo "::notice::The documentation has being automatically deployed to Netlify. %0A ✅ Preview: ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" + echo "::notice::The documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" + + publish-livedoc: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop' + steps: + - name: Download live doc + uses: actions/github-script@v6.4.1 + with: + script: | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "livedoc" + })[0]; + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/livedoc.zip', Buffer.from(download.data)); + + - name: Extract live doc + run: unzip livedoc.zip -d doc && unzip doc/livedoc.zip -d doc/doc + + - name: Deploy to Netlify + id: deploy-netlify + uses: netlify/actions/cli@master + with: + args: deploy --dir=doc/doc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + NETLIFY_MESSAGE: Deployed live doc + NETLIFY_ALIAS: deploy-livedoc + + - name: Report deployment url + run: | + echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" From 8310a4586c8091caa4156007307d23a0de682735 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 3 Nov 2023 20:36:23 +0900 Subject: [PATCH 433/494] Change docs to doc for conformity --- .github/workflows/doc-build.yml | 48 +++++++++++++++---------------- .github/workflows/doc-publish.yml | 14 ++++----- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 0495f4d3b19..ceca5367bef 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -38,7 +38,7 @@ jobs: path: upstream name: upstream - build-docs: + build-doc: runs-on: ubuntu-latest container: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets:dev needs: [get_ci_fixes] @@ -108,7 +108,7 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Build docs + - name: Build doc id: docbuild if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success') # Always non-incremental because of the concern that @@ -125,23 +125,23 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Copy docs + - name: Copy doc id: copy if: always() && steps.docbuild.outcome == 'success' run: | set -ex - mkdir -p ./docs + mkdir -p ./doc (cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new') # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html/en && \ find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html - echo '' > ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - cat >> ./docs/CHANGES.html << EOF + echo '' > ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + cat >> ./doc/CHANGES.html << EOF EOF - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt + echo '' >> ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + (cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./doc/diff.txt /sage/sage -python - << EOF import re, html - with open('./docs/diff.txt', 'r') as f: + with open('./doc/diff.txt', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) out_blocks = [] @@ -175,27 +175,27 @@ jobs: path = match.group(1) out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) - with open('./docs/diff.html', 'w') as f: + with open('./doc/diff.html', 'w') as f: f.write(output_text) EOF - cat ./docs/diff.html >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >>./docs/CHANGES.html - rm ./docs/diff.txt ./docs/diff.html + cat ./doc/diff.html >> ./doc/CHANGES.html + echo '' >> ./doc/CHANGES.html + echo '' >>./doc/CHANGES.html + rm ./doc/diff.txt ./doc/diff.html (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them - cp -r -L /sage/local/share/doc/sage/html/en/* ./docs + cp -r -L /sage/local/share/doc/sage/html/en/* ./doc # Zip everything for increased performance - zip -r docs.zip docs + zip -r doc.zip doc - - name: Upload docs + - name: Upload doc if: always() && steps.copy.outcome == 'success' uses: actions/upload-artifact@v3 with: - name: docs - path: docs.zip + name: doc + path: doc.zip - name: Build live doc id: buildlivedoc diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 1a1598ad37a..b0f087e635b 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -13,7 +13,7 @@ permissions: pull-requests: write jobs: - publish-docs: + publish-doc: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' steps: @@ -28,7 +28,7 @@ jobs: # https://github.com/actions/download-artifact/issues/60 is implemented, # we can use the official download-artifact action. For now, we use the solution from # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow - - name: Download docs + - name: Download doc uses: actions/github-script@v6.4.0 with: script: | @@ -38,7 +38,7 @@ jobs: run_id: ${{github.event.workflow_run.id }}, }); var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "docs" + return artifact.name == "doc" })[0]; var download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, @@ -47,16 +47,16 @@ jobs: archive_format: 'zip', }); var fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/docs.zip', Buffer.from(download.data)); + fs.writeFileSync('${{github.workspace}}/doc.zip', Buffer.from(download.data)); - - name: Extract docs - run: unzip docs.zip -d docs && unzip docs/docs.zip -d docs/docs + - name: Extract doc + run: unzip doc.zip -d doc && unzip doc/doc.zip -d doc/doc - name: Deploy to Netlify id: deploy-netlify uses: netlify/actions/cli@master with: - args: deploy --dir=docs/docs/docs ${NETLIFY_PRODUCTION:+"--prod"} --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} + args: deploy --dir=doc/doc/doc ${NETLIFY_PRODUCTION:+"--prod"} --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} From b494b123ded56f3fe06ce4a447cf7972ed0195fd Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 3 Nov 2023 20:48:35 +0900 Subject: [PATCH 434/494] Put celebratory emoji at the beginning to get attention first --- .github/workflows/doc-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index b0f087e635b..524ff4eea6b 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -74,7 +74,7 @@ jobs: header: preview-comment recreate: true message: | - [Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! :tada: + :tada:[Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! - name: Update deployment status PR check uses: myrotvorets/set-commit-status-action@v2.0.0 From 78a16ba653f8be850a8b918c0bc756621cf14ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 3 Nov 2023 14:45:45 +0100 Subject: [PATCH 435/494] suggested changes --- src/sage/games/hexad.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/sage/games/hexad.py b/src/sage/games/hexad.py index 9986bab2bb2..ddc08530b08 100644 --- a/src/sage/games/hexad.py +++ b/src/sage/games/hexad.py @@ -107,7 +107,7 @@ def view_list(L): return matrix(GF(2), 3, 3, lambda x, y: 1 if (x, y) in L else 0) -def picture_set(A, L): +def picture_set(A, L) -> set: """ This is needed in the :meth:`Minimog.find_hexad` function below. @@ -219,7 +219,7 @@ def __init__(self, type="shuffle"): tets[9] = MS34_GF3([[0, 0, 0, 1], [0, 0, 1, 0], [1, 1, 0, 0]]) self.tet = tets - def __repr__(self): + def __repr__(self) -> str: """ Return a string representation of ``self``. @@ -231,7 +231,7 @@ def __repr__(self): """ return "Minimog of type %s" % self.type - def __str__(self): + def __str__(self) -> str: """ EXAMPLES:: @@ -555,31 +555,31 @@ def find_hexad(self, pts): MINIMOG[0][2], MINIMOG[2][1]) if H: # must be type 3 return list(H), WHAT - if H == []: # could be type 0 - H, WHAT = self.find_hexad0(LL - L2) - if H: # must be type 0 - return list(H), WHAT + # could be type 0 + H, WHAT = self.find_hexad0(LL - L2) + if H: # must be type 0 + return list(H), WHAT if (MINIMOG[2][1] in LL and MINIMOG[0][0] in LL): H, WHAT = self.find_hexad3(LL - {MINIMOG[2][1], MINIMOG[0][0]}, MINIMOG[2][1], MINIMOG[0][0]) if H: # must be type 3 return list(H), WHAT - if H == []: # could be type 0 - H, WHAT = self.find_hexad0(LL - L2) - if H: # must be type 0 - return list(H), WHAT + # could be type 0 + H, WHAT = self.find_hexad0(LL - L2) + if H: # must be type 0 + return list(H), WHAT if (MINIMOG[0][2] in LL and MINIMOG[0][0] in LL): H, WHAT = self.find_hexad3(LL - {MINIMOG[0][2], MINIMOG[0][0]}, MINIMOG[0][2], MINIMOG[0][0]) if H: # must be type 3 return list(H), WHAT - if H == []: # could be type 0 - H, WHAT = self.find_hexad0(LL - L2) - if H: # must be type 0 - return list(H), WHAT + # could be type 0 + H, WHAT = self.find_hexad0(LL - L2) + if H: # must be type 0 + return list(H), WHAT if len(L2) == 1: H, WHAT = self.find_hexad2(LL - L2, list(L2)[0]) - if H == []: # not a cross in picture at infinity + if not H: # not a cross in picture at infinity if list(L2)[0] == MINIMOG[2][1]: L1 = LL - L2 H, WHAT = self.find_hexad3(L1, MINIMOG[0][0], MINIMOG[2][1]) From 9dd8572565d33a9fc35281c2d3d10e1ac692b1d0 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 3 Nov 2023 23:19:53 +0900 Subject: [PATCH 436/494] live-doc instead of livedoc --- .github/workflows/doc-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index d35b6f17838..4f42490626c 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -94,7 +94,7 @@ jobs: run: | echo "::notice::The documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" - publish-livedoc: + publish-live-doc: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop' steps: From 76196adecb90dd48341b72f58b9fc71849526887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 3 Nov 2023 15:31:01 +0100 Subject: [PATCH 437/494] fix pyright shouting --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 606d991b692..8ade7f9b31b 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -117,10 +117,7 @@ class initialization directly. lazy_import('sage.rings.padics.factory', 'Qp') lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') -try: - from sage.libs.pari.all import PariError -except ImportError: - PariError = () +from sage.libs.pari.all import PariError class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, From 06cdeea5cb18dd84adf98e1469afbb135d885f19 Mon Sep 17 00:00:00 2001 From: ymusleh <44390016+ymusleh@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:13:21 -0400 Subject: [PATCH 438/494] Update src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antoine Leudière --- .../drinfeld_modules/finite_drinfeld_module.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py index 86cb9c1bbd9..a6d64d46fa5 100644 --- a/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py @@ -337,14 +337,13 @@ def frobenius_charpoly(self, var='X', algorithm='crystalline'): The available options for 'algorithm' are: - ``'crystalline'`` -- Computes the characteristic polynomial of the - Frobenius endomorphism on the crystalline cohomology - of a Drinfeld module. + Frobenius endomorphism on the crystalline cohomology of a Drinfeld + module. - ``'motive'`` -- Based on computing the characteristic polynomial of - the Frobenius endomorphism on the motive of a - Drinfeld module. This instantiates the Frobenius - as a morphism object and calls its - ``'characteristic_polynomial'`` method. + the Frobenius endomorphism on the motive of a Drinfeld module. This + instantiates the Frobenius as a morphism object and calls its + ``'characteristic_polynomial'`` method. """ # Throw an error if the user asks for an unimplemented algorithm # even if the char poly has already been computed From 15dd4359bc53fa56ecc1d124383a8154da55e1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 3 Nov 2023 18:50:07 +0100 Subject: [PATCH 439/494] suggested doctest added --- src/sage/matrix/matrix2.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index e8a4748ca89..fee13a5a258 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -8542,15 +8542,18 @@ cdef class Matrix(Matrix1): TESTS:: + sage: # needs sage.graphs sage: M = matrix(ZZ, [[3, 4, 5], [3, 4, 5], [3, 5, 4], [2, 0,1]]) - sage: M.permutation_normal_form() # needs sage.graphs + sage: M.permutation_normal_form() [5 4 3] [5 4 3] [4 5 3] [1 0 2] sage: M = matrix(ZZ, 0, 0, []) - sage: M.permutation_normal_form() # needs sage.graphs + sage: M.permutation_normal_form() [] + sage: M.permutation_normal_form(check=True) + ([], ((), ())) """ nrows = self.nrows() ncols = self.ncols() From 754eff4e5e50f87b5de1ad09e6c7ad2a2aa7277b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:08:18 -0700 Subject: [PATCH 440/494] sage.rings: More block tags, fix tags --- src/sage/rings/complex_double.pyx | 9 +++++---- src/sage/rings/infinity.py | 18 ++++++++++-------- src/sage/rings/integer.pyx | 10 ++++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 2f5f5727bd4..8f1e8205817 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -2551,11 +2551,12 @@ cdef class ComplexToCDF(Morphism): EXAMPLES:: - sage: import numpy # needs numpy - sage: f = CDF.coerce_map_from(numpy.complex_) # needs numpy - sage: f(numpy.complex_(I)) # needs numpy + sage: # needs numpy + sage: import numpy + sage: f = CDF.coerce_map_from(numpy.complex_) + sage: f(numpy.complex_(I)) 1.0*I - sage: f(numpy.complex_(I)).parent() # needs numpy + sage: f(numpy.complex_(I)).parent() Complex Double Field """ def __init__(self, R): diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index 25ea7bccf7a..119f48a9f65 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -943,12 +943,13 @@ def _sympy_(self): EXAMPLES:: - sage: import sympy # needs sympy - sage: SR(unsigned_infinity)._sympy_() # needs sympy + sage: # needs sympy + sage: import sympy + sage: SR(unsigned_infinity)._sympy_() zoo - sage: gamma(-3)._sympy_() is sympy.factorial(-2) # needs sympy + sage: gamma(-3)._sympy_() is sympy.factorial(-2) True - sage: gamma(-3) is sympy.factorial(-2)._sage_() # needs sympy + sage: gamma(-3) is sympy.factorial(-2)._sage_() True """ import sympy @@ -1626,12 +1627,13 @@ def _sympy_(self): EXAMPLES:: - sage: import sympy # needs sympy - sage: bool(-oo == -sympy.oo) # needs sympy + sage: # needs sympy + sage: import sympy + sage: bool(-oo == -sympy.oo) True - sage: bool(SR(-oo) == -sympy.oo) # needs sympy + sage: bool(SR(-oo) == -sympy.oo) True - sage: bool((-oo)._sympy_() == -sympy.oo) # needs sympy + sage: bool((-oo)._sympy_() == -sympy.oo) True """ diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 0864c0b6b37..c3c87042caa 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -3448,10 +3448,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: divmod(1, sys.maxsize+1r) # should not raise OverflowError: Python int too large to convert to C long (0, 1) - sage: import mpmath # needs mpmath - sage: mpmath.mp.prec = 1000 # needs mpmath - sage: root = mpmath.findroot(lambda x: x^2 - 3, 2) # needs mpmath - sage: len(str(root)) # needs mpmath + sage: # needs mpmath + sage: import mpmath + sage: mpmath.mp.prec = 1000 + sage: root = mpmath.findroot(lambda x: x^2 - 3, 2) + sage: len(str(root)) 301 """ cdef Integer q = PY_NEW(Integer) @@ -6230,6 +6231,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: numpy.array([1, 2, 3]).dtype dtype('int32') # 32-bit dtype('int64') # 64-bit + sage: # needs numpy (this has to be repeated until #36099 is fixed) sage: numpy.array(2**40).dtype dtype('int64') sage: numpy.array(2**400).dtype From 0f5b767b9214fe58f3a98d0d645cae5228883e50 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:08:30 -0700 Subject: [PATCH 441/494] sage.rings.function_field: More block tags, fix tags --- src/sage/rings/function_field/function_field.py | 2 +- src/sage/rings/function_field/function_field_rational.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/function_field/function_field.py b/src/sage/rings/function_field/function_field.py index 47056fffb5c..af5b6c4d924 100644 --- a/src/sage/rings/function_field/function_field.py +++ b/src/sage/rings/function_field/function_field.py @@ -125,7 +125,7 @@ TESTS:: sage: TestSuite(J).run() - sage: TestSuite(K).run(max_runs=256) # long time (10s) # needs sage.rings.number_field + sage: TestSuite(K).run(max_runs=256) # long time (10s) # needs sage.rings.function_field sage.rings.number_field sage: TestSuite(L).run(max_runs=8) # long time (25s) # needs sage.rings.function_field sage.rings.number_field sage: # needs sage.rings.finite_rings sage.rings.function_field diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index 1b169275da4..e763a673a15 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -135,9 +135,10 @@ def __init__(self, constant_field, names, category=None): EXAMPLES:: + sage: K. = FunctionField(CC); K # needs sage.rings.real_mpfr Rational function field in t over Complex Field with 53 bits of precision - sage: TestSuite(K).run() # long time (5s) + sage: TestSuite(K).run() # long time (5s) # needs sage.rings.real_mpfr sage: FunctionField(QQ[I], 'alpha') # needs sage.rings.number_field Rational function field in alpha over From 7053a6465133e357bb49e55afeb3c1f96ee4069c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:13:05 -0700 Subject: [PATCH 442/494] sage.rings.padics: More block tags, fix tags --- src/sage/rings/padics/local_generic.py | 4 +++- src/sage/rings/padics/padic_capped_absolute_element.pyx | 3 ++- src/sage/rings/padics/padic_capped_relative_element.pyx | 3 ++- src/sage/rings/padics/padic_extension_leaves.py | 2 +- src/sage/rings/padics/padic_fixed_mod_element.pyx | 3 ++- src/sage/rings/padics/padic_floating_point_element.pyx | 3 ++- src/sage/rings/padics/padic_generic_element.pyx | 2 +- src/sage/rings/padics/tutorial.py | 4 ++-- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 62b8868b012..17d5c22398c 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -330,11 +330,12 @@ def change(self, **kwds): and variable names:: - sage: K.change(names='b') + sage: K.change(names='b') # needs sage.libs.flint 5-adic Unramified Extension Field in b defined by x^3 + 3*x + 3 and precision:: + sage: # needs sage.libs.flint sage: Kup = K.change(prec=8); Kup 5-adic Unramified Extension Field in a defined by x^3 + 3*x + 3 sage: Kup.precision_cap() @@ -344,6 +345,7 @@ def change(self, **kwds): If you decrease the precision, the precision of the base stays the same:: + sage: # needs sage.libs.flint sage: Kdown = K.change(prec=2); Kdown 5-adic Unramified Extension Field in a defined by x^3 + 3*x + 3 sage: Kdown.precision_cap() diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pyx b/src/sage/rings/padics/padic_capped_absolute_element.pyx index 5585510e1eb..6291f13ad9c 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pyx +++ b/src/sage/rings/padics/padic_capped_absolute_element.pyx @@ -477,7 +477,8 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: - sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: # needs sage.libs.ntl + sage: R. = Zq(7^2,5) sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_capped_relative_element.pyx b/src/sage/rings/padics/padic_capped_relative_element.pyx index b6268123fa2..81b48bff84d 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pyx +++ b/src/sage/rings/padics/padic_capped_relative_element.pyx @@ -535,7 +535,8 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: # needs sage.libs.ntl + sage: R. = Zq(7^2,5) sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index f711726c33f..2bb7b2439f8 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -303,7 +303,7 @@ class UnramifiedExtensionRingFixedMod(UnramifiedExtensionGeneric, pAdicFixedModR TESTS:: sage: R. = ZqFM(27,1000) # needs sage.libs.flint - sage: TestSuite(R).run(skip='_test_log',max_runs=4) # long time + sage: TestSuite(R).run(skip='_test_log',max_runs=4) # long time # needs sage.libs.flint """ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, implementation='FLINT'): """ diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pyx b/src/sage/rings/padics/padic_fixed_mod_element.pyx index 6b30b0e5646..99ecfd88d8e 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pyx +++ b/src/sage/rings/padics/padic_fixed_mod_element.pyx @@ -542,7 +542,8 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: - sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: # needs sage.libs.ntl + sage: R. = Zq(7^2,5) sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_floating_point_element.pyx b/src/sage/rings/padics/padic_floating_point_element.pyx index 0321aee4642..821d694d0ee 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pyx +++ b/src/sage/rings/padics/padic_floating_point_element.pyx @@ -419,7 +419,8 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R. = Zq(7^2,5) # needs sage.libs.ntl + sage: # needs sage.libs.ntl + sage: R. = Zq(7^2,5) sage: x = R(7*w) sage: x.exp(algorithm="newton") # indirect doctest 1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5) diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index 18e2d396630..dff932b3e0c 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -2306,7 +2306,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: zz = (1 + a*pi).log() sage: ww = pi.exp() # needs sage.symbolic sage: beta = P.hom([-pi], base_map=cc) - sage: beta(ww*zz) == beta(ww)*beta(zz) + sage: beta(ww*zz) == beta(ww)*beta(zz) # needs sage.symbolic True """ L = self.parent() diff --git a/src/sage/rings/padics/tutorial.py b/src/sage/rings/padics/tutorial.py index 20ffeacf586..45459711382 100644 --- a/src/sage/rings/padics/tutorial.py +++ b/src/sage/rings/padics/tutorial.py @@ -309,7 +309,7 @@ ``Zq`` also requires a name for the generator of the residue field. One can specify this name as follows:: - sage: R. = Zq(125, prec = 20); R # needs sage.libs.ntl + sage: R. = Zq(125, prec=20); R # needs sage.libs.ntl 5-adic Unramified Extension Ring in c defined by x^3 + 3*x + 3 Eisenstein Extensions @@ -332,7 +332,7 @@ You can do arithmetic in this Eisenstein extension:: - sage: (1 + w)^7 # needs sage.libs.ntl + sage: (1 + w)^7 # needs sage.libs.ntl sage.rings.padics 1 + 2*w + w^2 + w^5 + 3*w^6 + 3*w^7 + 3*w^8 + w^9 + O(w^10) Note that the precision cap increased by a factor of 5, since the From 45b833b7f71e131b25dabb42c0b0bc0da739395b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:14:31 -0700 Subject: [PATCH 443/494] sage.rings.number_field: More block tags, fix tags --- src/sage/rings/number_field/number_field.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 3eb10c95e03..8b0a9c4157d 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1334,7 +1334,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField): This example was suggested on sage-nt; see :trac:`18942`:: sage: G = DirichletGroup(80) # needs sage.modular - sage: for chi in G: # long time + sage: for chi in G: # long time # needs sage.modular ....: D = ModularSymbols(chi, 2, -1).cuspidal_subspace().new_subspace().decomposition() ....: for f in D: ....: elt = f.q_eigenform(10, 'alpha')[3] @@ -1726,7 +1726,6 @@ def _element_constructor_(self, x, check=True): Traceback (most recent call last): ... TypeError: unable to convert x to a rational - sage: QQi(("1", "2")) 2*I + 1 sage: QQi((RR(1), RR(2))) From 73e41c634fbd43fab3ebfd476f31cc8d76bed400 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:17:31 -0700 Subject: [PATCH 444/494] sage.rings.polynomial: More block tags, fix tags --- src/sage/rings/polynomial/hilbert.pyx | 3 ++- src/sage/rings/polynomial/multi_polynomial.pyx | 3 ++- src/sage/rings/polynomial/polynomial_element.pyx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx index d46df1cceb8..975e2f42d9e 100644 --- a/src/sage/rings/polynomial/hilbert.pyx +++ b/src/sage/rings/polynomial/hilbert.pyx @@ -440,8 +440,9 @@ def first_hilbert_series(I, grading=None, return_grading=False): EXAMPLES:: - sage: # needs sage.libs.singular sage: from sage.rings.polynomial.hilbert import first_hilbert_series + + sage: # needs sage.libs.singular sage: R = singular.ring(0,'(x,y,z)','dp') sage: I = singular.ideal(['x^2','y^2','z^2']) sage: first_hilbert_series(I) diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index d6de9037146..6cb9593081b 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -2728,7 +2728,8 @@ cdef class MPolynomial(CommutativePolynomial): is not a subring of the real numbers, as the notion is not defined in this case:: - sage: Q. = CC[] # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: Q. = CC[] sage: q = z^2 + w^2 sage: q.is_lorentzian() Traceback (most recent call last): diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index b85599d844b..8e9c4822a7b 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -9201,7 +9201,8 @@ cdef class Polynomial(CommutativePolynomial): is not a subring of the real numbers, as the notion is not defined in this case:: - sage: Q. = CC[] # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: Q. = CC[] sage: q = y^2 sage: q.is_lorentzian() Traceback (most recent call last): From 473f84d608ba8de6ad98c4f53f12d3ed1374b26e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 11:29:21 -0700 Subject: [PATCH 445/494] sage.rings.valuation: More block tags, fix tags, doctest cosmetics --- .../rings/valuation/augmented_valuation.py | 5 +- src/sage/rings/valuation/valuation.py | 78 ++++++++++++------- 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 82d0e465b93..7fac06e57ef 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -283,8 +283,9 @@ class AugmentedValuation_base(InductiveValuation): TESTS:: - sage: TestSuite(w).run() # long time - sage: TestSuite(ww).run() # long time + sage: # needs sage.rings.number_field + sage: TestSuite(w).run() # long time + sage: TestSuite(ww).run() # long time """ def __init__(self, parent, v, phi, mu): diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index a095595dc3d..62c5dac33d7 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -550,29 +550,38 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru `\QQ[x]/(x^2+1)`, 5 factors `-(x - 2)(x + 2)`, this behaviour can be read off the Mac Lane approximants:: + sage: # needs sage.rings.padics sage: k = Qp(5,4) sage: v = k.valuation() sage: R. = k[] # needs sage.libs.ntl sage: G = x^2 + 1 sage: v1,v2 = v.mac_lane_approximants(G); v1,v2 # needs sage.geometry.polyhedron - ([ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + O(5^4)) = 1 ], - [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + O(5^4)) = 1 ]) - sage: w1, w2 = v.mac_lane_approximants(G, required_precision = 2); w1,w2 # needs sage.geometry.polyhedron - ([ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + 5 + O(5^4)) = 2 ], - [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + 3*5 + O(5^4)) = 2 ]) + ([ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 2 + O(5^4)) = 1 ], + [ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 3 + O(5^4)) = 1 ]) + sage: w1, w2 = v.mac_lane_approximants(G, required_precision=2); w1, w2 # needs sage.geometry.polyhedron + ([ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 2 + 5 + O(5^4)) = 2 ], + [ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 3 + 3*5 + O(5^4)) = 2 ]) Note how the latter give a better approximation to the factors of `x^2 + 1`:: - sage: v1.phi() * v2.phi() - G # needs sage.rings.padics + sage: # needs sage.geometry.polyhedron sage.rings.padics + sage: v1.phi() * v2.phi() - G O(5^4)*x^2 + (5 + O(5^4))*x + 5 + O(5^4) - sage: w1.phi() * w2.phi() - G # needs sage.rings.padics + sage: w1.phi() * w2.phi() - G O(5^4)*x^2 + (5^2 + O(5^4))*x + 5^3 + O(5^4) In this example, the process stops with a factorization of `x^2 + 1`:: - sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.geometry.polyhedron sage.rings.padics - [[ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) = +Infinity ], - [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) = +Infinity ]] + sage: # needs sage.geometry.polyhedron sage.rings.padics + sage: v.mac_lane_approximants(G, required_precision=infinity) + [[ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) = +Infinity ], + [ Gauss valuation induced by 5-adic valuation, + v((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) = +Infinity ]] This obviously cannot happen over the rationals where we only get an approximate factorization:: @@ -590,14 +599,16 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Initial versions ran into problems with the trivial residue field extensions in this case:: + sage: # needs sage.libs.ntl sage: K = Qp(3, 20, print_mode='digits') - sage: R. = K[] # needs sage.libs.ntl - - sage: alpha = T^3/4 # needs sage.libs.ntl - sage: G = 3^3*T^3*(alpha^4 - alpha)^2 - (4*alpha^3 - 1)^3 # needs sage.libs.ntl + sage: R. = K[] + sage: alpha = T^3/4 + sage: G = 3^3*T^3*(alpha^4 - alpha)^2 - (4*alpha^3 - 1)^3 sage: G = G/G.leading_coefficient() sage: K.valuation().mac_lane_approximants(G) # needs sage.geometry.polyhedron - [[ Gauss valuation induced by 3-adic valuation, v(...1*T + ...2) = 1/9, v(...1*T^9 + ...20*T^8 + ...210*T^7 + ...20*T^6 + ...20*T^5 + ...10*T^4 + ...220*T^3 + ...20*T^2 + ...110*T + ...122) = 55/27 ]] + [[ Gauss valuation induced by 3-adic valuation, v(...1*T + ...2) = 1/9, + v(...1*T^9 + ...20*T^8 + ...210*T^7 + ...20*T^6 + ...20*T^5 + ...10*T^4 + + ...220*T^3 + ...20*T^2 + ...110*T + ...122) = 55/27 ]] A similar example:: @@ -605,13 +616,15 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru sage: v = QQ.valuation(3) sage: G = (x^3 + 3)^3 - 81 sage: v.mac_lane_approximants(G) # needs sage.geometry.polyhedron sage.rings.padics - [[ Gauss valuation induced by 3-adic valuation, v(x) = 1/3, v(x^3 + 3*x + 3) = 13/9 ]] + [[ Gauss valuation induced by 3-adic valuation, + v(x) = 1/3, v(x^3 + 3*x + 3) = 13/9 ]] Another problematic case:: sage: # needs sage.rings.number_field sage.rings.padics sage: R. = QQ[] - sage: Delta = x^12 + 20*x^11 + 154*x^10 + 664*x^9 + 1873*x^8 + 3808*x^7 + 5980*x^6 + 7560*x^5 + 7799*x^4 + 6508*x^3 + 4290*x^2 + 2224*x + 887 + sage: Delta = (x^12 + 20*x^11 + 154*x^10 + 664*x^9 + 1873*x^8 + 3808*x^7 + 5980*x^6 + ....: + 7560*x^5 + 7799*x^4 + 6508*x^3 + 4290*x^2 + 2224*x + 887) sage: K. = NumberField(x^6 + 108) sage: K.is_galois() True @@ -622,9 +635,12 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru 1/3 sage: G = Delta.change_ring(K) sage: vK.mac_lane_approximants(G) - [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + 3*theta + 1) = 3/2 ], - [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + theta + 1) = 3/2 ], - [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/4, v(x^4 + 2*theta + 1) = 3/2 ]] + [[ Gauss valuation induced by 2-adic valuation, + v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + 3*theta + 1) = 3/2 ], + [ Gauss valuation induced by 2-adic valuation, + v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + theta + 1) = 3/2 ], + [ Gauss valuation induced by 2-adic valuation, + v(x + 1) = 1/4, v(x^4 + 2*theta + 1) = 3/2 ]] An easy case that produced the wrong error at some point:: @@ -636,6 +652,8 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru ValueError: G must be integral Some examples that Sebastian Pauli used in a talk at Sage Days 87. + Here we use ``assume_squarefree=True`` because :meth:`is_squarefree` + is not properly implemented yet. :: @@ -643,8 +661,8 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru sage: S. = R[] sage: v = R.valuation() sage: f = x^4 + 234 - sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet # needs sage.geometry.polyhedron - ....: assume_squarefree=True)) + sage: len(v.mac_lane_approximants(f, assume_squarefree=True)) # needs sage.geometry.polyhedron + ....: 2 :: @@ -653,17 +671,25 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru sage: S. = R[] sage: f = (x^32 + 16)*(x^32 + 16 + 2^16*x^2) + 2^34 sage: v = R.valuation() - sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet # needs sage.geometry.polyhedron - ....: assume_squarefree=True)) + sage: len(v.mac_lane_approximants(f, assume_squarefree=True)) # needs sage.geometry.polyhedron + ....: 2 A case that triggered an assertion at some point:: sage: v = QQ.valuation(3) sage: R. = QQ[] - sage: f = x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 +17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116 + sage: f = (x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + ....: + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 + ....: + 17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116) sage: v.mac_lane_approximants(f) # needs sage.geometry.polyhedron - [[ Gauss valuation induced by 3-adic valuation, v(x) = 1/3, v(x^3 - 3) = 3/2, v(x^12 - 3*x^9 + 54*x^6 + 27/2*x^3 + 405/2) = 13/2, v(x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 + 17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116) = +Infinity ]] + [[ Gauss valuation induced by 3-adic valuation, + v(x) = 1/3, + v(x^3 - 3) = 3/2, + v(x^12 - 3*x^9 + 54*x^6 + 27/2*x^3 + 405/2) = 13/2, + v(x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 + + 17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116) = +Infinity ]] """ R = G.parent() From 7b88728eaba6117a7fbbc67c221a6fec5cafef63 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 3 Nov 2023 13:41:45 -0700 Subject: [PATCH 446/494] sage.rings: Fix remaining doctests warnings --- src/sage/rings/integer.pyx | 2 ++ src/sage/rings/number_field/number_field.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index c3c87042caa..3ecd0bd986d 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -6231,7 +6231,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: numpy.array([1, 2, 3]).dtype dtype('int32') # 32-bit dtype('int64') # 64-bit + sage: # needs numpy (this has to be repeated until #36099 is fixed) + sage: import numpy sage: numpy.array(2**40).dtype dtype('int64') sage: numpy.array(2**400).dtype diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 8b0a9c4157d..b80d26123de 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1720,9 +1720,10 @@ def _element_constructor_(self, x, check=True): Check that :trac:`30961` is fixed:: - sage: QQi = i.parent() # needs sage.symbolic - sage: x = SR.var('x') # needs sage.symbolic - sage: QQi((x, x)) # needs sage.symbolic + sage: # needs sage.symbolic + sage: QQi = i.parent() + sage: x = SR.var('x') + sage: QQi((x, x)) Traceback (most recent call last): ... TypeError: unable to convert x to a rational From 1a54d8c6952b10fe1610f6374cba1f7b794f4f2c Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 4 Nov 2023 06:26:31 +0900 Subject: [PATCH 447/494] Revert changes likely to incur merge conflict --- .github/workflows/doc-build.yml | 50 +++++++++++++++---------------- .github/workflows/doc-publish.yml | 30 +++++++++---------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index aa2d10d013b..dd809aebd99 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -38,7 +38,7 @@ jobs: path: upstream name: upstream - build-doc: + build-docs: runs-on: ubuntu-latest container: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets:dev needs: [get_ci_fixes] @@ -108,7 +108,7 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Build doc + - name: Build docs id: docbuild if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success') # Always non-incremental because of the concern that @@ -125,23 +125,23 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Copy doc + - name: Copy docs id: copy if: always() && steps.docbuild.outcome == 'success' run: | set -ex - mkdir -p ./doc + mkdir -p ./docs (cd /sage/local/share/doc/sage/html && git commit -a -m 'new') # Wipe out chronic diffs between old doc and new doc (cd /sage/local/share/doc/sage/html && \ find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html - echo '' > ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - cat >> ./doc/CHANGES.html << EOF + echo '' > ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + cat >> ./docs/CHANGES.html << EOF EOF - echo '' >> ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./doc/diff.txt + echo '' >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF import re, html - with open('./doc/diff.txt', 'r') as f: + with open('./docs/diff.txt', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) out_blocks = [] @@ -175,28 +175,28 @@ jobs: path = 'html/' + match.group(1) out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) - with open('./doc/diff.html', 'w') as f: + with open('./docs/diff.html', 'w') as f: f.write(output_text) EOF - cat ./doc/diff.html >> ./doc/CHANGES.html - echo '' >> ./doc/CHANGES.html - echo '' >>./doc/CHANGES.html - rm ./doc/diff.txt ./doc/diff.html + cat ./docs/diff.html >> ./docs/CHANGES.html + echo '' >> ./docs/CHANGES.html + echo '' >>./docs/CHANGES.html + rm ./docs/diff.txt ./docs/diff.html (cd /sage/local/share/doc/sage/html && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them - cp -r -L /sage/local/share/doc/sage/html ./doc - cp /sage/local/share/doc/sage/index.html ./doc + cp -r -L /sage/local/share/doc/sage/html ./docs + cp /sage/local/share/doc/sage/index.html ./docs # Zip everything for increased performance - zip -r doc.zip doc + zip -r docs.zip docs - - name: Upload doc + - name: Upload docs if: always() && steps.copy.outcome == 'success' uses: actions/upload-artifact@v3 with: - name: doc - path: doc.zip + name: docs + path: docs.zip - name: Build live doc id: buildlivedoc diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 4f42490626c..1a42a22dbb8 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -1,4 +1,5 @@ -# Publish the built documentation by taking the artifact and uploading it to Netlify. +# Triggers after the documentation build has finished, +# taking the artifact and uploading it to netlify name: Publish documentation on: @@ -13,7 +14,7 @@ permissions: pull-requests: write jobs: - publish-doc: + upload-docs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' steps: @@ -24,11 +25,9 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} sourceRunId: ${{ github.event.workflow_run.id }} - # Once https://github.com/actions/download-artifact/issues/172 and/or - # https://github.com/actions/download-artifact/issues/60 is implemented, - # we can use the official download-artifact action. For now, we use the solution from - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow - - name: Download doc + # Once https://github.com/actions/download-artifact/issues/172 and/or https://github.com/actions/download-artifact/issues/60 is implemented, we can use the official download-artifact action + # For now use the solution from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow + - name: Download docs uses: actions/github-script@v6.4.0 with: script: | @@ -38,7 +37,7 @@ jobs: run_id: ${{github.event.workflow_run.id }}, }); var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "doc" + return artifact.name == "docs" })[0]; var download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, @@ -47,16 +46,16 @@ jobs: archive_format: 'zip', }); var fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/doc.zip', Buffer.from(download.data)); + fs.writeFileSync('${{github.workspace}}/docs.zip', Buffer.from(download.data)); - - name: Extract doc - run: unzip doc.zip -d doc && unzip doc/doc.zip -d doc/doc + - name: Extract docs + run: unzip docs.zip -d docs && unzip docs/docs.zip -d docs/docs - name: Deploy to Netlify id: deploy-netlify uses: netlify/actions/cli@master with: - args: deploy --dir=doc/doc/doc ${NETLIFY_PRODUCTION:+"--prod"} --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} + args: deploy --dir=docs/docs/docs ${NETLIFY_PRODUCTION:+"--prod"} --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} @@ -64,9 +63,8 @@ jobs: NETLIFY_MESSAGE: ${{ steps.source-run-info.outputs.pullRequestNumber }} NETLIFY_ALIAS: deploy-preview-${{ steps.source-run-info.outputs.pullRequestNumber }} - # Add deployment as status check, PR comment and annotation we could use - # the nwtgck/actions-netlify action for that, except for that it is not - # (yet) working in workflow_run context: # https://github.com/nwtgck/actions-netlify/issues/545 + # Add deployment as status check, PR comment and annotation + # we could use the nwtgck/actions-netlify action for that, except for that it is not (yet) working in workflow_run context: https://github.com/nwtgck/actions-netlify/issues/545 - name: Add/Update deployment status PR comment uses: marocchino/sticky-pull-request-comment@v2 with: @@ -74,7 +72,7 @@ jobs: header: preview-comment recreate: true message: | - :tada: [Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/html/en) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! + [Documentation preview for this PR](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/html/en) (built with commit ${{ steps.source-run-info.outputs.sourceHeadSha }}; [changes](${{ steps.deploy-netlify.outputs.NETLIFY_URL }}/CHANGES.html)) is ready! :tada: - name: Update deployment status PR check uses: myrotvorets/set-commit-status-action@v2.0.0 From 009d0334ea515a0d1483b591ebf4158454872252 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 4 Nov 2023 07:01:53 +0900 Subject: [PATCH 448/494] Run only in sagemath/sage repo --- .github/workflows/doc-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index dd809aebd99..e079fa04beb 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -200,7 +200,7 @@ jobs: - name: Build live doc id: buildlivedoc - if: always() && steps.copy.outcome == 'success' && github.ref == 'refs/heads/develop' + if: (success() || failure()) && steps.copy.outcome == 'success' && github.repository == 'sagemath/sage' && github.ref == 'refs/heads/develop' run: | set -ex export SAGE_USE_CDNS=yes @@ -215,7 +215,7 @@ jobs: - name: Copy live doc id: copylivedoc - if: always() && steps.buildlivedoc.outcome == 'success' + if: (success() || failure()) && steps.buildlivedoc.outcome == 'success' run: | set -ex mkdir -p ./livedoc @@ -224,7 +224,7 @@ jobs: zip -r livedoc.zip livedoc - name: Upload live doc - if: always() && steps.copylivedoc.outcome == 'success' + if: (success() || failure()) && steps.copylivedoc.outcome == 'success' uses: actions/upload-artifact@v3 with: name: livedoc From e7949c48f94cc1bb077222ab685bcd0429009143 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Sat, 4 Nov 2023 10:57:43 +0100 Subject: [PATCH 449/494] mark doctest has random --- src/sage/rings/polynomial/skew_polynomial_finite_field.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx index 8066670c4a0..99b3b7e64c9 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx @@ -1079,7 +1079,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): we can get different orderings:: sage: factorizations2 = [ F for F in a.factorizations() ] - sage: factorizations == factorizations2 + sage: factorizations == factorizations2 # random False sage: sorted(factorizations) == sorted(factorizations2) True From 37e66cbe93f9d4a8a546d16f77fb58da5035c08e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 06:22:04 -0700 Subject: [PATCH 450/494] src/sage/rings/number_field/number_field_rel.py: Use more block tags --- .../rings/number_field/number_field_rel.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index f7578b84ed3..9e1e22dccd4 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -1255,13 +1255,16 @@ def is_isomorphic_relative(self, other, base_isom=None): sage: R. = PolynomialRing(K) sage: m1 = 3*z9^4 - 4*z9^3 - 4*z9^2 + 3*z9 - 8 sage: L1 = K.extension(z^2 - m1, 'b1') - sage: G = K.galois_group(); gamma = G.gen() # needs sage.groups - sage: m2 = (gamma^2)(m1) # needs sage.groups - sage: L2 = K.extension(z^2 - m2, 'b2') # needs sage.groups - sage: L1.is_isomorphic_relative(L2) # needs sage.groups + + sage: # needs sage.groups + sage: G = K.galois_group(); gamma = G.gen() + sage: m2 = (gamma^2)(m1) + sage: L2 = K.extension(z^2 - m2, 'b2') + sage: L1.is_isomorphic_relative(L2) False - sage: L1.is_isomorphic(L2) # needs sage.groups + sage: L1.is_isomorphic(L2) True + sage: L3 = K.extension(z^4 - m1, 'b3') sage: L1.is_isomorphic_relative(L3) False @@ -1276,12 +1279,14 @@ def is_isomorphic_relative(self, other, base_isom=None): sage: L1cyc = Kcyc.extension(zcyc^2 - m1cyc, 'b1cyc') sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi1) True - sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi1) # needs sage.groups + + sage: # needs sage.groups + sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi1) False - sage: phi2 = K.hom([phi1((gamma^(-2))(z9))]) # needs sage.groups - sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi2) # needs sage.groups + sage: phi2 = K.hom([phi1((gamma^(-2))(z9))]) + sage: L1.is_isomorphic_relative(L1cyc, base_isom=phi2) False - sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi2) # needs sage.groups + sage: L2.is_isomorphic_relative(L1cyc, base_isom=phi2) True Omitting ``base_isom`` raises a :class:`ValueError` when the base fields are not identical:: From a1bdea9dd8623e097eb7625e45b43932aa0da25e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 06:24:16 -0700 Subject: [PATCH 451/494] src/sage/rings/padics/padic_ZZ_pX_element.pyx: Use more block tags --- src/sage/rings/padics/padic_ZZ_pX_element.pyx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/padics/padic_ZZ_pX_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_element.pyx index c3afb0e827d..b3f57329e8f 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_element.pyx @@ -459,17 +459,18 @@ cdef class pAdicZZpXElement(pAdicExtElement): TESTS:: + sage: # needs sage.geometry.polyhedron sage: R = ZpCA(5,5) sage: S. = ZZ[] sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 - sage: a.trace() # needs sage.geometry.polyhedron + sage: a.trace() 3*5 + 2*5^2 + 3*5^3 + 2*5^4 + O(5^5) - sage: a.trace() + b.trace() # needs sage.geometry.polyhedron + sage: a.trace() + b.trace() 4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5) - sage: (a+b).trace() # needs sage.geometry.polyhedron + sage: (a+b).trace() 4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5) sage: R = ZpFM(5,5) sage: S. = R[] @@ -477,11 +478,11 @@ cdef class pAdicZZpXElement(pAdicExtElement): sage: W. = R.ext(f) sage: a = (2+3*w)^7 sage: b = (6+w^3)^5 - sage: a.trace() # needs sage.geometry.polyhedron + sage: a.trace() 3*5 + 2*5^2 + 3*5^3 + 2*5^4 - sage: a.trace() + b.trace() # needs sage.geometry.polyhedron + sage: a.trace() + b.trace() 4*5 + 5^2 + 5^3 + 2*5^4 - sage: (a+b).trace() # needs sage.geometry.polyhedron + sage: (a+b).trace() 4*5 + 5^2 + 5^3 + 2*5^4 TESTS: From a1f134f48f62501c3974efce3f2f91c85d90f4b7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 06:30:34 -0700 Subject: [PATCH 452/494] src/sage/rings/padics/padic_generic_element.pyx: Use more block tags --- .../rings/padics/padic_generic_element.pyx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index dff932b3e0c..f4712d76c5d 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -2838,7 +2838,6 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: x = 1 - z sage: z.log().precision_absolute() -975 - sage: (x^5/5).precision_absolute() -570 sage: (x^25/25).precision_absolute() @@ -3706,22 +3705,22 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: elt in (elt^108).nth_root(108, all=True) True - sage: # needs sage.libs.flint + sage: # needs sage.libs.flint sage.libs.ntl sage: K. = ZqCA(3^2) - sage: S. = K[] # needs sage.libs.ntl + sage: S. = K[] sage: Z = (1+x)^3 + 3*x^2 sage: E = Z^2 + Z + 1 - sage: L. = K.extension(E) # needs sage.libs.ntl - sage: elt = L.random_element() # needs sage.libs.ntl - sage: elt in (elt^9).nth_root(9, all=True) # needs sage.libs.ntl + sage: L. = K.extension(E) + sage: elt = L.random_element() + sage: elt in (elt^9).nth_root(9, all=True) True - sage: elt = L.random_element() # needs sage.libs.ntl - sage: try: # needs sage.libs.ntl sage.rings.real_double + sage: elt = L.random_element() + sage: try: # needs sage.rings.real_double ....: assert elt in (elt^27).nth_root(27, all=True) ....: except sage.rings.padics.precision_error.PrecisionError: ....: pass - sage: elt = L.random_element() # needs sage.libs.ntl - sage: try: # needs sage.libs.ntl sage.rings.real_double + sage: elt = L.random_element() + sage: try: # needs sage.rings.real_double ....: assert elt in (elt^108).nth_root(108, all=True) ....: except sage.rings.padics.precision_error.PrecisionError: ....: pass From b28f62655508562977fa9a15c314e28b470d3071 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 06:34:12 -0700 Subject: [PATCH 453/494] git grep -l '#indirec' src/sage/rings/padics | xargs sed -E -i.bak 's/#indirect doctest ?/# indirect doctest/'; git grep -l '# indirec' src/sage/rings/padics | xargs sed -E -i.bak 's/([^ ]) # indirect doctest ?/\1 # indirect doctest/' --- src/sage/rings/padics/CA_template.pxi | 48 ++++++++--------- src/sage/rings/padics/CR_template.pxi | 54 +++++++++---------- src/sage/rings/padics/FM_template.pxi | 38 ++++++------- src/sage/rings/padics/FP_template.pxi | 50 ++++++++--------- .../padics/eisenstein_extension_generic.py | 2 +- src/sage/rings/padics/local_generic.py | 2 +- .../rings/padics/local_generic_element.pyx | 6 +-- .../rings/padics/padic_ZZ_pX_CA_element.pyx | 6 +-- .../rings/padics/padic_ZZ_pX_CR_element.pyx | 4 +- .../rings/padics/padic_ZZ_pX_FM_element.pyx | 16 +++--- src/sage/rings/padics/padic_base_generic.py | 14 ++--- src/sage/rings/padics/padic_base_leaves.py | 18 +++---- .../padics/padic_capped_absolute_element.pyx | 4 +- .../padics/padic_capped_relative_element.pyx | 4 +- .../rings/padics/padic_extension_generic.py | 8 +-- .../rings/padics/padic_extension_leaves.py | 18 +++---- .../rings/padics/padic_fixed_mod_element.pyx | 2 +- .../padics/padic_floating_point_element.pyx | 6 +-- src/sage/rings/padics/padic_generic.py | 2 +- .../rings/padics/padic_generic_element.pyx | 8 +-- src/sage/rings/padics/padic_printing.pyx | 8 +-- .../rings/padics/padic_template_element.pxi | 6 +-- src/sage/rings/padics/padic_valuation.py | 4 +- src/sage/rings/padics/pow_computer.pyx | 2 +- src/sage/rings/padics/pow_computer_ext.pyx | 10 ++-- src/sage/rings/padics/pow_computer_flint.pyx | 6 +-- .../padics/unramified_extension_generic.py | 2 +- 27 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/sage/rings/padics/CA_template.pxi b/src/sage/rings/padics/CA_template.pxi index 209157f0cec..f8493fabd44 100644 --- a/src/sage/rings/padics/CA_template.pxi +++ b/src/sage/rings/padics/CA_template.pxi @@ -69,13 +69,13 @@ cdef class CAElement(pAdicTemplateElement): TESTS:: sage: R = ZpCA(5) - sage: a = R(17,5); a #indirect doctest + sage: a = R(17,5); a # indirect doctest 2 + 3*5 + O(5^5) - sage: a = R(75, absprec = 5, relprec = 4); a #indirect doctest + sage: a = R(75, absprec = 5, relprec = 4); a # indirect doctest 3*5^2 + O(5^5) - sage: a = R(25/9, absprec = 5); a #indirect doctest + sage: a = R(25/9, absprec = 5); a # indirect doctest 4*5^2 + 2*5^3 + O(5^5) - sage: a = R(25/9, absprec = 5, relprec = 4); a #indirect doctest + sage: a = R(25/9, absprec = 5, relprec = 4); a # indirect doctest 4*5^2 + 2*5^3 + O(5^5) """ IF CELEMENT_IS_PY_OBJECT: @@ -145,7 +145,7 @@ cdef class CAElement(pAdicTemplateElement): TESTS:: - sage: ZpCA(5)(1).lift_to_precision(30) # indirect doctest + sage: ZpCA(5)(1).lift_to_precision(30) # indirect doctest Traceback (most recent call last): ... PrecisionError: precision higher than allowed by the precision cap @@ -205,7 +205,7 @@ cdef class CAElement(pAdicTemplateElement): sage: R = Zp(5, prec=10, type='capped-abs') sage: a = R(1) - sage: -a #indirect doctest + sage: -a # indirect doctest 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + O(5^10) """ cdef CAElement ans = self._new_c() @@ -221,7 +221,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(13, 4) - sage: R(2) + R(3) #indirect doctest + sage: R(2) + R(3) # indirect doctest 5 + O(13^4) sage: R(12) + R(1) 13 + O(13^4) @@ -245,7 +245,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(13, 4) - sage: R(10) - R(10) #indirect doctest + sage: R(10) - R(10) # indirect doctest O(13^4) sage: R(10) - R(11) 12 + 12*13 + 12*13^2 + 12*13^3 + O(13^4) @@ -277,7 +277,7 @@ cdef class CAElement(pAdicTemplateElement): 7 + 3*17 + 10*17^2 + 13*17^3 + 6*17^4 + 3*17^5 + 10*17^6 + 13*17^7 + 6*17^8 + 3*17^9 + 10*17^10 + 13*17^11 + 6*17^12 + 3*17^13 + 10*17^14 + 13*17^15 + 6*17^16 + 3*17^17 + 10*17^18 + 13*17^19 + O(17^20) - sage: ~R(-1) == R(-1) #indirect doctest + sage: ~R(-1) == R(-1) # indirect doctest True """ return ~self.parent().fraction_field()(self) @@ -289,7 +289,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(5) - sage: a = R(20,5); b = R(75, 4); a * b #indirect doctest + sage: a = R(20,5); b = R(75, 4); a * b # indirect doctest 2*5^3 + 2*5^4 + O(5^5) """ cdef CAElement right = _right @@ -317,7 +317,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(13, 4) - sage: R(2) / R(3) # indirect doctest + sage: R(2) / R(3) # indirect doctest 5 + 4*13 + 4*13^2 + 4*13^3 + O(13^4) sage: a = R(169 * 2) / R(13); a 2*13 + O(13^3) @@ -338,9 +338,9 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(3, 5) - sage: R(12).quo_rem(R(2)) # indirect doctest + sage: R(12).quo_rem(R(2)) # indirect doctest (2*3 + O(3^5), O(3^5)) - sage: R(2).quo_rem(R(12)) # indirect doctest + sage: R(2).quo_rem(R(12)) # indirect doctest (O(3^4), 2 + O(3^5)) sage: q, r = R(4).quo_rem(R(12)); q, r (1 + 2*3 + 2*3^3 + O(3^4), 1 + O(3^5)) @@ -806,7 +806,7 @@ cdef class CAElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpCA(37) - sage: R(17) == R(17+37^6) # indirect doctest + sage: R(17) == R(17+37^6) # indirect doctest False """ cdef CAElement right = _right @@ -832,7 +832,7 @@ cdef class CAElement(pAdicTemplateElement): sage: R = ZpCA(19) sage: a = R(19, 7); a 19 + O(19^7) - sage: a.lift_to_precision(12) # indirect doctest + sage: a.lift_to_precision(12) # indirect doctest 19 + O(19^12) sage: a.lift_to_precision(4) is a True @@ -1125,7 +1125,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): EXAMPLES:: sage: f = ZpCA(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -1145,7 +1145,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): EXAMPLES:: sage: f = ZpCA(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -1189,7 +1189,7 @@ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism): sage: R = ZpCA(5,4) sage: type(R(10,2)) - sage: R(10,2) # indirect doctest + sage: R(10,2) # indirect doctest 2*5 + O(5^2) sage: R(10,3,1) 2*5 + O(5^2) @@ -1319,7 +1319,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): EXAMPLES:: sage: f = ZpCA(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) @@ -1338,7 +1338,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): EXAMPLES:: sage: f = ZpCA(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) @@ -1379,7 +1379,7 @@ cdef class pAdicConvert_QQ_CA(Morphism): sage: R = ZpCA(5,4) sage: type(R(10/3,2)) - sage: R(10/3,2) # indirect doctest + sage: R(10/3,2) # indirect doctest 4*5 + O(5^2) sage: R(10/3,3,1) 4*5 + O(5^2) @@ -1490,7 +1490,7 @@ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism): sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = K.coerce_map_from(R) - sage: f(a, 3) # indirect doctest + sage: f(a, 3) # indirect doctest a + O(3^3) sage: b = 9*a sage: f(b, 3) @@ -1685,7 +1685,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K) - sage: f(K.gen()) # indirect doctest + sage: f(K.gen()) # indirect doctest a + O(3^20) """ cdef CRElement x = _x @@ -1721,7 +1721,7 @@ cdef class pAdicConvert_CA_frac_field(Morphism): sage: R. = ZqCA(27, implementation='FLINT') sage: K = R.fraction_field() sage: f = R.convert_map_from(K); a = K(a) - sage: f(a, 3) # indirect doctest + sage: f(a, 3) # indirect doctest a + O(3^3) sage: b = 9*a sage: f(b, 3) diff --git a/src/sage/rings/padics/CR_template.pxi b/src/sage/rings/padics/CR_template.pxi index 799b0ce56c5..14a2f1686c0 100644 --- a/src/sage/rings/padics/CR_template.pxi +++ b/src/sage/rings/padics/CR_template.pxi @@ -94,21 +94,21 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: sage: R = Zp(5) - sage: R(15) #indirect doctest + sage: R(15) # indirect doctest 3*5 + O(5^21) sage: R(15, absprec=5) 3*5 + O(5^5) sage: R(15, relprec=5) 3*5 + O(5^6) - sage: R(75, absprec = 10, relprec = 9) #indirect doctest + sage: R(75, absprec = 10, relprec = 9) # indirect doctest 3*5^2 + O(5^10) - sage: R(25/9, relprec = 5) #indirect doctest + sage: R(25/9, relprec = 5) # indirect doctest 4*5^2 + 2*5^3 + 5^5 + 2*5^6 + O(5^7) - sage: R(25/9, relprec = 4, absprec = 5) #indirect doctest + sage: R(25/9, relprec = 4, absprec = 5) # indirect doctest 4*5^2 + 2*5^3 + O(5^5) sage: R = Zp(5,5) - sage: R(25/9) #indirect doctest + sage: R(25/9) # indirect doctest 4*5^2 + 2*5^3 + 5^5 + 2*5^6 + O(5^7) sage: R(25/9, absprec = 5) 4*5^2 + 2*5^3 + O(5^5) @@ -116,9 +116,9 @@ cdef class CRElement(pAdicTemplateElement): 4*5^2 + 2*5^3 + 5^5 + O(5^6) sage: R = Zp(5); S = Zp(5, 6) - sage: S(R(17)) # indirect doctest + sage: S(R(17)) # indirect doctest 2 + 3*5 + O(5^6) - sage: S(R(17),4) # indirect doctest + sage: S(R(17),4) # indirect doctest 2 + 3*5 + O(5^4) sage: T = Qp(5); a = T(1/5) - T(1/5) sage: R(a) @@ -129,7 +129,7 @@ cdef class CRElement(pAdicTemplateElement): O(5^17) sage: R = Zp(5); S = ZpCA(5) - sage: R(S(17, 5)) #indirect doctest + sage: R(S(17, 5)) # indirect doctest 2 + 3*5 + O(5^5) """ IF CELEMENT_IS_PY_OBJECT: @@ -156,7 +156,7 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: - sage: R = Zp(5); R(0) #indirect doctest + sage: R = Zp(5); R(0) # indirect doctest 0 """ csetzero(self.unit, self.prime_pow) @@ -169,7 +169,7 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: - sage: R = Zp(5); R(0, 5) #indirect doctest + sage: R = Zp(5); R(0, 5) # indirect doctest O(5^5) """ csetzero(self.unit, self.prime_pow) @@ -190,7 +190,7 @@ cdef class CRElement(pAdicTemplateElement): sage: R. = ZqCR(25) sage: S. = ZZ[] sage: W. = R.ext(x^2 - 5) - sage: w * (w+1) #indirect doctest + sage: w * (w+1) # indirect doctest w + w^2 + O(w^41) """ cdef type t = type(self) @@ -263,7 +263,7 @@ cdef class CRElement(pAdicTemplateElement): TESTS:: sage: R = Zp(5) - sage: R(6) + R(4) #indirect doctest + sage: R(6) + R(4) # indirect doctest 2*5 + O(5^20) """ cdef long diff @@ -313,7 +313,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(5, 20, 'capped-rel', 'val-unit') - sage: R(5) + (-R(5)) # indirect doctest + sage: R(5) + (-R(5)) # indirect doctest O(5^21) sage: -R(1) 95367431640624 + O(5^20) @@ -341,7 +341,7 @@ cdef class CRElement(pAdicTemplateElement): 18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5) sage: b=R(-5/2); b 7 + 9*19 + 9*19^2 + 9*19^3 + 9*19^4 + O(19^5) - sage: a+b #indirect doctest + sage: a+b # indirect doctest 6 + 9*19 + 9*19^2 + 9*19^3 + 9*19^4 + O(19^5) """ cdef CRElement ans @@ -381,7 +381,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(13, 4) - sage: R(10) - R(10) #indirect doctest + sage: R(10) - R(10) # indirect doctest O(13^4) sage: R(10) - R(11) 12 + 12*13 + 12*13^2 + 12*13^3 + O(13^4) @@ -459,7 +459,7 @@ cdef class CRElement(pAdicTemplateElement): 2*5 + 4*5^3 + 3*5^4 + O(5^11) sage: b = R(2387625, 16); b 5^3 + 4*5^5 + 2*5^6 + 5^8 + 5^9 + O(5^16) - sage: a * b # indirect doctest + sage: a * b # indirect doctest 2*5^4 + 2*5^6 + 4*5^7 + 2*5^8 + 3*5^10 + 5^11 + 3*5^12 + 4*5^13 + O(5^14) """ cdef CRElement ans @@ -491,7 +491,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(5,6) - sage: R(17) / R(21) #indirect doctest + sage: R(17) / R(21) # indirect doctest 2 + 4*5^2 + 3*5^3 + 4*5^4 + O(5^6) sage: a = R(50) / R(5); a 2*5 + O(5^7) @@ -644,7 +644,7 @@ cdef class CRElement(pAdicTemplateElement): 18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5) sage: K(5)^30 11 + 14*19 + 19^2 + 7*19^3 + O(19^5) - sage: K(5, 3)^19 #indirect doctest + sage: K(5, 3)^19 # indirect doctest 5 + 3*19 + 11*19^3 + O(19^4) `p`-adic exponents are also supported:: @@ -745,7 +745,7 @@ cdef class CRElement(pAdicTemplateElement): sage: a = Zp(5)(17); a 2 + 3*5 + O(5^20) - sage: a << 2 #indirect doctest + sage: a << 2 # indirect doctest 2*5^2 + 3*5^3 + O(5^22) sage: a << -2 O(5^18) @@ -814,7 +814,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(3, 5) - sage: R(12).quo_rem(R(2)) # indirect doctest + sage: R(12).quo_rem(R(2)) # indirect doctest (2*3 + O(3^6), 0) sage: R(2).quo_rem(R(12)) (O(3^4), 2 + O(3^5)) @@ -1475,7 +1475,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Qp(5); a = R(1) - sage: a.valuation() #indirect doctest + sage: a.valuation() # indirect doctest 0 sage: b = (a << 4); b.valuation() 4 @@ -1534,7 +1534,7 @@ cdef class CRElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(5) - sage: hash(R(17)) #indirect doctest + sage: hash(R(17)) # indirect doctest 17 sage: hash(R(-1)) @@ -1659,7 +1659,7 @@ cdef class pAdicCoercion_ZZ_CR(RingHomomorphism): sage: R = Zp(5,4) sage: type(R(10,2)) - sage: R(10,2) # indirect doctest + sage: R(10,2) # indirect doctest 2*5 + O(5^2) sage: R(10,3,1) 2*5 + O(5^2) @@ -1879,7 +1879,7 @@ cdef class pAdicCoercion_QQ_CR(RingHomomorphism): sage: R = Qp(5,4) sage: type(R(10/3,2)) - sage: R(10/3,2) # indirect doctest + sage: R(10/3,2) # indirect doctest 4*5 + O(5^2) sage: R(10/3,3,1) 4*5 + O(5^2) @@ -2080,7 +2080,7 @@ cdef class pAdicConvert_QQ_CR(Morphism): sage: R = Zp(5,4) sage: type(R(10/3,2)) - sage: R(10/3,2) # indirect doctest + sage: R(10/3,2) # indirect doctest 4*5 + O(5^2) sage: R(10/3,3,1) 4*5 + O(5^2) @@ -2213,7 +2213,7 @@ cdef class pAdicCoercion_CR_frac_field(RingHomomorphism): sage: f(a, 3) a + O(3^3) sage: b = 9*a - sage: f(b, 3) # indirect doctest + sage: f(b, 3) # indirect doctest a*3^2 + O(3^3) sage: f(b, 4, 1) a*3^2 + O(3^3) @@ -2442,7 +2442,7 @@ cdef class pAdicConvert_CR_frac_field(Morphism): sage: f(a, 3) a + O(3^3) sage: b = 9*a - sage: f(b, 3) # indirect doctest + sage: f(b, 3) # indirect doctest a*3^2 + O(3^3) sage: f(b, 4, 1) a*3^2 + O(3^3) diff --git a/src/sage/rings/padics/FM_template.pxi b/src/sage/rings/padics/FM_template.pxi index 43c6082a525..3e6abe53a7f 100644 --- a/src/sage/rings/padics/FM_template.pxi +++ b/src/sage/rings/padics/FM_template.pxi @@ -74,10 +74,10 @@ cdef class FMElement(pAdicTemplateElement): TESTS:: sage: R = ZpFM(5) - sage: a = R(17,5); a #indirect doctest + sage: a = R(17,5); a # indirect doctest 2 + 3*5 sage: R = ZpFM(5,5) - sage: a = R(25/9); a #indirect doctest + sage: a = R(25/9); a # indirect doctest 4*5^2 + 2*5^3 """ IF CELEMENT_IS_PY_OBJECT: @@ -95,7 +95,7 @@ cdef class FMElement(pAdicTemplateElement): TESTS:: - sage: R = ZpFM(5); R(6) * R(7) #indirect doctest + sage: R = ZpFM(5); R(6) * R(7) # indirect doctest 2 + 3*5 + 5^2 """ cdef type t = type(self) @@ -131,7 +131,7 @@ cdef class FMElement(pAdicTemplateElement): TESTS:: - sage: ZpFM(5)(1).lift_to_precision(30) # indirect doctest + sage: ZpFM(5)(1).lift_to_precision(30) # indirect doctest 1 """ pass @@ -186,7 +186,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'fixed-mod', 'series') - sage: -R(7) #indirect doctest + sage: -R(7) # indirect doctest 6*7 + 6*7^2 + 6*7^3 """ cdef FMElement ans = self._new_c() @@ -205,7 +205,7 @@ cdef class FMElement(pAdicTemplateElement): 6 + 5*7^3 sage: y = R(1373); y 1 + 4*7^3 - sage: x + y #indirect doctest + sage: x + y # indirect doctest 7 + 2*7^3 """ cdef FMElement right = _right @@ -225,7 +225,7 @@ cdef class FMElement(pAdicTemplateElement): 6 + 5*7^3 sage: y = R(1373); y 1 + 4*7^3 - sage: x - y #indirect doctest + sage: x - y # indirect doctest 5 + 7^3 """ cdef FMElement right = _right @@ -266,7 +266,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'fixed-mod', 'series') - sage: R(3) * R(2) #indirect doctest + sage: R(3) * R(2) # indirect doctest 6 sage: R(1/2) * R(2) 1 @@ -285,7 +285,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'fixed-mod', 'series') - sage: R(3) / R(2) #indirect doctest + sage: R(3) / R(2) # indirect doctest 5 + 3*7 + 3*7^2 + 3*7^3 sage: R(5) / R(0) Traceback (most recent call last): @@ -311,7 +311,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpFM(3, 5) - sage: R(12).quo_rem(R(2)) # indirect doctest + sage: R(12).quo_rem(R(2)) # indirect doctest (2*3, 0) sage: R(2).quo_rem(R(12)) (0, 2) @@ -359,7 +359,7 @@ cdef class FMElement(pAdicTemplateElement): 10 + 7*11 + 11^2 + 5*11^3 + 4*11^4 sage: R(1/2)^5 == R(1/32) True - sage: R(3)^1000 #indirect doctest + sage: R(3)^1000 # indirect doctest 1 + 4*11^2 + 3*11^3 + 7*11^4 TESTS: @@ -574,7 +574,7 @@ cdef class FMElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpFM(5); a = R(0); b = R(75) - sage: bool(a), bool(b) # indirect doctest + sage: bool(a), bool(b) # indirect doctest (False, True) """ return not ciszero(self.value, self.prime_pow) @@ -639,7 +639,7 @@ cdef class FMElement(pAdicTemplateElement): sage: R = ZpFM(5) sage: a = R(17); b = R(0,3); c = R(85,7); d = R(2, 1) - sage: any([a == b, a == c, b == c, b == d, c == d, a == d]) # indirect doctest + sage: any([a == b, a == c, b == c, b == d, c == d, a == d]) # indirect doctest False sage: all([a == a, b == b, c == c, d == d]) True @@ -659,7 +659,7 @@ cdef class FMElement(pAdicTemplateElement): sage: R = ZpFM(5) sage: a = R(77, 2); a 2 + 3*5^2 - sage: a.lift_to_precision(17) # indirect doctest + sage: a.lift_to_precision(17) # indirect doctest 2 + 3*5^2 """ return self @@ -810,7 +810,7 @@ cdef class FMElement(pAdicTemplateElement): TESTS:: - sage: R = ZpFM(5, 5); R(0).valuation() #indirect doctest + sage: R = ZpFM(5, 5); R(0).valuation() # indirect doctest 5 sage: R = Zp(17, 4,'fixed-mod') sage: a = R(2*17^2) @@ -904,7 +904,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): EXAMPLES:: sage: f = ZpFM(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -924,7 +924,7 @@ cdef class pAdicCoercion_ZZ_FM(RingHomomorphism): EXAMPLES:: sage: f = ZpFM(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -1088,7 +1088,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): EXAMPLES:: sage: f = ZpFM(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) @@ -1107,7 +1107,7 @@ cdef class pAdicConvert_QQ_FM(Morphism): EXAMPLES:: sage: f = ZpFM(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) diff --git a/src/sage/rings/padics/FP_template.pxi b/src/sage/rings/padics/FP_template.pxi index 904fcc73bbf..254d627630b 100644 --- a/src/sage/rings/padics/FP_template.pxi +++ b/src/sage/rings/padics/FP_template.pxi @@ -112,13 +112,13 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: sage: R = ZpFP(5) - sage: a = R(17,5); a #indirect doctest + sage: a = R(17,5); a # indirect doctest 2 + 3*5 - sage: R(15) #indirect doctest + sage: R(15) # indirect doctest 3*5 sage: R = ZpFP(5,5) - sage: a = R(25/9); a #indirect doctest + sage: a = R(25/9); a # indirect doctest 4*5^2 + 2*5^3 + 5^5 + 2*5^6 sage: R(ZpCR(5)(25/9)) == a True @@ -153,7 +153,7 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: - sage: R = Zp(5); R(0) #indirect doctest + sage: R = Zp(5); R(0) # indirect doctest 0 """ csetzero(self.unit, self.prime_pow) @@ -165,7 +165,7 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: - sage: R = Zp(5); R(0) #indirect doctest + sage: R = Zp(5); R(0) # indirect doctest 0 """ csetone(self.unit, self.prime_pow) @@ -177,14 +177,14 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: - sage: R = ZpFP(5); R(6) * R(7) #indirect doctest + sage: R = ZpFP(5); R(6) * R(7) # indirect doctest 2 + 3*5 + 5^2 sage: # needs sage.libs.flint sage: R. = ZqFP(25) sage: S. = ZZ[] sage: W. = R.ext(x^2 - 5) - sage: w * (w+1) #indirect doctest + sage: w * (w+1) # indirect doctest w + w^2 """ cdef type t = type(self) @@ -222,7 +222,7 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: - sage: ZpFP(5)(1).lift_to_precision(30) # indirect doctest + sage: ZpFP(5)(1).lift_to_precision(30) # indirect doctest 1 """ pass @@ -251,7 +251,7 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: sage: R = ZpFP(5) - sage: R(6) + R(4) #indirect doctest + sage: R(6) + R(4) # indirect doctest 2*5 """ cdef long diff @@ -320,7 +320,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'floating-point', 'series') - sage: -R(7) #indirect doctest + sage: -R(7) # indirect doctest 6*7 + 6*7^2 + 6*7^3 + 6*7^4 """ cdef FPElement ans = self._new_c() @@ -343,7 +343,7 @@ cdef class FPElement(pAdicTemplateElement): 6 + 5*7^3 sage: y = R(1373); y 1 + 4*7^3 - sage: x + y #indirect doctest + sage: x + y # indirect doctest 7 + 2*7^3 """ cdef FPElement ans @@ -387,7 +387,7 @@ cdef class FPElement(pAdicTemplateElement): 6 + 5*7^3 sage: y = R(1373); y 1 + 4*7^3 - sage: x - y #indirect doctest + sage: x - y # indirect doctest 5 + 7^3 """ cdef FPElement ans @@ -462,7 +462,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'floating-point', 'series') - sage: R(3) * R(2) #indirect doctest + sage: R(3) * R(2) # indirect doctest 6 sage: R(1/2) * R(2) 1 @@ -495,7 +495,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: sage: R = Zp(7, 4, 'floating-point', 'series') - sage: R(3) / R(2) #indirect doctest + sage: R(3) / R(2) # indirect doctest 5 + 3*7 + 3*7^2 + 3*7^3 sage: R(5) / R(0) infinity @@ -536,7 +536,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpFP(3, 5) - sage: R(12).quo_rem(R(2)) # indirect doctest + sage: R(12).quo_rem(R(2)) # indirect doctest (2*3, 0) sage: R(2).quo_rem(R(12)) (0, 2) @@ -598,7 +598,7 @@ cdef class FPElement(pAdicTemplateElement): 10 + 7*11 + 11^2 + 5*11^3 + 4*11^4 sage: R(1/2)^5 == R(1/32) True - sage: R(3)^1000 #indirect doctest + sage: R(3)^1000 # indirect doctest 1 + 4*11^2 + 3*11^3 + 7*11^4 sage: R(11)^-1 11^-1 @@ -785,7 +785,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: - sage: ZpFP(5,5)(1/3) # indirect doctest + sage: ZpFP(5,5)(1/3) # indirect doctest 2 + 3*5 + 5^2 + 3*5^3 + 5^4 sage: ~QpFP(5,5)(0) infinity @@ -904,7 +904,7 @@ cdef class FPElement(pAdicTemplateElement): EXAMPLES:: sage: R = ZpFP(5); a = R(0); b = R(75) - sage: bool(a), bool(b) # indirect doctest + sage: bool(a), bool(b) # indirect doctest (False, True) """ return not very_pos_val(self.ordp) @@ -979,7 +979,7 @@ cdef class FPElement(pAdicTemplateElement): sage: R = ZpFP(5) sage: a = R(17); b = R(0,3); c = R(85,7); d = R(2, 1) - sage: any([a == b, a == c, b == c, b == d, c == d, a == d]) # indirect doctest + sage: any([a == b, a == c, b == c, b == d, c == d, a == d]) # indirect doctest False sage: all([a == a, b == b, c == c, d == d]) True @@ -999,7 +999,7 @@ cdef class FPElement(pAdicTemplateElement): sage: R = ZpFP(5) sage: a = R(77, 2); a 2 - sage: a.lift_to_precision(17) # indirect doctest + sage: a.lift_to_precision(17) # indirect doctest 2 """ return self @@ -1179,7 +1179,7 @@ cdef class FPElement(pAdicTemplateElement): TESTS:: - sage: R = ZpFP(5, 5); R(1).valuation() #indirect doctest + sage: R = ZpFP(5, 5); R(1).valuation() # indirect doctest 0 sage: R = Zp(17, 4,'floating-point') sage: a = R(2*17^2) @@ -1286,7 +1286,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): EXAMPLES:: sage: f = ZpFP(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -1306,7 +1306,7 @@ cdef class pAdicCoercion_ZZ_FP(RingHomomorphism): EXAMPLES:: sage: f = ZpFP(5).coerce_map_from(ZZ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f True sage: g(6) @@ -1701,7 +1701,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): EXAMPLES:: sage: f = ZpFP(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) @@ -1720,7 +1720,7 @@ cdef class pAdicConvert_QQ_FP(Morphism): EXAMPLES:: sage: f = ZpFP(5).convert_map_from(QQ) - sage: g = copy(f) # indirect doctest + sage: g = copy(f) # indirect doctest sage: g == f # todo: comparison not implemented True sage: g(1/6) diff --git a/src/sage/rings/padics/eisenstein_extension_generic.py b/src/sage/rings/padics/eisenstein_extension_generic.py index 2e3f702a0aa..10e198abfb9 100644 --- a/src/sage/rings/padics/eisenstein_extension_generic.py +++ b/src/sage/rings/padics/eisenstein_extension_generic.py @@ -32,7 +32,7 @@ def __init__(self, poly, prec, print_mode, names, element_class): sage: A = Zp(7,10) sage: S. = A[] # needs sage.libs.ntl - sage: B. = A.ext(x^2+7) #indirect doctest # needs sage.libs.ntl sage.rings.padics + sage: B. = A.ext(x^2+7) # indirect doctest # needs sage.libs.ntl sage.rings.padics """ pAdicExtensionGeneric.__init__(self, poly, prec, print_mode, names, element_class) #self._precompute() diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 17d5c22398c..a88d74f605f 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -228,7 +228,7 @@ def _latex_(self): EXAMPLES:: - sage: latex(Zq(27,names='a')) #indirect doctest # needs sage.libs.ntl + sage: latex(Zq(27,names='a')) # indirect doctest # needs sage.libs.ntl \Bold{Z}_{3^{3}} """ return self._repr_(do_latex=True) diff --git a/src/sage/rings/padics/local_generic_element.pyx b/src/sage/rings/padics/local_generic_element.pyx index fab407a01fd..df5c454e865 100644 --- a/src/sage/rings/padics/local_generic_element.pyx +++ b/src/sage/rings/padics/local_generic_element.pyx @@ -47,7 +47,7 @@ cdef class LocalGenericElement(CommutativeRingElement): sage: R = Zp(7, 4, 'capped-rel', 'series'); R(3)/R(5) 2 + 4*7 + 5*7^2 + 2*7^3 + O(7^4) - sage: R(2/3) / R(1/3) #indirect doctest + sage: R(2/3) / R(1/3) # indirect doctest 2 + O(7^4) sage: R(49) / R(7) 7 + O(7^5) @@ -417,7 +417,7 @@ cdef class LocalGenericElement(CommutativeRingElement): EXAMPLES:: sage: R = Zp(5); a = R(17) - sage: latex(a) #indirect doctest + sage: latex(a) # indirect doctest 2 + 3 \cdot 5 + O(5^{20}) """ # TODO: add a bunch more documentation of latexing elements @@ -443,7 +443,7 @@ cdef class LocalGenericElement(CommutativeRingElement): sage: R = Zp(7, 4, 'capped-rel', 'series'); a = R(12); b = R(5); a - b 7 + O(7^4) - sage: R(4/3) - R(1/3) #indirect doctest + sage: R(4/3) - R(1/3) # indirect doctest 1 + O(7^4) """ # this doctest doesn't actually test this function, since _sub_ is overridden. diff --git a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx index b7d7b2789fe..fb62a0695f9 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx @@ -956,7 +956,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: z = (1 + w)^5; z 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) - sage: y = z.to_fraction_field(); y #indirect doctest + sage: y = z.to_fraction_field(); y # indirect doctest 1 + w^5 + w^6 + 2*w^7 + 4*w^8 + 3*w^10 + w^12 + 4*w^13 + 4*w^14 + 4*w^15 + 4*w^16 + 4*w^17 + 4*w^20 + w^21 + 4*w^24 + O(w^25) sage: y.parent() 5-adic Eisenstein Extension Field in w defined by x^5 + 75*x^3 - 15*x^2 + 125*x - 5 @@ -1477,7 +1477,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b # indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 + O(w^25) sage: a * 0 O(w^25) @@ -1764,7 +1764,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement): sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: a = W(566) - sage: a._const_term_test() #indirect doctest + sage: a._const_term_test() # indirect doctest 566 """ return ZZ_pX_ConstTerm(self.value) diff --git a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx index 319c017fe67..f4f8bce971f 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx @@ -2173,7 +2173,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a - b #indirect doctest + sage: a - b # indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) sage: W(218) 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 + O(w^25) @@ -2199,7 +2199,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b # indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 + O(w^25) sage: a * 0 0 diff --git a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx index e388c5c6376..e3785c4adff 100644 --- a/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx +++ b/src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx @@ -410,7 +410,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) sage: z = (1 + w)^5 - 1 - sage: loads(dumps(z)) == z #indirect doctest + sage: loads(dumps(z)) == z # indirect doctest True """ self.prime_pow.restore_top_context() @@ -782,7 +782,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a*b #indirect doctest + sage: a*b # indirect doctest 4 + 3*w^5 + w^7 + 2*w^9 + 4*w^11 + 3*w^12 + 2*w^13 + w^14 + 2*w^15 + 3*w^16 + 4*w^17 + 4*w^18 + 2*w^19 + 2*w^21 + 4*w^22 + 2*w^23 + w^24 sage: a * 0 @@ -806,7 +806,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: a = W(329) sage: b = W(111) - sage: a - b #indirect doctest + sage: a - b # indirect doctest 3 + 3*w^5 + w^7 + 2*w^9 + 3*w^10 + 4*w^11 + 2*w^13 + 2*w^14 + w^15 + 4*w^16 + 2*w^18 + 3*w^19 + 2*w^20 + 3*w^21 + w^22 + w^24 sage: W(218) @@ -829,7 +829,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: S. = R[] sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5 sage: W. = R.ext(f) - sage: W(125) / W(14) #indirect doctest + sage: W(125) / W(14) # indirect doctest 4*w^15 + 4*w^17 + w^19 + w^20 + w^23 + 2*w^24 sage: 1 / W(14) == ~W(14) True @@ -1705,9 +1705,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: W. = R.ext(f) sage: y = W(775); y w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 - sage: (y>>9).expansion() #indirect doctest + sage: (y>>9).expansion() # indirect doctest [0, 1, 0, 4, 0, 2, 1, 2, 4, 1, 0, 1, 2, 3, 1, 1, 4, 1, 2, 4, 1, 0, 0, 3] - sage: (y>>9).expansion(lift_mode='smallest') #indirect doctest + sage: (y>>9).expansion(lift_mode='smallest') # indirect doctest [0, 1, 0, -1, 0, 2, 1, 2, 0, 1, 2, 1, 1, -1, -1, 2, -2, 0, -2, -2, -2, 0, -2, -2, 2] sage: w^10 - w^12 + 2*w^14 + w^15 + 2*w^16 + w^18 + 2*w^19 + w^20 + w^21 - w^22 - w^23 + 2*w^24 w^10 + 4*w^12 + 2*w^14 + w^15 + 2*w^16 + 4*w^17 + w^18 + w^20 + 2*w^21 + 3*w^22 + w^23 + w^24 @@ -1717,9 +1717,9 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement): sage: A. = R.ext(g) sage: y = 75 + 45*a + 1200*a^2; y 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 - sage: list(y.expansion()) #indirect doctest + sage: list(y.expansion()) # indirect doctest [[], [0, 4], [3, 1, 3], [0, 0, 4], [0, 0, 1]] - sage: list(y.expansion(lift_mode='smallest')) #indirect doctest + sage: list(y.expansion(lift_mode='smallest')) # indirect doctest [[], [0, -1], [-2, 2, -2], [1], [0, 0, 2]] sage: 5*((-2*5 + 25) + (-1 + 2*5)*a + (-2*5 + 2*125)*a^2) 4*a*5 + (3*a^2 + a + 3)*5^2 + 4*a^2*5^3 + a^2*5^4 diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index b049cb6ea4c..792e99996c5 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -40,7 +40,7 @@ def __init__(self, p, prec, print_mode, names, element_class): TESTS:: - sage: R = Zp(5) #indirect doctest + sage: R = Zp(5) # indirect doctest """ if self.is_relaxed(): from sage.rings.padics.pow_computer_flint import PowComputer_flint @@ -92,21 +92,21 @@ def _repr_(self, do_latex=False): EXAMPLES:: - sage: K = Zp(17); K #indirect doctest + sage: K = Zp(17); K # indirect doctest 17-adic Ring with capped relative precision 20 sage: latex(K) \Bold{Z}_{17} - sage: K = ZpCA(17); K #indirect doctest + sage: K = ZpCA(17); K # indirect doctest 17-adic Ring with capped absolute precision 20 sage: latex(K) \Bold{Z}_{17} - sage: K = ZpFP(17); K #indirect doctest + sage: K = ZpFP(17); K # indirect doctest 17-adic Ring with floating precision 20 sage: latex(K) \Bold{Z}_{17} sage: K = ZpFM(7); K 7-adic Ring of fixed modulus 7^20 - sage: latex(K) #indirect doctest + sage: latex(K) # indirect doctest \Bold{Z}_{7} sage: K = ZpLF(2); K # indirect doctest doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. @@ -114,11 +114,11 @@ def _repr_(self, do_latex=False): 2-adic Ring with lattice-float precision sage: latex(K) \Bold{Z}_{2} - sage: K = Qp(17); K #indirect doctest + sage: K = Qp(17); K # indirect doctest 17-adic Field with capped relative precision 20 sage: latex(K) \Bold{Q}_{17} - sage: K = QpFP(17); K #indirect doctest + sage: K = QpFP(17); K # indirect doctest 17-adic Field with floating precision 20 sage: latex(K) \Bold{Q}_{17} diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py index 32c3630a552..4f48c187efc 100644 --- a/src/sage/rings/padics/padic_base_leaves.py +++ b/src/sage/rings/padics/padic_base_leaves.py @@ -225,7 +225,7 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpCR(next_prime(10^60)) #indirect doctest + sage: R = ZpCR(next_prime(10^60)) # indirect doctest sage: type(R) @@ -323,7 +323,7 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpCA(next_prime(10^60)) #indirect doctest + sage: R = ZpCA(next_prime(10^60)) # indirect doctest sage: type(R) @@ -423,7 +423,7 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpFP(next_prime(10^60)) #indirect doctest + sage: R = ZpFP(next_prime(10^60)) # indirect doctest sage: type(R) @@ -517,7 +517,7 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = ZpFM(next_prime(10^60)) #indirect doctest + sage: R = ZpFM(next_prime(10^60)) # indirect doctest sage: type(R) @@ -558,7 +558,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = ZpFM(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 sage: K.has_coerce_map_from(ZZ) True @@ -612,8 +612,8 @@ class pAdicFieldCappedRelative(pAdicFieldBaseGeneric, pAdicCappedRelativeFieldGe EXAMPLES:: - sage: K = Qp(17, 1000000) #indirect doctest - sage: K = Qp(101) #indirect doctest + sage: K = Qp(17, 1000000) # indirect doctest + sage: K = Qp(101) # indirect doctest """ @@ -761,7 +761,7 @@ def __init__(self, p, prec, print_mode, names): EXAMPLES:: - sage: R = QpFP(next_prime(10^60)) #indirect doctest + sage: R = QpFP(next_prime(10^60)) # indirect doctest sage: type(R) @@ -794,7 +794,7 @@ def _coerce_map_from_(self, R): EXAMPLES:: sage: K = QpFP(17) - sage: K(1) + 1 #indirect doctest + sage: K(1) + 1 # indirect doctest 2 sage: K.has_coerce_map_from(ZZ) True diff --git a/src/sage/rings/padics/padic_capped_absolute_element.pyx b/src/sage/rings/padics/padic_capped_absolute_element.pyx index 6291f13ad9c..7b2be478769 100644 --- a/src/sage/rings/padics/padic_capped_absolute_element.pyx +++ b/src/sage/rings/padics/padic_capped_absolute_element.pyx @@ -117,7 +117,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: sage: R = ZpCA(5) - sage: pari(R(1777)) #indirect doctest # needs sage.libs.pari + sage: pari(R(1777)) # indirect doctest # needs sage.libs.pari 2 + 5^2 + 4*5^3 + 2*5^4 + O(5^20) sage: pari(R(0,0)) # needs sage.libs.pari O(5^0) @@ -130,7 +130,7 @@ cdef class pAdicCappedAbsoluteElement(CAElement): EXAMPLES:: - sage: R = ZpCA(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = ZpCA(5, 10); a = R(17); pari(a) # indirect doctest 2 + 3*5 + O(5^10) sage: pari(R(0,5)) # needs sage.libs.pari O(5^5) diff --git a/src/sage/rings/padics/padic_capped_relative_element.pyx b/src/sage/rings/padics/padic_capped_relative_element.pyx index 81b48bff84d..aea7ecd6114 100644 --- a/src/sage/rings/padics/padic_capped_relative_element.pyx +++ b/src/sage/rings/padics/padic_capped_relative_element.pyx @@ -201,7 +201,7 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R = Zp(17, 10); a = ~R(14); pari(a) #indirect doctest + sage: R = Zp(17, 10); a = ~R(14); pari(a) # indirect doctest 11 + 3*17 + 17^2 + 6*17^3 + 13*17^4 + 15*17^5 + 10*17^6 + 3*17^7 + 17^8 + 6*17^9 + O(17^10) sage: pari(R(0)) # needs sage.libs.pari 0 @@ -216,7 +216,7 @@ cdef class pAdicCappedRelativeElement(CRElement): EXAMPLES:: - sage: R = Zp(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = Zp(5, 10); a = R(17); pari(a) # indirect doctest 2 + 3*5 + O(5^10) sage: pari(R(0)) # needs sage.libs.pari 0 diff --git a/src/sage/rings/padics/padic_extension_generic.py b/src/sage/rings/padics/padic_extension_generic.py index 11fb92c01a4..accb68ccfc4 100644 --- a/src/sage/rings/padics/padic_extension_generic.py +++ b/src/sage/rings/padics/padic_extension_generic.py @@ -51,7 +51,7 @@ def __init__(self, poly, prec, print_mode, names, element_class): sage: R = Zp(5,5) sage: S. = R[] sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 - sage: W. = R.ext(f) #indirect doctest + sage: W. = R.ext(f) # indirect doctest """ #type checking done in factory self._given_poly = poly @@ -74,7 +74,7 @@ def _coerce_map_from_(self, R): sage: R = Zp(5); S. = ZZ[]; f = x^5 + 25*x - 5; W. = R.ext(f) sage: L = W.fraction_field() - sage: w + L(w) #indirect doctest + sage: w + L(w) # indirect doctest 2*w + O(w^101) sage: w + R(5,2) w + w^5 + O(w^10) @@ -143,7 +143,7 @@ def _repr_(self, do_latex=False): '\\Bold{Z}_{7^{3}}' sage: x = polygen(ZZ, 'x') sage: R2. = R.ext(x^2 + 7) - sage: R2 #indirect doctest + sage: R2 # indirect doctest 7-adic Eisenstein Extension Ring in t defined by x^2 + 7 sage: R2._latex_() '\\Bold{Z}_{7}[t]' @@ -157,7 +157,7 @@ def _repr_(self, do_latex=False): sage: K1._latex_() '\\Bold{Q}_{7^{3}}' sage: K2. = K.ext(x^2+7) - sage: K2 #indirect doctest + sage: K2 # indirect doctest 7-adic Eisenstein Extension Field in t defined by x^2 + 7 sage: K2._latex_() '\\Bold{Q}_{7}[t]' diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index 2bb7b2439f8..ef0ed071a2c 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -126,7 +126,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqCR(27,10000); R #indirect doctest # needs sage.libs.ntl + sage: R. = ZqCR(27,10000); R # indirect doctest # needs sage.libs.ntl 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 sage: R. = ZqCR(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl @@ -184,7 +184,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = Qq(27,10000); R #indirect doctest # needs sage.libs.ntl + sage: R. = Qq(27,10000); R # indirect doctest # needs sage.libs.ntl 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl @@ -270,7 +270,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqCA(27,10000); R #indirect doctest # needs sage.libs.flint + sage: R. = ZqCA(27,10000); R # indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 sage: R. = ZqCA(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint @@ -328,7 +328,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqFM(27,10000); R #indirect doctest # needs sage.libs.flint + sage: R. = ZqFM(27,10000); R # indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 sage: R. = ZqFM(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint @@ -390,7 +390,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = ZqFP(27,10000); R #indirect doctest # needs sage.libs.flint + sage: R. = ZqFP(27,10000); R # indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1 sage: R. = ZqFP(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.flint 1000000000000000000000000000057 @@ -447,7 +447,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: - sage: R. = QqFP(27,10000); R #indirect doctest # needs sage.libs.flint + sage: R. = QqFP(27,10000); R # indirect doctest # needs sage.libs.flint 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1 sage: R. = Qq(next_prime(10^30)^3, 3); R.prime() # needs sage.libs.ntl 1000000000000000000000000000057 @@ -517,7 +517,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = Zp(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl + sage: W. = R.ext(f); W # indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Ring in w defined by x^3 + 9*x - 3 sage: W.precision_cap() # needs sage.libs.ntl 30000 @@ -572,7 +572,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = Qp(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl + sage: W. = R.ext(f); W # indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Field in w defined by x^3 + 9*x - 3 sage: W.precision_cap() # needs sage.libs.ntl 30000 @@ -683,7 +683,7 @@ def __init__(self, exact_modulus, poly, prec, print_mode, shift_seed, names, imp EXAMPLES:: sage: R = ZpFM(3, 10000, print_pos=False); S. = ZZ[]; f = x^3 + 9*x - 3 - sage: W. = R.ext(f); W #indirect doctest # needs sage.libs.ntl + sage: W. = R.ext(f); W # indirect doctest # needs sage.libs.ntl 3-adic Eisenstein Extension Ring in w defined by x^3 + 9*x - 3 sage: W.precision_cap() # needs sage.libs.ntl 30000 diff --git a/src/sage/rings/padics/padic_fixed_mod_element.pyx b/src/sage/rings/padics/padic_fixed_mod_element.pyx index 99ecfd88d8e..3c6928f3320 100644 --- a/src/sage/rings/padics/padic_fixed_mod_element.pyx +++ b/src/sage/rings/padics/padic_fixed_mod_element.pyx @@ -183,7 +183,7 @@ cdef class pAdicFixedModElement(FMElement): EXAMPLES:: sage: R = ZpCA(5) - sage: pari(R(1777)) #indirect doctest # needs sage.libs.pari + sage: pari(R(1777)) # indirect doctest # needs sage.libs.pari 2 + 5^2 + 4*5^3 + 2*5^4 + O(5^20) """ return self._to_gen() diff --git a/src/sage/rings/padics/padic_floating_point_element.pyx b/src/sage/rings/padics/padic_floating_point_element.pyx index 821d694d0ee..8e52ab95460 100644 --- a/src/sage/rings/padics/padic_floating_point_element.pyx +++ b/src/sage/rings/padics/padic_floating_point_element.pyx @@ -164,7 +164,7 @@ cdef class pAdicFloatingPointElement(FPElement): TESTS:: - sage: ZpFP(5)(0).lift() #indirect doctest + sage: ZpFP(5)(0).lift() # indirect doctest 0 sage: R = QpFP(5); R(0).lift() 0 @@ -197,7 +197,7 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R = ZpFP(17, 10); a = ~R(14); pari(a) #indirect doctest + sage: R = ZpFP(17, 10); a = ~R(14); pari(a) # indirect doctest 11 + 3*17 + 17^2 + 6*17^3 + 13*17^4 + 15*17^5 + 10*17^6 + 3*17^7 + 17^8 + 6*17^9 + O(17^10) sage: pari(R(0)) # needs sage.libs.pari 0 @@ -210,7 +210,7 @@ cdef class pAdicFloatingPointElement(FPElement): EXAMPLES:: - sage: R = ZpFP(5, 10); a = R(17); pari(a) #indirect doctest + sage: R = ZpFP(5, 10); a = R(17); pari(a) # indirect doctest 2 + 3*5 + O(5^10) sage: pari(R(0)) # needs sage.libs.pari 0 diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index 7c562d77e03..8abc87020fe 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -1836,7 +1836,7 @@ def _call_with_args(self, x, args=(), kwds={}): EXAMPLES:: sage: f = Zp(2).convert_map_from(Zmod(128)) - sage: f(7, 5) # indirect doctest + sage: f(7, 5) # indirect doctest 1 + 2 + 2^2 + O(2^5) """ R = self.codomain() diff --git a/src/sage/rings/padics/padic_generic_element.pyx b/src/sage/rings/padics/padic_generic_element.pyx index f4712d76c5d..88797ddf4ed 100644 --- a/src/sage/rings/padics/padic_generic_element.pyx +++ b/src/sage/rings/padics/padic_generic_element.pyx @@ -67,7 +67,7 @@ cdef class pAdicGenericElement(LocalGenericElement): :: sage: R = Zp(5); a = R(5, 6); b = R(5 + 5^6, 8) - sage: a == b #indirect doctest + sage: a == b # indirect doctest True :: @@ -329,7 +329,7 @@ cdef class pAdicGenericElement(LocalGenericElement): EXAMPLES:: sage: R = ZpCA(5); a = R(129378); b = R(2398125) - sage: a // b #indirect doctest + sage: a // b # indirect doctest 1 + 2*5 + 2*5^3 + 4*5^4 + 5^6 + 5^7 + 5^8 + 4*5^9 + 2*5^10 + 4*5^11 + 4*5^12 + 2*5^13 + 3*5^14 + O(5^16) sage: a / b 4*5^-4 + 3*5^-3 + 2*5^-2 + 5^-1 + 3 + 3*5 + 4*5^2 + 2*5^4 + 2*5^6 + 4*5^7 + 5^9 + 5^10 + 5^11 + O(5^12) @@ -375,7 +375,7 @@ cdef class pAdicGenericElement(LocalGenericElement): sage: R = Zp(7,4,'capped-rel','series'); a = R(1/3); a 5 + 4*7 + 4*7^2 + 4*7^3 + O(7^4) - sage: a[0] #indirect doctest + sage: a[0] # indirect doctest doctest:warning ... DeprecationWarning: __getitem__ is changing to match the behavior of number fields. Please use expansion instead. @@ -2110,7 +2110,7 @@ cdef class pAdicGenericElement(LocalGenericElement): :: - sage: Zp(5)(5).valuation() #indirect doctest + sage: Zp(5)(5).valuation() # indirect doctest 1 """ raise NotImplementedError diff --git a/src/sage/rings/padics/padic_printing.pyx b/src/sage/rings/padics/padic_printing.pyx index 2386bd7c197..caf19c7bdf9 100644 --- a/src/sage/rings/padics/padic_printing.pyx +++ b/src/sage/rings/padics/padic_printing.pyx @@ -379,7 +379,7 @@ cdef class pAdicPrinter_class(SageObject): TESTS:: - sage: R = Qp(7, print_mode='bars', print_sep='&') #indirect doctest + sage: R = Qp(7, print_mode='bars', print_sep='&') # indirect doctest sage: R = Zp(5, print_mode='digits', print_max_terms=10) Traceback (most recent call last): @@ -614,7 +614,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: - sage: Zp(5)._printer #indirect doctest + sage: Zp(5)._printer # indirect doctest series printer for 5-adic Ring with capped relative precision 20 """ return "%s printer for %s"%(self._print_mode(), self.ring) @@ -830,7 +830,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: sage: P = Zp(17)._printer - sage: P._base_p_list(1298734,True) #indirect doctest + sage: P._base_p_list(1298734,True) # indirect doctest [2, 15, 5, 9, 15] sage: P._base_p_list(1298734,False) [2, -2, 6, -8, -1, 1] @@ -900,7 +900,7 @@ cdef class pAdicPrinter_class(SageObject): EXAMPLES:: - sage: R = Zp(7,4,'capped-rel','val-unit'); a = R(364); a #indirect doctest + sage: R = Zp(7,4,'capped-rel','val-unit'); a = R(364); a # indirect doctest 7 * 52 + O(7^5) sage: print(a.str('terse')) 364 + O(7^5) diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index bbfc6bbbc33..7dcb624b666 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -833,7 +833,7 @@ cdef long padic_pow_helper(celement result, celement base, long base_val, long b sage: a = R(9283732, 6); b = R(17^3*237, 7) sage: str(a) '...692AAF' - sage: str(a^b) # indirect doctest + sage: str(a^b) # indirect doctest '...55GA0001' sage: str((a // R.teichmuller(15))^b) '...55GA0001' @@ -906,7 +906,7 @@ cdef class ExpansionIter(): EXAMPLES:: sage: E = Zp(5,4)(373).expansion() - sage: I = iter(E) # indirect doctest + sage: I = iter(E) # indirect doctest sage: type(I) """ @@ -1039,7 +1039,7 @@ cdef class ExpansionIterable(): EXAMPLES:: - sage: E = Zp(5,4)(373).expansion() # indirect doctest + sage: E = Zp(5,4)(373).expansion() # indirect doctest sage: type(E) """ diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index 52115963362..cb0207c10d4 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -388,7 +388,7 @@ def create_object(self, version, key, **extra_args): EXAMPLES:: - sage: ZZ.valuation(5) # indirect doctest + sage: ZZ.valuation(5) # indirect doctest 5-adic valuation """ @@ -872,7 +872,7 @@ class pAdicValuation_padic(pAdicValuation_base): EXAMPLES:: - sage: v = Qp(2).valuation(); v #indirect doctest + sage: v = Qp(2).valuation(); v # indirect doctest 2-adic valuation TESTS:: diff --git a/src/sage/rings/padics/pow_computer.pyx b/src/sage/rings/padics/pow_computer.pyx index 4d6c24df928..83aa163d36b 100644 --- a/src/sage/rings/padics/pow_computer.pyx +++ b/src/sage/rings/padics/pow_computer.pyx @@ -563,7 +563,7 @@ cdef class PowComputer_base(PowComputer_class): EXAMPLES:: sage: PC = PowComputer(3, 5, 10) - sage: PC._pow_mpz_t_top_test() #indirect doctest + sage: PC._pow_mpz_t_top_test() # indirect doctest 59049 """ return self.top_power diff --git a/src/sage/rings/padics/pow_computer_ext.pyx b/src/sage/rings/padics/pow_computer_ext.pyx index 748005974a3..82140353d10 100644 --- a/src/sage/rings/padics/pow_computer_ext.pyx +++ b/src/sage/rings/padics/pow_computer_ext.pyx @@ -682,7 +682,7 @@ cdef class PowComputer_ext(PowComputer_class): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 6, 6, 12, False, ntl.ZZ_pX([-5,0,1],5^6),'small', 'e',ntl.ZZ_pX([1],5^6)) - sage: PC._pow_mpz_t_top_test() #indirect doctest + sage: PC._pow_mpz_t_top_test() # indirect doctest 15625 """ ZZ_to_mpz(self.temp_m, &self.top_power) @@ -918,7 +918,7 @@ cdef class PowComputer_ZZ_pX(PowComputer_ext): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'FM', 'e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_context_capdiv_test(8) #indirect doctest + sage: PC._restore_context_capdiv_test(8) # indirect doctest """ cdef Integer _n = Integer(n) self.restore_context_capdiv(mpz_get_si(_n.value)) @@ -2098,7 +2098,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): EXAMPLES:: sage: PC = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) - sage: PC._restore_top_context_test() #indirect doctest + sage: PC._restore_top_context_test() # indirect doctest """ self.top_context.restore_c() @@ -2158,7 +2158,7 @@ cdef class PowComputer_ZZ_pX_big(PowComputer_ZZ_pX): sage: A = PowComputer_ext_maker(5, 5, 10, 20, False, ntl.ZZ_pX([-5,0,1],5^10), 'big','e',ntl.ZZ_pX([1],5^10)) sage: a = ntl.ZZ_pX([129223,1231],5^10) sage: b = ntl.ZZ_pX([289741,323],5^10) - sage: A._get_top_modulus_test(a, b) #indirect doctest + sage: A._get_top_modulus_test(a, b) # indirect doctest [1783058 7785200] """ return &self.top_mod @@ -2307,7 +2307,7 @@ cdef class PowComputer_ZZ_pX_big_Eis(PowComputer_ZZ_pX_big): sage: from sage.rings.padics.pow_computer_ext import ZZ_pX_eis_shift_test sage: A = PowComputer_ext_maker(5, 10, 10, 40, False, ntl.ZZ_pX([-5,75,15,0,1],5^10), 'big', 'e',ntl.ZZ_pX([1,-15,-3],5^10)) - sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) #indirect doctest + sage: ZZ_pX_eis_shift_test(A, [0, 1], 1, 5) # indirect doctest [1] sage: ZZ_pX_eis_shift_test(A, [0, 0, 1], 1, 5) [0 1] diff --git a/src/sage/rings/padics/pow_computer_flint.pyx b/src/sage/rings/padics/pow_computer_flint.pyx index 2525a8bd040..6d0837f7ee5 100644 --- a/src/sage/rings/padics/pow_computer_flint.pyx +++ b/src/sage/rings/padics/pow_computer_flint.pyx @@ -69,7 +69,7 @@ cdef class PowComputer_flint(PowComputer_class): sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker sage: R. = ZZ[]; f = x^3 - 8*x - 2 - sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest + sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest sage: TestSuite(A).run() """ @@ -103,8 +103,8 @@ cdef class PowComputer_flint(PowComputer_class): sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker sage: R. = ZZ[]; f = x^3 - 8*x - 2 - sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest - sage: A._test_pickling() # indirect doctest + sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest + sage: A._test_pickling() # indirect doctest """ return PowComputer_flint_maker, (self.prime, self.cache_limit, self.prec_cap, self.ram_prec_cap, self.in_field, self.polynomial(), self._prec_type) diff --git a/src/sage/rings/padics/unramified_extension_generic.py b/src/sage/rings/padics/unramified_extension_generic.py index 1a0b52eefde..3ca4d07b2b0 100644 --- a/src/sage/rings/padics/unramified_extension_generic.py +++ b/src/sage/rings/padics/unramified_extension_generic.py @@ -44,7 +44,7 @@ def __init__(self, poly, prec, print_mode, names, element_class): EXAMPLES:: - sage: R. = Zq(27) #indirect doctest # needs sage.libs.ntl + sage: R. = Zq(27) # indirect doctest # needs sage.libs.ntl """ #base = poly.base_ring() #if base.is_field(): From 957f80d658da2656eb8b1d5a1e3d0ac93f851331 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 06:43:24 -0700 Subject: [PATCH 454/494] src/sage/rings/valuation/augmented_valuation.py: Remove redundant tag, doctest cosmetics --- src/sage/rings/valuation/augmented_valuation.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 7fac06e57ef..5823c90f375 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -451,7 +451,7 @@ def augmentation_chain(self): sage: w = v.augmentation(x, 1) sage: w.augmentation_chain() [[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ], - Gauss valuation induced by 2-adic valuation] + Gauss valuation induced by 2-adic valuation] For performance reasons, (and to simplify the underlying implementation,) trivial augmentations might get dropped. You should @@ -461,7 +461,7 @@ def augmentation_chain(self): sage: ww = w.augmentation(x, 2) sage: ww.augmentation_chain() [[ Gauss valuation induced by 2-adic valuation, v(x) = 2 ], - Gauss valuation induced by 2-adic valuation] + Gauss valuation induced by 2-adic valuation] """ return [self] + self._base_valuation.augmentation_chain() @@ -1394,7 +1394,6 @@ def lift(self, F, report_coefficients=False): sage: w = v.augmentation(x^2 + x + u, 1/2) sage: y = w.residue_ring().gen() sage: u1 = w.residue_ring().base().gen() - sage: # needs sage.libs.ntl sage: w.lift(1) 1 + O(2^10) sage: w.lift(0) @@ -1799,7 +1798,11 @@ def simplify(self, f, error=None, force=False, effective_degree=None, size_heuri sage: v = F.valuation(v) sage: G = y^2 - 2*x^5 + 8*x^3 + 80*x^2 + 128*x + 192 sage: v.mac_lane_approximants(G) - [[ Gauss valuation induced by Valuation on rational function field induced by [ Gauss valuation induced by 2-adic valuation, v(x) = 3/2, v(x^2 + 8) = 13/4, v(x^4 + 16*x^2 + 32*x + 64) = 20/3 ], v(y + 4*x + 8) = 31/8 ]] + [[ Gauss valuation induced by + Valuation on rational function field induced by + [ Gauss valuation induced by 2-adic valuation, v(x) = 3/2, + v(x^2 + 8) = 13/4, v(x^4 + 16*x^2 + 32*x + 64) = 20/3 ], + v(y + 4*x + 8) = 31/8 ]] """ f = self.domain().coerce(f) From 5e4ea1124c746277272c60601783c0b9262fc65c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 09:16:39 -0700 Subject: [PATCH 455/494] src/sage/rings/valuation/augmented_valuation.py: Remove stray character in docstring --- src/sage/rings/valuation/augmented_valuation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 5823c90f375..6b23dab9d90 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -1783,7 +1783,7 @@ def simplify(self, f, error=None, force=False, effective_degree=None, size_heuri (u + 1)*2^-1 + O(2^4) Check that :trac:`25607` has been resolved, i.e., the coefficients - in the following example are small::` + in the following example are small:: sage: # needs sage.libs.ntl sage.rings.number_field sage: R. = QQ[] From 0eaed3c4a04f90e9747ae17fa3e0f55373af5373 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 15:16:31 -0700 Subject: [PATCH 456/494] .github/workflows/macos.yml: Use xcode_13.2.1 with macOS 11 so that homebrew does not complain --- .github/workflows/macos.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5b448cec1bb..91c38807e76 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -21,16 +21,16 @@ on: osversion_xcodeversion_toxenv_tuples: description: 'Stringified JSON object' default: >- - [["latest", "", "homebrew-macos-usrlocal-minimal"], - ["latest", "", "homebrew-macos-usrlocal-standard"], - ["11", "xcode_11.7", "homebrew-macos-usrlocal-standard"], - ["12", "", "homebrew-macos-usrlocal-standard"], - ["13", "xcode_15.0", "homebrew-macos-usrlocal-standard"], - ["latest", "", "homebrew-macos-usrlocal-maximal"], - ["latest", "", "homebrew-macos-usrlocal-python3_xcode-standard"], - ["latest", "", "conda-forge-macos-minimal"], - ["latest", "", "conda-forge-macos-standard"], - ["latest", "", "conda-forge-macos-maximal"]] + [["latest", "", "homebrew-macos-usrlocal-minimal"], + ["latest", "", "homebrew-macos-usrlocal-standard"], + ["11", "xcode_13.2.1", "homebrew-macos-usrlocal-standard"], + ["12", "", "homebrew-macos-usrlocal-standard"], + ["13", "xcode_15.0", "homebrew-macos-usrlocal-standard"], + ["latest", "", "homebrew-macos-usrlocal-maximal"], + ["latest", "", "homebrew-macos-usrlocal-python3_xcode-standard"], + ["latest", "", "conda-forge-macos-minimal"], + ["latest", "", "conda-forge-macos-standard"], + ["latest", "", "conda-forge-macos-maximal"]] type: string extra_sage_packages: description: 'Extra Sage packages to install as system packages' From 166eb132f6179d73357989403fb29417eb8cb36e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 15:18:47 -0700 Subject: [PATCH 457/494] .github/workflows/ci-macos.yml (dist): Fix use of 'git describe' --- .github/workflows/ci-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 9482eb9632b..2d101f7878a 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -85,7 +85,7 @@ jobs: run: | git config --global user.email "nobody@example.com" git config --global user.name "Sage GitHub CI" - SAGE_ROOT=. SAGE_SRC=./src src/bin/sage-update-version $(git describe) || echo "(ignoring error)" + SAGE_ROOT=. SAGE_SRC=./src src/bin/sage-update-version $(git describe --tags) || echo "(ignoring error)" - name: make dist run: | ./configure --enable-download-from-upstream-url && make dist From 543cd2dca5f88a23aacd5c50132b32639a87c083 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Sat, 4 Nov 2023 15:52:23 -0700 Subject: [PATCH 458/494] Check whether command-line tools includes the executable ld-classic, and if so, set LDFLAGS to use it. --- src/bin/sage-env | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index 72aa454bf4a..b4fca91b314 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -277,15 +277,6 @@ export UNAME=`uname | sed 's/CYGWIN.*/CYGWIN/' ` # Mac OS X-specific setup if [ "$UNAME" = "Darwin" ]; then export MACOSX_VERSION=`uname -r | awk -F. '{print $1}'` - # Try to identify command-line tools version. - # See https://apple.stackexchange.com/q/180957/351985. - XCLT_VERSION=`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version: / { print $NF }' | cut -d. -f-1` - # If this didn't produce an integer, set to 0. - case $XCLT_VERSION in - ''|*[!0-9]*) export XCLT_VERSION=0 ;; # bad - *) : ;; # good - esac - export XCLT_VERSION # Work around problems on recent OS X crashing with an error message # "... may have been in progress in another thread when fork() was called" # when objective-C functions are called after fork(). See Issue #25921. @@ -383,7 +374,10 @@ if [ -n "$PYTHONHOME" ]; then fi if [ -n "$SAGE_LOCAL" ]; then - if [ "$UNAME" = "Darwin" ] && [ "$XCLT_VERSION" -ge 15 ]; then + # On OS X, test whether "ld-classic" is present in the installed + # version of the command-line tools. If so, we add "-ld_classic" + # to LD_FLAGS. See #36599. + if [ "$UNAME" = "Darwin" ] && [ -x "$(xcode-select -p)/usr/bin/ld-classic" ] ; then LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-ld_classic,-rpath,$SAGE_LOCAL/lib $LDFLAGS" else LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS" From eff3be578a8efae01d8cdfcb8d79f7dd2341f2e3 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 5 Nov 2023 09:05:59 +0900 Subject: [PATCH 459/494] Check sagemath/sage also on publish-live-doc job --- .github/workflows/doc-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 1a42a22dbb8..961809e343e 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -94,7 +94,7 @@ jobs: publish-live-doc: runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop' + if: github.event.workflow_run.conclusion == 'success' && github.repository == 'sagemath/sage' && github.event.workflow_run.head_branch == 'develop' steps: - name: Download live doc uses: actions/github-script@v6.4.1 From 9ce90a05ffcd798eb96c06cf9be6555e0d1baa03 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 5 Nov 2023 09:16:38 +0900 Subject: [PATCH 460/494] Soothe linter --- src/sage/misc/sageinspect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 8c734ecd36d..0fa8551a271 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1806,8 +1806,10 @@ def formatannotation(annotation, base_module=None): return annotation.__module__ + '.' + annotation.__qualname__ return repr(annotation) + _formatannotation = formatannotation + def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults=None, annotations={}, formatarg=str, From ebef87aa8db942ce8ffff5723a68d9e44b03b949 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Sun, 5 Nov 2023 15:03:35 +0100 Subject: [PATCH 461/494] Updated SageMath version to 10.2.rc0 --- CITATION.cff | 4 ++-- VERSION.txt | 2 +- build/pkgs/configure/checksums.ini | 6 +++--- build/pkgs/configure/package-version.txt | 2 +- build/pkgs/sage_conf/install-requires.txt | 2 +- build/pkgs/sage_docbuild/install-requires.txt | 2 +- build/pkgs/sage_setup/install-requires.txt | 2 +- build/pkgs/sage_sws2rst/install-requires.txt | 2 +- build/pkgs/sagelib/install-requires.txt | 2 +- build/pkgs/sagemath_bliss/install-requires.txt | 2 +- build/pkgs/sagemath_categories/install-requires.txt | 2 +- build/pkgs/sagemath_coxeter3/install-requires.txt | 2 +- build/pkgs/sagemath_environment/install-requires.txt | 2 +- build/pkgs/sagemath_mcqd/install-requires.txt | 2 +- build/pkgs/sagemath_meataxe/install-requires.txt | 2 +- build/pkgs/sagemath_objects/install-requires.txt | 2 +- build/pkgs/sagemath_repl/install-requires.txt | 2 +- build/pkgs/sagemath_sirocco/install-requires.txt | 2 +- build/pkgs/sagemath_tdlib/install-requires.txt | 2 +- pkgs/sage-conf/VERSION.txt | 2 +- pkgs/sage-conf_conda/VERSION.txt | 2 +- pkgs/sage-conf_pypi/VERSION.txt | 2 +- pkgs/sage-docbuild/VERSION.txt | 2 +- pkgs/sage-setup/VERSION.txt | 2 +- pkgs/sage-sws2rst/VERSION.txt | 2 +- pkgs/sagemath-bliss/VERSION.txt | 2 +- pkgs/sagemath-categories/VERSION.txt | 2 +- pkgs/sagemath-coxeter3/VERSION.txt | 2 +- pkgs/sagemath-environment/VERSION.txt | 2 +- pkgs/sagemath-mcqd/VERSION.txt | 2 +- pkgs/sagemath-meataxe/VERSION.txt | 2 +- pkgs/sagemath-objects/VERSION.txt | 2 +- pkgs/sagemath-repl/VERSION.txt | 2 +- pkgs/sagemath-sirocco/VERSION.txt | 2 +- pkgs/sagemath-tdlib/VERSION.txt | 2 +- src/VERSION.txt | 2 +- src/bin/sage-version.sh | 6 +++--- src/sage/version.py | 6 +++--- 38 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 27438597f31..bcd3dad6665 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.2.beta9 +version: 10.2.rc0 doi: 10.5281/zenodo.593563 -date-released: 2023-10-30 +date-released: 2023-11-05 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index b2bf34c0be8..a43284eebe1 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.2.beta9, Release Date: 2023-10-30 +SageMath version 10.2.rc0, Release Date: 2023-11-05 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index 7467d40d64c..bae48b7cfe0 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=75db52b3b9bc744c79bd958dfecc7e90bbf4591e -md5=ee29fe6ac8fed617f118dd9f546eee19 -cksum=2457963166 +sha1=41ec9a0bdf6e5982204b26ce2593e4b5a1863c96 +md5=8ea80ef7438ed62345de677dc921af2e +cksum=2979893163 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 0222b113c74..6a758846d8a 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -ec00fc5c59415d7f6c8c139749c7b0c81f100e1a +be0b5cf887fefcdf31df70be0a62b10b7929f28c diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt index 1387216d0d4..4b66d1b0602 100644 --- a/build/pkgs/sage_conf/install-requires.txt +++ b/build/pkgs/sage_conf/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.2b9 +sage-conf ~= 10.2rc0 diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt index 530594cb2f7..cebed4e3b62 100644 --- a/build/pkgs/sage_docbuild/install-requires.txt +++ b/build/pkgs/sage_docbuild/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.2b9 +sage-docbuild ~= 10.2rc0 diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt index 5a9a50b1773..1631564eec7 100644 --- a/build/pkgs/sage_setup/install-requires.txt +++ b/build/pkgs/sage_setup/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.2b9 +sage-setup ~= 10.2rc0 diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt index 8f0dd4150d7..628374d5f1a 100644 --- a/build/pkgs/sage_sws2rst/install-requires.txt +++ b/build/pkgs/sage_sws2rst/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.2b9 +sage-sws2rst ~= 10.2rc0 diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt index fe389de2e2e..6004e85c25d 100644 --- a/build/pkgs/sagelib/install-requires.txt +++ b/build/pkgs/sagelib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.2b9 +sagemath-standard ~= 10.2rc0 diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt index dabe7e52643..5ea4526cc33 100644 --- a/build/pkgs/sagemath_bliss/install-requires.txt +++ b/build/pkgs/sagemath_bliss/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.2b9 +sagemath-bliss ~= 10.2rc0 diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt index eab5b455322..1d37a18c187 100644 --- a/build/pkgs/sagemath_categories/install-requires.txt +++ b/build/pkgs/sagemath_categories/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.2b9 +sagemath-categories ~= 10.2rc0 diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt index c07ca4d5a32..8d6115b1868 100644 --- a/build/pkgs/sagemath_coxeter3/install-requires.txt +++ b/build/pkgs/sagemath_coxeter3/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.2b9 +sagemath-coxeter3 ~= 10.2rc0 diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt index 7745d13c50c..c870e97dca1 100644 --- a/build/pkgs/sagemath_environment/install-requires.txt +++ b/build/pkgs/sagemath_environment/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.2b9 +sagemath-environment ~= 10.2rc0 diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt index 34d46c650c9..cff0dac0026 100644 --- a/build/pkgs/sagemath_mcqd/install-requires.txt +++ b/build/pkgs/sagemath_mcqd/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.2b9 +sagemath-mcqd ~= 10.2rc0 diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt index 3012f831c3a..464942fef75 100644 --- a/build/pkgs/sagemath_meataxe/install-requires.txt +++ b/build/pkgs/sagemath_meataxe/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.2b9 +sagemath-meataxe ~= 10.2rc0 diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt index 35022da8fde..663b7d78f8b 100644 --- a/build/pkgs/sagemath_objects/install-requires.txt +++ b/build/pkgs/sagemath_objects/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.2b9 +sagemath-objects ~= 10.2rc0 diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt index 4c33d1b3eb0..917144d154c 100644 --- a/build/pkgs/sagemath_repl/install-requires.txt +++ b/build/pkgs/sagemath_repl/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.2b9 +sagemath-repl ~= 10.2rc0 diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt index bd55a958d68..896662f1b95 100644 --- a/build/pkgs/sagemath_sirocco/install-requires.txt +++ b/build/pkgs/sagemath_sirocco/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.2b9 +sagemath-sirocco ~= 10.2rc0 diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt index 2e291c70e25..c26900d9abf 100644 --- a/build/pkgs/sagemath_tdlib/install-requires.txt +++ b/build/pkgs/sagemath_tdlib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.2b9 +sagemath-tdlib ~= 10.2rc0 diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-conf_conda/VERSION.txt +++ b/pkgs/sage-conf_conda/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/src/VERSION.txt b/src/VERSION.txt index d0cd2bc56e3..7694f7787b5 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.2.beta9 +10.2.rc0 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index 392f585e5de..d6b42fe389d 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.2.beta9' -SAGE_RELEASE_DATE='2023-10-30' -SAGE_VERSION_BANNER='SageMath version 10.2.beta9, Release Date: 2023-10-30' +SAGE_VERSION='10.2.rc0' +SAGE_RELEASE_DATE='2023-11-05' +SAGE_VERSION_BANNER='SageMath version 10.2.rc0, Release Date: 2023-11-05' diff --git a/src/sage/version.py b/src/sage/version.py index f00a3e839af..9d384e5af6e 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.2.beta9' -date = '2023-10-30' -banner = 'SageMath version 10.2.beta9, Release Date: 2023-10-30' +version = '10.2.rc0' +date = '2023-11-05' +banner = 'SageMath version 10.2.rc0, Release Date: 2023-11-05' From fb22d1cdbf4e3870c7cf3995d5d0780735481ed1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 08:40:50 -0800 Subject: [PATCH 462/494] src/sage/misc/sageinspect.py: Fix pycodestyle complaint --- src/sage/misc/sageinspect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 8c734ecd36d..0fa8551a271 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1806,8 +1806,10 @@ def formatannotation(annotation, base_module=None): return annotation.__module__ + '.' + annotation.__qualname__ return repr(annotation) + _formatannotation = formatannotation + def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults=None, annotations={}, formatarg=str, From 7dabb0a656dcbf6d670be0bd0faebbc36240b9ad Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 15:16:19 -0800 Subject: [PATCH 463/494] build/pkgs/prompt_toolkit/distros/conda.txt: Use version range as in install-requires.txt --- build/pkgs/prompt_toolkit/distros/conda.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/prompt_toolkit/distros/conda.txt b/build/pkgs/prompt_toolkit/distros/conda.txt index 29392dfc5b3..bfb1ed6a874 100644 --- a/build/pkgs/prompt_toolkit/distros/conda.txt +++ b/build/pkgs/prompt_toolkit/distros/conda.txt @@ -1 +1 @@ -prompt_toolkit +prompt_toolkit>=3.0.5,<3.0.25 From c15418d962c6f984a4ddaebb146639125385f366 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 6 Nov 2023 10:39:51 +0900 Subject: [PATCH 464/494] Continue on error of building live doc --- .github/workflows/doc-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index e079fa04beb..bd789779245 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -201,6 +201,7 @@ jobs: - name: Build live doc id: buildlivedoc if: (success() || failure()) && steps.copy.outcome == 'success' && github.repository == 'sagemath/sage' && github.ref == 'refs/heads/develop' + continue-on-error: true run: | set -ex export SAGE_USE_CDNS=yes From f56cd83fe88763bf60e1d37ee40b4510bbb61ec3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 19:19:34 -0800 Subject: [PATCH 465/494] build/pkgs/pyzmq: Update to 25.1.1 --- build/pkgs/pyzmq/checksums.ini | 6 +++--- build/pkgs/pyzmq/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/pyzmq/checksums.ini b/build/pkgs/pyzmq/checksums.ini index d9abd25d464..091981fb051 100644 --- a/build/pkgs/pyzmq/checksums.ini +++ b/build/pkgs/pyzmq/checksums.ini @@ -1,5 +1,5 @@ tarball=pyzmq-VERSION.tar.gz -sha1=1a2e7220d7d1b6167c14ae2cc001dfc5d9a28dde -md5=f10b7c3dee2c03557e2c5d00b73dfc7f -cksum=1163982926 +sha1=f750e59a3d5fcca64d0a1a6723c1bc72173e976f +md5=993a646d3f1c6201a8c93bcb2d2f867e +cksum=2057198190 upstream_url=https://pypi.io/packages/source/p/pyzmq/pyzmq-VERSION.tar.gz diff --git a/build/pkgs/pyzmq/package-version.txt b/build/pkgs/pyzmq/package-version.txt index 1b3e74f84e7..139ab877a87 100644 --- a/build/pkgs/pyzmq/package-version.txt +++ b/build/pkgs/pyzmq/package-version.txt @@ -1 +1 @@ -24.0.1 +25.1.1 From c1faab9433204079f132a7d158e141bc88672974 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 6 Nov 2023 13:11:42 +0900 Subject: [PATCH 466/494] Remove code distorting worktree --- .github/workflows/doc-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index bd789779245..10c9525d8a8 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -162,7 +162,7 @@ jobs: EOF echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt + (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html) > ./docs/diff.txt /sage/sage -python - << EOF import re, html with open('./docs/diff.txt', 'r') as f: @@ -182,7 +182,6 @@ jobs: echo '' >> ./docs/CHANGES.html echo '' >>./docs/CHANGES.html rm ./docs/diff.txt ./docs/diff.html - (cd /sage/local/share/doc/sage/html && git reset --hard HEAD) # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them From e18ac9f76c565b07336dc5903700098b1f5cedb4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 20:21:38 -0800 Subject: [PATCH 467/494] build/pkgs/zeromq: Update to 4.3.5 --- build/pkgs/zeromq/checksums.ini | 6 +++--- build/pkgs/zeromq/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/zeromq/checksums.ini b/build/pkgs/zeromq/checksums.ini index dc802612ddd..bc7f6b0c8b1 100644 --- a/build/pkgs/zeromq/checksums.ini +++ b/build/pkgs/zeromq/checksums.ini @@ -1,5 +1,5 @@ tarball=zeromq-VERSION.tar.gz -sha1=47277a64749049123d1401600e8cfbab10a3ae28 -md5=c897d4005a3f0b8276b00b7921412379 -cksum=1500782345 +sha1=bdbf686c8a40ba638e21cf74e34dbb425e108500 +md5=ae933b1e98411fd7cb8309f9502d2737 +cksum=1351453048 upstream_url=https://github.com/zeromq/libzmq/releases/download/vVERSION/zeromq-VERSION.tar.gz diff --git a/build/pkgs/zeromq/package-version.txt b/build/pkgs/zeromq/package-version.txt index eda862a98c1..e198586e42b 100644 --- a/build/pkgs/zeromq/package-version.txt +++ b/build/pkgs/zeromq/package-version.txt @@ -1 +1 @@ -4.3.4 +4.3.5 From ebd4db3d6ad33e08b4e20744047633b239e49432 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 20:21:59 -0800 Subject: [PATCH 468/494] build/pkgs/zeromq/patches/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch: Remove --- ...5d88392baffa6c2c5e0737d9de19d6686f0d.patch | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 build/pkgs/zeromq/patches/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch diff --git a/build/pkgs/zeromq/patches/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch b/build/pkgs/zeromq/patches/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch deleted file mode 100644 index 75bfbd8744b..00000000000 --- a/build/pkgs/zeromq/patches/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 438d5d88392baffa6c2c5e0737d9de19d6686f0d Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Tue, 20 Dec 2022 21:45:16 +0000 -Subject: [PATCH] src/secure_allocator.hpp: define missing 'rebind' type - -`gcc-13` added an assert to standard headers to make sure custom -allocators have intended implementation of rebind type instead -of inherited rebind. gcc change: - https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=64c986b49558a7 - -Without the fix build fails on this week's `gcc-13` as: - - [ 92%] Building CXX object tests/CMakeFiles/test_security_curve.dir/test_security_curve.cpp.o - In file included from /<>/gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:34, - from /<>/gcc-13.0.0/include/c++/13.0.0/bits/stl_uninitialized.h:64, - from /<>/gcc-13.0.0/include/c++/13.0.0/memory:69, - from tests/../src/secure_allocator.hpp:42, - from tests/../src/curve_client_tools.hpp:49, - from tests/test_security_curve.cpp:53: - /<>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind, unsigned char, void>': - /<>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:94:11: required by substitution of 'template using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = zmq::secure_allocator_t; _Up = unsigned char]' - /<>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:228:8: required by substitution of 'template template using std::allocator_traits< >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = unsigned char; _Alloc = zmq::secure_allocator_t]' - /<>/gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:126:65: required from 'struct __gnu_cxx::__alloc_traits, unsigned char>::rebind' - /<>/gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:88:21: required from 'struct std::_Vector_base >' - /<>/gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:423:11: required from 'class std::vector >' - tests/../src/curve_client_tools.hpp:64:76: required from here - /<>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits::rebind_alloc must be A - 70 | _Tp>::value, - | ^~~~~ - -The change adds trivial `rebind` definition with expected return type -and satisfies conversion requirements. ---- - src/secure_allocator.hpp | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -diff --git a/src/secure_allocator.hpp b/src/secure_allocator.hpp -index e0871dcc99..5e97368911 100644 ---- a/src/secure_allocator.hpp -+++ b/src/secure_allocator.hpp -@@ -99,6 +99,17 @@ bool operator!= (const secure_allocator_t &, const secure_allocator_t &) - #else - template struct secure_allocator_t : std::allocator - { -+ secure_allocator_t () ZMQ_DEFAULT; -+ -+ template -+ secure_allocator_t (const secure_allocator_t &) ZMQ_NOEXCEPT -+ { -+ } -+ -+ template struct rebind -+ { -+ typedef secure_allocator_t other; -+ }; - }; - #endif - } From c4d3fd7d6b8b9e8857ce3c372f4b403fceb7c8cf Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 6 Nov 2023 13:34:38 +0900 Subject: [PATCH 469/494] Adding continue-on-error may disrupt doc-publish --- .github/workflows/doc-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 10c9525d8a8..7f9e07aafe2 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -200,7 +200,6 @@ jobs: - name: Build live doc id: buildlivedoc if: (success() || failure()) && steps.copy.outcome == 'success' && github.repository == 'sagemath/sage' && github.ref == 'refs/heads/develop' - continue-on-error: true run: | set -ex export SAGE_USE_CDNS=yes From 2a5293c9761a1e4eb55abeebe7f040cb99852b10 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 5 Nov 2023 21:38:48 -0800 Subject: [PATCH 470/494] build/pkgs/pyzmq: Patch out broken rpath and version detection --- ...001-setup.py-Remove-setting-of-rpath.patch | 25 +++++++++++++++++++ ...y-Patch-out-broken-version-detection.patch | 24 ++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 build/pkgs/pyzmq/patches/0001-setup.py-Remove-setting-of-rpath.patch create mode 100644 build/pkgs/pyzmq/patches/0002-setup.py-Patch-out-broken-version-detection.patch diff --git a/build/pkgs/pyzmq/patches/0001-setup.py-Remove-setting-of-rpath.patch b/build/pkgs/pyzmq/patches/0001-setup.py-Remove-setting-of-rpath.patch new file mode 100644 index 00000000000..9f0483d8442 --- /dev/null +++ b/build/pkgs/pyzmq/patches/0001-setup.py-Remove-setting-of-rpath.patch @@ -0,0 +1,25 @@ +From 29427869ce0a9f13e29c7f89873a1880c8be55a1 Mon Sep 17 00:00:00 2001 +From: Matthias Koeppe +Date: Sun, 5 Nov 2023 21:12:48 -0800 +Subject: [PATCH 1/2] setup.py: Remove setting of rpath + +--- + setup.py | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/setup.py b/setup.py +index d5c77a23..8a2a4943 100755 +--- a/setup.py ++++ b/setup.py +@@ -300,8 +300,6 @@ def settings_from_prefix(prefix=None): + settings['include_dirs'] += [pjoin(env, 'include')] + settings['library_dirs'] += [pjoin(env, 'lib')] + +- for path in settings['library_dirs']: +- _add_rpath(settings, os.path.abspath(path)) + info(settings) + + return settings +-- +2.42.0 + diff --git a/build/pkgs/pyzmq/patches/0002-setup.py-Patch-out-broken-version-detection.patch b/build/pkgs/pyzmq/patches/0002-setup.py-Patch-out-broken-version-detection.patch new file mode 100644 index 00000000000..95e62898233 --- /dev/null +++ b/build/pkgs/pyzmq/patches/0002-setup.py-Patch-out-broken-version-detection.patch @@ -0,0 +1,24 @@ +From b5bdcad66a28394f6e5be4ad7fd00835deec73f7 Mon Sep 17 00:00:00 2001 +From: Matthias Koeppe +Date: Sun, 5 Nov 2023 21:35:29 -0800 +Subject: [PATCH 2/2] setup.py: Patch out broken version detection + +--- + setup.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/setup.py b/setup.py +index 8a2a4943..19d31654 100755 +--- a/setup.py ++++ b/setup.py +@@ -463,6 +463,7 @@ class Configure(build_ext): + + def check_zmq_version(self): + """check the zmq version""" ++ return + cfg = self.config + # build test program + zmq_prefix = cfg['zmq_prefix'] +-- +2.42.0 + From 33664560681dc013be7190d5adfc498880ac8974 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Mon, 6 Nov 2023 15:13:02 +0900 Subject: [PATCH 471/494] Remove .git for sure --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 7f9e07aafe2..3660ff3a947 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -162,7 +162,7 @@ jobs: EOF echo '' >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html) > ./docs/diff.txt + (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF import re, html with open('./docs/diff.txt', 'r') as f: From 9c8f3b6ffa182c3629b864805889f4ea5234cc43 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 6 Nov 2023 11:04:52 -0800 Subject: [PATCH 472/494] .github/workflows/docker.yml: Set DOCKER_TAG from pre-merge commit sha even when docker_push_repository is not set --- .github/workflows/docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c12ec820f83..1a210cad29c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -191,6 +191,9 @@ jobs: echo "DOCKER_PUSH_REPOSITORY=$(echo ${{ inputs.docker_push_repository }} | tr "[:upper:]" "[:lower:]")" >> $GITHUB_ENV echo "DOCKER_CONFIG_FILE=$HOME/.docker/config.json" >> $GITHUB_ENV fi + + - name: Determine Docker tags to use + run: | # This line needs to be run before the step "Merge CI fixes from sagemath/sage". DOCKER_TAG="$(git describe --dirty --always)" echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV From 08cdb2275ccb767561b710d44c0e12a24875da6e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 6 Nov 2023 13:30:13 -0800 Subject: [PATCH 473/494] build/pkgs/openblas: Stop openblas from using explicit 'make -j' --- build/pkgs/openblas/spkg-install.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/pkgs/openblas/spkg-install.in b/build/pkgs/openblas/spkg-install.in index 00413ca517d..eacd993e9d6 100644 --- a/build/pkgs/openblas/spkg-install.in +++ b/build/pkgs/openblas/spkg-install.in @@ -34,6 +34,9 @@ fi echo "Building OpenBLAS: $MAKE $OPENBLAS_CONFIGURE" +# Do not emit "-j" options +export MAKE_NB_JOBS=0 + # Ensure USE_TLS=1 ; see https://github.com/sagemath/sage/issues/27256 OPENBLAS_CONFIGURE="$OPENBLAS_CONFIGURE USE_TLS=1" From 91a4e0617b224eae0818bd6518bba56caca33d1d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 6 Nov 2023 17:08:23 -0800 Subject: [PATCH 474/494] build/pkgs/openblas/spkg-install.in: Put MAKE_NB_JOBS in OPENBLAS_CONFIGURE --- build/pkgs/openblas/spkg-install.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/openblas/spkg-install.in b/build/pkgs/openblas/spkg-install.in index eacd993e9d6..5050e165787 100644 --- a/build/pkgs/openblas/spkg-install.in +++ b/build/pkgs/openblas/spkg-install.in @@ -35,7 +35,7 @@ fi echo "Building OpenBLAS: $MAKE $OPENBLAS_CONFIGURE" # Do not emit "-j" options -export MAKE_NB_JOBS=0 +OPENBLAS_CONFIGURE+=" MAKE_NB_JOBS=0" # Ensure USE_TLS=1 ; see https://github.com/sagemath/sage/issues/27256 OPENBLAS_CONFIGURE="$OPENBLAS_CONFIGURE USE_TLS=1" From 33ea789e843c8e83ddf9014eae7ff4572e5cd73f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 14:58:41 -0700 Subject: [PATCH 475/494] pkgs/sage-conf_pypi/setup.py: Replace DistutilsSetupError --- pkgs/sage-conf_pypi/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/sage-conf_pypi/setup.py b/pkgs/sage-conf_pypi/setup.py index ac2b5fb3192..ff5ec5f5572 100644 --- a/pkgs/sage-conf_pypi/setup.py +++ b/pkgs/sage-conf_pypi/setup.py @@ -76,7 +76,7 @@ def run(self): cmd = f'cd {SAGE_ROOT} && {SETENV} && {SETMAKE} && $MAKE V=0 {TARGETS}' print(f"Running {cmd}", flush=True) if os.system(cmd) != 0: - raise DistutilsSetupError(f"make {TARGETS} failed") + raise SetupError(f"make {TARGETS} failed") setuptools_build_py.run(self) From 7a05c3673283ca20ed097a0c4f9602d057b01aaa Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 15:00:46 -0700 Subject: [PATCH 476/494] pkgs/sage-conf_pypi: Add missing .upstream.d to sage_root --- pkgs/sage-conf_pypi/sage_root/.upstream.d | 1 + 1 file changed, 1 insertion(+) create mode 120000 pkgs/sage-conf_pypi/sage_root/.upstream.d diff --git a/pkgs/sage-conf_pypi/sage_root/.upstream.d b/pkgs/sage-conf_pypi/sage_root/.upstream.d new file mode 120000 index 00000000000..243d6b8c910 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/.upstream.d @@ -0,0 +1 @@ +../../../.upstream.d \ No newline at end of file From 28df32fb95d5d28e7f755ba9062eb9be61426d93 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 15:45:58 -0700 Subject: [PATCH 477/494] pkgs/sage-conf_pypi/tox.ini: Pass HOMEBREW env var --- pkgs/sage-conf_pypi/tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/sage-conf_pypi/tox.ini b/pkgs/sage-conf_pypi/tox.ini index b530bd10554..00a53d0ea59 100644 --- a/pkgs/sage-conf_pypi/tox.ini +++ b/pkgs/sage-conf_pypi/tox.ini @@ -4,6 +4,8 @@ envlist = python [testenv] passenv = MAKE + # So that .homebrew-build-env will work + HOMEBREW setenv = HOME={envdir} From 5ce616bb8e178f48f537a1fa7514fdbb1a74dd1e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 17:05:26 -0700 Subject: [PATCH 478/494] pkgs/sage-conf_pypi/setup.py: Fix invocation of .homebrew-build-env --- pkgs/sage-conf_pypi/setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/sage-conf_pypi/setup.py b/pkgs/sage-conf_pypi/setup.py index ff5ec5f5572..e482ed83bc3 100644 --- a/pkgs/sage-conf_pypi/setup.py +++ b/pkgs/sage-conf_pypi/setup.py @@ -36,14 +36,14 @@ def run(self): if os.environ.get('CONDA_PREFIX', ''): SETENV = ':' else: - SETENV = '(. ./.homebrew-build-env 2> /dev/null || :)' + SETENV = '. ./.homebrew-build-env 2> /dev/null' SAGE_LOCAL = os.path.join(SAGE_ROOT, 'local') if os.path.exists(os.path.join(SAGE_ROOT, 'config.status')): print(f'Reusing configured SAGE_ROOT={SAGE_ROOT}') else: - cmd = f"cd {SAGE_ROOT} && {SETENV} && ./configure --prefix={SAGE_LOCAL} --with-python={sys.executable} --enable-build-as-root --enable-download-from-upstream-url --with-system-python3=force --with-sage-venv --disable-notebook --disable-sagelib --disable-sage_conf --disable-doc" + cmd = f"cd {SAGE_ROOT} && ({SETENV}; ./configure --prefix={SAGE_LOCAL} --with-python={sys.executable} --enable-build-as-root --enable-download-from-upstream-url --with-system-python3=force --with-sage-venv --disable-notebook --disable-sagelib --disable-sage_conf --disable-doc)" print(f"Running {cmd}") sys.stdout.flush() if os.system(cmd) != 0: @@ -73,7 +73,7 @@ def run(self): # (that use native libraries shared with other packages). SETMAKE = 'if [ -z "$MAKE" ]; then export MAKE="make -j$(PATH=build/bin:$PATH build/bin/sage-build-num-threads | cut -d" " -f 2)"; fi' TARGETS = 'build' - cmd = f'cd {SAGE_ROOT} && {SETENV} && {SETMAKE} && $MAKE V=0 {TARGETS}' + cmd = f'cd {SAGE_ROOT} && ({SETENV}; {SETMAKE} && $MAKE V=0 {TARGETS})' print(f"Running {cmd}", flush=True) if os.system(cmd) != 0: raise SetupError(f"make {TARGETS} failed") From 2632428fa08accd2605631865e4331268997ab17 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 19:18:39 -0700 Subject: [PATCH 479/494] pkgs/sage-conf_pypi/setup.py: Accept environment variable SAGE_CONF_TARGETS --- pkgs/sage-conf_pypi/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/sage-conf_pypi/setup.py b/pkgs/sage-conf_pypi/setup.py index e482ed83bc3..5a8240b6e9d 100644 --- a/pkgs/sage-conf_pypi/setup.py +++ b/pkgs/sage-conf_pypi/setup.py @@ -73,10 +73,10 @@ def run(self): # (that use native libraries shared with other packages). SETMAKE = 'if [ -z "$MAKE" ]; then export MAKE="make -j$(PATH=build/bin:$PATH build/bin/sage-build-num-threads | cut -d" " -f 2)"; fi' TARGETS = 'build' - cmd = f'cd {SAGE_ROOT} && ({SETENV}; {SETMAKE} && $MAKE V=0 {TARGETS})' + cmd = f'cd {SAGE_ROOT} && ({SETENV}; {SETMAKE} && $MAKE V=0 ${{SAGE_CONF_TARGETS-{TARGETS}}})' print(f"Running {cmd}", flush=True) if os.system(cmd) != 0: - raise SetupError(f"make {TARGETS} failed") + raise SetupError(f"make ${{SAGE_CONF_TARGETS-{TARGETS}}} failed") setuptools_build_py.run(self) From cf8f82675d85c688267980878e6a0cb714a595be Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 19:19:08 -0700 Subject: [PATCH 480/494] pkgs/sage-conf_pypi/tox.ini: Add environment 'python-user' --- pkgs/sage-conf_pypi/tox.ini | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/pkgs/sage-conf_pypi/tox.ini b/pkgs/sage-conf_pypi/tox.ini index 00a53d0ea59..ea7eee9eb48 100644 --- a/pkgs/sage-conf_pypi/tox.ini +++ b/pkgs/sage-conf_pypi/tox.ini @@ -1,14 +1,39 @@ [tox] -envlist = python +envlist = python, python-user -[testenv] +[testenv:.pkg] passenv = MAKE # So that .homebrew-build-env will work HOMEBREW setenv = - HOME={envdir} + HOME={work_dir}/home + # Passed to 'make' instead of 'build'. We test here: + # - frobby (standalone program with dependency on gmp; tests that .homebrew-build-env is invoked correctly) + # - lrcalc_python (builds a platform wheel, possibly with use of system library) + SAGE_CONF_TARGETS=frobby lrcalc_python +[testenv:python] +package = wheel +setenv = + HOME={work_dir}/home +allowlist_externals = + bash + env +commands = + bash -c 'eval $SETENV; sage-config' + bash -c 'eval $SETENV; ls $(sage-config SAGE_SPKG_WHEELS)' + +[testenv:python-user] +package = wheel +setenv = + HOME={work_dir}/home + PYTHONUSERBASE={work_dir}/userbase + SETENV=export PATH={env:PYTHONUSERBASE}/bin:{env:PATH} +system_site_packages = True +install_command = env PATH={env:PYTHONUSERBASE}/bin:{env_bin_dir} python -I -m pip install --user {opts} {packages} +allowlist_externals = + {[testenv:python]allowlist_externals} commands = - sage-config + {[testenv:python]commands} From 3c31ee62c62637cff3b28d1a306aa6b6166cc81f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 24 Oct 2023 20:22:05 -0700 Subject: [PATCH 481/494] pkgs/sage-conf_pypi/tox.ini: Test more --- pkgs/sage-conf_pypi/tox.ini | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/sage-conf_pypi/tox.ini b/pkgs/sage-conf_pypi/tox.ini index ea7eee9eb48..5a53c75ea35 100644 --- a/pkgs/sage-conf_pypi/tox.ini +++ b/pkgs/sage-conf_pypi/tox.ini @@ -12,23 +12,32 @@ setenv = # Passed to 'make' instead of 'build'. We test here: # - frobby (standalone program with dependency on gmp; tests that .homebrew-build-env is invoked correctly) # - lrcalc_python (builds a platform wheel, possibly with use of system library) - SAGE_CONF_TARGETS=frobby lrcalc_python + # - coxeter3 (which allows us to build sagemath-coxeter3) + SAGE_CONF_TARGETS=frobby lrcalc_python coxeter3 [testenv:python] package = wheel +deps = + # For the 'sage' script + sagemath-environment setenv = HOME={work_dir}/home allowlist_externals = bash env commands = - bash -c 'eval $SETENV; sage-config' - bash -c 'eval $SETENV; ls $(sage-config SAGE_SPKG_WHEELS)' + bash -c 'set -ex; eval $SETENV; \ + sage-config; \ + ls $(sage-config SAGE_SPKG_WHEELS); \ + sage -sh -c "frobby genideal"; \ + {envpython} -m pip install $(sage-config SAGE_SPKG_WHEELS)/*.whl' [testenv:python-user] package = wheel +deps = + {[testenv:python]deps} setenv = - HOME={work_dir}/home + {[testenv:python]setenv} PYTHONUSERBASE={work_dir}/userbase SETENV=export PATH={env:PYTHONUSERBASE}/bin:{env:PATH} system_site_packages = True From 19d1ea7f9878a387f981fbf346aa6e5b95dce8ba Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 6 Nov 2023 17:36:06 -0800 Subject: [PATCH 482/494] pkgs/sage-conf/setup.cfg: Add python_requires --- pkgs/sage-conf/setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/sage-conf/setup.cfg b/pkgs/sage-conf/setup.cfg index dac401c303d..d74e36432c2 100644 --- a/pkgs/sage-conf/setup.cfg +++ b/pkgs/sage-conf/setup.cfg @@ -9,6 +9,8 @@ author_email = sage-support@googlegroups.com url = https://www.sagemath.org [options] +python_requires = >=3.9, <3.12 + packages = _sage_conf From d2f56d204da9278169296d36a53fc4fd7009bf4a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 6 Nov 2023 18:01:25 -0800 Subject: [PATCH 483/494] build/pkgs/openblas/spkg-install.in: Work around hang with GNU make 3.81 (ubuntu-trusty) --- build/pkgs/openblas/spkg-install.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build/pkgs/openblas/spkg-install.in b/build/pkgs/openblas/spkg-install.in index 5050e165787..006067800af 100644 --- a/build/pkgs/openblas/spkg-install.in +++ b/build/pkgs/openblas/spkg-install.in @@ -34,8 +34,13 @@ fi echo "Building OpenBLAS: $MAKE $OPENBLAS_CONFIGURE" -# Do not emit "-j" options -OPENBLAS_CONFIGURE+=" MAKE_NB_JOBS=0" +if $MAKE --version | grep -q -F '3.81'; then + # Work around https://savannah.gnu.org/bugs/?15919 + OPENBLAS_CONFIGURE+=" MAKE_NB_JOBS=1" +else + # Do not emit "-j" options; use jobserver + OPENBLAS_CONFIGURE+=" MAKE_NB_JOBS=0" +fi # Ensure USE_TLS=1 ; see https://github.com/sagemath/sage/issues/27256 OPENBLAS_CONFIGURE="$OPENBLAS_CONFIGURE USE_TLS=1" From 6d1a957d2b540da8717eb7d9b86f3f4005b22c6a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 7 Nov 2023 10:04:07 -0800 Subject: [PATCH 484/494] build/pkgs/openblas/spkg-install.in: Build targets libs, netlib, shared in separate make invocations --- build/pkgs/openblas/spkg-install.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/openblas/spkg-install.in b/build/pkgs/openblas/spkg-install.in index 006067800af..2f8aea512bc 100644 --- a/build/pkgs/openblas/spkg-install.in +++ b/build/pkgs/openblas/spkg-install.in @@ -45,7 +45,7 @@ fi # Ensure USE_TLS=1 ; see https://github.com/sagemath/sage/issues/27256 OPENBLAS_CONFIGURE="$OPENBLAS_CONFIGURE USE_TLS=1" -if ! (sdh_make libs netlib shared $OPENBLAS_CONFIGURE); then +if ! (sdh_make libs $OPENBLAS_CONFIGURE && sdh_make netlib $OPENBLAS_CONFIGURE && sdh_make shared $OPENBLAS_CONFIGURE); then if [[ $OPENBLAS_CONFIGURE == *"TARGET"* ]]; then sdh_die "Error building OpenBLAS" else @@ -55,7 +55,7 @@ if ! (sdh_make libs netlib shared $OPENBLAS_CONFIGURE); then echo "Error building OpenBLAS" echo "Retrying building OpenBLAS: $MAKE $OPENBLAS_CONFIGURE" sdh_make clean - sdh_make libs netlib shared $OPENBLAS_CONFIGURE + sdh_make libs $OPENBLAS_CONFIGURE && sdh_make netlib $OPENBLAS_CONFIGURE && sdh_make shared $OPENBLAS_CONFIGURE fi fi From 0df3400b3d3cb672cc8848e4100f1c2927f19f2a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 7 Nov 2023 14:52:39 -0800 Subject: [PATCH 485/494] pkgs/sage-conf_pypi/tox.ini: Declare python versions to test, declare basepython of .pkg --- pkgs/sage-conf_pypi/tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/sage-conf_pypi/tox.ini b/pkgs/sage-conf_pypi/tox.ini index 5a53c75ea35..fadf9a9cc6c 100644 --- a/pkgs/sage-conf_pypi/tox.ini +++ b/pkgs/sage-conf_pypi/tox.ini @@ -1,7 +1,8 @@ [tox] -envlist = python, python-user +envlist = py39, py310, py311, py39-user, py310-user, py311-user [testenv:.pkg] +basepython = py311 passenv = MAKE # So that .homebrew-build-env will work From 11a8d350e0103224dcf71722bb1535c65162c7e1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 8 Nov 2023 15:15:29 -0800 Subject: [PATCH 486/494] pkgs/sage-conf/.gitignore: Remove setup.cfg from here --- pkgs/sage-conf/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/sage-conf/.gitignore b/pkgs/sage-conf/.gitignore index 2f96201a1c9..2fff1627b9f 100644 --- a/pkgs/sage-conf/.gitignore +++ b/pkgs/sage-conf/.gitignore @@ -1,5 +1,4 @@ /_sage_conf/_conf.py -/setup.cfg /build /dist /*.egg-info From 6274cdc3e887508dd08cac14d14b7e3e530ab907 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 8 Nov 2023 15:57:17 -0800 Subject: [PATCH 487/494] Revert "pkgs/sage-conf/setup.cfg: Add python_requires" This reverts commit 19d1ea7f9878a387f981fbf346aa6e5b95dce8ba. --- pkgs/sage-conf/setup.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/sage-conf/setup.cfg b/pkgs/sage-conf/setup.cfg index d74e36432c2..dac401c303d 100644 --- a/pkgs/sage-conf/setup.cfg +++ b/pkgs/sage-conf/setup.cfg @@ -9,8 +9,6 @@ author_email = sage-support@googlegroups.com url = https://www.sagemath.org [options] -python_requires = >=3.9, <3.12 - packages = _sage_conf From e349b0024996e4ac4878d70a0a34ae6b742e88c5 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Fri, 10 Nov 2023 16:41:57 +0100 Subject: [PATCH 488/494] Updated SageMath version to 10.2.rc1 --- CITATION.cff | 4 ++-- VERSION.txt | 2 +- build/pkgs/configure/checksums.ini | 6 +++--- build/pkgs/configure/package-version.txt | 2 +- build/pkgs/sage_conf/install-requires.txt | 2 +- build/pkgs/sage_docbuild/install-requires.txt | 2 +- build/pkgs/sage_setup/install-requires.txt | 2 +- build/pkgs/sage_sws2rst/install-requires.txt | 2 +- build/pkgs/sagelib/install-requires.txt | 2 +- build/pkgs/sagemath_bliss/install-requires.txt | 2 +- build/pkgs/sagemath_categories/install-requires.txt | 2 +- build/pkgs/sagemath_coxeter3/install-requires.txt | 2 +- build/pkgs/sagemath_environment/install-requires.txt | 2 +- build/pkgs/sagemath_mcqd/install-requires.txt | 2 +- build/pkgs/sagemath_meataxe/install-requires.txt | 2 +- build/pkgs/sagemath_objects/install-requires.txt | 2 +- build/pkgs/sagemath_repl/install-requires.txt | 2 +- build/pkgs/sagemath_sirocco/install-requires.txt | 2 +- build/pkgs/sagemath_tdlib/install-requires.txt | 2 +- pkgs/sage-conf/VERSION.txt | 2 +- pkgs/sage-conf_conda/VERSION.txt | 2 +- pkgs/sage-conf_pypi/VERSION.txt | 2 +- pkgs/sage-docbuild/VERSION.txt | 2 +- pkgs/sage-setup/VERSION.txt | 2 +- pkgs/sage-sws2rst/VERSION.txt | 2 +- pkgs/sagemath-bliss/VERSION.txt | 2 +- pkgs/sagemath-categories/VERSION.txt | 2 +- pkgs/sagemath-coxeter3/VERSION.txt | 2 +- pkgs/sagemath-environment/VERSION.txt | 2 +- pkgs/sagemath-mcqd/VERSION.txt | 2 +- pkgs/sagemath-meataxe/VERSION.txt | 2 +- pkgs/sagemath-objects/VERSION.txt | 2 +- pkgs/sagemath-repl/VERSION.txt | 2 +- pkgs/sagemath-sirocco/VERSION.txt | 2 +- pkgs/sagemath-tdlib/VERSION.txt | 2 +- src/VERSION.txt | 2 +- src/bin/sage-version.sh | 6 +++--- src/sage/version.py | 6 +++--- 38 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index bcd3dad6665..b1b171fb1a1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.2.rc0 +version: 10.2.rc1 doi: 10.5281/zenodo.593563 -date-released: 2023-11-05 +date-released: 2023-11-10 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index a43284eebe1..8ceae8bb576 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.2.rc0, Release Date: 2023-11-05 +SageMath version 10.2.rc1, Release Date: 2023-11-10 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index f7a9e8a1ba6..cabeaab3b1e 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=e965180c957a340bb04576df39802f3a36d340e7 -md5=932bfcea357845fa9610dc698e2390d3 -cksum=2852244160 +sha1=1be054f67f0d283b5eb57e6a6b06383a5418dd1a +md5=d14e84540b8f76777d225fa90fc8fba9 +cksum=3781778115 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 00dc1d6c929..1ef35d3a00f 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -fb5b09d7f749e15c38ecb4ffe2de7b398e37f73f +81bf4e52c662db7167c3955c93308c4a6bdb850c diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt index 4b66d1b0602..326aa7578ec 100644 --- a/build/pkgs/sage_conf/install-requires.txt +++ b/build/pkgs/sage_conf/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.2rc0 +sage-conf ~= 10.2rc1 diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt index cebed4e3b62..de534e08518 100644 --- a/build/pkgs/sage_docbuild/install-requires.txt +++ b/build/pkgs/sage_docbuild/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.2rc0 +sage-docbuild ~= 10.2rc1 diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt index 1631564eec7..3c0a80511a3 100644 --- a/build/pkgs/sage_setup/install-requires.txt +++ b/build/pkgs/sage_setup/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.2rc0 +sage-setup ~= 10.2rc1 diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt index 628374d5f1a..4a13b95c8f6 100644 --- a/build/pkgs/sage_sws2rst/install-requires.txt +++ b/build/pkgs/sage_sws2rst/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.2rc0 +sage-sws2rst ~= 10.2rc1 diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt index 6004e85c25d..9dd84a6d4d7 100644 --- a/build/pkgs/sagelib/install-requires.txt +++ b/build/pkgs/sagelib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.2rc0 +sagemath-standard ~= 10.2rc1 diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt index 5ea4526cc33..c66665c1f4d 100644 --- a/build/pkgs/sagemath_bliss/install-requires.txt +++ b/build/pkgs/sagemath_bliss/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.2rc0 +sagemath-bliss ~= 10.2rc1 diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt index 1d37a18c187..a1695d082b4 100644 --- a/build/pkgs/sagemath_categories/install-requires.txt +++ b/build/pkgs/sagemath_categories/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.2rc0 +sagemath-categories ~= 10.2rc1 diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt index 8d6115b1868..b9db4ef19c8 100644 --- a/build/pkgs/sagemath_coxeter3/install-requires.txt +++ b/build/pkgs/sagemath_coxeter3/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.2rc0 +sagemath-coxeter3 ~= 10.2rc1 diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt index c870e97dca1..f704a57eb7e 100644 --- a/build/pkgs/sagemath_environment/install-requires.txt +++ b/build/pkgs/sagemath_environment/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.2rc0 +sagemath-environment ~= 10.2rc1 diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt index cff0dac0026..947642f6baf 100644 --- a/build/pkgs/sagemath_mcqd/install-requires.txt +++ b/build/pkgs/sagemath_mcqd/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.2rc0 +sagemath-mcqd ~= 10.2rc1 diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt index 464942fef75..b05223e6735 100644 --- a/build/pkgs/sagemath_meataxe/install-requires.txt +++ b/build/pkgs/sagemath_meataxe/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.2rc0 +sagemath-meataxe ~= 10.2rc1 diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt index 663b7d78f8b..8245904bf01 100644 --- a/build/pkgs/sagemath_objects/install-requires.txt +++ b/build/pkgs/sagemath_objects/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.2rc0 +sagemath-objects ~= 10.2rc1 diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt index 917144d154c..83c797f99a3 100644 --- a/build/pkgs/sagemath_repl/install-requires.txt +++ b/build/pkgs/sagemath_repl/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.2rc0 +sagemath-repl ~= 10.2rc1 diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt index 896662f1b95..f828bbac488 100644 --- a/build/pkgs/sagemath_sirocco/install-requires.txt +++ b/build/pkgs/sagemath_sirocco/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.2rc0 +sagemath-sirocco ~= 10.2rc1 diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt index c26900d9abf..cd0d3390b93 100644 --- a/build/pkgs/sagemath_tdlib/install-requires.txt +++ b/build/pkgs/sagemath_tdlib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.2rc0 +sagemath-tdlib ~= 10.2rc1 diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-conf_conda/VERSION.txt +++ b/pkgs/sage-conf_conda/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/src/VERSION.txt b/src/VERSION.txt index 7694f7787b5..a9591a7f98d 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.2.rc0 +10.2.rc1 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index d6b42fe389d..6ba84d36e70 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.2.rc0' -SAGE_RELEASE_DATE='2023-11-05' -SAGE_VERSION_BANNER='SageMath version 10.2.rc0, Release Date: 2023-11-05' +SAGE_VERSION='10.2.rc1' +SAGE_RELEASE_DATE='2023-11-10' +SAGE_VERSION_BANNER='SageMath version 10.2.rc1, Release Date: 2023-11-10' diff --git a/src/sage/version.py b/src/sage/version.py index 9d384e5af6e..087d777c94b 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.2.rc0' -date = '2023-11-05' -banner = 'SageMath version 10.2.rc0, Release Date: 2023-11-05' +version = '10.2.rc1' +date = '2023-11-10' +banner = 'SageMath version 10.2.rc1, Release Date: 2023-11-10' From 429555a926b20d83ca89cd3531d38945d3e6403d Mon Sep 17 00:00:00 2001 From: Release Manager Date: Fri, 10 Nov 2023 16:54:59 +0100 Subject: [PATCH 489/494] Updated SageMath version to 10.2.rc1 --- build/pkgs/configure/checksums.ini | 6 +++--- build/pkgs/configure/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index cabeaab3b1e..f3165c40860 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=1be054f67f0d283b5eb57e6a6b06383a5418dd1a -md5=d14e84540b8f76777d225fa90fc8fba9 -cksum=3781778115 +sha1=75fe450806e89ce82978f9167b664d3e403d9af9 +md5=26211fca17d4d912cc11f22f353684b1 +cksum=1423896271 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 1ef35d3a00f..20a74069b66 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -81bf4e52c662db7167c3955c93308c4a6bdb850c +e349b0024996e4ac4878d70a0a34ae6b742e88c5 From 70036fb879831adce7a82906a6a1b6f3a7d48547 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Mon, 6 Nov 2023 18:51:58 +0000 Subject: [PATCH 490/494] shift the upper bound for implemented matrices to 1200 also, list unknown orders of (skew) Hadamard matrices in the corresponding docstring --- src/sage/combinat/matrices/hadamard_matrix.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index 908a3bec603..d6477decec6 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -31,21 +31,23 @@ of `4`. The module below implements constructions of Hadamard and skew Hadamard matrices -for all known orders `\le 1000`, plus some more greater than `1000`. It also +for all known orders `\le 1200`, plus some more greater than `1200`. It also allows you to pull a Hadamard matrix from the database at [SloaHada]_. The following code will test that a construction for all known orders `\le 4k` -is implemented. The assertion above can be verified by setting ``k=250`` +is implemented. The assertion above can be verified by setting ``k=300`` (note that it will take a long time to run):: sage: from sage.combinat.matrices.hadamard_matrix import (hadamard_matrix, ....: skew_hadamard_matrix, is_hadamard_matrix, ....: is_skew_hadamard_matrix) sage: k = 20 - sage: unknown_hadamard = [668, 716, 892] + sage: unknown_hadamard = [668, 716, 892, 1132] sage: unknown_skew_hadamard = [356, 404, 428, 476, 596, 612, 668, 708, 712, 716, ....: 764, 772, 804, 808, 820, 836, 856, 892, 900, 916, - ....: 932, 940, 952, 980, 996] + ....: 932, 940, 952, 980, 996, 1004, 1012, 1028, 1036, + ....: 1044, 1060, 1076, 1100, 1108, 1132, 1140, 1148, + ....: 1156, 1180, 1192, 1196] sage: for n in range(1, k+1): ....: if 4*n not in unknown_hadamard: ....: H = hadamard_matrix(4*n, check=False) @@ -58,7 +60,7 @@ - David Joyner (2009-05-17): initial version - Matteo Cati (2023-03-18): implemented more constructions for Hadamard and skew - Hadamard matrices, to cover all known orders up to 1000. + Hadamard matrices, to cover all known orders up to 1200. REFERENCES: @@ -1641,8 +1643,8 @@ def hadamard_matrix(n, existence=False, check=True): r""" Tries to construct a Hadamard matrix using the available methods. - Currently all orders `\le 1000` for which a construction is - known are implemented. For `n > 1000`, only some orders are available. + Currently all orders `\le 1200` for which a construction is + known are implemented. For `n > 1200`, only some orders are available. INPUT: @@ -3055,8 +3057,8 @@ def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True): Tries to construct a skew Hadamard matrix. A Hadamard matrix `H` is called skew if `H=S-I`, for `I` the identity matrix - and `-S=S^\top`. Currently all orders `\le 1000` for which a construction is - known are implemented. For `n > 1000`, only some orders are available. + and `-S=S^\top`. Currently all orders `\le 1200` for which a construction is + known are implemented. For `n > 1200`, only some orders are available. INPUT: From 780c3024f3b38eb03b2646ea291fda6ee800eb86 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Mon, 6 Nov 2023 19:07:36 +0000 Subject: [PATCH 491/494] add a reference to arxiv preprint Cati & Pasechnik --- src/doc/en/reference/references/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index d9f406d055d..697c50a6bcf 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -1373,6 +1373,10 @@ REFERENCES: for closed Riemannian manifolds*, Ann. of Math. (2) 45 (1944), 747–752. +.. [CP2023] \M. Cati and D.V. Pasechnik. + *Implementing Hadamard Matrices in SageMath*. + Preprint, :arxiv:`2306.16812`, (2023). + .. [CQ2019] \A. Cassella and C. Quadrelli. *Right-angled Artin groups and enhanced Koszul properties*. Preprint, :arxiv:`1907.03824`, (2019). From 93e987308a233e004c05512e34752a28e537e968 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Mon, 6 Nov 2023 19:09:49 +0000 Subject: [PATCH 492/494] refer to [CP2023] --- src/sage/combinat/matrices/hadamard_matrix.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py index d6477decec6..0693941851e 100644 --- a/src/sage/combinat/matrices/hadamard_matrix.py +++ b/src/sage/combinat/matrices/hadamard_matrix.py @@ -69,6 +69,8 @@ - [HadaWiki]_ - [Hora]_ + +- [CP2023]_ """ # ***************************************************************************** From ddc6a464e4b7a3128c538ecc0740de979855657c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 10 Nov 2023 19:38:43 -0800 Subject: [PATCH 493/494] src/sage/combinat/root_system/coxeter_group.py: Fix typo in lazy_import --- src/sage/combinat/root_system/coxeter_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/root_system/coxeter_group.py b/src/sage/combinat/root_system/coxeter_group.py index 83c1c0c7e9e..8fadad6035c 100644 --- a/src/sage/combinat/root_system/coxeter_group.py +++ b/src/sage/combinat/root_system/coxeter_group.py @@ -12,7 +12,7 @@ from sage.combinat.root_system.cartan_type import CartanType from sage.misc.lazy_import import lazy_import -lazy_import('from sage.combinat.root_system.reflection_group_real', 'ReflectionGroup') +lazy_import('sage.combinat.root_system.reflection_group_real', 'ReflectionGroup') lazy_import('sage.combinat.root_system.weyl_group', 'WeylGroup') From 4430e4cc37c968b71de6d2e4bf52e8825b42c719 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Sun, 12 Nov 2023 21:06:12 +0100 Subject: [PATCH 494/494] Updated SageMath version to 10.2.rc2 --- CITATION.cff | 4 ++-- VERSION.txt | 2 +- build/pkgs/configure/checksums.ini | 6 +++--- build/pkgs/configure/package-version.txt | 2 +- build/pkgs/sage_conf/install-requires.txt | 2 +- build/pkgs/sage_docbuild/install-requires.txt | 2 +- build/pkgs/sage_setup/install-requires.txt | 2 +- build/pkgs/sage_sws2rst/install-requires.txt | 2 +- build/pkgs/sagelib/install-requires.txt | 2 +- build/pkgs/sagemath_bliss/install-requires.txt | 2 +- build/pkgs/sagemath_categories/install-requires.txt | 2 +- build/pkgs/sagemath_coxeter3/install-requires.txt | 2 +- build/pkgs/sagemath_environment/install-requires.txt | 2 +- build/pkgs/sagemath_mcqd/install-requires.txt | 2 +- build/pkgs/sagemath_meataxe/install-requires.txt | 2 +- build/pkgs/sagemath_objects/install-requires.txt | 2 +- build/pkgs/sagemath_repl/install-requires.txt | 2 +- build/pkgs/sagemath_sirocco/install-requires.txt | 2 +- build/pkgs/sagemath_tdlib/install-requires.txt | 2 +- pkgs/sage-conf/VERSION.txt | 2 +- pkgs/sage-conf_conda/VERSION.txt | 2 +- pkgs/sage-conf_pypi/VERSION.txt | 2 +- pkgs/sage-docbuild/VERSION.txt | 2 +- pkgs/sage-setup/VERSION.txt | 2 +- pkgs/sage-sws2rst/VERSION.txt | 2 +- pkgs/sagemath-bliss/VERSION.txt | 2 +- pkgs/sagemath-categories/VERSION.txt | 2 +- pkgs/sagemath-coxeter3/VERSION.txt | 2 +- pkgs/sagemath-environment/VERSION.txt | 2 +- pkgs/sagemath-mcqd/VERSION.txt | 2 +- pkgs/sagemath-meataxe/VERSION.txt | 2 +- pkgs/sagemath-objects/VERSION.txt | 2 +- pkgs/sagemath-repl/VERSION.txt | 2 +- pkgs/sagemath-sirocco/VERSION.txt | 2 +- pkgs/sagemath-tdlib/VERSION.txt | 2 +- src/VERSION.txt | 2 +- src/bin/sage-version.sh | 6 +++--- src/sage/version.py | 6 +++--- 38 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index b1b171fb1a1..7294ca6763a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.2.rc1 +version: 10.2.rc2 doi: 10.5281/zenodo.593563 -date-released: 2023-11-10 +date-released: 2023-11-12 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index 8ceae8bb576..bf28f5b89de 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.2.rc1, Release Date: 2023-11-10 +SageMath version 10.2.rc2, Release Date: 2023-11-12 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index d8c83c023b0..b5731ea41cd 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=e0eb47055f79c8898be61aa53b45d7c243b9f22c -md5=05af6b3eb911bb709dff596cf1e05546 -cksum=796740784 +sha1=6c2020ef6639a24eb777eb1fa1adfca6dbd4520c +md5=c8641bab76511afffa14c46c8a6f4c73 +cksum=1432162721 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 8f8f1069ddc..9789b687e7f 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -0e598caa6f70248990092065e8948fba56d0867f +883e05f8ee0f97b25cf28c97859c615d9ea314f7 diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt index 326aa7578ec..72d982128c2 100644 --- a/build/pkgs/sage_conf/install-requires.txt +++ b/build/pkgs/sage_conf/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.2rc1 +sage-conf ~= 10.2rc2 diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt index de534e08518..b3ec06fd6bd 100644 --- a/build/pkgs/sage_docbuild/install-requires.txt +++ b/build/pkgs/sage_docbuild/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.2rc1 +sage-docbuild ~= 10.2rc2 diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt index 3c0a80511a3..32b2a0f11c4 100644 --- a/build/pkgs/sage_setup/install-requires.txt +++ b/build/pkgs/sage_setup/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.2rc1 +sage-setup ~= 10.2rc2 diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt index 4a13b95c8f6..cb0ef8de582 100644 --- a/build/pkgs/sage_sws2rst/install-requires.txt +++ b/build/pkgs/sage_sws2rst/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.2rc1 +sage-sws2rst ~= 10.2rc2 diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt index 9dd84a6d4d7..f7ce9fc4363 100644 --- a/build/pkgs/sagelib/install-requires.txt +++ b/build/pkgs/sagelib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.2rc1 +sagemath-standard ~= 10.2rc2 diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt index c66665c1f4d..45ef2f3037c 100644 --- a/build/pkgs/sagemath_bliss/install-requires.txt +++ b/build/pkgs/sagemath_bliss/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.2rc1 +sagemath-bliss ~= 10.2rc2 diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt index a1695d082b4..ead89ac718b 100644 --- a/build/pkgs/sagemath_categories/install-requires.txt +++ b/build/pkgs/sagemath_categories/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.2rc1 +sagemath-categories ~= 10.2rc2 diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt index b9db4ef19c8..1fcaeb1578e 100644 --- a/build/pkgs/sagemath_coxeter3/install-requires.txt +++ b/build/pkgs/sagemath_coxeter3/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.2rc1 +sagemath-coxeter3 ~= 10.2rc2 diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt index f704a57eb7e..c7125057ba4 100644 --- a/build/pkgs/sagemath_environment/install-requires.txt +++ b/build/pkgs/sagemath_environment/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.2rc1 +sagemath-environment ~= 10.2rc2 diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt index 947642f6baf..30adf8786bb 100644 --- a/build/pkgs/sagemath_mcqd/install-requires.txt +++ b/build/pkgs/sagemath_mcqd/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.2rc1 +sagemath-mcqd ~= 10.2rc2 diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt index b05223e6735..e2ea89298af 100644 --- a/build/pkgs/sagemath_meataxe/install-requires.txt +++ b/build/pkgs/sagemath_meataxe/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.2rc1 +sagemath-meataxe ~= 10.2rc2 diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt index 8245904bf01..7f040ebe9a2 100644 --- a/build/pkgs/sagemath_objects/install-requires.txt +++ b/build/pkgs/sagemath_objects/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.2rc1 +sagemath-objects ~= 10.2rc2 diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt index 83c797f99a3..27ebea3e770 100644 --- a/build/pkgs/sagemath_repl/install-requires.txt +++ b/build/pkgs/sagemath_repl/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.2rc1 +sagemath-repl ~= 10.2rc2 diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt index f828bbac488..4fb6d1a07b5 100644 --- a/build/pkgs/sagemath_sirocco/install-requires.txt +++ b/build/pkgs/sagemath_sirocco/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.2rc1 +sagemath-sirocco ~= 10.2rc2 diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt index cd0d3390b93..b00874fb242 100644 --- a/build/pkgs/sagemath_tdlib/install-requires.txt +++ b/build/pkgs/sagemath_tdlib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.2rc1 +sagemath-tdlib ~= 10.2rc2 diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-conf_conda/VERSION.txt +++ b/pkgs/sage-conf_conda/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/src/VERSION.txt b/src/VERSION.txt index a9591a7f98d..9a33c5df14e 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.2.rc1 +10.2.rc2 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index 6ba84d36e70..8bcbb63baec 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.2.rc1' -SAGE_RELEASE_DATE='2023-11-10' -SAGE_VERSION_BANNER='SageMath version 10.2.rc1, Release Date: 2023-11-10' +SAGE_VERSION='10.2.rc2' +SAGE_RELEASE_DATE='2023-11-12' +SAGE_VERSION_BANNER='SageMath version 10.2.rc2, Release Date: 2023-11-12' diff --git a/src/sage/version.py b/src/sage/version.py index 087d777c94b..4dc5fe09e63 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.2.rc1' -date = '2023-11-10' -banner = 'SageMath version 10.2.rc1, Release Date: 2023-11-10' +version = '10.2.rc2' +date = '2023-11-12' +banner = 'SageMath version 10.2.rc2, Release Date: 2023-11-12'