Skip to content

Commit

Permalink
warning_optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ozak committed May 18, 2015
1 parent 7970f9c commit fab9519
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions skimage/graph/tests/test_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
a[1:-1, 1] = 0
a[1, 1:-1] = 0

warning_optional = r'|\A\Z'

def test_basic():
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(a, fully_connected=True)
costs, traceback = m.find_costs([(1, 6)])
return_path = m.traceback((7, 2))
Expand Down Expand Up @@ -56,15 +56,13 @@ def test_neg_inf():
(6, 1)]
test_neg = np.where(a == 1, -1, 0)
test_inf = np.where(a == 1, np.inf, 0)
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(test_neg, fully_connected=True)
costs, traceback = m.find_costs([(1, 6)])
return_path = m.traceback((6, 1))
assert_array_equal(costs, expected_costs)
assert_array_equal(return_path, expected_path)
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(test_inf, fully_connected=True)
costs, traceback = m.find_costs([(1, 6)])
return_path = m.traceback((6, 1))
Expand All @@ -73,8 +71,7 @@ def test_neg_inf():


def test_route():
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
return_path, cost = mcp.route_through_array(a, (1, 6), (7, 2),
geometric=True)
assert_almost_equal(cost, np.sqrt(2) / 2)
Expand All @@ -93,8 +90,7 @@ def test_route():


def test_no_diagonal():
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(a, fully_connected=False)
costs, traceback = m.find_costs([(1, 6)])
return_path = m.traceback((7, 2))
Expand Down Expand Up @@ -125,8 +121,7 @@ def test_no_diagonal():

def test_offsets():
offsets = [(1, i) for i in range(10)] + [(1, -i) for i in range(1, 10)]
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(a, offsets=offsets)
costs, traceback = m.find_costs([(1, 6)])
assert_array_equal(traceback,
Expand All @@ -152,8 +147,7 @@ def _test_random(shape):
(np.random.rand(len(shape)) * shape).astype(int)]
ends = [(np.random.rand(len(shape)) * shape).astype(int)
for i in range(4)]
optional = r'|\A\Z'
with expected_warnings(['Upgrading NumPy' + optional]):
with expected_warnings(['Upgrading NumPy' + warning_optional]):
m = mcp.MCP(a, fully_connected=True)
costs, offsets = m.find_costs(starts)
for point in [(np.random.rand(len(shape)) * shape).astype(int)
Expand Down

0 comments on commit fab9519

Please sign in to comment.