@@ -61,6 +61,19 @@ void main() {
6161 expect (result, hasLength (3 ));
6262 });
6363
64+ test (
65+ 'should find the closest neighbours for Iterable [2.79, -9.15, 6.56, -18.59, 13.53], leafSize=1' ,
66+ () {
67+ final kdTree = KDTree (DataFrame (data, headerExists: false ), leafSize: 1 );
68+ final sample = [2.79 , - 9.15 , 6.56 , - 18.59 , 13.53 ];
69+ final result = kdTree.queryIterable (sample, 3 ).toList ();
70+
71+ expect (result[0 ].index, 12 );
72+ expect (result[1 ].index, 4 );
73+ expect (result[2 ].index, 18 );
74+ expect (result, hasLength (3 ));
75+ });
76+
6477 test (
6578 'should find the closest neighbours for [2.79, -9.15, 6.56, -18.59, 13.53], leafSize=3, splitStrategy=KDTreeSplitStrategy.largestVariance' ,
6679 () {
@@ -235,6 +248,32 @@ void main() {
235248 expect ((kdTree as KDTreeImpl ).searchIterationCount, 13 );
236249 });
237250
251+ test (
252+ 'should find the closest neighbours for [2.79, -9.15, 6.56, -18.59, 13.53], leafSize=3, manhatten distance' ,
253+ () {
254+ final kdTree = KDTree (DataFrame (data, headerExists: false ), leafSize: 3 );
255+ final sample = Vector .fromList ([2.79 , - 9.15 , 6.56 , - 18.59 , 13.53 ]);
256+ final result = kdTree.query (sample, 3 , Distance .manhattan).toList ();
257+
258+ expect (result[0 ].index, 12 );
259+ expect (result[1 ].index, 4 );
260+ expect (result[2 ].index, 13 );
261+ expect (result, hasLength (3 ));
262+ });
263+
264+ test (
265+ 'should find the closest neighbours for [2.79, -9.15, 6.56, -18.59, 13.53], leafSize=1, manhatten distance' ,
266+ () {
267+ final kdTree = KDTree (DataFrame (data, headerExists: false ), leafSize: 1 );
268+ final sample = Vector .fromList ([2.79 , - 9.15 , 6.56 , - 18.59 , 13.53 ]);
269+ final result = kdTree.query (sample, 3 , Distance .manhattan).toList ();
270+
271+ expect (result[0 ].index, 12 );
272+ expect (result[1 ].index, 4 );
273+ expect (result[2 ].index, 13 );
274+ expect (result, hasLength (3 ));
275+ });
276+
238277 test ('should throw an exception if the query point is of invalid length' ,
239278 () {
240279 final kdTree = KDTree (DataFrame (data, headerExists: false ), leafSize: 3 );
0 commit comments