Uploaded image for project: 'The Virtual Brain'
  1. The Virtual Brain
  2. TVB-692 Review Operations and Data Structure pages
  3. TVB-748

Raise Python exception on IEEE 754 floating point exceptions that yield NaNs during simulation


    • Type: Sub-task
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.2
    • Component/s: TVB-Simulator
    • Labels:
    • Environment:
      Any version of the simulator running on NumPy.
    • Sprint:
      Sprint 1.0.4 & 1.0.5


      In the context of the simulator, it is easy to imagine possible combinations of
      parameters and models that are unstable, i.e. go to infinity or otherwise
      produce NaNs. Specifically, when any of the variables in a simulation reaches a
      NaN state, we never want to continue the simulation (this may not be the case
      with any other component of the simulator, where NaN might be a placeholder for
      legitimately missing information). Numpy's default behavior in the case of
      operations resulting in NaNs is to print a RuntimeWarning to sys.stdout, but
      provides a mechanism, via the floating point error family of functions [1],
      to require NumPy to raise an exception in such cases, which would stop the
      execution of a simulation with a FloatingPointError exception. This is far
      more informative, e.g. when a simulation goes immediately to NaN everywhere
      and then goes for 10 seconds of data full of NaNs.

      We suggest as a fix in this issue that overflow, division by zero and invalid
      exceptions have as their actions to raise an exception. Underflow is not fatal,
      given our current experience and should have the default action. Concretely,
      each operation that performs a simulation should adhere to the pattern:

      >>> old_fp_error_handling = seterr(over='raise', divide='raise', invalid='raise')
      >>> do_simulation_now()
      >>> seterr(**old_fp_error_handling)

      Please refer to [1] for the four possible floating point exceptions, the
      six actions supported by NumPy, and descriptions of the functions.

      [1] http://docs.scipy.org/doc/numpy/reference/routines.err.html




            • Assignee:
              bogdan.neacsa Bogdan Neacsa
              marmaduke.woodman Marmaduke Woodman
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created:

                Time Tracking

                Original Estimate - 4 hours
                Remaining Estimate - 0 minutes
                Time Spent - 2 hours Time Not Required