Skip to content

Commit

Permalink
CountVector: Add __iter__ convenience wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed May 4, 2015
1 parent 067bd49 commit 3e1f1c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bears/codeclone_detection/CountVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ def __repr__(self):

def __len__(self):
return len(self.count_vector)

def __iter__(self):
return iter(self.count_vector)
3 changes: 2 additions & 1 deletion bears/tests/codeclone_detection/CountVectorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ def test_weighting(self):
uut.count_reference(True, False)
self.assertEqual(uut.count_vector, [2, 2])

def test_conversion(self):
def test_conversions(self):
uut = CountVector("varname",
[lambda cursor, stack: cursor and stack],
[2])
uut.count_reference(True, True)
self.assertEqual(repr(uut), str(uut))
self.assertEqual(repr(uut), "[2]")
self.assertEqual(list(uut), [2])


if __name__ == '__main__':
Expand Down

1 comment on commit 3e1f1c3

@sils
Copy link
Member Author

@sils sils commented on 3e1f1c3 May 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reack

Please sign in to comment.