-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Ignore non-significant kappa elbow when no non-significant kapp…
…a values exist (#760) * Add an informative error to getelbow functions. * Expand elbow calculations. Makes for more informative tracebacks. * Compromise with warning. * Improve warning text. * Replace random seed recommendation. * Add tests. * Update error messages.
- Loading branch information
Showing
3 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Tests for the tedana.selection._utils module.""" | ||
import numpy as np | ||
import pytest | ||
|
||
from tedana.selection import _utils | ||
|
||
|
||
def test_getelbow_smoke(): | ||
"""A smoke test for the getelbow function.""" | ||
arr = np.random.random(100) | ||
idx = _utils.getelbow(arr) | ||
assert isinstance(idx, np.integer) | ||
|
||
val = _utils.getelbow(arr, return_val=True) | ||
assert isinstance(val, float) | ||
|
||
# Running an empty array should raise a ValueError | ||
arr = np.array([]) | ||
with pytest.raises(ValueError): | ||
_utils.getelbow(arr) | ||
|
||
# Running a 2D array should raise a ValueError | ||
arr = np.random.random((100, 100)) | ||
with pytest.raises(ValueError): | ||
_utils.getelbow(arr) | ||
|
||
|
||
def test_getelbow_cons(): | ||
"""A smoke test for the getelbow_cons function.""" | ||
arr = np.random.random(100) | ||
idx = _utils.getelbow_cons(arr) | ||
assert isinstance(idx, np.integer) | ||
|
||
val = _utils.getelbow_cons(arr, return_val=True) | ||
assert isinstance(val, float) | ||
|
||
# Running an empty array should raise a ValueError | ||
arr = np.array([]) | ||
with pytest.raises(ValueError): | ||
_utils.getelbow_cons(arr) | ||
|
||
# Running a 2D array should raise a ValueError | ||
arr = np.random.random((100, 100)) | ||
with pytest.raises(ValueError): | ||
_utils.getelbow_cons(arr) |