Skip to content

Sympy minus infinity doesn't convert to Sage #12345

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

Closed
kcrisman opened this issue Jan 23, 2012 · 12 comments
Closed

Sympy minus infinity doesn't convert to Sage #12345

kcrisman opened this issue Jan 23, 2012 · 12 comments

Comments

@kcrisman
Copy link
Member

sage: a,b = oo, -oo
sage: a._sympy_()
oo
sage: b._sympy_()
--------------------------------------------
AttributeError                            Traceback (most recent call last)

/Users/.../sage-4.7.2/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2840)()

AttributeError: 'MinusInfinity' object has no attribute '_sympy_'

See this ask.sagemath.org question for background.

CC: @certik @rwst

Component: symbolics

Keywords: sd40.5

Author: Douglas McNeil

Branch/Commit: u/akhi/sympy_minus_infinity_doesn_t_convert_to_sage @ 52db42b

Reviewer: Karl-Dieter Crisman

Merged: sage-5.1.beta4

Issue created by migration from https://trac.sagemath.org/ticket/12345

@sagetrac-dsm
Copy link
Mannequin

sagetrac-dsm mannequin commented May 26, 2012

Changed keywords from none to sd40.5

@sagetrac-dsm
Copy link
Mannequin

sagetrac-dsm mannequin commented May 26, 2012

comment:1

Straightforward fix and test of the original case as an integral.

@sagetrac-dsm sagetrac-dsm mannequin added the s: needs review label May 26, 2012
@kcrisman
Copy link
Member Author

comment:2

Umm, even without this patch I get

sage: import sympy
sage: bool(SR(-oo) == -sympy.oo)
True
sage: bool(-oo == -sympy.oo)
True

Am I missing something? How is that an indirect doctest?

That said, the integral works fine now and the tests pass.

@kcrisman
Copy link
Member Author

Reviewer: Karl-Dieter Crisman

@kcrisman
Copy link
Member Author

Author: Douglas McNeil

@sagetrac-dsm
Copy link
Mannequin

sagetrac-dsm mannequin commented May 26, 2012

comment:3

Ah, those were merely mirroring the +oo cases. Really they were only testing whether the negation worked; it was the integral test which was really verifying the success. However, we can test it explicitly by adding.

    sage: bool((-oo)._sympy_() == -sympy.oo)
    True

which fails without the patch. Modified to incorporate this.

@kcrisman
Copy link
Member Author

comment:4

Positive review.

@jdemeyer
Copy link
Contributor

Attachment: trac_12345_minusinfinity_sympyfication.patch.gz

add _sympy_ method to MinusInfinity

@jdemeyer
Copy link
Contributor

Merged: sage-5.1.beta4

@sagetrac-akhi
Copy link
Mannequin

sagetrac-akhi mannequin commented Mar 18, 2015

@kcrisman
Copy link
Member Author

comment:7

I think this ticket is already fixed?

@kcrisman
Copy link
Member Author

Commit: 52db42b

vbraun pushed a commit that referenced this issue Mar 26, 2023
gh-35141: Revise the PR template
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->

### 📚 Description

Made small edits to the PR template, making it concise and tidy overall.

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
Depends on #12345: short description why this is a dependency
Depends on #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35141
Reported by: Kwankyu Lee
Reviewer(s): Kwankyu Lee, Tobias Diez
vbraun pushed a commit that referenced this issue Apr 6, 2023
gh-35355: partial fix for E221 (to be continued)
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

Partial fix for pycodestyle E221, done using autopep8.

E221 multiple spaces before operator

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35355
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
vbraun pushed a commit that referenced this issue Apr 6, 2023
gh-35356: Fix documentation deployment
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

The update #35184 broke the docs
upload. Hopefully this is fixed with this PR.

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35356
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik, Kwankyu Lee
vbraun pushed a commit that referenced this issue Apr 6, 2023
gh-35366: Many more namespace packages – follow up
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

<!-- Describe your changes here in detail. -->
Follow-up from #35322.
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35366
Reported by: Matthias Köppe
Reviewer(s): Gonzalo Tornaría
vbraun pushed a commit that referenced this issue Apr 6, 2023
gh-35372: Replace more `.all` imports
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

This is a follow-up on:
- #35110

As preparation for #35322, which is changing more packages to implicit
namespace packages, we remove `.all` imports from these packages
throughout the Sage library.

This is part of:
- #29705

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->
- Depends on #35418
- Depends on #35358
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35372
Reported by: Matthias Köppe
Reviewer(s): Gonzalo Tornaría
vbraun pushed a commit that referenced this issue Apr 6, 2023
gh-35377: build/pkgs/openblas/spkg-configure.m4: Reject version 0.3.22
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description
openblas 0.3.22 is broken, see:
- #35371
- scipy/scipy#18208
- OpenMathLib/OpenBLAS#3976

We reject it.

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35377
Reported by: Matthias Köppe
Reviewer(s): John H. Palmieri
vbraun pushed a commit to vbraun/sage that referenced this issue May 28, 2025
sagemathgh-40152: Use platformdirs to improve database path handling
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Improve the handling of the data directories by always including the
system data dirs, in addition to `SAGE_SHARE` (and it's variations).
Also move the `sage_data_paths` method to `sage.env` so that it can be
reused more easily.

Should fix sagemath#40144.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40152
Reported by: Tobias Diez
Reviewer(s): Antonio Rojas, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 28, 2025
sagemathgh-40155: Add check for Arch Linux in configure to recommend meson build
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Add a check if the configure is run on Arch Linux. If yes, then
recommend to use Meson instead since there is little need for configure
+ make on Arch and the Meson build works nicely there.
This check can be disabled by passing `--disable-meson-check`.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40155
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 28, 2025
sagemathgh-40157: Add back ubuntu-noble-standard to ci-linux
    
Fixes sagemath#40120 — I believe.

As explained there, the root cause is that `ci-linux.yml` no longer
build from scratch on `ubuntu-noble-standard` to generate the base
docker image for the incremental builds to base on.

In any case this appears to be harmless enough.

From some
[testing](https://github.com/user202729/sage/actions/workflows/ci-
linux.yml) this works _some_ of the time (the debug statements are
harmless)… which is not great, but the **current** `standard` runs
aren't completely reliable either.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40157
Reported by: user202729
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 28, 2025
sagemathgh-40162: Add documentation for packaging SageMath downstream
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Using meson. Should hopefully make it easier for downstream maintainers
to get started, so that we might get sage back in Fedora/Ubuntu/...

I don't have any packaging experience myself, so please make
suggestions!

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40162
Reported by: Tobias Diez
Reviewer(s): Antonio Rojas, Copilot, Dima Pasechnik, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-39726: Optimize AdditiveMonoids sum() method
    
Previously the example shown takes way too long. Now it takes 0.5s.

It is probably possible to optimize further by specialize it using
Singular.

Opinion: how should the iterator multiplication be implemented

* as is (disadvantage: slightly misleading method name),
* copy paste the code logic of `iterator_prod` and make a new method
`iterator_sum` (disadvantage: code duplication),
* make an internal method `_iterator_combine` that takes `bint
multiply`, then make `iterator_prod` and `iterator_sum` call it
(disadvantage: potential slower branching each operation, but should be
negligible)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39726
Reported by: user202729
Reviewer(s): Travis Scrimshaw, user202729
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-39742: Support inverse_mod() single element for multi_polynomial_ring
    
For consistency with other rings.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39742
Reported by: user202729
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-39918: add add_entry and anti_restrict methods to SkewTableau
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

`add_entry` and `anti_restrict` are already existing methods in
`Tableau`, but they also make sense for `SkewTableau`.
This PR ports these methods to `SkewTableau`, and adds a simple check to
`add_entry` to avoid trying to construct a new tableau when the given
cell is too large.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies
None
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39918
Reported by: Joe McDonough
Reviewer(s): Copilot, Joe McDonough, trevorkarn
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-39993: Update conda lock files
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Update lock file. On macos there is a new warning due to duplicate
rpaths, which is ignored by using code from
sagemath#36337.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39993
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40019: Hash fraction_field_elements more appropriately
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Equip various domains with a `canoncial_associate`, which finds unique
representatives in some rings modulo the action of the unit group. For
fields this is easy: there are only two orbits: 0 and the units (where 1
is a representative) and in ZZ we can just use "abs". For polynomial
rings we can extend representatives by normalizing the leading
coefficient to a canonical associate.

The normalization is important to find unique representatives of
fraction field elements (because multplying both numerator and
denominator by a unit doesn't change the represented class), which is
necessary for hashing them. The library uses hashes of fraction field
elements quite a bit, but luckily only in cases where we can actually
normalize denominators (in fact, "reduce" always seems to fail for such
rings, so the hash would already error out)

Fixes sagemath#35238

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#40019
Reported by: nbruin
Reviewer(s): Martin Rubey
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40020: Fixed infinite recursion in trig functions
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Fixes sagemath#35696

When the trig functions sin, cos, tan, csc, sec, or cot are provided
with a symbolic input which expands to 0 they would suffer an infinite
recursion error.

This occurred because of a bug in the corresponding sin_eval, cos_eval,
tan_eval, csc_eval, sec_eval, and cot_eval functions defined in
src/sage/symbolic/ginac/inifcns_trig.cpp. These functions perform a
simplification when the real part of the expanded input is 0. This
simplification led to infinite recursion when the expanded input was
exactly equal to 0.

A check has been added to each of these 6 functions which ensures
correct behaviour when the input expands to 0.
Tests have been added to src/sage/functions/trig.py to cover these
changes.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [X] The title is concise and informative.
- [X] The description explains in detail what this PR is about.
- [X] I have linked a relevant issue or discussion.
- [X] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40020
Reported by: Caleb Van't Land
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40074: Fixed error when calling CRT_list() with list of 1 python int
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Fixes Issue sagemath#40067, refer to [this
answer](https://ask.sagemath.org/question/82674/error-when-calling-crt-
with-list-of-1-python-int/?answer=82706#post-id-82706).

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40074
Reported by: shpark1104
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40080: cleanup in number_field.py
    
small pep8 cleanup, some typing annotation

alos getting rid of the old `_cache_an_element` attribute

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40080
Reported by: Frédéric Chapoton
Reviewer(s): Edgar Costa
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40093: Jacobi theta functions implemented as lazy series
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

An important special function $\vartheta_{ab}(z; \tau)$, which can be
considered as a (formal) power series in terms of the nome $q = e^{\pi i
\tau}$ with coefficient parameter $w = e^{\pi i z}$.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40093
Reported by: Travis Scrimshaw
Reviewer(s): Martin Rubey
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40094: msolve tarball got ./configure - sha*s are changed
    
As reported by @mezzarobba on
sagemath#39738 (comment)

Upstream was quick to update the tarball



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40094
Reported by: Dima Pasechnik
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40107: Add retry mechanism for Conda environment setup in CI workflow
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Sometimes the conda setup fails due to network issues (e.g. https://gith
ub.com/sagemath/sage/actions/runs/15036287079/job/42258557067?pr=38872#s
tep:9:7341). There is no easy way to configure conda to just retry this
request again in a few seconds, so we just simply retry the whole conda
env setup.

### :memo: Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### :hourglass: Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40107
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40114: add weighted cycle enumeration in digraph
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Add feature of enumerating weighted cycle in digraph. Specifically, I
added several arguments related to weight in
_all_cycles_iterator_vertex, all_cycles_iterator, all_simple_cycles
functions.

_all_cycles_iterator_vertex function enumerates cycles whose starting
point is specifed in increasing weight order by using PriorityQueue
instread of normal queue. By using this, all_cycls_iterator can
enumerate cycles in increasing weight order.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40114
Reported by: Yuta Inoue
Reviewer(s): David Coudert, Yuta Inoue
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40116: try to fix build on some arm64 macOS systems
    
as reported on
sagemath#40106

~Proposed~ Merged upstream as https://github.com/gap-
system/gap/pull/5992

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40116
Reported by: Dima Pasechnik
Reviewer(s): John H. Palmieri
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40124: Update Meson and Conda install instructions 
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Make the Meson build instructions independent from the Conda and sage-
the-distro instructions (previously it was linking to the relevant
section for the basic setup).
Also includes now how to use `uv` to setup a python env.

The conda instructions have been also updated, based on the work in
sagemath#39515.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40124
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40125: Fix superscript for 2^{32} in prime_pi.pyx
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

![image](https://github.com/user-
attachments/assets/755ba22f-bfaf-4d75-82b1-00c0c10d32c2)


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40125
Reported by: Aleksei Latyshev
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40126: Simplify QuiverRep_generic.linear_combination_of_basis method
    
Shorten the code.

This might become faster after
sagemath#39726 (or might not, I haven't
benchmarked)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40126
Reported by: user202729
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40132: update m4ri to gcc-15-supporting version
    
this in particular corrects m4ri's pkg-config file, which is not working
for gcc-15, see e.g. BRiAl/BRiAl#58 and the
sage-develop posts

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40132
Reported by: Dima Pasechnik
Reviewer(s): Chris Wuthrich
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40138: update primecount(py) to the latest versions
    
fixed primecountpy to work with new cython, and upgrade primecount along
the way


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40138
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40145: add simple cycle enumeration by k shortest simple path algorithm
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Add another algorithm of enumearting simple cycles in digraph, which is
based on k shortest simple path algorithm.

For each edge e=uv, delete e from the original graph and enumerate vu
simple path in increasing length order by k shortest simple path
algorithm to obtain simple cycles that contain e in increasing length
order.

Using iterators for each edge e and priority queue makes it possible to
enumerate simple cycles in increasing length order.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

sagemath#40114
    
URL: sagemath#40145
Reported by: Yuta Inoue
Reviewer(s): David Coudert, Yuta Inoue
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40149: Revision of the Khovanov polynomial
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

In sagemath#33965 and sagemath#33969, I introduced two methods named
`khovanov_polynomial`, one for the `Link` class and the other for
`KnotInfo`. Unfortunately, I misused the ring argument in both. IIRC,
the analogy to the other polynomial link invariants led me to use the
`base_ring` argument to specify the base ring of the polynomial.
However, this was not a good idea, since the Khovanov polynomial, as a
Poincaré polynomial of homology, always has integer coefficients. On the
other hand, a ring argument is needed to specify the underlying
homology.

This will be corrected in this PR. In particular, I will deprecate the
existing `base_ring` argument and introduce a new `ring` argument, which
corresponds to the `ring` argument of the `khovanov_homology` method of
the `Link` class. I take the occasion to remove the deprecation warning
for the argument `KhoHo` released in March 2024.

Furthermore, I introduce a new argument `torsion` to display the torsion
parts of the integral homology according to the [KnotInfo convention](ht
tps://knotinfo.math.indiana.edu/descriptions/khovanov_odd_integral_polyn
omial.html).


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40149
Reported by: Sebastian Oehms
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40152: Use platformdirs to improve database path handling
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Improve the handling of the data directories by always including the
system data dirs, in addition to `SAGE_SHARE` (and it's variations).
Also move the `sage_data_paths` method to `sage.env` so that it can be
reused more easily.

Should fix sagemath#40144.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40152
Reported by: Tobias Diez
Reviewer(s): Antonio Rojas, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40155: Add check for Arch Linux in configure to recommend meson build
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Add a check if the configure is run on Arch Linux. If yes, then
recommend to use Meson instead since there is little need for configure
+ make on Arch and the Meson build works nicely there.
This check can be disabled by passing `--disable-meson-check`.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40155
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40157: Add back ubuntu-noble-standard to ci-linux
    
Fixes sagemath#40120 — I believe.

As explained there, the root cause is that `ci-linux.yml` no longer
build from scratch on `ubuntu-noble-standard` to generate the base
docker image for the incremental builds to base on.

In any case this appears to be harmless enough.

From some
[testing](https://github.com/user202729/sage/actions/workflows/ci-
linux.yml) this works _some_ of the time (the debug statements are
harmless)… which is not great, but the **current** `standard` runs
aren't completely reliable either.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40157
Reported by: user202729
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40162: Add documentation for packaging SageMath downstream
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Using meson. Should hopefully make it easier for downstream maintainers
to get started, so that we might get sage back in Fedora/Ubuntu/...

I don't have any packaging experience myself, so please make
suggestions!

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40162
Reported by: Tobias Diez
Reviewer(s): Antonio Rojas, Copilot, Dima Pasechnik, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
sagemathgh-40173: Trac sagemath#40127: Pass factor_on_left in linear_combination
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Fixes [sagemath#40127](sagemath#40127).

Passes `factor_on_left` correctly to `iaxpy()` in `linear_combination`.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40173
Reported by: Aolong Li
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue May 29, 2025
…matrix-vector multiplication over GF(2)

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Fixes [sagemath#40167](sagemath#40167). This PR
fixes a bug in `Matrix_mod2_dense._matrix_times_vector_` revealed in
[sagemath#40167](sagemath#40167), where the
parent of the resulting vector was incorrectly reused from the input
vector.

The regression was introduced in [PR
sagemath#37375](sagemath#37375), which added an
optimization to speed up matrix-vector multiplication when the matrix is
square and matches the vector dimension. However, it failed to account
for edge cases where the input vector's parent is not the full ambient
vector space—for example, when working with subspaces. In this case, we
can no longer assume that the ambient space is the vector's ambient
space.

In such cases, reusing the parent leads to incorrect coercion or a
result vector with an invalid parent space. This patch introduces an
explicit check: if the vector's parent is the full space `GF(2)^n`, it
is reused; otherwise, a default parent is constructed to ensure
correctness.

### Example (correct behavior restored)

```python
sage: M = Matrix(GF(2), [[1, 1], [0, 1]])
sage: v = vector(GF(2), [0, 1])
sage: V = span([v])             # one-dimensional subspace of GF(2)^2
sage: image_basis = [M * b for b in V.basis()]
sage: image = span(image_basis)
sage: image.basis() == [(1, 1)]
True # now returns True
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

URL: sagemath#40176
Reported by: Aolong Li
Reviewer(s): Travis Scrimshaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants