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
has_custom_conversion check in UnitalAlgebras.ParentMethods is broken #25181
Comments
Commit: |
New commits:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:4
@nthiery: it would be great to have some advice on how to proceed... |
comment:5
So use Another way to spell it is |
comment:6
I meant advice on what to do with the lazy attribute situation. The comments do not agree with the code. So either we fix the comments to say what the code really does or we change the code to do what the comments say. Unfortunately, the latter breaks stuff (see ticket description). |
comment:7
Replying to @embray:
Not both sides, because one side is a bound method and the other is an unbound method. |
comment:8
Nicolas: I would love to hear your opinion on this ticket. |
comment:9
Given that this seems difficult to fix properly, I'll probably go for cleaning it up without making any functional changes and properly documenting what happens. |
comment:10
This is already "fixed" in #24955 but only superficially. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:15
Travis told me in person that he is willing to set this to positive review later this month, after discussing it with Nicolas. |
This comment has been minimized.
This comment has been minimized.
Changed keywords from none to sagedays@icerm |
Changed keywords from sagedays@icerm to sagedays@icerm python3 |
comment:18
Adding python3 keyword since this helps fix a number of bugs there as well. |
comment:19
Hi Jeroen! I have just been through the new version. It is now much much clearer what the current logic does; thanks a lot! The logic is still crappy and way too complicated. but it's indeed very reasonable to split the work in two stages (in this ticket: fixing the Python 3 issue + clarifying the current logic; in a later ticket:fix/improve the logic). Positive review on my side. Just one question: while rewriting the code, did you do some additional manual tests to check how things worked? Or were the current doctests sufficient? In the former case, in case you still have your manual tests under hand, could you add them to the doctests? Thanks again, |
comment:20
Travis is next to me and agrees with the above comment. I let you set the positive review on our behalf after the question above. |
Reviewer: Travis Scrimshaw, Nicolas M. Thiéry |
comment:22
Replying to @nthiery:
I don't think so.
I recall from my work in Cernay on this ticket that the code was quite brittle: any small change in functionality would induce doctest failures somewhere. Maybe there are not many explicit tests, but the code is used in many places and therefore well tested implicitly. |
Changed branch from u/jdemeyer/has_custom_conversion_check_in_unitalalgebras_parentmethods_is_broken to |
The code in
UnitalAlgebras.ParentMethods.__init_extra__
to determine a coercion from the base ring to the algebra is quite obscure (and probably buggy). Moreover, it doesn't work on Python 3.Since properly cleaning this up didn't work, I instead refactor the code, adding plenty of comments to explain what is happening.
This is a pure refactoring: no functionality is changed.
Original ticket description kept for reference:
This code
is trying to determine whether
from_base_ring
comes from the category or not. However, in the case of a lazy attribute it wrongly setshas_custom_conversion = True
without checking equality, even if the lazy attribute comes from the category.Now there are two ways to solve this:
Keep (and document) the current behaviour, namely that the
has_custom_conversion = True
branch is always taken iffrom_base_ring
is a lazy attribute.Fix the bug and set
has_custom_conversion = False
iffrom_base_ring
is a non-custom lazy attribute. Unfortunately, this leads to further breakage:Regardless of this bug, the code to do this check can be improved. The reason why the
__func__
access is needed in the first place is because we are trying to compare an unbound method with a bound method. If we have unbound methods on both sides of the equality, it can be simplified and fixed.CC: @nthiery
Component: categories
Keywords: sagedays@icerm python3
Author: Jeroen Demeyer
Branch/Commit:
003b22a
Reviewer: Travis Scrimshaw, Nicolas M. Thiéry
Issue created by migration from https://trac.sagemath.org/ticket/25181
The text was updated successfully, but these errors were encountered: