File data.py
has 2050 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Data structures for preprocessing and wrangling of motion tracking output data. This is the main module handled by the user.
There are three main data structures to pay attention to:
- :class:`~deepof.data.Project`, which serves as a configuration hub for the whole pipeline
- :class:`~deepof.data.Coordinates`, which acts as an intermediary between project configuration and data, and contains
Function get_coords
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
def get_coords(
self,
center: str = False,
polar: bool = False,
speed: int = 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"
Further reading
Function preprocess
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
def preprocess(
self,
automatic_changepoints=False,
handle_ids: str = "concat",
window_size: int = 25,
- 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 load_tables
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def load_tables(self, verbose: bool = True) -> Tuple:
"""Load videos and tables into dictionaries.
Args:
verbose (bool): If True, prints the progress of data loading.
- 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 get_distances
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def get_distances(
self,
speed: int = 0,
selected_id: str = None,
filter_on_graph: bool = True,
- 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 get_angles
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def get_angles(
self,
degrees: bool = False,
speed: int = 0,
selected_id: str = 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 deep_unsupervised_embedding
has 28 arguments (exceeds 4 allowed). Consider refactoring. Open
def deep_unsupervised_embedding(
Function get_graph_dataset
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def get_graph_dataset(
self,
animal_id: str = None,
precomputed_tab_dict: table_dict = None,
center: str = False,
- 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 __init__
has 22 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function __init__
has 21 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function get_training_set
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_training_set(
self, current_table_dict: table_dict, test_videos: int = 0
) -> tuple:
"""Generate training and test sets as numpy.array objects for model training.
- 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 get_areas
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_areas(self, speed: int = 0, selected_id: str = "all") -> table_dict:
"""Return a table_dict object with all relevant areas (head, torso, back, full). Unless specified otherwise, the areas are computed for all animals.
Args:
speed (int): The derivative to use for speed.
- 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 set_up_project_directory
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def set_up_project_directory(self, debug=False):
"""Create a project directory where to save all produced results."""
# Create a project directory, as well as subfolders for videos and tables
project_path = os.path.join(self.project_path, self.project_name)
- 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 get_areas
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_areas(self, tab_dict: dict, verbose: bool = True) -> dict:
"""Compute all relevant areas (head, torso, back) per video and per frame in the data.
Args:
tab_dict (dict): Dictionary of pandas DataFrames containing the trajectories of all bodyparts.
- 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 supervised_annotation
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def supervised_annotation(
self,
params: Dict = {},
center: str = "Center",
align: str = "Spine_1",
- 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 edit_arenas
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def edit_arenas(
self, videos: list = None, arena_type: str = None, verbose: bool = True
): # pragma: no cover
"""Tag the arena in the videos.
- 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 preprocess
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def preprocess(
Function create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create(
self,
verbose: bool = True,
force: bool = False,
debug: bool = True,
- 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 __init__
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(
self,
animal_ids: List = None,
arena: str = "polygonal-autodetect",
bodypart_graph: Union[str, dict] = "deepof_14",
Function __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function get_coords
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_coords(
Function supervised_annotation
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def supervised_annotation(
Function merge
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def merge(self, *args, ignore_index=False):
"""Take a number of table_dict objects and merges them to the current one.
Returns a table_dict object of type 'merged'.
Only annotations of the first table_dict object are kept.
- 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 extend
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def extend(
self,
project_to_extend: coordinates,
verbose: bool = True,
debug: bool = True,
- 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 get_graph_dataset
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_graph_dataset(
Function create
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create(
Function get_distances
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_distances(
Function get_angles
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_angles(
Function get_distances
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_distances(self, tab_dict: dict, verbose: bool = True) -> dict:
"""Compute the distances between all selected body parts over time. If ego is provided, it only returns distances to a specified bodypart.
Args:
tab_dict (dict): Dictionary of pandas DataFrames containing the trajectories of all bodyparts.
- 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 get_angles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_angles(self, tab_dict: dict, verbose: bool = True) -> dict:
"""Compute all the angles between adjacent bodypart trios per video and per frame in the data.
Args:
tab_dict (dict): Dictionary of pandas DataFrames containing the trajectories of all bodyparts.
- 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"