Skip to content

Commit

Permalink
Switch to or logic when multiple merge ids in restriction (#1126)
Browse files Browse the repository at this point in the history
* switch to or logic when multiple merge ids in restriction

* update_changelog
  • Loading branch information
samuelbray32 authored Sep 20, 2024
1 parent 860d470 commit a9f6a7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit a9f6a7f

Please sign in to comment.