benvial/gyptis

View on GitHub

Showing 161 of 211 total issues

Function read_mesh_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def read_mesh_info(self):
        if self.dim == 1:
            marker_dim = "line"
            sub_dim = "curves"
            marker_dim_minus_1 = "point"
Severity: Minor
Found in src/gyptis/geometry/geometry.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in src/gyptis/optimize.py - About 1 hr to fix

    Function _get_effective_coeff has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_effective_coeff(self, case, scalar=False):
            self.solve_param(case, scalar=scalar)
            xi = self.formulation.xi.as_subdomain()
            if xi.real.ufl_shape == (2, 2):
                if scalar:
    Severity: Minor
    Found in src/gyptis/models/twoscale2d.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function eigensolve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def eigensolve(
            self,
            n_eig=6,
            wavevector_target=0.0,
            tol=1e-6,
    Severity: Minor
    Found in src/gyptis/models/simulation.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _weak has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _weak(self, u, v, u1):
            xi = self.xi.as_subdomain()
            chi = self.chi.as_subdomain()
    
            xi_dict = self.xi.as_property()
    Severity: Minor
    Found in src/gyptis/formulations/maxwell2d.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _make_constant_property_3d has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _make_constant_property_3d(prop, inv=False, real=False):
        new_prop = {}
        for d, p in prop.items():
            lenp = _check_len(p)
            if lenp > 0:
    Severity: Minor
    Found in src/gyptis/materials.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_T_matrix_coeff has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_T_matrix_coeff(
            self,
            p0,
            p1,
            source_type,
    Severity: Minor
    Found in src/gyptis/models/scattering3d.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function solve has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def solve(thicknesses, eps, mu, lambda0, theta0, phi0, psi0):
        k0 = 2 * pi / lambda0
        omega = k0 * c
    
        alpha0 = -k0 * np.sin(theta0) * np.cos(phi0)
    Severity: Minor
    Found in src/gyptis/sources/stack.py - About 1 hr to fix

      Function _topopt_wrapper has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _topopt_wrapper(
      Severity: Major
      Found in src/gyptis/optimize.py - About 1 hr to fix

        Function u has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def u(x, n, m, y=None):
            y = y or sqrt_safe(1 - x**2)
            if m < 0:
                return (-1) ** (-m + 1) * u(x, n, -m)
            elif m == 0:
        Severity: Minor
        Found in src/gyptis/sources/spharm.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function tensor_const has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def tensor_const(T, dim=3, real=False, const=True):
            if dim not in (2, 3):
                raise NotImplementedError("only supports dim = 2 or 3")
        
            def _treal(T):
        Severity: Minor
        Found in src/gyptis/materials.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function get_periodic_bnds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_periodic_bnds(self):
                # define lines equations
                def _is_on_line(p, p1, p2):
                    x, y = p
                    x1, y1 = p1
        Severity: Minor
        Found in src/gyptis/geometry/phc2d.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function compute_absorption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def compute_absorption(self, subdomain_absorption=False):
                P0 = (
                    self.period[0]
                    * self.period[1]
                    * (epsilon_0 / mu_0) ** 0.5
        Severity: Minor
        Found in src/gyptis/models/grating3d.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function __init__ has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                box_size=(1, 1),
                box_center=(0, 0),
                pml_width=(0.2, 0.2),
        Severity: Minor
        Found in src/gyptis/geometry/scattering2d.py - About 1 hr to fix

          Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in src/gyptis/models/scattering3d.py - About 1 hr to fix

            Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Major
            Found in src/gyptis/models/grating2d.py - About 1 hr to fix

              Function __init__ has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def __init__(
                      self,
                      vectors,
                      periodic_tol=1e-8,
                      **kwargs,
              Severity: Minor
              Found in src/gyptis/geometry/phc3d.py - About 1 hr to fix

                Function build_geometry has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def build_geometry(wavelength, pmesh):
                    thicknesses = OrderedDict(
                        {
                            "pml_bottom": wavelength,
                            "substrate": wavelength * 1,
                Severity: Minor
                Found in examples/diffraction/plot_silver_core_shell_grating.py - About 1 hr to fix

                  Function __init__ has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def __init__(
                          self,
                          model_name="geometry",
                          mesh_name="mesh.msh",
                          data_dir=None,
                  Severity: Minor
                  Found in src/gyptis/geometry/geometry.py - About 1 hr to fix

                    Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(
                    Severity: Major
                    Found in src/gyptis/models/grating3d.py - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language