Hello everybody ! I need your help for something that I spent all of today (around six 6 hours) trying to do, and I can't. And I tried. So please, help me.
I am trying to use cartesian products of groups in Sage, and I cannot implement what I want because of the following problem : sage: GG = GF(2).cartesian_product(GF(2)); GG([2,2]) [2, 2] in Z/2z x Z/2Z, you naturally expect the answer to be (0,0). But it isn't, because the entries of [2,2] are not converted into elements of the cartesian product I defined. Thus, I tried to add the following to "class CartesianProduct" in categories/cartesian_product.py + class ParentMethods: + def _element_constructor_(self,x): + if hasattr(x,'parent') and x.parent() is self: + return x + if all( hasattr(xx,'parent') and xx.parent() is c for c,xx in zip(self._sets,x) ): + return x + else: + return tuple([c(xx) for c,xx in zip(self._sets,x)]) All I can obtain by trying many variations of this are 1) Infinite loops, for instance when I replace the last line by "return self( tuple (...." 2) This exception that I don't know how to interpret sage: GG = GF(2).cartesian_product(GF(2)); GG([2,2]) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-71d4d52371c6> in <module>() ----> 1 GG = GF(Integer(2)).cartesian_product(GF(Integer(2))); GG([Integer(2),Integer(2)]) /home/ncohen/.Sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:8858)() /home/ncohen/.Sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:4206)() /home/ncohen/.Sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:4116)() TypeError: Cannot convert tuple to sage.structure.element.Element Could you help, please ?... It is really hard to understand anything in this code as there are global implications to almost everything you do. Thanks. Nathann -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/d/optout.