benvial/gyptis

View on GitHub

Showing 161 of 211 total issues

File geometry.py has 570 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Benjamin Vial
# This file is part of gyptis
# Version: 1.0.2
Severity: Major
Found in src/gyptis/geometry/geometry.py - About 1 day to fix

    Function _adaptive_sampler has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

    def _adaptive_sampler(f, z0, max_bend=10, max_z_rel=1e-3, max_df=0.05):
        z0 = np.sort(z0)
        zmin = min(z0)
        zmax = max(z0)
    
    
    Severity: Minor
    Found in src/gyptis/utils/sample.py - About 1 day 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

    File materials.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # Author: Benjamin Vial
    # This file is part of gyptis
    # Version: 1.0.2
    Severity: Minor
    Found in src/gyptis/materials.py - About 5 hrs to fix

      Function diffraction_efficiencies has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def diffraction_efficiencies(
              self,
              N_d_order=0,
              cplx_effs=False,
              orders=False,
      Severity: Minor
      Found in src/gyptis/models/grating3d.py - About 4 hrs 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

      File stack.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      # Author: Benjamin Vial
      # This file is part of gyptis
      # Version: 1.0.2
      Severity: Minor
      Found in src/gyptis/sources/stack.py - About 4 hrs to fix

        Geometry has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Geometry:
            """Base class for geometry models."""
        
            def __init__(
                self,
        Severity: Minor
        Found in src/gyptis/geometry/geometry.py - About 3 hrs to fix

          File grating2d.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #!/usr/bin/env python
          # -*- coding: utf-8 -*-
          # Author: Benjamin Vial
          # This file is part of gyptis
          # Version: 1.0.2
          Severity: Minor
          Found in src/gyptis/models/grating2d.py - About 3 hrs to fix

            Function minimize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                def minimize(self, x0):
                    self.x0 = x0
                    if self.verbose:
                        mpi_print("#################################################")
                        mpi_print(f"Topology optimization with {self.nvar} variables")
            Severity: Minor
            Found in src/gyptis/optimize.py - About 3 hrs 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 diffraction_efficiencies has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def diffraction_efficiencies(
                    self,
                    N_order=0,
                    cplx_effs=False,
                    orders=False,
            Severity: Minor
            Found in src/gyptis/models/grating2d.py - About 3 hrs 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_stack has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            def make_stack(
                geometry,
                coefficients,
                plane_wave,
                polarization="TM",
            Severity: Minor
            Found in src/gyptis/sources/stack.py - About 3 hrs 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

            Complex has 26 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Complex:
                """A complex object.
            
                Parameters
                ----------
            Severity: Minor
            Found in src/gyptis/complex.py - About 3 hrs to fix

              Function run has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def run(polarization):
                  t2Dmesh = -time.time()
                  geom2D = build_geometry(2)
                  t2Dmesh += time.time()
                  simu2D = init_simu(geom2D, polarization)
              Severity: Major
              Found in examples/diffraction/plot_2d_to_3d_grating.py - About 2 hrs to fix

                File optimize.py has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/env python
                # -*- coding: utf-8 -*-
                # Author: Benjamin Vial
                # This file is part of gyptis
                # Version: 1.0.2
                Severity: Minor
                Found in src/gyptis/optimize.py - About 2 hrs to fix

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

                      def __init__(
                          self,
                          box_size=(1, 1, 1),
                          box_center=(0, 0, 0),
                          pml_width=(0.2, 0.2, 0.2),
                  Severity: Major
                  Found in src/gyptis/geometry/scattering3d.py - About 2 hrs to fix

                    File complex.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    #!/usr/bin/env python
                    # -*- coding: utf-8 -*-
                    # Author: Benjamin Vial
                    # This file is part of gyptis
                    # Version: 1.0.2
                    Severity: Minor
                    Found in src/gyptis/complex.py - About 2 hrs to fix

                      Function read_mesh has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def read_mesh(mesh_file, data_dir=None, data_dir_xdmf=None, dim=3, subdomains=None):
                          data_dir_xdmf = data_dir_xdmf or tempfile.mkdtemp()
                          meshio_mesh = meshio.read(mesh_file, file_format="gmsh")
                          if dim == 3:
                              base_cell_type = "tetra"
                      Severity: Minor
                      Found in src/gyptis/mesh/mesh.py - About 2 hrs 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_2d has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _make_constant_property_2d(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 2 hrs 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 _topopt_wrapper has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _topopt_wrapper(
                              self,
                              objfun,
                              Asub,
                              Actrl,
                      Severity: Minor
                      Found in src/gyptis/optimize.py - About 2 hrs 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

                      File scattering3d.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      #!/usr/bin/env python
                      # -*- coding: utf-8 -*-
                      # Author: Benjamin Vial
                      # This file is part of gyptis
                      # Version: 1.0.2
                      Severity: Minor
                      Found in src/gyptis/models/scattering3d.py - About 2 hrs to fix

                        Function __init__ has a Cognitive Complexity of 15 (exceeds 5 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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language