New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug in __cmp__ in permgroup_element.pyx #5537
Comments
Attachment: 5537.patch.gz |
comment:2
This will fix the error, but doesn't fix the underlying issue that the coercions should happen before cmp gets called. Also, I anticipate it will be a massive speed regression--if the sizes are inequal then the longer one should simply be checked to make sure it fixes the larger elements. I'll post a patch. |
comment:3
Replying to @robertwb: I spent some time with this earlier today, and had the same concerns about speed. I grabbed a random element of S_20 and of S_10 and then compared them repeatedly in a loop. One trip through the loop took about 0.8 seconds (including starting up Sage). Then for 2000 iterations the speed was 7.555s in 3.4 and 7.937s with the patch. Other runs with different number of iterations also indicated about 5-10% longer runtimes. I was just about to do more careful timings with timeit, but won't bother pending a new patch. I also added the following to the sage-devel thread, being current behavior under 3.4. A variant should maybe be added to the docstring.
|
comment:4
There is no such thing as "negative review". Cheers, Michael |
comment:5
Attachment: 5537-perm-cmp.patch.gz
vs. the old code
|
comment:6
I don't like having all of the < and > tests without documentation. I think in the old code, < and > didn't really mean anything, whereas now they do. I also don't like the examples that were in the old code: things like Also, a very minor point, but I think that in
there should be only one colon after TESTS. This isn't really important because right now, methods starting with an underscore don't appear in the reference manual, but I hope that some day they might... I changed this, too. Meanwhile, the patch fixes the problem in the summary and also the problem that rbeezer reports. All tests pass. If my patch is acceptable, positive review. |
apply 5537-perm-cmp.patch and then this one |
comment:7
Attachment: 5537-referee.patch.gz Replying to @robertwb: Hi Robert, Much improved. Correct and faster. Passed all tests in sage/groups/perm_gps. Do you think the code for the second loop checking the fixed elements of the longer permutation would be more readable if it mimicked the first loop? In other words, view the plain i's in the comparison as self.perm[i] and then have everything else match up exactly with the first loop:
|
comment:8
Replying to @jhpalmieri: John, I like the clear explanation of the ordering on permutations. Do the examples with < and > (or != and == in the referee patch) really need to come from the generators of some group? This just seems to make it harder for someone to decipher. Would it be clearer to just make two or three elements using |
comment:9
I'm not sure about the second colon on tests, but I thought that was needed for the ReST verbatim blocks. Other than that (which, again, I'm uncertain on) I approve of the referee patch--the explanation of the ordering is especially good. The first examples with the generators were there originally. I don't think they're the best, but I figured we'd keep them at least. As for whether or not it make sense to order these things, my choice of ordering was solely to be consistent with what was already there. There is another discussion ongoing at the moment about whether or not it makes sense to try and order everything, or just raise errors for non-obviously comparable things (in the case of permutations, there isn't an obvious ordering to choose), so I'm not sure its worth investing too much time into this until the dust settles there. |
comment:10
Replying to @robertwb:
After a double colon, ReST expects some indented text, and in fact if you use
in a docstring for a function not starting with an underscore, you get a warning about that. If you only use one colon after TESTS, the double colon at the end of the next part still signifies an upcoming verbatim block. As far as the original examples, I don't think they're very illuminating. I don't think it's that important, though, because it's not a docstring which appears in the reference manual or in a method people will be explicitly calling very much (and hence they won't be asking for interactive help about it, either). |
comment:11
RE ::, good point. I agree about the doctests, the most important point is that they get tested (so comparison of permutation group elements doesn't silently break one of these releases). |
comment:12
Replying to @robertwb:
Hi Robert. Is it possible for you to give some system info for those particular timing statistics? I think it's good to include both the statistics and some accompanying system/architecture info in a release tour. |
comment:13
Replying to @robertwb: Robert, If you were agreeable to the cosmetic changes I suggested above for the last bit of the code, then I'd roll up all the patches (your's, John's and mine) into one and John could finish off a review. Rob |
comment:14
Yes, I'm fine with those changes. As for what I ran timings on, OS X 10.4 intel core 2 duo 2.33 Ghz. |
comment:15
Attachment: trac_5537_perm_compare.patch.gz Replying to @robertwb: OK, final patch (trac_5537_perm_compare) has Robert's "perm-cmp" patch, John's "referee" patch, and my code changes listed above all in one. So this should be the only file Michael Abshoff will have to deal with. I think the ball is in your court now, John. Rob |
comment:16
Looks good to me. Positive review. |
comment:17
Merged trac_5537_perm_compare.patch in Sage 3.4.1.alpha0. Cheers, Michael |
From sage-support:
Clearly these comparisons should return the same thing. robertwb pointed out in the thread that, especially since the parents are not explicitly defined here, they should both return True.
I'll post a patch, but I don't know much about this code, and I don't want to slow things down too much. If anyone else has a faster way, please produce a new patch.
CC: @robertwb
Component: group theory
Issue created by migration from https://trac.sagemath.org/ticket/5537
The text was updated successfully, but these errors were encountered: