Skip to content

Save and load a finitely presented group #37061

@enriqueartal

Description

@enriqueartal

Steps To Reproduce

Run the following code:

sage: save(FreeGroup(1)/[], 'ab')
sage: load('ab.sobj')
Finitely presented group < x |  >
sage: from sage.groups.finitely_presented import wrap_FpGroup
sage: save(wrap_FpGroup(libgap(FreeGroup(1)/[])), 'ab')
sage: load('ab.sobj')
---------------------------------------------------------------------------
GAPError                                  Traceback (most recent call last)
Cell In[20], line 1
----> 1 load('ab.sobj')

File /usr/local/sage-310/src/sage/misc/persist.pyx:189, in sage.misc.persist.load()
    187 
    188     ## Load file by absolute filename
--> 189     with open(filename, 'rb') as fobj:
    190         X = loads(fobj.read(), compress=compress, **kwargs)
    191     try:

File /usr/local/sage-310/src/sage/misc/persist.pyx:190, in sage.misc.persist.load()
    188 ## Load file by absolute filename
    189 with open(filename, 'rb') as fobj:
--> 190     X = loads(fobj.read(), compress=compress, **kwargs)
    191 try:
    192     X._default_filename = os.path.abspath(filename)

File /usr/local/sage-310/src/sage/misc/persist.pyx:995, in sage.misc.persist.loads()
    993 unpickler = SageUnpickler(io.BytesIO(s), **kwargs)
    994 global already_unpickled
--> 995 ans = unpickler.load()
    996 already_unpickled = { }
    997 return ans

File /usr/local/sage-310/src/sage/libs/gap/element.pyx:390, in sage.libs.gap.element._from_sage()
    388 
    389 
--> 390 cpdef _from_sage(elem) noexcept:
    391     """
    392     Currently just used for unpickling; equivalent to calling ``libgap(elem)``

File /usr/local/sage-310/src/sage/libs/gap/element.pyx:396, in sage.libs.gap.element._from_sage()
    394 """
    395 if isinstance(elem, str):
--> 396     return libgap.eval(elem)
    397 
    398 return libgap(elem)

File /usr/local/sage-310/src/sage/libs/gap/libgap.pyx:406, in sage.libs.gap.libgap.Gap.eval()
    404 
    405         initialize()
--> 406         elem = make_any_gap_element(self, gap_eval(gap_command))
    407 
    408         # If the element is NULL just return None instead

File /usr/local/sage-310/src/sage/libs/gap/util.pyx:364, in sage.libs.gap.util.gap_eval()
    362 try:
    363     GAP_Enter()
--> 364     result = GAP_EvalString(cmd)
    365     # We can assume that the result object is a GAP PList (plain list)
    366     # and we should use functions for PLists directly for now; see

GAPError: Error, Variable: 'x' must have a value

Expected Behavior

It should be possible to save and load any finitely presented group. It is possible if it is created directly.

Actual Behavior

If the group comes from wrap_FpGroup a libgap group, the above error happens.

Additional Information

No response

Environment

- **Fedora 39**:
- **Sage Version*: 10.2*:

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions