Skip to content

Commit

Permalink
Merge pull request #223 from lettlini/arguments_bug
Browse files Browse the repository at this point in the history
Resolves #212
  • Loading branch information
freemansw1 authored Jan 27, 2023
2 parents 0990817 + 88bdf5e commit 2b43edf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tobac/tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,26 @@ def test_tracking_extrapolation():
output = tobac.linking_trackpy(
cell_1, None, 1, 1, d_max=100, method_linking="predict", extrapolate=1
)


def test_argument_logic():
"""Tests whether missing arguments are handled correctly,
i.e. whether a ValueError is raised if neither d_min, d_max nor v_max have
been provided to tobac.linking_trackpy.
"""
cell_1 = tobac.testing.generate_single_feature(
1,
1,
min_h1=0,
max_h1=100,
min_h2=0,
max_h2=100,
frame_start=0,
num_frames=5,
spd_h1=20,
spd_h2=20,
)
with pytest.raises(ValueError):
output = tobac.linking_trackpy(
cell_1, None, 1, 1, d_min=None, d_max=None, v_max=None
)
5 changes: 5 additions & 0 deletions tobac/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ def linking_trackpy(
# from trackpy import filter_stubs
# from .utils import add_coordinates

if (v_max is None) and (d_min is None) and (d_max is None):
raise ValueError(
"Neither d_max nor v_max has been provided. Either one of these arguments must be specified."
)

# calculate search range based on timestep and grid spacing
if v_max is not None:
search_range = int(dt * v_max / dxy)
Expand Down

0 comments on commit 2b43edf

Please sign in to comment.