Skip to content
Open
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/categories/examples/algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
r"""
Examples of algebras with basis
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
#
# 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.sets.family import Family
Expand Down Expand Up @@ -73,7 +73,7 @@ def product_on_basis(self, w1, w2):
sage: Words = A.basis().keys()
sage: A.product_on_basis(Words("acb"), Words("cba"))
B[word: acbcba]
sage: (a,b,c) = A.algebra_generators()
sage: a, b, c = A.algebra_generators()
sage: a * (1-b)^2 * c
B[word: abbc] - 2*B[word: abc] + B[word: ac]
"""
Expand Down
12 changes: 6 additions & 6 deletions src/sage/categories/examples/commutative_additive_monoids.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Examples of commutative additive monoids
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
#
# 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
Expand Down Expand Up @@ -35,7 +35,7 @@ class FreeCommutativeAdditiveMonoid(FreeCommutativeAdditiveSemigroup):

with product rule given by `a \times b = a` for all `a, b`::

sage: (a,b,c,d) = S.additive_semigroup_generators()
sage: a, b, c, d = S.additive_semigroup_generators()

We conclude by running systematic tests on this commutative monoid::

Expand Down Expand Up @@ -66,7 +66,7 @@ class FreeCommutativeAdditiveMonoid(FreeCommutativeAdditiveSemigroup):
running ._test_zero() . . . pass
"""

def __init__(self, alphabet=('a','b','c','d')):
def __init__(self, alphabet=('a', 'b', 'c', 'd')) -> None:
r"""
The free commutative monoid.

Expand All @@ -86,7 +86,7 @@ def __init__(self, alphabet=('a','b','c','d')):
self.alphabet = alphabet
Parent.__init__(self, category=CommutativeAdditiveMonoids())

def _repr_(self):
def _repr_(self) -> str:
r"""
TESTS::

Expand Down
20 changes: 10 additions & 10 deletions src/sage/categories/examples/commutative_additive_semigroups.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Examples of commutative additive semigroups
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
#
# 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
Expand Down Expand Up @@ -37,7 +37,7 @@ class FreeCommutativeAdditiveSemigroup(UniqueRepresentation, Parent):

with product rule given by `a \times b = a` for all `a, b`::

sage: (a,b,c,d) = S.additive_semigroup_generators()
sage: a, b, c, d = S.additive_semigroup_generators()

We conclude by running systematic tests on this commutative monoid::

Expand Down Expand Up @@ -66,7 +66,7 @@ class FreeCommutativeAdditiveSemigroup(UniqueRepresentation, Parent):
running ._test_some_elements() . . . pass
"""

def __init__(self, alphabet=('a','b','c','d')):
def __init__(self, alphabet=('a', 'b', 'c', 'd')) -> None:
r"""
The free commutative monoid.

Expand All @@ -86,7 +86,7 @@ def __init__(self, alphabet=('a','b','c','d')):
self.alphabet = alphabet
Parent.__init__(self, category=CommutativeAdditiveSemigroups())

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand All @@ -104,7 +104,7 @@ def summation(self, x, y):
EXAMPLES::

sage: F = CommutativeAdditiveSemigroups().example()
sage: (a,b,c,d) = F.additive_semigroup_generators()
sage: a, b, c, d = F.additive_semigroup_generators()
sage: F.summation(a,b)
a + b
sage: (a+b) + (a+c)
Expand All @@ -125,7 +125,7 @@ def additive_semigroup_generators(self):
sage: F.additive_semigroup_generators()
Family (a, b, c, d)
"""
return Family( [self(((a,1),)) for a in self.alphabet] )
return Family([self(((a, 1),)) for a in self.alphabet])
# FIXME: use this once the keys argument of FiniteFamily will be honoured
# for the specifying the order of the elements in the family
# return Family(self.alphabet, lambda a: self(((a,1),)))
Expand All @@ -140,10 +140,10 @@ def an_element(self):
sage: F.an_element()
a + 2*b + 3*c + 4*d
"""
return self((a, (ord(a)-96)) for a in self.alphabet)
return self((a, ord(a) - 96) for a in self.alphabet)

class Element(ElementWrapper):
def __init__(self, parent, iterable):
def __init__(self, parent, iterable) -> None:
"""
EXAMPLES::

Expand Down
27 changes: 13 additions & 14 deletions src/sage/categories/examples/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DihedralGroup(UniqueRepresentation, Parent):
((2, 1), (2,), 1)]
"""

def __init__(self, n=5):
def __init__(self, n=5) -> None:
r"""
Construct the `n`-th DihedralGroup of order `2 n`.

Expand Down Expand Up @@ -144,7 +144,7 @@ def one(self):
"""
return self(())

def index_set(self):
def index_set(self) -> tuple:
r"""
Implement :meth:`CoxeterGroups.ParentMethods.index_set`.

Expand All @@ -156,7 +156,7 @@ def index_set(self):
"""
return (1, 2)

def degrees(self):
def degrees(self) -> tuple:
"""
Return the degrees of ``self``.

Expand Down Expand Up @@ -214,10 +214,9 @@ def has_right_descent(self, i, positive=False, side='right') -> bool:
reduced_word = self.value
if len(reduced_word) == self.parent().n:
return not positive
elif len(reduced_word) == 0:
if len(reduced_word) == 0:
return positive
else:
return (i == reduced_word[0 if side == "left" else -1]) == (not positive)
return (i == reduced_word[0 if side == "left" else -1]) == (not positive)

def apply_simple_reflection_right(self, i):
r"""
Expand All @@ -237,15 +236,15 @@ def apply_simple_reflection_right(self, i):
if len(reduced_word) == n:
if (i == 1 and is_odd(n)) or (i == 2 and is_even(n)):
return self.parent()(reduced_word[:-1])
else:
return self.parent()(reduced_word[1:])
elif (len(reduced_word) == n - 1 and (not self.has_descent(i))) and (reduced_word[0] == 2):
return self.parent()(reduced_word[1:])

if (len(reduced_word) == n - 1 and (not self.has_descent(i))) and (reduced_word[0] == 2):
return self.parent()((1,) + reduced_word)
else:
if self.has_descent(i):
return self.parent()(reduced_word[:-1])
else:
return self.parent()(reduced_word + (i,))

if self.has_descent(i):
return self.parent()(reduced_word[:-1])

return self.parent()(reduced_word + (i,))


Example = DihedralGroup
14 changes: 7 additions & 7 deletions src/sage/categories/examples/finite_monoids.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Examples of finite monoids
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
#
# 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.sets.family import Family
Expand Down Expand Up @@ -66,7 +66,7 @@ class IntegerModMonoid(UniqueRepresentation, Parent):
running ._test_some_elements() . . . pass
"""

def __init__(self, n=12):
def __init__(self, n=12) -> None:
r"""
EXAMPLES::

Expand All @@ -80,7 +80,7 @@ def __init__(self, n=12):
self.n = n
Parent.__init__(self, category=Monoids().Finite().FinitelyGenerated())

def _repr_(self):
def _repr_(self) -> str:
r"""
TESTS::

Expand All @@ -92,9 +92,9 @@ def _repr_(self):

def semigroup_generators(self):
r"""

Returns a set of generators for ``self``, as per
Return a set of generators for ``self``, as per
:meth:`Semigroups.ParentMethods.semigroup_generators`.

Currently this returns all integers mod `n`, which is of
course far from optimal!

Expand Down
12 changes: 6 additions & 6 deletions src/sage/categories/examples/finite_semigroups.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Examples of finite semigroups
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
#
# 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.sets.family import Family
Expand Down Expand Up @@ -107,7 +107,7 @@ class LeftRegularBand(UniqueRepresentation, Parent):
running ._test_some_elements() . . . pass
"""

def __init__(self, alphabet=('a','b','c','d')):
def __init__(self, alphabet=('a', 'b', 'c', 'd')) -> None:
r"""
A left regular band.

Expand All @@ -123,7 +123,7 @@ def __init__(self, alphabet=('a','b','c','d')):
Parent.__init__(self,
category=Semigroups().Finite().FinitelyGenerated())

def _repr_(self):
def _repr_(self) -> str:
r"""
TESTS::

Expand Down Expand Up @@ -181,7 +181,7 @@ def an_element(self):
'b'
"""

return self(''.join(self.alphabet[2:]+self.alphabet[0:2]))
return self(''.join(self.alphabet[2:] + self.alphabet[0:2]))

class Element (ElementWrapper):
wrapped_class = str
Expand Down
16 changes: 8 additions & 8 deletions src/sage/categories/examples/finite_weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SymmetricGroup(UniqueRepresentation, Parent):
sage: TestSuite(S).run()
"""

def __init__(self, n=4):
def __init__(self, n=4) -> None:
"""
EXAMPLES::

Expand All @@ -84,14 +84,14 @@ def __init__(self, n=4):
Parent.__init__(self, category=FiniteWeylGroups().Irreducible())
self.n = n

def _repr_(self):
def _repr_(self) -> str:
"""
EXAMPLES::

sage: FiniteWeylGroups().example()
The symmetric group on {0, ..., 3}
"""
return "The symmetric group on {0, ..., %s}" % (self.n-1)
return "The symmetric group on {0, ..., %s}" % (self.n - 1)

@cached_method
def one(self):
Expand All @@ -105,7 +105,7 @@ def one(self):
"""
return self(tuple(range(self.n)))

def index_set(self):
def index_set(self) -> list[int]:
"""
Implement :meth:`CoxeterGroups.ParentMethods.index_set`.

Expand Down Expand Up @@ -139,8 +139,8 @@ def cartan_type(self):
['A', 3] relabelled by {1: 0, 2: 1, 3: 2}
"""
from sage.combinat.root_system.cartan_type import CartanType
C = CartanType(['A',self.n-1])
C = C.relabel(lambda i:i-1)
C = CartanType(['A', self.n - 1])
C = C.relabel(lambda i: i - 1)
return C

def product(self, x, y):
Expand All @@ -157,7 +157,7 @@ def product(self, x, y):
assert y in self
return self(tuple(x.value[i] for i in y.value))

def degrees(self):
def degrees(self) -> tuple:
"""
Return the degrees of ``self``.

Expand All @@ -184,7 +184,7 @@ def has_right_descent(self, i) -> bool:
True
sage: S._test_has_descent()
"""
return (self.value[i] > self.value[i + 1])
return self.value[i] > self.value[i + 1]


Example = SymmetricGroup
4 changes: 2 additions & 2 deletions src/sage/categories/examples/magmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FreeMagma(UniqueRepresentation, Parent):

sage: TestSuite(M).run()
"""
def __init__(self, alphabet=('a', 'b', 'c', 'd')):
def __init__(self, alphabet=('a', 'b', 'c', 'd')) -> None:
r"""
The free magma.

Expand Down Expand Up @@ -77,7 +77,7 @@ def __init__(self, alphabet=('a', 'b', 'c', 'd')):

Parent.__init__(self, category=Magmas().FinitelyGenerated().Infinite())

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand Down
Loading
Loading