-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from utkarshp1161/main
gwyfile in setup_requires
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
import sidpy | ||
import SciFiReaders as sr | ||
from pywget import wget | ||
import os | ||
try: | ||
import gwyfile | ||
except ImportError: | ||
import pip | ||
pip.main(['install', 'gwyfile']) | ||
root_path = "https://github.com/pycroscopy/SciFiDatasets/blob/main/data/microscopy/spm/afm/" | ||
|
||
@pytest.fixture | ||
def gwy_file(): | ||
file_path = 'PTO_110_Virgin0001.gwy' | ||
wget.download(root_path + "/PTO_110_Virgin0001.gwy?raw=true", out=file_path) | ||
yield file_path | ||
os.remove(file_path) | ||
|
||
def test_load_test_gwy_file(gwy_file): | ||
data_translator = sr.GwyddionReader(gwy_file) | ||
datasets = data_translator.read(verbose=False) | ||
assert len(datasets) == 4, f"Length of dataset should be 2 but is instead {len(datasets)}" | ||
channel_names = ['HeightRetrace', 'AmplitudeRetrace', 'DeflectionRetrace', 'PhaseRetrace'] | ||
channel_units = ['m', 'm', 'm', 'deg'] | ||
channel_labels = [['x (m)', 'y (m)'], ['x (m)', 'y (m)'], ['x (m)', 'y (m)'], ['x (m)', 'y (m)']] | ||
for ind, dataset in enumerate(datasets): | ||
assert isinstance(dataset, sidpy.sid.dataset.Dataset), f"Dataset No. {ind} not read in as sidpy dataset but was instead read in as {type(dataset)}" | ||
assert dataset.shape[0] == 256, f"Dataset[{ind}] is of size 512 but was read in as {dataset.shape[0]}" | ||
assert isinstance(dataset._axes[0], sidpy.sid.dimension.Dimension), "Dataset should have dimension type of sidpy Dimension, but is instead {}".format(type(dataset._axes)) | ||
assert dataset.quantity == channel_names[ind], "Dataset having inconsistent channel names" | ||
assert dataset.units == channel_units[ind], "Dataset having inconsistent unit names" | ||
assert dataset.labels == channel_labels[ind], "Dataset having inconsistent channel labels" |