-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Save and load finitely presented groups coming from libgap groups #37128
Conversation
A bit more detail about what is going wrong here. The problem is that when using the wrap function for a free group, it already knows what its libgap group is, so it passes that along as part of its construction data. This means it is becomes part of its pickling data as it is part of its input (which defines itself as a unique representation). This also causes two free groups to be constructed on the same generators that are not equal (as they are not identical). IMO, we should remove having the (lib)GAP group as an input option for free groups. Likewise, I think we should remove the |
I agree with this, may the opinion of @miguelmarco who created it would be interesting.
I am not sure this is a good idea to eliminate |
IIRC, my idea when I wrote that code was that the corresponding sage classes would be wrappers around gap groups, so it would make sense to have a way to wrap an already existing gap group. It can be useful if some user constructs a group using some group using lower level gap functionalities (not directly exposed by sage), and then wants to handle it as a sage group. For example, let's say we want to compute the lower central series of a group. Sage does not have a function for that, but gap does. So we can do:
That is, because we can create sage groups directly from gap groups, we have a lower level interface to get the underlying gap group, work in it within gap to obtain a new gap FpGroup, and then wrap it to get a sage group. If we drop the option of wrapping them directly, we loose this functionality. It wouldn't be a problem if we had methods that expose all (or at least, a vast majority) ways that you can construct finitely presented groups in gap... but there are a lot of them (this lower central series case is just an example). It would be nice to add them, but we are far from there now. So until we have an alternative for this kind of constructions, I would be against dropping this possibility. |
Basically I had the same kind of examples, e.g, subgroups of finite index of a f.p. group, using also For the results of the change of code, I do not know why
With this branch:
|
We should not have as part of the input data of a free group the libgap group. It creates needless complexity with breaking the unique representation. However, we can add a The For FP groups, this could be more useful. Although I don't know how sensitive GAP is to using different (but really equivalent) free groups for the FP groups. However, the methods |
I made a couple of commits:
|
That sounds interesting, but I didn't know about the ' classcall_private` method until now. How would be the interface in this approach? |
While there are still some issues, with the last changes, there is no more |
Should the class |
I tried some tricks for homomorphisms and it seems that it is related to the problem pointed out here by @tscrim, for |
Thank you. Well, there is one test that is failing, but we are removing it. So there is at least something that is breaking in a subtle way. At least with a separate PR, there is a clear point where people can see and comment. We can also clearly explain the reasoning (I can add this into the PR if necessary). |
<!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Currently in `UniqueRepresentation`, the MRO is constructed by ```class UniqueRepresentation(CachedRepresentation, WithEqualityById):``` However, in order to maximize the utility of the `WithEqualityById` class, in particular with subclasses of `UniqueRepresentation`, we should place it *first* in the MRO. This is useful in sagemath#37128, where this resolves MRO resolution issues and not having to reimplement (or set aliases) the behavior of `WithEqualityById`. However, this change, while seemingly innocuous, does cause a problem with one doctest dealing with very old pickles (Sage version <= 4.0) in `combinat/root_system/cartan_type.py` concerning `class CartanType_simple_finite:`. Currently, it is unclear why this change is resulting in the error: ``` sage: from sage.misc.fpickle import unpickleModule sage: pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer') sage: si2 = pg_make_integer('4') sage: unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 715, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute exec(compiled, globs) File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple _finite.__setstate__[5]>", line 1, in <module> unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) File "/sage/src/sage/misc/explain_pickle.py", line 2442, in unpickle_build setstate(state) File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106, in __setstate__ self.__class__ = T.__class__ TypeError: __class__ assignment: 'CartanType' object layout differs from 'CartanType_simple_finite' ``` However, since these are very old pickles and we cannot reproduce the failure otherwise, we feel that it is prudent to drop support for this and remove the corresponding class. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38203 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Travis Scrimshaw
<!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Currently in `UniqueRepresentation`, the MRO is constructed by ```class UniqueRepresentation(CachedRepresentation, WithEqualityById):``` However, in order to maximize the utility of the `WithEqualityById` class, in particular with subclasses of `UniqueRepresentation`, we should place it *first* in the MRO. This is useful in sagemath#37128, where this resolves MRO resolution issues and not having to reimplement (or set aliases) the behavior of `WithEqualityById`. However, this change, while seemingly innocuous, does cause a problem with one doctest dealing with very old pickles (Sage version <= 4.0) in `combinat/root_system/cartan_type.py` concerning `class CartanType_simple_finite:`. Currently, it is unclear why this change is resulting in the error: ``` sage: from sage.misc.fpickle import unpickleModule sage: pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer') sage: si2 = pg_make_integer('4') sage: unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 715, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute exec(compiled, globs) File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple _finite.__setstate__[5]>", line 1, in <module> unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) File "/sage/src/sage/misc/explain_pickle.py", line 2442, in unpickle_build setstate(state) File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106, in __setstate__ self.__class__ = T.__class__ TypeError: __class__ assignment: 'CartanType' object layout differs from 'CartanType_simple_finite' ``` However, since these are very old pickles and we cannot reproduce the failure otherwise, we feel that it is prudent to drop support for this and remove the corresponding class. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38203 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Travis Scrimshaw
<!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Currently in `UniqueRepresentation`, the MRO is constructed by ```class UniqueRepresentation(CachedRepresentation, WithEqualityById):``` However, in order to maximize the utility of the `WithEqualityById` class, in particular with subclasses of `UniqueRepresentation`, we should place it *first* in the MRO. This is useful in sagemath#37128, where this resolves MRO resolution issues and not having to reimplement (or set aliases) the behavior of `WithEqualityById`. However, this change, while seemingly innocuous, does cause a problem with one doctest dealing with very old pickles (Sage version <= 4.0) in `combinat/root_system/cartan_type.py` concerning `class CartanType_simple_finite:`. Currently, it is unclear why this change is resulting in the error: ``` sage: from sage.misc.fpickle import unpickleModule sage: pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer') sage: si2 = pg_make_integer('4') sage: unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 715, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute exec(compiled, globs) File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple _finite.__setstate__[5]>", line 1, in <module> unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) File "/sage/src/sage/misc/explain_pickle.py", line 2442, in unpickle_build setstate(state) File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106, in __setstate__ self.__class__ = T.__class__ TypeError: __class__ assignment: 'CartanType' object layout differs from 'CartanType_simple_finite' ``` However, since these are very old pickles and we cannot reproduce the failure otherwise, we feel that it is prudent to drop support for this and remove the corresponding class. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38203 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Travis Scrimshaw
<!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Currently in `UniqueRepresentation`, the MRO is constructed by ```class UniqueRepresentation(CachedRepresentation, WithEqualityById):``` However, in order to maximize the utility of the `WithEqualityById` class, in particular with subclasses of `UniqueRepresentation`, we should place it *first* in the MRO. This is useful in sagemath#37128, where this resolves MRO resolution issues and not having to reimplement (or set aliases) the behavior of `WithEqualityById`. However, this change, while seemingly innocuous, does cause a problem with one doctest dealing with very old pickles (Sage version <= 4.0) in `combinat/root_system/cartan_type.py` concerning `class CartanType_simple_finite:`. Currently, it is unclear why this change is resulting in the error: ``` sage: from sage.misc.fpickle import unpickleModule sage: pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer') sage: si2 = pg_make_integer('4') sage: unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 715, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute exec(compiled, globs) File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple _finite.__setstate__[5]>", line 1, in <module> unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2}) File "/sage/src/sage/misc/explain_pickle.py", line 2442, in unpickle_build setstate(state) File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106, in __setstate__ self.__class__ = T.__class__ TypeError: __class__ assignment: 'CartanType' object layout differs from 'CartanType_simple_finite' ``` However, since these are very old pickles and we cannot reproduce the failure otherwise, we feel that it is prudent to drop support for this and remove the corresponding class. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38203 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Travis Scrimshaw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the very long wait in getting to this and finishing my review. I have no additional comments. Let's get this in. Again, sorry for not getting this done sooner.
… libgap groups <!-- Describe your changes here in detail --> At this point it is not possible to load a saved finitely presented group that comes from a libgap group, see an example in sagemath#37061 One possible cause is the use of a general `__reduce__` method for free groups. At least, adding such a method allows to load free groups or finitely presented groups obtained from a libgap group using `wrapFreeGroup` or `wrapFpGroup`. It fixes sagemath#37061 and it would simplify some code in sagemath#36768 With these changes, free and finitely presented groups, included libgap groups, can be pickled. ### 📝 Checklist - [X] The title is concise, informative, and self-explanatory. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [X] I have updated the documentation accordingly. URL: sagemath#37128 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Enrique Manuel Artal Bartolo, Travis Scrimshaw
At this point it is not possible to load a saved finitely presented group that comes from a libgap group, see an example in #37061
One possible cause is the use of a general
__reduce__
method for free groups. At least, adding such a method allows to load free groups or finitely presented groups obtained from a libgap group usingwrapFreeGroup
orwrapFpGroup
. It fixes #37061 and it would simplify some code in #36768With these changes, free and finitely presented groups, included libgap groups, can be pickled.
📝 Checklist