File model_data_utils.py
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
import typing
import copy
import numpy as np
import scipy.sparse
from collections import defaultdict, OrderedDict
Function _extract_features
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def _extract_features(
features: List[List[List["Features"]]],
fake_features: List["Features"],
attribute: Text,
) -> Tuple[
- 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 _feature_arrays_for_attribute
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _feature_arrays_for_attribute(
attribute: Text,
absent_features: List[Any],
attribute_to_features: Dict[Text, List[List[List["Features"]]]],
training: bool,
- 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 featurize_training_examples
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def featurize_training_examples(
training_examples: List[Message],
attributes: List[Text],
entity_tag_specs: Optional[List["EntityTagSpec"]] = None,
featurizers: Optional[List[Text]] = 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 _surface_attributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _surface_attributes(
features: List[List[Dict[Text, List["Features"]]]],
featurizers: Optional[List[Text]] = None,
) -> DefaultDict[Text, List[List[Optional[List["Features"]]]]]:
"""Restructure the input.
- 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 _feature_arrays_for_attribute
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _feature_arrays_for_attribute(
Function featurize_training_examples
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def featurize_training_examples(
Function convert_to_data_format
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def convert_to_data_format(
features: Union[
List[List[Dict[Text, List["Features"]]]], List[Dict[Text, List["Features"]]]
],
fake_features: Optional[Dict[Text, List["Features"]]] = 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"