def test_volume(base_box): assert isclose(base_box.volume, np.product(base_box.L)) for L in np.linspace(1, 10, 10): box = Box.cube(L) assert isclose(box.volume, L**3) box = Box(L, L + 1, L + 2) assert isclose(box.volume, L * (L + 1) * (L + 2))
def test_neq(base_box, box_dict): box2 = Box(**box_dict) assert not base_box != box2 box2.Lx = 2 assert base_box != box2
def base_box(box_dict): return Box(**box_dict)
def test_base_constructor(box_dict): box = Box(**box_dict) for key in box_dict: assert getattr(box, key) == box_dict[key]