def test_SMat33_transformed_by(self): tensor = gemmi.SMat33f(random(), random(), random(), random(), random(), random()) mat = gemmi.Mat33() mat.fromlist([[random() for _ in range(3)] for _ in range(3)]) t1 = tensor.transformed_by(mat).as_mat33().tolist() t2 = mat.multiply(tensor.as_mat33()).multiply(mat.transpose()).tolist() for i in range(3): for j in range(3): self.assertAlmostEqual(t1[i][j], t2[i][j])
def test_atom_to_site(self): cell = UnitCell(35.996, 41.601, 45.756, 67.40, 66.90, 74.85) atom = gemmi.Atom() atom.aniso = gemmi.SMat33f(13.1, 20.1, 11.1, -3.5, 5.5, -0.4) site = gemmi.SmallStructure.Site(atom, cell) # tested against values from cctbx: # from cctbx import uctbx, adptbx # uc = uctbx.unit_cell((35.996, 41.601, 45.756, 67.40, 66.90, 74.85)) # aniso = (13.1, 20.1, 11.1, -3.5, 5.5, -0.4) # ucif = adptbx.u_cart_as_u_cif(uc, aniso) ucif = [11.537759976524049, 19.43436271641311, 11.1, -8.078683096677723, 1.4787260755519491, -3.9018967241279157] for a, b in zip(site.aniso.elements(), ucif): self.assertAlmostEqual(a, b, delta=1e-6)