On Wed, May 11, 2011 at 7:23 AM, Bruce <[email protected]> wrote:
> What I now understand and I assume no-one actually said as it is too > obvious (or maybe I was told and did not get it) is: > To implement a new monoid I define a new class which inherits from Parent. > The class definition has to include the line > Parent.__init__(self,category=Monoids()) > I don't think it is too obvious. Let me add the following, which may not help, but it is the way that I like to think about these things. There are two types of "inheritance" going on here: one mathematical; and one technical (the data type). The mathematical inheritance is via the category theory framework, as you did above by initializing with category=Monoids(). The other is the data structure, which in your example above is Parent. Note that it is possible to use other data types instead. For example, in order to implement a monoid algebra directly (without first implementing the monoid itself), you can use CombinatorialFreeModule. > Then I also have to implement class methods which are listed by > Monoids.ParentMethods > Only the required ones, which *should* be marked by @abstract_method. I think there is a way to ask which methods are required, but I don't remember how. You can also implement methods for the elements in the attribute Element of your class (which is a class). See the examples in examples/semigroup.py. Then reading these files I have some further questions: > What is the rationale for Family? I think the main rationale for Family is to provide a consistent interface for objects that model containers, regardless of the datatype used (list, dictionary, enumerated set, etc.). and what is ElementWrapper all about? Perhaps an example is best. Suppose your monoid elements are naturally described by strings. But strings do not have any knowledge about the monoid, so you can't write str1 * str2 in order to compute their product in the monoid. Essentially, by using ElementWrapper, you endow the object with information about its parent. (Technically, it is a new object that stores the original object in the attribute .value. It inherits methods via the category theory framework or through regular class inheritance.) I hope this helps. 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
