File nest_util.py
has 1350 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2023 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 sequence_like
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def sequence_like(instance, args):
"""Converts the sequence `args` to the same type as `instance`.
Args:
instance: an instance of `tuple`, `list`, `namedtuple`, `dict`,
- 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 _tf_core_yield_sorted_items
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def _tf_core_yield_sorted_items(iterable):
"""Yield (key, value) pairs for `iterable` in a deterministic order.
For Sequences, the key will be an int, the array index of a value.
For Mappings, the key will be the dictionary key.
- 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 _tf_data_yield_value
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _tf_data_yield_value(iterable):
"""Yield elements of `iterable` in a deterministic order.
Args:
iterable: an iterable.
- 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 _tf_core_pack_sequence_as
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _tf_core_pack_sequence_as(
structure, flat_sequence, expand_composites, sequence_fn=None
):
"""Implements sequence packing, with the option to alter the structure."""
is_nested_fn = (
- 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 _tf_core_packed_nest_with_indices
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _tf_core_packed_nest_with_indices(
Function yield_flat_up_to
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def yield_flat_up_to(modality, shallow_tree, input_tree, is_nested_fn, path=()):
Function assert_shallow_structure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_shallow_structure(
Function assert_same_structure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def assert_same_structure(
Function pack_sequence_as
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def pack_sequence_as(
Avoid too many return
statements within this function. Open
return type(instance)(sequence_like(instance.__wrapped__, args))
Avoid too many return
statements within this function. Open
return instance.__tf_unflatten__(metadata, tuple(args))
Avoid too many return
statements within this function. Open
return spec._from_components(args[0]) # pylint: disable=protected-access
Avoid too many return
statements within this function. Open
return instance._from_components(args[0]) # pylint: disable=protected-access
Avoid too many return
statements within this function. Open
return sequence_like(list(instance), args)
Avoid too many return
statements within this function. Open
return type(instance)(args)