Skip to content

Commit

Permalink
error handling when the input sample is not found in the dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
tungen committed Dec 31, 2015
1 parent b99dcf2 commit 22a043d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libact/labelers/ideal_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ def __init__(self, dataset, **kwargs):
self.y = y

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

0 comments on commit 22a043d

Please sign in to comment.