From 23bf573d2f8a6df1e9e69d2b833bfa757d2f65ed Mon Sep 17 00:00:00 2001 From: Kaleidophon Date: Tue, 26 Oct 2021 15:47:23 +0200 Subject: [PATCH] :bug: Hotfix for two crtiissues (see below) * Somehow, using multiple jobs resulted in import errors in the distributed function -> fixed by checking if modules are available in local scope and importin$ * After adding seeding to ASO, the number of bootstrap samples would be reduced to the number of jobs (oops) * Minor: Fix link to readthedocs link in README --- README.md | 2 +- README_RAW.md | 2 +- deepsig/__init__.py | 2 +- deepsig/aso.py | 17 ++++++++++++++--- docs/README_DOCS.md | 2 +- docs/build/html/README_DOCS.html | 2 +- docs/build/html/_sources/README_DOCS.md.txt | 2 +- docs/build/html/index.html | 2 +- setup.py | 2 +- 9 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ee603fd..b0f6d85 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ testing: All functions are fully tested and also compatible with common deep learning data structures, such as PyTorch / Tensorflow tensors as well as NumPy and Jax arrays. For examples about the usage, consult the documentation -[here](deep-significance.rtfd.io/en/latest/) or the scenarios in the section [Examples](#examples). +[here](https://deep-significance.readthedocs.io/en/latest/) or the scenarios in the section [Examples](#examples). ## :inbox_tray: Installation diff --git a/README_RAW.md b/README_RAW.md index 13bac4e..d07e0e8 100644 --- a/README_RAW.md +++ b/README_RAW.md @@ -49,7 +49,7 @@ testing: All functions are fully tested and also compatible with common deep learning data structures, such as PyTorch / Tensorflow tensors as well as NumPy and Jax arrays. For examples about the usage, consult the documentation -[here](deep-significance.rtfd.io/en/latest/) or the scenarios in the section [Examples](#examples). +[here](https://deep-significance.readthedocs.io/en/latest/) or the scenarios in the section [Examples](#examples). ## :inbox_tray: Installation diff --git a/deepsig/__init__.py b/deepsig/__init__.py index 6fd21ca..949d232 100644 --- a/deepsig/__init__.py +++ b/deepsig/__init__.py @@ -4,5 +4,5 @@ from deepsig.correction import bonferroni_correction from deepsig.permutation import permutation_test -__version__ = "1.1.1" +__version__ = "1.1.2" __author__ = "Dennis Ulmer" diff --git a/deepsig/aso.py b/deepsig/aso.py index 8ce5028..7e85251 100644 --- a/deepsig/aso.py +++ b/deepsig/aso.py @@ -4,7 +4,6 @@ """ # STD - from typing import List, Callable, Union, Optional from warnings import warn @@ -134,15 +133,22 @@ def _progress_iter(high: int, progress_bar: tqdm): # Set seeds for different jobs if applicable # "Sub-seeds" for jobs are just seed argument + job index seeds = ( - [None] * num_jobs + [None] * num_bootstrap_iterations if seed is None - else [seed + offset for offset in range(1, num_jobs + 1)] + else [seed + offset for offset in range(1, num_bootstrap_iterations + 1)] ) def _bootstrap_iter(seed: Optional[int] = None): """ One bootstrap iteration. Wrapped in a function so it can be handed to joblib.Parallel. """ + # When running multiple jobs, these modules have to be re-imported for some reason to avoid an error + # Use dir() to check whether module is available in local scope: + # https://stackoverflow.com/questions/30483246/how-to-check-if-a-module-has-been-imported + if "numpy" not in dir() or "deepsig" not in dir(): + import numpy as np + from deepsig.aso import compute_violation_ratio + if seed is not None: np.random.seed(seed) @@ -344,6 +350,11 @@ def get_quantile_function(scores: np.array) -> Callable: Callable Return the quantile function belonging to an empirical score distribution. """ + # When running multiple jobs via joblib, numpy has to be re-imported for some reason to avoid an error + # Use dir() to check whether module is available in local scope: + # https://stackoverflow.com/questions/30483246/how-to-check-if-a-module-has-been-imported + if "numpy" not in dir(): + import numpy as np def _quantile_function(p: float) -> float: cdf = np.sort(scores) diff --git a/docs/README_DOCS.md b/docs/README_DOCS.md index b221456..f7b0365 100644 --- a/docs/README_DOCS.md +++ b/docs/README_DOCS.md @@ -49,7 +49,7 @@ testing: All functions are fully tested and also compatible with common deep learning data structures, such as PyTorch / Tensorflow tensors as well as NumPy and Jax arrays. For examples about the usage, consult the documentation -[here](deep-significance.rtfd.io/en/latest/) or the scenarios in the section [Examples](#examples). +[here](https://deep-significance.readthedocs.io/en/latest/) or the scenarios in the section [Examples](#examples). ## |:inbox_tray:| Installation diff --git a/docs/build/html/README_DOCS.html b/docs/build/html/README_DOCS.html index f22d3fb..3af5c0f 100644 --- a/docs/build/html/README_DOCS.html +++ b/docs/build/html/README_DOCS.html @@ -195,7 +195,7 @@

|:interrobang:| Why?here or the scenarios in the section Examples.

+here or the scenarios in the section Examples.

|:inbox_tray:| Installation

diff --git a/docs/build/html/_sources/README_DOCS.md.txt b/docs/build/html/_sources/README_DOCS.md.txt index b221456..f7b0365 100644 --- a/docs/build/html/_sources/README_DOCS.md.txt +++ b/docs/build/html/_sources/README_DOCS.md.txt @@ -49,7 +49,7 @@ testing: All functions are fully tested and also compatible with common deep learning data structures, such as PyTorch / Tensorflow tensors as well as NumPy and Jax arrays. For examples about the usage, consult the documentation -[here](deep-significance.rtfd.io/en/latest/) or the scenarios in the section [Examples](#examples). +[here](https://deep-significance.readthedocs.io/en/latest/) or the scenarios in the section [Examples](#examples). ## |:inbox_tray:| Installation diff --git a/docs/build/html/index.html b/docs/build/html/index.html index feb8397..d91f41a 100644 --- a/docs/build/html/index.html +++ b/docs/build/html/index.html @@ -188,7 +188,7 @@

⁉️ Why?here or the scenarios in the section Examples.

+here or the scenarios in the section Examples.

📥 Installation

The package can simply be installed using pip by running

diff --git a/setup.py b/setup.py index ebe5c74..1935c48 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name="deepsig", - version="1.1.1", + version="1.1.2", author="Dennis Ulmer", description="Easy Significance Testing for Deep Neural Networks.", long_description=long_description,