xcoll 0.5.12__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 +121 -91
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -73
  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 +414 -217
  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 +3 -72
  40. xcoll/xaux.py +65 -109
  41. {xcoll-0.5.12.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.12.dist-info/RECORD +0 -415
  331. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,709 +0,0 @@
1
- /*
2
- pybind11/detail/class.h: Python C API implementation details for py::class_
3
-
4
- Copyright (c) 2017 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
- #pragma once
11
-
12
- #include "../attr.h"
13
- #include "../options.h"
14
-
15
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
16
- PYBIND11_NAMESPACE_BEGIN(detail)
17
-
18
- #if PY_VERSION_HEX >= 0x03030000 && !defined(PYPY_VERSION)
19
- # define PYBIND11_BUILTIN_QUALNAME
20
- # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj)
21
- #else
22
- // In pre-3.3 Python, we still set __qualname__ so that we can produce reliable function type
23
- // signatures; in 3.3+ this macro expands to nothing:
24
- # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj) setattr((PyObject *) obj, "__qualname__", nameobj)
25
- #endif
26
-
27
- inline std::string get_fully_qualified_tp_name(PyTypeObject *type) {
28
- #if !defined(PYPY_VERSION)
29
- return type->tp_name;
30
- #else
31
- auto module_name = handle((PyObject *) type).attr("__module__").cast<std::string>();
32
- if (module_name == PYBIND11_BUILTINS_MODULE)
33
- return type->tp_name;
34
- else
35
- return std::move(module_name) + "." + type->tp_name;
36
- #endif
37
- }
38
-
39
- inline PyTypeObject *type_incref(PyTypeObject *type) {
40
- Py_INCREF(type);
41
- return type;
42
- }
43
-
44
- #if !defined(PYPY_VERSION)
45
-
46
- /// `pybind11_static_property.__get__()`: Always pass the class instead of the instance.
47
- extern "C" inline PyObject *pybind11_static_get(PyObject *self, PyObject * /*ob*/, PyObject *cls) {
48
- return PyProperty_Type.tp_descr_get(self, cls, cls);
49
- }
50
-
51
- /// `pybind11_static_property.__set__()`: Just like the above `__get__()`.
52
- extern "C" inline int pybind11_static_set(PyObject *self, PyObject *obj, PyObject *value) {
53
- PyObject *cls = PyType_Check(obj) ? obj : (PyObject *) Py_TYPE(obj);
54
- return PyProperty_Type.tp_descr_set(self, cls, value);
55
- }
56
-
57
- /** A `static_property` is the same as a `property` but the `__get__()` and `__set__()`
58
- methods are modified to always use the object type instead of a concrete instance.
59
- Return value: New reference. */
60
- inline PyTypeObject *make_static_property_type() {
61
- constexpr auto *name = "pybind11_static_property";
62
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
63
-
64
- /* Danger zone: from now (and until PyType_Ready), make sure to
65
- issue no Python C API calls which could potentially invoke the
66
- garbage collector (the GC will call type_traverse(), which will in
67
- turn find the newly constructed type in an invalid state) */
68
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
69
- if (!heap_type)
70
- pybind11_fail("make_static_property_type(): error allocating type!");
71
-
72
- heap_type->ht_name = name_obj.inc_ref().ptr();
73
- #ifdef PYBIND11_BUILTIN_QUALNAME
74
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
75
- #endif
76
-
77
- auto type = &heap_type->ht_type;
78
- type->tp_name = name;
79
- type->tp_base = type_incref(&PyProperty_Type);
80
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
81
- type->tp_descr_get = pybind11_static_get;
82
- type->tp_descr_set = pybind11_static_set;
83
-
84
- if (PyType_Ready(type) < 0)
85
- pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
86
-
87
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
88
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
89
-
90
- return type;
91
- }
92
-
93
- #else // PYPY
94
-
95
- /** PyPy has some issues with the above C API, so we evaluate Python code instead.
96
- This function will only be called once so performance isn't really a concern.
97
- Return value: New reference. */
98
- inline PyTypeObject *make_static_property_type() {
99
- auto d = dict();
100
- PyObject *result = PyRun_String(R"(\
101
- class pybind11_static_property(property):
102
- def __get__(self, obj, cls):
103
- return property.__get__(self, cls, cls)
104
-
105
- def __set__(self, obj, value):
106
- cls = obj if isinstance(obj, type) else type(obj)
107
- property.__set__(self, cls, value)
108
- )", Py_file_input, d.ptr(), d.ptr()
109
- );
110
- if (result == nullptr)
111
- throw error_already_set();
112
- Py_DECREF(result);
113
- return (PyTypeObject *) d["pybind11_static_property"].cast<object>().release().ptr();
114
- }
115
-
116
- #endif // PYPY
117
-
118
- /** Types with static properties need to handle `Type.static_prop = x` in a specific way.
119
- By default, Python replaces the `static_property` itself, but for wrapped C++ types
120
- we need to call `static_property.__set__()` in order to propagate the new value to
121
- the underlying C++ data structure. */
122
- extern "C" inline int pybind11_meta_setattro(PyObject* obj, PyObject* name, PyObject* value) {
123
- // Use `_PyType_Lookup()` instead of `PyObject_GetAttr()` in order to get the raw
124
- // descriptor (`property`) instead of calling `tp_descr_get` (`property.__get__()`).
125
- PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
126
-
127
- // The following assignment combinations are possible:
128
- // 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
129
- // 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
130
- // 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
131
- const auto static_prop = (PyObject *) get_internals().static_property_type;
132
- const auto call_descr_set = (descr != nullptr) && (value != nullptr)
133
- && (PyObject_IsInstance(descr, static_prop) != 0)
134
- && (PyObject_IsInstance(value, static_prop) == 0);
135
- if (call_descr_set) {
136
- // Call `static_property.__set__()` instead of replacing the `static_property`.
137
- #if !defined(PYPY_VERSION)
138
- return Py_TYPE(descr)->tp_descr_set(descr, obj, value);
139
- #else
140
- if (PyObject *result = PyObject_CallMethod(descr, "__set__", "OO", obj, value)) {
141
- Py_DECREF(result);
142
- return 0;
143
- } else {
144
- return -1;
145
- }
146
- #endif
147
- } else {
148
- // Replace existing attribute.
149
- return PyType_Type.tp_setattro(obj, name, value);
150
- }
151
- }
152
-
153
- #if PY_MAJOR_VERSION >= 3
154
- /**
155
- * Python 3's PyInstanceMethod_Type hides itself via its tp_descr_get, which prevents aliasing
156
- * methods via cls.attr("m2") = cls.attr("m1"): instead the tp_descr_get returns a plain function,
157
- * when called on a class, or a PyMethod, when called on an instance. Override that behaviour here
158
- * to do a special case bypass for PyInstanceMethod_Types.
159
- */
160
- extern "C" inline PyObject *pybind11_meta_getattro(PyObject *obj, PyObject *name) {
161
- PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
162
- if (descr && PyInstanceMethod_Check(descr)) {
163
- Py_INCREF(descr);
164
- return descr;
165
- }
166
- return PyType_Type.tp_getattro(obj, name);
167
- }
168
- #endif
169
-
170
- /// metaclass `__call__` function that is used to create all pybind11 objects.
171
- extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, PyObject *kwargs) {
172
-
173
- // use the default metaclass call to create/initialize the object
174
- PyObject *self = PyType_Type.tp_call(type, args, kwargs);
175
- if (self == nullptr) {
176
- return nullptr;
177
- }
178
-
179
- // This must be a pybind11 instance
180
- auto instance = reinterpret_cast<detail::instance *>(self);
181
-
182
- // Ensure that the base __init__ function(s) were called
183
- for (const auto &vh : values_and_holders(instance)) {
184
- if (!vh.holder_constructed()) {
185
- PyErr_Format(PyExc_TypeError, "%.200s.__init__() must be called when overriding __init__",
186
- get_fully_qualified_tp_name(vh.type->type).c_str());
187
- Py_DECREF(self);
188
- return nullptr;
189
- }
190
- }
191
-
192
- return self;
193
- }
194
-
195
- /// Cleanup the type-info for a pybind11-registered type.
196
- extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {
197
- auto *type = (PyTypeObject *) obj;
198
- auto &internals = get_internals();
199
-
200
- // A pybind11-registered type will:
201
- // 1) be found in internals.registered_types_py
202
- // 2) have exactly one associated `detail::type_info`
203
- auto found_type = internals.registered_types_py.find(type);
204
- if (found_type != internals.registered_types_py.end() &&
205
- found_type->second.size() == 1 &&
206
- found_type->second[0]->type == type) {
207
-
208
- auto *tinfo = found_type->second[0];
209
- auto tindex = std::type_index(*tinfo->cpptype);
210
- internals.direct_conversions.erase(tindex);
211
-
212
- if (tinfo->module_local)
213
- get_local_internals().registered_types_cpp.erase(tindex);
214
- else
215
- internals.registered_types_cpp.erase(tindex);
216
- internals.registered_types_py.erase(tinfo->type);
217
-
218
- // Actually just `std::erase_if`, but that's only available in C++20
219
- auto &cache = internals.inactive_override_cache;
220
- for (auto it = cache.begin(), last = cache.end(); it != last; ) {
221
- if (it->first == (PyObject *) tinfo->type)
222
- it = cache.erase(it);
223
- else
224
- ++it;
225
- }
226
-
227
- delete tinfo;
228
- }
229
-
230
- PyType_Type.tp_dealloc(obj);
231
- }
232
-
233
- /** This metaclass is assigned by default to all pybind11 types and is required in order
234
- for static properties to function correctly. Users may override this using `py::metaclass`.
235
- Return value: New reference. */
236
- inline PyTypeObject* make_default_metaclass() {
237
- constexpr auto *name = "pybind11_type";
238
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
239
-
240
- /* Danger zone: from now (and until PyType_Ready), make sure to
241
- issue no Python C API calls which could potentially invoke the
242
- garbage collector (the GC will call type_traverse(), which will in
243
- turn find the newly constructed type in an invalid state) */
244
- auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
245
- if (!heap_type)
246
- pybind11_fail("make_default_metaclass(): error allocating metaclass!");
247
-
248
- heap_type->ht_name = name_obj.inc_ref().ptr();
249
- #ifdef PYBIND11_BUILTIN_QUALNAME
250
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
251
- #endif
252
-
253
- auto type = &heap_type->ht_type;
254
- type->tp_name = name;
255
- type->tp_base = type_incref(&PyType_Type);
256
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
257
-
258
- type->tp_call = pybind11_meta_call;
259
-
260
- type->tp_setattro = pybind11_meta_setattro;
261
- #if PY_MAJOR_VERSION >= 3
262
- type->tp_getattro = pybind11_meta_getattro;
263
- #endif
264
-
265
- type->tp_dealloc = pybind11_meta_dealloc;
266
-
267
- if (PyType_Ready(type) < 0)
268
- pybind11_fail("make_default_metaclass(): failure in PyType_Ready()!");
269
-
270
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
271
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
272
-
273
- return type;
274
- }
275
-
276
- /// For multiple inheritance types we need to recursively register/deregister base pointers for any
277
- /// base classes with pointers that are difference from the instance value pointer so that we can
278
- /// correctly recognize an offset base class pointer. This calls a function with any offset base ptrs.
279
- inline void traverse_offset_bases(void *valueptr, const detail::type_info *tinfo, instance *self,
280
- bool (*f)(void * /*parentptr*/, instance * /*self*/)) {
281
- for (handle h : reinterpret_borrow<tuple>(tinfo->type->tp_bases)) {
282
- if (auto parent_tinfo = get_type_info((PyTypeObject *) h.ptr())) {
283
- for (auto &c : parent_tinfo->implicit_casts) {
284
- if (c.first == tinfo->cpptype) {
285
- auto *parentptr = c.second(valueptr);
286
- if (parentptr != valueptr)
287
- f(parentptr, self);
288
- traverse_offset_bases(parentptr, parent_tinfo, self, f);
289
- break;
290
- }
291
- }
292
- }
293
- }
294
- }
295
-
296
- inline bool register_instance_impl(void *ptr, instance *self) {
297
- get_internals().registered_instances.emplace(ptr, self);
298
- return true; // unused, but gives the same signature as the deregister func
299
- }
300
- inline bool deregister_instance_impl(void *ptr, instance *self) {
301
- auto &registered_instances = get_internals().registered_instances;
302
- auto range = registered_instances.equal_range(ptr);
303
- for (auto it = range.first; it != range.second; ++it) {
304
- if (self == it->second) {
305
- registered_instances.erase(it);
306
- return true;
307
- }
308
- }
309
- return false;
310
- }
311
-
312
- inline void register_instance(instance *self, void *valptr, const type_info *tinfo) {
313
- register_instance_impl(valptr, self);
314
- if (!tinfo->simple_ancestors)
315
- traverse_offset_bases(valptr, tinfo, self, register_instance_impl);
316
- }
317
-
318
- inline bool deregister_instance(instance *self, void *valptr, const type_info *tinfo) {
319
- bool ret = deregister_instance_impl(valptr, self);
320
- if (!tinfo->simple_ancestors)
321
- traverse_offset_bases(valptr, tinfo, self, deregister_instance_impl);
322
- return ret;
323
- }
324
-
325
- /// Instance creation function for all pybind11 types. It allocates the internal instance layout for
326
- /// holding C++ objects and holders. Allocation is done lazily (the first time the instance is cast
327
- /// to a reference or pointer), and initialization is done by an `__init__` function.
328
- inline PyObject *make_new_instance(PyTypeObject *type) {
329
- #if defined(PYPY_VERSION)
330
- // PyPy gets tp_basicsize wrong (issue 2482) under multiple inheritance when the first inherited
331
- // object is a plain Python type (i.e. not derived from an extension type). Fix it.
332
- ssize_t instance_size = static_cast<ssize_t>(sizeof(instance));
333
- if (type->tp_basicsize < instance_size) {
334
- type->tp_basicsize = instance_size;
335
- }
336
- #endif
337
- PyObject *self = type->tp_alloc(type, 0);
338
- auto inst = reinterpret_cast<instance *>(self);
339
- // Allocate the value/holder internals:
340
- inst->allocate_layout();
341
-
342
- return self;
343
- }
344
-
345
- /// Instance creation function for all pybind11 types. It only allocates space for the
346
- /// C++ object, but doesn't call the constructor -- an `__init__` function must do that.
347
- extern "C" inline PyObject *pybind11_object_new(PyTypeObject *type, PyObject *, PyObject *) {
348
- return make_new_instance(type);
349
- }
350
-
351
- /// An `__init__` function constructs the C++ object. Users should provide at least one
352
- /// of these using `py::init` or directly with `.def(__init__, ...)`. Otherwise, the
353
- /// following default function will be used which simply throws an exception.
354
- extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject *) {
355
- PyTypeObject *type = Py_TYPE(self);
356
- std::string msg = get_fully_qualified_tp_name(type) + ": No constructor defined!";
357
- PyErr_SetString(PyExc_TypeError, msg.c_str());
358
- return -1;
359
- }
360
-
361
- inline void add_patient(PyObject *nurse, PyObject *patient) {
362
- auto &internals = get_internals();
363
- auto instance = reinterpret_cast<detail::instance *>(nurse);
364
- instance->has_patients = true;
365
- Py_INCREF(patient);
366
- internals.patients[nurse].push_back(patient);
367
- }
368
-
369
- inline void clear_patients(PyObject *self) {
370
- auto instance = reinterpret_cast<detail::instance *>(self);
371
- auto &internals = get_internals();
372
- auto pos = internals.patients.find(self);
373
- assert(pos != internals.patients.end());
374
- // Clearing the patients can cause more Python code to run, which
375
- // can invalidate the iterator. Extract the vector of patients
376
- // from the unordered_map first.
377
- auto patients = std::move(pos->second);
378
- internals.patients.erase(pos);
379
- instance->has_patients = false;
380
- for (PyObject *&patient : patients)
381
- Py_CLEAR(patient);
382
- }
383
-
384
- /// Clears all internal data from the instance and removes it from registered instances in
385
- /// preparation for deallocation.
386
- inline void clear_instance(PyObject *self) {
387
- auto instance = reinterpret_cast<detail::instance *>(self);
388
-
389
- // Deallocate any values/holders, if present:
390
- for (auto &v_h : values_and_holders(instance)) {
391
- if (v_h) {
392
-
393
- // We have to deregister before we call dealloc because, for virtual MI types, we still
394
- // need to be able to get the parent pointers.
395
- if (v_h.instance_registered() && !deregister_instance(instance, v_h.value_ptr(), v_h.type))
396
- pybind11_fail("pybind11_object_dealloc(): Tried to deallocate unregistered instance!");
397
-
398
- if (instance->owned || v_h.holder_constructed())
399
- v_h.type->dealloc(v_h);
400
- }
401
- }
402
- // Deallocate the value/holder layout internals:
403
- instance->deallocate_layout();
404
-
405
- if (instance->weakrefs)
406
- PyObject_ClearWeakRefs(self);
407
-
408
- PyObject **dict_ptr = _PyObject_GetDictPtr(self);
409
- if (dict_ptr)
410
- Py_CLEAR(*dict_ptr);
411
-
412
- if (instance->has_patients)
413
- clear_patients(self);
414
- }
415
-
416
- /// Instance destructor function for all pybind11 types. It calls `type_info.dealloc`
417
- /// to destroy the C++ object itself, while the rest is Python bookkeeping.
418
- extern "C" inline void pybind11_object_dealloc(PyObject *self) {
419
- clear_instance(self);
420
-
421
- auto type = Py_TYPE(self);
422
- type->tp_free(self);
423
-
424
- #if PY_VERSION_HEX < 0x03080000
425
- // `type->tp_dealloc != pybind11_object_dealloc` means that we're being called
426
- // as part of a derived type's dealloc, in which case we're not allowed to decref
427
- // the type here. For cross-module compatibility, we shouldn't compare directly
428
- // with `pybind11_object_dealloc`, but with the common one stashed in internals.
429
- auto pybind11_object_type = (PyTypeObject *) get_internals().instance_base;
430
- if (type->tp_dealloc == pybind11_object_type->tp_dealloc)
431
- Py_DECREF(type);
432
- #else
433
- // This was not needed before Python 3.8 (Python issue 35810)
434
- // https://github.com/pybind/pybind11/issues/1946
435
- Py_DECREF(type);
436
- #endif
437
- }
438
-
439
- /** Create the type which can be used as a common base for all classes. This is
440
- needed in order to satisfy Python's requirements for multiple inheritance.
441
- Return value: New reference. */
442
- inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
443
- constexpr auto *name = "pybind11_object";
444
- auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
445
-
446
- /* Danger zone: from now (and until PyType_Ready), make sure to
447
- issue no Python C API calls which could potentially invoke the
448
- garbage collector (the GC will call type_traverse(), which will in
449
- turn find the newly constructed type in an invalid state) */
450
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
451
- if (!heap_type)
452
- pybind11_fail("make_object_base_type(): error allocating type!");
453
-
454
- heap_type->ht_name = name_obj.inc_ref().ptr();
455
- #ifdef PYBIND11_BUILTIN_QUALNAME
456
- heap_type->ht_qualname = name_obj.inc_ref().ptr();
457
- #endif
458
-
459
- auto type = &heap_type->ht_type;
460
- type->tp_name = name;
461
- type->tp_base = type_incref(&PyBaseObject_Type);
462
- type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
463
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
464
-
465
- type->tp_new = pybind11_object_new;
466
- type->tp_init = pybind11_object_init;
467
- type->tp_dealloc = pybind11_object_dealloc;
468
-
469
- /* Support weak references (needed for the keep_alive feature) */
470
- type->tp_weaklistoffset = offsetof(instance, weakrefs);
471
-
472
- if (PyType_Ready(type) < 0)
473
- pybind11_fail("PyType_Ready failed in make_object_base_type():" + error_string());
474
-
475
- setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
476
- PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
477
-
478
- assert(!PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
479
- return (PyObject *) heap_type;
480
- }
481
-
482
- /// dynamic_attr: Support for `d = instance.__dict__`.
483
- extern "C" inline PyObject *pybind11_get_dict(PyObject *self, void *) {
484
- PyObject *&dict = *_PyObject_GetDictPtr(self);
485
- if (!dict)
486
- dict = PyDict_New();
487
- Py_XINCREF(dict);
488
- return dict;
489
- }
490
-
491
- /// dynamic_attr: Support for `instance.__dict__ = dict()`.
492
- extern "C" inline int pybind11_set_dict(PyObject *self, PyObject *new_dict, void *) {
493
- if (!PyDict_Check(new_dict)) {
494
- PyErr_Format(PyExc_TypeError, "__dict__ must be set to a dictionary, not a '%.200s'",
495
- get_fully_qualified_tp_name(Py_TYPE(new_dict)).c_str());
496
- return -1;
497
- }
498
- PyObject *&dict = *_PyObject_GetDictPtr(self);
499
- Py_INCREF(new_dict);
500
- Py_CLEAR(dict);
501
- dict = new_dict;
502
- return 0;
503
- }
504
-
505
- /// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
506
- extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
507
- PyObject *&dict = *_PyObject_GetDictPtr(self);
508
- Py_VISIT(dict);
509
- return 0;
510
- }
511
-
512
- /// dynamic_attr: Allow the GC to clear the dictionary.
513
- extern "C" inline int pybind11_clear(PyObject *self) {
514
- PyObject *&dict = *_PyObject_GetDictPtr(self);
515
- Py_CLEAR(dict);
516
- return 0;
517
- }
518
-
519
- /// Give instances of this type a `__dict__` and opt into garbage collection.
520
- inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
521
- auto type = &heap_type->ht_type;
522
- type->tp_flags |= Py_TPFLAGS_HAVE_GC;
523
- type->tp_dictoffset = type->tp_basicsize; // place dict at the end
524
- type->tp_basicsize += (ssize_t)sizeof(PyObject *); // and allocate enough space for it
525
- type->tp_traverse = pybind11_traverse;
526
- type->tp_clear = pybind11_clear;
527
-
528
- static PyGetSetDef getset[] = {
529
- {const_cast<char*>("__dict__"), pybind11_get_dict, pybind11_set_dict, nullptr, nullptr},
530
- {nullptr, nullptr, nullptr, nullptr, nullptr}
531
- };
532
- type->tp_getset = getset;
533
- }
534
-
535
- /// buffer_protocol: Fill in the view as specified by flags.
536
- extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int flags) {
537
- // Look for a `get_buffer` implementation in this type's info or any bases (following MRO).
538
- type_info *tinfo = nullptr;
539
- for (auto type : reinterpret_borrow<tuple>(Py_TYPE(obj)->tp_mro)) {
540
- tinfo = get_type_info((PyTypeObject *) type.ptr());
541
- if (tinfo && tinfo->get_buffer)
542
- break;
543
- }
544
- if (view == nullptr || !tinfo || !tinfo->get_buffer) {
545
- if (view)
546
- view->obj = nullptr;
547
- PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
548
- return -1;
549
- }
550
- std::memset(view, 0, sizeof(Py_buffer));
551
- buffer_info *info = tinfo->get_buffer(obj, tinfo->get_buffer_data);
552
- if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE && info->readonly) {
553
- delete info;
554
- // view->obj = nullptr; // Was just memset to 0, so not necessary
555
- PyErr_SetString(PyExc_BufferError, "Writable buffer requested for readonly storage");
556
- return -1;
557
- }
558
- view->obj = obj;
559
- view->ndim = 1;
560
- view->internal = info;
561
- view->buf = info->ptr;
562
- view->itemsize = info->itemsize;
563
- view->len = view->itemsize;
564
- for (auto s : info->shape)
565
- view->len *= s;
566
- view->readonly = static_cast<int>(info->readonly);
567
- if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT)
568
- view->format = const_cast<char *>(info->format.c_str());
569
- if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) {
570
- view->ndim = (int) info->ndim;
571
- view->strides = &info->strides[0];
572
- view->shape = &info->shape[0];
573
- }
574
- Py_INCREF(view->obj);
575
- return 0;
576
- }
577
-
578
- /// buffer_protocol: Release the resources of the buffer.
579
- extern "C" inline void pybind11_releasebuffer(PyObject *, Py_buffer *view) {
580
- delete (buffer_info *) view->internal;
581
- }
582
-
583
- /// Give this type a buffer interface.
584
- inline void enable_buffer_protocol(PyHeapTypeObject *heap_type) {
585
- heap_type->ht_type.tp_as_buffer = &heap_type->as_buffer;
586
- #if PY_MAJOR_VERSION < 3
587
- heap_type->ht_type.tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER;
588
- #endif
589
-
590
- heap_type->as_buffer.bf_getbuffer = pybind11_getbuffer;
591
- heap_type->as_buffer.bf_releasebuffer = pybind11_releasebuffer;
592
- }
593
-
594
- /** Create a brand new Python type according to the `type_record` specification.
595
- Return value: New reference. */
596
- inline PyObject* make_new_python_type(const type_record &rec) {
597
- auto name = reinterpret_steal<object>(PYBIND11_FROM_STRING(rec.name));
598
-
599
- auto qualname = name;
600
- if (rec.scope && !PyModule_Check(rec.scope.ptr()) && hasattr(rec.scope, "__qualname__")) {
601
- #if PY_MAJOR_VERSION >= 3
602
- qualname = reinterpret_steal<object>(
603
- PyUnicode_FromFormat("%U.%U", rec.scope.attr("__qualname__").ptr(), name.ptr()));
604
- #else
605
- qualname = str(rec.scope.attr("__qualname__").cast<std::string>() + "." + rec.name);
606
- #endif
607
- }
608
-
609
- object module_;
610
- if (rec.scope) {
611
- if (hasattr(rec.scope, "__module__"))
612
- module_ = rec.scope.attr("__module__");
613
- else if (hasattr(rec.scope, "__name__"))
614
- module_ = rec.scope.attr("__name__");
615
- }
616
-
617
- auto full_name = c_str(
618
- #if !defined(PYPY_VERSION)
619
- module_ ? str(module_).cast<std::string>() + "." + rec.name :
620
- #endif
621
- rec.name);
622
-
623
- char *tp_doc = nullptr;
624
- if (rec.doc && options::show_user_defined_docstrings()) {
625
- /* Allocate memory for docstring (using PyObject_MALLOC, since
626
- Python will free this later on) */
627
- size_t size = strlen(rec.doc) + 1;
628
- tp_doc = (char *) PyObject_MALLOC(size);
629
- memcpy((void *) tp_doc, rec.doc, size);
630
- }
631
-
632
- auto &internals = get_internals();
633
- auto bases = tuple(rec.bases);
634
- auto base = (bases.empty()) ? internals.instance_base
635
- : bases[0].ptr();
636
-
637
- /* Danger zone: from now (and until PyType_Ready), make sure to
638
- issue no Python C API calls which could potentially invoke the
639
- garbage collector (the GC will call type_traverse(), which will in
640
- turn find the newly constructed type in an invalid state) */
641
- auto metaclass = rec.metaclass.ptr() ? (PyTypeObject *) rec.metaclass.ptr()
642
- : internals.default_metaclass;
643
-
644
- auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
645
- if (!heap_type)
646
- pybind11_fail(std::string(rec.name) + ": Unable to create type object!");
647
-
648
- heap_type->ht_name = name.release().ptr();
649
- #ifdef PYBIND11_BUILTIN_QUALNAME
650
- heap_type->ht_qualname = qualname.inc_ref().ptr();
651
- #endif
652
-
653
- auto type = &heap_type->ht_type;
654
- type->tp_name = full_name;
655
- type->tp_doc = tp_doc;
656
- type->tp_base = type_incref((PyTypeObject *)base);
657
- type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
658
- if (!bases.empty())
659
- type->tp_bases = bases.release().ptr();
660
-
661
- /* Don't inherit base __init__ */
662
- type->tp_init = pybind11_object_init;
663
-
664
- /* Supported protocols */
665
- type->tp_as_number = &heap_type->as_number;
666
- type->tp_as_sequence = &heap_type->as_sequence;
667
- type->tp_as_mapping = &heap_type->as_mapping;
668
- #if PY_VERSION_HEX >= 0x03050000
669
- type->tp_as_async = &heap_type->as_async;
670
- #endif
671
-
672
- /* Flags */
673
- type->tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
674
- #if PY_MAJOR_VERSION < 3
675
- type->tp_flags |= Py_TPFLAGS_CHECKTYPES;
676
- #endif
677
- if (!rec.is_final)
678
- type->tp_flags |= Py_TPFLAGS_BASETYPE;
679
-
680
- if (rec.dynamic_attr)
681
- enable_dynamic_attributes(heap_type);
682
-
683
- if (rec.buffer_protocol)
684
- enable_buffer_protocol(heap_type);
685
-
686
- if (rec.custom_type_setup_callback)
687
- rec.custom_type_setup_callback(heap_type);
688
-
689
- if (PyType_Ready(type) < 0)
690
- pybind11_fail(std::string(rec.name) + ": PyType_Ready failed (" + error_string() + ")!");
691
-
692
- assert(!rec.dynamic_attr || PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
693
-
694
- /* Register type with the parent scope */
695
- if (rec.scope)
696
- setattr(rec.scope, rec.name, (PyObject *) type);
697
- else
698
- Py_INCREF(type); // Keep it alive forever (reference leak)
699
-
700
- if (module_) // Needed by pydoc
701
- setattr((PyObject *) type, "__module__", module_);
702
-
703
- PYBIND11_SET_OLDPY_QUALNAME(type, qualname);
704
-
705
- return (PyObject *) type;
706
- }
707
-
708
- PYBIND11_NAMESPACE_END(detail)
709
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)