Skip to content

Commit

Permalink
CI: Pre-Commit isort (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxence Thevenet <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent 6ba8583 commit d237046
Show file tree
Hide file tree
Showing 28 changed files with 86 additions and 69 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ repos:

# Sorts Python imports according to PEP8
# https://www.python.org/dev/peps/pep-0008/#imports
#- repo: https://github.com/pycqa/isort
# rev: 5.12.0
# hooks:
# - id: isort
# name: isort (python)
# args: ['--profile black']
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]

# Python: Flake8 (checks only, does this support auto-fixes?)
#- repo: https://github.com/PyCQA/flake8
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import sys
from datetime import date

from lasy import __version__

sys.path.insert(0, os.path.abspath("../.."))
Expand Down
11 changes: 6 additions & 5 deletions examples/example_gerchberg_saxton_algo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.laser import Laser
from lasy.utils.phase_retrieval import gerchberg_saxton_algo
import copy

import matplotlib.pyplot as plt
import numpy as np
from lasy.utils.zernike import zernike
import copy
from mpl_toolkits.axes_grid1 import make_axes_locatable

from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.utils.phase_retrieval import gerchberg_saxton_algo
from lasy.utils.zernike import zernike

# DEFINE PHYSICAL PARAMETERS & CREATE LASER PROFILE
wavelength = 800e-9
Expand Down
18 changes: 8 additions & 10 deletions examples/example_modal_decomposition_data.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import matplotlib.pyplot as plt
import numpy as np
import skimage
from mpl_toolkits.axes_grid1 import make_axes_locatable

from lasy.profiles.transverse.transverse_profile_from_data import (
TransverseProfileFromData,
)
from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile
from lasy.profiles.longitudinal.gaussian_profile import GaussianLongitudinalProfile
from lasy.profiles.transverse.hermite_gaussian_profile import (
HermiteGaussianTransverseProfile,
)
from lasy.profiles.longitudinal.gaussian_profile import GaussianLongitudinalProfile
from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile
from lasy.profiles.transverse.transverse_profile_from_data import (
TransverseProfileFromData,
)
from lasy.utils.mode_decomposition import hermite_gauss_decomposition

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import skimage


# Define the transverse profile of the laser pulse
img_url = "https://user-images.githubusercontent.com/27694869/228038930-d6ab03b1-a726-4b41-a378-5f4a83dc3778.png"
intensityData = skimage.io.imread(img_url)
Expand Down
3 changes: 1 addition & 2 deletions lasy/laser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from scipy.constants import c

from axiprop.lib import PropagatorFFT2, PropagatorResampling
from scipy.constants import c

from lasy.utils.grid import Grid
from lasy.utils.laser_utils import (
Expand Down
3 changes: 2 additions & 1 deletion lasy/optical_elements/parabolic_mirror.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .optical_element import OpticalElement
import numpy as np
from scipy.constants import c

from .optical_element import OpticalElement


class ParabolicMirror(OpticalElement):
r"""
Expand Down
4 changes: 2 additions & 2 deletions lasy/profiles/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .combined_profile import CombinedLongitudinalTransverseProfile
from .gaussian_profile import GaussianProfile
from .from_array_profile import FromArrayProfile
from .from_openpmd_profile import FromOpenPMDProfile
from .from_insight_file import FromInsightFile
from .from_openpmd_profile import FromOpenPMDProfile
from .gaussian_profile import GaussianProfile
from .speckle_profile import SpeckleProfile

__all__ = [
Expand Down
3 changes: 2 additions & 1 deletion lasy/profiles/from_array_profile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from scipy.interpolate import RegularGridInterpolator
import numpy as np
from scipy.interpolate import RegularGridInterpolator

from .profile import Profile


Expand Down
3 changes: 2 additions & 1 deletion lasy/profiles/from_insight_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import h5py
import numpy as np
from scipy.constants import c

from .from_array_profile import FromArrayProfile


Expand Down
8 changes: 5 additions & 3 deletions lasy/profiles/from_openpmd_profile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import numpy as np
from scipy.constants import c
import openpmd_api as io
from openpmd_viewer import OpenPMDTimeSeries
from .from_array_profile import FromArrayProfile
from lasy.utils.laser_utils import field_to_envelope, create_grid
from scipy.constants import c

from lasy.utils.laser_utils import create_grid, field_to_envelope
from lasy.utils.openpmd_input import reorder_array

from .from_array_profile import FromArrayProfile


class FromOpenPMDProfile(FromArrayProfile):
r"""
Expand Down
4 changes: 2 additions & 2 deletions lasy/profiles/longitudinal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .cosine_profile import CosineLongitudinalProfile
from .gaussian_profile import GaussianLongitudinalProfile
from .super_gaussian_profile import SuperGaussianLongitudinalProfile
from .longitudinal_profile_from_data import LongitudinalProfileFromData
from .longitudinal_profile import LongitudinalProfile
from .longitudinal_profile_from_data import LongitudinalProfileFromData
from .super_gaussian_profile import SuperGaussianLongitudinalProfile

__all__ = [
"CosineLongitudinalProfile",
Expand Down
8 changes: 4 additions & 4 deletions lasy/profiles/transverse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from .gaussian_profile import GaussianTransverseProfile
from .hermite_gaussian_profile import HermiteGaussianTransverseProfile
from .jinc_profile import JincTransverseProfile
from .laguerre_gaussian_profile import LaguerreGaussianTransverseProfile
from .super_gaussian_profile import SuperGaussianTransverseProfile
from .jinc_profile import JincTransverseProfile
from .transverse_profile_from_data import TransverseProfileFromData
from .transverse_profile import (
TransverseProfile,
SummedTransverseProfile,
ScaledTransverseProfile,
SummedTransverseProfile,
TransverseProfile,
)
from .transverse_profile_from_data import TransverseProfileFromData

__all__ = [
"GaussianTransverseProfile",
Expand Down
3 changes: 2 additions & 1 deletion lasy/profiles/transverse/hermite_gaussian_profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from math import factorial

import numpy as np
from scipy.special import hermite
from math import factorial

from .transverse_profile import TransverseProfile

Expand Down
1 change: 1 addition & 0 deletions lasy/profiles/transverse/jinc_profile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import scipy.special as scispe

from .transverse_profile import TransverseProfile


Expand Down
2 changes: 2 additions & 0 deletions lasy/profiles/transverse/transverse_profile_from_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
from scipy.interpolate import RegularGridInterpolator

from lasy.utils.exp_data_utils import find_center_of_mass

from .transverse_profile import TransverseProfile


Expand Down
7 changes: 4 additions & 3 deletions lasy/utils/laser_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import numpy as np
from scipy.constants import c, epsilon_0, e, m_e
from axiprop.containers import ScalarFieldEnvelope
from axiprop.lib import PropagatorFFT2, PropagatorResampling
from scipy.constants import c, e, epsilon_0, m_e
from scipy.interpolate import interp1d
from scipy.signal import hilbert
from axiprop.lib import PropagatorFFT2, PropagatorResampling
from axiprop.containers import ScalarFieldEnvelope

from .grid import Grid


Expand Down
13 changes: 7 additions & 6 deletions lasy/utils/mode_decomposition.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import math

import numpy as np

from lasy.profiles.transverse.hermite_gaussian_profile import (
HermiteGaussianTransverseProfile,
)
from lasy.profiles.transverse.transverse_profile import TransverseProfile
from lasy.profiles.transverse.transverse_profile_from_data import (
TransverseProfileFromData,
)
from lasy.profiles.transverse.hermite_gaussian_profile import (
HermiteGaussianTransverseProfile,
)
from lasy.utils.exp_data_utils import find_d4sigma

import numpy as np
import math


def hermite_gauss_decomposition(laserProfile, n_x_max=12, n_y_max=12, res=1e-6):
"""
Expand Down
4 changes: 3 additions & 1 deletion lasy/utils/openpmd_output.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np
import openpmd_api as io
from scipy.constants import c
from .laser_utils import field_to_vector_potential

from lasy import __version__ as lasy_version

from .laser_utils import field_to_vector_potential


def write_to_openpmd_file(
dim, file_prefix, file_format, grid, wavelength, pol, save_as_vector_potential=False
Expand Down
1 change: 1 addition & 0 deletions lasy/utils/phase_retrieval.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy

import numpy as np


Expand Down
3 changes: 2 additions & 1 deletion lasy/utils/zernike.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import math

import numpy as np


def get_zernike_nm(j):
"""
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from setuptools import find_packages, setup

import lasy # In order to extract the version number

# README file is long description
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gaussian_propagator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

import numpy as np
import pytest

import numpy as np
from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile

Expand Down
7 changes: 4 additions & 3 deletions tests/test_gsalgo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-

import pytest
import copy

import numpy as np
import pytest

from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.utils.zernike import zernike
from lasy.utils.phase_retrieval import gerchberg_saxton_algo
import copy
from lasy.utils.zernike import zernike

w0 = 25.0e-6 # m

Expand Down
18 changes: 9 additions & 9 deletions tests/test_laser_profiles.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# -*- coding: utf-8 -*-

import pytest
import numpy as np
import pytest
from scipy.constants import c

from lasy.laser import Laser
from lasy.profiles.profile import Profile, SummedProfile, ScaledProfile
from lasy.profiles import GaussianProfile, FromArrayProfile, SpeckleProfile
from lasy.profiles import FromArrayProfile, GaussianProfile, SpeckleProfile
from lasy.profiles.longitudinal import (
CosineLongitudinalProfile,
GaussianLongitudinalProfile,
SuperGaussianLongitudinalProfile,
CosineLongitudinalProfile,
)
from lasy.profiles.profile import Profile, ScaledProfile, SummedProfile
from lasy.profiles.transverse import (
GaussianTransverseProfile,
LaguerreGaussianTransverseProfile,
SuperGaussianTransverseProfile,
HermiteGaussianTransverseProfile,
JincTransverseProfile,
TransverseProfileFromData,
TransverseProfile,
SummedTransverseProfile,
LaguerreGaussianTransverseProfile,
ScaledTransverseProfile,
SummedTransverseProfile,
SuperGaussianTransverseProfile,
TransverseProfile,
TransverseProfileFromData,
)
from lasy.utils.exp_data_utils import find_center_of_mass

Expand Down
2 changes: 1 addition & 1 deletion tests/test_laser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.utils.laser_utils import get_spectrum, compute_laser_energy, get_duration
from lasy.utils.laser_utils import compute_laser_energy, get_duration, get_spectrum


def get_gaussian_profile():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_parabolic_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"""

import numpy as np

from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.optical_elements import ParabolicMirror
from lasy.profiles.gaussian_profile import GaussianProfile

wavelength = 0.8e-6
w0 = 5.0e-3 # m, initialized in near field
Expand Down
4 changes: 2 additions & 2 deletions tests/test_speckles.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
import pytest
from scipy.constants import c

np.random.seed(0) # Fix random seed for reproducibility

from lasy.laser import Laser
from lasy.profiles.speckle_profile import SpeckleProfile
import pytest
from scipy.constants import c


@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_t2z2t.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-

import numpy as np
import pytest
from scipy.constants import c

import numpy as np
from lasy.laser import Laser
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.utils.laser_utils import import_from_z, export_to_z
from scipy.constants import c
from lasy.utils.laser_utils import export_to_z, import_from_z


@pytest.fixture(scope="function")
Expand Down

0 comments on commit d237046

Please sign in to comment.