sympy/sympy — pull request #1555 by sn6uv (2012-10-02 23:27:54+00:00)
Title: Fix bug: relying on cpython poping the smallest element from a set

A test (sympy/combinatorics/tests/test_perm_groups.py) is failing for PyPy, since the current implementation relies on how CPython pops from sets.

The python docs (http://docs.python.org/library/stdtypes.html#set) state that the element popped from a set is arbitrary. I'm not sure if this is a bug in the current implementation, or just a bug in the tests. Maybe someone who understands the math could comment?

Cpython - Python 2.7.3
------------------------------
>>> a.pop()
0
>>> a
set([3, 4, 5])
>>> a = set([3, 4, 5, 0])
>>> a.pop()
0
>>> a
set([3, 4, 5])
>>> a = set([3, 4, 5, 0])
>>> a.pop()
0
>>> a
set([3, 4, 5])

PyPy nightly - Python 2.7.3 (993a0159055a, Oct 01 2012, 04:14:42 - [PyPy 1.9.1-dev0 with GCC 4.7.0]
----------------------------------------------------------------------------------------------------------------------------------------
>>>> a = set([3, 4, 5, 0])
>>>> a.pop()
0
>>>> a
set([3, 4, 5])
>>>> a = set([3, 4, 5, 0])
>>>> a.pop()
3
>>>> a
set([0, 4, 5])
>>>> a = set([3, 4, 5, 0])
>>>> a.pop()
4
>>>> a
set([0, 3, 5])