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

Fix CAlphabet::Clone + unit test #3676

Merged
merged 1 commit into from Mar 6, 2017

Conversation

lkuchenb
Copy link
Contributor

@lkuchenb lkuchenb commented Mar 4, 2017

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 of CCommWordStringKernel.

There are some remarks about this in the serialization section here.

Please check.

Copy link
Member

@karlnapf karlnapf left a 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
Copy link
Member

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());
Copy link
Member

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);
Copy link
Member

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

Copy link
Contributor Author

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();
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

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

no whitespace before *

@karlnapf
Copy link
Member

karlnapf commented Mar 6, 2017

@vigsterkr feel free to merge

@vigsterkr
Copy link
Member

boooyaaaa

@vigsterkr vigsterkr merged commit 0ed97dc into shogun-toolbox:develop Mar 6, 2017
@lkuchenb
Copy link
Contributor Author

lkuchenb commented Mar 6, 2017

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.

karasikov pushed a commit to karasikov/shogun that referenced this pull request Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants