You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scipy.sparse is being evolved from a matrix-centric API (exclusively 2D) to a generalized sparse array (1D or 2D) one.
Current versions ship both interfaces, but the plan is for the historical matrix-centric API to be deprecated in scipy 2.0 and eventually removed.
This change will affect astropy.nddata.covariance which uses sparse matrices both internally and publicly, and because sparse arrays do not behave identically to sparse matrices (for instance, some operators behave differently, see the migration guide), we cannot simply move from the historical API to the new one without risking breaking our own users, as was initially proposed in #20167
Affected public APIs
Here's a detailed overview of my findings. All of the following are public methods from the astropy.nddata.covariance.Covariance class. For convenience, Covariance[M] here denotes a Covariance instance that stores specifically a sparse matrix object (in the _cov attribute). Similarly, Covariance[A] (unused) denotes Covariance` instance that stores specifically a sparse array object.
__init__: takes in a csr_matrix, returns Covariance[M] from_array and from_sample: take in a csr_matrix and return Covariance[M] from_matrix_multiplication: returns Covariance[M] (actively converts its inputs to csr_matrix and coo_matrix) from_table: returns Covariance[M] (actively converts its inputs to coo_matrix) from_variance: returns Covariance[M] (actively converts its inputs to csr_matrix) to_correlation, to_sparse: return a csr_matrix apply_new_variance: returns Covariance[M] (actively converts its inputs to coo_matrix) to_correlation: actively converts its inputs to csr_matrix revert_correlation: returns a coo_matrix (actively converts its inputs to csr_matrix, then coo_matrix)
Plan of action
In order to minimize disruption, I propose the following migration plan:
ensure Covariance[A] can be instantiated without implicit conversions to Covariance[M]
make Covariance(ndarray) return Covariance[A] instead of Covariance[M]` (controlled, but breaking change)
deprecate Covariance[M] with a note that we plan to support it as long as our oldest-supported version of scipy has sparse matrices
Activity