From d54ba42330b9a55b3abd5c056edbc9f6f5e0f2df Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Thu, 22 Dec 2016 06:05:47 +0100 Subject: [PATCH] Fix more test failures on Windows. On Windows, float('nan') produces Indeterminate. To fix, set Indet first and then set NaN to the opposite. --- lslopt/lslbasefuncs.py | 2 +- testfuncs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 166833c..c24d125 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -76,8 +76,8 @@ ZERO_ROTATION = Quaternion((0.0, 0.0, 0.0, 1.0)) NULL_KEY = u'00000000-0000-0000-0000-000000000000' Infinity = float('inf') -NaN = float('nan') Indet = Infinity * 0 +NaN = -Indet # Don't use float("nan") - Windows gets upset. class ELSLTypeMismatch(Exception): def __init__(self): diff --git a/testfuncs.py b/testfuncs.py index b8cf1b5..8ebcab6 100644 --- a/testfuncs.py +++ b/testfuncs.py @@ -518,8 +518,8 @@ def do_tests(): test('reallyequal(NaN, Indet, 0.0)', False) test('reallyequal(-NaN, Indet, 0.0)', True) test('reallyequal(NaN, -Indet, 0.0)', True) - test('reallyequal(NaN, float("nan"), 0.0)', True) - test('reallyequal(-float("nan"), Indet, 0.0)', True) + test('reallyequal(NaN, -(Infinity*0), 0.0)', True) + test('reallyequal(Infinity*0, Indet, 0.0)', True) shouldexcept('div(1.0, 0.0)', ELSLMathError) shouldexcept('div(1, 0)', ELSLMathError)