]> gitweb.michael.orlitzky.com - dunshire.git/commitdiff
Add a new DEBUG_FLOAT_FORMAT and use it when raising game exceptions.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Nov 2016 23:24:24 +0000 (19:24 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Nov 2016 23:24:24 +0000 (19:24 -0400)
dunshire/games.py
dunshire/options.py

index 3575da52b15c0b874a1ebb0fd346d46947d887d4..2d6d6dae8d75352e4876954ba0cc2eff454c67f7 100644 (file)
@@ -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):
index 976fe082421539ef118d73f9ee7ac8f077efa971..719d7f2228a19e72aa52569fec4f88a9117668a7 100644 (file)
@@ -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'
 """