Comment #12 on issue 3501 by [email protected]: Missing partitions in sympy.utilities.iterables.multiset_partitions
http://code.google.com/p/sympy/issues/detail?id=3501

If 'ans' is the list of permutations that you want to make canonical, try

set( [tuple(sorted([tuple(sorted(j)) for j in i])) for i in ans] )

e.g.

ans
[[[1, 1, 1, 2]], [[1, 1, 1], [2]], [[1, 1, 2], [1]], [[1, 1], [1, 2]], [[1, 1], [1], [2]], [[1, 1, 2], [1]], [[1, 1], [1, 2]], [[1, 1], [1], [2]], [[1, 2], [1, 1]], [[1], [1, 1, 2]], [[1], [1, 1], [2]], [[1, 2], [1], [1]], [[1], [1, 2], [1]], [[1], [1], [1, 2]], [[1], [1], [1], [2]]]

set( [tuple(sorted([tuple(sorted(j)) for j in i])) for i in ans] )
set([((1, 1, 1, 2),), ((1,), (1,), (1,), (2,)), ((1,), (1, 1), (2,)), ((1, 1), (1, 2)), ((1, 1, 1), (2,)), ((1,), (1, 1, 2)), ((1,), (1,), (1, 2))])
for i in _:
...  if len(i)==2: print i
...
((1, 1), (1, 2))
((1, 1, 1), (2,))
((1,), (1, 1, 2))

compare to new version:

for i in multiset_partitions([1,1,1,2],2): print i
...
[[1, 1, 1], [2]]
[[1, 1, 2], [1]]
[[1, 1], [1, 2]]


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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/sympy-issues?hl=en.

Reply via email to