File check_ops.py
has 1864 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
Function _binary_assert
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def _binary_assert(sym, opname, op_func, static_func, x, y, data, summarize,
message, name):
"""Generic binary elementwise assertion.
Implements the behavior described in _binary_assert_doc() above.
- 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 _assert_ranks_condition
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _assert_ranks_condition(
x, ranks, static_condition, dynamic_condition, data, summarize):
"""Assert `x` has a rank that satisfies a given condition.
Args:
- 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 _binary_assert
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def _binary_assert(sym, opname, op_func, static_func, x, y, data, summarize,
Function assert_near
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_near(
Function _assert_rank_condition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _assert_rank_condition(
x, rank, static_condition, dynamic_condition, data, summarize):
"""Assert `x` has a rank that satisfies a given condition.
Args:
- 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 assert_rank
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def assert_rank(x, rank, data=None, summarize=None, message=None, name=None):
"""Assert `x` has rank equal to `rank`.
Example of adding a dependency to an operation:
- 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 assert_near_v2
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_near_v2(x, y, rtol=None, atol=None, message=None, summarize=None,
Function assert_equal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_equal(x, y, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function assert_rank
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_rank(x, rank, data=None, summarize=None, message=None, name=None):
Function _assert_ranks_condition
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _assert_ranks_condition(
Function assert_rank_in
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_rank_in(
Function assert_greater
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_greater(x, y, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function _assert_rank_condition
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _assert_rank_condition(
Function assert_rank_at_least
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_rank_at_least(
Function assert_less_equal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_less_equal(x, y, data=None, summarize=None, message=None, name=None):
Avoid deeply nested control flow statements. Open
if _has_known_value(actual_size) and _has_known_value(specified_size):
if int(actual_size) != int(specified_size):
raise ValueError(
'%s%s. Tensor %s dimension %s must have size %d. '
'Received size %d, shape %s' %
Avoid deeply nested control flow statements. Open
with ops.control_dependencies(rank_assertions):
actual_size = sizes.actual_sizes[tensor_dim]
if _has_known_value(actual_size) and _has_known_value(specified_size):
Avoid deeply nested control flow statements. Open
if _has_known_value(size_symbol):
specified_size = int(size_symbol)
size_check_message = 'Specified explicitly'
else:
specified_size, specified_by_y, specified_at_dim = (
Avoid deeply nested control flow statements. Open
with ops.control_dependencies(rank_assertions):
size = sizes.actual_sizes[tensor_dim]
size_specifications[size_symbol] = (size, sizes.x, tensor_dim)
Function assert_less
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_less(x, y, data=None, summarize=None, message=None, name=None):
Function assert_rank_in
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def assert_rank_in(
x, ranks, data=None, summarize=None, message=None, name=None):
"""Assert `x` has rank in `ranks`.
Example of adding a dependency to an operation:
- 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 assert_none_equal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_none_equal(
Avoid deeply nested control flow statements. Open
if data is None:
data_ = [
message_prefix, size_check_message,
'Tensor %s dimension' % tensor_name(sizes.x), tensor_dim,
'must have size', specified_size, 'Received shape: ',
Function _pretty_print
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _pretty_print(data_item, summarize):
"""Format a data item for use in an error message in eager mode.
Args:
data_item: One of the items in the "data" argument to an assert_* function.
- 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 assert_greater_equal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_greater_equal(x, y, data=None, summarize=None, message=None,
Function assert_greater_equal_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_greater_equal_v2(x, y, message=None, summarize=None, name=None):
Function assert_greater_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_greater_v2(x, y, message=None, summarize=None, name=None):
Function assert_non_positive
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_non_positive(x, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function assert_equal_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_equal_v2(x, y, message=None, summarize=None, name=None):
Function assert_negative
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_negative(x, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function assert_none_equal_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_none_equal_v2(x, y, summarize=None, message=None, name=None):
Function assert_non_negative
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_non_negative(x, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function assert_shapes_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_shapes_v2(shapes, data=None, summarize=None, message=None,
Function _make_assert_msg_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _make_assert_msg_data(sym, x, y, summarize, test_op):
Function assert_shapes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_shapes(shapes, data=None, summarize=None, message=None, name=None):
Function assert_less_equal_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_less_equal_v2(x, y, message=None, summarize=None, name=None):
Function assert_positive
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_positive(x, data=None, summarize=None, message=None, name=None): # pylint: disable=missing-docstring
Function assert_less_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_less_v2(x, y, message=None, summarize=None, name=None):
Function assert_rank_at_least
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def assert_rank_at_least(
x, rank, data=None, summarize=None, message=None, name=None):
"""Assert `x` has rank equal to `rank` or higher.
Example of adding a dependency to an operation:
- 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 assert_near
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def assert_near(
x, y, rtol=None, atol=None, data=None, summarize=None, message=None,
name=None):
"""Assert the condition `x` and `y` are close element-wise.
- 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"