On Jul 16, 2008, at 2:13 PM, Arnaud Bergeron wrote: > I am currently working on a module for combinatorics and manipulation > of words in sage (which is much more powerful than what is already > there). You can find our current code at > http://sage-words.googlecode.com/ if you are interested. > > We started out using as little as possible from the Sage library and > then realized this was a bad idea and went the opposite direction. > > In this process I have encountered a problem with the Element class. > > I have a class which represents the set of words over an alphabet (but > is not a Monoïd since it also contains infinite words) and another > class which represents a word. These classes have a natural > Parent/Element relationship and I tried to use these classes from Sage > as superclasses. > > But I am encountering various problems due to the implicit assumption > that the Elements are always sort of numeric. As an example > Element.__nonzero__() tries to call the parent with 0 to compare > against the 0 element. But in my case it does not makes sense to > create a word from that. > > So I am stuck. We already have a working parent/element relationship, > but since it is not the Sage one it does not participate in coercions > and we can't use Sage morphisms. > > Should I file a bug about this, override methods that make these > assumptions with sensible stuff for my case or add ugly hacks to allow > _parent(0).
It sounds like you should override __nonzero__. Though most elements are numeric (using that term very loosely) there should be very little that requires that. Are there other things you have run into? - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---