[ase-users] ase-db question on booleans

John Kitchin jkitchin at andrew.cmu.edu
Fri Mar 3 02:39:58 CET 2017


Hi all,

In ase.db.core there is this function:

def convert_str_to_int_float_or_str(value):
    """Safe eval()"""
    try:
        return int(value)
    except ValueError:
        try:
            value = float(value)
        except ValueError:
            value = {'True': 1.0, 'False': 0.0}.get(value, value)
        return value

I wondered why True and False are converted to floats? It seems strings
like True and False would be better, or integers. Is there some database
that can not store booleans where this is useful?

-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


More information about the ase-users mailing list