Skip to content

Deprecate sparse keyword argument of indicatormat - #1016

Open
devmotion wants to merge 2 commits into
masterfrom
dw/deprecate-indicatormat-sparse-kw
Open

devmotion wants to merge 2 commits into
masterfrom
dw/deprecate-indicatormat-sparse-kw

Conversation

@devmotion

@devmotion devmotion commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

SparseArrays accounts for most of the load time of StatsBase (Julia 1.13.1, warm cache):

Time
using StatsBase ~265 ms
all dependencies except SparseArrays ~65 ms
using SparseArrays (incl. SuiteSparse_jll) ~200 ms
StatsBase itself (@time_imports) ~7 ms

(using SparseArrays takes 100-170 ms on Julia 1.10-1.13 since it is no longer part of the sysimage.)

The only place where SparseArrays is used is indicatormat(...; sparse=true). #885 tried to make SparseArrays a weak dependency but was closed since it would break sparse=true if SparseArrays is not loaded. This PR follows the suggestion in #885 (comment) instead:

  • Add indicatormat(SparseMatrixCSC, x, k) and indicatormat(SparseMatrixCSC, x, c=sort!(unique(x)))
  • Deprecate the keyword argument sparse (both sparse=true and sparse=false)

This is non-breaking. In a follow-up PR for StatsBase 0.35, the keyword argument can be removed and SparseArrays can be moved to an extension, reducing the load time of StatsBase to ~65 ms.

Context: TuringLang/MCMCDiagnosticTools.jl#177 (comment)

🤖 Generated with Claude Code

Add `indicatormat(SparseMatrixCSC, x, ...)` as replacement for
`indicatormat(x, ...; sparse=true)`. This is the only use of SparseArrays,
which accounts for ~200 ms of the ~265 ms load time of StatsBase. Removing
the keyword argument allows SparseArrays to become a weak dependency in
StatsBase 0.35.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant