File inputs.py
has 442 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2024 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 features_map_fn
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def features_map_fn(features, local_radius, relative_pos_max_distance,
Function _flatten_dims
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _flatten_dims(tensor: tf.Tensor,
first_dim: Optional[int] = 0,
last_dim: Optional[int] = -1,
name: Optional[Text] = None) -> tf.Tensor:
"""Flattens the given span of dimensions in `tensor`.
- 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 features_map_fn
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def features_map_fn(features, local_radius, relative_pos_max_distance,
use_hard_g2l_mask, padding_id, eos_id, null_id, cls_id,
sep_id, sequence_length, global_sequence_length):
"""Make features."""
batch_size = tf.get_static_value(features['token_ids'].shape[0])
Function read_batches
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def read_batches(data_dir,
Function _pad_to_multiple
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _pad_to_multiple(tensor: tf.Tensor,
Function _make_relative_id_pattern
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _make_relative_id_pattern(
self, window_size: Union[int, tf.Tensor]) -> tf.Tensor:
"""Helper for making the relative id pattern for a particular window size.
For example, if `max_distance` is 3, `ignore_direction` is False, and
- 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 _pad_to_multiple
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _pad_to_multiple(tensor: tf.Tensor,
factor: Union[int, tf.Tensor],
axis: int,
mode: Optional[Text] = 'CONSTANT',
constant_values=0,
- 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"