class_docstr: !
  @brief Distance metric performs distance calculation between two points in line with encapsulated function, for
          example, euclidean distance or chebyshev distance, or even user-defined.
  
  @details
  
  Example of Euclidean distance metric:
  @code
      metric = distance_metric(type_metric.EUCLIDEAN)
      distance = metric([1.0, 2.5], [-1.2, 3.4])
  @endcode
  
  Example of Chebyshev distance metric:
  @code
      metric = distance_metric(type_metric.CHEBYSHEV)
      distance = metric([0.0, 0.0], [2.5, 6.0])
  @endcode
  
  In following example additional argument should be specified (generally, 'degree' is a optional argument that is
   equal to '2' by default) that is specific for Minkowski distance:
  @code
      metric = distance_metric(type_metric.MINKOWSKI, degree=4)
      distance = metric([4.0, 9.2, 1.0], [3.4, 2.5, 6.2])
  @endcode
  
  User may define its own function for distance calculation. In this case input is two points, for example, you
  want to implement your own version of Manhattan distance:
  @code
      from pyclustering.utils.metric import distance_metric, type_metric
  
      def my_manhattan(point1, point2):
          dimension = len(point1)
          result = 0.0
          for i in range(dimension):
              result += abs(point1[i] - point2[i]) * 0.1
          return result
  
      metric = distance_metric(type_metric.USER_DEFINED, func=my_manhattan)
      distance = metric([2.0, 3.0], [1.0, 3.0])
  @endcode
class_docstr_tok: ["!","@","brief","Distance","metric","performs","distance","calculation","between","two","points","in","line","with","encapsulated","function",",","for","example",",","euclidean","distance","or","chebyshev","distance",",","or","even","user-defined",".","@","details","Example","of","Euclidean","distance","metric",":","@","code","metric","=","distance_metric","(","type_metric.EUCLIDEAN",")","distance","=","metric","(","[","1.0",",","2.5","]",",","[","-1.2",",","3.4","]",")","@","endcode","Example","of","Chebyshev","distance","metric",":","@","code","metric","=","distance_metric","(","type_metric.CHEBYSHEV",")","distance","=","metric","(","[","0.0",",","0.0","]",",","[","2.5",",","6.0","]",")","@","endcode","In","following","example","additional","argument","should","be","specified","(","generally",",","'degree","'","is","a","optional","argument","that","is","equal","to","'","2","'","by","default",")","that","is","specific","for","Minkowski","distance",":","@","code","metric","=","distance_metric","(","type_metric.MINKOWSKI",",","degree=4",")","distance","=","metric","(","[","4.0",",","9.2",",","1.0","]",",","[","3.4",",","2.5",",","6.2","]",")","@","endcode","User","may","define","its","own","function","for","distance","calculation",".","In","this","case","input","is","two","points",",","for","example",",","you","want","to","implement","your","own","version","of","Manhattan","distance",":","@","code","from","pyclustering.utils.metric","import","distance_metric",",","type_metric","def","my_manhattan","(","point1",",","point2",")",":","dimension","=","len","(","point1",")","result","=","0.0","for","i","in","range","(","dimension",")",":","result","+=","abs","(","point1","[","i","]","-","point2","[","i","]",")","*","0.1","return","result","metric","=","distance_metric","(","type_metric.USER_DEFINED",",","func=my_manhattan",")","distance","=","metric","(","[","2.0",",","3.0","]",",","[","1.0",",","3.0","]",")","@","endcode"]
docstr: !
  @brief Creates distance metric instance for calculation distance between two points.
  
  @param[in] metric_type (type_metric):
  @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'numpy_usage' 'func' and corresponding additional argument for
              for specific metric types).
  
  <b>Keyword Args:</b><br>
      - func (callable): Callable object with two arguments (point #1 and point #2) or (object #1 and object #2) in case of numpy usage.
                          This argument is used only if metric is 'type_metric.USER_DEFINED'.
      - degree (numeric): Only for 'type_metric.MINKOWSKI' - degree of Minkowski equation.
      - max_range (array_like): Only for 'type_metric.GOWER' - max range in each dimension. 'data' can be used
                                 instead of this parameter.
      - data (array_like): Only for 'type_metric.GOWER' - input data that used for 'max_range' calculation.
                           'max_range' can be used instead of this parameter.
      - numpy_usage (bool): If True then numpy is used for calculation (by default is False).
docstr_tok: ["!","@","brief","Creates","distance","metric","instance","for","calculation","distance","between","two","points",".","@","param","[","in","]","metric_type","(","type_metric",")",":","@","param","[","in","]","*","*","kwargs",":","Arbitrary","keyword","arguments","(","available","arguments",":","'numpy_usage","'","'func","'","and","corresponding","additional","argument","for","for","specific","metric","types",")",".","<","b",">","Keyword","Args",":","<","\/b",">","<","br",">","-","func","(","callable",")",":","Callable","object","with","two","arguments","(","point","#","1","and","point","#","2",")","or","(","object","#","1","and","object","#","2",")","in","case","of","numpy","usage",".","This","argument","is","used","only","if","metric","is","'type_metric.USER_DEFINED","'",".","-","degree","(","numeric",")",":","Only","for","'type_metric.MINKOWSKI","'","-","degree","of","Minkowski","equation",".","-","max_range","(","array_like",")",":","Only","for","'type_metric.GOWER","'","-","max","range","in","each","dimension",".","'data","'","can","be","used","instead","of","this","parameter",".","-","data","(","array_like",")",":","Only","for","'type_metric.GOWER","'","-","input","data","that","used","for","'max_range","'","calculation",".","'max_range","'","can","be","used","instead","of","this","parameter",".","-","numpy_usage","(","bool",")",":","If","True","then","numpy","is","used","for","calculation","(","by","default","is","False",")","."]
code: def __init__(self, metric_type, **kwargs):
      """!
      @brief Creates distance metric instance for calculation distance between two points.
  
      @param[in] metric_type (type_metric):
      @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'numpy_usage' 'func' and corresponding additional argument for
                  for specific metric types).
  
      <b>Keyword Args:</b><br>
          - func (callable): Callable object with two arguments (point #1 and point #2) or (object #1 and object #2) in case of numpy usage.
                              This argument is used only if metric is 'type_metric.USER_DEFINED'.
          - degree (numeric): Only for 'type_metric.MINKOWSKI' - degree of Minkowski equation.
          - max_range (array_like): Only for 'type_metric.GOWER' - max range in each dimension. 'data' can be used
                                     instead of this parameter.
          - data (array_like): Only for 'type_metric.GOWER' - input data that used for 'max_range' calculation.
                               'max_range' can be used instead of this parameter.
          - numpy_usage (bool): If True then numpy is used for calculation (by default is False).
  
      """
      self.__type = metric_type
      self.__args = kwargs
      self.__func = self.__args.get("func", None)
      self.__numpy = self.__args.get("numpy_usage", False)
  
      self.__calculator = self.__create_distance_calculator()
  
imports: import numpy
  from enum import IntEnum
label_desc: Use image node_id 1 to create a new distance_metric object  with example: obj = distance_metric(metric_type)