Skip to content

Cleanup non-const methods in dense and combined features - #4365

Merged
karlnapf merged 3 commits into
shogun-toolbox:developfrom
vinx13:feature/const_dense_features
Jul 10, 2018
Merged

Cleanup non-const methods in dense and combined features#4365
karlnapf merged 3 commits into
shogun-toolbox:developfrom
vinx13:feature/const_dense_features

Conversation

@vinx13

@vinx13 vinx13 commented Jul 9, 2018

Copy link
Copy Markdown
Member
  • methods made const: create_merged_copy, get_feature_matrix, get_feature_obj
  • dropped public methods: set_feature_vector, reshape, steal_feature_matrix
  • made free_features protected

@lisitsyn

lisitsyn commented Jul 9, 2018

Copy link
Copy Markdown
Member

lgtm!


m_is_trained=true;
distance->init(m_centroids,distance->get_rhs());
distance->init(centroids_feats, distance->get_rhs());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why the change here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

since we would like to drop setters in featuresset_num_vectors, set_num_features, we can't an empty features and then set feature matrix later, and here there is no need to store it in a member field


/** list feature objects */
void list_feature_objs();
void list_feature_objs() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol, this method should rather be deleted (or return a list of strings or so)

return feat;
}

template<class ST> void CDenseFeatures<ST>::set_feature_vector(SGVector<ST> vector, int32_t num)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is not used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, and i think set_feature_matrix should be also removed (after some refactor)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

absolutely, the instance should be tied to the matrix, and otherwise users can create a new instance

}
}

template<class ST> SGMatrix<ST> CDenseFeatures<ST>::steal_feature_matrix()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol another joker method :D


template<class ST> EFeatureClass CDenseFeatures<ST>::get_feature_class() const { return C_DENSE; }

template<class ST> bool CDenseFeatures<ST>::reshape(int32_t p_num_features, int32_t p_num_vectors)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should just be in the matrix itself, i.e. create a new feature instance using the reshaped sgmatrix

* instance and of given one
*/
virtual CFeatures* create_merged_copy(CFeatures* other)
virtual CFeatures* create_merged_copy(CFeatures* other) const

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we can rename this to merge at some point later?

@karlnapf karlnapf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good!

@karlnapf

karlnapf commented Jul 9, 2018

Copy link
Copy Markdown
Member

CI is not happy though

@karlnapf

karlnapf commented Jul 9, 2018

Copy link
Copy Markdown
Member

let me know once CI is happy and I will merge

@vinx13

vinx13 commented Jul 10, 2018

Copy link
Copy Markdown
Member Author

@karlnapf timeout on windows

@karlnapf

Copy link
Copy Markdown
Member

restarted.
But I think this is good. Merging

@karlnapf
karlnapf merged commit f10f3ef into shogun-toolbox:develop Jul 10, 2018
ktiefe pushed a commit to ktiefe/shogun that referenced this pull request Jul 30, 2019
…box#4365)

* Cleanup non-const methods in DenseFeatures
* Make several getters in CombinedFeatures const
* Drop set_feature_vector in python examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants