Skip to content

Commit 6d3fa41

Browse files
authored
Merge pull request #65 from prjemian/52-initial-UB-should-be-2-pi-a-I
set initial UB matrix
2 parents 22184cc + 2d1befe commit 6d3fa41

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

hklpy2/blocks/sample.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"""
99

1010
import logging
11+
import math
12+
13+
import numpy as np
1114

1215
from ..misc import SampleError
1316
from ..misc import unique_name
@@ -60,7 +63,7 @@ def __init__(
6063
self.core = core
6164
self.lattice = lattice
6265
self.U = IDENTITY_MATRIX_3X3
63-
self.UB = IDENTITY_MATRIX_3X3 # TODO: * 2 * math.pi
66+
self.UB = (2 * math.pi * self.lattice.a * np.array(self.U)).tolist()
6467
# TODO: reciprocal_lattice
6568
self.reflections = ReflectionsDict()
6669

hklpy2/blocks/tests/test_configure.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
import pathlib
23
from contextlib import nullcontext as does_not_raise
34

@@ -18,6 +19,7 @@
1819
add_oriented_vibranium_to_e4cv(e4cv)
1920

2021
sim2c = creator(name="sim2c", solver="th_tth", geometry="TH TTH Q")
22+
twopi = 2 * math.pi
2123

2224

2325
@pytest.mark.parametrize(
@@ -46,7 +48,7 @@
4648
["samples.sample.reflections_order", []],
4749
["samples.sample.reflections", {}],
4850
["samples.sample.U", [[1, 0, 0], [0, 1, 0], [0, 0, 1]]],
49-
["samples.sample.UB", [[1, 0, 0], [0, 1, 0], [0, 0, 1]]],
51+
["samples.sample.UB", [[twopi, 0, 0], [0, twopi, 0], [0, 0, twopi]]],
5052
["samples.vibranium.name", "vibranium"],
5153
["samples.vibranium.reflections_order", "r040 r004".split()],
5254
["samples.vibranium.reflections_order", "r040 r004".split()],

hklpy2/tests/test_user.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import math
23
from collections import namedtuple
34
from contextlib import nullcontext as does_not_raise
45

@@ -30,6 +31,8 @@
3031
from .common import TESTS_DIR
3132
from .common import assert_context_result
3233

34+
twopi = 2 * math.pi
35+
3336

3437
@pytest.fixture(scope="function")
3538
def fourc():
@@ -222,7 +225,7 @@ def test_pa(fourc, capsys):
222225
"Sample(name='sample', lattice=Lattice(a=1, system='cubic'))",
223226
"Orienting reflections: []",
224227
"U=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]",
225-
"UB=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]",
228+
f"UB=[[{twopi}, 0.0, 0.0], [0.0, {twopi}, 0.0], [0.0, 0.0, {twopi}]]",
226229
"constraint: -180.0 <= omega <= 180.0",
227230
"constraint: -180.0 <= chi <= 180.0",
228231
"constraint: -180.0 <= phi <= 180.0",

0 commit comments

Comments
 (0)