Skip to content

Commit 1b5e571

Browse files
jrebackstangirala
authored andcommitted
DEPR: add shims for util + TST: test that we work in downstream packages (pandas-dev#16250)
1 parent 13714a8 commit 1b5e571

9 files changed

+159
-14
lines changed

ci/install_release_build.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# this requires cython to be installed
4+
5+
# this builds the release cleanly
6+
rm -rf dist
7+
git clean -xfd
8+
python setup.py clean
9+
python setup.py cython
10+
python setup.py sdist --formats=gztar

ci/install_travis.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,9 @@ if [ "$BUILD_TEST" ]; then
123123

124124
# build & install testing
125125
echo ["Starting installation test."]
126-
rm -rf dist
127-
python setup.py clean
128-
python setup.py build_ext --inplace
129-
python setup.py sdist --formats=gztar
130-
conda uninstall cython
131-
pip install dist/*tar.gz || exit 1
126+
bash ci/install_release_build.sh
127+
conda uninstall -y cython
128+
time pip install dist/*tar.gz || exit 1
132129

133130
else
134131

@@ -162,14 +159,13 @@ if [ -e ${REQ} ]; then
162159
time bash $REQ || exit 1
163160
fi
164161

165-
# finish install if we are not doing a build-testk
166-
if [ -z "$BUILD_TEST" ]; then
162+
# remove any installed pandas package
163+
# w/o removing anything else
164+
echo
165+
echo "[removing installed pandas]"
166+
conda remove pandas --force
167167

168-
# remove any installed pandas package
169-
# w/o removing anything else
170-
echo
171-
echo "[removing installed pandas]"
172-
conda remove pandas --force
168+
if [ -z "$BUILD_TEST" ]; then
173169

174170
# install our pandas
175171
echo
@@ -178,6 +174,10 @@ if [ -z "$BUILD_TEST" ]; then
178174

179175
fi
180176

177+
echo
178+
echo "[show pandas]"
179+
conda list pandas
180+
181181
echo
182182
echo "[done]"
183183
exit 0

ci/requirements-2.7_BUILD_TEST.pip

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
xarray
2+
geopandas
3+
seaborn
4+
pandas_gbq
5+
pandas_datareader
6+
statsmodels
7+
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 BUILD_TEST"
6+
7+
conda install -n pandas -c conda-forge pyarrow dask

pandas/tests/test_downstream.py

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

pandas/types/common.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import warnings
2+
3+
warnings.warn("pandas.types.common is deprecated and will be "
4+
"removed in a future version, import "
5+
"from pandas.api.types",
6+
DeprecationWarning, stacklevel=3)
7+
8+
from pandas.core.dtypes.common import * # noqa

pandas/util/decorators.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import warnings
2+
3+
warnings.warn("pandas.util.decorators is deprecated and will be "
4+
"removed in a future version, import "
5+
"from pandas.util",
6+
DeprecationWarning, stacklevel=3)
7+
8+
from pandas.util._decorators import * # noqa

pandas/util/hashing.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import warnings
2+
import sys
3+
4+
m = sys.modules['pandas.util.hashing']
5+
for t in ['hash_pandas_object', 'hash_array']:
6+
7+
def outer(t=t):
8+
9+
def wrapper(*args, **kwargs):
10+
from pandas import util
11+
warnings.warn("pandas.util.hashing is deprecated and will be "
12+
"removed in a future version, import "
13+
"from pandas.util",
14+
DeprecationWarning, stacklevel=3)
15+
return getattr(util, t)(*args, **kwargs)
16+
return wrapper
17+
18+
setattr(m, t, outer(t))

scripts/build_dist.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ read -p "Ok to continue (y/n)? " answer
1010
case ${answer:0:1} in
1111
y|Y )
1212
echo "Building distribution"
13+
rm -rf dist
14+
git clean -xfd
1315
python setup.py clean
14-
python setup.py build_ext --inplace
16+
python setup.py cython
1517
python setup.py sdist --formats=gztar
1618
;;
1719
* )

0 commit comments

Comments
 (0)