Skip to content

CLN: Improve Exceptions in core/frame and testing in test_frame and test_multilievel #4732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ pandas 0.13
when the key is a column
- Support for using a ``DatetimeIndex/PeriodsIndex`` directly in a datelike calculation
e.g. s-s.index (:issue:`4629`)
- Better/cleaned up exceptions in core/common, io/excel and core/format.
(:issue:`4721`, :issue:`3954`)
- Better/cleaned up exceptions in core/common, io/excel and core/format
(:issue:`4721`, :issue:`3954`), as well as cleaned up test cases in
tests/test_frame, tests/test_multilevel (:issue:`4732`).

**API Changes**

Expand Down Expand Up @@ -143,9 +144,10 @@ pandas 0.13
now returns a ``MultiIndex`` rather than an ``Index``. (:issue:`4039`)

- Infer and downcast dtype if ``downcast='infer'`` is passed to ``fillna/ffill/bfill`` (:issue:`4604`)
- Factored out excel_value_to_python_value from ExcelFile::_parse_excel (:issue:`4589`)
- ``__nonzero__`` for all NDFrame objects, will now raise a ``ValueError``, this reverts back to (:issue:`1073`, :issue:`4633`)
behavior.
- ``DataFrame.update()`` no longer raises a ``DataConflictError``, it now
will raise a ``ValueError`` instead (if necessary) (:issue:`4732`)

**Internal Refactoring**

Expand Down
19 changes: 19 additions & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,25 @@ def __and__(self, other):
else:
from collections import OrderedDict, Counter

if PY3:
def raise_with_traceback(exc, traceback=Ellipsis):
if traceback == Ellipsis:
_, _, traceback = sys.exc_info()
raise exc.with_traceback(traceback)
else:
# this version of raise is a syntax error in Python 3
exec("""
def raise_with_traceback(exc, traceback=Ellipsis):
if traceback == Ellipsis:
_, _, traceback = sys.exc_info()
raise exc, None, traceback
""")

raise_with_traceback.__doc__ = (
"""Raise exception with existing traceback.
If traceback is not passed, uses sys.exc_info() to get traceback."""
)

# http://stackoverflow.com/questions/4126348
# Thanks to @martineau at SO

Expand Down
5 changes: 2 additions & 3 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,8 @@ def __init__(self, obj, path_or_buf, sep=",", na_rep='', float_format=None,

# validate mi options
if self.has_mi_columns:
# guarded against in to_csv itself
if cols is not None: # pragma: no cover
raise AssertionError("cannot specify cols with a multi_index on the columns")
if cols is not None:
raise TypeError("cannot specify cols with a MultiIndex on the columns")

if cols is not None:
if isinstance(cols,Index):
Expand Down
Loading