Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytrendy/detect_trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def detect_trends(df: pd.DataFrame,
value_col (str):
Name of the column containing the primary signal to analyse for trend detection.
date_col (str|None):
Historically, this represents the name of the column containing timestamps, but pytrendy now allows for indexes of any type to be used. In general, this column represents a human readable reference to the x-position of the sequence. Normally this would be a date or timestamp, but any unique set of values could be used. Default is 'None', in which case an integer sequence will be generated and used to idenify segmenets.
Historically, this represents the name of the column containing dates, but pytrendy now allows for indexes of any type to be used. In general, this column represents a human readable reference to the x-position of the sequence. Normally this would be a date or timestamp, but any unique set of values could be used. Default is 'None', in which case an integer sequence will be generated and used to identify segments.
plot (bool, optional):
If `True`, generates a matplotlib plot showing the detected trend segments over the original signal.
Defaults to `True`.
Expand Down
2 changes: 1 addition & 1 deletion pytrendy/post_processing/segments_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_segments(df: pd.DataFrame) -> list[dict]:

Args:
df (pd.DataFrame):
Series DataFrame containing a `trend_flag` column.
Time series DataFrame containing a `trend_flag` column.

Returns:
list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def expand_contract_segments(df: pd.DataFrame, value_col: str, segments: list[di
Skips segments classified as 'abrupt' to preserve their precision.

Args:
df (pd.DataFrame): Series DataFrame.
df (pd.DataFrame): Time series DataFrame.
value_col (str): Name of the signal column.
segments (list): List of segment dictionaries.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def classify_trends(df: pd.DataFrame, value_col: str, segments: list[dict]) -> l
Adds a `'trend_class'` key to each segment based on similarity to synthetic patterns.

Args:
df (pd.DataFrame): Series DataFrame.
df (pd.DataFrame): Time series DataFrame.
value_col (str): Name of the signal column.
segments (list): List of segment dictionaries.

Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ def assert_segments_match(detected_segments, expected_segments):
Helper function to validate that detected segments match expected segments.

This function compares detected trend segments against expected segments,
validating that the direction, start date, and end date match for each segment.
validating that the direction, start time, and end time match for each segment.

Args:
detected_segments: List of dictionaries, each representing a detected segment.
Each dictionary must have the following keys:
- 'direction': str, the direction of the segment ('Up', 'Down', 'Flat', 'Noise')
- 'start': str or Timestamp, the start date of the segment
- 'end': str or Timestamp, the end date of the segment
- 'start': str, Timestamp, int, or float, the start time of the segment
- 'end': str, Timestamp, int, or float, the end time of the segment
expected_segments: List of dictionaries with the same structure as detected_segments.
Each dictionary must have the following keys:
- 'direction': str, the direction of the segment ('Up', 'Down', 'Flat', 'Noise')
- 'start': str, the start date of the segment in 'YYYY-MM-DD' format
- 'end': str, the end date of the segment in 'YYYY-MM-DD' format
- 'start': str, Timestamp, int, or float, the start time of the segment
- 'end': str, Timestamp, int, or float, the end time of the segment

Raises:
AssertionError: If the segments don't match in count, direction, or date boundaries.
AssertionError: If the segments don't match in count, direction, or time boundaries.
"""
# Assert number of segments matches
assert len(detected_segments) == len(expected_segments), \
Expand Down
Loading