-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_stp.py
More file actions
39 lines (32 loc) · 1.14 KB
/
test_stp.py
File metadata and controls
39 lines (32 loc) · 1.14 KB
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
"""Test the loading of .stp files."""
from pathlib import Path
import pytest
import numpy as np
from AFMReader.stp import load_stp
BASE_DIR = Path.cwd()
RESOURCES = BASE_DIR / "tests" / "resources"
@pytest.mark.parametrize(
(
"file_name",
"expected_pixel_to_nm_scaling",
"expected_image_shape",
"expected_image_dtype",
"expected_image_sum",
),
[pytest.param("sample_0.stp", 0.9765625, (512, 512), float, -15070620.440757688)],
)
def test_load_stp(
file_name: str,
expected_pixel_to_nm_scaling: float,
expected_image_shape: tuple[int, int],
expected_image_dtype: type,
expected_image_sum: float,
) -> None:
"""Test the normal operation of loading a .stp file."""
file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = load_stp(file_path=file_path)
assert result_pixel_to_nm_scaling == pytest.approx(expected_pixel_to_nm_scaling)
assert isinstance(result_image, np.ndarray)
assert result_image.shape == expected_image_shape
assert result_image.dtype == expected_image_dtype
assert result_image.sum() == pytest.approx(expected_image_sum)