embiggen/utils/abstract_edge_gcn.py
File abstract_edge_gcn.py
has 838 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"""GCN model for edge prediction."""
from typing import Any, Dict, List, Optional, Type, Union
import numpy as np
import pandas as pd
Function _build_model
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
Open
def _build_model(
self,
graph: Graph,
graph_convolution_model: Model,
edge_type_features: List[np.ndarray],
- 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 39 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Avoid deeply nested control flow statements. Open
Open
if len(self._number_of_units_per_ffnn_body_layer) > 1:
ordinal = number_to_ordinal(i + 1)
else:
ordinal = ""
layer_name = f"{ordinal}{source_feature_name}SiameseDense"
Avoid deeply nested control flow statements. Open
Open
if len(self._number_of_units_per_ffnn_body_layer) > 0:
hidden = BatchNormalization()(hidden)
this_ffnn_output.append(hidden)
Avoid deeply nested control flow statements. Open
Open
for i, units in enumerate(
self._number_of_units_per_ffnn_body_layer
):
assert isinstance(units, int)
assert not isinstance(hidden, list)
Avoid deeply nested control flow statements. Open
Open
for siamese_layer in partial_siamese_layers:
assert issubclass(
type(siamese_layer), Layer
), f"Expected a layer, but found {type(siamese_layer)}."
hidden = siamese_layer(hidden)
Consider simplifying this complex logical expression. Open
Open
if (
len(features) == 0
and not self._use_node_embedding
and not self._use_edge_type_embedding
and len(edge_features) == 0