sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

Documentation for .conjugacy_classes_representatives() does not mention that it is not deterministic #37285

Open maxale opened 9 months ago

maxale commented 9 months ago

Steps To Reproduce

The following code illustrates that the .conjugacy_classes_representatives() method is not deterministic:

sage: P = PermutationGroup( SymmetricGroup(7).gens() )
sage: set( P.conjugacy_classes_representatives() ) == set( P.conjugacy_classes_representatives() )
False

Expected Behavior

Method .conjugacy_classes_representatives() is a wrapper for GAP's function Representative() whose documentation says:

Note that Representative is free in choosing a representative if there are several elements in C. It is not even guaranteed that Representative returns the same representative if it is called several times for one collection.

Actual Behavior

Sage's documentation for .conjugacy_classes_representatives() fails to mention this important property, which may lead to unexpected side effects in an unaware code.

Additional Information

It may be even worth to include example illustrating the issue (like the one above) to raise awareness.

Environment

- **OS**: Ubuntu 22.04.3 LTS
- **Sage Version**: 10.2.beta5

Checklist

RuchitJagodara commented 9 months ago

Can you please check again the results because it is giving True in my case.

maxale commented 9 months ago

It is False on my system, and it is also False at Sagecell. This may be system-dependent. Anyway, the point is that for some permutations groups it may be False, and there is nothing wrong with it as soon as this behavior is documented.