Merge pull request #1816 from rcurtin/travis-python-fixes

Travis Python fixes
This commit is contained in:
Ryan Curtin
2019-04-13 16:27:58 -04:00
committed by GitHub
2 changed files with 18 additions and 11 deletions
+5 -5
View File
@@ -5,22 +5,22 @@ matrix:
include:
- os: linux
dist: xenial
env: CMAKE_OPTIONS="-DDEBUG=OFF -DPROFILE=OFF -DPYTHON=/usr/bin/python"
env: CMAKE_OPTIONS="-DDEBUG=OFF -DPROFILE=OFF -DPYTHON_EXECUTABLE=/usr/bin/python"
before_install:
- sudo apt-get update
- sudo apt-get install -y --allow-unauthenticated libopenblas-dev liblapack-dev g++ libboost-all-dev python-pip cython python-numpy python-pandas
- sudo pip install --upgrade --ignore-installed setuptools
- sudo pip install --upgrade --ignore-installed setuptools cython
- curl https://ftp.fau.de/macports/distfiles/armadillo/armadillo-6.500.5.tar.gz | tar xvz && cd armadillo*
- cmake . && make && sudo make install && cd ..
- sudo cp .travis/config.hpp /usr/include/armadillo_bits/config.hpp
- os: linux
dist: xenial
env: CMAKE_OPTIONS="-DDEBUG=OFF -DPROFILE=OFF -DPYTHON=/usr/bin/python3"
env: CMAKE_OPTIONS="-DDEBUG=OFF -DPROFILE=OFF -DPYTHON_EXECUTABLE=/usr/bin/python3"
before_install:
- sudo apt-get update
- sudo apt-get install -y --allow-unauthenticated libopenblas-dev liblapack-dev g++ libboost-all-dev python3-pip cython3 python3-numpy python3-pandas
- sudo pip3 install --upgrade --ignore-installed setuptools
- sudo apt-get install -y --allow-unauthenticated libopenblas-dev liblapack-dev g++ libboost-all-dev python3-pip cython3 python3-numpy
- sudo pip3 install --upgrade --ignore-installed setuptools cython pandas
- curl https://ftp.fau.de/macports/distfiles/armadillo/armadillo-6.500.5.tar.gz | tar xvz && cd armadillo*
- cmake . && make && sudo make install && cd ..
- sudo cp .travis/config.hpp /usr/include/armadillo_bits/config.hpp
@@ -54,19 +54,26 @@ def to_matrix(x, dtype=np.double, copy=False):
return x, False
elif (isinstance(x, np.ndarray) and x.dtype == dtype and x.flags.f_contiguous):
if copy: # Copy the matrix if required.
return np.ndarray(x.shape, buffer=x.flatten(), dtype=dtype, order='C').copy("C"), True
return np.ndarray(x.shape, buffer=x.flatten(), dtype=dtype,
order='C').copy("C"), True
else:
return np.ndarray(x.shape, buffer=x.flatten(), dtype=dtype, order='C'), False
return np.ndarray(x.shape, buffer=x.flatten(), dtype=dtype, order='C'), \
False
else:
if isinstance(x, pd.core.series.Series) or isinstance(x, pd.DataFrame):
# We can only avoid a copy if the dtype is the same and the copy flag is
# false. I'm actually not sure if this is possible, since in everything I
# have found, Pandas stores with F_CONTIGUOUS not C_CONTIGUOUS.
y = x.values
if copy: # Copy the matrix if required.
return np.ndarray(y.shape, buffer=y.flatten(), dtype=dtype, order='C').copy("C"), True
if copy == False and y.dtype == dtype and y.flags.c_contiguous:
return np.ndarray(y.shape, buffer=y.flatten(), dtype=dtype, order='C'),\
False
else:
return np.ndarray(y.shape, buffer=y.flatten(), dtype=dtype, order='C'), False
# We have to make a copy or change the dtype, so just do this directly.
return np.array(y, dtype=dtype, order='C', copy=True), True
else:
return np.array(x, copy=True, dtype=dtype, order='C'), True
def to_matrix_with_info(x, dtype, copy=False):
"""