Skip to content

CLN: raise correct error for Panel sort_values #16532

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 4 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
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
4 changes: 4 additions & 0 deletions pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,10 @@ def test_all_any_unhandled(self):
pytest.raises(NotImplementedError, self.panel.all, bool_only=True)
pytest.raises(NotImplementedError, self.panel.any, bool_only=True)

def test_sort_values(self):
pytest.raises(NotImplementedError, self.panel.sort_values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the issue reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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)


def test_sort_values(self):
pytest.raises(NotImplementedError, self.panel4d.sort_values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

pytest.raises(NotImplementedError, self.panel4d.sort_values, 'ItemA')