From 0984e19769b6bbe5d8495024949167a8a565c93f Mon Sep 17 00:00:00 2001 From: Moritz Kern <92092328+Moritz-Alexander-Kern@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:05:29 +0200 Subject: [PATCH] [Fix] CuBIC, SPADE with scipy 1.14.0, deprecated `.A` attribute in `scipy.sparse` matrices` (#636) * fix deprecated .A attribute on coo_matrix * make precision for cubic explicit * ensure float64 precision for data when using scipy.stats.kstat --- .github/workflows/CI.yml | 6 +++--- elephant/cubic.py | 3 ++- elephant/spade.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b22fc56ed..91f42577d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -131,14 +131,14 @@ jobs: fail-fast: false matrix: # OS [ubuntu-latest, macos-latest, windows-latest] - os: [macos-11,macos-12] + os: [macos-12,macos-13] python-version: [3.11] steps: - name: Get current year-month id: date run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT - - uses: actions/checkout@v3 + - uses: actions/checkout@v4.1.6 - name: Cache conda uses: actions/cache@v3 @@ -146,7 +146,7 @@ jobs: path: ~/conda_pkgs_dir key: ${{ runner.os }}-conda-${{hashFiles('requirements/environment.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }} - - uses: conda-incubator/setup-miniconda@030178870c779d9e5e1b4e563269f3aa69b04081 # corresponds to v3.0.3 + - uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # corresponds to v3.0.4 with: auto-update-conda: true python-version: ${{ matrix.python-version }} diff --git a/elephant/cubic.py b/elephant/cubic.py index ac117406e..b32536b90 100644 --- a/elephant/cubic.py +++ b/elephant/cubic.py @@ -237,5 +237,6 @@ def _kstat(data): """ if len(data) == 0: raise ValueError('The input data must be a non-empty array') - moments = [scipy.stats.kstat(data, n=n) for n in [1, 2, 3]] + # Due to issues with precision, ensure float64 (default) is the precision of the data array. (scipy == 1.14.0) + moments = [scipy.stats.kstat(data.astype(np.float64), n=n) for n in [1, 2, 3]] return moments diff --git a/elephant/spade.py b/elephant/spade.py index 251fc6ecd..ddaf411cf 100644 --- a/elephant/spade.py +++ b/elephant/spade.py @@ -768,7 +768,7 @@ def _build_context(binary_matrix, winlen): (np.ones((len(windows_col)), dtype=bool), (windows_row, windows_col)), shape=(num_bins, winlen * num_neurons), - dtype=bool).A + dtype=bool).toarray() # Array containing all the possible attributes (each spike is indexed by # a number equal to neu idx*winlen + bin_idx) attributes = np.array(