From 142b0a619511f96045520f3402e77b278a92443d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Sun, 7 Feb 2016 14:54:11 +0900 Subject: [PATCH 01/12] Add .clang-format --- .clang-format | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b0325c2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,14 @@ +--- +BasedOnStyle: Google +BreakBeforeBraces: Allman +AccessModifierOffset: -2 +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +KeepEmptyLinesAtTheStartOfBlocks: true +NamespaceIndentation: All +SpaceBeforeParens: Always +SpacesBeforeTrailingComments: 1 +... From e496107b536e393a7d01197a455012eeb85cc0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Tue, 23 Feb 2016 14:14:51 +0900 Subject: [PATCH 02/12] Update for changes to roboptim-core --- src/roboptim/core/__init__.py | 11 ---- src/wrap.cc | 121 +++------------------------------- 2 files changed, 9 insertions(+), 123 deletions(-) diff --git a/src/roboptim/core/__init__.py b/src/roboptim/core/__init__.py index 43f9a10..fed0d45 100644 --- a/src/roboptim/core/__init__.py +++ b/src/roboptim/core/__init__.py @@ -353,8 +353,6 @@ def minimum (self): (objType, obj) = minimum (self._solver) if objType == "roboptim_core_result": return PyResult (obj) - elif objType == "roboptim_core_result_with_warnings": - return PyResultWithWarnings (obj) elif objType == "roboptim_core_solver_error": return PySolverError (obj) else: @@ -460,15 +458,6 @@ def constraints(self): def lagrange(self): return self._dict["lambda"] - -class PyResultWithWarnings(PyResult): - def __init__(self, _result): - self._result = _result - self._dict = resultWithWarningsToDict (_result) - - def __str__ (self): - return strResultWithWarnings (self._result) - @property def warnings(self): return self._dict["warnings"] diff --git a/src/wrap.cc b/src/wrap.cc index 863a9cb..a7c7ceb 100644 --- a/src/wrap.cc +++ b/src/wrap.cc @@ -555,17 +555,6 @@ namespace detail delete ptr; } - template <> - void destructor (PyObject* obj) - { - resultWithWarnings_t* ptr = static_cast - (PyCapsule_GetPointer - (obj, ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME)); - assert (ptr && "failed to retrieve pointer from capsule"); - if (ptr) - delete ptr; - } - template <> void destructor (PyObject* obj) { @@ -769,15 +758,6 @@ namespace detail (PyCapsule_GetPointer (obj, ROBOPTIM_CORE_RESULT_CAPSULE_NAME)); } - // Try upcasting - // TODO: find a better way to handle that - else if (std::strcmp (capsule_name, - ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME) == 0) - { - ptr = static_cast - (PyCapsule_GetPointer - (obj, ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME)); - } if (!ptr) { @@ -791,26 +771,6 @@ namespace detail return 1; } - int - resultWithWarningsConverter (PyObject* obj, resultWithWarnings_t** address) - { - assert (address); - - resultWithWarnings_t* ptr = static_cast - (PyCapsule_GetPointer - (obj, ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME)); - - if (!ptr) - { - PyErr_SetString - (PyExc_TypeError, - "ResultWithWarnings object expected but another type was passed"); - return 0; - } - *address = ptr; - return 1; - } - int solverErrorConverter (PyObject* obj, solverError_t** address) { @@ -2061,16 +2021,6 @@ minimum (PyObject*, PyObject* args) return Py_BuildValue ("(s,N)", ROBOPTIM_CORE_RESULT_CAPSULE_NAME, resultPy); } - case solver_t::SOLVER_VALUE_WARNINGS: - { - resultWithWarnings_t* warn = - new resultWithWarnings_t (boost::get (result)); - PyObject* warnPy = - PyCapsule_New (warn, ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME, - &detail::destructor); - return Py_BuildValue - ("(s,N)", ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME, warnPy); - } case solver_t::SOLVER_ERROR: { solverError_t* err = new solverError_t @@ -2702,6 +2652,15 @@ toDict (result_t& result) } PyDict_SetItemString (dict_result, "lambda", lambdaNumpy); + // Warnings stored as a list + PyObject* warnings = PyList_New (result.warnings.size ()); + for (size_t i = 0; i < result.warnings.size (); ++i) + { + PyList_SetItem (warnings, i, + PyString_FromString (result.warnings[i].what ())); + } + PyDict_SetItemString (dict_result, "warnings", warnings); + return Py_BuildValue ("O", dict_result); } @@ -2729,44 +2688,6 @@ toDict (PyObject*, PyObject* args) return toDict (*result); } -template <> -PyObject* -toDict (PyObject* obj, PyObject* args) -{ - PyObject* dict_result = toDict (obj, args); - - if (!dict_result) - { - PyErr_SetString (PyExc_TypeError, - "1st argument must be inherited from result."); - return 0; - } - - resultWithWarnings_t* result = 0; - - if (!PyArg_ParseTuple (args, "O&", - &detail::resultWithWarningsConverter, &result)) - return 0; - - if (!result) - { - PyErr_SetString (PyExc_TypeError, - "1st argument must be a result with warnings."); - return 0; - } - - // Warnings stored as a list - PyObject* warnings = PyList_New (result->warnings.size ()); - for (size_t i = 0; i < result->warnings.size (); ++i) - { - PyList_SetItem (warnings, i, - PyString_FromString (result->warnings[i].what ())); - } - PyDict_SetItemString (dict_result, "warnings", warnings); - - return Py_BuildValue ("O", dict_result); -} - template <> PyObject* toDict (PyObject*, PyObject* args) @@ -2883,26 +2804,6 @@ print (PyObject*, PyObject* args) return Py_BuildValue ("s", ss.str ().c_str ()); } -template <> -PyObject* -print (PyObject*, PyObject* args) -{ - resultWithWarnings_t* obj = 0; - if (!PyArg_ParseTuple - (args, "O&", &detail::resultWithWarningsConverter, &obj)) - return 0; - if (!obj) - { - PyErr_SetString (PyExc_TypeError, "failed to retrieve object"); - return 0; - } - - std::stringstream ss; - ss << (*obj); - - return Py_BuildValue ("s", ss.str ().c_str ()); -} - template <> PyObject* print (PyObject*, PyObject* args) @@ -3045,8 +2946,6 @@ static PyMethodDef RobOptimCoreMethods[] = // Result functions {"resultToDict", toDict, METH_VARARGS, "Convert a Result object to a Python dictionary."}, - {"resultWithWarningsToDict", toDict, METH_VARARGS, - "Convert a ResultWithWarnings object to a Python dictionary."}, {"solverErrorToDict", toDict, METH_VARARGS, "Convert a SolverError object to a Python dictionary."}, @@ -3073,8 +2972,6 @@ static PyMethodDef RobOptimCoreMethods[] = "Print a solver state as a Python string."}, {"strResult", print, METH_VARARGS, "Print a result as a Python string."}, - {"strResultWithWarnings", print, METH_VARARGS, - "Print a result as a Python string."}, {"strSolverError", print, METH_VARARGS, "Print a solver error as a Python string."}, {0, 0, 0, 0} From 59e39ef871d638cccca0479cf804f12769da11e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Tue, 23 Feb 2016 15:19:34 +0900 Subject: [PATCH 03/12] Add support for new constraint_violation attribute in Result --- src/wrap.cc | 3 +++ src/wrap.hh | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wrap.cc b/src/wrap.cc index a7c7ceb..9b9148a 100644 --- a/src/wrap.cc +++ b/src/wrap.cc @@ -2641,6 +2641,9 @@ toDict (result_t& result) } PyDict_SetItemString (dict_result, "constraints", constraintsNumpy); + PyDict_SetItemString (dict_result, "constraint_violation", + PyFloat_FromDouble (result.constraint_violation)); + npy_size = static_cast (result.lambda.size ()); PyObject* lambdaNumpy = PyArray_SimpleNewFromData (1, &npy_size, diff --git a/src/wrap.hh b/src/wrap.hh index 6773a22..525b2b1 100644 --- a/src/wrap.hh +++ b/src/wrap.hh @@ -57,8 +57,6 @@ static const char* ROBOPTIM_CORE_OPTIMIZATION_LOGGER_CAPSULE_NAME = "roboptim_core_optimization_logger"; static const char* ROBOPTIM_CORE_RESULT_CAPSULE_NAME = "roboptim_core_result"; -static const char* ROBOPTIM_CORE_RESULT_WITH_WARNINGS_CAPSULE_NAME = - "roboptim_core_result_with_warnings"; static const char* ROBOPTIM_CORE_SOLVER_ERROR_CAPSULE_NAME = "roboptim_core_solver_error"; @@ -383,7 +381,6 @@ typedef roboptim::OptimizationLogger logger_t; typedef roboptim::callback::Multiplexer multiplexer_t; typedef roboptim::Result result_t; -typedef roboptim::ResultWithWarnings resultWithWarnings_t; typedef roboptim::SolverError solverError_t; typedef roboptim::Parameter parameter_t; typedef solver_t::parameters_t parameters_t; @@ -411,7 +408,6 @@ namespace detail int multiplexerConverter (PyObject* obj, rcp::Multiplexer** address); int solverStateConverter (PyObject* obj, solverState_t** address); int resultConverter (PyObject* obj, result_t** address); - int resultWithWarningsConverter (PyObject* obj, resultWithWarnings_t** address); int solverErrorConverter (PyObject* obj, solverError_t** address); struct ParameterValueVisitor; From 21a11ccc692aff50a679a9cc9daced3df5ab05f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Thu, 25 Feb 2016 01:31:47 +0900 Subject: [PATCH 04/12] [travis] Force synchronized patch level --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 360eba3..1fd4fb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: python python: - - "2.7" + - "2.7.3" - "3.4" + - "3.5" env: global: - APT_DEPENDENCIES="doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev coinor-libipopt-dev libblas-dev liblapack-dev libmumps-seq-dev gfortran" From 4174c79ee2705c6ce8b44473805378d38868f507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Fri, 4 Mar 2016 12:00:24 +0900 Subject: [PATCH 05/12] [travis] Allow failure for Python 2.7 --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1fd4fb6..93a836e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - - "2.7.3" + - "2.7" - "3.4" - "3.5" env: @@ -41,3 +41,8 @@ after_success: - export CC=gcc - ./.travis/run after_success after_failure: ./.travis/run after_failure + +matrix: + allow_failures: + # Known issue with virtualenv + - python: "2.7" From 0e52ea0bd2124535b3c56296b45d20279a1ca9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Fri, 4 Mar 2016 12:01:29 +0900 Subject: [PATCH 06/12] [travis] Synchronize --- .travis | 2 +- .travis.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis b/.travis index d002d2a..b819e8a 160000 --- a/.travis +++ b/.travis @@ -1 +1 @@ -Subproject commit d002d2ad1febde9b8f9cfacf452121bc64aff877 +Subproject commit b819e8a7c66f5ceba70a07a8b55b3e6ad49127f4 diff --git a/.travis.yml b/.travis.yml index 93a836e..3ae186f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - "3.5" env: global: - - APT_DEPENDENCIES="doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev coinor-libipopt-dev libblas-dev liblapack-dev libmumps-seq-dev gfortran" + - APT_DEPENDENCIES="doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev" - GIT_DEPENDENCIES="roboptim/roboptim-core roboptim/roboptim-core-plugin-ipopt" - GH_USERNAME=thomas-moulard - GH_REPO=roboptim/roboptim-core-python @@ -26,6 +26,7 @@ before_install: - if [ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]; then pip install futures; fi; - pip install matplotlib - ./.travis/dependencies/eigen-3.2 + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then CC=gcc CXX=g++ ./.travis/dependencies/ipopt; fi - ./.travis/run before_install script: - export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION}\"`" From 46e6eb5ac9505396ac140fdfeaab1c617dbdafac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Sun, 28 Aug 2016 23:17:33 +0200 Subject: [PATCH 07/12] [cmake] Synchronize --- cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake b/cmake index fdd7363..83d3fa7 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit fdd7363e4a672a5af098139182fbb6e73e46623a +Subproject commit 83d3fa76f5196bc667e516c590ae6fd297027050 From 60a22ba069aac6f302e6d7d82c45f24f9b01004b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Sun, 28 Aug 2016 23:24:16 +0200 Subject: [PATCH 08/12] [travis] Add OS X target --- .travis | 2 +- .travis.yml | 44 +++++++++++++++++++++++++++++++++----------- CMakeLists.txt | 1 + tests/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/.travis b/.travis index b819e8a..629f539 160000 --- a/.travis +++ b/.travis @@ -1 +1 @@ -Subproject commit b819e8a7c66f5ceba70a07a8b55b3e6ad49127f4 +Subproject commit 629f539ea0c78134e4b9fceaa4bab41b05bb3b6e diff --git a/.travis.yml b/.travis.yml index 3ae186f..4d924d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ -language: python -python: - - "2.7" - - "3.4" - - "3.5" +sudo: required env: global: - - APT_DEPENDENCIES="doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev" + - APT_DEPENDENCIES="cmake cmake-data doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev" + - HOMEBREW_DEPENDENCIES="doxygen log4cxx ipopt openblas mumps" - GIT_DEPENDENCIES="roboptim/roboptim-core roboptim/roboptim-core-plugin-ipopt" - GH_USERNAME=thomas-moulard - GH_REPO=roboptim/roboptim-core-python @@ -20,9 +17,9 @@ branches: - dev - travis before_install: - - sudo add-apt-repository ppa:fkrull/deadsnakes -y - - sudo apt-get update -q - - sudo apt-get install python${TRAVIS_PYTHON_VERSION}-dev + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo add-apt-repository ppa:fkrull/deadsnakes -y; fi; + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get update -q; fi; + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get install python${TRAVIS_PYTHON_VERSION}-dev; fi; - if [ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]; then pip install futures; fi; - pip install matplotlib - ./.travis/dependencies/eigen-3.2 @@ -30,9 +27,11 @@ before_install: - ./.travis/run before_install script: - export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION}\"`" - - export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION}*.so\" -print -quit`" + - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION}*.so\" -print -quit`"; fi; + - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export PYTHON_LIBRARY=#{%x(python-config --prefix).chomp}/lib/libpython2.7.dylib; fi; - export CMAKE_ADDITIONAL_OPTIONS="-DPython_ADDITIONAL_VERSIONS=${TRAVIS_PYTHON_VERSION} -DPythonLibs_FIND_VERSION=${TRAVIS_PYTHON_VERSION} -DPYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/" - - export LD_LIBRARY_PATH="/tmp/_ci/install/lib/roboptim-core/" + - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export LD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$LD_LIBRARY_PATH; fi + - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export DYLD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$DYLD_LIBRARY_PATH; fi - ./.travis/run build after_success: # Print Ipopt logs even after success @@ -47,3 +46,26 @@ matrix: allow_failures: # Known issue with virtualenv - python: "2.7" + include: + - os: linux + dist: trusty + language: python + python: "2.7" + - os: linux + dist: trusty + language: python + python: "3.5" + - os: linux + dist: precise + env: MASTER_PPA="george-edison55/precise-backports" + language: python + python: "2.7" + - os: linux + dist: precise + env: MASTER_PPA="george-edison55/precise-backports" + language: python + python: "3.5" + - os: osx + language: cpp + compiler: clang + env: TRAVIS_PYTHON_VERSION="2.7" diff --git a/CMakeLists.txt b/CMakeLists.txt index 383c26e..7cd5be2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ SET(HEADERS SET(CXX_DISABLE_WERROR 1) #FIXME: disable for now. +SET(PKG_CONFIG_ADDITIONAL_VARIABLES plugindir ${PKG_CONFIG_ADDITIONAL_VARIABLES}) SETUP_PROJECT() # Search for dependencies. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ccd4168..dada457 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,11 +5,45 @@ # Use adequate Python executable for tests SET(TEST_COMMAND "${PYTHON_EXECUTABLE}") +SET(PLUGINDIR "") +IF(ROBOPTIM_CORE_FOUND) + SET(PLUGINDIR ${ROBOPTIM_CORE_PLUGINDIR}) +ELSEIF() + SET(PLUGINDIR ${ROBOPTIM_CORE_DEBUG_PLUGINDIR}) +ENDIF() + +IF("${PLUGINDIR}" STREQUAL "") + MESSAGE(FATAL_ERROR "Plugin directory not found") +ENDIF() + +# SET_TEST_ENV(NAME) +# ------------------ +# +# Add the plugin directory to the proper environment variables. +# +MACRO(SET_TEST_ENV NAME) + # TODO: adapt for WIN32 + IF(UNIX) + IF(APPLE) + SET_PROPERTY( + TEST ${NAME} APPEND PROPERTY ENVIRONMENT + "DYLD_LIBRARY_PATH=${PLUGINDIR}:$ENV{DYLD_LIBRARY_PATH}") + ELSE() + SET_PROPERTY( + TEST ${NAME} APPEND PROPERTY ENVIRONMENT + "LD_LIBRARY_PATH=${PLUGINDIR}:$ENV{LD_LIBRARY_PATH}") + ENDIF() + ENDIF() +ENDMACRO() + MACRO(REGISTER_TEST NAME) ADD_TEST(${NAME} "${TEST_COMMAND}" "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.py") + # Update PYTHONPATH to find the Python module SET_TESTS_PROPERTIES(${NAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src") + + SET_TEST_ENV(${NAME}) ENDMACRO() # Check roboptim-py internal API. From 371af45ff07701be309234c618f1fcc64783d69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Wed, 4 Jul 2018 20:57:20 +0200 Subject: [PATCH 09/12] [travis] Synchronize --- .travis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis b/.travis index 629f539..dc8b946 160000 --- a/.travis +++ b/.travis @@ -1 +1 @@ -Subproject commit 629f539ea0c78134e4b9fceaa4bab41b05bb3b6e +Subproject commit dc8b946d456d2c41ad12b819111b005148c68031 From 28c0f1c9103ec464703c1dfa8d750eac4a8de298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Wed, 4 Jul 2018 20:57:26 +0200 Subject: [PATCH 10/12] [cmake] Synchronize --- cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake b/cmake index 83d3fa7..f7328a5 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 83d3fa76f5196bc667e516c590ae6fd297027050 +Subproject commit f7328a51032f970f64895770af719a6d0d775ef7 From 56ca346f9c21bc3c2198f73ba55dfb2d5d62b9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Wed, 4 Jul 2018 21:53:38 +0200 Subject: [PATCH 11/12] Fix test for changes to NumPy Before: [[ 0. 0. 0. ] [ 0. 0. 0. ] [ 0. 0. 0. ]] With recent NumPy: [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] See https://github.com/numpy/numpy/pull/9139 --- tests/to-python.cc | 1 + tests/to-python.stdout | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/to-python.cc b/tests/to-python.cc index 21ca1e1..2ce6ca3 100644 --- a/tests/to-python.cc +++ b/tests/to-python.cc @@ -36,6 +36,7 @@ BOOST_AUTO_TEST_CASE (redir) ToPython tp; tp << "import numpy as np" + << "np.set_printoptions(formatter={'all': lambda x: str(x)})" << "ar = np.zeros((3,3))" << "print(ar)" << "ar[0,1] = 42." diff --git a/tests/to-python.stdout b/tests/to-python.stdout index 26d1e88..e31fbb3 100644 --- a/tests/to-python.stdout +++ b/tests/to-python.stdout @@ -1,4 +1,4 @@ -[[ 0. 0. 0.] - [ 0. 0. 0.] - [ 0. 0. 0.]] +[[0.0 0.0 0.0] + [0.0 0.0 0.0] + [0.0 0.0 0.0]] 42.0 From be051e9a56ce172f8bb49a13f667d79c9c16f97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Wed, 4 Jul 2018 23:19:58 +0200 Subject: [PATCH 12/12] [ci] Fix compilation --- .travis.yml | 29 ++++++++++++++++------------- src/CMakeLists.txt | 6 +----- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d924d8..69efc5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: required env: global: - APT_DEPENDENCIES="cmake cmake-data doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev" - - HOMEBREW_DEPENDENCIES="doxygen log4cxx ipopt openblas mumps" + - HOMEBREW_DEPENDENCIES="doxygen log4cxx dartsim/dart/ipopt openblas mumps" - GIT_DEPENDENCIES="roboptim/roboptim-core roboptim/roboptim-core-plugin-ipopt" - GH_USERNAME=thomas-moulard - GH_REPO=roboptim/roboptim-core-python @@ -17,19 +17,20 @@ branches: - dev - travis before_install: + - export TRAVIS_PYTHON_VERSION_SHORT=$(echo "${TRAVIS_PYTHON_VERSION}" | cut -d'.' -f-2) - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo add-apt-repository ppa:fkrull/deadsnakes -y; fi; - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get update -q; fi; - - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get install python${TRAVIS_PYTHON_VERSION}-dev; fi; - - if [ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]; then pip install futures; fi; - - pip install matplotlib + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get install python${TRAVIS_PYTHON_VERSION_SHORT}-dev; fi; + - if [ "${TRAVIS_PYTHON_VERSION_SHORT}" == "2.7" ]; then pip2 install futures; fi; + - pip install matplotlib || pip2 install matplotlib - ./.travis/dependencies/eigen-3.2 - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then CC=gcc CXX=g++ ./.travis/dependencies/ipopt; fi - ./.travis/run before_install script: - - export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION}\"`" - - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION}*.so\" -print -quit`"; fi; - - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export PYTHON_LIBRARY=#{%x(python-config --prefix).chomp}/lib/libpython2.7.dylib; fi; - - export CMAKE_ADDITIONAL_OPTIONS="-DPython_ADDITIONAL_VERSIONS=${TRAVIS_PYTHON_VERSION} -DPythonLibs_FIND_VERSION=${TRAVIS_PYTHON_VERSION} -DPYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/" + - export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION_SHORT}\"`" + - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION_SHORT}*.so\" -print -quit`"; fi; + - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export PYTHON_LIBRARY='#{%x(python-config --prefix).chomp}/lib/libpython2.7.dylib'; fi; + - export CMAKE_ADDITIONAL_OPTIONS="-DPython_ADDITIONAL_VERSIONS=${TRAVIS_PYTHON_VERSION_SHORT} -DPythonLibs_FIND_VERSION=${TRAVIS_PYTHON_VERSION_SHORT} -DPYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python${TRAVIS_PYTHON_VERSION_SHORT}/site-packages/" - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export LD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$LD_LIBRARY_PATH; fi - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export DYLD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$DYLD_LIBRARY_PATH; fi - ./.travis/run build @@ -45,26 +46,28 @@ after_failure: ./.travis/run after_failure matrix: allow_failures: # Known issue with virtualenv - - python: "2.7" + - python: "2.7.6" + - python: "2.7.3" + - os: osx # TODO: Fix ipopt install include: - os: linux dist: trusty language: python - python: "2.7" + python: "2.7.6" # Match the system's version - os: linux dist: trusty language: python - python: "3.5" + python: "3.5.3" # Match the system's version - os: linux dist: precise env: MASTER_PPA="george-edison55/precise-backports" language: python - python: "2.7" + python: "2.7.3" # Match the system's version - os: linux dist: precise env: MASTER_PPA="george-edison55/precise-backports" language: python - python: "3.5" + python: "3.5.2" # Match the system's version - os: osx language: cpp compiler: clang diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b78d3ae..01fefd0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,8 +8,6 @@ INCLUDE_DIRECTORIES(SYSTEM ${NUMPY_INCLUDE_DIRS}) # Compile library ADD_LIBRARY(roboptim-core-python SHARED ${HEADERS} - common.hh - common.cc to-python.cc) TARGET_LINK_LIBRARIES(roboptim-core-python ${PYTHON_LIBRARIES}) @@ -27,7 +25,7 @@ PKG_CONFIG_APPEND_LIBS(roboptim-core-python) SET(LOCAL_MODULE_DIR "${PROJECT_BINARY_DIR}/src") # Compile module -ADD_LIBRARY(wrap MODULE wrap.cc) +ADD_LIBRARY(wrap MODULE common.cc wrap.cc) PKG_CONFIG_USE_DEPENDENCY(wrap roboptim-core) SET_TARGET_PROPERTIES(wrap PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LOCAL_MODULE_DIR}/roboptim/core @@ -36,8 +34,6 @@ SET_TARGET_PROPERTIES(wrap PROPERTIES # Link against Boost. TARGET_LINK_LIBRARIES(wrap ${Boost_LIBRARIES}) -TARGET_LINK_LIBRARIES(wrap roboptim-core-python) - SET_TARGET_PROPERTIES(wrap PROPERTIES PREFIX "") # Install libraries