From e8e9b50d9645ab40d37eb059f16f745a28f4ad2b Mon Sep 17 00:00:00 2001 From: OpenCode Agent Date: Thu, 9 Jul 2026 06:19:15 +0000 Subject: [PATCH] docs: update docstrings for consistency with index-type generalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix detect_trends.py: timestamps → dates, segmenets → segments - Fix segments_refine/trend_classify.py: Series DataFrame → Time series DataFrame - Fix segments_refine/gradual_expand_contract.py: Series DataFrame → Time series DataFrame - Fix segments_get.py: Series DataFrame → Time series DataFrame - Update conftest.py docstring to mention numeric types (int, float) in addition to str/Timestamp --- pytrendy/detect_trends.py | 2 +- pytrendy/post_processing/segments_get.py | 2 +- .../segments_refine/gradual_expand_contract.py | 2 +- .../segments_refine/trend_classify.py | 2 +- tests/conftest.py | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pytrendy/detect_trends.py b/pytrendy/detect_trends.py index 7b27e49b..073ae5a9 100644 --- a/pytrendy/detect_trends.py +++ b/pytrendy/detect_trends.py @@ -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`. diff --git a/pytrendy/post_processing/segments_get.py b/pytrendy/post_processing/segments_get.py index ec113309..d27277b0 100644 --- a/pytrendy/post_processing/segments_get.py +++ b/pytrendy/post_processing/segments_get.py @@ -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: diff --git a/pytrendy/post_processing/segments_refine/gradual_expand_contract.py b/pytrendy/post_processing/segments_refine/gradual_expand_contract.py index a76985e3..87de5ffe 100644 --- a/pytrendy/post_processing/segments_refine/gradual_expand_contract.py +++ b/pytrendy/post_processing/segments_refine/gradual_expand_contract.py @@ -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. diff --git a/pytrendy/post_processing/segments_refine/trend_classify.py b/pytrendy/post_processing/segments_refine/trend_classify.py index 841caead..7a3f4b54 100644 --- a/pytrendy/post_processing/segments_refine/trend_classify.py +++ b/pytrendy/post_processing/segments_refine/trend_classify.py @@ -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. diff --git a/tests/conftest.py b/tests/conftest.py index ac92775a..559af717 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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), \