Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ae6058

Browse files
committed
Remove mlab.contiguous_regions
1 parent e89fe8e commit 6ae6058

4 files changed

Lines changed: 24 additions & 36 deletions

File tree

doc/api/next_api_changes/2018-09-18-DS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ in Matplotlib 2.2 has been removed. See below for a list:
3434
- `mlab.path_length`
3535
- `mlab.cross_from_above`
3636
- `mlab.cross_from_below`
37+
- `mlab.contiguous_regions` (use `.cbook.contiguous_regions` instead)
3738
- `mlab.donothing_callback`

lib/matplotlib/mlab.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,12 +2755,3 @@ def is_closed_polygon(X):
27552755
tests if that curve is closed.
27562756
"""
27572757
return np.all(X[0] == X[-1])
2758-
2759-
2760-
@cbook.deprecated("2.2", message='Moved to matplotlib.cbook')
2761-
def contiguous_regions(mask):
2762-
"""
2763-
return a list of (ind0, ind1) such that mask[ind0:ind1].all() is
2764-
True and we cover all such regions
2765-
"""
2766-
return cbook.contiguous_regions(mask)

lib/matplotlib/tests/test_cbook.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,26 @@ class dummy():
503503
x = np.random.rand(3, 5)
504504
xnew = cbook._reshape_2D(x, 'x')
505505
assert np.shape(xnew) == (5, 3)
506+
507+
508+
def test_contiguous_regions():
509+
a, b, c = 3, 4, 5
510+
# Starts and ends with True
511+
mask = [True]*a + [False]*b + [True]*c
512+
expected = [(0, a), (a+b, a+b+c)]
513+
assert cbook.contiguous_regions(mask) == expected
514+
d, e = 6, 7
515+
# Starts with True ends with False
516+
mask = mask + [False]*e
517+
assert cbook.contiguous_regions(mask) == expected
518+
# Starts with False ends with True
519+
mask = [False]*d + mask[:-e]
520+
expected = [(d, d+a), (d+a+b, d+a+b+c)]
521+
assert cbook.contiguous_regions(mask) == expected
522+
# Starts and ends with False
523+
mask = mask + [False]*e
524+
assert cbook.contiguous_regions(mask) == expected
525+
# No True in mask
526+
assert cbook.contiguous_regions([False]*5) == []
527+
# Empty mask
528+
assert cbook.contiguous_regions([]) == []

lib/matplotlib/tests/test_mlab.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,33 +2274,6 @@ def test_evaluate_equal_dim_and_num_lt(self):
22742274
np.testing.assert_array_almost_equal(y, y_expected, 7)
22752275

22762276

2277-
def test_contiguous_regions():
2278-
a, b, c = 3, 4, 5
2279-
# Starts and ends with True
2280-
mask = [True]*a + [False]*b + [True]*c
2281-
expected = [(0, a), (a+b, a+b+c)]
2282-
with pytest.warns(MatplotlibDeprecationWarning):
2283-
assert mlab.contiguous_regions(mask) == expected
2284-
d, e = 6, 7
2285-
# Starts with True ends with False
2286-
mask = mask + [False]*e
2287-
with pytest.warns(MatplotlibDeprecationWarning):
2288-
assert mlab.contiguous_regions(mask) == expected
2289-
# Starts with False ends with True
2290-
mask = [False]*d + mask[:-e]
2291-
expected = [(d, d+a), (d+a+b, d+a+b+c)]
2292-
with pytest.warns(MatplotlibDeprecationWarning):
2293-
assert mlab.contiguous_regions(mask) == expected
2294-
# Starts and ends with False
2295-
mask = mask + [False]*e
2296-
with pytest.warns(MatplotlibDeprecationWarning):
2297-
assert mlab.contiguous_regions(mask) == expected
2298-
# No True in mask
2299-
assert mlab.contiguous_regions([False]*5) == []
2300-
# Empty mask
2301-
assert mlab.contiguous_regions([]) == []
2302-
2303-
23042277
def test_psd_onesided_norm():
23052278
u = np.array([0, 1, 2, 3, 1, 2, 1])
23062279
dt = 1.0

0 commit comments

Comments
 (0)