Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Format #533

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/docker_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
print("Validating image")
want = np.ones(size)
dists = np.sqrt(
np.linspace(-1, 1, size[0])[:, np.newaxis] ** 2
+ np.linspace(-1, 1, size[1]) ** 2
np.linspace(-1, 1, size[0])[:, np.newaxis] ** 2 + np.linspace(-1, 1, size[1]) ** 2
)
want = (dists > 0.5).astype(float)
corr = np.corrcoef(want.ravel(), data.ravel())[0, 1]
Expand Down
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ repos:
hooks:
- id: ruff
args: ["--fix"]
# - id: ruff-format
ci:
skip: [ruff]
- id: ruff-format
182 changes: 107 additions & 75 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# project-template documentation build configuration file, created by
# sphinx-quickstart on Mon Jan 18 14:44:12 2016.
Expand All @@ -12,18 +11,18 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

from datetime import datetime, timezone
import sys
import os
import sys
import warnings
import sphinx.util.logging
from sphinx_gallery.sorting import FileNameSortKey
from datetime import datetime, timezone

sys.path.append("../")
import mne
import sphinx.util.logging
from mne.fixes import _compare_version
import mne_nirs
from mne.tests.test_docstring_parameters import error_ignores
from sphinx_gallery.sorting import FileNameSortKey

import mne_nirs

sphinx_logger = sphinx.util.logging.getLogger("mne")

Expand All @@ -42,20 +41,22 @@

# We need to triage which date type we use so that incremental builds work
# (Sphinx looks at variable changes and rewrites all files if some change)
copyright = (
copyright = ( # noqa: A001
f'2012–{td.year}, MNE Developers. Last updated <time datetime="{td.isoformat()}" class="localized">{td.strftime("%Y-%m-%d %H:%M %Z")}</time>\n' # noqa: E501
'<script type="text/javascript">$(function () { $("time.localized").each(function () { var el = $(this); el.text(new Date(el.attr("datetime")).toLocaleString([], {dateStyle: "medium", timeStyle: "long"})); }); } )</script>' # noqa: E501
)
if os.getenv("MNE_FULL_DATE", "false").lower() != "true":
copyright = f"2012–{td.year}, {project} Developers. Last updated locally."
copyright = f"2012–{td.year}, {project} Developers. Last updated locally." # noqa: A001, E501

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = mne_nirs.__version__
sphinx_logger.info(f"Building documentation for {project} {release} ({mne_nirs.__file__})")
sphinx_logger.info(
f"Building documentation for {project} {release} ({mne_nirs.__file__})"
)
# The short X.Y version.
version = ".".join(release.split(".")[:2])

Expand All @@ -68,23 +69,23 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'sphinx_copybutton',
'sphinx_gallery.gen_gallery',
'numpydoc',
'sphinxcontrib.bibtex',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"sphinx_gallery.gen_gallery",
"numpydoc",
"sphinxcontrib.bibtex",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# generate autosummary even if no references.
autosummary_generate = True
autodoc_default_options = {'inherited-members': None}
autodoc_default_options = {"inherited-members": None}

# The suffix of source filenames.
source_suffix = ".rst"
Expand All @@ -101,7 +102,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build', '_templates']
exclude_patterns = ["_build", "_templates"]

# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ["mne_nirs."]
Expand All @@ -110,27 +111,48 @@
# default_role = "py:obj"

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"


# NumPyDoc configuration -----------------------------------------------------

numpydoc_class_members_toctree = False
numpydoc_attributes_as_param_list = True
numpydoc_validate = True
numpydoc_validation_checks = {'all'} | set(error_ignores)
numpydoc_validation_checks = {"all"} | set(error_ignores)
numpydoc_validation_exclude = { # set of regex
# dict subclasses
r'\.clear', r'\.get$', r'\.copy$', r'\.fromkeys', r'\.items', r'\.keys',
r'\.pop', r'\.popitem', r'\.setdefault', r'\.update', r'\.values',
r"\.clear",
r"\.get$",
r"\.copy$",
r"\.fromkeys",
r"\.items",
r"\.keys",
r"\.pop",
r"\.popitem",
r"\.setdefault",
r"\.update",
r"\.values",
# list subclasses
r'\.append', r'\.count', r'\.extend', r'\.index', r'\.insert', r'\.remove',
r'\.sort',
r"\.append",
r"\.count",
r"\.extend",
r"\.index",
r"\.insert",
r"\.remove",
r"\.sort",
# we currently don't document these properly (probably okay)
r'\.__getitem__', r'\.__contains__', r'\.__hash__', r'\.__mul__',
r'\.__sub__', r'\.__add__', r'\.__iter__', r'\.__div__', r'\.__neg__',
r"\.__getitem__",
r"\.__contains__",
r"\.__hash__",
r"\.__mul__",
r"\.__sub__",
r"\.__add__",
r"\.__iter__",
r"\.__div__",
r"\.__neg__",
# copied from sklearn
r'mne\.utils\.deprecated',
r"mne\.utils\.deprecated",
}
numpydoc_xref_param_type = True
numpydoc_xref_aliases = {
Expand Down Expand Up @@ -202,9 +224,9 @@
}

# sphinxcontrib-bibtex
bibtex_bibfiles = ['./references.bib', './references-nirs.bib']
bibtex_style = 'unsrt'
bibtex_footbibliography_header = ''
bibtex_bibfiles = ["./references.bib", "./references-nirs.bib"]
bibtex_style = "unsrt"
bibtex_footbibliography_header = ""

nitpick_ignore_regex = [
# Type hints for undocumented types
Expand All @@ -216,13 +238,13 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
switcher_version_match = 'dev' if release.endswith('dev0') else version
switcher_version_match = "dev" if release.endswith("dev0") else version
html_context = {
"default_mode": "auto",
# next 3 are for the "edit this page" button
Expand All @@ -248,11 +270,11 @@
"footer_start": ["copyright"],
"analytics": dict(google_analytics_id="UA-188272121-1"),
"switcher": {
"json_url": 'https://mne.tools/mne-nirs/dev/_static/versions.json',
"json_url": "https://mne.tools/mne-nirs/dev/_static/versions.json",
"version_match": switcher_version_match,
},
'pygment_light_style': 'default',
'pygment_dark_style': 'github-dark',
"pygment_light_style": "default",
"pygment_dark_style": "github-dark",
}

# The name of an image file (relative to this directory) to place at the top
Expand All @@ -268,7 +290,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
Expand All @@ -277,7 +299,7 @@
html_show_sphinx = False

# Output file base name for HTML help builder.
htmlhelp_basename = 'mnenirsdoc'
htmlhelp_basename = "mnenirsdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -291,8 +313,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'project-template.tex', u'project-template Documentation',
u'Robert Luke', 'manual'),
(
"index",
"project-template.tex",
"project-template Documentation",
"Robert Luke",
"manual",
),
]


Expand All @@ -301,8 +328,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'project-template', u'project-template Documentation',
[u'Robert Luke'], 1)
("index", "project-template", "project-template Documentation", ["Robert Luke"], 1)
]


Expand All @@ -312,9 +338,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'project-template', u'project-template Documentation',
u'Robert Luke', 'project-template', 'One line description of project.',
'Miscellaneous'),
(
"index",
"project-template",
"project-template Documentation",
"Robert Luke",
"project-template",
"One line description of project.",
"Miscellaneous",
),
]

# Example configuration for intersphinx: refer to the Python standard library.
Expand All @@ -332,14 +364,14 @@
"statsmodels": ("https://www.statsmodels.org/stable", None),
}

scrapers = ('matplotlib',)
scrapers = ("matplotlib",)
try:
mne.viz.set_3d_backend(mne.viz.get_3d_backend())
except Exception:
report_scraper = None
else:
backend = mne.viz.get_3d_backend()
if backend in ('notebook', 'pyvistaqt'):
if backend in ("notebook", "pyvistaqt"):
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
import pyvista
Expand All @@ -348,15 +380,16 @@
scrapers += (
mne.gui._GUIScraper(),
mne.viz._brain._BrainScraper(),
'pyvista',
"pyvista",
)
report_scraper = mne.report._ReportScraper()
scrapers += (report_scraper,)
del backend
try:
import mne_qt_browser
_min_ver = _compare_version(mne_qt_browser.__version__, '>=', '0.2')
if mne.viz.get_browser_backend() == 'qt' and _min_ver:

_min_ver = _compare_version(mne_qt_browser.__version__, ">=", "0.2")
if mne.viz.get_browser_backend() == "qt" and _min_ver:
scrapers += (mne.viz._scraper._MNEQtBrowserScraper(),)
except ImportError:
pass
Expand All @@ -367,33 +400,32 @@
# instead of in the root."
# we will store dev docs in a `dev` subdirectory and all other docs in a
# directory "v" + version_str. E.g., "v0.3"
if 'dev' in version:
filepath_prefix = 'dev'
if "dev" in version:
filepath_prefix = "dev"
else:
filepath_prefix = 'stable'
filepath_prefix = "stable"

# sphinx-gallery configuration
sphinx_gallery_conf = {
'doc_module': 'mne_nirs',
'backreferences_dir': os.path.join('generated'),
'image_scrapers': scrapers,
'reference_url': {
'mne_nirs': None},
'download_all_examples': False,
'show_memory': sys.platform.startswith("linux"),
'within_subsection_order': FileNameSortKey,
'junit': os.path.join('..', 'test-results', 'sphinx-gallery', 'junit.xml'),
'binder': {
# Required keys
'org': 'mne-tools',
'repo': 'mne-nirs',
'branch': 'gh-pages', # noqa: E501 Can be any branch, tag, or commit hash. Use a branch that hosts your docs.
'binderhub_url': 'https://mybinder.org', # noqa: E501 Any URL of a binderhub deployment. Must be full URL (e.g. https://mybinder.org).
'filepath_prefix': filepath_prefix, # noqa: E501 A prefix to prepend to any filepaths in Binder links.
'dependencies': [
'../requirements.txt',
'../requirements_doc.txt',
"doc_module": "mne_nirs",
"backreferences_dir": os.path.join("generated"),
"image_scrapers": scrapers,
"reference_url": {"mne_nirs": None},
"download_all_examples": False,
"show_memory": sys.platform.startswith("linux"),
"within_subsection_order": FileNameSortKey,
"junit": os.path.join("..", "test-results", "sphinx-gallery", "junit.xml"),
"binder": {
# Required keys
"org": "mne-tools",
"repo": "mne-nirs",
"branch": "gh-pages", # noqa: E501 Can be any branch, tag, or commit hash. Use a branch that hosts your docs.
"binderhub_url": "https://mybinder.org", # noqa: E501 Any URL of a binderhub deployment. Must be full URL (e.g. https://mybinder.org).
"filepath_prefix": filepath_prefix, # noqa: E501 A prefix to prepend to any filepaths in Binder links.
"dependencies": [
"../requirements.txt",
"../requirements_doc.txt",
],
},
'plot_gallery': 'True', # Avoid annoying str/bool default warning
"plot_gallery": "True", # Avoid annoying str/bool default warning
}
Loading
Loading