Skip to content

Conversation

@hagenw
Copy link
Member

@hagenw hagenw commented Jan 24, 2026

Fixes errors in tests/test_misc_table.py related to the switch from object to string as default new dtype for empty indices in pandas 3.0.

Summary by Sourcery

Adjust miscellaneous table tests for pandas 3.0 index dtype behavior changes.

Tests:

  • Update misc table tests to explicitly set index dtypes (object/string) for Series, Index, and MultiIndex fixtures.
  • Adapt dtype-related parametrized tests to expect explicit index dtypes instead of relying on default/None values and remove obsolete str-based cases.
  • Ensure index extension and pickle-loading tests use consistent object/string index dtypes, including via audformat.utils.set_index_dtypes for MultiIndex.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 24, 2026

Reviewer's Guide

Adjusts misc table tests to explicitly specify index dtypes and expected dtype parameters to align with pandas 3.0’s change of default empty index dtype from object to string, and removes now-invalid test cases that relied on implicit object defaults.

File-Level Changes

Change Details Files
Explicitly set index dtypes in misc table tests to avoid dependence on pandas’ default index dtype and to keep expected audformat data type mappings stable.
  • Add explicit dtype="object" or dtype="string" to various pd.Index and pd.Series index constructions used in create_misc_table tests and index-manipulation tests.
  • Update parameterized test_dtype_column, test_dtype_index, and test_dtype_multiindex cases so that the dtype argument is explicitly passed as "object" where the test expects an object index.
  • Remove parametrized cases that passed str as a dtype and assumed the resulting index would be of object dtype, which is no longer valid with pandas 3.0 defaults.
  • Ensure index extension tests (test_extend_index, test_drop_extend_and_pick_index_order, and test_load_old_pickle) construct indices and multi-indices with explicit dtypes, including using audformat.utils.set_index_dtypes for MultiIndex, so behavior is deterministic across pandas versions.
tests/test_misc_table.py

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
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:

  • The choice between dtype="object" and dtype="string" in different test cases is not obvious; consider adding a small helper or comment (in the test factory or parameterization) that makes the intended distinction between legacy and new pandas behavior explicit and consistent.
  • There is quite a bit of repetition in constructing pd.Index([...], name="idx", dtype=...) and similar objects; consider introducing a small factory/helper in the tests to reduce duplication and make future dtype-related adjustments easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The choice between `dtype="object"` and `dtype="string"` in different test cases is not obvious; consider adding a small helper or comment (in the test factory or parameterization) that makes the intended distinction between legacy and new pandas behavior explicit and consistent.
- There is quite a bit of repetition in constructing `pd.Index([...], name="idx", dtype=...)` and similar objects; consider introducing a small factory/helper in the tests to reduce duplication and make future dtype-related adjustments easier.

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.

@hagenw hagenw changed the title TST: fix misc table tests TST: fix remaining tests Jan 27, 2026
@hagenw hagenw merged commit 639d29d into dev Jan 27, 2026
13 checks passed
@hagenw hagenw deleted the fix-misc-table-tests branch January 27, 2026 12:08
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