Interesting. It seems the problem is that cm.discover_action(GF(5), ZZ, operator.div)
tries to look for a right action on of cm.discover_action(GF(5), Frac(ZZ), operator.mul) which doesn't exist as there are no coercions between GF(5) and QQ. I posted a patch to http://trac.sagemath.org/ticket/17740 . On Thu, Feb 5, 2015 at 1:39 PM, Jonas Jermann <jjerma...@gmail.com> wrote: > Hi > > Set x=GF(5)['x'].gen() > I dunno if this helps but here is an explanation why one gets a > different behavior for x/7 than cm.bin_op(x,7,operator.div): > > If you do "x/7" then I think it calls __div__ from polynomial_element > (Polynomial class): > > try: > if not isinstance(right, Element) or right.parent() != self.parent(): > R = self.parent().base_ring() > x = R._coerce_(right) > return self * ~x > except (TypeError, ValueError): > pass > return RingElement.__div__(self, right) > > Here right=ZZ(7), self=x, so right.parent() != self.parent() > so it does x = GF(5)._coerce_(7) > which is why you end up without the Fraction Field... > > If on the other hand you do cm.bin_op(x,7,operator.div) or x._div_(7) you > get a Fraction Field element at the moment. > > > Best > Jonas > > > On 05.02.2015 22:08, Vincent Delecroix wrote: >> >> 2015-02-05 21:38 UTC+01:00, John Cremona <john.crem...@gmail.com>: >>> >>> If you ask for operator.mul instead of operator.div then you get the >>> poly ring. Is that it, perhaps? >> >> >> Nope. I want to get rid of many hacks in rings/polynomial. In order to >> do that I need the div operation to be correctly handled by the >> coercion (or perhaps I missed something about the aim of coercion?). >> Namely, if p is an element of GF(5)['x,y'] then (p/Integer(2)) should >> be an element of GF(5)['x,y']. You can argue that this is what you get >> in Sage >> >> sage: R = GF(5)['x','y'] >> sage: (R.an_element() / 2).parent() >> Multivariate Polynomial Ring in x, y over Finite Field of size 5 >> >> But the reason why is a bit of a hack that actually introduce many >> bugs in other places: >> >> sage: R = GF(5)['x,y'] >> sage: (R.one() / R.one()).parent() >> Multivariate Polynomial Ring in x, y over Finite Field of size 5 >> >> the above should be an element of the fraction field! And you can >> build more involved examples. >> >> Vincent >> > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.