From ba200af409624e680acb978d3cf36fb9ae59b4e0 Mon Sep 17 00:00:00 2001 From: "John W. O'Brien" Date: Sun, 8 Dec 2013 23:25:25 -0500 Subject: [PATCH 1/4] 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 b2b7fcc3e1158..757524965bbef 100644 --- a/pandas/computation/align.py +++ b/pandas/computation/align.py @@ -251,6 +251,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 182110b4870c3bfed97abbc28b12afac96721af4 Mon Sep 17 00:00:00 2001 From: "John W. O'Brien" Date: Mon, 9 Dec 2013 14:40:44 -0500 Subject: [PATCH 2/4] 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 ------------- From 672d2b5972a02d016984a2f4785f058e26b659a8 Mon Sep 17 00:00:00 2001 From: Boris Lau Date: Mon, 12 Nov 2018 15:50:47 -0500 Subject: [PATCH 3/4] DOC: Display correct order for sections. Fix #23644 --- scripts/tests/test_validate_docstrings.py | 4 +-- scripts/validate_docstrings.py | 34 ++++++++++------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/scripts/tests/test_validate_docstrings.py b/scripts/tests/test_validate_docstrings.py index c1bdab73c2671..254162b7d1ffb 100644 --- a/scripts/tests/test_validate_docstrings.py +++ b/scripts/tests/test_validate_docstrings.py @@ -738,8 +738,8 @@ def test_bad_generic_functions(self, func): ('BadGenericDocStrings', 'unknown_section', ('Found unknown section "Unknown Section".',)), ('BadGenericDocStrings', 'sections_in_wrong_order', - ('Wrong order of sections. "See Also" should be located before ' - '"Notes"',)), + ('Sections are in the wrong order. Correct order is: Parameters, ' + 'See Also, Examples',)), ('BadSeeAlso', 'desc_no_period', ('Missing period at end of description for See Also "Series.iloc"',)), ('BadSeeAlso', 'desc_first_letter_lowercase', diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 7da77a1f60ad5..01c151884ac82 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -74,8 +74,8 @@ 'whitespace only', 'GL06': 'Found unknown section "{section}". Allowed sections are: ' '{allowed_sections}', - 'GL07': 'Wrong order of sections. "{wrong_section}" should be located ' - 'before "{goes_before}", the right order is: {sorted_sections}', + 'GL07': 'Sections are in the wrong order. Correct order is: ' + '{correct_sections}', 'SS01': 'No summary found (a short summary in a single line should be ' 'present at the beginning of the docstring)', 'SS02': 'Summary does not start with a capital letter', @@ -599,24 +599,18 @@ def validate_one(func_name): if re.match("^ *\t", line): errs.append(error('GL05', line_with_tabs=line.lstrip())) - unseen_sections = list(ALLOWED_SECTIONS) - for section in doc.section_titles: - if section not in ALLOWED_SECTIONS: - errs.append(error('GL06', - section=section, - allowed_sections=', '.join(ALLOWED_SECTIONS))) - else: - if section in unseen_sections: - section_idx = unseen_sections.index(section) - unseen_sections = unseen_sections[section_idx + 1:] - else: - section_idx = ALLOWED_SECTIONS.index(section) - goes_before = ALLOWED_SECTIONS[section_idx + 1] - errs.append(error('GL07', - sorted_sections=' > '.join(ALLOWED_SECTIONS), - wrong_section=section, - goes_before=goes_before)) - break + unexpected_sections = [section for section in doc.section_titles + if section not in ALLOWED_SECTIONS] + for section in unexpected_sections: + errs.append(error('GL06', + section=section, + allowed_sections=', '.join(ALLOWED_SECTIONS))) + + correct_order = [section for section in ALLOWED_SECTIONS + if section in doc.section_titles] + if correct_order != doc.section_titles: + errs.append(error('GL07', + correct_sections=', '.join(correct_order))) if not doc.summary: errs.append(error('SS01')) From 9a435ce8749b5c6300abc94f97e092663244e817 Mon Sep 17 00:00:00 2001 From: Boris Lau Date: Mon, 12 Nov 2018 16:01:17 -0500 Subject: [PATCH 4/4] Flake8 --- scripts/validate_docstrings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 01c151884ac82..e3bf1571acf22 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -603,14 +603,14 @@ def validate_one(func_name): if section not in ALLOWED_SECTIONS] for section in unexpected_sections: errs.append(error('GL06', - section=section, - allowed_sections=', '.join(ALLOWED_SECTIONS))) + section=section, + allowed_sections=', '.join(ALLOWED_SECTIONS))) correct_order = [section for section in ALLOWED_SECTIONS if section in doc.section_titles] if correct_order != doc.section_titles: errs.append(error('GL07', - correct_sections=', '.join(correct_order))) + correct_sections=', '.join(correct_order))) if not doc.summary: errs.append(error('SS01'))