Skip to content

Commit fca7b23

Browse files
Applied ruff formatting
1 parent 802fb5a commit fca7b23

File tree

93 files changed

+2562
-1938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2562
-1938
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ repos:
1212
args: [--fix]
1313
- id: ruff-format
1414

15-
- repo: https://github.com/pre-commit/mirrors-mypy
16-
rev: v1.18.2
17-
hooks:
18-
- id: mypy
19-
additional_dependencies: [
20-
"pydantic>=2.0",
21-
]
15+
# - repo: https://github.com/pre-commit/mirrors-mypy
16+
# rev: v1.18.2
17+
# hooks:
18+
# - id: mypy
19+
# additional_dependencies: [
20+
# "pydantic>=2.0",
21+
# ]

docs/conf.py

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# pyAML documentation build configuration file,
3+
# pyAML documentation build configuration file,
44
#
55
# This file is execfile()d with the current directory set to its
66
# containing dir.
@@ -17,6 +17,7 @@
1717
#
1818
import pathlib
1919
import sys
20+
2021
# ignore numpy warnings, see:
2122
# https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility
2223
import warnings
@@ -44,18 +45,19 @@
4445
# Add any Sphinx extension module names here, as strings. They can be
4546
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4647
# ones.
47-
extensions = ['sphinx.ext.autodoc',
48-
'sphinx.ext.doctest',
49-
'sphinx.ext.todo',
50-
'sphinx.ext.coverage',
51-
'sphinx.ext.mathjax',
52-
'sphinx.ext.viewcode',
53-
'sphinx.ext.githubpages',
54-
'sphinx.ext.napoleon',
55-
'sphinx.ext.autosectionlabel',
56-
'sphinx.ext.autosummary',
57-
'myst_nb'
58-
]
48+
extensions = [
49+
"sphinx.ext.autodoc",
50+
"sphinx.ext.doctest",
51+
"sphinx.ext.todo",
52+
"sphinx.ext.coverage",
53+
"sphinx.ext.mathjax",
54+
"sphinx.ext.viewcode",
55+
"sphinx.ext.githubpages",
56+
"sphinx.ext.napoleon",
57+
"sphinx.ext.autosectionlabel",
58+
"sphinx.ext.autosummary",
59+
"myst_nb",
60+
]
5961
autosectionlabel_prefix_document = True
6062
autosectionlabel_maxdepth = 2
6163

@@ -66,18 +68,18 @@
6668
# You can specify multiple suffix as a list of string:
6769
#
6870
# source_suffix = ['.rst', '.md']
69-
source_suffix = '.rst'
71+
source_suffix = ".rst"
7072

7173
# The master toctree document.
72-
master_doc = 'index'
74+
master_doc = "index"
7375

7476
# General information about the project.
7577
project = ABOUT_PYAML["__title__"]
76-
copyright_ = '2024, pyAML collaboration'
78+
copyright_ = "2024, pyAML collaboration"
7779
author = ABOUT_PYAML["__author__"]
7880

7981
rst_prolog = f"""
80-
:github_url: {ABOUT_PYAML['__url__']}
82+
:github_url: {ABOUT_PYAML["__url__"]}
8183
"""
8284

8385
# The version info for the project you're documenting, acts as replacement for
@@ -94,15 +96,15 @@
9496
#
9597
# This is also used if you do content translation via gettext catalogs.
9698
# Usually you set "language" from the command line for these cases.
97-
language = 'en'
99+
language = "en"
98100

99101
# List of patterns, relative to source directory, that match files and
100102
# directories to ignore when looking for source files.
101103
# This patterns also effect to html_static_path and html_extra_path
102104
exclude_patterns = []
103105

104106
# The name of the Pygments (syntax highlighting) style to use.
105-
pygments_style = 'sphinx'
107+
pygments_style = "sphinx"
106108

107109
# If true, `todo` and `todoList` produce output, else they produce nothing.
108110
todo_include_todos = True
@@ -120,44 +122,44 @@
120122
# further. For a list of options available for each theme, see the
121123
# documentation.
122124
html_theme_options = {
123-
'collapse_navigation': False,
124-
'display_version': True,
125-
'logo_only': True,
126-
'navigation_depth': 6,
125+
"collapse_navigation": False,
126+
"display_version": True,
127+
"logo_only": True,
128+
"navigation_depth": 6,
127129
"rightsidebar": True,
128-
"relbarbgcolor": "black"
130+
"relbarbgcolor": "black",
129131
}
130132

131133

132134
# Name of an image file (path relative to the configuration directory)
133135
# that is the logo of the docs, or URL that points an image file for the logo.
134136
# It is placed at the top of the sidebar;
135137
# its width should therefore not exceed 200 pixels.
136-
html_logo = '_static/img/logo.png'
138+
html_logo = "_static/img/logo.png"
137139
html_copy_source = False
138140
html_theme_options = {
139141
"github_url": "https://github.com/atcollab/at",
140142
"logo": {
141-
"image_light": '_static/img/logo.png',
142-
"image_dark": '_static/img/dark.png',
143-
}
143+
"image_light": "_static/img/logo.png",
144+
"image_dark": "_static/img/dark.png",
145+
},
144146
}
145147

146148
# Add any paths that contain custom static files (such as style sheets) here,
147149
# relative to this directory. They are copied after the builtin static files,
148150
# so a file named "default.css" will overwrite the builtin "default.css".
149151
#
150-
html_static_path = ['_static']
152+
html_static_path = ["_static"]
151153

152154
# A dictionary of values to pass into the template engine’s context for all
153155
# pages. Single values can also be put in this dictionary using the
154156
# -A command-line option of sphinx-build.
155157
html_context = {
156-
'display_github': True,
158+
"display_github": True,
157159
# the following are only needed if :github_url: is not set
158-
'github_user': author,
159-
'github_repo': project,
160-
'github_version': 'main/docs/',
160+
"github_user": author,
161+
"github_repo": project,
162+
"github_version": "main/docs/",
161163
}
162164

163165
# A list of CSS files. The entry must be a filename string or a tuple
@@ -169,17 +171,19 @@
169171
#
170172
html_css_files = ["css/custom.css"]
171173

172-
smartquotes_action = "qe" # renders only quotes and ellipses (...) but not dashes (option: D)
174+
smartquotes_action = (
175+
"qe" # renders only quotes and ellipses (...) but not dashes (option: D)
176+
)
173177

174178
# Custom sidebar templates, must be a dictionary that maps document names
175179
# to template names.
176180
#
177181
# This is required for the alabaster theme
178182
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
179183
html_sidebars = {
180-
'**': [
181-
'relations.html', # needs 'show_related': True theme option to display
182-
'searchbox.html',
184+
"**": [
185+
"relations.html", # needs 'show_related': True theme option to display
186+
"searchbox.html",
183187
],
184188
"index": [],
185189
"common/about": [],
@@ -189,23 +193,20 @@
189193
# -- Options for HTMLHelp output ------------------------------------------
190194

191195
# Output file base name for HTML help builder.
192-
htmlhelp_basename = 'pyamldoc'
196+
htmlhelp_basename = "pyamldoc"
193197

194198
# -- Options for LaTeX output ---------------------------------------------
195199

196200
latex_elements = {
197201
# The paper size ('letterpaper' or 'a4paper').
198202
#
199203
# 'papersize': 'letterpaper',
200-
201204
# The font size ('10pt', '11pt' or '12pt').
202205
#
203206
# 'pointsize': '10pt',
204-
205207
# Additional stuff for the LaTeX preamble.
206208
#
207209
# 'preamble': '',
208-
209210
# Latex figure (float) alignment
210211
#
211212
# 'figure_align': 'htbp',
@@ -215,37 +216,43 @@
215216
# (source start file, target name, title,
216217
# author, documentclass [howto, manual, or own class]).
217218
latex_documents = [
218-
(master_doc, 'pyaml.tex', u'pyAML Documentation',
219-
u'pyAML collaboration', 'manual'),
219+
(master_doc, "pyaml.tex", "pyAML Documentation", "pyAML collaboration", "manual"),
220220
]
221221

222222
# -- Options for manual page output ---------------------------------------
223223

224224
# One entry per manual page. List of tuples
225225
# (source start file, name, description, authors, manual section).
226-
man_pages = [
227-
(master_doc, 'pyaml', u'pyAML Documentation',
228-
[author], 1)
229-
]
226+
man_pages = [(master_doc, "pyaml", "pyAML Documentation", [author], 1)]
230227

231228
# -- Options for Texinfo output -------------------------------------------
232229

233230
# Grouping the document tree into Texinfo files. List of tuples
234231
# (source start file, target name, title, author,
235232
# dir menu entry, description, category)
236233
texinfo_documents = [
237-
(master_doc, 'pyaml', u'pyAML Documentation',
238-
author, 'pyaml', 'One line description of project.',
239-
'Miscellaneous'),
234+
(
235+
master_doc,
236+
"pyaml",
237+
"pyAML Documentation",
238+
author,
239+
"pyaml",
240+
"One line description of project.",
241+
"Miscellaneous",
242+
),
240243
]
241244

242245
# -- Autodoc Configuration ---------------------------------------------------
243246

244247
# Add here all modules to be mocked up. When the dependencies are not met
245248
# at building time. Here used to have PyQT mocked.
246-
autodoc_mock_imports = ['PyQt5', 'PyQt5.QtGui', 'PyQt5.QtCore', 'PyQt5.QtWidgets',
247-
"matplotlib.backends.backend_qt5agg",
248-
]
249+
autodoc_mock_imports = [
250+
"PyQt5",
251+
"PyQt5.QtGui",
252+
"PyQt5.QtCore",
253+
"PyQt5.QtWidgets",
254+
"matplotlib.backends.backend_qt5agg",
255+
]
249256

250257
# -- Options for the myst markdown parser ------------------------------------
251258

@@ -257,5 +264,5 @@
257264
"deflist",
258265
]
259266
myst_heading_anchors = 3
260-
nb_execution_mode = "off" #"auto"
267+
nb_execution_mode = "off" # "auto"
261268
nb_execution_allow_errors = True

docs/notebooks/control_system.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"from pyaml.pyaml import pyaml,PyAML"
18+
"from pyaml.pyaml import PyAML, pyaml"
1919
]
2020
}
2121
],

docs/notebooks/live_design.ipynb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36-
"from pyaml.pyaml import pyaml,PyAML\n",
36+
"import numpy as np\n",
3737
"from pyaml.instrument import Instrument\n",
38-
"from pyaml.configuration.factory import Factory\n",
39-
"import numpy as np"
38+
"from pyaml.pyaml import PyAML, pyaml\n",
39+
"\n",
40+
"from pyaml.configuration.factory import Factory"
4041
]
4142
},
4243
{
@@ -54,8 +55,8 @@
5455
"metadata": {},
5556
"outputs": [],
5657
"source": [
57-
"ml:PyAML = pyaml('../../tests/config/EBSTune.yaml')\n",
58-
"SR:Instrument = ml.get('sr')"
58+
"ml: PyAML = pyaml(\"../../tests/config/EBSTune.yaml\")\n",
59+
"SR: Instrument = ml.get(\"sr\")"
5960
]
6061
},
6162
{
@@ -103,7 +104,7 @@
103104
}
104105
],
105106
"source": [
106-
"sr.design.get_lattice() #Direct access to underlying pyAT lattice"
107+
"sr.design.get_lattice() # Direct access to underlying pyAT lattice"
107108
]
108109
},
109110
{
@@ -115,7 +116,7 @@
115116
"source": [
116117
"quadForTune = sr.get_magnets(\"QForTune\")\n",
117118
"\n",
118-
"tune_device = sr.get_betatron_tune_monitor('BETATRON_TUNE')"
119+
"tune_device = sr.get_betatron_tune_monitor(\"BETATRON_TUNE\")"
119120
]
120121
},
121122
{
@@ -140,14 +141,14 @@
140141
"print(f\"Tune directly from the lattice {tune_design}\")\n",
141142
"initial_tune = tune_device.tune.get()\n",
142143
"print(f\"Tune via pyAML interface for design mode {initial_tune}\")\n",
143-
"tunemat = np.zeros((len(quadForTune),2))\n",
144+
"tunemat = np.zeros((len(quadForTune), 2))\n",
144145
"\n",
145-
"for idx,m in enumerate(quadForTune):\n",
146-
" str = m.strength.get()\n",
147-
" m.strength.set(str+1e-4)\n",
148-
" dq = tune_device.tune.get() - initial_tune\n",
149-
" tunemat[idx] = dq*1e4\n",
150-
" m.strength.set(str)"
146+
"for idx, m in enumerate(quadForTune):\n",
147+
" str = m.strength.get()\n",
148+
" m.strength.set(str + 1e-4)\n",
149+
" dq = tune_device.tune.get() - initial_tune\n",
150+
" tunemat[idx] = dq * 1e4\n",
151+
" m.strength.set(str)"
151152
]
152153
},
153154
{
@@ -165,10 +166,12 @@
165166
"metadata": {},
166167
"outputs": [],
167168
"source": [
168-
"print(tune_device.tune.get()) # what ever the globally set mode whas\n",
169+
"print(tune_device.tune.get()) # what ever the globally set mode has\n",
169170
"\n",
170-
"SR.design.get_betatron_tune_monitor('BETATRON_TUNE').tune.get() # tune from design simulations \n",
171-
"# SR.live.get_betatron_tune_monitor('BETATRON_TUNE').tune.get() # tune from real accelerator"
171+
"# tune from design simulations\n",
172+
"SR.design.get_betatron_tune_monitor(\"BETATRON_TUNE\").tune.get()\n",
173+
"# tune from real accelerator\n",
174+
"# SR.live.get_betatron_tune_monitor('BETATRON_TUNE').tune.get()"
172175
]
173176
},
174177
{

docs/notebooks/load_configuration.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"from pyaml.pyaml import pyaml,PyAML\n",
18+
"from pyaml.pyaml import PyAML, pyaml\n",
1919
"\n",
20-
"ml:PyAML = pyaml('../../tests/config/EBSTune.yaml')"
20+
"ml: PyAML = pyaml(\"../../tests/config/EBSTune.yaml\")"
2121
]
2222
},
2323
{

0 commit comments

Comments
 (0)