Skip to content

Commit

Permalink
fix implicit optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Aug 12, 2024
1 parent 1abe24d commit 0ba7f80
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 88 deletions.
14 changes: 7 additions & 7 deletions pyhdtoolkit/cpymadtools/coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
def get_closest_tune_approach(
madx: Madx,
/,
accelerator: str = None,
sequence: str = None,
varied_knobs: Sequence[str] = None,
accelerator: str | None = None,
sequence: str | None = None,
varied_knobs: Sequence[str] | None = None,
telescopic_squeeze: bool = True,
run3: bool = False,
explicit_targets: tuple[float, float] = None,
explicit_targets: tuple[float, float] | None = None,
step: float = 1e-7,
calls: int = 100,
tolerance: float = 1e-21,
Expand Down Expand Up @@ -146,8 +146,8 @@ def get_cminus_from_coupling_rdts(
/,
patterns: Sequence[str] = [""],
method: str = "teapot",
qx: float = None,
qy: float = None,
qx: float | None = None,
qy: float | None = None,
filtering: float = 0,
) -> float:
"""
Expand Down Expand Up @@ -232,7 +232,7 @@ def get_cminus_from_coupling_rdts(


def match_no_coupling_through_ripkens(
madx: Madx, /, sequence: str = None, location: str = None, vary_knobs: Sequence[str] = None
madx: Madx, /, sequence: str | None = None, location: str | None = None, vary_knobs: Sequence[str] | None = None
) -> None:
"""
.. versionadded:: 0.16.0
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 @@ -169,7 +169,7 @@ def get_lhc_bpms_list(madx: Madx, /) -> list[str]:


def get_sizes_at_ip(
madx: Madx, /, ip: int, geom_emit_x: float = None, geom_emit_y: float = None
madx: Madx, /, ip: int, geom_emit_x: float | None = None, geom_emit_y: float | None = None
) -> tuple[float, float]:
"""
.. versionadded:: 1.0.0
Expand Down
6 changes: 3 additions & 3 deletions pyhdtoolkit/cpymadtools/lhc/_powering.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from loguru import logger


def apply_lhc_colinearity_knob(madx: Madx, /, colinearity_knob_value: float = 0, ir: int = None) -> None:
def apply_lhc_colinearity_knob(madx: Madx, /, colinearity_knob_value: float = 0, ir: int | None = None) -> None:
"""
.. versionadded:: 0.15.0
Expand Down Expand Up @@ -49,7 +49,7 @@ def apply_lhc_colinearity_knob(madx: Madx, /, colinearity_knob_value: float = 0,
logger.debug(f"Set '{left_knob}' to {madx.globals[left_knob]}")


def apply_lhc_colinearity_knob_delta(madx: Madx, /, colinearity_knob_delta: float = 0, ir: int = None) -> None:
def apply_lhc_colinearity_knob_delta(madx: Madx, /, colinearity_knob_delta: float = 0, ir: int | None = None) -> None:
"""
.. versionadded:: 0.21.0
Expand Down Expand Up @@ -89,7 +89,7 @@ def apply_lhc_colinearity_knob_delta(madx: Madx, /, colinearity_knob_delta: floa


def apply_lhc_rigidity_waist_shift_knob(
madx: Madx, /, rigidty_waist_shift_value: float = 0, ir: int = None, side: str = "left"
madx: Madx, /, rigidty_waist_shift_value: float = 0, ir: int | None = None, side: str = "left"
) -> None:
"""
.. versionadded:: 0.15.0
Expand Down
4 changes: 2 additions & 2 deletions pyhdtoolkit/cpymadtools/lhc/_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


def get_magnets_powering(
madx: Madx, /, patterns: Sequence[str] = [r"^mb\.", r"^mq\.", r"^ms\."], brho: str | float = None, **kwargs
madx: Madx, /, patterns: Sequence[str] = [r"^mb\.", r"^mq\.", r"^ms\."], brho: str | float | None = None, **kwargs
) -> tfs.TfsDataFrame:
r"""
.. versionadded:: 0.17.0
Expand Down Expand Up @@ -218,7 +218,7 @@ def get_current_orbit_setup(madx: Madx, /) -> dict[str, float]:
# ----- Helpers ----- #


def _list_field_currents(madx: Madx, /, brho: str | float = None) -> None:
def _list_field_currents(madx: Madx, /, brho: str | float | None = None) -> None:
"""
Creates additional columns for the ``TWISS`` table with the magnets' total fields
and currents, to help later on determine which proportion of their maximum powering
Expand Down
8 changes: 4 additions & 4 deletions pyhdtoolkit/cpymadtools/lhc/_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def prepare_lhc_run2(
opticsfile: str, beam: int = 1, use_b4: bool = False, energy: float = 6500, slicefactor: int = None, **kwargs
opticsfile: str, beam: int = 1, use_b4: bool = False, energy: float = 6500, slicefactor: int | None = None, **kwargs
) -> Madx:
"""
.. versionadded:: 1.0.0
Expand Down Expand Up @@ -96,7 +96,7 @@ def _run2_sequence_from_opticsfile(opticsfile: Path, use_b4: bool = False) -> Pa


def prepare_lhc_run3(
opticsfile: str, beam: int = 1, use_b4: bool = False, energy: float = 6800, slicefactor: int = None, **kwargs
opticsfile: str, beam: int = 1, use_b4: bool = False, energy: float = 6800, slicefactor: int | None = None, **kwargs
) -> Madx:
"""
.. versionadded:: 1.0.0
Expand Down Expand Up @@ -228,11 +228,11 @@ class LHCSetup:
def __init__(
self,
run: int = 3,
opticsfile: str = None,
opticsfile: str | None = None,
beam: int = 1,
use_b4: bool = False,
energy: float = 6800,
slicefactor: int = None,
slicefactor: int | None = None,
**kwargs,
):
assert opticsfile is not None, "An opticsfile must be provided"
Expand Down
28 changes: 14 additions & 14 deletions pyhdtoolkit/cpymadtools/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
def match_tunes_and_chromaticities(
madx: Madx,
/,
accelerator: str = None,
accelerator: str | None = None,
sequence: str | None = None,
q1_target: float = None,
q2_target: float = None,
dq1_target: float = None,
dq2_target: float = None,
varied_knobs: Sequence[str] = None,
q1_target: float | None = None,
q2_target: float | None = None,
dq1_target: float | None = None,
dq2_target: float | None = None,
varied_knobs: Sequence[str] | None = None,
telescopic_squeeze: bool = True,
run3: bool = False,
step: float = 1e-7,
Expand Down Expand Up @@ -192,11 +192,11 @@ def match(*args, **kwargs):
def match_tunes(
madx: Madx,
/,
accelerator: str = None,
accelerator: str | None = None,
sequence: str | None = None,
q1_target: float = None,
q2_target: float = None,
varied_knobs: Sequence[str] = None,
q1_target: float | None = None,
q2_target: float | None = None,
varied_knobs: Sequence[str] | None = None,
telescopic_squeeze: bool = True,
run3: bool = False,
step: float = 1e-7,
Expand Down Expand Up @@ -294,11 +294,11 @@ def match_tunes(
def match_chromaticities(
madx: Madx,
/,
accelerator: str = None,
accelerator: str | None = None,
sequence: str | None = None,
dq1_target: float = None,
dq2_target: float = None,
varied_knobs: Sequence[str] = None,
dq1_target: float | None = None,
dq2_target: float | None = None,
varied_knobs: Sequence[str] | None = None,
telescopic_squeeze: bool = True,
run3: bool = False,
step: float = 1e-7,
Expand Down
8 changes: 4 additions & 4 deletions pyhdtoolkit/cpymadtools/ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def get_amplitude_detuning(
madx: Madx, /, order: int = 2, file: Path | str = None, fringe: bool = False, **kwargs
madx: Madx, /, order: int = 2, file: Path | str | None = None, fringe: bool = False, **kwargs
) -> tfs.TfsDataFrame:
"""
.. versionadded:: 0.7.0
Expand Down Expand Up @@ -143,7 +143,7 @@ def get_amplitude_detuning(


def get_rdts(
madx: Madx, /, order: int = 4, file: Path | str = None, fringe: bool = False, **kwargs
madx: Madx, /, order: int = 4, file: Path | str | None = None, fringe: bool = False, **kwargs
) -> tfs.TfsDataFrame:
"""
.. versionadded:: 0.7.0
Expand Down Expand Up @@ -238,7 +238,7 @@ def ptc_twiss(
madx: Madx,
/,
order: int = 4,
file: Path | str = None,
file: Path | str | None = None,
fringe: bool = False,
table: str = "ptc_twiss",
**kwargs,
Expand Down Expand Up @@ -343,7 +343,7 @@ def ptc_track_particle(
initial_coordinates: tuple[float, float, float, float, float, float],
nturns: int,
sequence: str | None = None,
observation_points: Sequence[str] = None,
observation_points: Sequence[str] | None = None,
onetable: bool = False,
fringe: bool = False,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def track_single_particle(
initial_coordinates: tuple[float, float, float, float, float, float],
nturns: int,
sequence: str | None = None,
observation_points: Sequence[str] = None,
observation_points: Sequence[str] | None = None,
**kwargs,
) -> dict[str, pd.DataFrame]:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def make_footprint_table(
madx: Madx, /, sigma: float = 5, dense: bool = False, file: str = None, cleanup: bool = True, **kwargs
madx: Madx, /, sigma: float = 5, dense: bool = False, file: str | None = None, cleanup: bool = True, **kwargs
) -> tfs.TfsDataFrame:
"""
.. versionadded:: 0.9.0
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/twiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def get_pattern_twiss(
madx: Madx,
/,
columns: Sequence[str] = None,
columns: Sequence[str] | None = None,
patterns: Sequence[str] = [""],
**kwargs,
) -> tfs.TfsDataFrame:
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/cpymadtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def export_madx_table(
/,
table_name: str,
file_name: Path | str,
pattern: str = None,
pattern: str | None = None,
headers_table: str = "SUMM",
**kwargs,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/maths/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_magnitude(value: float) -> int:


def get_scaled_values_and_magnitude_string(
values_array: pd.DataFrame | np.ndarray, force_magnitude: float = None
values_array: pd.DataFrame | np.ndarray, force_magnitude: float | None = None
) -> tuple[pd.DataFrame | np.ndarray, str]:
"""
.. versionadded:: 0.8.2
Expand Down
18 changes: 9 additions & 9 deletions pyhdtoolkit/plotting/aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ def plot_aperture(
/,
title: str | None = None,
xoffset: float = 0,
xlimits: tuple[float, float] = None,
xlimits: tuple[float, float] | None = None,
plot_dipoles: bool = True,
plot_dipole_k1: bool = False,
plot_quadrupoles: bool = True,
plot_bpms: bool = False,
aperture_ylim: tuple[float, float] = None,
k0l_lim: tuple[float, float] | float = None,
k1l_lim: tuple[float, float] | float = None,
k2l_lim: tuple[float, float] | float = None,
k3l_lim: tuple[float, float] | float = None,
color: str = None,
aperture_ylim: tuple[float, float] | None = None,
k0l_lim: tuple[float, float] | float | None = None,
k1l_lim: tuple[float, float] | float | None = None,
k2l_lim: tuple[float, float] | float | None = None,
k3l_lim: tuple[float, float] | float | None = None,
color: str | None = None,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -191,7 +191,7 @@ def plot_physical_apertures(
plane: str,
scale: float = 1,
xoffset: float = 0,
xlimits: tuple[float, float] = None,
xlimits: tuple[float, float] | None = None,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -279,7 +279,7 @@ def plot_physical_apertures(


def _get_positions_and_real_apertures(
madx, /, plane: str, xoffset: float = 0, xlimits: tuple[float, float] = None, **kwargs
madx, /, plane: str, xoffset: float = 0, xlimits: tuple[float, float] | None = None, **kwargs
) -> tuple[np.ndarray, np.ndarray]:
"""
.. versionadded:: 1.2.0
Expand Down
6 changes: 3 additions & 3 deletions pyhdtoolkit/plotting/crossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def plot_single_ir_crossing(
plot_df_b2: pd.DataFrame,
plot_column: str,
scaling: float = 1,
ylabel: str = None,
xlabel: str = None,
title: str = None,
ylabel: str | None = None,
xlabel: str | None = None,
title: str | None = None,
) -> None:
"""
.. versionadded:: 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion pyhdtoolkit/plotting/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def plot_beam_envelope(
nsigma: float = 1,
scale: float = 1,
xoffset: float = 0,
xlimits: tuple[float, float] = None,
xlimits: tuple[float, float] | None = None,
**kwargs,
) -> None:
"""
Expand Down
16 changes: 8 additions & 8 deletions pyhdtoolkit/plotting/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ def plot_latwiss(
/,
title: str | None = None,
xoffset: float = 0,
xlimits: tuple[float, float] = None,
xlimits: tuple[float, float] | None = None,
plot_dipoles: bool = True,
plot_dipole_k1: bool = False,
plot_quadrupoles: bool = True,
plot_bpms: bool = False,
disp_ylim: tuple[float, float] | float = None,
beta_ylim: tuple[float, float] | float = None,
k0l_lim: tuple[float, float] | float = None,
k1l_lim: tuple[float, float] | float = None,
k2l_lim: tuple[float, float] | float = None,
k3l_lim: tuple[float, float] | float = None,
disp_ylim: tuple[float, float] | float | None = None,
beta_ylim: tuple[float, float] | float | None = None,
k0l_lim: tuple[float, float] | float | None = None,
k1l_lim: tuple[float, float] | float | None = None,
k2l_lim: tuple[float, float] | float | None = None,
k3l_lim: tuple[float, float] | float | None = None,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -199,7 +199,7 @@ def plot_latwiss(
def plot_machine_survey(
madx: Madx,
/,
title: str = None,
title: str | None = None,
show_elements: bool = False,
high_orders: bool = False,
**kwargs,
Expand Down
12 changes: 6 additions & 6 deletions pyhdtoolkit/plotting/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
def plot_machine_layout(
madx: Madx,
/,
title: str = None,
title: str | None = None,
xoffset: float = 0,
xlimits: tuple[float, float] = None,
xlimits: tuple[float, float] | None = None,
plot_dipoles: bool = True,
plot_dipole_k1: bool = False,
plot_quadrupoles: bool = True,
plot_bpms: bool = False,
k0l_lim: tuple[float, float] | float = None,
k1l_lim: tuple[float, float] | float = None,
k2l_lim: tuple[float, float] | float = None,
k3l_lim: tuple[float, float] | float = None,
k0l_lim: tuple[float, float] | float | None = None,
k1l_lim: tuple[float, float] | float | None = None,
k2l_lim: tuple[float, float] | float | None = None,
k3l_lim: tuple[float, float] | float | None = None,
**kwargs,
) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions pyhdtoolkit/plotting/phasespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def plot_courant_snyder_phase_space(
u_coordinates: np.ndarray,
pu_coordinates: np.ndarray,
plane: str = "Horizontal",
title: str = None,
title: str | None = None,
**kwargs,
) -> matplotlib.axes.Axes:
"""
Expand Down Expand Up @@ -94,7 +94,7 @@ def plot_courant_snyder_phase_space_colored(
u_coordinates: np.ndarray,
pu_coordinates: np.ndarray,
plane: str = "Horizontal",
title: str = None,
title: str | None = None,
**kwargs,
) -> matplotlib.figure.Figure:
"""
Expand Down
Loading

0 comments on commit 0ba7f80

Please sign in to comment.