Skip to content

Skipif no scipy #18794

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 2 commits into from
Dec 15, 2017
Merged

Skipif no scipy #18794

merged 2 commits into from
Dec 15, 2017

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Dec 15, 2017

@@ -739,8 +739,6 @@ def test_interp_rowwise(self):
expected[4] = expected[4].astype(np.float64)
assert_frame_equal(result, expected)

# scipy route
tm._skip_if_no_scipy()
Copy link
Member Author

Choose a reason for hiding this comment

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

I intentionally did not replace this with a decorator because it looks unnecessary (none of the subsequent code requires spicy)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

s = Series([np.nan, np.nan])
assert_series_equal(s.interpolate(method='polynomial', order=1), s)
assert_series_equal(s.interpolate(**kwargs), s)
Copy link
Member Author

Choose a reason for hiding this comment

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

There were a few instances where part of the function required scipy and the other part did not. I parametrized these using kwargs to give better visibility into what is being passed / skipped, especially on machines that don't have scipy installed

df = DataFrame({"A": [np.nan, np.nan, .5, .25, 0],
"B": [np.nan, -3, -3.5, np.nan, -4]})
result = df.interpolate()
expected = df.copy()
expected['B'].loc[3] = -3.75
assert_frame_equal(result, expected)

tm._skip_if_no_scipy()
Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of using kwargs for this function as noted in the subsequent comment, but it would slightly change the test given expected is a copy of the interpolation being done without scipy. The subsequent scipy interpolation is still compared back to that object for equality, which may or may not be intentional

def test_spline_extrapolate(self):
tm.skip_if_no_package(
Copy link
Member Author

Choose a reason for hiding this comment

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

As I'm adding comments I just realized that I can almost completely get rid of the tm.skip_if_no_package function as part of this change. It's practically always used used to check scipy (there's one check for pytables) and could be replaced by the skip_if_no function in the _test_decorators module. Will clean up in next push

@codecov
Copy link

codecov bot commented Dec 15, 2017

Codecov Report

Merging #18794 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18794      +/-   ##
==========================================
- Coverage   91.63%   91.62%   -0.02%     
==========================================
  Files         154      154              
  Lines       51422    51428       +6     
==========================================
- Hits        47121    47120       -1     
- Misses       4301     4308       +7
Flag Coverage Δ
#multiple 89.49% <100%> (ø) ⬆️
#single 40.83% <100%> (-0.1%) ⬇️
Impacted Files Coverage Δ
pandas/util/_test_decorators.py 94.54% <100%> (+0.66%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.68% <0%> (-0.11%) ⬇️
pandas/util/testing.py 82.91% <0%> (+0.19%) ⬆️

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 fe900cb...4aa0b7f. Read the comment docs.

@WillAyd
Copy link
Member Author

WillAyd commented Dec 15, 2017

@jreback how would you feel if we got rid of a dedicated skip_if_no_scipy decorator? The current dedicated function goes through importing the stats, sparse and interpolate subpackages. Looking at the SciPy source all three of those are available as far back as v0.6 released in 2007.

The test cases that use the existing function all seem to require just one and only one of those sub-packages, so we could either:

  1. Be explicit about the sub package required (ex: skip_if_no('scipy.stats') OR
  2. Simply do skip_if_no('scipy`), reasonably assuming the required sub-package is there

@jreback
Copy link
Contributor

jreback commented Dec 15, 2017

ok with removing extra decorators
in the one hand it is nice to have a dedicated function
if we r using it a lot but scipy skips are not so often

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. lmk when you are finished. (you mentioned might be changing the decorator)

@@ -739,8 +739,6 @@ def test_interp_rowwise(self):
expected[4] = expected[4].astype(np.float64)
assert_frame_equal(result, expected)

# scipy route
tm._skip_if_no_scipy()
Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@jreback jreback added the Testing pandas testing functions or related to the test suite label Dec 15, 2017
@jreback jreback added this to the 0.22.0 milestone Dec 15, 2017
@WillAyd
Copy link
Member Author

WillAyd commented Dec 15, 2017

I'm OK to have this merged as is. Not sure the juice is worth the squeeze yet in going back and getting rid of that decorator, so I'll defer for now.

tm.skip_if_no_package still needs to be replaced but that's already called out as a separate checklist item. While most calls of that can be replaced with the scipy decorator, there's one instance containing a max_version that isn't built out in the new module already, so I'd rather tackle that in another change.

@jreback jreback merged commit a845187 into pandas-dev:master Dec 15, 2017
@jreback
Copy link
Contributor

jreback commented Dec 15, 2017

thanks @WillAyd keep em coming!

@WillAyd WillAyd deleted the skipif-no-scipy branch December 15, 2017 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants