code: def test_rankdata_object_string():
      min_rank = lambda a: [1 + sum(i < j for i in a) for j in a]
      max_rank = lambda a: [sum(i <= j for i in a) for j in a]
      ordinal_rank = lambda a: min_rank(
          [(x, i) for i, x in enumerate(a)]
      )
  
      def average_rank(a):
          return np.array(
              [(i + j) / 2.0 for i, j in zip(min_rank(a), max_rank(a))]
          )
  
      def dense_rank(a):
          b = np.unique(a)
          return np.array([1 + sum(i < j for i in b) for j in a])
  
      rankf = dict(
          min=min_rank,
          max=max_rank,
          ordinal=ordinal_rank,
          average=average_rank,
          dense=dense_rank,
      )
  
      def check_ranks(a):
          for method in "min", "max", "dense", "ordinal", "average":
              out = rankdata(a, method=method)
              assert_array_equal(out, rankf[method](a))
  
      check_ranks(np.random.uniform(size=[200]))
  
file_path: pynndescent/pynndescent/tests/test_rank.py
imports: import pytest
  import numpy
  from numpy.testing import assert_array_equal
  from pynndescent.distances import rankdata
label_desc: Use image node_id 4 for calling a global function with example usage: test_rankdata_object_string() and returns: np, np