Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 30, 2024
1 parent 8094053 commit 5983194
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
37 changes: 16 additions & 21 deletions src/spikeinterface/curation/curation_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def validate_curation_dict(curation_dict):
if len(removed_units_set.intersection(merged_units_set)) != 0:
raise ValueError("Some units were merged and deleted")
if curation_dict["format_version"] not in supported_versions:
raise ValueError(f"Format version ({curation_dict['format_version']}) not supported. "
f"Only {supported_versions} are valid")
raise ValueError(
f"Format version ({curation_dict['format_version']}) not supported. " f"Only {supported_versions} are valid"
)
# Check the labels exclusivity
for lbl in curation_dict["manual_labels"]:
lbl_key = lbl["label_category"]
is_exclusive = curation_dict["label_definitions"][lbl_key]["auto_exclusive"]
if is_exclusive and not isinstance(lbl["labels"], str):
raise ValueError(f"{lbl_key} are mutually exclusive labels. {lbl['labels']} is invalid")
elif not is_exclusive and not isinstance(lbl["labels"], list):
raise ValueError(f"{lbl_key} are not mutually exclusive labels. "
f"{lbl['labels']} should be a lists")
raise ValueError(f"{lbl_key} are not mutually exclusive labels. " f"{lbl['labels']} should be a lists")
return True


Expand Down Expand Up @@ -82,29 +82,24 @@ def convert_from_sortingview(sortingview_dict, destination_format=1):
all_labels.extend(l_labels)
u_id = unit_id_type(unit_id)
all_units.append(u_id)
manual_labels.append({'unit_id': u_id, "label_category": general_cat,
"labels": l_labels})
labels_def = {"all_labels":
{"name": "all_labels",
"label_options": all_labels,
"auto_exclusive": False}}

curation_dict = {"unit_ids": None,
"label_definitions": labels_def,
"manual_labels": manual_labels,
"merged_unit_groups": merge_groups,
"removed_units": [],
"format_version": destination_format}
manual_labels.append({"unit_id": u_id, "label_category": general_cat, "labels": l_labels})
labels_def = {"all_labels": {"name": "all_labels", "label_options": all_labels, "auto_exclusive": False}}

curation_dict = {
"unit_ids": None,
"label_definitions": labels_def,
"manual_labels": manual_labels,
"merged_unit_groups": merge_groups,
"removed_units": [],
"format_version": destination_format,
}

return curation_dict


if __name__ == "__main__":
import json

with open("src/spikeinterface/curation/tests/sv-sorting-curation-str.json") as jf:
sv_curation = json.load(jf)
cur_d = convert_from_sortingview(sortingview_dict=sv_curation)




12 changes: 6 additions & 6 deletions src/spikeinterface/curation/tests/test_curation_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"merged_unit_groups": [[3, 6], [10, 14, 20]], # one cell goes into at most one list
"removed_units": [31, 42], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}


Expand All @@ -59,7 +59,7 @@
],
"merged_unit_groups": [["u3", "u6"], ["u10", "u14", "u20"]], # one cell goes into at most one list
"removed_units": ["u31", "u42"], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}

# This is a failure example
Expand All @@ -80,7 +80,7 @@
],
"merged_unit_groups": [[3, 6, 10], [10, 14, 20]], # one cell goes into at most one list
"removed_units": [31, 42], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}


Expand All @@ -102,7 +102,7 @@
],
"merged_unit_groups": [[3, 6], [10, 14, 20]], # one cell goes into at most one list
"removed_units": [3, 31, 42], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}


Expand All @@ -123,7 +123,7 @@
],
"merged_unit_groups": [[3, 6, 99], [10, 14, 20]], # one cell goes into at most one list
"removed_units": [31, 42], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}


Expand All @@ -144,7 +144,7 @@
],
"merged_unit_groups": [[3, 6], [10, 14, 20]], # one cell goes into at most one list
"removed_units": [31, 42, 99], # Can not be in the merged_units
"format_version": 1
"format_version": 1,
}


Expand Down

0 comments on commit 5983194

Please sign in to comment.