Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #11979 doctest correction and small cleanup (pep8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed May 11, 2014
1 parent 1f8e43f commit 9d056af
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/sage/algebras/divided_power_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from sage.categories.rings import Rings
from sage.sets.non_negative_integers import NonNegativeIntegers
from sage.rings.arith import binomial
from sage.categories.tensor import tensor
from sage.rings.integer import Integer


Expand All @@ -28,12 +27,15 @@ class DividedPowerAlgebra(CombinatorialFreeModule):
An example of a graded Hopf algebra with basis: the divided power algebra
in one variable.
This class illustrates a minimal implementation of the divided power algebra.
This class illustrates a minimal implementation of the divided
power algebra.
"""
def __init__(self, R):
if not R in Rings():
raise ValueError('R is not a ring')
CombinatorialFreeModule.__init__(self, R, NonNegativeIntegers(), category = GradedHopfAlgebrasWithBasis(R))
GHWBR = GradedHopfAlgebrasWithBasis(R)
CombinatorialFreeModule.__init__(self, R, NonNegativeIntegers(),
category=GHWBR)

def _repr_(self):
return "The divided power algebra over %s" % (self.base_ring())
Expand All @@ -56,15 +58,20 @@ def one(self):

def product_on_basis(self, left, right):
r"""
Product, on basis elements, as per :meth:`AlgebrasWithBasis.ParentMethods.product_on_basis`.
Product, on basis elements
As per :meth:`AlgebrasWithBasis.ParentMethods.product_on_basis`.
INPUT:
- ``left``, ``right`` - non-negative integers determining monomials (as the
exponents of the generators) in this algebra
- ``left``, ``right`` - non-negative integers determining
monomials (as the exponents of the generators) in this
algebra
OUTPUT:
OUTPUT: the product of the two corresponding monomials, as an
element of ``self``.
the product of the two corresponding monomials, as an element
of ``self``.
EXAMPLES::
Expand All @@ -88,11 +95,10 @@ def coproduct_on_basis(self, t):
B[0] # B[4] + B[1] # B[3] + B[2] # B[2] + B[3] # B[1] + B[4] # B[0]
sage: A.coproduct(B[0])
B[0] # B[0]
"""
AA = self.tensor(self)
return AA.sum_of_monomials( ( (k, t - k)
for k in range(t + 1) ) )
return AA.sum_of_monomials(((k, t - k)
for k in range(t + 1)))

def counit_on_basis(self, t):
"""
Expand All @@ -106,7 +112,7 @@ def counit_on_basis(self, t):
sage: A.counit(B[3])
0
sage: A.counit(B[0])
B[0]
1
"""
if t == 0:
return self.base_ring().one()
Expand Down Expand Up @@ -140,7 +146,9 @@ def degree_on_basis(self, t):
- ``t`` -- the index of an element of the basis of this module,
i.e. a non-negative integer
OUTPUT: an integer, the degree of the corresponding basis element
OUTPUT:
an integer, the degree of the corresponding basis element
EXAMPLES::
Expand All @@ -156,7 +164,9 @@ def degree_on_basis(self, t):
@cached_method
def algebra_generators(self):
r"""
The generators of this algebra, as per :meth:`Algebras.ParentMethods.algebra_generators`.
The generators of this algebra
As per :meth:`Algebras.ParentMethods.algebra_generators`.
EXAMPLES::
Expand Down

0 comments on commit 9d056af

Please sign in to comment.