-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
Fix coercion problem with Algebraic Real Field #36942
Conversation
This commit changes the _algebraic_ function of Expression class to simplify the expression with simplify_full() function before converting it to algebraic number.
Added the doctest for _element_constructor_() function of AlgebraicField class.
@mkoeppe, can you please review this PR? The PR is encountering test failures, but I believe the revised answer aligns closely with the expected one. So should I make adjustments to the tests? |
@videlec @zimmermann6 @nbruin @mezzarobba cc-ing some people who might be interested. |
I do not think it is a good idea to systematically sage: %time AA(sum(QQbar(i).sqrt() for i in range(20)))
CPU times: user 35.5 ms, sys: 2.95 ms, total: 38.5 ms
Wall time: 47.1 ms
57.19384185642023? |
This is my output sage: %time AA(sum(QQbar(i).sqrt() for i in range(20)))
CPU times: user 3.55 ms, sys: 0 ns, total: 3.55 ms
Wall time: 3.55 ms
57.19384185642023? I didn't understand what you were thinking. Can you please clarify? |
You should give timings before your change and with your change to look at possible speed regressions. Also, I would use |
I suspect you're going to be better off going via
|
So should I go with |
I would first explore |
Did you find anything, @nbruin, or should I proceed with QQbar and then address any errors that may arise as a result? Alternatively, should I stick with simplify_full() for now, prioritizing correctness over speed? It's better to provide a correct answer than to deliver an incorrect one quickly. |
Documentation preview for this PR (built with commit 108470b; changes) is ready! 🎉 |
That is a fallacy. You could cause code to be so slow that it is rendered unusable. In the case at hand, it doesn't "know" (in general) that the result lies in Also @nbruin's suggestion was for you to do the exploration. That being said, looking at
The quick solution is likely to go through |
I think this PR is merged by mistake (Because there was no positive review on this PR), and one problem is that I didn't fixed the answers of some doctests which were failing (because I was exploring QQbar solutions), so some doctests are failing, now. like below sage: elems = [sqrt(5), 2^(1/3)+sqrt(3)*I, 3/4]
....: nf, nums, hom = number_field_elements_from_algebraics(elems,
....: embedded=True)
sage: list(map(hom, nums)) == list(map(QQbar, nums))
True
sage: list(map(hom, nums)) == elems
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
...
NotImplementedError: cannot find radical expression Above example was working fine before these changes but now it is giving the error. And while exploring QQbar solutions, I observed that using QQbar instead of simplify_full may produce some problems as @nbruin said, if we are doing this conversion then we will face many side-effects and to fix them we have to check all functions which are related to QQbar and AA. So what should I do, now ? Should I make a new PR/issue to fix these doctests or should I revert these changes? |
@vbraun This was indeed incorrectly merged into the develop branch. I don't recall anyone approving this either. Please revert the merge. Perhaps there is an issue with the merge scripts? |
I didn't merge this PR, but this PR branch was entirely contained in #37038. The latter had positive review and was merged.
There is nothing wrong with this PR, its still open. The merged note will just remind you that currently there is no new code here (i.e. merging would not add new code) |
@vbraun I see, thanks for the diagnosis and explanation. Do you think you could squash away all of those intermediate commits from the main branch? I don't think it is a good idea to have some WIP that was reverted because it was meant for an independent ticket. I can figure out the precise commits if that would be helpful. @RuchitJagodara Please make sure your branches are properly independent (and only have correct dependencies and common history). |
The commit history is immutable, once its released its done. Don't worry, sometimes the commit history is messy. But that is not a problem, git has all the tools necessary to deal with it. Really squashing can only be done before code is released, and by the author and not by the release manager. |
Okay, thank you for the explanation. I am slightly worried about if someone is doing a @RuchitJagodara You will need to fix the commits here by copying them to a new branch and force pushing it to this branch on git. |
I will take care of that and apologize for my mistake.
I tried to force push the branch but it is giving me the following error
|
This PR is based on the develop branch in your own account https://github.com/RuchitJagodara/sage.git, you have to push there. |
I have pushed my changes there but it is not reflecting here. |
This PR might just be fully corrupted and we should close it and have @RuchitJagodara open a new one based on a branch that is not |
This patch fixes #12745. With this commit, the coerce
issue of Algebraic Real Field is fixed. Now it is giving correct answer for below cases
📝 Checklist
⌛ Dependencies
None