Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Sep 3, 2024
1 parent ff5a1a2 commit c83f5c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ limitations under the License.
#include "commonutils.h"
#include "utilities.h"

#include "libcellml/undefines.h"

namespace libcellml {

std::string astAsCode(const AnalyserEquationAstPtr &ast)
Expand Down Expand Up @@ -116,7 +114,7 @@ void printAnalyserModelEquations(const AnalyserModelPtr &model)
Debug() << "\nNo algebraic variables";
}

if (eqn->algebraicCount() != 0) {
if (eqn->externalCount() != 0) {
Debug() << "\nExternal variables:";

for (const auto &var : eqn->externals()) {
Expand Down Expand Up @@ -150,7 +148,7 @@ void printAnalyserModelEquations(const AnalyserModelPtr &model)
if (nlaSibling->ast() != nullptr) {
Debug() << " - " << astAsCode(nlaSibling->ast());
} else if (nlaSibling->type() == AnalyserEquation::Type::EXTERNAL) {
Debug() << " - External equation for '" << nlaSibling->algebraic(0)->variable()->name() << "'";
Debug() << " - External equation for '" << nlaSibling->external(0)->variable()->name() << "'";
} else {
Debug() << " - ??? [" << AnalyserEquation::typeAsString(nlaSibling->type()) << "]";
}
Expand Down Expand Up @@ -180,7 +178,7 @@ void printAnalyserModelVariables(const AnalyserModelPtr &model)
if (eqn->ast() != nullptr) {
Debug() << " - " << astAsCode(eqn->ast());
} else if (eqn->type() == AnalyserEquation::Type::EXTERNAL) {
Debug() << " - External equation for '" << eqn->algebraic(0)->variable()->name() << "'";
Debug() << " - External equation for '" << eqn->external(0)->variable()->name() << "'";
} else {
Debug() << " - ??? [" << AnalyserEquation::typeAsString(eqn->type()) << "]";
}
Expand Down
8 changes: 1 addition & 7 deletions src/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,15 @@ void Generator::GeneratorImpl::doAddImplementationVariableInfoCode(const std::st
void Generator::GeneratorImpl::addImplementationVariableInfoCode()
{
if (modelHasOdes()) {
std::vector<AnalyserVariablePtr> variables;

variables.push_back(mModel->voi());

doAddImplementationVariableInfoCode(mProfile->implementationVoiInfoString(), variables, true);
doAddImplementationVariableInfoCode(mProfile->implementationVoiInfoString(), {mModel->voi()}, true);
}

if (modelHasOdes()) {
doAddImplementationVariableInfoCode(mProfile->implementationStateInfoString(), mModel->states(), false);
}

doAddImplementationVariableInfoCode(mProfile->implementationConstantInfoString(), mModel->constants(), false);

doAddImplementationVariableInfoCode(mProfile->implementationComputedConstantInfoString(), mModel->computedConstants(), false);

doAddImplementationVariableInfoCode(mProfile->implementationAlgebraicInfoString(), mModel->algebraic(), false);

if (mModel->hasExternalVariables()) {
Expand Down
5 changes: 5 additions & 0 deletions tests/bindings/javascript/analysermodel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ describe("Analyser Model tests", () => {
expect(am.algebraicVariables().size()).toBe(10)
expect(am.algebraicVariable(2).variable().name()).toBe("i_K")
});
test('Checking Analyser Model external variables related API.', () => {
expect(am.externalCount()).toBe(0)
expect(am.externals().size()).toBe(0)
expect(am.external(0)).toBeNull()
});
test('Checking Analyser Model need* API.', () => {
expect(am.needEqFunction()).toBe(false)
expect(am.needNeqFunction()).toBe(false)
Expand Down
1 change: 1 addition & 0 deletions tests/bindings/javascript/analyservariable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe("Analyser Variable tests", () => {
expect(am.constantCount()).toBe(5)
expect(am.computedConstantCount()).toBe(3)
expect(am.algebraicCount()).toBe(10)
expect(am.externalCount()).toBe(0)
});
test('Checking Analyser Variable type.', () => {
const av = am.algebraicVariable(0)
Expand Down

0 comments on commit c83f5c7

Please sign in to comment.