Skip to content

Enable Pandas 3#803

Draft
Scienfitz wants to merge 8 commits into
mainfrom
feature/pandas3
Draft

Enable Pandas 3#803
Scienfitz wants to merge 8 commits into
mainfrom
feature/pandas3

Conversation

@Scienfitz
Copy link
Copy Markdown
Collaborator

TBD: Refinement and Fixes

Pandas 3 is only supported for Python 3.11+ so the 3.10 test serves as a verification that everything (still) works in Pandas 2

Scienfitz added 7 commits May 22, 2026 19:25
pandas 3 uses Arrow-backed string dtypes by default. Calling .values on
such a Series returns an ArrowExtensionArray which does not support
NumPy-style multi-dimensional indexing ([:, None]). Replace .values with
np.asarray() to guarantee a NumPy array in all pandas versions.
DataFrame.applymap was deprecated in pandas 2.1 and removed in pandas 3.0.
Use getattr fallback to DataFrame.map (added in 2.1) while retaining
compatibility with pandas < 2.1.
In pandas 3, assigning an object value into a typed column raises a
TypeError instead of emitting a FutureWarning as in pandas 2. Cast
affected columns to object dtype before the Dummy assignment in
DiscreteDependenciesConstraint to make the operation valid in all
pandas versions. Update tests accordingly and remove the now-unnecessary
FutureWarning suppression from pytest.ini.
pandas 3 with Copy-on-Write may return read-only NumPy arrays from
.values. torch.from_numpy() raises a UserWarning for non-writable arrays,
which pytest treats as an error. Use DataFrame.to_numpy(copy=True) to
guarantee a writable array in all pandas versions.
- hypothesis_strategies/parameters.py: pandas 3 Arrow-backed string
  indices return ArrowStringArray from .index.values, which
  hypothesis sampled_from() cannot draw from; convert to list instead.
- utils/dataframe.py: pandas 3 Copy-on-Write may return read-only
  NumPy arrays from to_numpy(copy=False); add a writability check and
  copy before passing to torch.from_numpy().
comp_rep_bounds.values returns a read-only NumPy array under pandas 3
Copy-on-Write semantics. Use to_numpy(copy=True) at the two call sites
in sample_uniform so that torch.from_numpy() receives a writable array.
astype(copy=False) returns a read-only view when the array already has
the target dtype. Add the same writability check as the pd.Series/
DataFrame branch to ensure torch.from_numpy() always receives a
writable array.
@Scienfitz Scienfitz added this to the 0.15.0 milestone May 22, 2026
@Scienfitz Scienfitz self-assigned this May 22, 2026
@Scienfitz Scienfitz added the dependencies Pull requests that update a dependency file label May 22, 2026
The method accepts a bounds array that callers may source directly from
comp_rep_bounds.values, which under pandas 3 CoW can be read-only.
Guard with a writability check inside the method so all call paths are
covered, including tests that call the method directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant