def test_UnitCell_cell_setter(): unitcell = UnitCell() unitcell.cell = 7 assert unitcell.cell == (7, 7, 7, 90, 90, 90) assert_almost_equal(unitcell.volume, 343) assert_array_almost_equal(unitcell.G, [[49, 0, 0], [0, 49, 0], [0, 0, 49]]) unitcell.cell = 4, 5, 6 assert unitcell.cell == (4, 5, 6, 90, 90, 90) unitcell.cell = [6, 5, 4] assert unitcell.cell == (6, 5, 4, 90, 90, 90) unitcell.cell = (6, 4, 5) assert unitcell.cell == (6, 4, 5, 90, 90, 90) unitcell.cell = 7, 6, 5, 120, 90, 45 assert_array_almost_equal(unitcell.cell, (7, 6, 5, 120, 90, 45))
def test_UnitCell_exceptions(): unitcell = UnitCell() with pytest.raises(ValueError): unitcell.cell = (1, 2) with pytest.raises(ValueError): unitcell.cell = (1, 2, 3, 4, 5) with pytest.raises(TypeError): unitcell.cell = "foobor" with pytest.raises(ValueError): UnitCell(1, 1, 1, 90, 90, 200) with pytest.raises(ValueError): UnitCell(1, 1, 1, 360, 90, 90)