Ticket #3548 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

[with patch, positive review] bug in Permutation creation from a string

Reported by: was Owned by: joyner
Priority: major Milestone: sage-3.0.4
Component: group theory Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

This sucks:

sage: Permutation( '(4,5)' )
IndexError: list assignment index out of range

See below for more details.

On Thu, Jul 3, 2008 at 10:50 AM, John Cremona <> wrote:
>
> I would still say that this is a bug, since the following does work:
> sage: Permutation('(1)(2)(3)(4,5)')
> [1, 2, 3, 5, 4]
> and the docstring says the Permutation can be given a string in cycle
> notation, and 1-cycles are usually omitted.  Looking at the code
> (Permutation??) the error is in the call to from_cycles where the
> first parameter n is computed as the sum of the lengths of the cycles
> input instead of the maximum integer input.
>
> John Cremona
>
> 2008/7/3 Pierre <>:
>>
>> hi all,
>>
>> I'm confused with the cycle notation for permutations (bug ?)
>> While the following works:
>>
>> sage: Permutation( '(1,2)' )
>>
>> the following yields an error:
>>
>> sage: Permutation( '(4,5)' )
>> IndexError: list assignment index out of range
>>
>> What's confusing is that if you go:
>>
>> sage: x= Permutation( (4,5) )
>> sage: s= x.cycle_string(); s
>> '(4,5)'
>>
>> I'm trying to build a dictionnary whose keys are permutations; since
>> the keys have to be hashable, i'm relying on the cycle_string()
>> strings. But the above issue prevents me from recovering a permutation
>> from its string !
>>
>> Is there a way around this ?
>>
>> thanks
>> pierre


Attachments

sage-trac3548.patch Download (1.4 KB) - added by cremona 5 years ago.

Change History

Changed 5 years ago by cremona

comment:1 Changed 5 years ago by cremona

  • Summary changed from bug in Permutation creation from a string to [with patch, needs review] bug in Permutation creation from a string

The attached patch (based on 3.0.4.alpha0) fixes this and adds some relevant doctests.

sage: p = Permutation( '(4,5)' ); p
[1, 2, 3, 5, 4]
sage: p2 = Permutation( '(4,5)(10)' ); p2
[1, 2, 3, 5, 4, 6, 7, 8, 9, 10]

comment:2 Changed 5 years ago by rlm

  • Summary changed from [with patch, needs review] bug in Permutation creation from a string to [with patch, positive review] bug in Permutation creation from a string

+1

comment:3 Changed 5 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.0.4.alpha2

Note: See TracTickets for help on using tickets.