-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: ensure new array processing results in identical values
- Loading branch information
Eoghan O'Connell
committed
Jan 7, 2025
1 parent
e9a623a
commit 284ebe1
Showing
10 changed files
with
411 additions
and
67 deletions.
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
sphinx==4.3.0 | ||
sphinxcontrib.bibtex>=2.0 | ||
sphinx_rtd_theme==1.0 | ||
|
||
sphinx | ||
sphinxcontrib.bibtex | ||
sphinx_rtd_theme |
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 @@ | ||
matplotlib |
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,46 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from qpretrieve.data_input import check_data_input_format | ||
|
||
|
||
def test_check_data_input_2d(): | ||
data = np.zeros(shape=(256, 256)) | ||
|
||
data_new, data_format = check_data_input_format(data) | ||
|
||
assert data_new.shape == (1, 256, 256) | ||
assert np.array_equal(data_new[0], data) | ||
assert data_format == "2d" | ||
|
||
|
||
def test_check_data_input_3d_image_stack(): | ||
data = np.zeros(shape=(50, 256, 256)) | ||
|
||
data_new, data_format = check_data_input_format(data) | ||
|
||
assert data_new.shape == (50, 256, 256) | ||
assert np.array_equal(data_new, data) | ||
assert data_format == "3d" | ||
|
||
|
||
def test_check_data_input_3d_rgb(): | ||
data = np.zeros(shape=(256, 256, 3)) | ||
|
||
with pytest.warns(UserWarning): | ||
data_new, data_format = check_data_input_format(data) | ||
|
||
assert data_new.shape == (1, 256, 256) | ||
assert np.array_equal(data_new[0], data[:, :, 0]) | ||
assert data_format == "rgb" | ||
|
||
|
||
def test_check_data_input_3d_rgba(): | ||
data = np.zeros(shape=(256, 256, 4)) | ||
|
||
with pytest.warns(UserWarning): | ||
data_new, data_format = check_data_input_format(data) | ||
|
||
assert data_new.shape == (1, 256, 256) | ||
assert np.array_equal(data_new[0], data[:, :, 0]) | ||
assert data_format == "rgba" |
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,40 @@ | ||
import pathlib | ||
import numpy as np | ||
import pytest | ||
|
||
import qpretrieve | ||
|
||
data_path = pathlib.Path(__file__).parent / "data" | ||
|
||
|
||
def test_interfere_base_best_interface(): | ||
edata = np.load(data_path / "hologram_cell.npz") | ||
|
||
holo = qpretrieve.OffAxisHologram(data=edata["data"]) | ||
assert holo.ff_iface.is_available | ||
assert issubclass(holo.ff_iface, | ||
qpretrieve.fourier.base.FFTFilter) | ||
assert issubclass(holo.ff_iface, | ||
qpretrieve.fourier.ff_numpy.FFTFilterNumpy) | ||
|
||
|
||
def test_interfere_base_choose_interface(): | ||
edata = np.load(data_path / "hologram_cell.npz") | ||
|
||
holo = qpretrieve.OffAxisHologram( | ||
data=edata["data"], | ||
fft_interface=qpretrieve.fourier.FFTFilterNumpy) | ||
assert holo.ff_iface.is_available | ||
assert issubclass(holo.ff_iface, | ||
qpretrieve.fourier.base.FFTFilter) | ||
assert issubclass(holo.ff_iface, | ||
qpretrieve.fourier.ff_numpy.FFTFilterNumpy) | ||
|
||
|
||
def test_interfere_base_bad_interface(): | ||
edata = np.load(data_path / "hologram_cell.npz") | ||
|
||
with pytest.raises(ValueError): | ||
_ = qpretrieve.OffAxisHologram( | ||
data=edata["data"], | ||
fft_interface="MyReallyCoolFFTInterface") |
Oops, something went wrong.