Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate test for spm_px_to_nm_scaling #86

Closed
ns-rse opened this issue Dec 11, 2024 · 0 comments · Fixed by #87
Closed

Migrate test for spm_px_to_nm_scaling #86

ns-rse opened this issue Dec 11, 2024 · 0 comments · Fixed by #87
Assignees
Labels
testing Problems with testing

Comments

@ns-rse
Copy link
Collaborator

ns-rse commented Dec 11, 2024

The AFMReader.io.spm_px_to_nm_scaling() function had additional units migrated to AFMReader (see #84).

We don't have the test copied over from TopoStats (tests/test_io.py)...

@patch("pySPM.SPM.SPM_image.pxs")
@pytest.mark.parametrize(
    ("unit", "x", "y", "expected_px2nm"),
    [
        pytest.param("mm", 0.01, 0.01, 10000, id="mm units; square"),
        pytest.param("um", 1.5, 1.5, 1500, id="um units; square"),
        pytest.param("nm", 50, 50, 50, id="nm units; square"),
        pytest.param("pm", 233, 233, 0.233, id="pm units; square"),
        pytest.param("pm", 1, 512, 0.001, id="pm units; rectangular (thin)"),
        pytest.param("pm", 512, 1, 0.512, id="pm units; rectangular (tall)"),
    ],
)
def test__spm_pixel_to_nm_scaling(
    mock_pxs,
    load_scan_spm: LoadScans,
    spm_channel_data: pySPM.SPM.SPM_image,
    unit: str,
    x: int,
    y: int,
    expected_px2nm: float,
) > None:
    """Test extraction of pixels to nanometer scaling."""
    mock_pxs.return_value = [(x, unit), (y, unit)]  # issue is that pxs is a func that returns the data
    result = load_scan_spm._spm_pixel_to_nm_scaling(spm_channel_data)
    assert result == expected_px2nm
@ns-rse ns-rse added the testing Problems with testing label Dec 11, 2024
@ns-rse ns-rse self-assigned this Dec 11, 2024
@ns-rse ns-rse closed this as completed in f4f6c9d Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Problems with testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant