xcoll 0.5.12__py3-none-any.whl → 0.6.1__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 +5 -18
- xcoll/__init__.py.orig +26 -0
- xcoll/beam_elements/__init__.py +1 -0
- xcoll/beam_elements/absorber.py +12 -2
- xcoll/beam_elements/base.py +162 -62
- xcoll/beam_elements/blowup.py +1 -0
- xcoll/beam_elements/elements_src/black_absorber.h +57 -58
- xcoll/beam_elements/elements_src/black_crystal.h +49 -50
- xcoll/beam_elements/elements_src/everest_block.h +21 -11
- xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
- xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
- xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
- xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
- xcoll/beam_elements/everest.py +16 -5
- xcoll/beam_elements/monitor.py +1 -0
- xcoll/beam_elements/transparent.py +83 -0
- xcoll/colldb.py +15 -6
- xcoll/general.py +1 -1
- xcoll/general.py.orig +20 -0
- xcoll/headers/particle_states.py +51 -0
- xcoll/initial_distribution.py +121 -91
- xcoll/initial_distribution.py.orig +256 -0
- xcoll/interaction_record/interaction_record.py +2 -1
- xcoll/interaction_record/interaction_types.py +2 -2
- xcoll/line_tools.py +163 -73
- xcoll/lossmap.py +519 -127
- xcoll/plot.py +109 -0
- xcoll/rf_sweep.py +6 -0
- xcoll/scattering_routines/engine.py +414 -217
- xcoll/scattering_routines/environment.py +297 -0
- xcoll/scattering_routines/everest/amorphous.h +95 -71
- xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
- xcoll/scattering_routines/everest/constants.h +1 -1
- xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
- xcoll/scattering_routines/everest/everest.h +8 -3
- xcoll/scattering_routines/everest/everest.py +2 -1
- xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
- xcoll/scattering_routines/everest/jaw.h +19 -24
- xcoll/scattering_routines/everest/materials.py +2 -0
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
- xcoll/scattering_routines/everest/properties.h +3 -72
- xcoll/xaux.py +65 -109
- {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/METADATA +5 -5
- xcoll-0.6.1.dist-info/RECORD +138 -0
- xcoll/_manager.py +0 -22
- xcoll/headers/particle_states.h +0 -25
- xcoll/install.py +0 -35
- xcoll/scattering_routines/geant4/collimasim/.git +0 -1
- xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
- xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
- 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 +0 -427
- 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 +0 -427
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
- 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 +0 -279
- 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 +0 -143
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
- xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
- xcoll-0.5.12.dist-info/RECORD +0 -415
- {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/LICENSE +0 -0
- {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/NOTICE +0 -0
- {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/WHEEL +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
Functional
|
|
2
|
-
##########
|
|
3
|
-
|
|
4
|
-
The following features must be enabled by including :file:`pybind11/functional.h`.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Callbacks and passing anonymous functions
|
|
8
|
-
=========================================
|
|
9
|
-
|
|
10
|
-
The C++11 standard brought lambda functions and the generic polymorphic
|
|
11
|
-
function wrapper ``std::function<>`` to the C++ programming language, which
|
|
12
|
-
enable powerful new ways of working with functions. Lambda functions come in
|
|
13
|
-
two flavors: stateless lambda function resemble classic function pointers that
|
|
14
|
-
link to an anonymous piece of code, while stateful lambda functions
|
|
15
|
-
additionally depend on captured variables that are stored in an anonymous
|
|
16
|
-
*lambda closure object*.
|
|
17
|
-
|
|
18
|
-
Here is a simple example of a C++ function that takes an arbitrary function
|
|
19
|
-
(stateful or stateless) with signature ``int -> int`` as an argument and runs
|
|
20
|
-
it with the value 10.
|
|
21
|
-
|
|
22
|
-
.. code-block:: cpp
|
|
23
|
-
|
|
24
|
-
int func_arg(const std::function<int(int)> &f) {
|
|
25
|
-
return f(10);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
The example below is more involved: it takes a function of signature ``int -> int``
|
|
29
|
-
and returns another function of the same kind. The return value is a stateful
|
|
30
|
-
lambda function, which stores the value ``f`` in the capture object and adds 1 to
|
|
31
|
-
its return value upon execution.
|
|
32
|
-
|
|
33
|
-
.. code-block:: cpp
|
|
34
|
-
|
|
35
|
-
std::function<int(int)> func_ret(const std::function<int(int)> &f) {
|
|
36
|
-
return [f](int i) {
|
|
37
|
-
return f(i) + 1;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
This example demonstrates using python named parameters in C++ callbacks which
|
|
42
|
-
requires using ``py::cpp_function`` as a wrapper. Usage is similar to defining
|
|
43
|
-
methods of classes:
|
|
44
|
-
|
|
45
|
-
.. code-block:: cpp
|
|
46
|
-
|
|
47
|
-
py::cpp_function func_cpp() {
|
|
48
|
-
return py::cpp_function([](int i) { return i+1; },
|
|
49
|
-
py::arg("number"));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
After including the extra header file :file:`pybind11/functional.h`, it is almost
|
|
53
|
-
trivial to generate binding code for all of these functions.
|
|
54
|
-
|
|
55
|
-
.. code-block:: cpp
|
|
56
|
-
|
|
57
|
-
#include <pybind11/functional.h>
|
|
58
|
-
|
|
59
|
-
PYBIND11_MODULE(example, m) {
|
|
60
|
-
m.def("func_arg", &func_arg);
|
|
61
|
-
m.def("func_ret", &func_ret);
|
|
62
|
-
m.def("func_cpp", &func_cpp);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
The following interactive session shows how to call them from Python.
|
|
66
|
-
|
|
67
|
-
.. code-block:: pycon
|
|
68
|
-
|
|
69
|
-
$ python
|
|
70
|
-
>>> import example
|
|
71
|
-
>>> def square(i):
|
|
72
|
-
... return i * i
|
|
73
|
-
...
|
|
74
|
-
>>> example.func_arg(square)
|
|
75
|
-
100L
|
|
76
|
-
>>> square_plus_1 = example.func_ret(square)
|
|
77
|
-
>>> square_plus_1(4)
|
|
78
|
-
17L
|
|
79
|
-
>>> plus_1 = func_cpp()
|
|
80
|
-
>>> plus_1(number=43)
|
|
81
|
-
44L
|
|
82
|
-
|
|
83
|
-
.. warning::
|
|
84
|
-
|
|
85
|
-
Keep in mind that passing a function from C++ to Python (or vice versa)
|
|
86
|
-
will instantiate a piece of wrapper code that translates function
|
|
87
|
-
invocations between the two languages. Naturally, this translation
|
|
88
|
-
increases the computational cost of each function call somewhat. A
|
|
89
|
-
problematic situation can arise when a function is copied back and forth
|
|
90
|
-
between Python and C++ many times in a row, in which case the underlying
|
|
91
|
-
wrappers will accumulate correspondingly. The resulting long sequence of
|
|
92
|
-
C++ -> Python -> C++ -> ... roundtrips can significantly decrease
|
|
93
|
-
performance.
|
|
94
|
-
|
|
95
|
-
There is one exception: pybind11 detects case where a stateless function
|
|
96
|
-
(i.e. a function pointer or a lambda function without captured variables)
|
|
97
|
-
is passed as an argument to another C++ function exposed in Python. In this
|
|
98
|
-
case, there is no overhead. Pybind11 will extract the underlying C++
|
|
99
|
-
function pointer from the wrapped function to sidestep a potential C++ ->
|
|
100
|
-
Python -> C++ roundtrip. This is demonstrated in :file:`tests/test_callbacks.cpp`.
|
|
101
|
-
|
|
102
|
-
.. note::
|
|
103
|
-
|
|
104
|
-
This functionality is very useful when generating bindings for callbacks in
|
|
105
|
-
C++ libraries (e.g. GUI libraries, asynchronous networking libraries, etc.).
|
|
106
|
-
|
|
107
|
-
The file :file:`tests/test_callbacks.cpp` contains a complete example
|
|
108
|
-
that demonstrates how to work with callbacks and anonymous functions in
|
|
109
|
-
more detail.
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
.. _type-conversions:
|
|
2
|
-
|
|
3
|
-
Type conversions
|
|
4
|
-
################
|
|
5
|
-
|
|
6
|
-
Apart from enabling cross-language function calls, a fundamental problem
|
|
7
|
-
that a binding tool like pybind11 must address is to provide access to
|
|
8
|
-
native Python types in C++ and vice versa. There are three fundamentally
|
|
9
|
-
different ways to do this—which approach is preferable for a particular type
|
|
10
|
-
depends on the situation at hand.
|
|
11
|
-
|
|
12
|
-
1. Use a native C++ type everywhere. In this case, the type must be wrapped
|
|
13
|
-
using pybind11-generated bindings so that Python can interact with it.
|
|
14
|
-
|
|
15
|
-
2. Use a native Python type everywhere. It will need to be wrapped so that
|
|
16
|
-
C++ functions can interact with it.
|
|
17
|
-
|
|
18
|
-
3. Use a native C++ type on the C++ side and a native Python type on the
|
|
19
|
-
Python side. pybind11 refers to this as a *type conversion*.
|
|
20
|
-
|
|
21
|
-
Type conversions are the most "natural" option in the sense that native
|
|
22
|
-
(non-wrapped) types are used everywhere. The main downside is that a copy
|
|
23
|
-
of the data must be made on every Python ↔ C++ transition: this is
|
|
24
|
-
needed since the C++ and Python versions of the same type generally won't
|
|
25
|
-
have the same memory layout.
|
|
26
|
-
|
|
27
|
-
pybind11 can perform many kinds of conversions automatically. An overview
|
|
28
|
-
is provided in the table ":ref:`conversion_table`".
|
|
29
|
-
|
|
30
|
-
The following subsections discuss the differences between these options in more
|
|
31
|
-
detail. The main focus in this section is on type conversions, which represent
|
|
32
|
-
the last case of the above list.
|
|
33
|
-
|
|
34
|
-
.. toctree::
|
|
35
|
-
:maxdepth: 1
|
|
36
|
-
|
|
37
|
-
overview
|
|
38
|
-
strings
|
|
39
|
-
stl
|
|
40
|
-
functional
|
|
41
|
-
chrono
|
|
42
|
-
eigen
|
|
43
|
-
custom
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
Overview
|
|
2
|
-
########
|
|
3
|
-
|
|
4
|
-
.. rubric:: 1. Native type in C++, wrapper in Python
|
|
5
|
-
|
|
6
|
-
Exposing a custom C++ type using :class:`py::class_` was covered in detail
|
|
7
|
-
in the :doc:`/classes` section. There, the underlying data structure is
|
|
8
|
-
always the original C++ class while the :class:`py::class_` wrapper provides
|
|
9
|
-
a Python interface. Internally, when an object like this is sent from C++ to
|
|
10
|
-
Python, pybind11 will just add the outer wrapper layer over the native C++
|
|
11
|
-
object. Getting it back from Python is just a matter of peeling off the
|
|
12
|
-
wrapper.
|
|
13
|
-
|
|
14
|
-
.. rubric:: 2. Wrapper in C++, native type in Python
|
|
15
|
-
|
|
16
|
-
This is the exact opposite situation. Now, we have a type which is native to
|
|
17
|
-
Python, like a ``tuple`` or a ``list``. One way to get this data into C++ is
|
|
18
|
-
with the :class:`py::object` family of wrappers. These are explained in more
|
|
19
|
-
detail in the :doc:`/advanced/pycpp/object` section. We'll just give a quick
|
|
20
|
-
example here:
|
|
21
|
-
|
|
22
|
-
.. code-block:: cpp
|
|
23
|
-
|
|
24
|
-
void print_list(py::list my_list) {
|
|
25
|
-
for (auto item : my_list)
|
|
26
|
-
std::cout << item << " ";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.. code-block:: pycon
|
|
30
|
-
|
|
31
|
-
>>> print_list([1, 2, 3])
|
|
32
|
-
1 2 3
|
|
33
|
-
|
|
34
|
-
The Python ``list`` is not converted in any way -- it's just wrapped in a C++
|
|
35
|
-
:class:`py::list` class. At its core it's still a Python object. Copying a
|
|
36
|
-
:class:`py::list` will do the usual reference-counting like in Python.
|
|
37
|
-
Returning the object to Python will just remove the thin wrapper.
|
|
38
|
-
|
|
39
|
-
.. rubric:: 3. Converting between native C++ and Python types
|
|
40
|
-
|
|
41
|
-
In the previous two cases we had a native type in one language and a wrapper in
|
|
42
|
-
the other. Now, we have native types on both sides and we convert between them.
|
|
43
|
-
|
|
44
|
-
.. code-block:: cpp
|
|
45
|
-
|
|
46
|
-
void print_vector(const std::vector<int> &v) {
|
|
47
|
-
for (auto item : v)
|
|
48
|
-
std::cout << item << "\n";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.. code-block:: pycon
|
|
52
|
-
|
|
53
|
-
>>> print_vector([1, 2, 3])
|
|
54
|
-
1 2 3
|
|
55
|
-
|
|
56
|
-
In this case, pybind11 will construct a new ``std::vector<int>`` and copy each
|
|
57
|
-
element from the Python ``list``. The newly constructed object will be passed
|
|
58
|
-
to ``print_vector``. The same thing happens in the other direction: a new
|
|
59
|
-
``list`` is made to match the value returned from C++.
|
|
60
|
-
|
|
61
|
-
Lots of these conversions are supported out of the box, as shown in the table
|
|
62
|
-
below. They are very convenient, but keep in mind that these conversions are
|
|
63
|
-
fundamentally based on copying data. This is perfectly fine for small immutable
|
|
64
|
-
types but it may become quite expensive for large data structures. This can be
|
|
65
|
-
avoided by overriding the automatic conversion with a custom wrapper (i.e. the
|
|
66
|
-
above-mentioned approach 1). This requires some manual effort and more details
|
|
67
|
-
are available in the :ref:`opaque` section.
|
|
68
|
-
|
|
69
|
-
.. _conversion_table:
|
|
70
|
-
|
|
71
|
-
List of all builtin conversions
|
|
72
|
-
-------------------------------
|
|
73
|
-
|
|
74
|
-
The following basic data types are supported out of the box (some may require
|
|
75
|
-
an additional extension header to be included). To pass other data structures
|
|
76
|
-
as arguments and return values, refer to the section on binding :ref:`classes`.
|
|
77
|
-
|
|
78
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
79
|
-
| Data type | Description | Header file |
|
|
80
|
-
+====================================+===========================+===============================+
|
|
81
|
-
| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` |
|
|
82
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
83
|
-
| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` |
|
|
84
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
85
|
-
| ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` |
|
|
86
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
87
|
-
| ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` |
|
|
88
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
89
|
-
| ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` |
|
|
90
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
91
|
-
| ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` |
|
|
92
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
93
|
-
| ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` |
|
|
94
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
95
|
-
| ``char`` | Character literal | :file:`pybind11/pybind11.h` |
|
|
96
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
97
|
-
| ``char16_t`` | UTF-16 character literal | :file:`pybind11/pybind11.h` |
|
|
98
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
99
|
-
| ``char32_t`` | UTF-32 character literal | :file:`pybind11/pybind11.h` |
|
|
100
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
101
|
-
| ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` |
|
|
102
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
103
|
-
| ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` |
|
|
104
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
105
|
-
| ``const char16_t *`` | UTF-16 string literal | :file:`pybind11/pybind11.h` |
|
|
106
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
107
|
-
| ``const char32_t *`` | UTF-32 string literal | :file:`pybind11/pybind11.h` |
|
|
108
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
109
|
-
| ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` |
|
|
110
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
111
|
-
| ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` |
|
|
112
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
113
|
-
| ``std::u16string`` | STL dynamic UTF-16 string | :file:`pybind11/pybind11.h` |
|
|
114
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
115
|
-
| ``std::u32string`` | STL dynamic UTF-32 string | :file:`pybind11/pybind11.h` |
|
|
116
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
117
|
-
| ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` |
|
|
118
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
119
|
-
| ``std::string_view``, | STL C++17 string views | :file:`pybind11/pybind11.h` |
|
|
120
|
-
| ``std::u16string_view``, etc. | | |
|
|
121
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
122
|
-
| ``std::pair<T1, T2>`` | Pair of two custom types | :file:`pybind11/pybind11.h` |
|
|
123
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
124
|
-
| ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` |
|
|
125
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
126
|
-
| ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` |
|
|
127
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
128
|
-
| ``std::complex<T>`` | Complex numbers | :file:`pybind11/complex.h` |
|
|
129
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
130
|
-
| ``std::array<T, Size>`` | STL static array | :file:`pybind11/stl.h` |
|
|
131
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
132
|
-
| ``std::vector<T>`` | STL dynamic array | :file:`pybind11/stl.h` |
|
|
133
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
134
|
-
| ``std::deque<T>`` | STL double-ended queue | :file:`pybind11/stl.h` |
|
|
135
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
136
|
-
| ``std::valarray<T>`` | STL value array | :file:`pybind11/stl.h` |
|
|
137
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
138
|
-
| ``std::list<T>`` | STL linked list | :file:`pybind11/stl.h` |
|
|
139
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
140
|
-
| ``std::map<T1, T2>`` | STL ordered map | :file:`pybind11/stl.h` |
|
|
141
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
142
|
-
| ``std::unordered_map<T1, T2>`` | STL unordered map | :file:`pybind11/stl.h` |
|
|
143
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
144
|
-
| ``std::set<T>`` | STL ordered set | :file:`pybind11/stl.h` |
|
|
145
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
146
|
-
| ``std::unordered_set<T>`` | STL unordered set | :file:`pybind11/stl.h` |
|
|
147
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
148
|
-
| ``std::optional<T>`` | STL optional type (C++17) | :file:`pybind11/stl.h` |
|
|
149
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
150
|
-
| ``std::experimental::optional<T>`` | STL optional type (exp.) | :file:`pybind11/stl.h` |
|
|
151
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
152
|
-
| ``std::variant<...>`` | Type-safe union (C++17) | :file:`pybind11/stl.h` |
|
|
153
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
154
|
-
| ``std::filesystem::path<T>`` | STL path (C++17) [#]_ | :file:`pybind11/stl.h` |
|
|
155
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
156
|
-
| ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` |
|
|
157
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
158
|
-
| ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` |
|
|
159
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
160
|
-
| ``std::chrono::time_point<...>`` | STL date/time | :file:`pybind11/chrono.h` |
|
|
161
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
162
|
-
| ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` |
|
|
163
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
164
|
-
| ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` |
|
|
165
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
166
|
-
| ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` |
|
|
167
|
-
+------------------------------------+---------------------------+-------------------------------+
|
|
168
|
-
|
|
169
|
-
.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and
|
|
170
|
-
``os.PathLike`` is converted to ``std::filesystem::path``, but this requires
|
|
171
|
-
Python 3.6 (for ``__fspath__`` support).
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
STL containers
|
|
2
|
-
##############
|
|
3
|
-
|
|
4
|
-
Automatic conversion
|
|
5
|
-
====================
|
|
6
|
-
|
|
7
|
-
When including the additional header file :file:`pybind11/stl.h`, conversions
|
|
8
|
-
between ``std::vector<>``/``std::deque<>``/``std::list<>``/``std::array<>``/``std::valarray<>``,
|
|
9
|
-
``std::set<>``/``std::unordered_set<>``, and
|
|
10
|
-
``std::map<>``/``std::unordered_map<>`` and the Python ``list``, ``set`` and
|
|
11
|
-
``dict`` data structures are automatically enabled. The types ``std::pair<>``
|
|
12
|
-
and ``std::tuple<>`` are already supported out of the box with just the core
|
|
13
|
-
:file:`pybind11/pybind11.h` header.
|
|
14
|
-
|
|
15
|
-
The major downside of these implicit conversions is that containers must be
|
|
16
|
-
converted (i.e. copied) on every Python->C++ and C++->Python transition, which
|
|
17
|
-
can have implications on the program semantics and performance. Please read the
|
|
18
|
-
next sections for more details and alternative approaches that avoid this.
|
|
19
|
-
|
|
20
|
-
.. note::
|
|
21
|
-
|
|
22
|
-
Arbitrary nesting of any of these types is possible.
|
|
23
|
-
|
|
24
|
-
.. seealso::
|
|
25
|
-
|
|
26
|
-
The file :file:`tests/test_stl.cpp` contains a complete
|
|
27
|
-
example that demonstrates how to pass STL data types in more detail.
|
|
28
|
-
|
|
29
|
-
.. _cpp17_container_casters:
|
|
30
|
-
|
|
31
|
-
C++17 library containers
|
|
32
|
-
========================
|
|
33
|
-
|
|
34
|
-
The :file:`pybind11/stl.h` header also includes support for ``std::optional<>``
|
|
35
|
-
and ``std::variant<>``. These require a C++17 compiler and standard library.
|
|
36
|
-
In C++14 mode, ``std::experimental::optional<>`` is supported if available.
|
|
37
|
-
|
|
38
|
-
Various versions of these containers also exist for C++11 (e.g. in Boost).
|
|
39
|
-
pybind11 provides an easy way to specialize the ``type_caster`` for such
|
|
40
|
-
types:
|
|
41
|
-
|
|
42
|
-
.. code-block:: cpp
|
|
43
|
-
|
|
44
|
-
// `boost::optional` as an example -- can be any `std::optional`-like container
|
|
45
|
-
namespace pybind11 { namespace detail {
|
|
46
|
-
template <typename T>
|
|
47
|
-
struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
|
|
48
|
-
}}
|
|
49
|
-
|
|
50
|
-
The above should be placed in a header file and included in all translation units
|
|
51
|
-
where automatic conversion is needed. Similarly, a specialization can be provided
|
|
52
|
-
for custom variant types:
|
|
53
|
-
|
|
54
|
-
.. code-block:: cpp
|
|
55
|
-
|
|
56
|
-
// `boost::variant` as an example -- can be any `std::variant`-like container
|
|
57
|
-
namespace pybind11 { namespace detail {
|
|
58
|
-
template <typename... Ts>
|
|
59
|
-
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
|
|
60
|
-
|
|
61
|
-
// Specifies the function used to visit the variant -- `apply_visitor` instead of `visit`
|
|
62
|
-
template <>
|
|
63
|
-
struct visit_helper<boost::variant> {
|
|
64
|
-
template <typename... Args>
|
|
65
|
-
static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
|
|
66
|
-
return boost::apply_visitor(args...);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}} // namespace pybind11::detail
|
|
70
|
-
|
|
71
|
-
The ``visit_helper`` specialization is not required if your ``name::variant`` provides
|
|
72
|
-
a ``name::visit()`` function. For any other function name, the specialization must be
|
|
73
|
-
included to tell pybind11 how to visit the variant.
|
|
74
|
-
|
|
75
|
-
.. warning::
|
|
76
|
-
|
|
77
|
-
When converting a ``variant`` type, pybind11 follows the same rules as when
|
|
78
|
-
determining which function overload to call (:ref:`overload_resolution`), and
|
|
79
|
-
so the same caveats hold. In particular, the order in which the ``variant``'s
|
|
80
|
-
alternatives are listed is important, since pybind11 will try conversions in
|
|
81
|
-
this order. This means that, for example, when converting ``variant<int, bool>``,
|
|
82
|
-
the ``bool`` variant will never be selected, as any Python ``bool`` is already
|
|
83
|
-
an ``int`` and is convertible to a C++ ``int``. Changing the order of alternatives
|
|
84
|
-
(and using ``variant<bool, int>``, in this example) provides a solution.
|
|
85
|
-
|
|
86
|
-
.. note::
|
|
87
|
-
|
|
88
|
-
pybind11 only supports the modern implementation of ``boost::variant``
|
|
89
|
-
which makes use of variadic templates. This requires Boost 1.56 or newer.
|
|
90
|
-
Additionally, on Windows, MSVC 2017 is required because ``boost::variant``
|
|
91
|
-
falls back to the old non-variadic implementation on MSVC 2015.
|
|
92
|
-
|
|
93
|
-
.. _opaque:
|
|
94
|
-
|
|
95
|
-
Making opaque types
|
|
96
|
-
===================
|
|
97
|
-
|
|
98
|
-
pybind11 heavily relies on a template matching mechanism to convert parameters
|
|
99
|
-
and return values that are constructed from STL data types such as vectors,
|
|
100
|
-
linked lists, hash tables, etc. This even works in a recursive manner, for
|
|
101
|
-
instance to deal with lists of hash maps of pairs of elementary and custom
|
|
102
|
-
types, etc.
|
|
103
|
-
|
|
104
|
-
However, a fundamental limitation of this approach is that internal conversions
|
|
105
|
-
between Python and C++ types involve a copy operation that prevents
|
|
106
|
-
pass-by-reference semantics. What does this mean?
|
|
107
|
-
|
|
108
|
-
Suppose we bind the following function
|
|
109
|
-
|
|
110
|
-
.. code-block:: cpp
|
|
111
|
-
|
|
112
|
-
void append_1(std::vector<int> &v) {
|
|
113
|
-
v.push_back(1);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
and call it from Python, the following happens:
|
|
117
|
-
|
|
118
|
-
.. code-block:: pycon
|
|
119
|
-
|
|
120
|
-
>>> v = [5, 6]
|
|
121
|
-
>>> append_1(v)
|
|
122
|
-
>>> print(v)
|
|
123
|
-
[5, 6]
|
|
124
|
-
|
|
125
|
-
As you can see, when passing STL data structures by reference, modifications
|
|
126
|
-
are not propagated back the Python side. A similar situation arises when
|
|
127
|
-
exposing STL data structures using the ``def_readwrite`` or ``def_readonly``
|
|
128
|
-
functions:
|
|
129
|
-
|
|
130
|
-
.. code-block:: cpp
|
|
131
|
-
|
|
132
|
-
/* ... definition ... */
|
|
133
|
-
|
|
134
|
-
class MyClass {
|
|
135
|
-
std::vector<int> contents;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/* ... binding code ... */
|
|
139
|
-
|
|
140
|
-
py::class_<MyClass>(m, "MyClass")
|
|
141
|
-
.def(py::init<>())
|
|
142
|
-
.def_readwrite("contents", &MyClass::contents);
|
|
143
|
-
|
|
144
|
-
In this case, properties can be read and written in their entirety. However, an
|
|
145
|
-
``append`` operation involving such a list type has no effect:
|
|
146
|
-
|
|
147
|
-
.. code-block:: pycon
|
|
148
|
-
|
|
149
|
-
>>> m = MyClass()
|
|
150
|
-
>>> m.contents = [5, 6]
|
|
151
|
-
>>> print(m.contents)
|
|
152
|
-
[5, 6]
|
|
153
|
-
>>> m.contents.append(7)
|
|
154
|
-
>>> print(m.contents)
|
|
155
|
-
[5, 6]
|
|
156
|
-
|
|
157
|
-
Finally, the involved copy operations can be costly when dealing with very
|
|
158
|
-
large lists. To deal with all of the above situations, pybind11 provides a
|
|
159
|
-
macro named ``PYBIND11_MAKE_OPAQUE(T)`` that disables the template-based
|
|
160
|
-
conversion machinery of types, thus rendering them *opaque*. The contents of
|
|
161
|
-
opaque objects are never inspected or extracted, hence they *can* be passed by
|
|
162
|
-
reference. For instance, to turn ``std::vector<int>`` into an opaque type, add
|
|
163
|
-
the declaration
|
|
164
|
-
|
|
165
|
-
.. code-block:: cpp
|
|
166
|
-
|
|
167
|
-
PYBIND11_MAKE_OPAQUE(std::vector<int>);
|
|
168
|
-
|
|
169
|
-
before any binding code (e.g. invocations to ``class_::def()``, etc.). This
|
|
170
|
-
macro must be specified at the top level (and outside of any namespaces), since
|
|
171
|
-
it adds a template instantiation of ``type_caster``. If your binding code consists of
|
|
172
|
-
multiple compilation units, it must be present in every file (typically via a
|
|
173
|
-
common header) preceding any usage of ``std::vector<int>``. Opaque types must
|
|
174
|
-
also have a corresponding ``class_`` declaration to associate them with a name
|
|
175
|
-
in Python, and to define a set of available operations, e.g.:
|
|
176
|
-
|
|
177
|
-
.. code-block:: cpp
|
|
178
|
-
|
|
179
|
-
py::class_<std::vector<int>>(m, "IntVector")
|
|
180
|
-
.def(py::init<>())
|
|
181
|
-
.def("clear", &std::vector<int>::clear)
|
|
182
|
-
.def("pop_back", &std::vector<int>::pop_back)
|
|
183
|
-
.def("__len__", [](const std::vector<int> &v) { return v.size(); })
|
|
184
|
-
.def("__iter__", [](std::vector<int> &v) {
|
|
185
|
-
return py::make_iterator(v.begin(), v.end());
|
|
186
|
-
}, py::keep_alive<0, 1>()) /* Keep vector alive while iterator is used */
|
|
187
|
-
// ....
|
|
188
|
-
|
|
189
|
-
.. seealso::
|
|
190
|
-
|
|
191
|
-
The file :file:`tests/test_opaque_types.cpp` contains a complete
|
|
192
|
-
example that demonstrates how to create and expose opaque types using
|
|
193
|
-
pybind11 in more detail.
|
|
194
|
-
|
|
195
|
-
.. _stl_bind:
|
|
196
|
-
|
|
197
|
-
Binding STL containers
|
|
198
|
-
======================
|
|
199
|
-
|
|
200
|
-
The ability to expose STL containers as native Python objects is a fairly
|
|
201
|
-
common request, hence pybind11 also provides an optional header file named
|
|
202
|
-
:file:`pybind11/stl_bind.h` that does exactly this. The mapped containers try
|
|
203
|
-
to match the behavior of their native Python counterparts as much as possible.
|
|
204
|
-
|
|
205
|
-
The following example showcases usage of :file:`pybind11/stl_bind.h`:
|
|
206
|
-
|
|
207
|
-
.. code-block:: cpp
|
|
208
|
-
|
|
209
|
-
// Don't forget this
|
|
210
|
-
#include <pybind11/stl_bind.h>
|
|
211
|
-
|
|
212
|
-
PYBIND11_MAKE_OPAQUE(std::vector<int>);
|
|
213
|
-
PYBIND11_MAKE_OPAQUE(std::map<std::string, double>);
|
|
214
|
-
|
|
215
|
-
// ...
|
|
216
|
-
|
|
217
|
-
// later in binding code:
|
|
218
|
-
py::bind_vector<std::vector<int>>(m, "VectorInt");
|
|
219
|
-
py::bind_map<std::map<std::string, double>>(m, "MapStringDouble");
|
|
220
|
-
|
|
221
|
-
When binding STL containers pybind11 considers the types of the container's
|
|
222
|
-
elements to decide whether the container should be confined to the local module
|
|
223
|
-
(via the :ref:`module_local` feature). If the container element types are
|
|
224
|
-
anything other than already-bound custom types bound without
|
|
225
|
-
``py::module_local()`` the container binding will have ``py::module_local()``
|
|
226
|
-
applied. This includes converting types such as numeric types, strings, Eigen
|
|
227
|
-
types; and types that have not yet been bound at the time of the stl container
|
|
228
|
-
binding. This module-local binding is designed to avoid potential conflicts
|
|
229
|
-
between module bindings (for example, from two separate modules each attempting
|
|
230
|
-
to bind ``std::vector<int>`` as a python type).
|
|
231
|
-
|
|
232
|
-
It is possible to override this behavior to force a definition to be either
|
|
233
|
-
module-local or global. To do so, you can pass the attributes
|
|
234
|
-
``py::module_local()`` (to make the binding module-local) or
|
|
235
|
-
``py::module_local(false)`` (to make the binding global) into the
|
|
236
|
-
``py::bind_vector`` or ``py::bind_map`` arguments:
|
|
237
|
-
|
|
238
|
-
.. code-block:: cpp
|
|
239
|
-
|
|
240
|
-
py::bind_vector<std::vector<int>>(m, "VectorInt", py::module_local(false));
|
|
241
|
-
|
|
242
|
-
Note, however, that such a global binding would make it impossible to load this
|
|
243
|
-
module at the same time as any other pybind module that also attempts to bind
|
|
244
|
-
the same container type (``std::vector<int>`` in the above example).
|
|
245
|
-
|
|
246
|
-
See :ref:`module_local` for more details on module-local bindings.
|
|
247
|
-
|
|
248
|
-
.. seealso::
|
|
249
|
-
|
|
250
|
-
The file :file:`tests/test_stl_binders.cpp` shows how to use the
|
|
251
|
-
convenience STL container wrappers.
|