From: Michael Orlitzky Date: Fri, 4 Nov 2016 23:24:24 +0000 (-0400) Subject: Add a new DEBUG_FLOAT_FORMAT and use it when raising game exceptions. X-Git-Tag: 0.1.0~67 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dunshire.git;a=commitdiff_plain;h=7080424243887787b6ff925d611a837e8229ec6e Add a new DEBUG_FLOAT_FORMAT and use it when raising game exceptions. --- 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' """