Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sage/combinat/designs/difference_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ def radical_difference_set(K, k, l=1, existence=False, check=True):
x = K.multiplicative_generator()
D = K.cyclotomic_cosets(x**((v-1)//k), [K.one()])
if is_difference_family(K, D, v, k, l):
print("** You found a new example of radical difference set **\n"\
"** for the parameters (v,k,l)=({},{},{}). **\n"\
print("** You found a new example of radical difference set **\n"
"** for the parameters (v,k,l)=({},{},{}). **\n"
"** Please contact [email protected] **\n".format(v, k, l))
if existence:
return True
Expand All @@ -602,8 +602,8 @@ def radical_difference_set(K, k, l=1, existence=False, check=True):
D = K.cyclotomic_cosets(x**((v-1)//(k-1)), [K.one()])
D[0].insert(0,K.zero())
if is_difference_family(K, D, v, k, l):
print("** You found a new example of radical difference set **\n"\
"** for the parameters (v,k,l)=({},{},{}). **\n"\
print("** You found a new example of radical difference set **\n"
"** for the parameters (v,k,l)=({},{},{}). **\n"
"** Please contact [email protected] **\n".format(v, k, l))
if existence:
return True
Expand Down
23 changes: 11 additions & 12 deletions src/sage/combinat/finite_state_machine_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def Word(self, word, input_alphabet=None):
letters = list(word)
length = len(letters)
from sage.rings.integer_ring import ZZ
return Automaton([(ZZ(i), ZZ(i+1), letter)
return Automaton([(ZZ(i), ZZ(i + 1), letter)
for i, letter in enumerate(letters)],
initial_states=[ZZ(0)],
final_states=[ZZ(length)],
Expand Down Expand Up @@ -1241,7 +1241,7 @@ def convert_output(output):
for ring in output_rings:
try:
return ring(output)
except (ValueError,TypeError):
except (ValueError, TypeError):
pass
return output

Expand Down Expand Up @@ -1353,12 +1353,12 @@ def to_list(output):
assert equation == parsed_equation, \
"Parsing of %s failed for unknown reasons." % (equation,)

rule = self.RecursionRule(K=K,r=r, k=k, s=s, t=to_list(t))
rule = self.RecursionRule(K=K, r=r, k=k, s=s, t=to_list(t))
return rule

def Recursion(self, recursions, base, function=None, var=None,
input_alphabet=None, word_function=None,
is_zero=None, output_rings=[ZZ, QQ]):
is_zero=None, output_rings=[ZZ, QQ]):
r"""
Return a transducer realizing the given recursion when reading
the digit expansion with base ``base``.
Expand Down Expand Up @@ -1815,11 +1815,11 @@ def Recursion(self, recursions, base, function=None, var=None,

for given_rule in rules:
q, remainder = given_rule.r.quo_rem(base**given_rule.K)
rule=self.RecursionRule(K=given_rule.K,
r=remainder,
k=given_rule.k,
s=given_rule.s - base**given_rule.k*q,
t=given_rule.t)
rule = self.RecursionRule(K=given_rule.K,
r=remainder,
k=given_rule.k,
s=given_rule.s - base**given_rule.k * q,
t=given_rule.t)
for m in range(max_K - rule.K + 1):
for ell in range(base**m):
R = rule.r + base**rule.K * ell
Expand Down Expand Up @@ -1988,9 +1988,8 @@ def f(n):
"Too many initial conditions, only give one of %s." %
cycle[1:])
required_initial_values.update(intersection)
output_sum = sum([edge[2]
for edge in recursion_digraph.\
outgoing_edge_iterator(cycle[1:])],
output_sum = sum([e[2]
for e in recursion_digraph.outgoing_edge_iterator(cycle[1:])],
[])
if not is_zero(output_sum):
raise ValueError(
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/gelfand_tsetlin_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def _row_iter(self, upper_row):
[2, 0]
[2, 1]
"""
row = [x-1 for x in upper_row[1:]]
row = [x - 1 for x in upper_row[1:]]
row_len = len(row)
pos = 0
while pos >= 0:
Expand All @@ -1002,11 +1002,11 @@ def _row_iter(self, upper_row):
pos -= 1
continue
# If it would create an invalid entry, backstep
if ( pos > 0 and (row[pos] >= row[pos-1] \
or (self._strict and row[pos] == row[pos-1]-1)) ) \
if (pos > 0 and (row[pos] >= row[pos - 1]
or (self._strict and row[pos] == row[pos - 1] - 1))) \
or row[pos] >= upper_row[pos] \
or (self._k is not None and row[pos] >= self._k):
row[pos] = upper_row[pos+1] - 1
row[pos] = upper_row[pos + 1] - 1
pos -= 1
continue
row[pos] += 1
Expand Down
6 changes: 4 additions & 2 deletions src/sage/combinat/integer_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,8 +1455,10 @@ def cardinality(self):
return Integer(binomial(self.n + self.k - 1, self.n))
# do by inclusion / exclusion on the number
# i of parts greater than m
return Integer(sum( (-1)**i * binomial(self.n+self.k-1-i*(m+1), self.k-1) \
* binomial(self.k,i) for i in range(self.n/(m+1)+1) ))
n, k = self.n, self.k
return Integer(sum(
(-1)**i * binomial(n + k - 1 - i * (m + 1), k - 1)
* binomial(k, i) for i in range(self.n // (m + 1) + 1)))
return ZZ.sum(ZZ.one() for x in self)

def __iter__(self):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/multiset_partition_into_sets_ordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -2787,8 +2787,8 @@ def _base_iterator(constraints):
if min_ord:
min_k = max(1, min_k, min_ord // len(A))
if infinity not in (max_k, max_ord):
return chain(*(_iterator_order(A, ord, range(min_k, max_k+1)) \
for ord in range(min_ord, max_ord+1)))
return chain(*(_iterator_order(A, ord, range(min_k, max_k + 1))
for ord in range(min_ord, max_ord + 1)))
# else
return None

Expand Down
11 changes: 6 additions & 5 deletions src/sage/combinat/ncsf_qsym/generic_basis_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ def skew(self, x, y, side='left'):
x = self(x)
y = self.dual()(y)
v = 1 if side == 'left' else 0
return self.sum(coeff * y[IJ[1-v]] * self[IJ[v]] \
for (IJ, coeff) in x.coproduct() if IJ[1-v] in y.support())
return self.sum(coeff * y[IJ[1-v]] * self[IJ[v]]
for (IJ, coeff) in x.coproduct()
if IJ[1-v] in y.support())
else:
return self._skew_by_coercion(x, y, side=side)

Expand Down Expand Up @@ -710,9 +711,9 @@ def duality_pairing_matrix(self, basis, degree):
# TODO: generalize to keys indexing the basis of the graded component
from sage.combinat.composition import Compositions
return matrix(self.base_ring(),
[[self.duality_pairing(self[I], basis[J]) \
for J in Compositions(degree)] \
for I in Compositions(degree)])
[[self.duality_pairing(self[I], basis[J])
for J in Compositions(degree)]
for I in Compositions(degree)])

def counit_on_basis(self, I):
r"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ def __init__(self, cartan_type, B):
FullTensorProductOfRegularCrystals.__init__(self, tensor_prod, cartan_type=cartan_type)
# This is needed to override the module_generators set in FullTensorProductOfRegularCrystals
self.module_generators = HighestWeightTensorKRT(self)
self.rename("Tensor product of Kirillov-Reshetikhin tableaux of type %s and factor(s) %s"%(\
cartan_type, B))
self.rename("Tensor product of Kirillov-Reshetikhin tableaux "
f"of type {cartan_type} and factor(s) {B}")

def __iter__(self):
"""
Returns the iterator of ``self``.
Return the iterator of ``self``.

EXAMPLES::

Expand Down
11 changes: 5 additions & 6 deletions src/sage/combinat/root_system/root_lattice_realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def simple_roots(self):
@cached_method
def alpha(self):
r"""
Returns the family `(\alpha_i)_{i\in I}` of the simple roots,
Return the family `(\alpha_i)_{i\in I}` of the simple roots,
with the extra feature that, for simple irreducible root
systems, `\alpha_0` yields the opposite of the highest root.

Expand All @@ -475,13 +475,12 @@ def alpha(self):
alpha[1]
sage: alpha[0]
-alpha[1] - alpha[2]

"""
if self.root_system.is_finite() and self.root_system.is_irreducible():
return Family(self.index_set(), self.simple_root, \
hidden_keys = [0], hidden_function = lambda i: - self.highest_root())
else:
return self.simple_roots()
return Family(self.index_set(), self.simple_root,
hidden_keys=[0],
hidden_function=lambda i: - self.highest_root())
return self.simple_roots()

@cached_method
def basic_imaginary_roots(self):
Expand Down
20 changes: 11 additions & 9 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,19 +2090,20 @@ def _from_cache(self, element, cache_function, cache_dict, **subs_dict):
# needed for the old kschur functions - TCS
part = _Partitions(part)
for part2, c2 in cache_dict[sum(part)][part].items():
if hasattr(c2,'subs'): # c3 may be in the base ring
c3 = c*BR(c2.subs(**subs_dict))
if hasattr(c2, 'subs'): # c3 may be in the base ring
c3 = c * BR(c2.subs(**subs_dict))
else:
c3 = c*BR(c2)
c3 = c * BR(c2)
# c3 = c*c2
# if hasattr(c3,'subs'): # c3 may be in the base ring
# c3 = c3.subs(**subs_dict)
z_elt[ part2 ] = z_elt.get(part2, zero) + BR(c3)
z_elt[part2] = z_elt.get(part2, zero) + BR(c3)
return self._from_dict(z_elt)

def _invert_morphism(self, n, base_ring, self_to_other_cache, other_to_self_cache,\
to_other_function=None, to_self_function=None, \
upper_triangular=False, lower_triangular=False, \
def _invert_morphism(self, n, base_ring,
self_to_other_cache, other_to_self_cache,
to_other_function=None, to_self_function=None,
upper_triangular=False, lower_triangular=False,
ones_on_diagonal=False):
r"""
Compute the inverse of a morphism between ``self`` and ``other``
Expand Down Expand Up @@ -5979,8 +5980,9 @@ def character_to_frobenius_image(self, n):
2*s[2, 2, 1] + s[3, 1, 1] + 4*s[3, 2] + 3*s[4, 1] + 2*s[5]
"""
p = self.parent().symmetric_function_ring().p()
return self.parent()(p.sum(self.eval_at_permutation_roots(rho) \
*p(rho)/rho.centralizer_size() for rho in Partitions(n)))
return self.parent()(p.sum(self.eval_at_permutation_roots(rho)
* p(rho) / rho.centralizer_size()
for rho in Partitions(n)))

def principal_specialization(self, n=infinity, q=None):
r"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/words/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ def __eq__(self, other):
sage: W1 == W3
False
"""
return self is other or (type(self) == type(other) and \
self.alphabet() == other.alphabet() and \
self.vector_space() == other.vector_space() and \
self.letters_to_steps() == other.letters_to_steps())
return self is other or (type(self) == type(other) and
self.alphabet() == other.alphabet() and
self.vector_space() == other.vector_space() and
self.letters_to_steps() == other.letters_to_steps())

def __ne__(self, other):
r"""
Expand Down
9 changes: 4 additions & 5 deletions src/sage/combinat/words/suffix_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,13 @@ def transition_function(self, node, word):
if word.is_empty():
return 0
if word.length() == 1:
return self._transition_function[(node,word)]
else:
return self.transition_function( \
self._transition_function[(node,word[0:1])], word[1:])
return self._transition_function[(node, word)]
return self.transition_function(
self._transition_function[(node, word[0:1])], word[1:])

def states(self):
r"""
Returns the states of the automaton defined by the suffix trie.
Return the states of the automaton defined by the suffix trie.

EXAMPLES::

Expand Down
14 changes: 7 additions & 7 deletions src/sage/combinat/words/word_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class LowerChristoffelWord(FiniteWord_list):
word: 01
"""

def __init__(self, p, q, alphabet=(0,1), algorithm='cf'):
def __init__(self, p, q, alphabet=(0, 1), algorithm='cf'):
r"""
INPUT:

Expand Down Expand Up @@ -184,7 +184,7 @@ def __init__(self, p, q, alphabet=(0,1), algorithm='cf'):
if len(set(alphabet)) != 2:
raise ValueError("alphabet must contain exactly two distinct elements")
# Compute gcd of p, q; raise TypeError if not 1.
if gcd(p,q) != 1:
if gcd(p, q) != 1:
raise ValueError("%s and %s are not relatively prime" % (p, q))
# Compute the Christoffel word
if algorithm == 'linear':
Expand All @@ -194,7 +194,7 @@ def __init__(self, p, q, alphabet=(0,1), algorithm='cf'):
w = [alphabet[0]]
else:
for i in range(p + q):
v = (u+p) % (p+q)
v = (u + p) % (p + q)
new_letter = alphabet[0] if u < v else alphabet[1]
w.append(new_letter)
u = v
Expand All @@ -208,7 +208,7 @@ def __init__(self, p, q, alphabet=(0,1), algorithm='cf'):
cf = QQ((p, q)).continued_fraction_list()
u = [alphabet[0]]
v = [alphabet[1]]
#do not consider the first zero if p < q
# do not consider the first zero if p < q
start = 1 if p < q else 0
for i in range(start, len(cf)-1):
if i % 2 == 0:
Expand Down Expand Up @@ -1276,9 +1276,9 @@ def StandardEpisturmianWord(self, directive_word):
"""
if not isinstance(directive_word, Word_class):
raise TypeError("directive_word is not a word, so it cannot be used to build an episturmian word")
epistandard = directive_word.parent()(\
self._StandardEpisturmianWord_LetterIterator(directive_word),
datatype='iter')
epistandard = directive_word.parent()(
self._StandardEpisturmianWord_LetterIterator(directive_word),
datatype='iter')
return epistandard

def _StandardEpisturmianWord_LetterIterator(self, directive_word):
Expand Down
9 changes: 6 additions & 3 deletions src/sage/schemes/affine/affine_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,12 @@ def _fastpolys(self):
if self._is_prime_finite_field:
prime = polys[0].base_ring().characteristic()
degree = max(poly_numerator.degree(), poly_denominator.degree())
height = max([abs(c.lift()) for c in poly_numerator.coefficients()]\
+ [abs(c.lift()) for c in poly_denominator.coefficients()])
num_terms = max(len(poly_numerator.coefficients()), len(poly_denominator.coefficients()))
height = max([abs(c.lift())
for c in poly_numerator.coefficients()]
+ [abs(c.lift())
for c in poly_denominator.coefficients()])
num_terms = max(len(poly_numerator.coefficients()),
len(poly_denominator.coefficients()))
largest_value = num_terms * height * (prime - 1) ** degree
# If the calculations will not overflow the float data type use domain float
# Else use domain integer
Expand Down
6 changes: 3 additions & 3 deletions src/sage/schemes/affine/affine_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,18 @@ def __mul__(self, right):
if isinstance(right, AffineSpace_generic):
if self is right:
return self.__pow__(2)
return AffineSpace(self.dimension_relative() + right.dimension_relative(),\
return AffineSpace(self.dimension_relative() + right.dimension_relative(),
self.base_ring(), self.variable_names() + right.variable_names())
elif isinstance(right, AlgebraicScheme_subscheme):
AS = self*right.ambient_space()
AS = self * right.ambient_space()
CR = AS.coordinate_ring()
n = self.ambient_space().coordinate_ring().ngens()

phi = self.ambient_space().coordinate_ring().hom(list(CR.gens()[:n]), CR)
psi = right.ambient_space().coordinate_ring().hom(list(CR.gens()[n:]), CR)
return AS.subscheme([phi(t) for t in self.defining_polynomials()] + [psi(t) for t in right.defining_polynomials()])
else:
raise TypeError('%s must be an affine space or affine subscheme'%right)
raise TypeError('%s must be an affine space or affine subscheme' % right)

def change_ring(self, R):
r"""
Expand Down
Loading