From 6a9f737400a9744e69626d5ea08a0c4877b4318b Mon Sep 17 00:00:00 2001 From: gcattan Date: Mon, 28 Oct 2024 15:50:51 +0100 Subject: [PATCH] Order imports (#324) * Update .pre-commit-config.yaml add isort * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update heavy_benchmark.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update noplot_classify_P300_bi_quantum_mdm.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update .pre-commit-config.yaml * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update plot_classifier_comparison.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update plot_classifier_comparison.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update pipelines.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update plot_classifier_comparison.py * Update noplot_classify_alexmi_with_quantum_pipeline.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update heavy_benchmark.py * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update .pre-commit-config.yaml * [pre-commit.ci] auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++ benchmarks/hb_nch.py | 7 +-- benchmarks/heavy_benchmark.py | 51 +++++++------------ benchmarks/lb_base.py | 1 - benchmarks/light_benchmark.py | 11 ++-- benchmarks/light_benchmark_nch_min_hull.py | 6 +-- benchmarks/light_benchmark_nch_qaoacv.py | 8 +-- doc/conf.py | 8 ++- examples/ERP/noplot_autoencoders_example.py | 4 +- .../ERP/noplot_classify_P300_bi_illiteracy.py | 22 ++++---- .../noplot_classify_P300_bi_quantum_mdm.py | 21 ++------ examples/ERP/noplot_classify_P300_nch.py | 2 +- examples/ERP/noplot_firebase_moabb.py | 12 ++--- examples/ERP/plot_classify_EEG_quantum_svm.py | 8 +-- examples/ERP/plot_classify_P300_bi.py | 10 ++-- examples/ERP/plot_distances_visualization.py | 5 +- examples/MI/helpers/alias.py | 2 +- ...t_classify_alexmi_with_quantum_pipeline.py | 10 ++-- .../MI/noplot_multiclass_classification.py | 9 ++-- examples/MI/plot_compare_dim_red.py | 6 +-- .../other_datasets/plot_financial_data.py | 12 ++--- .../plot_tutorial_quantum_svm_titanic_data.py | 8 +-- .../plot_classifier_comparison.py | 16 ++---- examples/toys_dataset/plot_learning_curve.py | 5 +- examples/toys_dataset/plot_qaoa_cv.py | 3 +- examples/toys_dataset/plot_quantum_art_vqc.py | 5 +- pyriemann_qiskit/__init__.py | 2 +- pyriemann_qiskit/autoencoders.py | 2 +- pyriemann_qiskit/classification.py | 28 ++++------ pyriemann_qiskit/datasets/__init__.py | 5 +- pyriemann_qiskit/datasets/utils.py | 2 +- pyriemann_qiskit/ensemble.py | 2 +- pyriemann_qiskit/pipelines.py | 18 ++----- pyriemann_qiskit/utils/__init__.py | 24 +++++---- pyriemann_qiskit/utils/distance.py | 9 ++-- pyriemann_qiskit/utils/docplex.py | 5 +- pyriemann_qiskit/utils/firebase_connector.py | 3 +- .../utils/hyper_params_factory.py | 9 +--- pyriemann_qiskit/utils/math.py | 3 +- pyriemann_qiskit/utils/mean.py | 5 +- pyriemann_qiskit/utils/quantum_provider.py | 4 +- pyriemann_qiskit/utils/utils.py | 2 +- setup.py | 3 +- tests/conftest.py | 8 +-- tests/test_classification.py | 13 ++--- tests/test_datasets.py | 1 + tests/test_docplex.py | 9 ++-- tests/test_ensemble.py | 11 ++-- tests/test_filtering.py | 5 +- tests/test_pipelines.py | 7 ++- tests/test_preprocessing.py | 3 +- tests/test_utils_distance.py | 23 +++++---- tests/test_utils_firebase.py | 8 +-- tests/test_utils_hyper_params_factory.py | 5 +- tests/test_utils_math.py | 3 +- tests/test_utils_mean.py | 15 +++--- 56 files changed, 225 insertions(+), 270 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6adb162..ec8104fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,3 +39,9 @@ repos: - id: prettier args: [--print-width=90, --prose-wrap=always] exclude: ^(.github/|.devcontainer/|doc/_static/|doc/conf.py|pyriemann_qiskit/_version.py|setup.py) + + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile=black", "--known-local-folder=helpers"] diff --git a/benchmarks/hb_nch.py b/benchmarks/hb_nch.py index 7cc88127..87aef229 100644 --- a/benchmarks/hb_nch.py +++ b/benchmarks/hb_nch.py @@ -7,13 +7,14 @@ @author: anton andreev """ +import os + +from heavy_benchmark import benchmark_alpha, plot_stat +from pyriemann.classification import MDM from pyriemann.estimation import XdawnCovariances from sklearn.pipeline import make_pipeline -from pyriemann.classification import MDM -import os from pyriemann_qiskit.classification import QuanticNCH -from heavy_benchmark import benchmark_alpha, plot_stat # start configuration hb_max_n_subjects = 3 diff --git a/benchmarks/heavy_benchmark.py b/benchmarks/heavy_benchmark.py index f1241697..6ed36380 100644 --- a/benchmarks/heavy_benchmark.py +++ b/benchmarks/heavy_benchmark.py @@ -16,55 +16,40 @@ """ # Author: Anton Andreev -from pyriemann.estimation import Covariances -from matplotlib import pyplot as plt import warnings -import seaborn as sns + +import moabb.analysis.plotting as moabb_plt import pandas as pd +import seaborn as sns +from matplotlib import pyplot as plt from moabb import set_log_level - -# P300 databases +from moabb.analysis.meta_analysis import ( + compute_dataset_statistics, + find_significant_differences, +) from moabb.datasets import ( - BI2013a, + BNCI2014_001, + BNCI2014_004, BNCI2014_008, BNCI2014_009, BNCI2015_003, - # EPFLP300, - # Lee2019_ERP, + BI2013a, BI2014a, BI2014b, BI2015a, BI2015b, -) - -# Motor imagery databases -from moabb.datasets import ( - BNCI2014_001, - Zhou2016, - # BNCI2015_001, - # BNCI2014_002, - BNCI2014_004, - # BNCI2015_004, #not tested - # AlexMI, - Weibo2014, Cho2017, GrosseWentrup2009, + Lee2019_MI, PhysionetMI, + Schirrmeister2017, Shin2017A, - Lee2019_MI, # new - Schirrmeister2017, # new -) -from moabb.evaluations import ( - WithinSessionEvaluation, - CrossSubjectEvaluation, -) -from moabb.paradigms import P300, MotorImagery, LeftRightImagery - -import moabb.analysis.plotting as moabb_plt -from moabb.analysis.meta_analysis import ( - compute_dataset_statistics, - find_significant_differences, + Weibo2014, + Zhou2016, ) +from moabb.evaluations import CrossSubjectEvaluation, WithinSessionEvaluation +from moabb.paradigms import P300, LeftRightImagery, MotorImagery +from pyriemann.estimation import Covariances print(__doc__) print("Version 1.0 24/06/2024") diff --git a/benchmarks/lb_base.py b/benchmarks/lb_base.py index 2fae2681..20031cdb 100644 --- a/benchmarks/lb_base.py +++ b/benchmarks/lb_base.py @@ -20,7 +20,6 @@ from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder - print(__doc__) ############################################################################## diff --git a/benchmarks/light_benchmark.py b/benchmarks/light_benchmark.py index ef42e9db..2c4bc907 100644 --- a/benchmarks/light_benchmark.py +++ b/benchmarks/light_benchmark.py @@ -13,18 +13,19 @@ import warnings +from lb_base import run from moabb import set_log_level -from pyriemann.estimation import XdawnCovariances, Shrinkage +from pyriemann.estimation import Shrinkage, XdawnCovariances from pyriemann.tangentspace import TangentSpace +from sklearn.decomposition import PCA +from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA +from sklearn.pipeline import make_pipeline + from pyriemann_qiskit.pipelines import ( QuantumClassifierWithDefaultRiemannianPipeline, QuantumMDMWithRiemannianPipeline, ) from pyriemann_qiskit.utils import distance, mean # noqa -from sklearn.decomposition import PCA -from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA -from sklearn.pipeline import make_pipeline -from lb_base import run print(__doc__) diff --git a/benchmarks/light_benchmark_nch_min_hull.py b/benchmarks/light_benchmark_nch_min_hull.py index 027dd951..e8219b2c 100644 --- a/benchmarks/light_benchmark_nch_min_hull.py +++ b/benchmarks/light_benchmark_nch_min_hull.py @@ -13,13 +13,13 @@ import warnings +from lb_base import run from moabb import set_log_level from pyriemann.estimation import XdawnCovariances -from pyriemann_qiskit.classification import QuanticNCH -from pyriemann_qiskit.utils import distance, mean # noqa from sklearn.pipeline import make_pipeline -from lb_base import run +from pyriemann_qiskit.classification import QuanticNCH +from pyriemann_qiskit.utils import distance, mean # noqa print(__doc__) diff --git a/benchmarks/light_benchmark_nch_qaoacv.py b/benchmarks/light_benchmark_nch_qaoacv.py index b1b36033..f7c7ae45 100644 --- a/benchmarks/light_benchmark_nch_qaoacv.py +++ b/benchmarks/light_benchmark_nch_qaoacv.py @@ -13,15 +13,15 @@ import warnings +from lb_base import run from moabb import set_log_level from pyriemann.estimation import XdawnCovariances -from pyriemann_qiskit.classification import QuanticNCH -from pyriemann_qiskit.utils import distance, mean # noqa -from pyriemann_qiskit.utils.hyper_params_factory import create_mixer_rotational_X_gates from qiskit_algorithms.optimizers import SPSA from sklearn.pipeline import make_pipeline -from lb_base import run +from pyriemann_qiskit.classification import QuanticNCH +from pyriemann_qiskit.utils import distance, mean # noqa +from pyriemann_qiskit.utils.hyper_params_factory import create_mixer_rotational_X_gates print(__doc__) diff --git a/doc/conf.py b/doc/conf.py index 76c1cc67..da50a856 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,18 +12,21 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os +import sys + import matplotlib # mne update path import mne + print(mne.datasets.sample.data_path(update_path=True, download=False)) matplotlib.use('Agg') import shlex -import sphinx_gallery + import sphinx_bootstrap_theme +import sphinx_gallery # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -95,6 +98,7 @@ # The short X.Y version. sys.path.insert(0, os.path.abspath(os.path.pardir)) import pyriemann_qiskit + version = pyriemann_qiskit.__version__ # The full version, including alpha/beta/rc tags. release = pyriemann_qiskit.__version__ diff --git a/examples/ERP/noplot_autoencoders_example.py b/examples/ERP/noplot_autoencoders_example.py index ffbf6b28..594c6979 100644 --- a/examples/ERP/noplot_autoencoders_example.py +++ b/examples/ERP/noplot_autoencoders_example.py @@ -17,6 +17,7 @@ import logging import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level from moabb.datasets import Hinss2021 @@ -25,13 +26,12 @@ from pyriemann.estimation import Covariances from pyriemann.tangentspace import TangentSpace from qiskit_algorithms.optimizers import COBYLA -import seaborn as sns from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline from pyriemann_qiskit.autoencoders import BasicQnnAutoencoder from pyriemann_qiskit.utils.filtering import ChannelSelection -from pyriemann_qiskit.utils.preprocessing import Vectorizer, Devectorizer +from pyriemann_qiskit.utils.preprocessing import Devectorizer, Vectorizer print(__doc__) diff --git a/examples/ERP/noplot_classify_P300_bi_illiteracy.py b/examples/ERP/noplot_classify_P300_bi_illiteracy.py index 6451dd89..1c9d5570 100644 --- a/examples/ERP/noplot_classify_P300_bi_illiteracy.py +++ b/examples/ERP/noplot_classify_P300_bi_illiteracy.py @@ -11,36 +11,36 @@ # Author: Gregoire Cattan # License: BSD (3-clause) -from enum import Enum import warnings +from enum import Enum +import numpy as np +import seaborn as sns from matplotlib import pyplot as plt from mne.decoding import Vectorizer from moabb import set_log_level from moabb.datasets.compound_dataset import BI_Il from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import P300 -import numpy as np -from pyriemann.estimation import XdawnCovariances -from pyriemann.tangentspace import TangentSpace from pyriemann.classification import MDM +from pyriemann.estimation import XdawnCovariances from pyriemann.spatialfilters import Xdawn -import seaborn as sns -from sklearn.ensemble import VotingClassifier -from sklearn.pipeline import make_pipeline, Pipeline +from pyriemann.tangentspace import TangentSpace from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA +from sklearn.ensemble import VotingClassifier +from sklearn.pipeline import Pipeline, make_pipeline from sklearn.svm import SVC from pyriemann_qiskit.ensemble import JudgeClassifier - -# inject convex distance and mean to pyriemann (if not done already) -from pyriemann_qiskit.utils import distance, mean # noqa from pyriemann_qiskit.pipelines import ( + QuantumClassifierWithDefaultRiemannianPipeline, QuantumMDMVotingClassifier, QuantumMDMWithRiemannianPipeline, - QuantumClassifierWithDefaultRiemannianPipeline, ) +# inject convex distance and mean to pyriemann (if not done already) +from pyriemann_qiskit.utils import distance, mean # noqa + print(__doc__) diff --git a/examples/ERP/noplot_classify_P300_bi_quantum_mdm.py b/examples/ERP/noplot_classify_P300_bi_quantum_mdm.py index 5a6e9618..02d0f221 100644 --- a/examples/ERP/noplot_classify_P300_bi_quantum_mdm.py +++ b/examples/ERP/noplot_classify_P300_bi_quantum_mdm.py @@ -25,32 +25,21 @@ import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level -from moabb.datasets import ( - # bi2012, - # bi2013a, - # bi2014a, - # bi2014b, - # bi2015a, - # bi2015b, - # BNCI2014008, - BNCI2014009, - # BNCI2015003, - # EPFLP300, - # Lee2019_ERP, -) +from moabb.datasets import BNCI2014009 from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import P300 -import seaborn as sns -# inject cpm distance and mean to pyriemann (if not done already) -from pyriemann_qiskit.utils import distance, mean # noqa from pyriemann_qiskit.pipelines import ( QuantumMDMVotingClassifier, QuantumMDMWithRiemannianPipeline, ) +# inject cpm distance and mean to pyriemann (if not done already) +from pyriemann_qiskit.utils import distance, mean # noqa + print(__doc__) ############################################################################## diff --git a/examples/ERP/noplot_classify_P300_nch.py b/examples/ERP/noplot_classify_P300_nch.py index 20f4957e..75a418ca 100644 --- a/examples/ERP/noplot_classify_P300_nch.py +++ b/examples/ERP/noplot_classify_P300_nch.py @@ -21,6 +21,7 @@ import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level from moabb.datasets import bi2013a @@ -28,7 +29,6 @@ from moabb.paradigms import P300 from pyriemann.classification import MDM from pyriemann.estimation import XdawnCovariances -import seaborn as sns from sklearn.pipeline import make_pipeline from pyriemann_qiskit.classification import QuanticNCH diff --git a/examples/ERP/noplot_firebase_moabb.py b/examples/ERP/noplot_firebase_moabb.py index 6b85bb32..930a3420 100644 --- a/examples/ERP/noplot_firebase_moabb.py +++ b/examples/ERP/noplot_firebase_moabb.py @@ -25,6 +25,7 @@ import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level from moabb.datasets import bi2012 @@ -32,19 +33,16 @@ from moabb.paradigms import P300 from pyriemann.estimation import XdawnCovariances from pyriemann.tangentspace import TangentSpace -import seaborn as sns +from sklearn.decomposition import PCA from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline -from sklearn.decomposition import PCA +from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline from pyriemann_qiskit.utils import ( - generate_caches, - filter_subjects_by_incomplete_results, add_moabb_dataframe_results_to_caches, convert_caches_to_dataframes, -) -from pyriemann_qiskit.pipelines import ( - QuantumClassifierWithDefaultRiemannianPipeline, + filter_subjects_by_incomplete_results, + generate_caches, ) print(__doc__) diff --git a/examples/ERP/plot_classify_EEG_quantum_svm.py b/examples/ERP/plot_classify_EEG_quantum_svm.py index eb6babfc..276ebf3a 100644 --- a/examples/ERP/plot_classify_EEG_quantum_svm.py +++ b/examples/ERP/plot_classify_EEG_quantum_svm.py @@ -16,17 +16,17 @@ from matplotlib import pyplot as plt from pyriemann.estimation import XdawnCovariances from pyriemann.tangentspace import TangentSpace -from sklearn.pipeline import make_pipeline -from sklearn.model_selection import train_test_split from sklearn.metrics import ( - confusion_matrix, ConfusionMatrixDisplay, balanced_accuracy_score, + confusion_matrix, ) +from sklearn.model_selection import train_test_split +from sklearn.pipeline import make_pipeline from pyriemann_qiskit.classification import QuanticSVM -from pyriemann_qiskit.utils.filtering import NaiveDimRed from pyriemann_qiskit.datasets import get_mne_sample +from pyriemann_qiskit.utils.filtering import NaiveDimRed print(__doc__) diff --git a/examples/ERP/plot_classify_P300_bi.py b/examples/ERP/plot_classify_P300_bi.py index 78616e49..24eac79e 100644 --- a/examples/ERP/plot_classify_P300_bi.py +++ b/examples/ERP/plot_classify_P300_bi.py @@ -24,6 +24,7 @@ import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level from moabb.datasets import bi2012 @@ -31,14 +32,11 @@ from moabb.paradigms import P300 from pyriemann.estimation import XdawnCovariances from pyriemann.tangentspace import TangentSpace -import seaborn as sns -from sklearn.pipeline import make_pipeline -from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.decomposition import PCA +from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA +from sklearn.pipeline import make_pipeline -from pyriemann_qiskit.pipelines import ( - QuantumClassifierWithDefaultRiemannianPipeline, -) +from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline print(__doc__) diff --git a/examples/ERP/plot_distances_visualization.py b/examples/ERP/plot_distances_visualization.py index 29520868..9a71ad95 100644 --- a/examples/ERP/plot_distances_visualization.py +++ b/examples/ERP/plot_distances_visualization.py @@ -19,14 +19,13 @@ from pyriemann.classification import MDM from pyriemann.estimation import XdawnCovariances from pyriemann.preprocessing import Whitening -from pyriemann.utils.viz import plot_biscatter, plot_bihist -from sklearn.pipeline import make_pipeline +from pyriemann.utils.viz import plot_bihist, plot_biscatter from sklearn.model_selection import train_test_split +from sklearn.pipeline import make_pipeline from pyriemann_qiskit.classification import QuanticNCH from pyriemann_qiskit.visualization.manifold import plot_manifold - print(__doc__) ############################################################################## diff --git a/examples/MI/helpers/alias.py b/examples/MI/helpers/alias.py index 8954f49c..c4734441 100644 --- a/examples/MI/helpers/alias.py +++ b/examples/MI/helpers/alias.py @@ -1,5 +1,5 @@ -from pyriemann.estimation import ERPCovariances from pyriemann.classification import MDM +from pyriemann.estimation import ERPCovariances from sklearn.pipeline import make_pipeline ERPCov_MDM = make_pipeline(ERPCovariances(estimator="lwf"), MDM()) diff --git a/examples/MI/noplot_classify_alexmi_with_quantum_pipeline.py b/examples/MI/noplot_classify_alexmi_with_quantum_pipeline.py index 7fa6461c..0e780f7c 100644 --- a/examples/MI/noplot_classify_alexmi_with_quantum_pipeline.py +++ b/examples/MI/noplot_classify_alexmi_with_quantum_pipeline.py @@ -14,19 +14,19 @@ import warnings +import seaborn as sns from matplotlib import pyplot as plt from moabb import set_log_level from moabb.datasets import AlexMI from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import MotorImagery -import seaborn as sns + +from pyriemann_qiskit.pipelines import QuantumMDMWithRiemannianPipeline # inject cpm distance and mean to pyriemann (if not done already) -from helpers.alias import ERPCov_MDM from pyriemann_qiskit.utils import distance, mean # noqa -from pyriemann_qiskit.pipelines import ( - QuantumMDMWithRiemannianPipeline, -) + +from helpers.alias import ERPCov_MDM print(__doc__) diff --git a/examples/MI/noplot_multiclass_classification.py b/examples/MI/noplot_multiclass_classification.py index 0076c3c9..c611bd6a 100644 --- a/examples/MI/noplot_multiclass_classification.py +++ b/examples/MI/noplot_multiclass_classification.py @@ -14,21 +14,22 @@ # License: BSD (3-clause) from matplotlib import pyplot as plt -from sklearn.model_selection import train_test_split +from sklearn.decomposition import PCA from sklearn.metrics import ( - confusion_matrix, ConfusionMatrixDisplay, balanced_accuracy_score, + confusion_matrix, ) -from sklearn.decomposition import PCA +from sklearn.model_selection import train_test_split -from helpers.alias import ERPCov_MDM from pyriemann_qiskit.datasets import get_mne_sample from pyriemann_qiskit.pipelines import ( QuantumClassifierWithDefaultRiemannianPipeline, QuantumMDMWithRiemannianPipeline, ) +from helpers.alias import ERPCov_MDM + print(__doc__) ############################################################################### diff --git a/examples/MI/plot_compare_dim_red.py b/examples/MI/plot_compare_dim_red.py index 7eb677e0..317a8eab 100644 --- a/examples/MI/plot_compare_dim_red.py +++ b/examples/MI/plot_compare_dim_red.py @@ -20,12 +20,10 @@ # License: BSD (3-clause) from sklearn.decomposition import PCA -from sklearn.model_selection import StratifiedKFold, GridSearchCV +from sklearn.model_selection import GridSearchCV, StratifiedKFold from pyriemann_qiskit.datasets import get_mne_sample -from pyriemann_qiskit.pipelines import ( - QuantumClassifierWithDefaultRiemannianPipeline, -) +from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline from pyriemann_qiskit.utils.filtering import NaiveDimRed print(__doc__) diff --git a/examples/other_datasets/plot_financial_data.py b/examples/other_datasets/plot_financial_data.py index 54a01a04..fe9a931d 100644 --- a/examples/other_datasets/plot_financial_data.py +++ b/examples/other_datasets/plot_financial_data.py @@ -33,21 +33,21 @@ import os import warnings -from imblearn.under_sampling import NearMiss -from matplotlib import pyplot as plt import numpy as np import pandas as pd -from pyriemann.preprocessing import Whitening +from imblearn.under_sampling import NearMiss +from matplotlib import pyplot as plt from pyriemann.estimation import XdawnCovariances +from pyriemann.preprocessing import Whitening from pyriemann.utils.viz import plot_waveforms -from sklearn.base import TransformerMixin, BaseEstimator, ClassifierMixin +from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin +from sklearn.ensemble import RandomForestClassifier from sklearn.experimental import enable_halving_search_cv # noqa +from sklearn.metrics import balanced_accuracy_score from sklearn.model_selection import HalvingGridSearchCV, train_test_split from sklearn.pipeline import make_pipeline from sklearn.preprocessing import LabelEncoder -from sklearn.ensemble import RandomForestClassifier from sklearn.svm import SVC -from sklearn.metrics import balanced_accuracy_score from pyriemann_qiskit.classification import QuanticSVM from pyriemann_qiskit.utils.hyper_params_factory import gen_zz_feature_map diff --git a/examples/other_datasets/plot_tutorial_quantum_svm_titanic_data.py b/examples/other_datasets/plot_tutorial_quantum_svm_titanic_data.py index 9909c5cb..1216322e 100644 --- a/examples/other_datasets/plot_tutorial_quantum_svm_titanic_data.py +++ b/examples/other_datasets/plot_tutorial_quantum_svm_titanic_data.py @@ -14,13 +14,13 @@ import numpy as np import pandas as pd import seaborn as sns -from sklearn.impute import KNNImputer -from sklearn.preprocessing import LabelEncoder, StandardScaler from sklearn.decomposition import PCA -from sklearn.model_selection import train_test_split +from sklearn.impute import KNNImputer from sklearn.linear_model import LogisticRegression -from sklearn.svm import SVC from sklearn.metrics import balanced_accuracy_score +from sklearn.model_selection import train_test_split +from sklearn.preprocessing import LabelEncoder, StandardScaler +from sklearn.svm import SVC from pyriemann_qiskit.classification import QuanticSVM diff --git a/examples/toys_dataset/plot_classifier_comparison.py b/examples/toys_dataset/plot_classifier_comparison.py index 5c9afac2..932b5e59 100644 --- a/examples/toys_dataset/plot_classifier_comparison.py +++ b/examples/toys_dataset/plot_classifier_comparison.py @@ -13,26 +13,20 @@ # License: BSD 3 clause import matplotlib.pyplot as plt -from matplotlib.colors import ListedColormap import numpy as np +from matplotlib.colors import ListedColormap +from sklearn.datasets import make_circles, make_moons from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler -from sklearn.datasets import make_moons, make_circles from sklearn.svm import SVC +# uncomment to run comparison with QuanticVQC (disabled for CI/CD) +# from pyriemann_qiskit.classification import QuanticVQC +from pyriemann_qiskit.classification import QuanticSVM from pyriemann_qiskit.datasets import ( generate_linearly_separable_dataset, generate_qiskit_dataset, ) -from pyriemann_qiskit.classification import ( - QuanticSVM, - # uncomment to run comparison with QuanticVQC (disabled for CI/CD) - # QuanticVQC -) - -# uncomment to run comparison with QuanticVQC (disabled for CI/CD) -# from pyriemann_qiskit.classification import QuanticVQC - print(__doc__) diff --git a/examples/toys_dataset/plot_learning_curve.py b/examples/toys_dataset/plot_learning_curve.py index 3fadf8d1..8b77fea3 100644 --- a/examples/toys_dataset/plot_learning_curve.py +++ b/examples/toys_dataset/plot_learning_curve.py @@ -14,12 +14,11 @@ import matplotlib.pyplot as plt from pyriemann.estimation import Shrinkage +from pyriemann_qiskit.classification import QuanticVQC +from pyriemann_qiskit.datasets import generate_linearly_separable_dataset from pyriemann_qiskit.datasets.utils import get_mne_sample from pyriemann_qiskit.pipelines import QuantumMDMWithRiemannianPipeline from pyriemann_qiskit.utils.hyper_params_factory import get_spsa -from pyriemann_qiskit.datasets import generate_linearly_separable_dataset -from pyriemann_qiskit.classification import QuanticVQC - print(__doc__) diff --git a/examples/toys_dataset/plot_qaoa_cv.py b/examples/toys_dataset/plot_qaoa_cv.py index ed4d80b7..4de7be58 100644 --- a/examples/toys_dataset/plot_qaoa_cv.py +++ b/examples/toys_dataset/plot_qaoa_cv.py @@ -16,8 +16,8 @@ import math -from docplex.mp.model import Model import matplotlib.pyplot as plt +from docplex.mp.model import Model from qiskit_algorithms.optimizers import COBYLA, SPSA from pyriemann_qiskit.utils.docplex import QAOACVOptimizer @@ -28,7 +28,6 @@ create_mixer_rotational_XZ_gates, ) - ############################################################################### # Run QAOA-CV # diff --git a/examples/toys_dataset/plot_quantum_art_vqc.py b/examples/toys_dataset/plot_quantum_art_vqc.py index 611b31ca..e634f8f8 100644 --- a/examples/toys_dataset/plot_quantum_art_vqc.py +++ b/examples/toys_dataset/plot_quantum_art_vqc.py @@ -13,12 +13,11 @@ import matplotlib.pyplot as plt -from pyriemann_qiskit.utils.hyper_params_factory import gen_two_local -from pyriemann_qiskit.datasets import generate_linearly_separable_dataset from pyriemann_qiskit.classification import QuanticVQC +from pyriemann_qiskit.datasets import generate_linearly_separable_dataset +from pyriemann_qiskit.utils.hyper_params_factory import gen_two_local from pyriemann_qiskit.visualization import weights_spiral - print(__doc__) ############################################################################### diff --git a/pyriemann_qiskit/__init__.py b/pyriemann_qiskit/__init__.py index 7c628aa0..4518e9b1 100644 --- a/pyriemann_qiskit/__init__.py +++ b/pyriemann_qiskit/__init__.py @@ -1,5 +1,5 @@ +from . import autoencoders, classification, ensemble, pipelines from ._version import __version__ -from . import classification, pipelines, ensemble, autoencoders __all__ = [ "__version__", diff --git a/pyriemann_qiskit/autoencoders.py b/pyriemann_qiskit/autoencoders.py index 8c0901ef..3a6ce9ca 100644 --- a/pyriemann_qiskit/autoencoders.py +++ b/pyriemann_qiskit/autoencoders.py @@ -1,7 +1,7 @@ import logging import numpy as np -from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit +from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister from qiskit.circuit.library import RealAmplitudes from qiskit.quantum_info import Statevector from qiskit_algorithms.optimizers import SPSA diff --git a/pyriemann_qiskit/classification.py b/pyriemann_qiskit/classification.py index 9caf9502..301c8068 100644 --- a/pyriemann_qiskit/classification.py +++ b/pyriemann_qiskit/classification.py @@ -4,49 +4,39 @@ in several modes quantum/classical and simulated/real quantum computer. """ -from datetime import datetime import logging import random +from datetime import datetime from warnings import warn -from joblib import Parallel, delayed import numpy as np +from joblib import Parallel, delayed from pyriemann.classification import MDM from pyriemann.utils.distance import distance from qiskit.primitives import BackendSampler from qiskit_algorithms.optimizers import SLSQP from qiskit_ibm_runtime import QiskitRuntimeService from qiskit_machine_learning.algorithms import QSVC, VQC, PegasosQSVC -from qiskit_optimization.algorithms import ( - CobylaOptimizer, - SlsqpOptimizer, -) +from qiskit_optimization.algorithms import CobylaOptimizer, SlsqpOptimizer from scipy.special import softmax from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin from sklearn.svm import SVC from .datasets import get_feature_dimension +from .utils.distance import distance_functions, qdistance_logeuclid_to_convex_hull from .utils.docplex import ( - set_global_optimizer, - get_global_optimizer, ClassicalOptimizer, NaiveQAOAOptimizer, QAOACVOptimizer, + get_global_optimizer, + set_global_optimizer, ) -from .utils.distance import ( - distance_functions, - qdistance_logeuclid_to_convex_hull, -) -from .utils.hyper_params_factory import ( - gen_zz_feature_map, - gen_two_local, - get_spsa, -) +from .utils.hyper_params_factory import gen_two_local, gen_zz_feature_map, get_spsa from .utils.quantum_provider import ( + get_device, + get_provider, get_quantum_kernel, get_simulator, - get_provider, - get_device, ) from .utils.utils import is_qfunction diff --git a/pyriemann_qiskit/datasets/__init__.py b/pyriemann_qiskit/datasets/__init__.py index 5361940b..6255e064 100644 --- a/pyriemann_qiskit/datasets/__init__.py +++ b/pyriemann_qiskit/datasets/__init__.py @@ -1,12 +1,11 @@ from .utils import ( - get_mne_sample, + MockDataset, generate_linearly_separable_dataset, generate_qiskit_dataset, get_feature_dimension, - MockDataset, + get_mne_sample, ) - __all__ = [ "get_mne_sample", "generate_linearly_separable_dataset", diff --git a/pyriemann_qiskit/datasets/utils.py b/pyriemann_qiskit/datasets/utils.py index 45fe4d06..c0c726d3 100644 --- a/pyriemann_qiskit/datasets/utils.py +++ b/pyriemann_qiskit/datasets/utils.py @@ -4,7 +4,7 @@ from warnings import warn try: - from mne import io, read_events, pick_types, Epochs + from mne import Epochs, io, pick_types, read_events from mne.datasets import sample except Exception: warn("mne not available. get_mne_sample will fail.") diff --git a/pyriemann_qiskit/ensemble.py b/pyriemann_qiskit/ensemble.py index 50c1ef45..632613c1 100644 --- a/pyriemann_qiskit/ensemble.py +++ b/pyriemann_qiskit/ensemble.py @@ -2,7 +2,7 @@ Ensemble classifiers. """ import numpy as np -from sklearn.base import ClassifierMixin, BaseEstimator +from sklearn.base import BaseEstimator, ClassifierMixin from .utils import union_of_diff diff --git a/pyriemann_qiskit/pipelines.py b/pyriemann_qiskit/pipelines.py index ea994300..0d649195 100644 --- a/pyriemann_qiskit/pipelines.py +++ b/pyriemann_qiskit/pipelines.py @@ -1,7 +1,7 @@ """Module for pipelines.""" import numpy as np from pyriemann.classification import MDM -from pyriemann.estimation import XdawnCovariances, ERPCovariances +from pyriemann.estimation import ERPCovariances, XdawnCovariances from pyriemann.preprocessing import Whitening from pyriemann.tangentspace import TangentSpace from qiskit_algorithms.optimizers import SLSQP @@ -9,22 +9,12 @@ from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin from sklearn.decomposition import PCA from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA -from sklearn.pipeline import make_pipeline, FeatureUnion from sklearn.ensemble import VotingClassifier +from sklearn.pipeline import FeatureUnion, make_pipeline -from .classification import ( - QuanticNCH, - QuanticVQC, - QuanticSVM, - QuanticMDM, -) +from .classification import QuanticMDM, QuanticNCH, QuanticSVM, QuanticVQC from .utils.filtering import NoDimRed -from .utils.hyper_params_factory import ( - # gen_zz_feature_map, - gen_x_feature_map, - gen_two_local, - get_spsa, -) +from .utils.hyper_params_factory import gen_two_local, gen_x_feature_map, get_spsa from .utils.utils import is_qfunction diff --git a/pyriemann_qiskit/utils/__init__.py b/pyriemann_qiskit/utils/__init__.py index bcd331b3..5e6b146a 100644 --- a/pyriemann_qiskit/utils/__init__.py +++ b/pyriemann_qiskit/utils/__init__.py @@ -1,18 +1,22 @@ -from . import hyper_params_factory, filtering, preprocessing -from . import quantum_provider -from .math import cov_to_corr_matrix, union_of_diff -from . import docplex +from . import ( + distance, + docplex, + filtering, + hyper_params_factory, + mean, + preprocessing, + quantum_provider, + utils, +) from .firebase_connector import ( - FirebaseConnector, Cache, - generate_caches, - filter_subjects_by_incomplete_results, + FirebaseConnector, add_moabb_dataframe_results_to_caches, convert_caches_to_dataframes, + filter_subjects_by_incomplete_results, + generate_caches, ) -from . import distance -from . import mean -from . import utils +from .math import cov_to_corr_matrix, union_of_diff __all__ = [ "hyper_params_factory", diff --git a/pyriemann_qiskit/utils/distance.py b/pyriemann_qiskit/utils/distance.py index fb49b2e9..60910207 100644 --- a/pyriemann_qiskit/utils/distance.py +++ b/pyriemann_qiskit/utils/distance.py @@ -1,14 +1,13 @@ -from typing_extensions import deprecated - -from docplex.mp.model import Model import numpy as np +from docplex.mp.model import Model +from pyriemann.utils.base import logm from pyriemann.utils.distance import ( + distance_euclid, distance_functions, distance_logeuclid, - distance_euclid, ) -from pyriemann.utils.base import logm from pyriemann.utils.mean import mean_logeuclid +from typing_extensions import deprecated from .docplex import ClassicalOptimizer, get_global_optimizer diff --git a/pyriemann_qiskit/utils/docplex.py b/pyriemann_qiskit/utils/docplex.py index da1baa89..6555cdf9 100644 --- a/pyriemann_qiskit/utils/docplex.py +++ b/pyriemann_qiskit/utils/docplex.py @@ -8,8 +8,8 @@ import math import time -from docplex.mp.vartype import ContinuousVarType, IntegerVarType, BinaryVarType import numpy as np +from docplex.mp.vartype import BinaryVarType, ContinuousVarType, IntegerVarType from pyriemann.utils.covariance import normalize from qiskit.circuit.library import QAOAAnsatz from qiskit.primitives import BackendSampler @@ -18,15 +18,14 @@ from qiskit_algorithms.optimizers import SLSQP, SPSA from qiskit_optimization.algorithms import CobylaOptimizer, MinimumEigenOptimizer from qiskit_optimization.converters import IntegerToBinary, LinearEqualityToPenalty -from qiskit_optimization.translators import from_docplex_mp from qiskit_optimization.problems import VarType +from qiskit_optimization.translators import from_docplex_mp from sklearn.preprocessing import MinMaxScaler from .hyper_params_factory import create_mixer_rotational_X_gates from .math import is_pauli_identity from .quantum_provider import get_simulator - _global_optimizer = [None] diff --git a/pyriemann_qiskit/utils/firebase_connector.py b/pyriemann_qiskit/utils/firebase_connector.py index e84a16c5..ddf899d4 100644 --- a/pyriemann_qiskit/utils/firebase_connector.py +++ b/pyriemann_qiskit/utils/firebase_connector.py @@ -1,7 +1,8 @@ -import firebase_admin import os from warnings import warn +import firebase_admin + try: from firebase_admin import credentials, firestore except Exception: diff --git a/pyriemann_qiskit/utils/hyper_params_factory.py b/pyriemann_qiskit/utils/hyper_params_factory.py index c0f78052..e528b4d0 100644 --- a/pyriemann_qiskit/utils/hyper_params_factory.py +++ b/pyriemann_qiskit/utils/hyper_params_factory.py @@ -1,12 +1,7 @@ import inspect -from qiskit.circuit import QuantumCircuit, QuantumRegister, Parameter -from qiskit.circuit.library import ( - ZZFeatureMap, - ZFeatureMap, - PauliFeatureMap, - TwoLocal, -) +from qiskit.circuit import Parameter, QuantumCircuit, QuantumRegister +from qiskit.circuit.library import PauliFeatureMap, TwoLocal, ZFeatureMap, ZZFeatureMap from qiskit_algorithms.optimizers import SPSA diff --git a/pyriemann_qiskit/utils/math.py b/pyriemann_qiskit/utils/math.py index 5a63de08..e88491ed 100644 --- a/pyriemann_qiskit/utils/math.py +++ b/pyriemann_qiskit/utils/math.py @@ -1,9 +1,8 @@ """Module for mathematical helpers""" -from typing_extensions import deprecated - import numpy as np from pyriemann.utils.covariance import normalize from qiskit.quantum_info import Pauli, SparsePauliOp +from typing_extensions import deprecated @deprecated( diff --git a/pyriemann_qiskit/utils/mean.py b/pyriemann_qiskit/utils/mean.py index 207269b0..ddff2131 100644 --- a/pyriemann_qiskit/utils/mean.py +++ b/pyriemann_qiskit/utils/mean.py @@ -1,9 +1,8 @@ -from typing_extensions import deprecated - from docplex.mp.model import Model -from pyriemann.utils.base import logm, expm +from pyriemann.utils.base import expm, logm from pyriemann.utils.mean import mean_functions from qiskit_optimization.algorithms import ADMMOptimizer +from typing_extensions import deprecated from .docplex import ClassicalOptimizer, get_global_optimizer diff --git a/pyriemann_qiskit/utils/quantum_provider.py b/pyriemann_qiskit/utils/quantum_provider.py index 6cf33165..bae98dc3 100644 --- a/pyriemann_qiskit/utils/quantum_provider.py +++ b/pyriemann_qiskit/utils/quantum_provider.py @@ -1,19 +1,19 @@ """Module containing helpers for IBM quantum backends providers and simulators.""" -import joblib import logging import os import pickle +import joblib import numpy as np from qiskit_aer import AerSimulator from qiskit_aer.quantum_info import AerStatevector from qiskit_algorithms.state_fidelities import ComputeUncompute from qiskit_ibm_runtime import QiskitRuntimeService from qiskit_machine_learning.kernels import ( - FidelityStatevectorKernel, FidelityQuantumKernel, + FidelityStatevectorKernel, ) try: diff --git a/pyriemann_qiskit/utils/utils.py b/pyriemann_qiskit/utils/utils.py index 6ffaf91a..03e31590 100644 --- a/pyriemann_qiskit/utils/utils.py +++ b/pyriemann_qiskit/utils/utils.py @@ -1,5 +1,5 @@ -from .mean import mean_functions from .distance import distance_functions +from .mean import mean_functions def is_qfunction(string): diff --git a/setup.py b/setup.py index 670e7862..9c2a687f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ import os.path as op -from setuptools import setup, find_packages - +from setuptools import find_packages, setup # get the version (don't import mne here, so dependencies are not needed) version = None diff --git a/tests/conftest.py b/tests/conftest.py index ea97f52b..ee424cf6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,14 @@ """ Contains helper methods and classes to manage the tests. """ -import pytest -import numpy as np from functools import partial +from operator import itemgetter + +import numpy as np +import pytest from pyriemann.datasets import make_matrices + from pyriemann_qiskit.datasets import get_mne_sample -from operator import itemgetter def requires_module(function, name, call=None): diff --git a/tests/test_classification.py b/tests/test_classification.py index 55e00f04..4c00d74d 100644 --- a/tests/test_classification.py +++ b/tests/test_classification.py @@ -1,18 +1,19 @@ -import pytest -from conftest import BinaryTest, BinaryFVT, MultiClassFVT, MultiClassTest import numpy as np +import pytest +from conftest import BinaryFVT, BinaryTest, MultiClassFVT, MultiClassTest from pyriemann.classification import TangentSpace from pyriemann.estimation import XdawnCovariances +from sklearn.model_selection import StratifiedKFold, cross_val_score +from sklearn.pipeline import make_pipeline + from pyriemann_qiskit.classification import ( - QuanticSVM, - QuanticVQC, QuanticMDM, QuanticNCH, + QuanticSVM, + QuanticVQC, ) from pyriemann_qiskit.datasets import get_mne_sample from pyriemann_qiskit.utils.filtering import NaiveDimRed -from sklearn.pipeline import make_pipeline -from sklearn.model_selection import StratifiedKFold, cross_val_score @pytest.mark.parametrize( diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 20a2d643..fde095e3 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -1,4 +1,5 @@ import pytest + from pyriemann_qiskit.datasets import get_feature_dimension diff --git a/tests/test_docplex.py b/tests/test_docplex.py index d7f1e541..47231097 100644 --- a/tests/test_docplex.py +++ b/tests/test_docplex.py @@ -1,13 +1,14 @@ import pytest from docplex.mp.model import Model -from docplex.mp.vartype import ContinuousVarType, IntegerVarType, BinaryVarType +from docplex.mp.vartype import BinaryVarType, ContinuousVarType, IntegerVarType + from pyriemann_qiskit.utils.docplex import ( - square_cont_mat_var, - square_int_mat_var, - square_bin_mat_var, ClassicalOptimizer, NaiveQAOAOptimizer, QAOACVOptimizer, + square_bin_mat_var, + square_cont_mat_var, + square_int_mat_var, ) diff --git a/tests/test_ensemble.py b/tests/test_ensemble.py index 31f2cdbb..f3e2d5c8 100644 --- a/tests/test_ensemble.py +++ b/tests/test_ensemble.py @@ -1,10 +1,9 @@ -from pyriemann_qiskit.ensemble import ( - JudgeClassifier, -) -from sklearn.svm import SVC -from sklearn.base import ClassifierMixin -from sklearn.model_selection import cross_val_score, StratifiedKFold import numpy as np +from sklearn.base import ClassifierMixin +from sklearn.model_selection import StratifiedKFold, cross_val_score +from sklearn.svm import SVC + +from pyriemann_qiskit.ensemble import JudgeClassifier def test_canary(): diff --git a/tests/test_filtering.py b/tests/test_filtering.py index dfcbea7e..dd348098 100644 --- a/tests/test_filtering.py +++ b/tests/test_filtering.py @@ -1,6 +1,7 @@ -import pytest import numpy as np -from pyriemann_qiskit.utils.filtering import NoDimRed, NaiveDimRed +import pytest + +from pyriemann_qiskit.utils.filtering import NaiveDimRed, NoDimRed class TestCommon: diff --git a/tests/test_pipelines.py b/tests/test_pipelines.py index c591386e..d7da775c 100644 --- a/tests/test_pipelines.py +++ b/tests/test_pipelines.py @@ -1,11 +1,10 @@ import pytest from conftest import BinaryFVT -from pyriemann_qiskit.pipelines import ( - QuantumClassifierWithDefaultRiemannianPipeline, -) -from pyriemann_qiskit.datasets import get_mne_sample from sklearn.model_selection import StratifiedKFold, cross_val_score +from pyriemann_qiskit.datasets import get_mne_sample +from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline + @pytest.mark.parametrize( "estimator", diff --git a/tests/test_preprocessing.py b/tests/test_preprocessing.py index aeb1ca78..602bf5f3 100644 --- a/tests/test_preprocessing.py +++ b/tests/test_preprocessing.py @@ -1,7 +1,8 @@ import numpy as np -from pyriemann_qiskit.utils.preprocessing import NdRobustScaler from sklearn.preprocessing import RobustScaler +from pyriemann_qiskit.utils.preprocessing import NdRobustScaler + def test_ndrobustscaler(get_covmats): n_matrices, n_features = 5, 3 diff --git a/tests/test_utils_distance.py b/tests/test_utils_distance.py index 13bfc6c7..81fead44 100644 --- a/tests/test_utils_distance.py +++ b/tests/test_utils_distance.py @@ -1,20 +1,21 @@ -import pytest import numpy as np +import pytest +from pyriemann.estimation import XdawnCovariances +from pyriemann.utils.mean import mean_logeuclid +from sklearn.model_selection import StratifiedKFold, cross_val_score +from sklearn.pipeline import make_pipeline + +from pyriemann_qiskit.classification import QuanticMDM +from pyriemann_qiskit.datasets import get_mne_sample +from pyriemann_qiskit.utils.distance import ( + qdistance_logeuclid_to_convex_hull, + weights_logeuclid_to_convex_hull, +) from pyriemann_qiskit.utils.docplex import ( ClassicalOptimizer, NaiveQAOAOptimizer, QAOACVOptimizer, ) -from pyriemann_qiskit.utils.distance import ( - qdistance_logeuclid_to_convex_hull, - weights_logeuclid_to_convex_hull, -) -from pyriemann_qiskit.classification import QuanticMDM -from pyriemann_qiskit.datasets import get_mne_sample -from pyriemann.estimation import XdawnCovariances -from pyriemann.utils.mean import mean_logeuclid -from sklearn.pipeline import make_pipeline -from sklearn.model_selection import StratifiedKFold, cross_val_score @pytest.mark.parametrize( diff --git a/tests/test_utils_firebase.py b/tests/test_utils_firebase.py index 71f18608..8807bb92 100644 --- a/tests/test_utils_firebase.py +++ b/tests/test_utils_firebase.py @@ -1,10 +1,12 @@ -from pyriemann_qiskit.datasets import MockDataset -from pyriemann_qiskit.utils import FirebaseConnector, Cache +import warnings + from sklearn.metrics import balanced_accuracy_score from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC -import warnings + +from pyriemann_qiskit.datasets import MockDataset +from pyriemann_qiskit.utils import Cache, FirebaseConnector def test_firebase_connection(): diff --git a/tests/test_utils_hyper_params_factory.py b/tests/test_utils_hyper_params_factory.py index 3813c478..5c665320 100644 --- a/tests/test_utils_hyper_params_factory.py +++ b/tests/test_utils_hyper_params_factory.py @@ -1,11 +1,12 @@ import pytest from qiskit.circuit.parametertable import ParameterView + from pyriemann_qiskit.utils.hyper_params_factory import ( + gates, + gen_two_local, gen_x_feature_map, gen_z_feature_map, gen_zz_feature_map, - gen_two_local, - gates, get_spsa, get_spsa_parameters, ) diff --git a/tests/test_utils_math.py b/tests/test_utils_math.py index 83709d60..17d355f2 100644 --- a/tests/test_utils_math.py +++ b/tests/test_utils_math.py @@ -1,6 +1,7 @@ -from pyriemann_qiskit.utils import union_of_diff import numpy as np +from pyriemann_qiskit.utils import union_of_diff + def test_union_of_diff(): A = np.array([0, 1, 0]) diff --git a/tests/test_utils_mean.py b/tests/test_utils_mean.py index b717f892..c00f9393 100644 --- a/tests/test_utils_mean.py +++ b/tests/test_utils_mean.py @@ -1,18 +1,19 @@ -import pytest import numpy as np +import pytest +from pyriemann.estimation import Shrinkage, XdawnCovariances from pyriemann.utils.mean import mean_euclid, mean_logeuclid -from pyriemann.estimation import XdawnCovariances, Shrinkage -from sklearn.pipeline import make_pipeline +from qiskit_optimization.algorithms import ADMMOptimizer from sklearn.model_selection import StratifiedKFold, cross_val_score -from pyriemann_qiskit.utils.mean import qmean_euclid, qmean_logeuclid +from sklearn.pipeline import make_pipeline + +from pyriemann_qiskit.classification import QuanticMDM +from pyriemann_qiskit.datasets import get_mne_sample from pyriemann_qiskit.utils.docplex import ( ClassicalOptimizer, NaiveQAOAOptimizer, QAOACVOptimizer, ) -from pyriemann_qiskit.classification import QuanticMDM -from pyriemann_qiskit.datasets import get_mne_sample -from qiskit_optimization.algorithms import ADMMOptimizer +from pyriemann_qiskit.utils.mean import qmean_euclid, qmean_logeuclid @pytest.mark.parametrize(