The mess in Permutations

70 views
Skip to first unread message

Nathann Cohen

unread,
Nov 22, 2012, 9:40:26 AM11/22/12
to Sage devel
Hello everybody.

I just created a new patch that adds an input check in the constructor of Permutation. This, because I have had problems with it, because you can create an infinite loop with it in two lines, and because it is totally impossible that -- after looking at the code -- such a thing would not break anyway.

This has been mentionned there already : 

Mainly : some methods of this class are *WRITTEN* with the assumption that the elements of a permutation are 1...n. Some other parts of the code freely feed it with 0...n-1, some others feed it with lists instead of integers instead of integers.

This patch adds a check_input flag to check that the Permutation is indeed correct, and this flag is obviously the default. It can be disabled if needed (for speed), but obviously not to freely feed it with bad input data.

Now, as a lot of code *in Sage* (and doctests) use the code anyway, I set some check_input = False in the code, and warnings everywhere when needed to warn people about the results. These warnings have to be removed and a correct code written. But this patch is totally selfish : I use Permutations from time to time, and I need to know that my code does not return wrong results. It's as simple as that. If others do not have such constraints, I do not mind letting them compute whatever they want. Let them fix it if they wish. That I have been using such a thing for so long scares me enough, and quite honestly I am not that eager to deal again with parts of the code I do not know. Honestly again, I'm sick to think that this is in Sage. I'm also sick to thing that people have been knowing the state of this for so long, never doing anything about it.


Nathann
Reply all
Reply to author
Forward
0 new messages