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

Revise datajoint import name #1116

Merged
merged 2 commits into from
Sep 17, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop()
- 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
- Import `datajoint.dependencies.unite_master_parts` -> `topo_sort` #1116

### Pipelines

Expand Down
8 changes: 6 additions & 2 deletions src/spyglass/utils/dj_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from datajoint import FreeTable, Table
from datajoint.condition import make_condition
from datajoint.dependencies import unite_master_parts
from datajoint.hash import key_hash
from datajoint.user_tables import TableMeta
from datajoint.utils import get_master, to_camel_case
Expand All @@ -35,6 +34,11 @@
unique_dicts,
)

try: # Datajoint 0.14.2+ uses topo_sort instead of unite_master_parts
from datajoint.dependencies import topo_sort as dj_topo_sort
except ImportError:
from datajoint.dependencies import unite_master_parts as dj_topo_sort


class Direction(Enum):
"""Cascade direction enum. Calling Up returns True. Inverting flips."""
Expand Down Expand Up @@ -474,7 +478,7 @@ def _topo_sort(
if not self._is_out(node, warn=False)
]
graph = self.graph.subgraph(nodes) if subgraph else self.graph
ordered = unite_master_parts(list(topological_sort(graph)))
ordered = dj_topo_sort(list(topological_sort(graph)))
if reverse:
ordered.reverse()
return [n for n in ordered if n in nodes]
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def frequent_imports():
from spyglass.lfp.analysis.v1 import LFPBandSelection
from spyglass.mua.v1.mua import MuaEventsV1
from spyglass.ripple.v1.ripple import RippleTimesV1
from spyglass.spikesorting.analysis.v1.unit_annotation import UnitAnnotation
from spyglass.spikesorting.v0.figurl_views import SpikeSortingRecordingView

return (
Expand All @@ -403,6 +404,7 @@ def frequent_imports():
RippleTimesV1,
SortedSpikesIndicatorSelection,
SpikeSortingRecordingView,
UnitAnnotation,
UnitMarksIndicatorSelection,
)

Expand Down
Loading