-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use same util to strip substructure acronym everywhere
- Loading branch information
Showing
7 changed files
with
93 additions
and
88 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
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
32 changes: 32 additions & 0 deletions
32
allensdk/test/brain_observatory/ecephys/test_ecephys_utils.py
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,32 @@ | ||
import pytest | ||
from allensdk.brain_observatory.ecephys.utils import ( | ||
strip_substructure_acronym) | ||
|
||
|
||
def test_strip_substructure_acronym(): | ||
""" | ||
Test that strip_substructure_acronym behaves properly | ||
""" | ||
|
||
assert strip_substructure_acronym('abcde-fg-hi') == 'abcde' | ||
assert strip_substructure_acronym(None) is None | ||
|
||
data = ['DG-mo', 'DG-pd', 'LS-ab', 'LT-x', 'AB-cd', | ||
'WX-yz', 'AB-ef'] | ||
expected = ['AB', 'DG', 'LS', 'LT', 'WX'] | ||
assert strip_substructure_acronym(data) == expected | ||
|
||
data = [None, 'DG-mo', 'DG-pd', 'LS-ab', 'LT-x', 'AB-cd', | ||
'WX-yz', None, 'AB-ef'] | ||
expected = ['AB', 'DG', 'LS', 'LT', 'WX'] | ||
assert strip_substructure_acronym(data) == expected | ||
|
||
assert strip_substructure_acronym([None]) == [] | ||
|
||
# pass in a tuple; check that it fails since that is not | ||
# a str or a list | ||
with pytest.raises(RuntimeError, match="list or a str"): | ||
strip_substructure_acronym(('a', 'b', 'c')) | ||
|
||
with pytest.raises(RuntimeError, match="Do not know how to parse"): | ||
strip_substructure_acronym(['abc', 2.3]) |
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