benvial/gyptis

View on GitHub

Showing 211 of 211 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def build_pec_boundary_conditions(self, applied_function):
        if self.case == "epsilon" and self.pec_boundaries != []:
            # FIXME: project is slow, avoid it.
            applied_function = project_iterative(
                applied_function, self.real_function_space
Severity: Major
Found in src/gyptis/formulations/twoscale2d.py and 2 other locations - About 3 hrs to fix
src/gyptis/formulations/_high_contrast.py on lines 69..82
src/gyptis/formulations/maxwell2d.py on lines 128..141

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 64.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    def eigensolve(self, *args, **kwargs):
        sol = super().eigensolve(*args, **kwargs)
        self.solution["eigenvectors"] = [
            u * self.formulation.phasor for u in sol["eigenvectors"]
        ]
Severity: Major
Found in src/gyptis/models/phc3d.py and 1 other location - About 3 hrs to fix
src/gyptis/models/phc2d.py on lines 52..57

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 63.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    def eigensolve(self, *args, **kwargs):
        sol = super().eigensolve(*args, **kwargs)
        self.solution["eigenvectors"] = [
            u * self.formulation.phasor for u in sol["eigenvectors"]
        ]
Severity: Major
Found in src/gyptis/models/phc2d.py and 1 other location - About 3 hrs to fix
src/gyptis/models/phc3d.py on lines 48..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 63.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                for dom in source_dom_func:
                    form += self.maxwell(
                        u1,
                        v,
                        epsilon_dict[dom] - epsilon_a_dict[dom],
    Severity: Major
    Found in src/gyptis/formulations/maxwell3d.py and 1 other location - About 3 hrs to fix
    src/gyptis/formulations/maxwell2d.py on lines 106..111

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 62.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                for dom in source_dom_func:
                    form += self.maxwell(
                        u1,
                        v,
                        xi_dict[dom] - xi_a_dict[dom],
    Severity: Major
    Found in src/gyptis/formulations/maxwell2d.py and 1 other location - About 3 hrs to fix
    src/gyptis/formulations/maxwell3d.py on lines 105..110

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 62.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if self.modal:
                        return [form[0] * self.dx(domain), -form[1] * self.dx(domain)]
            Severity: Major
            Found in src/gyptis/formulations/maxwell3d.py and 1 other location - About 2 hrs to fix
            src/gyptis/formulations/maxwell2d.py on lines 61..62

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if self.modal:
                        return [form[0] * self.dx(domain), -form[1] * self.dx(domain)]
            Severity: Major
            Found in src/gyptis/formulations/maxwell2d.py and 1 other location - About 2 hrs to fix
            src/gyptis/formulations/maxwell3d.py on lines 51..52

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              class Lattice(Geometry):
                  """Lattice(vectors, **kwargs)
                  Unit cell for periodic problems.
              
                  Parameters
              Severity: Major
              Found in src/gyptis/api.py and 1 other location - About 2 hrs to fix
              src/gyptis/api.py on lines 68..101

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              class Layered(Geometry):
                  """Layered(dim, period, thicknesses, **kwargs)
                  Layered media for diffraction problems, defining the periodic unit cell
                  for mono or bi periodic gratings.
              
              
              Severity: Major
              Found in src/gyptis/api.py and 1 other location - About 2 hrs to fix
              src/gyptis/api.py on lines 104..121

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language