Overview

SciPy 1.9, released on July 30, 2022, improves the COO format for sparse matrices and adds new statistical functions.

Main Features

COO sparse improvements

The COO (Coordinate) format for sparse matrices is optimized with faster arithmetic operations and better duplicate handling.

python
from scipy.sparse import coo_array
import numpy as np

# New coo_array class (replaces coo_matrix)
row = np.array([0, 1, 2, 3])
col = np.array([1, 2, 0, 3])
data = np.array([1.0, 2.0, 3.0, 4.0])

sparse = coo_array((data, (row, col)), shape=(4, 4))
print(f'Non-zero elements: {sparse.nnz}')
print(sparse.toarray())

New statistical functions

The scipy.stats module adds new distributions and improved nonparametric statistical tests.

python
from scipy import stats
import numpy as np

# Normality test
data = np.random.randn(1000)
stat, p_value = stats.normaltest(data)
print(f'p-value: {p_value:.4f}')

# Bootstrap for confidence interval
result = stats.bootstrap(
    (data,), np.mean, n_resamples=1000
)
print(f'95% CI: [{result.confidence_interval.low:.3f}, '
      f'{result.confidence_interval.high:.3f}]')

Sources