xcoll 0.3.6__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +13 -4
- xcoll/beam_elements/__init__.py +14 -6
- xcoll/beam_elements/absorber.py +41 -7
- xcoll/beam_elements/base.py +1202 -247
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/elements_src/black_absorber.h +136 -0
- xcoll/beam_elements/elements_src/black_crystal.h +129 -0
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
- xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
- xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
- xcoll/beam_elements/everest.py +65 -119
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +276 -747
- xcoll/general.py +5 -5
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +2 -2
- xcoll/initial_distribution.py +207 -0
- xcoll/install.py +179 -0
- xcoll/interaction_record/__init__.py +1 -0
- xcoll/interaction_record/interaction_record.py +298 -0
- xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
- xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
- xcoll/line_tools.py +82 -0
- xcoll/lossmap.py +219 -0
- xcoll/manager.py +2 -937
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +232 -0
- xcoll/scattering_routines/everest/channeling.h +240 -0
- xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
- xcoll/scattering_routines/everest/everest.h +11 -30
- xcoll/scattering_routines/everest/everest.py +13 -10
- xcoll/scattering_routines/everest/jaw.h +28 -197
- xcoll/scattering_routines/everest/materials.py +37 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
- xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/__init__.py +6 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
- xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
- xcoll/scattering_routines/geometry/geometry.py +26 -0
- xcoll/scattering_routines/geometry/get_s.h +92 -0
- xcoll/scattering_routines/geometry/methods.h +111 -0
- xcoll/scattering_routines/geometry/objects.h +154 -0
- xcoll/scattering_routines/geometry/rotation.h +23 -0
- xcoll/scattering_routines/geometry/segments.h +226 -0
- xcoll/scattering_routines/geometry/sort.h +184 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/beam_elements/collimators_src/absorber.h +0 -141
- xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
- xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
- xcoll/collimator_settings.py +0 -457
- xcoll/impacts/__init__.py +0 -1
- xcoll/impacts/impacts.py +0 -102
- xcoll/impacts/impacts_src/impacts.h +0 -99
- xcoll/scattering_routines/everest/crystal.h +0 -1302
- xcoll/scattering_routines/everest/scatter.h +0 -169
- xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.3.6.dist-info/RECORD +0 -111
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from pybind11_tests import ConstructorStats, UserType
|
|
5
|
+
from pybind11_tests import stl as m
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_vector(doc):
|
|
9
|
+
"""std::vector <-> list"""
|
|
10
|
+
lst = m.cast_vector()
|
|
11
|
+
assert lst == [1]
|
|
12
|
+
lst.append(2)
|
|
13
|
+
assert m.load_vector(lst)
|
|
14
|
+
assert m.load_vector(tuple(lst))
|
|
15
|
+
|
|
16
|
+
assert m.cast_bool_vector() == [True, False]
|
|
17
|
+
assert m.load_bool_vector([True, False])
|
|
18
|
+
|
|
19
|
+
assert doc(m.cast_vector) == "cast_vector() -> List[int]"
|
|
20
|
+
assert doc(m.load_vector) == "load_vector(arg0: List[int]) -> bool"
|
|
21
|
+
|
|
22
|
+
# Test regression caused by 936: pointers to stl containers weren't castable
|
|
23
|
+
assert m.cast_ptr_vector() == ["lvalue", "lvalue"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_deque(doc):
|
|
27
|
+
"""std::deque <-> list"""
|
|
28
|
+
lst = m.cast_deque()
|
|
29
|
+
assert lst == [1]
|
|
30
|
+
lst.append(2)
|
|
31
|
+
assert m.load_deque(lst)
|
|
32
|
+
assert m.load_deque(tuple(lst))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_array(doc):
|
|
36
|
+
"""std::array <-> list"""
|
|
37
|
+
lst = m.cast_array()
|
|
38
|
+
assert lst == [1, 2]
|
|
39
|
+
assert m.load_array(lst)
|
|
40
|
+
|
|
41
|
+
assert doc(m.cast_array) == "cast_array() -> List[int[2]]"
|
|
42
|
+
assert doc(m.load_array) == "load_array(arg0: List[int[2]]) -> bool"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_valarray(doc):
|
|
46
|
+
"""std::valarray <-> list"""
|
|
47
|
+
lst = m.cast_valarray()
|
|
48
|
+
assert lst == [1, 4, 9]
|
|
49
|
+
assert m.load_valarray(lst)
|
|
50
|
+
|
|
51
|
+
assert doc(m.cast_valarray) == "cast_valarray() -> List[int]"
|
|
52
|
+
assert doc(m.load_valarray) == "load_valarray(arg0: List[int]) -> bool"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_map(doc):
|
|
56
|
+
"""std::map <-> dict"""
|
|
57
|
+
d = m.cast_map()
|
|
58
|
+
assert d == {"key": "value"}
|
|
59
|
+
assert "key" in d
|
|
60
|
+
d["key2"] = "value2"
|
|
61
|
+
assert "key2" in d
|
|
62
|
+
assert m.load_map(d)
|
|
63
|
+
|
|
64
|
+
assert doc(m.cast_map) == "cast_map() -> Dict[str, str]"
|
|
65
|
+
assert doc(m.load_map) == "load_map(arg0: Dict[str, str]) -> bool"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_set(doc):
|
|
69
|
+
"""std::set <-> set"""
|
|
70
|
+
s = m.cast_set()
|
|
71
|
+
assert s == {"key1", "key2"}
|
|
72
|
+
s.add("key3")
|
|
73
|
+
assert m.load_set(s)
|
|
74
|
+
|
|
75
|
+
assert doc(m.cast_set) == "cast_set() -> Set[str]"
|
|
76
|
+
assert doc(m.load_set) == "load_set(arg0: Set[str]) -> bool"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_recursive_casting():
|
|
80
|
+
"""Tests that stl casters preserve lvalue/rvalue context for container values"""
|
|
81
|
+
assert m.cast_rv_vector() == ["rvalue", "rvalue"]
|
|
82
|
+
assert m.cast_lv_vector() == ["lvalue", "lvalue"]
|
|
83
|
+
assert m.cast_rv_array() == ["rvalue", "rvalue", "rvalue"]
|
|
84
|
+
assert m.cast_lv_array() == ["lvalue", "lvalue"]
|
|
85
|
+
assert m.cast_rv_map() == {"a": "rvalue"}
|
|
86
|
+
assert m.cast_lv_map() == {"a": "lvalue", "b": "lvalue"}
|
|
87
|
+
assert m.cast_rv_nested() == [[[{"b": "rvalue", "c": "rvalue"}], [{"a": "rvalue"}]]]
|
|
88
|
+
assert m.cast_lv_nested() == {
|
|
89
|
+
"a": [[["lvalue", "lvalue"]], [["lvalue", "lvalue"]]],
|
|
90
|
+
"b": [[["lvalue", "lvalue"], ["lvalue", "lvalue"]]],
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Issue #853 test case:
|
|
94
|
+
z = m.cast_unique_ptr_vector()
|
|
95
|
+
assert z[0].value == 7 and z[1].value == 42
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_move_out_container():
|
|
99
|
+
"""Properties use the `reference_internal` policy by default. If the underlying function
|
|
100
|
+
returns an rvalue, the policy is automatically changed to `move` to avoid referencing
|
|
101
|
+
a temporary. In case the return value is a container of user-defined types, the policy
|
|
102
|
+
also needs to be applied to the elements, not just the container."""
|
|
103
|
+
c = m.MoveOutContainer()
|
|
104
|
+
moved_out_list = c.move_list
|
|
105
|
+
assert [x.value for x in moved_out_list] == [0, 1, 2]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.skipif(not hasattr(m, "has_optional"), reason="no <optional>")
|
|
109
|
+
def test_optional():
|
|
110
|
+
assert m.double_or_zero(None) == 0
|
|
111
|
+
assert m.double_or_zero(42) == 84
|
|
112
|
+
pytest.raises(TypeError, m.double_or_zero, "foo")
|
|
113
|
+
|
|
114
|
+
assert m.half_or_none(0) is None
|
|
115
|
+
assert m.half_or_none(42) == 21
|
|
116
|
+
pytest.raises(TypeError, m.half_or_none, "foo")
|
|
117
|
+
|
|
118
|
+
assert m.test_nullopt() == 42
|
|
119
|
+
assert m.test_nullopt(None) == 42
|
|
120
|
+
assert m.test_nullopt(42) == 42
|
|
121
|
+
assert m.test_nullopt(43) == 43
|
|
122
|
+
|
|
123
|
+
assert m.test_no_assign() == 42
|
|
124
|
+
assert m.test_no_assign(None) == 42
|
|
125
|
+
assert m.test_no_assign(m.NoAssign(43)) == 43
|
|
126
|
+
pytest.raises(TypeError, m.test_no_assign, 43)
|
|
127
|
+
|
|
128
|
+
assert m.nodefer_none_optional(None)
|
|
129
|
+
|
|
130
|
+
holder = m.OptionalHolder()
|
|
131
|
+
mvalue = holder.member
|
|
132
|
+
assert mvalue.initialized
|
|
133
|
+
assert holder.member_initialized()
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@pytest.mark.skipif(
|
|
137
|
+
not hasattr(m, "has_exp_optional"), reason="no <experimental/optional>"
|
|
138
|
+
)
|
|
139
|
+
def test_exp_optional():
|
|
140
|
+
assert m.double_or_zero_exp(None) == 0
|
|
141
|
+
assert m.double_or_zero_exp(42) == 84
|
|
142
|
+
pytest.raises(TypeError, m.double_or_zero_exp, "foo")
|
|
143
|
+
|
|
144
|
+
assert m.half_or_none_exp(0) is None
|
|
145
|
+
assert m.half_or_none_exp(42) == 21
|
|
146
|
+
pytest.raises(TypeError, m.half_or_none_exp, "foo")
|
|
147
|
+
|
|
148
|
+
assert m.test_nullopt_exp() == 42
|
|
149
|
+
assert m.test_nullopt_exp(None) == 42
|
|
150
|
+
assert m.test_nullopt_exp(42) == 42
|
|
151
|
+
assert m.test_nullopt_exp(43) == 43
|
|
152
|
+
|
|
153
|
+
assert m.test_no_assign_exp() == 42
|
|
154
|
+
assert m.test_no_assign_exp(None) == 42
|
|
155
|
+
assert m.test_no_assign_exp(m.NoAssign(43)) == 43
|
|
156
|
+
pytest.raises(TypeError, m.test_no_assign_exp, 43)
|
|
157
|
+
|
|
158
|
+
holder = m.OptionalExpHolder()
|
|
159
|
+
mvalue = holder.member
|
|
160
|
+
assert mvalue.initialized
|
|
161
|
+
assert holder.member_initialized()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@pytest.mark.skipif(not hasattr(m, "has_filesystem"), reason="no <filesystem>")
|
|
165
|
+
def test_fs_path():
|
|
166
|
+
from pathlib import Path
|
|
167
|
+
|
|
168
|
+
class PseudoStrPath:
|
|
169
|
+
def __fspath__(self):
|
|
170
|
+
return "foo/bar"
|
|
171
|
+
|
|
172
|
+
class PseudoBytesPath:
|
|
173
|
+
def __fspath__(self):
|
|
174
|
+
return b"foo/bar"
|
|
175
|
+
|
|
176
|
+
assert m.parent_path(Path("foo/bar")) == Path("foo")
|
|
177
|
+
assert m.parent_path("foo/bar") == Path("foo")
|
|
178
|
+
assert m.parent_path(b"foo/bar") == Path("foo")
|
|
179
|
+
assert m.parent_path(PseudoStrPath()) == Path("foo")
|
|
180
|
+
assert m.parent_path(PseudoBytesPath()) == Path("foo")
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")
|
|
184
|
+
def test_variant(doc):
|
|
185
|
+
assert m.load_variant(1) == "int"
|
|
186
|
+
assert m.load_variant("1") == "std::string"
|
|
187
|
+
assert m.load_variant(1.0) == "double"
|
|
188
|
+
assert m.load_variant(None) == "std::nullptr_t"
|
|
189
|
+
|
|
190
|
+
assert m.load_variant_2pass(1) == "int"
|
|
191
|
+
assert m.load_variant_2pass(1.0) == "double"
|
|
192
|
+
|
|
193
|
+
assert m.cast_variant() == (5, "Hello")
|
|
194
|
+
|
|
195
|
+
assert (
|
|
196
|
+
doc(m.load_variant) == "load_variant(arg0: Union[int, str, float, None]) -> str"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def test_vec_of_reference_wrapper():
|
|
201
|
+
"""#171: Can't return reference wrappers (or STL structures containing them)"""
|
|
202
|
+
assert (
|
|
203
|
+
str(m.return_vec_of_reference_wrapper(UserType(4)))
|
|
204
|
+
== "[UserType(1), UserType(2), UserType(3), UserType(4)]"
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_stl_pass_by_pointer(msg):
|
|
209
|
+
"""Passing nullptr or None to an STL container pointer is not expected to work"""
|
|
210
|
+
with pytest.raises(TypeError) as excinfo:
|
|
211
|
+
m.stl_pass_by_pointer() # default value is `nullptr`
|
|
212
|
+
assert (
|
|
213
|
+
msg(excinfo.value)
|
|
214
|
+
== """
|
|
215
|
+
stl_pass_by_pointer(): incompatible function arguments. The following argument types are supported:
|
|
216
|
+
1. (v: List[int] = None) -> List[int]
|
|
217
|
+
|
|
218
|
+
Invoked with:
|
|
219
|
+
""" # noqa: E501 line too long
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
with pytest.raises(TypeError) as excinfo:
|
|
223
|
+
m.stl_pass_by_pointer(None)
|
|
224
|
+
assert (
|
|
225
|
+
msg(excinfo.value)
|
|
226
|
+
== """
|
|
227
|
+
stl_pass_by_pointer(): incompatible function arguments. The following argument types are supported:
|
|
228
|
+
1. (v: List[int] = None) -> List[int]
|
|
229
|
+
|
|
230
|
+
Invoked with: None
|
|
231
|
+
""" # noqa: E501 line too long
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
assert m.stl_pass_by_pointer([1, 2, 3]) == [1, 2, 3]
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def test_missing_header_message():
|
|
238
|
+
"""Trying convert `list` to a `std::vector`, or vice versa, without including
|
|
239
|
+
<pybind11/stl.h> should result in a helpful suggestion in the error message"""
|
|
240
|
+
import pybind11_cross_module_tests as cm
|
|
241
|
+
|
|
242
|
+
expected_message = (
|
|
243
|
+
"Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,\n"
|
|
244
|
+
"<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic\n"
|
|
245
|
+
"conversions are optional and require extra headers to be included\n"
|
|
246
|
+
"when compiling your pybind11 module."
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
with pytest.raises(TypeError) as excinfo:
|
|
250
|
+
cm.missing_header_arg([1.0, 2.0, 3.0])
|
|
251
|
+
assert expected_message in str(excinfo.value)
|
|
252
|
+
|
|
253
|
+
with pytest.raises(TypeError) as excinfo:
|
|
254
|
+
cm.missing_header_return()
|
|
255
|
+
assert expected_message in str(excinfo.value)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_function_with_string_and_vector_string_arg():
|
|
259
|
+
"""Check if a string is NOT implicitly converted to a list, which was the
|
|
260
|
+
behavior before fix of issue #1258"""
|
|
261
|
+
assert m.func_with_string_or_vector_string_arg_overload(("A", "B")) == 2
|
|
262
|
+
assert m.func_with_string_or_vector_string_arg_overload(["A", "B"]) == 2
|
|
263
|
+
assert m.func_with_string_or_vector_string_arg_overload("A") == 3
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def test_stl_ownership():
|
|
267
|
+
cstats = ConstructorStats.get(m.Placeholder)
|
|
268
|
+
assert cstats.alive() == 0
|
|
269
|
+
r = m.test_stl_ownership()
|
|
270
|
+
assert len(r) == 1
|
|
271
|
+
del r
|
|
272
|
+
assert cstats.alive() == 0
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def test_array_cast_sequence():
|
|
276
|
+
assert m.array_cast_sequence((1, 2, 3)) == [1, 2, 3]
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def test_issue_1561():
|
|
280
|
+
"""check fix for issue #1561"""
|
|
281
|
+
bar = m.Issue1561Outer()
|
|
282
|
+
bar.list = [m.Issue1561Inner("bar")]
|
|
283
|
+
bar.list
|
|
284
|
+
assert bar.list[0].data == "bar"
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def test_return_vector_bool_raw_ptr():
|
|
288
|
+
# Add `while True:` for manual leak checking.
|
|
289
|
+
v = m.return_vector_bool_raw_ptr()
|
|
290
|
+
assert isinstance(v, list)
|
|
291
|
+
assert len(v) == 4513
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
tests/test_stl_binders.cpp -- Usage of stl_binders functions
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2016 Sergey Lyskov
|
|
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
|
+
|
|
12
|
+
#include <pybind11/stl_bind.h>
|
|
13
|
+
#include <pybind11/numpy.h>
|
|
14
|
+
#include <map>
|
|
15
|
+
#include <deque>
|
|
16
|
+
#include <unordered_map>
|
|
17
|
+
|
|
18
|
+
class El {
|
|
19
|
+
public:
|
|
20
|
+
El() = delete;
|
|
21
|
+
explicit El(int v) : a(v) {}
|
|
22
|
+
|
|
23
|
+
int a;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
std::ostream & operator<<(std::ostream &s, El const&v) {
|
|
27
|
+
s << "El{" << v.a << '}';
|
|
28
|
+
return s;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Issue #487: binding std::vector<E> with E non-copyable
|
|
32
|
+
class E_nc {
|
|
33
|
+
public:
|
|
34
|
+
explicit E_nc(int i) : value{i} {}
|
|
35
|
+
E_nc(const E_nc &) = delete;
|
|
36
|
+
E_nc &operator=(const E_nc &) = delete;
|
|
37
|
+
E_nc(E_nc &&) = default;
|
|
38
|
+
E_nc &operator=(E_nc &&) = default;
|
|
39
|
+
|
|
40
|
+
int value;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
template <class Container> Container *one_to_n(int n) {
|
|
44
|
+
auto v = new Container();
|
|
45
|
+
for (int i = 1; i <= n; i++)
|
|
46
|
+
v->emplace_back(i);
|
|
47
|
+
return v;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
template <class Map> Map *times_ten(int n) {
|
|
51
|
+
auto m = new Map();
|
|
52
|
+
for (int i = 1; i <= n; i++)
|
|
53
|
+
m->emplace(int(i), E_nc(10*i));
|
|
54
|
+
return m;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
template <class NestMap> NestMap *times_hundred(int n) {
|
|
58
|
+
auto m = new NestMap();
|
|
59
|
+
for (int i = 1; i <= n; i++)
|
|
60
|
+
for (int j = 1; j <= n; j++)
|
|
61
|
+
(*m)[i].emplace(int(j*10), E_nc(100*j));
|
|
62
|
+
return m;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
TEST_SUBMODULE(stl_binders, m) {
|
|
66
|
+
// test_vector_int
|
|
67
|
+
py::bind_vector<std::vector<unsigned int>>(m, "VectorInt", py::buffer_protocol());
|
|
68
|
+
|
|
69
|
+
// test_vector_custom
|
|
70
|
+
py::class_<El>(m, "El")
|
|
71
|
+
.def(py::init<int>());
|
|
72
|
+
py::bind_vector<std::vector<El>>(m, "VectorEl");
|
|
73
|
+
py::bind_vector<std::vector<std::vector<El>>>(m, "VectorVectorEl");
|
|
74
|
+
|
|
75
|
+
// test_map_string_double
|
|
76
|
+
py::bind_map<std::map<std::string, double>>(m, "MapStringDouble");
|
|
77
|
+
py::bind_map<std::unordered_map<std::string, double>>(m, "UnorderedMapStringDouble");
|
|
78
|
+
|
|
79
|
+
// test_map_string_double_const
|
|
80
|
+
py::bind_map<std::map<std::string, double const>>(m, "MapStringDoubleConst");
|
|
81
|
+
py::bind_map<std::unordered_map<std::string, double const>>(m, "UnorderedMapStringDoubleConst");
|
|
82
|
+
|
|
83
|
+
py::class_<E_nc>(m, "ENC")
|
|
84
|
+
.def(py::init<int>())
|
|
85
|
+
.def_readwrite("value", &E_nc::value);
|
|
86
|
+
|
|
87
|
+
// test_noncopyable_containers
|
|
88
|
+
py::bind_vector<std::vector<E_nc>>(m, "VectorENC");
|
|
89
|
+
m.def("get_vnc", &one_to_n<std::vector<E_nc>>);
|
|
90
|
+
py::bind_vector<std::deque<E_nc>>(m, "DequeENC");
|
|
91
|
+
m.def("get_dnc", &one_to_n<std::deque<E_nc>>);
|
|
92
|
+
py::bind_map<std::map<int, E_nc>>(m, "MapENC");
|
|
93
|
+
m.def("get_mnc", ×_ten<std::map<int, E_nc>>);
|
|
94
|
+
py::bind_map<std::unordered_map<int, E_nc>>(m, "UmapENC");
|
|
95
|
+
m.def("get_umnc", ×_ten<std::unordered_map<int, E_nc>>);
|
|
96
|
+
// Issue #1885: binding nested std::map<X, Container<E>> with E non-copyable
|
|
97
|
+
py::bind_map<std::map<int, std::vector<E_nc>>>(m, "MapVecENC");
|
|
98
|
+
m.def("get_nvnc", [](int n)
|
|
99
|
+
{
|
|
100
|
+
auto m = new std::map<int, std::vector<E_nc>>();
|
|
101
|
+
for (int i = 1; i <= n; i++)
|
|
102
|
+
for (int j = 1; j <= n; j++)
|
|
103
|
+
(*m)[i].emplace_back(j);
|
|
104
|
+
return m;
|
|
105
|
+
});
|
|
106
|
+
py::bind_map<std::map<int, std::map<int, E_nc>>>(m, "MapMapENC");
|
|
107
|
+
m.def("get_nmnc", ×_hundred<std::map<int, std::map<int, E_nc>>>);
|
|
108
|
+
py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(m, "UmapUmapENC");
|
|
109
|
+
m.def("get_numnc", ×_hundred<std::unordered_map<int, std::unordered_map<int, E_nc>>>);
|
|
110
|
+
|
|
111
|
+
// test_vector_buffer
|
|
112
|
+
py::bind_vector<std::vector<unsigned char>>(m, "VectorUChar", py::buffer_protocol());
|
|
113
|
+
// no dtype declared for this version:
|
|
114
|
+
struct VUndeclStruct { bool w; uint32_t x; double y; bool z; };
|
|
115
|
+
m.def("create_undeclstruct", [m] () mutable {
|
|
116
|
+
py::bind_vector<std::vector<VUndeclStruct>>(m, "VectorUndeclStruct", py::buffer_protocol());
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// The rest depends on numpy:
|
|
120
|
+
try { py::module_::import("numpy"); }
|
|
121
|
+
catch (...) { return; }
|
|
122
|
+
|
|
123
|
+
// test_vector_buffer_numpy
|
|
124
|
+
struct VStruct { bool w; uint32_t x; double y; bool z; };
|
|
125
|
+
PYBIND11_NUMPY_DTYPE(VStruct, w, x, y, z);
|
|
126
|
+
py::class_<VStruct>(m, "VStruct").def_readwrite("x", &VStruct::x);
|
|
127
|
+
py::bind_vector<std::vector<VStruct>>(m, "VectorStruct", py::buffer_protocol());
|
|
128
|
+
m.def("get_vectorstruct", [] {
|
|
129
|
+
return std::vector<VStruct>{{false, 5, 3.0, true}, {true, 30, -1e4, false}};
|
|
130
|
+
});
|
|
131
|
+
}
|