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 7a9065f
Show file tree
Hide file tree
Showing 3 changed files with 9 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

0 comments on commit 7a9065f

Please sign in to comment.