code: def test_rbp_perfect_k(items, k, p):
      n = len(items)
      eff_n = min(n, k)
      recs = pd.DataFrame({"item": items})
      truth = pd.DataFrame({"item": items, "rating": 1})
      truth = truth.set_index("item").sort_index()
      assert rbp(recs, truth, k=k, patience=p) == approx(
          np.sum(p ** np.arange(eff_n)) * (1 - p)
      )
  
imports: import logging
  import numpy
  import pandas
  from pytest import approx, mark
  from hypothesis import given
  import hypothesis.strategies
  import hypothesis.extra.numpy
  from lenskit.metrics.topn import rbp, _bulk_rbp
  from lenskit.topn import RecListAnalysis
  from lenskit.util.test import demo_recs
label_desc: Use image node_id 6 for calling a global function with example usage: test_rbp_perfect_k(items, k, p) without return types