def test_symmrmsd_rotated_benzene_stripped(angle: float) -> None: mol1 = copy.deepcopy(molecules.benzene) mol2 = copy.deepcopy(molecules.benzene) mol2.rotate(angle, np.array([0, 0, 1]), units="deg") mol1.strip() mol2.strip() assert (rmsd.rmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) > 0) assert rmsd.rmsd( mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums, minimize=True, ) == pytest.approx(0) assert rmsd.hrmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) == pytest.approx(0, abs=1e-4) assert rmsd.symmrmsd( mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums, mol1.adjacency_matrix, mol2.adjacency_matrix, ) == pytest.approx(0, abs=1e-4)
def test_rmsd_hungarian_centred(mol: molecule.Molecule) -> None: mol1 = copy.deepcopy(mol) mol2 = copy.deepcopy(mol) mol2.translate(np.random.rand(3)) assert (rmsd.hrmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) > 0) assert rmsd.hrmsd( mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums, center=True, ) == pytest.approx(0)
def test_rmsd_hungarian_benzene_rotated(angle: float, tol: float) -> None: mol1 = copy.deepcopy(molecules.benzene) mol2 = copy.deepcopy(molecules.benzene) assert rmsd.rmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) == pytest.approx(0) assert rmsd.hrmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) == pytest.approx(0) # Rotations different than 180 degrees introduce numerical errors (~1e-6) mol2.rotate(angle, [0, 0, 1], units="deg") assert (rmsd.rmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) > 0) assert rmsd.hrmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums) == pytest.approx(0, abs=tol)