xcoll 0.5.11__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xcoll might be problematic. Click here for more details.

Files changed (333) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/beam_elements/__init__.py +1 -0
  3. xcoll/beam_elements/absorber.py +12 -2
  4. xcoll/beam_elements/base.py +162 -62
  5. xcoll/beam_elements/blowup.py +1 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  7. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  8. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  9. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  10. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  11. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  12. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  13. xcoll/beam_elements/everest.py +16 -5
  14. xcoll/beam_elements/monitor.py +1 -0
  15. xcoll/beam_elements/transparent.py +83 -0
  16. xcoll/colldb.py +15 -6
  17. xcoll/general.py +1 -1
  18. xcoll/headers/particle_states.py +51 -0
  19. xcoll/initial_distribution.py +129 -103
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -74
  23. xcoll/lossmap.py +519 -127
  24. xcoll/plot.py +109 -0
  25. xcoll/rf_sweep.py +6 -0
  26. xcoll/scattering_routines/engine.py +600 -0
  27. xcoll/scattering_routines/environment.py +297 -0
  28. xcoll/scattering_routines/everest/amorphous.h +95 -71
  29. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  30. xcoll/scattering_routines/everest/constants.h +1 -1
  31. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  32. xcoll/scattering_routines/everest/everest.h +8 -3
  33. xcoll/scattering_routines/everest/everest.py +2 -1
  34. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  35. xcoll/scattering_routines/everest/jaw.h +19 -24
  36. xcoll/scattering_routines/everest/materials.py +2 -0
  37. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  38. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  39. xcoll/scattering_routines/everest/properties.h +4 -73
  40. xcoll/xaux.py +73 -0
  41. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
  42. xcoll-0.6.0.dist-info/RECORD +135 -0
  43. xcoll/_manager.py +0 -22
  44. xcoll/headers/particle_states.h +0 -25
  45. xcoll/install.py +0 -35
  46. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  47. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  48. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  49. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  50. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  51. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  52. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  53. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  54. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  55. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  289. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  290. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  304. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  330. xcoll-0.5.11.dist-info/RECORD +0 -413
  331. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,510 +0,0 @@
1
- /*
2
- tests/test_virtual_functions.cpp -- overriding virtual functions from Python
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include "constructor_stats.h"
12
- #include <pybind11/functional.h>
13
- #include <thread>
14
-
15
- /* This is an example class that we'll want to be able to extend from Python */
16
- class ExampleVirt {
17
- public:
18
- explicit ExampleVirt(int state) : state(state) { print_created(this, state); }
19
- ExampleVirt(const ExampleVirt &e) : state(e.state) { print_copy_created(this); }
20
- ExampleVirt(ExampleVirt &&e) noexcept : state(e.state) {
21
- print_move_created(this);
22
- e.state = 0;
23
- }
24
- virtual ~ExampleVirt() { print_destroyed(this); }
25
-
26
- virtual int run(int value) {
27
- py::print("Original implementation of "
28
- "ExampleVirt::run(state={}, value={}, str1={}, str2={})"_s.format(state, value, get_string1(), *get_string2()));
29
- return state + value;
30
- }
31
-
32
- virtual bool run_bool() = 0;
33
- virtual void pure_virtual() = 0;
34
-
35
- // Returning a reference/pointer to a type converted from python (numbers, strings, etc.) is a
36
- // bit trickier, because the actual int& or std::string& or whatever only exists temporarily, so
37
- // we have to handle it specially in the trampoline class (see below).
38
- virtual const std::string &get_string1() { return str1; }
39
- virtual const std::string *get_string2() { return &str2; }
40
-
41
- private:
42
- int state;
43
- const std::string str1{"default1"}, str2{"default2"};
44
- };
45
-
46
- /* This is a wrapper class that must be generated */
47
- class PyExampleVirt : public ExampleVirt {
48
- public:
49
- using ExampleVirt::ExampleVirt; /* Inherit constructors */
50
-
51
- int run(int value) override {
52
- /* Generate wrapping code that enables native function overloading */
53
- PYBIND11_OVERRIDE(
54
- int, /* Return type */
55
- ExampleVirt, /* Parent class */
56
- run, /* Name of function */
57
- value /* Argument(s) */
58
- );
59
- }
60
-
61
- bool run_bool() override {
62
- PYBIND11_OVERRIDE_PURE(
63
- bool, /* Return type */
64
- ExampleVirt, /* Parent class */
65
- run_bool, /* Name of function */
66
- /* This function has no arguments. The trailing comma
67
- in the previous line is needed for some compilers */
68
- );
69
- }
70
-
71
- void pure_virtual() override {
72
- PYBIND11_OVERRIDE_PURE(
73
- void, /* Return type */
74
- ExampleVirt, /* Parent class */
75
- pure_virtual, /* Name of function */
76
- /* This function has no arguments. The trailing comma
77
- in the previous line is needed for some compilers */
78
- );
79
- }
80
-
81
- // We can return reference types for compatibility with C++ virtual interfaces that do so, but
82
- // note they have some significant limitations (see the documentation).
83
- const std::string &get_string1() override {
84
- PYBIND11_OVERRIDE(
85
- const std::string &, /* Return type */
86
- ExampleVirt, /* Parent class */
87
- get_string1, /* Name of function */
88
- /* (no arguments) */
89
- );
90
- }
91
-
92
- const std::string *get_string2() override {
93
- PYBIND11_OVERRIDE(
94
- const std::string *, /* Return type */
95
- ExampleVirt, /* Parent class */
96
- get_string2, /* Name of function */
97
- /* (no arguments) */
98
- );
99
- }
100
-
101
- };
102
-
103
- class NonCopyable {
104
- public:
105
- NonCopyable(int a, int b) : value{new int(a*b)} { print_created(this, a, b); }
106
- NonCopyable(NonCopyable &&o) noexcept {
107
- value = std::move(o.value);
108
- print_move_created(this);
109
- }
110
- NonCopyable(const NonCopyable &) = delete;
111
- NonCopyable() = delete;
112
- void operator=(const NonCopyable &) = delete;
113
- void operator=(NonCopyable &&) = delete;
114
- std::string get_value() const {
115
- if (value)
116
- return std::to_string(*value);
117
- return "(null)";
118
- }
119
- ~NonCopyable() { print_destroyed(this); }
120
-
121
- private:
122
- std::unique_ptr<int> value;
123
- };
124
-
125
- // This is like the above, but is both copy and movable. In effect this means it should get moved
126
- // when it is not referenced elsewhere, but copied if it is still referenced.
127
- class Movable {
128
- public:
129
- Movable(int a, int b) : value{a+b} { print_created(this, a, b); }
130
- Movable(const Movable &m) { value = m.value; print_copy_created(this); }
131
- Movable(Movable &&m) noexcept {
132
- value = m.value;
133
- print_move_created(this);
134
- }
135
- std::string get_value() const { return std::to_string(value); }
136
- ~Movable() { print_destroyed(this); }
137
- private:
138
- int value;
139
- };
140
-
141
- class NCVirt {
142
- public:
143
- virtual ~NCVirt() = default;
144
- NCVirt() = default;
145
- NCVirt(const NCVirt&) = delete;
146
- virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); }
147
- virtual Movable get_movable(int a, int b) = 0;
148
-
149
- std::string print_nc(int a, int b) { return get_noncopyable(a, b).get_value(); }
150
- std::string print_movable(int a, int b) { return get_movable(a, b).get_value(); }
151
- };
152
- class NCVirtTrampoline : public NCVirt {
153
- #if !defined(__INTEL_COMPILER) && !defined(__CUDACC__) && !defined(__PGIC__)
154
- NonCopyable get_noncopyable(int a, int b) override {
155
- PYBIND11_OVERRIDE(NonCopyable, NCVirt, get_noncopyable, a, b);
156
- }
157
- #endif
158
- Movable get_movable(int a, int b) override {
159
- PYBIND11_OVERRIDE_PURE(Movable, NCVirt, get_movable, a, b);
160
- }
161
- };
162
-
163
- struct Base {
164
- /* for some reason MSVC2015 can't compile this if the function is pure virtual */
165
- virtual std::string dispatch() const { return {}; };
166
- virtual ~Base() = default;
167
- Base() = default;
168
- Base(const Base&) = delete;
169
- };
170
-
171
- struct DispatchIssue : Base {
172
- std::string dispatch() const override {
173
- PYBIND11_OVERRIDE_PURE(std::string, Base, dispatch, /* no arguments */);
174
- }
175
- };
176
-
177
- static void test_gil() {
178
- {
179
- py::gil_scoped_acquire lock;
180
- py::print("1st lock acquired");
181
-
182
- }
183
-
184
- {
185
- py::gil_scoped_acquire lock;
186
- py::print("2nd lock acquired");
187
- }
188
-
189
- }
190
-
191
- static void test_gil_from_thread() {
192
- py::gil_scoped_release release;
193
-
194
- std::thread t(test_gil);
195
- t.join();
196
- }
197
-
198
-
199
- // Forward declaration (so that we can put the main tests here; the inherited virtual approaches are
200
- // rather long).
201
- void initialize_inherited_virtuals(py::module_ &m);
202
-
203
- TEST_SUBMODULE(virtual_functions, m) {
204
- // test_override
205
- py::class_<ExampleVirt, PyExampleVirt>(m, "ExampleVirt")
206
- .def(py::init<int>())
207
- /* Reference original class in function definitions */
208
- .def("run", &ExampleVirt::run)
209
- .def("run_bool", &ExampleVirt::run_bool)
210
- .def("pure_virtual", &ExampleVirt::pure_virtual);
211
-
212
- py::class_<NonCopyable>(m, "NonCopyable")
213
- .def(py::init<int, int>());
214
-
215
- py::class_<Movable>(m, "Movable")
216
- .def(py::init<int, int>());
217
-
218
- // test_move_support
219
- #if !defined(__INTEL_COMPILER) && !defined(__CUDACC__) && !defined(__PGIC__)
220
- py::class_<NCVirt, NCVirtTrampoline>(m, "NCVirt")
221
- .def(py::init<>())
222
- .def("get_noncopyable", &NCVirt::get_noncopyable)
223
- .def("get_movable", &NCVirt::get_movable)
224
- .def("print_nc", &NCVirt::print_nc)
225
- .def("print_movable", &NCVirt::print_movable);
226
- #endif
227
-
228
- m.def("runExampleVirt", [](ExampleVirt *ex, int value) { return ex->run(value); });
229
- m.def("runExampleVirtBool", [](ExampleVirt* ex) { return ex->run_bool(); });
230
- m.def("runExampleVirtVirtual", [](ExampleVirt *ex) { ex->pure_virtual(); });
231
-
232
- m.def("cstats_debug", &ConstructorStats::get<ExampleVirt>);
233
- initialize_inherited_virtuals(m);
234
-
235
- // test_alias_delay_initialization1
236
- // don't invoke Python dispatch classes by default when instantiating C++ classes
237
- // that were not extended on the Python side
238
- struct A {
239
- A() = default;
240
- A(const A&) = delete;
241
- virtual ~A() = default;
242
- virtual void f() { py::print("A.f()"); }
243
- };
244
-
245
- struct PyA : A {
246
- PyA() { py::print("PyA.PyA()"); }
247
- PyA(const PyA&) = delete;
248
- ~PyA() override { py::print("PyA.~PyA()"); }
249
-
250
- void f() override {
251
- py::print("PyA.f()");
252
- // This convolution just gives a `void`, but tests that PYBIND11_TYPE() works to protect
253
- // a type containing a ,
254
- PYBIND11_OVERRIDE(PYBIND11_TYPE(typename std::enable_if<true, void>::type), A, f);
255
- }
256
- };
257
-
258
- py::class_<A, PyA>(m, "A")
259
- .def(py::init<>())
260
- .def("f", &A::f);
261
-
262
- m.def("call_f", [](A *a) { a->f(); });
263
-
264
- // test_alias_delay_initialization2
265
- // ... unless we explicitly request it, as in this example:
266
- struct A2 {
267
- A2() = default;
268
- A2(const A2&) = delete;
269
- virtual ~A2() = default;
270
- virtual void f() { py::print("A2.f()"); }
271
- };
272
-
273
- struct PyA2 : A2 {
274
- PyA2() { py::print("PyA2.PyA2()"); }
275
- PyA2(const PyA2&) = delete;
276
- ~PyA2() override { py::print("PyA2.~PyA2()"); }
277
- void f() override {
278
- py::print("PyA2.f()");
279
- PYBIND11_OVERRIDE(void, A2, f);
280
- }
281
- };
282
-
283
- py::class_<A2, PyA2>(m, "A2")
284
- .def(py::init_alias<>())
285
- .def(py::init([](int) { return new PyA2(); }))
286
- .def("f", &A2::f);
287
-
288
- m.def("call_f", [](A2 *a2) { a2->f(); });
289
-
290
- // test_dispatch_issue
291
- // #159: virtual function dispatch has problems with similar-named functions
292
- py::class_<Base, DispatchIssue>(m, "DispatchIssue")
293
- .def(py::init<>())
294
- .def("dispatch", &Base::dispatch);
295
-
296
- m.def("dispatch_issue_go", [](const Base * b) { return b->dispatch(); });
297
-
298
- // test_override_ref
299
- // #392/397: overriding reference-returning functions
300
- class OverrideTest {
301
- public:
302
- struct A { std::string value = "hi"; };
303
- std::string v;
304
- A a;
305
- explicit OverrideTest(const std::string &v) : v{v} {}
306
- OverrideTest() = default;
307
- OverrideTest(const OverrideTest&) = delete;
308
- virtual std::string str_value() { return v; }
309
- virtual std::string &str_ref() { return v; }
310
- virtual A A_value() { return a; }
311
- virtual A &A_ref() { return a; }
312
- virtual ~OverrideTest() = default;
313
- };
314
-
315
- class PyOverrideTest : public OverrideTest {
316
- public:
317
- using OverrideTest::OverrideTest;
318
- std::string str_value() override { PYBIND11_OVERRIDE(std::string, OverrideTest, str_value); }
319
- // Not allowed (uncommenting should hit a static_assert failure): we can't get a reference
320
- // to a python numeric value, since we only copy values in the numeric type caster:
321
- // std::string &str_ref() override { PYBIND11_OVERRIDE(std::string &, OverrideTest, str_ref); }
322
- // But we can work around it like this:
323
- private:
324
- std::string _tmp;
325
- std::string str_ref_helper() { PYBIND11_OVERRIDE(std::string, OverrideTest, str_ref); }
326
- public:
327
- std::string &str_ref() override { return _tmp = str_ref_helper(); }
328
-
329
- A A_value() override { PYBIND11_OVERRIDE(A, OverrideTest, A_value); }
330
- A &A_ref() override { PYBIND11_OVERRIDE(A &, OverrideTest, A_ref); }
331
- };
332
-
333
- py::class_<OverrideTest::A>(m, "OverrideTest_A")
334
- .def_readwrite("value", &OverrideTest::A::value);
335
- py::class_<OverrideTest, PyOverrideTest>(m, "OverrideTest")
336
- .def(py::init<const std::string &>())
337
- .def("str_value", &OverrideTest::str_value)
338
- // .def("str_ref", &OverrideTest::str_ref)
339
- .def("A_value", &OverrideTest::A_value)
340
- .def("A_ref", &OverrideTest::A_ref);
341
- }
342
-
343
-
344
- // Inheriting virtual methods. We do two versions here: the repeat-everything version and the
345
- // templated trampoline versions mentioned in docs/advanced.rst.
346
- //
347
- // These base classes are exactly the same, but we technically need distinct
348
- // classes for this example code because we need to be able to bind them
349
- // properly (pybind11, sensibly, doesn't allow us to bind the same C++ class to
350
- // multiple python classes).
351
- class A_Repeat {
352
- #define A_METHODS \
353
- public: \
354
- virtual int unlucky_number() = 0; \
355
- virtual std::string say_something(unsigned times) { \
356
- std::string s = ""; \
357
- for (unsigned i = 0; i < times; ++i) \
358
- s += "hi"; \
359
- return s; \
360
- } \
361
- std::string say_everything() { \
362
- return say_something(1) + " " + std::to_string(unlucky_number()); \
363
- }
364
- A_METHODS
365
- A_Repeat() = default;
366
- A_Repeat(const A_Repeat&) = delete;
367
- virtual ~A_Repeat() = default;
368
- };
369
- class B_Repeat : public A_Repeat {
370
- #define B_METHODS \
371
- public: \
372
- int unlucky_number() override { return 13; } \
373
- std::string say_something(unsigned times) override { \
374
- return "B says hi " + std::to_string(times) + " times"; \
375
- } \
376
- virtual double lucky_number() { return 7.0; }
377
- B_METHODS
378
- };
379
- class C_Repeat : public B_Repeat {
380
- #define C_METHODS \
381
- public: \
382
- int unlucky_number() override { return 4444; } \
383
- double lucky_number() override { return 888; }
384
- C_METHODS
385
- };
386
- class D_Repeat : public C_Repeat {
387
- #define D_METHODS // Nothing overridden.
388
- D_METHODS
389
- };
390
-
391
- // Base classes for templated inheritance trampolines. Identical to the repeat-everything version:
392
- class A_Tpl {
393
- A_METHODS;
394
- A_Tpl() = default;
395
- A_Tpl(const A_Tpl&) = delete;
396
- virtual ~A_Tpl() = default;
397
- };
398
- class B_Tpl : public A_Tpl { B_METHODS };
399
- class C_Tpl : public B_Tpl { C_METHODS };
400
- class D_Tpl : public C_Tpl { D_METHODS };
401
-
402
-
403
- // Inheritance approach 1: each trampoline gets every virtual method (11 in total)
404
- class PyA_Repeat : public A_Repeat {
405
- public:
406
- using A_Repeat::A_Repeat;
407
- int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, A_Repeat, unlucky_number, ); }
408
- std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, A_Repeat, say_something, times); }
409
- };
410
- class PyB_Repeat : public B_Repeat {
411
- public:
412
- using B_Repeat::B_Repeat;
413
- int unlucky_number() override { PYBIND11_OVERRIDE(int, B_Repeat, unlucky_number, ); }
414
- std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, B_Repeat, say_something, times); }
415
- double lucky_number() override { PYBIND11_OVERRIDE(double, B_Repeat, lucky_number, ); }
416
- };
417
- class PyC_Repeat : public C_Repeat {
418
- public:
419
- using C_Repeat::C_Repeat;
420
- int unlucky_number() override { PYBIND11_OVERRIDE(int, C_Repeat, unlucky_number, ); }
421
- std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, C_Repeat, say_something, times); }
422
- double lucky_number() override { PYBIND11_OVERRIDE(double, C_Repeat, lucky_number, ); }
423
- };
424
- class PyD_Repeat : public D_Repeat {
425
- public:
426
- using D_Repeat::D_Repeat;
427
- int unlucky_number() override { PYBIND11_OVERRIDE(int, D_Repeat, unlucky_number, ); }
428
- std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, D_Repeat, say_something, times); }
429
- double lucky_number() override { PYBIND11_OVERRIDE(double, D_Repeat, lucky_number, ); }
430
- };
431
-
432
- // Inheritance approach 2: templated trampoline classes.
433
- //
434
- // Advantages:
435
- // - we have only 2 (template) class and 4 method declarations (one per virtual method, plus one for
436
- // any override of a pure virtual method), versus 4 classes and 6 methods (MI) or 4 classes and 11
437
- // methods (repeat).
438
- // - Compared to MI, we also don't have to change the non-trampoline inheritance to virtual, and can
439
- // properly inherit constructors.
440
- //
441
- // Disadvantage:
442
- // - the compiler must still generate and compile 14 different methods (more, even, than the 11
443
- // required for the repeat approach) instead of the 6 required for MI. (If there was no pure
444
- // method (or no pure method override), the number would drop down to the same 11 as the repeat
445
- // approach).
446
- template <class Base = A_Tpl>
447
- class PyA_Tpl : public Base {
448
- public:
449
- using Base::Base; // Inherit constructors
450
- int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, Base, unlucky_number, ); }
451
- std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, Base, say_something, times); }
452
- };
453
- template <class Base = B_Tpl>
454
- class PyB_Tpl : public PyA_Tpl<Base> {
455
- public:
456
- using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
457
- // NOLINTNEXTLINE(bugprone-parent-virtual-call)
458
- int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
459
- double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
460
- };
461
- // Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these (we can
462
- // use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):
463
- /*
464
- template <class Base = C_Tpl> class PyC_Tpl : public PyB_Tpl<Base> {
465
- public:
466
- using PyB_Tpl<Base>::PyB_Tpl;
467
- };
468
- template <class Base = D_Tpl> class PyD_Tpl : public PyC_Tpl<Base> {
469
- public:
470
- using PyC_Tpl<Base>::PyC_Tpl;
471
- };
472
- */
473
-
474
- void initialize_inherited_virtuals(py::module_ &m) {
475
- // test_inherited_virtuals
476
-
477
- // Method 1: repeat
478
- py::class_<A_Repeat, PyA_Repeat>(m, "A_Repeat")
479
- .def(py::init<>())
480
- .def("unlucky_number", &A_Repeat::unlucky_number)
481
- .def("say_something", &A_Repeat::say_something)
482
- .def("say_everything", &A_Repeat::say_everything);
483
- py::class_<B_Repeat, A_Repeat, PyB_Repeat>(m, "B_Repeat")
484
- .def(py::init<>())
485
- .def("lucky_number", &B_Repeat::lucky_number);
486
- py::class_<C_Repeat, B_Repeat, PyC_Repeat>(m, "C_Repeat")
487
- .def(py::init<>());
488
- py::class_<D_Repeat, C_Repeat, PyD_Repeat>(m, "D_Repeat")
489
- .def(py::init<>());
490
-
491
- // test_
492
- // Method 2: Templated trampolines
493
- py::class_<A_Tpl, PyA_Tpl<>>(m, "A_Tpl")
494
- .def(py::init<>())
495
- .def("unlucky_number", &A_Tpl::unlucky_number)
496
- .def("say_something", &A_Tpl::say_something)
497
- .def("say_everything", &A_Tpl::say_everything);
498
- py::class_<B_Tpl, A_Tpl, PyB_Tpl<>>(m, "B_Tpl")
499
- .def(py::init<>())
500
- .def("lucky_number", &B_Tpl::lucky_number);
501
- py::class_<C_Tpl, B_Tpl, PyB_Tpl<C_Tpl>>(m, "C_Tpl")
502
- .def(py::init<>());
503
- py::class_<D_Tpl, C_Tpl, PyB_Tpl<D_Tpl>>(m, "D_Tpl")
504
- .def(py::init<>());
505
-
506
-
507
- // Fix issue #1454 (crash when acquiring/releasing GIL on another thread in Python 2.7)
508
- m.def("test_gil", &test_gil);
509
- m.def("test_gil_from_thread", &test_gil_from_thread);
510
- };