Skip to content

API: expose public testing functions in pandas.testing (GH9895) #16003

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 3 commits into from
Apr 16, 2017
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
10 changes: 10 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1886,3 +1886,13 @@ Working with options
get_option
set_option
option_context

Testing functions
~~~~~~~~~~~~~~~~~

.. autosummary::
:toctree: generated/

testing.assert_frame_equal
testing.assert_series_equal
testing.assert_index_equal
19 changes: 17 additions & 2 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ Commonly called 'unix epoch' or POSIX time. This was the previous default, so th

.. _whatsnew_0200.enhancements.errors:

pandas errors
^^^^^^^^^^^^^
``pandas.errors``
^^^^^^^^^^^^^^^^^

We are adding a standard public module for all pandas exceptions & warnings ``pandas.errors``. (:issue:`14800`). Previously
these exceptions & warnings could be imported from ``pandas.core.common`` or ``pandas.io.common``. These exceptions and warnings
Expand All @@ -170,6 +170,21 @@ The following are now part of this API:
'UnsortedIndexError',
'UnsupportedFunctionCall']


.. _whatsnew_0200.enhancements.testing:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think both of these should be moved to the privacy sub-section now.

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, will need some general editing


``pandas.testing``
^^^^^^^^^^^^^^^^^^

We are adding a standard module that exposes the public testing functions in ``pandas.testing``(:issue:`9895`). Those functions can be used when writing tests for functionality using pandas objects.

The following testing functions are now part of this API:

- :func:`testing.assert_frame_equal`
- :func:`testing.assert_series_equal`
- :func:`testing.assert_index_equal`


.. _whatsnew_0200.enhancements.groupby_access:

Groupby Enhancements
Expand Down
1 change: 1 addition & 0 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
from pandas.util.print_versions import show_versions
from pandas.io.api import *
from pandas.util._tester import test
import pandas.testing

# extension module deprecations
from pandas.util.depr_module import _DeprecatedModule
Expand Down
8 changes: 8 additions & 0 deletions pandas/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# flake8: noqa

"""
Public testing utility functions.
"""

from pandas.util.testing import (
assert_frame_equal, assert_series_equal, assert_index_equal)
13 changes: 12 additions & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestPDApi(Base, tm.TestCase):
# top-level sub-packages
lib = ['api', 'compat', 'core',
'indexes', 'errors', 'pandas',
'plotting', 'test', 'tools', 'tseries',
'plotting', 'test', 'testing', 'tools', 'tseries',
'util', 'options', 'io']

# these are already deprecated; awaiting removal
Expand Down Expand Up @@ -128,6 +128,17 @@ def test_api(self):
self.check(api, self.allowed)


class TestTesting(Base):

funcs = ['assert_frame_equal', 'assert_series_equal',
'assert_index_equal']

def test_testing(self):

from pandas import testing
self.check(testing, self.funcs)


class TestDatetoolsDeprecation(tm.TestCase):

def test_deprecation_access_func(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def assert_index_equal(left, right, exact='equiv', check_names=True,
right : Index
exact : bool / string {'equiv'}, default False
Whether to check the Index class, dtype and inferred_type
are identical. If 'equiv', then RangeIndex can be substitued for
are identical. If 'equiv', then RangeIndex can be substituted for
Int64Index as well
check_names : bool, default True
Whether to check the names attribute.
Expand Down