From bcde4b874bd48465f200c4a2df2e93334b2cae0a Mon Sep 17 00:00:00 2001 From: Adam Lugowski Date: Sat, 23 Dec 2023 18:04:27 -0800 Subject: [PATCH 1/3] Make pybind11 classes `py::module_local` Prevents a clash with SciPy 1.12's FMM --- python/src/fast_matrix_market/_fmm_core.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/src/fast_matrix_market/_fmm_core.cpp b/python/src/fast_matrix_market/_fmm_core.cpp index 46af352..0791560 100644 --- a/python/src/fast_matrix_market/_fmm_core.cpp +++ b/python/src/fast_matrix_market/_fmm_core.cpp @@ -195,7 +195,7 @@ PYBIND11_MODULE(_fmm_core, m) { } }); - py::class_(m, "header") + py::class_(m, "header", py::module_local()) #ifndef FMM_SCIPY_PRUNE .def(py::init<>()) .def(py::init()) @@ -224,7 +224,7 @@ PYBIND11_MODULE(_fmm_core, m) { #endif /////////////////////////////// // Read methods - py::class_(m, "_read_cursor") + py::class_(m, "_read_cursor", py::module_local()) .def_readonly("header", &read_cursor::header) .def("close", &read_cursor::close); @@ -236,7 +236,7 @@ PYBIND11_MODULE(_fmm_core, m) { /////////////////////////////// // Write methods - py::class_(m, "_write_cursor") + py::class_(m, "_write_cursor", py::module_local()) #ifndef FMM_SCIPY_PRUNE .def_readwrite("header", &write_cursor::header) #endif From d68f568230b086fb9d1a77226792a621af743f56 Mon Sep 17 00:00:00 2001 From: Adam Lugowski Date: Sat, 23 Dec 2023 18:09:24 -0800 Subject: [PATCH 2/3] Test against RC versions of numpy and scipy --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e85dc4..06ece58 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -148,11 +148,13 @@ jobs: - name: Install NumPy # --only-binary disables compiling the package from source if a binary wheel is not available, such as some versions of PyPy - run: pip install --only-binary ":all:" numpy || true + # `--pre` to test against RCs, if any + run: pip install --pre --only-binary ":all:" numpy || true - name: Install SciPy # --only-binary disables compiling the package from source if a binary wheel is not available, such as PyPy - run: pip install --only-binary ":all:" scipy || true + # `--pre` to test against RCs, if any + run: pip install --pre --only-binary ":all:" scipy || true - name: Python Test working-directory: python/tests From 0dcf5cdabf8eb486fc7dcf56c03bc73e38ff3788 Mon Sep 17 00:00:00 2001 From: Adam Lugowski Date: Sat, 23 Dec 2023 18:22:14 -0800 Subject: [PATCH 3/3] Disable `test_scipy_crashes` tests for SciPy versions that no longer crash --- python/tests/test_scipy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/tests/test_scipy.py b/python/tests/test_scipy.py index 139f35d..c4cdd90 100644 --- a/python/tests/test_scipy.py +++ b/python/tests/test_scipy.py @@ -132,6 +132,8 @@ def test_read_array_or_coo(self): self.assertMatrixEqual(m, m_fmm) + @unittest.skipIf(scipy is None or not scipy.__version__.startswith("1.11"), + "SciPy 1.12 ships FMM so this no longer crashes.") def test_scipy_crashes(self): for mtx in sorted(list((matrices / "scipy_crashes").glob("*.mtx*"))): with self.subTest(msg=mtx.stem):