Skip to content

Commit

Permalink
Deprecate cov_to_corr_matrix (#269)
Browse files Browse the repository at this point in the history
* deprecate cov_to_corr_matrix

* change import for deprecated

* Update setup.py

fix setup.py

* Update requirements.txt

add mne dependency to requirement file for doc only

* Update Dockerfile

remove protobuf install in Dockerfile (now by default in setup.py)

* Update light_benchmark.py

flake8  # noqa: E231

* Update plot_financial_data.py

flake8

* Update light_benchmark.yml

trigger benchmark on change to setup.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Update testing.yml

as per actions/setup-python#850 (comment)

---------

Co-authored-by: gcattan <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 23, 2024
1 parent 6e4c49e commit 4ddf866
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/light_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'examples/**'
- '.github/workflows/light_benchmark.yml'
- 'benchmarks/light_benchmark.py'
- 'setup.py'

jobs:
light_benchmark:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
matrix:
python-version: [3.9, "3.10", 3.11]
os: [ubuntu-latest, macOS-latest, windows-latest]
# Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
exclude:
- { python-version: "3.9", os: "macos-latest" }
include:
- { python-version: "3.9", os: "macos-13" }

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ RUN mkdir /root/mne_data
RUN mkdir /home/mne_data

## Workaround for firestore
RUN pip install protobuf==4.25.3
RUN pip install google_cloud_firestore==2.16.0
### Missing __init__ file in protobuf
RUN touch /usr/local/lib/python3.9/site-packages/protobuf-4.25.3-py3.9.egg/google/__init__.py
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/light_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@


def set_output(key: str, value: str):
print(f"::set-output name={key}::{value}")
print(f"::set-output name={key}::{value}") # noqa: E231


is_pr = sys.argv[1] == "pr"
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sphinx-gallery
sphinx-bootstrap_theme
numpydoc
cython
mne==1.6.1
mne[data]>=0.24
seaborn>=0.12.1
scikit-learn==1.3.2
Expand Down
4 changes: 2 additions & 2 deletions examples/other_datasets/plot_financial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ def transform(self, X):
print(
f"Classical SVM: {train_score_svm:.3f}\
\nQuantum SVM: {train_score_qsvm:.3f}\
\nClassical RandomForest: {train_score_rf:.3f}"
\nClassical RandomForest: {train_score_rf:.3f}" # noqa: E231
)
print("----Testing score:----")
print(
f"Classical SVM: {score_svm:.3f}\
\nQuantum SVM: {score_qsvm:.3f}\
\nClassical RandomForest: {score_rf:.3f}"
\nClassical RandomForest: {score_rf:.3f}" # noqa: E231
)


Expand Down
5 changes: 3 additions & 2 deletions pyriemann_qiskit/utils/docplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from qiskit_optimization.algorithms import CobylaOptimizer, MinimumEigenOptimizer
from qiskit_optimization.converters import IntegerToBinary
from qiskit_optimization.translators import from_docplex_mp
from pyriemann_qiskit.utils import cov_to_corr_matrix, get_simulator
from pyriemann.utils.covariance import normalize
from pyriemann_qiskit.utils import get_simulator


_global_optimizer = [None]
Expand Down Expand Up @@ -460,7 +461,7 @@ def __init__(self, upper_bound=7, quantum_instance=None):
"""

def convert_covmat(self, covmat):
corr = cov_to_corr_matrix(covmat)
corr = normalize(covmat, "corr")
return np.round(corr * self.upper_bound, 0)

"""Helper to create a docplex representation of a
Expand Down
8 changes: 6 additions & 2 deletions pyriemann_qiskit/utils/math.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""Module for mathematical helpers"""

from pyriemann.utils.covariance import normalize
from typing_extensions import deprecated
import numpy as np
from pyriemann.utils.covariance import normalize


@deprecated(
"cov_to_corr_matrix is deprecated and will be removed in 0.4.0; "
"please use pyriemann.utils.covariance.normalize."
)
def cov_to_corr_matrix(covmat):
"""Convert covariance matrices to correlation matrices.
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
'cvxpy==1.4.2',
'scipy==1.11.4',
'docplex==2.25.236',
'grpcio-status==1.62.1',
'protobuf==4.25.3',
'firebase_admin==6.4.0',
'scikit-learn==1.3.2',
'tqdm',
Expand All @@ -54,7 +56,7 @@
'sphinx-gallery',
'sphinx-bootstrap_theme',
'numpydoc',
'mne',
'mne==1.6.1',
'seaborn>=0.12.1',
'moabb>=1.0.0',
'imbalanced-learn==0.12.0'
Expand Down

0 comments on commit 4ddf866

Please sign in to comment.