Code Duplication    Length = 27-27 lines in 2 locations

pyclustering/utils/metric.py 2 locations

@@ 214-240 (lines=27) @@
211
            raise ValueError("Unknown type of metric: '%d'", self.__type)
212
213
214
    def __create_distance_calculator_numpy(self):
215
        """!
216
        @brief Creates distance metric calculator that uses numpy.
217
218
        @return (callable) Callable object of distance metric calculator.
219
220
        """
221
        if self.__type == type_metric.EUCLIDEAN:
222
            return euclidean_distance_numpy
223
224
        elif self.__type == type_metric.EUCLIDEAN_SQUARE:
225
            return euclidean_distance_square_numpy
226
227
        elif self.__type == type_metric.MANHATTAN:
228
            return manhattan_distance_numpy
229
230
        elif self.__type == type_metric.CHEBYSHEV:
231
            return chebyshev_distance_numpy
232
233
        elif self.__type == type_metric.MINKOWSKI:
234
            return lambda object1, object2: minkowski_distance_numpy(object1, object2, self.__args.get('degree', 2))
235
236
        elif self.__type == type_metric.USER_DEFINED:
237
            return self.__func
238
239
        else:
240
            raise ValueError("Unknown type of metric: '%d'", self.__type)
241
242
243
@@ 185-211 (lines=27) @@
182
        return self.__create_distance_calculator_basic()
183
184
185
    def __create_distance_calculator_basic(self):
186
        """!
187
        @brief Creates distance metric calculator.
188
189
        @return (callable) Callable object of distance metric calculator.
190
191
        """
192
        if self.__type == type_metric.EUCLIDEAN:
193
            return euclidean_distance
194
195
        elif self.__type == type_metric.EUCLIDEAN_SQUARE:
196
            return euclidean_distance_square
197
198
        elif self.__type == type_metric.MANHATTAN:
199
            return manhattan_distance
200
201
        elif self.__type == type_metric.CHEBYSHEV:
202
            return chebyshev_distance
203
204
        elif self.__type == type_metric.MINKOWSKI:
205
            return lambda point1, point2: minkowski_distance(point1, point2, self.__args.get('degree', 2))
206
207
        elif self.__type == type_metric.USER_DEFINED:
208
            return self.__func
209
210
        else:
211
            raise ValueError("Unknown type of metric: '%d'", self.__type)
212
213
214
    def __create_distance_calculator_numpy(self):