P. Portilla P. Portilla - 3 months ago 6
Python Question

Sage doesn't find cycle_type() attribute on a permutation element

Im trying to work on some group theory with Sage.

In particular I was trying to learn the basic commands related to symmetric groups.

My input is

G=SymmetricGroup(6)

sigma=G('(1,3,5)(4,6)')


then I use
sigma.cycle_type()
and according to the documentation, I should get as output a list with the lengths of the cycles that form sigma in decreasing order, in this case I should get something like [3,2]. Instead I get an "AttributeError" :

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-25-94f73ca80516> in <module>()
----> 1 sigma.cycle_type()

/home/sage/sage-7.2/src/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (/home/sage/sage-7.2/src/build/cythonized/sage/structure/element.c:4649)()
411 dummy_error_message.name = name
412 raise dummy_attribute_error
--> 413 return getattr_from_other_class(self, P._abstract_element_class, name)
414
415 def __dir__(self):

/home/sage/sage-7.2/src/sage/structure/misc.pyx in sage.structure.misc.getattr_from_other_class (/home/sage/sage-7.2/src/build/cythonized/sage/structure/misc.c:1870)()
257 dummy_error_message.cls = type(self)
258 dummy_error_message.name = name
--> 259 raise dummy_attribute_error
260 if isinstance(attribute, methodwrapper):
261 dummy_error_message.cls = type(self)

AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute 'cycle_type'


What am I doing wrong?

Answer

Possibly you just need a newer version of Sage? In a late beta of 7.3, I get:

sage: sigma.cycle_type()
[3, 2, 1]

I should point out that the version in SageMathCloud appears to be too old for this currently, if that's your platform...