From b1c5972d4a23fe7dda0dbfcb6f505b4333637ef4 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 6 Aug 2019 19:22:29 -0700 Subject: [PATCH 1/6] CLN: remove nested error handling --- pandas/core/internals/blocks.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 8c3cf7cc51495..f3d848f937928 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1374,20 +1374,8 @@ def func(cond, values, other): # np.where will cast integer array to floats in this case other = self._try_coerce_args(other) - try: - fastres = expressions.where(cond, values, other) - return fastres - except Exception as detail: - if errors == "raise": - raise TypeError( - "Could not operate [{other!r}] with block values " - "[{detail!s}]".format(other=other, detail=detail) - ) - else: - # return the values - result = np.empty(values.shape, dtype="float64") - result.fill(np.nan) - return result + fastres = expressions.where(cond, values, other) + return fastres if cond.ravel().all(): result = values From fe7b9e4e8ece0c0964a6dceea7359103be7f07c0 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 6 Aug 2019 20:18:28 -0700 Subject: [PATCH 2/6] un-xfail --- pandas/tests/series/test_analytics.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 3a5a387b919be..8d2de2e0caea5 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1482,16 +1482,7 @@ def test_value_counts_with_nan(self): @pytest.mark.parametrize( "dtype", - [ - "int_", - "uint", - "float_", - "unicode_", - "timedelta64[h]", - pytest.param( - "datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=True) - ), - ], + ["int_", "uint", "float_", "unicode_", "timedelta64[h]", "datetime64[D]"], ) def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): cat_array = np.array([1, 2, 3, 4, 5], dtype=np.dtype(dtype)) From d712569dedde8ed949690b4cc89882c4e3316219 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 6 Aug 2019 20:26:58 -0700 Subject: [PATCH 3/6] make xfail conditional --- pandas/tests/series/test_analytics.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 8d2de2e0caea5..07d33e7375b4e 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -5,6 +5,7 @@ from numpy import nan import pytest +from pandas.compat import PY35 import pandas.util._test_decorators as td import pandas as pd @@ -1482,7 +1483,17 @@ def test_value_counts_with_nan(self): @pytest.mark.parametrize( "dtype", - ["int_", "uint", "float_", "unicode_", "timedelta64[h]", "datetime64[D]"], + [ + "int_", + "uint", + "float_", + "unicode_", + "timedelta64[h]", + pytest.param( + "datetime64[D]", + marks=pytest.mark.xfail(not PY35, reason="GH#7996", strict=True), + ), + ], ) def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): cat_array = np.array([1, 2, 3, 4, 5], dtype=np.dtype(dtype)) From 1930c22a9eb06b0d251f57dc828beef8cef6b6fd Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 7 Aug 2019 07:36:25 -0700 Subject: [PATCH 4/6] restore xfail --- pandas/tests/series/test_analytics.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 07d33e7375b4e..ed1f823e2a5dc 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1490,8 +1490,7 @@ def test_value_counts_with_nan(self): "unicode_", "timedelta64[h]", pytest.param( - "datetime64[D]", - marks=pytest.mark.xfail(not PY35, reason="GH#7996", strict=True), + "datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=True) ), ], ) From c5cee5e2a800a4ff7b32a1cb10333ad6fc121fe2 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 7 Aug 2019 07:36:45 -0700 Subject: [PATCH 5/6] unused import --- pandas/tests/series/test_analytics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index ed1f823e2a5dc..3a5a387b919be 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -5,7 +5,6 @@ from numpy import nan import pytest -from pandas.compat import PY35 import pandas.util._test_decorators as td import pandas as pd From 4a1e1753602d6b5b787379fec5a0247d076b32e0 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 7 Aug 2019 08:17:23 -0700 Subject: [PATCH 6/6] dummy to force CI