Skip to content

Commit

Permalink
TST: added tests for mlab.contiguous_regions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimefrio committed Feb 27, 2015
1 parent 6007164 commit 3f384aa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/matplotlib/tests/test_mlab.py
Expand Up @@ -2963,6 +2963,30 @@ def test_evaluate_equal_dim_and_num_lt(self):


#*****************************************************************

def test_contiguous_regions():
a, b, c = 3, 4, 5
# Starts and ends with True
mask = [True]*a + [False]*b + [True]*c
expected = [(0, a), (a+b, a+b+c)]
assert_equal(mlab.contiguous_regions(mask), expected)
d, e = 6, 7
# Starts with True ends with False
mask = mask + [False]*e
assert_equal(mlab.contiguous_regions(mask), expected)
# Starts with False ends with True
mask = [False]*d + mask[:-e]
expected = [(d, d+a), (d+a+b, d+a+b+c)]
assert_equal(mlab.contiguous_regions(mask), expected)
# Starts and ends with False
mask = mask + [False]*e
assert_equal(mlab.contiguous_regions(mask), expected)
# No True in mask
assert_equal(mlab.contiguous_regions([False]*5), [])
# Empty mask
assert_equal(mlab.contiguous_regions([]), [])


#*****************************************************************

if __name__ == '__main__':
Expand Down

0 comments on commit 3f384aa

Please sign in to comment.