Showing 6 of 6 total issues
File segmentation.py
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Confirmed
import warnings
from typing import Optional
from typing import Union
import numpy as np
Function calculate_segments
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def calculate_segments(self) -> list[Segment]:
"""Calculate segments with similar trend for the given timeserie.
Calculates:
- boundaries of segments
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function _handle_input_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _handle_input_data(self, column, df, x, y):
# --- Handle input data
# error - most likely pandas dataframe as argument instead of kwarg
if x is not None and not isinstance(x, list):
# TODO: KS: 2022-09-07: accept also numpy array, ndarray,np.matrix, pd.Series
- 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 _handle_configuration
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _handle_configuration(self, config, n):
# Handle configuration
if config is None:
# use default configuration if no configuration is provided
self.config = Config()
- 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 _plot_segments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _plot_segments(obj, fig_size: FigSize = (8, 4)) -> None:
"""Plot all segments and linear trend lines.
Args:
fig_size: size of the figure e.g. (8, 4)
- 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"