-
Notifications
You must be signed in to change notification settings - Fork 175
document objects with memory #6174
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
base: master
Are you sure you want to change the base?
Conversation
| ## It may, however, happen that some ⪆ function runs into an error | ||
| ## when it is called with elements with memory. | ||
| ## In such cases, probably a method for elements with memory is missing, | ||
| ## and perhaps some existing methods are installed with too weak | ||
| ## requirements. |
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.
As an end user, I think I'd find this paragraph frustrating: it describes a problem but gives no hint as to how to resolve it.
Perhaps we can offer some solutions:
- add your own method, by looking at the methods in
lib/memory.giand adapting them - contact GAP support / write an issue and requesting this, and we might add it for you
- .... anything else?
Also perhaps we could list which operations are currently supported / "wrapped"?
It might also make sense that these things are written mainly with groups in mind, and are tested relatively well for permutations and (quadratic) matrices, and nothing else.
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.
Good point.
I will provide a utility function that creates an overview of the currently supported methods for objects with memory.
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.
Based on our last discussion, it seems you are working on a serious text addressing this point.
Which I think is great, but perhaps we should not let the perfect be the enemy of the good, and first get this PR merged? It seems to me that this point here could already be improved by stating something like. "In this case, additional methods may have to be defined. Please contact GAP support if you run into such a problem and need help."
This can then later be replaced by your better text. But at least the rest of this PR does not need to stay open for an extended time, and people can benefit from it sooner.
| ############################################################################# | ||
| ## | ||
| ## <#GAPDoc Label="objwithmemory"> | ||
| ## The idea behind objects with memory is as follows. |
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.
Other communities refer to this as "tracing" / "tracing operations". Perhaps we could bring that up, briefly, it might help some people?
| ## | ||
| DeclareOperation( "StripMemory", [ IsObject ] ); | ||
|
|
||
| DeclareOperation( "ForgetMemory", [ IsObject ] ); |
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.
I was wondering why we even need ForgetMemory ; looking at the methods defined here in GAP, it would seem that ForgetMemory(x); could always be replaced by x := List(x, StripMemory);.
But it turns out it is mainly useful due to its method installed in the genss ("for a stabilizer chain") and orb ("for an orbit object") packages. Then recog uses the one in genss, which in turn uses the one in orb.
|
|
||
| DeclareOperation( "ForgetMemory", [ IsObject ] ); | ||
|
|
||
| DeclareGlobalFunction( "StripStabChain" ); |
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.
It seems to me that StripStabChain really should be turned into a method for ForgetMemory -- and also that it should in turn perhaps make use of ForgetMemory ?
|
|
||
| DeclareOperation( "ForgetMemory", [ IsObject ] ); | ||
|
|
||
| DeclareGlobalFunction( "StripStabChain" ); |
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.
It seems to me that StripStabChain really should be turned into a method for ForgetMemory -- and also that it should in turn perhaps make use of ForgetMemory ?
UPDATE: ah I see you in fact did change it to use ForgetMemory, excellent!
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.
Logically, StripStabChain does what ForgetMemory is intended for.
However, stabilizer chains are plain records, and installing a method for a record would require some additional checks. Since StripStabChain is not used in the library, I left the name and kept the function undocumented.
| ## | ||
| DeclareOperation( "StripMemory", [ IsObject ] ); | ||
|
|
||
| DeclareOperation( "ForgetMemory", [ IsObject ] ); |
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.
I was wondering why we even need ForgetMemory ; looking at the methods defined here in GAP, it would seem that ForgetMemory(x); could always be replaced by x := List(x, StripMemory);.
But it turns out it is mainly useful due to its method installed in the genss ("for a stabilizer chain") and orb ("for an orbit object") packages. Then recog uses the one in genss, which in turn uses the one in orb.
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.
My interpretation was that the main purpose of ForgetMemory is that it works in place. This is how the function StripStabChain uses it.
By not documenting the function, I have postponed the decision whether the function is needed.
|
|
||
| DeclareGlobalFunction( "StripStabChain" ); | ||
|
|
||
| DeclareGlobalFunction( "CopyMemory" ); |
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.
I am not aware of any code using this. It seems rather dangerous. Ah well.
lib/memory.gi
Outdated
| return ObjWithMemory( slp, b!.n, b!.el ); | ||
| #T why can't we return b? |
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.
Huh, beats me. The line was added by checks notes one Thomas Breuer, in PR #5875, but to be fair, the code before was essentially equivalent.
I'd be willing to change it and try what happens...?
| return ObjWithMemory( slp, b!.n, b!.el ); | |
| #T why can't we return b? | |
| return b; |
lib/memory.gi
Outdated
| return ObjWithMemory( slp, a!.n, a!.el ); | ||
| #T why can't we return a? |
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.
| return ObjWithMemory( slp, a!.n, a!.el ); | |
| #T why can't we return a? | |
| return a; |
lib/memory.gi
Outdated
| return ObjWithMemory( slp, 0, a!.el ); | ||
| #T why can't we return a? |
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.
| return ObjWithMemory( slp, 0, a!.el ); | |
| #T why can't we return a? | |
| return a; |
|
This is great, thanks a lot @ThomasBreuer ! I only left some minor nitpicks |
Concerning the question what to do when objects with memory cause GAP errors, add and document `MethodsForObjWithMemory`. For better reference, document also `MethodsOperation`. And fix some GAPDoc syntax.
addresses #6173