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

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

Potentially problematic release.


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

Files changed (333) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/beam_elements/__init__.py +1 -0
  3. xcoll/beam_elements/absorber.py +12 -2
  4. xcoll/beam_elements/base.py +162 -62
  5. xcoll/beam_elements/blowup.py +1 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  7. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  8. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  9. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  10. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  11. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  12. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  13. xcoll/beam_elements/everest.py +16 -5
  14. xcoll/beam_elements/monitor.py +1 -0
  15. xcoll/beam_elements/transparent.py +83 -0
  16. xcoll/colldb.py +15 -6
  17. xcoll/general.py +1 -1
  18. xcoll/headers/particle_states.py +51 -0
  19. xcoll/initial_distribution.py +129 -103
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -74
  23. xcoll/lossmap.py +519 -127
  24. xcoll/plot.py +109 -0
  25. xcoll/rf_sweep.py +6 -0
  26. xcoll/scattering_routines/engine.py +600 -0
  27. xcoll/scattering_routines/environment.py +297 -0
  28. xcoll/scattering_routines/everest/amorphous.h +95 -71
  29. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  30. xcoll/scattering_routines/everest/constants.h +1 -1
  31. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  32. xcoll/scattering_routines/everest/everest.h +8 -3
  33. xcoll/scattering_routines/everest/everest.py +2 -1
  34. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  35. xcoll/scattering_routines/everest/jaw.h +19 -24
  36. xcoll/scattering_routines/everest/materials.py +2 -0
  37. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  38. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  39. xcoll/scattering_routines/everest/properties.h +4 -73
  40. xcoll/xaux.py +73 -0
  41. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
  42. xcoll-0.6.0.dist-info/RECORD +135 -0
  43. xcoll/_manager.py +0 -22
  44. xcoll/headers/particle_states.h +0 -25
  45. xcoll/install.py +0 -35
  46. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  47. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  48. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  49. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  50. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  51. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  52. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  53. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  54. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  55. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  289. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  290. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  304. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  330. xcoll-0.5.11.dist-info/RECORD +0 -413
  331. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,520 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import re
3
-
4
- import pytest
5
-
6
- import env # noqa: F401
7
- from pybind11_tests import ConstructorStats
8
- from pybind11_tests import factory_constructors as m
9
- from pybind11_tests.factory_constructors import tag
10
-
11
-
12
- def test_init_factory_basic():
13
- """Tests py::init_factory() wrapper around various ways of returning the object"""
14
-
15
- cstats = [
16
- ConstructorStats.get(c)
17
- for c in [m.TestFactory1, m.TestFactory2, m.TestFactory3]
18
- ]
19
- cstats[0].alive() # force gc
20
- n_inst = ConstructorStats.detail_reg_inst()
21
-
22
- x1 = m.TestFactory1(tag.unique_ptr, 3)
23
- assert x1.value == "3"
24
- y1 = m.TestFactory1(tag.pointer)
25
- assert y1.value == "(empty)"
26
- z1 = m.TestFactory1("hi!")
27
- assert z1.value == "hi!"
28
-
29
- assert ConstructorStats.detail_reg_inst() == n_inst + 3
30
-
31
- x2 = m.TestFactory2(tag.move)
32
- assert x2.value == "(empty2)"
33
- y2 = m.TestFactory2(tag.pointer, 7)
34
- assert y2.value == "7"
35
- z2 = m.TestFactory2(tag.unique_ptr, "hi again")
36
- assert z2.value == "hi again"
37
-
38
- assert ConstructorStats.detail_reg_inst() == n_inst + 6
39
-
40
- x3 = m.TestFactory3(tag.shared_ptr)
41
- assert x3.value == "(empty3)"
42
- y3 = m.TestFactory3(tag.pointer, 42)
43
- assert y3.value == "42"
44
- z3 = m.TestFactory3("bye")
45
- assert z3.value == "bye"
46
-
47
- for null_ptr_kind in [tag.null_ptr, tag.null_unique_ptr, tag.null_shared_ptr]:
48
- with pytest.raises(TypeError) as excinfo:
49
- m.TestFactory3(null_ptr_kind)
50
- assert (
51
- str(excinfo.value) == "pybind11::init(): factory function returned nullptr"
52
- )
53
-
54
- assert [i.alive() for i in cstats] == [3, 3, 3]
55
- assert ConstructorStats.detail_reg_inst() == n_inst + 9
56
-
57
- del x1, y2, y3, z3
58
- assert [i.alive() for i in cstats] == [2, 2, 1]
59
- assert ConstructorStats.detail_reg_inst() == n_inst + 5
60
- del x2, x3, y1, z1, z2
61
- assert [i.alive() for i in cstats] == [0, 0, 0]
62
- assert ConstructorStats.detail_reg_inst() == n_inst
63
-
64
- assert [i.values() for i in cstats] == [
65
- ["3", "hi!"],
66
- ["7", "hi again"],
67
- ["42", "bye"],
68
- ]
69
- assert [i.default_constructions for i in cstats] == [1, 1, 1]
70
-
71
-
72
- def test_init_factory_signature(msg):
73
- with pytest.raises(TypeError) as excinfo:
74
- m.TestFactory1("invalid", "constructor", "arguments")
75
- assert (
76
- msg(excinfo.value)
77
- == """
78
- __init__(): incompatible constructor arguments. The following argument types are supported:
79
- 1. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int)
80
- 2. m.factory_constructors.TestFactory1(arg0: str)
81
- 3. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.pointer_tag)
82
- 4. m.factory_constructors.TestFactory1(arg0: handle, arg1: int, arg2: handle)
83
-
84
- Invoked with: 'invalid', 'constructor', 'arguments'
85
- """ # noqa: E501 line too long
86
- )
87
-
88
- assert (
89
- msg(m.TestFactory1.__init__.__doc__)
90
- == """
91
- __init__(*args, **kwargs)
92
- Overloaded function.
93
-
94
- 1. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int) -> None
95
-
96
- 2. __init__(self: m.factory_constructors.TestFactory1, arg0: str) -> None
97
-
98
- 3. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.pointer_tag) -> None
99
-
100
- 4. __init__(self: m.factory_constructors.TestFactory1, arg0: handle, arg1: int, arg2: handle) -> None
101
- """ # noqa: E501 line too long
102
- )
103
-
104
-
105
- def test_init_factory_casting():
106
- """Tests py::init_factory() wrapper with various upcasting and downcasting returns"""
107
-
108
- cstats = [
109
- ConstructorStats.get(c)
110
- for c in [m.TestFactory3, m.TestFactory4, m.TestFactory5]
111
- ]
112
- cstats[0].alive() # force gc
113
- n_inst = ConstructorStats.detail_reg_inst()
114
-
115
- # Construction from derived references:
116
- a = m.TestFactory3(tag.pointer, tag.TF4, 4)
117
- assert a.value == "4"
118
- b = m.TestFactory3(tag.shared_ptr, tag.TF4, 5)
119
- assert b.value == "5"
120
- c = m.TestFactory3(tag.pointer, tag.TF5, 6)
121
- assert c.value == "6"
122
- d = m.TestFactory3(tag.shared_ptr, tag.TF5, 7)
123
- assert d.value == "7"
124
-
125
- assert ConstructorStats.detail_reg_inst() == n_inst + 4
126
-
127
- # Shared a lambda with TF3:
128
- e = m.TestFactory4(tag.pointer, tag.TF4, 8)
129
- assert e.value == "8"
130
-
131
- assert ConstructorStats.detail_reg_inst() == n_inst + 5
132
- assert [i.alive() for i in cstats] == [5, 3, 2]
133
-
134
- del a
135
- assert [i.alive() for i in cstats] == [4, 2, 2]
136
- assert ConstructorStats.detail_reg_inst() == n_inst + 4
137
-
138
- del b, c, e
139
- assert [i.alive() for i in cstats] == [1, 0, 1]
140
- assert ConstructorStats.detail_reg_inst() == n_inst + 1
141
-
142
- del d
143
- assert [i.alive() for i in cstats] == [0, 0, 0]
144
- assert ConstructorStats.detail_reg_inst() == n_inst
145
-
146
- assert [i.values() for i in cstats] == [
147
- ["4", "5", "6", "7", "8"],
148
- ["4", "5", "8"],
149
- ["6", "7"],
150
- ]
151
-
152
-
153
- def test_init_factory_alias():
154
- """Tests py::init_factory() wrapper with value conversions and alias types"""
155
-
156
- cstats = [m.TestFactory6.get_cstats(), m.TestFactory6.get_alias_cstats()]
157
- cstats[0].alive() # force gc
158
- n_inst = ConstructorStats.detail_reg_inst()
159
-
160
- a = m.TestFactory6(tag.base, 1)
161
- assert a.get() == 1
162
- assert not a.has_alias()
163
- b = m.TestFactory6(tag.alias, "hi there")
164
- assert b.get() == 8
165
- assert b.has_alias()
166
- c = m.TestFactory6(tag.alias, 3)
167
- assert c.get() == 3
168
- assert c.has_alias()
169
- d = m.TestFactory6(tag.alias, tag.pointer, 4)
170
- assert d.get() == 4
171
- assert d.has_alias()
172
- e = m.TestFactory6(tag.base, tag.pointer, 5)
173
- assert e.get() == 5
174
- assert not e.has_alias()
175
- f = m.TestFactory6(tag.base, tag.alias, tag.pointer, 6)
176
- assert f.get() == 6
177
- assert f.has_alias()
178
-
179
- assert ConstructorStats.detail_reg_inst() == n_inst + 6
180
- assert [i.alive() for i in cstats] == [6, 4]
181
-
182
- del a, b, e
183
- assert [i.alive() for i in cstats] == [3, 3]
184
- assert ConstructorStats.detail_reg_inst() == n_inst + 3
185
- del f, c, d
186
- assert [i.alive() for i in cstats] == [0, 0]
187
- assert ConstructorStats.detail_reg_inst() == n_inst
188
-
189
- class MyTest(m.TestFactory6):
190
- def __init__(self, *args):
191
- m.TestFactory6.__init__(self, *args)
192
-
193
- def get(self):
194
- return -5 + m.TestFactory6.get(self)
195
-
196
- # Return Class by value, moved into new alias:
197
- z = MyTest(tag.base, 123)
198
- assert z.get() == 118
199
- assert z.has_alias()
200
-
201
- # Return alias by value, moved into new alias:
202
- y = MyTest(tag.alias, "why hello!")
203
- assert y.get() == 5
204
- assert y.has_alias()
205
-
206
- # Return Class by pointer, moved into new alias then original destroyed:
207
- x = MyTest(tag.base, tag.pointer, 47)
208
- assert x.get() == 42
209
- assert x.has_alias()
210
-
211
- assert ConstructorStats.detail_reg_inst() == n_inst + 3
212
- assert [i.alive() for i in cstats] == [3, 3]
213
- del x, y, z
214
- assert [i.alive() for i in cstats] == [0, 0]
215
- assert ConstructorStats.detail_reg_inst() == n_inst
216
-
217
- assert [i.values() for i in cstats] == [
218
- ["1", "8", "3", "4", "5", "6", "123", "10", "47"],
219
- ["hi there", "3", "4", "6", "move", "123", "why hello!", "move", "47"],
220
- ]
221
-
222
-
223
- def test_init_factory_dual():
224
- """Tests init factory functions with dual main/alias factory functions"""
225
- from pybind11_tests.factory_constructors import TestFactory7
226
-
227
- cstats = [TestFactory7.get_cstats(), TestFactory7.get_alias_cstats()]
228
- cstats[0].alive() # force gc
229
- n_inst = ConstructorStats.detail_reg_inst()
230
-
231
- class PythFactory7(TestFactory7):
232
- def get(self):
233
- return 100 + TestFactory7.get(self)
234
-
235
- a1 = TestFactory7(1)
236
- a2 = PythFactory7(2)
237
- assert a1.get() == 1
238
- assert a2.get() == 102
239
- assert not a1.has_alias()
240
- assert a2.has_alias()
241
-
242
- b1 = TestFactory7(tag.pointer, 3)
243
- b2 = PythFactory7(tag.pointer, 4)
244
- assert b1.get() == 3
245
- assert b2.get() == 104
246
- assert not b1.has_alias()
247
- assert b2.has_alias()
248
-
249
- c1 = TestFactory7(tag.mixed, 5)
250
- c2 = PythFactory7(tag.mixed, 6)
251
- assert c1.get() == 5
252
- assert c2.get() == 106
253
- assert not c1.has_alias()
254
- assert c2.has_alias()
255
-
256
- d1 = TestFactory7(tag.base, tag.pointer, 7)
257
- d2 = PythFactory7(tag.base, tag.pointer, 8)
258
- assert d1.get() == 7
259
- assert d2.get() == 108
260
- assert not d1.has_alias()
261
- assert d2.has_alias()
262
-
263
- # Both return an alias; the second multiplies the value by 10:
264
- e1 = TestFactory7(tag.alias, tag.pointer, 9)
265
- e2 = PythFactory7(tag.alias, tag.pointer, 10)
266
- assert e1.get() == 9
267
- assert e2.get() == 200
268
- assert e1.has_alias()
269
- assert e2.has_alias()
270
-
271
- f1 = TestFactory7(tag.shared_ptr, tag.base, 11)
272
- f2 = PythFactory7(tag.shared_ptr, tag.base, 12)
273
- assert f1.get() == 11
274
- assert f2.get() == 112
275
- assert not f1.has_alias()
276
- assert f2.has_alias()
277
-
278
- g1 = TestFactory7(tag.shared_ptr, tag.invalid_base, 13)
279
- assert g1.get() == 13
280
- assert not g1.has_alias()
281
- with pytest.raises(TypeError) as excinfo:
282
- PythFactory7(tag.shared_ptr, tag.invalid_base, 14)
283
- assert (
284
- str(excinfo.value)
285
- == "pybind11::init(): construction failed: returned holder-wrapped instance is not an "
286
- "alias instance"
287
- )
288
-
289
- assert [i.alive() for i in cstats] == [13, 7]
290
- assert ConstructorStats.detail_reg_inst() == n_inst + 13
291
-
292
- del a1, a2, b1, d1, e1, e2
293
- assert [i.alive() for i in cstats] == [7, 4]
294
- assert ConstructorStats.detail_reg_inst() == n_inst + 7
295
- del b2, c1, c2, d2, f1, f2, g1
296
- assert [i.alive() for i in cstats] == [0, 0]
297
- assert ConstructorStats.detail_reg_inst() == n_inst
298
-
299
- assert [i.values() for i in cstats] == [
300
- ["1", "2", "3", "4", "5", "6", "7", "8", "9", "100", "11", "12", "13", "14"],
301
- ["2", "4", "6", "8", "9", "100", "12"],
302
- ]
303
-
304
-
305
- def test_no_placement_new(capture):
306
- """Prior to 2.2, `py::init<...>` relied on the type supporting placement
307
- new; this tests a class without placement new support."""
308
- with capture:
309
- a = m.NoPlacementNew(123)
310
-
311
- found = re.search(r"^operator new called, returning (\d+)\n$", str(capture))
312
- assert found
313
- assert a.i == 123
314
- with capture:
315
- del a
316
- pytest.gc_collect()
317
- assert capture == "operator delete called on " + found.group(1)
318
-
319
- with capture:
320
- b = m.NoPlacementNew()
321
-
322
- found = re.search(r"^operator new called, returning (\d+)\n$", str(capture))
323
- assert found
324
- assert b.i == 100
325
- with capture:
326
- del b
327
- pytest.gc_collect()
328
- assert capture == "operator delete called on " + found.group(1)
329
-
330
-
331
- def test_multiple_inheritance():
332
- class MITest(m.TestFactory1, m.TestFactory2):
333
- def __init__(self):
334
- m.TestFactory1.__init__(self, tag.unique_ptr, 33)
335
- m.TestFactory2.__init__(self, tag.move)
336
-
337
- a = MITest()
338
- assert m.TestFactory1.value.fget(a) == "33"
339
- assert m.TestFactory2.value.fget(a) == "(empty2)"
340
-
341
-
342
- def create_and_destroy(*args):
343
- a = m.NoisyAlloc(*args)
344
- print("---")
345
- del a
346
- pytest.gc_collect()
347
-
348
-
349
- def strip_comments(s):
350
- return re.sub(r"\s+#.*", "", s)
351
-
352
-
353
- def test_reallocation_a(capture, msg):
354
- """When the constructor is overloaded, previous overloads can require a preallocated value.
355
- This test makes sure that such preallocated values only happen when they might be necessary,
356
- and that they are deallocated properly."""
357
-
358
- pytest.gc_collect()
359
-
360
- with capture:
361
- create_and_destroy(1)
362
- assert (
363
- msg(capture)
364
- == """
365
- noisy new
366
- noisy placement new
367
- NoisyAlloc(int 1)
368
- ---
369
- ~NoisyAlloc()
370
- noisy delete
371
- """
372
- )
373
-
374
-
375
- def test_reallocation_b(capture, msg):
376
- with capture:
377
- create_and_destroy(1.5)
378
- assert msg(capture) == strip_comments(
379
- """
380
- noisy new # allocation required to attempt first overload
381
- noisy delete # have to dealloc before considering factory init overload
382
- noisy new # pointer factory calling "new", part 1: allocation
383
- NoisyAlloc(double 1.5) # ... part two, invoking constructor
384
- ---
385
- ~NoisyAlloc() # Destructor
386
- noisy delete # operator delete
387
- """
388
- )
389
-
390
-
391
- def test_reallocation_c(capture, msg):
392
- with capture:
393
- create_and_destroy(2, 3)
394
- assert msg(capture) == strip_comments(
395
- """
396
- noisy new # pointer factory calling "new", allocation
397
- NoisyAlloc(int 2) # constructor
398
- ---
399
- ~NoisyAlloc() # Destructor
400
- noisy delete # operator delete
401
- """
402
- )
403
-
404
-
405
- def test_reallocation_d(capture, msg):
406
- with capture:
407
- create_and_destroy(2.5, 3)
408
- assert msg(capture) == strip_comments(
409
- """
410
- NoisyAlloc(double 2.5) # construction (local func variable: operator_new not called)
411
- noisy new # return-by-value "new" part 1: allocation
412
- ~NoisyAlloc() # moved-away local func variable destruction
413
- ---
414
- ~NoisyAlloc() # Destructor
415
- noisy delete # operator delete
416
- """
417
- )
418
-
419
-
420
- def test_reallocation_e(capture, msg):
421
- with capture:
422
- create_and_destroy(3.5, 4.5)
423
- assert msg(capture) == strip_comments(
424
- """
425
- noisy new # preallocation needed before invoking placement-new overload
426
- noisy placement new # Placement new
427
- NoisyAlloc(double 3.5) # construction
428
- ---
429
- ~NoisyAlloc() # Destructor
430
- noisy delete # operator delete
431
- """
432
- )
433
-
434
-
435
- def test_reallocation_f(capture, msg):
436
- with capture:
437
- create_and_destroy(4, 0.5)
438
- assert msg(capture) == strip_comments(
439
- """
440
- noisy new # preallocation needed before invoking placement-new overload
441
- noisy delete # deallocation of preallocated storage
442
- noisy new # Factory pointer allocation
443
- NoisyAlloc(int 4) # factory pointer construction
444
- ---
445
- ~NoisyAlloc() # Destructor
446
- noisy delete # operator delete
447
- """
448
- )
449
-
450
-
451
- def test_reallocation_g(capture, msg):
452
- with capture:
453
- create_and_destroy(5, "hi")
454
- assert msg(capture) == strip_comments(
455
- """
456
- noisy new # preallocation needed before invoking first placement new
457
- noisy delete # delete before considering new-style constructor
458
- noisy new # preallocation for second placement new
459
- noisy placement new # Placement new in the second placement new overload
460
- NoisyAlloc(int 5) # construction
461
- ---
462
- ~NoisyAlloc() # Destructor
463
- noisy delete # operator delete
464
- """
465
- )
466
-
467
-
468
- @pytest.mark.skipif("env.PY2")
469
- def test_invalid_self():
470
- """Tests invocation of the pybind-registered base class with an invalid `self` argument. You
471
- can only actually do this on Python 3: Python 2 raises an exception itself if you try."""
472
-
473
- class NotPybindDerived(object):
474
- pass
475
-
476
- # Attempts to initialize with an invalid type passed as `self`:
477
- class BrokenTF1(m.TestFactory1):
478
- def __init__(self, bad):
479
- if bad == 1:
480
- a = m.TestFactory2(tag.pointer, 1)
481
- m.TestFactory1.__init__(a, tag.pointer)
482
- elif bad == 2:
483
- a = NotPybindDerived()
484
- m.TestFactory1.__init__(a, tag.pointer)
485
-
486
- # Same as above, but for a class with an alias:
487
- class BrokenTF6(m.TestFactory6):
488
- def __init__(self, bad):
489
- if bad == 0:
490
- m.TestFactory6.__init__()
491
- elif bad == 1:
492
- a = m.TestFactory2(tag.pointer, 1)
493
- m.TestFactory6.__init__(a, tag.base, 1)
494
- elif bad == 2:
495
- a = m.TestFactory2(tag.pointer, 1)
496
- m.TestFactory6.__init__(a, tag.alias, 1)
497
- elif bad == 3:
498
- m.TestFactory6.__init__(
499
- NotPybindDerived.__new__(NotPybindDerived), tag.base, 1
500
- )
501
- elif bad == 4:
502
- m.TestFactory6.__init__(
503
- NotPybindDerived.__new__(NotPybindDerived), tag.alias, 1
504
- )
505
-
506
- for arg in (1, 2):
507
- with pytest.raises(TypeError) as excinfo:
508
- BrokenTF1(arg)
509
- assert (
510
- str(excinfo.value)
511
- == "__init__(self, ...) called with invalid or missing `self` argument"
512
- )
513
-
514
- for arg in (0, 1, 2, 3, 4):
515
- with pytest.raises(TypeError) as excinfo:
516
- BrokenTF6(arg)
517
- assert (
518
- str(excinfo.value)
519
- == "__init__(self, ...) called with invalid or missing `self` argument"
520
- )
@@ -1,49 +0,0 @@
1
- /*
2
- tests/test_gil_scoped.cpp -- acquire and release gil
3
-
4
- Copyright (c) 2017 Borja Zarco (Google LLC) <bzarco@google.com>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include <pybind11/functional.h>
12
-
13
-
14
- class VirtClass {
15
- public:
16
- virtual ~VirtClass() = default;
17
- VirtClass() = default;
18
- VirtClass(const VirtClass&) = delete;
19
- virtual void virtual_func() {}
20
- virtual void pure_virtual_func() = 0;
21
- };
22
-
23
- class PyVirtClass : public VirtClass {
24
- void virtual_func() override {
25
- PYBIND11_OVERRIDE(void, VirtClass, virtual_func,);
26
- }
27
- void pure_virtual_func() override {
28
- PYBIND11_OVERRIDE_PURE(void, VirtClass, pure_virtual_func,);
29
- }
30
- };
31
-
32
- TEST_SUBMODULE(gil_scoped, m) {
33
- py::class_<VirtClass, PyVirtClass>(m, "VirtClass")
34
- .def(py::init<>())
35
- .def("virtual_func", &VirtClass::virtual_func)
36
- .def("pure_virtual_func", &VirtClass::pure_virtual_func);
37
-
38
- m.def("test_callback_py_obj", [](py::object &func) { func(); });
39
- m.def("test_callback_std_func", [](const std::function<void()> &func) { func(); });
40
- m.def("test_callback_virtual_func", [](VirtClass &virt) { virt.virtual_func(); });
41
- m.def("test_callback_pure_virtual_func", [](VirtClass &virt) { virt.pure_virtual_func(); });
42
- m.def("test_cross_module_gil", []() {
43
- auto cm = py::module_::import("cross_module_gil_utils");
44
- auto gil_acquire
45
- = reinterpret_cast<void (*)()>(PyLong_AsVoidPtr(cm.attr("gil_acquire_funcaddr").ptr()));
46
- py::gil_scoped_release gil_release;
47
- gil_acquire();
48
- });
49
- }
@@ -1,94 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import multiprocessing
3
- import threading
4
-
5
- from pybind11_tests import gil_scoped as m
6
-
7
-
8
- def _run_in_process(target, *args, **kwargs):
9
- """Runs target in process and returns its exitcode after 10s (None if still alive)."""
10
- process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
11
- process.daemon = True
12
- try:
13
- process.start()
14
- # Do not need to wait much, 10s should be more than enough.
15
- process.join(timeout=10)
16
- return process.exitcode
17
- finally:
18
- if process.is_alive():
19
- process.terminate()
20
-
21
-
22
- def _python_to_cpp_to_python():
23
- """Calls different C++ functions that come back to Python."""
24
-
25
- class ExtendedVirtClass(m.VirtClass):
26
- def virtual_func(self):
27
- pass
28
-
29
- def pure_virtual_func(self):
30
- pass
31
-
32
- extended = ExtendedVirtClass()
33
- m.test_callback_py_obj(lambda: None)
34
- m.test_callback_std_func(lambda: None)
35
- m.test_callback_virtual_func(extended)
36
- m.test_callback_pure_virtual_func(extended)
37
-
38
-
39
- def _python_to_cpp_to_python_from_threads(num_threads, parallel=False):
40
- """Calls different C++ functions that come back to Python, from Python threads."""
41
- threads = []
42
- for _ in range(num_threads):
43
- thread = threading.Thread(target=_python_to_cpp_to_python)
44
- thread.daemon = True
45
- thread.start()
46
- if parallel:
47
- threads.append(thread)
48
- else:
49
- thread.join()
50
- for thread in threads:
51
- thread.join()
52
-
53
-
54
- # TODO: FIXME, sometimes returns -11 (segfault) instead of 0 on macOS Python 3.9
55
- def test_python_to_cpp_to_python_from_thread():
56
- """Makes sure there is no GIL deadlock when running in a thread.
57
-
58
- It runs in a separate process to be able to stop and assert if it deadlocks.
59
- """
60
- assert _run_in_process(_python_to_cpp_to_python_from_threads, 1) == 0
61
-
62
-
63
- # TODO: FIXME on macOS Python 3.9
64
- def test_python_to_cpp_to_python_from_thread_multiple_parallel():
65
- """Makes sure there is no GIL deadlock when running in a thread multiple times in parallel.
66
-
67
- It runs in a separate process to be able to stop and assert if it deadlocks.
68
- """
69
- assert _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=True) == 0
70
-
71
-
72
- # TODO: FIXME on macOS Python 3.9
73
- def test_python_to_cpp_to_python_from_thread_multiple_sequential():
74
- """Makes sure there is no GIL deadlock when running in a thread multiple times sequentially.
75
-
76
- It runs in a separate process to be able to stop and assert if it deadlocks.
77
- """
78
- assert (
79
- _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=False) == 0
80
- )
81
-
82
-
83
- # TODO: FIXME on macOS Python 3.9
84
- def test_python_to_cpp_to_python_from_process():
85
- """Makes sure there is no GIL deadlock when using processes.
86
-
87
- This test is for completion, but it was never an issue.
88
- """
89
- assert _run_in_process(_python_to_cpp_to_python) == 0
90
-
91
-
92
- def test_cross_module_gil():
93
- """Makes sure that the GIL can be acquired by another module from a GIL-released state."""
94
- m.test_cross_module_gil() # Should not raise a SIGSEGV