def test_fast_float_converts_float_string_to_float_example(): assert fast_float('45.8') == 45.8 assert fast_float('-45') == -45.0 assert fast_float('45.8e-2', key=len) == 45.8e-2 assert isnan(fast_float('nan')) assert isnan(fast_float('+nan')) assert isnan(fast_float('-NaN')) assert fast_float('۱۲.۱۲') == 12.12 assert fast_float('-۱۲.۱۲') == -12.12
def test_fast_float_converts_float_string_to_float_example(): assert fast_float("45.8") == 45.8 assert fast_float("-45") == -45.0 assert fast_float("45.8e-2", key=len) == 45.8e-2 assert isnan(fast_float("nan")) assert isnan(fast_float("+nan")) assert isnan(fast_float("-NaN")) assert fast_float("۱۲.۱۲") == 12.12 assert fast_float("-۱۲.۱۲") == -12.12
def test_locale_convert_with_groupletters_transforms_nonfloat_string_to_strxfrm_string_with_grouped_letters( x): assume(type(fast_float(x)) is not float) load_locale('en_US') strxfrm = get_strxfrm() assert locale_convert(x, (fast_float, isfloat), True) == strxfrm(''.join( chain.from_iterable([low(y), y] for y in x))) locale.setlocale(locale.LC_NUMERIC, str(''))
def test_fast_float_converts_float_string_to_float_example(): assert fast_float('45.8') == 45.8 assert fast_float('-45') == -45.0 assert fast_float('45.8e-2', key=len) == 45.8e-2 assert isnan(fast_float('nan')) assert isnan(fast_float('+nan')) assert isnan(fast_float('-NaN'))
def test_fast_float_converts_float_string_to_float_example(): assert fast_float('45.8') == 45.8 assert fast_float('-45') == -45.0 assert fast_float('45.8e-2') == 45.8e-2 assert isnan(fast_float('nan'))
def test_fast_float_leaves_float_asis_example(): assert fast_float(45.8) == 45.8
def test_fast_float_with_key_applies_to_string_example(): assert fast_float('invalid', key=len) == len('invalid')
def test_fast_float_leaves_string_as_is_example(): assert fast_float('invalid') == 'invalid'
def test_locale_convert_transforms_nonfloat_string_to_strxfrm_string(x): assume(type(fast_float(x)) is not float) load_locale('en_US') strxfrm = get_strxfrm() assert locale_convert(x, (fast_float, isfloat), False) == strxfrm(x) locale.setlocale(locale.LC_NUMERIC, str(''))
def test_fast_float_leaves_string_as_is_example(): assert fast_float("invalid") == "invalid"
def test_fast_float_with_key_applies_to_string(x): assert fast_float(x, key=len) == len(x)
def test_fast_float_leaves_string_as_is(x): assert fast_float(x) == x
def test_fast_float_converts_float_string_to_float(x): assert fast_float(repr(x)) == x
def test_fast_float_with_key_applies_to_string(x): assume(not is_float(x)) assume(bool(x)) assert fast_float(x, key=len) == len(x)
def test_grouper_returns_letters_with_lowercase_transform_of_letter(x): assume(type(fast_float(x)) is not float) assert grouper(x, (fast_float, isfloat)) == ''.join( chain.from_iterable([low(y), y] for y in x))
def test_fast_float_returns_nan_alternate_if_nan_option_is_given(): assert fast_float('nan', nan=7) == 7
def test_fast_float_converts_float_string_to_float(x): assume(not isnan(x)) # But inf is included assert fast_float(repr(x)) == x
def test_fast_float_leaves_string_as_is(x): assume(not is_float(x)) assume(bool(x)) assert fast_float(x) == x
def test_fast_float_leaves_float_asis(x): assume(not isnan(x)) # But inf is included assert fast_float(x) == x
def test_grouper_returns_letters_with_lowercase_transform_of_letter(x): assume(type(fast_float(x)) is not float) assert grouper(x, (fast_float, isfloat)) == ''.join(chain.from_iterable([low(y), y] for y in x))
def test_fast_float_leaves_string_as_is(x): assume(not is_float(x)) assert fast_float(x) == x
def test_locale_convert_with_groupletters_transforms_nonfloat_string_to_strxfrm_string_with_grouped_letters(x): assume(type(fast_float(x)) is not float) load_locale('en_US') strxfrm = get_strxfrm() assert locale_convert(x, (fast_float, isfloat), True) == strxfrm(''.join(chain.from_iterable([low(y), y] for y in x))) locale.setlocale(locale.LC_NUMERIC, str(''))