diff --git a/.github/workflows/lint_benchmarks.yml b/.github/workflows/lint_benchmarks.yml deleted file mode 100644 index 3fe367c..0000000 --- a/.github/workflows/lint_benchmarks.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Lint - -on: - workflow_call: - - -jobs: - linter-flake8: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Lint with flake8 - run: | - pip install flake8 - flake8 . diff --git a/.github/workflows/test_benchmarks.yml b/.github/workflows/test_benchmarks.yml deleted file mode 100644 index 4554ca7..0000000 --- a/.github/workflows/test_benchmarks.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Test Benchmark - -on: - workflow_call: - inputs: - benchopt_branch: - description: Branch of benchopt to install to test the benchmark. - default: benchopt@main - required: false - type: string - benchopt_version: - description: | - If set, use a specific version of benchopt for the tests, - thus ignoring the benchopt_branch input. - default: git - required: false - type: string - -jobs: - test-benchmark: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ['ubuntu-latest', 'macos-latest'] - exclude: - # Only run OSX test on version==git, not on the release ones. - - os: ${{ inputs.benchopt_version == 'git' || 'macos-latest' }} - env: - CONDA_ENV: 'test_env' - BENCHOPT_BRANCH: ${{ inputs.benchopt_branch }} - BENCHOPT_VERSION: ${{ inputs.benchopt_version }} - BENCHOPT_DEBUG: 1 - BENCHOPT_CONDA_CMD: mamba - - defaults: - run: - # Need to use this shell to get conda working properly. - # See https://github.com/marketplace/actions/setup-miniconda#important - shell: bash -l {0} - - steps: - - uses: actions/checkout@v2 - - name: Setup Conda - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - miniforge-variant: Mambaforge - use-mamba: true - channels: conda-forge - python-version: 3.9 - activate-environment: ${{ env.CONDA_ENV }} - - - name: Create/Restore MNE Data Cache - id: cache-mne_data - uses: actions/cache@v3 - with: - path: ~/mne_data - key: ${{ runner.os }}-v3 - - - run: conda info - - - name: Install benchopt and its dependencies - run: | - conda info - mamba install -yq pip - - # Get the correct branch of benchopt - if [[ "$BENCHOPT_VERSION" == "git" ]] - then - user=${BENCHOPT_BRANCH%@*} - branch=${BENCHOPT_BRANCH##*@} - pip install -U git+https://github.com/$user/benchopt@$branch - elif [[ "$BENCHOPT_VERSION" == "latest" ]] - then - pip install -U benchopt - else - pip install -U benchopt==$BENCHOPT_VERSION - fi - - - name: Test - run: | - benchopt test . --env-name bench_test_env -vl - benchopt test . --env-name bench_test_env -vl --skip-install diff --git a/benchmark_utils/transformation.py b/benchmark_utils/transformation.py deleted file mode 100644 index 2d0cb27..0000000 --- a/benchmark_utils/transformation.py +++ /dev/null @@ -1,93 +0,0 @@ -from benchopt import safe_import_context - - -# Protect the import with `safe_import_context()`. This allows: -# - skipping import to speed up autocompletion in CLI. -# - getting requirements info when all dependencies are not installed. -with safe_import_context() as import_ctx: - import numpy as np - - from numpy import concatenate - from torch import as_tensor - from skorch.helper import to_numpy - from braindecode.augmentation import ChannelsDropout, SmoothTimeMask - - -def channels_dropout( - X, y, n_augmentation, seed=0, probability=0.5, p_drop=0.2 -): - """ - Function to apply channels dropout to X raw data - and concatenate it to the original data. - - ---------- - X : array-like of shape (n_trials, n_channels, n_times) - The input trials. - y : array-like of shape (n_trials,) - The labels. - n_augmentation : int - Number of augmentation to apply and increase the size of the dataset. - seed : int - Random seed. - probability : float - Probability of applying the tranformation. - p_drop : float - Probability of dropout a channel. - - Returns - ------- - X_augm : array-like of shape (n_trials * n_augmentation, - n_channels, n_times) - The augmented trials. - y_augm : array-like of shape (n_trials * n_augmentation,) - The labels. - - """ - transform = ChannelsDropout(probability=probability, random_state=seed) - X_augm = to_numpy(X) - y_augm = y - for i in range(n_augmentation): - X_tr, _ = transform.operation( - as_tensor(X).float(), None, p_drop=p_drop - ) - - X_tr = X_tr.numpy() - X_augm = concatenate((X_augm, X_tr)) - y_augm = concatenate((y_augm, y)) - - return X_augm, y_augm - - -def smooth_timemask( - X, y, n_augmentation, sfreq, seed=0, probability=0.5, second=0.1 -): - """ - Function to apply smooth time mask to X raw data - and concatenate it to the original data. - """ - - transform = SmoothTimeMask( - probability=probability, - mask_len_samples=int(sfreq * second), - random_state=seed, - ) - - X_torch = as_tensor(np.array(X)).float() - y_torch = as_tensor(y).float() - param_augm = transform.get_augmentation_params(X_torch, y_torch) - mls = param_augm["mask_len_samples"] - msps = param_augm["mask_start_per_sample"] - - X_augm = to_numpy(X) - y_augm = y - - for i in range(n_augmentation): - X_tr, _ = transform.operation( - X_torch, None, mask_len_samples=mls, mask_start_per_sample=msps - ) - - X_tr = X_tr.numpy() - X_augm = concatenate((X_augm, X_tr)) - y_augm = concatenate((y_augm, y)) - - return X_augm, y_augm