tensorflow/tensorflow

View on GitHub
tensorflow/python/ops/metrics_impl.py

Summary

Maintainability
F
1 wk
Test Coverage

File metrics_impl.py has 3204 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
Severity: Major
Found in tensorflow/python/ops/metrics_impl.py - About 1 wk to fix

    Function _remove_squeezable_dimensions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _remove_squeezable_dimensions(predictions, labels, weights):
      """Squeeze or expand last dim if needed.
    
      Squeezes last dim of `predictions` or `labels` if their rank differs by 1
      (using confusion_matrix.remove_squeezable_dimensions).
    Severity: Minor
    Found in tensorflow/python/ops/metrics_impl.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 auc has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def auc(labels,
    Severity: Major
    Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

      Function _maybe_expand_labels has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def _maybe_expand_labels(labels, predictions):
        """If necessary, expand `labels` along last dimension to match `predictions`.
      
        Args:
          labels: `Tensor` or `SparseTensor` with shape
      Severity: Minor
      Found in tensorflow/python/ops/metrics_impl.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 compute_auc has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_auc(tp, fn, tn, fp, name):
            """Computes the roc-auc or pr-auc based on confusion counts."""
            if curve == 'PR':
              if summation_method == 'trapezoidal':
                logging.warning(
      Severity: Minor
      Found in tensorflow/python/ops/metrics_impl.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 recall_at_top_k has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def recall_at_top_k(labels,
      Severity: Major
      Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

        def recall_at_k(labels,
        Severity: Major
        Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

          def sparse_precision_at_k(labels,
          Severity: Major
          Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

            def precision_at_k(labels,
            Severity: Major
            Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

              def specificity_at_sensitivity(labels,
              Severity: Major
              Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

                def precision_at_top_k(labels,
                Severity: Major
                Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

                  def sensitivity_at_specificity(labels,
                  Severity: Major
                  Found in tensorflow/python/ops/metrics_impl.py - About 1 hr to fix

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

                    def mean_iou(labels,
                    Severity: Major
                    Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                      def precision_at_thresholds(labels,
                      Severity: Major
                      Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                        def mean_per_class_accuracy(labels,
                        Severity: Major
                        Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                          def false_negatives_at_thresholds(labels,
                          Severity: Major
                          Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                            def mean_relative_error(labels,
                            Severity: Major
                            Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                              def true_positives_at_thresholds(labels,
                              Severity: Major
                              Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                def recall_at_thresholds(labels,
                                Severity: Major
                                Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                  def true_negatives_at_thresholds(labels,
                                  Severity: Major
                                  Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                    def mean_cosine_distance(labels,
                                    Severity: Major
                                    Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                      def sparse_average_precision_at_k(labels,
                                      Severity: Major
                                      Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                        def false_positives_at_thresholds(labels,
                                        Severity: Major
                                        Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                          def average_precision_at_k(labels,
                                          Severity: Major
                                          Found in tensorflow/python/ops/metrics_impl.py - About 50 mins to fix

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

                                            def _streaming_sparse_true_positive_at_k(labels,
                                            Severity: Minor
                                            Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                              def percentage_below(values,
                                              Severity: Minor
                                              Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                def true_negatives(labels,
                                                Severity: Minor
                                                Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                  def precision(labels,
                                                  Severity: Minor
                                                  Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                    def mean_squared_error(labels,
                                                    Severity: Minor
                                                    Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                      def accuracy(labels,
                                                      Severity: Minor
                                                      Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                        def false_negatives(labels,
                                                        Severity: Minor
                                                        Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                          def true_positives(labels,
                                                          Severity: Minor
                                                          Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                            def _streaming_sparse_average_precision_at_top_k(labels,
                                                            Severity: Minor
                                                            Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                              def false_positives(labels,
                                                              Severity: Minor
                                                              Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                def recall(labels,
                                                                Severity: Minor
                                                                Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                  def _streaming_sparse_false_negative_at_k(labels,
                                                                  Severity: Minor
                                                                  Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                    def root_mean_squared_error(labels,
                                                                    Severity: Minor
                                                                    Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                      def mean_absolute_error(labels,
                                                                      Severity: Minor
                                                                      Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                        def _streaming_sparse_false_positive_at_k(labels,
                                                                        Severity: Minor
                                                                        Found in tensorflow/python/ops/metrics_impl.py - About 45 mins to fix

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

                                                                          def _confusion_matrix_at_thresholds(labels,
                                                                          Severity: Minor
                                                                          Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                            def mean(values,
                                                                            Severity: Minor
                                                                            Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                                  def compute_auc(tp, fn, tn, fp, name):
                                                                              Severity: Minor
                                                                              Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                                def _sparse_true_positive_at_k(labels,
                                                                                Severity: Minor
                                                                                Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                                  def mean_tensor(values,
                                                                                  Severity: Minor
                                                                                  Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                                        def compute_specificity_at_sensitivity(tp, tn, fp, fn, name):
                                                                                    Severity: Minor
                                                                                    Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

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

                                                                                          def compute_sensitivity_at_specificity(tp, tn, fp, fn, name):
                                                                                      Severity: Minor
                                                                                      Found in tensorflow/python/ops/metrics_impl.py - About 35 mins to fix

                                                                                        Function fn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                        Open

                                                                                          def fn(distribution, *a):
                                                                                            """Call `metric_value_fn` in the correct control flow context."""
                                                                                            if hasattr(distribution.extended, '_outer_control_flow_context'):
                                                                                              # If there was an outer context captured before this method was called,
                                                                                              # then we enter that context to create the metric value op. If the
                                                                                        Severity: Minor
                                                                                        Found in tensorflow/python/ops/metrics_impl.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