Repository: sympy/sympy
Pull request: Runtime Warning changed to an error
<!-- Please give this pull request a descriptive title. Pull requests with descriptive titles are more likely to receive reviews. Describe what you changed! A title that only references an issue number is not descriptive. -->

<!-- If this pull request fixes an issue please indicate which issue by typing "Fixes #NNNN" below. -->

Fixes #11727 


Problem statement:
RuntimeWarning: divide by zero encountered in true_divide in lambdify tests
```
$./bin/test lambdify
==================================================================== test process starts =====================================================================
executable:         /Users/aaronmeurer/anaconda3/bin/python  (3.5.2-final-0) [CPython]
architecture:       64-bit
cache:              yes
ground types:       gmpy 2.0.7
random seed:        92687094
hash randomization: on (PYTHONHASHSEED=2305149269)

sympy/utilities/tests/test_lambdify.py[65] ...........s.................../Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/numpy/__init__.py:1: RuntimeWarning: divide by zero encountered in true_divide
  """
........ssssssss..................                                              [OK]

=================================================== tests finished: 56 passed, 9 skipped, in 1.87 seconds ====================================================
```

The RuntimeWarning should not be printed. We might want to make them cause an error in the tests.

Hints from issue discussion:
Hi I'm new here. Can I work on this? Seems like I should be able to figure this out if I dig around.. Any suggestions is appreciated

Hi,
   I encountered neither an error nor an exception. If there is a real problem can you give me a reference to a file so that I can try to fix it. @asmeurer 

![screenshot from 2017-01-27 20-32-35 png 1366x768](https://cloud.githubusercontent.com/assets/6770064/22375441/0f2d33b6-e4d0-11e6-83b0-a98edbd16ddd.png)



@akshaym96 make sure you have NumPy installed. Otherwise it will just skip those tests (that's what the `s`s are in your test run. 
Hello,
I'd like to work on this issue. I'm new and looking around the codebase. What should I do to get started on this problem?
@asmeurer  Yeah I have installed numpy and got the same issue. Can please suggest some steps suggest some steps so that I can fix the problem. Which file do I need to start with?
@asmeurer Is this issue still open ? I would want to solve it if it is.
@asmeurer , I tried a fix. Is that what you expect from this test ?
![screenshot from 2017-03-07 18-45-14](https://cloud.githubusercontent.com/assets/18261500/23657911/6f3f75a2-0366-11e7-8d01-5ed9312aab30.png)

Yes, but the test should also be fixed to not fail. The original issue https://github.com/sympy/sympy/issues/11306 may be useful to read up on here. 
@asmeurer , Yeah i got it and i'm working on it, thanks. Will get back to you with a PR.

Commit message: Runtime Warning changed to an error

Patch to review:
diff --git a/sympy/utilities/tests/test_lambdify.py b/sympy/utilities/tests/test_lambdify.py
index 8749c667c587..91d8db7f4833 100644
--- a/sympy/utilities/tests/test_lambdify.py
+++ b/sympy/utilities/tests/test_lambdify.py
@@ -364,8 +364,11 @@ def test_numpy_old_matrix():
 def test_python_div_zero_issue_11306():
     if not numpy:
         skip("numpy not installed.")
-    p = Piecewise((1 / x, y < -1), (x, y <= 1), (1 / x, True))
-    lambdify([x, y], p, modules='numpy')(0, 1)
+    p = Piecewise((1 / x, y < -1), (x, y < 1), (1 / x, True))
+    f = lambdify([x, y], p, modules='numpy')
+    numpy.seterr(all='ignore')
+    assert str(float(f(0,1))) == 'inf'
+    numpy.seterr(all='raise')
 
 def test_issue9474():
     mods = [None, 'math']


Code review comments:
diff_hunk: @@ -364,8 +364,11 @@ def test_numpy_old_matrix():
 def test_python_div_zero_issue_11306():
     if not numpy:
         skip("numpy not installed.")
-    p = Piecewise((1 / x, y < -1), (x, y <= 1), (1 / x, True))
-    lambdify([x, y], p, modules='numpy')(0, 1)
+    p = Piecewise((1 / x, y < -1), (x, y < 1), (1 / x, True))
+    f = lambdify([x, y], p, modules='numpy')
+    numpy.seterr(all='ignore')
path: sympy/utilities/tests/test_lambdify.py
text: @user1:
Would it suffice to ignore divide only?


@author:
Yes, i guess so because the assert statement makes sure that the wrapper produces an output as `inf`.
Any specific cases you think it can give an error in ?