diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b543d6c..75dd289b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,23 +5,23 @@ ci: repos: - repo: https://github.com/crate-ci/typos - rev: v1.16.26 + rev: v1.18.1 hooks: - id: typos - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff args: [--fix] - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject diff --git a/src/traccuracy/__init__.py b/src/traccuracy/__init__.py index 662c5f31..537b8fc8 100644 --- a/src/traccuracy/__init__.py +++ b/src/traccuracy/__init__.py @@ -1,4 +1,5 @@ """package description.""" + from importlib.metadata import PackageNotFoundError, version try: diff --git a/src/traccuracy/_tracking_graph.py b/src/traccuracy/_tracking_graph.py index 45dd65de..db60a204 100644 --- a/src/traccuracy/_tracking_graph.py +++ b/src/traccuracy/_tracking_graph.py @@ -195,13 +195,13 @@ def __init__( self.nodes_by_frame[frame].add(node) # store node id in nodes_by_flag mapping for node_flag in NodeFlag: - if node_flag in attrs and attrs[node_flag]: + if attrs.get(node_flag): self.nodes_by_flag[node_flag].add(node) # store edge id in edges_by_flag for edge, attrs in self.graph.edges.items(): for edge_flag in EdgeFlag: - if edge_flag in attrs and attrs[edge_flag]: + if attrs.get(edge_flag): self.edges_by_flag[edge_flag].add(edge) # Store first and last frames for reference diff --git a/src/traccuracy/loaders/__init__.py b/src/traccuracy/loaders/__init__.py index eab93295..edb98eac 100644 --- a/src/traccuracy/loaders/__init__.py +++ b/src/traccuracy/loaders/__init__.py @@ -5,6 +5,7 @@ Each loading function must return one TrackingGraph object which has a track graph and optionally contains a corresponding segmentation. """ + from ._ctc import _check_ctc, _get_node_attributes, _load_tiffs, load_ctc_data __all__ = ["load_ctc_data", "_check_ctc", "_load_tiffs", "_get_node_attributes"] diff --git a/src/traccuracy/matchers/__init__.py b/src/traccuracy/matchers/__init__.py index e7a641b1..f662ecc3 100644 --- a/src/traccuracy/matchers/__init__.py +++ b/src/traccuracy/matchers/__init__.py @@ -25,6 +25,7 @@ While we specify ground truth and prediction, it is possible to write a matching function that matches two arbitrary tracking solutions. """ + from ._base import Matched from ._compute_overlap import get_labels_with_overlap from ._ctc import CTCMatcher diff --git a/src/traccuracy/matchers/_compute_overlap.py b/src/traccuracy/matchers/_compute_overlap.py index abd04085..ee904736 100644 --- a/src/traccuracy/matchers/_compute_overlap.py +++ b/src/traccuracy/matchers/_compute_overlap.py @@ -5,6 +5,7 @@ Licensed under The MIT License [see LICENSE for details] Copyright (c) 2015 Microsoft """ + from typing import Tuple import numpy as np diff --git a/src/traccuracy/metrics/_divisions.py b/src/traccuracy/metrics/_divisions.py index b3ed3d7e..9cc9f6d3 100644 --- a/src/traccuracy/metrics/_divisions.py +++ b/src/traccuracy/metrics/_divisions.py @@ -32,6 +32,7 @@ of the early division, by advancing along the graph to find nodes in the same frame as the late division daughters. """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/src/traccuracy/metrics/_track_overlap.py b/src/traccuracy/metrics/_track_overlap.py index 4326a74a..7a9ff5de 100644 --- a/src/traccuracy/metrics/_track_overlap.py +++ b/src/traccuracy/metrics/_track_overlap.py @@ -10,6 +10,7 @@ - TP is defined analogously, with T^g_j and T^p_j being swapped in the definition. """ + from __future__ import annotations from itertools import groupby, product