File: peak2d_limits_unit_test.py

package info (click to toggle)
python-sigima 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 25,608 kB
  • sloc: python: 35,251; makefile: 3
file content (41 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.

"""
Image peak detection test: testing algorithm limits
"""

# pylint: disable=invalid-name  # Allows short reference names like x, y, ...

import pytest

from sigima.tests.data import get_peak2d_data
from sigima.tests.env import execenv
from sigima.tests.image.peak2d_unit_test import (
    exec_image_peak_detection_func,
)
from sigima.tools.image import get_2d_peaks_coords


@pytest.mark.skip(reason="Limit testing, not required for automated testing")
def test_peak2d_limit():
    """2D peak detection test"""
    # pylint: disable=import-outside-toplevel
    from guidata.qthelpers import qt_app_context

    with qt_app_context():
        execenv.print("Testing peak detection algorithm with random generated data:")
        for idx in range(100):
            execenv.print(f"  Iteration #{idx:02d}: ", end="")
            generated_data, _coords = get_peak2d_data(multi=True)
            coords = get_2d_peaks_coords(generated_data)
            if coords.shape[0] != 4:
                execenv.print(f"KO - {coords.shape[0]}/4 peaks were detected")
                exec_image_peak_detection_func(generated_data)
            else:
                execenv.print("OK")
        # Showing results for last generated sample
        exec_image_peak_detection_func(generated_data)


if __name__ == "__main__":
    test_peak2d_limit()