code: def test_precision_at_k_with_ties():
      no_users, no_items = (10, 100)
  
      train, test = _generate_data(no_users, no_items)
  
      model = LightFM(loss="bpr")
      model.fit_partial(train)
  
      # Make all predictions zero
      model.user_embeddings = np.zeros_like(model.user_embeddings)
      model.item_embeddings = np.zeros_like(model.item_embeddings)
      model.user_biases = np.zeros_like(model.user_biases)
      model.item_biases = np.zeros_like(model.item_biases)
  
      k = 10
  
      precision = evaluation.precision_at_k(model, test, k=k)
  
      # Pessimistic precision with all ties
      assert precision.mean() == 0.0
  
file_path: lightfm/tests/test_evaluation.py
imports: import numpy
  import pytest
  import scipy.sparse
  from sklearn.metrics import roc_auc_score
  from lightfm.lightfm import LightFM
  from lightfm import evaluation
label_desc: Use image node_id 6 for calling a global function with example usage: test_precision_at_k_with_ties() without return types