monarch-initiative/N2V

View on GitHub
embiggen/edge_prediction/edge_prediction_model.py

Summary

Maintainability
F
1 wk
Test Coverage

File edge_prediction_model.py has 1870 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Module providing abstract edge prediction model."""
import math
import gc
import warnings
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
Severity: Major
Found in embiggen/edge_prediction/edge_prediction_model.py - About 5 days to fix

    Function predict_proba has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        def predict_proba(
            self,
            graph: Graph,
            support: Optional[Graph] = None,
            node_features: Optional[
    Severity: Minor
    Found in embiggen/edge_prediction/edge_prediction_model.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 _evaluate has 21 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _evaluate(
    Severity: Major
    Found in embiggen/edge_prediction/edge_prediction_model.py - About 2 hrs to fix

      Function _prepare_evaluation has 16 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _prepare_evaluation(
      Severity: Major
      Found in embiggen/edge_prediction/edge_prediction_model.py - About 2 hrs to fix

        Function __iterate_negative_graphs has 15 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __iterate_negative_graphs(
        Severity: Major
        Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

          Function predict_proba_bipartite_graph_from_edge_node_types has 14 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def predict_proba_bipartite_graph_from_edge_node_types(
          Severity: Major
          Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

            Function predict_proba_bipartite_graph_from_edge_node_names has 14 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def predict_proba_bipartite_graph_from_edge_node_names(
            Severity: Major
            Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

              Function predict_proba_bipartite_graph_from_edge_node_prefixes has 14 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def predict_proba_bipartite_graph_from_edge_node_prefixes(
              Severity: Major
              Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                Function predict_proba_bipartite_graph_from_edge_node_ids has 14 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def predict_proba_bipartite_graph_from_edge_node_ids(
                Severity: Major
                Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                  Function predict_proba_clique_graph_from_node_ids has 13 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def predict_proba_clique_graph_from_node_ids(
                  Severity: Major
                  Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                    Function predict_proba_clique_graph_from_node_prefixes has 13 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def predict_proba_clique_graph_from_node_prefixes(
                    Severity: Major
                    Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                      Function predict_proba_clique_graph_from_node_type_names has 13 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def predict_proba_clique_graph_from_node_type_names(
                      Severity: Major
                      Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                        Function predict_proba_clique_graph_from_node_names has 13 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def predict_proba_clique_graph_from_node_names(
                        Severity: Major
                        Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                          Function predict_bipartite_graph_from_edge_node_names has 12 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def predict_bipartite_graph_from_edge_node_names(
                          Severity: Major
                          Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                            Function predict_bipartite_graph_from_edge_node_ids has 12 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def predict_bipartite_graph_from_edge_node_ids(
                            Severity: Major
                            Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                              Function predict_bipartite_graph_from_edge_node_prefixes has 12 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def predict_bipartite_graph_from_edge_node_prefixes(
                              Severity: Major
                              Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                Function predict_bipartite_graph_from_edge_node_types has 12 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def predict_bipartite_graph_from_edge_node_types(
                                Severity: Major
                                Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                  Function predict_proba has 12 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def predict_proba(
                                  Severity: Major
                                  Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                    Function predict has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def predict(
                                            self,
                                            graph: Graph,
                                            support: Optional[Graph] = None,
                                            node_features: Optional[
                                    Severity: Minor
                                    Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr 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 predict_clique_graph_from_node_ids has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def predict_clique_graph_from_node_ids(
                                    Severity: Major
                                    Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                      Function predict_clique_graph_from_node_type_names has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def predict_clique_graph_from_node_type_names(
                                      Severity: Major
                                      Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                        Function predict_clique_graph_from_node_prefixes has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def predict_clique_graph_from_node_prefixes(
                                        Severity: Major
                                        Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                          Function predict_clique_graph_from_node_names has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              def predict_clique_graph_from_node_names(
                                          Severity: Major
                                          Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

                                            Function predict has 10 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def predict(
                                            Severity: Major
                                            Found in embiggen/edge_prediction/edge_prediction_model.py - About 1 hr to fix

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

                                                  def _evaluate(
                                                      self,
                                                      graph: Graph,
                                                      train: Graph,
                                                      test: Graph,
                                              Severity: Minor
                                              Found in embiggen/edge_prediction/edge_prediction_model.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 fit has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  def fit(
                                              Severity: Major
                                              Found in embiggen/edge_prediction/edge_prediction_model.py - About 50 mins to fix

                                                Function split_graph_following_evaluation_schema has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    def split_graph_following_evaluation_schema(
                                                Severity: Major
                                                Found in embiggen/edge_prediction/edge_prediction_model.py - About 50 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                              if separator in dst:
                                                                                  dst = dst.replace("\"", "\\\"")
                                                                                  dst = f"\"{dst}\""
                                                                          else:
                                                  Severity: Major
                                                  Found in embiggen/edge_prediction/edge_prediction_model.py - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                                if separator in src:
                                                                                    src = src.replace("\"", "\\\"")
                                                                                    src = f"\"{src}\""
                                                                                if separator in dst:
                                                    Severity: Major
                                                    Found in embiggen/edge_prediction/edge_prediction_model.py - About 45 mins to fix

                                                      There are no issues that match your filters.

                                                      Category
                                                      Status