Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 27, 2024
1 parent 5c2fead commit 250c7e3
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 87 deletions.
30 changes: 23 additions & 7 deletions benchmarks/heavy_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,33 @@
import seaborn as sns
from matplotlib import pyplot as plt
from moabb import set_log_level
from moabb.analysis.meta_analysis import (compute_dataset_statistics,
find_significant_differences)
from moabb.analysis.meta_analysis import (
compute_dataset_statistics,
find_significant_differences,
)

# Motor imagery databases
# P300 databases
from moabb.datasets import Lee2019_MI # new
from moabb.datasets import Schirrmeister2017 # new
from moabb.datasets import (BNCI2014_001, BNCI2014_004, BNCI2014_008,
BNCI2014_009, BNCI2015_003, BI2013a, BI2014a,
BI2014b, BI2015a, BI2015b, Cho2017,
GrosseWentrup2009, PhysionetMI, Shin2017A,
Weibo2014, Zhou2016)
from moabb.datasets import (
BNCI2014_001,
BNCI2014_004,
BNCI2014_008,
BNCI2014_009,
BNCI2015_003,
BI2013a,
BI2014a,
BI2014b,
BI2015a,
BI2015b,
Cho2017,
GrosseWentrup2009,
PhysionetMI,
Shin2017A,
Weibo2014,
Zhou2016,
)
from moabb.evaluations import CrossSubjectEvaluation, WithinSessionEvaluation
from moabb.paradigms import P300, LeftRightImagery, MotorImagery
from pyriemann.estimation import Covariances
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/light_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
QuantumMDMWithRiemannianPipeline)
QuantumMDMWithRiemannianPipeline,
)
from pyriemann_qiskit.utils import distance, mean # noqa

print(__doc__)
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/light_benchmark_nch_qaoacv.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

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 pyriemann_qiskit.utils.hyper_params_factory import create_mixer_rotational_X_gates

print(__doc__)

Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys

import matplotlib

# mne update path
import mne

Expand Down
7 changes: 5 additions & 2 deletions examples/ERP/noplot_classify_P300_bi_illiteracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@

from pyriemann_qiskit.ensemble import JudgeClassifier
from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline, QuantumMDMVotingClassifier,
QuantumMDMWithRiemannianPipeline)
QuantumClassifierWithDefaultRiemannianPipeline,
QuantumMDMVotingClassifier,
QuantumMDMWithRiemannianPipeline,
)

# inject convex distance and mean to pyriemann (if not done already)
from pyriemann_qiskit.utils import distance, mean # noqa

Expand Down
7 changes: 5 additions & 2 deletions examples/ERP/noplot_classify_P300_bi_quantum_mdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
from moabb.evaluations import WithinSessionEvaluation
from moabb.paradigms import P300

from pyriemann_qiskit.pipelines import (QuantumMDMVotingClassifier,
QuantumMDMWithRiemannianPipeline)
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

Expand Down
13 changes: 7 additions & 6 deletions examples/ERP/noplot_firebase_moabb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.pipeline import make_pipeline

from pyriemann_qiskit.pipelines import \
QuantumClassifierWithDefaultRiemannianPipeline
from pyriemann_qiskit.utils import (add_moabb_dataframe_results_to_caches,
convert_caches_to_dataframes,
filter_subjects_by_incomplete_results,
generate_caches)
from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline
from pyriemann_qiskit.utils import (
add_moabb_dataframe_results_to_caches,
convert_caches_to_dataframes,
filter_subjects_by_incomplete_results,
generate_caches,
)

print(__doc__)

Expand Down
7 changes: 5 additions & 2 deletions examples/ERP/plot_classify_EEG_quantum_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
from matplotlib import pyplot as plt
from pyriemann.estimation import XdawnCovariances
from pyriemann.tangentspace import TangentSpace
from sklearn.metrics import (ConfusionMatrixDisplay, balanced_accuracy_score,
confusion_matrix)
from sklearn.metrics import (
ConfusionMatrixDisplay,
balanced_accuracy_score,
confusion_matrix,
)
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline

Expand Down
3 changes: 1 addition & 2 deletions examples/ERP/plot_classify_P300_bi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
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__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import warnings

import seaborn as sns

# inject cpm distance and mean to pyriemann (if not done already)
from helpers.alias import ERPCov_MDM
from matplotlib import pyplot as plt
Expand Down
10 changes: 7 additions & 3 deletions examples/MI/noplot_multiclass_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
from helpers.alias import ERPCov_MDM
from matplotlib import pyplot as plt
from sklearn.decomposition import PCA
from sklearn.metrics import (ConfusionMatrixDisplay, balanced_accuracy_score,
confusion_matrix)
from sklearn.metrics import (
ConfusionMatrixDisplay,
balanced_accuracy_score,
confusion_matrix,
)
from sklearn.model_selection import train_test_split

from pyriemann_qiskit.datasets import get_mne_sample
from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
QuantumMDMWithRiemannianPipeline)
QuantumMDMWithRiemannianPipeline,
)

print(__doc__)

Expand Down
3 changes: 1 addition & 2 deletions examples/MI/plot_compare_dim_red.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
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__)
Expand Down
11 changes: 7 additions & 4 deletions examples/toys_dataset/plot_classifier_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC

from pyriemann_qiskit.classification import \
QuanticSVM # uncomment to run comparison with QuanticVQC (disabled for CI/CD); QuanticVQC
from pyriemann_qiskit.datasets import (generate_linearly_separable_dataset,
generate_qiskit_dataset)
from pyriemann_qiskit.classification import ( # uncomment to run comparison with QuanticVQC (disabled for CI/CD); QuanticVQC
QuanticSVM,
)
from pyriemann_qiskit.datasets import (
generate_linearly_separable_dataset,
generate_qiskit_dataset,
)

# uncomment to run comparison with QuanticVQC (disabled for CI/CD)
# from pyriemann_qiskit.classification import QuanticVQC
Expand Down
7 changes: 5 additions & 2 deletions examples/toys_dataset/plot_qaoa_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

from pyriemann_qiskit.utils.docplex import QAOACVOptimizer
from pyriemann_qiskit.utils.hyper_params_factory import (
create_mixer_qiskit_default, create_mixer_rotational_X_gates,
create_mixer_rotational_XY_gates, create_mixer_rotational_XZ_gates)
create_mixer_qiskit_default,
create_mixer_rotational_X_gates,
create_mixer_rotational_XY_gates,
create_mixer_rotational_XZ_gates,
)

###############################################################################
# Run QAOA-CV
Expand Down
24 changes: 15 additions & 9 deletions pyriemann_qiskit/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@
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 (ClassicalOptimizer, NaiveQAOAOptimizer,
QAOACVOptimizer, get_global_optimizer,
set_global_optimizer)
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)
from .utils.distance import distance_functions, qdistance_logeuclid_to_convex_hull
from .utils.docplex import (
ClassicalOptimizer,
NaiveQAOAOptimizer,
QAOACVOptimizer,
get_global_optimizer,
set_global_optimizer,
)
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,
)
from .utils.utils import is_qfunction

logging.basicConfig(level=logging.WARNING)
Expand Down
10 changes: 7 additions & 3 deletions pyriemann_qiskit/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from .utils import (MockDataset, generate_linearly_separable_dataset,
generate_qiskit_dataset, get_feature_dimension,
get_mne_sample)
from .utils import (
MockDataset,
generate_linearly_separable_dataset,
generate_qiskit_dataset,
get_feature_dimension,
get_mne_sample,
)

__all__ = [
"get_mne_sample",
Expand Down
25 changes: 18 additions & 7 deletions pyriemann_qiskit/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
from . import (distance, docplex, filtering, hyper_params_factory, mean,
preprocessing, quantum_provider, utils)
from .firebase_connector import (Cache, FirebaseConnector,
add_moabb_dataframe_results_to_caches,
convert_caches_to_dataframes,
filter_subjects_by_incomplete_results,
generate_caches)
from . import (
distance,
docplex,
filtering,
hyper_params_factory,
mean,
preprocessing,
quantum_provider,
utils,
)
from .firebase_connector import (
Cache,
FirebaseConnector,
add_moabb_dataframe_results_to_caches,
convert_caches_to_dataframes,
filter_subjects_by_incomplete_results,
generate_caches,
)
from .math import cov_to_corr_matrix, union_of_diff

__all__ = [
Expand Down
7 changes: 5 additions & 2 deletions pyriemann_qiskit/utils/distance.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
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)
from pyriemann.utils.distance import (
distance_euclid,
distance_functions,
distance_logeuclid,
)
from pyriemann.utils.mean import mean_logeuclid
from typing_extensions import deprecated

Expand Down
6 changes: 2 additions & 4 deletions pyriemann_qiskit/utils/docplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
from qiskit.quantum_info import Statevector
from qiskit_algorithms import QAOA
from qiskit_algorithms.optimizers import SLSQP, SPSA
from qiskit_optimization.algorithms import (CobylaOptimizer,
MinimumEigenOptimizer)
from qiskit_optimization.converters import (IntegerToBinary,
LinearEqualityToPenalty)
from qiskit_optimization.algorithms import CobylaOptimizer, MinimumEigenOptimizer
from qiskit_optimization.converters import IntegerToBinary, LinearEqualityToPenalty
from qiskit_optimization.problems import VarType
from qiskit_optimization.translators import from_docplex_mp
from sklearn.preprocessing import MinMaxScaler
Expand Down
3 changes: 1 addition & 2 deletions pyriemann_qiskit/utils/hyper_params_factory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import inspect

from qiskit.circuit import Parameter, QuantumCircuit, QuantumRegister
from qiskit.circuit.library import (PauliFeatureMap, TwoLocal, ZFeatureMap,
ZZFeatureMap)
from qiskit.circuit.library import PauliFeatureMap, TwoLocal, ZFeatureMap, ZZFeatureMap
from qiskit_algorithms.optimizers import SPSA


Expand Down
6 changes: 4 additions & 2 deletions pyriemann_qiskit/utils/quantum_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
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 (FidelityQuantumKernel,
FidelityStatevectorKernel)
from qiskit_machine_learning.kernels import (
FidelityQuantumKernel,
FidelityStatevectorKernel,
)

try:
from qiskit_symb.quantum_info import Statevector
Expand Down
8 changes: 6 additions & 2 deletions tests/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.pipeline import make_pipeline

from pyriemann_qiskit.classification import (QuanticMDM, QuanticNCH,
QuanticSVM, QuanticVQC)
from pyriemann_qiskit.classification import (
QuanticMDM,
QuanticNCH,
QuanticSVM,
QuanticVQC,
)
from pyriemann_qiskit.datasets import get_mne_sample
from pyriemann_qiskit.utils.filtering import NaiveDimRed

Expand Down
14 changes: 8 additions & 6 deletions tests/test_docplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from docplex.mp.model import Model
from docplex.mp.vartype import BinaryVarType, ContinuousVarType, IntegerVarType

from pyriemann_qiskit.utils.docplex import (ClassicalOptimizer,
NaiveQAOAOptimizer,
QAOACVOptimizer,
square_bin_mat_var,
square_cont_mat_var,
square_int_mat_var)
from pyriemann_qiskit.utils.docplex import (
ClassicalOptimizer,
NaiveQAOAOptimizer,
QAOACVOptimizer,
square_bin_mat_var,
square_cont_mat_var,
square_int_mat_var,
)


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from sklearn.model_selection import StratifiedKFold, cross_val_score

from pyriemann_qiskit.datasets import get_mne_sample
from pyriemann_qiskit.pipelines import \
QuantumClassifierWithDefaultRiemannianPipeline
from pyriemann_qiskit.pipelines import QuantumClassifierWithDefaultRiemannianPipeline


@pytest.mark.parametrize(
Expand Down
Loading

0 comments on commit 250c7e3

Please sign in to comment.