Skip to content

Commit

Permalink
Fix imports sort + remove setup + add pyproject dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
achamma723 committed Jul 17, 2024
1 parent ef1c030 commit 2b0c27a
Show file tree
Hide file tree
Showing 45 changed files with 184 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions doc_conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 0 additions & 20 deletions doc_conf/doc-requirements.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


#############################################################################
Expand Down
11 changes: 5 additions & 6 deletions examples/plot_2D_simulation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions examples/plot_diabetes_variable_importance_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
16 changes: 8 additions & 8 deletions examples/plot_fmri_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


#############################################################################
Expand Down
5 changes: 3 additions & 2 deletions examples_not_exhibited/plot_fig_1_nguyen_et_al.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions examples_not_exhibited/plot_meg_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 6 additions & 13 deletions hidimstat/BBI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions hidimstat/Dnn_learner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from sklearn.base import BaseEstimator

from .Dnn_learner_single import Dnn_learner_single


Expand Down
11 changes: 2 additions & 9 deletions hidimstat/Dnn_learner_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion hidimstat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions hidimstat/clustered_inference.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
9 changes: 4 additions & 5 deletions hidimstat/compute_importance.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
6 changes: 3 additions & 3 deletions hidimstat/desparsified_lasso.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion hidimstat/ensemble_clustered_inference.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
3 changes: 2 additions & 1 deletion hidimstat/gaussian_knockoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion hidimstat/importance_functions.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand Down
3 changes: 2 additions & 1 deletion hidimstat/knockoff_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 2b0c27a

Please sign in to comment.