-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: rename siibraconf -> perfconf
maint: low ram/non local as perf default feat: append all dataop for volumes feat: query cursor data table & reconfigure
- Loading branch information
Showing
21 changed files
with
276 additions
and
306 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 |
---|---|---|
@@ -1,60 +1,84 @@ | ||
import pytest | ||
import siibra | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def all_receptor_density_features(): | ||
def receptor_density_search_cursor(): | ||
modality = siibra.modality_vocab.modality["receptor"] | ||
query = siibra.QueryParam(attributes=[modality]) | ||
yield siibra.find([query], siibra.Feature) | ||
yield siibra.SearchResult(criteria=[query], search_type=siibra.Feature) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def filtered_for_fp(all_receptor_density_features): | ||
yield siibra.Feature.filter_facets(all_receptor_density_features, { | ||
"Data Type": "fingerprint" | ||
}) | ||
|
||
def all_receptor_density_features(receptor_density_search_cursor): | ||
yield receptor_density_search_cursor.find() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def filtered_for_pr(all_receptor_density_features): | ||
yield siibra.Feature.filter_facets(all_receptor_density_features, { | ||
"Data Type": "cortical profile" | ||
}) | ||
def filtered_for_fp(receptor_density_search_cursor): | ||
new_cursor = receptor_density_search_cursor.reconfigure( | ||
spec={"category_Data Type": "fingerprint"} | ||
) | ||
yield new_cursor.find() | ||
|
||
def has_fp(feat: siibra.Feature): | ||
facets = feat.facets | ||
return len(facets.query("key == 'Data Type' & value == 'fingerprint'")) > 0 | ||
|
||
def has_profile(feat: siibra.Feature): | ||
facets = feat.facets | ||
return len(facets.query("key == 'Data Type' & value == 'cortical profile'")) > 0 | ||
@pytest.fixture(scope="session") | ||
def filtered_for_pr(receptor_density_search_cursor): | ||
new_cursor = receptor_density_search_cursor.reconfigure( | ||
spec={"category_Data Type": "cortical profile"} | ||
) | ||
yield new_cursor.find() | ||
|
||
|
||
# at least 1 feature | ||
def test_all_receptor_features(all_receptor_density_features): | ||
assert len(all_receptor_density_features) > 0 | ||
|
||
|
||
# no duplicated ID | ||
def test_no_duplicated_id(all_receptor_density_features): | ||
id_set = {feat._get(siibra.attributes.descriptions.ID).value for feat in all_receptor_density_features} | ||
id_set = { | ||
feat._get(siibra.attributes.descriptions.ID).value | ||
for feat in all_receptor_density_features | ||
} | ||
assert len(id_set) == len(all_receptor_density_features) | ||
|
||
|
||
def is_fp(feat: siibra.Feature): | ||
for cat in feat._find(siibra.attributes.descriptions.Categorization): | ||
if cat.key == "Data Type" and cat.value == "fingerprint": | ||
return True | ||
return False | ||
|
||
|
||
def is_pr(feat: siibra.Feature): | ||
for cat in feat._find(siibra.attributes.descriptions.Categorization): | ||
if cat.key == "Data Type" and cat.value == "cortical profile": | ||
return True | ||
return False | ||
|
||
|
||
# fingerprint | ||
def test_some_has_fp(all_receptor_density_features): | ||
assert any(has_fp(feat) for feat in all_receptor_density_features) | ||
assert any(is_fp(feat) for feat in all_receptor_density_features) | ||
|
||
|
||
def test_some_has_no_fp(all_receptor_density_features): | ||
assert any(not has_fp(feat) for feat in all_receptor_density_features) | ||
assert any(not is_fp(feat) for feat in all_receptor_density_features) | ||
|
||
|
||
def test_after_filter_all_has_fp(filtered_for_fp): | ||
assert all(has_fp(feat) for feat in filtered_for_fp) | ||
assert all(is_fp(feat) for feat in filtered_for_fp) | ||
|
||
|
||
# cortical profiles | ||
def test_some_has_pr(all_receptor_density_features): | ||
assert any(has_profile(feat) for feat in all_receptor_density_features) | ||
assert any(is_pr(feat) for feat in all_receptor_density_features) | ||
|
||
|
||
def test_some_has_no_pr(all_receptor_density_features): | ||
assert any(not has_profile(feat) for feat in all_receptor_density_features) | ||
assert any(not is_pr(feat) for feat in all_receptor_density_features) | ||
|
||
|
||
def test_after_filter_all_has_pr(filtered_for_pr): | ||
assert all(has_profile(feat) for feat in filtered_for_pr) | ||
assert all(is_pr(feat) for feat in filtered_for_pr) |
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
Oops, something went wrong.