Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow put of dynamic parameter #4357

Merged
merged 2 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/shogun/base/SGObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,17 @@ class CSGObject
{
if (has_parameter(_tag))
{
auto parameter_value = get_parameter(_tag).get_value();
if (!parameter_value.cloneable())
{
SG_ERROR(
"Cannot put parameter %s::%s. Perhaps it is immutable for "
"%s",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont understand the message.
Perhaps it is unmutable for CLASSNAME?

get_name(), _tag.name().c_str(), get_name());
}
try
{
any_cast<T>(get_parameter(_tag).get_value());
any_cast<T>(parameter_value);
}
catch (const TypeMismatchException& exc)
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/base/SGObject_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,5 @@ TEST(SGObject, watch_method)
{
auto obj = some<CMockObject>();
EXPECT_EQ(obj->get<int>("some_method"), obj->some_method());
EXPECT_THROW(obj->put<int>("some_method", 0), ShogunException);
}