tensorflow/python/framework/ops.py
File ops.py
has 4545 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
# Copyright 2015 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
_EagerTensorBase
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class _EagerTensorBase(
tensor_lib.Tensor, internal.NativeObject, core_tf_types.Value):
"""Base class for EagerTensor."""
# __complex__, __int__, __float__ and __index__ may copy the tensor to CPU and
Function create_op
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_op(
Function convert_to_tensor
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def convert_to_tensor(
Function _create_op_internal
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _create_op_internal(
Function from_node_def
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def from_node_def(
Function internal_convert_n_to_tensor
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def internal_convert_n_to_tensor(
Function _create_c_op
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _create_c_op(graph,
Function _create_graph_constant
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _create_graph_constant(
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def __init__(self, device_name_or_function) -> None:
self._device_name_or_function = device_name_or_function
self.display_name = str(self._device_name_or_function)
self.function = device_name_or_function
self.raw_string = None
- Read upRead up
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 value_text
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def value_text(tensor, is_repr=False) -> AnyStr:
"""Either the NumPy value or a custom TensorFlow formatting of `tensor`.
Custom formatting is used for custom device tensors, e.g. parallel tensors
with multiple components on different devices.
- Read upRead up
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"