-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
alph_clone->init_map_table(); | ||
alph_clone->copy_histogram(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
return alph_clone; | ||
} | ||
|
||
template <class ST> | ||
void CAlphabet::translate_from_single_order(ST* obs, int32_t sequence_length, int32_t start, int32_t p_order, int32_t max_val, int32_t gap) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. we usually have no space before pointer * |
||
|
||
private: | ||
/** Do basic initialisations like default settings | ||
* and registering parameters */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. BSD please, see more recent headers |
||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2017 Leon Kuchenbecker | ||
*/ | ||
|
||
#include <shogun/features/Alphabet.h> | ||
#include <gtest/gtest.h> | ||
|
||
using namespace shogun; | ||
|
||
TEST(AlphabetTest, test_clone) | ||
{ | ||
CAlphabet * alph = new CAlphabet(PROTEIN); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. did you valgrind check this for leaks? |
||
|
||
SG_UNREF(alph); | ||
SG_UNREF(alph_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 *