Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/ruff_formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Ruff Format Check

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ruff-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11" # or your preferred version

- name: Install Ruff
run: pip install ruff

- name: Run Ruff Check
run: ruff check --diff .
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.18.2
# hooks:
# - id: mypy
# additional_dependencies: [
# "pydantic>=2.0",
# ]
115 changes: 61 additions & 54 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# pyAML documentation build configuration file,
# pyAML documentation build configuration file,
#
# This file is execfile()d with the current directory set to its
# containing dir.
Expand All @@ -17,6 +17,7 @@
#
import pathlib
import sys

# ignore numpy warnings, see:
# https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility
import warnings
Expand Down Expand Up @@ -44,18 +45,19 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon',
'sphinx.ext.autosectionlabel',
'sphinx.ext.autosummary',
'myst_nb'
]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.napoleon",
"sphinx.ext.autosectionlabel",
"sphinx.ext.autosummary",
"myst_nb",
]
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2

Expand All @@ -66,18 +68,18 @@
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = ABOUT_PYAML["__title__"]
copyright_ = '2024, pyAML collaboration'
copyright_ = "2024, pyAML collaboration"
author = ABOUT_PYAML["__author__"]

rst_prolog = f"""
:github_url: {ABOUT_PYAML['__url__']}
:github_url: {ABOUT_PYAML["__url__"]}
"""

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

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

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -120,44 +122,44 @@
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'collapse_navigation': False,
'display_version': True,
'logo_only': True,
'navigation_depth': 6,
"collapse_navigation": False,
"display_version": True,
"logo_only": True,
"navigation_depth": 6,
"rightsidebar": True,
"relbarbgcolor": "black"
"relbarbgcolor": "black",
}


# Name of an image file (path relative to the configuration directory)
# that is the logo of the docs, or URL that points an image file for the logo.
# It is placed at the top of the sidebar;
# its width should therefore not exceed 200 pixels.
html_logo = '_static/img/logo.png'
html_logo = "_static/img/logo.png"
html_copy_source = False
html_theme_options = {
"github_url": "https://github.com/atcollab/at",
"logo": {
"image_light": '_static/img/logo.png',
"image_dark": '_static/img/dark.png',
}
"image_light": "_static/img/logo.png",
"image_dark": "_static/img/dark.png",
},
}

# 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"]

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

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

smartquotes_action = "qe" # renders only quotes and ellipses (...) but not dashes (option: D)
smartquotes_action = (
"qe" # renders only quotes and ellipses (...) but not dashes (option: D)
)

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
],
"index": [],
"common/about": [],
Expand All @@ -189,23 +193,20 @@
# -- Options for HTMLHelp output ------------------------------------------

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

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# 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 @@ -215,37 +216,43 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyaml.tex', u'pyAML Documentation',
u'pyAML collaboration', 'manual'),
(master_doc, "pyaml.tex", "pyAML Documentation", "pyAML collaboration", "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, 'pyaml', u'pyAML Documentation',
[author], 1)
]
man_pages = [(master_doc, "pyaml", "pyAML Documentation", [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pyaml', u'pyAML Documentation',
author, 'pyaml', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"pyaml",
"pyAML Documentation",
author,
"pyaml",
"One line description of project.",
"Miscellaneous",
),
]

# -- Autodoc Configuration ---------------------------------------------------

# Add here all modules to be mocked up. When the dependencies are not met
# at building time. Here used to have PyQT mocked.
autodoc_mock_imports = ['PyQt5', 'PyQt5.QtGui', 'PyQt5.QtCore', 'PyQt5.QtWidgets',
"matplotlib.backends.backend_qt5agg",
]
autodoc_mock_imports = [
"PyQt5",
"PyQt5.QtGui",
"PyQt5.QtCore",
"PyQt5.QtWidgets",
"matplotlib.backends.backend_qt5agg",
]

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

Expand All @@ -257,5 +264,5 @@
"deflist",
]
myst_heading_anchors = 3
nb_execution_mode = "off" #"auto"
nb_execution_mode = "off" # "auto"
nb_execution_allow_errors = True
2 changes: 1 addition & 1 deletion docs/notebooks/control_system.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pyaml.pyaml import pyaml,PyAML"
"from pyaml.pyaml import PyAML, pyaml"
]
}
],
Expand Down
37 changes: 20 additions & 17 deletions docs/notebooks/live_design.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
"metadata": {},
"outputs": [],
"source": [
"from pyaml.pyaml import pyaml,PyAML\n",
"import numpy as np\n",
"from pyaml.instrument import Instrument\n",
"from pyaml.configuration.factory import Factory\n",
"import numpy as np"
"from pyaml.pyaml import PyAML, pyaml\n",
"\n",
"from pyaml.configuration.factory import Factory"
]
},
{
Expand All @@ -54,8 +55,8 @@
"metadata": {},
"outputs": [],
"source": [
"ml:PyAML = pyaml('../../tests/config/EBSTune.yaml')\n",
"SR:Instrument = ml.get('sr')"
"ml: PyAML = pyaml(\"../../tests/config/EBSTune.yaml\")\n",
"SR: Instrument = ml.get(\"sr\")"
]
},
{
Expand Down Expand Up @@ -103,7 +104,7 @@
}
],
"source": [
"sr.design.get_lattice() #Direct access to underlying pyAT lattice"
"sr.design.get_lattice() # Direct access to underlying pyAT lattice"
]
},
{
Expand All @@ -115,7 +116,7 @@
"source": [
"quadForTune = sr.get_magnets(\"QForTune\")\n",
"\n",
"tune_device = sr.get_betatron_tune_monitor('BETATRON_TUNE')"
"tune_device = sr.get_betatron_tune_monitor(\"BETATRON_TUNE\")"
]
},
{
Expand All @@ -140,14 +141,14 @@
"print(f\"Tune directly from the lattice {tune_design}\")\n",
"initial_tune = tune_device.tune.get()\n",
"print(f\"Tune via pyAML interface for design mode {initial_tune}\")\n",
"tunemat = np.zeros((len(quadForTune),2))\n",
"tunemat = np.zeros((len(quadForTune), 2))\n",
"\n",
"for idx,m in enumerate(quadForTune):\n",
" str = m.strength.get()\n",
" m.strength.set(str+1e-4)\n",
" dq = tune_device.tune.get() - initial_tune\n",
" tunemat[idx] = dq*1e4\n",
" m.strength.set(str)"
"for idx, m in enumerate(quadForTune):\n",
" str = m.strength.get()\n",
" m.strength.set(str + 1e-4)\n",
" dq = tune_device.tune.get() - initial_tune\n",
" tunemat[idx] = dq * 1e4\n",
" m.strength.set(str)"
]
},
{
Expand All @@ -165,10 +166,12 @@
"metadata": {},
"outputs": [],
"source": [
"print(tune_device.tune.get()) # what ever the globally set mode whas\n",
"print(tune_device.tune.get()) # what ever the globally set mode has\n",
"\n",
"SR.design.get_betatron_tune_monitor('BETATRON_TUNE').tune.get() # tune from design simulations \n",
"# SR.live.get_betatron_tune_monitor('BETATRON_TUNE').tune.get() # tune from real accelerator"
"# tune from design simulations\n",
"SR.design.get_betatron_tune_monitor(\"BETATRON_TUNE\").tune.get()\n",
"# tune from real accelerator\n",
"# SR.live.get_betatron_tune_monitor('BETATRON_TUNE').tune.get()"
]
},
{
Expand Down
Loading
Loading