Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent 8d96f0e commit db30005
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions lasy/profiles/longitudinal/longitudinal_profile_from_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def __init__(self, data, lo, hi):
spectral_intensity = (
data["intensity"] * 2.0 * np.pi * c / wavelength**2
) # Convert spectral data
assert np.all(np.diff(wavelength) > 0) or np.all(
np.diff(wavelength) < 0
), 'data["axis"] must be in monotonically increasing or decreasing order.'
assert np.all(np.diff(wavelength) > 0) or np.all(np.diff(wavelength) < 0), (
'data["axis"] must be in monotonically increasing or decreasing order.'
)
if data.get("phase") is None:
spectral_phase = np.zeros_like(wavelength)
else:
Expand Down
18 changes: 9 additions & 9 deletions lasy/profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ class SummedProfile(Profile):
def __init__(self, *profiles):
"""Initialize the summed profile."""
# Check that all profiles are Profile objects
assert all(
[isinstance(p, Profile) for p in profiles]
), "All summands must be Profile objects."
assert all([isinstance(p, Profile) for p in profiles]), (
"All summands must be Profile objects."
)
self.profiles = profiles
# Get the wavelength values from each profile
lambda0s = [p.lambda0 for p in self.profiles]
pols = [p.pol for p in self.profiles]
# Check that all wavelengths are the same
assert np.allclose(
lambda0s, lambda0s[0]
), "Added profiles must have the same wavelength."
assert np.allclose(lambda0s, lambda0s[0]), (
"Added profiles must have the same wavelength."
)
lambda0 = profiles[0].lambda0
# Check that all polarizations are the same
assert np.allclose(
pols, pols[0]
), "Added profiles must have the same polarization."
assert np.allclose(pols, pols[0]), (
"Added profiles must have the same polarization."
)
pol = profiles[0].pol
# Initialize the parent class
super().__init__(lambda0, pol)
Expand Down
18 changes: 9 additions & 9 deletions lasy/profiles/speckle_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ def __init__(
assert relative_laser_bandwidth > 0, "laser_bandwidth must be greater than 0"
assert np.size(n_beamlets) == 2, "has to be a size 2 array"
if "SSD" in self.temporal_smoothing_type.upper():
assert (
ssd_number_color_cycles is not None
), "must supply `ssd_number_color_cycles` to use SSD"
assert (
ssd_transverse_bandwidth_distribution is not None
), "must supply `ssd_transverse_bandwidth_distribution` to use SSD"
assert (
ssd_phase_modulation_amplitude is not None
), "must supply `ssd_phase_modulation_amplitude` to use SSD"
assert ssd_number_color_cycles is not None, (
"must supply `ssd_number_color_cycles` to use SSD"
)
assert ssd_transverse_bandwidth_distribution is not None, (
"must supply `ssd_transverse_bandwidth_distribution` to use SSD"
)
assert ssd_phase_modulation_amplitude is not None, (
"must supply `ssd_phase_modulation_amplitude` to use SSD"
)
for q in (
ssd_number_color_cycles,
ssd_transverse_bandwidth_distribution,
Expand Down
6 changes: 3 additions & 3 deletions lasy/profiles/transverse/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def __init__(self, w0, wavelength=None, z_foc=0):
if z_foc == 0:
self.z_foc_over_zr = 0
else:
assert (
wavelength is not None
), "You need to pass the wavelength, when `z_foc` is non-zero."
assert wavelength is not None, (
"You need to pass the wavelength, when `z_foc` is non-zero."
)
self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2)

def _evaluate(self, x, y):
Expand Down
12 changes: 6 additions & 6 deletions lasy/profiles/transverse/transverse_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def __init__(self, *transverse_profiles):
"""Initialize the summed profile."""
TransverseProfile.__init__(self)
# Check that all transverse_profiles are TransverseProfile objects
assert all(
[isinstance(tp, TransverseProfile) for tp in transverse_profiles]
), "All summands must be Profile objects."
assert all([isinstance(tp, TransverseProfile) for tp in transverse_profiles]), (
"All summands must be Profile objects."
)
self.transverse_profiles = transverse_profiles

def evaluate(self, x, y):
Expand Down Expand Up @@ -137,9 +137,9 @@ def __init__(self, transverse_profile, factor):
# Check that the factor is a number
assert isinstance(factor, (int, float, complex)), "The factor must be a number."
# Check that the profile is a Profile object
assert isinstance(
transverse_profile, TransverseProfile
), "The profile must be a TransverseProfile object."
assert isinstance(transverse_profile, TransverseProfile), (
"The profile must be a TransverseProfile object."
)
self.transverse_profile = transverse_profile
self.factor = factor

Expand Down
6 changes: 3 additions & 3 deletions lasy/utils/laser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ def create_grid(array, axes, dim, is_envelope=True):
grid = Grid(dim, lo, hi, npoints, n_azimuthal_modes=1, is_envelope=is_envelope)
assert np.all(grid.axes[0] == axes["r"])
assert np.allclose(grid.axes[1], axes["t"], rtol=1.0e-14)
assert (
array.ndim == 3
), "Input array should be of dimension 3 [modes, radius, time]"
assert array.ndim == 3, (
"Input array should be of dimension 3 [modes, radius, time]"
)
grid.set_temporal_field(array)
return grid

Expand Down
6 changes: 3 additions & 3 deletions lasy/utils/mode_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def hermite_gauss_decomposition(
It is computed as the waist for which the weight of order 0 is maximum.
"""
# Check if the provided laserProfile is a transverse profile.
assert isinstance(
laserProfile, TransverseProfile
), "laserProfile must be an instance of TransverseProfile"
assert isinstance(laserProfile, TransverseProfile), (
"laserProfile must be an instance of TransverseProfile"
)

# Get the field, sensible spatial bounds for the profile
lo0 = lo[0] + laserProfile.x_offset
Expand Down

0 comments on commit db30005

Please sign in to comment.