| 1 |
"""Test the plotting module from systematic_absences.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from dials.algorithms.symmetry.absences.plots import color_axis_data, plot_screw_axes |
| 6 |
|
| 7 |
|
| 8 |
def test_color_axis_data(): |
| 9 |
"""Test the helper function used to color the data.""" |
| 10 |
colors = color_axis_data("41c", list(range(1, 9))) |
| 11 |
assert colors == [0, 0, 0, 1, 0, 0, 0, 1] |
| 12 |
colors = color_axis_data("42c", list(range(1, 9))) |
| 13 |
assert colors == [0, 1, 0, 1, 0, 1, 0, 1] |
| 14 |
colors = color_axis_data("31c", list(range(1, 7))) |
| 15 |
assert colors == [0, 0, 1, 0, 0, 1] |
| 16 |
colors = color_axis_data("21c", list(range(1, 7))) |
| 17 |
assert colors == [0, 1, 0, 1, 0, 1] |
| 18 |
colors = color_axis_data("61c", list(range(1, 7))) |
| 19 |
assert colors == [0, 0, 0, 0, 0, 1] |
| 20 |
colors = color_axis_data("62c", list(range(1, 7))) |
| 21 |
assert colors == [0, 0, 1, 0, 0, 1] |
| 22 |
colors = color_axis_data("63c", list(range(1, 7))) |
| 23 |
assert colors == [0, 1, 0, 1, 0, 1] |
| 24 |
|
| 25 |
|
| 26 |
def test_plot_screw_axes(): |
| 27 |
"""Test that the plotting function returns plots with data.""" |
| 28 |
data = { |
| 29 |
"miller_axis_vals": [1, 2, 3, 4, 5, 6], |
| 30 |
"i_over_sigma": [0.5, 20.0, 0.2, 10.0, 0.4, 15.0], |
| 31 |
"intensities": [0.5, 20.0, 0.2, 10.0, 0.4, 15.0], |
| 32 |
"sigmas": [1.0] * 6, |
| 33 |
"fourier_space_data": {}, |
| 34 |
} |
| 35 |
plots = plot_screw_axes({"21a": data}) |
| 36 |
for pl in plots.values(): |
| 37 |
assert pl["data"][0]["x"] |
| 38 |
assert pl["data"][0]["y"] |