Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to or logic when multiple merge ids in restriction #1126

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop()
#1108
- Add docstrings to all public methods #1076
- Update DataJoint to 0.14.2 #1081
- Allow restriction based on parent keys in `Merge.fetch_nwb()` #1086
- Allow restriction based on parent keys in `Merge.fetch_nwb()` #1086, #1126
- Import `datajoint.dependencies.unite_master_parts` -> `topo_sort` #1116

### Pipelines
Expand Down
7 changes: 4 additions & 3 deletions src/spyglass/utils/dj_merge_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,9 @@ def extract_merge_id(cls, restriction) -> Union[dict, list]:
merge_id present in the input, relying on parent func to
restrict on secondary or part-parent key(s).

Assumes that a valid set of merge_id keys should have OR logic
to allow selection of an entries.

Parameters
----------
restriction : str, dict, or dj.condition.AndList
Expand All @@ -878,9 +881,7 @@ def extract_merge_id(cls, restriction) -> Union[dict, list]:
merge_restr = [x for x in merge_id_list if x is not None]
elif isinstance(restriction, str):
parsed = [x.split(")")[0] for x in restriction.split("(") if x]
merge_restr = dj.condition.AndList(
[x for x in parsed if "merge_id" in x]
)
merge_restr = [x for x in parsed if "merge_id" in x]

if len(merge_restr) == 0:
return True
Expand Down
Loading