diff --git a/pyproject.toml b/pyproject.toml index e3fd5767..5f2602c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ tests = [ ] tox = ["sparse[tests]", "tox"] all = ["sparse[docs,tox]", "matrepr"] -finch = ["finch-tensor>=0.1.9"] +finch = ["finch-tensor>=0.1.10"] [project.urls] Documentation = "https://sparse.pydata.org/" diff --git a/sparse/finch_backend/__init__.py b/sparse/finch_backend/__init__.py index 0d73ba33..b9d62ab2 100644 --- a/sparse/finch_backend/__init__.py +++ b/sparse/finch_backend/__init__.py @@ -4,6 +4,7 @@ raise ImportError("Finch not installed. Run `pip install sparse[finch]` to enable Finch backend") from e from finch import ( + SparseArray, abs, acos, acosh, @@ -56,6 +57,7 @@ ) __all__ = [ + "SparseArray", "abs", "acos", "acosh", diff --git a/sparse/tests/test_backends.py b/sparse/tests/test_backends.py index 983779c0..50c87743 100644 --- a/sparse/tests/test_backends.py +++ b/sparse/tests/test_backends.py @@ -4,7 +4,8 @@ import numpy as np import scipy.sparse as sp -from numpy.testing import assert_equal +import scipy.sparse.linalg as splin +from numpy.testing import assert_almost_equal, assert_equal def test_backend_contex_manager(backend): @@ -58,10 +59,24 @@ def my_fun(tns1, tns2): assert_equal(result.todense(), np.sum(2 * np_eye, axis=0)) -@pytest.mark.parametrize("format", ["csc", "csr", "coo"]) -def test_asarray(backend, format): - arr = np.eye(5) +@pytest.mark.parametrize("format, order", [("csc", "F"), ("csr", "C"), ("coo", "F"), ("coo", "C")]) +def test_asarray(backend, format, order): + arr = np.eye(5, order=order) result = sparse.asarray(arr, format=format) assert_equal(result.todense(), arr) + + +@pytest.mark.parametrize("format, order", [("csc", "F"), ("csr", "C"), ("coo", "F"), ("coo", "C")]) +def test_scipy_sparse_dispatch(backend, format, order): + x = np.eye(10, order=order) * 2 + y = np.ones((10, 1), order=order) + + x_sp = sparse.asarray(x, format=format) + y_sp = sparse.asarray(y, format="coo") + + actual = splin.spsolve(x_sp, y_sp) + expected = np.linalg.solve(x, y.ravel()) + + assert_almost_equal(actual, expected)