Skip to content

Commit

Permalink
fixing circular import by moving NO_PARENTS to constants files
Browse files Browse the repository at this point in the history
  • Loading branch information
JoOkuma committed Oct 2, 2024
1 parent b734749 commit 271de53
Show file tree
Hide file tree
Showing 26 changed files with 32 additions and 27 deletions.
3 changes: 2 additions & 1 deletion ultrack/cli/data_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

from ultrack.cli.utils import config_option
from ultrack.config import MainConfig
from ultrack.core.database import NO_PARENT, LinkDB, NodeDB
from ultrack.core.database import LinkDB, NodeDB
from ultrack.core.export.utils import solution_dataframe_from_sql
from ultrack.tracks.graph import add_track_ids_to_tracks_df
from ultrack.utils.constants import NO_PARENT
from ultrack.utils.printing import pretty_print_df


Expand Down
4 changes: 1 addition & 3 deletions ultrack/core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

from ultrack.config.dataconfig import DatabaseChoices, DataConfig
from ultrack.utils.array import assert_same_length

# constant value to indicate it has no parent
NO_PARENT = -1
from ultrack.utils.constants import NO_PARENT

Base = declarative_base()

Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/export/_test/test_ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import pandas as pd
import pytest

from ultrack.core.database import NO_PARENT
from ultrack.core.export.ctc import ctc_compress_forest, stitch_tracks_df
from ultrack.tracks.graph import add_track_ids_to_tracks_df
from ultrack.utils.constants import NO_PARENT


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/export/_test/test_networkx.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pandas as pd
import pytest

from ultrack.core.database import NO_PARENT
from ultrack.core.export import tracks_layer_to_networkx
from ultrack.utils.constants import NO_PARENT


@pytest.mark.parametrize("children_to_parent", [True, False])
Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/export/_test/test_trackmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pandas as pd
import pytest

from ultrack.core.database import NO_PARENT
from ultrack.core.export.trackmate import tracks_layer_to_trackmate
from ultrack.utils.constants import NO_PARENT

pytrackmate = pytest.importorskip("pytrackmate")

Expand Down
3 changes: 2 additions & 1 deletion ultrack/core/export/ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ultrack.config.config import MainConfig
from ultrack.config.dataconfig import DataConfig
from ultrack.core.database import NO_PARENT, NodeDB
from ultrack.core.database import NodeDB
from ultrack.core.export.utils import (
export_segmentation_generic,
filter_nodes_generic,
Expand All @@ -32,6 +32,7 @@
tracks_df_forest,
)
from ultrack.tracks.stats import estimate_drift
from ultrack.utils.constants import NO_PARENT
from ultrack.utils.data import validate_and_overwrite_path

logging.basicConfig()
Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/export/networkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import pandas as pd

from ultrack.config.config import MainConfig
from ultrack.core.database import NO_PARENT
from ultrack.core.export.tracks_layer import to_tracks_layer
from ultrack.tracks.graph import _create_tracks_forest
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/export/trackmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pandas as pd

from ultrack.config.config import MainConfig
from ultrack.core.database import NO_PARENT
from ultrack.core.export.tracks_layer import to_tracks_layer
from ultrack.utils.constants import NO_PARENT


def _set_filter_elem(elem: ET.Element) -> None:
Expand Down
3 changes: 2 additions & 1 deletion ultrack/core/export/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from toolz import curry

from ultrack.config.dataconfig import DataConfig
from ultrack.core.database import NO_PARENT, NodeDB
from ultrack.core.database import NodeDB
from ultrack.core.segmentation.node import Node
from ultrack.utils.constants import NO_PARENT
from ultrack.utils.multiprocessing import multiprocessing_apply

LOG = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion ultrack/core/linking/_test/test_link_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from sqlalchemy.orm import Session

from ultrack.config.config import MainConfig
from ultrack.core.database import NO_PARENT, LinkDB, NodeDB
from ultrack.core.database import LinkDB, NodeDB
from ultrack.core.linking.utils import clear_linking_data
from ultrack.utils.constants import NO_PARENT


@pytest.mark.parametrize(
Expand Down
3 changes: 2 additions & 1 deletion ultrack/core/solve/_test/test_sql_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

from ultrack import solve, to_tracks_layer
from ultrack.config.config import MainConfig
from ultrack.core.database import NO_PARENT, LinkDB, NodeDB, VarAnnotation
from ultrack.core.database import LinkDB, NodeDB, VarAnnotation
from ultrack.core.solve.sqltracking import SQLTracking
from ultrack.utils.constants import NO_PARENT

_CONFIG_PARAMS = {
"segmentation.n_workers": 4,
Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/solve/solver/heuristic/heuristic_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from skimage.util._map_array import ArrayMap

from ultrack.config.config import TrackingConfig
from ultrack.core.database import NO_PARENT
from ultrack.core.solve.solver.base_solver import BaseSolver
from ultrack.core.solve.solver.heuristic._numba_heuristic_solver import (
NumbaHeuristicSolver,
)
from ultrack.utils.array import assert_same_length
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion ultrack/core/solve/solver/mip_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from skimage.util._map_array import ArrayMap

from ultrack.config.config import TrackingConfig
from ultrack.core.database import NO_PARENT
from ultrack.core.solve.solver.base_solver import BaseSolver
from ultrack.utils.array import assert_same_length
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion ultrack/reader/_test/test_napari_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from napari.plugins import _initialize_plugins
from napari.viewer import ViewerModel

from ultrack.core.database import NO_PARENT
from ultrack.reader.napari_reader import napari_get_reader
from ultrack.utils.constants import NO_PARENT


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/_test/test_tracks_gap_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import zarr
import zarr.storage

from ultrack.core.database import NO_PARENT
from ultrack.tracks import close_tracks_gaps
from ultrack.utils.constants import NO_PARENT


def test_gap_closing() -> None:
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/_test/test_tracks_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import pandas as pd
import pytest

from ultrack.core.database import NO_PARENT
from ultrack.tracks import (
filter_short_sibling_tracks,
get_paths_to_roots,
get_subgraph,
split_trees,
)
from ultrack.utils.constants import NO_PARENT


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/_test/test_tracks_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import pandas as pd
from numba import typed, types

from ultrack.core.database import NO_PARENT
from ultrack.tracks import (
left_first_search,
sort_track_ids,
sort_trees_by_length,
sort_trees_by_max_radius,
)
from ultrack.utils.constants import NO_PARENT


def test_sortrees_by_length() -> None:
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/_test/test_tracks_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import pandas as pd
import pytest

from ultrack.core.database import NO_PARENT
from ultrack.tracks.stats import (
estimate_drift,
tracks_df_movement,
tracks_length,
tracks_profile_matrix,
)
from ultrack.utils.constants import NO_PARENT


def spatial_df(group_drift: Sequence[int], length_per_group: int = 10) -> pd.DataFrame:
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/_test/test_tracks_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pytest
from napari.viewer import ViewerModel

from ultrack.core.database import NO_PARENT
from ultrack.tracks.video import (
tracks_df_to_3D_video,
tracks_df_to_moving_2D_plane_video,
tracks_df_to_videos,
)
from ultrack.utils.constants import NO_PARENT

pytest.importorskip("napari_animation")

Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/gap_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scipy.spatial.distance import cdist
from zarr.storage import Store

from ultrack.core.database import NO_PARENT
from ultrack.utils.constants import NO_PARENT
from ultrack.utils.segmentation import SegmentationPainter, copy_segments


Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from numpy.typing import ArrayLike
from zarr.storage import Store

from ultrack.core.database import NO_PARENT
from ultrack.utils.constants import NO_PARENT
from ultrack.utils.segmentation import SegmentationPainter, copy_segments

LOG = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from scipy.spatial.distance import pdist
from tqdm import tqdm

from ultrack.core.database import NO_PARENT
from ultrack.tracks.graph import (
inv_tracks_df_forest,
left_first_search,
split_trees,
tracks_df_forest,
)
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion ultrack/tracks/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy as np
import pandas as pd

from ultrack.core.database import NO_PARENT
from ultrack.tracks.sorting import sort_track_ids
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 2 additions & 0 deletions ultrack/utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

NO_PARENT = -1

ULTRACK_DEBUG = bool(int(os.environ.get("ULTRACK_DEBUG", False)))
2 changes: 1 addition & 1 deletion ultrack/validation/_test/test_link_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from napari.viewer import ViewerModel

from ultrack.core.database import NO_PARENT
from ultrack.utils.constants import NO_PARENT
from ultrack.validation.link_validation import Annotation, LinkValidation


Expand Down
2 changes: 1 addition & 1 deletion ultrack/validation/link_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from qtpy.QtGui import QKeySequence
from qtpy.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget

from ultrack.core.database import NO_PARENT
from ultrack.utils.constants import NO_PARENT

LOG = logging.getLogger(__name__)

Expand Down

0 comments on commit 271de53

Please sign in to comment.