Skip to content

Commit

Permalink
🐛 Hotfix for two crtiissues (see below)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Kaleidophon committed Oct 26, 2021
1 parent b3d58d3 commit 23bf573
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README_RAW.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion deepsig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 14 additions & 3 deletions deepsig/aso.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

# STD

from typing import List, Callable, Union, Optional
from warnings import warn

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/README_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/README_DOCS.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ <h2>|:interrobang:| Why?<a class="headerlink" href="#interrobang-why" title="Per
</ul>
<p>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
<a class="reference external" href="deep-significance.rtfd.io/en/latest/">here</a> or the scenarios in the section <a class="reference external" href="#examples">Examples</a>.</p>
<a class="reference external" href="https://deep-significance.readthedocs.io/en/latest/">here</a> or the scenarios in the section <a class="reference external" href="#examples">Examples</a>.</p>
</div>
<div class="section" id="inbox-tray-installation">
<h2>|:inbox_tray:| Installation<a class="headerlink" href="#inbox-tray-installation" title="Permalink to this headline"></a></h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/_sources/README_DOCS.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h2>⁉️ Why?<a class="headerlink" href="#id1" title="Permalink to this headli
</ul>
<p>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
<a class="reference external" href="deep-significance.rtfd.io/en/latest/">here</a> or the scenarios in the section <a class="reference external" href="#examples">Examples</a>.</p>
<a class="reference external" href="https://deep-significance.readthedocs.io/en/latest/">here</a> or the scenarios in the section <a class="reference external" href="#examples">Examples</a>.</p>
<div class="section" id="id2">
<h3>📥 Installation<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>The package can simply be installed using <code class="docutils literal notranslate"><span class="pre">pip</span></code> by running</p>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 23bf573

Please sign in to comment.