From 8d96f0e9f45f67a54848128496a885fbc55ed81e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:18:54 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.3 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.3...v0.9.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 600b90be..4d41bd64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,7 +56,7 @@ repos: # Python: Ruff linter & formatter # https://docs.astral.sh/ruff/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.3 + rev: v0.9.1 hooks: # Run the linter - id: ruff From db300055842b731376d009a858ae2d2f3ff08d35 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:19:01 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../longitudinal_profile_from_data.py | 6 +++--- lasy/profiles/profile.py | 18 +++++++++--------- lasy/profiles/speckle_profile.py | 18 +++++++++--------- lasy/profiles/transverse/gaussian_profile.py | 6 +++--- lasy/profiles/transverse/transverse_profile.py | 12 ++++++------ lasy/utils/laser_utils.py | 6 +++--- lasy/utils/mode_decomposition.py | 6 +++--- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lasy/profiles/longitudinal/longitudinal_profile_from_data.py b/lasy/profiles/longitudinal/longitudinal_profile_from_data.py index d987ee69..53878c8d 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile_from_data.py +++ b/lasy/profiles/longitudinal/longitudinal_profile_from_data.py @@ -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: diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index f8d28bac..16230e68 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -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) diff --git a/lasy/profiles/speckle_profile.py b/lasy/profiles/speckle_profile.py index da2bba3d..d05a864d 100644 --- a/lasy/profiles/speckle_profile.py +++ b/lasy/profiles/speckle_profile.py @@ -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, diff --git a/lasy/profiles/transverse/gaussian_profile.py b/lasy/profiles/transverse/gaussian_profile.py index 9905f2ca..f3f57ce0 100644 --- a/lasy/profiles/transverse/gaussian_profile.py +++ b/lasy/profiles/transverse/gaussian_profile.py @@ -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): diff --git a/lasy/profiles/transverse/transverse_profile.py b/lasy/profiles/transverse/transverse_profile.py index e133032b..d86d3464 100644 --- a/lasy/profiles/transverse/transverse_profile.py +++ b/lasy/profiles/transverse/transverse_profile.py @@ -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): @@ -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 diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 53204436..bf3d46c1 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -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 diff --git a/lasy/utils/mode_decomposition.py b/lasy/utils/mode_decomposition.py index d61324c3..a92f0e20 100644 --- a/lasy/utils/mode_decomposition.py +++ b/lasy/utils/mode_decomposition.py @@ -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