Skip to content

Commit ad3d4d4

Browse files
committed
ci: Add synthetic indexing file for testing
1 parent 3f260d0 commit ad3d4d4

3 files changed

Lines changed: 244 additions & 97 deletions

File tree

tests/fixtures/test_indexing.xml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<AllSteps>
2+
<step>
3+
<Xsample>100.0</Xsample>
4+
<Ysample>200.0</Ysample>
5+
<Zsample>300.0</Zsample>
6+
<depth>nan</depth>
7+
<energy unit="keV">20.0</energy>
8+
<scanNum>1001</scanNum>
9+
<detector>
10+
<inputImage>test/image_001.h5</inputImage>
11+
<detectorID>TEST-DET</detectorID>
12+
<Nx>2048</Nx>
13+
<Ny>2048</Ny>
14+
<peaksXY Npeaks="12">
15+
<Xpixel>100.1 200.2 300.3 400.4 500.5 600.6 700.7 800.8 900.9 1000.0 1100.1 1200.2</Xpixel>
16+
<Ypixel>150.1 250.2 350.3 450.4 550.5 650.6 750.7 850.8 950.9 1050.0 1150.1 1250.2</Ypixel>
17+
<Intens>1000 900 800 700 600 500 400 300 200 100 50 25</Intens>
18+
<Integral>30.0 28.0 26.0 24.0 22.0 20.0 18.0 16.0 14.0 12.0 10.0 8.0</Integral>
19+
<Qx>0.10 -0.17 0.25 -0.30 0.12 -0.22 0.18 -0.14 0.20 -0.11 0.15 -0.19</Qx>
20+
<Qy>0.67 0.64 0.55 0.70 0.60 0.58 0.62 0.66 0.53 0.71 0.59 0.63</Qy>
21+
<Qz>-0.74 -0.75 -0.80 -0.65 -0.79 -0.78 -0.76 -0.73 -0.82 -0.69 -0.77 -0.74</Qz>
22+
</peaksXY>
23+
</detector>
24+
<indexing Nindexed="12" Npeaks="12" Npatterns="2">
25+
<pattern num="0" rms_error="0.005" goodness="150.0" Nindexed="9">
26+
<recip_lattice unit="1/nm">
27+
<astar>-10.0 5.0 -6.0</astar>
28+
<bstar>-15.0 -2.0 -1.0</bstar>
29+
<cstar>-2.0 13.0 8.0</cstar>
30+
</recip_lattice>
31+
<hkl_s>
32+
<h>3 5 7 5 7 8 6 8 10</h>
33+
<k>-1 -1 -1 1 1 -2 0 0 0</k>
34+
<l>1 1 1 1 1 2 2 2 2</l>
35+
<PkIndex>0 1 2 3 4 5 6 7 8</PkIndex>
36+
</hkl_s>
37+
</pattern>
38+
<pattern num="1" rms_error="0.008" goodness="120.0" Nindexed="3">
39+
<recip_lattice unit="1/nm">
40+
<astar>-11.0 4.0 -5.0</astar>
41+
<bstar>-14.0 -3.0 -2.0</bstar>
42+
<cstar>-3.0 12.0 7.0</cstar>
43+
</recip_lattice>
44+
<hkl_s>
45+
<h>2 4 6</h>
46+
<k>0 0 0</k>
47+
<l>2 2 2</l>
48+
<PkIndex>9 10 11</PkIndex>
49+
</hkl_s>
50+
</pattern>
51+
<xtl>
52+
<structureDesc>TestMaterial</structureDesc>
53+
<SpaceGroup>225</SpaceGroup>
54+
<latticeParameters unit="nm">0.40000 0.40000 0.40000 90 90 90</latticeParameters>
55+
<atom n="1" symbol="X" label="X">0 0 0</atom>
56+
</xtl>
57+
</indexing>
58+
</step>
59+
<step>
60+
<Xsample>101.0</Xsample>
61+
<Ysample>200.0</Ysample>
62+
<Zsample>300.0</Zsample>
63+
<depth>nan</depth>
64+
<energy unit="keV">20.0</energy>
65+
<scanNum>1002</scanNum>
66+
<detector>
67+
<inputImage>test/image_002.h5</inputImage>
68+
<detectorID>TEST-DET</detectorID>
69+
<Nx>2048</Nx>
70+
<Ny>2048</Ny>
71+
<peaksXY Npeaks="8">
72+
<Xpixel>110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0</Xpixel>
73+
<Ypixel>160.0 260.0 360.0 460.0 560.0 660.0 760.0 860.0</Ypixel>
74+
<Intens>950 850 750 650 550 450 350 250</Intens>
75+
<Integral>29.0 27.0 25.0 23.0 21.0 19.0 17.0 15.0</Integral>
76+
<Qx>0.11 -0.16 0.24 -0.29 0.13 -0.21 0.17 -0.13</Qx>
77+
<Qy>0.66 0.63 0.54 0.69 0.61 0.57 0.61 0.65</Qy>
78+
<Qz>-0.73 -0.76 -0.81 -0.66 -0.78 -0.79 -0.77 -0.74</Qz>
79+
</peaksXY>
80+
</detector>
81+
<indexing Nindexed="6" Npeaks="8" Npatterns="1">
82+
<pattern num="0" rms_error="0.006" goodness="140.0" Nindexed="6">
83+
<recip_lattice unit="1/nm">
84+
<astar>-10.1 5.1 -6.1</astar>
85+
<bstar>-15.1 -2.1 -1.1</bstar>
86+
<cstar>-2.1 13.1 8.1</cstar>
87+
</recip_lattice>
88+
<hkl_s>
89+
<h>3 5 7 5 7 8</h>
90+
<k>-1 -1 -1 1 1 -2</k>
91+
<l>1 1 1 1 1 2</l>
92+
<PkIndex>0 1 2 3 4 5</PkIndex>
93+
</hkl_s>
94+
</pattern>
95+
<xtl>
96+
<structureDesc>TestMaterial</structureDesc>
97+
<SpaceGroup>225</SpaceGroup>
98+
<latticeParameters unit="nm">0.40000 0.40000 0.40000 90 90 90</latticeParameters>
99+
</xtl>
100+
</indexing>
101+
</step>
102+
<step>
103+
<Xsample>102.0</Xsample>
104+
<Ysample>200.0</Ysample>
105+
<Zsample>300.0</Zsample>
106+
<depth>nan</depth>
107+
<energy unit="keV">20.0</energy>
108+
<scanNum>1003</scanNum>
109+
<detector>
110+
<inputImage>test/image_003.h5</inputImage>
111+
<detectorID>TEST-DET</detectorID>
112+
<Nx>2048</Nx>
113+
<Ny>2048</Ny>
114+
<peaksXY Npeaks="5">
115+
<Xpixel>120.0 230.0 340.0 450.0 560.0</Xpixel>
116+
<Ypixel>170.0 270.0 370.0 470.0 570.0</Ypixel>
117+
<Intens>920 820 720 620 520</Intens>
118+
<Integral>28.5 26.5 24.5 22.5 20.5</Integral>
119+
<Qx>0.12 -0.15 0.23 -0.28 0.14</Qx>
120+
<Qy>0.65 0.62 0.53 0.68 0.62</Qy>
121+
<Qz>-0.72 -0.77 -0.82 -0.67 -0.77</Qz>
122+
</peaksXY>
123+
</detector>
124+
<indexing Nindexed="4" Npeaks="5" Npatterns="1">
125+
<pattern num="0" rms_error="0.007" goodness="130.0" Nindexed="4">
126+
<recip_lattice unit="1/nm">
127+
<astar>-10.2 5.2 -6.2</astar>
128+
<bstar>-15.2 -2.2 -1.2</bstar>
129+
<cstar>-2.2 13.2 8.2</cstar>
130+
</recip_lattice>
131+
<hkl_s>
132+
<h>3 5 7 5</h>
133+
<k>-1 -1 -1 1</k>
134+
<l>1 1 1 1</l>
135+
<PkIndex>0 1 2 3</PkIndex>
136+
</hkl_s>
137+
</pattern>
138+
<xtl>
139+
<structureDesc>TestMaterial</structureDesc>
140+
<SpaceGroup>225</SpaceGroup>
141+
<latticeParameters unit="nm">0.40000 0.40000 0.40000 90 90 90</latticeParameters>
142+
</xtl>
143+
</indexing>
144+
</step>
145+
<step>
146+
<Xsample>103.0</Xsample>
147+
<Ysample>200.0</Ysample>
148+
<Zsample>300.0</Zsample>
149+
<depth>nan</depth>
150+
<energy unit="keV">20.0</energy>
151+
<scanNum>1004</scanNum>
152+
<detector>
153+
<inputImage>test/image_004.h5</inputImage>
154+
<detectorID>TEST-DET</detectorID>
155+
<Nx>2048</Nx>
156+
<Ny>2048</Ny>
157+
<peaksXY Npeaks="6">
158+
<Xpixel>130.0 240.0 350.0 460.0 570.0 680.0</Xpixel>
159+
<Ypixel>180.0 280.0 380.0 480.0 580.0 680.0</Ypixel>
160+
<Intens>910 810 710 610 510 410</Intens>
161+
<Integral>28.0 26.0 24.0 22.0 20.0 18.0</Integral>
162+
<Qx>0.13 -0.14 0.22 -0.27 0.15 -0.20</Qx>
163+
<Qy>0.64 0.61 0.52 0.67 0.63 0.56</Qy>
164+
<Qz>-0.71 -0.78 -0.83 -0.68 -0.76 -0.80</Qz>
165+
</peaksXY>
166+
</detector>
167+
<indexing Nindexed="5" Npeaks="6" Npatterns="1">
168+
<pattern num="0" rms_error="0.004" goodness="160.0" Nindexed="5">
169+
<recip_lattice unit="1/nm">
170+
<astar>-10.3 5.3 -6.3</astar>
171+
<bstar>-15.3 -2.3 -1.3</bstar>
172+
<cstar>-2.3 13.3 8.3</cstar>
173+
</recip_lattice>
174+
<hkl_s>
175+
<h>3 5 7 5 7</h>
176+
<k>-1 -1 -1 1 1</k>
177+
<l>1 1 1 1 1</l>
178+
<PkIndex>0 1 2 3 4</PkIndex>
179+
</hkl_s>
180+
</pattern>
181+
<xtl>
182+
<structureDesc>TestMaterial</structureDesc>
183+
<SpaceGroup>225</SpaceGroup>
184+
<latticeParameters unit="nm">0.40000 0.40000 0.40000 90 90 90</latticeParameters>
185+
</xtl>
186+
</indexing>
187+
</step>
188+
</AllSteps>

tests/test_viz_integration.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Quick integration test: verify all viz components import and execute."""
1+
"""Integration tests for visualization components using synthetic fixture."""
22

33
import os
44
import sys
@@ -19,66 +19,64 @@
1919
)
2020
from laue_portal.components.visualization.peak_table import make_peak_table
2121

22-
SAMPLE_XML = os.path.join(project_root, "output.xml")
22+
FIXTURE_XML = os.path.join(os.path.dirname(__file__), "fixtures", "test_indexing.xml")
23+
24+
25+
def _parsed():
26+
return parse_indexing_xml(FIXTURE_XML)
2327

2428

2529
def test_orientation_map_creates_figure():
26-
parsed = parse_indexing_xml(SAMPLE_XML)
27-
fig = make_orientation_map(parsed, color_by="n_indexed")
30+
fig = make_orientation_map(_parsed(), color_by="n_indexed")
2831
assert len(fig.data) == 1
2932
assert fig.data[0].type == "scattergl"
3033

3134

3235
def test_orientation_map_all_color_modes():
33-
parsed = parse_indexing_xml(SAMPLE_XML)
36+
parsed = _parsed()
3437
for mode in ("n_indexed", "goodness", "rms_error", "n_patterns"):
3538
fig = make_orientation_map(parsed, color_by=mode)
3639
assert len(fig.data) >= 1
3740

3841

3942
def test_quality_map_creates_figure():
40-
parsed = parse_indexing_xml(SAMPLE_XML)
41-
fig = make_quality_map(parsed, metric="goodness")
43+
fig = make_quality_map(_parsed(), metric="goodness")
4244
assert len(fig.data) == 1
4345
assert fig.data[0].type == "scattergl"
4446

4547

4648
def test_quality_map_all_metrics():
47-
parsed = parse_indexing_xml(SAMPLE_XML)
49+
parsed = _parsed()
4850
for metric in ("goodness", "rms_error", "n_indexed", "n_patterns"):
4951
fig = make_quality_map(parsed, metric=metric)
5052
assert len(fig.data) >= 1
5153

5254

5355
def test_orientation_map_marker_size():
54-
parsed = parse_indexing_xml(SAMPLE_XML)
55-
fig = make_orientation_map(parsed, marker_size=25)
56+
fig = make_orientation_map(_parsed(), marker_size=25)
5657
assert fig.data[0].marker.size == 25
5758

5859

5960
def test_orientation_map_aspect_ratio():
60-
parsed = parse_indexing_xml(SAMPLE_XML)
61-
fig = make_orientation_map(parsed)
61+
fig = make_orientation_map(_parsed())
6262
assert fig.layout.yaxis.scaleanchor == "x"
6363
assert fig.layout.yaxis.scaleratio == 1
6464

6565

6666
def test_quality_map_marker_size():
67-
parsed = parse_indexing_xml(SAMPLE_XML)
68-
fig = make_quality_map(parsed, marker_size=30)
67+
fig = make_quality_map(_parsed(), marker_size=30)
6968
assert fig.data[0].marker.size == 30
7069

7170

7271
def test_orientation_map_3d_creates_figure():
73-
parsed = parse_indexing_xml(SAMPLE_XML)
74-
fig = make_orientation_map_3d(parsed, color_by="n_indexed")
72+
fig = make_orientation_map_3d(_parsed(), color_by="n_indexed")
7573
assert len(fig.data) == 1
7674
assert fig.data[0].type == "scatter3d"
7775
assert fig.layout.scene.aspectmode == "data"
7876

7977

8078
def test_orientation_map_3d_uses_all_coordinates():
81-
parsed = parse_indexing_xml(SAMPLE_XML)
79+
parsed = _parsed()
8280
fig = make_orientation_map_3d(parsed)
8381
trace = fig.data[0]
8482
n = len(parsed["positions"])
@@ -88,23 +86,20 @@ def test_orientation_map_3d_uses_all_coordinates():
8886

8987

9088
def test_quality_map_3d_creates_figure():
91-
parsed = parse_indexing_xml(SAMPLE_XML)
92-
fig = make_quality_map_3d(parsed, metric="goodness")
89+
fig = make_quality_map_3d(_parsed(), metric="goodness")
9390
assert len(fig.data) == 1
9491
assert fig.data[0].type == "scatter3d"
9592

9693

9794
def test_quality_map_3d_all_metrics():
98-
parsed = parse_indexing_xml(SAMPLE_XML)
95+
parsed = _parsed()
9996
for metric in ("goodness", "rms_error", "n_indexed", "n_patterns"):
10097
fig = make_quality_map_3d(parsed, metric=metric)
10198
assert len(fig.data) >= 1
10299

103100

104101
def test_peak_table_creates_div():
105-
parsed = parse_indexing_xml(SAMPLE_XML)
106-
peaks = get_all_indexed_peaks(parsed)
102+
peaks = get_all_indexed_peaks(_parsed())
107103
table = make_peak_table(peaks)
108104
assert table is not None
109-
# Should be an html.Div with children
110105
assert hasattr(table, "children")

0 commit comments

Comments
 (0)