Hello John, On Sat, Jun 19, 2010 at 11:45 PM, John H Palmieri <jhpalmier...@gmail.com> wrote: > I have a simple example of a graded algebra with basis. Please take a > look at > > <http://trac.sagemath.org/sage_trac/ticket/9280> > > and provide feedback. Since the details for graded algebras are not > very well fleshed out anywhere, I had to make some things up, and > others might not agree with my decisions. Since I'm proposing adding > this as an example in sage.categories.examples, it ought to be "done > right", whatever that means.
I have some comments on the interface for GradedAlgebraWithBasis. 1. Your choice of using ``A[n]`` to return the degree `n` piece of `A` is not consistent with other "graded" algebras in Sage. For example: sage: sf = SymmetricFunctions(QQ) sage: s = sf.schur() sage: s[3] s[3] This returns an element of the algebra, and not the degree 3 homogoneous component. I wrote "graded" because the algebra is indeed graded, but Sage does not currently know about the grading. Personally, I strongly prefer the idea of using __getitem__ to access elements of the algebra, by passing data to construct an element of the indexing set. I really don't like to write sage: s.basis()(Partition([3])) to construct an element of the algebra. Instead, I suggest a method called homogeneous_component(n) that returns the degree n component. (This should be generic and pushed up to every GradedAlgebraWithBasis, and so you don't need to define it in your case. It would also have the benefit of showing up in tab completion.) 2. I wonder if your method basis_in_degree should be merged with basis: if no argument is specified, then default to the current behaviour (return a basis of the algebra); otherwise, return a basis of the degree n component. Again, this should be generic and pushed up to every GradedAlgebraWithBasis. It would look something like this. def basis(self, d=None): r""" Return the basis of the homogeneous component of degree ``d``. If ``d`` is None, then a basis of the algebra is returned. """ from sage.sets.family import Family if d is None: return Family(self._basis_keys, self.monomial) else: return Family([self.term(tuple(a)) for a in self._basis_fcn(n)]) 3. Right now, you are starting with a DisjointUnionEnumeratedSets constructed from a family: DisjointUnionEnumeratedSets(Family(NN, self._basis_fcn)) The family contains all the information you need: .keys() gives the objects grading the algebra and the output produces an indexing set for the basis for the degree n component. So it might make more sense to take the family as the starting point instead of the disjoint union. Franco -- -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-de...@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.