Skip to content

Commit

Permalink
ci: fix tests for pytest>=8.0.0
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
JoepVanlier committed Jan 30, 2024
1 parent 5380adb commit c27c82e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -12,6 +12,7 @@
* 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.
* 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.
* 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.
* Fixed tests to be compatible with `pytest>=8.0.0`.

## v1.3.1 | 2023-12-07

Expand Down
1 change: 1 addition & 0 deletions lumicks/pylake/force_calibration/tests/test_touchdown.py
Expand Up @@ -145,6 +145,7 @@ def test_exp_sine_fits(decay, amplitude, frequency, phase_shift):
np.testing.assert_allclose(par, frequency, rtol=1e-6)


@pytest.mark.filterwarnings("ignore:Covariance of the parameters could not be estimated")
def test_insufficient_data(mack_parameters):
stage_positions, simulation = simulate_touchdown(102.5, 103.5, 0.01, mack_parameters)

Expand Down
4 changes: 3 additions & 1 deletion lumicks/pylake/kymotracker/tests/conftest.py
Expand Up @@ -66,7 +66,7 @@ def two_gaussians_1d():

@pytest.fixture
def blank_kymo():
return generate_kymo(
kymo = generate_kymo(
"",
np.ones((1, 10)),
pixel_size_nm=1000,
Expand All @@ -75,6 +75,8 @@ def blank_kymo():
samples_per_pixel=1,
line_padding=0,
)
kymo._motion_blur_constant = 0
return kymo


@pytest.fixture
Expand Down
12 changes: 10 additions & 2 deletions lumicks/pylake/kymotracker/tests/test_kymotrack.py
Expand Up @@ -867,7 +867,9 @@ def test_fit_binding_times_nonzero(blank_kymo, blank_kymo_track_args):
r"analysis. If you wish to not see this warning, filter the tracks with "
r"`lk.filter_tracks` with a minimum length of 2 samples.",
):
dwelltime_model = tracks.fit_binding_times(1)
dwelltime_model = tracks.fit_binding_times(
n_components=1, observed_minimum=True, discrete_model=False
)
np.testing.assert_equal(dwelltime_model.dwelltimes, [4, 4, 4, 4])
np.testing.assert_equal(dwelltime_model._observation_limits[0], 4)
np.testing.assert_allclose(dwelltime_model.lifetimes[0], [0.4])
Expand Down Expand Up @@ -1145,6 +1147,7 @@ def test_kymotrack_group_diffusion_filter():
image = np.random.randint(0, 20, size=(10, 10, 3))
kwargs = dict(line_time_seconds=10e-3, start=np.int64(20e9), pixel_size_um=0.05, name="test")
kymo = _kymo_from_array(image, "rgb", **kwargs)
kymo._motion_blur_constant = 0

base_coordinates = (
np.arange(1, 10),
Expand Down Expand Up @@ -1408,7 +1411,12 @@ def test_ensemble_diffusion_different_attributes():
line_times = (1, 0.5)
pixel_sizes = (0.1, 0.05)
kwargs = [{"line_time_seconds": t, "pixel_size_um": s} for t in line_times for s in pixel_sizes]
kymos = [_kymo_from_array(np.random.poisson(5, (25, 25, 3)), "rgb", **k) for k in kwargs]
kymos = []
for k in kwargs:
kymo = _kymo_from_array(np.random.poisson(5, (25, 25, 3)), "rgb", **k)
kymo._motion_blur_constant = 0
kymos.append(kymo)

tracks = [
KymoTrackGroup(
[KymoTrack(np.arange(5), np.random.uniform(3, 5, 5), k, "green", 0) for _ in range(5)]
Expand Down

0 comments on commit c27c82e

Please sign in to comment.