-
-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[WIP] Kd tree, ball tree error #17400
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 |
---|---|---|
|
@@ -1053,9 +1053,13 @@ cdef class BinaryTree: | |
if leaf_size < 1: | ||
raise ValueError("leaf_size must be greater than or equal to 1") | ||
|
||
longest_data = max(len(item) for item in data) | ||
if np.any([len(item) < longest_data for item in data]): | ||
raise ValueError("Input points must have " | ||
"the same number of dimensions") | ||
|
||
n_samples = data.shape[0] | ||
n_features = data.shape[1] | ||
|
||
self.data_arr = np.asarray(data, dtype=DTYPE, order='C') | ||
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 think you should rather just use self.data_arr = check_array(data, dtype=DTYPE, order='C') It should display a |
||
self.leaf_size = leaf_size | ||
self.dist_metric = DistanceMetric.get_metric(metric, **kwargs) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,11 @@ def test_query_haversine(): | |
|
||
assert_array_almost_equal(dist1, dist2) | ||
assert_array_almost_equal(ind1, ind2) | ||
|
||
|
||
def test_different_dimension_size(): | ||
X = [(1, 2, 3), (2, 5), (5, 5, 1, 2)] | ||
Y = np.array(X) | ||
msg = ("Input points must have the same number of dimensions") | ||
with pytest.raises(ValueError, match=msg): | ||
BallTree(Y) | ||
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. it need change if u do raise error |
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.
dont delete it line...