Skip to content

Make issparse return false for an array whose parent is not an array - #1192

Merged
ViralBShah merged 1 commit into
mainfrom
an/issparse-fallback
Nov 22, 2026
Merged

ViralBShah merged 1 commit into
mainfrom
an/issparse-fallback

Conversation

@andreasnoack

Copy link
Copy Markdown
Member

Fixes #1191.

Before

julia> using SparseArrays

julia> struct KeysVector <: AbstractVector{String}
           parent::Dict{String,Int}
       end

julia> Base.size(k::KeysVector) = (length(k.parent),)

julia> Base.getindex(k::KeysVector, i::Int) = sort!(collect(keys(k.parent)))[i]

julia> Base.parent(k::KeysVector) = k.parent

julia> k = KeysVector(Dict("a" => 1, "b" => 2));

julia> [k; k]
ERROR: MethodError: no method matching issparse(::Dict{String, Int64})

After

julia> [k; k]
4-element Vector{String}:
 "a"
 "b"
 "a"
 "b"

issparse(::AbstractArray) recurses on parent(A), which need not be an array. Since #890 the vcat, hcat and hvcat of any AbstractVecOrMat call issparse, so concatenating such arrays threw as soon as SparseArrays was loaded. The recursion now stops with false when the parent is not an array. The issue suggested a catch-all issparse(::Any) = false; that is left out, so issparse of a non-array still throws.

This should be backported to 1.14: the error breaks DataFrames.jl on 1.14.0-beta1, where keys(::GroupedDataFrame) is an AbstractVector whose parent is the GroupedDataFrame. With this branch on nightly, the failing DataFrames expression [keys(groupby(df, [:a, :b])); keys(groupby(df, :a))] returns a Vector of the four keys.

This pull request was written by generative AI (Claude Code).

ViralBShah added a commit that referenced this pull request Nov 22, 2026
Julia's CI stopped building 32-bit Windows on Nov 18 (JuliaCI/julia-buildkite#797, following the [Discourse announcement](https://discourse.julialang.org/t/phasing-out-julia-support-for-32-bit-windows/137912) that 1.13 is the last release with 32-bit Windows binaries). The last win32 nightly is `julia-publish` build 11438, for `dffa1584150`.

**Before**

`julia-latest-win32.zip` was last modified on Nov 18, while the other nightlies are current:

```
winnt/x86/julia-latest-win32.zip        last-modified: Wed, 18 Nov 2026 09:16:40 GMT
winnt/x64/julia-latest-win64.zip        last-modified: Sun, 22 Nov 2026 12:29:29 GMT
linux/x86/julia-latest-linux32.tar.gz   last-modified: Sun, 22 Nov 2026 12:19:36 GMT
```

So `test (windows-latest, x86, nightly)` runs 1.15.0-DEV.831 while every other job runs DEV.904. It passes on #1192 without seeing the LinearAlgebra bumps that fail the other jobs, and on #1186 SparseArrays fails to precompile:

```
Julia Version 1.15.0-DEV.831
  Commit dffa158415 (2026-11-18 07:58 UTC)
ERROR: LoadError: UndefVarError: `_aliasparts` not defined in `LinearAlgebra`
```

**After**

There is no Windows x86 job. The matrix lists all four runners under `os` with `julia-arch: default`, which `setup-julia` resolves to the runner's own architecture, and 32-bit Linux is the one `include` that sets an architecture:

```
test (ubuntu-latest, default, nightly)      coverage
test (windows-latest, default, nightly)
test (macOS-latest, default, nightly)       check-bounds=yes
test (ubuntu-26.04-arm, default, nightly)
test (ubuntu-latest, x86, nightly)
```

`julia-arch` stays a matrix key so that the x86 `include` adds a job instead of merging into the 64-bit Linux one. 32-bit builds are still tested on Linux, whose nightly is current, and `test/AGENTS.md` now names that job as the source of the 32-bit standard coverage.

The required checks in the `main` ruleset follow the new job names: `test (windows-latest, x86, nightly)` is removed, and the macOS, Linux x64 and Windows x64 checks are now the `default` ones. Release branches test their own Julia release and are unaffected, so no backport.

*This pull request was written by generative AI (Claude Code).*

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@andreasnoack andreasnoack mentioned this pull request Nov 22, 2026
10 tasks done
`issparse(::AbstractArray)` recurses on `parent`, which need not be an
array. Since `vcat`, `hcat` and `hvcat` of any `AbstractVecOrMat` call
`issparse`, concatenating such arrays threw a `MethodError`.

Fixes #1191
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.97%. Comparing base (a31bcc2) to head (d00b07c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1192   +/-   ##
=======================================
  Coverage   98.97%   98.97%           
=======================================
  Files          16       16           
  Lines       10759    10759           
=======================================
  Hits        10649    10649           
  Misses        110      110           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ViralBShah
ViralBShah merged commit fedda1e into main Nov 22, 2026
11 checks passed
@ViralBShah
ViralBShah deleted the an/issparse-fallback branch November 22, 2026 14:54
ViralBShah added a commit that referenced this pull request Nov 22, 2026
Julia's CI stopped building 32-bit Windows on Nov 18 (JuliaCI/julia-buildkite#797, following the [Discourse announcement](https://discourse.julialang.org/t/phasing-out-julia-support-for-32-bit-windows/137912) that 1.13 is the last release with 32-bit Windows binaries). The last win32 nightly is `julia-publish` build 11438, for `dffa1584150`.

**Before**

`julia-latest-win32.zip` was last modified on Nov 18, while the other nightlies are current:

```
winnt/x86/julia-latest-win32.zip        last-modified: Wed, 18 Nov 2026 09:16:40 GMT
winnt/x64/julia-latest-win64.zip        last-modified: Sun, 22 Nov 2026 12:29:29 GMT
linux/x86/julia-latest-linux32.tar.gz   last-modified: Sun, 22 Nov 2026 12:19:36 GMT
```

So `test (windows-latest, x86, nightly)` runs 1.15.0-DEV.831 while every other job runs DEV.904. It passes on #1192 without seeing the LinearAlgebra bumps that fail the other jobs, and on #1186 SparseArrays fails to precompile:

```
Julia Version 1.15.0-DEV.831
  Commit dffa158415 (2026-11-18 07:58 UTC)
ERROR: LoadError: UndefVarError: `_aliasparts` not defined in `LinearAlgebra`
```

**After**

There is no Windows x86 job. The matrix lists all four runners under `os` with `julia-arch: default`, which `setup-julia` resolves to the runner's own architecture, and 32-bit Linux is the one `include` that sets an architecture:

```
test (ubuntu-latest, default, nightly)      coverage
test (windows-latest, default, nightly)
test (macOS-latest, default, nightly)       check-bounds=yes
test (ubuntu-26.04-arm, default, nightly)
test (ubuntu-latest, x86, nightly)
```

`julia-arch` stays a matrix key so that the x86 `include` adds a job instead of merging into the 64-bit Linux one. 32-bit builds are still tested on Linux, whose nightly is current, and `test/AGENTS.md` now names that job as the source of the 32-bit standard coverage.

The required checks in the `main` ruleset follow the new job names: `test (windows-latest, x86, nightly)` is removed, and the macOS, Linux x64 and Windows x64 checks are now the `default` ones. Release branches test their own Julia release and are unaffected, so no backport.

*This pull request was written by generative AI (Claude Code).*

🤖 Generated with [Claude Code](https://claude.com/claude-code)

(cherry picked from commit ac81ca0)
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.

vcat of non-sparse AbstractVectors throws in issparse when parent is not an array

2 participants