Skip to content

Commit

Permalink
Adding test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
obriente committed Mar 4, 2020
1 parent 3ee10f2 commit 8198068
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/openfermion/measurements/_fermion_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _loop_iterator(func, *params):
looped = True
num_loops += 1
if num_loops > MAX_LOOPS:
raise ValueError('Number of loops exceeded maximum allowed.')
raise ValueError('Number of loops exceeded maximum allowed.') # pragma: no cover
generator = func(*params)


Expand All @@ -138,8 +138,8 @@ def _gen_partitions(labels, min_size=4):
labels(list): list to be partitioned
'''
if len(labels) == 1:
yield (labels, )
return
yield (labels, ) # pragma: no cover
return # pragma: no cover
partitions = (labels[:len(labels)//2], labels[len(labels)//2:])
while True:
yield partitions
Expand Down
6 changes: 6 additions & 0 deletions src/openfermion/measurements/_fermion_partitioning_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

class TestPairWithin(unittest.TestCase):

def test_zero(self):
count = 0
for _ in pair_within([]):
count += 1
self.assertEqual(count, 0)

def test_pair(self):
labels = [0, 1]
pairings_list = [
Expand Down

0 comments on commit 8198068

Please sign in to comment.