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.

Files changed (324) hide show
  1. xcoll/__init__.py +2 -1
  2. xcoll/beam_elements/__init__.py +9 -2
  3. xcoll/beam_elements/absorber.py +2 -2
  4. xcoll/beam_elements/base.py +105 -67
  5. xcoll/beam_elements/blowup.py +198 -0
  6. xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
  7. xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
  8. xcoll/beam_elements/elements_src/blowup.h +42 -0
  9. xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
  10. xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +19 -2
  11. xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
  12. xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
  13. xcoll/beam_elements/everest.py +5 -6
  14. xcoll/beam_elements/monitor.py +428 -0
  15. xcoll/colldb.py +103 -74
  16. xcoll/general.py +4 -4
  17. xcoll/initial_distribution.py +18 -6
  18. xcoll/install.py +3 -1
  19. xcoll/interaction_record/interaction_record.py +127 -81
  20. xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
  21. xcoll/line_tools.py +8 -9
  22. xcoll/lossmap.py +48 -38
  23. xcoll/scattering_routines/everest/amorphous.h +4 -11
  24. xcoll/scattering_routines/everest/channeling.h +3 -8
  25. xcoll/scattering_routines/everest/everest.h +4 -1
  26. xcoll/scattering_routines/everest/jaw.h +4 -3
  27. xcoll/scattering_routines/everest/materials.py +35 -15
  28. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  29. xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
  30. xcoll/scattering_routines/everest/properties.h +6 -1
  31. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  32. xcoll/scattering_routines/geant4/collimasim/.git +1 -0
  33. xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
  34. xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
  35. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
  36. xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
  37. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
  38. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
  39. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
  40. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
  41. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
  42. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
  43. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
  44. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
  45. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
  46. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
  47. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
  48. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
  49. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
  275. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
  276. xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
  277. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
  278. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
  279. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
  280. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
  281. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
  282. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
  283. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
  284. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
  290. xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
  291. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
  292. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
  293. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
  294. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
  295. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
  296. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
  297. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
  298. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
  303. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
  304. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
  305. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
  306. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
  307. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
  308. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
  309. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
  310. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
  316. xcoll/scattering_routines/geometry/collimator_geometry.h +9 -10
  317. xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
  318. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/METADATA +1 -1
  319. xcoll-0.5.1.dist-info/RECORD +413 -0
  320. xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
  321. xcoll-0.4.0.dist-info/RECORD +0 -126
  322. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/LICENSE +0 -0
  323. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/NOTICE +0 -0
  324. {xcoll-0.4.0.dist-info → xcoll-0.5.1.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", &times_ten<std::map<int, E_nc>>);
94
+ py::bind_map<std::unordered_map<int, E_nc>>(m, "UmapENC");
95
+ m.def("get_umnc", &times_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", &times_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", &times_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
+ }