Skip to content

Commit

Permalink
GeneratorProfile: use the externals array to retrieve the value of ex…
Browse files Browse the repository at this point in the history
…ternal variables.
  • Loading branch information
agarny committed Aug 20, 2024
1 parent 183d531 commit 5d6745d
Show file tree
Hide file tree
Showing 46 changed files with 92 additions and 92 deletions.
18 changes: 9 additions & 9 deletions src/generatorprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
"[CODE]"
"}\n";

mInterfaceComputeRatesMethodWevString = "void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n";
mImplementationComputeRatesMethodWevString = "void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n{\n"
mInterfaceComputeRatesMethodWevString = "void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n";
mImplementationComputeRatesMethodWevString = "void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n{\n"
"[CODE]"
"}\n";

Expand All @@ -451,8 +451,8 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
"[CODE]"
"}\n";

mInterfaceComputeVariablesMethodFamWevString = "void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n";
mImplementationComputeVariablesMethodFamWevString = "void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n"
mInterfaceComputeVariablesMethodFamWevString = "void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n";
mImplementationComputeVariablesMethodFamWevString = "void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n"
"{\n"
"[CODE]"
"}\n";
Expand All @@ -463,8 +463,8 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
"[CODE]"
"}\n";

mInterfaceComputeVariablesMethodFdmWevString = "void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n";
mImplementationComputeVariablesMethodFdmWevString = "void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n"
mInterfaceComputeVariablesMethodFdmWevString = "void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n";
mImplementationComputeVariablesMethodFdmWevString = "void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n"
"{\n"
"[CODE]"
"}\n";
Expand Down Expand Up @@ -834,7 +834,7 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi

mInterfaceComputeRatesMethodWevString = "";
mImplementationComputeRatesMethodWevString = "\n"
"def compute_rates(voi, states, rates, constants, computed_constants, algebraic, external_variable):\n"
"def compute_rates(voi, states, rates, constants, computed_constants, algebraic, externals, external_variable):\n"
"[CODE]";

mInterfaceComputeVariablesMethodFamWoevString = "";
Expand All @@ -844,7 +844,7 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi

mInterfaceComputeVariablesMethodFamWevString = "";
mImplementationComputeVariablesMethodFamWevString = "\n"
"def compute_variables(constants, computed_constants, algebraic, external_variable):\n"
"def compute_variables(constants, computed_constants, algebraic, externals, external_variable):\n"
"[CODE]";

mInterfaceComputeVariablesMethodFdmWoevString = "";
Expand All @@ -854,7 +854,7 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi

mInterfaceComputeVariablesMethodFdmWevString = "";
mImplementationComputeVariablesMethodFdmWevString = "\n"
"def compute_variables(voi, states, rates, constants, computed_constants, algebraic, external_variable):\n"
"def compute_variables(voi, states, rates, constants, computed_constants, algebraic, externals, external_variable):\n"
"[CODE]";

mEmptyMethodString = "pass\n";
Expand Down
4 changes: 2 additions & 2 deletions src/generatorprofilesha1values.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace libcellml {
* The content of this file is generated, do not edit this file directly.
* See docs/dev_utilities.rst for further information.
*/
static const char C_GENERATOR_PROFILE_SHA1[] = "1e07f5b270d8f8fe62cffa8bcd81bf04804aa9e5";
static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "3c4d4503bca8066e85c60491ac85a960ec8144bf";
static const char C_GENERATOR_PROFILE_SHA1[] = "499d2a09f435466b1b21814ad5ef24ecce632565";
static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "68f0b0a709a9fd32a8e697eecb91a42b2dad485d";

} // namespace libcellml
12 changes: 6 additions & 6 deletions tests/bindings/python/test_generator_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def test_implementation_compute_rates_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeRatesMethodString(False))

self.assertEqual(
'void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n{\n[CODE]}\n',
'void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n{\n[CODE]}\n',
g.implementationComputeRatesMethodString(True))
g.setImplementationComputeRatesMethodString(True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeRatesMethodString(True))
Expand All @@ -741,7 +741,7 @@ def test_implementation_compute_variables_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeVariablesMethodString(False, False))

self.assertEqual(
'void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n{\n[CODE]}\n',
'void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n{\n[CODE]}\n',
g.implementationComputeVariablesMethodString(False, True))
g.setImplementationComputeVariablesMethodString(False, True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeVariablesMethodString(False, True))
Expand All @@ -753,7 +753,7 @@ def test_implementation_compute_variables_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeVariablesMethodString(True, False))

self.assertEqual(
'void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n{\n[CODE]}\n',
'void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n{\n[CODE]}\n',
g.implementationComputeVariablesMethodString(True, True))
g.setImplementationComputeVariablesMethodString(True, True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.implementationComputeVariablesMethodString(True, True))
Expand Down Expand Up @@ -1006,7 +1006,7 @@ def test_interface_compute_rates_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeRatesMethodString(False))

self.assertEqual(
'void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n',
'void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n',
g.interfaceComputeRatesMethodString(True))
g.setInterfaceComputeRatesMethodString(True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeRatesMethodString(True))
Expand All @@ -1023,7 +1023,7 @@ def test_interface_compute_variables_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeVariablesMethodString(False, False))

self.assertEqual(
'void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n',
'void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n',
g.interfaceComputeVariablesMethodString(False, True))
g.setInterfaceComputeVariablesMethodString(False, True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeVariablesMethodString(False, True))
Expand All @@ -1035,7 +1035,7 @@ def test_interface_compute_variables_method_string(self):
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeVariablesMethodString(True, False))

self.assertEqual(
'void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n',
'void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n',
g.interfaceComputeVariablesMethodString(True, True))
g.setInterfaceComputeVariablesMethodString(True, True, GeneratorProfileTestCase.VALUE)
self.assertEqual(GeneratorProfileTestCase.VALUE, g.interfaceComputeVariablesMethodString(True, True))
Expand Down
12 changes: 6 additions & 6 deletions tests/generator/generatorprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ TEST(GeneratorProfile, defaultMiscellaneousValues)
"}\n",
generatorProfile->implementationComputeRatesMethodString(false));

EXPECT_EQ("void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n",
EXPECT_EQ("void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n",
generatorProfile->interfaceComputeRatesMethodString(true));
EXPECT_EQ("void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n"
EXPECT_EQ("void computeRates(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n"
"{\n"
"[CODE]"
"}\n",
Expand All @@ -542,9 +542,9 @@ TEST(GeneratorProfile, defaultMiscellaneousValues)
"}\n",
generatorProfile->implementationComputeVariablesMethodString(false, false));

EXPECT_EQ("void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n",
EXPECT_EQ("void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n",
generatorProfile->interfaceComputeVariablesMethodString(false, true));
EXPECT_EQ("void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n"
EXPECT_EQ("void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n"
"{\n"
"[CODE]"
"}\n",
Expand All @@ -558,9 +558,9 @@ TEST(GeneratorProfile, defaultMiscellaneousValues)
"}\n",
generatorProfile->implementationComputeVariablesMethodString(true, false));

EXPECT_EQ("void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);\n",
EXPECT_EQ("void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);\n",
generatorProfile->interfaceComputeVariablesMethodString(true, true));
EXPECT_EQ("void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)\n"
EXPECT_EQ("void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)\n"
"{\n"
"[CODE]"
"}\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void computeComputedConstants(double *constants, double *computedConstants)
{
}

void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)
{
externals[0] = externalVariable(constants, computedConstants, algebraic, 0);
algebraic[0] = externals[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ typedef double (* ExternalVariable)(double *constants, double *computedConstants

void initialiseVariables(double *constants, double *computedConstants, double *algebraic);
void computeComputedConstants(double *constants, double *computedConstants);
void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def compute_computed_constants(constants, computed_constants):
pass


def compute_variables(constants, computed_constants, algebraic, external_variable):
def compute_variables(constants, computed_constants, algebraic, externals, external_variable):
externals[0] = external_variable(constants, computed_constants, algebraic, 0)
algebraic[0] = externals[0]
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void computeComputedConstants(double *constants, double *computedConstants)
{
}

void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)
{
externals[0] = externalVariable(constants, computedConstants, algebraic, 0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ typedef double (* ExternalVariable)(double *constants, double *computedConstants

void initialiseVariables(double *constants, double *computedConstants, double *algebraic);
void computeComputedConstants(double *constants, double *computedConstants);
void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def compute_computed_constants(constants, computed_constants):
pass


def compute_variables(constants, computed_constants, algebraic, external_variable):
def compute_variables(constants, computed_constants, algebraic, externals, external_variable):
externals[0] = external_variable(constants, computed_constants, algebraic, 0)
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void computeComputedConstants(double *constants, double *computedConstants)
{
}

void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)
{
externals[0] = externalVariable(constants, computedConstants, algebraic, 0);
externals[1] = externalVariable(constants, computedConstants, algebraic, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ typedef double (* ExternalVariable)(double *constants, double *computedConstants

void initialiseVariables(double *constants, double *computedConstants, double *algebraic);
void computeComputedConstants(double *constants, double *computedConstants);
void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def compute_computed_constants(constants, computed_constants):
pass


def compute_variables(constants, computed_constants, algebraic, external_variable):
def compute_variables(constants, computed_constants, algebraic, externals, external_variable):
externals[0] = external_variable(constants, computed_constants, algebraic, 0)
externals[1] = external_variable(constants, computed_constants, algebraic, 1)
externals[2] = external_variable(constants, computed_constants, algebraic, 2)
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void computeComputedConstants(double *constants, double *computedConstants)
{
}

void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable)
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable)
{
externals[0] = externalVariable(constants, computedConstants, algebraic, 0);
externals[1] = externalVariable(constants, computedConstants, algebraic, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ typedef double (* ExternalVariable)(double *constants, double *computedConstants

void initialiseVariables(double *constants, double *computedConstants, double *algebraic);
void computeComputedConstants(double *constants, double *computedConstants);
void computeVariables(double *constants, double *computedConstants, double *algebraic, ExternalVariable externalVariable);
void computeVariables(double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable);
Loading

0 comments on commit 5d6745d

Please sign in to comment.