On Tue, 26 Jan 2010 01:23:10 -0800 (PST), Dima Pasechnik <dimp...@gmail.com> 
wrote:
> it does not help:
> indeed, I do not see how e.g. the following:
> 
> --- a/sage/groups/class_function.py     Wed Jan 20 15:09:32 2010 -0800
> +++ b/sage/groups/class_function.py     Tue Jan 26 09:10:38 2010 +1100
> @@ -284,7 +284,7 @@
>              sage: S5 = SymmetricGroup(5)
>              sage: irr = S5.irreducible_characters()
>              sage: [x.degree() for x in irr]
> -            [1, 4, 5, 6, 5, 4, 1]
> +            [1, 1, 4, 4, 5, 5, 6]
>          """
>          return Integer(self._gap_classfunction.DegreeOfCharacter())
> 
> amounts to a fix; the thing is that you need to sort [x.degree() for x
> in irr]
> (e.g. just sort([x.degree() for x in irr])) before comparing it with
> [1, 1, 4, 4, 5, 5, 6]
> 
> (I do not know how to write such a test in Sage, though...)
> 

I'll explain the reasoning behind my patch.  If you still think it
doesn't do the right thing then you are free to do things differently.

In irreducible_characters(), Sage calls the GAP function Irr to get the
irreducible characters of a group as GAP objects.  As you pointed out,
there is no natural *mathematical* ordering of these characters; in
other words, the right answer is the set of characters, independent of
the order in which they are listed.

This can cause problems with testing (as it just did when you ran tests
with 4.4.12).  When code gets rewritten in GAP, the order in which
things are listed might change; this is not a bug in GAP, the answer is
still mathematically correct, but it's silly for us to always have to
change our doctests when this happens.  Or, if the GAP function uses a
randomised algorithm, there is no guarantee that the order will be the
same between different machines or different runs on the same machine.
One way to fix this is to explicitly sort things in the doctests, which
is I think what you are proposing above:

sage: sorted([x.degree() for x in irr])
[1, 1, 4, 4, 5, 5, 6]

Another way, which I find more appealing, is to make
irreducible_characters() take the list from GAP and sort it, then return
the sorted list.  I find this better because it is less error-prone, and
now the exact output of irreducible_characters() is no more dependent on
irrelevant factors such as architecture, GAP version, random seed, etc.
And someone who uses this function from Sage does not need to know
anything about GAP internals and how they might have changed from one
version to another.

This is something that is done in a lot of places in the Sage library in
this type of situation.

It is possible that I am misunderstanding your objection, though.  


Best,
Alex


-- 
Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
-- Australia -- http://www.ms.unimelb.edu.au/~aghitza/

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to