Skip to content

Commit

Permalink
Changed assert to ValueError
Browse files Browse the repository at this point in the history
Signed-off-by: David Davó <[email protected]>
  • Loading branch information
daviddavo committed Sep 9, 2024
1 parent b049091 commit 84497f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion recommenders/models/deeprec/DataModel/ImplicitCF.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def train_loader(self, batch_size):
"""

def sample_neg(x):
assert len(x) < self.n_items, "A user has voted in every item. Can't find a negative sample"
if len(x) >= self.n_items:
raise ValueError("A user has voted in every item. Can't find a negative sample.")
while True:
neg_id = random.randint(0, self.n_items - 1)
if neg_id not in x:
Expand Down

0 comments on commit 84497f2

Please sign in to comment.