[aGrUM] remove dummy instance name when only one class and one instance in O3prmBNReader

parent 0027ffee
......@@ -129,7 +129,7 @@ namespace gum {
const std::string& nn = __bn->variable( node ).name();
__bn->variable( node ).setDescription( nn );
// trying to simplify the name
// trying to simplify the
auto start = nn.find_first_of( '(' );
auto end = nn.find_first_of( ')' );
if ( 0 < start && start < end && end < nn.size() ) {
......@@ -137,7 +137,8 @@ namespace gum {
auto type = nn.substr( start + 1, end - start - 1 );
auto name = nn.substr( end + 1, std::string::npos );
std::string newNameRadical = __getVariableName( path, type, name );
std::string newNameRadical =
__getVariableName( path, type, name, instanceName );
std::string newName = newNameRadical;
// forcing newName to be unique
......@@ -148,7 +149,6 @@ namespace gum {
names.insert( newName );
__bn->changeVariableName( node, newName );
} else {
ParseError warn(
false, "Name " + nn + " cannot be simplified.", __filename, 0 );
......
......@@ -143,7 +143,7 @@ namespace gum_tests {
TS_ASSERT_EQUALS( res, (gum::Size)0 );
TS_ASSERT_EQUALS( reader.warnings(), (gum::Size)1 ); // no system
for ( auto n : bn.nodes() ) {
TS_ASSERT( bn.variable( n ).name().find( "." ) != std::string::npos );
TS_ASSERT( bn.variable( n ).name().find( "." ) == std::string::npos );
}
}
{
......
......@@ -119,13 +119,13 @@ namespace gum_tests {
const auto& cpt_1 = bn->cpt( node );
auto i = gum::Instantiation( cpt_1 );
const auto& cpt_2 = bn2.cpt( "baye." + name );
const auto& cpt_2 = bn2.cpt( name );
auto j = gum::Instantiation( cpt_2 );
TS_ASSERT_EQUALS( i.domainSize(), j.domainSize() );
if ( i.domainSize() == j.domainSize() ) {
for ( i.setFirst(); !i.end(); i.inc() ) {
for ( auto i_var : i.variablesSequence() ) {
const auto& j_var = bn2.variable( "baye." + i_var->name() );
const auto& j_var = bn2.variable( i_var->name() );
j.chgVal( j_var, i.val( *i_var ) );
}
TS_ASSERT_DELTA( cpt_1[i], cpt_2[j], 1e-6 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment