Merge pull request #1167 from stefoss23/add_keyword

Add keyword, python deck
This commit is contained in:
Joakim Hove 2019-10-29 16:54:22 +01:00 committed by GitHub
commit 92188eea8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -35,6 +35,11 @@ namespace {
return deck.getKeyword(index);
}
//This adds a keyword by copy
void addKeyword(Deck& deck, const DeckKeyword kw) {
deck.addKeyword(kw);
}
}
@ -59,6 +64,7 @@ void python::common::export_Deck(py::module &module) {
} )
.def( "count", &count )
.def( "add", &addKeyword)
;
}

View File

@ -152,6 +152,10 @@ FIPNUM
self.assertAlmostEqual( si_array[0], 1.1 * unit_foot )
self.assertAlmostEqual( si_array[2], 3.3 * unit_foot )
assert( not( "ZCORN" in deck ) )
deck.add( zcorn_kw )
assert( "ZCORN" in deck )
if __name__ == "__main__":

View File

@ -49,8 +49,11 @@ BOOST_AUTO_TEST_CASE(INSTANTIATE) {
std::string python_code = R"(
print('Parser: {}'.format(context.parser))
print('Deck: {}'.format(context.deck))
kw = context.DeckKeyword( context.parser['FIELD'] )
context.deck.add(kw)
)";
BOOST_CHECK_NO_THROW( python.exec(python_code, parser, deck));
BOOST_CHECK( deck.hasKeyword("FIELD") );
}
#endif