-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Uniformize the API to compute the inverse of an element #17965
Comments
This comment has been minimized.
This comment has been minimized.
Commit: |
Author: Frédéric Chapoton |
Branch: u/chapoton/17965 |
comment:2
Here is a first attempt. Opinions ? New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:4
In general I think unifying this is a good idea. Something to keep in mind is that |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:9
oh, boy, now with an infinite loop in
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:41
I see no way out other than removing the |
comment:42
But basically you want to remove the I am particularly worried about someone could have implemented an algebraic structure just through |
comment:43
here is an experimental branch with the default inverse re-activated, let us see what happens. New commits:
|
Changed branch from u/chapoton/17965 to public/ticket-17965-experiment |
comment:44
well, this seems to be almost green.. |
comment:45
It seems like that is unrelated. Have you tested locally? |
comment:46
the failure is #33161 ; the tests in this file pass with other random seeds |
comment:47
I am basically ready to flip the switch. The last thing I probably would like (although not fully convinced) is to have an alias |
comment:48
But this would basically contradict the fact that there is a unique global alias that maps |
comment:49
It isn't an alias in the Python sense. However, I didn't think your proposal said there should be a unique such redirect. I don't see any advantages of trying to impose that (it isn't really enforceable either). I think if we are consistent about using |
comment:50
Sorry, I am now confused and not sure what you would like me to change. |
comment:51
For example, in inverse = __invert__ alias there so the documentation won't change. Anyways, it sounds like you don't really like it and I wasn't convinced of how useful it would be, so we can move on. |
comment:52
So, is this a positive review ? |
Reviewer: Travis Scrimshaw |
comment:53
Yes. |
comment:54
After these changes, is ticket #17692 still relevant? |
comment:55
#17692 is independent of these changes (and the main proposal has already been done somewhere else). The issue of whether |
comment:56
Replying to Travis Scrimshaw:
No, the bitwise complement question is not the topic of #17692 (it is only mentioned in the very last comment) |
comment:57
Replying to Matthias Köppe:
Either way, #17692 is independent of this ticket. (It probably should be closed (again, the main change has been implemented elsewhere) or converted into a bitwise issue ticket.) |
Changed branch from public/ticket-17965-experiment to |
Some classes in Sage implement the inverse of an element through the
inverse method:
Some other through the
__invert__
method:Usually they provide a crosslink so that
__invert__
andinverse
are equivalent, but this is done on a case by case bases,so of course such links are missing here and there:
Shall we change the code to systematically implement
__invert__
asper Python's convention, and then implement the cross link
inverse
->
__invert__
once for all high up in the class hierarchy,typically in
Magmas.ElementMethods
?Caveat: this won't cover all cases since we have invertible elements
that don't belong to a magma; e.g. a isomorphisms between two
different parents; so it will still be necessary to handle a couple
special cases by hand.
See also comment about
__inverse__
insage.categories.coxeter_groups.py around line 699.
Note: the default implementation ~f = 1/f provided by Element should
probably be implemented in
Monoids.ElementMethods
; see also #17692.Note: the qqbar classes also implement an
invert
method, but that'sfor a slightly different use case. So we may, or not, want to make
this uniform too.
invert
does not fit Sage's usual verb/nounconvention since it's a verb while it is not inplace.
CC: @saliola @videlec @simon-king-jena @slel @tscrim
Component: categories
Author: Frédéric Chapoton
Branch/Commit:
312a91d
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/17965
The text was updated successfully, but these errors were encountered: