Skip to content

Commit

Permalink
[Fix] CuBIC, SPADE with scipy 1.14.0, deprecated .A attribute in `s…
Browse files Browse the repository at this point in the history
…cipy.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
  • Loading branch information
Moritz-Alexander-Kern authored Jul 17, 2024
1 parent 32e1199 commit 0984e19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,22 @@ 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
with:
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 }}
Expand Down
3 changes: 2 additions & 1 deletion elephant/cubic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion elephant/spade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0984e19

Please sign in to comment.