Skip to content

Commit

Permalink
Tests: simplified the use of some arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 10, 2024
1 parent 00e5880 commit 6505182
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
15 changes: 9 additions & 6 deletions tests/bindings/javascript/interpreter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,20 @@ describe("Interpreter tests", () => {

expect(i.voi()).toBe(0.0)

expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.states())
expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.rates())
expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.variables())
const NaN_x_5 = Array(5).fill(Number.NaN)
const NaN_x_18 = Array(18).fill(Number.NaN)

expectArray(NaN_x_5, i.states())
expectArray(NaN_x_5, i.rates())
expectArray(NaN_x_18, i.variables())

i.initialiseVariables()
i.computeComputedConstants()
i.computeRates()
i.computeVariables()

expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.states())
expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.rates())
expectArray([Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN], i.variables())
expectArray(NaN_x_5, i.states())
expectArray(NaN_x_5, i.rates())
expectArray(NaN_x_18, i.variables())
})
})
15 changes: 9 additions & 6 deletions tests/bindings/python/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ def test_hodgkin_huxley_squid_axon_model_1952(self):

self.assertEqual(0.0, i.voi())

self.assert_array_equal([math.nan, math.nan, math.nan, math.nan], i.states())
self.assert_array_equal([math.nan, math.nan, math.nan, math.nan], i.rates())
self.assert_array_equal([math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan], i.variables())
nan_x_4 = 4 * [math.nan]
nan_x_18 = 18 * [math.nan]

self.assert_array_equal(nan_x_4, i.states())
self.assert_array_equal(nan_x_4, i.rates())
self.assert_array_equal(nan_x_18, i.variables())

i.initialiseVariables()
i.computeComputedConstants()
i.computeRates()
i.computeVariables()

self.assert_array_equal([math.nan, math.nan, math.nan, math.nan], i.states())
self.assert_array_equal([math.nan, math.nan, math.nan, math.nan], i.rates())
self.assert_array_equal([math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan, math.nan], i.variables())
self.assert_array_equal(nan_x_4, i.states())
self.assert_array_equal(nan_x_4, i.rates())
self.assert_array_equal(nan_x_18, i.variables())


if __name__ == '__main__':
Expand Down
30 changes: 15 additions & 15 deletions tests/generator/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ limitations under the License.
static const std::string EMPTY_STRING;
static const std::vector<double> NO_VALUES;
static const auto NaN = std::numeric_limits<double>::quiet_NaN();
static const auto NaN_x_1 = std::vector<double>({NaN});
static const auto NaN_x_2 = std::vector<double>({NaN, NaN});
static const auto NaN_x_3 = std::vector<double>({NaN, NaN, NaN});
static const auto NaN_x_4 = std::vector<double>({NaN, NaN, NaN, NaN});
static const auto NaN_x_5 = std::vector<double>({NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_6 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_10 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_15 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_17 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_18 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_19 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_20 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_33 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_185 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_217 = std::vector<double>({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN});
static const auto NaN_x_1 = std::vector<double>(1, NaN);
static const auto NaN_x_2 = std::vector<double>(2, NaN);
static const auto NaN_x_3 = std::vector<double>(3, NaN);
static const auto NaN_x_4 = std::vector<double>(4, NaN);
static const auto NaN_x_5 = std::vector<double>(5, NaN);
static const auto NaN_x_6 = std::vector<double>(6, NaN);
static const auto NaN_x_10 = std::vector<double>(10, NaN);
static const auto NaN_x_15 = std::vector<double>(15, NaN);
static const auto NaN_x_17 = std::vector<double>(17, NaN);
static const auto NaN_x_18 = std::vector<double>(18, NaN);
static const auto NaN_x_19 = std::vector<double>(19, NaN);
static const auto NaN_x_20 = std::vector<double>(20, NaN);
static const auto NaN_x_33 = std::vector<double>(33, NaN);
static const auto NaN_x_185 = std::vector<double>(185, NaN);
static const auto NaN_x_217 = std::vector<double>(217, NaN);

TEST(Generator, emptyModel)
{
Expand Down

0 comments on commit 6505182

Please sign in to comment.