From 5475db3198b84a2f8fac2d871ff0de3f7a515daa Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Mon, 23 Jan 2017 17:01:49 -0500 Subject: [PATCH 1/2] COMPAT: numpy-dev compat on bool(dtype) change This is >= 1.13 xref https://github.com/numpy/numpy/pull/8279 closes #15199 --- pandas/compat/numpy/__init__.py | 1 + pandas/core/ops.py | 4 +++- pandas/tseries/index.py | 2 +- pandas/tseries/tdi.py | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index 358ac3c30b8e7..bfd770d7af2c6 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -14,6 +14,7 @@ _np_version_under1p10 = _nlv < '1.10' _np_version_under1p11 = _nlv < '1.11' _np_version_under1p12 = _nlv < '1.12' +_np_version_under1p13 = _nlv < '1.13' if _nlv < '1.7.0': raise ImportError('this version of pandas is incompatible with ' diff --git a/pandas/core/ops.py b/pandas/core/ops.py index 396b0e048bc49..697a99f63f62f 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -444,13 +444,15 @@ def _convert_to_array(self, values, name=None, other=None): supplied_dtype = None if not is_list_like(values): values = np.array([values]) + # if this is a Series that contains relevant dtype info, then use this # instead of the inferred type; this avoids coercing Series([NaT], # dtype='datetime64[ns]') to Series([NaT], dtype='timedelta64[ns]') elif (isinstance(values, pd.Series) and (is_timedelta64_dtype(values) or is_datetime64_dtype(values))): supplied_dtype = values.dtype - inferred_type = supplied_dtype or lib.infer_dtype(values) + + inferred_type = lib.infer_dtype(values) if (inferred_type in ('datetime64', 'datetime', 'date', 'time') or is_datetimetz(inferred_type)): # if we have a other of timedelta, but use pd.NaT here we diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index aca962c8178d3..6cbb696783e09 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -557,7 +557,7 @@ def _simple_new(cls, values, name=None, freq=None, tz=None, if we are passed a non-dtype compat, then coerce using the constructor """ - if not getattr(values, 'dtype', None): + if getattr(values, 'dtype', None) is None: # empty, but with dtype compat if values is None: values = np.empty(0, dtype=_NS_DTYPE) diff --git a/pandas/tseries/tdi.py b/pandas/tseries/tdi.py index 1585aac0c8ead..2e050445f788a 100644 --- a/pandas/tseries/tdi.py +++ b/pandas/tseries/tdi.py @@ -272,8 +272,7 @@ def _box_func(self): @classmethod def _simple_new(cls, values, name=None, freq=None, **kwargs): - if not getattr(values, 'dtype', None): - values = np.array(values, copy=False) + values = np.array(values, copy=False) if values.dtype == np.object_: values = tslib.array_to_timedelta64(values) if values.dtype != _TD_DTYPE: From 53d663e18e2ea28f4cce18f6093548b84b3be910 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Tue, 24 Jan 2017 10:54:07 -0500 Subject: [PATCH 2/2] BLD: pull wheel for numpy builds --- ci/install_travis.sh | 48 +++++++++++-------- ...sh => requirements-3.5_NUMPY_DEV.build.sh} | 5 -- 2 files changed, 28 insertions(+), 25 deletions(-) rename ci/{requirements-3.5_NUMPY_DEV.sh => requirements-3.5_NUMPY_DEV.build.sh} (66%) diff --git a/ci/install_travis.sh b/ci/install_travis.sh index 542d22d9fa871..ded428c677f17 100755 --- a/ci/install_travis.sh +++ b/ci/install_travis.sh @@ -16,28 +16,29 @@ function edit_init() { if [ -n "$LOCALE_OVERRIDE" ]; then - echo "Adding locale to the first line of pandas/__init__.py" + echo "[Adding locale to the first line of pandas/__init__.py]" rm -f pandas/__init__.pyc sedc="3iimport locale\nlocale.setlocale(locale.LC_ALL, '$LOCALE_OVERRIDE')\n" sed -i "$sedc" pandas/__init__.py - echo "head -4 pandas/__init__.py" + echo "[head -4 pandas/__init__.py]" head -4 pandas/__init__.py echo fi } +echo "[install_travis]" edit_init home_dir=$(pwd) -echo "home_dir: [$home_dir]" +echo "[home_dir: $home_dir]" MINICONDA_DIR="$HOME/miniconda3" if [ -d "$MINICONDA_DIR" ] && [ -e "$MINICONDA_DIR/bin/conda" ] && [ "$USE_CACHE" ]; then - echo "Miniconda install already present from cache: $MINICONDA_DIR" + echo "[Miniconda install already present from cache: $MINICONDA_DIR]" conda config --set always_yes yes --set changeps1 no || exit 1 - echo "update conda" + echo "[update conda]" conda update -q conda || exit 1 # Useful for debugging any issues with conda @@ -45,18 +46,18 @@ if [ -d "$MINICONDA_DIR" ] && [ -e "$MINICONDA_DIR/bin/conda" ] && [ "$USE_CACHE # set the compiler cache to work if [ "${TRAVIS_OS_NAME}" == "linux" ]; then - echo "Using ccache" + echo "[Using ccache]" export PATH=/usr/lib/ccache:/usr/lib64/ccache:$PATH gcc=$(which gcc) - echo "gcc: $gcc" + echo "[gcc: $gcc]" ccache=$(which ccache) - echo "ccache: $ccache" + echo "[ccache: $ccache]" export CC='ccache gcc' fi else - echo "Using clean Miniconda install" - echo "Not using ccache" + echo "[Using clean Miniconda install]" + echo "[Not using ccache]" rm -rf "$MINICONDA_DIR" # install miniconda if [ "${TRAVIS_OS_NAME}" == "osx" ]; then @@ -66,14 +67,14 @@ else fi bash miniconda.sh -b -p "$MINICONDA_DIR" || exit 1 - echo "update conda" + echo "[update conda]" conda config --set ssl_verify false || exit 1 conda config --set always_yes true --set changeps1 false || exit 1 conda update -q conda # add the pandas channel to take priority # to add extra packages - echo "add channels" + echo "[add channels]" conda config --add channels pandas || exit 1 conda config --remove channels defaults || exit 1 conda config --add channels defaults || exit 1 @@ -103,13 +104,19 @@ else fi # build deps +echo "[build installs]" REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.build" - -# install deps if [ -e ${REQ} ]; then time conda install -n pandas --file=${REQ} || exit 1 fi +# may have addtl installation instructions for this build +echo "[build addtl installs]" +REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.build.sh" +if [ -e ${REQ} ]; then + time bash $REQ || exit 1 +fi + source activate pandas if [ "$BUILD_TEST" ]; then @@ -122,24 +129,25 @@ if [ "$BUILD_TEST" ]; then else # build but don't install - echo "build em" + echo "[build em]" time python setup.py build_ext --inplace || exit 1 # we may have run installations - echo "conda installs" + echo "[conda installs]" REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.run" if [ -e ${REQ} ]; then time conda install -n pandas --file=${REQ} || exit 1 fi # we may have additional pip installs - echo "pip installs" + echo "[pip installs]" REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.pip" if [ -e ${REQ} ]; then pip install --upgrade -r $REQ fi # may have addtl installation instructions for this build + echo "[addtl installs]" REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.sh" if [ -e ${REQ} ]; then time bash $REQ || exit 1 @@ -147,14 +155,14 @@ else # remove any installed pandas package # w/o removing anything else - echo "removing installed pandas" + echo "[removing installed pandas]" conda remove pandas --force # install our pandas - echo "running setup.py develop" + echo "[running setup.py develop]" python setup.py develop || exit 1 fi -echo "done" +echo "[done]" exit 0 diff --git a/ci/requirements-3.5_NUMPY_DEV.sh b/ci/requirements-3.5_NUMPY_DEV.build.sh similarity index 66% rename from ci/requirements-3.5_NUMPY_DEV.sh rename to ci/requirements-3.5_NUMPY_DEV.build.sh index 946ec43ad9f1a..91fa15491bbf7 100644 --- a/ci/requirements-3.5_NUMPY_DEV.sh +++ b/ci/requirements-3.5_NUMPY_DEV.build.sh @@ -7,11 +7,6 @@ echo "install numpy master wheel" # remove the system installed numpy pip uninstall numpy -y -# we need these for numpy - -# these wheels don't play nice with the conda libgfortran / openblas -# time conda install -n pandas libgfortran openblas || exit 1 - # install numpy wheel from master pip install --pre --upgrade --no-index --timeout=60 --trusted-host travis-dev-wheels.scipy.org -f http://travis-dev-wheels.scipy.org/ numpy scipy