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

Lazy any #4343

Merged
merged 11 commits into from Jul 5, 2018
18 changes: 18 additions & 0 deletions src/shogun/base/SGObject.cpp
Expand Up @@ -698,6 +698,14 @@ CSGObject* CSGObject::clone()
const BaseTag& tag = it.first;
const Any& own = it.second.get_value();

if (!own.cloneable())
{
SG_SDEBUG(
"Skipping clone of %s::%s of type %s.\n", this->get_name(),
tag.name().c_str(), own.type().c_str());
Copy link
Member

Choose a reason for hiding this comment

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

continue!

Copy link
Member

Choose a reason for hiding this comment

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

actually, why not move the check after the debug msg below, then you dont need to print the name and stuff again, but can just say "Skipping as not cloneable"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah but since it is here such thing might be useful anyway

continue;
}

SG_SDEBUG(
"Cloning parameter %s::%s of type %s.\n", this->get_name(),
tag.name().c_str(), own.type().c_str());
Expand Down Expand Up @@ -993,6 +1001,16 @@ bool CSGObject::equals(const CSGObject* other) const
{
const BaseTag& tag = it.first;
const Any& own = it.second.get_value();

if (!own.visitable())
{
SG_SDEBUG(
"Skipping comparison of %s::%s of type %s as it is "
"non-visitable.\n",
this->get_name(), tag.name().c_str(), own.type().c_str());
continue;
Copy link
Member

Choose a reason for hiding this comment

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

same here, i would move this down and only say "skipping" to avoid duplicate code

}

const Any& given = other->get_parameter(tag).get_value();

SG_SDEBUG(
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/base/SGObject.h
Expand Up @@ -335,7 +335,7 @@ class CSGObject
if (!has_parameter(tag))
return false;
const Any value = get_parameter(tag).get_value();
return value.same_type<T>();
return value.has_type<T>();
}

/** Setter for a class parameter, identified by a Tag.
Expand Down