Repository navigation
Promote the index type over all sparse arguments in mixed sparse and dense cat - #1127
Open
ViralBShah wants to merge 1 commit into
Open
ViralBShah wants to merge 1 commit into
ViralBShah wants to merge 1 commit into
Conversation
…dense `cat` A mixed sparse/dense `hcat`, `vcat` or `cat` took the index type of its first argument, so `vcat(A32, A64, ones(1, n))` threw when the result did not fit in `Int32`, while `vcat(A64, A32, ones(1, n))` worked. The index type is now promoted over every sparse argument; a dense argument other than the first still does not widen it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1127 +/- ##
=======================================
Coverage 94.72% 94.72%
=======================================
Files 16 16
Lines 10310 10319 +9
=======================================
+ Hits 9766 9775 +9
Misses 544 544 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A sparse/dense
hcat,vcatorcatwith a matrix result took its index type from the first argument, so the same blocks in another order could throw. The all-sparse methods already promote over every argument.Before
After
_sparse_cat_t_shaped, whichhcat,vcat,catandsparse_hcat/sparse_vcatshare, chose the index type from the arguments after_makesparse. By then a dense array is anInt-indexed sparse matrix, so only the first argument was used. The callers now pass the original arguments, and_sparse_cat_t_shapedconverts them itself. The index type keeps its old value, from the first argument orIntfor a leading number, and is now promoted with the index type of every argument that is sparse (issparse). A dense argument after the first still adds nothing, sovcat(A32, ones(1, n))staysInt32. The index type is still worked out from types alone, so the result type is still inferred.Potential breakage: some calls that worked before now return a wider index type. One case is
vcat(A8, A32, D), which gaveInt8and now givesInt32, asvcat(A8, A32)already does. Another ishcat(A32, I), which gaveInt32and now givesInt64. LinearAlgebra turnsIinto anInt-indexed sparse matrix before the call, andhcat(I, A32)andhvcatalready gaveInt64.Left out:
hvcatwith dense blocks already promotes over all blocks, and it counts a dense block asInt. That behaviour is unchanged. A concatenation whose result is a vector still takes its index type from the first argument, through_catdest.🤖 Generated with Claude Code