Please sign in to comment.
Small modifications to support BNG's 'stop_if' method (#407)
* Some small modifications to support the 'stop_if' method in BNG, which allows one to define a logical function that if True will terminate a simulation. First problem is that BNG creates a new internal function called '_stop_if' that gets output to the .gdat file. This was causing problems in PySB since the number of defined Expressions wasn't matching the number of functions in the .gdat file. Fixed this by explicitly using the length of 'model.expressions' when reading in the .gdat file. Second problem is that if 'stop_if' is satisfied at the outset BNG will immediately quit, only outputting the initial state to the .cdat and .gdat files. This meant that PySB was reading this in as a single numpy array, rather than an array of arrays, which was causing a downstream error. Fixed this by requiring the number of dimensions 'ndmin=2' in the 'numpy.loadtxt' calls. Also added a small test model to the validation test suite called 'test_stop_if'. * Fix BNG gdat parsing when constant expressions in model * Fix test so works consistently across platforms
- Loading branch information...
Showing with 25 additions and 4 deletions.