Skip to content

Commit

Permalink
CLN: raise correct error for Panel sort_values (pandas-dev#16532)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepicello authored and Kiv committed Jun 11, 2017
1 parent c193235 commit b9febe0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2366,9 +2366,14 @@ def add_suffix(self, suffix):
1 A 1 1
"""

def sort_values(self, by, axis=0, ascending=True, inplace=False,
def sort_values(self, by=None, axis=0, ascending=True, inplace=False,
kind='quicksort', na_position='last'):
raise AbstractMethodError(self)
"""
NOT IMPLEMENTED: do not call this method, as sorting values is not
supported for Panel objects and will raise an error.
"""
raise NotImplementedError("sort_values has not been implemented "
"on Panel or Panel4D objects.")

_shared_docs['sort_index'] = """
Sort object by labels (along an axis)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,11 @@ def test_all_any_unhandled(self):
pytest.raises(NotImplementedError, self.panel.all, bool_only=True)
pytest.raises(NotImplementedError, self.panel.any, bool_only=True)

# GH issue 15960
def test_sort_values(self):
pytest.raises(NotImplementedError, self.panel.sort_values)
pytest.raises(NotImplementedError, self.panel.sort_values, 'ItemA')


class TestLongPanel(object):
"""
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/test_panel4d.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,3 +939,8 @@ def test_rename(self):

def test_get_attr(self):
tm.assert_panel_equal(self.panel4d['l1'], self.panel4d.l1)

# GH issue 15960
def test_sort_values(self):
pytest.raises(NotImplementedError, self.panel4d.sort_values)
pytest.raises(NotImplementedError, self.panel4d.sort_values, 'ItemA')

0 comments on commit b9febe0

Please sign in to comment.