From 1f71bde558e46b3d2aa130844457ce4c2312c0ef Mon Sep 17 00:00:00 2001 From: ChunjiangZhu Date: Thu, 24 Oct 2019 12:08:53 -0400 Subject: [PATCH] python binding rangeQueries definition --- .DS_Store | Bin 10244 -> 10244 bytes python_bindings/.DS_Store | Bin 6148 -> 8196 bytes python_bindings/nmslib.cc | 22 ++++++++++++++++++++++ similarity_search/.DS_Store | Bin 8196 -> 10244 bytes 4 files changed, 22 insertions(+) diff --git a/.DS_Store b/.DS_Store index aecd4699bca1be0b246532ce5153274b69e01657..cb80f626719648302056363d4698f6ef36641e31 100644 GIT binary patch delta 16 XcmZn(XbISGN^tUC36IS}LZ3tdJwXP- delta 16 XcmZn(XbISGN^tT55s%G6LZ3tdJUs@X diff --git a/python_bindings/.DS_Store b/python_bindings/.DS_Store index e24f25391f1e09eca60c0889bd4ea55796aeee73..933c8e5a8837ffedd5c524eb8a0fc74b9d58a0b6 100644 GIT binary patch delta 147 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD6lbLH}hr%jz7$c**Q2SHn1=X zOy*(HW@lkYVaR7lo*ckBiP3cOV^()js0c%GS#VKaPJUiG$mGo?ERM{Z^LQ38b4hRm g1zbT!Zx-bE&ODi4#B;Jg4+jS$#8!sQ@jP>w0ksPrWdHyG delta 107 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jG-bU^g=(-((&E?ac;)cFYrt tCoN{@;1Fa6DgpulZXn?bQophAJM(0I8BdUI1}2C}Aj26p$Mei#1^~9Z5ZnL& diff --git a/python_bindings/nmslib.cc b/python_bindings/nmslib.cc index 980b0b8..87e8f6d 100644 --- a/python_bindings/nmslib.cc +++ b/python_bindings/nmslib.cc @@ -579,6 +579,23 @@ void exportIndex(py::module * m) { " A 1D vector of the ids of each nearest neighbour.\n" "distances: array_like.\n" " A 1D vector of the distance to each nearest neigbhour.\n") + + .def("rangeQuery", &IndexWrapper::rangeQuery, + py::arg("vector"), py::arg("radius") = 0.2, + "Finds the neighbours of a vector in the index, with distance smaller than the radius \n\n" + "Parameters\n" + "----------\n" + "vector: array_like\n" + " A 1D vector to query for.\n" + "radius: float optional\n" + " The radius\n" + "\n" + "Returns\n" + "----------\n" + "ids: array_like.\n" + " A 1D vector of the ids of each nearest neighbour.\n" + "distances: array_like.\n" + " A 1D vector of the distance to each nearest neigbhour.\n") .def("knnQueryBatch", &IndexWrapper::knnQueryBatch, py::arg("queries"), py::arg("k") = 10, py::arg("num_threads") = 0, @@ -775,6 +792,11 @@ void exportLegacyAPI(py::module * m) { py::list ids(ret[0]); return ids; }); + m->def("rangeQuery", [](py::object self, dist_t radius, py::object query) { + py::tuple ret = self.attr("rangeQuery")(query, radius); + py::list ids(ret[0]); + return ids; + }); m->def("getDataPoint", [](py::object self, size_t pos) { return self.attr("__getitem__")(pos); }); diff --git a/similarity_search/.DS_Store b/similarity_search/.DS_Store index 39e1a75684845ea2be064b481dcf9d27943f476d..9c50c20251c86dc4d8207e27de2c104e0a0196fe 100644 GIT binary patch literal 10244 zcmeHNU2GIp6h3EL=*&Rr6k6K4ENp0y3I$sJD#*`v+foX}R$BT)3uSh9XeXV{EHktH zq103jMvc*+CdMCL&=*pb2ScLx;EO*PjbLp2OHdQve39rAF^XsA&TiX*niv~JGq;(0 z?mhRMduGmjXU?420sux+iAsPl0C05JR9r~iZJNDqAGfrC%PAm=qz?_M9*?PdjOOAk z(muoYfbRj{1HK1*5BMIq6FfjU+iu(fM*ZIRfbRj{0~rt4&xbG_HjTJ+oKfe|L7h_q z5X~mG(`f9x`V$S?45AU2jx$OeYRFWHGF5a-40J08Wa_jYaplJuW$J*AW!lHJjBbU3 zZsCDpM;tK1sNee@@I7#=2khEC8ze~5pXsUJ@1wP{n@)2SGjg#ZGwIg(AH|ZYVpArFjaxRBhpV+j$=0tDx}D|?6LF9pG)6qw|L7O-C~bZl=z^FWPCG?!n)XOEa?#tmInn{`vM6kY4=HYvUu zEP0?oJFb((L5ioQq`hRe$%aYv7M+ex$u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