Skip to content

COMPAT: don't rely on dtype being False after numpy >= 1.13 #15200

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions ci/install_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,48 @@
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
conda info -a || exit 1

# 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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -122,39 +129,40 @@ 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
fi

# 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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions pandas/tseries/tdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down