Skip to content

Commit

Permalink
Order imports (#324)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gcattan and pre-commit-ci[bot] authored Oct 28, 2024
1 parent 88b7b4c commit 6a9f737
Show file tree
Hide file tree
Showing 56 changed files with 225 additions and 270 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 4 additions & 3 deletions benchmarks/hb_nch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 18 additions & 33 deletions benchmarks/heavy_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion benchmarks/lb_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder


print(__doc__)

##############################################################################
Expand Down
11 changes: 6 additions & 5 deletions benchmarks/light_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/light_benchmark_nch_min_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/light_benchmark_nch_qaoacv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
8 changes: 6 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions examples/ERP/noplot_autoencoders_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)

Expand Down
22 changes: 11 additions & 11 deletions examples/ERP/noplot_classify_P300_bi_illiteracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down
21 changes: 5 additions & 16 deletions examples/ERP/noplot_classify_P300_bi_quantum_mdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

##############################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/ERP/noplot_classify_P300_nch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import warnings

import seaborn as sns
from matplotlib import pyplot as plt
from moabb import set_log_level
from moabb.datasets import bi2013a
from moabb.evaluations import WithinSessionEvaluation
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
Expand Down
12 changes: 5 additions & 7 deletions examples/ERP/noplot_firebase_moabb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,24 @@

import warnings

import seaborn as sns
from matplotlib import pyplot as plt
from moabb import set_log_level
from moabb.datasets import bi2012
from moabb.evaluations import WithinSessionEvaluation
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__)
Expand Down
8 changes: 4 additions & 4 deletions examples/ERP/plot_classify_EEG_quantum_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
Loading

0 comments on commit 6a9f737

Please sign in to comment.