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 CAlphabet::Clone + unit test #3676
Conversation
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.
Good to go from my side. Some minor style comments
@@ -0,0 +1,25 @@ | |||
/* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by |
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.
BSD please, see more recent headers
CAlphabet * alph_clone = (CAlphabet *) alph->clone(); | ||
|
||
EXPECT_EQ(alph->get_num_symbols(), alph_clone->get_num_symbols()); | ||
EXPECT_EQ(alph->get_num_symbols_in_histogram(), alph_clone->get_num_symbols_in_histogram()); |
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.
did you valgrind check this for leaks?
{ | ||
CAlphabet * alph_clone = (CAlphabet *) CSGObject::clone(); | ||
alph_clone->init_map_table(); | ||
alph_clone->copy_histogram(this); |
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.
is this all that is needed? If so this is a neat solution
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 was hoping you guys could tell! There was that obscure comment in the code here, I can't say for sure the patch is enough. Certainly the code before wasn't all that was needed :P
@@ -306,6 +306,8 @@ class CAlphabet : public CSGObject | |||
template <class ST> | |||
static void translate_from_single_order_reversed(ST* obs, int32_t sequence_length, int32_t start, int32_t p_order, int32_t max_val, int32_t gap); | |||
|
|||
CSGObject * clone(); |
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.
we usually have no space before pointer *
@@ -832,6 +832,14 @@ void CAlphabet::translate_from_single_order_reversed(ST* obs, int32_t sequence_l | |||
} | |||
} | |||
|
|||
CSGObject * CAlphabet::clone() | |||
{ | |||
CAlphabet * alph_clone = (CAlphabet *) CSGObject::clone(); |
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.
no whitespace before *
@vigsterkr feel free to merge |
boooyaaaa |
Feel free to change the license to BSD and fix the code style issues. Now that this was merged I guess it's easier if you commit directly. |
Fix CAlphabet::Clone + unit test
Seems like
CAlphabet
couldn't be cloned properly. Another bug that surfaced with the all the cloning happening now with parallel xval, for me in the case ofCCommWordStringKernel
.There are some remarks about this in the serialization section here.
Please check.