Skip to content

Commit dee358c

Browse files
committed
test symmetry handling log messages
1 parent 0524dc9 commit dee358c

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/test_nug.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,28 @@ def test_unspupported_symmetry_raises(dtype):
185185

186186
with pytest.raises(ValueError, match="supports cyclic or dihedral symmetry"):
187187
_ = CommonlineNUG(src)
188+
189+
190+
def test_symmetry_logging(caplog):
191+
"""
192+
Check expected log messages for mismatch or unprovided symmetry.
193+
"""
194+
vol = CnSymmetricVolume(L=16, order=3, C=1, dtype=np.float64, seed=SEED).generate()
195+
src = Simulation(n=3, vols=vol).cache()
196+
197+
# Check unprovided symmetry populates with source symmetry and logs messsage
198+
caplog.clear()
199+
with caplog.at_level("INFO"):
200+
orient_est = CommonlineNUG(src)
201+
202+
assert str(orient_est.sym_grp) == "C3"
203+
assert "Symmetry not provided. Using Source symmetry: C3" in caplog.text
204+
205+
# Check we use provided symmetry on mismatch, with log
206+
caplog.clear()
207+
with caplog.at_level("INFO"):
208+
orient_est = CommonlineNUG(src, symmetry="D3")
209+
210+
assert str(orient_est.sym_grp) == "D3"
211+
assert "Provided symmetry, D3, does not match source, C3" in caplog.text
212+
assert "Using provided symmetry: D3" in caplog.text

0 commit comments

Comments
 (0)