code: def test_ninteraction():
      simple_vectors = [
          list(string.ascii_lowercase),
          random.sample(string.ascii_lowercase, 26),
          list(range(1, 27)),
      ]
  
      # vector of unique values is equivalent to rank
      for case in simple_vectors:
          data = pd.DataFrame(case)
          rank = data.rank(method="min")
          rank = rank[0].astype(int).tolist()
          rank_data = ninteraction(data)
          assert rank == rank_data
  
      # duplicates are numbered sequentially
      # data                    ids
      # [6, 6, 4, 4, 5, 5] -> [3, 3, 1, 1, 2, 2]
      for case in simple_vectors:
          rank = pd.DataFrame(case).rank(method="min")
          rank = rank[0].astype(int).repeat(2).tolist()
          rank_data = ninteraction(
              pd.DataFrame(np.array(case).repeat(2))
          )
          assert rank == rank_data
  
      # grids are correctly ranked
      data = pd.DataFrame(list(itertools.product([1, 2], range(1, 11))))
      assert ninteraction(data) == list(range(1, len(data) + 1))
      assert ninteraction(data, drop=True) == list(
          range(1, len(data) + 1)
      )
  
      # zero length dataframe
      data = pd.DataFrame()
      assert ninteraction(data) == []
  
      # dataframe with single variable
      data = pd.DataFrame({"a": ["a"]})
      assert ninteraction(data) == [1]
  
      data = pd.DataFrame({"a": ["b"]})
      assert ninteraction(data) == [1]
  
file_path: plotnine/tests/test_utils.py
imports: import itertools
  import random
  import string
  import warnings
  import numpy
  import pandas
  from plotnine._utils import _margins, add_margins, join_keys, match, ninteraction, pivot_apply, remove_missing, uniquecols
  from plotnine.data import mtcars
label_desc: Use image node_id 3 for calling a global function with example usage: test_ninteraction() without return types