def test__from_data(): """ test getters """ cgr = automol.graph.from_data( atm_symb_dct=graph.atom_symbols(C8H13O_CGR), bnd_keys=graph.bond_keys(C8H13O_CGR), atm_imp_hyd_vlc_dct=( graph.atom_implicit_hydrogen_valences(C8H13O_CGR)), ) assert cgr == C8H13O_CGR rgr = automol.graph.from_data( atm_symb_dct=graph.atom_symbols(C8H13O_RGR), bnd_keys=graph.bond_keys(C8H13O_RGR), atm_imp_hyd_vlc_dct=( graph.atom_implicit_hydrogen_valences(C8H13O_RGR)), bnd_ord_dct=graph.bond_orders(C8H13O_RGR), ) assert rgr == C8H13O_RGR sgr = automol.graph.from_data( atm_symb_dct=graph.atom_symbols(C8H13O_SGR), bnd_keys=graph.bond_keys(C8H13O_SGR), atm_imp_hyd_vlc_dct=( graph.atom_implicit_hydrogen_valences(C8H13O_SGR)), atm_ste_par_dct=graph.atom_stereo_parities(C8H13O_SGR), bnd_ste_par_dct=graph.bond_stereo_parities(C8H13O_SGR)) assert sgr == C8H13O_SGR
def test__from_dictionaries(): """ test graph.from_dictionaries """ assert graph.from_dictionaries( graph.atom_symbols(CH2FH2H_CGR_EXP), graph.bond_keys(CH2FH2H_CGR_EXP) ) == CH2FH2H_CGR_EXP assert graph.from_dictionaries( graph.atom_symbols(C8H13O_RGRS[0]), graph.bond_keys(C8H13O_RGRS[0]), atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences( C8H13O_RGRS[0]), bnd_ord_dct=graph.bond_orders(C8H13O_RGRS[0]) ) == C8H13O_RGRS[0] assert graph.from_dictionaries( graph.atom_symbols(C8H13O_SGRS[0]), graph.bond_keys(C8H13O_SGRS[0]), atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences( C8H13O_SGRS[0]), atm_ste_par_dct=graph.atom_stereo_parities(C8H13O_SGRS[0]), bnd_ste_par_dct=graph.bond_stereo_parities(C8H13O_SGRS[0]) ) == C8H13O_SGRS[0] # a litte ridiculous, but make sure we get the keys right sgr_ref = C8H13O_SGRS[0] natms = len(graph.atoms(sgr_ref)) for _ in range(10): pmt_dct = dict(enumerate(numpy.random.permutation(natms))) sgr = graph.relabel(sgr_ref, pmt_dct) assert graph.from_dictionaries( graph.atom_symbols(sgr), graph.bond_keys(sgr), atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences(sgr), atm_ste_par_dct=graph.atom_stereo_parities(sgr), bnd_ste_par_dct=graph.bond_stereo_parities(sgr) ) == sgr