SparseArrays.jl
SparseArrays.jl copied to clipboard
Resize buffers in `sparse!` to satisfy buffer checks in constructor
With this patch the output buffers to sparse! are resized in order to satisfy the buffer length checks in the SparseMatrixCSC constructor that were introduced in JuliaLang/julia#40523. Previously csccolptr was never resized, and cscrowval and cscnzval were only resized if the buffers were too short (i.e. never truncated).
The requirement length(csccolptr) >= n + 1 could be kept, but seems unnecessary since all buffers need to be resized anyway (to pass the constructor checks).
In particular this fixes calling sparse! with I, J, V as both input and output buffers: sparse!(I, J, V, m, n, ..., I, J, V).
Fixes #313.
Codecov Report
Merging #314 (40e989c) into main (57cbb74) will increase coverage by
0.05%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #314 +/- ##
==========================================
+ Coverage 93.62% 93.68% +0.05%
==========================================
Files 12 12
Lines 7390 7391 +1
==========================================
+ Hits 6919 6924 +5
+ Misses 471 467 -4
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/sparsematrix.jl | 95.56% <100.00%> (+0.16%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
The backport to 1.8 failed:
The process '/usr/bin/git' failed with exit code 128
To backport manually, run these commands in your terminal:
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.8 1.8
# Navigate to the new working tree
cd .worktrees/backport-1.8
# Create a new branch
git switch --create backport-314-to-1.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 85a381b2ea0f5e8a1553b51bc75a83dfc0445e36
# Push it to GitHub
git push --set-upstream origin backport-314-to-1.8
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.8
Then, create a pull request where the base branch is 1.8 and the compare/head branch is backport-314-to-1.8.
The backport to 1.9 failed:
The process '/usr/bin/git' failed with exit code 128
To backport manually, run these commands in your terminal:
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.9 1.9
# Navigate to the new working tree
cd .worktrees/backport-1.9
# Create a new branch
git switch --create backport-314-to-1.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 85a381b2ea0f5e8a1553b51bc75a83dfc0445e36
# Push it to GitHub
git push --set-upstream origin backport-314-to-1.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.9
Then, create a pull request where the base branch is 1.9 and the compare/head branch is backport-314-to-1.9.