Hi Pavel, Obstinately, it is not a bug but bad user input as it should be integers. However, it should be more forceful about making sure its internal structure is what it needs to be. As you said, the issue is because (i-average) is an element of QQ and the affine permutation group code is assuming that its elements are integers. So when it is doing the floor division //, it is getting wrong results:
sage: z = 2 sage: r = 2/1 sage: z // 2 1 sage: r // 2 1 sage: r // 3 2/3 sage: z // 3 0 This is now https://trac.sagemath.org/ticket/26436. Best, Travis On Monday, October 8, 2018 at 8:01:32 PM UTC+10, Pavel Galashin wrote: > > Hi, > > I found a problem in the AffinePermutationGroup class. Here is a > reproducible example: > > def elt(window): >> average=(sum(window)-n*(n+1)/2)/n; >> print [i-average for i in window]; >> return A([(i-average) for i in window]); >> n=4; >> A=AffinePermutationGroup(['A',n-1,1]); >> p=elt([1,6,7,12]); >> q=p^-1; >> p;q; >> p*q==A.one()#this is false. Looking at the source code, I found something >> even more weird, see below >> q.value(2) >> p.value(2) >> p.value(q.value(2))#should be 2, but outputs 3 > > > I believe the issue arises because (i-average) belongs to QQ, not ZZ, and > in particular replacing the line > >> return A([(i-average) for i in window]); >> > with > >> return A([ZZ(i-average) for i in window]); > > fixes the problem for me. (But this still looks like a bug.) > -- 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 https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.