Skip to content

Commit

Permalink
Add tests. Fixes #142
Browse files Browse the repository at this point in the history
  • Loading branch information
dagewa committed Mar 24, 2020
1 parent 85ed11f commit 4b4ea7b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/model/test_crystal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,26 @@ def test_set_scan_varying_B_covariance(crystal_class):
assert cov_B_at_scan_point == cov_B_2d
cell_sd_at_scan_point = xl.get_cell_parameter_sd_at_scan_point(i)
assert cell_sd_at_scan_point == pytest.approx(cell_sd)


def test_recalculated_cell():
xl = Crystal(
real_space_a=(10, 0, 0),
real_space_b=(0, 11, 0),
real_space_c=(0, 0, 12),
space_group_symbol="P 1",
)

assert not xl.has_recalc_unit_cell()

uc1 = xl.get_unit_cell()
xl.set_recalc_unit_cell(uc1)
assert xl.has_recalc_unit_cell()

uc2 = xl.get_recalc_unit_cell()
assert uc1.is_similar_to(uc2)

xl.set_recalc_cell_parameter_sd((0.1,) * 6)

for val in xl.get_recalc_cell_parameter_sd():
assert val == 0.1
12 changes: 12 additions & 0 deletions tests/serialize/test_crystal_model_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ def test_crystal_with_scan_points(example_crystal):
assert abs(e1 - e2) <= eps

assert c1 == c2


def test_crystal_with_recalculated_cell(example_crystal):
c1 = Crystal(**example_crystal)
uc = c1.get_unit_cell()
c1.set_recalc_unit_cell(uc)

d = c1.to_dict()
c2 = CrystalFactory.from_dict(d)

assert c1.get_recalc_unit_cell().is_similar_to(c2.get_recalc_unit_cell())
assert c1 == c2

0 comments on commit 4b4ea7b

Please sign in to comment.