-
Notifications
You must be signed in to change notification settings - Fork 19
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
Allowing FPS to take numpy array of ints as initialize parameter #225
Conversation
src/skmatter/_selection.py
Outdated
self.selected_idx_[i] = val | ||
self._update_post_selection(X, y, self.selected_idx_[i]) | ||
else: | ||
raise ValueError("Initialize parameter must contain only int") |
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.
Would you mind adding a test for this error raise?
You can take a look how to test that in the pytest docs or find another example in our test suite
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.
Should be fixed now. Added the unit tests I wrote in test_feature_simple_fps to test_sample_simple_fps. Let me know if this looks correct!
src/skmatter/_selection.py
Outdated
@@ -1038,7 +1038,14 @@ def _init_greedy_search(self, X, y, n_to_select): | |||
self.hausdorff_ = np.full(X.shape[self._axis], np.inf) | |||
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf) | |||
|
|||
if self.initialize == "random": | |||
if isinstance(self.initialize, np.ndarray): |
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.
Shouldn't these operattions also be performed for a List and not only for a numpy array? Something like
if isinstance(self.initialize, np.ndarray) or isinstance(self.initialize, list):
Even though there is probably a shorter way to check of an instance belongs to either one of two classes.
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.
Yes. Let me know what you think about the new changes I made.
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.
Yes looks good. Can you add to the CHANGELOG?
Bump supported and testes Python versions
Updated the changelog! |
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.
Very nice. Thanks for this addition! Let's wait until CI is finished.
Hello!
This pull request is my attempt to address issue #145. With these changes, FPS should be able to accept a numpy array of ints as an input. I wrote a few tests as well to ensure the updated code is functioning properly. I'd love to hear any feedback you may have!
Contributor (creator of PR) checklist
For Reviewer
📚 Documentation preview 📚: https://scikit-matter--225.org.readthedocs.build/en/225/