def test_calculateProjections(): # TODO: Update test s1 = Sample(np.pi * 2, np.pi * 2, np.pi * 2, 90, 90, 60) s1.calculateProjections() theta = 2 * np.pi / 3 # 120 degrees between projection vectors AStar = np.linalg.norm(s1.reciprocalVectorA) BStar = np.linalg.norm(s1.reciprocalVectorB) CStar = np.linalg.norm(s1.reciprocalVectorC)
def test_sample_exceptions(): try: # No parameters given s1 = Sample(a=None) assert False except: assert True try: # negative parameters given s1 = Sample(a=-1, b=1, c=1) assert False except: assert True try: # negative parameters given s1 = Sample(a=1, b=-1, c=1) assert False except: assert True try: # negative parameters given s1 = Sample(a=1, b=1, c=-1) assert False except: assert True try: # negative parameters given s1 = Sample(a=1, b=1, c=1, alpha=200) assert False except: assert True try: # negative parameters given s1 = Sample(a=1, b=1, c=1, beta=-10) assert False except: assert True try: # negative parameters given s1 = Sample(a=1, b=1, c=1, gamma=-10) assert False except: assert True
def test_equality(): s1 = Sample(1, 2, 3, 90, 90, 120) s2 = Sample(1, 2, 3, 90, 90, 120) assert (s1 == s2)
def test_parameters(): s1 = Sample(1,2,3,90,90,120) pars = np.array([getattr(s1,x) for x in ['a','b','c','alpha','beta','gamma']]) assert(np.all(np.isclose(pars,np.array([1,2,3,90,90,120]))))