monarch-initiative/N2V

View on GitHub
embiggen/utils/abstract_edge_gcn.py

Summary

Maintainability
F
4 days
Test Coverage

File abstract_edge_gcn.py has 838 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""GCN model for edge prediction."""
from typing import Any, Dict, List, Optional, Type, Union

import numpy as np
import pandas as pd
Severity: Major
Found in embiggen/utils/abstract_edge_gcn.py - About 2 days to fix

    Function _build_model has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_model(
            self,
            graph: Graph,
            graph_convolution_model: Model,
            edge_type_features: List[np.ndarray],
    Severity: Minor
    Found in embiggen/utils/abstract_edge_gcn.py - About 1 day 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 39 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in embiggen/utils/abstract_edge_gcn.py - About 4 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                              if len(self._number_of_units_per_ffnn_body_layer) > 0:
                                  hidden = BatchNormalization()(hidden)
                              this_ffnn_output.append(hidden)
      Severity: Major
      Found in embiggen/utils/abstract_edge_gcn.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for i, units in enumerate(
                                    self._number_of_units_per_ffnn_body_layer
                                ):
                                    assert isinstance(units, int)
                                    assert not isinstance(hidden, list)
        Severity: Major
        Found in embiggen/utils/abstract_edge_gcn.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          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"
          Severity: Major
          Found in embiggen/utils/abstract_edge_gcn.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            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)
            Severity: Major
            Found in embiggen/utils/abstract_edge_gcn.py - About 45 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (
                          len(features) == 0
                          and not self._use_node_embedding
                          and not self._use_edge_type_embedding
                          and len(edge_features) == 0
              Severity: Major
              Found in embiggen/utils/abstract_edge_gcn.py - About 40 mins to fix

                There are no issues that match your filters.

                Category
                Status