Skip to content

Commit

Permalink
implemented 'sample' method in 'Localization'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTimperley committed Apr 1, 2018
1 parent 18642e3 commit 8ed1376
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bugzoo/localization/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def sample(self) -> FileLine:
ValueError: if there are no suspicious lines within this fault
localization.
"""
raise NotImplementedError
lines = list(self.__normalized.keys())
dist = [self.__normalized[line] for line in lines]
try:
return numpy.random.choice(lines, p=dist)
except ValueError:
raise ValueError

def without_line(self,
line: FileLine,
Expand Down

0 comments on commit 8ed1376

Please sign in to comment.