Skip to content

Commit

Permalink
style: huge reformat using ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
asoplata committed Nov 8, 2024
1 parent 1bd58f3 commit 2e79a5a
Show file tree
Hide file tree
Showing 64 changed files with 8,420 additions and 5,565 deletions.
46 changes: 24 additions & 22 deletions dev_scripts/convert_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def download_folder_contents(owner, repo, path):
-------
Path to temporary directory or None
"""
url = f"https://api.github.com/repos/{owner}/{repo}/contents/{path}"
url = f'https://api.github.com/repos/{owner}/{repo}/contents/{path}'

try:
response = requests.get(url)
Expand All @@ -47,7 +47,7 @@ def download_folder_contents(owner, repo, path):
file_name = os.path.join(temp_dir, item['name'])
with open(file_name, 'wb') as f:
f.write(requests.get(download_url).content)
print(f"Downloaded: {file_name}")
print(f'Downloaded: {file_name}')
return temp_dir


Expand All @@ -70,36 +70,38 @@ def convert_param_files_from_repo(owner, repo, repo_path, local_path):
# Download param files
temp_dir = download_folder_contents(owner, repo, repo_path)
# Get list of json and param files
file_list = [Path(temp_dir, f)
for f in os.listdir(temp_dir)
if f.endswith('.param') or f.endswith('.json')]
file_list = [
Path(temp_dir, f)
for f in os.listdir(temp_dir)
if f.endswith('.param') or f.endswith('.json')
]
# Assign output location and names
output_dir = Path(local_path)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
output_filenames = [Path(output_dir, f.name.split('.')[0])
for f in file_list]
output_filenames = [Path(output_dir, f.name.split('.')[0]) for f in file_list]

[convert_to_json(file, outfile)
for (file, outfile) in zip(file_list, output_filenames)]
[
convert_to_json(file, outfile)
for (file, outfile) in zip(file_list, output_filenames)
]

# Delete downloads
shutil.rmtree(temp_dir)


if __name__ == '__main__':

# hnn param files
convert_param_files_from_repo(owner='jonescompneurolab',
repo='hnn',
repo_path='param',
local_path=(root_path /
'network_configuration'),
)
convert_param_files_from_repo(
owner='jonescompneurolab',
repo='hnn',
repo_path='param',
local_path=(root_path / 'network_configuration'),
)
# hnn-core json files
convert_param_files_from_repo(owner='jonescompneurolab',
repo='hnn-core',
repo_path='hnn_core/param',
local_path=(root_path /
'network_configuration'),
)
convert_param_files_from_repo(
owner='jonescompneurolab',
repo='hnn-core',
repo_path='hnn_core/param',
local_path=(root_path / 'network_configuration'),
)
79 changes: 39 additions & 40 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
import os
import sys

# sys.path.insert(0, os.path.abspath('.'))
import sphinx_gallery
from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder
Expand Down Expand Up @@ -57,7 +58,7 @@
'sphinx.ext.intersphinx',
'numpydoc',
'sphinx_copybutton',
'gh_substitutions' # custom extension, see ./sphinxext/gh_substitutions.py
'gh_substitutions', # custom extension, see ./sphinxext/gh_substitutions.py
]

# generate autosummary even if no references
Expand All @@ -68,7 +69,7 @@
default_role = 'autolink' # XXX silently allows bad syntax, someone should fix

# Sphinx-Copybutton configuration
copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_text = r'>>> |\.\.\. |\$ '
copybutton_prompt_is_regexp = True

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -113,13 +114,13 @@
html_theme_options = {
'navbar_sidebarrel': False,
'navbar_links': [
("Examples", "auto_examples/index"),
("API", "api"),
("Glossary", "glossary"),
("What's new", "whats_new"),
("GitHub", "https://github.com/jonescompneurolab/hnn-core", True)
('Examples', 'auto_examples/index'),
('API', 'api'),
('Glossary', 'glossary'),
("What's new", 'whats_new'),
('GitHub', 'https://github.com/jonescompneurolab/hnn-core', True),
],
'bootswatch_theme': "yeti"
'bootswatch_theme': 'yeti',
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down Expand Up @@ -150,15 +151,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -168,19 +166,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'hnn-core.tex', 'hnn-core Documentation',
'Mainak Jas', 'manual'),
(master_doc, 'hnn-core.tex', 'hnn-core Documentation', 'Mainak Jas', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'hnn-core', 'hnn-core Documentation',
[author], 1)
]
man_pages = [(master_doc, 'hnn-core', 'hnn-core Documentation', [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -189,17 +183,23 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'hnn-core', 'hnn-core Documentation',
author, 'hnn-core', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
'hnn-core',
'hnn-core Documentation',
author,
'hnn-core',
'One line description of project.',
'Miscellaneous',
),
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'mne': ('https://mne.tools/dev', None),
'numpy': ('https://numpy.org/devdocs', None),
'scipy': ('https://scipy.github.io/devdocs', None),
'matplotlib': ('https://matplotlib.org', None)
'matplotlib': ('https://matplotlib.org', None),
}
intersphinx_timeout = 5

Expand All @@ -209,7 +209,7 @@
'https://doi.org/10.1152/jn.00535.2009',
'https://doi.org/10.1152/jn.00122.2010',
'https://doi.org/10.1101/2021.04.16.440210',
'https://groups.google.com/g/hnnsolver'
'https://groups.google.com/g/hnnsolver',
]

# Resolve binder filepath_prefix. From the docs:
Expand All @@ -224,29 +224,28 @@
filepath_prefix = 'v{}'.format(version)

sphinx_gallery_conf = {
'first_notebook_cell': ("import pyvista as pv\n"
"from mne.viz import set_3d_backend\n"
"set_3d_backend('notebook')\n"
"pv.set_jupyter_backend('client')"
),
'first_notebook_cell': (
'import pyvista as pv\n'
'from mne.viz import set_3d_backend\n'
"set_3d_backend('notebook')\n"
"pv.set_jupyter_backend('client')"
),
'doc_module': 'hnn_core',
# path to your examples scripts
'examples_dirs': '../examples',
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
'backreferences_dir': 'generated',
'reference_url': {
'hnn_core': None
},
'reference_url': {'hnn_core': None},
'within_subsection_order': ExampleTitleSortKey,
'subsection_order': ExplicitOrder(['../examples/workflows/',
'../examples/howto/']),
'binder': {'org': 'jonescompneurolab',
'repo': 'hnn-core',
'branch': 'gh-pages',
'binderhub_url': 'https://mybinder.org',
'filepath_prefix': filepath_prefix,
'notebooks_dir': 'notebooks',
'dependencies': 'Dockerfile'
}
'subsection_order': ExplicitOrder(['../examples/workflows/', '../examples/howto/']),
'binder': {
'org': 'jonescompneurolab',
'repo': 'hnn-core',
'branch': 'gh-pages',
'binderhub_url': 'https://mybinder.org',
'filepath_prefix': filepath_prefix,
'notebooks_dir': 'notebooks',
'dependencies': 'Dockerfile',
},
}
1 change: 1 addition & 0 deletions doc/sphinxext/gh_substitutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
https://doughellmann.com/blog/2010/05/09/defining-custom-roles-in-sphinx/
"""

from docutils.nodes import reference
from docutils.parsers.rst.roles import set_classes

Expand Down
Loading

0 comments on commit 2e79a5a

Please sign in to comment.