kjappelbaum/pyepal

View on GitHub
src/pyepal/models/nt.py

Summary

Maintainability
A
1 hr
Test Coverage

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert len(hidden_layers) >= 1, "You must provide at least one hidden layer"
Severity: Info
Found in src/pyepal/models/nt.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert len(activations) == len(
        hidden_layers
    ), "The number of hidden layers should match the number of nonlinearities"
Severity: Info
Found in src/pyepal/models/nt.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

            assert callable(activation), "You need to provide `neural_tangents.stax` activations"
Severity: Info
Found in src/pyepal/models/nt.py by bandit

Function build_dense_network has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def build_dense_network(
    hidden_layers: Sequence[int],
    activations: Union[Sequence, str] = "erf",
    w_std: float = 2.5,
    b_std=1,
Severity: Minor
Found in src/pyepal/models/nt.py - About 55 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_optimizer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_optimizer(
    learning_rate: float = 1e-4, optimizer="sdg", optimizer_kwargs: dict = None
) -> JaxOptimizer:
    """Return a `JaxOptimizer` dataclass for a JAX optimizer

Severity: Minor
Found in src/pyepal/models/nt.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

There are no issues that match your filters.

Category
Status