Skip to content

Commit 22a043d

Browse files
committed
error handling when the input sample is not found in the dataset
1 parent b99dcf2 commit 22a043d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

libact/labelers/ideal_labeler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ def __init__(self, dataset, **kwargs):
2626
self.y = y
2727

2828
def label(self, feature):
29-
return self.y[np.where([np.array_equal(x, feature) for x in self.X])[0]]
29+
if np.count_nonzero([np.array_equal(x, feature) for x in self.X])==0
30+
raise ValueError("No matching sample found in the dataset.")
31+
return self.y[np.where([np.array_equal(x, feature) for x in self.X])]

0 commit comments

Comments
 (0)