Skip to content

Commit

Permalink
Improve doc rendering (#310)
Browse files Browse the repository at this point in the history
* improve doc rendering

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

* correct conf

* sort imports

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

* correct imports

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
qbarthelemy and pre-commit-ci[bot] authored Sep 13, 2024
1 parent 6aa64d2 commit 461e546
Show file tree
Hide file tree
Showing 29 changed files with 172 additions and 131 deletions.
5 changes: 5 additions & 0 deletions doc/_templates/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
{% block methods %}
.. automethod:: __init__
{% endblock %}

.. _sphx_glr_backreferences_{{ fullname }}:

.. minigallery:: {{ fullname }}
:add-heading:
10 changes: 6 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

# mne update path
import mne
print(mne.datasets.sample.data_path(update_path=True))
print(mne.datasets.eegbci.load_data(1, [6, 10, 14], update_path=True))
print(mne.datasets.sample.data_path(update_path=True, download=False))

matplotlib.use('Agg')
import shlex
Expand Down Expand Up @@ -61,8 +60,11 @@
plot_html_show_source_link = False

sphinx_gallery_conf = {
'examples_dirs': ['../examples', '../tutorials'],
'gallery_dirs': ['auto_examples']
'examples_dirs': ['../examples'],
'gallery_dirs': ['auto_examples'],
'doc_module': 'pyriemann_qiskit',
'backreferences_dir': 'generated',
'plot_gallery': 'True',
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
2 changes: 1 addition & 1 deletion doc/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ References
How to cite?
================================
Anton Andreev, Grégoire Cattan, Sylvain Chevallier, and Quentin Barthélemy. ‘PyRiemann-Qiskit: A Sandbox for Quantum Classification Experiments with Riemannian Geometry’. Research Ideas and Outcomes 9 (20 March 2023). https://doi.org/10.3897/rio.9.e101006.
Anton Andreev, Grégoire Cattan, Sylvain Chevallier, and Quentin Barthélemy. ‘pyRiemann-qiskit: A Sandbox for Quantum Classification Experiments with Riemannian Geometry’. Research Ideas and Outcomes 9 (20 March 2023). https://doi.org/10.3897/rio.9.e101006.
8 changes: 4 additions & 4 deletions examples/ERP/noplot_classify_P300_bi_illiteracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@
# License: BSD (3-clause)

from enum import Enum
from matplotlib import pyplot as plt
import numpy as np
import seaborn as sns
import warnings

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.spatialfilters import Xdawn
import seaborn as sns
from sklearn.ensemble import VotingClassifier
from sklearn.pipeline import make_pipeline, Pipeline
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.svm import SVC

from pyriemann_qiskit.ensemble import JudgeClassifier

# inject convex distance and mean to pyriemann (if not done already)
Expand All @@ -40,7 +41,6 @@
QuantumClassifierWithDefaultRiemannianPipeline,
)


print(__doc__)


Expand Down
5 changes: 3 additions & 2 deletions examples/ERP/noplot_classify_P300_bi_quantum_mdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# Modified from plot_classify_EEG_tangentspace.py of pyRiemann
# License: BSD (3-clause)

from matplotlib import pyplot as plt
import warnings
import seaborn as sns

from matplotlib import pyplot as plt
from moabb import set_log_level
from moabb.datasets import (
# bi2012,
Expand All @@ -42,6 +42,7 @@
)
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
Expand Down
22 changes: 12 additions & 10 deletions examples/ERP/noplot_firebase_moabb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,29 @@
# Modified from plot_classify_P300_bi.py
# License: BSD (3-clause)

import warnings

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.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.pipeline import make_pipeline
from sklearn.decomposition import PCA

from pyriemann_qiskit.utils import (
generate_caches,
filter_subjects_by_incomplete_results,
add_moabb_dataframe_results_to_caches,
convert_caches_to_dataframes,
)
from sklearn.pipeline import make_pipeline
from matplotlib import pyplot as plt
import warnings
import seaborn as sns
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from moabb import set_log_level
from moabb.datasets import bi2012
from moabb.evaluations import WithinSessionEvaluation
from moabb.paradigms import P300
from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
)
from sklearn.decomposition import PCA

print(__doc__)

Expand Down
9 changes: 5 additions & 4 deletions examples/ERP/plot_classify_EEG_quantum_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
# Modified from plot_classify_EEG_tangentspace.py of pyRiemann
# License: BSD (3-clause)

from matplotlib import pyplot as plt
from pyriemann.estimation import XdawnCovariances
from pyriemann.tangentspace import TangentSpace
from pyriemann_qiskit.classification import QuanticSVM
from pyriemann_qiskit.utils.filtering import NaiveDimRed
from pyriemann_qiskit.datasets import get_mne_sample
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import train_test_split
from sklearn.metrics import (
confusion_matrix,
ConfusionMatrixDisplay,
balanced_accuracy_score,
)
from matplotlib import pyplot as plt

from pyriemann_qiskit.classification import QuanticSVM
from pyriemann_qiskit.utils.filtering import NaiveDimRed
from pyriemann_qiskit.datasets import get_mne_sample

print(__doc__)

##############################################################################

X, y = get_mne_sample(n_trials=-1)

Expand Down
16 changes: 9 additions & 7 deletions examples/ERP/plot_classify_P300_bi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@
# Modified from plot_classify_EEG_tangentspace.py of pyRiemann
# License: BSD (3-clause)

from pyriemann.estimation import XdawnCovariances
from pyriemann.tangentspace import TangentSpace
from sklearn.pipeline import make_pipeline
from matplotlib import pyplot as plt
import warnings
import seaborn as sns
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA

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.pipeline import make_pipeline
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.decomposition import PCA

from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
)
from sklearn.decomposition import PCA

print(__doc__)

Expand Down
5 changes: 3 additions & 2 deletions examples/MI/noplot_classify_alexmi_with_quantum_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# Modified from ERP/classify_P300_bi_quantum_mdm.py
# License: BSD (3-clause)

from matplotlib import pyplot as plt
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

# inject cpm distance and mean to pyriemann (if not done already)
from helpers.alias import ERPCov_MDM
Expand Down
14 changes: 7 additions & 7 deletions examples/MI/noplot_multiclass_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
# Modified from plot_classify_EEG_quantum_svm
# License: BSD (3-clause)

from helpers.alias import ERPCov_MDM
from pyriemann_qiskit.datasets import get_mne_sample
from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
QuantumMDMWithRiemannianPipeline,
)
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import (
confusion_matrix,
ConfusionMatrixDisplay,
balanced_accuracy_score,
)
from sklearn.decomposition import PCA
from matplotlib import pyplot as plt

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

print(__doc__)

Expand Down
7 changes: 5 additions & 2 deletions examples/MI/plot_compare_dim_red.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
# Author: Gregoire Cattan
# License: BSD (3-clause)

from sklearn.decomposition import PCA
from sklearn.model_selection import StratifiedKFold, GridSearchCV

from pyriemann_qiskit.datasets import get_mne_sample
from pyriemann_qiskit.pipelines import (
QuantumClassifierWithDefaultRiemannianPipeline,
)
from pyriemann_qiskit.utils.filtering import NaiveDimRed
from sklearn.decomposition import PCA
from sklearn.model_selection import StratifiedKFold, GridSearchCV

print(__doc__)

###############################################################################

X, y = get_mne_sample(n_trials=10)

default_params = {
Expand Down
26 changes: 12 additions & 14 deletions examples/other_datasets/plot_financial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,27 @@
# Authors: Gregoire Cattan, Filipe Barroso
# License: BSD (3-clause)

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 pyriemann.estimation import XdawnCovariances
from pyriemann.utils.viz import plot_waveforms
from sklearn.base import TransformerMixin, BaseEstimator, ClassifierMixin
from sklearn.experimental import enable_halving_search_cv # noqa
from sklearn.model_selection import HalvingGridSearchCV
from sklearn.model_selection import HalvingGridSearchCV, train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from sklearn.metrics import balanced_accuracy_score
from imblearn.under_sampling import NearMiss
from pyriemann.preprocessing import Whitening
from pyriemann.estimation import XdawnCovariances
from pyriemann.utils.viz import plot_waveforms

from pyriemann_qiskit.classification import QuanticSVM
from pyriemann_qiskit.utils.preprocessing import NdRobustScaler
from matplotlib import pyplot as plt
import warnings
import pandas as pd
import numpy as np
import os

print(__doc__)

Expand Down Expand Up @@ -86,7 +87,6 @@ def plot_ERP(X, title, n=10, ylim=None, add_digest=False):


def merge_2axes(fig1, fig2, file_name1="f1.png", file_name2="f2.png"):
# Modified from [4]
fig1.savefig(file_name1)
fig2.savefig(file_name2)
plt.close(fig1)
Expand Down Expand Up @@ -466,5 +466,3 @@ def predict(self, X):
# .. [2] 'Synthetic Data of Transactions for Inmediate Loans Fraud'
# https://zenodo.org/records/7418458
# .. [3] https://pyriemann.readthedocs.io/en/latest/auto_examples/ERP/plot_ERP.html
#
# .. [4] https://stackoverflow.com/questions/16748577
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
# Author: Adrien Veres
# License: BSD (3-clause)

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
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.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.metrics import balanced_accuracy_score

from pyriemann_qiskit.classification import QuanticSVM

print(__doc__)
Expand Down
3 changes: 2 additions & 1 deletion examples/toys_dataset/plot_classifier_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# Modified for pyRiemann-qiskit by Gregoire Cattan
# License: BSD 3 clause

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
import numpy as np
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

from pyriemann_qiskit.datasets import (
generate_linearly_separable_dataset,
generate_qiskit_dataset,
Expand Down
6 changes: 4 additions & 2 deletions examples/toys_dataset/plot_learning_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
# Author: Gregoire Cattan
# License: BSD (3-clause)

import matplotlib.pyplot as plt
from pyriemann.estimation import Shrinkage

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
import matplotlib.pyplot as plt
from pyriemann_qiskit.datasets import generate_linearly_separable_dataset
from pyriemann_qiskit.classification import QuanticVQC
from pyriemann.estimation import Shrinkage


print(__doc__)

Expand Down
Loading

0 comments on commit 461e546

Please sign in to comment.