Source code for pimmslearn.io.types

"""
papermill strategy to determine type
see: https://github.com/nteract/papermill/blob/76906a882bb5b3e719ad113c7b2447e0ddffb2c7/papermill/cli.py#L275-L307
"""


[docs] def resolve_type(value): if value == "True": return True elif value == "False": return False elif value == "None": return None elif _is_int(value): return int(value) elif _is_float(value): return float(value) else: return value
def _is_int(value): """Use casting to check if value can convert to an `int`.""" try: int(value) except ValueError: return False else: return True def _is_float(value): """Use casting to check if value can convert to a `float`.""" try: float(value) except ValueError: return False else: return True