From 6cfb83b946eebccf299e81abe27f4d6a968ef18f Mon Sep 17 00:00:00 2001 From: Avi Singh Date: Wed, 2 Nov 2016 12:00:25 -0700 Subject: [PATCH 01/10] Remove line which imports caffe stuff --- experiments/reacher_images/hyperparams.py | 1 - 1 file changed, 1 deletion(-) diff --git a/experiments/reacher_images/hyperparams.py b/experiments/reacher_images/hyperparams.py index 5f38d30ce..d400e01e5 100644 --- a/experiments/reacher_images/hyperparams.py +++ b/experiments/reacher_images/hyperparams.py @@ -17,7 +17,6 @@ from gps.algorithm.dynamics.dynamics_prior_gmm import DynamicsPriorGMM from gps.algorithm.traj_opt.traj_opt_lqr_python import TrajOptLQRPython from gps.algorithm.policy.lin_gauss_init import init_lqr, init_pd -from gps.algorithm.policy_opt.policy_opt_caffe import PolicyOptCaffe from gps.algorithm.policy_opt.policy_opt_tf import PolicyOptTf from gps.algorithm.policy.policy_prior_gmm import PolicyPriorGMM from gps.algorithm.policy_opt.tf_model_example import example_tf_network From 2a77eaac999b0ddd73294419d87608e55b8283b8 Mon Sep 17 00:00:00 2001 From: Avi Singh Date: Wed, 2 Nov 2016 16:30:24 -0700 Subject: [PATCH 02/10] Remove old mjcpy2 bindings --- src/3rdparty/Boost.NumPy/.gitignore | 16 - src/3rdparty/Boost.NumPy/CMake-init.sh | 5 - src/3rdparty/Boost.NumPy/CMakeLists.txt | 109 ---- src/3rdparty/Boost.NumPy/Jamroot | 7 - src/3rdparty/Boost.NumPy/LICENSE_1_0.txt | 23 - src/3rdparty/Boost.NumPy/README | 86 --- src/3rdparty/Boost.NumPy/SConscript | 244 --------- src/3rdparty/Boost.NumPy/SConstruct | 21 - src/3rdparty/Boost.NumPy/boost/numpy.hpp | 38 -- .../Boost.NumPy/boost/numpy/dtype.hpp | 115 ---- .../Boost.NumPy/boost/numpy/internal.hpp | 33 -- .../boost/numpy/invoke_matching.hpp | 190 ------- .../Boost.NumPy/boost/numpy/matrix.hpp | 85 --- .../Boost.NumPy/boost/numpy/ndarray.hpp | 303 ----------- .../boost/numpy/numpy_object_mgr_traits.hpp | 35 -- .../Boost.NumPy/boost/numpy/scalars.hpp | 64 --- .../Boost.NumPy/boost/numpy/ufunc.hpp | 213 -------- .../libs/numpy/cmake/FindNumPy.cmake | 90 ---- .../libs/numpy/cmake/FindPythonLibsNew.cmake | 211 -------- .../Boost.NumPy/libs/numpy/cmake/README.txt | 9 - .../Boost.NumPy/libs/numpy/doc/CMakeLists.txt | 56 -- .../Boost.NumPy/libs/numpy/doc/Jamfile | 25 - .../libs/numpy/doc/_static/boost.css | 66 --- .../libs/numpy/doc/_static/style.css | 11 - .../libs/numpy/doc/_templates/layout.html | 120 ----- .../Boost.NumPy/libs/numpy/doc/cmakeBuild.rst | 167 ------ .../Boost.NumPy/libs/numpy/doc/conf.py | 219 -------- .../Boost.NumPy/libs/numpy/doc/index.rst | 17 - .../Boost.NumPy/libs/numpy/doc/make.bat | 170 ------ .../libs/numpy/doc/reference/Jamfile | 25 - .../libs/numpy/doc/reference/binary_ufunc.rst | 104 ---- .../libs/numpy/doc/reference/dtype.rst | 86 --- .../libs/numpy/doc/reference/index.rst | 14 - .../libs/numpy/doc/reference/multi_iter.rst | 91 ---- .../libs/numpy/doc/reference/ndarray.rst | 377 -------------- .../libs/numpy/doc/reference/unary_ufunc.rst | 97 ---- .../Boost.NumPy/libs/numpy/doc/rst.css | 149 ------ .../libs/numpy/doc/tutorial/dtype.rst | 55 -- .../libs/numpy/doc/tutorial/fromdata.rst | 51 -- .../libs/numpy/doc/tutorial/index.rst | 14 - .../libs/numpy/doc/tutorial/ndarray.rst | 94 ---- .../libs/numpy/doc/tutorial/simple.rst | 41 -- .../libs/numpy/doc/tutorial/ufunc.rst | 116 ----- .../libs/numpy/example/CMakeLists.txt | 51 -- .../Boost.NumPy/libs/numpy/example/Jamfile | 20 - .../Boost.NumPy/libs/numpy/example/SConscript | 27 - .../libs/numpy/example/demo_gaussian.py | 37 -- .../Boost.NumPy/libs/numpy/example/dtype.cpp | 49 -- .../libs/numpy/example/fromdata.cpp | 48 -- .../libs/numpy/example/gaussian.cpp | 315 ----------- .../libs/numpy/example/ndarray.cpp | 71 --- .../Boost.NumPy/libs/numpy/example/simple.cpp | 32 -- .../Boost.NumPy/libs/numpy/example/ufunc.cpp | 86 --- .../Boost.NumPy/libs/numpy/example/wrap.cpp | 132 ----- .../Boost.NumPy/libs/numpy/src/CMakeLists.txt | 26 - .../Boost.NumPy/libs/numpy/src/Jamfile | 64 --- .../Boost.NumPy/libs/numpy/src/SConscript | 12 - .../Boost.NumPy/libs/numpy/src/dtype.cpp | 164 ------ .../Boost.NumPy/libs/numpy/src/matrix.cpp | 68 --- .../Boost.NumPy/libs/numpy/src/ndarray.cpp | 281 ---------- .../Boost.NumPy/libs/numpy/src/numpy.cpp | 34 -- .../Boost.NumPy/libs/numpy/src/scalars.cpp | 40 -- .../Boost.NumPy/libs/numpy/src/ufunc.cpp | 69 --- .../libs/numpy/test/CMakeLists.txt | 65 --- .../Boost.NumPy/libs/numpy/test/Jamfile | 23 - .../Boost.NumPy/libs/numpy/test/SConscript | 35 -- .../Boost.NumPy/libs/numpy/test/dtype.py | 60 --- .../Boost.NumPy/libs/numpy/test/dtype_mod.cpp | 48 -- .../Boost.NumPy/libs/numpy/test/indexing.py | 55 -- .../libs/numpy/test/indexing_mod.cpp | 27 - .../Boost.NumPy/libs/numpy/test/ndarray.py | 79 --- .../libs/numpy/test/ndarray_mod.cpp | 45 -- .../libs/numpy/test/runCmakeTest.bat.in | 4 - .../libs/numpy/test/runCmakeTest.sh.in | 3 - .../Boost.NumPy/libs/numpy/test/shapes.py | 21 - .../libs/numpy/test/shapes_mod.cpp | 21 - .../Boost.NumPy/libs/numpy/test/templates.py | 28 - .../libs/numpy/test/templates_mod.cpp | 62 --- .../Boost.NumPy/libs/numpy/test/ufunc.py | 57 -- .../Boost.NumPy/libs/numpy/test/ufunc_mod.cpp | 35 -- src/3rdparty/CMakeLists.txt | 33 -- src/3rdparty/cmake/FindNumpy.cmake | 64 --- src/3rdparty/cmake/boost-python.cmake | 31 -- src/3rdparty/macros.h | 62 --- src/3rdparty/mjcpy2/CMakeLists.txt | 54 -- src/3rdparty/mjcpy2/mj_struct_codegen.py | 98 ---- src/3rdparty/mjcpy2/mjcpy2.cpp | 373 ------------- src/3rdparty/mjcpy2/mjcpy2_getdata_autogen.i | 99 ---- src/3rdparty/mjcpy2/mjcpy2_getmodel_autogen.i | 253 --------- src/3rdparty/mjcpy2/mjcpy2_setdata_autogen.i | 99 ---- src/3rdparty/mjcpy2/mjcpy2_setmodel_autogen.i | 253 --------- src/3rdparty/mjcpy2/mujoco_osg_viewer.cpp | 491 ------------------ src/3rdparty/mjcpy2/mujoco_osg_viewer.hpp | 35 -- src/3rdparty/mjcpy2/test_mujoco_osg.cpp | 28 - 94 files changed, 8329 deletions(-) delete mode 100644 src/3rdparty/Boost.NumPy/.gitignore delete mode 100644 src/3rdparty/Boost.NumPy/CMake-init.sh delete mode 100644 src/3rdparty/Boost.NumPy/CMakeLists.txt delete mode 100644 src/3rdparty/Boost.NumPy/Jamroot delete mode 100644 src/3rdparty/Boost.NumPy/LICENSE_1_0.txt delete mode 100644 src/3rdparty/Boost.NumPy/README delete mode 100644 src/3rdparty/Boost.NumPy/SConscript delete mode 100644 src/3rdparty/Boost.NumPy/SConstruct delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/dtype.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/internal.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/invoke_matching.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/matrix.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/ndarray.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/numpy_object_mgr_traits.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/scalars.hpp delete mode 100644 src/3rdparty/Boost.NumPy/boost/numpy/ufunc.hpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindNumPy.cmake delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindPythonLibsNew.cmake delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/cmake/README.txt delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/CMakeLists.txt delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/Jamfile delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/boost.css delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/style.css delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/_templates/layout.html delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/cmakeBuild.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/conf.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/index.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/make.bat delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/Jamfile delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/binary_ufunc.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/dtype.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/index.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/multi_iter.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/ndarray.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/unary_ufunc.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/rst.css delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/dtype.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/fromdata.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/index.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ndarray.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/simple.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ufunc.rst delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/CMakeLists.txt delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/Jamfile delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/SConscript delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/demo_gaussian.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/dtype.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/fromdata.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/gaussian.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/ndarray.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/simple.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/ufunc.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/example/wrap.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/CMakeLists.txt delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/Jamfile delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/SConscript delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/dtype.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/matrix.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/ndarray.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/numpy.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/scalars.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/src/ufunc.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/CMakeLists.txt delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/Jamfile delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/SConscript delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/dtype.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/dtype_mod.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/indexing.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/indexing_mod.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray_mod.cpp delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.bat.in delete mode 100755 src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.sh.in delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/shapes.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/shapes_mod.cpp delete mode 100755 src/3rdparty/Boost.NumPy/libs/numpy/test/templates.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/templates_mod.cpp delete mode 100755 src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc.py delete mode 100644 src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc_mod.cpp delete mode 100644 src/3rdparty/CMakeLists.txt delete mode 100644 src/3rdparty/cmake/FindNumpy.cmake delete mode 100644 src/3rdparty/cmake/boost-python.cmake delete mode 100644 src/3rdparty/macros.h delete mode 100644 src/3rdparty/mjcpy2/CMakeLists.txt delete mode 100644 src/3rdparty/mjcpy2/mj_struct_codegen.py delete mode 100755 src/3rdparty/mjcpy2/mjcpy2.cpp delete mode 100644 src/3rdparty/mjcpy2/mjcpy2_getdata_autogen.i delete mode 100644 src/3rdparty/mjcpy2/mjcpy2_getmodel_autogen.i delete mode 100644 src/3rdparty/mjcpy2/mjcpy2_setdata_autogen.i delete mode 100644 src/3rdparty/mjcpy2/mjcpy2_setmodel_autogen.i delete mode 100755 src/3rdparty/mjcpy2/mujoco_osg_viewer.cpp delete mode 100755 src/3rdparty/mjcpy2/mujoco_osg_viewer.hpp delete mode 100644 src/3rdparty/mjcpy2/test_mujoco_osg.cpp diff --git a/src/3rdparty/Boost.NumPy/.gitignore b/src/3rdparty/Boost.NumPy/.gitignore deleted file mode 100644 index 024e2344f..000000000 --- a/src/3rdparty/Boost.NumPy/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -config.log -.sconf_temp -.sconsign.dblite -*.os -*.succeeded -libs/numpy/example/dtype -libs/numpy/example/fromdata -libs/numpy/example/ndarray -libs/numpy/example/simple -libs/numpy/example/ufunc -libs/numpy/example/wrap -build -build-vc90 -build-vc100 -*~ -\#*\# \ No newline at end of file diff --git a/src/3rdparty/Boost.NumPy/CMake-init.sh b/src/3rdparty/Boost.NumPy/CMake-init.sh deleted file mode 100644 index c86353650..000000000 --- a/src/3rdparty/Boost.NumPy/CMake-init.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -mkdir build -cd build -cmake -D Boost_NO_BOOST_CMAKE=ON .. \ No newline at end of file diff --git a/src/3rdparty/Boost.NumPy/CMakeLists.txt b/src/3rdparty/Boost.NumPy/CMakeLists.txt deleted file mode 100644 index cffd33f98..000000000 --- a/src/3rdparty/Boost.NumPy/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -cmake_minimum_required(VERSION 2.8.0) - -# project( boost.numpy ) - -# put our local cmake find scripts at the beginning of the cmake -# module search path -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/numpy/cmake ${CMAKE_MODULE_PATH}) - -# configure output folders so artifacts are built into a single set of -# top-level folders rather than the default cmake build structure that -# matches the source tree. - -# find required python packages -find_package(PythonLibs 2.7 REQUIRED) -find_package(NumPy REQUIRED) - -# find boost -# -# set(Boost_USE_STATIC_LIBS ON) -# set(Boost_USE_MULTITHREADED ON) -# set(Boost_USE_STATIC_RUNTIME ON) -FIND_PACKAGE(Boost COMPONENTS python REQUIRED) - -message( STATUS "found boost:" - "\nINCLUDE: ${Boost_INCLUDE_DIRS}" - "\nLIB: ${Boost_LIBRARIES}" -) - -# add_definitions( -DBOOST_ALL_NO_LIB ) -# In some cases, you may need to explicitly specify that a dynamic Boost is used; if so use: -# add_definitions( -DBOOST_ALL_DYN_LINK ) - -# variable controlling whether the boost_numpy is a shared or static library -if (WIN32) - set(LIBRARY_TYPE STATIC CACHE STRING "type of library to make for boost_numpy") -else() - set(LIBRARY_TYPE SHARED CACHE STRING "type of library to make for boost_numpy") -endif() - -# variable controlling building of documentation -set(BUILD_DOCS OFF CACHE BOOL "Build Boost.NumPy Documentation") - -# logic for configuring documentation generation -if(BUILD_DOCS) - # find sphinx - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__" - RESULT_VARIABLE SPHINX_PROCESS - OUTPUT_VARIABLE SPHINX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(HAVE_SPHINX 0) - if(SPHINX_PROCESS EQUAL 0) - FIND_PROGRAM(SPHINX_BUILD sphinx-build) - if(SPHINX_BUILD) - set(HAVE_SPHINX 1) - message(STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}") - else() - # sphinx is required to generate documention, so it is an error - # if we cannot find it - MESSAGE(SEND_ERROR "must be able to find sphinx-build when BUILD_DOCS is enabled") - endif() - endif() - - # find pdflatex, which is only required for doc-pdf - FIND_PACKAGE(LATEX) - if (PDFLATEX_COMPILER) - message( STATUS "Found PDFLATEX_COMPILER=${PDFLATEX_COMPILER}" ) - else() - message( STATUS "Found PDFLATEX_COMPILER NOT found" ) - endif() -endif() - -# compiler definitions for non-windows builds -if (NOT WIN32) - add_definitions(-fPIC) -endif() - -# enable ctest targets -ENABLE_TESTING() - -# turn on visual studio solution folders -SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) - -# global settings for include paths -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${PYTHON_INCLUDE_DIRS} - ${NUMPY_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ) - -# install headers -install(DIRECTORY boost - DESTINATION "include" - FILES_MATCHING - PATTERN "*.hpp" - ${INSTALL_PERMISSIONS_SRC} - ) - -# add submodules -ADD_SUBDIRECTORY(libs/numpy/src) -# ADD_SUBDIRECTORY(libs/numpy/example) -# ADD_SUBDIRECTORY(libs/numpy/test) - -if (BUILD_DOCS) - ADD_SUBDIRECTORY(libs/numpy/doc) -endif() - - diff --git a/src/3rdparty/Boost.NumPy/Jamroot b/src/3rdparty/Boost.NumPy/Jamroot deleted file mode 100644 index aeaff166a..000000000 --- a/src/3rdparty/Boost.NumPy/Jamroot +++ /dev/null @@ -1,7 +0,0 @@ - - -project boost_numpy - : requirements . - : build-dir bin.v2 - ; - diff --git a/src/3rdparty/Boost.NumPy/LICENSE_1_0.txt b/src/3rdparty/Boost.NumPy/LICENSE_1_0.txt deleted file mode 100644 index 36b7cd93c..000000000 --- a/src/3rdparty/Boost.NumPy/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/src/3rdparty/Boost.NumPy/README b/src/3rdparty/Boost.NumPy/README deleted file mode 100644 index b24d4bae1..000000000 --- a/src/3rdparty/Boost.NumPy/README +++ /dev/null @@ -1,86 +0,0 @@ -Boost.NumPy is an extension for Boost.Python that adds NumPy support. - -It is intended as a replacement for the old numeric support in -Boost.Python proper, which is now out-of-date and does not support -C/C++ pointer access to the data. Because it builds against the NumPy -headers and hence has a dependency that Boost.Python does not, it is -intended to be built as a separate library. This is also not intended -to be a high-level C++ array library; it would be more accurate to -consider it a C++ NumPy API, with the intent of making the NumPy C-API -available in a form that is safer and more convenient for C++ users -(and particularly those using Boost.Python, of course). - -THIS IS NOT AN OFFICIAL BOOST LIBRARY - -...we're just calling it Boost.NumPy right now because that clearly -indicates that it's for Boost.Python and NumPy. We do intend to -propose it for inclusion in Boost eventually. - - -INSTALLATION - -We have provided three build systems: Boost.Build, SCons, and CMake -build system. At the moment, we recommend using SCons or CMake on -Linux and CMake on Windows. - -Building with SCons should be as simple as running "scons" and "scons -install", but you may need to use the "--with-boost*" options (see -"scons --help") to specify where to find Boost. The Python that is -used by SCons will be the one built against. - -Please see libs/numpy/doc/cmakeBuild.rst for more information on -building with CMake. - - -DOCUMENTATION - -More documentation on how to use the library can be found in -libs/numpy/doc, but it may be most useful to start with the -examples in libs/numpy/examples. The headers files are also -well documented and are intended to serve as a reference. - - -ISSUES AND NEW FEATURES - -Please create an issue on the GitHub site at: - -https://github.com/ndarray/Boost.NumPy/issues - - -CONTACT - -Please send email questions to: - -ndarray-dev@googlegroups.com - -...but I would prefer bug reports and feature requests to go to -the GitHub issues list (see above). - - -MULTI-PLATFORM SUPPORT - -The vast majority of development has happened on Linux/g++, and while -we have taken some steps to support MacOS/clang, there hasn't been -much testing. There has been no testing on Windows, though we have -no reason to believe anything we've done won't work on Windows. - -In short, we'd really love to have some testing on additional platforms, -especially from people who know their way around SCons, NumPy, or -Boost.Python. - - -HISTORY/AUTHORS - -Boost.NumPy was originally written by Jim Bosch as part of the -"ndarray" C++ library, then reorganized into a standalone component, -cleaned up, and documented as part of a Boost-sponsored -Google Summer of Code by Ankit Daftery, mentored by Stefan Seefeld. -Philip Miller contributed the CMake build system. - -The project is hosted both on the Boost Sandbox: - -https://svn.boost.org/svn/boost/sandbox/numpy - -and on GitHub: - -https://github.com/ndarray/Boost.NumPy diff --git a/src/3rdparty/Boost.NumPy/SConscript b/src/3rdparty/Boost.NumPy/SConscript deleted file mode 100644 index e5072565e..000000000 --- a/src/3rdparty/Boost.NumPy/SConscript +++ /dev/null @@ -1,244 +0,0 @@ -# -*- python -*- - -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# Big thanks to Mike Jarvis for help with the configuration prescriptions below. - -import os -import sys -import subprocess -from SCons.SConf import CheckContext - -def setupPaths(env, prefix, include, lib): - if prefix is not None: - if include is None: - include = os.path.join(prefix, "include") - if lib is None: - lib = os.path.join(prefix, "lib") - if include: - env.PrependUnique(CPPPATH=[include]) - if lib: - env.PrependUnique(LIBPATH=[lib]) -AddMethod(Environment, setupPaths) - -def checkLibs(context, try_libs, source_file): - init_libs = context.env.get('LIBS', []) - context.env.PrependUnique(LIBS=[try_libs]) - result = context.TryLink(source_file, '.cpp') - if not result : - context.env.Replace(LIBS=init_libs) - return result -AddMethod(CheckContext, checkLibs) - -def CheckPython(context): - python_source_file = """ -#include "Python.h" -int main() -{ - Py_Initialize(); - Py_Finalize(); - return 0; -} -""" - context.Message('Checking if we can build against Python... ') - try: - import distutils.sysconfig - except ImportError: - context.Result(0) - print 'Failed to import distutils.sysconfig.' - return False - context.env.AppendUnique(CPPPATH=[distutils.sysconfig.get_python_inc()]) - libDir = distutils.sysconfig.get_config_var("LIBDIR") - context.env.AppendUnique(LIBPATH=[libDir]) - libfile = distutils.sysconfig.get_config_var("LIBRARY") - import re - match = re.search("(python.*)\.(a|so|dylib)", libfile) - if match: - context.env.AppendUnique(LIBS=[match.group(1)]) - if match.group(2) == 'a': - flags = distutils.sysconfig.get_config_var('LINKFORSHARED') - if flags is not None: - context.env.AppendUnique(LINKFLAGS=flags.split()) - flags = [f for f in " ".join(distutils.sysconfig.get_config_vars("MODLIBS", "SHLIBS")).split() - if f != "-L"] - context.env.MergeFlags(" ".join(flags)) - result, output = context.TryRun(python_source_file,'.cpp') - if not result and context.env["PLATFORM"] == 'darwin': - # Sometimes we need some extra stuff on Mac OS - frameworkDir = libDir # search up the libDir tree for the proper home for frameworks - while frameworkDir and frameworkDir != "/": - frameworkDir, d2 = os.path.split(frameworkDir) - if d2 == "Python.framework": - if not "Python" in os.listdir(os.path.join(frameworkDir, d2)): - context.Result(0) - print ( - "Expected to find Python in framework directory %s, but it isn't there" - % frameworkDir) - return False - break - context.env.AppendUnique(LINKFLAGS="-F%s" % frameworkDir) - result, output = context.TryRun(python_source_file,'.cpp') - if not result: - context.Result(0) - print "Cannot run program built with Python." - return False - if context.env["PLATFORM"] == "darwin": - context.env["LDMODULESUFFIX"] = ".so" - context.Result(1) - return True - -def CheckNumPy(context): - numpy_source_file = """ -#include "Python.h" -#include "numpy/arrayobject.h" -void doImport() { - import_array(); -} -int main() -{ - int result = 0; - Py_Initialize(); - doImport(); - if (PyErr_Occurred()) { - result = 1; - } else { - npy_intp dims = 2; - PyObject * a = PyArray_SimpleNew(1, &dims, NPY_INT); - if (!a) result = 1; - Py_DECREF(a); - } - Py_Finalize(); - return result; -} -""" - context.Message('Checking if we can build against NumPy... ') - try: - import numpy - except ImportError: - context.Result(0) - print 'Failed to import numpy.' - print 'Things to try:' - print '1) Check that the command line python (with which you probably installed numpy):' - print ' ', - sys.stdout.flush() - subprocess.call('which python',shell=True) - print ' is the same as the one used by SCons:' - print ' ',sys.executable - print ' If not, then you probably need to reinstall numpy with %s.' % sys.executable - print ' Alternatively, you can reinstall SCons with your preferred python.' - print '2) Check that if you open a python session from the command line,' - print ' import numpy is successful there.' - return False - context.env.Append(CPPPATH=numpy.get_include()) - result = context.checkLibs([''],numpy_source_file) - if not result: - context.Result(0) - print "Cannot build against NumPy." - return False - result, output = context.TryRun(numpy_source_file,'.cpp') - if not result: - context.Result(0) - print "Cannot run program built with NumPy." - return False - context.Result(1) - return True - -def CheckBoostPython(context): - bp_source_file = """ -#include "boost/python.hpp" -class Foo { public: Foo() {} }; -int main() -{ - Py_Initialize(); - boost::python::object obj; - boost::python::class_< Foo >("Foo", boost::python::init<>()); - Py_Finalize(); - return 0; -} -""" - context.Message('Checking if we can build against Boost.Python... ') - context.env.setupPaths( - prefix = GetOption("boost_prefix"), - include = GetOption("boost_include"), - lib = GetOption("boost_lib") - ) - result = ( - context.checkLibs([''], bp_source_file) or - context.checkLibs(['boost_python'], bp_source_file) or - context.checkLibs(['boost_python-mt'], bp_source_file) - ) - if not result: - context.Result(0) - print "Cannot build against Boost.Python." - return False - result, output = context.TryRun(bp_source_file, '.cpp') - if not result: - context.Result(0) - print "Cannot run program built against Boost.Python." - return False - context.Result(1) - return True - -# Setup command-line options -def setupOptions(): - AddOption("--prefix", dest="prefix", type="string", nargs=1, action="store", - metavar="DIR", default="/usr/local", help="installation prefix") - AddOption("--install-headers", dest="install_headers", type="string", nargs=1, action="store", - metavar="DIR", help="location to install header files (overrides --prefix for headers)") - AddOption("--install-lib", dest="install_lib", type="string", nargs=1, action="store", - metavar="DIR", help="location to install libraries (overrides --prefix for libraries)") - AddOption("--with-boost", dest="boost_prefix", type="string", nargs=1, action="store", - metavar="DIR", default=os.environ.get("BOOST_DIR"), - help="prefix for Boost libraries; should have 'include' and 'lib' subdirectories") - AddOption("--with-boost-include", dest="boost_include", type="string", nargs=1, action="store", - metavar="DIR", help="location of Boost header files") - AddOption("--with-boost-lib", dest="boost_lib", type="string", nargs=1, action="store", - metavar="DIR", help="location of Boost libraries") - AddOption("--rpath", dest="custom_rpath", type="string", action="append", - help="runtime link paths to add to libraries and executables; may be passed more than once") - variables = Variables() - variables.Add("CCFLAGS", default=os.environ.get("CCFLAGS", "-O2 -g"), help="compiler flags") - return variables - -def makeEnvironment(variables): - shellEnv = {} - for key in ("PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "PYTHONPATH"): - if key in os.environ: - shellEnv[key] = os.environ[key] - env = Environment(variables=variables, ENV=shellEnv) - if os.environ.has_key("CCFLAGS"): - env.AppendUnique(CCFLAGS = os.environ["CCFLAGS"]) - custom_rpath = GetOption("custom_rpath") - if custom_rpath is not None: - env.AppendUnique(RPATH=custom_rpath) - boost_lib = GetOption ('boost_lib') - if boost_lib is not None: - env.PrependUnique(LIBPATH=boost_lib) - return env - -def setupTargets(env, root="."): - lib = SConscript(os.path.join(root, "libs", "numpy", "src", "SConscript"), exports='env') - example = SConscript(os.path.join(root, "libs", "numpy", "example", "SConscript"), exports='env') - test = SConscript(os.path.join(root, "libs", "numpy", "test", "SConscript"), exports='env') - prefix = Dir(GetOption("prefix")).abspath - install_headers = GetOption('install_headers') - install_lib = GetOption('install_lib') - if not install_headers: - install_headers = os.path.join(prefix, "include") - if not install_lib: - install_lib = os.path.join(prefix, "lib") - env.Alias("install", env.Install(install_lib, lib)) - for header in ("dtype.hpp", "invoke_matching.hpp", "matrix.hpp", - "ndarray.hpp", "numpy_object_mgr_traits.hpp", - "scalars.hpp", "ufunc.hpp",): - env.Alias("install", env.Install(os.path.join(install_headers, "boost", "numpy"), - os.path.join(root, "boost", "numpy", header))) - env.Alias("install", env.Install(os.path.join(install_headers, "boost"), - os.path.join(root, "boost", "numpy.hpp"))) - -checks = {"CheckPython": CheckPython, "CheckNumPy": CheckNumPy, "CheckBoostPython": CheckBoostPython} - -Return("setupOptions", "makeEnvironment", "setupTargets", "checks") diff --git a/src/3rdparty/Boost.NumPy/SConstruct b/src/3rdparty/Boost.NumPy/SConstruct deleted file mode 100644 index f80ee9c01..000000000 --- a/src/3rdparty/Boost.NumPy/SConstruct +++ /dev/null @@ -1,21 +0,0 @@ -# -*- python -*- - -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -setupOptions, makeEnvironment, setupTargets, checks = SConscript("SConscript") - -variables = setupOptions() - -env = makeEnvironment(variables) -env.AppendUnique(CPPPATH="#.") - -if not GetOption("help") and not GetOption("clean"): - config = env.Configure(custom_tests=checks) - if not (config.CheckPython() and config.CheckNumPy() and config.CheckBoostPython()): - Exit(1) - env = config.Finish() - -setupTargets(env) diff --git a/src/3rdparty/Boost.NumPy/boost/numpy.hpp b/src/3rdparty/Boost.NumPy/boost/numpy.hpp deleted file mode 100644 index e4fb087e9..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_HPP_INCLUDED -#define BOOST_NUMPY_HPP_INCLUDED - -/** - * @file boost/numpy.hpp - * @brief Main public header file for boost.numpy. - */ - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace numpy { - -/** - * @brief Initialize the Numpy C-API - * - * This must be called before using anything in boost.numpy; - * It should probably be the first line inside BOOST_PYTHON_MODULE. - * - * @internal This just calls the Numpy C-API functions "import_array()" - * and "import_ufunc()", and then calls - * dtype::register_scalar_converters(). - */ -void initialize(bool register_scalar_converters=true); - -} // namespace boost::numpy -} // namespace boost - -#endif // !BOOST_NUMPY_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/dtype.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/dtype.hpp deleted file mode 100644 index 9d92f0087..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/dtype.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_DTYPE_HPP_INCLUDED -#define BOOST_NUMPY_DTYPE_HPP_INCLUDED - -/** - * @file boost/numpy/dtype.hpp - * @brief Object manager for Python's numpy.dtype class. - */ - -#include -#include - -#include -#include - -namespace boost { namespace numpy { - -/** - * @brief A boost.python "object manager" (subclass of object) for numpy.dtype. - * - * @todo This could have a lot more interesting accessors. - */ -class dtype : public python::object { - static python::detail::new_reference convert(python::object::object_cref arg, bool align); -public: - - /// @brief Convert an arbitrary Python object to a data-type descriptor object. - template - explicit dtype(T arg, bool align=false) : python::object(convert(arg, align)) {} - - /** - * @brief Get the built-in numpy dtype associated with the given scalar template type. - * - * This is perhaps the most useful part of the numpy API: it returns the dtype object - * corresponding to a built-in C++ type. This should work for any integer or floating point - * type supported by numpy, and will also work for std::complex if - * sizeof(std::complex) == 2*sizeof(T). - * - * It can also be useful for users to add explicit specializations for POD structs - * that return field-based dtypes. - */ - template static dtype get_builtin(); - - /// @brief Return the size of the data type in bytes. - int get_itemsize() const; - - /** - * @brief Compare two dtypes for equivalence. - * - * This is more permissive than equality tests. For instance, if long and int are the same - * size, the dtypes corresponding to each will be equivalent, but not equal. - */ - friend bool equivalent(dtype const & a, dtype const & b); - - /** - * @brief Register from-Python converters for NumPy's built-in array scalar types. - * - * This is usually called automatically by initialize(), and shouldn't be called twice - * (doing so just adds unused converters to the Boost.Python registry). - */ - static void register_scalar_converters(); - - BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dtype, python::object); - -}; - -bool equivalent(dtype const & a, dtype const & b); - -namespace detail -{ - -template dtype get_int_dtype(); - -template dtype get_float_dtype(); - -template dtype get_complex_dtype(); - -template ::value> -struct builtin_dtype; - -template -struct builtin_dtype { - static dtype get() { return get_int_dtype< 8*sizeof(T), boost::is_unsigned::value >(); } -}; - -template <> -struct builtin_dtype { - static dtype get(); -}; - -template -struct builtin_dtype { - static dtype get() { return get_float_dtype< 8*sizeof(T) >(); } -}; - -template -struct builtin_dtype< std::complex, false > { - static dtype get() { return get_complex_dtype< 16*sizeof(T) >(); } -}; - -} // namespace detail - -template -inline dtype dtype::get_builtin() { return detail::builtin_dtype::get(); } - -}} // namespace boost::numpy - -namespace boost { namespace python { namespace converter { -NUMPY_OBJECT_MANAGER_TRAITS(numpy::dtype); -}}} // namespace boost::python::converter - -#endif // !BOOST_NUMPY_DTYPE_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/internal.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/internal.hpp deleted file mode 100644 index 400a584b0..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/internal.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_INTERNAL_HPP_INCLUDED -#define BOOST_NUMPY_INTERNAL_HPP_INCLUDED - -/** - * @file boost/numpy/internal.hpp - * @brief Internal header file to include the Numpy C-API headers. - * - * This should only be included by source files in the boost.numpy library itself. - */ - -#include -#ifdef BOOST_NUMPY_INTERNAL -#define NO_IMPORT_ARRAY -#define NO_IMPORT_UFUNC -#else -#ifndef BOOST_NUMPY_INTERNAL_MAIN -ERROR_internal_hpp_is_for_internal_use_only -#endif -#endif -#define PY_ARRAY_UNIQUE_SYMBOL BOOST_NUMPY_ARRAY_API -#define PY_UFUNC_UNIQUE_SYMBOL BOOST_UFUNC_ARRAY_API -#include -#include -#include - -#define NUMPY_OBJECT_MANAGER_TRAITS_IMPL(pytype,manager) \ - PyTypeObject const * object_manager_traits::get_pytype() { return &pytype; } - -#endif // !BOOST_NUMPY_INTERNAL_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/invoke_matching.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/invoke_matching.hpp deleted file mode 100644 index 6a4dfdb19..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/invoke_matching.hpp +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_INVOKE_MATCHING_HPP_INCLUDED -#define BOOST_NUMPY_INVOKE_MATCHING_HPP_INCLUDED - -/** - * @file boost/numpy/invoke_matching.hpp - * @brief Template invocation based on dtype matching. - */ - -#include -#include - -#include - -namespace boost -{ -namespace numpy -{ -namespace detail -{ - -struct add_pointer_meta -{ - template - struct apply - { - typedef typename boost::add_pointer::type type; - }; - -}; - -struct dtype_template_match_found {}; -struct nd_template_match_found {}; - -template -struct dtype_template_invoker -{ - - template - void operator()(T *) const - { - if (dtype::get_builtin() == m_dtype) - { - m_func.Function::template apply(); - throw dtype_template_match_found(); - } - } - - dtype_template_invoker(dtype const & dtype_, Function func) - : m_dtype(dtype_), m_func(func) {} - -private: - dtype const & m_dtype; - Function m_func; -}; - -template -struct dtype_template_invoker< boost::reference_wrapper > -{ - - template - void operator()(T *) const - { - if (dtype::get_builtin() == m_dtype) - { - m_func.Function::template apply(); - throw dtype_template_match_found(); - } - } - - dtype_template_invoker(dtype const & dtype_, Function & func) - : m_dtype(dtype_), m_func(func) {} - -private: - dtype const & m_dtype; - Function & m_func; -}; - -template -struct nd_template_invoker -{ - template - void operator()(boost::mpl::integral_c *) const - { - if (m_nd == N) - { - m_func.Function::template apply(); - throw nd_template_match_found(); - } - } - - nd_template_invoker(int nd, Function func) : m_nd(nd), m_func(func) {} - -private: - int m_nd; - Function m_func; -}; - -template -struct nd_template_invoker< boost::reference_wrapper > -{ - template - void operator()(boost::mpl::integral_c *) const - { - if (m_nd == N) - { - m_func.Function::template apply(); - throw nd_template_match_found(); - } - } - - nd_template_invoker(int nd, Function & func) : m_nd(nd), m_func(func) {} - -private: - int m_nd; - Function & m_func; -}; - -} // namespace boost::numpy::detail - -template -void invoke_matching_nd(int nd, Function f) -{ - detail::nd_template_invoker invoker(nd, f); - try { boost::mpl::for_each< Sequence, detail::add_pointer_meta >(invoker);} - catch (detail::nd_template_match_found &) { return;} - PyErr_SetString(PyExc_TypeError, "number of dimensions not found in template list."); - python::throw_error_already_set(); -} - -template -void invoke_matching_dtype(dtype const & dtype_, Function f) -{ - detail::dtype_template_invoker invoker(dtype_, f); - try { boost::mpl::for_each< Sequence, detail::add_pointer_meta >(invoker);} - catch (detail::dtype_template_match_found &) { return;} - PyErr_SetString(PyExc_TypeError, "dtype not found in template list."); - python::throw_error_already_set(); -} - -namespace detail -{ - -template -struct array_template_invoker_wrapper_2 -{ - template - void apply() const { m_func.Function::template apply();} - array_template_invoker_wrapper_2(Function & func) : m_func(func) {} - -private: - Function & m_func; -}; - -template -struct array_template_invoker_wrapper_1 -{ - template - void apply() const { invoke_matching_nd(m_nd, array_template_invoker_wrapper_2(m_func));} - array_template_invoker_wrapper_1(int nd, Function & func) : m_nd(nd), m_func(func) {} - -private: - int m_nd; - Function & m_func; -}; - -template -struct array_template_invoker_wrapper_1< DimSequence, boost::reference_wrapper > - : public array_template_invoker_wrapper_1< DimSequence, Function > -{ - array_template_invoker_wrapper_1(int nd, Function & func) - : array_template_invoker_wrapper_1< DimSequence, Function >(nd, func) {} -}; - -} // namespace boost::numpy::detail - -template -void invoke_matching_array(ndarray const & array_, Function f) -{ - detail::array_template_invoker_wrapper_1 wrapper(array_.get_nd(), f); - invoke_matching_dtype(array_.get_dtype(), wrapper); -} - -} // namespace boost::numpy -} // namespace boost - -#endif // !BOOST_NUMPY_INVOKE_MATCHING_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/matrix.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/matrix.hpp deleted file mode 100644 index ff165f81e..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/matrix.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_MATRIX_HPP_INCLUDED -#define BOOST_NUMPY_MATRIX_HPP_INCLUDED - -/** - * @file boost/numpy/matrix.hpp - * @brief Object manager for numpy.matrix. - */ - -#include -#include -#include - -namespace boost -{ -namespace numpy -{ - -/** - * @brief A boost.python "object manager" (subclass of object) for numpy.matrix. - * - * @internal numpy.matrix is defined in Python, so object_manager_traits::get_pytype() - * is implemented by importing numpy and getting the "matrix" attribute of the module. - * We then just hope that doesn't get destroyed while we need it, because if we put - * a dynamic python object in a static-allocated boost::python::object or handle<>, - * bad things happen when Python shuts down. I think this solution is safe, but I'd - * love to get that confirmed. - */ -class matrix : public ndarray -{ - static python::object construct(object_cref obj, dtype const & dt, bool copy); - static python::object construct(object_cref obj, bool copy); -public: - - BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(matrix, ndarray); - - /// @brief Equivalent to "numpy.matrix(obj,dt,copy)" in Python. - explicit matrix(python::object const & obj, dtype const & dt, bool copy=true) - : ndarray(python::extract(construct(obj, dt, copy))) {} - - /// @brief Equivalent to "numpy.matrix(obj,copy=copy)" in Python. - explicit matrix(python::object const & obj, bool copy=true) - : ndarray(python::extract(construct(obj, copy))) {} - - /// \brief Return a view of the matrix with the given dtype. - matrix view(dtype const & dt) const; - - /// \brief Copy the scalar (deep for all non-object fields). - matrix copy() const; - - /// \brief Transpose the matrix. - matrix transpose() const; - -}; - -/** - * @brief CallPolicies that causes a function that returns a numpy.ndarray to - * return a numpy.matrix instead. - */ -template -struct as_matrix : Base { - static PyObject * postcall(PyObject *, PyObject * result) { - python::object a = python::object(python::handle<>(result)); - numpy::matrix m(a, false); - Py_INCREF(m.ptr()); - return m.ptr(); - } -}; - -} // namespace boost::numpy -namespace python -{ -namespace converter -{ - -NUMPY_OBJECT_MANAGER_TRAITS(numpy::matrix); - -} // namespace boost::python::converter -} // namespace boost::python -} // namespace boost - -#endif // !BOOST_NUMPY_MATRIX_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/ndarray.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/ndarray.hpp deleted file mode 100644 index ee5800c0e..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/ndarray.hpp +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_NDARRAY_HPP_INCLUDED -#define BOOST_NUMPY_NDARRAY_HPP_INCLUDED - -/** - * @file boost/numpy/ndarray.hpp - * @brief Object manager and various utilities for numpy.ndarray. - */ - -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace numpy -{ - -/** - * @brief A boost.python "object manager" (subclass of object) for numpy.ndarray. - * - * @todo This could have a lot more functionality (like boost::python::numeric::array). - * Right now all that exists is what was needed to move raw data between C++ and Python. - */ -class ndarray : public python::object -{ - - /** - * @brief An internal struct that's byte-compatible with PyArrayObject. - * - * This is just a hack to allow inline access to this stuff while hiding numpy/arrayobject.h - * from the user. - */ - struct array_struct - { - PyObject_HEAD - char * data; - int nd; - Py_intptr_t * shape; - Py_intptr_t * strides; - PyObject * base; - PyObject * descr; - int flags; - PyObject * weakreflist; - }; - - /// @brief Return the held Python object as an array_struct. - array_struct * get_struct() const { return reinterpret_cast(this->ptr()); } - -public: - - /** - * @brief Enum to represent (some) of Numpy's internal flags. - * - * These don't match the actual Numpy flag values; we can't get those without including - * numpy/arrayobject.h or copying them directly. That's very unfortunate. - * - * @todo I'm torn about whether this should be an enum. It's very convenient to not - * make these simple integer values for overloading purposes, but the need to - * define every possible combination and custom bitwise operators is ugly. - */ - enum bitflag - { - NONE=0x0, C_CONTIGUOUS=0x1, F_CONTIGUOUS=0x2, V_CONTIGUOUS=0x1|0x2, - ALIGNED=0x4, WRITEABLE=0x8, BEHAVED=0x4|0x8, - CARRAY_RO=0x1|0x4, CARRAY=0x1|0x4|0x8, CARRAY_MIS=0x1|0x8, - FARRAY_RO=0x2|0x4, FARRAY=0x2|0x4|0x8, FARRAY_MIS=0x2|0x8, - UPDATE_ALL=0x1|0x2|0x4, VARRAY=0x1|0x2|0x8, ALL=0x1|0x2|0x4|0x8 - }; - - BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(ndarray, object); - - /// @brief Return a view of the scalar with the given dtype. - ndarray view(dtype const & dt) const; - - /// @brief Copy the array, cast to a specified type. - ndarray astype(dtype const & dt) const; - - /// @brief Copy the scalar (deep for all non-object fields). - ndarray copy() const; - - /// @brief Return the size of the nth dimension. - int const shape(int n) const { return get_shape()[n]; } - - /// @brief Return the stride of the nth dimension. - int const strides(int n) const { return get_strides()[n]; } - - /** - * @brief Return the array's raw data pointer. - * - * This returns char so stride math works properly on it. It's pretty much - * expected that the user will have to reinterpret_cast it. - */ - char * get_data() const { return get_struct()->data; } - - /// @brief Return the array's data-type descriptor object. - dtype get_dtype() const; - - /// @brief Return the object that owns the array's data, or None if the array owns its own data. - python::object get_base() const; - - /// @brief Set the object that owns the array's data. Use with care. - void set_base(object const & base); - - /// @brief Return the shape of the array as an array of integers (length == get_nd()). - Py_intptr_t const * get_shape() const { return get_struct()->shape; } - - /// @brief Return the stride of the array as an array of integers (length == get_nd()). - Py_intptr_t const * get_strides() const { return get_struct()->strides; } - - /// @brief Return the number of array dimensions. - int const get_nd() const { return get_struct()->nd; } - - /// @brief Return the array flags. - bitflag const get_flags() const; - - /// @brief Reverse the dimensions of the array. - ndarray transpose() const; - - /// @brief Eliminate any unit-sized dimensions. - ndarray squeeze() const; - - /// @brief Equivalent to self.reshape(*shape) in Python. - ndarray reshape(python::tuple const & shape) const; - - /** - * @brief If the array contains only a single element, return it as an array scalar; otherwise return - * the array. - * - * @internal This is simply a call to PyArray_Return(); - */ - python::object scalarize() const; -}; - -/** - * @brief Construct a new array with the given shape and data type, with data initialized to zero. - */ -ndarray zeros(python::tuple const & shape, dtype const & dt); -ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt); - -/** - * @brief Construct a new array with the given shape and data type, with data left uninitialized. - */ -ndarray empty(python::tuple const & shape, dtype const & dt); -ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt); - -/** - * @brief Construct a new array from an arbitrary Python sequence. - * - * @todo This does't seem to handle ndarray subtypes the same way that "numpy.array" does in Python. - */ -ndarray array(python::object const & obj); -ndarray array(python::object const & obj, dtype const & dt); - -namespace detail -{ - -ndarray from_data_impl(void * data, - dtype const & dt, - std::vector const & shape, - std::vector const & strides, - python::object const & owner, - bool writeable); - -template -ndarray from_data_impl(void * data, - dtype const & dt, - Container shape, - Container strides, - python::object const & owner, - bool writeable, - typename boost::enable_if< boost::is_integral >::type * enabled = NULL) -{ - std::vector shape_(shape.begin(),shape.end()); - std::vector strides_(strides.begin(), strides.end()); - return from_data_impl(data, dt, shape_, strides_, owner, writeable); -} - -ndarray from_data_impl(void * data, - dtype const & dt, - python::object const & shape, - python::object const & strides, - python::object const & owner, - bool writeable); - -} // namespace boost::numpy::detail - -/** - * @brief Construct a new ndarray object from a raw pointer. - * - * @param[in] data Raw pointer to the first element of the array. - * @param[in] dt Data type descriptor. Often retrieved with dtype::get_builtin(). - * @param[in] shape Shape of the array as STL container of integers; must have begin() and end(). - * @param[in] strides Shape of the array as STL container of integers; must have begin() and end(). - * @param[in] owner An arbitray Python object that owns that data pointer. The array object will - * keep a reference to the object, and decrement it's reference count when the - * array goes out of scope. Pass None at your own peril. - * - * @todo Should probably take ranges of iterators rather than actual container objects. - */ -template -inline ndarray from_data(void * data, - dtype const & dt, - Container shape, - Container strides, - python::object const & owner) -{ - return numpy::detail::from_data_impl(data, dt, shape, strides, owner, true); -} - -/** - * @brief Construct a new ndarray object from a raw pointer. - * - * @param[in] data Raw pointer to the first element of the array. - * @param[in] dt Data type descriptor. Often retrieved with dtype::get_builtin(). - * @param[in] shape Shape of the array as STL container of integers; must have begin() and end(). - * @param[in] strides Shape of the array as STL container of integers; must have begin() and end(). - * @param[in] owner An arbitray Python object that owns that data pointer. The array object will - * keep a reference to the object, and decrement it's reference count when the - * array goes out of scope. Pass None at your own peril. - * - * This overload takes a const void pointer and sets the "writeable" flag of the array to false. - * - * @todo Should probably take ranges of iterators rather than actual container objects. - */ -template -inline ndarray from_data(void const * data, - dtype const & dt, - Container shape, - Container strides, - python::object const & owner) -{ - return numpy::detail::from_data_impl(const_cast(data), dt, shape, strides, owner, false); -} - -/** - * @brief Transform an arbitrary object into a numpy array with the given requirements. - * - * @param[in] obj An arbitrary python object to convert. Arrays that meet the requirements - * will be passed through directly. - * @param[in] dt Data type descriptor. Often retrieved with dtype::get_builtin(). - * @param[in] nd_min Minimum number of dimensions. - * @param[in] nd_max Maximum number of dimensions. - * @param[in] flags Bitwise OR of flags specifying additional requirements. - */ -ndarray from_object(python::object const & obj, dtype const & dt, - int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE); - -inline ndarray from_object(python::object const & obj, dtype const & dt, - int nd, ndarray::bitflag flags=ndarray::NONE) -{ - return from_object(obj, dt, nd, nd, flags); -} - -inline ndarray from_object(python::object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE) -{ - return from_object(obj, dt, 0, 0, flags); -} - -ndarray from_object(python::object const & obj, int nd_min, int nd_max, - ndarray::bitflag flags=ndarray::NONE); - -inline ndarray from_object(python::object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE) -{ - return from_object(obj, nd, nd, flags); -} - -inline ndarray from_object(python::object const & obj, ndarray::bitflag flags=ndarray::NONE) -{ - return from_object(obj, 0, 0, flags); -} - -inline ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b) -{ - return ndarray::bitflag(int(a) | int(b)); -} - -inline ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b) -{ - return ndarray::bitflag(int(a) & int(b)); -} - -} // namespace boost::numpy - -namespace python -{ -namespace converter -{ - -NUMPY_OBJECT_MANAGER_TRAITS(numpy::ndarray); - -} // namespace boost::python::converter -} // namespace boost::python -} // namespace boost - -#endif // !BOOST_NUMPY_NDARRAY_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/numpy_object_mgr_traits.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/numpy_object_mgr_traits.hpp deleted file mode 100644 index c0bad69c3..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/numpy_object_mgr_traits.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_NUMPY_OBJECT_MGR_TRAITS_HPP_INCLUDED -#define BOOST_NUMPY_NUMPY_OBJECT_MGR_TRAITS_HPP_INCLUDED - -/** - * @file boost/numpy/numpy_object_mgr_traits.hpp - * @brief Macro that specializes object_manager_traits by requiring a - * source-file implementation of get_pytype(). - */ - -#define NUMPY_OBJECT_MANAGER_TRAITS(manager) \ -template <> \ -struct object_manager_traits \ -{ \ - BOOST_STATIC_CONSTANT(bool, is_specialized = true); \ - static inline python::detail::new_reference adopt(PyObject* x) \ - { \ - return python::detail::new_reference(python::pytype_check((PyTypeObject*)get_pytype(), x)); \ - } \ - static bool check(PyObject* x) \ - { \ - return ::PyObject_IsInstance(x, (PyObject*)get_pytype()); \ - } \ - static manager* checked_downcast(PyObject* x) \ - { \ - return python::downcast((checked_downcast_impl)(x, (PyTypeObject*)get_pytype())); \ - } \ - static PyTypeObject const * get_pytype(); \ -} - -#endif // !BOOST_NUMPY_NUMPY_OBJECT_MGR_TRAITS_HPP_INCLUDED - diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/scalars.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/scalars.hpp deleted file mode 100644 index b0bb4e095..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/scalars.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_SCALARS_HPP_INCLUDED -#define BOOST_NUMPY_SCALARS_HPP_INCLUDED - -/** - * @file boost/numpy/scalars.hpp - * @brief Object managers for array scalars (currently only numpy.void is implemented). - */ - -#include -#include -#include - -namespace boost -{ -namespace numpy -{ - -/** - * @brief A boost.python "object manager" (subclass of object) for numpy.void. - * - * @todo This could have a lot more functionality. - */ -class void_ : public python::object -{ - static python::detail::new_reference convert(object_cref arg, bool align); -public: - - /** - * @brief Construct a new array scalar with the given size and void dtype. - * - * Data is initialized to zero. One can create a standalone scalar object - * with a certain dtype "dt" with: - * @code - * void_ scalar = void_(dt.get_itemsize()).view(dt); - * @endcode - */ - explicit void_(Py_ssize_t size); - - BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(void_, object); - - /// @brief Return a view of the scalar with the given dtype. - void_ view(dtype const & dt) const; - - /// @brief Copy the scalar (deep for all non-object fields). - void_ copy() const; - -}; - -} // namespace boost::numpy - -namespace python -{ -namespace converter -{ -NUMPY_OBJECT_MANAGER_TRAITS(numpy::void_); -} // namespace boost::python::converter -} // namespace boost::python -} // namespace boost - -#endif // !BOOST_NUMPY_SCALARS_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/boost/numpy/ufunc.hpp b/src/3rdparty/Boost.NumPy/boost/numpy/ufunc.hpp deleted file mode 100644 index 98ecbf49a..000000000 --- a/src/3rdparty/Boost.NumPy/boost/numpy/ufunc.hpp +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_NUMPY_UFUNC_HPP_INCLUDED -#define BOOST_NUMPY_UFUNC_HPP_INCLUDED - -/** - * @file boost/numpy/ufunc.hpp - * @brief Utilities to create ufunc-like broadcasting functions out of C++ functors. - */ - -#include -#include -#include -#include - -namespace boost -{ -namespace numpy -{ - -/** - * @brief A boost.python "object manager" (subclass of object) for PyArray_MultiIter. - * - * multi_iter is a Python object, but a very low-level one. It should generally only be used - * in loops of the form: - * @code - * while (iter.not_done()) { - * ... - * iter.next(); - * } - * @endcode - * - * @todo I can't tell if this type is exposed in Python anywhere; if it is, we should use that name. - * It's more dangerous than most object managers, however - maybe it actually belongs in - * a detail namespace? - */ -class multi_iter : public python::object -{ -public: - - BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(multi_iter, python::object); - - /// @brief Increment the iterator. - void next(); - - /// @brief Check if the iterator is at its end. - bool not_done() const; - - /// @brief Return a pointer to the element of the nth broadcasted array. - char * get_data(int n) const; - - /// @brief Return the number of dimensions of the broadcasted array expression. - int const get_nd() const; - - /// @brief Return the shape of the broadcasted array expression as an array of integers. - Py_intptr_t const * get_shape() const; - - /// @brief Return the shape of the broadcasted array expression in the nth dimension. - Py_intptr_t const shape(int n) const; - -}; - -/// @brief Construct a multi_iter over a single sequence or scalar object. -multi_iter make_multi_iter(python::object const & a1); - -/// @brief Construct a multi_iter by broadcasting two objects. -multi_iter make_multi_iter(python::object const & a1, python::object const & a2); - -/// @brief Construct a multi_iter by broadcasting three objects. -multi_iter make_multi_iter(python::object const & a1, python::object const & a2, python::object const & a3); - -/** - * @brief Helps wrap a C++ functor taking a single scalar argument as a broadcasting ufunc-like - * Python object. - * - * Typical usage looks like this: - * @code - * struct TimesPI - * { - * typedef double argument_type; - * typedef double result_type; - * double operator()(double input) const { return input * M_PI; } - * }; - * - * BOOST_PYTHON_MODULE(example) - * { - * class_< TimesPI >("TimesPI") - * .def("__call__", unary_ufunc::make()); - * } - * @endcode - * - */ -template -struct unary_ufunc -{ - - /** - * @brief A C++ function with object arguments that broadcasts its arguments before - * passing them to the underlying C++ functor. - */ - static python::object call(TUnaryFunctor & self, python::object const & input, python::object const & output) - { - dtype in_dtype = dtype::get_builtin(); - dtype out_dtype = dtype::get_builtin(); - ndarray in_array = from_object(input, in_dtype, ndarray::ALIGNED); - ndarray out_array = (output != python::object()) ? - from_object(output, out_dtype, ndarray::ALIGNED | ndarray::WRITEABLE) - : zeros(in_array.get_nd(), in_array.get_shape(), out_dtype); - multi_iter iter = make_multi_iter(in_array, out_array); - while (iter.not_done()) - { - TArgument * argument = reinterpret_cast(iter.get_data(0)); - TResult * result = reinterpret_cast(iter.get_data(1)); - *result = self(*argument); - iter.next(); - } - return out_array.scalarize(); - } - - /** - * @brief Construct a boost.python function object from call() with reasonable keyword names. - * - * Users will often want to specify their own keyword names with the same signature, but this - * is a convenient shortcut. - */ - static python::object make() - { - namespace p = python; - return p::make_function(call, p::default_call_policies(), (p::arg("input"), p::arg("output")=p::object())); - } -}; - -/** - * @brief Helps wrap a C++ functor taking a pair of scalar arguments as a broadcasting ufunc-like - * Python object. - * - * Typical usage looks like this: - * @code - * struct CosSum - * { - * typedef double first_argument_type; - * typedef double second_argument_type; - * typedef double result_type; - * double operator()(double input1, double input2) const { return std::cos(input1 + input2); } - * }; - * - * BOOST_PYTHON_MODULE(example) - * { - * class_< CosSum >("CosSum") - * .def("__call__", binary_ufunc::make()); - * } - * @endcode - * - */ -template -struct binary_ufunc -{ - - static python::object - call(TBinaryFunctor & self, python::object const & input1, python::object const & input2, - python::object const & output) - { - dtype in1_dtype = dtype::get_builtin(); - dtype in2_dtype = dtype::get_builtin(); - dtype out_dtype = dtype::get_builtin(); - ndarray in1_array = from_object(input1, in1_dtype, ndarray::ALIGNED); - ndarray in2_array = from_object(input2, in2_dtype, ndarray::ALIGNED); - multi_iter iter = make_multi_iter(in1_array, in2_array); - ndarray out_array = (output != python::object()) - ? from_object(output, out_dtype, ndarray::ALIGNED | ndarray::WRITEABLE) - : zeros(iter.get_nd(), iter.get_shape(), out_dtype); - iter = make_multi_iter(in1_array, in2_array, out_array); - while (iter.not_done()) - { - TArgument1 * argument1 = reinterpret_cast(iter.get_data(0)); - TArgument2 * argument2 = reinterpret_cast(iter.get_data(1)); - TResult * result = reinterpret_cast(iter.get_data(2)); - *result = self(*argument1, *argument2); - iter.next(); - } - return out_array.scalarize(); - } - - static python::object make() - { - namespace p = python; - return p::make_function(call, p::default_call_policies(), - (p::arg("input1"), p::arg("input2"), p::arg("output")=p::object())); - } - -}; - -} // namespace boost::numpy - -namespace python -{ -namespace converter -{ - -NUMPY_OBJECT_MANAGER_TRAITS(numpy::multi_iter); - -} // namespace boost::python::converter -} // namespace boost::python -} // namespace boost - -#endif // !BOOST_NUMPY_UFUNC_HPP_INCLUDED diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindNumPy.cmake b/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindNumPy.cmake deleted file mode 100644 index ecae7e6b7..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindNumPy.cmake +++ /dev/null @@ -1,90 +0,0 @@ -# - Find the NumPy libraries -# This module finds if NumPy is installed, and sets the following variables -# indicating where it is. -# -# TODO: Update to provide the libraries and paths for linking npymath lib. -# -# NUMPY_FOUND - was NumPy found -# NUMPY_VERSION - the version of NumPy found as a string -# NUMPY_VERSION_MAJOR - the major version number of NumPy -# NUMPY_VERSION_MINOR - the minor version number of NumPy -# NUMPY_VERSION_PATCH - the patch version number of NumPy -# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 -# NUMPY_INCLUDE_DIRS - path to the NumPy include files - -#============================================================================ -# Copyright 2012 Continuum Analytics, Inc. -# -# MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -# -#============================================================================ - -# Finding NumPy involves calling the Python interpreter -if(NumPy_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) -else() - find_package(PythonInterp) -endif() - -if(NOT PYTHONINTERP_FOUND) - set(NUMPY_FOUND FALSE) -endif() - -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy as n; print(n.__version__); print(n.get_include());" - RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS - OUTPUT_VARIABLE _NUMPY_VALUES - ERROR_VARIABLE _NUMPY_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) - if(NumPy_FIND_REQUIRED) - message(FATAL_ERROR - "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") - endif() - set(NUMPY_FOUND FALSE) -endif() - -# Convert the process output into a list -string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES}) -string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) -list(GET _NUMPY_VALUES 0 NUMPY_VERSION) -list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) - -# Make sure all directory separators are '/' -string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) - -# Get the major and minor version numbers -string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) -list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) -list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) -list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) -string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) -math(EXPR NUMPY_VERSION_DECIMAL - "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") - -find_package_message(NUMPY - "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" - "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") - -set(NUMPY_FOUND TRUE) - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindPythonLibsNew.cmake b/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindPythonLibsNew.cmake deleted file mode 100644 index b2a5d6033..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/FindPythonLibsNew.cmake +++ /dev/null @@ -1,211 +0,0 @@ -# - Find python libraries -# This module finds the libraries corresponding to the Python interpeter -# FindPythonInterp provides. -# This code sets the following variables: -# -# PYTHONLIBS_FOUND - have the Python libs been found -# PYTHON_PREFIX - path to the Python installation -# PYTHON_LIBRARIES - path to the python library -# PYTHON_INCLUDE_DIRS - path to where Python.h is found -# PYTHON_SITE_PACKAGES - path to installation site-packages -# PYTHON_IS_DEBUG - whether the Python interpreter is a debug build -# -# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) -# -# A function PYTHON_ADD_MODULE( src1 src2 ... srcN) is defined to build modules for python. - -#============================================================================= -# Copyright 2001-2009 Kitware, Inc. -# Copyright 2012 Continuum Analytics, Inc. -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the names of Kitware, Inc., the Insight Software Consortium, -# nor the names of their contributors may be used to endorse or promote -# products derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Use the Python interpreter to find the libs. -if(PythonLibsNew_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) -else() - find_package(PythonInterp) -endif() - -if(NOT PYTHONINTERP_FOUND) - set(PYTHONLIBS_FOUND FALSE) - return() -endif() - -# According to http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter -# testing whether sys has the gettotalrefcount function is a reliable, cross-platform -# way to detect a CPython debug interpreter. -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "from distutils import sysconfig as s;import sys;import struct; -print('.'.join(str(v) for v in sys.version_info)); -print(s.PREFIX); -print(s.get_python_inc(plat_specific=True)); -print(s.get_python_lib(plat_specific=True)); -print(s.get_config_var('SO')); -print(hasattr(sys, 'gettotalrefcount')+0); -print(struct.calcsize('@P')); -" - RESULT_VARIABLE _PYTHON_SUCCESS - OUTPUT_VARIABLE _PYTHON_VALUES - ERROR_VARIABLE _PYTHON_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(NOT _PYTHON_SUCCESS MATCHES 0) - if(PythonLibsNew_FIND_REQUIRED) - message(FATAL_ERROR - "Python config failure:\n${_PYTHON_ERROR_VALUE}") - endif() - set(PYTHONLIBS_FOUND FALSE) - return() -endif() - -# Convert the process output into a list -string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES}) -string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES}) -list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST) -list(GET _PYTHON_VALUES 1 PYTHON_PREFIX) -list(GET _PYTHON_VALUES 2 PYTHON_INCLUDE_DIR) -list(GET _PYTHON_VALUES 3 PYTHON_SITE_PACKAGES) -list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION) -list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG) -list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) - -# Make sure the Python has the same pointer-size as the chosen compiler -if(NOT ${PYTHON_SIZEOF_VOID_P} MATCHES ${CMAKE_SIZEOF_VOID_P}) - if(PythonLibsNew_FIND_REQUIRED) - math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8") - math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8") - message(FATAL_ERROR - "Python config failure: Python is ${_PYTHON_BITS}-bit, " - "chosen compiler is ${_CMAKE_BITS}-bit") - endif() - set(PYTHONLIBS_FOUND FALSE) - return() -endif() - -# The built-in FindPython didn't always give the version numbers -string(REGEX REPLACE "\\." ";" _PYTHON_VERSION_LIST ${_PYTHON_VERSION_LIST}) -list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR) -list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR) -list(GET _PYTHON_VERSION_LIST 2 PYTHON_VERSION_PATCH) - -# Make sure all directory separators are '/' -string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX ${PYTHON_PREFIX}) -string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) -string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES}) - -# TODO: All the nuances of CPython debug builds have not been dealt with/tested. -if(PYTHON_IS_DEBUG) - set(PYTHON_MODULE_EXTENSION "_d${PYTHON_MODULE_EXTENSION}") -endif() - -if(CMAKE_HOST_WIN32) - set(PYTHON_LIBRARY - "${PYTHON_PREFIX}/libs/Python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib") -elseif(APPLE) - set(PYTHON_LIBRARY - "${PYTHON_PREFIX}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.dylib") -else() - if(${PYTHON_SIZEOF_VOID_P} MATCHES 8) - set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib64" "${PYTHON_PREFIX}/lib") - else() - set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib") - endif() - # Probably this needs to be more involved. It would be nice if the config - # information the python interpreter itself gave us were more complete. - find_library(PYTHON_LIBRARY - NAMES "python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - PATHS ${_PYTHON_LIBS_SEARCH} - NO_SYSTEM_ENVIRONMENT_PATH) -endif() - -# For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal. -SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL - "Path to where Python.h is found (deprecated)") - -MARK_AS_ADVANCED( - PYTHON_LIBRARY - PYTHON_INCLUDE_DIR -) - -# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the -# cache entries because they are meant to specify the location of a single -# library. We now set the variables listed by the documentation for this -# module. -SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") -SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") -SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") - - -# Don't know how to get to this directory, just doing something simple :P -#INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -#FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) -find_package_message(PYTHON - "Found PythonLibs: ${PYTHON_LIBRARY}" - "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") - - -# PYTHON_ADD_MODULE( src1 src2 ... srcN) is used to build modules for python. -FUNCTION(PYTHON_ADD_MODULE _NAME ) - GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS - GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) - OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) - OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED - "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) - - # Mark these options as advanced - MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME} - PYTHON_MODULE_${_NAME}_BUILD_SHARED) - - IF(PYTHON_ENABLE_MODULE_${_NAME}) - IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET(PY_MODULE_TYPE MODULE) - ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET(PY_MODULE_TYPE STATIC) - SET_PROPERTY(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) - ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - - SET_PROPERTY(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) - ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) - TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES}) - - IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX "${PYTHON_MODULE_EXTENSION}") - ELSE() - ENDIF() - - ENDIF(PYTHON_ENABLE_MODULE_${_NAME}) -ENDFUNCTION(PYTHON_ADD_MODULE) - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/README.txt b/src/3rdparty/Boost.NumPy/libs/numpy/cmake/README.txt deleted file mode 100644 index 806d9fa59..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/cmake/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -The cmake files, FindNumPy.cmake and FindPythonLibsNew.cmake, in this -folder came from the numexpr project at -http://code.google.com/p/numexpr. - -The numexpr project was also a valuable resource in making many of the -cmake constructs used in the cmake lists files written for -Boost.NumPy. The boost-python-examples project at -https://github.com/TNG/boost-python-examples was another helpful -resource for understanding how to use cmake with boost.python. diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/CMakeLists.txt b/src/3rdparty/Boost.NumPy/libs/numpy/doc/CMakeLists.txt deleted file mode 100644 index 159f3fff0..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -project(doc-html) -file(GLOB NUMPY_DOC_DEPS conf.py *.rst) -message( STATUS "NUMPY_DOC_DEPS=${NUMPY_DOC_DEPS}" ) - -# add_custom_target(doc-html make -C ${PROJECT_SOURCE_DIR} html BUILDDIR=${PROJECT_BINARY_DIR}/_build) -# -# this custom target is a cross-platform python/sphinx way to -# replicate what the above make command is doing. -# -add_custom_target(doc-html - ${SPHINX_BUILD} - -b html - -c ${CMAKE_CURRENT_SOURCE_DIR} - -d .doctrees - ${CMAKE_CURRENT_SOURCE_DIR} - html - - DEPENDS ${NUMPY_DOC_DEPS} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Generating HTML Documentation" -) - -SET_PROPERTY(TARGET doc-html PROPERTY FOLDER "doc") - -install(DIRECTORY ${PROJECT_BINARY_DIR}/html - DESTINATION share/doc/libboost_numpy - OPTIONAL - ) - -if (PDFLATEX_COMPILER) - project(doc-pdf) - - add_custom_target(doc-pdf - ${SPHINX_BUILD} - -b latex - -c ${CMAKE_CURRENT_SOURCE_DIR} - -d .doctrees - ${CMAKE_CURRENT_SOURCE_DIR} - latex - - COMMAND ${PDFLATEX_COMPILER} --include-directory=latex --output-directory=latex latex/BoostNumPy.tex - COMMAND ${PDFLATEX_COMPILER} --include-directory=latex --output-directory=latex latex/BoostNumPy.tex - - DEPENDS ${NUMPY_DOC_DEPS} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Generating Latex-pdf Documentation" - ) - - SET_PROPERTY(TARGET doc-pdf PROPERTY FOLDER "doc") - - install(FILES ${PROJECT_BINARY_DIR}/latex/BoostNumPy.pdf - DESTINATION share/doc/libboost_numpy - OPTIONAL - ) - -endif() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/Jamfile b/src/3rdparty/Boost.NumPy/libs/numpy/doc/Jamfile deleted file mode 100644 index 0afe62361..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/Jamfile +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright David Abrahams 2006. Distributed under the Boost -# Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -project user-config : requirements rst2html ; - -import docutils ; - -import path ; -sources = tutorial.rst dtype.rst ndarray.rst fromdata.rst ufunc.rst ; -bases = $(sources:S=) ; - -# This is a path relative to the html/ subdirectory where the -# generated output will eventually be moved. -stylesheet = "--stylesheet=rst.css" ; - -for local b in $(bases) -{ - html $(b) : $(b).rst : - - "-gdt --source-url="./$(b).rst" --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript "$(stylesheet) - ; -} - -alias htmls : $(bases) ; -stage . : $(bases) ; diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/boost.css b/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/boost.css deleted file mode 100644 index 986c4050f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/boost.css +++ /dev/null @@ -1,66 +0,0 @@ -/*============================================================================= - Copyright 2002 William E. Kempf - Distributed under the Boost Software License, Version 1.0. (See accompany- - ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -H1 -{ - FONT-SIZE: 200%; - COLOR: #00008B; -} -H2 -{ - FONT-SIZE: 150%; -} -H3 -{ - FONT-SIZE: 125%; -} -H4 -{ - FONT-SIZE: 108%; -} -BODY -{ - FONT-SIZE: 100%; - BACKGROUND-COLOR: #ffffff; - COLOR: #000000; -} -PRE -{ - MARGIN-LEFT: 2em; - FONT-FAMILY: Courier, - monospace; -} -CODE -{ - FONT-FAMILY: Courier, - monospace; -} -CODE.as_pre -{ - white-space: pre; -} -.index -{ - TEXT-ALIGN: left; -} -.page-index -{ - TEXT-ALIGN: left; -} -.definition -{ - TEXT-ALIGN: left; -} -.footnote -{ - FONT-SIZE: 66%; - VERTICAL-ALIGN: super; - TEXT-DECORATION: none; -} -.function-semantics -{ - CLEAR: left; -} \ No newline at end of file diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/style.css b/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/style.css deleted file mode 100644 index 19d5d096c..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_static/style.css +++ /dev/null @@ -1,11 +0,0 @@ -@import url(boost.css); - -#contents -{ -/* border-bottom: solid thin black;*/ -} - -.highlight -{ - border: 1px solid #aaaaaa; -} \ No newline at end of file diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_templates/layout.html b/src/3rdparty/Boost.NumPy/libs/numpy/doc/_templates/layout.html deleted file mode 100644 index a5ebc1092..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/_templates/layout.html +++ /dev/null @@ -1,120 +0,0 @@ -{%- macro navbar() %} - -{%- endmacro %} - - - - - - {{ metatags }} - {%- if builder != 'htmlhelp' %} - {%- set titlesuffix = docstitle|e %} - {%- set titlesuffix = " - " + titlesuffix %} - {%- endif %} - {{ title|striptags }}{{ titlesuffix }} - {%- if builder == 'web' %} - - {%- for link, type, title in page_links %} - - {%- endfor %} - {%- else %} - - - - {%- endif %} - {%- if builder != 'htmlhelp' %} - - {%- for scriptfile in script_files %} - - {%- endfor %} - {%- if use_opensearch %} - - {%- endif %} - {%- if favicon %} - - {%- endif %} - {%- endif %} -{%- block linktags %} - {%- if hasdoc('about') %} - - {%- endif %} - - - {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - - {%- endif %} - {%- if next %} - - {%- endif %} - {%- if prev %} - - {%- endif %} -{%- endblock %} -{%- block extrahead %} {% endblock %} - - -
- - - - - - - -
-

C++ Boost

-
-

Boost.NumPy

- -
- {%- if pagename != "search" %} - - - {%- endif %} -
-
-
-
- {%- block top_navbar %}{{ navbar() }}{% endblock %} - {% block body %} {% endblock %} - {%- block bottom_navbar %}{{ navbar() }}{% endblock %} -
- - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/cmakeBuild.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/cmakeBuild.rst deleted file mode 100644 index c8d419830..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/cmakeBuild.rst +++ /dev/null @@ -1,167 +0,0 @@ -============= - CMake Build -============= - -.. contents:: - :local: - -Usage -===== - -.. code-block:: bash - - $ mkdir build - $ cd build - $ cmake .. - -On my CentOs 6.3 linux system with a custom installation of boost, I -needed to invoke cmake with a special option as shown here to get -cmake to properly use the boost installation as referenced by the -environment variable :envvar:`BOOST_ROOT` or :envvar:`BOOST_DIR`. - -.. code-block:: bash - - $ cmake -D Boost_NO_BOOST_CMAKE=ON .. - -On windows I invoked cmake using: - -.. code-block:: bash - - > cmake -G "Visual Studio 9 2008 Win64" ^ - -D CMAKE_INSTALL_PREFIX=c:/pkg/x64-vc90 ^ - -D CMAKE_PREFIX_PATH=c:/pkg/x64-vc90 ^ - -D CMAKE_CONFIGURATION_TYPES="Debug;Release" ^ - .. - -Once you have the cmake generated build files you may build -Boost.NumPy. On linux you may build it using: - -.. code-block:: bash - - $ make - $ make install - -On windows you may build it using: - -.. code-block:: bash - - $ cmake --build . --config release - $ cmake --build . --config release --target install - -Note: You need to make sure that the cmake generator you use is -compatible with your python installation. The cmake scripts try to be -helpful, but the verification logic is incomplete. On both Linux and -Windows, I am using the 64-bit python from Enthought. On windows it is -built using Visual Studio 2008. I have also successfully used Visual -Studio 2010 for Boost.NumPy extension modules, but the VS 2010 -generated executables that embed python do not run because of an -apparent conflict with the runtimes. - -The build artifacts get installed to ``${CMAKE_INSTALL_PREFIX}`` -:file:`include` :file:`lib` and :file:`boost.numpy` where the first -two are the conventional locations for header files and libraries (aka -archives, shared objects, DLLs). The last one :file:`boost.numpy` is -my guess at how to install the tests and examples in a place that is -useful. But it is likely that this will need to be tweaked once other -people start using it. Here is an outline of the installed files. - -:: - - boost.numpy/doc/BoostNumPy.pdf - | |- html/index.html - |- example/demo_gaussian.py - | |- dtype.exe - | |- fromdata.exe - | |- gaussian.pyd - | |- ndarray.exe - | |- simple.exe - | |- ufunc.exe - | |- wrap.exe - |- test/dtype.py - |- dtype_mod.pyd - |- indexing.py - |- indexing_mod.pyd - |- ndarray.py - |- ndarray_mod.pyd - |- shapes.py - |- shapes_mod.pyd - |- templates.py - |- templates_mod.pyd - |- ufunc.py - |- ufunc_mod.pyd - - -You may develope and test without performing an install. The build -binary directory is configured so the executables are in the -:file:`build/bin` folder and the shared objects are in the -:file:`build/lib` folder. If you want to test then you simply need to -set the :envvar:`PYTHONPATH` environment variable to the lib folder -containing the shared object files so that python can find the -imported extension modules. - -Details -======= - -I borrowed from the python ``numexpr`` project the two ``.cmake`` -files :file:`FindNumPy.cmake` and :file:`FindPythonLibsNew.cmake` in -:file:`libs/numpy/cmake`. - -I followed a conventional structuring of the cmake -:file:`CMakeLists.txt` input files where the one at the top level -contains all of the configuration logic for the submodules that are -built. - -If you want to also generate this documentation, invoke cmake with the -additional argument ``-DBUILD_DOCS=ON`` and make sure that the sphinx -package is in your path. You may build the documentation using ``make -doc-html``. If pdflatex is also in your path, then there is an -additonal target ``make doc-pdf`` that will generate the pdf manual. - -CMakeLists.txt Source Files -=========================== - -For reference the source code of each of the new -:file:`CMakeLists.txt` files are included below. - -Top-Level ---------- - -:file:`Boost.NumPy/CMakeLists.txt` where the parent subdirectory -:file:`Boost.NumPy` is ommited in directory references in the rest of -this section. - -.. literalinclude:: ../../../CMakeLists.txt - :language: cmake - :linenos: - -Library Source --------------- - -The file :file:`libs/numpy/src/CMakeLists.txt` contains the build of the :file:`boost_numpy library`. - -.. literalinclude:: ../src/CMakeLists.txt - :language: cmake - :linenos: - -Tests ------ - -The file :file:`libs/numpy/test/CMakeLists.txt` contains the python tests. - -.. literalinclude:: ../test/CMakeLists.txt - :language: cmake - :linenos: - -Examples --------- - -The file :file:`libs/numpy/example/CMakeLists.txt` contains simple -examples (both an extension module and executables embedding python). - -.. literalinclude:: ../example/CMakeLists.txt - :language: cmake - :linenos: - - - - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/conf.py b/src/3rdparty/Boost.NumPy/libs/numpy/doc/conf.py deleted file mode 100644 index 84e20f4c7..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/conf.py +++ /dev/null @@ -1,219 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Boost.NumPy documentation build configuration file, created by -# sphinx-quickstart on Thu Oct 27 09:04:58 2011. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Boost.NumPy' -copyright = u'2011, Stefan Seefeld' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '1.0' -# The full version, including alpha/beta/rc tags. -release = '1.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'default' - -highlight_language = 'c++' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -html_logo = '_static/boost.png' - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'BoostNumPydoc' - -html_add_permalinks = False - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'BoostNumPy.tex', u'Boost.NumPy Documentation', - u'Stefan Seefeld', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'boostnumpy', u'Boost.NumPy Documentation', - [u'Stefan Seefeld'], 1) -] diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/index.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/index.rst deleted file mode 100644 index 8456fc328..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. Boost.NumPy documentation master file, created by - sphinx-quickstart on Thu Oct 27 09:04:58 2011. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Boost.NumPy's documentation! -======================================= - -Contents: - -.. toctree:: - :maxdepth: 2 - - Tutorial - Reference - cmakeBuild.rst - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/make.bat b/src/3rdparty/Boost.NumPy/libs/numpy/doc/make.bat deleted file mode 100644 index fbf68af6d..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/make.bat +++ /dev/null @@ -1,170 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. changes to make an overview over all changed/added/deprecated items - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\BoostNumPy.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\BoostNumPy.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -:end diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/Jamfile b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/Jamfile deleted file mode 100644 index ca0457734..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/Jamfile +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright David Abrahams 2006. Distributed under the Boost -# Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -project user-config : requirements rst2html ; - -import docutils ; - -import path ; -sources = dtype.rst ndarray.rst multi_iter.rst unary_ufunc.rst binary_ufunc.rst ; -bases = $(sources:S=) ; - -# This is a path relative to the html/ subdirectory where the -# generated output will eventually be moved. -stylesheet = "--stylesheet=rst.css" ; - -for local b in $(bases) -{ - html $(b) : $(b).rst : - - "-gdt --source-url="./$(b).rst" --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript "$(stylesheet) - ; -} - -alias htmls : $(bases) ; -stage . : $(bases) ; diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/binary_ufunc.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/binary_ufunc.rst deleted file mode 100644 index 23a36f779..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/binary_ufunc.rst +++ /dev/null @@ -1,104 +0,0 @@ -binary_ufunc -============ - -.. contents :: - -A ``binary_ufunc`` is a struct used as an intermediate step to broadcast two arguments so that a C++ function can be converted to a ufunc like function - - ```` contains the ``binary_ufunc`` structure definitions - - -synopsis --------- - -:: - - namespace boost - { - namespace numpy - { - - template - - struct binary_ufunc - { - - static python::object call(TBinaryFunctor & self, - python::object const & input1, - python::object const & input2, - python::object const & output); - - static python::object make(); - }; - - } - } - - -constructors ------------- - -:: - - struct example_binary_ufunc - { - typedef any_valid first_argument_type; - typedef any_valid second_argument_type; - typedef any_valid result_type; - }; - -:Requirements: The ``any_valid`` type must be defined using typedef as a valid C++ type in order to use the struct methods correctly - -:Note: The struct must be exposed as a Python class, and an instance of the class must be created to use the ``call`` method corresponding to the ``__call__`` attribute of the Python object - -accessors ---------- - -:: - - template - static python::object call(TBinaryFunctor & self, - python::object const & input, - python::object const & output); - -:Requires: Typenames ``TBinaryFunctor`` and optionally ``TArgument1`` and ``TArgument2`` for argument type and ``TResult`` for result type - -:Effects: Passes a Python object to the underlying C++ functor after broadcasting its arguments - -:: - - template - static python::object make(); - -:Requires: Typenames ``TBinaryFunctor`` and optionally ``TArgument1`` and ``TArgument2`` for argument type and ``TResult`` for result type - -:Returns: A Python function object to call the overloaded () operator in the struct (in typical usage) - -Example(s) ----------- - -:: - - struct BinarySquare - { - typedef double first_argument_type; - typedef double second_argument_type; - typedef double result_type; - - double operator()(double a,double b) const { return (a*a + b*b) ; } - }; - - p::object ud = p::class_ >("BinarySquare").def("__call__", np::binary_ufunc::make()); - p::object inst = ud(); - result_array = inst.attr("__call__")(demo_array,demo_array) ; - std::cout << "Square of list with binary ufunc is " << p::extract (p::str(result_array)) << std::endl ; - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/dtype.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/dtype.rst deleted file mode 100644 index b76e79a46..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/dtype.rst +++ /dev/null @@ -1,86 +0,0 @@ -dtype -===== - -.. contents :: - -A `dtype`_ is an object describing the type of the elements of an ndarray - -.. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype - - ```` contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types - - -synopsis --------- - -:: - - namespace boost - { - namespace numpy - { - - class dtype : public python::object - { - static python::detail::new_reference convert(python::object::object_cref arg, bool align); - public: - - // Convert an arbitrary Python object to a data-type descriptor object. - template - explicit dtype(T arg, bool align=false); - - // Get the built-in numpy dtype associated with the given scalar template type. - template static dtype get_builtin(); - - // Return the size of the data type in bytes. - int get_itemsize() const; - }; - - } - -constructors ------------- - -:: - - template - explicit dtype(T arg, bool align=false) - -:Requirements: ``T`` must be either : - - * a built-in C++ typename convertible to object - * a valid python object or convertible to object - -:Effects: Constructs an object from the supplied python object / convertible - to object / builtin C++ data type - -:Throws: Nothing - -:: - - template static dtype get_builtin(); - -:Requirements: The typename supplied, ``T`` must be a builtin C++ type also supported by numpy - -:Returns: Numpy dtype corresponding to builtin C++ type - -accessors ---------- - -:: - - int get_itemsize() const; - -:Returns: the size of the data type in bytes. - - -Example(s) ----------- - -:: - - namespace np = boost::numpy; - np::dtype dtype = np::dtype::get_builtin(); - p::tuple for_custom_dtype = p::make_tuple("ha",dtype); - np::dtype custom_dtype = np::dtype(list_for_dtype); - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/index.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/index.rst deleted file mode 100644 index 27de3ee2c..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -Boost.NumPy Reference -===================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - dtype - ndarray - unary_ufunc - binary_ufunc - multi_iter - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/multi_iter.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/multi_iter.rst deleted file mode 100644 index 610f91ee2..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/multi_iter.rst +++ /dev/null @@ -1,91 +0,0 @@ -multi_iter -========== - -.. contents :: - -A ``multi_iter`` is a Python object, intended to be used as an iterator It should generally only be used in loops. - - ```` contains the class definitions for ``multi_iter`` - - -synopsis --------- - -:: - - namespace boost - { - namespace numpy - { - - class multi_iter : public python::object - { - public: - void next(); - bool not_done() const; - char * get_data(int n) const; - int const get_nd() const; - Py_intptr_t const * get_shape() const; - Py_intptr_t const shape(int n) const; - }; - - - multi_iter make_multi_iter(python::object const & a1); - multi_iter make_multi_iter(python::object const & a1, python::object const & a2); - multi_iter make_multi_iter(python::object const & a1, python::object const & a2, python::object const & a3); - - } - } - - -constructors ------------- - -:: - - multi_iter make_multi_iter(python::object const & a1); - multi_iter make_multi_iter(python::object const & a1, python::object const & a2); - multi_iter make_multi_iter(python::object const & a1, python::object const & a2, python::object const & a3); - -:Returns: A Python iterator object broadcasting over one, two or three sequences as supplied - -accessors ---------- - -:: - - void next(); - -:Effects: Increments the iterator - -:: - - bool not_done() const; - -:Returns: boolean value indicating whether the iterator is at its end - -:: - - char * get_data(int n) const; - -:Returns: a pointer to the element of the nth broadcasted array. - -:: - - int const get_nd() const; - -:Returns: the number of dimensions of the broadcasted array expression - -:: - - Py_intptr_t const * get_shape() const; - -:Returns: the shape of the broadcasted array expression as an array of integers. - -:: - - Py_intptr_t const shape(int n) const; - -:Returns: the shape of the broadcasted array expression in the nth dimension. - - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/ndarray.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/ndarray.rst deleted file mode 100644 index 9b4703923..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/ndarray.rst +++ /dev/null @@ -1,377 +0,0 @@ -ndarray -======= - -.. contents :: - -A `ndarray`_ is an N-dimensional array which contains items of the same type and size, where N is the number of dimensions and is specified in the form of a ``shape`` tuple. Optionally, the numpy ``dtype`` for the objects contained may also be specified. - -.. _ndarray: http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html -.. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype - - ```` contains the structures and methods necessary to move raw data between C++ and Python and create ndarrays from the data - - - -synopsis --------- - -:: - - namespace boost - { - namespace numpy - { - - class ndarray : public python::object - { - - public: - - enum bitflag - { - NONE=0x0, C_CONTIGUOUS=0x1, F_CONTIGUOUS=0x2, V_CONTIGUOUS=0x1|0x2, - ALIGNED=0x4, WRITEABLE=0x8, BEHAVED=0x4|0x8, - CARRAY_RO=0x1|0x4, CARRAY=0x1|0x4|0x8, CARRAY_MIS=0x1|0x8, - FARRAY_RO=0x2|0x4, FARRAY=0x2|0x4|0x8, FARRAY_MIS=0x2|0x8, - UPDATE_ALL=0x1|0x2|0x4, VARRAY=0x1|0x2|0x8, ALL=0x1|0x2|0x4|0x8 - }; - - ndarray view(dtype const & dt) const; - ndarray astype(dtype const & dt) const; - ndarray copy() const; - int const shape(int n) const; - int const strides(int n) const; - char * get_data() const; - dtype get_dtype() const; - python::object get_base() const; - void set_base(object const & base); - Py_intptr_t const * get_shape() const; - Py_intptr_t const * get_strides() const; - int const get_nd() const; - - bitflag const get_flags() const; - - ndarray transpose() const; - ndarray squeeze() const; - ndarray reshape(python::tuple const & shape) const; - python::object scalarize() const; - }; - - ndarray zeros(python::tuple const & shape, dtype const & dt); - ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt); - - ndarray empty(python::tuple const & shape, dtype const & dt); - ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt); - - ndarray array(python::object const & obj); - ndarray array(python::object const & obj, dtype const & dt); - - template - ndarray from_data(void * data,dtype const & dt,Container shape,Container strides,python::object const & owner); - template - ndarray from_data(void const * data, dtype const & dt, Container shape, Container strides, python::object const & owner); - - ndarray from_object(python::object const & obj, dtype const & dt,int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE); - ndarray from_object(python::object const & obj, dtype const & dt,int nd, ndarray::bitflag flags=ndarray::NONE); - ndarray from_object(python::object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE); - ndarray from_object(python::object const & obj, int nd_min, int nd_max,ndarray::bitflag flags=ndarray::NONE); - ndarray from_object(python::object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE); - ndarray from_object(python::object const & obj, ndarray::bitflag flags=ndarray::NONE) - - ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b) ; - ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b); - - } - - -constructors ------------- - -:: - - ndarray view(dtype const & dt) const; - -:Returns: new ndarray with old ndarray data cast as supplied dtype - -:: - - ndarray astype(dtype const & dt) const; - -:Returns: new ndarray with old ndarray data converted to supplied dtype - -:: - - ndarray copy() const; - -:Returns: Copy of calling ndarray object - -:: - - ndarray transpose() const; - -:Returns: An ndarray with the rows and columns interchanged - -:: - - ndarray squeeze() const; - -:Returns: An ndarray with all unit-shaped dimensions removed - -:: - - ndarray reshape(python::tuple const & shape) const; - -:Requirements: The new ``shape`` of the ndarray must be supplied as a tuple - -:Returns: An ndarray with the same data but reshaped to the ``shape`` supplied - - -:: - - python::object scalarize() const; - -:Returns: A scalar if the ndarray has only one element, otherwise it returns the entire array - -:: - - ndarray zeros(python::tuple const & shape, dtype const & dt); - ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt); - -:Requirements: The following parameters must be supplied as required : - - * the ``shape`` or the size of all dimensions, as a tuple - * the ``dtype`` of the data - * the ``nd`` size for a square shaped ndarray - * the ``shape`` Py_intptr_t - -:Returns: A new ndarray with the given shape and data type, with data initialized to zero. - -:: - - ndarray empty(python::tuple const & shape, dtype const & dt); - ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt); - - -:Requirements: The following parameters must be supplied : - - * the ``shape`` or the size of all dimensions, as a tuple - * the ``dtype`` of the data - * the ``shape`` Py_intptr_t - -:Returns: A new ndarray with the given shape and data type, with data left uninitialized. - -:: - - ndarray array(python::object const & obj); - ndarray array(python::object const & obj, dtype const & dt); - -:Returns: A new ndarray from an arbitrary Python sequence, with dtype of each element specified optionally - -:: - - template - inline ndarray from_data(void * data,dtype const & dt,Container shape,Container strides,python::object const & owner) - -:Requirements: The following parameters must be supplied : - - * the ``data`` which is a generic C++ data container - * the dtype ``dt`` of the data - * the ``shape`` of the ndarray as Python object - * the ``strides`` of each dimension of the array as a Python object - * the ``owner`` of the data, in case it is not the ndarray itself - -:Returns: ndarray with attributes and data supplied - -:Note: The ``Container`` typename must be one that is convertible to a std::vector or python object type - -:: - - ndarray from_object(python::object const & obj, dtype const & dt,int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE); - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * the dtype ``dt`` of the data - * minimum number of dimensions ``nd_min`` of the ndarray as Python object - * maximum number of dimensions ``nd_max`` of the ndarray as Python object - * optional ``flags`` bitflags - -:Returns: ndarray constructed with dimensions and data supplied as parameters - -:: - - inline ndarray from_object(python::object const & obj, dtype const & dt, int nd, ndarray::bitflag flags=ndarray::NONE); - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * the dtype ``dt`` of the data - * number of dimensions ``nd`` of the ndarray as Python object - * optional ``flags`` bitflags - -:Returns: ndarray with dimensions ``nd`` x ``nd`` and suplied parameters - -:: - - inline ndarray from_object(python::object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE) - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * the dtype ``dt`` of the data - * optional ``flags`` bitflags - -:Returns: Supplied Python object as ndarray - -:: - - ndarray from_object(python::object const & obj, int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE); - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * minimum number of dimensions ``nd_min`` of the ndarray as Python object - * maximum number of dimensions ``nd_max`` of the ndarray as Python object - * optional ``flags`` bitflags - -:Returns: ndarray with supplied dimension limits and parameters - -:Note: dtype need not be supplied here - -:: - - inline ndarray from_object(python::object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE); - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * the dtype ``dt`` of the data - * number of dimensions ``nd`` of the ndarray as Python object - * optional ``flags`` bitflags - -:Returns: ndarray of ``nd`` x ``nd`` dimensions constructed from the supplied object - -:: - - inline ndarray from_object(python::object const & obj, ndarray::bitflag flags=ndarray::NONE) - -:Requirements: The following parameters must be supplied : - - * the ``obj`` Python object to convert to ndarray - * optional ``flags`` bitflags - -:Returns: ndarray of same dimensions and dtype as supplied Python object - - -accessors ---------- - -:: - - int const shape(int n) const; - -:Returns: The size of the n-th dimension of the ndarray - -:: - - int const strides(int n) const; - -:Returns: The stride of the nth dimension. - -:: - - char * get_data() const; - -:Returns: Array's raw data pointer as a char - -:Note: This returns char so stride math works properly on it.User will have to reinterpret_cast it. - -:: - - dtype get_dtype() const; - -:Returns: Array's data-type descriptor object (dtype) - - -:: - - python::object get_base() const; - -:Returns: Object that owns the array's data, or None if the array owns its own data. - - -:: - - void set_base(object const & base); - -:Returns: Set the object that owns the array's data. Exercise caution while using this - - -:: - - Py_intptr_t const * get_shape() const; - -:Returns: Shape of the array as an array of integers - - -:: - - Py_intptr_t const * get_strides() const; - -:Returns: Stride of the array as an array of integers - - -:: - - int const get_nd() const; - -:Returns: Number of array dimensions - - -:: - - bitflag const get_flags() const; - -:Returns: Array flags - -:: - - inline ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b) - -:Returns: bitflag logically OR-ed as (a | b) - -:: - - inline ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b) - -:Returns: bitflag logically AND-ed as (a & b) - - -Example(s) ----------- - -:: - - p::object tu = p::make_tuple('a','b','c') ; - np::ndarray example_tuple = np::array (tu) ; - - p::list l ; - np::ndarray example_list = np::array (l) ; - - np::dtype dt = np::dtype::get_builtin(); - np::ndarray example_list1 = np::array (l,dt); - - int data[] = {1,2,3,4} ; - p::tuple shape = p::make_tuple(4) ; - p::tuple stride = p::make_tuple(4) ; - p::object own ; - np::ndarray data_ex = np::from_data(data,dt,shape,stride,own); - - uint8_t mul_data[][4] = {{1,2,3,4},{5,6,7,8},{1,3,5,7}}; - shape = p::make_tuple(3,2) ; - stride = p::make_tuple(4,2) ; - np::dtype dt1 = np::dtype::get_builtin(); - - np::ndarray mul_data_ex = np::from_data(mul_data,dt1, p::make_tuple(3,4),p::make_tuple(4,1),p::object()); - mul_data_ex = np::from_data(mul_data,dt1, shape,stride,p::object()); - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/unary_ufunc.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/unary_ufunc.rst deleted file mode 100644 index 1cdf6c750..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/reference/unary_ufunc.rst +++ /dev/null @@ -1,97 +0,0 @@ -unary_ufunc -=========== - -.. contents :: - -A ``unary_ufunc`` is a struct used as an intermediate step to broadcast a single argument so that a C++ function can be converted to a ufunc like function - - ```` contains the ``unary_ufunc`` structure definitions - - -synopsis --------- - -:: - - namespace boost - { - namespace numpy - { - - template - struct unary_ufunc - { - - static python::object call(TUnaryFunctor & self, - python::object const & input, - python::object const & output) ; - - static python::object make(); - - }; - } - } - - -constructors ------------- - -:: - - struct example_unary_ufunc - { - typedef any_valid_type argument_type; - typedef any_valid_type result_type; - }; - -:Requirements: The ``any_valid`` type must be defined using typedef as a valid C++ type in order to use the struct methods correctly - -:Note: The struct must be exposed as a Python class, and an instance of the class must be created to use the ``call`` method corresponding to the ``__call__`` attribute of the Python object - -accessors ---------- - -:: - - template - static python::object call(TUnaryFunctor & self, - python::object const & input, - python::object const & output); - -:Requires: Typenames ``TUnaryFunctor`` and optionally ``TArgument`` for argument type and ``TResult`` for result type - -:Effects: Passes a Python object to the underlying C++ functor after broadcasting its arguments - -:: - - template - static python::object make(); - -:Requires: Typenames ``TUnaryFunctor`` and optionally ``TArgument`` for argument type and ``TResult`` for result type - -:Returns: A Python function object to call the overloaded () operator in the struct (in typical usage) - - - -Example(s) ----------- - -:: - - struct UnarySquare - { - typedef double argument_type; - typedef double result_type; - double operator()(double r) const { return r * r;} - }; - - p::object ud = p::class_ >("UnarySquare").def("__call__", np::unary_ufunc::make()); - p::object inst = ud(); - std::cout << "Square of unary scalar 1.0 is " << p::extract (p::str(inst.attr("__call__")(1.0))) << std::endl ; - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/rst.css b/src/3rdparty/Boost.NumPy/libs/numpy/doc/rst.css deleted file mode 100644 index afd9a98c3..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/rst.css +++ /dev/null @@ -1,149 +0,0 @@ -@import url("doc/src/boostbook.css"); -@import url("doc/src/docutils.css"); -/* Copyright David Abrahams 2006. Distributed under the Boost - Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -dl.docutils dt { - font-weight: bold } - -img.boost-logo { - border: none; - vertical-align: middle -} - -pre.literal-block span.concept { - font-style: italic; -} - -.nav { -display: inline; -list-style-type: none; -} - -.prevpage { -padding-top: -5px; -text-align: left; -float: left; -} - -.nextpage { -padding-top: -20px; -text-align: right; -float: right; -} - -div.small { - font-size: smaller } - -h2 a { - font-size: 90%; -} -h3 a { - font-size: 80%; -} -h4 a { - font-size: 70%; -} -h5 a { - font-size: 60%; -} - -dl,table -{ - text-align: left; - font-size: 10pt; - line-height: 1.15; -} - - -/*============================================================================= - Tables -=============================================================================*/ - -/* The only clue docutils gives us that tables are logically tables, - and not, e.g., footnotes, is that they have border="1". Therefore - we're keying off of that. We used to manually patch docutils to - add a "table" class to all logical tables, but that proved much too - fragile. -*/ - - table[border="1"] - { - width: 92%; - margin-left: 4%; - margin-right: 4%; - } - - table[border="1"] - { - padding: 4px; - } - - /* Table Cells */ - table[border="1"] tr td - { - padding: 0.5em; - text-align: left; - font-size: 9pt; - } - - table[border="1"] tr th - { - padding: 0.5em 0.5em 0.5em 0.5em; - border: 1pt solid white; - font-size: 80%; - } - - @media screen - { - - /* Tables */ - table[border="1"] tr td - { - border: 1px solid #DCDCDC; - } - - table[border="1"] tr th - { - background-color: #F0F0F0; - border: 1px solid #DCDCDC; - } - - pre, - .screen - { - border: 1px solid #DCDCDC; - } - - td pre - td .screen - { - border: 0px - } - - .sidebar pre - { - border: 0px - } - - } - - pre, - .screen - { - font-size: 9pt; - display: block; - margin: 1pc 4% 0pc 4%; - padding: 0.5pc 0.5pc 0.5pc 0.5pc; - } - - /* Program listings in tables don't get borders */ - td pre, - td .screen - { - margin: 0pc 0pc 0pc 0pc; - padding: 0pc 0pc 0pc 0pc; - } - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/dtype.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/dtype.rst deleted file mode 100644 index 02bb513b3..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/dtype.rst +++ /dev/null @@ -1,55 +0,0 @@ -How to use dtypes -================= - -Here is a brief tutorial to show how to create ndarrays with built-in python data types, and extract the types and values of member variables - -Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:: - - #include - #include - - namespace p = boost::python; - namespace np = boost::numpy; - - int main(int argc, char **argv) - { - Py_Initialize(); - np::initialize(); - -Next, we create the shape and dtype. We use the get_builtin method to get the numpy dtype corresponding to the builtin C++ dtype -Here, we will create a 3x3 array passing a tuple with (3,3) for the size, and double as the data type :: - - p::tuple shape = p::make_tuple(3, 3); - np::dtype dtype = np::dtype::get_builtin(); - np::ndarray a = np::zeros(shape, dtype); - -Finally, we can print the array using the extract method in the python namespace. -Here, we first convert the variable into a string, and then extract it as a C++ character array from the python string using the template :: - - std::cout << "Original array:\n" << p::extract(p::str(a)) << std::endl; - -We can also print the dtypes of the data members of the ndarray by using the get_dtype method for the ndarray :: - - std::cout << "Datatype is:\n" << p::extract(p::str(a.get_dtype())) << std::endl ; - -We can also create custom dtypes and build ndarrays with the custom dtypes - -We use the dtype constructor to create a custom dtype. This constructor takes a list as an argument. - -The list should contain one or more tuples of the format (variable name, variable type) - -So first create a tuple with a variable name and its dtype, double, to create a custom dtype :: - - p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ; - -Next, create a list, and add this tuple to the list. Then use the list to create the custom dtype :: - - p::list list_for_dtype ; - list_for_dtype.append(for_custom_dtype) ; - np::dtype custom_dtype = np::dtype(list_for_dtype) ; - -We are now ready to create an ndarray with dimensions specified by \*shape\* and of custom dtpye :: - - np::ndarray new_array = np::zeros(shape,custom_dtype); - - } diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/fromdata.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/fromdata.rst deleted file mode 100644 index 2937c78e1..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/fromdata.rst +++ /dev/null @@ -1,51 +0,0 @@ -How to access data using raw pointers -===================================== - -One of the advantages of the ndarray wrapper is that the same data can be used in both Python and C++ and changes can be made to reflect at both ends. -The from_data method makes this possible. - -Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:: - - #include - #include - - namespace p = boost::python; - namespace np = boost::numpy; - - int main(int argc, char **argv) - { - Py_Initialize(); - np::initialize(); - -Create an array in C++ , and pass the pointer to it to the from_data method to create an ndarray:: - - int arr[] = {1,2,3,4} ; - np::ndarray py_array = np::from_data(arr, np::dtype::get_builtin() , p::make_tuple(4), p::make_tuple(4), p::object()); - -Print the source C++ array, as well as the ndarray, to check if they are the same:: - - std::cout << "C++ array :" << std::endl ; - for (int j=0;j<4;j++) - { - std::cout << arr[j] << ' ' ; - } - std::cout << std::endl << "Python ndarray :" << p::extract(p::str(py_array)) << std::endl; - -Now, change an element in the Python ndarray, and check if the value changed correspondingly in the source C++ array:: - - py_array[1] = 5 ; - std::cout << "Is the change reflected in the C++ array used to create the ndarray ? " << std::endl ; - for (int j = 0;j<4 ; j++) - { - std::cout << arr[j] << ' ' ; - } - -Next, change an element of the source C++ array and see if it is reflected in the Python ndarray:: - - arr[2] = 8 ; - std::cout << std::endl << "Is the change reflected in the Python ndarray ?" << std::endl << p::extract(p::str(py_array)) << std::endl; - -} - -As we can see, the changes are reflected across the ends. This happens because the from_data method passes the C++ array by reference to create the ndarray, and thus uses the same locations for storing data. - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/index.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/index.rst deleted file mode 100644 index ca15971ce..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -Boost.NumPy Tutorial -==================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - simple - dtype - ndarray - ufunc - fromdata - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ndarray.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ndarray.rst deleted file mode 100644 index c00783917..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ndarray.rst +++ /dev/null @@ -1,94 +0,0 @@ -Creating ndarrays -================= - -The Boost.Numpy library exposes quite a few methods to create ndarrays. ndarrays can be created in a variety of ways, include empty arrays and zero filled arrays. -ndarrays can also be created from arbitrary python sequences as well as from data and dtypes. - -This tutorial will introduce you to some of the ways in which you can create ndarrays. The methods covered here include creating ndarrays from arbitrary Python sequences, as well as from C++ containers, using both unit and non-unit strides - -First, as before, initialise the necessary namepaces and runtimes :: - - #include - #include - - namespace p = boost::python; - namespace np = boost::numpy; - - int main(int argc, char **argv) - { - Py_Initialize(); - np::initialize(); - -Let's now create an ndarray from a simple tuple. We first create a tuple object, and then pass it to the array method, to generate the necessary tuple :: - - p::object tu = p::make_tuple('a','b','c') ; - np::ndarray example_tuple = np::array(tu) ; - -Let's now try the same with a list. We create an empty list, add an element using the append method, and as before, call the array method :: - - p::list l ; - l.append('a') ; - np::ndarray example_list = np::array (l) ; - -Optionally, we can also specify a dtype for the array :: - - np::dtype dt = np::dtype::get_builtin(); - np::ndarray example_list1 = np::array (l,dt); - -We can also create an array by supplying data arrays and a few other parameters. - -First,create an integer array :: - - int data[] = {1,2,3,4} ; - -Create a shape, and strides, needed by the function :: - - p::tuple shape = p::make_tuple(4) ; - p::tuple stride = p::make_tuple(4) ; - -Here, shape is 1x4 , and the stride is also 4. -A stride is the number of bytes that must be travelled to get to the next desired element while constructing the ndarray. Here, the size of the "int" is 32 bits and hence, the stride is 4 to access each element. - -The function also needs an owner, to keep track of the data array passed. Passing none is dangerous :: - - p::object own ; - -The from_data function takes the data array, datatype,shape,stride and owner as arguments and returns an ndarray :: - - np::ndarray data_ex1 = np::from_data(data,dt, shape,stride,own); - -Now let's print the ndarray we created :: - - std::cout << "Single dimensional array ::" << std::endl << p::extract < char const * > (p::str(data_ex)) << std::endl ; - -Let's make it a little more interesting. Lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides - -First lets create a 3x4 array of 8-bit integers :: - - uint8_t mul_data[][4] = {{1,2,3,4},{5,6,7,8},{1,3,5,7}}; - -Now let's create an array of 3x2 elements, picking the first and third elements from each row . For that, the shape will be 3x2. -The strides will be 4x2 i.e. 4 bytes to go to the next desired row, and 2 bytes to go to the next desired column :: - - shape = p::make_tuple(3,2) ; - stride = p::make_tuple(4,2) ; - -Get the numpy dtype for the built-in 8-bit integer data type :: - - np::dtype dt1 = np::dtype::get_builtin(); - -Now lets first create and print out the ndarray as is. -Notice how we can pass the shape and strides in the function directly, as well as the owner. The last part can be done because we don't have any use to -manipulate the "owner" object :: - - np::ndarray mul_data_ex = np::from_data(mul_data,dt1, p::make_tuple(3,4),p::make_tuple(4,1),p::object()); - std::cout << "Original multi dimensional array :: " << std::endl << p::extract < char const * > (p::str(mul_data_ex)) << std::endl ; - -Now create the new ndarray using the shape and strides and print out the array we created using non-unit strides :: - - mul_data_ex = np::from_data(mul_data,dt1, shape,stride,p::object()); - std::cout << "Selective multidimensional array :: "< (p::str(mul_data_ex)) << std::endl ; - -Note : The from_data method will throw "error_already_set" if the number of elements dictated by the shape and the corresponding strides don't match - -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/simple.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/simple.rst deleted file mode 100644 index 3c462962b..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/simple.rst +++ /dev/null @@ -1,41 +0,0 @@ -A simple tutorial on Arrays -=========================== - -Let's start with a simple tutorial to create and modify arrays. - -Get the necessary headers for numpy components and set up necessary namespaces:: - - #include - #include - - namespace p = boost::python; - namespace np = boost::numpy; - -Initialise the Python runtime, and the numpy module. Failure to call these results in segmentation errors:: - - int main(int argc, char **argv) - { - Py_Initialize(); - np::initialize(); - - -Zero filled n-dimensional arrays can be created using the shape and data-type of the array as a parameter. Here, the shape is 3x3 and the datatype is the built-in float type:: - - p::tuple shape = p::make_tuple(3, 3); - np::dtype dtype = np::dtype::get_builtin(); - np::ndarray a = np::zeros(shape, dtype); - -You can also create an empty array like this :: - - np::ndarray b = np::empty(shape,dtype); - -Print the original and reshaped array. The array a which is a list is first converted to a string, and each value in the list is extracted using extract< >:: - - std::cout << "Original array:\n" << p::extract(p::str(a)) << std::endl; - - // Reshape the array into a 1D array - a = a.reshape(p::make_tuple(9)); - // Print it again. - std::cout << "Reshaped array:\n" << p::extract(p::str(a)) << std::endl; - } - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ufunc.rst b/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ufunc.rst deleted file mode 100644 index 1943e675d..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/doc/tutorial/ufunc.rst +++ /dev/null @@ -1,116 +0,0 @@ -Ufuncs -====== - -Ufuncs or universal functions operate on ndarrays element by element, and support array broadcasting, type casting, and other features. - -Lets try and see how we can use the binary and unary ufunc methods - -After the neccessary includes :: - - #include - #include - - namespace p = boost::python; - namespace np = boost::numpy; - -Now we create the structs necessary to implement the ufuncs. The typedefs *must* be made as the ufunc generators take these typedefs as inputs and return an error otherwise :: - - struct UnarySquare - { - typedef double argument_type; - typedef double result_type; - - double operator()(double r) const { return r * r;} - }; - - struct BinarySquare - { - typedef double first_argument_type; - typedef double second_argument_type; - typedef double result_type; - - double operator()(double a,double b) const { return (a*a + b*b) ; } - }; - -Initialise the Python runtime and the numpy module :: - - int main(int argc, char **argv) - { - Py_Initialize(); - np::initialize(); - -Now expose the struct UnarySquare to Python as a class, and let ud be the class object. :: - - p::object ud = p::class_ >("UnarySquare") - .def("__call__", np::unary_ufunc::make()); - -Let inst be an instance of the class ud :: - - p::object inst = ud(); - -Use the "__call__" method to call the overloaded () operator and print the value :: - - std::cout << "Square of unary scalar 1.0 is " << p::extract (p::str(inst.attr("__call__")(1.0))) << std::endl ; - -Create an array in C++ :: - - int arr[] = {1,2,3,4} ; - - -..and use it to create the ndarray in Python :: - - np::ndarray demo_array = np::from_data(arr, np::dtype::get_builtin() , p::make_tuple(4), p::make_tuple(4), p::object()); - -Print out the demo array :: - - std::cout << "Demo array is " << p::extract (p::str(demo_array)) << std::endl ; - -Call the "__call__" method to perform the operation and assign the value to result_array :: - - p::object result_array = inst.attr("__call__")(demo_array) ; - -Print the resultant array :: - - std::cout << "Square of demo array is " << p::extract (p::str(result_array)) << std::endl ; - -Lets try the same with a list :: - - p::list li ; - li.append(3); - li.append(7); - -Print out the demo list :: - - std::cout << "Demo list is " << p::extract (p::str(li)) << std::endl ; - -Call the ufunc for the list :: - - result_array = inst.attr("__call__")(li) ; - -And print the list out :: - - std::cout << "Square of demo list is " << p::extract (p::str(result_array)) << std::endl ; - -Now lets try Binary ufuncs. Again, expose the struct BinarySquare to Python as a class, and let ud be the class object :: - - ud = p::class_ >("BinarySquare") - .def("__call__", np::binary_ufunc::make()); - -And initialise ud :: - - inst = ud(); - -Print the two input lists :: - - std::cout << "The two input list for binary ufunc are " << std::endl << p::extract (p::str(demo_array)) << std::endl << p::extract (p::str(demo_array)) << std::endl ; - -Call the binary ufunc taking demo_array as both inputs :: - - result_array = inst.attr("__call__")(demo_array,demo_array) ; - -And print the output :: - - std::cout << "Square of list with binary ufunc is " << p::extract (p::str(result_array)) << std::endl ; - -} - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/CMakeLists.txt b/src/3rdparty/Boost.NumPy/libs/numpy/example/CMakeLists.txt deleted file mode 100644 index 24d463a20..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# custom macro with most of the redundant code for making a python example module -macro( addPythonExe _name _srccpp ) - ADD_EXECUTABLE(${_name} ${_srccpp}) - - # make the pyd library link against boost_numpy python and boost - TARGET_LINK_LIBRARIES(${_name} boost_numpy) - - # put the example target into a VS solution folder named example (should - # be a no-op for Linux) - SET_PROPERTY(TARGET ${_name} PROPERTY FOLDER "example") -endmacro() - -macro( addPythonMod _name _srccpp ) - PYTHON_ADD_MODULE(${_name} ${_srccpp}) - - # make the pyd library link against boost_numpy python and boost - TARGET_LINK_LIBRARIES(${_name} boost_numpy) - - # put the example target into a VS solution folder named example (should - # be a no-op for Linux) - SET_PROPERTY(TARGET ${_name} PROPERTY FOLDER "example") -endmacro() - -addPythonMod(gaussian gaussian.cpp) -addPythonExe(dtype dtype.cpp) -addPythonExe(fromdata fromdata.cpp) -addPythonExe(ndarray ndarray.cpp) -addPythonExe(simple simple.cpp) -addPythonExe(ufunc ufunc.cpp) -addPythonExe(wrap wrap.cpp) - -# # installation logic (skip until it is better thought out) -# set(DEST_EXAMPLE boost.numpy/example) -# -# # install executables demonstrating embedding python -# install(TARGETS dtype fromdata ndarray simple ufunc wrap RUNTIME -# DESTINATION ${DEST_EXAMPLE} -# ${INSTALL_PERMSSIONS_RUNTIME} -# ) -# -# # install extension module -# install(TARGETS gaussian LIBRARY -# DESTINATION ${DEST_EXAMPLE} -# ${INSTALL_PERMSSIONS_RUNTIME} -# ) -# -# # install source file using the extension module -# install(FILES demo_gaussian.py -# DESTINATION ${DEST_EXAMPLE} -# ${INSTALL_PERMSSIONS_SRC} -# ) diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/Jamfile b/src/3rdparty/Boost.NumPy/libs/numpy/example/Jamfile deleted file mode 100644 index 7355f0e90..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/Jamfile +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2011 Stefan Seefeld. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import python ; - -use-project /boost/numpy : ../src ; -project /boost/numpy/example ; - -lib boost_python ; - -exe simple : simple.cpp ../src//boost_numpy boost_python /python//python ; -exe dtype : dtype.cpp ../src//boost_numpy boost_python /python//python ; -exe ndarray : ndarray.cpp ../src//boost_numpy boost_python /python//python ; -exe hybrid : hybrid.cpp ../src//boost_numpy boost_python /python//python ; -exe fromdata : fromdata.cpp ../src//boost_numpy boost_python /python//python ; -exe ufunc : ufunc.cpp ../src//boost_numpy boost_python /python//python ; - -python-extension gaussian : gaussian.cpp ../src//boost_numpy boost_python ; diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/SConscript b/src/3rdparty/Boost.NumPy/libs/numpy/example/SConscript deleted file mode 100644 index 66490e73f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/SConscript +++ /dev/null @@ -1,27 +0,0 @@ -# -*- python -*- - -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -Import("env") - -import os - -example_env = env.Clone() -lib_path = os.path.abspath(os.path.join("..", "src")) -example_env.Append(LIBPATH=[lib_path]) -example_env.Append(RPATH=[lib_path]) -example_env.Append(LINKFLAGS = ["$__RPATH"]) # workaround for SCons bug #1644 -example_env.Append(LIBS=["boost_numpy"]) - -example = [] - -for name in ("ufunc", "dtype", "fromdata", "ndarray", "simple"): - example.extend(example_env.Program(name, "%s.cpp" % name)) - -for name in ("gaussian",): - example.extend(example_env.SharedLibrary(name, "%s.cpp" % name, SHLIBPREFIX="")) - -Return("example") diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/demo_gaussian.py b/src/3rdparty/Boost.NumPy/libs/numpy/example/demo_gaussian.py deleted file mode 100644 index 0b1c78995..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/demo_gaussian.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import numpy -import gaussian - -mu = numpy.zeros(2, dtype=float) -sigma = numpy.identity(2, dtype=float) -sigma[0, 1] = 0.15 -sigma[1, 0] = 0.15 - -g = gaussian.bivariate_gaussian(mu, sigma) - -r = numpy.linspace(-40, 40, 1001) -x, y = numpy.meshgrid(r, r) - -z = g(x, y) - -s = z.sum() * (r[1] - r[0])**2 -print "sum (should be ~ 1):", s - -xc = (z * x).sum() / z.sum() -print "x centroid (should be ~ %f): %f" % (mu[0], xc) - -yc = (z * y).sum() / z.sum() -print "y centroid (should be ~ %f): %f" % (mu[1], yc) - -xx = (z * (x - xc)**2).sum() / z.sum() -print "xx moment (should be ~ %f): %f" % (sigma[0,0], xx) - -yy = (z * (y - yc)**2).sum() / z.sum() -print "yy moment (should be ~ %f): %f" % (sigma[1,1], yy) - -xy = 0.5 * (z * (x - xc) * (y - yc)).sum() / z.sum() -print "xy moment (should be ~ %f): %f" % (sigma[0,1], xy) diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/dtype.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/dtype.cpp deleted file mode 100644 index 41c15db3f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/dtype.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright Ankit Daftery 2011-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/** - * @brief An example to show how to create ndarrays with built-in python data types, and extract - * the types and values of member variables - * - * @todo Add an example to show type conversion. - * Add an example to show use of user-defined types - * - */ - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -int main(int argc, char **argv) -{ - // Initialize the Python runtime. - Py_Initialize(); - // Initialize NumPy - np::initialize(); - // Create a 3x3 shape... - p::tuple shape = p::make_tuple(3, 3); - // ...as well as a type for C++ double - np::dtype dtype = np::dtype::get_builtin(); - // Construct an array with the above shape and type - np::ndarray a = np::zeros(shape, dtype); - // Print the array - std::cout << "Original array:\n" << p::extract(p::str(a)) << std::endl; - // Print the datatype of the elements - std::cout << "Datatype is:\n" << p::extract(p::str(a.get_dtype())) << std::endl ; - // Using user defined dtypes to create dtype and an array of the custom dtype - // First create a tuple with a variable name and its dtype, double, to create a custom dtype - p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ; - // The list needs to be created, because the constructor to create the custom dtype - // takes a list of (variable,variable_type) as an argument - p::list list_for_dtype ; - list_for_dtype.append(for_custom_dtype) ; - // Create the custom dtype - np::dtype custom_dtype = np::dtype(list_for_dtype) ; - // Create an ndarray with the custom dtype - np::ndarray new_array = np::zeros(shape,custom_dtype); - -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/fromdata.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/fromdata.cpp deleted file mode 100644 index 04dd5e1d7..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/fromdata.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright Ankit Daftery 2011-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/** - * @brief An example to show how to access data using raw pointers. This shows that you can use and - * manipulate data in either Python or C++ and have the changes reflected in both. - */ - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - - -int main(int argc, char **argv) -{ - // Initialize the Python runtime. - Py_Initialize(); - // Initialize NumPy - np::initialize(); - // Create an array in C++ - int arr[] = {1,2,3,4} ; - // Create the ndarray in Python - np::ndarray py_array = np::from_data(arr, np::dtype::get_builtin() , p::make_tuple(4), p::make_tuple(4), p::object()); - // Print the ndarray that we just created, and the source C++ array - std::cout << "C++ array :" << std::endl ; - for (int j=0;j<4;j++) - { - std::cout << arr[j] << ' ' ; - } - std::cout << std::endl << "Python ndarray :" << p::extract(p::str(py_array)) << std::endl; - // Change an element in the python ndarray - py_array[1] = 5 ; - // And see if the C++ container is changed or not - std::cout << "Is the change reflected in the C++ array used to create the ndarray ? " << std::endl ; - for (int j = 0;j<4 ; j++) - { - std::cout << arr[j] << ' ' ; - } - // Conversely, change it in C++ - arr[2] = 8 ; - // And see if the changes are reflected in the Python ndarray - std::cout << std::endl << "Is the change reflected in the Python ndarray ?" << std::endl << p::extract(p::str(py_array)) << std::endl; - -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/gaussian.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/gaussian.cpp deleted file mode 100644 index 85045382e..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/gaussian.cpp +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include - -#ifndef M_PI -#include -const double M_PI = boost::math::constants::pi(); -#endif - -namespace bp = boost::python; -namespace bn = boost::numpy; - -/** - * A 2x2 matrix class, purely for demonstration purposes. - * - * Instead of wrapping this class with Boost.Python, we'll convert it to/from numpy.ndarray. - */ -class matrix2 { -public: - - double & operator()(int i, int j) { - return _data[i*2 + j]; - } - - double const & operator()(int i, int j) const { - return _data[i*2 + j]; - } - - double const * data() const { return _data; } - -private: - double _data[4]; -}; - -/** - * A 2-element vector class, purely for demonstration purposes. - * - * Instead of wrapping this class with Boost.Python, we'll convert it to/from numpy.ndarray. - */ -class vector2 { -public: - - double & operator[](int i) { - return _data[i]; - } - - double const & operator[](int i) const { - return _data[i]; - } - - double const * data() const { return _data; } - - vector2 operator+(vector2 const & other) const { - vector2 r; - r[0] = _data[0] + other[0]; - r[1] = _data[1] + other[1]; - return r; - } - - vector2 operator-(vector2 const & other) const { - vector2 r; - r[0] = _data[0] - other[0]; - r[1] = _data[1] - other[1]; - return r; - } - -private: - double _data[2]; -}; - -/** - * Matrix-vector multiplication. - */ -vector2 operator*(matrix2 const & m, vector2 const & v) { - vector2 r; - r[0] = m(0, 0) * v[0] + m(0, 1) * v[1]; - r[1] = m(1, 0) * v[0] + m(1, 1) * v[1]; - return r; -} - -/** - * Vector inner product. - */ -double dot(vector2 const & v1, vector2 const & v2) { - return v1[0] * v2[0] + v1[1] * v2[1]; -} - -/** - * This class represents a simple 2-d Gaussian (Normal) distribution, defined by a - * mean vector 'mu' and a covariance matrix 'sigma'. - */ -class bivariate_gaussian { -public: - - vector2 const & get_mu() const { return _mu; } - - matrix2 const & get_sigma() const { return _sigma; } - - /** - * Evaluate the density of the distribution at a point defined by a two-element vector. - */ - double operator()(vector2 const & p) const { - vector2 u = _cholesky * (p - _mu); - return 0.5 * _cholesky(0, 0) * _cholesky(1, 1) * std::exp(-0.5 * dot(u, u)) / M_PI; - } - - /** - * Evaluate the density of the distribution at an (x, y) point. - */ - double operator()(double x, double y) const { - vector2 p; - p[0] = x; - p[1] = y; - return operator()(p); - } - - /** - * Construct from a mean vector and covariance matrix. - */ - bivariate_gaussian(vector2 const & mu, matrix2 const & sigma) - : _mu(mu), _sigma(sigma), _cholesky(compute_inverse_cholesky(sigma)) - {} - -private: - - /** - * This evaluates the inverse of the Cholesky factorization of a 2x2 matrix; - * it's just a shortcut in evaluating the density. - */ - static matrix2 compute_inverse_cholesky(matrix2 const & m) { - matrix2 l; - // First do cholesky factorization: l l^t = m - l(0, 0) = std::sqrt(m(0, 0)); - l(0, 1) = m(0, 1) / l(0, 0); - l(1, 1) = std::sqrt(m(1, 1) - l(0,1) * l(0,1)); - // Now do forward-substitution (in-place) to invert: - l(0, 0) = 1.0 / l(0, 0); - l(1, 0) = l(0, 1) = -l(0, 1) / l(1, 1); - l(1, 1) = 1.0 / l(1, 1); - return l; - } - - vector2 _mu; - matrix2 _sigma; - matrix2 _cholesky; - -}; - -/* - * We have a two options for wrapping get_mu and get_sigma into NumPy-returning Python methods: - * - we could deep-copy the data, making totally new NumPy arrays; - * - we could make NumPy arrays that point into the existing memory. - * The latter is often preferable, especially if the arrays are large, but it's dangerous unless - * the reference counting is correct: the returned NumPy array needs to hold a reference that - * keeps the memory it points to from being deallocated as long as it is alive. This is what the - * "owner" argument to from_data does - the NumPy array holds a reference to the owner, keeping it - * from being destroyed. - * - * Note that this mechanism isn't completely safe for data members that can have their internal - * storage reallocated. A std::vector, for instance, can be invalidated when it is resized, - * so holding a Python reference to a C++ class that holds a std::vector may not be a guarantee - * that the memory in the std::vector will remain valid. - */ - -/** - * These two functions are custom wrappers for get_mu and get_sigma, providing the shallow-copy - * conversion with reference counting described above. - * - * It's also worth noting that these return NumPy arrays that cannot be modified in Python; - * the const overloads of vector::data() and matrix::data() return const references, - * and passing a const pointer to from_data causes NumPy's 'writeable' flag to be set to false. - */ -static bn::ndarray py_get_mu(bp::object const & self) { - vector2 const & mu = bp::extract(self)().get_mu(); - return bn::from_data( - mu.data(), - bn::dtype::get_builtin(), - bp::make_tuple(2), - bp::make_tuple(sizeof(double)), - self - ); -} -static bn::ndarray py_get_sigma(bp::object const & self) { - matrix2 const & sigma = bp::extract(self)().get_sigma(); - return bn::from_data( - sigma.data(), - bn::dtype::get_builtin(), - bp::make_tuple(2, 2), - bp::make_tuple(2 * sizeof(double), sizeof(double)), - self - ); -} - -/** - * To allow the constructor to work, we need to define some from-Python converters from NumPy arrays - * to the matrix/vector types. The rvalue-from-python functionality is not well-documented in Boost.Python - * itself; you can learn more from boost/python/converter/rvalue_from_python_data.hpp. - */ - -/** - * We start with two functions that just copy a NumPy array into matrix/vector objects. These will be used - * in the templated converted below. The first just uses the operator[] overloads provided by - * bp::object. - */ -static void copy_ndarray_to_mv2(bn::ndarray const & array, vector2 & vec) { - vec[0] = bp::extract(array[0]); - vec[1] = bp::extract(array[1]); -} - -/** - * Here, we'll take the alternate approach of using the strides to access the array's memory directly. - * This can be much faster for large arrays. - */ -static void copy_ndarray_to_mv2(bn::ndarray const & array, matrix2 & mat) { - // Unfortunately, get_strides() can't be inlined, so it's best to call it once up-front. - Py_intptr_t const * strides = array.get_strides(); - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 2; ++j) { - mat(i, j) = *reinterpret_cast(array.get_data() + i * strides[0] + j * strides[1]); - } - } -} - -/** - * Here's the actual converter. Because we've separated the differences into the above functions, - * we can write a single template class that works for both matrix2 and vector2. - */ -template -struct mv2_from_python { - - /** - * Register the converter. - */ - mv2_from_python() { - bp::converter::registry::push_back( - &convertible, - &construct, - bp::type_id< T >() - ); - } - - /** - * Test to see if we can convert this to the desired type; if not return zero. - * If we can convert, returned pointer can be used by construct(). - */ - static void * convertible(PyObject * p) { - try { - bp::object obj(bp::handle<>(bp::borrowed(p))); - std::auto_ptr array( - new bn::ndarray( - bn::from_object(obj, bn::dtype::get_builtin(), N, N, bn::ndarray::V_CONTIGUOUS) - ) - ); - if (array->shape(0) != 2) return 0; - if (N == 2 && array->shape(1) != 2) return 0; - return array.release(); - } catch (bp::error_already_set & err) { - bp::handle_exception(); - return 0; - } - } - - /** - * Finish the conversion by initializing the C++ object into memory prepared by Boost.Python. - */ - static void construct(PyObject * obj, bp::converter::rvalue_from_python_stage1_data * data) { - // Extract the array we passed out of the convertible() member function. - std::auto_ptr array(reinterpret_cast(data->convertible)); - // Find the memory block Boost.Python has prepared for the result. - typedef bp::converter::rvalue_from_python_storage storage_t; - storage_t * storage = reinterpret_cast(data); - // Use placement new to initialize the result. - T * m_or_v = new (storage->storage.bytes) T(); - // Fill the result with the values from the NumPy array. - copy_ndarray_to_mv2(*array, *m_or_v); - // Finish up. - data->convertible = storage->storage.bytes; - } - -}; - - -BOOST_PYTHON_MODULE(gaussian) { - bn::initialize(); - - // Register the from-python converters - mv2_from_python< vector2, 1 >(); - mv2_from_python< matrix2, 2 >(); - - typedef double (bivariate_gaussian::*call_vector)(vector2 const &) const; - - bp::class_("bivariate_gaussian", bp::init()) - - // Declare the constructor (wouldn't work without the from-python converters). - .def(bp::init< vector2 const &, matrix2 const & >()) - - // Use our custom reference-counting getters - .add_property("mu", &py_get_mu) - .add_property("sigma", &py_get_sigma) - - // First overload accepts a two-element array argument - .def("__call__", (call_vector)&bivariate_gaussian::operator()) - - // This overload works like a binary NumPy universal function: you can pass - // in scalars or arrays, and the C++ function will automatically be called - // on each element of an array argument. - .def("__call__", bn::binary_ufunc::make()) - ; -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/ndarray.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/ndarray.cpp deleted file mode 100644 index 510fd94a9..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/ndarray.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright Ankit Daftery 2011-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/** - * @brief An example to show how to create ndarrays using arbitrary Python sequences. - * - * The Python sequence could be any object whose __array__ method returns an array, or any - * (nested) sequence. This example also shows how to create arrays using both unit and - * non-unit strides. - */ - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -#if _MSC_VER -using boost::uint8_t; -#endif - -int main(int argc, char **argv) -{ - // Initialize the Python runtime. - Py_Initialize(); - // Initialize NumPy - np::initialize(); - // Create an ndarray from a simple tuple - p::object tu = p::make_tuple('a','b','c') ; - np::ndarray example_tuple = np::array (tu) ; - // and from a list - p::list l ; - np::ndarray example_list = np::array (l) ; - // Optionally, you can also specify a dtype - np::dtype dt = np::dtype::get_builtin(); - np::ndarray example_list1 = np::array (l,dt); - // You can also create an array by supplying data.First,create an integer array - int data[] = {1,2,3,4} ; - // Create a shape, and strides, needed by the function - p::tuple shape = p::make_tuple(4) ; - p::tuple stride = p::make_tuple(4) ; - // The function also needs an owner, to keep track of the data array passed. Passing none is dangerous - p::object own ; - // The from_data function takes the data array, datatype,shape,stride and owner as arguments - // and returns an ndarray - np::ndarray data_ex = np::from_data(data,dt,shape,stride,own); - // Print the ndarray we created - std::cout << "Single dimensional array ::" << std::endl << p::extract < char const * > (p::str(data_ex)) << std::endl ; - // Now lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides - // First lets create a 3x4 array of 8-bit integers - uint8_t mul_data[][4] = {{1,2,3,4},{5,6,7,8},{1,3,5,7}}; - // Now let's create an array of 3x2 elements, picking the first and third elements from each row - // For that, the shape will be 3x2 - shape = p::make_tuple(3,2) ; - // The strides will be 4x2 i.e. 4 bytes to go to the next desired row, and 2 bytes to go to the next desired column - stride = p::make_tuple(4,2) ; - // Get the numpy dtype for the built-in 8-bit integer data type - np::dtype dt1 = np::dtype::get_builtin(); - // First lets create and print out the ndarray as is - np::ndarray mul_data_ex = np::from_data(mul_data,dt1, p::make_tuple(3,4),p::make_tuple(4,1),p::object()); - std::cout << "Original multi dimensional array :: " << std::endl << p::extract < char const * > (p::str(mul_data_ex)) << std::endl ; - // Now create the new ndarray using the shape and strides - mul_data_ex = np::from_data(mul_data,dt1, shape,stride,p::object()); - // Print out the array we created using non-unit strides - std::cout << "Selective multidimensional array :: "< (p::str(mul_data_ex)) << std::endl ; - -} - - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/simple.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/simple.cpp deleted file mode 100644 index b1f2dc3f2..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/simple.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2011 Stefan Seefeld. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -int main(int argc, char **argv) -{ - // Initialize the Python runtime. - Py_Initialize(); - // Initialize NumPy - np::initialize(); - // Create a 3x3 shape... - p::tuple shape = p::make_tuple(3, 3); - // ...as well as a type for C++ float - np::dtype dtype = np::dtype::get_builtin(); - // Construct an array with the above shape and type - np::ndarray a = np::zeros(shape, dtype); - // Construct an empty array with the above shape and dtype as well - np::ndarray b = np::empty(shape,dtype); - // Print the array - std::cout << "Original array:\n" << p::extract(p::str(a)) << std::endl; - // Reshape the array into a 1D array - a = a.reshape(p::make_tuple(9)); - // Print it again. - std::cout << "Reshaped array:\n" << p::extract(p::str(a)) << std::endl; -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/ufunc.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/ufunc.cpp deleted file mode 100644 index 66a691a69..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/ufunc.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright Ankit Daftery 2011-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/** - * @brief An example to demonstrate use of universal functions or ufuncs - * - * - * @todo Calling the overloaded () operator is in a roundabout manner, find a simpler way - * None of the methods like np::add, np::multiply etc are supported as yet - */ - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - - -// Create the structs necessary to implement the ufuncs -// The typedefs *must* be made - -struct UnarySquare -{ - typedef double argument_type; - typedef double result_type; - - double operator()(double r) const { return r * r;} -}; - -struct BinarySquare -{ - typedef double first_argument_type; - typedef double second_argument_type; - typedef double result_type; - - double operator()(double a,double b) const { return (a*a + b*b) ; } -}; - -int main(int argc, char **argv) -{ - // Initialize the Python runtime. - Py_Initialize(); - // Initialize NumPy - np::initialize(); - // Expose the struct UnarySquare to Python as a class, and let ud be the class object - p::object ud = p::class_ >("UnarySquare") - .def("__call__", np::unary_ufunc::make()); - // Let inst be an instance of the class ud - p::object inst = ud(); - // Use the "__call__" method to call the overloaded () operator and print the value - std::cout << "Square of unary scalar 1.0 is " << p::extract (p::str(inst.attr("__call__")(1.0))) << std::endl ; - // Create an array in C++ - int arr[] = {1,2,3,4} ; - // ..and use it to create the ndarray in Python - np::ndarray demo_array = np::from_data(arr, np::dtype::get_builtin() , p::make_tuple(4), p::make_tuple(4), p::object()); - // Print out the demo array - std::cout << "Demo array is " << p::extract (p::str(demo_array)) << std::endl ; - // Call the "__call__" method to perform the operation and assign the value to result_array - p::object result_array = inst.attr("__call__")(demo_array) ; - // Print the resultant array - std::cout << "Square of demo array is " << p::extract (p::str(result_array)) << std::endl ; - // Lets try the same with a list - p::list li ; - li.append(3); - li.append(7); - // Print out the demo list - std::cout << "Demo list is " << p::extract (p::str(li)) << std::endl ; - // Call the ufunc for the list - result_array = inst.attr("__call__")(li) ; - // And print the list out - std::cout << "Square of demo list is " << p::extract (p::str(result_array)) << std::endl ; - // Now lets try Binary ufuncs - // Expose the struct BinarySquare to Python as a class, and let ud be the class object - ud = p::class_ >("BinarySquare") - .def("__call__", np::binary_ufunc::make()); - // Again initialise inst as an instance of the class ud - inst = ud(); - // Print the two input listsPrint the two input lists - std::cout << "The two input list for binary ufunc are " << std::endl << p::extract (p::str(demo_array)) << std::endl << p::extract (p::str(demo_array)) << std::endl ; - // Call the binary ufunc taking demo_array as both inputs - result_array = inst.attr("__call__")(demo_array,demo_array) ; - std::cout << "Square of list with binary ufunc is " << p::extract (p::str(result_array)) << std::endl ; -} - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/example/wrap.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/example/wrap.cpp deleted file mode 100644 index 06a8d552a..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/example/wrap.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright Jim Bosch 2011-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/** - * A simple example showing how to wrap a couple of C++ functions that - * operate on 2-d arrays into Python functions that take NumPy arrays - * as arguments. - * - * If you find have a lot of such functions to wrap, you may want to - * create a C++ array type (or use one of the many existing C++ array - * libraries) that maps well to NumPy arrays and create Boost.Python - * converters. There's more work up front than the approach here, - * but much less boilerplate per function. See the "Gaussian" example - * included with Boost.NumPy for an example of custom converters, or - * take a look at the "ndarray" project on GitHub for a more complete, - * high-level solution. - * - * Note that we're using embedded Python here only to make a convenient - * self-contained example; you could just as easily put the wrappers - * in a regular C++-compiled module and imported them in regular - * Python. Again, see the Gaussian demo for an example. - */ - -#include -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -// This is roughly the most efficient way to write a C/C++ function that operates -// on a 2-d NumPy array - operate directly on the array by incrementing a pointer -// with the strides. -void fill1(double * array, int rows, int cols, int row_stride, int col_stride) { - double * row_iter = array; - double n = 0.0; // just a counter we'll fill the array with. - for (int i = 0; i < rows; ++i, row_iter += row_stride) { - double * col_iter = row_iter; - for (int j = 0; j < cols; ++j, col_iter += col_stride) { - *col_iter = ++n; - } - } -} - -// Here's a simple wrapper function for fill1. It requires that the passed -// NumPy array be exactly what we're looking for - no conversion from nested -// sequences or arrays with other data types, because we want to modify it -// in-place. -void wrap_fill1(np::ndarray const & array) { - if (array.get_dtype() != np::dtype::get_builtin()) { - PyErr_SetString(PyExc_TypeError, "Incorrect array data type"); - p::throw_error_already_set(); - } - if (array.get_nd() != 2) { - PyErr_SetString(PyExc_TypeError, "Incorrect number of dimensions"); - p::throw_error_already_set(); - } - fill1(reinterpret_cast(array.get_data()), - array.shape(0), array.shape(1), - array.strides(0) / sizeof(double), array.strides(1) / sizeof(double)); -} - -// Another fill function that takes a double**. This is less efficient, because -// it's not the native NumPy data layout, but it's common enough in C/C++ that -// it's worth its own example. This time we don't pass the strides, and instead -// in wrap_fill2 we'll require the C_CONTIGUOUS bitflag, which guarantees that -// the column stride is 1 and the row stride is the number of columns. That -// restricts the arrays that can be passed to fill2 (it won't work on most -// subarray views or transposes, for instance). -void fill2(double ** array, int rows, int cols) { - double n = 0.0; // just a counter we'll fill the array with. - for (int i = 0; i < rows; ++i) { - for (int j = 0; j < cols; ++j) { - array[i][j] = ++n; - } - } -} -// Here's the wrapper for fill2; it's a little more complicated because we need -// to check the flags and create the array of pointers. -void wrap_fill2(np::ndarray const & array) { - if (array.get_dtype() != np::dtype::get_builtin()) { - PyErr_SetString(PyExc_TypeError, "Incorrect array data type"); - p::throw_error_already_set(); - } - if (array.get_nd() != 2) { - PyErr_SetString(PyExc_TypeError, "Incorrect number of dimensions"); - p::throw_error_already_set(); - } - if (!(array.get_flags() & np::ndarray::C_CONTIGUOUS)) { - PyErr_SetString(PyExc_TypeError, "Array must be row-major contiguous"); - p::throw_error_already_set(); - } - double * iter = reinterpret_cast(array.get_data()); - int rows = array.shape(0); - int cols = array.shape(1); - boost::scoped_array ptrs(new double*[rows]); - for (int i = 0; i < rows; ++i, iter += cols) { - ptrs[i] = iter; - } - fill2(ptrs.get(), array.shape(0), array.shape(1)); -} - -BOOST_PYTHON_MODULE(example) { - np::initialize(); // have to put this in any module that uses Boost.NumPy - p::def("fill1", wrap_fill1); - p::def("fill2", wrap_fill2); -} - -int main(int argc, char **argv) -{ - // This line makes our module available to the embedded Python intepreter. - PyImport_AppendInittab("example", &initexample); - - // Initialize the Python runtime. - Py_Initialize(); - - PyRun_SimpleString( - "import example\n" - "import numpy\n" - "z1 = numpy.zeros((5,6), dtype=float)\n" - "z2 = numpy.zeros((4,3), dtype=float)\n" - "example.fill1(z1)\n" - "example.fill2(z2)\n" - "print z1\n" - "print z2\n" - ); - Py_Finalize(); -} - - diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/CMakeLists.txt b/src/3rdparty/Boost.NumPy/libs/numpy/src/CMakeLists.txt deleted file mode 100644 index 6b9666400..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -add_library(boost_numpy ${LIBRARY_TYPE} - # header files - ../../../boost/numpy/dtype.hpp - ../../../boost/numpy/internal.hpp - ../../../boost/numpy/invoke_matching.hpp - ../../../boost/numpy/matrix.hpp - ../../../boost/numpy/ndarray.hpp - ../../../boost/numpy/numpy_object_mgr_traits.hpp - ../../../boost/numpy/scalars.hpp - ../../../boost/numpy/ufunc.hpp - - # source files (in current directory) - dtype.cpp - scalars.cpp - ndarray.cpp - matrix.cpp - ufunc.cpp - numpy.cpp -) -target_link_libraries(boost_numpy ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) - -install(TARGETS boost_numpy - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/Jamfile b/src/3rdparty/Boost.NumPy/libs/numpy/src/Jamfile deleted file mode 100644 index 8f52e27b1..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/Jamfile +++ /dev/null @@ -1,64 +0,0 @@ -import python ; -#import numpy ; -import regex ; -using python ; - -libraries = ; - -if [ python.configured ] -{ - -project boost/numpy - : source-location . -# : requirements - ; - -lib boost_python ; - -rule numpy-includes ( properties * ) -{ - import feature ; - local python-interpreter = [ feature.get-values python.interpreter : $(properties) ] ; - if $(python-interpreter) - { - local full-cmd = - $(python-interpreter)" -c \"from numpy.distutils import misc_util; print ':'.join(misc_util.get_numpy_include_dirs())\" " ; - local output = [ SHELL $(full-cmd) ] ; - local includes = [ regex.split $(output) ":" ] ; - return $(includes) ; - } -} - -lib boost_numpy - : # sources - dtype.cpp - scalars.cpp - ndarray.cpp - matrix.cpp - ufunc.cpp - numpy.cpp - : # requirements - /python//python_for_extensions - #/boost/python//boost_python - boost_python - @numpy-includes - : # default build - shared - : # usage requirements - @numpy-includes - ; - -libraries += boost_numpy ; - -} -else if ! ( --without-python in [ modules.peek : ARGV ] ) -{ - message boost_numpy - : "warning: No python installation configured and autoconfiguration" - : "note: failed. See http://www.boost.org/libs/python/doc/building.html" - : "note: for configuration instructions or pass --without-python to" - : "note: suppress this message and silently skip all Boost.NumPy targets" - ; -} - -#boost-install $(libraries) ; diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/SConscript b/src/3rdparty/Boost.NumPy/libs/numpy/src/SConscript deleted file mode 100644 index c4fe05b1f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# -*- python -*- - -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -Import("env") - -lib = env.SharedLibrary("boost_numpy", Glob("*.cpp")) - -Return("lib") diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/dtype.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/dtype.cpp deleted file mode 100644 index a21c27eb6..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/dtype.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL -#include - -#define DTYPE_FROM_CODE(code) \ - dtype(python::detail::new_reference(reinterpret_cast(PyArray_DescrFromType(code)))) - -#define BUILTIN_INT_DTYPE(bits) \ - template <> struct builtin_int_dtype< bits, false > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_INT ## bits); } \ - }; \ - template <> struct builtin_int_dtype< bits, true > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_UINT ## bits); } \ - }; \ - template dtype get_int_dtype< bits, false >(); \ - template dtype get_int_dtype< bits, true >() - -#define BUILTIN_FLOAT_DTYPE(bits) \ - template <> struct builtin_float_dtype< bits > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_FLOAT ## bits); } \ - }; \ - template dtype get_float_dtype< bits >() - -#define BUILTIN_COMPLEX_DTYPE(bits) \ - template <> struct builtin_complex_dtype< bits > { \ - static dtype get() { return DTYPE_FROM_CODE(NPY_COMPLEX ## bits); } \ - }; \ - template dtype get_complex_dtype< bits >() - -namespace boost { namespace python { namespace converter { -NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayDescr_Type, numpy::dtype) -}}} // namespace boost::python::converter - -namespace boost { namespace numpy { - -namespace detail { - -dtype builtin_dtype::get() { return DTYPE_FROM_CODE(NPY_BOOL); } - -template struct builtin_int_dtype; -template struct builtin_float_dtype; -template struct builtin_complex_dtype; - -template dtype get_int_dtype() { - return builtin_int_dtype::get(); -} -template dtype get_float_dtype() { return builtin_float_dtype::get(); } -template dtype get_complex_dtype() { return builtin_complex_dtype::get(); } - -BUILTIN_INT_DTYPE(8); -BUILTIN_INT_DTYPE(16); -BUILTIN_INT_DTYPE(32); -BUILTIN_INT_DTYPE(64); -BUILTIN_FLOAT_DTYPE(32); -BUILTIN_FLOAT_DTYPE(64); -BUILTIN_COMPLEX_DTYPE(64); -BUILTIN_COMPLEX_DTYPE(128); -#if NPY_BITSOF_LONGDOUBLE > NPY_BITSOF_DOUBLE -template <> struct builtin_float_dtype< NPY_BITSOF_LONGDOUBLE > { - static dtype get() { return DTYPE_FROM_CODE(NPY_LONGDOUBLE); } -}; -template dtype get_float_dtype< NPY_BITSOF_LONGDOUBLE >(); -template <> struct builtin_complex_dtype< 2 * NPY_BITSOF_LONGDOUBLE > { - static dtype get() { return DTYPE_FROM_CODE(NPY_CLONGDOUBLE); } -}; -template dtype get_complex_dtype< 2 * NPY_BITSOF_LONGDOUBLE >(); -#endif - -} // namespace detail - -python::detail::new_reference dtype::convert(python::object const & arg, bool align) { - PyArray_Descr* obj=NULL; - if (align) { - if (PyArray_DescrAlignConverter(arg.ptr(), &obj) < 0) - python::throw_error_already_set(); - } else { - if (PyArray_DescrConverter(arg.ptr(), &obj) < 0) - python::throw_error_already_set(); - } - return python::detail::new_reference(reinterpret_cast(obj)); -} - -int dtype::get_itemsize() const { return reinterpret_cast(ptr())->elsize;} - -bool equivalent(dtype const & a, dtype const & b) { - return PyArray_EquivTypes( - reinterpret_cast(a.ptr()), - reinterpret_cast(b.ptr()) - ); -} - -namespace { - -namespace pyconv = boost::python::converter; - -template -class array_scalar_converter { -public: - - static PyTypeObject const * get_pytype() { - // This implementation depends on the fact that get_builtin returns pointers to objects - // NumPy has declared statically, and that the typeobj member also refers to a static - // object. That means we don't need to do any reference counting. - // In fact, I'm somewhat concerned that increasing the reference count of any of these - // might cause leaks, because I don't think Boost.Python ever decrements it, but it's - // probably a moot point if everything is actually static. - return reinterpret_cast(dtype::get_builtin().ptr())->typeobj; - } - - static void * convertible(PyObject * obj) { - if (obj->ob_type == get_pytype()) { - return obj; - } else { - return 0; - } - } - - static void convert(PyObject * obj, pyconv::rvalue_from_python_stage1_data* data) { - void * storage = reinterpret_cast*>(data)->storage.bytes; - // We assume std::complex is a "standard layout" here and elsewhere; not guaranteed by - // C++03 standard, but true in every known implementation (and guaranteed by C++11). - PyArray_ScalarAsCtype(obj, reinterpret_cast(storage)); - data->convertible = storage; - } - - static void declare() { - pyconv::registry::push_back( - &convertible, &convert, python::type_id() -#ifndef BOOST_PYTHON_NO_PY_SIGNATURES - , &get_pytype -#endif - ); - } - -}; - -} // anonymous - -void dtype::register_scalar_converters() { - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter::declare(); - array_scalar_converter< std::complex >::declare(); - array_scalar_converter< std::complex >::declare(); -#if NPY_BITSOF_LONGDOUBLE > NPY_BITSOF_DOUBLE - array_scalar_converter::declare(); - array_scalar_converter< std::complex >::declare(); -#endif -} - -} // namespace boost::numpy -} // namespace boost diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/matrix.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/matrix.cpp deleted file mode 100644 index 57e1e421a..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/matrix.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL -#include -#include - -namespace boost -{ -namespace numpy -{ -namespace detail -{ -inline python::object get_matrix_type() -{ - python::object module = python::import("numpy"); - return module.attr("matrix"); -} -} // namespace boost::numpy::detail -} // namespace boost::numpy - -namespace python -{ -namespace converter -{ - -PyTypeObject const * object_manager_traits::get_pytype() -{ - return reinterpret_cast(numpy::detail::get_matrix_type().ptr()); -} - -} // namespace boost::python::converter -} // namespace boost::python - -namespace numpy -{ - -python::object matrix::construct(python::object const & obj, dtype const & dt, bool copy) -{ - return numpy::detail::get_matrix_type()(obj, dt, copy); -} - -python::object matrix::construct(python::object const & obj, bool copy) -{ - return numpy::detail::get_matrix_type()(obj, object(), copy); -} - -matrix matrix::view(dtype const & dt) const -{ - return matrix(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("view"), const_cast("O"), dt.ptr()))); -} - -matrix matrix::copy() const -{ - return matrix(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("copy"), const_cast("")))); -} - -matrix matrix::transpose() const -{ - return matrix(python::extract(ndarray::transpose())); -} - -} // namespace boost::numpy -} // namespace boost diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/ndarray.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/ndarray.cpp deleted file mode 100644 index ce431546f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/ndarray.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL -#include -#include - -namespace boost -{ -namespace python -{ -namespace converter -{ -NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArray_Type, numpy::ndarray) -} // namespace boost::python::converter -} // namespace boost::python - -namespace numpy -{ -namespace detail -{ - -ndarray::bitflag numpy_to_bitflag(int const f) -{ - ndarray::bitflag r = ndarray::NONE; - if (f & NPY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS); - if (f & NPY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS); - if (f & NPY_ALIGNED) r = (r | ndarray::ALIGNED); - if (f & NPY_WRITEABLE) r = (r | ndarray::WRITEABLE); - return r; -} - -int const bitflag_to_numpy(ndarray::bitflag f) -{ - int r = 0; - if (f & ndarray::C_CONTIGUOUS) r |= NPY_C_CONTIGUOUS; - if (f & ndarray::F_CONTIGUOUS) r |= NPY_F_CONTIGUOUS; - if (f & ndarray::ALIGNED) r |= NPY_ALIGNED; - if (f & ndarray::WRITEABLE) r |= NPY_WRITEABLE; - return r; -} - -bool is_c_contiguous(std::vector const & shape, - std::vector const & strides, - int itemsize) -{ - std::vector::const_reverse_iterator j = strides.rbegin(); - int total = itemsize; - for (std::vector::const_reverse_iterator i = shape.rbegin(); i != shape.rend(); ++i, ++j) - { - if (total != *j) return false; - total *= (*i); - } - return true; -} - -bool is_f_contiguous(std::vector const & shape, - std::vector const & strides, - int itemsize) -{ - std::vector::const_iterator j = strides.begin(); - int total = itemsize; - for (std::vector::const_iterator i = shape.begin(); i != shape.end(); ++i, ++j) - { - if (total != *j) return false; - total *= (*i); - } - return true; -} - -bool is_aligned(std::vector const & strides, - int itemsize) -{ - for (std::vector::const_iterator i = strides.begin(); i != strides.end(); ++i) - { - if (*i % itemsize) return false; - } - return true; -} - -inline PyArray_Descr * incref_dtype(dtype const & dt) -{ - Py_INCREF(dt.ptr()); - return reinterpret_cast(dt.ptr()); -} - -ndarray from_data_impl(void * data, - dtype const & dt, - python::object const & shape, - python::object const & strides, - python::object const & owner, - bool writeable) -{ - std::vector shape_(len(shape)); - std::vector strides_(len(strides)); - if (shape_.size() != strides_.size()) - { - PyErr_SetString(PyExc_ValueError, "Length of shape and strides arrays do not match."); - python::throw_error_already_set(); - } - for (std::size_t i = 0; i < shape_.size(); ++i) - { - shape_[i] = python::extract(shape[i]); - strides_[i] = python::extract(strides[i]); - } - return from_data_impl(data, dt, shape_, strides_, owner, writeable); -} - -ndarray from_data_impl(void * data, - dtype const & dt, - std::vector const & shape, - std::vector const & strides, - python::object const & owner, - bool writeable) -{ - if (shape.size() != strides.size()) - { - PyErr_SetString(PyExc_ValueError, "Length of shape and strides arrays do not match."); - python::throw_error_already_set(); - } - int itemsize = dt.get_itemsize(); - int flags = 0; - if (writeable) flags |= NPY_WRITEABLE; - if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_C_CONTIGUOUS; - if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_F_CONTIGUOUS; - if (is_aligned(strides, itemsize)) flags |= NPY_ALIGNED; - ndarray r(python::detail::new_reference - (PyArray_NewFromDescr(&PyArray_Type, - incref_dtype(dt), - shape.size(), - const_cast(&shape.front()), - const_cast(&strides.front()), - data, - flags, - NULL))); - r.set_base(owner); - return r; -} - -} // namespace detail - -ndarray ndarray::view(dtype const & dt) const -{ - return ndarray(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("view"), const_cast("O"), dt.ptr()))); -} - -ndarray ndarray::astype(dtype const & dt) const -{ - return ndarray(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("astype"), const_cast("O"), dt.ptr()))); -} - -ndarray ndarray::copy() const -{ - return ndarray(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("copy"), const_cast("")))); -} - -dtype ndarray::get_dtype() const -{ - return dtype(python::detail::borrowed_reference(get_struct()->descr)); -} - -python::object ndarray::get_base() const -{ - if (get_struct()->base == NULL) return object(); - return python::object(python::detail::borrowed_reference(get_struct()->base)); -} - -void ndarray::set_base(object const & base) -{ - Py_XDECREF(get_struct()->base); - if (base != object()) - { - Py_INCREF(base.ptr()); - get_struct()->base = base.ptr(); - } - else - { - get_struct()->base = NULL; - } -} - -ndarray::bitflag const ndarray::get_flags() const -{ - return numpy::detail::numpy_to_bitflag(get_struct()->flags); -} - -ndarray ndarray::transpose() const -{ - return ndarray(python::detail::new_reference - (PyArray_Transpose(reinterpret_cast(this->ptr()), NULL))); -} - -ndarray ndarray::squeeze() const -{ - return ndarray(python::detail::new_reference - (PyArray_Squeeze(reinterpret_cast(this->ptr())))); -} - -ndarray ndarray::reshape(python::tuple const & shape) const -{ - return ndarray(python::detail::new_reference - (PyArray_Reshape(reinterpret_cast(this->ptr()), shape.ptr()))); -} - -python::object ndarray::scalarize() const -{ - Py_INCREF(ptr()); - return python::object(python::detail::new_reference(PyArray_Return(reinterpret_cast(ptr())))); -} - -ndarray zeros(python::tuple const & shape, dtype const & dt) -{ - int nd = len(shape); - boost::scoped_array dims(new Py_intptr_t[nd]); - for (int n=0; n(shape[n]); - return ndarray(python::detail::new_reference - (PyArray_Zeros(nd, dims.get(), detail::incref_dtype(dt), 0))); -} - -ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt) -{ - return ndarray(python::detail::new_reference - (PyArray_Zeros(nd, const_cast(shape), detail::incref_dtype(dt), 0))); -} - -ndarray empty(python::tuple const & shape, dtype const & dt) -{ - int nd = len(shape); - boost::scoped_array dims(new Py_intptr_t[nd]); - for (int n=0; n(shape[n]); - return ndarray(python::detail::new_reference - (PyArray_Empty(nd, dims.get(), detail::incref_dtype(dt), 0))); -} - -ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt) -{ - return ndarray(python::detail::new_reference - (PyArray_Empty(nd, const_cast(shape), detail::incref_dtype(dt), 0))); -} - -ndarray array(python::object const & obj) -{ - return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ENSUREARRAY, NULL))); -} - -ndarray array(python::object const & obj, dtype const & dt) -{ - return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ENSUREARRAY, NULL))); -} - -ndarray from_object(python::object const & obj, dtype const & dt, int nd_min, int nd_max, ndarray::bitflag flags) -{ - int requirements = detail::bitflag_to_numpy(flags); - return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), - detail::incref_dtype(dt), - nd_min, nd_max, - requirements, - NULL))); -} - -ndarray from_object(python::object const & obj, int nd_min, int nd_max, ndarray::bitflag flags) -{ - int requirements = detail::bitflag_to_numpy(flags); - return ndarray(python::detail::new_reference - (PyArray_FromAny(obj.ptr(), - NULL, - nd_min, nd_max, - requirements, - NULL))); -} - -} -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/numpy.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/numpy.cpp deleted file mode 100644 index 0cc3f5f69..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/numpy.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL_MAIN -#include -#include - -namespace boost -{ -namespace numpy -{ - -#if PY_MAJOR_VERSION == 2 -static void wrap_import_array() { - import_array(); -} -#else -static void * wrap_import_array() { - import_array(); -} -#endif - -void initialize(bool register_scalar_converters) -{ - wrap_import_array(); - import_ufunc(); - if (register_scalar_converters) - dtype::register_scalar_converters(); -} - -} -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/scalars.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/scalars.cpp deleted file mode 100644 index 1f97df157..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/scalars.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL -#include - -namespace boost -{ -namespace python -{ -namespace converter -{ -NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyVoidArrType_Type, numpy::void_) -} // namespace boost::python::converter -} // namespace boost::python - -namespace numpy -{ - -void_::void_(Py_ssize_t size) - : object(python::detail::new_reference - (PyObject_CallFunction((PyObject*)&PyVoidArrType_Type, const_cast("i"), size))) -{} - -void_ void_::view(dtype const & dt) const -{ - return void_(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("view"), const_cast("O"), dt.ptr()))); -} - -void_ void_::copy() const -{ - return void_(python::detail::new_reference - (PyObject_CallMethod(this->ptr(), const_cast("copy"), const_cast("")))); -} - -} -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/src/ufunc.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/src/ufunc.cpp deleted file mode 100644 index aa6c79390..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/src/ufunc.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright Jim Bosch 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_NUMPY_INTERNAL -#include -#include - -namespace boost -{ -namespace python -{ -namespace converter -{ -NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayMultiIter_Type, numpy::multi_iter) -} // namespace boost::python::converter -} // namespace boost::python - -namespace numpy -{ - -multi_iter make_multi_iter(python::object const & a1) -{ - return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(1, a1.ptr()))); -} - -multi_iter make_multi_iter(python::object const & a1, python::object const & a2) -{ - return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(2, a1.ptr(), a2.ptr()))); -} - -multi_iter make_multi_iter(python::object const & a1, python::object const & a2, python::object const & a3) -{ - return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(3, a1.ptr(), a2.ptr(), a3.ptr()))); -} - -void multi_iter::next() -{ - PyArray_MultiIter_NEXT(ptr()); -} - -bool multi_iter::not_done() const -{ - return PyArray_MultiIter_NOTDONE(ptr()); -} - -char * multi_iter::get_data(int i) const -{ - return reinterpret_cast(PyArray_MultiIter_DATA(ptr(), i)); -} - -int const multi_iter::get_nd() const -{ - return reinterpret_cast(ptr())->nd; -} - -Py_intptr_t const * multi_iter::get_shape() const -{ - return reinterpret_cast(ptr())->dimensions; -} - -Py_intptr_t const multi_iter::shape(int n) const -{ - return reinterpret_cast(ptr())->dimensions[n]; -} - -} -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/CMakeLists.txt b/src/3rdparty/Boost.NumPy/libs/numpy/test/CMakeLists.txt deleted file mode 100644 index 0075f927f..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/CMakeLists.txt +++ /dev/null @@ -1,65 +0,0 @@ -project(BoostNumpyTests) - -if (WIN32) - set(runCmakeTest runCmakeTest.bat) - foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) - message( STATUS "configuring runCmakeTest for cfg=${cfg}" ) - CONFIGURE_FILE( ${runCmakeTest}.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${cfg}/${runCmakeTest} @ONLY ) - endforeach() -else() - set(runCmakeTest runCmakeTest.sh) - CONFIGURE_FILE( ${runCmakeTest}.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${runCmakeTest} @ONLY ) -endif() - -set( TEST_SOURCE_DIR ${PROJECT_SOURCE_DIR} ) -set( TestCommand ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${runCmakeTest} ) - -# custom macro with most of the redundant code for making a python test -macro( addPythonTest _name _srcpy ) - # make the pyd library link against boost_numpy python and boost - TARGET_LINK_LIBRARIES(${_name} boost_numpy) - - # make a test of the module using the python source file in the test directory - ADD_TEST(${_name} ${TestCommand} ${TEST_SOURCE_DIR}/${_srcpy}) - - # set the regex to use to recognize a failure since `python testfoo.py` - # does not seem to return non-zero with a test failure - set_property(TEST ${_name} PROPERTY FAIL_REGULAR_EXPRESSION "ERROR\\:" "ImportError\\: DLL load failed\\: " ) - - # put the test target into a VS solution folder named test (should - # be a no-op for Linux) - SET_PROPERTY(TARGET ${_name} PROPERTY FOLDER "test") -endmacro() - -PYTHON_ADD_MODULE(dtype_mod dtype_mod.cpp) -addPythonTest( dtype_mod dtype.py ) - -PYTHON_ADD_MODULE(indexing_mod indexing_mod.cpp) -addPythonTest( indexing_mod indexing.py ) - -PYTHON_ADD_MODULE(ndarray_mod ndarray_mod.cpp) -addPythonTest( ndarray_mod ndarray.py ) - -PYTHON_ADD_MODULE(shapes_mod shapes_mod.cpp) -addPythonTest( shapes_mod shapes.py ) - -PYTHON_ADD_MODULE(templates_mod templates_mod.cpp) -addPythonTest( templates_mod templates.py ) - -PYTHON_ADD_MODULE(ufunc_mod ufunc_mod.cpp) -addPythonTest( ufunc_mod ufunc.py ) - -# installation logic (skip until it is better thought out) -# set(DEST_TEST boost.numpy/test) -# -# # copy the extension modules to DEST_TEST -# install(TARGETS dtype_mod indexing_mod ndarray_mod shapes_mod templates_mod ufunc_mod LIBRARY -# DESTINATION ${DEST_TEST} -# ${INSTALL_PERMSSIONS_RUNTIME} -# ) -# -# # copy the source test python modules to DEST_TEST too -# install(FILES dtype.py indexing.py ndarray.py shapes.py templates.py ufunc.py -# DESTINATION ${DEST_TEST} -# ${INSTALL_PERMSSIONS_SRC} -# ) diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/Jamfile b/src/3rdparty/Boost.NumPy/libs/numpy/test/Jamfile deleted file mode 100644 index 75b158353..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/Jamfile +++ /dev/null @@ -1,23 +0,0 @@ -import testing ; -import python ; - -use-project /boost/numpy : ../src ; -project /boost/numpy/test ; - -rule numpy-test ( name : sources * : requirements * ) -{ - sources ?= $(name).py $(name)_mod.cpp ; - return [ testing.make-test run-pyd : $(sources) /boost/numpy//boost_numpy - : $(requirements) : $(name) ] ; -} - -test-suite numpy - : - - [ numpy-test templates ] - [ numpy-test ufunc ] - [ numpy-test shapes ] - [ numpy-test ndarray ] - [ numpy-test indexing ] - - ; diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/SConscript b/src/3rdparty/Boost.NumPy/libs/numpy/test/SConscript deleted file mode 100644 index de3bc9980..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/SConscript +++ /dev/null @@ -1,35 +0,0 @@ -# -*- python -*- - -# Copyright Jim Bosch 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -Import("env") - -import os -import sys - -test_env = env.Clone() -lib_path = os.path.abspath(os.path.join("..", "src")) -test_env.Append(LIBPATH=[lib_path]) -test_env.Append(RPATH=[lib_path]) -test_env.Append(LINKFLAGS = ["$__RPATH"]) # workaround for SCons bug #1644t -test_env.Append(LIBS=["boost_numpy"]) - -test = [] - -def RunPythonUnitTest(target, source, env): - if not env.Execute('%s %s' % (sys.executable, source[0].abspath)): - env.Execute(Touch(target)) - -def PythonUnitTest(env, script, dependencies): - run = env.Command(".%s.succeeded" % str(script), script, RunPythonUnitTest) - env.Depends(run, dependencies) - return run - -for name in ("dtype", "ufunc", "templates", "ndarray", "indexing", "shapes"): - mod = test_env.LoadableModule("%s_mod" % name, "%s_mod.cpp" % name, LDMODULEPREFIX="") - test.extend(PythonUnitTest(test_env, "%s.py" % name, mod)) - -Return("test") diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype.py deleted file mode 100644 index 4dadb80a6..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import dtype_mod -import unittest -import numpy - -class DtypeTestCase(unittest.TestCase): - - def assertEquivalent(self, a, b): - return self.assert_(dtype_mod.equivalent(a, b), "%r is not equivalent to %r") - - def testIntegers(self): - for bits in (8, 16, 32, 64): - s = getattr(numpy, "int%d" % bits) - u = getattr(numpy, "uint%d" % bits) - fs = getattr(dtype_mod, "accept_int%d" % bits) - fu = getattr(dtype_mod, "accept_uint%d" % bits) - self.assertEquivalent(fs(s(1)), numpy.dtype(s)) - self.assertEquivalent(fu(u(1)), numpy.dtype(u)) - # these should just use the regular Boost.Python converters - self.assertEquivalent(fs(True), numpy.dtype(s)) - self.assertEquivalent(fu(True), numpy.dtype(u)) - self.assertEquivalent(fs(int(1)), numpy.dtype(s)) - self.assertEquivalent(fu(int(1)), numpy.dtype(u)) - self.assertEquivalent(fs(long(1)), numpy.dtype(s)) - self.assertEquivalent(fu(long(1)), numpy.dtype(u)) - for name in ("bool_", "byte", "ubyte", "short", "ushort", "intc", "uintc"): - t = getattr(numpy, name) - ft = getattr(dtype_mod, "accept_%s" % name) - self.assertEquivalent(ft(t(1)), numpy.dtype(t)) - # these should just use the regular Boost.Python converters - self.assertEquivalent(ft(True), numpy.dtype(t)) - if name != "bool_": - self.assertEquivalent(ft(int(1)), numpy.dtype(t)) - self.assertEquivalent(ft(long(1)), numpy.dtype(t)) - - - def testFloats(self): - f = numpy.float32 - c = numpy.complex64 - self.assertEquivalent(dtype_mod.accept_float32(f(numpy.pi)), numpy.dtype(f)) - self.assertEquivalent(dtype_mod.accept_complex64(c(1+2j)), numpy.dtype(c)) - f = numpy.float64 - c = numpy.complex128 - self.assertEquivalent(dtype_mod.accept_float64(f(numpy.pi)), numpy.dtype(f)) - self.assertEquivalent(dtype_mod.accept_complex128(c(1+2j)), numpy.dtype(c)) - if hasattr(numpy, "longdouble"): - f = numpy.longdouble - c = numpy.clongdouble - self.assertEquivalent(dtype_mod.accept_longdouble(f(numpy.pi)), numpy.dtype(f)) - self.assertEquivalent(dtype_mod.accept_clongdouble(c(1+2j)), numpy.dtype(c)) - - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype_mod.cpp deleted file mode 100644 index b9900590e..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/dtype_mod.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -template -np::dtype accept(T) { - return np::dtype::get_builtin(); -} - -BOOST_PYTHON_MODULE(dtype_mod) -{ - np::initialize(); - // wrap dtype equivalence test, since it isn't available in Python API. - p::def("equivalent", np::equivalent); - // integers, by number of bits - p::def("accept_int8", accept); - p::def("accept_uint8", accept); - p::def("accept_int16", accept); - p::def("accept_uint16", accept); - p::def("accept_int32", accept); - p::def("accept_uint32", accept); - p::def("accept_int64", accept); - p::def("accept_uint64", accept); - // integers, by C name according to NumPy - p::def("accept_bool_", accept); - p::def("accept_byte", accept); - p::def("accept_ubyte", accept); - p::def("accept_short", accept); - p::def("accept_ushort", accept); - p::def("accept_intc", accept); - p::def("accept_uintc", accept); - // floats and complex - p::def("accept_float32", accept); - p::def("accept_complex64", accept< std::complex >); - p::def("accept_float64", accept); - p::def("accept_complex128", accept< std::complex >); - if (sizeof(long double) > sizeof(double)) { - p::def("accept_longdouble", accept); - p::def("accept_clongdouble", accept< std::complex >); - } -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing.py deleted file mode 100644 index e3d06a22b..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import unittest -import numpy -import indexing_mod - -class TestIndexing(unittest.TestCase): - - def testSingle(self): - x = numpy.arange(0,10) - for i in range(0,10): - numpy.testing.assert_equal(indexing_mod.single(x,i), i) - for i in range(-10,0): - numpy.testing.assert_equal(indexing_mod.single(x,i),10+i) - - def testSlice(self): - x = numpy.arange(0,10) - sl = slice(3,8) - b = [3,4,5,6,7] - numpy.testing.assert_equal(indexing_mod.slice(x,sl), b) - - def testStepSlice(self): - x = numpy.arange(0,10) - sl = slice(3,8,2) - b = [3,5,7] - numpy.testing.assert_equal(indexing_mod.slice(x,sl), b) - - def testIndex(self): - x = numpy.arange(0,10) - chk = numpy.array([3,4,5,6]) - numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk) - chk = numpy.array([[0,1],[2,3]]) - numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk) - x = numpy.arange(9).reshape(3,3) - y = numpy.array([0,1]) - z = numpy.array([0,2]) - chk = numpy.array([0,5]) - numpy.testing.assert_equal(indexing_mod.indexarray(x,y,z),chk) - x = numpy.arange(0,10) - b = x>4 - chk = numpy.array([5,6,7,8,9]) - numpy.testing.assert_equal(indexing_mod.indexarray(x,b),chk) - x = numpy.arange(9).reshape(3,3) - b = numpy.array([0,2]) - sl = slice(0,3) - chk = numpy.array([[0,1,2],[6,7,8]]) - numpy.testing.assert_equal(indexing_mod.indexslice(x,b,sl),chk) - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing_mod.cpp deleted file mode 100644 index dadb05dee..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/indexing_mod.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -p::object single(np::ndarray ndarr, int i) { return ndarr[i];} -p::object slice(np::ndarray ndarr, p::slice sl) { return ndarr[sl];} -p::object indexarray(np::ndarray ndarr, np::ndarray d1) { return ndarr[d1];} -p::object indexarray_2d(np::ndarray ndarr, np::ndarray d1,np::ndarray d2) { return ndarr[p::make_tuple(d1,d2)];} -p::object indexslice(np::ndarray ndarr, np::ndarray d1, p::slice sl) { return ndarr[p::make_tuple(d1, sl)];} - -BOOST_PYTHON_MODULE(indexing_mod) -{ - np::initialize(); - p::def("single", single); - p::def("slice", slice); - p::def("indexarray", indexarray); - p::def("indexarray", indexarray_2d); - p::def("indexslice", indexslice); - -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray.py deleted file mode 100644 index 6ef387ea1..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import ndarray_mod -import unittest -import numpy - -class TestNdarray(unittest.TestCase): - - def testNdzeros(self): - for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - v = numpy.zeros(60, dtype=dtp) - dt = numpy.dtype(dtp) - for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)): - a1 = ndarray_mod.zeros(shape,dt) - a2 = v.reshape(a1.shape) - self.assertEqual(shape,a1.shape) - self.assert_((a1 == a2).all()) - - def testNdzeros_matrix(self): - for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - dt = numpy.dtype(dtp) - shape = (6, 10) - a1 = ndarray_mod.zeros_matrix(shape, dt) - a2 = numpy.matrix(numpy.zeros(shape, dtype=dtp)) - self.assertEqual(shape,a1.shape) - self.assert_((a1 == a2).all()) - self.assertEqual(type(a1), type(a2)) - - def testNdarray(self): - a = range(0,60) - for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - v = numpy.array(a, dtype=dtp) - dt = numpy.dtype(dtp) - a1 = ndarray_mod.array(a) - a2 = ndarray_mod.array(a,dt) - self.assert_((a1 == v).all()) - self.assert_((a2 == v).all()) - for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)): - a1 = a1.reshape(shape) - self.assertEqual(shape,a1.shape) - a2 = a2.reshape(shape) - self.assertEqual(shape,a2.shape) - - def testNdempty(self): - for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - dt = numpy.dtype(dtp) - for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)): - a1 = ndarray_mod.empty(shape,dt) - a2 = ndarray_mod.c_empty(shape,dt) - self.assertEqual(shape,a1.shape) - self.assertEqual(shape,a2.shape) - - def testTranspose(self): - for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - dt = numpy.dtype(dtp) - for shape in ((6,10),(4,3,5),(2,2,3,5)): - a1 = numpy.empty(shape,dt) - a2 = a1.transpose() - a1 = ndarray_mod.transpose(a1) - self.assertEqual(a1.shape,a2.shape) - - def testSqueeze(self): - a1 = numpy.array([[[3,4,5]]]) - a2 = a1.squeeze() - a1 = ndarray_mod.squeeze(a1) - self.assertEqual(a1.shape,a2.shape) - - def testReshape(self): - a1 = numpy.empty((2,2)) - a2 = ndarray_mod.reshape(a1,(1,4)) - self.assertEqual(a2.shape,(1,4)) - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray_mod.cpp deleted file mode 100644 index 099b005ae..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/ndarray_mod.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -np::ndarray zeros(p::tuple shape, np::dtype dt) { return np::zeros(shape, dt);} -np::ndarray array2(p::object obj, np::dtype dt) { return np::array(obj,dt);} -np::ndarray array1(p::object obj) { return np::array(obj);} -np::ndarray empty1(p::tuple shape, np::dtype dt) { return np::empty(shape,dt);} - -np::ndarray c_empty(p::tuple shape, np::dtype dt) -{ - // convert 'shape' to a C array so we can test the corresponding - // version of the constructor - unsigned len = p::len(shape); - Py_intptr_t *c_shape = new Py_intptr_t[len]; - for (unsigned i = 0; i != len; ++i) - c_shape[i] = p::extract(shape[i]); - np::ndarray result = np::empty(len, c_shape, dt); - delete [] c_shape; - return result; -} - -np::ndarray transpose(np::ndarray arr) { return arr.transpose();} -np::ndarray squeeze(np::ndarray arr) { return arr.squeeze();} -np::ndarray reshape(np::ndarray arr,p::tuple tup) { return arr.reshape(tup);} - -BOOST_PYTHON_MODULE(ndarray_mod) -{ - np::initialize(); - p::def("zeros", zeros); - p::def("zeros_matrix", zeros, np::as_matrix<>()); - p::def("array", array2); - p::def("array", array1); - p::def("empty", empty1); - p::def("c_empty", c_empty); - p::def("transpose", transpose); - p::def("squeeze", squeeze); - p::def("reshape", reshape); -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.bat.in b/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.bat.in deleted file mode 100644 index fb1ba438b..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.bat.in +++ /dev/null @@ -1,4 +0,0 @@ -set local -set PYTHONPATH=@CMAKE_LIBRARY_OUTPUT_DIRECTORY@/@cfg@;%PYTHONPATH% -python %1 -endlocal diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.sh.in b/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.sh.in deleted file mode 100755 index efaa756d9..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/runCmakeTest.sh.in +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -export PYTHONPATH=@CMAKE_LIBRARY_OUTPUT_DIRECTORY@:${PYTHONPATH} -python $1 \ No newline at end of file diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes.py deleted file mode 100644 index 76c0e9015..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import shapes_mod -import unittest -import numpy - -class TestShapes(unittest.TestCase): - - def testShapes(self): - a1 = numpy.array([(0,1),(2,3)]) - a1_shape = (1,4) - a1 = shapes_mod.reshape(a1,a1_shape) - self.assertEqual(a1_shape,a1.shape) - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes_mod.cpp deleted file mode 100644 index f03425ae0..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/shapes_mod.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -np::ndarray reshape(np::ndarray old_array, p::tuple shape) -{ - np::ndarray local_shape = old_array.reshape(shape); - return local_shape; -} - -BOOST_PYTHON_MODULE(shapes_mod) -{ - np::initialize(); - p::def("reshape", reshape); -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/templates.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/templates.py deleted file mode 100755 index 09e90fbe4..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/templates.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import templates_mod -import unittest -import numpy - -class TestTemplates(unittest.TestCase): - - def testTemplates(self): - for dtype in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128): - v = numpy.arange(12, dtype=dtype) - for shape in ((12,), (4, 3), (2, 6)): - a1 = numpy.zeros(shape, dtype=dtype) - a2 = v.reshape(a1.shape) - templates_mod.fill(a1) - self.assert_((a1 == a2).all()) - a1 = numpy.zeros((12,), dtype=numpy.float64) - self.assertRaises(TypeError, templates_mod.fill, a1) - a1 = numpy.zeros((12,2,3), dtype=numpy.float32) - self.assertRaises(TypeError, templates_mod.fill, a1) - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/templates_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/templates_mod.cpp deleted file mode 100644 index c9a4cc919..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/templates_mod.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -struct ArrayFiller -{ - - typedef boost::mpl::vector< short, int, float, std::complex > TypeSequence; - typedef boost::mpl::vector_c< int, 1, 2 > DimSequence; - - explicit ArrayFiller(np::ndarray const & arg) : argument(arg) {} - - template - void apply() const - { - if (N == 1) - { - char * p = argument.get_data(); - int stride = argument.strides(0); - int size = argument.shape(0); - for (int n = 0; n != size; ++n, p += stride) - *reinterpret_cast(p) = static_cast(n); - } - else - { - char * row_p = argument.get_data(); - int row_stride = argument.strides(0); - int col_stride = argument.strides(1); - int rows = argument.shape(0); - int cols = argument.shape(1); - int i = 0; - for (int n = 0; n != rows; ++n, row_p += row_stride) - { - char * col_p = row_p; - for (int m = 0; m != cols; ++i, ++m, col_p += col_stride) - *reinterpret_cast(col_p) = static_cast(i); - } - } - } - - np::ndarray argument; -}; - -void fill(np::ndarray const & arg) -{ - ArrayFiller filler(arg); - np::invoke_matching_array(arg, filler); -} - -BOOST_PYTHON_MODULE(templates_mod) -{ - np::initialize(); - p::def("fill", fill); -} diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc.py b/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc.py deleted file mode 100755 index b698082c5..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -# Copyright Jim Bosch & Ankit Daftery 2010-2012. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import ufunc_mod -import unittest -import numpy -from numpy.testing.utils import assert_array_almost_equal - -class TestUnary(unittest.TestCase): - - def testScalar(self): - f = ufunc_mod.UnaryCallable() - assert_array_almost_equal(f(1.0), 2.0) - assert_array_almost_equal(f(3.0), 6.0) - - def testArray(self): - f = ufunc_mod.UnaryCallable() - a = numpy.arange(5, dtype=float) - b = f(a) - assert_array_almost_equal(b, a*2.0) - c = numpy.zeros(5, dtype=float) - d = f(a,output=c) - self.assert_(c is d) - assert_array_almost_equal(d, a*2.0) - - def testList(self): - f = ufunc_mod.UnaryCallable() - a = range(5) - b = f(a) - assert_array_almost_equal(b/2.0, a) - -class TestBinary(unittest.TestCase): - - def testScalar(self): - f = ufunc_mod.BinaryCallable() - assert_array_almost_equal(f(1.0, 3.0), 11.0) - assert_array_almost_equal(f(3.0, 2.0), 12.0) - - def testArray(self): - f = ufunc_mod.BinaryCallable() - a = numpy.random.randn(5) - b = numpy.random.randn(5) - assert_array_almost_equal(f(a,b), (a*2+b*3)) - c = numpy.zeros(5, dtype=float) - d = f(a,b,output=c) - self.assert_(c is d) - assert_array_almost_equal(d, a*2 + b*3) - assert_array_almost_equal(f(a, 2.0), a*2 + 6.0) - assert_array_almost_equal(f(1.0, b), 2.0 + b*3) - - -if __name__=="__main__": - unittest.main() diff --git a/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc_mod.cpp b/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc_mod.cpp deleted file mode 100644 index cfad10888..000000000 --- a/src/3rdparty/Boost.NumPy/libs/numpy/test/ufunc_mod.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Jim Bosch & Ankit Daftery 2010-2012. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -namespace p = boost::python; -namespace np = boost::numpy; - -struct UnaryCallable -{ - typedef double argument_type; - typedef double result_type; - - double operator()(double r) const { return r * 2;} -}; - -struct BinaryCallable -{ - typedef double first_argument_type; - typedef double second_argument_type; - typedef double result_type; - - double operator()(double a, double b) const { return a * 2 + b * 3;} -}; - -BOOST_PYTHON_MODULE(ufunc_mod) -{ - np::initialize(); - p::class_("UnaryCallable") - .def("__call__", np::unary_ufunc::make()); - p::class_< BinaryCallable>("BinaryCallable") - .def("__call__", np::binary_ufunc::make()); -} diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt deleted file mode 100644 index dbc520659..000000000 --- a/src/3rdparty/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -if (GCC) - set(CMAKE_C_COMPILER "gcc") - set(CMAKE_CXX_COMPILER "g++") -endif() - -set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") - -# http://cmake.3232098.n2.nabble.com/Default-value-for-CMAKE-BUILD-TYPE-td7550756.html -if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Output directory for static libraries.") - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Output directory for shared libraries.") - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Output directory for executables and DLL's.") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -find_package(Boost COMPONENTS python REQUIRED) -find_package(PythonLibs 2.7 REQUIRED) -find_package(Numpy) - -include(${CMAKE_SOURCE_DIR}/cmake/boost-python.cmake) - -add_subdirectory(Boost.NumPy) -add_subdirectory(mjcpy2) diff --git a/src/3rdparty/cmake/FindNumpy.cmake b/src/3rdparty/cmake/FindNumpy.cmake deleted file mode 100644 index d96a35c0b..000000000 --- a/src/3rdparty/cmake/FindNumpy.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# -# $Id: $ -# -# Author(s): Anton Deguet -# Created on: 2010-01-20 -# -# (C) Copyright 2010 Johns Hopkins University (JHU), All Rights -# Reserved. -# -# --- begin cisst license - do not edit --- -# -# This software is provided "as is" under an open source license, with -# no warranty. The complete license can be found in license.txt and -# http://www.cisst.org/cisst/license.txt. -# -# --- end cisst license --- -# -# File based on FindNUMARRAY distributed with ITK 3.4 (see itk.org) -# -# Main modifications: -# - use Numpy instead of Numarray for all naming -# - added path for Python 2.5 and 2.6 -# - renamed python script generated (det_npp became determineNumpyPath) -# - use lower case for CMake commands and keywords -# - updated python script to use get_include, not get_numpy_include which is now deprecated -# -# --- -# -# Try to find numpy python package -# Once done this will define -# -# PYTHON_NUMPY_FOUND - system has numpy development package and it should be used -# PYTHON_NUMPY_INCLUDE_DIR - directory where the arrayobject.h header file can be found -# -# - -if (PYTHON_NUMPY_INCLUDE_DIR) - return() -endif() - -set(PYTHON_EXECUTABLE "python") -if(PYTHON_EXECUTABLE) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py "try: import numpy; print numpy.get_include()\nexcept: pass\n") - exec_program("${PYTHON_EXECUTABLE}" - ARGS "\"${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py\"" - OUTPUT_VARIABLE NUMPY_PATH - ) -endif(PYTHON_EXECUTABLE) - -find_path(_PYTHON_NUMPY_INCLUDE_DIR arrayobject.h - "${NUMPY_PATH}/numpy/" - "${PYTHON_INCLUDE_PATH}/numpy/" - "~/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy" - /usr/include/python2.6/numpy/ - /usr/include/python2.5/numpy/ - /usr/include/python2.4/numpy/ - /usr/include/python2.3/numpy/ - DOC "Directory where the arrayobject.h header file can be found. This file is part of the numpy package" - ) - -if(_PYTHON_NUMPY_INCLUDE_DIR) - set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy development package is available") - get_filename_component(PYTHON_NUMPY_INCLUDE_DIR ${_PYTHON_NUMPY_INCLUDE_DIR} PATH) -endif(_PYTHON_NUMPY_INCLUDE_DIR) diff --git a/src/3rdparty/cmake/boost-python.cmake b/src/3rdparty/cmake/boost-python.cmake deleted file mode 100644 index 8ba2b7bf8..000000000 --- a/src/3rdparty/cmake/boost-python.cmake +++ /dev/null @@ -1,31 +0,0 @@ -function(boost_python_module NAME) - - set(DEP_LIBS - ${Boost_PYTHON_LIBRARY} - ${PYTHON_LIBRARIES} - ) - #these are required includes for every ecto module - include_directories( - ${PYTHON_INCLUDE_PATH} - ${Boost_INCLUDE_DIRS} - ) - add_library(${NAME} SHARED - ${ARGN} - ) - set_target_properties(${NAME} - PROPERTIES - OUTPUT_NAME ${NAME} - COMPILE_FLAGS "${FASTIDIOUS_FLAGS}" - LINK_FLAGS -dynamic - PREFIX "" - ) - if( WIN32 ) - set_target_properties(${NAME} PROPERTIES SUFFIX ".pyd") - elseif( APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # on mac osx, python cannot import libraries with .dylib extension - set_target_properties(${NAME} PROPERTIES SUFFIX ".so") - endif() - target_link_libraries(${NAME} - ${DEP_LIBS} - ) -endfunction() diff --git a/src/3rdparty/macros.h b/src/3rdparty/macros.h deleted file mode 100644 index 968a742fd..000000000 --- a/src/3rdparty/macros.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once -#include -#include -#include -#include -/* -// Generic helper definitions for shared library support -#if defined _WIN32 || defined __CYGWIN__ - #define TRAJOPT_HELPER_DLL_IMPORT __declspec(dllimport) - #define TRAJOPT_HELPER_DLL_EXPORT __declspec(dllexport) - #define TRAJOPT_HELPER_DLL_LOCAL -#else - #if __GNUC__ >= 4 - #define TRAJOPT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default"))) - #define TRAJOPT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default"))) - #define TRAJOPT_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden"))) - #else - #define TRAJOPT_HELPER_DLL_IMPORT - #define TRAJOPT_HELPER_DLL_EXPORT - #define TRAJOPT_HELPER_DLL_LOCAL - #endif -#endif - -// Now we use the generic helper definitions above to define TRAJOPT_API and TRAJOPT_LOCAL. -// TRAJOPT_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build) -// TRAJOPT_LOCAL is used for non-api symbols. - -#define TRAJOPT_DLL - -#ifdef TRAJOPT_DLL // defined if TRAJOPT is compiled as a DLL - #ifdef TRAJOPT_DLL_EXPORTS // defined if we are building the TRAJOPT DLL (instead of using it) - #define TRAJOPT_API TRAJOPT_HELPER_DLL_EXPORT - #else - #define TRAJOPT_API TRAJOPT_HELPER_DLL_IMPORT - #endif // TRAJOPT_DLL_EXPORTS - #define TRAJOPT_LOCAL TRAJOPT_HELPER_DLL_LOCAL -#else // TRAJOPT_DLL is not defined: this means TRAJOPT is a static lib. - #define TRAJOPT_API - #define TRAJOPT_LOCAL -#endif // TRAJOPT_DLL -*/ - - - - -#define PRINT_AND_THROW(s) do {\ - std::cerr << "\033[1;31mERROR " << s << "\033[0m\n";\ - std::cerr << "at " << __FILE__ << ":" << __LINE__ << std::endl;\ - std::stringstream ss;\ - ss << s;\ - throw std::runtime_error(ss.str());\ -} while (0) -#define FAIL_IF_FALSE(expr) if (!(expr)) {\ - PRINT_AND_THROW( "expected true: " #expr);\ - } -#define NOTIMPLEMENTED PRINT_AND_THROW("NOT IMPLEMENTED ERROR") - -#ifdef __CDT_PARSER__ -#define BOOST_FOREACH(a,b) for(a;;) -#endif - -#define ALWAYS_ASSERT(exp) if (!(exp)) {printf("%s failed in file %s at line %i\n", #exp, __FILE__, __LINE__ ); abort();} diff --git a/src/3rdparty/mjcpy2/CMakeLists.txt b/src/3rdparty/mjcpy2/CMakeLists.txt deleted file mode 100644 index 557bdb9d5..000000000 --- a/src/3rdparty/mjcpy2/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}") -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/Boost.NumPy") - -include_directories(SYSTEM - "${CMAKE_SOURCE_DIR}/mjpro" -) -# boost_python_module(mjcpy2 mjcpy2.cpp mjosgviewer.cpp) -# target_link_libraries(mjcpy mjc boost_numpy) - -add_definitions("-DmjUSEDOUBLE") - - -# if (APPLE) -if(APPLE) - include_directories(SYSTEM - "/Users/xyz/Src/osg/include" - "/Users/xyz/build/osg/include" - ) - link_directories("/Users/xyz/build/osg/lib") - set(OSG_LIBRARIES - osg - osgViewer - OpenThreads - osgGA - osgUtil - osgText - osgDB - ) -else() - find_package( osg ) - find_package( osgViewer ) - find_package( OpenThreads ) - find_package(osgGA) - # link_directories(${OSG}) - set(OSG_LIBRARIES ${OSG_LIBRARY} ${OSGVIEWER_LIBRARY} ${OPENTHREADS_LIBRARY} ${OSGGA_LIBRARY} ) -endif() - - -include_directories(SYSTEM ${OSG_INCLUDE_DIR}) -include_directories("../mjpro/include") -message("osg includes: ${OSG_INCLUDE_DIR}") -# add_definitions("-DOPENTHREADS_ATOMIC_USE_MUTEX") -# add_executable(test_mujoco_osg test_mujoco_osg.cpp mujoco_osg_viewer.cpp) -# target_link_libraries(test_mujoco_osg mujoco ${OSG_LIBRARIES} stdc++ pthread) - - -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}") -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/Boost.NumPy") -boost_python_module(mjcpy mjcpy2.cpp mujoco_osg_viewer.cpp) -if (MJC_OLD) # version of mujoco older than 1.31 -target_link_libraries(mjcpy "${CMAKE_SOURCE_DIR}/mjpro/libmujoco.so" ${OSG_LIBRARIES} boost_numpy) -else() -target_link_libraries(mjcpy "${CMAKE_SOURCE_DIR}/mjpro/bin/libmujoco131.so" ${OSG_LIBRARIES} boost_numpy) -endif() diff --git a/src/3rdparty/mjcpy2/mj_struct_codegen.py b/src/3rdparty/mjcpy2/mj_struct_codegen.py deleted file mode 100644 index 503831c14..000000000 --- a/src/3rdparty/mjcpy2/mj_struct_codegen.py +++ /dev/null @@ -1,98 +0,0 @@ -import re -import os.path as osp - -# fname = "../mjpro/mjmodel.h" -fname = "../mjpro/mjdata.h" -with open(fname,"r") as fh: - all_lines = fh.readlines() - -def find_lines_between(lines, start_substring, end_substring): - it = iter(lines) - for line in it: - if start_substring in line: - break - outlines = [] - for line in it: - if end_substring in line: break - else: outlines.append(line) - return outlines - - - -scalar_re = re.compile("\s+(\w+)\s+(\w+);") -arrsize=".+\(([\w\+\*]+) x (\w+)\)" -ptr_re = re.compile("\s+(\w+)\*\s+(\w+);"+arrsize) -arr_re = re.compile("\s+(\w+)\s(\w+)\[(\w+)\];") - -def isint(s): - try: - int(s) - return True - except ValueError: - return False -def isvalidsize(s): - return (s in int_names) or isint(s) -def ismacro(s): - return s.lower() != s and s != "nM" -def add_model_to_fields(s): - md = re.match("^\w+$",s) - if md: - if "*" in s: asdf - if ismacro(s) or isint(s): - return s - else: - return "m_model->%s"%s - if s == "nlmax+ncmax": - return "m_model->nlmax+m_model->ncmax" - elif s == "nwrap*2": - return "m_model->nwrap*2" - else: - raise Exception - - - -def process(in_lines,structname): - get_lines = [] - set_lines = [] - - for line in in_lines: - md = scalar_re.match(line) - if md: - dtype,name = md.group(1),md.group(2) - get_lines.append(' out["%(name)s"] = %(structname)s->%(name)s;'%dict(structname=structname,dtype=dtype,name=name)) - set_lines.append(' _csdihk(d, "%(name)s", %(structname)s->%(name)s);'%dict(structname=structname,name=name)) - continue - md = ptr_re.match(line) - if md: - dtype,name,size0,size1 = md.group(1),md.group(2),md.group(3),md.group(4) - if dtype == "mjContact": - print "skipping due to dtype",line - continue - size0 = add_model_to_fields(size0) - size1 = add_model_to_fields(size1) - get_lines.append(' out["%(name)s"] = toNdarray2<%(dtype)s>(%(structname)s->%(name)s, %(size0)s, %(size1)s);'%dict(structname=structname,name=name,dtype=dtype,size0=size0,size1=size1)) - set_lines.append(' _cadihk(d, "%(name)s", %(structname)s->%(name)s);'%dict(structname=structname,name=name)) - continue - md = arr_re.match(line) - if md: - dtype,name,size = md.group(1),md.group(2),md.group(3) - get_lines.append(' out["%(name)s"] = toNdarray1<%(dtype)s>(%(structname)s->%(name)s, %(size)s);'%dict(structname=structname,name=name,dtype=dtype,size=size)) - set_lines.append(' _cadihk(d, "%(name)s", %(structname)s->%(name)s);'%dict(structname=structname,name=name)) - continue - print "ignore line:",line, - return get_lines,set_lines - - - -# with open("mjcpy2_getmodel_autogen.i","w") as outfile: -# get_lines, set_lines = process(find_lines_between(all_lines, "_mjModel","}"),"m_model") -# outfile.write("\n".join(get_lines)) -# with open("mjcpy2_setmodel_autogen.i","w") as outfile: -# get_lines, set_lines = process(find_lines_between(all_lines, "_mjModel","}"),"m_model") -# outfile.write("\n".join(set_lines)) -with open("mjcpy2_getdata_autogen.i","w") as outfile: - get_lines, set_lines = process(find_lines_between(all_lines, "_mjData","}"),"m_data") - outfile.write("\n".join(get_lines)) -with open("mjcpy2_setdata_autogen.i","w") as outfile: - get_lines, set_lines = process(find_lines_between(all_lines, "_mjData","}"),"m_data") - outfile.write("\n".join(set_lines)) diff --git a/src/3rdparty/mjcpy2/mjcpy2.cpp b/src/3rdparty/mjcpy2/mjcpy2.cpp deleted file mode 100755 index ef1cf69f9..000000000 --- a/src/3rdparty/mjcpy2/mjcpy2.cpp +++ /dev/null @@ -1,373 +0,0 @@ -#include -#include -#include "macros.h" -#include -#include -#include "mujoco_osg_viewer.hpp" - -namespace bp = boost::python; -namespace bn = boost::numpy; - - - - -namespace { - -bp::object main_namespace; - -template -bn::ndarray toNdarray1(const T* data, long dim0) { - long dims[1] = {dim0}; - bn::ndarray out = bn::empty(1, dims, bn::dtype::get_builtin()); - memcpy(out.get_data(), data, dim0*sizeof(T)); - return out; -} -template -bn::ndarray toNdarray2(const T* data, long dim0, long dim1) { - long dims[2] = {dim0,dim1}; - bn::ndarray out = bn::empty(2, dims, bn::dtype::get_builtin()); - memcpy(out.get_data(), data, dim0*dim1*sizeof(T)); - return out; -} -template -bn::ndarray toNdarray3(const T* data, long dim0, long dim1, long dim2) { - long dims[3] = {dim0,dim1,dim2}; - bn::ndarray out = bn::empty(3, dims, bn::dtype::get_builtin()); - memcpy(out.get_data(), data, dim0*dim1*dim2*sizeof(T)); - return out; -} - - -bool endswith(const std::string& fullString, const std::string& ending) -{ - return (fullString.length() >= ending.length()) && - (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending)); -} - - - - -class PyMJCWorld2 { - - -public: - - PyMJCWorld2(const std::string& loadfile); - bp::object Step(const bn::ndarray& x, const bn::ndarray& u); - void Plot(const bn::ndarray& x); - void InitCam(float cx,float cy,float cz,float px,float py,float pz); - void InitViewer(int width, int height, float cx,float cy,float cz,float px,float py,float pz); - void Idle(const bn::ndarray& x); - bn::ndarray GetCOMMulti(const bn::ndarray& x); - bn::ndarray GetJacSite(int site); - void Kinematics(); - bp::dict GetModel(); - void SetModel(bp::dict d); - bp::dict GetData(); - void SetData(bp::dict d); - bp::dict GetImage(); - bp::dict GetImageScaled(int width, int height); - void SetNumSteps(int n) {m_numSteps=n;} - void SetCamera(float x, float y, float z, float px, float py, float pz); - - ~PyMJCWorld2(); -private: - - void _PlotInit(); - void _PlotInit(float x, float y, float z, float px, float py, float pz); - void _PlotInit(int width, int height, float x, float y, float z, float px, float py, float pz); - - mjModel* m_model; - mjData* m_data; - MujocoOSGViewer* m_viewer; - int m_numSteps; - int m_featmask; - -}; - -PyMJCWorld2::PyMJCWorld2(const std::string& loadfile) { - mj_activate("src/3rdparty/mjpro/mjkey.txt"); - if (endswith(loadfile, "xml")) { - NewModelFromXML(loadfile.c_str(), m_model); - } - else { - NOTIMPLEMENTED; - } - if (!m_model) PRINT_AND_THROW("couldn't load model: " + std::string(loadfile)); - m_data = mj_makeData(m_model); - FAIL_IF_FALSE(!!m_data); - m_viewer = NULL; - m_numSteps = 1; - m_featmask = 0; -} - - -PyMJCWorld2::~PyMJCWorld2() { - if (m_viewer) { - delete m_viewer; - } - mj_deleteData(m_data); - mj_deleteModel(m_model); -} - - -int StateSize(mjModel* m) { - return m->nq + m->nv; -} -void GetState(mjtNum* ptr, const mjModel* m, const mjData* d) { - mju_copy(ptr, d->qpos, m->nq); - ptr += m->nq; - mju_copy(ptr, d->qvel, m->nv); -} -void SetState(const mjtNum* ptr, const mjModel* m, mjData* d) { - mju_copy(d->qpos, ptr, m->nq); - ptr += m->nq; - mju_copy(d->qvel, ptr, m->nv); -} -inline void SetCtrl(const mjtNum* ptr, const mjModel* m, mjData* d) { - mju_copy(d->ctrl, ptr, m->nu); -} - -#define MJTNUM_DTYPE bn::dtype::get_builtin() - -bp::object PyMJCWorld2::Step(const bn::ndarray& x, const bn::ndarray& u) { - FAIL_IF_FALSE(x.get_dtype() == MJTNUM_DTYPE && x.get_nd() == 1 && x.get_flags() & bn::ndarray::C_CONTIGUOUS && x.shape(0) == m_model->nq+m_model->nv); - FAIL_IF_FALSE(u.get_dtype() == MJTNUM_DTYPE && u.get_nd() == 1 && u.get_flags() & bn::ndarray::C_CONTIGUOUS && u.shape(0) == m_model->nu); - - SetState(reinterpret_cast(x.get_data()), m_model, m_data); - - mj_step1(m_model,m_data); - SetCtrl(reinterpret_cast(u.get_data()), m_model, m_data); - mj_step2(m_model,m_data); - - long xdims[1] = {StateSize(m_model)}; - long site_dims[2] = {m_model->nsite, 3}; - bn::ndarray xout = bn::empty(1, xdims, bn::dtype::get_builtin()); - bn::ndarray site_out = bn::empty(2, site_dims, bn::dtype::get_builtin()); - - GetState((mjtNum*)xout.get_data(), m_model, m_data); - mju_copy((mjtNum*)site_out.get_data(), m_data->site_xpos, 3*m_model->nsite); - - return bp::make_tuple(xout, site_out); -} - - -void GetCOM(const mjModel* m, const mjData* d, mjtNum* com) { - // see mj_com in engine_core.c - mjtNum tot=0; - com[0] = com[1] = com[2] = 0; - for(int i=1; inbody; i++ ) { - com[0] += d->xipos[3*i+0]*m->body_mass[i]; - com[1] += d->xipos[3*i+1]*m->body_mass[i]; - com[2] += d->xipos[3*i+2]*m->body_mass[i]; - tot += m->body_mass[i]; - } - // compute com - com[0] /= tot; - com[1] /= tot; - com[2] /= tot; -} - -bn::ndarray PyMJCWorld2::GetCOMMulti(const bn::ndarray& x) { - int state_size = StateSize(m_model); - FAIL_IF_FALSE(x.get_dtype() == MJTNUM_DTYPE && x.get_nd() == 2 && x.get_flags() & bn::ndarray::C_CONTIGUOUS && x.shape(1) == state_size); - int N = x.shape(0); - long outdims[2] = {N,3}; - bn::ndarray out = bn::empty(2, outdims, bn::dtype::get_builtin()); - mjtNum* ptr = (mjtNum*)out.get_data(); - for (int n=0; n < N; ++n) { - SetState(reinterpret_cast(x.get_data()), m_model, m_data); - mj_kinematics(m_model, m_data); - GetCOM(m_model, m_data, ptr); - ptr += 3; - } - return out; -} - -bn::ndarray PyMJCWorld2::GetJacSite(int site) { - bn::ndarray out = bn::zeros(bp::make_tuple(3,m_model->nv), bn::dtype::get_builtin()); - mjtNum* ptr = (mjtNum*)out.get_data(); - mj_jacSite(m_model, m_data, ptr, 0, site); - return out; -} - -void PyMJCWorld2::Kinematics() { - mj_kinematics(m_model, m_data); - mj_comPos(m_model, m_data); - mj_tendon(m_model, m_data); - mj_transmission(m_model, m_data); -} - -void PyMJCWorld2::_PlotInit() { - if (m_viewer == NULL) { - m_viewer = new MujocoOSGViewer(); - m_viewer->SetModel(m_model); - } -} - -void PyMJCWorld2::_PlotInit(float x, float y, float z, float px, float py, float pz) { - if (m_viewer == NULL) { - m_viewer = new MujocoOSGViewer(osg::Vec3(x, y, z),osg::Vec3(px, py, pz)); - m_viewer->SetModel(m_model); - } -} - -void PyMJCWorld2::_PlotInit(int width, int height, float x, float y, float z, float px, float py, float pz) { - if (m_viewer == NULL) { - m_viewer = new MujocoOSGViewer(width, height, osg::Vec3(x, y, z),osg::Vec3(px, py, pz)); - m_viewer->SetModel(m_model); - } -} - -void PyMJCWorld2::Plot(const bn::ndarray& x) { - FAIL_IF_FALSE(x.get_dtype() == MJTNUM_DTYPE && x.get_nd() == 1 && x.get_flags() & bn::ndarray::C_CONTIGUOUS); - _PlotInit(); - SetState(reinterpret_cast(x.get_data()),m_model,m_data); - m_viewer->SetData(m_data); - m_viewer->RenderOnce(); -} - -void PyMJCWorld2::InitCam(float cx, float cy, float cz, float px, float py, float pz) { - _PlotInit(cx, cy, cz, px, py, pz); -} - -void PyMJCWorld2::InitViewer(int width, int height, float cx, float cy, float cz, float px, float py, float pz) { - _PlotInit(width, height, cx, cy, cz, px, py, pz); -} - -void PyMJCWorld2::Idle(const bn::ndarray& x) { - FAIL_IF_FALSE(x.get_dtype() == MJTNUM_DTYPE && x.get_nd() == 1 && x.get_flags() & bn::ndarray::C_CONTIGUOUS); - _PlotInit(); - SetState(reinterpret_cast(x.get_data()),m_model,m_data); - m_viewer->SetData(m_data); - m_viewer->Idle(); -} - - -int _ndarraysize(const bn::ndarray& arr) { - int prod = 1; - for (int i=0; i < arr.get_nd(); ++i) { - prod *= arr.shape(i); - } - return prod; -} -template -void _copyscalardata(const bp::object& from, T& to) { - to = bp::extract(from); -} -template -void _copyarraydata(const bn::ndarray& from, T* to) { - FAIL_IF_FALSE(from.get_dtype() == bn::dtype::get_builtin() && from.get_flags() & bn::ndarray::C_CONTIGUOUS); - memcpy(to, from.get_data(), _ndarraysize(from)*sizeof(T)); -} -template -void _csdihk(bp::dict d, const char* key, T& to) { - // copy scalar data if has_key - if (d.has_key(key)) _copyscalardata(d[key], to); -} -template -void _cadihk(bp::dict d, const char* key, T* to) { - // copy array data if has_key - if (d.has_key(key)) { - bn::ndarray arr = bp::extract(d[key]); - _copyarraydata(arr, to); - } -} - -bp::dict PyMJCWorld2::GetModel() { - bp::dict out; - #include "mjcpy2_getmodel_autogen.i" - return out; -} -void PyMJCWorld2::SetModel(bp::dict d) { - #include "mjcpy2_setmodel_autogen.i" -} -bp::dict PyMJCWorld2::GetData() { - bp::dict out; - #include "mjcpy2_getdata_autogen.i" - - return out; -} -void PyMJCWorld2::SetData(bp::dict d) { - #include "mjcpy2_setdata_autogen.i" -} - - -} - -// grabs current image, returns an array of shape [height, width, channels] -bp::dict PyMJCWorld2::GetImage() { - m_viewer->RenderOnce(); - bp::dict out; - const unsigned char* tmp = static_cast(m_viewer->m_image->getDataPointer()); - out["num_pixels"] = m_viewer->m_image->getTotalDataSize(); - out["width"] = m_viewer->m_image->s(); - out["height"] = m_viewer->m_image->t(); - int num_channels = 0; - if (m_viewer->m_image->getTotalDataSize() > 0) - { - num_channels = m_viewer->m_image->getTotalDataSize() / m_viewer->m_image->s() / m_viewer->m_image->t(); - } - out["img"] = toNdarray3(tmp, m_viewer->m_image->t(), m_viewer->m_image->s(), num_channels); - out["num_channels"] = num_channels; - return out; -} - -// grabs current image, returns an array of shape [height, width, channels] -bp::dict PyMJCWorld2::GetImageScaled(int width, int height) { - m_viewer->RenderOnce(); - m_viewer->m_image->scaleImage(width,height,m_viewer->m_image->r()); - bp::dict out; - const unsigned char* tmp = static_cast(m_viewer->m_image->getDataPointer()); - out["num_pixels"] = m_viewer->m_image->getTotalDataSize(); - out["width"] = m_viewer->m_image->s(); - out["height"] = m_viewer->m_image->t(); - int num_channels = 0; - if (m_viewer->m_image->getTotalDataSize() > 0) - { - num_channels = m_viewer->m_image->getTotalDataSize() / m_viewer->m_image->s() / m_viewer->m_image->t(); - } - out["img"] = toNdarray3(tmp, m_viewer->m_image->t(), m_viewer->m_image->s(), num_channels); - out["num_channels"] = num_channels; - return out; -} - -void PyMJCWorld2::SetCamera(float x, float y, float z, float px, float py, float pz){ - // place camera at (x,y,z) pointing to (px,py,pz) - m_viewer->SetCamera(x,y,z,px,py,pz); -} - -BOOST_PYTHON_MODULE(mjcpy) { - bn::initialize(); - - bp::class_("MJCWorld","docstring here", bp::init()) - - .def("step",&PyMJCWorld2::Step) - .def("get_model",&PyMJCWorld2::GetModel) - .def("set_model",&PyMJCWorld2::SetModel) - .def("get_data",&PyMJCWorld2::GetData) - .def("set_data",&PyMJCWorld2::SetData) - .def("plot",&PyMJCWorld2::Plot) - .def("init_cam",&PyMJCWorld2::InitCam) - .def("init_viewer",&PyMJCWorld2::InitViewer) - .def("idle",&PyMJCWorld2::Idle) - .def("get_COM_multi",&PyMJCWorld2::GetCOMMulti) - .def("get_jac_site",&PyMJCWorld2::GetJacSite) - .def("kinematics",&PyMJCWorld2::Kinematics) - .def("get_image",&PyMJCWorld2::GetImage) - .def("get_image_scaled",&PyMJCWorld2::GetImageScaled) - .def("set_num_steps",&PyMJCWorld2::SetNumSteps) - .def("set_camera",&PyMJCWorld2::SetCamera) - ; - - - bp::object main = bp::import("__main__"); - main_namespace = main.attr("__dict__"); - bp::exec( - "import numpy as np\n" - "contact_dtype = np.dtype([('dim','i'), ('geom1','i'), ('geom2','i'),('flc_address','i'),('compliance','f8'),('timeconst','f8'),('dist','f8'),('mindist','f8'),('pos','f8',3),('frame','f8',9),('friction','f8',5)])\n" - , main_namespace - ); - - -} diff --git a/src/3rdparty/mjcpy2/mjcpy2_getdata_autogen.i b/src/3rdparty/mjcpy2/mjcpy2_getdata_autogen.i deleted file mode 100644 index db1e454f9..000000000 --- a/src/3rdparty/mjcpy2/mjcpy2_getdata_autogen.i +++ /dev/null @@ -1,99 +0,0 @@ - out["nstack"] = m_data->nstack; - out["nbuffer"] = m_data->nbuffer; - out["pstack"] = m_data->pstack; - out["maxstackuse"] = m_data->maxstackuse; - out["ne"] = m_data->ne; - out["nf"] = m_data->nf; - out["nefc"] = m_data->nefc; - out["ncon"] = m_data->ncon; - out["nwarning"] = toNdarray1(m_data->nwarning, mjNWARNING); - out["timer_duration"] = toNdarray1(m_data->timer_duration, mjNTIMER); - out["timer_ncall"] = toNdarray1(m_data->timer_ncall, mjNTIMER); - out["mocaptime"] = toNdarray1(m_data->mocaptime, 3); - out["time"] = m_data->time; - out["energy"] = toNdarray1(m_data->energy, 2); - out["solverstat"] = toNdarray1(m_data->solverstat, 4); - out["qpos"] = toNdarray2(m_data->qpos, m_model->nq, 1); - out["qvel"] = toNdarray2(m_data->qvel, m_model->nv, 1); - out["act"] = toNdarray2(m_data->act, m_model->na, 1); - out["ctrl"] = toNdarray2(m_data->ctrl, m_model->nu, 1); - out["qfrc_applied"] = toNdarray2(m_data->qfrc_applied, m_model->nv, 1); - out["xfrc_applied"] = toNdarray2(m_data->xfrc_applied, m_model->nbody, 6); - out["qacc"] = toNdarray2(m_data->qacc, m_model->nv, 1); - out["act_dot"] = toNdarray2(m_data->act_dot, m_model->na, 1); - out["mocap_pos"] = toNdarray2(m_data->mocap_pos, m_model->nmocap, 3); - out["mocap_quat"] = toNdarray2(m_data->mocap_quat, m_model->nmocap, 4); - out["userdata"] = toNdarray2(m_data->userdata, m_model->nuserdata, 1); - out["sensordata"] = toNdarray2(m_data->sensordata, m_model->nsensordata, 1); - out["xpos"] = toNdarray2(m_data->xpos, m_model->nbody, 3); - out["xquat"] = toNdarray2(m_data->xquat, m_model->nbody, 4); - out["xmat"] = toNdarray2(m_data->xmat, m_model->nbody, 9); - out["xipos"] = toNdarray2(m_data->xipos, m_model->nbody, 3); - out["ximat"] = toNdarray2(m_data->ximat, m_model->nbody, 9); - out["xanchor"] = toNdarray2(m_data->xanchor, m_model->njnt, 3); - out["xaxis"] = toNdarray2(m_data->xaxis, m_model->njnt, 3); - out["geom_xpos"] = toNdarray2(m_data->geom_xpos, m_model->ngeom, 3); - out["geom_xmat"] = toNdarray2(m_data->geom_xmat, m_model->ngeom, 9); - out["site_xpos"] = toNdarray2(m_data->site_xpos, m_model->nsite, 3); - out["site_xmat"] = toNdarray2(m_data->site_xmat, m_model->nsite, 9); - out["cam_xpos"] = toNdarray2(m_data->cam_xpos, m_model->ncam, 3); - out["cam_xmat"] = toNdarray2(m_data->cam_xmat, m_model->ncam, 9); - out["light_xpos"] = toNdarray2(m_data->light_xpos, m_model->nlight, 3); - out["light_xdir"] = toNdarray2(m_data->light_xdir, m_model->nlight, 3); - out["com_subtree"] = toNdarray2(m_data->com_subtree, m_model->nbody, 3); - out["cdof"] = toNdarray2(m_data->cdof, m_model->nv, 6); - out["cinert"] = toNdarray2(m_data->cinert, m_model->nbody, 10); - out["ten_wrapadr"] = toNdarray2(m_data->ten_wrapadr, m_model->ntendon, 1); - out["ten_wrapnum"] = toNdarray2(m_data->ten_wrapnum, m_model->ntendon, 1); - out["ten_length"] = toNdarray2(m_data->ten_length, m_model->ntendon, 1); - out["ten_moment"] = toNdarray2(m_data->ten_moment, m_model->ntendon, m_model->nv); - out["wrap_obj"] = toNdarray2(m_data->wrap_obj, m_model->nwrap*2, 1); - out["wrap_xpos"] = toNdarray2(m_data->wrap_xpos, m_model->nwrap*2, 3); - out["actuator_length"] = toNdarray2(m_data->actuator_length, m_model->nu, 1); - out["actuator_moment"] = toNdarray2(m_data->actuator_moment, m_model->nu, m_model->nv); - out["crb"] = toNdarray2(m_data->crb, m_model->nbody, 10); - out["qM"] = toNdarray2(m_data->qM, m_model->nM, 1); - out["qLD"] = toNdarray2(m_data->qLD, m_model->nM, 1); - out["qLDiagInv"] = toNdarray2(m_data->qLDiagInv, m_model->nv, 1); - out["qLDiagSqrtInv"] = toNdarray2(m_data->qLDiagSqrtInv, m_model->nv, 1); - out["efc_type"] = toNdarray2(m_data->efc_type, m_model->njmax, 1); - out["efc_id"] = toNdarray2(m_data->efc_id, m_model->njmax, 1); - out["efc_rownnz"] = toNdarray2(m_data->efc_rownnz, m_model->njmax, 1); - out["efc_rowadr"] = toNdarray2(m_data->efc_rowadr, m_model->njmax, 1); - out["efc_colind"] = toNdarray2(m_data->efc_colind, m_model->njmax, m_model->nv); - out["efc_rownnz_T"] = toNdarray2(m_data->efc_rownnz_T, m_model->nv, 1); - out["efc_rowadr_T"] = toNdarray2(m_data->efc_rowadr_T, m_model->nv, 1); - out["efc_colind_T"] = toNdarray2(m_data->efc_colind_T, m_model->nv, m_model->njmax); - out["efc_solref"] = toNdarray2(m_data->efc_solref, m_model->njmax, mjNREF); - out["efc_solimp"] = toNdarray2(m_data->efc_solimp, m_model->njmax, mjNIMP); - out["efc_margin"] = toNdarray2(m_data->efc_margin, m_model->njmax, 1); - out["efc_frictionloss"] = toNdarray2(m_data->efc_frictionloss, m_model->njmax, 1); - out["efc_pos"] = toNdarray2(m_data->efc_pos, m_model->njmax, 1); - out["efc_J"] = toNdarray2(m_data->efc_J, m_model->njmax, m_model->nv); - out["efc_J_T"] = toNdarray2(m_data->efc_J_T, m_model->nv, m_model->njmax); - out["efc_diagApprox"] = toNdarray2(m_data->efc_diagApprox, m_model->njmax, 1); - out["efc_R"] = toNdarray2(m_data->efc_R, m_model->njmax, 1); - out["efc_AR"] = toNdarray2(m_data->efc_AR, m_model->njmax, m_model->njmax); - out["e_ARchol"] = toNdarray2(m_data->e_ARchol, m_model->nemax, m_model->nemax); - out["fc_e_rect"] = toNdarray2(m_data->fc_e_rect, m_model->njmax, m_model->nemax); - out["fc_AR"] = toNdarray2(m_data->fc_AR, m_model->njmax, m_model->njmax); - out["ten_velocity"] = toNdarray2(m_data->ten_velocity, m_model->ntendon, 1); - out["actuator_velocity"] = toNdarray2(m_data->actuator_velocity, m_model->nu, 1); - out["cvel"] = toNdarray2(m_data->cvel, m_model->nbody, 6); - out["cdof_dot"] = toNdarray2(m_data->cdof_dot, m_model->nv, 6); - out["qfrc_bias"] = toNdarray2(m_data->qfrc_bias, m_model->nv, 1); - out["qfrc_passive"] = toNdarray2(m_data->qfrc_passive, m_model->nv, 1); - out["efc_vel"] = toNdarray2(m_data->efc_vel, m_model->njmax, 1); - out["efc_aref"] = toNdarray2(m_data->efc_aref, m_model->njmax, 1); - out["actuator_force"] = toNdarray2(m_data->actuator_force, m_model->nu, 1); - out["qfrc_actuator"] = toNdarray2(m_data->qfrc_actuator, m_model->nv, 1); - out["qfrc_unc"] = toNdarray2(m_data->qfrc_unc, m_model->nv, 1); - out["qacc_unc"] = toNdarray2(m_data->qacc_unc, m_model->nv, 1); - out["efc_b"] = toNdarray2(m_data->efc_b, m_model->njmax, 1); - out["fc_b"] = toNdarray2(m_data->fc_b, m_model->njmax, 1); - out["efc_force"] = toNdarray2(m_data->efc_force, m_model->njmax, 1); - out["qfrc_constraint"] = toNdarray2(m_data->qfrc_constraint, m_model->nv, 1); - out["qfrc_inverse"] = toNdarray2(m_data->qfrc_inverse, m_model->nv, 1); - out["cacc"] = toNdarray2(m_data->cacc, m_model->nbody, 6); - out["cfrc_int"] = toNdarray2(m_data->cfrc_int, m_model->nbody, 6); - out["cfrc_ext"] = toNdarray2(m_data->cfrc_ext, m_model->nbody, 6); diff --git a/src/3rdparty/mjcpy2/mjcpy2_getmodel_autogen.i b/src/3rdparty/mjcpy2/mjcpy2_getmodel_autogen.i deleted file mode 100644 index 396bc7b61..000000000 --- a/src/3rdparty/mjcpy2/mjcpy2_getmodel_autogen.i +++ /dev/null @@ -1,253 +0,0 @@ - out["nq"] = m_model->nq; - out["nv"] = m_model->nv; - out["nu"] = m_model->nu; - out["na"] = m_model->na; - out["nbody"] = m_model->nbody; - out["njnt"] = m_model->njnt; - out["ngeom"] = m_model->ngeom; - out["nsite"] = m_model->nsite; - out["ncam"] = m_model->ncam; - out["nlight"] = m_model->nlight; - out["nmesh"] = m_model->nmesh; - out["nmeshvert"] = m_model->nmeshvert; - out["nmeshface"] = m_model->nmeshface; - out["nmeshgraph"] = m_model->nmeshgraph; - out["nhfield"] = m_model->nhfield; - out["nhfielddata"] = m_model->nhfielddata; - out["ntex"] = m_model->ntex; - out["ntexdata"] = m_model->ntexdata; - out["nmat"] = m_model->nmat; - out["npair"] = m_model->npair; - out["nexclude"] = m_model->nexclude; - out["neq"] = m_model->neq; - out["ntendon"] = m_model->ntendon; - out["nwrap"] = m_model->nwrap; - out["nsensor"] = m_model->nsensor; - out["nnumeric"] = m_model->nnumeric; - out["nnumericdata"] = m_model->nnumericdata; - out["ntext"] = m_model->ntext; - out["ntextdata"] = m_model->ntextdata; - out["nkey"] = m_model->nkey; - out["nuser_body"] = m_model->nuser_body; - out["nuser_jnt"] = m_model->nuser_jnt; - out["nuser_geom"] = m_model->nuser_geom; - out["nuser_site"] = m_model->nuser_site; - out["nuser_tendon"] = m_model->nuser_tendon; - out["nuser_actuator"] = m_model->nuser_actuator; - out["nuser_sensor"] = m_model->nuser_sensor; - out["nnames"] = m_model->nnames; - out["nM"] = m_model->nM; - out["nemax"] = m_model->nemax; - out["njmax"] = m_model->njmax; - out["nconmax"] = m_model->nconmax; - out["nstack"] = m_model->nstack; - out["nuserdata"] = m_model->nuserdata; - out["nmocap"] = m_model->nmocap; - out["nsensordata"] = m_model->nsensordata; - out["nbuffer"] = m_model->nbuffer; - out["qpos0"] = toNdarray2(m_model->qpos0, m_model->nq, 1); - out["qpos_spring"] = toNdarray2(m_model->qpos_spring, m_model->nq, 1); - out["body_parentid"] = toNdarray2(m_model->body_parentid, m_model->nbody, 1); - out["body_rootid"] = toNdarray2(m_model->body_rootid, m_model->nbody, 1); - out["body_weldid"] = toNdarray2(m_model->body_weldid, m_model->nbody, 1); - out["body_mocapid"] = toNdarray2(m_model->body_mocapid, m_model->nbody, 1); - out["body_jntnum"] = toNdarray2(m_model->body_jntnum, m_model->nbody, 1); - out["body_jntadr"] = toNdarray2(m_model->body_jntadr, m_model->nbody, 1); - out["body_dofnum"] = toNdarray2(m_model->body_dofnum, m_model->nbody, 1); - out["body_dofadr"] = toNdarray2(m_model->body_dofadr, m_model->nbody, 1); - out["body_geomnum"] = toNdarray2(m_model->body_geomnum, m_model->nbody, 1); - out["body_geomadr"] = toNdarray2(m_model->body_geomadr, m_model->nbody, 1); - out["body_pos"] = toNdarray2(m_model->body_pos, m_model->nbody, 3); - out["body_quat"] = toNdarray2(m_model->body_quat, m_model->nbody, 4); - out["body_ipos"] = toNdarray2(m_model->body_ipos, m_model->nbody, 3); - out["body_iquat"] = toNdarray2(m_model->body_iquat, m_model->nbody, 4); - out["body_mass"] = toNdarray2(m_model->body_mass, m_model->nbody, 1); - out["body_inertia"] = toNdarray2(m_model->body_inertia, m_model->nbody, 3); - out["body_invweight0"] = toNdarray2(m_model->body_invweight0, m_model->nbody, 2); - out["body_user"] = toNdarray2(m_model->body_user, m_model->nbody, m_model->nuser_body); - out["jnt_type"] = toNdarray2(m_model->jnt_type, m_model->njnt, 1); - out["jnt_qposadr"] = toNdarray2(m_model->jnt_qposadr, m_model->njnt, 1); - out["jnt_dofadr"] = toNdarray2(m_model->jnt_dofadr, m_model->njnt, 1); - out["jnt_bodyid"] = toNdarray2(m_model->jnt_bodyid, m_model->njnt, 1); - out["jnt_limited"] = toNdarray2(m_model->jnt_limited, m_model->njnt, 1); - out["jnt_solref"] = toNdarray2(m_model->jnt_solref, m_model->njnt, mjNREF); - out["jnt_solimp"] = toNdarray2(m_model->jnt_solimp, m_model->njnt, mjNIMP); - out["jnt_pos"] = toNdarray2(m_model->jnt_pos, m_model->njnt, 3); - out["jnt_axis"] = toNdarray2(m_model->jnt_axis, m_model->njnt, 3); - out["jnt_stiffness"] = toNdarray2(m_model->jnt_stiffness, m_model->njnt, 1); - out["jnt_range"] = toNdarray2(m_model->jnt_range, m_model->njnt, 2); - out["jnt_margin"] = toNdarray2(m_model->jnt_margin, m_model->njnt, 1); - out["jnt_user"] = toNdarray2(m_model->jnt_user, m_model->njnt, m_model->nuser_jnt); - out["dof_bodyid"] = toNdarray2(m_model->dof_bodyid, m_model->nv, 1); - out["dof_jntid"] = toNdarray2(m_model->dof_jntid, m_model->nv, 1); - out["dof_parentid"] = toNdarray2(m_model->dof_parentid, m_model->nv, 1); - out["dof_Madr"] = toNdarray2(m_model->dof_Madr, m_model->nv, 1); - out["dof_frictional"] = toNdarray2(m_model->dof_frictional, m_model->nv, 1); - out["dof_solref"] = toNdarray2(m_model->dof_solref, m_model->nv, mjNREF); - out["dof_solimp"] = toNdarray2(m_model->dof_solimp, m_model->nv, mjNIMP); - out["dof_frictionloss"] = toNdarray2(m_model->dof_frictionloss, m_model->nv, 1); - out["dof_armature"] = toNdarray2(m_model->dof_armature, m_model->nv, 1); - out["dof_damping"] = toNdarray2(m_model->dof_damping, m_model->nv, 1); - out["dof_invweight0"] = toNdarray2(m_model->dof_invweight0, m_model->nv, 1); - out["geom_type"] = toNdarray2(m_model->geom_type, m_model->ngeom, 1); - out["geom_contype"] = toNdarray2(m_model->geom_contype, m_model->ngeom, 1); - out["geom_conaffinity"] = toNdarray2(m_model->geom_conaffinity, m_model->ngeom, 1); - out["geom_condim"] = toNdarray2(m_model->geom_condim, m_model->ngeom, 1); - out["geom_bodyid"] = toNdarray2(m_model->geom_bodyid, m_model->ngeom, 1); - out["geom_dataid"] = toNdarray2(m_model->geom_dataid, m_model->ngeom, 1); - out["geom_matid"] = toNdarray2(m_model->geom_matid, m_model->ngeom, 1); - out["geom_group"] = toNdarray2(m_model->geom_group, m_model->ngeom, 1); - out["geom_solmix"] = toNdarray2(m_model->geom_solmix, m_model->ngeom, 1); - out["geom_solref"] = toNdarray2(m_model->geom_solref, m_model->ngeom, mjNREF); - out["geom_solimp"] = toNdarray2(m_model->geom_solimp, m_model->ngeom, mjNIMP); - out["geom_size"] = toNdarray2(m_model->geom_size, m_model->ngeom, 3); - out["geom_rbound"] = toNdarray2(m_model->geom_rbound, m_model->ngeom, 1); - out["geom_pos"] = toNdarray2(m_model->geom_pos, m_model->ngeom, 3); - out["geom_quat"] = toNdarray2(m_model->geom_quat, m_model->ngeom, 4); - out["geom_friction"] = toNdarray2(m_model->geom_friction, m_model->ngeom, 3); - out["geom_margin"] = toNdarray2(m_model->geom_margin, m_model->ngeom, 1); - out["geom_gap"] = toNdarray2(m_model->geom_gap, m_model->ngeom, 1); - out["geom_user"] = toNdarray2(m_model->geom_user, m_model->ngeom, m_model->nuser_geom); - out["geom_rgba"] = toNdarray2(m_model->geom_rgba, m_model->ngeom, 4); - out["site_type"] = toNdarray2(m_model->site_type, m_model->nsite, 1); - out["site_bodyid"] = toNdarray2(m_model->site_bodyid, m_model->nsite, 1); - out["site_matid"] = toNdarray2(m_model->site_matid, m_model->nsite, 1); - out["site_group"] = toNdarray2(m_model->site_group, m_model->nsite, 1); - out["site_size"] = toNdarray2(m_model->site_size, m_model->nsite, 3); - out["site_pos"] = toNdarray2(m_model->site_pos, m_model->nsite, 3); - out["site_quat"] = toNdarray2(m_model->site_quat, m_model->nsite, 4); - out["site_user"] = toNdarray2(m_model->site_user, m_model->nsite, m_model->nuser_site); - out["site_rgba"] = toNdarray2(m_model->site_rgba, m_model->nsite, 4); - out["cam_bodyid"] = toNdarray2(m_model->cam_bodyid, m_model->ncam, 1); - out["cam_pos"] = toNdarray2(m_model->cam_pos, m_model->ncam, 3); - out["cam_quat"] = toNdarray2(m_model->cam_quat, m_model->ncam, 4); - out["cam_fovy"] = toNdarray2(m_model->cam_fovy, m_model->ncam, 1); - out["cam_ipd"] = toNdarray2(m_model->cam_ipd, m_model->ncam, 1); - out["light_bodyid"] = toNdarray2(m_model->light_bodyid, m_model->nlight, 1); - out["light_directional"] = toNdarray2(m_model->light_directional, m_model->nlight, 1); - out["light_castshadow"] = toNdarray2(m_model->light_castshadow, m_model->nlight, 1); - out["light_active"] = toNdarray2(m_model->light_active, m_model->nlight, 1); - out["light_pos"] = toNdarray2(m_model->light_pos, m_model->nlight, 3); - out["light_dir"] = toNdarray2(m_model->light_dir, m_model->nlight, 3); - out["light_attenuation"] = toNdarray2(m_model->light_attenuation, m_model->nlight, 3); - out["light_cutoff"] = toNdarray2(m_model->light_cutoff, m_model->nlight, 1); - out["light_exponent"] = toNdarray2(m_model->light_exponent, m_model->nlight, 1); - out["light_ambient"] = toNdarray2(m_model->light_ambient, m_model->nlight, 3); - out["light_diffuse"] = toNdarray2(m_model->light_diffuse, m_model->nlight, 3); - out["light_specular"] = toNdarray2(m_model->light_specular, m_model->nlight, 3); - out["mesh_faceadr"] = toNdarray2(m_model->mesh_faceadr, m_model->nmesh, 1); - out["mesh_facenum"] = toNdarray2(m_model->mesh_facenum, m_model->nmesh, 1); - out["mesh_vertadr"] = toNdarray2(m_model->mesh_vertadr, m_model->nmesh, 1); - out["mesh_vertnum"] = toNdarray2(m_model->mesh_vertnum, m_model->nmesh, 1); - out["mesh_graphadr"] = toNdarray2(m_model->mesh_graphadr, m_model->nmesh, 1); - out["mesh_vert"] = toNdarray2(m_model->mesh_vert, m_model->nmeshvert, 3); - out["mesh_normal"] = toNdarray2(m_model->mesh_normal, m_model->nmeshvert, 3); - out["mesh_face"] = toNdarray2(m_model->mesh_face, m_model->nmeshface, 3); - out["mesh_graph"] = toNdarray2(m_model->mesh_graph, m_model->nmeshgraph, 1); - out["hfield_size"] = toNdarray2(m_model->hfield_size, m_model->nhfield, 4); - out["hfield_nrow"] = toNdarray2(m_model->hfield_nrow, m_model->nhfield, 1); - out["hfield_ncol"] = toNdarray2(m_model->hfield_ncol, m_model->nhfield, 1); - out["hfield_adr"] = toNdarray2(m_model->hfield_adr, m_model->nhfield, 1); - out["hfield_data"] = toNdarray2(m_model->hfield_data, m_model->nhfielddata, 1); - out["tex_type"] = toNdarray2(m_model->tex_type, m_model->ntex, 1); - out["tex_height"] = toNdarray2(m_model->tex_height, m_model->ntex, 1); - out["tex_width"] = toNdarray2(m_model->tex_width, m_model->ntex, 1); - out["tex_adr"] = toNdarray2(m_model->tex_adr, m_model->ntex, 1); - out["tex_rgb"] = toNdarray2(m_model->tex_rgb, m_model->ntexdata, 1); - out["mat_texid"] = toNdarray2(m_model->mat_texid, m_model->nmat, 1); - out["mat_texuniform"] = toNdarray2(m_model->mat_texuniform, m_model->nmat, 1); - out["mat_emission"] = toNdarray2(m_model->mat_emission, m_model->nmat, 1); - out["mat_specular"] = toNdarray2(m_model->mat_specular, m_model->nmat, 1); - out["mat_shininess"] = toNdarray2(m_model->mat_shininess, m_model->nmat, 1); - out["mat_reflectance"] = toNdarray2(m_model->mat_reflectance, m_model->nmat, 1); - out["mat_rgba"] = toNdarray2(m_model->mat_rgba, m_model->nmat, 4); - out["pair_dim"] = toNdarray2(m_model->pair_dim, m_model->npair, 1); - out["pair_geom1"] = toNdarray2(m_model->pair_geom1, m_model->npair, 1); - out["pair_geom2"] = toNdarray2(m_model->pair_geom2, m_model->npair, 1); - out["pair_signature"] = toNdarray2(m_model->pair_signature, m_model->npair, 1); - out["pair_solref"] = toNdarray2(m_model->pair_solref, m_model->npair, mjNREF); - out["pair_solimp"] = toNdarray2(m_model->pair_solimp, m_model->npair, mjNIMP); - out["pair_margin"] = toNdarray2(m_model->pair_margin, m_model->npair, 1); - out["pair_gap"] = toNdarray2(m_model->pair_gap, m_model->npair, 1); - out["pair_friction"] = toNdarray2(m_model->pair_friction, m_model->npair, 5); - out["exclude_signature"] = toNdarray2(m_model->exclude_signature, m_model->nexclude, 1); - out["eq_type"] = toNdarray2(m_model->eq_type, m_model->neq, 1); - out["eq_obj1id"] = toNdarray2(m_model->eq_obj1id, m_model->neq, 1); - out["eq_obj2id"] = toNdarray2(m_model->eq_obj2id, m_model->neq, 1); - out["eq_active"] = toNdarray2(m_model->eq_active, m_model->neq, 1); - out["eq_solref"] = toNdarray2(m_model->eq_solref, m_model->neq, mjNREF); - out["eq_solimp"] = toNdarray2(m_model->eq_solimp, m_model->neq, mjNIMP); - out["eq_data"] = toNdarray2(m_model->eq_data, m_model->neq, mjNEQDATA); - out["tendon_adr"] = toNdarray2(m_model->tendon_adr, m_model->ntendon, 1); - out["tendon_num"] = toNdarray2(m_model->tendon_num, m_model->ntendon, 1); - out["tendon_matid"] = toNdarray2(m_model->tendon_matid, m_model->ntendon, 1); - out["tendon_limited"] = toNdarray2(m_model->tendon_limited, m_model->ntendon, 1); - out["tendon_frictional"] = toNdarray2(m_model->tendon_frictional, m_model->ntendon, 1); - out["tendon_width"] = toNdarray2(m_model->tendon_width, m_model->ntendon, 1); - out["tendon_solref_lim"] = toNdarray2(m_model->tendon_solref_lim, m_model->ntendon, mjNREF); - out["tendon_solimp_lim"] = toNdarray2(m_model->tendon_solimp_lim, m_model->ntendon, mjNIMP); - out["tendon_solref_fri"] = toNdarray2(m_model->tendon_solref_fri, m_model->ntendon, mjNREF); - out["tendon_solimp_fri"] = toNdarray2(m_model->tendon_solimp_fri, m_model->ntendon, mjNIMP); - out["tendon_range"] = toNdarray2(m_model->tendon_range, m_model->ntendon, 2); - out["tendon_margin"] = toNdarray2(m_model->tendon_margin, m_model->ntendon, 1); - out["tendon_stiffness"] = toNdarray2(m_model->tendon_stiffness, m_model->ntendon, 1); - out["tendon_damping"] = toNdarray2(m_model->tendon_damping, m_model->ntendon, 1); - out["tendon_frictionloss"] = toNdarray2(m_model->tendon_frictionloss, m_model->ntendon, 1); - out["tendon_lengthspring"] = toNdarray2(m_model->tendon_lengthspring, m_model->ntendon, 1); - out["tendon_length0"] = toNdarray2(m_model->tendon_length0, m_model->ntendon, 1); - out["tendon_invweight0"] = toNdarray2(m_model->tendon_invweight0, m_model->ntendon, 1); - out["tendon_user"] = toNdarray2(m_model->tendon_user, m_model->ntendon, m_model->nuser_tendon); - out["tendon_rgba"] = toNdarray2(m_model->tendon_rgba, m_model->ntendon, 4); - out["wrap_type"] = toNdarray2(m_model->wrap_type, m_model->nwrap, 1); - out["wrap_objid"] = toNdarray2(m_model->wrap_objid, m_model->nwrap, 1); - out["wrap_prm"] = toNdarray2(m_model->wrap_prm, m_model->nwrap, 1); - out["actuator_trntype"] = toNdarray2(m_model->actuator_trntype, m_model->nu, 1); - out["actuator_dyntype"] = toNdarray2(m_model->actuator_dyntype, m_model->nu, 1); - out["actuator_gaintype"] = toNdarray2(m_model->actuator_gaintype, m_model->nu, 1); - out["actuator_biastype"] = toNdarray2(m_model->actuator_biastype, m_model->nu, 1); - out["actuator_trnid"] = toNdarray2(m_model->actuator_trnid, m_model->nu, 2); - out["actuator_ctrllimited"] = toNdarray2(m_model->actuator_ctrllimited, m_model->nu, 1); - out["actuator_forcelimited"] = toNdarray2(m_model->actuator_forcelimited, m_model->nu, 1); - out["actuator_dynprm"] = toNdarray2(m_model->actuator_dynprm, m_model->nu, mjNDYN); - out["actuator_gainprm"] = toNdarray2(m_model->actuator_gainprm, m_model->nu, mjNGAIN); - out["actuator_biasprm"] = toNdarray2(m_model->actuator_biasprm, m_model->nu, mjNBIAS); - out["actuator_ctrlrange"] = toNdarray2(m_model->actuator_ctrlrange, m_model->nu, 2); - out["actuator_forcerange"] = toNdarray2(m_model->actuator_forcerange, m_model->nu, 2); - out["actuator_gear"] = toNdarray2(m_model->actuator_gear, m_model->nu, 1); - out["actuator_cranklength"] = toNdarray2(m_model->actuator_cranklength, m_model->nu, 1); - out["actuator_invweight0"] = toNdarray2(m_model->actuator_invweight0, m_model->nu, 1); - out["actuator_length0"] = toNdarray2(m_model->actuator_length0, m_model->nu, 1); - out["actuator_lengthrange"] = toNdarray2(m_model->actuator_lengthrange, m_model->nu, 2); - out["actuator_user"] = toNdarray2(m_model->actuator_user, m_model->nu, m_model->nuser_actuator); - out["sensor_type"] = toNdarray2(m_model->sensor_type, m_model->nsensor, 1); - out["sensor_objid"] = toNdarray2(m_model->sensor_objid, m_model->nsensor, 1); - out["sensor_dim"] = toNdarray2(m_model->sensor_dim, m_model->nsensor, 1); - out["sensor_adr"] = toNdarray2(m_model->sensor_adr, m_model->nsensor, 1); - out["sensor_scale"] = toNdarray2(m_model->sensor_scale, m_model->nsensor, 1); - out["sensor_user"] = toNdarray2(m_model->sensor_user, m_model->nsensor, m_model->nuser_sensor); - out["numeric_adr"] = toNdarray2(m_model->numeric_adr, m_model->nnumeric, 1); - out["numeric_size"] = toNdarray2(m_model->numeric_size, m_model->nnumeric, 1); - out["numeric_data"] = toNdarray2(m_model->numeric_data, m_model->nnumericdata, 1); - out["text_adr"] = toNdarray2(m_model->text_adr, m_model->ntext, 1); - out["text_data"] = toNdarray2(m_model->text_data, m_model->ntextdata, 1); - out["key_time"] = toNdarray2(m_model->key_time, m_model->nkey, 1); - out["key_qpos"] = toNdarray2(m_model->key_qpos, m_model->nkey, m_model->nq); - out["key_qvel"] = toNdarray2(m_model->key_qvel, m_model->nkey, m_model->nv); - out["key_act"] = toNdarray2(m_model->key_act, m_model->nkey, m_model->na); - out["name_bodyadr"] = toNdarray2(m_model->name_bodyadr, m_model->nbody, 1); - out["name_jntadr"] = toNdarray2(m_model->name_jntadr, m_model->njnt, 1); - out["name_geomadr"] = toNdarray2(m_model->name_geomadr, m_model->ngeom, 1); - out["name_siteadr"] = toNdarray2(m_model->name_siteadr, m_model->nsite, 1); - out["name_camadr"] = toNdarray2(m_model->name_camadr, m_model->ncam, 1); - out["name_lightadr"] = toNdarray2(m_model->name_lightadr, m_model->nlight, 1); - out["name_meshadr"] = toNdarray2(m_model->name_meshadr, m_model->nmesh, 1); - out["name_hfieldadr"] = toNdarray2(m_model->name_hfieldadr, m_model->nhfield, 1); - out["name_texadr"] = toNdarray2(m_model->name_texadr, m_model->ntex, 1); - out["name_matadr"] = toNdarray2(m_model->name_matadr, m_model->nmat, 1); - out["name_eqadr"] = toNdarray2(m_model->name_eqadr, m_model->neq, 1); - out["name_tendonadr"] = toNdarray2(m_model->name_tendonadr, m_model->ntendon, 1); - out["name_actuatoradr"] = toNdarray2(m_model->name_actuatoradr, m_model->nu, 1); - out["name_sensoradr"] = toNdarray2(m_model->name_sensoradr, m_model->nsensor, 1); - out["name_numericadr"] = toNdarray2(m_model->name_numericadr, m_model->nnumeric, 1); - out["name_textadr"] = toNdarray2(m_model->name_textadr, m_model->ntext, 1); - out["names"] = toNdarray2(m_model->names, m_model->nnames, 1); diff --git a/src/3rdparty/mjcpy2/mjcpy2_setdata_autogen.i b/src/3rdparty/mjcpy2/mjcpy2_setdata_autogen.i deleted file mode 100644 index 58d316116..000000000 --- a/src/3rdparty/mjcpy2/mjcpy2_setdata_autogen.i +++ /dev/null @@ -1,99 +0,0 @@ - _csdihk(d, "nstack", m_data->nstack); - _csdihk(d, "nbuffer", m_data->nbuffer); - _csdihk(d, "pstack", m_data->pstack); - _csdihk(d, "maxstackuse", m_data->maxstackuse); - _csdihk(d, "ne", m_data->ne); - _csdihk(d, "nf", m_data->nf); - _csdihk(d, "nefc", m_data->nefc); - _csdihk(d, "ncon", m_data->ncon); - _cadihk(d, "nwarning", m_data->nwarning); - _cadihk(d, "timer_duration", m_data->timer_duration); - _cadihk(d, "timer_ncall", m_data->timer_ncall); - _cadihk(d, "mocaptime", m_data->mocaptime); - _csdihk(d, "time", m_data->time); - _cadihk(d, "energy", m_data->energy); - _cadihk(d, "solverstat", m_data->solverstat); - _cadihk(d, "qpos", m_data->qpos); - _cadihk(d, "qvel", m_data->qvel); - _cadihk(d, "act", m_data->act); - _cadihk(d, "ctrl", m_data->ctrl); - _cadihk(d, "qfrc_applied", m_data->qfrc_applied); - _cadihk(d, "xfrc_applied", m_data->xfrc_applied); - _cadihk(d, "qacc", m_data->qacc); - _cadihk(d, "act_dot", m_data->act_dot); - _cadihk(d, "mocap_pos", m_data->mocap_pos); - _cadihk(d, "mocap_quat", m_data->mocap_quat); - _cadihk(d, "userdata", m_data->userdata); - _cadihk(d, "sensordata", m_data->sensordata); - _cadihk(d, "xpos", m_data->xpos); - _cadihk(d, "xquat", m_data->xquat); - _cadihk(d, "xmat", m_data->xmat); - _cadihk(d, "xipos", m_data->xipos); - _cadihk(d, "ximat", m_data->ximat); - _cadihk(d, "xanchor", m_data->xanchor); - _cadihk(d, "xaxis", m_data->xaxis); - _cadihk(d, "geom_xpos", m_data->geom_xpos); - _cadihk(d, "geom_xmat", m_data->geom_xmat); - _cadihk(d, "site_xpos", m_data->site_xpos); - _cadihk(d, "site_xmat", m_data->site_xmat); - _cadihk(d, "cam_xpos", m_data->cam_xpos); - _cadihk(d, "cam_xmat", m_data->cam_xmat); - _cadihk(d, "light_xpos", m_data->light_xpos); - _cadihk(d, "light_xdir", m_data->light_xdir); - _cadihk(d, "com_subtree", m_data->com_subtree); - _cadihk(d, "cdof", m_data->cdof); - _cadihk(d, "cinert", m_data->cinert); - _cadihk(d, "ten_wrapadr", m_data->ten_wrapadr); - _cadihk(d, "ten_wrapnum", m_data->ten_wrapnum); - _cadihk(d, "ten_length", m_data->ten_length); - _cadihk(d, "ten_moment", m_data->ten_moment); - _cadihk(d, "wrap_obj", m_data->wrap_obj); - _cadihk(d, "wrap_xpos", m_data->wrap_xpos); - _cadihk(d, "actuator_length", m_data->actuator_length); - _cadihk(d, "actuator_moment", m_data->actuator_moment); - _cadihk(d, "crb", m_data->crb); - _cadihk(d, "qM", m_data->qM); - _cadihk(d, "qLD", m_data->qLD); - _cadihk(d, "qLDiagInv", m_data->qLDiagInv); - _cadihk(d, "qLDiagSqrtInv", m_data->qLDiagSqrtInv); - _cadihk(d, "efc_type", m_data->efc_type); - _cadihk(d, "efc_id", m_data->efc_id); - _cadihk(d, "efc_rownnz", m_data->efc_rownnz); - _cadihk(d, "efc_rowadr", m_data->efc_rowadr); - _cadihk(d, "efc_colind", m_data->efc_colind); - _cadihk(d, "efc_rownnz_T", m_data->efc_rownnz_T); - _cadihk(d, "efc_rowadr_T", m_data->efc_rowadr_T); - _cadihk(d, "efc_colind_T", m_data->efc_colind_T); - _cadihk(d, "efc_solref", m_data->efc_solref); - _cadihk(d, "efc_solimp", m_data->efc_solimp); - _cadihk(d, "efc_margin", m_data->efc_margin); - _cadihk(d, "efc_frictionloss", m_data->efc_frictionloss); - _cadihk(d, "efc_pos", m_data->efc_pos); - _cadihk(d, "efc_J", m_data->efc_J); - _cadihk(d, "efc_J_T", m_data->efc_J_T); - _cadihk(d, "efc_diagApprox", m_data->efc_diagApprox); - _cadihk(d, "efc_R", m_data->efc_R); - _cadihk(d, "efc_AR", m_data->efc_AR); - _cadihk(d, "e_ARchol", m_data->e_ARchol); - _cadihk(d, "fc_e_rect", m_data->fc_e_rect); - _cadihk(d, "fc_AR", m_data->fc_AR); - _cadihk(d, "ten_velocity", m_data->ten_velocity); - _cadihk(d, "actuator_velocity", m_data->actuator_velocity); - _cadihk(d, "cvel", m_data->cvel); - _cadihk(d, "cdof_dot", m_data->cdof_dot); - _cadihk(d, "qfrc_bias", m_data->qfrc_bias); - _cadihk(d, "qfrc_passive", m_data->qfrc_passive); - _cadihk(d, "efc_vel", m_data->efc_vel); - _cadihk(d, "efc_aref", m_data->efc_aref); - _cadihk(d, "actuator_force", m_data->actuator_force); - _cadihk(d, "qfrc_actuator", m_data->qfrc_actuator); - _cadihk(d, "qfrc_unc", m_data->qfrc_unc); - _cadihk(d, "qacc_unc", m_data->qacc_unc); - _cadihk(d, "efc_b", m_data->efc_b); - _cadihk(d, "fc_b", m_data->fc_b); - _cadihk(d, "efc_force", m_data->efc_force); - _cadihk(d, "qfrc_constraint", m_data->qfrc_constraint); - _cadihk(d, "qfrc_inverse", m_data->qfrc_inverse); - _cadihk(d, "cacc", m_data->cacc); - _cadihk(d, "cfrc_int", m_data->cfrc_int); - _cadihk(d, "cfrc_ext", m_data->cfrc_ext); diff --git a/src/3rdparty/mjcpy2/mjcpy2_setmodel_autogen.i b/src/3rdparty/mjcpy2/mjcpy2_setmodel_autogen.i deleted file mode 100644 index a89f67461..000000000 --- a/src/3rdparty/mjcpy2/mjcpy2_setmodel_autogen.i +++ /dev/null @@ -1,253 +0,0 @@ - _csdihk(d, "nq", m_model->nq); - _csdihk(d, "nv", m_model->nv); - _csdihk(d, "nu", m_model->nu); - _csdihk(d, "na", m_model->na); - _csdihk(d, "nbody", m_model->nbody); - _csdihk(d, "njnt", m_model->njnt); - _csdihk(d, "ngeom", m_model->ngeom); - _csdihk(d, "nsite", m_model->nsite); - _csdihk(d, "ncam", m_model->ncam); - _csdihk(d, "nlight", m_model->nlight); - _csdihk(d, "nmesh", m_model->nmesh); - _csdihk(d, "nmeshvert", m_model->nmeshvert); - _csdihk(d, "nmeshface", m_model->nmeshface); - _csdihk(d, "nmeshgraph", m_model->nmeshgraph); - _csdihk(d, "nhfield", m_model->nhfield); - _csdihk(d, "nhfielddata", m_model->nhfielddata); - _csdihk(d, "ntex", m_model->ntex); - _csdihk(d, "ntexdata", m_model->ntexdata); - _csdihk(d, "nmat", m_model->nmat); - _csdihk(d, "npair", m_model->npair); - _csdihk(d, "nexclude", m_model->nexclude); - _csdihk(d, "neq", m_model->neq); - _csdihk(d, "ntendon", m_model->ntendon); - _csdihk(d, "nwrap", m_model->nwrap); - _csdihk(d, "nsensor", m_model->nsensor); - _csdihk(d, "nnumeric", m_model->nnumeric); - _csdihk(d, "nnumericdata", m_model->nnumericdata); - _csdihk(d, "ntext", m_model->ntext); - _csdihk(d, "ntextdata", m_model->ntextdata); - _csdihk(d, "nkey", m_model->nkey); - _csdihk(d, "nuser_body", m_model->nuser_body); - _csdihk(d, "nuser_jnt", m_model->nuser_jnt); - _csdihk(d, "nuser_geom", m_model->nuser_geom); - _csdihk(d, "nuser_site", m_model->nuser_site); - _csdihk(d, "nuser_tendon", m_model->nuser_tendon); - _csdihk(d, "nuser_actuator", m_model->nuser_actuator); - _csdihk(d, "nuser_sensor", m_model->nuser_sensor); - _csdihk(d, "nnames", m_model->nnames); - _csdihk(d, "nM", m_model->nM); - _csdihk(d, "nemax", m_model->nemax); - _csdihk(d, "njmax", m_model->njmax); - _csdihk(d, "nconmax", m_model->nconmax); - _csdihk(d, "nstack", m_model->nstack); - _csdihk(d, "nuserdata", m_model->nuserdata); - _csdihk(d, "nmocap", m_model->nmocap); - _csdihk(d, "nsensordata", m_model->nsensordata); - _csdihk(d, "nbuffer", m_model->nbuffer); - _cadihk(d, "qpos0", m_model->qpos0); - _cadihk(d, "qpos_spring", m_model->qpos_spring); - _cadihk(d, "body_parentid", m_model->body_parentid); - _cadihk(d, "body_rootid", m_model->body_rootid); - _cadihk(d, "body_weldid", m_model->body_weldid); - _cadihk(d, "body_mocapid", m_model->body_mocapid); - _cadihk(d, "body_jntnum", m_model->body_jntnum); - _cadihk(d, "body_jntadr", m_model->body_jntadr); - _cadihk(d, "body_dofnum", m_model->body_dofnum); - _cadihk(d, "body_dofadr", m_model->body_dofadr); - _cadihk(d, "body_geomnum", m_model->body_geomnum); - _cadihk(d, "body_geomadr", m_model->body_geomadr); - _cadihk(d, "body_pos", m_model->body_pos); - _cadihk(d, "body_quat", m_model->body_quat); - _cadihk(d, "body_ipos", m_model->body_ipos); - _cadihk(d, "body_iquat", m_model->body_iquat); - _cadihk(d, "body_mass", m_model->body_mass); - _cadihk(d, "body_inertia", m_model->body_inertia); - _cadihk(d, "body_invweight0", m_model->body_invweight0); - _cadihk(d, "body_user", m_model->body_user); - _cadihk(d, "jnt_type", m_model->jnt_type); - _cadihk(d, "jnt_qposadr", m_model->jnt_qposadr); - _cadihk(d, "jnt_dofadr", m_model->jnt_dofadr); - _cadihk(d, "jnt_bodyid", m_model->jnt_bodyid); - _cadihk(d, "jnt_limited", m_model->jnt_limited); - _cadihk(d, "jnt_solref", m_model->jnt_solref); - _cadihk(d, "jnt_solimp", m_model->jnt_solimp); - _cadihk(d, "jnt_pos", m_model->jnt_pos); - _cadihk(d, "jnt_axis", m_model->jnt_axis); - _cadihk(d, "jnt_stiffness", m_model->jnt_stiffness); - _cadihk(d, "jnt_range", m_model->jnt_range); - _cadihk(d, "jnt_margin", m_model->jnt_margin); - _cadihk(d, "jnt_user", m_model->jnt_user); - _cadihk(d, "dof_bodyid", m_model->dof_bodyid); - _cadihk(d, "dof_jntid", m_model->dof_jntid); - _cadihk(d, "dof_parentid", m_model->dof_parentid); - _cadihk(d, "dof_Madr", m_model->dof_Madr); - _cadihk(d, "dof_frictional", m_model->dof_frictional); - _cadihk(d, "dof_solref", m_model->dof_solref); - _cadihk(d, "dof_solimp", m_model->dof_solimp); - _cadihk(d, "dof_frictionloss", m_model->dof_frictionloss); - _cadihk(d, "dof_armature", m_model->dof_armature); - _cadihk(d, "dof_damping", m_model->dof_damping); - _cadihk(d, "dof_invweight0", m_model->dof_invweight0); - _cadihk(d, "geom_type", m_model->geom_type); - _cadihk(d, "geom_contype", m_model->geom_contype); - _cadihk(d, "geom_conaffinity", m_model->geom_conaffinity); - _cadihk(d, "geom_condim", m_model->geom_condim); - _cadihk(d, "geom_bodyid", m_model->geom_bodyid); - _cadihk(d, "geom_dataid", m_model->geom_dataid); - _cadihk(d, "geom_matid", m_model->geom_matid); - _cadihk(d, "geom_group", m_model->geom_group); - _cadihk(d, "geom_solmix", m_model->geom_solmix); - _cadihk(d, "geom_solref", m_model->geom_solref); - _cadihk(d, "geom_solimp", m_model->geom_solimp); - _cadihk(d, "geom_size", m_model->geom_size); - _cadihk(d, "geom_rbound", m_model->geom_rbound); - _cadihk(d, "geom_pos", m_model->geom_pos); - _cadihk(d, "geom_quat", m_model->geom_quat); - _cadihk(d, "geom_friction", m_model->geom_friction); - _cadihk(d, "geom_margin", m_model->geom_margin); - _cadihk(d, "geom_gap", m_model->geom_gap); - _cadihk(d, "geom_user", m_model->geom_user); - _cadihk(d, "geom_rgba", m_model->geom_rgba); - _cadihk(d, "site_type", m_model->site_type); - _cadihk(d, "site_bodyid", m_model->site_bodyid); - _cadihk(d, "site_matid", m_model->site_matid); - _cadihk(d, "site_group", m_model->site_group); - _cadihk(d, "site_size", m_model->site_size); - _cadihk(d, "site_pos", m_model->site_pos); - _cadihk(d, "site_quat", m_model->site_quat); - _cadihk(d, "site_user", m_model->site_user); - _cadihk(d, "site_rgba", m_model->site_rgba); - _cadihk(d, "cam_bodyid", m_model->cam_bodyid); - _cadihk(d, "cam_pos", m_model->cam_pos); - _cadihk(d, "cam_quat", m_model->cam_quat); - _cadihk(d, "cam_fovy", m_model->cam_fovy); - _cadihk(d, "cam_ipd", m_model->cam_ipd); - _cadihk(d, "light_bodyid", m_model->light_bodyid); - _cadihk(d, "light_directional", m_model->light_directional); - _cadihk(d, "light_castshadow", m_model->light_castshadow); - _cadihk(d, "light_active", m_model->light_active); - _cadihk(d, "light_pos", m_model->light_pos); - _cadihk(d, "light_dir", m_model->light_dir); - _cadihk(d, "light_attenuation", m_model->light_attenuation); - _cadihk(d, "light_cutoff", m_model->light_cutoff); - _cadihk(d, "light_exponent", m_model->light_exponent); - _cadihk(d, "light_ambient", m_model->light_ambient); - _cadihk(d, "light_diffuse", m_model->light_diffuse); - _cadihk(d, "light_specular", m_model->light_specular); - _cadihk(d, "mesh_faceadr", m_model->mesh_faceadr); - _cadihk(d, "mesh_facenum", m_model->mesh_facenum); - _cadihk(d, "mesh_vertadr", m_model->mesh_vertadr); - _cadihk(d, "mesh_vertnum", m_model->mesh_vertnum); - _cadihk(d, "mesh_graphadr", m_model->mesh_graphadr); - _cadihk(d, "mesh_vert", m_model->mesh_vert); - _cadihk(d, "mesh_normal", m_model->mesh_normal); - _cadihk(d, "mesh_face", m_model->mesh_face); - _cadihk(d, "mesh_graph", m_model->mesh_graph); - _cadihk(d, "hfield_size", m_model->hfield_size); - _cadihk(d, "hfield_nrow", m_model->hfield_nrow); - _cadihk(d, "hfield_ncol", m_model->hfield_ncol); - _cadihk(d, "hfield_adr", m_model->hfield_adr); - _cadihk(d, "hfield_data", m_model->hfield_data); - _cadihk(d, "tex_type", m_model->tex_type); - _cadihk(d, "tex_height", m_model->tex_height); - _cadihk(d, "tex_width", m_model->tex_width); - _cadihk(d, "tex_adr", m_model->tex_adr); - _cadihk(d, "tex_rgb", m_model->tex_rgb); - _cadihk(d, "mat_texid", m_model->mat_texid); - _cadihk(d, "mat_texuniform", m_model->mat_texuniform); - _cadihk(d, "mat_emission", m_model->mat_emission); - _cadihk(d, "mat_specular", m_model->mat_specular); - _cadihk(d, "mat_shininess", m_model->mat_shininess); - _cadihk(d, "mat_reflectance", m_model->mat_reflectance); - _cadihk(d, "mat_rgba", m_model->mat_rgba); - _cadihk(d, "pair_dim", m_model->pair_dim); - _cadihk(d, "pair_geom1", m_model->pair_geom1); - _cadihk(d, "pair_geom2", m_model->pair_geom2); - _cadihk(d, "pair_signature", m_model->pair_signature); - _cadihk(d, "pair_solref", m_model->pair_solref); - _cadihk(d, "pair_solimp", m_model->pair_solimp); - _cadihk(d, "pair_margin", m_model->pair_margin); - _cadihk(d, "pair_gap", m_model->pair_gap); - _cadihk(d, "pair_friction", m_model->pair_friction); - _cadihk(d, "exclude_signature", m_model->exclude_signature); - _cadihk(d, "eq_type", m_model->eq_type); - _cadihk(d, "eq_obj1id", m_model->eq_obj1id); - _cadihk(d, "eq_obj2id", m_model->eq_obj2id); - _cadihk(d, "eq_active", m_model->eq_active); - _cadihk(d, "eq_solref", m_model->eq_solref); - _cadihk(d, "eq_solimp", m_model->eq_solimp); - _cadihk(d, "eq_data", m_model->eq_data); - _cadihk(d, "tendon_adr", m_model->tendon_adr); - _cadihk(d, "tendon_num", m_model->tendon_num); - _cadihk(d, "tendon_matid", m_model->tendon_matid); - _cadihk(d, "tendon_limited", m_model->tendon_limited); - _cadihk(d, "tendon_frictional", m_model->tendon_frictional); - _cadihk(d, "tendon_width", m_model->tendon_width); - _cadihk(d, "tendon_solref_lim", m_model->tendon_solref_lim); - _cadihk(d, "tendon_solimp_lim", m_model->tendon_solimp_lim); - _cadihk(d, "tendon_solref_fri", m_model->tendon_solref_fri); - _cadihk(d, "tendon_solimp_fri", m_model->tendon_solimp_fri); - _cadihk(d, "tendon_range", m_model->tendon_range); - _cadihk(d, "tendon_margin", m_model->tendon_margin); - _cadihk(d, "tendon_stiffness", m_model->tendon_stiffness); - _cadihk(d, "tendon_damping", m_model->tendon_damping); - _cadihk(d, "tendon_frictionloss", m_model->tendon_frictionloss); - _cadihk(d, "tendon_lengthspring", m_model->tendon_lengthspring); - _cadihk(d, "tendon_length0", m_model->tendon_length0); - _cadihk(d, "tendon_invweight0", m_model->tendon_invweight0); - _cadihk(d, "tendon_user", m_model->tendon_user); - _cadihk(d, "tendon_rgba", m_model->tendon_rgba); - _cadihk(d, "wrap_type", m_model->wrap_type); - _cadihk(d, "wrap_objid", m_model->wrap_objid); - _cadihk(d, "wrap_prm", m_model->wrap_prm); - _cadihk(d, "actuator_trntype", m_model->actuator_trntype); - _cadihk(d, "actuator_dyntype", m_model->actuator_dyntype); - _cadihk(d, "actuator_gaintype", m_model->actuator_gaintype); - _cadihk(d, "actuator_biastype", m_model->actuator_biastype); - _cadihk(d, "actuator_trnid", m_model->actuator_trnid); - _cadihk(d, "actuator_ctrllimited", m_model->actuator_ctrllimited); - _cadihk(d, "actuator_forcelimited", m_model->actuator_forcelimited); - _cadihk(d, "actuator_dynprm", m_model->actuator_dynprm); - _cadihk(d, "actuator_gainprm", m_model->actuator_gainprm); - _cadihk(d, "actuator_biasprm", m_model->actuator_biasprm); - _cadihk(d, "actuator_ctrlrange", m_model->actuator_ctrlrange); - _cadihk(d, "actuator_forcerange", m_model->actuator_forcerange); - _cadihk(d, "actuator_gear", m_model->actuator_gear); - _cadihk(d, "actuator_cranklength", m_model->actuator_cranklength); - _cadihk(d, "actuator_invweight0", m_model->actuator_invweight0); - _cadihk(d, "actuator_length0", m_model->actuator_length0); - _cadihk(d, "actuator_lengthrange", m_model->actuator_lengthrange); - _cadihk(d, "actuator_user", m_model->actuator_user); - _cadihk(d, "sensor_type", m_model->sensor_type); - _cadihk(d, "sensor_objid", m_model->sensor_objid); - _cadihk(d, "sensor_dim", m_model->sensor_dim); - _cadihk(d, "sensor_adr", m_model->sensor_adr); - _cadihk(d, "sensor_scale", m_model->sensor_scale); - _cadihk(d, "sensor_user", m_model->sensor_user); - _cadihk(d, "numeric_adr", m_model->numeric_adr); - _cadihk(d, "numeric_size", m_model->numeric_size); - _cadihk(d, "numeric_data", m_model->numeric_data); - _cadihk(d, "text_adr", m_model->text_adr); - _cadihk(d, "text_data", m_model->text_data); - _cadihk(d, "key_time", m_model->key_time); - _cadihk(d, "key_qpos", m_model->key_qpos); - _cadihk(d, "key_qvel", m_model->key_qvel); - _cadihk(d, "key_act", m_model->key_act); - _cadihk(d, "name_bodyadr", m_model->name_bodyadr); - _cadihk(d, "name_jntadr", m_model->name_jntadr); - _cadihk(d, "name_geomadr", m_model->name_geomadr); - _cadihk(d, "name_siteadr", m_model->name_siteadr); - _cadihk(d, "name_camadr", m_model->name_camadr); - _cadihk(d, "name_lightadr", m_model->name_lightadr); - _cadihk(d, "name_meshadr", m_model->name_meshadr); - _cadihk(d, "name_hfieldadr", m_model->name_hfieldadr); - _cadihk(d, "name_texadr", m_model->name_texadr); - _cadihk(d, "name_matadr", m_model->name_matadr); - _cadihk(d, "name_eqadr", m_model->name_eqadr); - _cadihk(d, "name_tendonadr", m_model->name_tendonadr); - _cadihk(d, "name_actuatoradr", m_model->name_actuatoradr); - _cadihk(d, "name_sensoradr", m_model->name_sensoradr); - _cadihk(d, "name_numericadr", m_model->name_numericadr); - _cadihk(d, "name_textadr", m_model->name_textadr); - _cadihk(d, "names", m_model->names); diff --git a/src/3rdparty/mjcpy2/mujoco_osg_viewer.cpp b/src/3rdparty/mjcpy2/mujoco_osg_viewer.cpp deleted file mode 100755 index edb9bd1bf..000000000 --- a/src/3rdparty/mjcpy2/mujoco_osg_viewer.cpp +++ /dev/null @@ -1,491 +0,0 @@ -#include "assert.h" -#include "mujoco_osg_viewer.hpp" -#include -#include -#include "mujoco.h" -#include "unistd.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "macros.h" - -#define PLOT_JOINTS 0 -// mujoco 1.31 or newer -#define MJC131 1 - -class PhotoCallback : public osg::Camera::DrawCallback -{ -public: - PhotoCallback( osg::Image* img ) - : _image(img), _fileIndex(0) {} - - virtual void operator()( osg::RenderInfo& renderInfo ) const - { - if ( _image.valid() ) - { - osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext(); - if ( gc->getTraits() ) - { - int width = gc->getTraits()->width; - int height = gc->getTraits()->height; - GLenum pixelFormat = (gc->getTraits()->alpha ? GL_RGBA : GL_RGB); - _image->readPixels( 0, 0, width, height, pixelFormat, GL_UNSIGNED_BYTE ); - } - } - } - -protected: - osg::ref_ptr _image; - mutable int _fileIndex; -}; - -struct EventHandler : public osgGA::GUIEventHandler -{ - EventHandler( MujocoOSGViewer* parent ) : - m_parent(parent), - m_idling(false) {} - bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ); - MujocoOSGViewer* m_parent; - bool m_idling; -}; - -bool EventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa ) { - osgGA::GUIEventAdapter::EventType t = ea.getEventType(); - if (t == osgGA::GUIEventAdapter::KEYDOWN) { - int key = ea.getKey(); - switch (key) { - case 'h': - printf( - "=== Mujoco OSG Viewer ===\n" - "'h': Print help\n" - "'p': Unpause\n" - "'1': Set camera mode to trackball manipulator\n" - "'2': Set camera mode to node tracker\n" - ); - return true; - case 'p': - if (m_idling) - m_idling = false; - return true; - } - } - return osgGA::GUIEventHandler::handle(ea,aa); -} - -// GROUND PLANE CODE RIPPED OFF FROM https://github.com/naderman/orca-robotics/blob/master/src/libs/orcaqgui3dfactory/gridelement.cpp -void makeCheckImage64x64x3( GLubyte img[64][64][3], - int numSquaresPerEdge, - int lowVal, - int highVal ) -{ - - - const int widthInPixels=64; - const int heightInPixels=64; - assert( lowVal >= 0 && lowVal <= 255 ); - assert( highVal >= 0 && highVal <= 255 ); - - int wOn=0; - int hOn=0; - for (int i = 0; i < widthInPixels; i++) - { - if ( (i % (widthInPixels/numSquaresPerEdge)) == 0 ) - wOn = wOn ? 0 : 1; - - for (int j = 0; j < heightInPixels; j++) - { - if ( (j % (heightInPixels/numSquaresPerEdge)) == 0 ) - hOn = hOn ? 0 : 1; - - int c = (wOn^hOn); - if ( c==0 ) c = lowVal; - else c = highVal; - // cout<<"TRACE(glutil.cpp): hOn: " << hOn << ", wOn: " << wOn << ", c: " << c << endl; - img[i][j][0] = (GLubyte) c; - img[i][j][1] = (GLubyte) c; - img[i][j][2] = (GLubyte) c; - } - } -} - -osg::Image *createCheckImage() -{ - osg::Image *img = new osg::Image; - img->allocateImage( 64, 64, 3, GL_RGB, GL_UNSIGNED_BYTE ); - - GLubyte checkImage[64][64][3]; - - // Draw the chess-board in memory - makeCheckImage64x64x3( checkImage, 2, 12, 200 ); - - // copy to the image - int n=0; - for ( uint i=0; i < 64; i++ ) - for ( uint j=0; j < 64; j++ ) - for ( uint k=0; k < 3; k++ ) - img->data()[n++] = checkImage[i][j][k]; - - return img; -} - - - - -osg::Node* createGroundPlane(){ - // - // Create the geode - // - osg::Geode* groundPlaneGeode_ = new osg::Geode; - - // - // Create the texture - // - osg::ref_ptr checkImage = createCheckImage(); - - osg::ref_ptr checkTexture = new osg::Texture2D; - // protect from being optimized away as static state: - checkTexture->setDataVariance(osg::Object::DYNAMIC); - checkTexture->setImage( checkImage.get() ); - - // Tell the texture to repeat - checkTexture->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT ); - checkTexture->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT ); - - // Create a new StateSet with default settings: - osg::ref_ptr groundPlaneStateSet = new osg::StateSet(); - - // Assign texture unit 0 of our new StateSet to the texture - // we just created and enable the texture. - groundPlaneStateSet->setTextureAttributeAndModes(0,checkTexture.get(),osg::StateAttribute::ON); - - // Texture mode - osg::TexEnv* texEnv = new osg::TexEnv; - texEnv->setMode(osg::TexEnv::DECAL); // (osg::TexEnv::MODULATE); - groundPlaneStateSet->setTextureAttribute(0,texEnv); - - // Associate this state set with our Geode - groundPlaneGeode_->setStateSet(groundPlaneStateSet.get()); - - // - // Create the ground plane - // - osg::ref_ptr groundPlaneGeometry = new osg::Geometry(); - double groundPlaneSquareSpacing_ = 1; - - const double infty=1000; - - const double metresPerTile=2*groundPlaneSquareSpacing_; - const double texCoordExtreme=2*infty/metresPerTile; - - osg::ref_ptr vertices = new osg::Vec3Array; - groundPlaneGeometry->setVertexArray( vertices.get() ); - - osg::ref_ptr texCoords = new osg::Vec2Array; - groundPlaneGeometry->setTexCoordArray( 0, texCoords.get() ); - - vertices->push_back( osg::Vec3d( -infty, -infty, 0 ) ); - texCoords->push_back( osg::Vec2( 0, 0 ) ); - vertices->push_back( osg::Vec3d( infty, -infty, 0 ) ); - texCoords->push_back( osg::Vec2( texCoordExtreme, 0 ) ); - vertices->push_back( osg::Vec3d( infty, infty, 0 ) ); - texCoords->push_back( osg::Vec2( texCoordExtreme, texCoordExtreme ) ); - vertices->push_back( osg::Vec3d( -infty, infty, 0 ) ); - texCoords->push_back( osg::Vec2( 0, texCoordExtreme ) ); - -// osg::ref_ptr colors = new osg::Vec4Array; -// colors->push_back(osg::Vec4(0.2, 0.2, 0.2, 1.0) ); -// // colors->push_back(osg::Vec4(0.0, 0.5, 0.0, 1.0) ); -// groundPlaneGeometry->setColorArray(colors.get()); -// groundPlaneGeometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); - - osg::ref_ptr quad = - new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS); - for ( uint i=0; i < vertices->size(); i++ ) - quad->push_back( i ); - - groundPlaneGeometry->addPrimitiveSet( quad.get() ); - - groundPlaneGeode_->addDrawable( groundPlaneGeometry.get() ); - return groundPlaneGeode_; -} - -osg::Node* createOSGNode(const mjModel* model, int i_geom) { - int geom = model->geom_type[i_geom]; - mjtNum* size = model->geom_size + 3*i_geom; - osg::Shape* shape = NULL; - switch (geom) { - case mjGEOM_PLANE: { - return createGroundPlane(); - } - // case mjGEOM_HFIELD: - // break; - case mjGEOM_SPHERE: { - shape = new osg::Sphere(); - ((osg::Sphere*)shape)->setRadius(size[0]); - break; - } - case mjGEOM_CAPSULE: { - shape = new osg::Capsule(); - ((osg::Capsule*)shape)->setRadius(size[0]); - ((osg::Capsule*)shape)->setHeight(2*size[1]); - break; - } - #if 0 - case mjGEOM_ELLIPSOID: { - osg::MatrixTransform* mt = new osg::MatrixTransform(osg::Matrix::scale(size[0], size[1], size[2])); - osg::Sphere* sphere = new osg::Sphere(); - sphere->setRadius(1); - osg::Geode* geode1 = new osg::Geode; - geode1->addDrawable(new osg::ShapeDrawable(sphere)); - mt->addChild(geode1); - geode->addChild(mt); - break; - } - #endif - case mjGEOM_CYLINDER: { - shape = new osg::Cylinder(); - ((osg::Cylinder*)shape)->setRadius(size[0]); - ((osg::Cylinder*)shape)->setHeight(size[1]*2); - break; - } - - case mjGEOM_BOX: { - shape = new osg::Box(); - ((osg::Box*)shape)->setHalfLengths(osg::Vec3(size[0],size[1],size[2])); - break; - } - case mjGEOM_MESH: { - int id = model->geom_dataid[i_geom]; - shape = new osg::TriangleMesh; - osg::Vec3Array* vertices = new osg::Vec3Array; - osg::IntArray* indices = new osg::IntArray; - for (int j=0; j < model->mesh_vertnum[id]; ++j) { - float* p = model->mesh_vert + 3*model->mesh_vertadr[id] + 3*j; - vertices->push_back(osg::Vec3f(p[0], p[1], p[2])); - } - for (int j=0; j < model->mesh_facenum[id]; ++j) { - int* p = model->mesh_face + 3*model->mesh_faceadr[id] + 3*j; - indices->push_back( p[0] ); - indices->push_back( p[1] ); - indices->push_back( p[2] ); - - } - - ((osg::TriangleMesh*)shape)->setIndices(indices); - ((osg::TriangleMesh*)shape)->setVertices(vertices); - break; - } - default: - printf("unimplemented geom type: %i\n",geom); - break; - } - osg::Geode* geode = new osg::Geode; - osg::ShapeDrawable* drawable = new osg::ShapeDrawable(shape); - float* p = model->geom_rgba + i_geom*4; - drawable->setColor(osg::Vec4(p[0],p[1],p[2],p[3])); - geode->addDrawable(drawable); - - return geode; -} - - - -MujocoOSGViewer::MujocoOSGViewer() -: m_data(NULL), m_model(NULL) -{ - m_root = new osg::Group; - m_robot = new osg::Group; - m_root->addChild(m_robot); - - m_image = new osg::Image; - osg::ref_ptr pcb = new PhotoCallback( m_image.get() ); - m_viewer.getCamera()->setPostDrawCallback( pcb.get() ); - - m_viewer.setSceneData(m_root.get()); - m_viewer.setUpViewInWindow(0, 0, 640, 480); - m_viewer.realize(); - - osg::ref_ptr man = new osgGA::TrackballManipulator; - man->setHomePosition(osg::Vec3(2, 3, 2), osg::Vec3(0, 0, 0), osg::Vec3(-1, -1.5, 2)); - m_viewer.setCameraManipulator(man); - - m_handler = new EventHandler(this); - m_viewer.addEventHandler(m_handler.get()); -} - -MujocoOSGViewer::MujocoOSGViewer(int width, int height, osg::Vec3 cam_pos, osg::Vec3 cam_target) -: m_data(NULL), m_model(NULL) -{ - m_viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded); - - m_root = new osg::Group; - m_robot = new osg::Group; - m_root->addChild(m_robot); - - m_image = new osg::Image; - osg::ref_ptr pcb = new PhotoCallback( m_image.get() ); - m_viewer.getCamera()->setPostDrawCallback( pcb.get() ); - - m_viewer.setSceneData(m_root.get()); - m_viewer.setUpViewInWindow(0, 0, width, height); - m_viewer.realize(); - - osg::ref_ptr man = new osgGA::TrackballManipulator; - man->setHomePosition(cam_pos, cam_target, cam_pos); - m_viewer.setCameraManipulator(man); - - m_handler = new EventHandler(this); - m_viewer.addEventHandler(m_handler.get()); -} - -MujocoOSGViewer::MujocoOSGViewer(osg::Vec3 cam_pos, osg::Vec3 cam_target) -: m_data(NULL), m_model(NULL) -{ - m_viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded); - - m_root = new osg::Group; - m_robot = new osg::Group; - m_root->addChild(m_robot); - - m_image = new osg::Image; - osg::ref_ptr pcb = new PhotoCallback( m_image.get() ); - m_viewer.getCamera()->setPostDrawCallback( pcb.get() ); - - m_viewer.setSceneData(m_root.get()); - m_viewer.setUpViewInWindow(0, 0, 640, 480); - m_viewer.realize(); - - osg::ref_ptr man = new osgGA::TrackballManipulator; - man->setHomePosition(cam_pos, cam_target, osg::Vec3(-1, -1.5, 2)); - m_viewer.setCameraManipulator(man); - - m_handler = new EventHandler(this); - m_viewer.addEventHandler(m_handler.get()); -} - -void MujocoOSGViewer::SetCamera(float x, float y, float z, float px, float py, float pz){ - // place camera at (x,y,z) pointing to (px,py,pz) - m_viewer.getCameraManipulator()->setHomePosition(osg::Vec3(x, y, z), osg::Vec3(px, py, pz), osg::Vec3(x, y, z),false); -} - -void MujocoOSGViewer::Idle() { - EventHandler* handler = dynamic_cast(m_handler.get()); - handler->m_idling = true; - mj_kinematics(m_model, m_data); - _UpdateTransforms(); - while (handler->m_idling && !m_viewer.done()) { - m_viewer.frame(); - OpenThreads::Thread::microSleep(30000); - } -} - -void MujocoOSGViewer::RenderOnce() { - mj_kinematics(m_model,m_data); - _UpdateTransforms(); - m_viewer.frame(); -} - -void MujocoOSGViewer::_UpdateTransforms() { - for (int i=0; i < m_model->ngeom; ++i) { - mjtNum* tptr = m_data->geom_xpos + 3*i, - * rptr = m_data->geom_xmat + 9*i; - osg::Matrix mat(rptr[0],rptr[3],rptr[6],0,rptr[1],rptr[4],rptr[7],0,rptr[2],rptr[5],rptr[8],0,tptr[0],tptr[1],tptr[2],1); - m_geomTFs[i]->setMatrix(mat); - } -#if PLOT_JOINTS - for (int i=0; i < m_model->njnt; ++i) { - if (m_model->jnt_type[i] == mjJNT_HINGE) { - mjtNum* panchor = m_data->xanchor + 3*i, - * pax = m_data->xaxis + 3*i; - osg::Vec3 anchor(panchor[0], panchor[1], panchor[2]); - osg::Quat q; - q.makeRotate(osg::Vec3(0,0,1), osg::Vec3(pax[0], pax[1], pax[2])); - osg::Matrix mat; - mat.setTrans(anchor); - mat.setRotate(q); - m_axTFs[i]->setMatrix(mat); - } - } -#endif -} - -void MujocoOSGViewer::HandleInput() { - // TODO -} - -void MujocoOSGViewer::StartAsyncRendering() { - -} - -void MujocoOSGViewer::StopAsyncRendering() { - // TODO -} - -void MujocoOSGViewer::SetModel(const mjModel* m) { - m_model = m; - if (m_data!=NULL) mj_deleteData(m_data); - m_data = mj_makeData(m_model); - - m_geomTFs.clear(); - for (int i=0; i < m->ngeom; ++i) { - osg::MatrixTransform* geom_tf = new osg::MatrixTransform; - m_geomTFs.push_back(geom_tf); - if (i==0) {m_root->addChild(geom_tf);} - else {m_robot->addChild(geom_tf);} - osg::Node* node = createOSGNode(m,i); - // FAIL_IF_FALSE(!!node); - if (!!node) { - geom_tf->addChild(node); - } - else printf("SKIPPING\n"); - - } - -#if PLOT_JOINTS - m_axTFs.resize(m->njnt); - for (int i=0; i < m->njnt; ++i) { - if (m_model->jnt_type[i] == mjJNT_HINGE) { - printf("jnt type %i %i\n",i,m_model->jnt_type[i]); - osg::Cylinder* shape = new osg::Cylinder(); - shape->setRadius(0.01); - shape->setHeight(0.3); - osg::ShapeDrawable* drawable = new osg::ShapeDrawable(shape); - drawable->setColor(osg::Vec4(1,1,0,1)); - osg::Geode* geode = new osg::Geode; - geode->addDrawable(drawable); - osg::MatrixTransform* tf = new osg::MatrixTransform; - tf->addChild(geode); - m_root->addChild(tf); - m_axTFs[i] = tf; - } - } -#endif -} - -void MujocoOSGViewer::SetData(const mjData* d) { - mju_copy(m_data->qpos, d->qpos, m_model->nq); -} - - -void NewModelFromXML(const char* filename,mjModel*& model) { - char errmsg[100]; -#if MJC131 - model = mj_loadXML(filename, NULL, errmsg, sizeof(errmsg)); -#else - model = mj_loadXML(filename, errmsg); -#endif - if( !model ) { - printf("%s\n",errmsg); - } -} diff --git a/src/3rdparty/mjcpy2/mujoco_osg_viewer.hpp b/src/3rdparty/mjcpy2/mujoco_osg_viewer.hpp deleted file mode 100755 index 3ad492c6f..000000000 --- a/src/3rdparty/mjcpy2/mujoco_osg_viewer.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include -#include -#include -#include "mujoco.h" -//#include "mj_engine.h" - - -class MujocoOSGViewer { -public: - MujocoOSGViewer(); - MujocoOSGViewer(osg::Vec3, osg::Vec3); - MujocoOSGViewer(int, int, osg::Vec3, osg::Vec3); - void Idle(); // Block and draw in a loop until the 'p' key is pressed - void RenderOnce(); - void HandleInput(); - void StartAsyncRendering(); - void StopAsyncRendering(); // - void SetModel(const mjModel*); - void SetData(const mjData*); - void _UpdateTransforms(); - void SetCamera(float x, float y, float z, float px, float py, float pz); - - // osg::ref_ptr m_handler; - mjData* m_data; - const mjModel* m_model; - osg::ref_ptr m_root, m_robot; - osg::ref_ptr m_image; - osgViewer::Viewer m_viewer; - std::vector m_geomTFs, m_axTFs; - osg::ref_ptr m_handler; -}; - - -void NewModelFromXML(const char* filename,mjModel*&); \ No newline at end of file diff --git a/src/3rdparty/mjcpy2/test_mujoco_osg.cpp b/src/3rdparty/mjcpy2/test_mujoco_osg.cpp deleted file mode 100644 index 5b0861f1b..000000000 --- a/src/3rdparty/mjcpy2/test_mujoco_osg.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "mujoco_osg_viewer.hpp" -#include "macros.h" - -int main(int argc, char** argv) { - if (argc != 2) { - printf("usage: test_mujoco_osg /path/to/file.xml\n"); - exit(1); - } - const char* fname = argv[1]; - - mjOption* option; - mjModel* model; - NewModelFromXML(fname, model, option); - mjData* data = mj_makeData(model, option); - if (!model) PRINT_AND_THROW("couldn't load model: " + std::string(fname)); - MujocoOSGViewer viewer; - viewer.SetModel(model); - viewer.SetData(data); - viewer.Idle(); - - while (true) { - mj_step(model, option, data); - viewer.SetData(data); - viewer.RenderOnce(); - OpenThreads::Thread::microSleep(30000); - } - -} From f00cc31e22435a0f052516a7fc32007c5e4cff16 Mon Sep 17 00:00:00 2001 From: Avi Singh Date: Wed, 2 Nov 2016 16:46:56 -0700 Subject: [PATCH 03/10] Port from mjcpy2 to mujoco_py --- python/gps/agent/mjc/agent_mjc.py | 182 ++++++++++++++++++++---------- 1 file changed, 122 insertions(+), 60 deletions(-) diff --git a/python/gps/agent/mjc/agent_mjc.py b/python/gps/agent/mjc/agent_mjc.py index bfc53747a..60a70eaa5 100755 --- a/python/gps/agent/mjc/agent_mjc.py +++ b/python/gps/agent/mjc/agent_mjc.py @@ -3,7 +3,9 @@ import numpy as np -import mjcpy +import mujoco_py +from mujoco_py.mjlib import mjlib +from mujoco_py.mjtypes import * from gps.agent.agent import Agent from gps.agent.agent_utils import generate_noise, setup @@ -45,30 +47,27 @@ def _setup_world(self, filename): Args: filename: Path to XML file containing the world information. """ - self._world = [] self._model = [] - - # Initialize Mujoco worlds. If there's only one xml file, create a single world object, + + # Initialize Mujoco models. If there's only one xml file, create a single model object, # otherwise create a different world for each condition. if not isinstance(filename, list): - world = mjcpy.MJCWorld(filename) - self._world = [world for _ in range(self._hyperparams['conditions'])] - self._model = [self._world[i].get_model().copy() - for i in range(self._hyperparams['conditions'])] + for i in range(self._hyperparams['conditions']): #the prev way of initalizing was not making deep copies + self._model.append(mujoco_py.MjModel(filename)) else: for i in range(self._hyperparams['conditions']): - self._world.append(mjcpy.MJCWorld(self._hyperparams['filename'][i])) - self._model.append(self._world[i].get_model()) - + self._model.append(mujoco_py.MjModel(self._hyperparams['filename'][i])) + for i in range(self._hyperparams['conditions']): + temp = copy.deepcopy(self._model[i].body_pos) for j in range(len(self._hyperparams['pos_body_idx'][i])): idx = self._hyperparams['pos_body_idx'][i][j] - # TODO: this should actually add [i][j], but that would break things - self._model[i]['body_pos'][idx, :] += \ - self._hyperparams['pos_body_offset'][i] + temp[idx, :] = temp[idx, :] + self._hyperparams['pos_body_offset'][i][j] #TODO should be [i][j] + self._model[i].body_pos = temp + self._model[i].step() - self._joint_idx = list(range(self._model[0]['nq'])) - self._vel_idx = [i + self._model[0]['nq'] for i in self._joint_idx] + self._joint_idx = list(range(self._model[0].nq)) + self._vel_idx = [i + self._model[0].nq for i in self._joint_idx] # Initialize x0. self.x0 = [] @@ -76,13 +75,13 @@ def _setup_world(self, filename): if END_EFFECTOR_POINTS in self.x_data_types: # TODO: this assumes END_EFFECTOR_VELOCITIES is also in datapoints right? self._init(i) - eepts = self._world[i].get_data()['site_xpos'].flatten() + eepts = self._model[i].data.site_xpos.flatten() self.x0.append( np.concatenate([self._hyperparams['x0'][i], eepts, np.zeros_like(eepts)]) ) elif END_EFFECTOR_POINTS_NO_TARGET in self.x_data_types: self._init(i) - eepts = self._world[i].get_data()['site_xpos'].flatten() + eepts = self._model[i].data.site_xpos.flatten() eepts_notgt = np.delete(eepts, self._hyperparams['target_idx']) self.x0.append( np.concatenate([self._hyperparams['x0'][i], eepts_notgt, np.zeros_like(eepts_notgt)]) @@ -92,12 +91,38 @@ def _setup_world(self, filename): if IMAGE_FEAT in self.x_data_types: self.x0[i] = np.concatenate([self.x0[i], np.zeros((self._hyperparams['sensor_dims'][IMAGE_FEAT],))]) + cam_pos = self._hyperparams['camera_pos'] - for i in range(self._hyperparams['conditions']): - self._world[i].init_viewer(AGENT_MUJOCO['image_width'], - AGENT_MUJOCO['image_height'], - cam_pos[0], cam_pos[1], cam_pos[2], - cam_pos[3], cam_pos[4], cam_pos[5]) + + self._viewer_main = mujoco_py.MjViewer(visible=True, init_width=AGENT_MUJOCO['image_width'], + init_height=AGENT_MUJOCO['image_height']) + #self._viewer_main.start() + + if RGB_IMAGE in self.obs_data_types or CONTEXT_IMAGE in self.obs_data_types: + self._viewer_bot = mujoco_py.MjViewer(visible=True, init_width=AGENT_MUJOCO['image_width'], + init_height=AGENT_MUJOCO['image_height']) + self._viewer_bot.start() + + if RGB_IMAGE in self.obs_data_types or CONTEXT_IMAGE in self.obs_data_types: + self._viewer = [] + for i in range(self._hyperparams['conditions']): + self._viewer.append(mujoco_py.MjViewer(visible=True, + init_width=self._hyperparams['image_width'], init_height=self._hyperparams['image_height'])) + for i in range(self._hyperparams['conditions']): + self._viewer[i].start() + self._viewer[i].set_model(self._model[i]) + + for j in range(3): + self._viewer[i].cam.lookat[j] = cam_pos[j] + self._viewer[i].cam.distance = cam_pos[3] + self._viewer[i].cam.elevation = cam_pos[4] + self._viewer[i].cam.azimuth = cam_pos[5] + self._viewer[i].cam.trackbodyid = -1 + + for j in range(5): + self._viewer[i].render() + + def sample(self, policy, condition, verbose=True, save=True, noisy=True): """ @@ -115,6 +140,7 @@ def sample(self, policy, condition, verbose=True, save=True, noisy=True): if 'get_features' in dir(policy): feature_fn = policy.get_features new_sample = self._init_sample(condition, feature_fn=feature_fn) + mj_X = self._hyperparams['x0'][condition] U = np.zeros([self.T, self.dU]) if noisy: @@ -130,8 +156,24 @@ def sample(self, policy, condition, verbose=True, save=True, noisy=True): for i in range(len(noisy_body_idx)): idx = noisy_body_idx[i] var = self._hyperparams['noisy_body_var'][condition][i] - self._model[condition]['body_pos'][idx, :] += \ - var * np.random.randn(1, 3) + temp = np.copy(self._model[condition].body_pos) + temp[idx, :] += var * np.random.randn(1, 3) + self._model[condition].body_pos = temp + + cam_pos = self._hyperparams['camera_pos'] + if not self._viewer_main.running: + self._viewer_main.start() + self._viewer_main.set_model(self._model[condition]) + + if RGB_IMAGE in self.obs_data_types or CONTEXT_IMAGE in self.obs_data_types: + self._viewer_bot.set_model(self._model[condition]) + for i in range(3): + self._viewer_bot.cam.lookat[i] = cam_pos[i] + self._viewer_bot.cam.distance = cam_pos[3] + self._viewer_bot.cam.elevation = cam_pos[4] + self._viewer_bot.cam.azimuth = cam_pos[5] + self._viewer_bot.cam.trackbodyid = -1 + # Take the sample. for t in range(self.T): X_t = new_sample.get_X(t=t) @@ -139,16 +181,23 @@ def sample(self, policy, condition, verbose=True, save=True, noisy=True): mj_U = policy.act(X_t, obs_t, t, noise[t, :]) U[t, :] = mj_U if verbose: - self._world[condition].plot(mj_X) + self._viewer_main.loop_once() + if RGB_IMAGE in self.obs_data_types or CONTEXT_IMAGE in self.obs_data_types: + self._viewer_bot.loop_once() + self._viewer[condition].loop_once() + if (t + 1) < self.T: for _ in range(self._hyperparams['substeps']): - mj_X, _ = self._world[condition].step(mj_X, mj_U) + self._model[condition].data.ctrl = mj_U + self._model[condition].step() #TODO: Some hidden state stuff will go here. - self._data = self._world[condition].get_data() + mj_X = np.concatenate([self._model[condition].data.qpos, self._model[condition].data.qvel]).flatten() + self._data = self._model[condition].data self._set_sample(new_sample, mj_X, t, condition, feature_fn=feature_fn) new_sample.set(ACTION, U) if save: self._samples[condition].append(new_sample) + return new_sample def _init(self, condition): @@ -159,19 +208,20 @@ def _init(self, condition): """ # Initialize world/run kinematics - self._world[condition].set_model(self._model[condition]) x0 = self._hyperparams['x0'][condition] idx = len(x0) // 2 - data = {'qpos': x0[:idx], 'qvel': x0[idx:]} - self._world[condition].set_data(data) - self._world[condition].kinematics() - + self._model[condition].data.qpos = x0[:idx] + self._model[condition].data.qvel = x0[idx:] + mjlib.mj_kinematics(self._model[condition].ptr, self._model[condition].data.ptr) + mjlib.mj_comPos(self._model[condition].ptr, self._model[condition].data.ptr) + mjlib.mj_tendon(self._model[condition].ptr, self._model[condition].data.ptr) + mjlib.mj_transmission(self._model[condition].ptr, self._model[condition].data.ptr) + def _init_sample(self, condition, feature_fn=None): """ Construct a new sample and fill in the first time step. Args: condition: Which condition to initialize. - feature_fn: funciton to comptue image features from the observation. """ sample = Sample(self) @@ -179,10 +229,10 @@ def _init_sample(self, condition, feature_fn=None): self._init(condition) # Initialize sample with stuff from _data - data = self._world[condition].get_data() - sample.set(JOINT_ANGLES, data['qpos'].flatten(), t=0) - sample.set(JOINT_VELOCITIES, data['qvel'].flatten(), t=0) - eepts = data['site_xpos'].flatten() + data = self._model[condition].data + sample.set(JOINT_ANGLES, data.qpos.flatten(), t=0) + sample.set(JOINT_VELOCITIES, data.qvel.flatten(), t=0) + eepts = data.site_xpos.flatten() sample.set(END_EFFECTOR_POINTS, eepts, t=0) sample.set(END_EFFECTOR_POINT_VELOCITIES, np.zeros_like(eepts), t=0) @@ -190,24 +240,31 @@ def _init_sample(self, condition, feature_fn=None): sample.set(END_EFFECTOR_POINTS_NO_TARGET, np.delete(eepts, self._hyperparams['target_idx']), t=0) sample.set(END_EFFECTOR_POINT_VELOCITIES_NO_TARGET, np.delete(np.zeros_like(eepts), self._hyperparams['target_idx']), t=0) - jac = np.zeros([eepts.shape[0], self._model[condition]['nq']]) + jac = np.zeros([eepts.shape[0], self._model[condition].nq]) for site in range(eepts.shape[0] // 3): idx = site * 3 - jac[idx:(idx+3), :] = self._world[condition].get_jac_site(site) + temp = np.zeros((3, jac.shape[1])) + mjlib.mj_jacSite(self._model[condition].ptr, self._model[condition].data.ptr, temp.ctypes.data_as(POINTER(c_double)), 0, site) + jac[idx:(idx+3), :] = temp sample.set(END_EFFECTOR_POINT_JACOBIANS, jac, t=0) # save initial image to meta data - self._world[condition].plot(self._hyperparams['x0'][condition]) - img = self._world[condition].get_image_scaled(self._hyperparams['image_width'], - self._hyperparams['image_height']) - # mjcpy image shape is [height, width, channels], - # dim-shuffle it for later conv-net processing, - # and flatten for storage - img_data = np.transpose(img["img"], (2, 1, 0)).flatten() + if RGB_IMAGE in self.obs_data_types or CONTEXT_IMAGE in self.obs_data_types: + img_string, width, height = self._viewer[condition].get_image() + img = np.fromstring(img_string, dtype='uint8').reshape(height, width, 3)[::-1,:,:] + img_data = img.flatten() + # if initial image is an observation, replicate it for each time step if CONTEXT_IMAGE in self.obs_data_types: sample.set(CONTEXT_IMAGE, np.tile(img_data, (self.T, 1)), t=None) else: + from scipy.misc import imresize + img_string, width, height = self._viewer_main.get_image() + img = np.fromstring(img_string, dtype='uint8').reshape(height, width, 3)[::-1,:,:] + img = imresize(img, (self._hyperparams['image_width'], + self._hyperparams['image_height']), + interp='bilinear') + img_data = img.flatten() sample.set(CONTEXT_IMAGE, img_data, t=None) sample.set(CONTEXT_IMAGE_SIZE, np.array([self._hyperparams['image_channels'], self._hyperparams['image_width'], @@ -218,6 +275,7 @@ def _init_sample(self, condition, feature_fn=None): sample.set(RGB_IMAGE_SIZE, [self._hyperparams['image_channels'], self._hyperparams['image_width'], self._hyperparams['image_height']], t=None) + if IMAGE_FEAT in self.obs_data_types: raise ValueError('Image features should not be in observation, just state') if feature_fn is not None: @@ -226,6 +284,7 @@ def _init_sample(self, condition, feature_fn=None): else: # TODO - need better solution than setting this to 0. sample.set(IMAGE_FEAT, np.zeros((self._hyperparams['sensor_dims'][IMAGE_FEAT],)), t=0) + return sample def _set_sample(self, sample, mj_X, t, condition, feature_fn=None): @@ -240,25 +299,28 @@ def _set_sample(self, sample, mj_X, t, condition, feature_fn=None): """ sample.set(JOINT_ANGLES, np.array(mj_X[self._joint_idx]), t=t+1) sample.set(JOINT_VELOCITIES, np.array(mj_X[self._vel_idx]), t=t+1) - cur_eepts = self._data['site_xpos'].flatten() - sample.set(END_EFFECTOR_POINTS, cur_eepts, t=t+1) + curr_eepts = self._data.site_xpos.flatten() + sample.set(END_EFFECTOR_POINTS, curr_eepts, t=t+1) prev_eepts = sample.get(END_EFFECTOR_POINTS, t=t) - eept_vels = (cur_eepts - prev_eepts) / self._hyperparams['dt'] + eept_vels = (curr_eepts - prev_eepts) / self._hyperparams['dt'] sample.set(END_EFFECTOR_POINT_VELOCITIES, eept_vels, t=t+1) + jac = np.zeros([curr_eepts.shape[0], self._model[condition].nq]) + for site in range(curr_eepts.shape[0] // 3): + idx = site * 3 + temp = np.zeros((3, jac.shape[1])) + mjlib.mj_jacSite(self._model[condition].ptr, self._model[condition].data.ptr, temp.ctypes.data_as(POINTER(c_double)), 0, site) + jac[idx:(idx+3), :] = temp + + sample.set(END_EFFECTOR_POINT_JACOBIANS, jac, t=t+1) if (END_EFFECTOR_POINTS_NO_TARGET in self._hyperparams['obs_include']): - sample.set(END_EFFECTOR_POINTS_NO_TARGET, np.delete(cur_eepts, self._hyperparams['target_idx']), t=t+1) + sample.set(END_EFFECTOR_POINTS_NO_TARGET, np.delete(curr_eepts, self._hyperparams['target_idx']), t=t+1) sample.set(END_EFFECTOR_POINT_VELOCITIES_NO_TARGET, np.delete(eept_vels, self._hyperparams['target_idx']), t=t+1) - jac = np.zeros([cur_eepts.shape[0], self._model[condition]['nq']]) - for site in range(cur_eepts.shape[0] // 3): - idx = site * 3 - jac[idx:(idx+3), :] = self._world[condition].get_jac_site(site) - sample.set(END_EFFECTOR_POINT_JACOBIANS, jac, t=t+1) if RGB_IMAGE in self.obs_data_types: - img = self._world[condition].get_image_scaled(self._hyperparams['image_width'], - self._hyperparams['image_height']) - sample.set(RGB_IMAGE, np.transpose(img["img"], (2, 1, 0)).flatten(), t=t+1) + img_string, width, height = self._viewer[condition].get_image()#CHANGES + img = np.fromstring(img_string, dtype='uint8').reshape(height, width, 3)[::-1,:,:] + sample.set(RGB_IMAGE, img.flatten(), t=t+1) if feature_fn is not None: obs = sample.get_obs() # Assumes that the rest of the observation has been populated sample.set(IMAGE_FEAT, feature_fn(obs), t=t+1) @@ -281,4 +343,4 @@ def _get_image_from_obs(self, obs): imstart += self._hyperparams['sensor_dims'][sensor] img = obs[imstart:imend] img = img.reshape((image_width, image_height, image_channels)) - return img + return img \ No newline at end of file From c14d9b4b6b91f2baa20e6958a147bc4eeaf98682 Mon Sep 17 00:00:00 2001 From: Avi Singh Date: Wed, 2 Nov 2016 16:47:42 -0700 Subject: [PATCH 04/10] Modified reacher task for mujoco_py --- experiments/reacher_images/hyperparams.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/experiments/reacher_images/hyperparams.py b/experiments/reacher_images/hyperparams.py index d400e01e5..ff6979ed7 100644 --- a/experiments/reacher_images/hyperparams.py +++ b/experiments/reacher_images/hyperparams.py @@ -56,7 +56,7 @@ np.random.seed(14) pos_body_offset = [] for _ in range(CONDITIONS): - pos_body_offset.append(np.array([0.4*np.random.rand()-0.3, 0.4*np.random.rand()-0.1, 0])) + pos_body_offset.append([np.array([0.4*np.random.rand()-0.3, 0.4*np.random.rand()-0.1, 0])]) common = { 'experiment_name': 'my_experiment' + '_' + \ @@ -92,7 +92,8 @@ 'image_height': IMAGE_HEIGHT, 'image_channels': IMAGE_CHANNELS, 'sensor_dims': SENSOR_DIMS, - 'camera_pos': np.array([0., 0., 1.5, 0., 0., 0.]), + #'camera_pos': np.array([0., 0., 1.5, 0., 0., 0.]), + 'camera_pos': np.array([0., 0., 0., 1., -90., 90.]), 'record_reward': True, } @@ -110,7 +111,7 @@ 'plot_dir': EXP_DIR, 'agent_pos_body_idx': agent['pos_body_idx'], 'agent_pos_body_offset': agent['pos_body_offset'], - 'target_end_effector': [np.concatenate([np.array([.1, -.1, .01])+ agent['pos_body_offset'][i], np.array([0., 0., 0.])]) + 'target_end_effector': [np.concatenate([np.array([.1, -.1, .01])+ agent['pos_body_offset'][i][0], np.array([0., 0., 0.])]) for i in xrange(CONDITIONS)], } @@ -149,7 +150,7 @@ fk_cost_1 = [{ 'type': CostFK, - 'target_end_effector': np.concatenate([np.array([.1, -.1, .01])+ agent['pos_body_offset'][i], np.array([0., 0., 0.])]), + 'target_end_effector': np.concatenate([np.array([.1, -.1, .01])+ agent['pos_body_offset'][i][0], np.array([0., 0., 0.])]), 'wp': np.array([1, 1, 1, 0, 0, 0]), 'l1': 1.0, 'l2': 0.0, @@ -160,7 +161,7 @@ algorithm['cost'] = [{ 'type': CostSum, 'costs': [torque_cost_1[i], fk_cost_1[i]], - 'weights': [2.0, 1.0], + 'weights': [20.0, 1.0], } for i in range(common['conditions'])] algorithm['dynamics'] = { From 3c0b3d860e1134753fcc6d9e7187348cc98019b1 Mon Sep 17 00:00:00 2001 From: Avi Singh Date: Wed, 2 Nov 2016 17:32:02 -0700 Subject: [PATCH 05/10] Add light to reacher and pr2_arm3d --- mjc_models/pr2_arm3d.xml | 1 + mjc_models/reacher.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/mjc_models/pr2_arm3d.xml b/mjc_models/pr2_arm3d.xml index a7afea672..bb467967c 100644 --- a/mjc_models/pr2_arm3d.xml +++ b/mjc_models/pr2_arm3d.xml @@ -8,6 +8,7 @@ + diff --git a/mjc_models/reacher.xml b/mjc_models/reacher.xml index 658f4ebd0..6559e15df 100644 --- a/mjc_models/reacher.xml +++ b/mjc_models/reacher.xml @@ -6,6 +6,7 @@