Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/resources/sample_0.jpk-qi-image
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/test_gwy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def test_load_gwy() -> None:
result_image, result_pixel_to_nm_scaling = gwy.load_gwy(file_path, channel=channel)
assert isinstance(result_image, np.ndarray)
assert result_image.shape == (512, 512)
assert result_image.sum() == 33836850.232917726
assert result_image.sum() == pytest.approx(33836850.232917726)
assert isinstance(result_pixel_to_nm_scaling, float)
assert result_pixel_to_nm_scaling == 0.8468632812499975
assert result_pixel_to_nm_scaling == pytest.approx(0.8468632812499975)


def test_gwy_read_object() -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ibw.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def test_load_ibw(
file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = ibw.load_ibw(file_path, channel) # type: ignore

assert result_pixel_to_nm_scaling == pixel_to_nm_scaling
assert result_pixel_to_nm_scaling == pytest.approx(pixel_to_nm_scaling)
assert isinstance(result_image, np.ndarray)
assert result_image.shape == image_shape
assert result_image.dtype == image_dtype
assert result_image.sum() == image_sum
assert result_image.sum() == pytest.approx(image_sum)


def test_load_ibw_file_not_found() -> None:
Expand Down
52 changes: 48 additions & 4 deletions tests/test_jpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,52 @@
[
pytest.param(
"sample_0.jpk", "height_trace", 1.2770176335964876, (256, 256), float, 219242202.8256843, id="test image 0"
)
),
pytest.param(
"sample_0.jpk-qi-image",
"height_trace",
4.999999999999986,
(100, 100),
float,
31593146.16051172,
id="qi-image 0; height_trace",
),
pytest.param(
"sample_0.jpk-qi-image",
"slope_trace",
4.999999999999986,
(100, 100),
float,
626.3810326940231,
id="qi-image 0; slope_trace",
),
pytest.param(
"sample_0.jpk-qi-image",
"adhesion_trace",
4.999999999999986,
(100, 100),
float,
1.579363986493833e-06,
id="qi-image 0; adhesion_trace",
),
pytest.param(
"sample_0.jpk-qi-image",
"measuredHeight_trace",
4.999999999999986,
(100, 100),
float,
32181137.138706185,
id="qi-image 0; measuredHeight_trace",
),
pytest.param(
"sample_0.jpk-qi-image",
"vDeflection_trace",
4.999999999999986,
(100, 100),
float,
-1.3615033224242345e-05,
id="qi-image 0; vDeflection_trace",
),
],
)
def test_load_jpk(
Expand All @@ -30,15 +75,14 @@ def test_load_jpk(
"""Test the normal operation of loading a .jpk file."""
result_image = np.ndarray
result_pixel_to_nm_scaling = float

file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = jpk.load_jpk(file_path, channel) # type: ignore

assert result_pixel_to_nm_scaling == pixel_to_nm_scaling
assert result_pixel_to_nm_scaling == pytest.approx(pixel_to_nm_scaling)
assert isinstance(result_image, np.ndarray)
assert result_image.shape == image_shape
assert result_image.dtype == image_dtype
assert result_image.sum() == image_sum
assert result_image.sum() == pytest.approx(image_sum)


def test_load_jpk_file_not_found() -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def test_load_spm(
file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = spm.load_spm(file_path, channel=channel)

assert result_pixel_to_nm_scaling == pixel_to_nm_scaling
assert result_pixel_to_nm_scaling == pytest.approx(pixel_to_nm_scaling)
assert isinstance(result_image, np.ndarray)
assert result_image.shape == image_shape
assert result_image.dtype == image_dtype
assert result_image.sum() == image_sum
assert result_image.sum() == pytest.approx(image_sum)


@patch("pySPM.SPM.SPM_image.pxs")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_load_stp(
file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = load_stp(file_path=file_path)

assert result_pixel_to_nm_scaling == expected_pixel_to_nm_scaling
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() == expected_image_sum
assert result_image.sum() == pytest.approx(expected_image_sum)
4 changes: 2 additions & 2 deletions tests/test_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_load_top(
file_path = RESOURCES / file_name
result_image, result_pixel_to_nm_scaling = load_top(file_path=file_path)

assert result_pixel_to_nm_scaling == expected_pixel_to_nm_scaling
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() == expected_image_sum
assert result_image.sum() == pytest.approx(expected_image_sum)
4 changes: 2 additions & 2 deletions tests/test_topostats.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def test_load_topostats(
assert topostats_data[version_key] == float(version)
else:
assert topostats_data[version_key] == version
assert topostats_data["pixel_to_nm_scaling"] == pixel_to_nm_scaling
assert topostats_data["pixel_to_nm_scaling"] == pytest.approx(pixel_to_nm_scaling)
assert topostats_data["image"].shape == image_shape
assert topostats_data["image"].sum() == image_sum
assert topostats_data["image"].sum() == pytest.approx(image_sum)
if version >= "0.2":
assert isinstance(topostats_data["img_path"], Path)

Expand Down