test_crop_center_2d and test_pad_centre_2d in tests/core/test_unit/test_tools/test_image_processing.py choose crop/pad sizes with unseeded random.randint:
def test_crop_center_2d():
x_shape = random.randint(2, 100)
...
new_x_shape = random.randint(1, x_shape)
def test_pad_centre_2d():
...
new_x_shape = random.randint(x_shape, x_shape * 10)
crop_center_2d / pad_center_2d branch on is_even(pad), so whether the even-branch or odd-branch line executes depends on those random sizes. As a result, cellfinder/core/tools/image_processing.py reports a slightly different set of covered lines on each run, with no code change.
Reproduce:
pytest tests/core/test_unit/test_tools/test_image_processing.py \
--cov=cellfinder.core.tools.image_processing --cov-report=term-missing -p no:xdist
Running it a few times, the missing lines flip between e.g. 77-78, 84 (11 missed) and 77-78, 86-87 (12 missed). Adding random.seed(0); np.random.seed(0) to the two tests makes the missing lines identical on every run.
test_crop_center_2dandtest_pad_centre_2dintests/core/test_unit/test_tools/test_image_processing.pychoose crop/pad sizes with unseededrandom.randint:crop_center_2d/pad_center_2dbranch onis_even(pad), so whether the even-branch or odd-branch line executes depends on those random sizes. As a result,cellfinder/core/tools/image_processing.pyreports a slightly different set of covered lines on each run, with no code change.Reproduce:
Running it a few times, the missing lines flip between e.g.
77-78, 84(11 missed) and77-78, 86-87(12 missed). Addingrandom.seed(0); np.random.seed(0)to the two tests makes the missing lines identical on every run.