xcoll 0.4.0__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +2 -1
- xcoll/beam_elements/__init__.py +9 -2
- 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 +127 -81
- 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.1.dist-info}/METADATA +1 -1
- xcoll-0.5.1.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.1.dist-info}/LICENSE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/NOTICE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/*
|
|
2
|
+
tests/test_numpy_dtypes.cpp -- Structured and compound NumPy dtypes
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2016 Ivan Smirnov
|
|
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 <pybind11/numpy.h>
|
|
12
|
+
|
|
13
|
+
#ifdef __GNUC__
|
|
14
|
+
#define PYBIND11_PACKED(cls) cls __attribute__((__packed__))
|
|
15
|
+
#else
|
|
16
|
+
#define PYBIND11_PACKED(cls) __pragma(pack(push, 1)) cls __pragma(pack(pop))
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace py = pybind11;
|
|
20
|
+
|
|
21
|
+
struct SimpleStruct {
|
|
22
|
+
bool bool_;
|
|
23
|
+
uint32_t uint_;
|
|
24
|
+
float float_;
|
|
25
|
+
long double ldbl_;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
std::ostream& operator<<(std::ostream& os, const SimpleStruct& v) {
|
|
29
|
+
return os << "s:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
struct SimpleStructReordered {
|
|
33
|
+
bool bool_;
|
|
34
|
+
float float_;
|
|
35
|
+
uint32_t uint_;
|
|
36
|
+
long double ldbl_;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
PYBIND11_PACKED(struct PackedStruct {
|
|
40
|
+
bool bool_;
|
|
41
|
+
uint32_t uint_;
|
|
42
|
+
float float_;
|
|
43
|
+
long double ldbl_;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
std::ostream& operator<<(std::ostream& os, const PackedStruct& v) {
|
|
47
|
+
return os << "p:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
PYBIND11_PACKED(struct NestedStruct {
|
|
51
|
+
SimpleStruct a;
|
|
52
|
+
PackedStruct b;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
std::ostream& operator<<(std::ostream& os, const NestedStruct& v) {
|
|
56
|
+
return os << "n:a=" << v.a << ";b=" << v.b;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
struct PartialStruct {
|
|
60
|
+
bool bool_;
|
|
61
|
+
uint32_t uint_;
|
|
62
|
+
float float_;
|
|
63
|
+
uint64_t dummy2;
|
|
64
|
+
long double ldbl_;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
struct PartialNestedStruct {
|
|
68
|
+
uint64_t dummy1;
|
|
69
|
+
PartialStruct a;
|
|
70
|
+
uint64_t dummy2;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
struct UnboundStruct { };
|
|
74
|
+
|
|
75
|
+
struct StringStruct {
|
|
76
|
+
char a[3];
|
|
77
|
+
std::array<char, 3> b;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
struct ComplexStruct {
|
|
81
|
+
std::complex<float> cflt;
|
|
82
|
+
std::complex<double> cdbl;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
std::ostream& operator<<(std::ostream& os, const ComplexStruct& v) {
|
|
86
|
+
return os << "c:" << v.cflt << "," << v.cdbl;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
struct ArrayStruct {
|
|
90
|
+
char a[3][4];
|
|
91
|
+
int32_t b[2];
|
|
92
|
+
std::array<uint8_t, 3> c;
|
|
93
|
+
std::array<float, 2> d[4];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
PYBIND11_PACKED(struct StructWithUglyNames {
|
|
97
|
+
int8_t __x__;
|
|
98
|
+
uint64_t __y__;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
enum class E1 : int64_t { A = -1, B = 1 };
|
|
102
|
+
enum E2 : uint8_t { X = 1, Y = 2 };
|
|
103
|
+
|
|
104
|
+
PYBIND11_PACKED(struct EnumStruct {
|
|
105
|
+
E1 e1;
|
|
106
|
+
E2 e2;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
std::ostream& operator<<(std::ostream& os, const StringStruct& v) {
|
|
110
|
+
os << "a='";
|
|
111
|
+
for (size_t i = 0; i < 3 && (v.a[i] != 0); i++)
|
|
112
|
+
os << v.a[i];
|
|
113
|
+
os << "',b='";
|
|
114
|
+
for (size_t i = 0; i < 3 && (v.b[i] != 0); i++)
|
|
115
|
+
os << v.b[i];
|
|
116
|
+
return os << "'";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
std::ostream& operator<<(std::ostream& os, const ArrayStruct& v) {
|
|
120
|
+
os << "a={";
|
|
121
|
+
for (int i = 0; i < 3; i++) {
|
|
122
|
+
if (i > 0)
|
|
123
|
+
os << ',';
|
|
124
|
+
os << '{';
|
|
125
|
+
for (int j = 0; j < 3; j++)
|
|
126
|
+
os << v.a[i][j] << ',';
|
|
127
|
+
os << v.a[i][3] << '}';
|
|
128
|
+
}
|
|
129
|
+
os << "},b={" << v.b[0] << ',' << v.b[1];
|
|
130
|
+
os << "},c={" << int(v.c[0]) << ',' << int(v.c[1]) << ',' << int(v.c[2]);
|
|
131
|
+
os << "},d={";
|
|
132
|
+
for (int i = 0; i < 4; i++) {
|
|
133
|
+
if (i > 0)
|
|
134
|
+
os << ',';
|
|
135
|
+
os << '{' << v.d[i][0] << ',' << v.d[i][1] << '}';
|
|
136
|
+
}
|
|
137
|
+
return os << '}';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
std::ostream& operator<<(std::ostream& os, const EnumStruct& v) {
|
|
141
|
+
return os << "e1=" << (v.e1 == E1::A ? "A" : "B") << ",e2=" << (v.e2 == E2::X ? "X" : "Y");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
template <typename T>
|
|
145
|
+
py::array mkarray_via_buffer(size_t n) {
|
|
146
|
+
return py::array(py::buffer_info(nullptr, sizeof(T),
|
|
147
|
+
py::format_descriptor<T>::format(),
|
|
148
|
+
1, { n }, { sizeof(T) }));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#define SET_TEST_VALS(s, i) \
|
|
152
|
+
do { \
|
|
153
|
+
(s).bool_ = (i) % 2 != 0; \
|
|
154
|
+
(s).uint_ = (uint32_t) (i); \
|
|
155
|
+
(s).float_ = (float) (i) *1.5f; \
|
|
156
|
+
(s).ldbl_ = (long double) (i) * -2.5L; \
|
|
157
|
+
} while (0)
|
|
158
|
+
|
|
159
|
+
template <typename S>
|
|
160
|
+
py::array_t<S, 0> create_recarray(size_t n) {
|
|
161
|
+
auto arr = mkarray_via_buffer<S>(n);
|
|
162
|
+
auto req = arr.request();
|
|
163
|
+
auto ptr = static_cast<S*>(req.ptr);
|
|
164
|
+
for (size_t i = 0; i < n; i++) {
|
|
165
|
+
SET_TEST_VALS(ptr[i], i);
|
|
166
|
+
}
|
|
167
|
+
return arr;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
template <typename S>
|
|
171
|
+
py::list print_recarray(py::array_t<S, 0> arr) {
|
|
172
|
+
const auto req = arr.request();
|
|
173
|
+
const auto ptr = static_cast<S*>(req.ptr);
|
|
174
|
+
auto l = py::list();
|
|
175
|
+
for (py::ssize_t i = 0; i < req.size; i++) {
|
|
176
|
+
std::stringstream ss;
|
|
177
|
+
ss << ptr[i];
|
|
178
|
+
l.append(py::str(ss.str()));
|
|
179
|
+
}
|
|
180
|
+
return l;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
py::array_t<int32_t, 0> test_array_ctors(int i) {
|
|
184
|
+
using arr_t = py::array_t<int32_t, 0>;
|
|
185
|
+
|
|
186
|
+
std::vector<int32_t> data { 1, 2, 3, 4, 5, 6 };
|
|
187
|
+
std::vector<py::ssize_t> shape { 3, 2 };
|
|
188
|
+
std::vector<py::ssize_t> strides { 8, 4 };
|
|
189
|
+
|
|
190
|
+
auto ptr = data.data();
|
|
191
|
+
auto vptr = (void *) ptr;
|
|
192
|
+
auto dtype = py::dtype("int32");
|
|
193
|
+
|
|
194
|
+
py::buffer_info buf_ndim1(vptr, 4, "i", 6);
|
|
195
|
+
py::buffer_info buf_ndim1_null(nullptr, 4, "i", 6);
|
|
196
|
+
py::buffer_info buf_ndim2(vptr, 4, "i", 2, shape, strides);
|
|
197
|
+
py::buffer_info buf_ndim2_null(nullptr, 4, "i", 2, shape, strides);
|
|
198
|
+
|
|
199
|
+
auto fill = [](py::array arr) {
|
|
200
|
+
auto req = arr.request();
|
|
201
|
+
for (int i = 0; i < 6; i++) ((int32_t *) req.ptr)[i] = i + 1;
|
|
202
|
+
return arr;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
switch (i) {
|
|
206
|
+
// shape: (3, 2)
|
|
207
|
+
case 10: return arr_t(shape, strides, ptr);
|
|
208
|
+
case 11: return py::array(shape, strides, ptr);
|
|
209
|
+
case 12: return py::array(dtype, shape, strides, vptr);
|
|
210
|
+
case 13: return arr_t(shape, ptr);
|
|
211
|
+
case 14: return py::array(shape, ptr);
|
|
212
|
+
case 15: return py::array(dtype, shape, vptr);
|
|
213
|
+
case 16: return arr_t(buf_ndim2);
|
|
214
|
+
case 17: return py::array(buf_ndim2);
|
|
215
|
+
// shape: (3, 2) - post-fill
|
|
216
|
+
case 20: return fill(arr_t(shape, strides));
|
|
217
|
+
case 21: return py::array(shape, strides, ptr); // can't have nullptr due to templated ctor
|
|
218
|
+
case 22: return fill(py::array(dtype, shape, strides));
|
|
219
|
+
case 23: return fill(arr_t(shape));
|
|
220
|
+
case 24: return py::array(shape, ptr); // can't have nullptr due to templated ctor
|
|
221
|
+
case 25: return fill(py::array(dtype, shape));
|
|
222
|
+
case 26: return fill(arr_t(buf_ndim2_null));
|
|
223
|
+
case 27: return fill(py::array(buf_ndim2_null));
|
|
224
|
+
// shape: (6, )
|
|
225
|
+
case 30: return arr_t(6, ptr);
|
|
226
|
+
case 31: return py::array(6, ptr);
|
|
227
|
+
case 32: return py::array(dtype, 6, vptr);
|
|
228
|
+
case 33: return arr_t(buf_ndim1);
|
|
229
|
+
case 34: return py::array(buf_ndim1);
|
|
230
|
+
// shape: (6, )
|
|
231
|
+
case 40: return fill(arr_t(6));
|
|
232
|
+
case 41: return py::array(6, ptr); // can't have nullptr due to templated ctor
|
|
233
|
+
case 42: return fill(py::array(dtype, 6));
|
|
234
|
+
case 43: return fill(arr_t(buf_ndim1_null));
|
|
235
|
+
case 44: return fill(py::array(buf_ndim1_null));
|
|
236
|
+
}
|
|
237
|
+
return arr_t();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
py::list test_dtype_ctors() {
|
|
241
|
+
py::list list;
|
|
242
|
+
list.append(py::dtype("int32"));
|
|
243
|
+
list.append(py::dtype(std::string("float64")));
|
|
244
|
+
list.append(py::dtype::from_args(py::str("bool")));
|
|
245
|
+
py::list names, offsets, formats;
|
|
246
|
+
py::dict dict;
|
|
247
|
+
names.append(py::str("a")); names.append(py::str("b")); dict["names"] = names;
|
|
248
|
+
offsets.append(py::int_(1)); offsets.append(py::int_(10)); dict["offsets"] = offsets;
|
|
249
|
+
formats.append(py::dtype("int32")); formats.append(py::dtype("float64")); dict["formats"] = formats;
|
|
250
|
+
dict["itemsize"] = py::int_(20);
|
|
251
|
+
list.append(py::dtype::from_args(dict));
|
|
252
|
+
list.append(py::dtype(names, formats, offsets, 20));
|
|
253
|
+
list.append(py::dtype(py::buffer_info((void *) 0, sizeof(unsigned int), "I", 1)));
|
|
254
|
+
list.append(py::dtype(py::buffer_info((void *) 0, 0, "T{i:a:f:b:}", 1)));
|
|
255
|
+
return list;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
struct A {};
|
|
259
|
+
struct B {};
|
|
260
|
+
|
|
261
|
+
TEST_SUBMODULE(numpy_dtypes, m) {
|
|
262
|
+
try { py::module_::import("numpy"); }
|
|
263
|
+
catch (...) { return; }
|
|
264
|
+
|
|
265
|
+
// typeinfo may be registered before the dtype descriptor for scalar casts to work...
|
|
266
|
+
py::class_<SimpleStruct>(m, "SimpleStruct")
|
|
267
|
+
// Explicit construct to ensure zero-valued initialization.
|
|
268
|
+
.def(py::init([]() { return SimpleStruct(); }))
|
|
269
|
+
.def_readwrite("bool_", &SimpleStruct::bool_)
|
|
270
|
+
.def_readwrite("uint_", &SimpleStruct::uint_)
|
|
271
|
+
.def_readwrite("float_", &SimpleStruct::float_)
|
|
272
|
+
.def_readwrite("ldbl_", &SimpleStruct::ldbl_)
|
|
273
|
+
.def("astuple",
|
|
274
|
+
[](const SimpleStruct &self) {
|
|
275
|
+
return py::make_tuple(self.bool_, self.uint_, self.float_, self.ldbl_);
|
|
276
|
+
})
|
|
277
|
+
.def_static("fromtuple", [](const py::tuple &tup) {
|
|
278
|
+
if (py::len(tup) != 4) {
|
|
279
|
+
throw py::cast_error("Invalid size");
|
|
280
|
+
}
|
|
281
|
+
return SimpleStruct{
|
|
282
|
+
tup[0].cast<bool>(),
|
|
283
|
+
tup[1].cast<uint32_t>(),
|
|
284
|
+
tup[2].cast<float>(),
|
|
285
|
+
tup[3].cast<long double>()};
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_);
|
|
289
|
+
PYBIND11_NUMPY_DTYPE(SimpleStructReordered, bool_, uint_, float_, ldbl_);
|
|
290
|
+
PYBIND11_NUMPY_DTYPE(PackedStruct, bool_, uint_, float_, ldbl_);
|
|
291
|
+
PYBIND11_NUMPY_DTYPE(NestedStruct, a, b);
|
|
292
|
+
PYBIND11_NUMPY_DTYPE(PartialStruct, bool_, uint_, float_, ldbl_);
|
|
293
|
+
PYBIND11_NUMPY_DTYPE(PartialNestedStruct, a);
|
|
294
|
+
PYBIND11_NUMPY_DTYPE(StringStruct, a, b);
|
|
295
|
+
PYBIND11_NUMPY_DTYPE(ArrayStruct, a, b, c, d);
|
|
296
|
+
PYBIND11_NUMPY_DTYPE(EnumStruct, e1, e2);
|
|
297
|
+
PYBIND11_NUMPY_DTYPE(ComplexStruct, cflt, cdbl);
|
|
298
|
+
|
|
299
|
+
// ... or after
|
|
300
|
+
py::class_<PackedStruct>(m, "PackedStruct");
|
|
301
|
+
|
|
302
|
+
PYBIND11_NUMPY_DTYPE_EX(StructWithUglyNames, __x__, "x", __y__, "y");
|
|
303
|
+
|
|
304
|
+
// If uncommented, this should produce a static_assert failure telling the user that the struct
|
|
305
|
+
// is not a POD type
|
|
306
|
+
// struct NotPOD { std::string v; NotPOD() : v("hi") {}; };
|
|
307
|
+
// PYBIND11_NUMPY_DTYPE(NotPOD, v);
|
|
308
|
+
|
|
309
|
+
// Check that dtypes can be registered programmatically, both from
|
|
310
|
+
// initializer lists of field descriptors and from other containers.
|
|
311
|
+
py::detail::npy_format_descriptor<A>::register_dtype(
|
|
312
|
+
{}
|
|
313
|
+
);
|
|
314
|
+
py::detail::npy_format_descriptor<B>::register_dtype(
|
|
315
|
+
std::vector<py::detail::field_descriptor>{}
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
// test_recarray, test_scalar_conversion
|
|
319
|
+
m.def("create_rec_simple", &create_recarray<SimpleStruct>);
|
|
320
|
+
m.def("create_rec_packed", &create_recarray<PackedStruct>);
|
|
321
|
+
m.def("create_rec_nested", [](size_t n) { // test_signature
|
|
322
|
+
py::array_t<NestedStruct, 0> arr = mkarray_via_buffer<NestedStruct>(n);
|
|
323
|
+
auto req = arr.request();
|
|
324
|
+
auto ptr = static_cast<NestedStruct*>(req.ptr);
|
|
325
|
+
for (size_t i = 0; i < n; i++) {
|
|
326
|
+
SET_TEST_VALS(ptr[i].a, i);
|
|
327
|
+
SET_TEST_VALS(ptr[i].b, i + 1);
|
|
328
|
+
}
|
|
329
|
+
return arr;
|
|
330
|
+
});
|
|
331
|
+
m.def("create_rec_partial", &create_recarray<PartialStruct>);
|
|
332
|
+
m.def("create_rec_partial_nested", [](size_t n) {
|
|
333
|
+
py::array_t<PartialNestedStruct, 0> arr = mkarray_via_buffer<PartialNestedStruct>(n);
|
|
334
|
+
auto req = arr.request();
|
|
335
|
+
auto ptr = static_cast<PartialNestedStruct*>(req.ptr);
|
|
336
|
+
for (size_t i = 0; i < n; i++) {
|
|
337
|
+
SET_TEST_VALS(ptr[i].a, i);
|
|
338
|
+
}
|
|
339
|
+
return arr;
|
|
340
|
+
});
|
|
341
|
+
m.def("print_rec_simple", &print_recarray<SimpleStruct>);
|
|
342
|
+
m.def("print_rec_packed", &print_recarray<PackedStruct>);
|
|
343
|
+
m.def("print_rec_nested", &print_recarray<NestedStruct>);
|
|
344
|
+
|
|
345
|
+
// test_format_descriptors
|
|
346
|
+
m.def("get_format_unbound", []() { return py::format_descriptor<UnboundStruct>::format(); });
|
|
347
|
+
m.def("print_format_descriptors", []() {
|
|
348
|
+
py::list l;
|
|
349
|
+
for (const auto &fmt : {
|
|
350
|
+
py::format_descriptor<SimpleStruct>::format(),
|
|
351
|
+
py::format_descriptor<PackedStruct>::format(),
|
|
352
|
+
py::format_descriptor<NestedStruct>::format(),
|
|
353
|
+
py::format_descriptor<PartialStruct>::format(),
|
|
354
|
+
py::format_descriptor<PartialNestedStruct>::format(),
|
|
355
|
+
py::format_descriptor<StringStruct>::format(),
|
|
356
|
+
py::format_descriptor<ArrayStruct>::format(),
|
|
357
|
+
py::format_descriptor<EnumStruct>::format(),
|
|
358
|
+
py::format_descriptor<ComplexStruct>::format()
|
|
359
|
+
}) {
|
|
360
|
+
l.append(py::cast(fmt));
|
|
361
|
+
}
|
|
362
|
+
return l;
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
// test_dtype
|
|
366
|
+
std::vector<const char *> dtype_names{
|
|
367
|
+
"byte", "short", "intc", "int_", "longlong",
|
|
368
|
+
"ubyte", "ushort", "uintc", "uint", "ulonglong",
|
|
369
|
+
"half", "single", "double", "longdouble",
|
|
370
|
+
"csingle", "cdouble", "clongdouble",
|
|
371
|
+
"bool_", "datetime64", "timedelta64", "object_"
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
m.def("print_dtypes", []() {
|
|
375
|
+
py::list l;
|
|
376
|
+
for (const py::handle &d : {
|
|
377
|
+
py::dtype::of<SimpleStruct>(),
|
|
378
|
+
py::dtype::of<PackedStruct>(),
|
|
379
|
+
py::dtype::of<NestedStruct>(),
|
|
380
|
+
py::dtype::of<PartialStruct>(),
|
|
381
|
+
py::dtype::of<PartialNestedStruct>(),
|
|
382
|
+
py::dtype::of<StringStruct>(),
|
|
383
|
+
py::dtype::of<ArrayStruct>(),
|
|
384
|
+
py::dtype::of<EnumStruct>(),
|
|
385
|
+
py::dtype::of<StructWithUglyNames>(),
|
|
386
|
+
py::dtype::of<ComplexStruct>()
|
|
387
|
+
})
|
|
388
|
+
l.append(py::str(d));
|
|
389
|
+
return l;
|
|
390
|
+
});
|
|
391
|
+
m.def("test_dtype_ctors", &test_dtype_ctors);
|
|
392
|
+
m.def("test_dtype_kind", [dtype_names]() {
|
|
393
|
+
py::list list;
|
|
394
|
+
for (auto& dt_name : dtype_names)
|
|
395
|
+
list.append(py::dtype(dt_name).kind());
|
|
396
|
+
return list;
|
|
397
|
+
});
|
|
398
|
+
m.def("test_dtype_char_", [dtype_names]() {
|
|
399
|
+
py::list list;
|
|
400
|
+
for (auto& dt_name : dtype_names)
|
|
401
|
+
list.append(py::dtype(dt_name).char_());
|
|
402
|
+
return list;
|
|
403
|
+
});
|
|
404
|
+
m.def("test_dtype_methods", []() {
|
|
405
|
+
py::list list;
|
|
406
|
+
auto dt1 = py::dtype::of<int32_t>();
|
|
407
|
+
auto dt2 = py::dtype::of<SimpleStruct>();
|
|
408
|
+
list.append(dt1); list.append(dt2);
|
|
409
|
+
list.append(py::bool_(dt1.has_fields())); list.append(py::bool_(dt2.has_fields()));
|
|
410
|
+
list.append(py::int_(dt1.itemsize())); list.append(py::int_(dt2.itemsize()));
|
|
411
|
+
return list;
|
|
412
|
+
});
|
|
413
|
+
struct TrailingPaddingStruct {
|
|
414
|
+
int32_t a;
|
|
415
|
+
char b;
|
|
416
|
+
};
|
|
417
|
+
PYBIND11_NUMPY_DTYPE(TrailingPaddingStruct, a, b);
|
|
418
|
+
m.def("trailing_padding_dtype", []() { return py::dtype::of<TrailingPaddingStruct>(); });
|
|
419
|
+
|
|
420
|
+
// test_string_array
|
|
421
|
+
m.def("create_string_array", [](bool non_empty) {
|
|
422
|
+
py::array_t<StringStruct, 0> arr = mkarray_via_buffer<StringStruct>(non_empty ? 4 : 0);
|
|
423
|
+
if (non_empty) {
|
|
424
|
+
auto req = arr.request();
|
|
425
|
+
auto ptr = static_cast<StringStruct*>(req.ptr);
|
|
426
|
+
for (py::ssize_t i = 0; i < req.size * req.itemsize; i++)
|
|
427
|
+
static_cast<char*>(req.ptr)[i] = 0;
|
|
428
|
+
ptr[1].a[0] = 'a'; ptr[1].b[0] = 'a';
|
|
429
|
+
ptr[2].a[0] = 'a'; ptr[2].b[0] = 'a';
|
|
430
|
+
ptr[3].a[0] = 'a'; ptr[3].b[0] = 'a';
|
|
431
|
+
|
|
432
|
+
ptr[2].a[1] = 'b'; ptr[2].b[1] = 'b';
|
|
433
|
+
ptr[3].a[1] = 'b'; ptr[3].b[1] = 'b';
|
|
434
|
+
|
|
435
|
+
ptr[3].a[2] = 'c'; ptr[3].b[2] = 'c';
|
|
436
|
+
}
|
|
437
|
+
return arr;
|
|
438
|
+
});
|
|
439
|
+
m.def("print_string_array", &print_recarray<StringStruct>);
|
|
440
|
+
|
|
441
|
+
// test_array_array
|
|
442
|
+
m.def("create_array_array", [](size_t n) {
|
|
443
|
+
py::array_t<ArrayStruct, 0> arr = mkarray_via_buffer<ArrayStruct>(n);
|
|
444
|
+
auto ptr = (ArrayStruct *) arr.mutable_data();
|
|
445
|
+
for (size_t i = 0; i < n; i++) {
|
|
446
|
+
for (size_t j = 0; j < 3; j++)
|
|
447
|
+
for (size_t k = 0; k < 4; k++)
|
|
448
|
+
ptr[i].a[j][k] = char('A' + (i * 100 + j * 10 + k) % 26);
|
|
449
|
+
for (size_t j = 0; j < 2; j++)
|
|
450
|
+
ptr[i].b[j] = int32_t(i * 1000 + j);
|
|
451
|
+
for (size_t j = 0; j < 3; j++)
|
|
452
|
+
ptr[i].c[j] = uint8_t(i * 10 + j);
|
|
453
|
+
for (size_t j = 0; j < 4; j++)
|
|
454
|
+
for (size_t k = 0; k < 2; k++)
|
|
455
|
+
ptr[i].d[j][k] = float(i) * 100.0f + float(j) * 10.0f + float(k);
|
|
456
|
+
}
|
|
457
|
+
return arr;
|
|
458
|
+
});
|
|
459
|
+
m.def("print_array_array", &print_recarray<ArrayStruct>);
|
|
460
|
+
|
|
461
|
+
// test_enum_array
|
|
462
|
+
m.def("create_enum_array", [](size_t n) {
|
|
463
|
+
py::array_t<EnumStruct, 0> arr = mkarray_via_buffer<EnumStruct>(n);
|
|
464
|
+
auto ptr = (EnumStruct *) arr.mutable_data();
|
|
465
|
+
for (size_t i = 0; i < n; i++) {
|
|
466
|
+
ptr[i].e1 = static_cast<E1>(-1 + ((int) i % 2) * 2);
|
|
467
|
+
ptr[i].e2 = static_cast<E2>(1 + (i % 2));
|
|
468
|
+
}
|
|
469
|
+
return arr;
|
|
470
|
+
});
|
|
471
|
+
m.def("print_enum_array", &print_recarray<EnumStruct>);
|
|
472
|
+
|
|
473
|
+
// test_complex_array
|
|
474
|
+
m.def("create_complex_array", [](size_t n) {
|
|
475
|
+
py::array_t<ComplexStruct, 0> arr = mkarray_via_buffer<ComplexStruct>(n);
|
|
476
|
+
auto ptr = (ComplexStruct *) arr.mutable_data();
|
|
477
|
+
for (size_t i = 0; i < n; i++) {
|
|
478
|
+
ptr[i].cflt.real(float(i));
|
|
479
|
+
ptr[i].cflt.imag(float(i) + 0.25f);
|
|
480
|
+
ptr[i].cdbl.real(double(i) + 0.5);
|
|
481
|
+
ptr[i].cdbl.imag(double(i) + 0.75);
|
|
482
|
+
}
|
|
483
|
+
return arr;
|
|
484
|
+
});
|
|
485
|
+
m.def("print_complex_array", &print_recarray<ComplexStruct>);
|
|
486
|
+
|
|
487
|
+
// test_array_constructors
|
|
488
|
+
m.def("test_array_ctors", &test_array_ctors);
|
|
489
|
+
|
|
490
|
+
// test_compare_buffer_info
|
|
491
|
+
struct CompareStruct {
|
|
492
|
+
bool x;
|
|
493
|
+
uint32_t y;
|
|
494
|
+
float z;
|
|
495
|
+
};
|
|
496
|
+
PYBIND11_NUMPY_DTYPE(CompareStruct, x, y, z);
|
|
497
|
+
m.def("compare_buffer_info", []() {
|
|
498
|
+
py::list list;
|
|
499
|
+
list.append(py::bool_(py::detail::compare_buffer_info<float>::compare(py::buffer_info(nullptr, sizeof(float), "f", 1))));
|
|
500
|
+
list.append(py::bool_(py::detail::compare_buffer_info<unsigned>::compare(py::buffer_info(nullptr, sizeof(int), "I", 1))));
|
|
501
|
+
list.append(py::bool_(py::detail::compare_buffer_info<long>::compare(py::buffer_info(nullptr, sizeof(long), "l", 1))));
|
|
502
|
+
list.append(py::bool_(py::detail::compare_buffer_info<long>::compare(py::buffer_info(nullptr, sizeof(long), sizeof(long) == sizeof(int) ? "i" : "q", 1))));
|
|
503
|
+
list.append(py::bool_(py::detail::compare_buffer_info<CompareStruct>::compare(py::buffer_info(nullptr, sizeof(CompareStruct), "T{?:x:3xI:y:f:z:}", 1))));
|
|
504
|
+
return list;
|
|
505
|
+
});
|
|
506
|
+
m.def("buffer_to_dtype", [](py::buffer& buf) { return py::dtype(buf.request()); });
|
|
507
|
+
|
|
508
|
+
// test_scalar_conversion
|
|
509
|
+
auto f_simple = [](SimpleStruct s) { return s.uint_ * 10; };
|
|
510
|
+
m.def("f_simple", f_simple);
|
|
511
|
+
m.def("f_packed", [](PackedStruct s) { return s.uint_ * 10; });
|
|
512
|
+
m.def("f_nested", [](NestedStruct s) { return s.a.uint_ * 10; });
|
|
513
|
+
|
|
514
|
+
// test_vectorize
|
|
515
|
+
m.def("f_simple_vectorized", py::vectorize(f_simple));
|
|
516
|
+
auto f_simple_pass_thru = [](SimpleStruct s) { return s; };
|
|
517
|
+
m.def("f_simple_pass_thru_vectorized", py::vectorize(f_simple_pass_thru));
|
|
518
|
+
|
|
519
|
+
// test_register_dtype
|
|
520
|
+
m.def("register_dtype", []() { PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_); });
|
|
521
|
+
|
|
522
|
+
// test_str_leak
|
|
523
|
+
m.def("dtype_wrapper", [](py::object d) { return py::dtype::from_args(std::move(d)); });
|
|
524
|
+
}
|