From 7080424243887787b6ff925d611a837e8229ec6e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 4 Nov 2016 19:24:24 -0400 Subject: [PATCH] Add a new DEBUG_FLOAT_FORMAT and use it when raising game exceptions. --- dunshire/games.py | 11 ++++++++--- dunshire/options.py | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dunshire/games.py b/dunshire/games.py index 3575da5..2d6d6da 100644 --- a/dunshire/games.py +++ b/dunshire/games.py @@ -1028,9 +1028,14 @@ class SymmetricLinearGame: return self._try_solution(options.ABS_TOL / 10) except (PoorScalingException, GameUnsolvableException): - # Ok, that didn't work. Let's try it with the default - # tolerance, and whatever happens, happens. - return self._try_solution(options.ABS_TOL) + # Ok, that didn't work. Let's try it with the default tolerance.. + try: + return self._try_solution(options.ABS_TOL / 10) + except (PoorScalingException, GameUnsolvableException) as error: + # Well, that didn't work either. Let's verbosify the matrix + # output format before we allow the exception to be raised. + printing.options['dformat'] = options.DEBUG_FLOAT_FORMAT + raise error def condition(self): diff --git a/dunshire/options.py b/dunshire/options.py index 976fe08..719d7f2 100644 --- a/dunshire/options.py +++ b/dunshire/options.py @@ -15,6 +15,14 @@ improves the solubility of real problems is a question for the philosophers. """ +DEBUG_FLOAT_FORMAT = '%.20f' +""" +The float output format to use when something goes wrong. If we need to +produce a random test case, for example, then we need all of the digits +of the things involved. If we try to recreate the problem using only, +say, the first seven digits of each number, then the resulting game +might not reproduce the failure. +""" FLOAT_FORMAT = '%.7f' """ -- 2.43.2