Skip to content

Commit 4ecf5b1

Browse files
committed
TST: test that we work in downstream packages
1 parent a31c96d commit 4ecf5b1

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

ci/requirements-2.7.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source activate pandas
44

5-
echo "install 27"
5+
echo "install 27 BUILD_TEST"
66

77
conda install -n pandas -c conda-forge feather-format

ci/requirements-2.7_BUILD_TEST.pip

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
xarray
2+
geopandas
3+
dask
4+
seaborn
5+
pandas_gbq
6+
pandas_datareader
7+
statsmodels
8+
scikit-learn

ci/requirements-2.7_BUILD_TEST.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
source activate pandas
4+
5+
echo "install 27"
6+
7+
conda install -n pandas -c conda-forge pyarrow

pandas/tests/test_downstream.py

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"""
2+
Testing that we work in the downstream packages
3+
"""
4+
import pytest
5+
from pandas import DataFrame
6+
from pandas.util import testing as tm
7+
8+
9+
@pytest.fixture
10+
def df():
11+
return DataFrame({'A': [1, 2, 3]})
12+
13+
14+
def test_dask(df):
15+
16+
dask = pytest.importorskip('dask') # noqa
17+
18+
import dask.dataframe as dd
19+
20+
ddf = dd.from_pandas(df)
21+
assert ddf.A is not None
22+
assert ddf.compute()
23+
24+
25+
def test_xarray(df):
26+
27+
xarray = pytest.importorskip('xarray') # noqa
28+
29+
assert df.to_xarray() is not None
30+
31+
32+
def test_statsmodels():
33+
34+
statsmodels = pytest.importorskip('statsmodels') # noqa
35+
import statsmodels.api as sm
36+
import statsmodels.formula.api as smf
37+
df = sm.datasets.get_rdataset("Guerry", "HistData").data
38+
smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=df).fit()
39+
40+
41+
def test_scikit_learn(df):
42+
43+
sklearn = pytest.importorskip('sklearn') # noqa
44+
from sklearn import svm, datasets
45+
46+
digits = datasets.load_digits()
47+
clf = svm.SVC(gamma=0.001, C=100.)
48+
clf.fit(digits.data[:-1], digits.target[:-1])
49+
clf.predict(digits.data[-1:])
50+
51+
52+
def test_seaborn():
53+
54+
seaborn = pytest.importorskip('seaborn')
55+
tips = seaborn.load_dataset("tips")
56+
seaborn.stripplot(x="day", y="total_bill", data=tips)
57+
58+
59+
def test_pandas_gbq(df):
60+
61+
pandas_gbq = pytest.importorskip('pandas-gbq') # noqa
62+
63+
64+
@tm.network
65+
def test_pandas_datareader():
66+
67+
pandas_datareader = pytest.importorskip('pandas-datareader') # noqa
68+
pandas_datareader.get_data_yahoo('AAPL')
69+
70+
71+
def test_geopandas():
72+
73+
geopandas = pytest.importorskip('geopandas') # noqa
74+
fp = geopandas.datasets.get_path('naturalearth_lowres')
75+
assert geopandas.read_file(fp) is not None
76+
77+
78+
def test_pyarrow(df):
79+
80+
pyarrow = pytest.importorskip('pyarrow') # noqa
81+
table = pyarrow.Table.from_pandas(df)
82+
result = table.to_pandas()
83+
tm.assert_frame_equal(result, df)

0 commit comments

Comments
 (0)