Skip to content

Commit 3e6bd1a

Browse files
committed
ci: fix tests for pytest>=8.0.0
pytest changed its warning/exception order starting from 8.0.0 (see pytest-dev/pytest#9036). This updates our tests to fit the new spec. For kymographs, this meant explicitly passing a motion blur parameter such that we don't issue that error instead of what we are looking for. For the dwelltime analysis, we have to make sure we don't get any of the deprecation warnings so that we can see the warning we are testing for. For touchdown, we have to explicitly silence the covariance matrix is undefined error (which actually already tells us that the problem will be non-identifiable).
1 parent 5380adb commit 3e6bd1a

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Fixed a bug where the time between frames was incorrectly not excluded when calling [`ImageStack.frame_timestamp_ranges()`](https://lumicks-pylake.readthedocs.io/en/latest/_api/lumicks.pylake.ImageStack.html#lumicks.pylake.ImageStack.frame_timestamp_ranges) with `include_dead_time=False`. Note that `Scan` and `Kymo` are not affected.
1313
* Fixed a bug where [`ImageStack.plot_correlated()`](https://lumicks-pylake.readthedocs.io/en/v1.3.0/_api/lumicks.pylake.ImageStack.html#lumicks.pylake.ImageStack.plot_correlated) was not excluding the dead time between frames.
1414
* Changed the `DateTime` tag on TIFFs exported with Pylake from `Scan` and `Kymo` objects. Before the change, the start and end of the scanning period in nanoseconds was stored. After the change, we store the starting timestamp of the frame, followed by the starting timestamp of the next frame to be consistent with data exported from Bluelake. The scanning time is stored in the field `Exposure time (ms)` on the Description tag.
15+
* Fixed tests to be compatible with `pytest>=8.0.0`.
1516

1617
## v1.3.1 | 2023-12-07
1718

lumicks/pylake/force_calibration/tests/test_touchdown.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def test_exp_sine_fits(decay, amplitude, frequency, phase_shift):
145145
np.testing.assert_allclose(par, frequency, rtol=1e-6)
146146

147147

148+
@pytest.mark.filterwarnings("ignore:Covariance of the parameters could not be estimated")
149+
@pytest.mark.filterwarnings("ignore:Surface detection failed")
148150
def test_insufficient_data(mack_parameters):
149151
stage_positions, simulation = simulate_touchdown(102.5, 103.5, 0.01, mack_parameters)
150152

lumicks/pylake/kymotracker/tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def two_gaussians_1d():
6666

6767
@pytest.fixture
6868
def blank_kymo():
69-
return generate_kymo(
69+
kymo = generate_kymo(
7070
"",
7171
np.ones((1, 10)),
7272
pixel_size_nm=1000,
@@ -75,6 +75,8 @@ def blank_kymo():
7575
samples_per_pixel=1,
7676
line_padding=0,
7777
)
78+
kymo._motion_blur_constant = 0
79+
return kymo
7880

7981

8082
@pytest.fixture

lumicks/pylake/kymotracker/tests/test_kymotrack.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,9 @@ def test_fit_binding_times_nonzero(blank_kymo, blank_kymo_track_args):
867867
r"analysis. If you wish to not see this warning, filter the tracks with "
868868
r"`lk.filter_tracks` with a minimum length of 2 samples.",
869869
):
870-
dwelltime_model = tracks.fit_binding_times(1)
870+
dwelltime_model = tracks.fit_binding_times(
871+
n_components=1, observed_minimum=True, discrete_model=False
872+
)
871873
np.testing.assert_equal(dwelltime_model.dwelltimes, [4, 4, 4, 4])
872874
np.testing.assert_equal(dwelltime_model._observation_limits[0], 4)
873875
np.testing.assert_allclose(dwelltime_model.lifetimes[0], [0.4])
@@ -1145,6 +1147,7 @@ def test_kymotrack_group_diffusion_filter():
11451147
image = np.random.randint(0, 20, size=(10, 10, 3))
11461148
kwargs = dict(line_time_seconds=10e-3, start=np.int64(20e9), pixel_size_um=0.05, name="test")
11471149
kymo = _kymo_from_array(image, "rgb", **kwargs)
1150+
kymo._motion_blur_constant = 0
11481151

11491152
base_coordinates = (
11501153
np.arange(1, 10),
@@ -1407,8 +1410,15 @@ def test_invalid_ensemble_diffusion(blank_kymo):
14071410
def test_ensemble_diffusion_different_attributes():
14081411
line_times = (1, 0.5)
14091412
pixel_sizes = (0.1, 0.05)
1410-
kwargs = [{"line_time_seconds": t, "pixel_size_um": s} for t in line_times for s in pixel_sizes]
1411-
kymos = [_kymo_from_array(np.random.poisson(5, (25, 25, 3)), "rgb", **k) for k in kwargs]
1413+
multi_kwargs = [
1414+
{"line_time_seconds": t, "pixel_size_um": s} for t in line_times for s in pixel_sizes
1415+
]
1416+
kymos = []
1417+
for kwargs in multi_kwargs:
1418+
kymo = _kymo_from_array(np.random.poisson(5, (25, 25, 3)), "rgb", **kwargs)
1419+
kymo._motion_blur_constant = 0
1420+
kymos.append(kymo)
1421+
14121422
tracks = [
14131423
KymoTrackGroup(
14141424
[KymoTrack(np.arange(5), np.random.uniform(3, 5, 5), k, "green", 0) for _ in range(5)]

0 commit comments

Comments
 (0)