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