sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.98k stars 4.43k forks source link

BooleanFunction._to_nnf looses order of the original arguments #17575

Open fsaad opened 5 years ago

fsaad commented 5 years ago

https://github.com/sympy/sympy/blob/ade4ebc63ecd9d3d08749b296a745c53b40d2743/sympy/logic/boolalg.py#L478-L496

Using return cls(*argset) throws errors (stochastically), since placing the arguments in a set does not guarantee that unpacking the set returns the items in the insertion order.

asmeurer commented 5 years ago

Maybe we can add an OrderedSet object to compatibility. See https://stackoverflow.com/questions/1653970/does-python-have-an-ordered-set. In Python 3.6 you can build it on top of dict but for lower versions you have to use OrderedDict.