Skip to content

src/sage/structure/sequence.py: skip fewer cases when pbori is missing#41539

Merged
vbraun merged 1 commit intosagemath:developfrom
orlitzky:fix-polynomial-sequence
Mar 22, 2026
Merged

src/sage/structure/sequence.py: skip fewer cases when pbori is missing#41539
vbraun merged 1 commit intosagemath:developfrom
orlitzky:fix-polynomial-sequence

Conversation

@orlitzky
Copy link
Copy Markdown
Contributor

When the (optional) sage.rings.polynomial.pbori.pbori fails to import, one of the cases in the Sequence() constructor is skipped, leading to certain polynomial sequences being returned as generic sequences instead of polynomial ones. In one egregious case, this causes a multivariate polynomial sequence with 324 elements to be printed to the screen rather than the short description that is intended:

File "...multi_polynomial_libsingular.pyx", line 4790...
Failed example:
    f.lift(I)
Expected:
    Polynomial Sequence with 324 Polynomials in 2 Variables
Got:
    [0,
     0,
     0,
     0,
     0, ...

We fix this by handling the (failure of the) pbori import separately, keeping the rest of the special case for polynomial sequences.

@orlitzky
Copy link
Copy Markdown
Contributor Author

Can be reproduced/tested by passing -Dbrial=disabled to meson setup.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 27, 2026

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

@orlitzky orlitzky force-pushed the fix-polynomial-sequence branch 2 times, most recently from 63c0156 to d381c76 Compare February 20, 2026 13:08
When the (optional) sage.rings.polynomial.pbori.pbori fails to import,
one of the cases in the Sequence() constructor is skipped, leading to
certain polynomial sequences being returned as generic sequences
instead of polynomial ones. In one egregious case, this causes a
multivariate polynomial sequence with 324 elements to be printed to
the screen rather than the short description that is intended:

  File "...multi_polynomial_libsingular.pyx", line 4790...
  Failed example:
      f.lift(I)
  Expected:
      Polynomial Sequence with 324 Polynomials in 2 Variables
  Got:
      [0,
       0,
       0,
       0,
       0, ...

We fix this by handling the (failure of the) pbori import separately,
keeping the rest of the special case for polynomial sequences.
@orlitzky orlitzky force-pushed the fix-polynomial-sequence branch from d381c76 to 7615d58 Compare March 2, 2026 16:47
@orlitzky orlitzky requested a review from kiwifb March 2, 2026 16:56
@orlitzky
Copy link
Copy Markdown
Contributor Author

orlitzky commented Mar 2, 2026

@kiwifb can I borrow you for a second as the de-facto brial person?

This diff is confusing, but all it does is move something important out of the try ... except ImportError block for brial.

@kiwifb
Copy link
Copy Markdown
Member

kiwifb commented Mar 2, 2026

Yes, it seems keeping the try block minimal and not throwing the stuff you would need anyway looks much cleaner. But the other bits are interesting. You get rid of the else alternative and you alias the method you can't import to a generic one.
I'd say that else part was probably badly broken and giving funny behavior.

Copy link
Copy Markdown
Member

@kiwifb kiwifb left a comment

Choose a reason for hiding this comment

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

LGTM

@orlitzky
Copy link
Copy Markdown
Contributor Author

orlitzky commented Mar 3, 2026

But the other bits are interesting. You get rid of the else alternative and you alias the method you can't import to a generic one.

This was a trick to keep the existing conditional working without having to add cases. By setting BooleanMonomialMonoid = MPolynomialRing_base when the import fails, the subsequent isinstance() reduces to a check for one type (BooleanMonomialMonoid == MPolynomialRing_base). Without that we would have needed a special case (copy & paste of the "if" statement) to avoid checking for an instance of None.

The name BooleanMonomialMonoid is local and undefined when we set it (for only a few lines), so it shouldn't impact anything else. Thanks for taking a look.

vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 6, 2026
sagemathgh-41539: src/sage/structure/sequence.py: skip fewer cases when pbori is missing
    
When the (optional) `sage.rings.polynomial.pbori.pbori` fails to import,
one of the cases in the `Sequence()` constructor is skipped, leading to
certain polynomial sequences being returned as generic sequences instead
of polynomial ones. In one egregious case, this causes a multivariate
polynomial sequence with 324 elements to be printed to the screen rather
than the short description that is intended:

```
File "...multi_polynomial_libsingular.pyx", line 4790...
Failed example:
    f.lift(I)
Expected:
    Polynomial Sequence with 324 Polynomials in 2 Variables
Got:
    [0,
     0,
     0,
     0,
     0, ...
```

We fix this by handling the (failure of the) pbori import separately,
keeping the rest of the special case for polynomial sequences.
    
URL: sagemath#41539
Reported by: Michael Orlitzky
Reviewer(s): François Bissey
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 15, 2026
sagemathgh-41539: src/sage/structure/sequence.py: skip fewer cases when pbori is missing
    
When the (optional) `sage.rings.polynomial.pbori.pbori` fails to import,
one of the cases in the `Sequence()` constructor is skipped, leading to
certain polynomial sequences being returned as generic sequences instead
of polynomial ones. In one egregious case, this causes a multivariate
polynomial sequence with 324 elements to be printed to the screen rather
than the short description that is intended:

```
File "...multi_polynomial_libsingular.pyx", line 4790...
Failed example:
    f.lift(I)
Expected:
    Polynomial Sequence with 324 Polynomials in 2 Variables
Got:
    [0,
     0,
     0,
     0,
     0, ...
```

We fix this by handling the (failure of the) pbori import separately,
keeping the rest of the special case for polynomial sequences.
    
URL: sagemath#41539
Reported by: Michael Orlitzky
Reviewer(s): François Bissey
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 18, 2026
sagemathgh-41539: src/sage/structure/sequence.py: skip fewer cases when pbori is missing
    
When the (optional) `sage.rings.polynomial.pbori.pbori` fails to import,
one of the cases in the `Sequence()` constructor is skipped, leading to
certain polynomial sequences being returned as generic sequences instead
of polynomial ones. In one egregious case, this causes a multivariate
polynomial sequence with 324 elements to be printed to the screen rather
than the short description that is intended:

```
File "...multi_polynomial_libsingular.pyx", line 4790...
Failed example:
    f.lift(I)
Expected:
    Polynomial Sequence with 324 Polynomials in 2 Variables
Got:
    [0,
     0,
     0,
     0,
     0, ...
```

We fix this by handling the (failure of the) pbori import separately,
keeping the rest of the special case for polynomial sequences.
    
URL: sagemath#41539
Reported by: Michael Orlitzky
Reviewer(s): François Bissey
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 21, 2026
sagemathgh-41539: src/sage/structure/sequence.py: skip fewer cases when pbori is missing
    
When the (optional) `sage.rings.polynomial.pbori.pbori` fails to import,
one of the cases in the `Sequence()` constructor is skipped, leading to
certain polynomial sequences being returned as generic sequences instead
of polynomial ones. In one egregious case, this causes a multivariate
polynomial sequence with 324 elements to be printed to the screen rather
than the short description that is intended:

```
File "...multi_polynomial_libsingular.pyx", line 4790...
Failed example:
    f.lift(I)
Expected:
    Polynomial Sequence with 324 Polynomials in 2 Variables
Got:
    [0,
     0,
     0,
     0,
     0, ...
```

We fix this by handling the (failure of the) pbori import separately,
keeping the rest of the special case for polynomial sequences.
    
URL: sagemath#41539
Reported by: Michael Orlitzky
Reviewer(s): François Bissey
@vbraun vbraun merged commit d5b421c into sagemath:develop Mar 22, 2026
20 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants