Skip to content

Commit 4984e53

Browse files
authored
fix: Pandas deprecations (#906)
* chore(tox): Add UV_EXTRA_INDEX_URL for pre-releases * fix: Copy correlation values before zeroing diagonal * fix: Pandas deprecation * chore(tox): Pass environment variables * chore(ci): Enable Python 3.13 tests * chore: Disable 3.13. runs until traits is figured out
1 parent 2e5dcb5 commit 4984e53

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
runs-on: ubuntu-latest
9595
strategy:
9696
matrix:
97-
python-version: ["3.9", "3.10", "3.11", "3.12"]
97+
python-version: ["3.9", "3.10", "3.11", "3.12"] #, "3.13"]
9898
dependencies: [latest, pre]
9999
include:
100100
- python-version: "3.9"

niworkflows/interfaces/utility.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ class AddTSVHeader(SimpleInterface):
251251
>>> addheader.inputs.in_file = 'data.tsv'
252252
>>> addheader.inputs.columns = ['a', 'b', 'c', 'd', 'e']
253253
>>> res = addheader.run()
254-
>>> df = pd.read_csv(res.outputs.out_file, delim_whitespace=True,
255-
... index_col=None)
254+
>>> df = pd.read_csv(res.outputs.out_file, sep='\s+', index_col=None)
256255
>>> df.columns.ravel().tolist()
257256
['a', 'b', 'c', 'd', 'e']
258257
@@ -311,7 +310,7 @@ class JoinTSVColumns(SimpleInterface):
311310
>>> join.inputs.in_file = 'data.tsv'
312311
>>> join.inputs.join_file = 'add.tsv'
313312
>>> res = join.run()
314-
>>> df = pd.read_csv(res.outputs.out_file, delim_whitespace=True,
313+
>>> df = pd.read_csv(res.outputs.out_file, sep='\s+',
315314
... index_col=None, dtype=float, header=None)
316315
>>> df.columns.ravel().tolist() == list(range(5))
317316
True
@@ -328,8 +327,7 @@ class JoinTSVColumns(SimpleInterface):
328327
>>> res = join.run()
329328
>>> res.outputs.out_file # doctest: +ELLIPSIS
330329
'...data_joined.tsv'
331-
>>> df = pd.read_csv(res.outputs.out_file, delim_whitespace=True,
332-
... index_col=None)
330+
>>> df = pd.read_csv(res.outputs.out_file, sep='\s+', index_col=None)
333331
>>> df.columns.ravel().tolist()
334332
['a', 'b', 'c', 'd', 'e']
335333
@@ -342,8 +340,7 @@ class JoinTSVColumns(SimpleInterface):
342340
>>> join.inputs.side = 'left'
343341
>>> join.inputs.columns = ['a', 'b', 'c', 'd', 'e']
344342
>>> res = join.run()
345-
>>> df = pd.read_csv(res.outputs.out_file, delim_whitespace=True,
346-
... index_col=None)
343+
>>> df = pd.read_csv(res.outputs.out_file, sep='\s+', index_col=None)
347344
>>> df.columns.ravel().tolist()
348345
['a', 'b', 'c', 'd', 'e']
349346

niworkflows/viz/plots.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,11 @@ def confounds_correlation_plot(
926926
gs_descending = gs_descending[:max_dim]
927927
features = [p for p in corr.columns if p in gs_descending]
928928
corr = corr.loc[features, features]
929-
np.fill_diagonal(corr.values, 0)
929+
930+
# Modifying in-place is no longer supported
931+
corr_vals = corr.to_numpy(copy=True)
932+
np.fill_diagonal(corr_vals, 0)
933+
corr.iloc[:, :] = corr_vals
930934

931935
if figure is None:
932936
plt.figure(figsize=(15, 5))

tox.ini

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ python =
1414
3.10: py310
1515
3.11: py311
1616
3.12: py312
17+
3.13: py313
1718

1819
[gh-actions:env]
1920
DEPENDS =
@@ -27,6 +28,20 @@ labels = test
2728
pip_pre =
2829
pre: true
2930
pass_env =
31+
TEMPLATEFLOW_HOME
32+
# Freesurfer variables searched for
33+
FREESURFER_HOME
34+
SUBJECTS_DIR
35+
FS_LICENSE
36+
# CI variables
37+
TEST_DATA_HOME
38+
TEST_OUTPUT_DIR
39+
TEST_WORK_DIR
40+
FMRIPREP_REGRESSION_SOURCE
41+
CACHED_WORK_DIRECTORY
42+
# CircleCI-specific
43+
CIRCLE_NPROCS
44+
SAVE_CIRCLE_ARTIFACTS
3045
# getpass.getuser() sources for Windows:
3146
LOGNAME
3247
USER
@@ -39,9 +54,12 @@ pass_env =
3954
CLICOLOR
4055
CLICOLOR_FORCE
4156
PYTHON_GIL
57+
deps =
58+
py313: traits @ git+https://github.com/enthought/traits.git@10954eb
4259
extras = tests
4360
setenv =
4461
pre: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
62+
pre: UV_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
4563
uv_resolution =
4664
min: lowest-direct
4765

@@ -91,7 +109,6 @@ set_env =
91109
# https://github.com/pypa/pip/issues/11684
92110
# https://github.com/pypa/pip/issues/12243
93111
strict: PYTHONWARNINGS=error,once:pkg_resources is deprecated as an API.:DeprecationWarning:pip._internal.metadata.importlib._envs,once:Unimplemented abstract methods {'locate_file'}:DeprecationWarning:pip._internal.metadata.importlib._dists
94-
commands_pre =
95112
commands =
96113
python -m build
97114
python -m twine check dist/*

0 commit comments

Comments
 (0)