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
Fix observe() method when called for SGVector/SGMatrix. #4626
Fix observe() method when called for SGVector/SGMatrix. #4626
Conversation
T_SGMATRIX_INT32 = 24, | ||
T_SGMATRIX_INT64 = 25, | ||
T_UNDEFINED = 26 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be worth adding all the combinations of containers and primitive types, or some macro that would do that? Because right now stuff like SGVector<bool>
isn't included (whether or not we actually use it is another question...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would make sense if we were to use it somewhere in Shogun. For instance, if we find a machine which needs to emit SGVector<bool>
then we will add it.
e540d7e
to
42835a7
Compare
756b353
to
939c907
Compare
c9a2064
to
4bdea29
Compare
c8b39fe
to
30ca2d6
Compare
…d is_sg_matrix." This reverts commit cb70da3.
* Override create_empty() inside MockObject.h to ensure proper testing.
30ca2d6
to
d2bce30
Compare
@karlnapf any final comments before I merge this? :) |
@@ -316,6 +316,13 @@ namespace shogun | |||
watch_method("some_method", &CMockObject::some_method); | |||
} | |||
|
|||
virtual CSGObject* create_empty() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curios: why did you add this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, since observe()
emit a clone of the given value, we happens to call MockObject->clone()
. However, the standard SGObject
implementation of clone()
assumes that there is a corresponding create()
method, for that element, inside class_list.h
. This is not true for MockObject
since it is used only for testing purpose. Therefore, I needed to override create_empty
such to return a new instance without relying on the class_list.h
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yep, I remember that stuff now. thanks!
good! |
observe()
method when called forSGVector
/SGMatrix
. The givenSGVector/SGMatrix
was not cloned correctly (since copying them just copy the pointer to the raw data and it does not make a clone of the data itself).I moved some useful type traits fromtype_case.h
tobase_types.h
since I did not want to pollute too muchSGObject.h
with unnecessary headers.Any comments on this change? @karlnapf @vigsterkr @gf712