Skip to content

Conversation

S17A05
Copy link
Member

@S17A05 S17A05 commented Apr 22, 2024

When iterating over a pbori.BooleanPolynomial, the iterator generates just the monomials, whereas iterating over a MPolynomial_libsingular defined over GF(2) yields a tuple of the monomial together with its coefficient $1$. This causes issues in the method .coefficients_monomials() of PolynomialSequence_gf2; we fix said issue by checking whether the iteration yields tuples, in which case we simply replace the tuple by its second element (the actual monomial) in each iteration. which type of polynomial ring we are working in before iterating.

Fixes #37837 (but there might be a more elegant solution).

Copy link

github-actions bot commented Apr 22, 2024

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

Copy link
Contributor

@mantepse mantepse left a comment

Choose a reason for hiding this comment

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

Thank you!

@mantepse
Copy link
Contributor

In case you are interested in the boolean polynomial ring, maybe you want to resurrect #26929.

vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 28, 2024
sagemathgh-37853: Work around inconsistent iteration in `multi_polynomial_sequence.py`
    
When iterating over a `pbori.BooleanPolynomial`, the iterator generates
just the monomials, whereas iterating over a `MPolynomial_libsingular`
defined over `GF(2)` yields a tuple of the monomial together with its
coefficient $1$. This causes issues in the method
`.coefficients_monomials()` of `PolynomialSequence_gf2`; we fix said
issue by checking ~~whether the iteration yields tuples, in which case
we simply replace the tuple by its second element (the actual monomial)
in each iteration.~~ which type of polynomial ring we are working in
before iterating.

Fixes sagemath#37837 (but there might be a more elegant solution).
    
URL: sagemath#37853
Reported by: Sebastian A. Spindler
Reviewer(s): Martin Rubey, Sebastian A. Spindler
@vbraun vbraun merged commit 9ce51d0 into sagemath:develop May 2, 2024
@S17A05 S17A05 deleted the multipoly_seq_fix branch May 3, 2024 17:06
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.

PolynomialSequence_gf2.coefficients_monomials is broken
4 participants