Skip to content

Commit

Permalink
Merge pull request #68 from PinkShnack/adding_tests_02
Browse files Browse the repository at this point in the history
Add plot polarisation vectors tests to cover most important params
  • Loading branch information
PinkShnack committed Mar 20, 2022
2 parents 86e11d1 + 0ad5cc8 commit 0d7c950
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
flake8 temul tests docs
- name: Test with pytest
run: |
pytest tests
pytest -v tests
pytest --doctest-modules temul/topotem temul/element_tools.py temul/intensity_tools.py temul/io.py temul/model_creation.py temul/signal_plotting.py temul/signal_processing.py
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.1.8
- test: add plot polarisation plotting tests (#47, #68)
- enh: add and test polaris(z)ation aliases (#64)
- enh: add latest and all versions for citing in README
- enh: add PR and issue templates
Expand Down
75 changes: 74 additions & 1 deletion tests/test_topotem_polarisation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import pytest
import numpy as np

import temul.topotem.polarisation as pol
Expand Down Expand Up @@ -61,3 +61,76 @@ def test_get_angles_from_uv_radian():

angles = pol.get_angles_from_uv(u, v, degrees=False)
assert np.allclose(angles, angles_expt)


@pytest.mark.parametrize(
"plot_style, vector_rep",
[
("vector", "magnitude"), ("vector", "angle"),
("colormap", "magnitude"), ("colormap", "angle"),
("contour", "magnitude"), ("contour", "angle"),
("colorwheel", "angle"), # magnitude not allowed for colorwheel
("polar_colorwheel", "magnitude"), ("polar_colorwheel", "angle"),
]
)
def test_plot_polarisation_vectors_plot_style_vector_rep(
plot_style, vector_rep, get_dummy_xyuv, handle_plots):
"""Check the available plot_style."""
sublatticeA, sublatticeB, x, y, u, v = get_dummy_xyuv
_ = pol.plot_polarisation_vectors(
x, y, u, v, image=sublatticeA.image, save=None,
plot_style=plot_style, vector_rep=vector_rep)


@pytest.mark.parametrize(
"overlay, unit_vector",
[
(True, True),
(True, False),
(False, True),
(False, False),
]
)
def test_plot_polarisation_vectors_overlay_unit_vector(
overlay, unit_vector, get_dummy_xyuv, handle_plots):
"""Check the available overlay, unit_vector."""
sublatticeA, sublatticeB, x, y, u, v = get_dummy_xyuv
_ = pol.plot_polarisation_vectors(
x, y, u, v, image=sublatticeA.image, save=None,
overlay=overlay, unit_vector=unit_vector)


@pytest.mark.parametrize(
"sampling, units",
[
(None, 'pix'),
(0.05, 'um'),
(0.0034, 'nm'),
]
)
def test_plot_polarisation_vectors_sampling_units(
sampling, units, get_dummy_xyuv, handle_plots):
"""Check the available sampling, units."""
sublatticeA, sublatticeB, x, y, u, v = get_dummy_xyuv
_ = pol.plot_polarisation_vectors(
x, y, u, v, image=sublatticeA.image, save=None,
sampling=sampling, units=units)


@pytest.mark.parametrize(
"vector_rep, degrees, angle_offset",
[
('magnitude', False, None),
('angle', False, None),
('angle', True, None),
('angle', True, 10), # degrees
('angle', False, 0.02), # radians
]
)
def test_plot_polarisation_vectors_degrees_angle_offset(
vector_rep, degrees, angle_offset, get_dummy_xyuv, handle_plots):
"""Check the available sampling, units."""
sublatticeA, sublatticeB, x, y, u, v = get_dummy_xyuv
_ = pol.plot_polarisation_vectors(
x, y, u, v, image=sublatticeA.image, save=None,
vector_rep=vector_rep, degrees=degrees, angle_offset=angle_offset)

0 comments on commit 0d7c950

Please sign in to comment.