Skip to content
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

be more specific when raising "not a constant polynomial" #37747

Merged

Conversation

mantepse
Copy link
Collaborator

@mantepse mantepse commented Apr 4, 2024

Currently, if retracting a polynomial to its base ring fails, the error message is TypeError: not a constant polynomial.

In some circumstances, this is not very helpful, because it may be hard to find out where the nonconstant polynomial comes from. In particular, this happens when the lazy implicit equations solver (#37033) fails.

Therefore, it seems sensible to add the offending polynomial.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 4, 2024

doctest failure because one more test needs updating in: src/doc/en/thematic_tutorials/coercion_and_categories

Copy link
Contributor

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mantepse
Copy link
Collaborator Author

mantepse commented Apr 5, 2024

Thank you!

@tscrim
Copy link
Collaborator

tscrim commented Apr 5, 2024

Bit of bikeshedding, but I think f is not a constant polynomial would be better in terms of English. Not a big deal if you don't want to change it.

@mantepse
Copy link
Collaborator Author

mantepse commented Apr 5, 2024

Bit of bikeshedding, but I think f is not a constant polynomial would be better in terms of English. Not a big deal if you don't want to change it.

I actually put the polynomial last on purpose: it may be a long string. I thought that in this case the error message will likely be easier to read if the polynomial comes last, because any linebreak will break the polynomial and not the not a constant polynomial.

@tscrim
Copy link
Collaborator

tscrim commented Apr 5, 2024

I would argue the error message at the end is easier to read since it won’t be buried in a long string output (which further has the traceback above it). The double colon use in the full output is also a bit weird to me. Well, as I said, not a big deal, just wanted to mention it.

@mantepse
Copy link
Collaborator Author

mantepse commented Apr 5, 2024

OK

@mantepse
Copy link
Collaborator Author

mantepse commented Apr 5, 2024

I included another unspecific error message in the same spirit.

Copy link

github-actions bot commented Apr 5, 2024

Documentation preview for this PR (built with commit 1430492; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 6, 2024

Should we be concerned about performance implications if this ends up being called within the coercion framework on polynomials with many terms?

@tscrim
Copy link
Collaborator

tscrim commented Apr 6, 2024

I don’t think we need to, but it wouldn’t hurt to make it a lazy string.

@mantepse
Copy link
Collaborator Author

mantepse commented Apr 6, 2024

I am willign to do this, but on the condition of showing an example (even if artificial) where the performance degrades. (I would then turn that example as a doctest.)

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 12, 2024

I don't have such tests at hand, so let's just merge it.

@vbraun
Copy link
Member

vbraun commented Apr 16, 2024

fails as in the CI

vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 20, 2024
…omial"

    
Currently, if retracting a polynomial to its base ring fails, the error
message is `TypeError: not a constant polynomial`.

In some circumstances, this is not very helpful, because it may be hard
to find out where the nonconstant polynomial comes from.  In particular,
this happens when the lazy implicit equations solver (sagemath#37033) fails.

Therefore, it seems sensible to add the offending polynomial.
    
URL: sagemath#37747
Reported by: Martin Rubey
Reviewer(s): Matthias Köppe
@vbraun vbraun merged commit bea03c7 into sagemath:develop Apr 27, 2024
17 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone Apr 27, 2024
@mantepse mantepse deleted the rings/polynomial_element_not_constant branch May 8, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants