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

[MAINT] add warning to deprecate darkness #3855

Merged
merged 12 commits into from Jul 21, 2023
8 changes: 8 additions & 0 deletions nilearn/plotting/surf_plotting.py
Expand Up @@ -22,6 +22,8 @@
from nilearn.surface import load_surf_data, load_surf_mesh, vol_to_surf
from nilearn.surface.surface import _check_mesh

from warnings import warn

Check warning on line 25 in nilearn/plotting/surf_plotting.py

View check run for this annotation

Codecov / codecov/patch

nilearn/plotting/surf_plotting.py#L25

Added line #L25 was not covered by tests

VALID_VIEWS = "anterior", "posterior", "medial", "lateral", "dorsal", "ventral"
VALID_HEMISPHERES = "left", "right"

Expand Down Expand Up @@ -460,6 +462,12 @@

if darkness is not None:
bg_faces *= darkness
warn(

Check warning on line 465 in nilearn/plotting/surf_plotting.py

View check run for this annotation

Codecov / codecov/patch

nilearn/plotting/surf_plotting.py#L465

Added line #L465 was not covered by tests
(
"The `darkness` parameter will be deprecated in release 0.13. "
"We recommend setting `darkness` to None"
)
alishakodibagkar marked this conversation as resolved.
Show resolved Hide resolved
)
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved

face_colors = plt.cm.gray_r(bg_faces)

Expand Down
15 changes: 15 additions & 0 deletions nilearn/plotting/tests/test_surf_plotting.py
Expand Up @@ -1105,3 +1105,18 @@ def test_compute_facecolors_matplotlib():
assert not np.allclose(
facecolors_manually_rescaled, facecolors_auto_normalized
)

with pytest.warns(
UserWarning,
alishakodibagkar marked this conversation as resolved.
Show resolved Hide resolved
match=(
"The `darkness` parameter will be deprecated in release 0.13. "
"We recommend setting `darkness` to None"
),
):
facecolors_manually_rescaled = _compute_facecolors_matplotlib(
bg_map_scaled,
mesh[1],
len(mesh[0]),
0.5,
alpha,
)