xcoll 0.3.6__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +13 -4
- xcoll/beam_elements/__init__.py +14 -6
- xcoll/beam_elements/absorber.py +41 -7
- xcoll/beam_elements/base.py +1202 -247
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/elements_src/black_absorber.h +136 -0
- xcoll/beam_elements/elements_src/black_crystal.h +129 -0
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
- xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
- xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
- xcoll/beam_elements/everest.py +65 -119
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +276 -747
- xcoll/general.py +5 -5
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +2 -2
- xcoll/initial_distribution.py +207 -0
- xcoll/install.py +179 -0
- xcoll/interaction_record/__init__.py +1 -0
- xcoll/interaction_record/interaction_record.py +298 -0
- xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
- xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
- xcoll/line_tools.py +82 -0
- xcoll/lossmap.py +219 -0
- xcoll/manager.py +2 -937
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +232 -0
- xcoll/scattering_routines/everest/channeling.h +240 -0
- xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
- xcoll/scattering_routines/everest/everest.h +11 -30
- xcoll/scattering_routines/everest/everest.py +13 -10
- xcoll/scattering_routines/everest/jaw.h +28 -197
- xcoll/scattering_routines/everest/materials.py +37 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
- xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/__init__.py +6 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
- xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
- xcoll/scattering_routines/geometry/geometry.py +26 -0
- xcoll/scattering_routines/geometry/get_s.h +92 -0
- xcoll/scattering_routines/geometry/methods.h +111 -0
- xcoll/scattering_routines/geometry/objects.h +154 -0
- xcoll/scattering_routines/geometry/rotation.h +23 -0
- xcoll/scattering_routines/geometry/segments.h +226 -0
- xcoll/scattering_routines/geometry/sort.h +184 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/beam_elements/collimators_src/absorber.h +0 -141
- xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
- xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
- xcoll/collimator_settings.py +0 -457
- xcoll/impacts/__init__.py +0 -1
- xcoll/impacts/impacts.py +0 -102
- xcoll/impacts/impacts_src/impacts.h +0 -99
- xcoll/scattering_routines/everest/crystal.h +0 -1302
- xcoll/scattering_routines/everest/scatter.h +0 -169
- xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.3.6.dist-info/RECORD +0 -111
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line.
|
|
5
|
+
SPHINXOPTS =
|
|
6
|
+
SPHINXBUILD = sphinx-build
|
|
7
|
+
PAPER =
|
|
8
|
+
BUILDDIR = .build
|
|
9
|
+
|
|
10
|
+
# User-friendly check for sphinx-build
|
|
11
|
+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
|
12
|
+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
|
13
|
+
endif
|
|
14
|
+
|
|
15
|
+
# Internal variables.
|
|
16
|
+
PAPEROPT_a4 = -D latex_paper_size=a4
|
|
17
|
+
PAPEROPT_letter = -D latex_paper_size=letter
|
|
18
|
+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|
19
|
+
# the i18n builder cannot share the environment and doctrees with the others
|
|
20
|
+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|
21
|
+
|
|
22
|
+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
|
|
23
|
+
|
|
24
|
+
help:
|
|
25
|
+
@echo "Please use \`make <target>' where <target> is one of"
|
|
26
|
+
@echo " html to make standalone HTML files"
|
|
27
|
+
@echo " dirhtml to make HTML files named index.html in directories"
|
|
28
|
+
@echo " singlehtml to make a single large HTML file"
|
|
29
|
+
@echo " pickle to make pickle files"
|
|
30
|
+
@echo " json to make JSON files"
|
|
31
|
+
@echo " htmlhelp to make HTML files and a HTML help project"
|
|
32
|
+
@echo " qthelp to make HTML files and a qthelp project"
|
|
33
|
+
@echo " applehelp to make an Apple Help Book"
|
|
34
|
+
@echo " devhelp to make HTML files and a Devhelp project"
|
|
35
|
+
@echo " epub to make an epub"
|
|
36
|
+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
|
37
|
+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
|
38
|
+
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
|
39
|
+
@echo " text to make text files"
|
|
40
|
+
@echo " man to make manual pages"
|
|
41
|
+
@echo " texinfo to make Texinfo files"
|
|
42
|
+
@echo " info to make Texinfo files and run them through makeinfo"
|
|
43
|
+
@echo " gettext to make PO message catalogs"
|
|
44
|
+
@echo " changes to make an overview of all changed/added/deprecated items"
|
|
45
|
+
@echo " xml to make Docutils-native XML files"
|
|
46
|
+
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
|
47
|
+
@echo " linkcheck to check all external links for integrity"
|
|
48
|
+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
|
49
|
+
@echo " coverage to run coverage check of the documentation (if enabled)"
|
|
50
|
+
|
|
51
|
+
clean:
|
|
52
|
+
rm -rf $(BUILDDIR)/*
|
|
53
|
+
|
|
54
|
+
html:
|
|
55
|
+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
|
56
|
+
@echo
|
|
57
|
+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
|
58
|
+
|
|
59
|
+
dirhtml:
|
|
60
|
+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
|
61
|
+
@echo
|
|
62
|
+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
|
63
|
+
|
|
64
|
+
singlehtml:
|
|
65
|
+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
|
66
|
+
@echo
|
|
67
|
+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
|
68
|
+
|
|
69
|
+
pickle:
|
|
70
|
+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
|
71
|
+
@echo
|
|
72
|
+
@echo "Build finished; now you can process the pickle files."
|
|
73
|
+
|
|
74
|
+
json:
|
|
75
|
+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
|
76
|
+
@echo
|
|
77
|
+
@echo "Build finished; now you can process the JSON files."
|
|
78
|
+
|
|
79
|
+
htmlhelp:
|
|
80
|
+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
|
81
|
+
@echo
|
|
82
|
+
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
|
83
|
+
".hhp project file in $(BUILDDIR)/htmlhelp."
|
|
84
|
+
|
|
85
|
+
qthelp:
|
|
86
|
+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
|
87
|
+
@echo
|
|
88
|
+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
|
89
|
+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
|
90
|
+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pybind11.qhcp"
|
|
91
|
+
@echo "To view the help file:"
|
|
92
|
+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pybind11.qhc"
|
|
93
|
+
|
|
94
|
+
applehelp:
|
|
95
|
+
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
|
96
|
+
@echo
|
|
97
|
+
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
|
|
98
|
+
@echo "N.B. You won't be able to view it unless you put it in" \
|
|
99
|
+
"~/Library/Documentation/Help or install it in your application" \
|
|
100
|
+
"bundle."
|
|
101
|
+
|
|
102
|
+
devhelp:
|
|
103
|
+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
|
104
|
+
@echo
|
|
105
|
+
@echo "Build finished."
|
|
106
|
+
@echo "To view the help file:"
|
|
107
|
+
@echo "# mkdir -p $$HOME/.local/share/devhelp/pybind11"
|
|
108
|
+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pybind11"
|
|
109
|
+
@echo "# devhelp"
|
|
110
|
+
|
|
111
|
+
epub:
|
|
112
|
+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
|
113
|
+
@echo
|
|
114
|
+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
|
115
|
+
|
|
116
|
+
latex:
|
|
117
|
+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
118
|
+
@echo
|
|
119
|
+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
|
120
|
+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
|
121
|
+
"(use \`make latexpdf' here to do that automatically)."
|
|
122
|
+
|
|
123
|
+
latexpdf:
|
|
124
|
+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
125
|
+
@echo "Running LaTeX files through pdflatex..."
|
|
126
|
+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
|
127
|
+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
|
128
|
+
|
|
129
|
+
latexpdfja:
|
|
130
|
+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
131
|
+
@echo "Running LaTeX files through platex and dvipdfmx..."
|
|
132
|
+
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
|
133
|
+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
|
134
|
+
|
|
135
|
+
text:
|
|
136
|
+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
|
137
|
+
@echo
|
|
138
|
+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
|
139
|
+
|
|
140
|
+
man:
|
|
141
|
+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
|
142
|
+
@echo
|
|
143
|
+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
|
144
|
+
|
|
145
|
+
texinfo:
|
|
146
|
+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
147
|
+
@echo
|
|
148
|
+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
|
149
|
+
@echo "Run \`make' in that directory to run these through makeinfo" \
|
|
150
|
+
"(use \`make info' here to do that automatically)."
|
|
151
|
+
|
|
152
|
+
info:
|
|
153
|
+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
154
|
+
@echo "Running Texinfo files through makeinfo..."
|
|
155
|
+
make -C $(BUILDDIR)/texinfo info
|
|
156
|
+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
|
157
|
+
|
|
158
|
+
gettext:
|
|
159
|
+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
|
160
|
+
@echo
|
|
161
|
+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
|
162
|
+
|
|
163
|
+
changes:
|
|
164
|
+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
|
165
|
+
@echo
|
|
166
|
+
@echo "The overview file is in $(BUILDDIR)/changes."
|
|
167
|
+
|
|
168
|
+
linkcheck:
|
|
169
|
+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
|
170
|
+
@echo
|
|
171
|
+
@echo "Link check complete; look for any errors in the above output " \
|
|
172
|
+
"or in $(BUILDDIR)/linkcheck/output.txt."
|
|
173
|
+
|
|
174
|
+
doctest:
|
|
175
|
+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
|
176
|
+
@echo "Testing of doctests in the sources finished, look at the " \
|
|
177
|
+
"results in $(BUILDDIR)/doctest/output.txt."
|
|
178
|
+
|
|
179
|
+
coverage:
|
|
180
|
+
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
|
|
181
|
+
@echo "Testing of coverage in the sources finished, look at the " \
|
|
182
|
+
"results in $(BUILDDIR)/coverage/python.txt."
|
|
183
|
+
|
|
184
|
+
xml:
|
|
185
|
+
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
|
186
|
+
@echo
|
|
187
|
+
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
|
188
|
+
|
|
189
|
+
pseudoxml:
|
|
190
|
+
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
|
191
|
+
@echo
|
|
192
|
+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.wy-table-responsive table td,
|
|
2
|
+
.wy-table-responsive table th {
|
|
3
|
+
white-space: initial !important;
|
|
4
|
+
}
|
|
5
|
+
.rst-content table.docutils td {
|
|
6
|
+
vertical-align: top !important;
|
|
7
|
+
}
|
|
8
|
+
div[class^='highlight'] pre {
|
|
9
|
+
white-space: pre;
|
|
10
|
+
white-space: pre-wrap;
|
|
11
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Chrono
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
When including the additional header file :file:`pybind11/chrono.h` conversions
|
|
5
|
+
from C++11 chrono datatypes to python datetime objects are automatically enabled.
|
|
6
|
+
This header also enables conversions of python floats (often from sources such
|
|
7
|
+
as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``)
|
|
8
|
+
into durations.
|
|
9
|
+
|
|
10
|
+
An overview of clocks in C++11
|
|
11
|
+
------------------------------
|
|
12
|
+
|
|
13
|
+
A point of confusion when using these conversions is the differences between
|
|
14
|
+
clocks provided in C++11. There are three clock types defined by the C++11
|
|
15
|
+
standard and users can define their own if needed. Each of these clocks have
|
|
16
|
+
different properties and when converting to and from python will give different
|
|
17
|
+
results.
|
|
18
|
+
|
|
19
|
+
The first clock defined by the standard is ``std::chrono::system_clock``. This
|
|
20
|
+
clock measures the current date and time. However, this clock changes with to
|
|
21
|
+
updates to the operating system time. For example, if your time is synchronised
|
|
22
|
+
with a time server this clock will change. This makes this clock a poor choice
|
|
23
|
+
for timing purposes but good for measuring the wall time.
|
|
24
|
+
|
|
25
|
+
The second clock defined in the standard is ``std::chrono::steady_clock``.
|
|
26
|
+
This clock ticks at a steady rate and is never adjusted. This makes it excellent
|
|
27
|
+
for timing purposes, however the value in this clock does not correspond to the
|
|
28
|
+
current date and time. Often this clock will be the amount of time your system
|
|
29
|
+
has been on, although it does not have to be. This clock will never be the same
|
|
30
|
+
clock as the system clock as the system clock can change but steady clocks
|
|
31
|
+
cannot.
|
|
32
|
+
|
|
33
|
+
The third clock defined in the standard is ``std::chrono::high_resolution_clock``.
|
|
34
|
+
This clock is the clock that has the highest resolution out of the clocks in the
|
|
35
|
+
system. It is normally a typedef to either the system clock or the steady clock
|
|
36
|
+
but can be its own independent clock. This is important as when using these
|
|
37
|
+
conversions as the types you get in python for this clock might be different
|
|
38
|
+
depending on the system.
|
|
39
|
+
If it is a typedef of the system clock, python will get datetime objects, but if
|
|
40
|
+
it is a different clock they will be timedelta objects.
|
|
41
|
+
|
|
42
|
+
Provided conversions
|
|
43
|
+
--------------------
|
|
44
|
+
|
|
45
|
+
.. rubric:: C++ to Python
|
|
46
|
+
|
|
47
|
+
- ``std::chrono::system_clock::time_point`` → ``datetime.datetime``
|
|
48
|
+
System clock times are converted to python datetime instances. They are
|
|
49
|
+
in the local timezone, but do not have any timezone information attached
|
|
50
|
+
to them (they are naive datetime objects).
|
|
51
|
+
|
|
52
|
+
- ``std::chrono::duration`` → ``datetime.timedelta``
|
|
53
|
+
Durations are converted to timedeltas, any precision in the duration
|
|
54
|
+
greater than microseconds is lost by rounding towards zero.
|
|
55
|
+
|
|
56
|
+
- ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta``
|
|
57
|
+
Any clock time that is not the system clock is converted to a time delta.
|
|
58
|
+
This timedelta measures the time from the clocks epoch to now.
|
|
59
|
+
|
|
60
|
+
.. rubric:: Python to C++
|
|
61
|
+
|
|
62
|
+
- ``datetime.datetime`` or ``datetime.date`` or ``datetime.time`` → ``std::chrono::system_clock::time_point``
|
|
63
|
+
Date/time objects are converted into system clock timepoints. Any
|
|
64
|
+
timezone information is ignored and the type is treated as a naive
|
|
65
|
+
object.
|
|
66
|
+
|
|
67
|
+
- ``datetime.timedelta`` → ``std::chrono::duration``
|
|
68
|
+
Time delta are converted into durations with microsecond precision.
|
|
69
|
+
|
|
70
|
+
- ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point``
|
|
71
|
+
Time deltas that are converted into clock timepoints are treated as
|
|
72
|
+
the amount of time from the start of the clocks epoch.
|
|
73
|
+
|
|
74
|
+
- ``float`` → ``std::chrono::duration``
|
|
75
|
+
Floats that are passed to C++ as durations be interpreted as a number of
|
|
76
|
+
seconds. These will be converted to the duration using ``duration_cast``
|
|
77
|
+
from the float.
|
|
78
|
+
|
|
79
|
+
- ``float`` → ``std::chrono::[other_clocks]::time_point``
|
|
80
|
+
Floats that are passed to C++ as time points will be interpreted as the
|
|
81
|
+
number of seconds from the start of the clocks epoch.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Custom type casters
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
In very rare cases, applications may require custom type casters that cannot be
|
|
5
|
+
expressed using the abstractions provided by pybind11, thus requiring raw
|
|
6
|
+
Python C API calls. This is fairly advanced usage and should only be pursued by
|
|
7
|
+
experts who are familiar with the intricacies of Python reference counting.
|
|
8
|
+
|
|
9
|
+
The following snippets demonstrate how this works for a very simple ``inty``
|
|
10
|
+
type that that should be convertible from Python types that provide a
|
|
11
|
+
``__int__(self)`` method.
|
|
12
|
+
|
|
13
|
+
.. code-block:: cpp
|
|
14
|
+
|
|
15
|
+
struct inty { long long_value; };
|
|
16
|
+
|
|
17
|
+
void print(inty s) {
|
|
18
|
+
std::cout << s.long_value << std::endl;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
The following Python snippet demonstrates the intended usage from the Python side:
|
|
22
|
+
|
|
23
|
+
.. code-block:: python
|
|
24
|
+
|
|
25
|
+
class A:
|
|
26
|
+
def __int__(self):
|
|
27
|
+
return 123
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
from example import print
|
|
31
|
+
|
|
32
|
+
print(A())
|
|
33
|
+
|
|
34
|
+
To register the necessary conversion routines, it is necessary to add an
|
|
35
|
+
instantiation of the ``pybind11::detail::type_caster<T>`` template.
|
|
36
|
+
Although this is an implementation detail, adding an instantiation of this
|
|
37
|
+
type is explicitly allowed.
|
|
38
|
+
|
|
39
|
+
.. code-block:: cpp
|
|
40
|
+
|
|
41
|
+
namespace pybind11 { namespace detail {
|
|
42
|
+
template <> struct type_caster<inty> {
|
|
43
|
+
public:
|
|
44
|
+
/**
|
|
45
|
+
* This macro establishes the name 'inty' in
|
|
46
|
+
* function signatures and declares a local variable
|
|
47
|
+
* 'value' of type inty
|
|
48
|
+
*/
|
|
49
|
+
PYBIND11_TYPE_CASTER(inty, _("inty"));
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Conversion part 1 (Python->C++): convert a PyObject into a inty
|
|
53
|
+
* instance or return false upon failure. The second argument
|
|
54
|
+
* indicates whether implicit conversions should be applied.
|
|
55
|
+
*/
|
|
56
|
+
bool load(handle src, bool) {
|
|
57
|
+
/* Extract PyObject from handle */
|
|
58
|
+
PyObject *source = src.ptr();
|
|
59
|
+
/* Try converting into a Python integer value */
|
|
60
|
+
PyObject *tmp = PyNumber_Long(source);
|
|
61
|
+
if (!tmp)
|
|
62
|
+
return false;
|
|
63
|
+
/* Now try to convert into a C++ int */
|
|
64
|
+
value.long_value = PyLong_AsLong(tmp);
|
|
65
|
+
Py_DECREF(tmp);
|
|
66
|
+
/* Ensure return code was OK (to avoid out-of-range errors etc) */
|
|
67
|
+
return !(value.long_value == -1 && !PyErr_Occurred());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Conversion part 2 (C++ -> Python): convert an inty instance into
|
|
72
|
+
* a Python object. The second and third arguments are used to
|
|
73
|
+
* indicate the return value policy and parent object (for
|
|
74
|
+
* ``return_value_policy::reference_internal``) and are generally
|
|
75
|
+
* ignored by implicit casters.
|
|
76
|
+
*/
|
|
77
|
+
static handle cast(inty src, return_value_policy /* policy */, handle /* parent */) {
|
|
78
|
+
return PyLong_FromLong(src.long_value);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}} // namespace pybind11::detail
|
|
82
|
+
|
|
83
|
+
.. note::
|
|
84
|
+
|
|
85
|
+
A ``type_caster<T>`` defined with ``PYBIND11_TYPE_CASTER(T, ...)`` requires
|
|
86
|
+
that ``T`` is default-constructible (``value`` is first default constructed
|
|
87
|
+
and then ``load()`` assigns to it).
|
|
88
|
+
|
|
89
|
+
.. warning::
|
|
90
|
+
|
|
91
|
+
When using custom type casters, it's important to declare them consistently
|
|
92
|
+
in every compilation unit of the Python extension module. Otherwise,
|
|
93
|
+
undefined behavior can ensue.
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
Eigen
|
|
2
|
+
#####
|
|
3
|
+
|
|
4
|
+
`Eigen <http://eigen.tuxfamily.org>`_ is C++ header-based library for dense and
|
|
5
|
+
sparse linear algebra. Due to its popularity and widespread adoption, pybind11
|
|
6
|
+
provides transparent conversion and limited mapping support between Eigen and
|
|
7
|
+
Scientific Python linear algebra data types.
|
|
8
|
+
|
|
9
|
+
To enable the built-in Eigen support you must include the optional header file
|
|
10
|
+
:file:`pybind11/eigen.h`.
|
|
11
|
+
|
|
12
|
+
Pass-by-value
|
|
13
|
+
=============
|
|
14
|
+
|
|
15
|
+
When binding a function with ordinary Eigen dense object arguments (for
|
|
16
|
+
example, ``Eigen::MatrixXd``), pybind11 will accept any input value that is
|
|
17
|
+
already (or convertible to) a ``numpy.ndarray`` with dimensions compatible with
|
|
18
|
+
the Eigen type, copy its values into a temporary Eigen variable of the
|
|
19
|
+
appropriate type, then call the function with this temporary variable.
|
|
20
|
+
|
|
21
|
+
Sparse matrices are similarly copied to or from
|
|
22
|
+
``scipy.sparse.csr_matrix``/``scipy.sparse.csc_matrix`` objects.
|
|
23
|
+
|
|
24
|
+
Pass-by-reference
|
|
25
|
+
=================
|
|
26
|
+
|
|
27
|
+
One major limitation of the above is that every data conversion implicitly
|
|
28
|
+
involves a copy, which can be both expensive (for large matrices) and disallows
|
|
29
|
+
binding functions that change their (Matrix) arguments. Pybind11 allows you to
|
|
30
|
+
work around this by using Eigen's ``Eigen::Ref<MatrixType>`` class much as you
|
|
31
|
+
would when writing a function taking a generic type in Eigen itself (subject to
|
|
32
|
+
some limitations discussed below).
|
|
33
|
+
|
|
34
|
+
When calling a bound function accepting a ``Eigen::Ref<const MatrixType>``
|
|
35
|
+
type, pybind11 will attempt to avoid copying by using an ``Eigen::Map`` object
|
|
36
|
+
that maps into the source ``numpy.ndarray`` data: this requires both that the
|
|
37
|
+
data types are the same (e.g. ``dtype='float64'`` and ``MatrixType::Scalar`` is
|
|
38
|
+
``double``); and that the storage is layout compatible. The latter limitation
|
|
39
|
+
is discussed in detail in the section below, and requires careful
|
|
40
|
+
consideration: by default, numpy matrices and Eigen matrices are *not* storage
|
|
41
|
+
compatible.
|
|
42
|
+
|
|
43
|
+
If the numpy matrix cannot be used as is (either because its types differ, e.g.
|
|
44
|
+
passing an array of integers to an Eigen parameter requiring doubles, or
|
|
45
|
+
because the storage is incompatible), pybind11 makes a temporary copy and
|
|
46
|
+
passes the copy instead.
|
|
47
|
+
|
|
48
|
+
When a bound function parameter is instead ``Eigen::Ref<MatrixType>`` (note the
|
|
49
|
+
lack of ``const``), pybind11 will only allow the function to be called if it
|
|
50
|
+
can be mapped *and* if the numpy array is writeable (that is
|
|
51
|
+
``a.flags.writeable`` is true). Any access (including modification) made to
|
|
52
|
+
the passed variable will be transparently carried out directly on the
|
|
53
|
+
``numpy.ndarray``.
|
|
54
|
+
|
|
55
|
+
This means you can can write code such as the following and have it work as
|
|
56
|
+
expected:
|
|
57
|
+
|
|
58
|
+
.. code-block:: cpp
|
|
59
|
+
|
|
60
|
+
void scale_by_2(Eigen::Ref<Eigen::VectorXd> v) {
|
|
61
|
+
v *= 2;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Note, however, that you will likely run into limitations due to numpy and
|
|
65
|
+
Eigen's difference default storage order for data; see the below section on
|
|
66
|
+
:ref:`storage_orders` for details on how to bind code that won't run into such
|
|
67
|
+
limitations.
|
|
68
|
+
|
|
69
|
+
.. note::
|
|
70
|
+
|
|
71
|
+
Passing by reference is not supported for sparse types.
|
|
72
|
+
|
|
73
|
+
Returning values to Python
|
|
74
|
+
==========================
|
|
75
|
+
|
|
76
|
+
When returning an ordinary dense Eigen matrix type to numpy (e.g.
|
|
77
|
+
``Eigen::MatrixXd`` or ``Eigen::RowVectorXf``) pybind11 keeps the matrix and
|
|
78
|
+
returns a numpy array that directly references the Eigen matrix: no copy of the
|
|
79
|
+
data is performed. The numpy array will have ``array.flags.owndata`` set to
|
|
80
|
+
``False`` to indicate that it does not own the data, and the lifetime of the
|
|
81
|
+
stored Eigen matrix will be tied to the returned ``array``.
|
|
82
|
+
|
|
83
|
+
If you bind a function with a non-reference, ``const`` return type (e.g.
|
|
84
|
+
``const Eigen::MatrixXd``), the same thing happens except that pybind11 also
|
|
85
|
+
sets the numpy array's ``writeable`` flag to false.
|
|
86
|
+
|
|
87
|
+
If you return an lvalue reference or pointer, the usual pybind11 rules apply,
|
|
88
|
+
as dictated by the binding function's return value policy (see the
|
|
89
|
+
documentation on :ref:`return_value_policies` for full details). That means,
|
|
90
|
+
without an explicit return value policy, lvalue references will be copied and
|
|
91
|
+
pointers will be managed by pybind11. In order to avoid copying, you should
|
|
92
|
+
explicitly specify an appropriate return value policy, as in the following
|
|
93
|
+
example:
|
|
94
|
+
|
|
95
|
+
.. code-block:: cpp
|
|
96
|
+
|
|
97
|
+
class MyClass {
|
|
98
|
+
Eigen::MatrixXd big_mat = Eigen::MatrixXd::Zero(10000, 10000);
|
|
99
|
+
public:
|
|
100
|
+
Eigen::MatrixXd &getMatrix() { return big_mat; }
|
|
101
|
+
const Eigen::MatrixXd &viewMatrix() { return big_mat; }
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Later, in binding code:
|
|
105
|
+
py::class_<MyClass>(m, "MyClass")
|
|
106
|
+
.def(py::init<>())
|
|
107
|
+
.def("copy_matrix", &MyClass::getMatrix) // Makes a copy!
|
|
108
|
+
.def("get_matrix", &MyClass::getMatrix, py::return_value_policy::reference_internal)
|
|
109
|
+
.def("view_matrix", &MyClass::viewMatrix, py::return_value_policy::reference_internal)
|
|
110
|
+
;
|
|
111
|
+
|
|
112
|
+
.. code-block:: python
|
|
113
|
+
|
|
114
|
+
a = MyClass()
|
|
115
|
+
m = a.get_matrix() # flags.writeable = True, flags.owndata = False
|
|
116
|
+
v = a.view_matrix() # flags.writeable = False, flags.owndata = False
|
|
117
|
+
c = a.copy_matrix() # flags.writeable = True, flags.owndata = True
|
|
118
|
+
# m[5,6] and v[5,6] refer to the same element, c[5,6] does not.
|
|
119
|
+
|
|
120
|
+
Note in this example that ``py::return_value_policy::reference_internal`` is
|
|
121
|
+
used to tie the life of the MyClass object to the life of the returned arrays.
|
|
122
|
+
|
|
123
|
+
You may also return an ``Eigen::Ref``, ``Eigen::Map`` or other map-like Eigen
|
|
124
|
+
object (for example, the return value of ``matrix.block()`` and related
|
|
125
|
+
methods) that map into a dense Eigen type. When doing so, the default
|
|
126
|
+
behaviour of pybind11 is to simply reference the returned data: you must take
|
|
127
|
+
care to ensure that this data remains valid! You may ask pybind11 to
|
|
128
|
+
explicitly *copy* such a return value by using the
|
|
129
|
+
``py::return_value_policy::copy`` policy when binding the function. You may
|
|
130
|
+
also use ``py::return_value_policy::reference_internal`` or a
|
|
131
|
+
``py::keep_alive`` to ensure the data stays valid as long as the returned numpy
|
|
132
|
+
array does.
|
|
133
|
+
|
|
134
|
+
When returning such a reference of map, pybind11 additionally respects the
|
|
135
|
+
readonly-status of the returned value, marking the numpy array as non-writeable
|
|
136
|
+
if the reference or map was itself read-only.
|
|
137
|
+
|
|
138
|
+
.. note::
|
|
139
|
+
|
|
140
|
+
Sparse types are always copied when returned.
|
|
141
|
+
|
|
142
|
+
.. _storage_orders:
|
|
143
|
+
|
|
144
|
+
Storage orders
|
|
145
|
+
==============
|
|
146
|
+
|
|
147
|
+
Passing arguments via ``Eigen::Ref`` has some limitations that you must be
|
|
148
|
+
aware of in order to effectively pass matrices by reference. First and
|
|
149
|
+
foremost is that the default ``Eigen::Ref<MatrixType>`` class requires
|
|
150
|
+
contiguous storage along columns (for column-major types, the default in Eigen)
|
|
151
|
+
or rows if ``MatrixType`` is specifically an ``Eigen::RowMajor`` storage type.
|
|
152
|
+
The former, Eigen's default, is incompatible with ``numpy``'s default row-major
|
|
153
|
+
storage, and so you will not be able to pass numpy arrays to Eigen by reference
|
|
154
|
+
without making one of two changes.
|
|
155
|
+
|
|
156
|
+
(Note that this does not apply to vectors (or column or row matrices): for such
|
|
157
|
+
types the "row-major" and "column-major" distinction is meaningless).
|
|
158
|
+
|
|
159
|
+
The first approach is to change the use of ``Eigen::Ref<MatrixType>`` to the
|
|
160
|
+
more general ``Eigen::Ref<MatrixType, 0, Eigen::Stride<Eigen::Dynamic,
|
|
161
|
+
Eigen::Dynamic>>`` (or similar type with a fully dynamic stride type in the
|
|
162
|
+
third template argument). Since this is a rather cumbersome type, pybind11
|
|
163
|
+
provides a ``py::EigenDRef<MatrixType>`` type alias for your convenience (along
|
|
164
|
+
with EigenDMap for the equivalent Map, and EigenDStride for just the stride
|
|
165
|
+
type).
|
|
166
|
+
|
|
167
|
+
This type allows Eigen to map into any arbitrary storage order. This is not
|
|
168
|
+
the default in Eigen for performance reasons: contiguous storage allows
|
|
169
|
+
vectorization that cannot be done when storage is not known to be contiguous at
|
|
170
|
+
compile time. The default ``Eigen::Ref`` stride type allows non-contiguous
|
|
171
|
+
storage along the outer dimension (that is, the rows of a column-major matrix
|
|
172
|
+
or columns of a row-major matrix), but not along the inner dimension.
|
|
173
|
+
|
|
174
|
+
This type, however, has the added benefit of also being able to map numpy array
|
|
175
|
+
slices. For example, the following (contrived) example uses Eigen with a numpy
|
|
176
|
+
slice to multiply by 2 all coefficients that are both on even rows (0, 2, 4,
|
|
177
|
+
...) and in columns 2, 5, or 8:
|
|
178
|
+
|
|
179
|
+
.. code-block:: cpp
|
|
180
|
+
|
|
181
|
+
m.def("scale", [](py::EigenDRef<Eigen::MatrixXd> m, double c) { m *= c; });
|
|
182
|
+
|
|
183
|
+
.. code-block:: python
|
|
184
|
+
|
|
185
|
+
# a = np.array(...)
|
|
186
|
+
scale_by_2(myarray[0::2, 2:9:3])
|
|
187
|
+
|
|
188
|
+
The second approach to avoid copying is more intrusive: rearranging the
|
|
189
|
+
underlying data types to not run into the non-contiguous storage problem in the
|
|
190
|
+
first place. In particular, that means using matrices with ``Eigen::RowMajor``
|
|
191
|
+
storage, where appropriate, such as:
|
|
192
|
+
|
|
193
|
+
.. code-block:: cpp
|
|
194
|
+
|
|
195
|
+
using RowMatrixXd = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
|
196
|
+
// Use RowMatrixXd instead of MatrixXd
|
|
197
|
+
|
|
198
|
+
Now bound functions accepting ``Eigen::Ref<RowMatrixXd>`` arguments will be
|
|
199
|
+
callable with numpy's (default) arrays without involving a copying.
|
|
200
|
+
|
|
201
|
+
You can, alternatively, change the storage order that numpy arrays use by
|
|
202
|
+
adding the ``order='F'`` option when creating an array:
|
|
203
|
+
|
|
204
|
+
.. code-block:: python
|
|
205
|
+
|
|
206
|
+
myarray = np.array(source, order="F")
|
|
207
|
+
|
|
208
|
+
Such an object will be passable to a bound function accepting an
|
|
209
|
+
``Eigen::Ref<MatrixXd>`` (or similar column-major Eigen type).
|
|
210
|
+
|
|
211
|
+
One major caveat with this approach, however, is that it is not entirely as
|
|
212
|
+
easy as simply flipping all Eigen or numpy usage from one to the other: some
|
|
213
|
+
operations may alter the storage order of a numpy array. For example, ``a2 =
|
|
214
|
+
array.transpose()`` results in ``a2`` being a view of ``array`` that references
|
|
215
|
+
the same data, but in the opposite storage order!
|
|
216
|
+
|
|
217
|
+
While this approach allows fully optimized vectorized calculations in Eigen, it
|
|
218
|
+
cannot be used with array slices, unlike the first approach.
|
|
219
|
+
|
|
220
|
+
When *returning* a matrix to Python (either a regular matrix, a reference via
|
|
221
|
+
``Eigen::Ref<>``, or a map/block into a matrix), no special storage
|
|
222
|
+
consideration is required: the created numpy array will have the required
|
|
223
|
+
stride that allows numpy to properly interpret the array, whatever its storage
|
|
224
|
+
order.
|
|
225
|
+
|
|
226
|
+
Failing rather than copying
|
|
227
|
+
===========================
|
|
228
|
+
|
|
229
|
+
The default behaviour when binding ``Eigen::Ref<const MatrixType>`` Eigen
|
|
230
|
+
references is to copy matrix values when passed a numpy array that does not
|
|
231
|
+
conform to the element type of ``MatrixType`` or does not have a compatible
|
|
232
|
+
stride layout. If you want to explicitly avoid copying in such a case, you
|
|
233
|
+
should bind arguments using the ``py::arg().noconvert()`` annotation (as
|
|
234
|
+
described in the :ref:`nonconverting_arguments` documentation).
|
|
235
|
+
|
|
236
|
+
The following example shows an example of arguments that don't allow data
|
|
237
|
+
copying to take place:
|
|
238
|
+
|
|
239
|
+
.. code-block:: cpp
|
|
240
|
+
|
|
241
|
+
// The method and function to be bound:
|
|
242
|
+
class MyClass {
|
|
243
|
+
// ...
|
|
244
|
+
double some_method(const Eigen::Ref<const MatrixXd> &matrix) { /* ... */ }
|
|
245
|
+
};
|
|
246
|
+
float some_function(const Eigen::Ref<const MatrixXf> &big,
|
|
247
|
+
const Eigen::Ref<const MatrixXf> &small) {
|
|
248
|
+
// ...
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// The associated binding code:
|
|
252
|
+
using namespace pybind11::literals; // for "arg"_a
|
|
253
|
+
py::class_<MyClass>(m, "MyClass")
|
|
254
|
+
// ... other class definitions
|
|
255
|
+
.def("some_method", &MyClass::some_method, py::arg().noconvert());
|
|
256
|
+
|
|
257
|
+
m.def("some_function", &some_function,
|
|
258
|
+
"big"_a.noconvert(), // <- Don't allow copying for this arg
|
|
259
|
+
"small"_a // <- This one can be copied if needed
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
With the above binding code, attempting to call the the ``some_method(m)``
|
|
263
|
+
method on a ``MyClass`` object, or attempting to call ``some_function(m, m2)``
|
|
264
|
+
will raise a ``RuntimeError`` rather than making a temporary copy of the array.
|
|
265
|
+
It will, however, allow the ``m2`` argument to be copied into a temporary if
|
|
266
|
+
necessary.
|
|
267
|
+
|
|
268
|
+
Note that explicitly specifying ``.noconvert()`` is not required for *mutable*
|
|
269
|
+
Eigen references (e.g. ``Eigen::Ref<MatrixXd>`` without ``const`` on the
|
|
270
|
+
``MatrixXd``): mutable references will never be called with a temporary copy.
|
|
271
|
+
|
|
272
|
+
Vectors versus column/row matrices
|
|
273
|
+
==================================
|
|
274
|
+
|
|
275
|
+
Eigen and numpy have fundamentally different notions of a vector. In Eigen, a
|
|
276
|
+
vector is simply a matrix with the number of columns or rows set to 1 at
|
|
277
|
+
compile time (for a column vector or row vector, respectively). NumPy, in
|
|
278
|
+
contrast, has comparable 2-dimensional 1xN and Nx1 arrays, but *also* has
|
|
279
|
+
1-dimensional arrays of size N.
|
|
280
|
+
|
|
281
|
+
When passing a 2-dimensional 1xN or Nx1 array to Eigen, the Eigen type must
|
|
282
|
+
have matching dimensions: That is, you cannot pass a 2-dimensional Nx1 numpy
|
|
283
|
+
array to an Eigen value expecting a row vector, or a 1xN numpy array as a
|
|
284
|
+
column vector argument.
|
|
285
|
+
|
|
286
|
+
On the other hand, pybind11 allows you to pass 1-dimensional arrays of length N
|
|
287
|
+
as Eigen parameters. If the Eigen type can hold a column vector of length N it
|
|
288
|
+
will be passed as such a column vector. If not, but the Eigen type constraints
|
|
289
|
+
will accept a row vector, it will be passed as a row vector. (The column
|
|
290
|
+
vector takes precedence when both are supported, for example, when passing a
|
|
291
|
+
1D numpy array to a MatrixXd argument). Note that the type need not be
|
|
292
|
+
explicitly a vector: it is permitted to pass a 1D numpy array of size 5 to an
|
|
293
|
+
Eigen ``Matrix<double, Dynamic, 5>``: you would end up with a 1x5 Eigen matrix.
|
|
294
|
+
Passing the same to an ``Eigen::MatrixXd`` would result in a 5x1 Eigen matrix.
|
|
295
|
+
|
|
296
|
+
When returning an Eigen vector to numpy, the conversion is ambiguous: a row
|
|
297
|
+
vector of length 4 could be returned as either a 1D array of length 4, or as a
|
|
298
|
+
2D array of size 1x4. When encountering such a situation, pybind11 compromises
|
|
299
|
+
by considering the returned Eigen type: if it is a compile-time vector--that
|
|
300
|
+
is, the type has either the number of rows or columns set to 1 at compile
|
|
301
|
+
time--pybind11 converts to a 1D numpy array when returning the value. For
|
|
302
|
+
instances that are a vector only at run-time (e.g. ``MatrixXd``,
|
|
303
|
+
``Matrix<float, Dynamic, 4>``), pybind11 returns the vector as a 2D array to
|
|
304
|
+
numpy. If this isn't want you want, you can use ``array.reshape(...)`` to get
|
|
305
|
+
a view of the same data in the desired dimensions.
|
|
306
|
+
|
|
307
|
+
.. seealso::
|
|
308
|
+
|
|
309
|
+
The file :file:`tests/test_eigen.cpp` contains a complete example that
|
|
310
|
+
shows how to pass Eigen sparse and dense data types in more detail.
|