#9831: Permutation(list) should check its input (?)
-----------------------------+----------------------------------------------
   Reporter:  mmezzarobba    |       Owner:  sage-combinat
       Type:  defect         |      Status:  new          
   Priority:  major          |   Milestone:  sage-4.5.3   
  Component:  combinatorics  |    Keywords:               
     Author:                 |    Upstream:  N/A          
   Reviewer:                 |      Merged:               
Work_issues:                 |  
-----------------------------+----------------------------------------------
Description changed by mmezzarobba:

Old description:

> {{{
> ~$ ulimit -v 1048576
> ~$ sage
> ----------------------------------------------------------------------
> | Sage Version 4.5.1, Release Date: 2010-07-19                       |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: Permutation([1]).signature()
> 1
> sage: Permutation([0]).signature()
> -1
> sage: Permutation([1,0]).signature()
> -1
> sage: Permutation([0,1]).signature()
> ---------------------------------------------------------------------------
> MemoryError                               Traceback (most recent call
> last)
>
> /home/marc/<ipython console> in <module>()
>
> /data/sage-4.5.1/local/lib/python2.6/site-
> packages/sage/combinat/permutation.pyc in signature(p)
>     739             -1
>     740         """
> --> 741         return (-1)**(len(p)-len(p.to_cycles()))
>     742
>     743
>
> /data/sage-4.5.1/local/lib/python2.6/site-
> packages/sage/combinat/permutation.pyc in to_cycles(self, singletons)
>     556             l[i], next = False, l[i]
>     557             while next != cycleFirst:
> --> 558                 cycle.append( next )
>     559                 l[next - 1], next  = False, l[next - 1]
>     560             #Add the cycle to the list of cycles
>
> MemoryError:
> }}}

New description:

 It seems that ``Permutation(list)`` requires that the elements of list are
 exactly 1, 2, ..., n, but this is not clearly documented. Other values of
 ``list`` are accepted without error and lead to strange behaviours later.

 When ``list`` contains 0:
 {{{
 ~$ ulimit -v 1048576
 ~$ sage
 ----------------------------------------------------------------------
 | Sage Version 4.5.1, Release Date: 2010-07-19                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: Permutation([1]).signature()
 1
 sage: Permutation([0]).signature()
 -1
 sage: Permutation([1,0]).signature()
 -1
 sage: Permutation([0,1]).signature()
 ---------------------------------------------------------------------------
 MemoryError                               Traceback (most recent call
 last)

 /home/marc/<ipython console> in <module>()

 /data/sage-4.5.1/local/lib/python2.6/site-
 packages/sage/combinat/permutation.pyc in signature(p)
     739             -1
     740         """
 --> 741         return (-1)**(len(p)-len(p.to_cycles()))
     742
     743

 /data/sage-4.5.1/local/lib/python2.6/site-
 packages/sage/combinat/permutation.pyc in to_cycles(self, singletons)
     556             l[i], next = False, l[i]
     557             while next != cycleFirst:
 --> 558                 cycle.append( next )
     559                 l[next - 1], next  = False, l[next - 1]
     560             #Add the cycle to the list of cycles

 MemoryError:
 }}}
 With repeated elements:
 {{{
 sage: Permutation([1,1]).signature()
 ---------------------------------------------------------------------------
 MemoryError                               Traceback (most recent call
 last)

 /home/marc/<ipython console> in <module>()

 /data/sage-4.5.1/local/lib/python2.6/site-
 packages/sage/combinat/permutation.pyc in signature(p)
     739             -1
     740         """
 --> 741         return (-1)**(len(p)-len(p.to_cycles()))
     742
     743

 /data/sage-4.5.1/local/lib/python2.6/site-
 packages/sage/combinat/permutation.pyc in to_cycles(self, singletons)
     556             l[i], next = False, l[i]
     557             while next != cycleFirst:
 --> 558                 cycle.append( next )
     559                 l[next - 1], next  = False, l[next - 1]
     560             #Add the cycle to the list of cycles

 MemoryError:
 }}}

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9831#comment:1>
Sage <http://www.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.

Reply via email to