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
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Run this command to always ignore formatting commits in `git blame`
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# Ruff rules refactoring, part 1
# insert_commit_sha_and_uncomment

# Ruff rules refactoring, part 1
# insert_commit_sha_and_uncomment
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: "3.13"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install uv and Python ${{ env.python-version }}
uses: astral-sh/setup-uv@v6
Expand All @@ -38,6 +38,6 @@ jobs:
run: make tests

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Check Out Repo
uses: actions/checkout@v4
- name: Check Out Repo
uses: actions/checkout@v5

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: "3.13"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Update apt
run: sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:


steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install uv and Python ${{ env.python-version }}
uses: astral-sh/setup-uv@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v6
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# -- Project information -----------------------------------------------------

project = "PyhDToolkit"
copyright = f"2019, {pyhdtoolkit.__author__}"
copyright_ = f"2019, {pyhdtoolkit.__author__}"
author = pyhdtoolkit.__author__

rst_prolog = f""":github_url: {pyhdtoolkit.__url__}"""
Expand Down Expand Up @@ -175,7 +175,7 @@
"capture_repr": ("_repr_html_",),
"compress_images": ("images", "thumbnails", "-o1"),
"only_warn_on_example_error": True, # keep the build going if an example fails, important for doc workflow
"parallel": -1, # number of jobs to use to build the gallery
"parallel": 1, # number of jobs to use to build the gallery
"write_computation_times": False, # do not write time to run example in the output
}

Expand Down
1 change: 0 additions & 1 deletion examples/demo_acd_tracking_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import lhc, matching, track
Expand Down
1 change: 0 additions & 1 deletion examples/demo_aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""

import matplotlib.pyplot as plt

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import lhc
Expand Down
3 changes: 1 addition & 2 deletions examples/demo_beam_enveloppe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# sphinx_gallery_thumbnail_number = 1
import matplotlib.pyplot as plt
import numpy as np

from cpymad.madx import Madx

from pyhdtoolkit.plotting.envelope import plot_beam_envelope
Expand All @@ -29,7 +28,7 @@
###############################################################################
# Define relevant constants.

pc_GeV = 19 # Beam momentum [GeV]
pc_GeV = 19 # Beam momentum [GeV] # noqa: N816
B_rho_Tm = pc_GeV / 0.3 # Magnetic rigidity [Tm]
E_0_GeV = 0.9382720813 # proton rest mass [GeV]
E_tot_GeV = np.sqrt(pc_GeV**2 + E_0_GeV**2)
Expand Down
8 changes: 4 additions & 4 deletions examples/demo_ir_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# sphinx_gallery_thumbnail_number = 1
import matplotlib.pyplot as plt
import numpy as np

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import lhc, matching
Expand All @@ -51,10 +50,11 @@

###############################################################################
# Importantly in ``MAD-X``, when dealing with RNG one should set a generator and
# seed, which we do below:
# seed, which we will do below. Make sure to respect numpy's RNG recommendations

madx.option(rand="best", randid=np.random.randint(1, 11)) # random number generator
madx.eoption(seed=np.random.randint(1, 999999999)) # not using default seed
rng = np.random.default_rng()
madx.option(rand="best", randid=rng.integers(1, 11)) # random number generator
madx.eoption(seed=rng.integers(1, 999999999)) # not using default seed

###############################################################################
# We can now install errors in the IR quadrupoles. Note that this function accepts
Expand Down
1 change: 0 additions & 1 deletion examples/demo_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

import matplotlib.pyplot as plt

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import lhc, matching
Expand Down
1 change: 0 additions & 1 deletion examples/demo_lhc_crossing_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

import matplotlib.pyplot as plt

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import lhc
Expand Down
1 change: 0 additions & 1 deletion examples/demo_lhc_rigid_waist_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import matplotlib.pyplot as plt
import numpy as np
import tfs

from cpymad.madx import Madx
from joblib import Parallel, delayed

Expand Down
1 change: 0 additions & 1 deletion examples/demo_lhc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

# sphinx_gallery_thumbnail_number = 4
import matplotlib.pyplot as plt

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import coupling, lhc, twiss
Expand Down
1 change: 0 additions & 1 deletion examples/demo_machine_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# sphinx_gallery_thumbnail_number = 2
import matplotlib.pyplot as plt

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools._generators import LatticeGenerator
Expand Down
1 change: 0 additions & 1 deletion examples/demo_phase_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# sphinx_gallery_thumbnail_number = 2
import matplotlib.pyplot as plt
import numpy as np

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools._generators import LatticeGenerator
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
[f"kqs.l{ip}b1" for ip in [2, 4, 6, 8]] + \
[f"kqs.a{sector}{sector+1 if sector < _MAX_SECTOR_VALUE else 1}b1" for sector in [2, 4, 6, 8]] + \
[f"kqs.r{ip}b2" for ip in [2, 4, 6, 8]] + \
[f"kqs.l" f"{ip}b2" for ip in [3, 5, 7, 1]] + \
[f"kqs.l{ip}b2" for ip in [3, 5, 7, 1]] + \
[f"kqs.a{sector}{sector+1 if sector < _MAX_SECTOR_VALUE else 1}b2" for sector in [1, 3, 5, 7]]
# fmt: on
LHC_KSF_KNOBS: list[str] = [ # sextupole correctors
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/cpymadtools/coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from typing import TYPE_CHECKING

import numpy as np

from loguru import logger
from optics_functions.coupling import check_resonance_relation, closest_tune_approach, coupling_via_cmatrix
from scipy import stats
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/lhc/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def reset_lhc_bump_flags(madx: Madx, /) -> None:
+ LHC_PARALLEL_SEPARATION_FLAGS
)
with madx.batch():
madx.globals.update({bump: 0 for bump in all_bumps})
madx.globals.update(dict.fromkeys(all_bumps, 0))


def get_lhc_tune_and_chroma_knobs(
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/cpymadtools/lhc/_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import numpy as np
import tfs

from loguru import logger

from pyhdtoolkit.cpymadtools.lhc._twiss import get_ir_twiss
Expand Down
2 changes: 0 additions & 2 deletions pyhdtoolkit/cpymadtools/ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from typing import TYPE_CHECKING

import tfs

from loguru import logger

from pyhdtoolkit.cpymadtools.utils import get_table_tfs
Expand All @@ -23,7 +22,6 @@
from collections.abc import Sequence

import pandas as pd

from cpymad.madx import Madx

_MAX_PTC_AMPDET_ORDER: int = 2
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/cpymadtools/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from collections.abc import Sequence

import pandas as pd

from cpymad.madx import Madx

# ----- Utlites ----- #
Expand Down
2 changes: 0 additions & 2 deletions pyhdtoolkit/cpymadtools/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@

import math
import sys

from pathlib import Path
from typing import TYPE_CHECKING

import matplotlib.collections
import matplotlib.patches
import numpy as np
import tfs

from loguru import logger

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/cpymadtools/twiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING

import tfs

from loguru import logger

from pyhdtoolkit.cpymadtools.constants import DEFAULT_TWISS_COLUMNS
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/cpymadtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import pandas as pd
import tfs

from loguru import logger

if TYPE_CHECKING:
Expand Down
2 changes: 0 additions & 2 deletions pyhdtoolkit/maths/stats_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
from __future__ import annotations

import warnings

from typing import TYPE_CHECKING

import matplotlib.pyplot as plt # noqa: F401 | if omitted, get AttributeError: module 'matplotlib' has no attribute 'axes'
import numpy as np
import pandas as pd
import scipy.stats as st

from loguru import logger

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/maths/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING

import numpy as np

from loguru import logger

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/optics/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""

import numpy as np

from scipy import constants

from pyhdtoolkit.models.beam import BeamParameters
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/plotting/aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from loguru import logger

from pyhdtoolkit.plotting.layout import plot_machine_layout
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/plotting/crossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING

import matplotlib.pyplot as plt

from loguru import logger

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion pyhdtoolkit/plotting/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING

import numpy as np

from loguru import logger

from pyhdtoolkit.plotting.utils import maybe_get_ax
Expand Down
3 changes: 1 addition & 2 deletions pyhdtoolkit/plotting/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING

import matplotlib.pyplot as plt

from loguru import logger

from pyhdtoolkit.plotting.layout import _ylim_from_input, plot_machine_layout
Expand Down Expand Up @@ -222,7 +221,7 @@ def plot_latwiss(
dispertion_axis.legend(loc=1)
dispertion_axis.set_ylabel("$D_{x,y}$ $[m]$", color="brown")
dispertion_axis.tick_params(axis="y", labelcolor="brown")
dispertion_axis.grid(False)
dispertion_axis.grid(visible=False)

if beta_ylim:
logger.debug("Setting ylim for betatron functions plot")
Expand Down
Loading
Loading