-
Notifications
You must be signed in to change notification settings - Fork 229
[MRG] Uniformize num_dims and add it for LMNN #193
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
Changes from 4 commits
07c156a
65d7709
b003d83
9ec6892
5edad14
047191b
6630d0a
5579c9a
b015258
81c9a8d
1334797
0c9758e
ca58256
e161cc9
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 |
---|---|---|
|
@@ -405,3 +405,15 @@ def validate_vector(u, dtype=None): | |
if u.ndim > 1: | ||
raise ValueError("Input vector should be 1-D.") | ||
return u | ||
|
||
|
||
def _check_num_dims(n_features, num_dims): | ||
"""Checks that num_dims is less that n_features and deal with the None | ||
case""" | ||
if num_dims is None: | ||
dim = n_features | ||
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. As a style nitpick, I prefer early-return for cases like this: if num_dims is None:
return n_features
if 0 < num_dims <= n_features:
return num_dims
raise ValueError(...) 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. That's better I agree, done |
||
else: | ||
if not 0 < num_dims <= n_features: | ||
raise ValueError('Invalid num_dims, must be in [1, %d]' % n_features) | ||
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. Some existing code would only warn if 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. That's true, maybe adding it in the changelog is enough ? Something like "for all the algorithms that have a parameter 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. |
||
dim = num_dims | ||
return dim |
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.
typo: "less than"
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.
Thanks, done