Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix tests failing due to deprecations in pre-release dependencies #3746

Merged
merged 6 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions nilearn/image/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ def resample_img(
# preventing ringing artefact
# We need to add zero as a value considered for clipping, as it
# appears in padding images.
vmin = min(data.min(), 0)
vmax = max(data.max(), 0)
vmin = min(np.nanmin(data), 0)
vmax = max(np.nanmax(data), 0)
resampled_data.clip(vmin, vmax, out=resampled_data)

return new_img_like(img, resampled_data, target_affine)
Expand Down
3 changes: 1 addition & 2 deletions nilearn/image/tests/test_resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ def test_resampling_nan(affine, core_shape):

# check 3x3 transformation matrix
target_affine = np.eye(3)[axis_permutation]
with pytest.warns(Warning, match=r"(\bnan\b|invalid value)"):
resampled_img = resample_img(source_img, target_affine=target_affine)
resampled_img = resample_img(source_img, target_affine=target_affine)

resampled_data = get_data(resampled_img)
if full_data.ndim == 4:
Expand Down
6 changes: 5 additions & 1 deletion nilearn/maskers/nifti_maps_masker.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ def generate_report(self, displayed_maps=10):
from nilearn.reporting.html_report import generate_report

if (
displayed_maps != "all"
(isinstance(displayed_maps, str) and displayed_maps != "all")
or (
not isinstance(displayed_maps, str)
and np.all(displayed_maps != "all")
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is abit complex. Cna you give plain word explanation of the intended behevior

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it with the code. Is it clear enough like this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely clearer. To me at least.

and not isinstance(displayed_maps, (list, np.ndarray, int))
):
raise TypeError(
Expand Down