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
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:
- Read upRead up
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:
- Read upRead up
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):
- Read upRead up
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_tensor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _make_tensor(mapping):
mapping_tens = mapping.copy()
N = max(len(v) for v in mapping.values() if isiter(v))
idf = np.eye(N).tolist()
for k, v in mapping.items():
- Read upRead up
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 deeply nested control flow statements. Open
if callable(k):
const = False
break
# if p.shape != (2, 2):
# p = p[:2][:2]
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, dict, geometry=None, pmls=None, dim=2, degree=1, element=None):
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, markers, subdomains, mapping, *args, **kwargs):
Function __new__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
Function __new__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
Function __new__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
Function __new__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __new__(self, markers, subdomains, mapping, cpp=True, **kwargs):
Function __new__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __new__(self, markers, subdomains, mapping, cpp=True, **kwargs):
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
- Read upRead up
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 __new__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
iterable = any(isiter(v) for v in mapping.values())
flatvals = _flatten_list(mapping.values())
cplx = any(iscomplex(v) and np.any(v.imag != 0) for v in flatvals)
if iterable:
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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"