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] Implement deprecation warnings-as-errors in prerelease test using pytest fixture #3936

Merged
merged 9 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
58 changes: 58 additions & 0 deletions .github/workflows/check_deprecations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: check deprecations

# Runs once a month.
# Checks for deprecations of core dependencies of nilearn
# Turns deprecation warnings into errors so we can handle
# them before an actual failure happens.

on:

# Uses the cron schedule for github actions
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
#
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
schedule:
- cron: 0 0 25 * * # on the 25th of every monday
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deprecations:
if: github.repository == 'nilearn/nilearn'
runs-on: ubuntu-latest
env:
# TODO: Add another env variable that will be used in conftest.py
PIP_FLAGS: --pre
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.11
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install dependencies
run: ./build_tools/github/dependencies.sh

- name: Install nilearn
run: ./build_tools/github/install.sh

- name: Run tests
run: python -m pytest --pyargs nilearn
1 change: 0 additions & 1 deletion nilearn/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def warnings_as_errors():
with warnings.catch_warnings():
warnings.filterwarnings(
"error",
# TODO: try with module argument in prerelease local env
message=".*numpy.*|.*scipy.*|.*nibabel.*|"
".*joblib.*|.*pandas.*|.*scikit-learn.*",
category=DeprecationWarning,
Expand Down
4 changes: 2 additions & 2 deletions nilearn/mass_univariate/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_tvalue_with_alternative_library(tested_vars, target_vars, covars=None):
current_tested_mask[j] = True
current_design_matrix = design_matrix[:, current_tested_mask]
ols_fit = OLS(current_target, current_design_matrix).fit()
t_values[i, j] = np.ravel(ols_fit.t_test(test_matrix).tvalue)
t_values[i, j] = np.squeeze(ols_fit.t_test(test_matrix).tvalue)

except ImportError: # use linalg if statsmodels is not available
from numpy import linalg
Expand Down Expand Up @@ -83,7 +83,7 @@ def get_tvalue_with_alternative_library(tested_vars, target_vars, covars=None):
/ float(n_samples - lost_dof)
* t_val_denom_aux
)
t_values[j, i] = np.ravel(t_val_num / t_val_denom)
t_values[j, i] = np.squeeze(t_val_num / t_val_denom)

t_values = t_values.T
assert t_values.shape == (n_regressors, n_descriptors)
Expand Down