code: def test_map(pickle_module):
      ty = pa.map_(pa.string(), pa.int8())
      v = [("a", 1), ("b", 2)]
      s = pa.scalar(v, type=ty)
  
      assert len(s) == 2
      assert isinstance(s, pa.MapScalar)
      assert isinstance(s.values, pa.Array)
      assert repr(s) == "<pyarrow.MapScalar: [('a', 1), ('b', 2)]>"
      assert s.values.to_pylist() == [
          {"key": "a", "value": 1},
          {"key": "b", "value": 2},
      ]
  
      # test iteration
      for i, j in zip(s, v):
          assert i == j
  
      # test iteration with missing values
      for _ in pa.scalar(None, type=ty):
          pass
  
      assert s.as_py() == v
      assert s[1] == (
          pa.scalar("b", type=pa.string()),
          pa.scalar(2, type=pa.int8()),
      )
      assert s[-1] == s[1]
      assert s[-2] == s[0]
      with pytest.raises(IndexError):
          s[-3]
      with pytest.raises(IndexError):
          s[2]
  
      restored = pickle_module.loads(pickle_module.dumps(s))
      assert restored.equals(s)
  
imports: import datetime
  import decimal
  import pytest
  import sys
  import weakref
  import numpy
  import pyarrow
  import pyarrow.compute
  from pyarrow.tests import util
label_desc: Use image node_id 38 for calling a global function with example usage: test_map(pickle_module) without return types