lucasmiranda42/deepof

View on GitHub
deepof/model_utils.py

Summary

Maintainability
F
6 days
Test Coverage

File model_utils.py has 1354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# @author lucasmiranda42
# encoding: utf-8
# module deepof

"""Utility functions for both training autoencoder models in deepof.models and tuning hyperparameters with deepof.hypermodels."""
Severity: Major
Found in deepof/model_utils.py - About 3 days to fix

    Function embedding_model_fitting has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def embedding_model_fitting(
        preprocessed_object: Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray],
        adjacency_matrix: np.ndarray,
        embedding_model: str,
        encoder_type: str,
    Severity: Minor
    Found in deepof/model_utils.py - About 4 hrs 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 embedding_model_fitting has 30 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def embedding_model_fitting(
    Severity: Major
    Found in deepof/model_utils.py - About 3 hrs to fix

      Function embedding_per_video has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def embedding_per_video(
          coordinates: coordinates,
          to_preprocess: table_dict,
          model: tf.keras.models.Model,
          scale: str = "standard",
      Severity: Minor
      Found in deepof/model_utils.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 tune_search has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def tune_search(
      Severity: Major
      Found in deepof/model_utils.py - About 1 hr to fix

        Function select_contrastive_loss has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def select_contrastive_loss(
        Severity: Major
        Found in deepof/model_utils.py - About 1 hr to fix

          Function embedding_per_video has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def embedding_per_video(
          Severity: Major
          Found in deepof/model_utils.py - About 1 hr to fix

            Function get_callbacks has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def get_callbacks(
            Severity: Major
            Found in deepof/model_utils.py - About 1 hr to fix

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

                  def __init__(
              Severity: Major
              Found in deepof/model_utils.py - About 50 mins to fix

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

                    def __init__(
                Severity: Major
                Found in deepof/model_utils.py - About 50 mins to fix

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

                  def hard_loss(
                  Severity: Major
                  Found in deepof/model_utils.py - About 50 mins to fix

                    Function find_learning_rate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def find_learning_rate(
                    Severity: Minor
                    Found in deepof/model_utils.py - About 45 mins to fix

                      Function dcl_loss has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def dcl_loss(
                      Severity: Minor
                      Found in deepof/model_utils.py - About 45 mins to fix

                        Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(
                        Severity: Minor
                        Found in deepof/model_utils.py - About 45 mins to fix

                          Function call has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def call(
                          Severity: Minor
                          Found in deepof/model_utils.py - About 35 mins to fix

                            Function call has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def call(
                            Severity: Minor
                            Found in deepof/model_utils.py - About 35 mins to fix

                              Function fc_loss has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def fc_loss(
                              Severity: Minor
                              Found in deepof/model_utils.py - About 35 mins to fix

                                Function tune_search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def tune_search(
                                    preprocessed_object: tuple,
                                    adjacency_matrix: np.ndarray,
                                    encoding_size: int,
                                    embedding_model: str,
                                Severity: Minor
                                Found in deepof/model_utils.py - About 35 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_callbacks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def get_callbacks(
                                    embedding_model: str,
                                    encoder_type: str,
                                    kmeans_loss: float = 1.0,
                                    input_type: str = False,
                                Severity: Minor
                                Found in deepof/model_utils.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