xcoll 0.4.0__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 +2 -1
- xcoll/beam_elements/__init__.py +7 -1
- xcoll/beam_elements/absorber.py +2 -2
- xcoll/beam_elements/base.py +105 -67
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
- xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
- 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 +19 -2
- xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
- xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
- xcoll/beam_elements/everest.py +5 -6
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +103 -74
- xcoll/general.py +4 -4
- xcoll/initial_distribution.py +18 -6
- xcoll/install.py +3 -1
- xcoll/interaction_record/interaction_record.py +126 -80
- xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
- xcoll/line_tools.py +8 -9
- xcoll/lossmap.py +48 -38
- xcoll/scattering_routines/everest/amorphous.h +4 -11
- xcoll/scattering_routines/everest/channeling.h +3 -8
- xcoll/scattering_routines/everest/everest.h +4 -1
- xcoll/scattering_routines/everest/jaw.h +4 -3
- xcoll/scattering_routines/everest/materials.py +35 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
- 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/collimator_geometry.h +9 -10
- xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.4.0.dist-info/RECORD +0 -126
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
m = pytest.importorskip("pybind11_tests.smart_ptr")
|
|
5
|
+
from pybind11_tests import ConstructorStats # noqa: E402
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_smart_ptr(capture):
|
|
9
|
+
# Object1
|
|
10
|
+
for i, o in enumerate(
|
|
11
|
+
[m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
|
|
12
|
+
):
|
|
13
|
+
assert o.getRefCount() == 1
|
|
14
|
+
with capture:
|
|
15
|
+
m.print_object_1(o)
|
|
16
|
+
m.print_object_2(o)
|
|
17
|
+
m.print_object_3(o)
|
|
18
|
+
m.print_object_4(o)
|
|
19
|
+
assert capture == "MyObject1[{i}]\n".format(i=i) * 4
|
|
20
|
+
|
|
21
|
+
for i, o in enumerate(
|
|
22
|
+
[m.make_myobject1_1(), m.make_myobject1_2(), m.MyObject1(6), 7], start=4
|
|
23
|
+
):
|
|
24
|
+
print(o)
|
|
25
|
+
with capture:
|
|
26
|
+
if not isinstance(o, int):
|
|
27
|
+
m.print_object_1(o)
|
|
28
|
+
m.print_object_2(o)
|
|
29
|
+
m.print_object_3(o)
|
|
30
|
+
m.print_object_4(o)
|
|
31
|
+
m.print_myobject1_1(o)
|
|
32
|
+
m.print_myobject1_2(o)
|
|
33
|
+
m.print_myobject1_3(o)
|
|
34
|
+
m.print_myobject1_4(o)
|
|
35
|
+
|
|
36
|
+
times = 4 if isinstance(o, int) else 8
|
|
37
|
+
assert capture == "MyObject1[{i}]\n".format(i=i) * times
|
|
38
|
+
|
|
39
|
+
cstats = ConstructorStats.get(m.MyObject1)
|
|
40
|
+
assert cstats.alive() == 0
|
|
41
|
+
expected_values = ["MyObject1[{}]".format(i) for i in range(1, 7)] + [
|
|
42
|
+
"MyObject1[7]"
|
|
43
|
+
] * 4
|
|
44
|
+
assert cstats.values() == expected_values
|
|
45
|
+
assert cstats.default_constructions == 0
|
|
46
|
+
assert cstats.copy_constructions == 0
|
|
47
|
+
# assert cstats.move_constructions >= 0 # Doesn't invoke any
|
|
48
|
+
assert cstats.copy_assignments == 0
|
|
49
|
+
assert cstats.move_assignments == 0
|
|
50
|
+
|
|
51
|
+
# Object2
|
|
52
|
+
for i, o in zip(
|
|
53
|
+
[8, 6, 7], [m.MyObject2(8), m.make_myobject2_1(), m.make_myobject2_2()]
|
|
54
|
+
):
|
|
55
|
+
print(o)
|
|
56
|
+
with capture:
|
|
57
|
+
m.print_myobject2_1(o)
|
|
58
|
+
m.print_myobject2_2(o)
|
|
59
|
+
m.print_myobject2_3(o)
|
|
60
|
+
m.print_myobject2_4(o)
|
|
61
|
+
assert capture == "MyObject2[{i}]\n".format(i=i) * 4
|
|
62
|
+
|
|
63
|
+
cstats = ConstructorStats.get(m.MyObject2)
|
|
64
|
+
assert cstats.alive() == 1
|
|
65
|
+
o = None
|
|
66
|
+
assert cstats.alive() == 0
|
|
67
|
+
assert cstats.values() == ["MyObject2[8]", "MyObject2[6]", "MyObject2[7]"]
|
|
68
|
+
assert cstats.default_constructions == 0
|
|
69
|
+
assert cstats.copy_constructions == 0
|
|
70
|
+
# assert cstats.move_constructions >= 0 # Doesn't invoke any
|
|
71
|
+
assert cstats.copy_assignments == 0
|
|
72
|
+
assert cstats.move_assignments == 0
|
|
73
|
+
|
|
74
|
+
# Object3
|
|
75
|
+
for i, o in zip(
|
|
76
|
+
[9, 8, 9], [m.MyObject3(9), m.make_myobject3_1(), m.make_myobject3_2()]
|
|
77
|
+
):
|
|
78
|
+
print(o)
|
|
79
|
+
with capture:
|
|
80
|
+
m.print_myobject3_1(o)
|
|
81
|
+
m.print_myobject3_2(o)
|
|
82
|
+
m.print_myobject3_3(o)
|
|
83
|
+
m.print_myobject3_4(o)
|
|
84
|
+
assert capture == "MyObject3[{i}]\n".format(i=i) * 4
|
|
85
|
+
|
|
86
|
+
cstats = ConstructorStats.get(m.MyObject3)
|
|
87
|
+
assert cstats.alive() == 1
|
|
88
|
+
o = None
|
|
89
|
+
assert cstats.alive() == 0
|
|
90
|
+
assert cstats.values() == ["MyObject3[9]", "MyObject3[8]", "MyObject3[9]"]
|
|
91
|
+
assert cstats.default_constructions == 0
|
|
92
|
+
assert cstats.copy_constructions == 0
|
|
93
|
+
# assert cstats.move_constructions >= 0 # Doesn't invoke any
|
|
94
|
+
assert cstats.copy_assignments == 0
|
|
95
|
+
assert cstats.move_assignments == 0
|
|
96
|
+
|
|
97
|
+
# Object
|
|
98
|
+
cstats = ConstructorStats.get(m.Object)
|
|
99
|
+
assert cstats.alive() == 0
|
|
100
|
+
assert cstats.values() == []
|
|
101
|
+
assert cstats.default_constructions == 10
|
|
102
|
+
assert cstats.copy_constructions == 0
|
|
103
|
+
# assert cstats.move_constructions >= 0 # Doesn't invoke any
|
|
104
|
+
assert cstats.copy_assignments == 0
|
|
105
|
+
assert cstats.move_assignments == 0
|
|
106
|
+
|
|
107
|
+
# ref<>
|
|
108
|
+
cstats = m.cstats_ref()
|
|
109
|
+
assert cstats.alive() == 0
|
|
110
|
+
assert cstats.values() == ["from pointer"] * 10
|
|
111
|
+
assert cstats.default_constructions == 30
|
|
112
|
+
assert cstats.copy_constructions == 12
|
|
113
|
+
# assert cstats.move_constructions >= 0 # Doesn't invoke any
|
|
114
|
+
assert cstats.copy_assignments == 30
|
|
115
|
+
assert cstats.move_assignments == 0
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def test_smart_ptr_refcounting():
|
|
119
|
+
assert m.test_object1_refcounting()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_unique_nodelete():
|
|
123
|
+
o = m.MyObject4(23)
|
|
124
|
+
assert o.value == 23
|
|
125
|
+
cstats = ConstructorStats.get(m.MyObject4)
|
|
126
|
+
assert cstats.alive() == 1
|
|
127
|
+
del o
|
|
128
|
+
assert cstats.alive() == 1
|
|
129
|
+
m.MyObject4.cleanup_all_instances()
|
|
130
|
+
assert cstats.alive() == 0
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_unique_nodelete4a():
|
|
134
|
+
o = m.MyObject4a(23)
|
|
135
|
+
assert o.value == 23
|
|
136
|
+
cstats = ConstructorStats.get(m.MyObject4a)
|
|
137
|
+
assert cstats.alive() == 1
|
|
138
|
+
del o
|
|
139
|
+
assert cstats.alive() == 1
|
|
140
|
+
m.MyObject4a.cleanup_all_instances()
|
|
141
|
+
assert cstats.alive() == 0
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_unique_deleter():
|
|
145
|
+
m.MyObject4a(0)
|
|
146
|
+
o = m.MyObject4b(23)
|
|
147
|
+
assert o.value == 23
|
|
148
|
+
cstats4a = ConstructorStats.get(m.MyObject4a)
|
|
149
|
+
assert cstats4a.alive() == 2
|
|
150
|
+
cstats4b = ConstructorStats.get(m.MyObject4b)
|
|
151
|
+
assert cstats4b.alive() == 1
|
|
152
|
+
del o
|
|
153
|
+
assert cstats4a.alive() == 1 # Should now only be one leftover
|
|
154
|
+
assert cstats4b.alive() == 0 # Should be deleted
|
|
155
|
+
m.MyObject4a.cleanup_all_instances()
|
|
156
|
+
assert cstats4a.alive() == 0
|
|
157
|
+
assert cstats4b.alive() == 0
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_large_holder():
|
|
161
|
+
o = m.MyObject5(5)
|
|
162
|
+
assert o.value == 5
|
|
163
|
+
cstats = ConstructorStats.get(m.MyObject5)
|
|
164
|
+
assert cstats.alive() == 1
|
|
165
|
+
del o
|
|
166
|
+
assert cstats.alive() == 0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_shared_ptr_and_references():
|
|
170
|
+
s = m.SharedPtrRef()
|
|
171
|
+
stats = ConstructorStats.get(m.A)
|
|
172
|
+
assert stats.alive() == 2
|
|
173
|
+
|
|
174
|
+
ref = s.ref # init_holder_helper(holder_ptr=false, owned=false)
|
|
175
|
+
assert stats.alive() == 2
|
|
176
|
+
assert s.set_ref(ref)
|
|
177
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
178
|
+
assert s.set_holder(ref)
|
|
179
|
+
assert "Unable to cast from non-held to held instance" in str(excinfo.value)
|
|
180
|
+
|
|
181
|
+
copy = s.copy # init_holder_helper(holder_ptr=false, owned=true)
|
|
182
|
+
assert stats.alive() == 3
|
|
183
|
+
assert s.set_ref(copy)
|
|
184
|
+
assert s.set_holder(copy)
|
|
185
|
+
|
|
186
|
+
holder_ref = s.holder_ref # init_holder_helper(holder_ptr=true, owned=false)
|
|
187
|
+
assert stats.alive() == 3
|
|
188
|
+
assert s.set_ref(holder_ref)
|
|
189
|
+
assert s.set_holder(holder_ref)
|
|
190
|
+
|
|
191
|
+
holder_copy = s.holder_copy # init_holder_helper(holder_ptr=true, owned=true)
|
|
192
|
+
assert stats.alive() == 3
|
|
193
|
+
assert s.set_ref(holder_copy)
|
|
194
|
+
assert s.set_holder(holder_copy)
|
|
195
|
+
|
|
196
|
+
del ref, copy, holder_ref, holder_copy, s
|
|
197
|
+
assert stats.alive() == 0
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def test_shared_ptr_from_this_and_references():
|
|
201
|
+
s = m.SharedFromThisRef()
|
|
202
|
+
stats = ConstructorStats.get(m.B)
|
|
203
|
+
assert stats.alive() == 2
|
|
204
|
+
|
|
205
|
+
ref = s.ref # init_holder_helper(holder_ptr=false, owned=false, bad_wp=false)
|
|
206
|
+
assert stats.alive() == 2
|
|
207
|
+
assert s.set_ref(ref)
|
|
208
|
+
assert s.set_holder(
|
|
209
|
+
ref
|
|
210
|
+
) # std::enable_shared_from_this can create a holder from a reference
|
|
211
|
+
|
|
212
|
+
bad_wp = s.bad_wp # init_holder_helper(holder_ptr=false, owned=false, bad_wp=true)
|
|
213
|
+
assert stats.alive() == 2
|
|
214
|
+
assert s.set_ref(bad_wp)
|
|
215
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
216
|
+
assert s.set_holder(bad_wp)
|
|
217
|
+
assert "Unable to cast from non-held to held instance" in str(excinfo.value)
|
|
218
|
+
|
|
219
|
+
copy = s.copy # init_holder_helper(holder_ptr=false, owned=true, bad_wp=false)
|
|
220
|
+
assert stats.alive() == 3
|
|
221
|
+
assert s.set_ref(copy)
|
|
222
|
+
assert s.set_holder(copy)
|
|
223
|
+
|
|
224
|
+
holder_ref = (
|
|
225
|
+
s.holder_ref
|
|
226
|
+
) # init_holder_helper(holder_ptr=true, owned=false, bad_wp=false)
|
|
227
|
+
assert stats.alive() == 3
|
|
228
|
+
assert s.set_ref(holder_ref)
|
|
229
|
+
assert s.set_holder(holder_ref)
|
|
230
|
+
|
|
231
|
+
holder_copy = (
|
|
232
|
+
s.holder_copy
|
|
233
|
+
) # init_holder_helper(holder_ptr=true, owned=true, bad_wp=false)
|
|
234
|
+
assert stats.alive() == 3
|
|
235
|
+
assert s.set_ref(holder_copy)
|
|
236
|
+
assert s.set_holder(holder_copy)
|
|
237
|
+
|
|
238
|
+
del ref, bad_wp, copy, holder_ref, holder_copy, s
|
|
239
|
+
assert stats.alive() == 0
|
|
240
|
+
|
|
241
|
+
z = m.SharedFromThisVirt.get()
|
|
242
|
+
y = m.SharedFromThisVirt.get()
|
|
243
|
+
assert y is z
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def test_move_only_holder():
|
|
247
|
+
a = m.TypeWithMoveOnlyHolder.make()
|
|
248
|
+
b = m.TypeWithMoveOnlyHolder.make_as_object()
|
|
249
|
+
stats = ConstructorStats.get(m.TypeWithMoveOnlyHolder)
|
|
250
|
+
assert stats.alive() == 2
|
|
251
|
+
del b
|
|
252
|
+
assert stats.alive() == 1
|
|
253
|
+
del a
|
|
254
|
+
assert stats.alive() == 0
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def test_holder_with_addressof_operator():
|
|
258
|
+
# this test must not throw exception from c++
|
|
259
|
+
a = m.TypeForHolderWithAddressOf.make()
|
|
260
|
+
a.print_object_1()
|
|
261
|
+
a.print_object_2()
|
|
262
|
+
a.print_object_3()
|
|
263
|
+
a.print_object_4()
|
|
264
|
+
|
|
265
|
+
stats = ConstructorStats.get(m.TypeForHolderWithAddressOf)
|
|
266
|
+
assert stats.alive() == 1
|
|
267
|
+
|
|
268
|
+
np = m.TypeForHolderWithAddressOf.make()
|
|
269
|
+
assert stats.alive() == 2
|
|
270
|
+
del a
|
|
271
|
+
assert stats.alive() == 1
|
|
272
|
+
del np
|
|
273
|
+
assert stats.alive() == 0
|
|
274
|
+
|
|
275
|
+
b = m.TypeForHolderWithAddressOf.make()
|
|
276
|
+
c = b
|
|
277
|
+
assert b.get() is c.get()
|
|
278
|
+
assert stats.alive() == 1
|
|
279
|
+
|
|
280
|
+
del b
|
|
281
|
+
assert stats.alive() == 1
|
|
282
|
+
|
|
283
|
+
del c
|
|
284
|
+
assert stats.alive() == 0
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def test_move_only_holder_with_addressof_operator():
|
|
288
|
+
a = m.TypeForMoveOnlyHolderWithAddressOf.make()
|
|
289
|
+
a.print_object()
|
|
290
|
+
|
|
291
|
+
stats = ConstructorStats.get(m.TypeForMoveOnlyHolderWithAddressOf)
|
|
292
|
+
assert stats.alive() == 1
|
|
293
|
+
|
|
294
|
+
a.value = 42
|
|
295
|
+
assert a.value == 42
|
|
296
|
+
|
|
297
|
+
del a
|
|
298
|
+
assert stats.alive() == 0
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def test_smart_ptr_from_default():
|
|
302
|
+
instance = m.HeldByDefaultHolder()
|
|
303
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
304
|
+
m.HeldByDefaultHolder.load_shared_ptr(instance)
|
|
305
|
+
assert (
|
|
306
|
+
"Unable to load a custom holder type from a "
|
|
307
|
+
"default-holder instance" in str(excinfo.value)
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def test_shared_ptr_gc():
|
|
312
|
+
"""#187: issue involving std::shared_ptr<> return value policy & garbage collection"""
|
|
313
|
+
el = m.ElementList()
|
|
314
|
+
for i in range(10):
|
|
315
|
+
el.add(m.ElementA(i))
|
|
316
|
+
pytest.gc_collect()
|
|
317
|
+
for i, v in enumerate(el.get()):
|
|
318
|
+
assert i == v.value()
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/*
|
|
2
|
+
tests/test_stl.cpp -- STL type casters
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017 Wenzel Jakob <wenzel.jakob@epfl.ch>
|
|
5
|
+
|
|
6
|
+
All rights reserved. Use of this source code is governed by a
|
|
7
|
+
BSD-style license that can be found in the LICENSE file.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "pybind11_tests.h"
|
|
11
|
+
#include "constructor_stats.h"
|
|
12
|
+
#include <pybind11/stl.h>
|
|
13
|
+
|
|
14
|
+
#ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
|
|
15
|
+
#define PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
|
|
16
|
+
#endif
|
|
17
|
+
#include <pybind11/stl/filesystem.h>
|
|
18
|
+
|
|
19
|
+
#include <vector>
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
// Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14
|
|
23
|
+
#if defined(PYBIND11_HAS_VARIANT)
|
|
24
|
+
using std::variant;
|
|
25
|
+
#elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910)
|
|
26
|
+
# include <boost/variant.hpp>
|
|
27
|
+
# define PYBIND11_HAS_VARIANT 1
|
|
28
|
+
using boost::variant;
|
|
29
|
+
|
|
30
|
+
namespace pybind11 { namespace detail {
|
|
31
|
+
template <typename... Ts>
|
|
32
|
+
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
|
|
33
|
+
|
|
34
|
+
template <>
|
|
35
|
+
struct visit_helper<boost::variant> {
|
|
36
|
+
template <typename... Args>
|
|
37
|
+
static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
|
|
38
|
+
return boost::apply_visitor(args...);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}} // namespace pybind11::detail
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
PYBIND11_MAKE_OPAQUE(std::vector<std::string, std::allocator<std::string>>);
|
|
45
|
+
|
|
46
|
+
/// Issue #528: templated constructor
|
|
47
|
+
struct TplCtorClass {
|
|
48
|
+
template <typename T>
|
|
49
|
+
explicit TplCtorClass(const T &) {}
|
|
50
|
+
bool operator==(const TplCtorClass &) const { return true; }
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
namespace std {
|
|
54
|
+
template <>
|
|
55
|
+
struct hash<TplCtorClass> { size_t operator()(const TplCtorClass &) const { return 0; } };
|
|
56
|
+
} // namespace std
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
template <template <typename> class OptionalImpl, typename T>
|
|
60
|
+
struct OptionalHolder
|
|
61
|
+
{
|
|
62
|
+
OptionalHolder() = default;
|
|
63
|
+
bool member_initialized() const {
|
|
64
|
+
return member && member->initialized;
|
|
65
|
+
}
|
|
66
|
+
OptionalImpl<T> member = T{};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
TEST_SUBMODULE(stl, m) {
|
|
71
|
+
// test_vector
|
|
72
|
+
m.def("cast_vector", []() { return std::vector<int>{1}; });
|
|
73
|
+
m.def("load_vector", [](const std::vector<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
|
|
74
|
+
// `std::vector<bool>` is special because it returns proxy objects instead of references
|
|
75
|
+
m.def("cast_bool_vector", []() { return std::vector<bool>{true, false}; });
|
|
76
|
+
m.def("load_bool_vector", [](const std::vector<bool> &v) {
|
|
77
|
+
return v.at(0) == true && v.at(1) == false;
|
|
78
|
+
});
|
|
79
|
+
// Unnumbered regression (caused by #936): pointers to stl containers aren't castable
|
|
80
|
+
static std::vector<RValueCaster> lvv{2};
|
|
81
|
+
m.def("cast_ptr_vector", []() { return &lvv; });
|
|
82
|
+
|
|
83
|
+
// test_deque
|
|
84
|
+
m.def("cast_deque", []() { return std::deque<int>{1}; });
|
|
85
|
+
m.def("load_deque", [](const std::deque<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
|
|
86
|
+
|
|
87
|
+
// test_array
|
|
88
|
+
m.def("cast_array", []() { return std::array<int, 2> {{1 , 2}}; });
|
|
89
|
+
m.def("load_array", [](const std::array<int, 2> &a) { return a[0] == 1 && a[1] == 2; });
|
|
90
|
+
|
|
91
|
+
// test_valarray
|
|
92
|
+
m.def("cast_valarray", []() { return std::valarray<int>{1, 4, 9}; });
|
|
93
|
+
m.def("load_valarray", [](const std::valarray<int>& v) {
|
|
94
|
+
return v.size() == 3 && v[0] == 1 && v[1] == 4 && v[2] == 9;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// test_map
|
|
98
|
+
m.def("cast_map", []() { return std::map<std::string, std::string>{{"key", "value"}}; });
|
|
99
|
+
m.def("load_map", [](const std::map<std::string, std::string> &map) {
|
|
100
|
+
return map.at("key") == "value" && map.at("key2") == "value2";
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// test_set
|
|
104
|
+
m.def("cast_set", []() { return std::set<std::string>{"key1", "key2"}; });
|
|
105
|
+
m.def("load_set", [](const std::set<std::string> &set) {
|
|
106
|
+
return (set.count("key1") != 0u) && (set.count("key2") != 0u) && (set.count("key3") != 0u);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// test_recursive_casting
|
|
110
|
+
m.def("cast_rv_vector", []() { return std::vector<RValueCaster>{2}; });
|
|
111
|
+
m.def("cast_rv_array", []() { return std::array<RValueCaster, 3>(); });
|
|
112
|
+
// NB: map and set keys are `const`, so while we technically do move them (as `const Type &&`),
|
|
113
|
+
// casters don't typically do anything with that, which means they fall to the `const Type &`
|
|
114
|
+
// caster.
|
|
115
|
+
m.def("cast_rv_map", []() { return std::unordered_map<std::string, RValueCaster>{{"a", RValueCaster{}}}; });
|
|
116
|
+
m.def("cast_rv_nested", []() {
|
|
117
|
+
std::vector<std::array<std::list<std::unordered_map<std::string, RValueCaster>>, 2>> v;
|
|
118
|
+
v.emplace_back(); // add an array
|
|
119
|
+
v.back()[0].emplace_back(); // add a map to the array
|
|
120
|
+
v.back()[0].back().emplace("b", RValueCaster{});
|
|
121
|
+
v.back()[0].back().emplace("c", RValueCaster{});
|
|
122
|
+
v.back()[1].emplace_back(); // add a map to the array
|
|
123
|
+
v.back()[1].back().emplace("a", RValueCaster{});
|
|
124
|
+
return v;
|
|
125
|
+
});
|
|
126
|
+
static std::array<RValueCaster, 2> lva;
|
|
127
|
+
static std::unordered_map<std::string, RValueCaster> lvm{{"a", RValueCaster{}}, {"b", RValueCaster{}}};
|
|
128
|
+
static std::unordered_map<std::string, std::vector<std::list<std::array<RValueCaster, 2>>>> lvn;
|
|
129
|
+
lvn["a"].emplace_back(); // add a list
|
|
130
|
+
lvn["a"].back().emplace_back(); // add an array
|
|
131
|
+
lvn["a"].emplace_back(); // another list
|
|
132
|
+
lvn["a"].back().emplace_back(); // add an array
|
|
133
|
+
lvn["b"].emplace_back(); // add a list
|
|
134
|
+
lvn["b"].back().emplace_back(); // add an array
|
|
135
|
+
lvn["b"].back().emplace_back(); // add another array
|
|
136
|
+
m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
|
|
137
|
+
m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
|
|
138
|
+
m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });
|
|
139
|
+
m.def("cast_lv_nested", []() -> const decltype(lvn) & { return lvn; });
|
|
140
|
+
// #853:
|
|
141
|
+
m.def("cast_unique_ptr_vector", []() {
|
|
142
|
+
std::vector<std::unique_ptr<UserType>> v;
|
|
143
|
+
v.emplace_back(new UserType{7});
|
|
144
|
+
v.emplace_back(new UserType{42});
|
|
145
|
+
return v;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// test_move_out_container
|
|
149
|
+
struct MoveOutContainer {
|
|
150
|
+
struct Value { int value; };
|
|
151
|
+
std::list<Value> move_list() const { return {{0}, {1}, {2}}; }
|
|
152
|
+
};
|
|
153
|
+
py::class_<MoveOutContainer::Value>(m, "MoveOutContainerValue")
|
|
154
|
+
.def_readonly("value", &MoveOutContainer::Value::value);
|
|
155
|
+
py::class_<MoveOutContainer>(m, "MoveOutContainer")
|
|
156
|
+
.def(py::init<>())
|
|
157
|
+
.def_property_readonly("move_list", &MoveOutContainer::move_list);
|
|
158
|
+
|
|
159
|
+
// Class that can be move- and copy-constructed, but not assigned
|
|
160
|
+
struct NoAssign {
|
|
161
|
+
int value;
|
|
162
|
+
|
|
163
|
+
explicit NoAssign(int value = 0) : value(value) { }
|
|
164
|
+
NoAssign(const NoAssign &) = default;
|
|
165
|
+
NoAssign(NoAssign &&) = default;
|
|
166
|
+
|
|
167
|
+
NoAssign &operator=(const NoAssign &) = delete;
|
|
168
|
+
NoAssign &operator=(NoAssign &&) = delete;
|
|
169
|
+
};
|
|
170
|
+
py::class_<NoAssign>(m, "NoAssign", "Class with no C++ assignment operators")
|
|
171
|
+
.def(py::init<>())
|
|
172
|
+
.def(py::init<int>());
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
struct MoveOutDetector
|
|
176
|
+
{
|
|
177
|
+
MoveOutDetector() = default;
|
|
178
|
+
MoveOutDetector(const MoveOutDetector&) = default;
|
|
179
|
+
MoveOutDetector(MoveOutDetector&& other) noexcept
|
|
180
|
+
: initialized(other.initialized) {
|
|
181
|
+
// steal underlying resource
|
|
182
|
+
other.initialized = false;
|
|
183
|
+
}
|
|
184
|
+
bool initialized = true;
|
|
185
|
+
};
|
|
186
|
+
py::class_<MoveOutDetector>(m, "MoveOutDetector", "Class with move tracking")
|
|
187
|
+
.def(py::init<>())
|
|
188
|
+
.def_readonly("initialized", &MoveOutDetector::initialized);
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
#ifdef PYBIND11_HAS_OPTIONAL
|
|
192
|
+
// test_optional
|
|
193
|
+
m.attr("has_optional") = true;
|
|
194
|
+
|
|
195
|
+
using opt_int = std::optional<int>;
|
|
196
|
+
using opt_no_assign = std::optional<NoAssign>;
|
|
197
|
+
m.def("double_or_zero", [](const opt_int& x) -> int {
|
|
198
|
+
return x.value_or(0) * 2;
|
|
199
|
+
});
|
|
200
|
+
m.def("half_or_none", [](int x) -> opt_int { return x != 0 ? opt_int(x / 2) : opt_int(); });
|
|
201
|
+
m.def("test_nullopt", [](opt_int x) {
|
|
202
|
+
return x.value_or(42);
|
|
203
|
+
}, py::arg_v("x", std::nullopt, "None"));
|
|
204
|
+
m.def("test_no_assign", [](const opt_no_assign &x) {
|
|
205
|
+
return x ? x->value : 42;
|
|
206
|
+
}, py::arg_v("x", std::nullopt, "None"));
|
|
207
|
+
|
|
208
|
+
m.def("nodefer_none_optional", [](std::optional<int>) { return true; });
|
|
209
|
+
m.def("nodefer_none_optional", [](const py::none &) { return false; });
|
|
210
|
+
|
|
211
|
+
using opt_holder = OptionalHolder<std::optional, MoveOutDetector>;
|
|
212
|
+
py::class_<opt_holder>(m, "OptionalHolder", "Class with optional member")
|
|
213
|
+
.def(py::init<>())
|
|
214
|
+
.def_readonly("member", &opt_holder::member)
|
|
215
|
+
.def("member_initialized", &opt_holder::member_initialized);
|
|
216
|
+
#endif
|
|
217
|
+
|
|
218
|
+
#ifdef PYBIND11_HAS_EXP_OPTIONAL
|
|
219
|
+
// test_exp_optional
|
|
220
|
+
m.attr("has_exp_optional") = true;
|
|
221
|
+
|
|
222
|
+
using exp_opt_int = std::experimental::optional<int>;
|
|
223
|
+
using exp_opt_no_assign = std::experimental::optional<NoAssign>;
|
|
224
|
+
m.def("double_or_zero_exp", [](const exp_opt_int& x) -> int {
|
|
225
|
+
return x.value_or(0) * 2;
|
|
226
|
+
});
|
|
227
|
+
m.def("half_or_none_exp", [](int x) -> exp_opt_int {
|
|
228
|
+
return x ? exp_opt_int(x / 2) : exp_opt_int();
|
|
229
|
+
});
|
|
230
|
+
m.def("test_nullopt_exp", [](exp_opt_int x) {
|
|
231
|
+
return x.value_or(42);
|
|
232
|
+
}, py::arg_v("x", std::experimental::nullopt, "None"));
|
|
233
|
+
m.def("test_no_assign_exp", [](const exp_opt_no_assign &x) {
|
|
234
|
+
return x ? x->value : 42;
|
|
235
|
+
}, py::arg_v("x", std::experimental::nullopt, "None"));
|
|
236
|
+
|
|
237
|
+
using opt_exp_holder = OptionalHolder<std::experimental::optional, MoveOutDetector>;
|
|
238
|
+
py::class_<opt_exp_holder>(m, "OptionalExpHolder", "Class with optional member")
|
|
239
|
+
.def(py::init<>())
|
|
240
|
+
.def_readonly("member", &opt_exp_holder::member)
|
|
241
|
+
.def("member_initialized", &opt_exp_holder::member_initialized);
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
#ifdef PYBIND11_HAS_FILESYSTEM
|
|
245
|
+
// test_fs_path
|
|
246
|
+
m.attr("has_filesystem") = true;
|
|
247
|
+
m.def("parent_path", [](const std::filesystem::path& p) { return p.parent_path(); });
|
|
248
|
+
#endif
|
|
249
|
+
|
|
250
|
+
#ifdef PYBIND11_HAS_VARIANT
|
|
251
|
+
static_assert(std::is_same<py::detail::variant_caster_visitor::result_type, py::handle>::value,
|
|
252
|
+
"visitor::result_type is required by boost::variant in C++11 mode");
|
|
253
|
+
|
|
254
|
+
struct visitor {
|
|
255
|
+
using result_type = const char *;
|
|
256
|
+
|
|
257
|
+
result_type operator()(int) { return "int"; }
|
|
258
|
+
result_type operator()(const std::string &) { return "std::string"; }
|
|
259
|
+
result_type operator()(double) { return "double"; }
|
|
260
|
+
result_type operator()(std::nullptr_t) { return "std::nullptr_t"; }
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// test_variant
|
|
264
|
+
m.def("load_variant", [](const variant<int, std::string, double, std::nullptr_t> &v) {
|
|
265
|
+
return py::detail::visit_helper<variant>::call(visitor(), v);
|
|
266
|
+
});
|
|
267
|
+
m.def("load_variant_2pass", [](variant<double, int> v) {
|
|
268
|
+
return py::detail::visit_helper<variant>::call(visitor(), v);
|
|
269
|
+
});
|
|
270
|
+
m.def("cast_variant", []() {
|
|
271
|
+
using V = variant<int, std::string>;
|
|
272
|
+
return py::make_tuple(V(5), V("Hello"));
|
|
273
|
+
});
|
|
274
|
+
#endif
|
|
275
|
+
|
|
276
|
+
// #528: templated constructor
|
|
277
|
+
// (no python tests: the test here is that this compiles)
|
|
278
|
+
m.def("tpl_ctor_vector", [](std::vector<TplCtorClass> &) {});
|
|
279
|
+
m.def("tpl_ctor_map", [](std::unordered_map<TplCtorClass, TplCtorClass> &) {});
|
|
280
|
+
m.def("tpl_ctor_set", [](std::unordered_set<TplCtorClass> &) {});
|
|
281
|
+
#if defined(PYBIND11_HAS_OPTIONAL)
|
|
282
|
+
m.def("tpl_constr_optional", [](std::optional<TplCtorClass> &) {});
|
|
283
|
+
#elif defined(PYBIND11_HAS_EXP_OPTIONAL)
|
|
284
|
+
m.def("tpl_constr_optional", [](std::experimental::optional<TplCtorClass> &) {});
|
|
285
|
+
#endif
|
|
286
|
+
|
|
287
|
+
// test_vec_of_reference_wrapper
|
|
288
|
+
// #171: Can't return STL structures containing reference wrapper
|
|
289
|
+
m.def("return_vec_of_reference_wrapper", [](std::reference_wrapper<UserType> p4) {
|
|
290
|
+
static UserType p1{1}, p2{2}, p3{3};
|
|
291
|
+
return std::vector<std::reference_wrapper<UserType>> {
|
|
292
|
+
std::ref(p1), std::ref(p2), std::ref(p3), p4
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// test_stl_pass_by_pointer
|
|
297
|
+
m.def("stl_pass_by_pointer", [](std::vector<int>* v) { return *v; }, "v"_a=nullptr);
|
|
298
|
+
|
|
299
|
+
// #1258: pybind11/stl.h converts string to vector<string>
|
|
300
|
+
m.def("func_with_string_or_vector_string_arg_overload",
|
|
301
|
+
[](const std::vector<std::string> &) { return 1; });
|
|
302
|
+
m.def("func_with_string_or_vector_string_arg_overload",
|
|
303
|
+
[](const std::list<std::string> &) { return 2; });
|
|
304
|
+
m.def("func_with_string_or_vector_string_arg_overload", [](const std::string &) { return 3; });
|
|
305
|
+
|
|
306
|
+
class Placeholder {
|
|
307
|
+
public:
|
|
308
|
+
Placeholder() { print_created(this); }
|
|
309
|
+
Placeholder(const Placeholder &) = delete;
|
|
310
|
+
~Placeholder() { print_destroyed(this); }
|
|
311
|
+
};
|
|
312
|
+
py::class_<Placeholder>(m, "Placeholder");
|
|
313
|
+
|
|
314
|
+
/// test_stl_vector_ownership
|
|
315
|
+
m.def("test_stl_ownership",
|
|
316
|
+
[]() {
|
|
317
|
+
std::vector<Placeholder *> result;
|
|
318
|
+
result.push_back(new Placeholder());
|
|
319
|
+
return result;
|
|
320
|
+
},
|
|
321
|
+
py::return_value_policy::take_ownership);
|
|
322
|
+
|
|
323
|
+
m.def("array_cast_sequence", [](std::array<int, 3> x) { return x; });
|
|
324
|
+
|
|
325
|
+
/// test_issue_1561
|
|
326
|
+
struct Issue1561Inner { std::string data; };
|
|
327
|
+
struct Issue1561Outer { std::vector<Issue1561Inner> list; };
|
|
328
|
+
|
|
329
|
+
py::class_<Issue1561Inner>(m, "Issue1561Inner")
|
|
330
|
+
.def(py::init<std::string>())
|
|
331
|
+
.def_readwrite("data", &Issue1561Inner::data);
|
|
332
|
+
|
|
333
|
+
py::class_<Issue1561Outer>(m, "Issue1561Outer")
|
|
334
|
+
.def(py::init<>())
|
|
335
|
+
.def_readwrite("list", &Issue1561Outer::list);
|
|
336
|
+
|
|
337
|
+
m.def(
|
|
338
|
+
"return_vector_bool_raw_ptr",
|
|
339
|
+
[]() { return new std::vector<bool>(4513); },
|
|
340
|
+
// Without explicitly specifying `take_ownership`, this function leaks.
|
|
341
|
+
py::return_value_policy::take_ownership);
|
|
342
|
+
}
|