Ticket #750 (closed enhancement: fixed)

Opened 6 years ago

Last modified 4 years ago

[with patch] permutation group element (dict method, acting on lists)

Reported by: jason Owned by: boothby
Priority: minor Milestone: sage-2.8.11
Component: combinatorics Keywords:
Cc: sage-combinat Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

It would be nice to get permutation elements as dictionaries as well as lists. If g is a permutation group element, then something like

  sage: g.dict()
{1:2, 2:1}

It would also be nice if we could have permutation elements act on lists to switch the order according to the permutation.

  sage: g.action(range(3))
[0,2,1]

Are these things possible already?

Attachments

750.hg Download (801 bytes) - added by boothby 6 years ago.
750.1.hg Download (1.6 KB) - added by boothby 6 years ago.
Includes .dict() code.
750.1.2.hg Download (39.5 KB) - added by boothby 6 years ago.
fixes bugs from previous edition / ready for 2.8.11

Change History

comment:1 Changed 6 years ago by mabshoff

  • Milestone set to sage-feature

Changed 6 years ago by boothby

comment:2 Changed 6 years ago by boothby

Added a patch to implement something similar to the second. With this patch, one may do the following:

sage: G = SymmetricGroup(4)
sage: g = G((1,2,3,4))
sage: sage: g('abcd')
'bcda'
sage: sage: g([0,1,2,3])
[1, 2, 3, 0]
sage: sage: g(('foo','bar','baz','what'))
('bar', 'baz', 'what', 'foo')

However, I can see absolutely no reason for one to want a dict rather than a list. Do you have an example of where this might be useful?

comment:3 Changed 6 years ago by boothby

  • Owner changed from was to boothby
  • Status changed from new to assigned
  • Milestone changed from sage-feature to sage-2.8.11

Robert Miller convinced me that there are good reasons to want a dict, so I implemented this, too.

Changed 6 years ago by boothby

Includes .dict() code.

Changed 6 years ago by boothby

fixes bugs from previous edition / ready for 2.8.11

comment:4 Changed 6 years ago by mabshoff

  • Summary changed from permutation group element (dict method, acting on lists) to [with patch] permutation group element (dict method, acting on lists)

comment:5 Changed 6 years ago by mabshoff

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

comment:6 Changed 4 years ago by nthiery

  • Cc sage-combinat added
Note: See TracTickets for help on using tickets.