Skip to content

TST: changes AssertionErrors in core/generic/_construct_axes_from_arguments to Type/Value Errors #5311

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 1 commit into from
Oct 24, 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
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _construct_axes_from_arguments(self, args, kwargs, require_all=False):
if alias is not None:
if a in kwargs:
if alias in kwargs:
raise Exception(
raise TypeError(
"arguments are multually exclusive for [%s,%s]" % (a, alias))
continue
if alias in kwargs:
Expand All @@ -246,8 +246,8 @@ def _construct_axes_from_arguments(self, args, kwargs, require_all=False):
kwargs[a] = args.pop(0)
except (IndexError):
if require_all:
raise AssertionError(
"not enough arguments specified!")
raise TypeError(
"not enough/duplicate arguments specified!")

axes = dict([(a, kwargs.get(a)) for a in self._AXIS_ORDERS])
return axes, kwargs
Expand Down
14 changes: 6 additions & 8 deletions pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,14 +1248,12 @@ def test_transpose(self):
expected = self.panel.swapaxes('items', 'minor')
assert_panel_equal(result, expected)

## test bad aliases
# test ambiguous aliases
self.assertRaises(AssertionError, self.panel.transpose, 'minor',
maj='major', majo='items')

# test invalid kwargs
self.assertRaises(AssertionError, self.panel.transpose, 'minor',
maj='major', minor='items')
# duplicate axes
with tm.assertRaisesRegexp(TypeError, 'not enough/duplicate arguments'):
self.panel.transpose('minor', maj='major', minor='items')

with tm.assertRaisesRegexp(ValueError, 'repeated axis in transpose'):
self.panel.transpose('minor', 'major', major='minor', minor='items')

result = self.panel.transpose(2, 1, 0)
assert_panel_equal(result, expected)
Expand Down