From a5ec12c9e952471e50d2da19f134c6f3a2c38023 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 14 Oct 2017 13:05:14 +0200 Subject: [PATCH] Change (float)"NaN" to (-1e40*0) in output. Solves both an inconsistency and the need to create a string. --- lslopt/lsloutput.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lslopt/lsloutput.py b/lslopt/lsloutput.py index 3acde8d..4aca83d 100644 --- a/lslopt/lsloutput.py +++ b/lslopt/lsloutput.py @@ -21,7 +21,7 @@ import lslfuncs import lslcommon from lslcommon import Key, Vector, Quaternion from lslparse import warning -import math +from math import copysign class outscript(object): @@ -71,19 +71,17 @@ class outscript(object): if tvalue == float: if self.optfloats and value.is_integer() and -2147483648.0 <= value < 2147483648.0: if self.globalmode and not self.listmode: - if value == 0 and math.copysign(1, value) == -1: + if value == 0 and copysign(1, value) == -1: return '-0.' return str(int(value)) elif not self.globalmode: # Important inside lists!! - if value == 0 and math.copysign(1, value) == -1: + if value == 0 and copysign(1, value) == -1: return '(-(float)0)' return '((float)' + str(int(value)) + ')' s = repr(value) if s == 'nan': - if math.copysign(1, value) < 0: # Indeterminate - return '(1e40*0)' - return '((float)"NaN")' # this shouldn't appear in globals + return '(1e40*0)' if copysign(1, value) < 0 else '(-1e40*0)' if s == 'inf': return '1e40' if s == '-inf':