benvial/gyptis

View on GitHub

Showing 161 of 211 total issues

Function plot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def plot(self, figsize=None, ax=None):
        if self.dim == 2:
            tri, cb = plot(self.expression, mesh=self.domain, ax=ax)
            fig = plt.gcf()
            ax = fig.axes
Severity: Minor
Found in src/gyptis/sources/source.py - About 35 mins 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 build_geometry has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def build_geometry(pmesh):
    pmesh_scatt = 1 * pmesh
    b = a * 2 * 1.2
    box_size = (b, b, b)
    pml_width = (lambda0, lambda0, lambda0)
Severity: Minor
Found in examples/scattering/dielectric_sphere.py - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

    def weak(self, a):
        self.mesh = a.function_space().mesh() if self._mesh is None else self._mesh
        self.dim = self.mesh.ufl_domain().geometric_dimension()
        self.function_space = self._function_space or df.FunctionSpace(
            self.mesh, "CG", self.degree
Severity: Minor
Found in src/gyptis/optimize.py - About 35 mins 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 set_size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def set_size(self, idf, s, dim=None):
        if hasattr(idf, "__len__") and not isinstance(idf, str):
            for i, id_ in enumerate(idf):
                s_ = s[i] if hasattr(s, "__len__") else s
                params = {id_: s_}
Severity: Minor
Found in src/gyptis/geometry/geometry.py - About 35 mins 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 jacobian_matrix has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def jacobian_matrix(self):
        if self.direction == "x":
            s = self.stretch, 1, 1
        elif self.direction == "y":
            s = 1, self.stretch, 1
Severity: Minor
Found in src/gyptis/materials.py - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

    def compute_absorption(self, subdomain_absorption=False):
        omega = self.source.pulsation
        doms_no_pml = [
            z for z in self.epsilon.keys() if z not in ["pml_bottom", "pml_top"]
        ]
Severity: Minor
Found in src/gyptis/models/grating2d.py - About 35 mins 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 plot_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def plot_field(
        self,
        nper=1,
        type="real",
        field="total",
Severity: Minor
Found in src/gyptis/models/grating2d.py - About 35 mins 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 _complexcheck has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def _complexcheck(func):
    """Wrapper to check if arguments are complex"""

    def wrapper(self, z):
        if hasattr(z, "real") and hasattr(z, "imag"):
Severity: Minor
Found in src/gyptis/complex.py - About 35 mins 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

Avoid too many return statements within this function.
Open

        return ((2 * n + 1) * (n - 1) / (n + 1)) ** 0.5 * x * u(x, n - 1, n - 1)
Severity: Major
Found in src/gyptis/sources/spharm.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return ((2 * n + 1) * (n - 1) / ((n + 1) * (n**2 - m**2))) ** 0.5 * (
    Severity: Major
    Found in src/gyptis/sources/spharm.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return (((2 * n + 1) / (n**2 - m**2)) ** 0.5) * (
      Severity: Major
      Found in src/gyptis/sources/spharm.py - About 30 mins to fix

        Function solve_system has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def solve_system(self, again=False, vector_function=True):
                """Solve the discretized system.
        
                Parameters
                ----------
        Severity: Minor
        Found in src/gyptis/models/simulation.py - About 25 mins 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_effective_param has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_effective_param(self, case):
                self.solve_param(case)
                coeff = self.formulation.epsilon if case == "epsilon" else self.formulation.mu
                param = coeff.as_subdomain()
                if param.real.ufl_shape == (3, 3):
        Severity: Minor
        Found in src/gyptis/models/twoscale3d.py - About 25 mins 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def update(directory):
            for root, dirs, files in os.walk(directory):
                for file in files:
                    if file.endswith(".py"):
                        python_file = os.path.abspath(os.path.join(root, file))
        Severity: Minor
        Found in dev/update_header.py - About 25 mins 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 read_mesh_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_mesh_file(self, subdomains=None):
                if subdomains is not None:
                    if isinstance(subdomains, str):
                        subdomains = [subdomains]
                    key = "volumes" if self.dim == 3 else "surfaces"
        Severity: Minor
        Found in src/gyptis/geometry/geometry.py - About 25 mins 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 pause has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def pause(interval):
            backend = plt.rcParams["backend"]
            if backend in matplotlib.rcsetup.interactive_bk:
                figManager = matplotlib._pylab_helpers.Gcf.get_active()
                if figManager is not None:
        Severity: Minor
        Found in src/gyptis/plot.py - About 25 mins 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 eval_cell has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def eval_cell(self, values, x, cell):
                for sub, val in self.mapping.items():
                    if self.markers[cell.index] == self.subdomains[sub]:
                        values[:] = val(x) if callable(val) else val
        
        
        Severity: Minor
        Found in src/gyptis/materials.py - About 25 mins 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, dict, geometry=None, pmls=None, dim=2, degree=1, element=None):
                if pmls is None:
                    pmls = []
                self.dict = dict
                self.geometry = geometry
        Severity: Minor
        Found in src/gyptis/materials.py - About 25 mins 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 _cross_section_helper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _cross_section_helper(self, return_type="s", boundaries="calc_bnds"):
                uscatt = self.solution["diffracted"]
                vscatt = self.formulation.get_dual(uscatt)
                utot = self.solution["total"]
                vtot = self.formulation.get_dual(utot)
        Severity: Minor
        Found in src/gyptis/models/scattering2d.py - About 25 mins 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 _check_subdomains has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _check_subdomains(self):
                groups = self.model.getPhysicalGroups()
                names = [self.model.getPhysicalName(*g) for g in groups]
                for subtype, subitems in self.subdomains.items():
                    for idf in subitems.copy().keys():
        Severity: Minor
        Found in src/gyptis/geometry/geometry.py - About 25 mins 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