Skip to content

Commit 127658e

Browse files
authored
Merge pull request #85 from funkelab/73-deprecate-node_id_to_track_id-dict
Mark node_id_to_track_id for deprecation
2 parents 2d706dc + d5ea817 commit 127658e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/funtracks/data_model/solution_tracks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import warnings
34
from typing import TYPE_CHECKING
45

56
import networkx as nx
@@ -59,6 +60,12 @@ def from_tracks(cls, tracks: Tracks):
5960

6061
@property
6162
def node_id_to_track_id(self) -> dict[Node, int]:
63+
warnings.warn(
64+
"node_id_to_track_id property will be removed in funtracks v2. "
65+
"Use `get_track_id` instead for better performance.",
66+
DeprecationWarning,
67+
stacklevel=2,
68+
)
6269
return nx.get_node_attributes(self.graph, NodeAttr.TRACK_ID.value)
6370

6471
def get_next_track_id(self) -> int:

tests/data_model/test_solution_tracks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import networkx as nx
22
import numpy as np
3+
import pytest
34

45
from funtracks.actions import AddNode
56
from funtracks.data_model import NodeAttr, SolutionTracks, Tracks
@@ -16,6 +17,15 @@ def test_next_track_id(graph_2d):
1617
assert tracks.get_next_track_id() == 11
1718

1819

20+
def test_node_id_to_track_id(graph_2d):
21+
tracks = SolutionTracks(graph_2d, ndim=3)
22+
with pytest.warns(
23+
DeprecationWarning,
24+
match="node_id_to_track_id property will be removed in funtracks v2. ",
25+
):
26+
tracks.node_id_to_track_id # noqa B018
27+
28+
1929
def test_from_tracks_cls(graph_2d):
2030
tracks = Tracks(
2131
graph_2d, ndim=3, pos_attr="POSITION", time_attr="TIME", scale=(2, 2, 2)

0 commit comments

Comments
 (0)