From 650518252cc40aeb67eb2a0fd8c32a7c894d30a7 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Thu, 11 Apr 2024 02:18:05 +1200 Subject: [PATCH] Tests: simplified the use of some arrays. --- tests/bindings/javascript/interpreter.test.js | 15 ++++++---- tests/bindings/python/test_interpreter.py | 15 ++++++---- tests/generator/generator.cpp | 30 +++++++++---------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/bindings/javascript/interpreter.test.js b/tests/bindings/javascript/interpreter.test.js index 9d9b77e7ba..cfbf2b3dac 100644 --- a/tests/bindings/javascript/interpreter.test.js +++ b/tests/bindings/javascript/interpreter.test.js @@ -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()) }) }) diff --git a/tests/bindings/python/test_interpreter.py b/tests/bindings/python/test_interpreter.py index 802f661776..392b31afc3 100644 --- a/tests/bindings/python/test_interpreter.py +++ b/tests/bindings/python/test_interpreter.py @@ -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__': diff --git a/tests/generator/generator.cpp b/tests/generator/generator.cpp index 8ef3cd76ab..0c84b08742 100644 --- a/tests/generator/generator.cpp +++ b/tests/generator/generator.cpp @@ -23,21 +23,21 @@ limitations under the License. static const std::string EMPTY_STRING; static const std::vector NO_VALUES; static const auto NaN = std::numeric_limits::quiet_NaN(); -static const auto NaN_x_1 = std::vector({NaN}); -static const auto NaN_x_2 = std::vector({NaN, NaN}); -static const auto NaN_x_3 = std::vector({NaN, NaN, NaN}); -static const auto NaN_x_4 = std::vector({NaN, NaN, NaN, NaN}); -static const auto NaN_x_5 = std::vector({NaN, NaN, NaN, NaN, NaN}); -static const auto NaN_x_6 = std::vector({NaN, NaN, NaN, NaN, NaN, NaN}); -static const auto NaN_x_10 = std::vector({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN}); -static const auto NaN_x_15 = std::vector({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN}); -static const auto NaN_x_17 = std::vector({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({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({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({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({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 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({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 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({NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 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(1, NaN); +static const auto NaN_x_2 = std::vector(2, NaN); +static const auto NaN_x_3 = std::vector(3, NaN); +static const auto NaN_x_4 = std::vector(4, NaN); +static const auto NaN_x_5 = std::vector(5, NaN); +static const auto NaN_x_6 = std::vector(6, NaN); +static const auto NaN_x_10 = std::vector(10, NaN); +static const auto NaN_x_15 = std::vector(15, NaN); +static const auto NaN_x_17 = std::vector(17, NaN); +static const auto NaN_x_18 = std::vector(18, NaN); +static const auto NaN_x_19 = std::vector(19, NaN); +static const auto NaN_x_20 = std::vector(20, NaN); +static const auto NaN_x_33 = std::vector(33, NaN); +static const auto NaN_x_185 = std::vector(185, NaN); +static const auto NaN_x_217 = std::vector(217, NaN); TEST(Generator, emptyModel) {