bundles / astropy 7.0.1 / astropy / extern / configobj / validate / is_float
function
astropy.extern.configobj.validate:is_float
source: /astropy/extern/configobj/validate.py :839
Signature
def is_float ( value , min = None , max = None ) Summary
A check that tests that a given value is a float (an integer will be accepted), and optionally - that it is between bounds.
Extended Summary
If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised.
This can accept negative values.
>>> vtor.check('float', '2') 2.0
From now on we multiply the value to avoid comparing decimals
>>> vtor.check('float', '-6.8') * 10 -68.0 >>> vtor.check('float', '12.2') * 10 122.0 >>> vtor.check('float', 8.4) * 10 84.0 >>> vtor.check('float', 'a') Traceback (most recent call last): VdtTypeError: the value "a" is of the wrong type. >>> vtor.check('float(10.1)', '10.2') * 10 102.0 >>> vtor.check('float(max=20.2)', '15.1') * 10 151.0 >>> vtor.check('float(10.0)', '9.0') Traceback (most recent call last): VdtValueTooSmallError: the value "9.0" is too small. >>> vtor.check('float(max=20.0)', '35.0') Traceback (most recent call last): VdtValueTooBigError: the value "35.0" is too big.
Aliases
-
astropy.config.configuration.validate.is_float