From 1440f7811e2f665134f2fdb05d81eeaf7fdaf8ef Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 28 Feb 2015 17:34:26 +0100 Subject: [PATCH] Fix bug where (float)"infi" did not produce Infinity. --- lslopt/lslbasefuncs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index b0d5cbd..5ba956e 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -32,6 +32,9 @@ from base64 import b64encode, b64decode # The lookahead (?!i) is essential for parsing them that way without extra code. # Note that '|' in REs is order-sensitive. float_re = re.compile(ur'^\s*[+-]?(?:0(x)(?:[0-9a-f]+(?:\.[0-9a-f]*)?|\.[0-9a-f]+)(?:p[+-]?[0-9]+)?' + ur'|(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:e[+-]?[0-9]+)?|inf|nan)', + re.I) +vfloat_re = re.compile(ur'^\s*[+-]?(?:0(x)(?:[0-9a-f]+(?:\.[0-9a-f]*)?|\.[0-9a-f]+)(?:p[+-]?[0-9]+)?' ur'|(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:e[+-]?[0-9]+)?|infinity|inf(?!i)|nan)', re.I) @@ -329,7 +332,7 @@ def InternalTypecast(val, out, InList, f32): return Z val = val[1:] for _ in range(dim): - match = float_re.match(val) + match = vfloat_re.match(val) if match is None: return Z if match.group(1):