From 9aaee8ac7e83ff01e8aab0ba5855a1dd1a642a03 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 26 Aug 2021 16:31:51 +0800 Subject: [PATCH] Modify api description (#665) Signed-off-by: yhmo --- pymilvus/client/grpc_handler.py | 1 + pymilvus/client/stub.py | 17 ++++++++++------- pymilvus/orm/pymilvus_orm/utility.py | 23 +++++++++++++---------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index b91f48aa7..e14c563d0 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1163,6 +1163,7 @@ def calc_distance(self, vectors_left, vectors_right, params, timeout=30, **kwarg params = params or {"metric": config.CALC_DIST_METRIC} if "metric_type" in params.keys(): params["metric"] = params["metric_type"] + params.pop("metric_type") req = Prepare.calc_distance_request(vectors_left, vectors_right, params) future = self._stub.CalcDistance.future(req, wait_for_ready=True, timeout=timeout) diff --git a/pymilvus/client/stub.py b/pymilvus/client/stub.py index fb832a0bc..4a0e8f9e3 100644 --- a/pymilvus/client/stub.py +++ b/pymilvus/client/stub.py @@ -1078,16 +1078,19 @@ def calc_distance(self, vectors_left, vectors_right, params=None, timeout=None, or `{"bin_vectors": [b'\x94', b'N', ... b'\xca']}` - :param params: parameters, currently only support "metric_type", default value is "L2" - extra parameter for "L2" distance: "sqrt", true or false, default is false - extra parameter for "HAMMING" and "TANIMOTO": "dim", set this value if dimension is not a multiple of 8, otherwise the dimension will be calculted by list length + :param params: key-value pair parameters + Key: "metric_type"/"metric" Value: "L2"/"IP"/"HAMMING"/"TANIMOTO", default is "L2", + Key: "sqrt" Value: true or false, default is false Only for "L2" distance + Key: "dim" Value: set this value if dimension is not a multiple of 8, + otherwise the dimension will be calculted by list length, + only for "HAMMING" and "TANIMOTO" :type params: dict - There are examples of supported metric_type: - `{"metric_type": "L2"}` + Examples of supported metric_type: + `{"metric_type": "L2", "sqrt": true}` `{"metric_type": "IP"}` - `{"metric_type": "HAMMING"}` + `{"metric_type": "HAMMING", "dim": 17}` `{"metric_type": "TANIMOTO"}` - Note: "L2", "IP", "HAMMING", "TANIMOTO" are case insensitive + Note: metric type are case insensitive :return: 2-d array distances :rtype: list[list[int]] for "HAMMING" or list[list[float]] for others diff --git a/pymilvus/orm/pymilvus_orm/utility.py b/pymilvus/orm/pymilvus_orm/utility.py index 2e215fe8a..a55178b7e 100644 --- a/pymilvus/orm/pymilvus_orm/utility.py +++ b/pymilvus/orm/pymilvus_orm/utility.py @@ -314,16 +314,19 @@ def calc_distance(vectors_left, vectors_right, params=None, timeout=None, using= or `{"bin_vectors": [b'\x94', b'N', ... b'\xca']}` - :param params: parameters, currently only support "metric_type", default value is "L2" - extra parameter for "L2" distance: "sqrt", true or false, default is false - extra parameter for "HAMMING" and "TANIMOTO": "dim", set this value if dimension is not a multiple of 8, otherwise the dimension will be calculted by list length - :type params: dict - There are examples of supported metric_type: - `{"metric_type": "L2"}` - `{"metric_type": "IP"}` - `{"metric_type": "HAMMING"}` - `{"metric_type": "TANIMOTO"}` - Note: "L2", "IP", "HAMMING", "TANIMOTO" are case insensitive + :param params: key-value pair parameters + Key: "metric_type"/"metric" Value: "L2"/"IP"/"HAMMING"/"TANIMOTO", default is "L2", + Key: "sqrt" Value: true or false, default is false Only for "L2" distance + Key: "dim" Value: set this value if dimension is not a multiple of 8, + otherwise the dimension will be calculted by list length, + only for "HAMMING" and "TANIMOTO" + :type params: dict + Examples of supported metric_type: + `{"metric_type": "L2", "sqrt": true}` + `{"metric_type": "IP"}` + `{"metric_type": "HAMMING", "dim": 17}` + `{"metric_type": "TANIMOTO"}` + Note: metric type are case insensitive :return: 2-d array distances :rtype: list[list[int]] for "HAMMING" or list[list[float]] for others