[sage-devel] Re: TypeError: unsupported operand parent(s) for *: <(1,3)(2,4), (1,4,3,2)> and S4
PS: On 2018-01-30, Simon Kingwrote: > The coercion model chooses coercion to the left factor's parent, if > there are coercions available in *both* directions. However, if there > only is a coercion from the left factor's parent to the right factor's > parent but not vice versa, that coercion is supposed to be used. Jeroen just pointed out on trac, that indeed Sage believes that there is not only a coercion from the subgroup to the group, but also from the group to the subgroup, which is totally wrong (and the "coercion map" from group to subgroup indeed raises an error when being applied to an element of the group). That would explain it. -- 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.
[sage-devel] Re: TypeError: unsupported operand parent(s) for *: <(1,3)(2,4), (1,4,3,2)> and S4
Dear Hsin-Po Wang, On 2018-01-30, Hsin-Po Wangwrote: > But it is still interesting to see if this is an unintentional bug in, say, > the coercion model and can be fixed. We have sage: S4.has_coerce_map_from(S4.subgroups()[19]) True Hence, the coercion model is supposed to *automatically* convert the element S4.subgroups()[19][1] into an element of S4, and then do the multiplication. Oddly enough, sage: S4[1]*S4.subgroups()[19][1] (1,4,2,3) works (i.e., the right factor is automatically converted into the parent of the left factor), but sage: S4.subgroups()[19][1]*S4[1] doesn't work (as you reported). The coercion model chooses coercion to the left factor's parent, if there are coercions available in *both* directions. However, if there only is a coercion from the left factor's parent to the right factor's parent but not vice versa, that coercion is supposed to be used. So, shortly, it is a clear bug. I created https://trac.sagemath.org/ticket/24612 for it. Thank you for reporting it! Best regards, Simon -- 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.
[sage-devel] Re: TypeError: unsupported operand parent(s) for *: <(1,3)(2,4), (1,4,3,2)> and S4
> use > S4(S4.subgroups()[19][1]) * S4[1] > Thank you. That makes perfect sense. This does not bother me anymore since I found that pre-casting all subgroup-elements to S4 accelerates my work a lot. (i.e. S4subgroups=[ [S4(h) for h in H] for H in S4.subgroups()] ) But it is still interesting to see if this is an unintentional bug in, say, the coercion model and can be fixed. -- 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.
[sage-devel] Re: TypeError: unsupported operand parent(s) for *: <(1,3)(2,4), (1,4,3,2)> and S4
I'm not sure if Sage can always tell, if you multiply an element of a subgroup by an element of the larger group, that the result should make sense and lie in the larger group. You should be able to fix this by forcing Sage to consider the subgroup element as lying in the larger group: rather than S4.subgroups()[19][1] * S4[1] use S4(S4.subgroups()[19][1]) * S4[1] On Monday, January 29, 2018 at 3:20:16 PM UTC-8, Hsin-Po Wang wrote: > > The following code > > sage: S4=SymmetricGroup(*4*) > > sage: S4.subgroups()[*19*][*1*]*S4[*1*] > > raises an error > > TypeError: unsupported operand parent(s) for *: 'Subgroup of (Symmetric > group of order 4! as a permutation group) generated by [(1,3)(2,4), > (1,4,3,2)]' and 'Symmetric group of order 4! as a permutation group' > > I am not sure what exactly happened but this is quite peculiar. Among al > 30 subgroups of S4 only the 19th and 27th raise errors. > > sage: *for* Sid,S in enumerate(S4.subgroups()): > > : *for* s in S: > > : *for* g in S4: > > : *try*: > > : sg=s*g > > : *except* *TypeError*: > > : #print'For {}-th subgroup: {}*{} is > bad'.format(Sid,s,g) > > : *print* Sid, > > : > > > 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 > 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 > 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 > 19 19 19 19 19 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 > 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 > 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 > 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 > 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 > 27 27 27 27 27 27 27 27 > > I am using Sage 8.0.0 on macOS 10.13.2 > > -- 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.