diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index f4489de..8c68ee6 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/setup-python@v5 - name: Install dependencies run: | - pip install -r doc_conf/doc-requirements.txt + python -m pip install .[doc, plotting] pip install -e . - name: Sphinx build id: build-docs diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index c869baf..4fe384c 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -27,13 +27,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - # - name: Lint with flake8 - # uses: py-actions/flake8@v2.3.0 + python -m pip install .[dependencies] - name: Generate coverage report run: | - pip install pytest pytest-cov + python -m pip install .[test] pytest --cov=./ --cov-report=xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.5.0 diff --git a/doc_conf/conf.py b/doc_conf/conf.py index a0ff7c9..b93dff3 100644 --- a/doc_conf/conf.py +++ b/doc_conf/conf.py @@ -13,12 +13,12 @@ # serve to show the default. import os -import sys import warnings -import sphinx_gallery -import sphinx_bootstrap_theme from distutils.version import LooseVersion + import matplotlib +import sphinx_bootstrap_theme +import sphinx_gallery # Disable agg warnings in doc warnings.filterwarnings( diff --git a/doc_conf/doc-requirements.txt b/doc_conf/doc-requirements.txt deleted file mode 100644 index 4192564..0000000 --- a/doc_conf/doc-requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ ---extra-index-url https://download.pytorch.org/whl/cu118 -joblib -matplotlib -memory_profiler -mne -nilearn -numpy -numpydoc -pandas -pillow -PyQt5 -pyvista -pyvistaqt -scikit-learn -scipy -sphinx-bootstrap-theme -sphinxcontrib-bibtex -sphinx-gallery -torch -torchmetrics diff --git a/docs/_downloads/0f0a1edc554c21f6f7fda8f53284928a/plot_2D_simulation_example.py b/docs/_downloads/0f0a1edc554c21f6f7fda8f53284928a/plot_2D_simulation_example.py index 57bee37..4fdb7dc 100644 --- a/docs/_downloads/0f0a1edc554c21f6f7fda8f53284928a/plot_2D_simulation_example.py +++ b/docs/_downloads/0f0a1edc554c21f6f7fda8f53284928a/plot_2D_simulation_example.py @@ -51,20 +51,19 @@ arXiv preprint arXiv:2106.02590. """ +import matplotlib.pyplot as plt ############################################################################# # Imports needed for this script # ------------------------------ import numpy as np -import matplotlib.pyplot as plt -from sklearn.feature_extraction import image from sklearn.cluster import FeatureAgglomeration +from sklearn.feature_extraction import image -from hidimstat.scenario import multivariate_simulation -from hidimstat.stat_tools import zscore_from_pval, pval_from_cb -from hidimstat.desparsified_lasso import desparsified_lasso from hidimstat.clustered_inference import clustered_inference +from hidimstat.desparsified_lasso import desparsified_lasso from hidimstat.ensemble_clustered_inference import ensemble_clustered_inference - +from hidimstat.scenario import multivariate_simulation +from hidimstat.stat_tools import pval_from_cb, zscore_from_pval ############################################################################# # Specific plotting functions diff --git a/docs/_downloads/6f624092537330c9f373c01828b2b9ae/plot_diabetes_variable_importance_example.py b/docs/_downloads/6f624092537330c9f373c01828b2b9ae/plot_diabetes_variable_importance_example.py index 29cf767..f6ccf40 100644 --- a/docs/_downloads/6f624092537330c9f373c01828b2b9ae/plot_diabetes_variable_importance_example.py +++ b/docs/_downloads/6f624092537330c9f373c01828b2b9ae/plot_diabetes_variable_importance_example.py @@ -10,10 +10,11 @@ # Imports needed for this script # ------------------------------ +import matplotlib.pyplot as plt import numpy as np -from hidimstat.BBI import BlockBasedImportance from sklearn.datasets import load_diabetes -import matplotlib.pyplot as plt + +from hidimstat.BBI import BlockBasedImportance plt.rcParams.update({"font.size": 14}) diff --git a/docs/_downloads/76c0979bf6618aa210fd11bb28dcf896/plot_fmri_data_example.py b/docs/_downloads/76c0979bf6618aa210fd11bb28dcf896/plot_fmri_data_example.py index ef0625f..25b89b8 100644 --- a/docs/_downloads/76c0979bf6618aa210fd11bb28dcf896/plot_fmri_data_example.py +++ b/docs/_downloads/76c0979bf6618aa210fd11bb28dcf896/plot_fmri_data_example.py @@ -45,21 +45,21 @@ # ------------------------------ import numpy as np import pandas as pd -from sklearn.utils import Bunch -from sklearn.cluster import FeatureAgglomeration -from sklearn.feature_extraction import image -from sklearn.linear_model import Ridge from nilearn import datasets -from nilearn.input_data import NiftiMasker from nilearn.image import mean_img +from nilearn.input_data import NiftiMasker from nilearn.plotting import plot_stat_map, show +from sklearn.cluster import FeatureAgglomeration +from sklearn.feature_extraction import image +from sklearn.linear_model import Ridge +from sklearn.utils import Bunch -from hidimstat.stat_tools import zscore_from_pval, pval_from_scale -from hidimstat.standardized_svr import standardized_svr -from hidimstat.permutation_test import permutation_test, permutation_test_cv from hidimstat.adaptive_permutation_threshold import ada_svr from hidimstat.clustered_inference import clustered_inference from hidimstat.ensemble_clustered_inference import ensemble_clustered_inference +from hidimstat.permutation_test import permutation_test, permutation_test_cv +from hidimstat.standardized_svr import standardized_svr +from hidimstat.stat_tools import pval_from_scale, zscore_from_pval ############################################################################# diff --git a/examples/plot_2D_simulation_example.py b/examples/plot_2D_simulation_example.py index 57bee37..4fdb7dc 100644 --- a/examples/plot_2D_simulation_example.py +++ b/examples/plot_2D_simulation_example.py @@ -51,20 +51,19 @@ arXiv preprint arXiv:2106.02590. """ +import matplotlib.pyplot as plt ############################################################################# # Imports needed for this script # ------------------------------ import numpy as np -import matplotlib.pyplot as plt -from sklearn.feature_extraction import image from sklearn.cluster import FeatureAgglomeration +from sklearn.feature_extraction import image -from hidimstat.scenario import multivariate_simulation -from hidimstat.stat_tools import zscore_from_pval, pval_from_cb -from hidimstat.desparsified_lasso import desparsified_lasso from hidimstat.clustered_inference import clustered_inference +from hidimstat.desparsified_lasso import desparsified_lasso from hidimstat.ensemble_clustered_inference import ensemble_clustered_inference - +from hidimstat.scenario import multivariate_simulation +from hidimstat.stat_tools import pval_from_cb, zscore_from_pval ############################################################################# # Specific plotting functions diff --git a/examples/plot_diabetes_variable_importance_example.py b/examples/plot_diabetes_variable_importance_example.py index cb17cf4..51e5c3d 100644 --- a/examples/plot_diabetes_variable_importance_example.py +++ b/examples/plot_diabetes_variable_importance_example.py @@ -10,10 +10,11 @@ # Imports needed for this script # ------------------------------ +import matplotlib.pyplot as plt import numpy as np -from hidimstat.BBI import BlockBasedImportance from sklearn.datasets import load_diabetes -import matplotlib.pyplot as plt + +from hidimstat.BBI import BlockBasedImportance plt.rcParams.update({"font.size": 14}) diff --git a/examples/plot_fmri_data_example.py b/examples/plot_fmri_data_example.py index ef0625f..25b89b8 100644 --- a/examples/plot_fmri_data_example.py +++ b/examples/plot_fmri_data_example.py @@ -45,21 +45,21 @@ # ------------------------------ import numpy as np import pandas as pd -from sklearn.utils import Bunch -from sklearn.cluster import FeatureAgglomeration -from sklearn.feature_extraction import image -from sklearn.linear_model import Ridge from nilearn import datasets -from nilearn.input_data import NiftiMasker from nilearn.image import mean_img +from nilearn.input_data import NiftiMasker from nilearn.plotting import plot_stat_map, show +from sklearn.cluster import FeatureAgglomeration +from sklearn.feature_extraction import image +from sklearn.linear_model import Ridge +from sklearn.utils import Bunch -from hidimstat.stat_tools import zscore_from_pval, pval_from_scale -from hidimstat.standardized_svr import standardized_svr -from hidimstat.permutation_test import permutation_test, permutation_test_cv from hidimstat.adaptive_permutation_threshold import ada_svr from hidimstat.clustered_inference import clustered_inference from hidimstat.ensemble_clustered_inference import ensemble_clustered_inference +from hidimstat.permutation_test import permutation_test, permutation_test_cv +from hidimstat.standardized_svr import standardized_svr +from hidimstat.stat_tools import pval_from_scale, zscore_from_pval ############################################################################# diff --git a/examples_not_exhibited/plot_fig_1_nguyen_et_al.py b/examples_not_exhibited/plot_fig_1_nguyen_et_al.py index 91efffb..17e8815 100644 --- a/examples_not_exhibited/plot_fig_1_nguyen_et_al.py +++ b/examples_not_exhibited/plot_fig_1_nguyen_et_al.py @@ -12,11 +12,12 @@ """ import matplotlib.pyplot as plt import numpy as np +from joblib import Parallel, delayed +from sklearn.preprocessing import StandardScaler + from hidimstat.knockoffs import knockoff_aggregation, model_x_knockoff from hidimstat.knockoffs.data_simulation import simu_data from hidimstat.knockoffs.utils import cal_fdp_power -from joblib import Parallel, delayed -from sklearn.preprocessing import StandardScaler color_blue = "#1f77b4" color_teal = "#1fbecf" diff --git a/examples_not_exhibited/plot_meg_data_example.py b/examples_not_exhibited/plot_meg_data_example.py index bc529ea..b3c19b2 100644 --- a/examples_not_exhibited/plot_meg_data_example.py +++ b/examples_not_exhibited/plot_meg_data_example.py @@ -23,14 +23,15 @@ """ import os -import numpy as np + import matplotlib.image as mpimg import matplotlib.pyplot as plt import mne -from scipy.sparse.csgraph import connected_components +import numpy as np from mne.datasets import sample, somato -from mne.inverse_sparse.mxne_inverse import _prepare_gain, _make_sparse_stc -from mne.minimum_norm import make_inverse_operator, apply_inverse +from mne.inverse_sparse.mxne_inverse import _make_sparse_stc, _prepare_gain +from mne.minimum_norm import apply_inverse, make_inverse_operator +from scipy.sparse.csgraph import connected_components from sklearn.cluster import FeatureAgglomeration from sklearn.metrics.pairwise import pairwise_distances diff --git a/hidimstat/BBI.py b/hidimstat/BBI.py index ccf15f7..297e959 100644 --- a/hidimstat/BBI.py +++ b/hidimstat/BBI.py @@ -9,24 +9,17 @@ from sklearn.base import BaseEstimator, TransformerMixin from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.linear_model import RidgeCV -from sklearn.metrics import ( - log_loss, - mean_absolute_error, - mean_squared_error, - roc_auc_score, - r2_score, -) -from sklearn.model_selection import KFold, GroupKFold +from sklearn.metrics import (log_loss, mean_absolute_error, mean_squared_error, + r2_score, roc_auc_score) +from sklearn.model_selection import GroupKFold, KFold from sklearn.pipeline import make_pipeline from sklearn.preprocessing import OneHotEncoder, StandardScaler from sklearn.utils.validation import check_is_fitted -from .compute_importance import ( - joblib_compute_conditional, - joblib_compute_permutation, -) +from .compute_importance import (joblib_compute_conditional, + joblib_compute_permutation) from .Dnn_learner import Dnn_learner -from .utils import convert_predict_proba, create_X_y, compute_imp_std +from .utils import compute_imp_std, convert_predict_proba, create_X_y class BlockBasedImportance(BaseEstimator, TransformerMixin): diff --git a/hidimstat/Dnn_learner.py b/hidimstat/Dnn_learner.py index 366e9be..c986aa1 100644 --- a/hidimstat/Dnn_learner.py +++ b/hidimstat/Dnn_learner.py @@ -1,5 +1,6 @@ import numpy as np from sklearn.base import BaseEstimator + from .Dnn_learner_single import Dnn_learner_single diff --git a/hidimstat/Dnn_learner_single.py b/hidimstat/Dnn_learner_single.py index 64b7a7b..f25b489 100644 --- a/hidimstat/Dnn_learner_single.py +++ b/hidimstat/Dnn_learner_single.py @@ -8,15 +8,8 @@ from sklearn.preprocessing import OneHotEncoder from sklearn.utils.validation import check_is_fitted -from .utils import ( - create_X_y, - dnn_net, - joblib_ensemble_dnnet, - ordinal_encode, - relu, - sigmoid, - softmax, -) +from .utils import (create_X_y, dnn_net, joblib_ensemble_dnnet, ordinal_encode, + relu, sigmoid, softmax) class Dnn_learner_single(BaseEstimator): diff --git a/hidimstat/__init__.py b/hidimstat/__init__.py index 47c955c..f17c584 100644 --- a/hidimstat/__init__.py +++ b/hidimstat/__init__.py @@ -5,8 +5,8 @@ from .Dnn_learner_single import Dnn_learner_single from .ensemble_clustered_inference import ensemble_clustered_inference from .importance_functions import compute_loco -from .knockoffs import model_x_knockoff from .knockoff_aggregation import knockoff_aggregation +from .knockoffs import model_x_knockoff from .multi_sample_split import aggregate_quantiles from .noise_std import group_reid, reid from .permutation_test import permutation_test_cv diff --git a/hidimstat/clustered_inference.py b/hidimstat/clustered_inference.py index 1273df9..5202f0a 100644 --- a/hidimstat/clustered_inference.py +++ b/hidimstat/clustered_inference.py @@ -1,10 +1,10 @@ import numpy as np -from sklearn.utils import resample from sklearn.preprocessing import StandardScaler +from sklearn.utils import resample from sklearn.utils.validation import check_memory +from .desparsified_lasso import desparsified_group_lasso, desparsified_lasso from .stat_tools import pval_from_cb -from .desparsified_lasso import desparsified_lasso, desparsified_group_lasso def _subsampling(n_samples, train_size, groups=None, seed=0): diff --git a/hidimstat/compute_importance.py b/hidimstat/compute_importance.py index ec99a75..58437fc 100644 --- a/hidimstat/compute_importance.py +++ b/hidimstat/compute_importance.py @@ -1,15 +1,14 @@ +import itertools import warnings from collections import Counter -import itertools + import numpy as np from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.metrics import mean_absolute_error, r2_score, roc_auc_score from sklearn.model_selection import GridSearchCV -from .RandomForestModified import ( - RandomForestClassifierModified, - RandomForestRegressorModified, -) +from .RandomForestModified import (RandomForestClassifierModified, + RandomForestRegressorModified) from .utils import convert_predict_proba, ordinal_encode, sample_predictions warnings.filterwarnings("ignore") diff --git a/hidimstat/desparsified_lasso.py b/hidimstat/desparsified_lasso.py index a6169ce..aaa5e03 100644 --- a/hidimstat/desparsified_lasso.py +++ b/hidimstat/desparsified_lasso.py @@ -1,12 +1,12 @@ import numpy as np +from joblib import Parallel, delayed from numpy.linalg import multi_dot from scipy import stats from scipy.linalg import inv -from joblib import Parallel, delayed -from sklearn.utils.validation import check_memory from sklearn.linear_model import Lasso +from sklearn.utils.validation import check_memory -from .noise_std import reid, group_reid +from .noise_std import group_reid, reid from .stat_tools import pval_from_two_sided_pval_and_sign diff --git a/hidimstat/ensemble_clustered_inference.py b/hidimstat/ensemble_clustered_inference.py index d44a277..73bbdad 100644 --- a/hidimstat/ensemble_clustered_inference.py +++ b/hidimstat/ensemble_clustered_inference.py @@ -1,8 +1,8 @@ import numpy as np from joblib import Parallel, delayed -from .multi_sample_split import aggregate_medians, aggregate_quantiles from .clustered_inference import clustered_inference +from .multi_sample_split import aggregate_medians, aggregate_quantiles def _ensembling( diff --git a/hidimstat/gaussian_knockoff.py b/hidimstat/gaussian_knockoff.py index 68c8f03..6228be5 100644 --- a/hidimstat/gaussian_knockoff.py +++ b/hidimstat/gaussian_knockoff.py @@ -5,7 +5,8 @@ import warnings import numpy as np -from sklearn.covariance import GraphicalLassoCV, empirical_covariance, ledoit_wolf +from sklearn.covariance import (GraphicalLassoCV, empirical_covariance, + ledoit_wolf) from sklearn.utils.validation import check_memory diff --git a/hidimstat/importance_functions.py b/hidimstat/importance_functions.py index c6c61c8..b912d97 100644 --- a/hidimstat/importance_functions.py +++ b/hidimstat/importance_functions.py @@ -1,10 +1,11 @@ -from hidimstat.Dnn_learner_single import Dnn_learner_single import numpy as np from scipy.stats import ttest_1samp from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.model_selection import GridSearchCV from sklearn.preprocessing import OneHotEncoder +from hidimstat.Dnn_learner_single import Dnn_learner_single + def compute_loco(X, y, ntree=100, problem_type="regression", use_dnn=True, seed=2024): """ diff --git a/hidimstat/knockoff_aggregation.py b/hidimstat/knockoff_aggregation.py index 9e7ebd8..63a53c0 100644 --- a/hidimstat/knockoff_aggregation.py +++ b/hidimstat/knockoff_aggregation.py @@ -6,7 +6,8 @@ from sklearn.utils import check_random_state from sklearn.utils.validation import check_memory -from .gaussian_knockoff import _estimate_distribution, gaussian_knockoff_generation +from .gaussian_knockoff import (_estimate_distribution, + gaussian_knockoff_generation) from .stat_coef_diff import stat_coef_diff from .utils import fdr_threshold, quantile_aggregation diff --git a/hidimstat/knockoffs.py b/hidimstat/knockoffs.py index c7c646b..d62f74a 100644 --- a/hidimstat/knockoffs.py +++ b/hidimstat/knockoffs.py @@ -10,7 +10,8 @@ from sklearn.preprocessing import StandardScaler from sklearn.utils.validation import check_memory -from .gaussian_knockoff import _estimate_distribution, gaussian_knockoff_generation +from .gaussian_knockoff import (_estimate_distribution, + gaussian_knockoff_generation) from .stat_coef_diff import _coef_diff_threshold, stat_coef_diff diff --git a/hidimstat/noise_std.py b/hidimstat/noise_std.py index 64080ef..4d953ea 100644 --- a/hidimstat/noise_std.py +++ b/hidimstat/noise_std.py @@ -1,6 +1,6 @@ import numpy as np from numpy.linalg import norm -from scipy.linalg import toeplitz, solve +from scipy.linalg import solve, toeplitz from sklearn.linear_model import LassoCV, MultiTaskLassoCV from sklearn.model_selection import KFold diff --git a/hidimstat/permutation_test.py b/hidimstat/permutation_test.py index a3249bd..3492385 100644 --- a/hidimstat/permutation_test.py +++ b/hidimstat/permutation_test.py @@ -1,11 +1,10 @@ import numpy as np from joblib import Parallel, delayed - from sklearn.base import clone -from sklearn.utils import _safe_indexing -from sklearn.svm import LinearSVR from sklearn.model_selection import GridSearchCV from sklearn.pipeline import Pipeline +from sklearn.svm import LinearSVR +from sklearn.utils import _safe_indexing from hidimstat.stat_tools import pval_from_two_sided_pval_and_sign diff --git a/hidimstat/standardized_svr.py b/hidimstat/standardized_svr.py index 9158e2d..e6dcca3 100644 --- a/hidimstat/standardized_svr.py +++ b/hidimstat/standardized_svr.py @@ -1,8 +1,8 @@ import numpy as np from numpy.linalg import norm -from sklearn.svm import LinearSVR from sklearn.model_selection import GridSearchCV from sklearn.pipeline import Pipeline +from sklearn.svm import LinearSVR def standardized_svr(X, y, Cs=np.logspace(-7, 1, 9), n_jobs=1): diff --git a/hidimstat/test/test_BBI.py b/hidimstat/test/test_BBI.py index b442d27..3674eab 100644 --- a/hidimstat/test/test_BBI.py +++ b/hidimstat/test/test_BBI.py @@ -4,10 +4,11 @@ import numpy as np import pandas as pd -from hidimstat.BBI import BlockBasedImportance from sklearn.datasets import make_classification, make_regression from sklearn.model_selection import train_test_split +from hidimstat.BBI import BlockBasedImportance + # Fixing the random seed rng = np.random.RandomState(2024) diff --git a/hidimstat/test/test_adaptive_permutation_threshold.py b/hidimstat/test/test_adaptive_permutation_threshold.py index 88939a1..7886253 100644 --- a/hidimstat/test/test_adaptive_permutation_threshold.py +++ b/hidimstat/test/test_adaptive_permutation_threshold.py @@ -5,9 +5,9 @@ import numpy as np from numpy.testing import assert_almost_equal +from hidimstat.adaptive_permutation_threshold import ada_svr from hidimstat.scenario import multivariate_1D_simulation from hidimstat.stat_tools import pval_from_scale -from hidimstat.adaptive_permutation_threshold import ada_svr def test_ada_svr(): diff --git a/hidimstat/test/test_clustered_inference.py b/hidimstat/test/test_clustered_inference.py index 59f0ad5..1e1a71b 100644 --- a/hidimstat/test/test_clustered_inference.py +++ b/hidimstat/test/test_clustered_inference.py @@ -3,13 +3,13 @@ """ import numpy as np +from numpy.testing import assert_almost_equal from sklearn.cluster import FeatureAgglomeration from sklearn.feature_extraction import image -from numpy.testing import assert_almost_equal -from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.scenario import multivariate_temporal_simulation from hidimstat.clustered_inference import clustered_inference +from hidimstat.scenario import (multivariate_1D_simulation, + multivariate_temporal_simulation) def test_clustered_inference(): diff --git a/hidimstat/test/test_desparsified_lasso.py b/hidimstat/test/test_desparsified_lasso.py index bd70d83..5e32d4f 100644 --- a/hidimstat/test/test_desparsified_lasso.py +++ b/hidimstat/test/test_desparsified_lasso.py @@ -6,10 +6,10 @@ from numpy.testing import assert_almost_equal, assert_equal from scipy.linalg import toeplitz -from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.scenario import multivariate_temporal_simulation -from hidimstat.desparsified_lasso import desparsified_lasso -from hidimstat.desparsified_lasso import desparsified_group_lasso +from hidimstat.desparsified_lasso import (desparsified_group_lasso, + desparsified_lasso) +from hidimstat.scenario import (multivariate_1D_simulation, + multivariate_temporal_simulation) def test_desparsified_lasso(): diff --git a/hidimstat/test/test_ensemble_clustered_inference.py b/hidimstat/test/test_ensemble_clustered_inference.py index bc8a7ed..926c3f5 100644 --- a/hidimstat/test/test_ensemble_clustered_inference.py +++ b/hidimstat/test/test_ensemble_clustered_inference.py @@ -3,13 +3,13 @@ """ import numpy as np +from numpy.testing import assert_almost_equal from sklearn.cluster import FeatureAgglomeration from sklearn.feature_extraction import image -from numpy.testing import assert_almost_equal -from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.scenario import multivariate_temporal_simulation from hidimstat.ensemble_clustered_inference import ensemble_clustered_inference +from hidimstat.scenario import (multivariate_1D_simulation, + multivariate_temporal_simulation) def test_ensemble_clustered_inference(): diff --git a/hidimstat/test/test_generate_knockoff.py b/hidimstat/test/test_generate_knockoff.py index 54056f7..094fdc9 100644 --- a/hidimstat/test/test_generate_knockoff.py +++ b/hidimstat/test/test_generate_knockoff.py @@ -2,10 +2,8 @@ # Authors: Binh Nguyen from hidimstat.data_simulation import simu_data -from hidimstat.gaussian_knockoff import ( - _estimate_distribution, - gaussian_knockoff_generation, -) +from hidimstat.gaussian_knockoff import (_estimate_distribution, + gaussian_knockoff_generation) SEED = 42 fdr = 0.1 diff --git a/hidimstat/test/test_importance_funtions.py b/hidimstat/test/test_importance_funtions.py index 8ee3127..80f6b32 100644 --- a/hidimstat/test/test_importance_funtions.py +++ b/hidimstat/test/test_importance_funtions.py @@ -2,11 +2,12 @@ Test the importance functions module """ -from hidimstat.importance_functions import compute_loco import numpy as np import pandas as pd from sklearn.datasets import make_classification, make_regression +from hidimstat.importance_functions import compute_loco + # Fixing the random seed rng = np.random.RandomState(2024) diff --git a/hidimstat/test/test_knockoff_aggregation.py b/hidimstat/test/test_knockoff_aggregation.py index d4895b8..a20c8c8 100644 --- a/hidimstat/test/test_knockoff_aggregation.py +++ b/hidimstat/test/test_knockoff_aggregation.py @@ -1,4 +1,5 @@ import numpy as np + from hidimstat import knockoff_aggregation, model_x_knockoff from hidimstat.data_simulation import simu_data from hidimstat.utils import cal_fdp_power diff --git a/hidimstat/test/test_model_x_knockoff.py b/hidimstat/test/test_model_x_knockoff.py index 42bbae7..504e469 100644 --- a/hidimstat/test/test_model_x_knockoff.py +++ b/hidimstat/test/test_model_x_knockoff.py @@ -1,5 +1,5 @@ -from hidimstat.data_simulation import simu_data from hidimstat import model_x_knockoff +from hidimstat.data_simulation import simu_data from hidimstat.utils import cal_fdp_power seed = 42 diff --git a/hidimstat/test/test_noise_std.py b/hidimstat/test/test_noise_std.py index 6d5ec6a..82d4588 100644 --- a/hidimstat/test/test_noise_std.py +++ b/hidimstat/test/test_noise_std.py @@ -6,9 +6,9 @@ from numpy.testing import assert_almost_equal from scipy.linalg import toeplitz -from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.scenario import multivariate_temporal_simulation -from hidimstat.noise_std import reid, group_reid, empirical_snr +from hidimstat.noise_std import empirical_snr, group_reid, reid +from hidimstat.scenario import (multivariate_1D_simulation, + multivariate_temporal_simulation) def test_reid(): diff --git a/hidimstat/test/test_permutation_test.py b/hidimstat/test/test_permutation_test.py index c33ae4e..6e1835d 100644 --- a/hidimstat/test/test_permutation_test.py +++ b/hidimstat/test/test_permutation_test.py @@ -5,8 +5,8 @@ import numpy as np from numpy.testing import assert_almost_equal -from hidimstat.scenario import multivariate_1D_simulation from hidimstat.permutation_test import permutation_test_cv +from hidimstat.scenario import multivariate_1D_simulation def test_permutation_test(): diff --git a/hidimstat/test/test_scenario.py b/hidimstat/test/test_scenario.py index e655e43..dc3f9e8 100644 --- a/hidimstat/test/test_scenario.py +++ b/hidimstat/test/test_scenario.py @@ -5,9 +5,9 @@ import numpy as np from numpy.testing import assert_almost_equal, assert_equal -from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.scenario import multivariate_simulation -from hidimstat.scenario import multivariate_temporal_simulation +from hidimstat.scenario import (multivariate_1D_simulation, + multivariate_simulation, + multivariate_temporal_simulation) ROI_SIZE_2D = 2 SHAPE_2D = (12, 12) diff --git a/hidimstat/test/test_standardized_svr.py b/hidimstat/test/test_standardized_svr.py index 945108e..a6665c5 100644 --- a/hidimstat/test/test_standardized_svr.py +++ b/hidimstat/test/test_standardized_svr.py @@ -6,8 +6,8 @@ from numpy.testing import assert_almost_equal from hidimstat.scenario import multivariate_1D_simulation -from hidimstat.stat_tools import pval_from_scale from hidimstat.standardized_svr import standardized_svr +from hidimstat.stat_tools import pval_from_scale def test_standardized_svr(): diff --git a/hidimstat/test/test_stat_tools.py b/hidimstat/test/test_stat_tools.py index 7761110..9635cbf 100644 --- a/hidimstat/test/test_stat_tools.py +++ b/hidimstat/test/test_stat_tools.py @@ -5,18 +5,13 @@ import numpy as np from numpy.testing import assert_almost_equal, assert_equal -from hidimstat.stat_tools import ( - _replace_infinity, - pval_corr_from_pval, - pval_from_scale, - zscore_from_cb, - pval_from_cb, - two_sided_pval_from_zscore, - two_sided_pval_from_cb, - zscore_from_pval, - pval_from_two_sided_pval_and_sign, - two_sided_pval_from_pval, -) +from hidimstat.stat_tools import (_replace_infinity, pval_corr_from_pval, + pval_from_cb, pval_from_scale, + pval_from_two_sided_pval_and_sign, + two_sided_pval_from_cb, + two_sided_pval_from_pval, + two_sided_pval_from_zscore, zscore_from_cb, + zscore_from_pval) def test__replace_infinity(): diff --git a/hidimstat/utils.py b/hidimstat/utils.py index 1e30337..4fd16ce 100644 --- a/hidimstat/utils.py +++ b/hidimstat/utils.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Authors: Binh Nguyen & Jerome-Alexis Chevalier & Ahmad Chamma import copy + import numpy as np import torch import torch.nn as nn diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ba6dcbb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "HiDimStat" +version = "0.0.1" +dependencies = [ + "joblib>=1.4.2", + "numpy>=2.0.0", + "pandas>=2.2.2", + "scikit-learn>=1.5.1", + "scipy>=1.14.0", + "torch>=2.3.1", + "torchmetrics>=1.4.0.post0", +] +requires-python = ">=3.12" +authors = [{name = "HiDimStat developers"}] +maintainers = [ + {name = "Bertrand Thirion", email = "bertrand.thirion@inria.fr"} +] +description = "High-dimensional statistical inference tools for Python" +readme = "README.md" +classifiers = [ + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Operating System :: Microsoft :: Windows", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", +] +license = {file = "LICENSE"} + + +[project.optional-dependencies] +# A combination of dependencies useful for developers + +# Requirements necessary for building the documentation +doc = [ + "memory_profiler>=0.61.0", + "mne>=1.7.1", + "nilearn>=0.10.4", + "numpydoc>=1.7.0", + "pillow>=10.4.0", + "PyQt5>=5.15.10", + "pyvista>=0.44.0", + "pyvistaqt>=0.11.1", + "sphinx-bootstrap-theme>=0.8.1", + "sphinxcontrib-bibtex>=2.6.2", + "sphinx-gallery>=0.16.0", +] +plotting = [ + "matplotlib>=3.9.1", +] +style = [ + "black>=24.4.2", + "isort>=5.13.2", +] +# For running unit and docstring tests +test = [ + "coverage>=7.6.0", + "pytest>=8.2.2", + "pytest-cov>=5.0.0" +] + +[project.urls] +Development = "https://github.com/nilearn/nilearn" +Homepage = "https://mind-inria.github.io/hidimstat" +Repository = "https://github.com/mind-inria/hidimstat" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2372b18..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ ---extra-index-url https://download.pytorch.org/whl/cpu -numpy -joblib -scipy -scikit-learn -torch -torchmetrics -pandas -mne diff --git a/setup.py b/setup.py deleted file mode 100644 index 67a37e1..0000000 --- a/setup.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python - -import os -import sys - -from setuptools import find_packages - -PKG = "hidimstat" -DESCRIPTION = "High-dimensional statistical inference tools for Python" -LONG_DESCRIPTION = open("README.md").read() -MAINTAINER = "Chevalier (ja-che), Nguyen (tbng), Alexandre Blain (alexblnn), Ahmad Chamma (achamma723) and Bertrand Thirion (bthirion)" -MAINTAINER_EMAIL = "bertrand.thirion@inria.fr" -URL = "https://github.com/Parietal-INRIA/hidimstat" -DOWNLOAD_URL = "https://github.com/Parietal-INRIA/hidimstat" -LICENSE = "BSD" - - -def load_version(): - """Executes hidimstat/version.py in a globals dictionary and return it. - Following format from Nilearn repo on github. - """ - # load all vars into globals, otherwise - # the later function call using global vars doesn't work. - globals_dict = {} - with open(os.path.join("hidimstat", "version.py")) as fp: - exec(fp.read(), globals_dict) - - return globals_dict - - -def setup_package(version): - local_path = os.path.dirname(os.path.abspath(sys.argv[0])) - - os.chdir(local_path) - sys.path.insert(0, local_path) - - from numpy.distutils.core import setup - - setup( - packages=find_packages(exclude=["contrib", "docs", "tests"]), - name=PKG, - maintainer=MAINTAINER, - include_package_data=True, - maintainer_email=MAINTAINER_EMAIL, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - license=LICENSE, - url=URL, - version=version, - # download_url=DOWNLOAD_URL, - zip_safe=False, # the package can run out of an .egg file - classifiers=[ - "Programming Language :: Python", - "Programming Language :: Python :: 3.5", - "Development Status :: 3 - Alpha", - ], - ) - - -_VERSION_GLOBALS = load_version() -VERSION = _VERSION_GLOBALS["__version__"] - -if __name__ == "__main__": - setup_package(VERSION)