Code Duplication    Length = 25-25 lines in 3 locations

tests/milvus_python_test/entity/test_search.py 3 locations

@@ 727-751 (lines=25) @@
724
        assert result[1][0].id in ids
725
        assert result[1][0].distance <= epsilon
726
727
    def _test_search_distance_tanimoto_flat_index(self, connect, binary_collection):
728
        '''
729
        target: search binary_collection, and check the result: distance
730
        method: compare the return distance value with value computed with Inner product
731
        expected: the return distance equals to the computed value
732
        '''
733
        # from scipy.spatial import distance
734
        nprobe = 512
735
        int_vectors, vectors, ids = self.init_binary_data(connect, binary_collection, nb=2)
736
        index_type = "FLAT"
737
        index_param = {
738
            "nlist": 16384,
739
            "metric_type": "TANIMOTO"
740
        }
741
        connect.create_index(binary_collection, binary_field_name, index_param)
742
        logging.getLogger().info(connect.get_collection_info(binary_collection))
743
        logging.getLogger().info(connect.get_index_info(binary_collection))
744
        query_int_vectors, query_vecs, tmp_ids = self.init_binary_data(connect, binary_collection, nb=1, insert=False)
745
        distance_0 = tanimoto(query_int_vectors[0], int_vectors[0])
746
        distance_1 = tanimoto(query_int_vectors[0], int_vectors[1])
747
        search_param = get_search_param(index_type)
748
        status, result = connect.search(binary_collection, top_k, query_vecs, params=search_param)
749
        logging.getLogger().info(status)
750
        logging.getLogger().info(result)
751
        assert abs(result[0][0].distance - min(distance_0, distance_1)) <= epsilon
752
753
    @pytest.mark.timeout(30)
754
    def test_search_concurrent_multithreads(self, connect, args):
@@ 671-695 (lines=25) @@
668
        assert result[1][0].distance <= epsilon
669
        assert result[1][0].id == ids[1]
670
671
    def _test_search_distance_superstructure_flat_index(self, connect, binary_collection):
672
        '''
673
        target: search binary_collection, and check the result: distance
674
        method: compare the return distance value with value computed with Inner product
675
        expected: the return distance equals to the computed value
676
        '''
677
        # from scipy.spatial import distance
678
        nprobe = 512
679
        int_vectors, vectors, ids = self.init_binary_data(connect, binary_collection, nb=2)
680
        index_type = "FLAT"
681
        index_param = {
682
            "nlist": 16384,
683
            "metric_type": "SUBSTRUCTURE"
684
        }
685
        connect.create_index(binary_collection, binary_field_name, index_param)
686
        logging.getLogger().info(connect.get_collection_info(binary_collection))
687
        logging.getLogger().info(connect.get_index_info(binary_collection))
688
        query_int_vectors, query_vecs, tmp_ids = self.init_binary_data(connect, binary_collection, nb=1, insert=False)
689
        distance_0 = superstructure(query_int_vectors[0], int_vectors[0])
690
        distance_1 = superstructure(query_int_vectors[0], int_vectors[1])
691
        search_param = get_search_param(index_type)
692
        status, result = connect.search(binary_collection, top_k, query_vecs, params=search_param)
693
        logging.getLogger().info(status)
694
        logging.getLogger().info(result)
695
        assert len(result[0]) == 0
696
697
    def _test_search_distance_superstructure_flat_index_B(self, connect, binary_collection):
698
        '''
@@ 615-639 (lines=25) @@
612
        res = connect.search(binary_collection, query_entities)
613
        assert abs(res[0][0].distance - min(distance_0, distance_1).astype(float)) <= epsilon
614
615
    def _test_search_distance_substructure_flat_index(self, connect, binary_collection):
616
        '''
617
        target: search binary_collection, and check the result: distance
618
        method: compare the return distance value with value computed with Inner product
619
        expected: the return distance equals to the computed value
620
        '''
621
        # from scipy.spatial import distance
622
        nprobe = 512
623
        int_vectors, vectors, ids = self.init_binary_data(connect, binary_collection, nb=2)
624
        index_type = "FLAT"
625
        index_param = {
626
            "nlist": 16384,
627
            "metric_type": "SUBSTRUCTURE"
628
        }
629
        connect.create_index(binary_collection, binary_field_name, index_param)
630
        logging.getLogger().info(connect.get_collection_info(binary_collection))
631
        logging.getLogger().info(connect.get_index_info(binary_collection))
632
        query_int_vectors, query_vecs, tmp_ids = self.init_binary_data(connect, binary_collection, nb=1, insert=False)
633
        distance_0 = substructure(query_int_vectors[0], int_vectors[0])
634
        distance_1 = substructure(query_int_vectors[0], int_vectors[1])
635
        search_param = get_search_param(index_type)
636
        status, result = connect.search(binary_collection, top_k, query_vecs, params=search_param)
637
        logging.getLogger().info(status)
638
        logging.getLogger().info(result)
639
        assert len(result[0]) == 0
640
641
    def _test_search_distance_substructure_flat_index_B(self, connect, binary_collection):
642
        '''