def test_rename(): """ test vmat.rename """ ref_renamed_zma = (('C', (None, None, None), (None, None, None), (None, None, None)), ('C', (0, None, None), ('R1', None, None), (2.894126135733367, None, None)), ('H', (0, 1, None), ('R2', 'A2', None), (2.1002551784038714, 1.9218361502726833, None)), ('H', (0, 1, 2), ('R3', 'A3', 'D3'), (2.1008326855365818, 1.932519243247544, 4.182194537966691)), ('H', (0, 1, 2), ('R4NEW', 'A4', 'D4'), (2.0985632786105715, 1.9267905467443245, 2.078543469899091)), ('C', (1, 0, 2), ('R5', 'A5', 'D5'), (2.7809944542976193, 1.9090367411091194, 1.0264175778482927)), ('C', (1, 0, 5), ('R6', 'A6', 'D6'), (2.905905476629344, 1.9462477957117656, 2.1246205025559037)), ('H', (1, 0, 5), ('R7', 'A7', 'D7'), (2.1005624282579265, 1.8988979609840009, 4.223022677525844)), ('X', (5, 1, 0), ('R8', 'A8', 'D8'), (1.8897261254578288, 1.5707963267948968, 4.216836292856281)), ('C', (5, 8, 1), ('R9', 'A9NEW', 'D9'), (2.2778505841014964, 1.5732722619955628, 3.1519457859137696)), ('X', (9, 5, 8), ('R10', 'A10', 'D10'), (1.8897261254578286, 1.56832039159423, 0.0)), ('H', (9, 10, 5), ('R11', 'A11', 'D11'), (2.0003442808863467, 1.57550991099349, 3.14859478950736)), ('O', (6, 1, 0), ('R12', 'A12', 'D12'), (2.65076899334649, 1.9387190313618887, 1.0262708014428483)), ('H', (6, 1, 12), ('R13', 'A13', 'D13NEW'), (2.1058345184525726, 1.9323237957467607, 2.129177885999989)), ('H', (6, 1, 12), ('R14', 'A14', 'D14'), (2.1010240316411886, 1.9207088798352128, 4.1894956154070275)), ('H', (12, 6, 1), ('R15', 'A15', 'D15'), (1.8758293656194, 1.8624105681328567, 1.2477273554765336))) renamed_zma = zmat.rename(C5H8O_ZMA, { 'R4': 'R4NEW', 'A9': 'A9NEW', 'D13': 'D13NEW' }) assert zmat.almost_equal(ref_renamed_zma, renamed_zma)
def test__standardize(): """ test zmat.standard_form test zmat.standard_name_matrix """ nonstandard_zma = ( ('C', (None, None, None), (None, None, None), (None, None, None)), ('C', (0, None, None), ('R210', None, None), (2.894126135733367, None, None)), ('H', (0, 1, None), ('R220', 'A220', None), (2.1002551784038714, 1.9218361502726833, None)), ('H', (0, 1, 2), ('R230', 'A230', 'D230'), (2.1008326855365818, 1.932519243247544, 4.182194537966691)), ('H', (0, 1, 2), ('R240', 'A240', 'D240'), (2.0985632786105715, 1.9267905467443245, 2.078543469899091)), ('C', (1, 0, 2), ('R250', 'A250', 'D250'), (2.7809944542976193, 1.9090367411091194, 1.0264175778482927)), ('C', (1, 0, 5), ('R260', 'A260', 'D260'), (2.905905476629344, 1.9462477957117656, 2.1246205025559037)), ('H', (1, 0, 5), ('R270', 'A270', 'D270'), (2.1005624282579265, 1.8988979609840009, 4.223022677525844)), ('X', (5, 1, 0), ('R280', 'A280', 'D280'), (1.8897261254578288, 1.5707963267948968, 4.216836292856281)), ('C', (5, 8, 1), ('R290', 'A290', 'D290'), (2.2778505841014964, 1.5732722619955628, 3.1519457859137696)), ('X', (9, 5, 8), ('R2100', 'A2100', 'D2100'), (1.8897261254578286, 1.56832039159423, 0.0)), ('H', (9, 10, 5), ('R2110', 'A2110', 'D2110'), (2.0003442808863467, 1.57550991099349, 3.14859478950736)), ('O', (6, 1, 0), ('R2120', 'A2120', 'D2120'), (2.65076899334649, 1.9387190313618887, 1.0262708014428483)), ('H', (6, 1, 12), ('R2130', 'A2130', 'D2130'), (2.1058345184525726, 1.9323237957467607, 2.129177885999989)), ('H', (6, 1, 12), ('R2140', 'A2140', 'D2140'), (2.1010240316411886, 1.9207088798352128, 4.1894956154070275)), ('H', (12, 6, 1), ('R2150', 'A2150', 'D2150'), (1.8758293656194, 1.8624105681328567, 1.2477273554765336))) assert zmat.almost_equal(C5H8O_ZMA, zmat.standard_form(nonstandard_zma))
def test__string(): """ test zmat.string """ zma = zmat.from_string(zmat.string(CH4O2_ZMA)) assert zmat.almost_equal(zma, CH4O2_ZMA)
def test__equality(): """ test zmat.almost_equal """ assert not zmat.almost_equal(HOOH_ZMA_C2, HOOH_ZMA_CS) assert zmat.almost_equal(HOOH_ZMA_C2, HOOH_ZMA_CS, just_dist=True)
def test__set(): """ test zmat.set_key_matrix test zmat.set_name_matrix """ # Increment keys by 1 (not physical, but just for testing) ref_reset_zma1 = ( ('C', (None, None, None), (None, None, None), (None, None, None)), ('C', (1, None, None), ('R1', None, None), (2.894126135733367, None, None)), ('H', (1, 2, None), ('R2', 'A2', None), (2.1002551784038714, 1.9218361502726833, None)), ('H', (1, 2, 3), ('R3', 'A3', 'D3'), (2.1008326855365818, 1.932519243247544, 4.182194537966691)), ('H', (1, 2, 3), ('R4', 'A4', 'D4'), (2.0985632786105715, 1.9267905467443245, 2.078543469899091)), ('C', (2, 1, 3), ('R5', 'A5', 'D5'), (2.7809944542976193, 1.9090367411091194, 1.0264175778482927)), ('C', (2, 1, 6), ('R6', 'A6', 'D6'), (2.905905476629344, 1.9462477957117656, 2.1246205025559037)), ('H', (2, 1, 6), ('R7', 'A7', 'D7'), (2.1005624282579265, 1.8988979609840009, 4.223022677525844)), ('X', (6, 2, 1), ('R8', 'A8', 'D8'), (1.8897261254578288, 1.5707963267948968, 4.216836292856281)), ('C', (6, 9, 2), ('R9', 'A9', 'D9'), (2.2778505841014964, 1.5732722619955628, 3.1519457859137696)), ('X', (10, 6, 9), ('R10', 'A10', 'D10'), (1.8897261254578286, 1.56832039159423, 0.0)), ('H', (10, 11, 6), ('R11', 'A11', 'D11'), (2.0003442808863467, 1.57550991099349, 3.14859478950736)), ('O', (7, 2, 1), ('R12', 'A12', 'D12'), (2.65076899334649, 1.9387190313618887, 1.0262708014428483)), ('H', (7, 2, 13), ('R13', 'A13', 'D13'), (2.1058345184525726, 1.9323237957467607, 2.129177885999989)), ('H', (7, 2, 13), ('R14', 'A14', 'D14'), (2.1010240316411886, 1.9207088798352128, 4.1894956154070275)), ('H', (13, 7, 2), ('R15', 'A15', 'D15'), (1.8758293656194, 1.8624105681328567, 1.2477273554765336))) new_key_mat = ((None, None, None), (1, None, None), (1, 2, None), (1, 2, 3), (1, 2, 3), (2, 1, 3), (2, 1, 6), (2, 1, 6), (6, 2, 1), (6, 9, 2), (10, 6, 9), (10, 11, 6), (7, 2, 1), (7, 2, 13), (7, 2, 13), (13, 7, 2)) reset_zma1 = zmat.set_key_matrix(C5H8O_ZMA, new_key_mat) assert zmat.almost_equal(ref_reset_zma1, reset_zma1) # Increment all the numbers on the name by 1 ref_reset_zma2 = ( ('C', (None, None, None), (None, None, None), (None, None, None)), ('C', (0, None, None), ('R2', None, None), (2.894126135733367, None, None)), ('H', (0, 1, None), ('R3', 'A3', None), (2.1002551784038714, 1.9218361502726833, None)), ('H', (0, 1, 2), ('R4', 'A4', 'D4'), (2.1008326855365818, 1.932519243247544, 4.182194537966691)), ('H', (0, 1, 2), ('R5', 'A5', 'D5'), (2.0985632786105715, 1.9267905467443245, 2.078543469899091)), ('C', (1, 0, 2), ('R6', 'A6', 'D6'), (2.7809944542976193, 1.9090367411091194, 1.0264175778482927)), ('C', (1, 0, 5), ('R7', 'A7', 'D7'), (2.905905476629344, 1.9462477957117656, 2.1246205025559037)), ('H', (1, 0, 5), ('R8', 'A8', 'D8'), (2.1005624282579265, 1.8988979609840009, 4.223022677525844)), ('X', (5, 1, 0), ('R9', 'A9', 'D9'), (1.8897261254578288, 1.5707963267948968, 4.216836292856281)), ('C', (5, 8, 1), ('R10', 'A10', 'D10'), (2.2778505841014964, 1.5732722619955628, 3.1519457859137696)), ('X', (9, 5, 8), ('R11', 'A11', 'D11'), (1.8897261254578286, 1.56832039159423, 0.0)), ('H', (9, 10, 5), ('R12', 'A12', 'D12'), (2.0003442808863467, 1.57550991099349, 3.14859478950736)), ('O', (6, 1, 0), ('R13', 'A13', 'D13'), (2.65076899334649, 1.9387190313618887, 1.0262708014428483)), ('H', (6, 1, 12), ('R14', 'A14', 'D14'), (2.1058345184525726, 1.9323237957467607, 2.129177885999989)), ('H', (6, 1, 12), ('R15', 'A15', 'D15'), (2.1010240316411886, 1.9207088798352128, 4.1894956154070275)), ('H', (12, 6, 1), ('R16', 'A16', 'D16'), (1.8758293656194, 1.8624105681328567, 1.2477273554765336))) new_name_mat = ((None, None, None), ('R2', None, None), ('R3', 'A3', None), ('R4', 'A4', 'D4'), ('R5', 'A5', 'D5'), ('R6', 'A6', 'D6'), ('R7', 'A7', 'D7'), ('R8', 'A8', 'D8'), ('R9', 'A9', 'D9'), ('R10', 'A10', 'D10'), ('R11', 'A11', 'D11'), ('R12', 'A12', 'D12'), ('R13', 'A13', 'D13'), ('R14', 'A14', 'D14'), ('R15', 'A15', 'D15'), ('R16', 'A16', 'D16')) reset_zma2 = zmat.set_name_matrix(C5H8O_ZMA, new_name_mat) assert zmat.almost_equal(ref_reset_zma2, reset_zma2)