Skip to content

TST: check total seconds of segmented index#530

Merged
audeerington merged 4 commits into
mainfrom
test_segmented_index_pandas_3
Apr 13, 2026
Merged

TST: check total seconds of segmented index#530
audeerington merged 4 commits into
mainfrom
test_segmented_index_pandas_3

Conversation

@audeerington
Copy link
Copy Markdown
Contributor

@audeerington audeerington commented Apr 13, 2026

This adds a test that checks whether the total seconds of the start and end levels of an index created with audformat.segmented_index() are as expected. (See #529)

Summary by Sourcery

Tests:

  • Add parametrized tests ensuring segmented_index start and end levels match expected total seconds for various floating-point inputs.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 13, 2026

Reviewer's Guide

Adds a new parametrized test ensuring that the total seconds derived from the start/end levels of segmented indexes match the original numeric inputs, and documents the related GitHub issue in the existing dtype test.

File-Level Changes

Change Details Files
Extend the existing segmented index dtype test with an inline reference to the related GitHub issue.
  • Update the docstring of the segmented index dtype test to mention the relevant GitHub issue for additional context.
tests/test_index.py
Add a regression test that validates total_seconds correctness for start and end levels in segmented indexes for various float/integer second inputs.
  • Introduce a new parametrized pytest function that constructs segmented indexes from different combinations of file paths and numeric start/end values.
  • Convert the MultiIndex start and end levels to series, compute their total seconds, and compare them against the original numeric starts/ends using NumPy's assert_almost_equal to allow for floating point tolerance.
tests/test_index.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In test_segmented_index_seconds, consider converting the starts and ends parameters to np.array(..., dtype=float) explicitly before comparison to avoid any ambiguity from mixing ints and floats across parametrizations.
  • You could add ids= to the @pytest.mark.parametrize for test_segmented_index_seconds to make it easier to see which specific case fails when a regression occurs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_segmented_index_seconds`, consider converting the `starts` and `ends` parameters to `np.array(..., dtype=float)` explicitly before comparison to avoid any ambiguity from mixing ints and floats across parametrizations.
- You could add `ids=` to the `@pytest.mark.parametrize` for `test_segmented_index_seconds` to make it easier to see which specific case fails when a regression occurs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@audeerington audeerington requested a review from hagenw April 13, 2026 06:01
@hagenw
Copy link
Copy Markdown
Member

hagenw commented Apr 13, 2026

Looks good.

I tested locally, and it passes when using pandas<3.0.0.

I would propose we merge this failing test first and afterwards implement a solution for it.

@audeerington audeerington merged commit a848f9f into main Apr 13, 2026
3 of 11 checks passed
@audeerington audeerington deleted the test_segmented_index_pandas_3 branch April 13, 2026 06:05
@hagenw hagenw mentioned this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants