Repository: pandas-dev/pandas

Issue:
some warnings not being silenced
Some comparison operations seem to escape the silencing of numpy RuntimeWarnings.  For example:

```
pd.DataFrame([0,0]).gt(pd.Series([0, np.nan]), axis=0)
pd.DataFrame([0,0]).lt(pd.Series([0, np.nan]), axis=0)
pd.DataFrame([0,0]).le(pd.Series([0, np.nan]), axis=0)
pd.DataFrame([0,0]).ge(pd.Series([0, np.nan]), axis=0)
```

all give

```
In [13]: pd.DataFrame([0,0]).gt(pd.Series([0, np.nan]), axis=0)
/home/dsm/sys/miniconda3/envs/36/lib/python3.6/site-packages/pandas/core/ops.py:1253: RuntimeWarning: invalid value encountered in greater
  result = op(x, y)
```

This is working with some timeseries data after some rolling operations, and so there are going to be lots of NaNs floating around.  It'd be nice if I didn't need to suppress them myself.

#### Output of ``pd.show_versions()``
<details>
```
In [19]: pd.show_versions()
/home/dsm/sys/miniconda3/envs/36/lib/python3.6/site-packages/xarray/core/formatting.py:16: FutureWarning: The pandas.tslib module is deprecated and will be removed in a future version.
  from pandas.tslib import OutOfBoundsDatetime

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-77-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8

pandas: 0.20.1
pytest: 3.0.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: 0.9.1
IPython: 5.3.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.5.3
html5lib: 0.999
sqlalchemy: 1.1.6
pymysql: None
psycopg2: None
jinja2: 2.9.5
s3fs: None
pandas_gbq: None
pandas_datareader: None
```
</details>


Discussion:
likely a symptom of #13145, we do some `np.errstate` wrapping on ops but apparently this case isn't
@dsm054 always welcome to look into it, if you are interested. `pandas/core/ops.py` is already sprinkled with `with np.errstate(all='ignore'):` 's, but apparently not for this case (I think it is https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L1253). 
But not fully sure how it was decided which op calls where wrapped and which not.

Resolving patch:
diff --git a/pandas/core/ops.py b/pandas/core/ops.py
--- a/pandas/core/ops.py
+++ b/pandas/core/ops.py
@@ -1250,7 +1250,8 @@ def _flex_comp_method_FRAME(op, name, str_rep=None, default_axis='columns',
                             masker=False):
     def na_op(x, y):
         try:
-            result = op(x, y)
+            with np.errstate(invalid='ignore'):
+                result = op(x, y)
         except TypeError:
             xrav = x.ravel()
             result = np.empty(x.size, dtype=bool)


Test patch:
diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py
--- a/pandas/tests/frame/test_analytics.py
+++ b/pandas/tests/frame/test_analytics.py
@@ -2073,3 +2073,16 @@ def test_n_duplicate_index(self, df_duplicates, n, order):
         result = df.nlargest(n, order)
         expected = df.sort_values(order, ascending=False).head(n)
         tm.assert_frame_equal(result, expected)
+
+    def test_series_broadcasting(self):
+        # smoke test for numpy warnings
+        # GH 16378, GH 16306
+        df = DataFrame([1.0, 1.0, 1.0])
+        df_nan = DataFrame({'A': [np.nan, 2.0, np.nan]})
+        s = Series([1, 1, 1])
+        s_nan = Series([np.nan, np.nan, 1])
+
+        with tm.assert_produces_warning(None):
+            df_nan.clip_lower(s, axis=0)
+            for op in ['lt', 'le', 'gt', 'ge', 'eq', 'ne']:
+                getattr(df, op)(s_nan, axis=0)