Skip to content

Fix NumPy 2.4+ / pandas 3 compatibility#1650

Open
cfuselli wants to merge 6 commits intomasterfrom
fix-numpy
Open

Fix NumPy 2.4+ / pandas 3 compatibility#1650
cfuselli wants to merge 6 commits intomasterfrom
fix-numpy

Conversation

@cfuselli
Copy link
Member

@cfuselli cfuselli commented Mar 2, 2026

Why

Recent CI started failing after dependency refreshes (NumPy 2.4+, pandas 3 / pyarrow strings), with errors like:

  • AttributeError: module 'numpy' has no attribute 'in1d'
  • TypeError: Expected string or tuple of strings, got <class 'pandas.arrays.ArrowStringArray'>
  • event display tests failing due to scalar vs 1-element array time handling.

What changed

  • Replaced np.in1d with np.isin in straxen code and tests where applicable.
  • Fixed _event_display to consistently use scalar event[...] fields (instead of events[...] array fields) for time ranges and titles.
  • Added runtime compatibility layer in straxen/_compat.py and invoked it from straxen/__init__.py:
    • alias np.in1d to np.isin when missing (NumPy >= 2.4)
    • patch strax.to_str_tuple / strax.utils.to_str_tuple to accept pandas ExtensionArray (e.g. ArrowStringArray)
  • Updated SCADA tests for newer pandas behavior:
    • timezone assertion compares string representation (zoneinfo vs pytz)
    • positional indexing now uses .iloc.

Notes

  • Compatibility patches were moved out of inline __init__ logic into straxen/_compat.py to keep imports clean and satisfy pre-commit (flake8 E402).

@coveralls
Copy link

coveralls commented Mar 2, 2026

Coverage Status

coverage: 88.965% (+0.01%) from 88.954%
when pulling 8dca461 on fix-numpy
into 310bd23 on master.

@cfuselli cfuselli changed the title Fix numpy for compatibility 2.4+ Fix NumPy 2.4+ / pandas 3 compatibility Mar 3, 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