From 7660c8001e7265f5b7e96da160b971740393fad4 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 5 May 2017 05:56:33 -0400 Subject: [PATCH 1/2] TST: test that we work in downstream packages --- ci/install_travis.sh | 26 ++++----- ci/requirements-2.7_BUILD_TEST.pip | 7 +++ ci/requirements-2.7_BUILD_TEST.sh | 7 +++ pandas/tests/test_downstream.py | 85 ++++++++++++++++++++++++++++++ pandas/types/common.py | 8 +++ pandas/util/decorators.py | 8 +++ pandas/util/hashing.py | 18 +++++++ release_build.sh | 10 ++++ 8 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 ci/requirements-2.7_BUILD_TEST.pip create mode 100755 ci/requirements-2.7_BUILD_TEST.sh create mode 100644 pandas/tests/test_downstream.py create mode 100644 pandas/types/common.py create mode 100644 pandas/util/decorators.py create mode 100644 pandas/util/hashing.py create mode 100755 release_build.sh diff --git a/ci/install_travis.sh b/ci/install_travis.sh index 09668cbccc9d2..99291d64e9abc 100755 --- a/ci/install_travis.sh +++ b/ci/install_travis.sh @@ -123,12 +123,9 @@ if [ "$BUILD_TEST" ]; then # build & install testing echo ["Starting installation test."] - rm -rf dist - python setup.py clean - python setup.py build_ext --inplace - python setup.py sdist --formats=gztar - conda uninstall cython - pip install dist/*tar.gz || exit 1 + bash ./release_build.sh + conda uninstall -y cython + time pip install dist/*tar.gz || exit 1 else @@ -162,14 +159,13 @@ if [ -e ${REQ} ]; then time bash $REQ || exit 1 fi -# finish install if we are not doing a build-testk -if [ -z "$BUILD_TEST" ]; then +# remove any installed pandas package +# w/o removing anything else +echo +echo "[removing installed pandas]" +conda remove pandas --force - # remove any installed pandas package - # w/o removing anything else - echo - echo "[removing installed pandas]" - conda remove pandas --force +if [ -z "$BUILD_TEST" ]; then # install our pandas echo @@ -178,6 +174,10 @@ if [ -z "$BUILD_TEST" ]; then fi +echo +echo "[show pandas]" +conda list pandas + echo echo "[done]" exit 0 diff --git a/ci/requirements-2.7_BUILD_TEST.pip b/ci/requirements-2.7_BUILD_TEST.pip new file mode 100644 index 0000000000000..a0fc77c40bc00 --- /dev/null +++ b/ci/requirements-2.7_BUILD_TEST.pip @@ -0,0 +1,7 @@ +xarray +geopandas +seaborn +pandas_gbq +pandas_datareader +statsmodels +scikit-learn diff --git a/ci/requirements-2.7_BUILD_TEST.sh b/ci/requirements-2.7_BUILD_TEST.sh new file mode 100755 index 0000000000000..78941fd0944e5 --- /dev/null +++ b/ci/requirements-2.7_BUILD_TEST.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source activate pandas + +echo "install 27 BUILD_TEST" + +conda install -n pandas -c conda-forge pyarrow dask diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py new file mode 100644 index 0000000000000..2baedb82aa2a7 --- /dev/null +++ b/pandas/tests/test_downstream.py @@ -0,0 +1,85 @@ +""" +Testing that we work in the downstream packages +""" +import pytest +import numpy as np # noqa +from pandas import DataFrame +from pandas.util import testing as tm + + +@pytest.fixture +def df(): + return DataFrame({'A': [1, 2, 3]}) + + +def test_dask(df): + + toolz = pytest.importorskip('toolz') # noqa + dask = pytest.importorskip('dask') # noqa + + import dask.dataframe as dd + + ddf = dd.from_pandas(df, npartitions=3) + assert ddf.A is not None + assert ddf.compute() is not None + + +def test_xarray(df): + + xarray = pytest.importorskip('xarray') # noqa + + assert df.to_xarray() is not None + + +def test_statsmodels(): + + statsmodels = pytest.importorskip('statsmodels') # noqa + import statsmodels.api as sm + import statsmodels.formula.api as smf + df = sm.datasets.get_rdataset("Guerry", "HistData").data + smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=df).fit() + + +def test_scikit_learn(df): + + sklearn = pytest.importorskip('sklearn') # noqa + from sklearn import svm, datasets + + digits = datasets.load_digits() + clf = svm.SVC(gamma=0.001, C=100.) + clf.fit(digits.data[:-1], digits.target[:-1]) + clf.predict(digits.data[-1:]) + + +def test_seaborn(): + + seaborn = pytest.importorskip('seaborn') + tips = seaborn.load_dataset("tips") + seaborn.stripplot(x="day", y="total_bill", data=tips) + + +def test_pandas_gbq(df): + + pandas_gbq = pytest.importorskip('pandas-gbq') # noqa + + +@tm.network +def test_pandas_datareader(): + + pandas_datareader = pytest.importorskip('pandas-datareader') # noqa + pandas_datareader.get_data_yahoo('AAPL') + + +def test_geopandas(): + + geopandas = pytest.importorskip('geopandas') # noqa + fp = geopandas.datasets.get_path('naturalearth_lowres') + assert geopandas.read_file(fp) is not None + + +def test_pyarrow(df): + + pyarrow = pytest.importorskip('pyarrow') # noqa + table = pyarrow.Table.from_pandas(df) + result = table.to_pandas() + tm.assert_frame_equal(result, df) diff --git a/pandas/types/common.py b/pandas/types/common.py new file mode 100644 index 0000000000000..a125c27d04596 --- /dev/null +++ b/pandas/types/common.py @@ -0,0 +1,8 @@ +import warnings + +warnings.warn("pandas.types.common is deprecated and will be " + "removed in a future version, import " + "from pandas.api.types", + DeprecationWarning, stacklevel=3) + +from pandas.core.dtypes.common import * # noqa diff --git a/pandas/util/decorators.py b/pandas/util/decorators.py new file mode 100644 index 0000000000000..54bb834e829f3 --- /dev/null +++ b/pandas/util/decorators.py @@ -0,0 +1,8 @@ +import warnings + +warnings.warn("pandas.util.decorators is deprecated and will be " + "removed in a future version, import " + "from pandas.util", + DeprecationWarning, stacklevel=3) + +from pandas.util._decorators import * # noqa diff --git a/pandas/util/hashing.py b/pandas/util/hashing.py new file mode 100644 index 0000000000000..f97a7ac507407 --- /dev/null +++ b/pandas/util/hashing.py @@ -0,0 +1,18 @@ +import warnings +import sys + +m = sys.modules['pandas.util.hashing'] +for t in ['hash_pandas_object', 'hash_array']: + + def outer(t=t): + + def wrapper(*args, **kwargs): + from pandas import util + warnings.warn("pandas.util.hashing is deprecated and will be " + "removed in a future version, import " + "from pandas.util", + DeprecationWarning, stacklevel=3) + return getattr(util, t)(*args, **kwargs) + return wrapper + + setattr(m, t, outer(t)) diff --git a/release_build.sh b/release_build.sh new file mode 100755 index 0000000000000..f8373176643fa --- /dev/null +++ b/release_build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# this requires cython to be installed + +# this builds the release cleanly +rm -rf dist +git clean -xfd +python setup.py clean +python setup.py cython +python setup.py sdist --formats=gztar From 085375fc1a47d03a9503c9adfc8a7d8779348b5b Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 5 May 2017 09:58:50 -0400 Subject: [PATCH 2/2] move to install_release_build.sh --- release_build.sh => ci/install_release_build.sh | 0 ci/install_travis.sh | 2 +- scripts/build_dist.sh | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) rename release_build.sh => ci/install_release_build.sh (100%) mode change 100755 => 100644 diff --git a/release_build.sh b/ci/install_release_build.sh old mode 100755 new mode 100644 similarity index 100% rename from release_build.sh rename to ci/install_release_build.sh diff --git a/ci/install_travis.sh b/ci/install_travis.sh index 99291d64e9abc..601edded29f5a 100755 --- a/ci/install_travis.sh +++ b/ci/install_travis.sh @@ -123,7 +123,7 @@ if [ "$BUILD_TEST" ]; then # build & install testing echo ["Starting installation test."] - bash ./release_build.sh + bash ci/install_release_build.sh conda uninstall -y cython time pip install dist/*tar.gz || exit 1 diff --git a/scripts/build_dist.sh b/scripts/build_dist.sh index c9c36c18bed9c..d6a7d0ba67239 100755 --- a/scripts/build_dist.sh +++ b/scripts/build_dist.sh @@ -10,8 +10,10 @@ read -p "Ok to continue (y/n)? " answer case ${answer:0:1} in y|Y ) echo "Building distribution" + rm -rf dist + git clean -xfd python setup.py clean - python setup.py build_ext --inplace + python setup.py cython python setup.py sdist --formats=gztar ;; * )