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
[with patch, with positive review, rebased to 3.0.3.a1] permgps: added normal_subgroups and fixed image and kernel #3130
Comments
Attachment: 9670.patch.gz permgp.py+permgp_morphism.py patch based on 3.0.1 |
comment:2
This is not a review but I can review this patch. Here are a few preliminary comments. The effect of the patch is obscured by the fact that the methods in PermutationGroup_generic have been reordered. The new order first places methods whose names start with underscore at the top, and then begins alphabetical order. However the alphabetical order breaks down after quotient_group. I get the impression that alphabetization of the methods was started but not completed. There are merits to alphabetical ordering of the methods but there are also disadvantages. For example, largest_moved_point and smallest_moved_point are no longer adjacent. The patch affects (favorably) the examples at the head of permgroup_morphism.py. Many of the methods in this short file have no docstring and no doctests. It might be good to take this opportunity to add docstrings and doctests to these methods. The patch addresses finding normal subgroups of a permutation group by adding a new method. The normalizer_method should first test whether the parameter g is an element or itself a group. For example:
I will review the patch within the next few days but in the meantime I'm offering these preliminary comments. |
comment:3
I agree with everything said. I'm not looking forward to having to rebase this, but hopefully I can do that and fix whatever problems Dan finds at the same time. |
Attachment: 9670-factored-a.patch.gz |
Attachment: 9670-factored-b.patch.gz |
comment:4
I uploaded two patches called 9670-factored-a.patch and 9670-factored-b.patch. The union of these two patches is exactly David's patch 9670.patch. The first patch 9670-factored-a.patch only reorders the methods of PermutationGroup_generic The second patch goes on top. Importing these two patches is equivalent to David's patch. The purpose of this exercise is to show exactly what David's patch does. The second patch |
comment:5
I just want to add that this applies cleanly to 3.0.2 and 3.0.3.alpha0 (thanks Dan!) and passes sage -testall on sage 3.0.2. I am currently testing it on 3.0.3.alpha0. If it passes (and I assume it will) then I'll add the functionality to normalizer suggested by Dan above and posta new patch based on 3.0.3.alpha0. |
comment:6
If you are revising the patch, how about adding docstrings and tests in permgrp_morphism.py? Dan |
Attachment: 9792.patch.gz patch based on 3.0.3.alpha0 |
comment:7
I modified normalizer almost as suggested about (the version above returned a GAP Group; the one in the latext patch returns a SAGE PermutationGroup). Also, I straightened out the organization to the methods are now really in alphabetical order. Passes sage -testall. I don't think I should review this but if you twist my arm, I'll give it a positive review:-) |
comment:8
I'll review it. (Maybe not until tomorrow.) |
comment:9
The contents of the patch are as follows. (1) Methods of PermutationGroup_generic are alphabetized. (2) A comment on the Suzuki and Ree groups was moved to the file (3) Certain tests are commented # random output. (4) A method normal_subgroup() of PermutationGroup_generic is added. (5) The method normalizer() of PermutationGroup_generic is enhanced. (5) In permgroup_morphism.py PermutationGroupMorphism_im_gens gets I have looked at the patch carefully and tested it and found it good. |
comment:10
I am concerned about the added #random to doctests. Since we see GAP's random seed these doctests should be reproducible and it should be unneeded. I am CCing cwitty on the ticket - he might have some explanation or might know where the bug lurks [in case these is one]. Cheers, Michael |
comment:11
I'm not sure what Michael's comment means. I just have the following observation to report which might be relevant. Consider for example the "random output" comment in:
The output of the block
is, when entered repeatedly, not constant. However, once you enter the first 2 lines and then
repeatedly, the answer is always the same. It seems to me that "# random output" is to help the reader of the code recognize that their output might be different than the output given in the docstring. If that is the case, then for readability, it seems that some sort of comment on the random nature of the output should stay in the documentation somewhere. Does this seem reasonable? |
comment:12
|
comment:13
The order is not the issue.. The generators are randomly determined. |
comment:14
In any case, I am confused as to what to do. Do I wait for cwitty to comment, or just remove the "# random output" lines in the cases when the random seed is set (then post a new patch), or ... ? |
comment:15
Any function that calls a GAP function that uses random numbers should set the GAP random number seed, as explained in the following excerpt from randstate.pyx:
You can see several uses of this idiom in permgroup.py. |
comment:16
Okay, but it isn't clear to me that GAP is calling GAP's random numbers. "The method used by GAP to obtain random elements may depend on the type object." Is it true that the random method used to obtain generators of the terms in the CompositionSeries (and DerivedSeries, and friends) depends on the same seed used to generate random numbers? If this is not known, then I don't see why one uses the randstate.pyx function in permgroup.py. In any case, I am still unsure if I am supposed to submit a new patch or not. |
comment:17
"Is it true that the random method ... depends on the same seed used to generate random numbers?" I think it's very likely to be true (for practical purposes, there seems to be a single global random number generator in GAP). Did you check that the "# random" cases you added were actually random (that is, that they gave different answers on different doctest runs)? With our current approach to doctesting pseudo-random numbers, slight modifications to the code could easily result in changing the results of the doctests to a new, consistent value. I think it's worth removing as many "# random" from the Sage doctests as possible (which is why I bothered to write randstate.pyx), but I don't think there's any formal policy forbidding new "# random" doctests (even if they are easily fixable). |
comment:18
Forgive my questions but I'm still confused. You asked "Did you check that the "# random" cases you added were actually random (that is, that they gave different answers on different doctest runs)?" I'm not sure if this answers your question but here are two consecutive runs which set the seed and give different answers. Is that what you mean?
|
comment:19
OK, this seems to be a general problem with randstate; I can reproduce similar problems in Sage 3.0.2. I'm going to open a new ticket for the randstate bug; since the randstate issues have nothing to do with this patch, I'm going to reinstate bump's positive review. |
comment:20
(See #3364 for the new randstate ticket.) |
comment:21
9670.patch no longer merges cleanly because of the following hunk:
This is because of the fixes by William at #3353. This patch will need to be rebased against 3.0.3.alpha1 once it is out. Cheers, Michael |
comment:22
Looking at 9670.patch the problem might be limited to the actual moving of the list(self) function. Replacing that version with the one written by William might be enough. I did not look at the second patch, so there might be more problems there. David: For the record since you asked: Rebasing does not mean copying over the old files into the 3.0.3.alpha1 and then exporting again. You need to merge all the fixes including the moving of the new list(self) function. It would also be good if you posted a single new patch. Cheers, Michael |
comment:23
Since the patch must be rebased let me point out that the patch would be easier to evaluate it would be better if the patch were factored into two parts, one of which only reorders the methods of |
comment:24
I'm trying to rebase but don't know how to merge. When I try to apply the old patch I get
The methods in file permgroup.py.rej make no sense to me:
Why would these be rejected? AFAIK, they have nothing to do with the list(self) function. In any case, I don't know what to do with these. The link http://hgbook.red-bean.com/hgbookch12.html simply says "it is usually best to fix up the rejected hunks", but that isn't very specific. These passes sage -testall before, so I don't know what there is to fix. |
comment:25
Perhaps I'm misreading something, but it seems like the files size before William's patch #3353 is 72K and now it is 80K. So, I'm leary of just taking my file and replacing the list method by William's. Maybe I should just completely redo the entire thing? To me that would be more straightforward than dealing with hg-rejected methods. If I should do this, should I also start a new ticket? |
comment:26
It seems to me that the patch has to be redone but without starting a new ticket. I'd prefer to see just the changes to the methods without alphabetizing. That way the effect of the patch is clear. A separate patch putting the methods in alphabetical order could be a separate ticket. I think it is good practice if code-cleanup patches (such as realphabetizing, tab removal, etc.) do the cleanup but have no other effect. Especially realphabetizing the methods should not be mixed with actual code changes since one can't tell that a method hasn't been changed when it is moved to another spot. This was a problem when I reviewed the patch. |
comment:27
I agree with Dan: Post a new patch that adds normal_subgroups and fixes image and kernel only against 3.0.3.a1. Then open a new ticket that sorts all the functions alphabetically. Cheers, Michael |
comment:28
Please apply both of these patches. The 2 pass sage -testall. There is no alphabetical resorting in this patch. |
Attachment: 9807.patch.gz this and 9807 are based on sage 3.0.3alpha1 |
comment:29
Attachment: 9808.patch.gz I went through the patch (9807.patch+9808.patch) and it looks good to me. It is I hope that this ticket is closed before 3364. When 3364 is closed maybe someone |
comment:30
Merged in Sage 3.0.3.alpha2 |
Why SAGE doesn't support the computation of normal subgroups has been raised on sage-support. I needed it myself for a research problem so, added it. While constructing an example for the docstring, it dawned on me that image and kernel still only return a string. William Stein and David Kohel suggested that be fixed, maybe 2 years ago now, so I added that. While doctesting, I discovered that derived_series and friends is a random computation. (Very odd that a docstring failure hasn't been triggered until now.) Anyway, some "# random" comments were added to fix that.
Finally, I rearranged the PermutationGroup class methods in a more alphabetical order for easier reading.
Passes sage -testall. The diff file is huge but only because of the reordering of the methods. Really, it is a fairly simple pach.
CC: @sagetrac-cwitty
Component: group theory
Issue created by migration from https://trac.sagemath.org/ticket/3130
The text was updated successfully, but these errors were encountered: