How to use the thermo.identifiers.CAS_from_any function in thermo

To help you get started, we’ve selected a few thermo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_CRC_ion_conductivities():
    # Check CASs match up
    assert all([CAS_from_any(i) == i for i in CRC_ion_conductivities.index])
    
    # Check search by formula matches up
    for formula, CAS in zip(CRC_ion_conductivities['Formula'], CRC_ion_conductivities.index):
        assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS
    # Charges weren't stored
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_Marcus_ion_conductivities():
    # Check the CAS numbers are the "canonical" ones
    assert all([CAS_from_any(i) == i for i in Marcus_ion_conductivities.index])

    # Check the charges match up
    for v, CAS in zip(Marcus_ion_conductivities['Charge'], Marcus_ion_conductivities.index):
        assert v == charge_from_formula(pubchem_db.search_CAS(CAS).formula)

    # Even check the formulas work!
    for formula, CAS in zip(Marcus_ion_conductivities['Formula'], Marcus_ion_conductivities.index):
        assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_Marcus_ion_conductivities():
    # Check the CAS numbers are the "canonical" ones
    assert all([CAS_from_any(i) == i for i in Marcus_ion_conductivities.index])

    # Check the charges match up
    for v, CAS in zip(Marcus_ion_conductivities['Charge'], Marcus_ion_conductivities.index):
        assert v == charge_from_formula(pubchem_db.search_CAS(CAS).formula)

    # Even check the formulas work!
    for formula, CAS in zip(Marcus_ion_conductivities['Formula'], Marcus_ion_conductivities.index):
        assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_McCleskey_data():   
    # Check the CAS lookups
    for CAS, d in McCleskey_conductivities.items():
        assert pubchem_db.search_CAS(CAS).CASs == CAS

    # Check the formula lookups
    for CAS, d in McCleskey_conductivities.items():
        assert CAS_from_any(d.Formula) == CAS
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_dissociation_reactions():
    from thermo.electrochem import electrolyte_dissociation_reactions as df
    from collections import Counter
    
    # Check there's only one dissociation reaction for each product 
    assert len(df['Electrolyte Formula'].values) == len(set(df['Electrolyte Formula'].values))

    # Check the chemicals match up with the database
    for name, CAS, formula in zip(df['Electrolyte name'], df['Electrolyte CAS'], df['Electrolyte Formula']):
        assert CAS_from_any(CAS) == CAS
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)

    # Check the anions match up with the database
    for formula, CAS, charge in zip(df['Anion formula'], df['Anion CAS'], df['Anion charge']):
        assert CAS_from_any(CAS) == CAS
        assert CAS_from_any(formula) == CAS
        assert pubchem_db.search_CAS(CAS).charge == charge
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)
        
    # Check the cations match up with the database
    for formula, CAS, charge in zip(df['Cation formula'], df['Cation CAS'], df['Cation charge']):
        assert CAS_from_any(CAS) == CAS
        assert CAS_from_any(formula) == CAS
        assert pubchem_db.search_CAS(CAS).charge == charge    
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_Laliberte_metadata():
    from thermo.electrochem import _Laliberte_Density_ParametersDict, _Laliberte_Viscosity_ParametersDict, _Laliberte_Heat_Capacity_ParametersDict
    lalib = _Laliberte_Density_ParametersDict.copy()
    lalib.update(_Laliberte_Viscosity_ParametersDict)
    lalib.update(_Laliberte_Heat_Capacity_ParametersDict)
    
    for CAS, d in lalib.items():
        c = None
        formula = d['Formula']
        name = d['Name']
        if formula not in set(['HCHO2', 'CH3CH2OH', 'HCH3CO2']):
            assert CAS_from_any(formula) == CAS
#        try:
github CalebBell / thermo / tests / test_critical.py View on Github external
assert_allclose(Tc_sum, 65343.210900000005)

    Pc_sum = _crit_Matthews['Pc'].sum()
    assert_allclose(Pc_sum, 579365204.25)

    Vc_sum = _crit_Matthews['Vc'].sum()
    assert_allclose(Vc_sum, 0.014921000000000002)

    Zc_sum = _crit_Matthews['Zc'].sum()
    assert_allclose(Zc_sum, 12.141000000000002)

    assert _crit_Matthews.shape == (120, 6)
    assert _crit_Matthews.index.is_unique
    
    for CAS, name in zip(_crit_Matthews.index, _crit_Matthews['Chemical']):
        assert CAS_from_any(CAS) == CAS
#        try:
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_CRC_ion_conductivities():
    # Check CASs match up
    assert all([CAS_from_any(i) == i for i in CRC_ion_conductivities.index])
    
    # Check search by formula matches up
    for formula, CAS in zip(CRC_ion_conductivities['Formula'], CRC_ion_conductivities.index):
        assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS
    # Charges weren't stored
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_dissociation_reactions():
    from thermo.electrochem import electrolyte_dissociation_reactions as df
    from collections import Counter
    
    # Check there's only one dissociation reaction for each product 
    assert len(df['Electrolyte Formula'].values) == len(set(df['Electrolyte Formula'].values))

    # Check the chemicals match up with the database
    for name, CAS, formula in zip(df['Electrolyte name'], df['Electrolyte CAS'], df['Electrolyte Formula']):
        assert CAS_from_any(CAS) == CAS
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)

    # Check the anions match up with the database
    for formula, CAS, charge in zip(df['Anion formula'], df['Anion CAS'], df['Anion charge']):
        assert CAS_from_any(CAS) == CAS
        assert CAS_from_any(formula) == CAS
        assert pubchem_db.search_CAS(CAS).charge == charge
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)
        
    # Check the cations match up with the database
    for formula, CAS, charge in zip(df['Cation formula'], df['Cation CAS'], df['Cation charge']):
        assert CAS_from_any(CAS) == CAS
        assert CAS_from_any(formula) == CAS
        assert pubchem_db.search_CAS(CAS).charge == charge    
        assert pubchem_db.search_CAS(CAS).formula == serialize_formula(formula)

    # Check the charges and counts of ions sums to zero
    for index, row in df.iterrows():
        an_charge = row['Anion charge']
        an_count = row['Anion count']
        cat_charge = row['Cation charge']
        cat_count = row['Cation count']
github CalebBell / thermo / tests / test_electrochem.py View on Github external
def test_CRC_aqueous_thermodynamics():
    assert all([checkCAS(i) for i in CRC_aqueous_thermodynamics.index])
    
    # Check CASs match up
    assert all([CAS_from_any(i) == i for i in CRC_aqueous_thermodynamics.index])
    
    # Check search by formula matches up
    for formula, CAS in zip(CRC_aqueous_thermodynamics['Formula'], CRC_aqueous_thermodynamics.index):
        assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS
        
    # Check the MWs match up
    for CAS, MW_specified in zip(CRC_aqueous_thermodynamics.index, CRC_aqueous_thermodynamics['MW']):
        c = pubchem_db.search_CAS(CAS)
        assert_allclose(c.MW, MW_specified, atol=0.05)
        
    # Checking names is an option too but of 173, only 162 are unique
    # and many of the others have names that seem ambiguous for ions which can
    # have more than one charge
    
    assert CRC_aqueous_thermodynamics.index.is_unique
    assert CRC_aqueous_thermodynamics.shape == (173, 7)