tensorflow/tensorflow

View on GitHub
tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py

Summary

Maintainability
F
1 wk
Test Coverage

File cwise_ops_unary_test.py has 554 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2018 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/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 day to fix

    UnaryOpTest has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UnaryOpTest(test.TestCase):
    
      def _compareCpu(self, x, np_func, tf_func, grad_rtol=None, grad_atol=None):
        if grad_rtol is None:
          grad_rtol = _default_tolerance(x.dtype)
    Severity: Minor
    Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 3 hrs to fix

      Function testFloatBasic has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def testFloatBasic(self):
          x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float32)
          w = x - x.min() + 1.02  # all greater than 1
          y = (x + .5).astype(np.float32)  # no zero
          z = (x + 15.5).astype(np.float32)  # all positive
      Severity: Minor
      Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

        Function testDoubleBasic has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def testDoubleBasic(self):
            x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float64)
            w = x - x.min() + 1.02  # all greater than 1
            y = (x + .5).astype(np.float64)  # no zero
            z = (x + 15.5).astype(np.float64)  # all positive
        Severity: Minor
        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

          Function testHalfBasic has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def testHalfBasic(self):
              x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float16)
              w = x - x.min() + 1.1  # all greater than 1
              y = (x + .5).astype(np.float16)  # no zero
              z = (x + 15.5).astype(np.float16)  # all positive
          Severity: Minor
          Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

            Function testFloatEmpty has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def testFloatEmpty(self):
                x = np.empty((2, 0, 5), dtype=np.float32)
                self._compareBoth(x, np.abs, math_ops.abs)
                self._compareBoth(x, np.abs, _ABS)
                self._compareBoth(x, np.negative, math_ops.negative)
            Severity: Minor
            Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

              Function testBFloat16Basic has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def testBFloat16Basic(self):
              
                  def compute_f32(np_func):
                    """Decorator to compute Numpy function with float32 math."""
              
              
              Severity: Minor
              Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

                Function testComplex128Basic has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def testComplex128Basic(self):
                    x = (1 + 1j) * np.arange(-3, 3).reshape(1, 3, 2).astype(np.complex128)
                    y = x + (0.5 + 0.5j)  # no zeros
                    self._compareBoth(x, np.abs, math_ops.abs)
                    self._compareBoth(x, np.abs, _ABS)
                Severity: Minor
                Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

                  Function testComplex64Basic has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def testComplex64Basic(self):
                      x = (1 + 1j) * np.arange(-3, 3).reshape(1, 3, 2).astype(np.complex64)
                      y = x + (0.5 + 0.5j)  # no zeros
                      self._compareBoth(x, np.abs, math_ops.abs)
                      self._compareBoth(x, np.abs, _ABS)
                  Severity: Minor
                  Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 1 hr to fix

                    Function _compareCpu has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _compareCpu(self, x, np_func, tf_func, grad_rtol=None, grad_atol=None):
                        if grad_rtol is None:
                          grad_rtol = _default_tolerance(x.dtype)
                        if grad_atol is None:
                          grad_atol = _default_tolerance(x.dtype)
                    Severity: Minor
                    Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.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 testGradGrad has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def testGradGrad(self):
                        np.random.seed(7)
                        shape = (5,)
                        dtype_tols = [(np.float32, 5e-4), (np.float64, 1e-6), (np.complex64, 5e-4),
                                      (np.complex128, 1e-6)]
                    Severity: Minor
                    Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.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 _compareCpu has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def _compareCpu(self, x, np_func, tf_func, grad_rtol=None, grad_atol=None):
                    Severity: Minor
                    Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return None  # Fail fast for unexpected types
                      Severity: Major
                      Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py - About 30 mins to fix

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

                          def _replace_domain_error_with_inf(self, fn):
                        
                            def func(x):
                              try:
                                return fn(x)
                        Severity: Minor
                        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.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

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                              if x.dtype in (np.float16, dtypes_lib.bfloat16.as_numpy_dtype):
                                s = list(np.shape(x))
                                jacob_t, _ = gradient_checker.compute_gradient(
                                    inx, s, y, s, x_init_value=x)
                                xf = x.astype(np.float64)
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5831..5855

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 151.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                            for op, real_range in op_range:
                              with self.cached_session():
                                for dtype, tol in dtype_tols:
                                  x = constant_op.constant(rand(dtype, real_range))
                                  y = constant_op.constant(rand(dtype, real_range))
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5690..5706

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 147.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def testInt16Basic(self):
                            x = np.arange(-6, 6, 2).reshape(1, 3, 2).astype(np.int16)
                            self._compareCpu(x, np.abs, math_ops.abs)
                            self._compareCpu(x, np.abs, _ABS)
                            self._compareBoth(x, np.negative, math_ops.negative)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 448..454

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 106.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def testInt8Basic(self):
                            x = np.arange(-6, 6, 2).reshape(1, 3, 2).astype(np.int8)
                            self._compareCpu(x, np.abs, math_ops.abs)
                            self._compareCpu(x, np.abs, _ABS)
                            self._compareBoth(x, np.negative, math_ops.negative)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 460..466

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 106.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                        def _sparsify(x, thresh=0.5, index_dtype=np.int64):
                          x[x < thresh] = 0
                        
                          non_zero = np.where(x)
                          x_indices = np.vstack(non_zero).astype(index_dtype).T
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_binary_test.py on lines 49..58
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_test.py on lines 52..61

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 98.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                              if x.dtype == np.float16:
                                self.assertAllClose(np_ans, tf_cpu, rtol=1e-3, atol=1e-3)
                              elif x.dtype == dtypes_lib.bfloat16.as_numpy_dtype:
                                self.assertAllClose(np_ans, tf_cpu, rtol=1e-2, atol=1e-2)
                              else:
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5821..5826

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 76.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def _replace_domain_error_with_inf(self, fn):
                        
                            def func(x):
                              try:
                                return fn(x)
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5540..5550

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 67.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                            try:
                              from scipy import special  # pylint: disable=g-import-not-at-top
                              self._compareBoth(x, special.i0e, special_math_ops.bessel_i0e)
                              self._compareBoth(x, special.i1e, special_math_ops.bessel_i1e)
                            except ImportError as e:
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 282..287
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 336..341

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 61.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                            try:
                              from scipy import special  # pylint: disable=g-import-not-at-top
                              self._compareBoth(x, special.i0e, special_math_ops.bessel_i0e)
                              self._compareBoth(x, special.i1e, special_math_ops.bessel_i1e)
                            except ImportError as e:
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 227..232
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 336..341

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 61.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                            try:
                              from scipy import special  # pylint: disable=g-import-not-at-top
                              self._compareBoth(x, special.i0e, special_math_ops.bessel_i0e)
                              self._compareBoth(x, special.i1e, special_math_ops.bessel_i1e)
                            except ImportError as e:
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 227..232
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 282..287

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 61.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def _compareSparseGpu(self, x, np_func, tf_func, tol):
                            x_sp, x_sp_vals = _sparsify(x)
                            res_np = np_func(x_sp_vals)
                            with test_util.use_gpu():
                              self._check(tf_func(x_sp), res_np, x_sp, tol)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 130..134

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 55.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def _compareSparseCpu(self, x, np_func, tf_func, tol):
                            x_sp, x_sp_vals = _sparsify(x)
                            res_np = np_func(x_sp_vals)
                            with test_util.force_cpu():
                              self._check(tf_func(x_sp), res_np, x_sp, tol)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 147..151

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 55.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          def testUInt8Basic(self):
                            x = np.arange(6).reshape(1, 3, 2).astype(np.uint8)
                            self._compareBoth(x, np.square, math_ops.square)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 468..470
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 486..488
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 507..509

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          def testUInt32Basic(self):
                            x = np.arange(6).reshape(1, 3, 2).astype(np.uint32)
                            self._compareBoth(x, np.square, math_ops.square)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 456..458
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 468..470
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 507..509

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          def testUInt16Basic(self):
                            x = np.arange(6).reshape(1, 3, 2).astype(np.uint16)
                            self._compareBoth(x, np.square, math_ops.square)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 456..458
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 486..488
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 507..509

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          def testUInt64Basic(self):
                            x = np.arange(6).reshape(1, 3, 2).astype(np.uint64)
                            self._compareBoth(x, np.square, math_ops.square)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 456..458
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 468..470
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 486..488

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 3 locations. Consider refactoring.
                        Open

                            x = np.arange(-6 << 40, 6 << 40, 2 << 40).reshape(1, 3, 2).astype(np.int64)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_binary_test.py on lines 394..394
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 503..503

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 47.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 3 locations. Consider refactoring.
                        Open

                            x = np.arange(-6 << 20, 6 << 20, 2 << 20).reshape(1, 3, 2).astype(np.int64)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_binary_test.py on lines 394..394
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 491..491

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 47.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                              x = np.random.uniform(
                                  real_range[0], real_range[1], size=shape[0]).astype(dtype)
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5685..5685

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 42.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            x = (1 + 1j) * np.arange(-3, 3).reshape(1, 3, 2).astype(np.complex64)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 559..559

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 40.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            x = (1 + 1j) * np.arange(-3, 3).reshape(1, 3, 2).astype(np.complex128)
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 513..513

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 40.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                              if x.dtype in (np.complex64, np.complex128) and tf_func == math_ops.sign:
                        Severity: Minor
                        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py and 1 other location - About 35 mins to fix
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5828..5828

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 33.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def _sigmoid(self, x):
                            return 1.0 / (1.0 + np.exp(-x))
                        Severity: Minor
                        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py and 1 other location - About 30 mins to fix
                        tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test.py on lines 5534..5535

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            x = np.arange(-40, -40 + 6).reshape(6).astype(np.float32)
                        Severity: Minor
                        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py and 1 other location - About 30 mins to fix
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 244..244

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            x = np.arange(40, 40 + 6).reshape(6).astype(np.float32)
                        Severity: Minor
                        Found in tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py and 1 other location - About 30 mins to fix
                        tensorflow/python/kernel_tests/math_ops/cwise_ops_unary_test.py on lines 246..246

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status