Debian Codegraph @

tests/algorithms/symmetry/cosym/test_plots.py

raw
1 from __future__ import annotations
2
3 import numpy as np
4
5 from dials.algorithms.symmetry.cosym import plots
6
7
8 def test_plot_coords():
9 coords = np.array([0.5, 0.5, 0, 1, 0, 1, 1, 0, 1, 0]).reshape(5, 2)
10 labels = np.array([-1, 0, 0, 1, 1])
11 d = plots.plot_coords(coords, labels=labels)
12 assert "cosym_coordinates" in d
13 assert set(d["cosym_coordinates"]) == {"data", "help", "layout"}
14 assert (
15 d["cosym_coordinates"]["data"][0]["marker"]["color"]
16 == "rgb(0.000000,0.000000,0.000000)"
17 )
18 assert d["cosym_coordinates"]["data"][0]["x"] == [0.5]
19 assert d["cosym_coordinates"]["data"][0]["y"] == [0.5]
20 assert d["cosym_coordinates"]["data"][1]["x"] == [0.0, 0.0]
21 assert d["cosym_coordinates"]["data"][1]["y"] == [1.0, 1.0]
22 assert d["cosym_coordinates"]["data"][2]["x"] == [1.0, 1.0]
23 assert d["cosym_coordinates"]["data"][2]["y"] == [0.0, 0.0]
24
25
26 def test_plot_rij_histogram():
27 rij_matrix = np.random.rand(16)
28 d = plots.plot_rij_histogram(rij_matrix)
29 assert "cosym_rij_histogram" in d
30 assert sum(d["cosym_rij_histogram"]["data"][0]["y"]) == 16