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

Conversation

jorisvandenbossche
Copy link
Member

Closes #9895

This just exposes a few of our testing functions publicly in pandas.testing.

  • Alternative is to move the full testing module to pandas.testing (the actual code), question is then however how to only expose a subset of it publicly.
  • I now only included the 3 most obvious ones (frame, series, index). Are there other ones that people would want to use? (the sparse ones?)
  • We have quite a lot of keywords to those assert_* functions. We could op to only expose a subset of those publicly (redefining in pandas.testing instead of importing and only passing subset of the kwargs through)

@jorisvandenbossche jorisvandenbossche added this to the 0.20.0 milestone Apr 14, 2017
@jorisvandenbossche jorisvandenbossche added API Design Testing pandas testing functions or related to the test suite labels Apr 14, 2017
@jreback
Copy link
Contributor

jreback commented Apr 14, 2017

lgtm. need some whatsnew docs (but can prob add onto the pandas.errors section maybe (rename it though)

@codecov
Copy link

codecov bot commented Apr 14, 2017

Codecov Report

Merging #16003 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16003      +/-   ##
==========================================
+ Coverage   91.02%   91.02%   +<.01%     
==========================================
  Files         145      146       +1     
  Lines       50391    50394       +3     
==========================================
+ Hits        45870    45873       +3     
  Misses       4521     4521
Flag Coverage Δ
#multiple 88.83% <100%> (ø) ⬆️
#single 40.33% <100%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/util/testing.py 81.01% <ø> (ø) ⬆️
pandas/testing.py 100% <100%> (ø)
pandas/__init__.py 92.85% <100%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d9451d...bb65d12. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 14, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@1f812e3). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #16003   +/-   ##
=========================================
  Coverage          ?      91%           
=========================================
  Files             ?      147           
  Lines             ?    50422           
  Branches          ?        0           
=========================================
  Hits              ?    45887           
  Misses            ?     4535           
  Partials          ?        0
Flag Coverage Δ
#multiple 88.81% <100%> (?)
#single 40.32% <100%> (?)
Impacted Files Coverage Δ
pandas/util/testing.py 81.01% <ø> (ø)
pandas/testing.py 100% <100%> (ø)
pandas/__init__.py 92.85% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f812e3...1bf8a93. Read the comment docs.

@jorisvandenbossche
Copy link
Member Author

I did a quick search for which pandas.util.testing functionality is used by other projects (apart from the main 3 assert_frame/series/index_equal ones):

  • dask:
    • makeDataFrame, makeTimeDataFrame, makeMissingDataframe, makeDateIndex, makeTimedeltaIndex, makeTimeSeries
    • assertRaisesRegexp, assertRaises, assert_produces_warning, assert_numpy_array_equal
  • statsmodels:
    • makeDataFrame, makeTimeDataFrame, assert_produces_warning
  • zipline:
    • assert_panel_equal (but since panel is deprecated, this is less important)

I am not sure whether we want to commit to keeping some of the make.. functions stable? (and projects can of course keep using them at own risk as it is now)

For the raises and warning ones, since those are not pandas-objects specific test functions, I would also not include them in the official public ones?

@jreback
Copy link
Contributor

jreback commented Apr 15, 2017

xref #15911

I think we will create a pandas.util.benchmarks sub-module that holds things like make* which we can make public, keeping pandas.util.testing private (or dask can reach in, doesn't really matter). I don't think these need to be really public anyhow.

cc @mrocklin

@jreback
Copy link
Contributor

jreback commented Apr 15, 2017

makeDataFrame in camelCase is a really old naming convention anyhow.

@jreback
Copy link
Contributor

jreback commented Apr 16, 2017

pls rebase. lgtm. let's merge and can always amend/add to this.

@@ -166,6 +166,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

@jorisvandenbossche jorisvandenbossche merged commit 8daf9a7 into pandas-dev:master Apr 16, 2017
@Rufflewind
Copy link
Contributor

Does this mean pytest is now a dependency of pandas?

I just upgraded pandas through AUR and got this error message:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pandas/__init__.py", line 60, in <module>
    import pandas.testing
  File "/usr/lib/python3.6/site-packages/pandas/testing.py", line 7, in <module>
    from pandas.util.testing import (
  File "/usr/lib/python3.6/site-packages/pandas/util/testing.py", line 22, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

I do not have pytest installed. Is it now required?

@jreback
Copy link
Contributor

jreback commented Apr 23, 2017

pytest is not required unless you are actually testing things - this is fixed in the rc

unclear what version you actually have

@Rufflewind
Copy link
Contributor

I had 1b52b12 installed. Looks like it was fixed in 70ae817 . Re-reinstalled Pandas and it seems to import without pytest just fine now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants