code: def test_kvp_add_middle(data):
      "Test that KVP works in the middle of an array."
      ks = np.full(100, -1, dtype=np.int32)
      vs = np.full(100, np.nan)
  
      n = 25
      avs = []
  
      values = st.floats(-100, 100)
      for k in range(25):
          v = data.draw(values)
          avs.append(v)
          n = kvp_minheap_insert(25, n, 10, k, v, ks, vs)
  
      assert n == 35
      # all the keys
      assert all(ks[25:35] >= 0)
      # value is the smallest
      assert vs[25] == np.min(vs[25:35])
      # highest-ranked keys
      assert all(np.sort(vs[25:35]) == np.sort(avs)[15:])
  
      # early is untouched
      assert all(ks[:25] == -1)
      assert all(np.isnan(vs[:25]))
      assert all(ks[35:] == -1)
      assert all(np.isnan(vs[35:]))
  
file_path: lkpy/tests/test_util_accum.py
imports: import numpy
  from lenskit.util.accum import kvp_minheap_insert, kvp_minheap_sort
  from hypothesis import given, assume, settings
  import hypothesis.strategies
  import hypothesis.extra.numpy
label_desc: Use image node_id 5 for calling a global function with example usage: test_kvp_add_middle(data) without return types