#6857: [with patch, positive review] in automorphism_group, orbits=True does not
translate vertices back
--------------------------+-------------------------------------------------
Reporter: rlm | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone: sage-4.1.2
Component: graph theory | Keywords:
Reviewer: | Author: Robert Miller
Merged: |
--------------------------+-------------------------------------------------
Comment(by ncohen):
Applies fines, does its job. Positive review !
Not related to this patch, I found out testing things some *really
unimportant* error :
{{{
sage: g.automorphism_group(return_group=False)
---------------------------------------------------------------------------
IndexError Traceback (most recent call
last)
/user/ncohen/home/.sage/temp/rebelote.inria.fr/22721/_user_ncohen_home__sage_init_sage_0.py
in <module>()
/usr/local/sage/local/lib/python2.6/site-packages/sage/graphs/graph.pyc in
automorphism_group(self, partition, translation, verbosity, edge_labels,
order, return_group, orbits)
8462 # A Python switch statement!
8463 return { 0: None,
-> 8464 1: output[0],
8465 2: tuple(output),
8466 3: tuple(output),
IndexError: list index out of range
}}}
This comes from the fact that in this configuration of arguments, the
function is expected to ... do nothing ;-)
At the end of the function, the code already expects this eventuality and
reads :
{{{
# A Python switch statement!
return { 0: None,
1: output[0],
2: tuple(output),
3: tuple(output),
4: tuple(output)
}[len(output)]
}}}
I knew nothing about such things in Python and I am glad I read it. But
the key 0: None does not behave as expected : it behaves as if there was
NO key "0" in the dictionary and when len(output) equals 0 there is an
error because of that... It can be fixed pretty easily this way :
{{{
# A Python switch statement!
return { 1: output[0],
2: tuple(output),
3: tuple(output),
4: tuple(output)
}[len(output)] if len(output)>0 else None
}}}
Could it be possible to include discreetely it in your patch ? It does not
seem necessary to create a ticket just for this ;-)
Nathann
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6857#comment:1>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---