Skip to content

Fix Python 3.12+ SyntaxWarning and pandas 3.0 compatibility#80

Open
AlJohri wants to merge 2 commits into
AmenRa:masterfrom
AlJohri:fix/python3.13-compat
Open

Fix Python 3.12+ SyntaxWarning and pandas 3.0 compatibility#80
AlJohri wants to merge 2 commits into
AmenRa:masterfrom
AlJohri:fix/python3.13-compat

Conversation

@AlJohri
Copy link
Copy Markdown

@AlJohri AlJohri commented Mar 25, 2026

Summary

Fixes two issues encountered when using ranx with Python 3.12+ and pandas 3.0:

  • SyntaxWarning: invalid escape sequence — LaTeX strings in report.py used unescaped backslashes (e.g. \centering, \le, \midrule, \end, \label) which Python 3.12+ warns about and future versions will make a SyntaxError.

  • AssertionError: DataFrame Query IDs column dtype must be 'object' (string)qrels.py and run.py checked dtype == "O" to validate string columns, but pandas 3.0 defaults to StringDtype instead of object for string columns. Replaced with pd.api.types.is_string_dtype() which handles both.

Test plan

  • pytest — 124 passed, 0 failed (previously 6 failures from the dtype issue)
  • Verified no SyntaxWarning on Python 3.11, 3.12, and 3.13

- Fix invalid escape sequences in LaTeX strings in report.py
- Use pd.api.types.is_string_dtype() instead of dtype == "O" checks
  in qrels.py and run.py for pandas 3.0 StringDtype compatibility
@AlJohri AlJohri marked this pull request as ready for review March 25, 2026 13:20
@AlJohri
Copy link
Copy Markdown
Author

AlJohri commented Mar 25, 2026

Fixes #79

@diegoceccarelli
Copy link
Copy Markdown
Collaborator

@AmenRa looks good to me, any concerns merging this?

The typos spell checker flags scipy's ttest_rel as a misspelling.
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