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

chore: Remove unused method, test and package dependencies #1049

Merged
merged 1 commit into from
Dec 12, 2024
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
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ dependencies = [
"art",
"AFMReader",
"h5py",
"igor2",
"keras",
"matplotlib",
"numpy",
"numpyencoder",
"pandas",
"pySPM",
"pyyaml",
"ruamel.yaml",
"schema",
Expand All @@ -54,7 +52,6 @@ dependencies = [
"skan~=0.11.0",
"snoop",
"tensorflow",
"tifffile",
"topoly",
"tqdm",
]
Expand All @@ -66,7 +63,6 @@ tests = [
"pytest-github-actions-annotate-failures",
"pytest-mpl",
"pytest-regtest==2.3.1",
"pytest-testmon",
"filetype",
]
docs = [
Expand All @@ -89,6 +85,7 @@ dev = [
"pyupgrade",
"pytest-durations",
"pytest-icdiff",
"pytest-testmon",
"pytest-xdist",
]
pypi = [
Expand Down
8 changes: 0 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
import pySPM
import pytest
import yaml
from skimage import draw, filters
Expand Down Expand Up @@ -373,13 +372,6 @@ def load_scan_spm() -> LoadScans:
return LoadScans([RESOURCES / "minicircle.spm"], channel="Height")


@pytest.fixture()
def spm_channel_data() -> pySPM.SPM.SPM_image:
"""Instantiate channel data from a LoadScans object."""
scan = pySPM.Bruker(RESOURCES / "minicircle.spm")
return scan.get_channel("Height")


@pytest.fixture()
def load_scan_ibw() -> LoadScans:
"""Instantiate a LoadScans object from a .ibw file."""
Expand Down
29 changes: 0 additions & 29 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import logging
from datetime import datetime
from pathlib import Path
from unittest.mock import patch

import h5py
import numpy as np
import pandas as pd
import pySPM
import pytest

from topostats.io import (
Expand Down Expand Up @@ -603,33 +601,6 @@ def test_load_scan_topostats(load_scan_topostats: LoadScans) -> None:
assert grain_trace_data.keys() == {"above"}


@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


@pytest.mark.parametrize(
("load_scan_object", "length", "image_shape", "image_sum", "filename", "pixel_to_nm_scaling"),
[
Expand Down
33 changes: 0 additions & 33 deletions topostats/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
import pySPM
from AFMReader import asd, gwy, ibw, jpk, spm, topostats
from numpyencoder import NumpyEncoder
from ruamel.yaml import YAML, YAMLError
Expand Down Expand Up @@ -642,38 +641,6 @@ def load_spm(self) -> tuple[npt.NDArray, float]:
LOGGER.error(f"File Not Found : {self.img_path}")
raise

def _spm_pixel_to_nm_scaling(self, channel_data: pySPM.SPM.SPM_image) -> float:
"""
Extract pixel to nm scaling from the SPM image metadata.

Parameters
----------
channel_data : pySPM.SPM.SPM_image
Channel data from PySPM.

Returns
-------
float
Pixel to nm scaling factor.
"""
unit_dict = {
"pm": 1e-3,
"nm": 1,
"um": 1e3,
"mm": 1e6,
}
px_to_real = channel_data.pxs()
# Has potential for non-square pixels but not yet implemented
pixel_to_nm_scaling = (
px_to_real[0][0] * unit_dict[px_to_real[0][1]],
px_to_real[1][0] * unit_dict[px_to_real[1][1]],
)[0]
if px_to_real[0][0] == 0 and px_to_real[1][0] == 0:
pixel_to_nm_scaling = 1
LOGGER.warning(f"[{self.filename}] : Pixel size not found in metadata, defaulting to 1nm")
LOGGER.debug(f"[{self.filename}] : Pixel to nm scaling : {pixel_to_nm_scaling}")
return pixel_to_nm_scaling

def load_topostats(self) -> tuple[npt.NDArray, float]:
"""
Load a .topostats file (hdf5 format).
Expand Down
Loading