Problem
markov/core.py, markov/ddp.py, markov/random.py, _graph_tools.py, and game_theory/localint.py are written against scipy.sparse matrix classes (csr_matrix, coo_matrix). SciPy's announced direction is sparse arrays; the matrix classes — whose semantics rest on np.matrix, itself slated for removal — are on the way out. Our dependence is behavioral, not just nominal: markov/core.py:201 comments that row_sums is np.matrix (ndim=2) and the surrounding reduction code relies on that quirk. And it is user-visible: public APIs accept and return these types (MarkovChain docstrings advertise scipy.sparse.csr_matrix).
Proposed change (staged)
- Now: accept both matrix and array inputs everywhere (
sp.issparse already covers both); add a test leg that feeds csr_array inputs through MarkovChain / DiscreteDP.
- Next minor: convert internals to array semantics (explicit-axis reductions replacing
np.matrix-shaped sums — removes the core.py:201 reliance).
- Announced release: switch sparse return types to arrays with a changelog notice and, if warranted, a one-release
FutureWarning on the affected attributes.
Acceptance criteria
From the July 2026 technical-debt audit (AI-assisted; claims verified against 28d4b3b on 2026-07-25).
Problem
markov/core.py,markov/ddp.py,markov/random.py,_graph_tools.py, andgame_theory/localint.pyare written againstscipy.sparsematrix classes (csr_matrix,coo_matrix). SciPy's announced direction is sparse arrays; the matrix classes — whose semantics rest onnp.matrix, itself slated for removal — are on the way out. Our dependence is behavioral, not just nominal:markov/core.py:201comments thatrow_sumsisnp.matrix(ndim=2) and the surrounding reduction code relies on that quirk. And it is user-visible: public APIs accept and return these types (MarkovChaindocstrings advertisescipy.sparse.csr_matrix).Proposed change (staged)
sp.issparsealready covers both); add a test leg that feedscsr_arrayinputs throughMarkovChain/DiscreteDP.np.matrix-shaped sums — removes thecore.py:201reliance).FutureWarningon the affected attributes.Acceptance criteria
np.matrixsemanticsFrom the July 2026 technical-debt audit (AI-assisted; claims verified against
28d4b3bon 2026-07-25).