From 2bcb163440164f0c2793b01012bdb3bf77fe8e59 Mon Sep 17 00:00:00 2001 From: "John W. O'Brien" Date: Sun, 8 Dec 2013 23:25:25 -0500 Subject: [PATCH 1/2] BUG: Work-around a numpy regression numpy 1.7.0 erroneously raises IndexError instead of ValueError from ndarray.item() when the array is not of length 1. This can be seen as a failure of computation.tests.test_eval.TestScope.test_global_scope for the cases that engine='numexpr'. Absorb the splatter from this regression by explicitly catching the erroneous IndexError. --- pandas/computation/align.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/computation/align.py b/pandas/computation/align.py index b61169e1f55e0..71adb74492425 100644 --- a/pandas/computation/align.py +++ b/pandas/computation/align.py @@ -249,6 +249,9 @@ def _reconstruct_object(typ, obj, axes, dtype): try: ret = ret_value.item() - except ValueError: + except (ValueError, IndexError): + # XXX: we catch IndexError to absorb a + # regression in numpy 1.7.0 + # fixed by numpy/numpy@04b89c63 ret = ret_value return ret From ba3fbb896e7b0da3d3fc8d59e53ac853d9f764ba Mon Sep 17 00:00:00 2001 From: "John W. O'Brien" Date: Mon, 9 Dec 2013 14:40:44 -0500 Subject: [PATCH 2/2] DOC: Mention #5666 in 0.13.0 release notes --- doc/source/release.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/release.rst b/doc/source/release.rst index 97b86703e73b8..8a911a6e41d0b 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -820,6 +820,7 @@ Bug Fixes - Bug fix in apply when using custom function and objects are not mutated (:issue:`5545`) - Bug in selecting from a non-unique index with ``loc`` (:issue:`5553`) - Bug in groupby returning non-consistent types when user function returns a ``None``, (:issue:`5592`) + - Work around regression in numpy 1.7.0 which erroneously raises IndexError from ``ndarray.item`` (:issue:`5666`) pandas 0.12.0 -------------