Another issue with units
Closed this issue · 1 comments
agarny commented
This issue stems from a feature request that was made here for OpenCOR.
I was checking @FinbarArgus' model using libCellML and... libCellML crashed on it. Here is how I tried to check his model:
TEST(Generator, finbarModel)
{
auto parser = libcellml::Parser::create(false);
auto model = parser->parseModel(fileContents("generator/SN_to_cAMP/SN_to_cAMP.cellml"));
auto importer = libcellml::Importer::create(false);
EXPECT_EQ(size_t(0), parser->errorCount());
EXPECT_TRUE(model->hasUnresolvedImports());
importer->resolveImports(model, resourcePath("generator/SN_to_cAMP"));
EXPECT_FALSE(model->hasUnresolvedImports()); // <--- >>> CRASH! <<<
model = importer->flattenModel(model);
auto analyser = libcellml::Analyser::create();
analyser->analyseModel(model);
EXPECT_EQ(size_t(0), analyser->errorCount());
auto analyserModel = analyser->model();
auto generator = libcellml::Generator::create();
generator->setModel(analyserModel);
EXPECT_EQ(fileContents("generator/SN_to_cAMP/SN_to_cAMP.h"), generator->interfaceCode());
EXPECT_EQ(fileContents("generator/SN_to_cAMP/SN_to_cAMP.c"), generator->implementationCode());
auto profile = libcellml::GeneratorProfile::create(libcellml::GeneratorProfile::Profile::PYTHON);
generator->setProfile(profile);
EXPECT_EQ(fileContents("generator/SN_to_cAMP/SN_to_cAMP.py"), generator->implementationCode());
}
FinbarArgus commented
This issue might encompass two separate issues. One might be libcellml struggling with initialising variables with other variables. I have had issues with this in the past. The other might be due to the inconsistency in units between the environment and the module for the variable Cav.