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,47 +0,0 @@
1
- possibly_uninitialized(PYTHON_MODULE_EXTENSION Python_INTERPRETER_ID)
2
-
3
- if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy")
4
- message(STATUS "Skipping embed test on PyPy")
5
- add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported.
6
- set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}")
7
- return()
8
- endif()
9
-
10
- find_package(Catch 2.13.2)
11
-
12
- if(CATCH_FOUND)
13
- message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}")
14
- else()
15
- message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers"
16
- " manually or use `cmake -DDOWNLOAD_CATCH=ON` to fetch them automatically.")
17
- return()
18
- endif()
19
-
20
- find_package(Threads REQUIRED)
21
-
22
- add_executable(test_embed catch.cpp test_interpreter.cpp)
23
- pybind11_enable_warnings(test_embed)
24
-
25
- target_link_libraries(test_embed PRIVATE pybind11::embed Catch2::Catch2 Threads::Threads)
26
-
27
- if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
28
- file(COPY test_interpreter.py DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
29
- endif()
30
-
31
- add_custom_target(
32
- cpptest
33
- COMMAND "$<TARGET_FILE:test_embed>"
34
- DEPENDS test_embed
35
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
36
-
37
- pybind11_add_module(external_module THIN_LTO external_module.cpp)
38
- set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY
39
- "${CMAKE_CURRENT_BINARY_DIR}")
40
- foreach(config ${CMAKE_CONFIGURATION_TYPES})
41
- string(TOUPPER ${config} config)
42
- set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config}
43
- "${CMAKE_CURRENT_BINARY_DIR}")
44
- endforeach()
45
- add_dependencies(cpptest external_module)
46
-
47
- add_dependencies(check cpptest)
@@ -1,22 +0,0 @@
1
- // The Catch implementation is compiled here. This is a standalone
2
- // translation unit to avoid recompiling it for every test change.
3
-
4
- #include <pybind11/embed.h>
5
-
6
- #ifdef _MSC_VER
7
- // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch
8
- // 2.0.1; this should be fixed in the next catch release after 2.0.1).
9
- # pragma warning(disable: 4996)
10
- #endif
11
-
12
- #define CATCH_CONFIG_RUNNER
13
- #include <catch.hpp>
14
-
15
- namespace py = pybind11;
16
-
17
- int main(int argc, char *argv[]) {
18
- py::scoped_interpreter guard{};
19
- auto result = Catch::Session().run(argc, argv);
20
-
21
- return result < 0xff ? result : 0xff;
22
- }
@@ -1,23 +0,0 @@
1
- #include <pybind11/pybind11.h>
2
-
3
- namespace py = pybind11;
4
-
5
- /* Simple test module/test class to check that the referenced internals data of external pybind11
6
- * modules aren't preserved over a finalize/initialize.
7
- */
8
-
9
- PYBIND11_MODULE(external_module, m) {
10
- class A {
11
- public:
12
- explicit A(int value) : v{value} {};
13
- int v;
14
- };
15
-
16
- py::class_<A>(m, "A")
17
- .def(py::init<int>())
18
- .def_readwrite("value", &A::v);
19
-
20
- m.def("internals_at", []() {
21
- return reinterpret_cast<uintptr_t>(&py::detail::get_internals());
22
- });
23
- }
@@ -1,326 +0,0 @@
1
- #include <pybind11/embed.h>
2
-
3
- #ifdef _MSC_VER
4
- // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch
5
- // 2.0.1; this should be fixed in the next catch release after 2.0.1).
6
- # pragma warning(disable: 4996)
7
- #endif
8
-
9
- #include <catch.hpp>
10
-
11
- #include <cstdlib>
12
- #include <fstream>
13
- #include <functional>
14
- #include <thread>
15
- #include <utility>
16
-
17
- namespace py = pybind11;
18
- using namespace py::literals;
19
-
20
- class Widget {
21
- public:
22
- explicit Widget(std::string message) : message(std::move(message)) {}
23
- virtual ~Widget() = default;
24
-
25
- std::string the_message() const { return message; }
26
- virtual int the_answer() const = 0;
27
- virtual std::string argv0() const = 0;
28
-
29
- private:
30
- std::string message;
31
- };
32
-
33
- class PyWidget final : public Widget {
34
- using Widget::Widget;
35
-
36
- int the_answer() const override { PYBIND11_OVERRIDE_PURE(int, Widget, the_answer); }
37
- std::string argv0() const override { PYBIND11_OVERRIDE_PURE(std::string, Widget, argv0); }
38
- };
39
-
40
- PYBIND11_EMBEDDED_MODULE(widget_module, m) {
41
- py::class_<Widget, PyWidget>(m, "Widget")
42
- .def(py::init<std::string>())
43
- .def_property_readonly("the_message", &Widget::the_message);
44
-
45
- m.def("add", [](int i, int j) { return i + j; });
46
- }
47
-
48
- PYBIND11_EMBEDDED_MODULE(throw_exception, ) {
49
- throw std::runtime_error("C++ Error");
50
- }
51
-
52
- PYBIND11_EMBEDDED_MODULE(throw_error_already_set, ) {
53
- auto d = py::dict();
54
- d["missing"].cast<py::object>();
55
- }
56
-
57
- TEST_CASE("Pass classes and data between modules defined in C++ and Python") {
58
- auto module_ = py::module_::import("test_interpreter");
59
- REQUIRE(py::hasattr(module_, "DerivedWidget"));
60
-
61
- auto locals = py::dict("hello"_a="Hello, World!", "x"_a=5, **module_.attr("__dict__"));
62
- py::exec(R"(
63
- widget = DerivedWidget("{} - {}".format(hello, x))
64
- message = widget.the_message
65
- )", py::globals(), locals);
66
- REQUIRE(locals["message"].cast<std::string>() == "Hello, World! - 5");
67
-
68
- auto py_widget = module_.attr("DerivedWidget")("The question");
69
- auto message = py_widget.attr("the_message");
70
- REQUIRE(message.cast<std::string>() == "The question");
71
-
72
- const auto &cpp_widget = py_widget.cast<const Widget &>();
73
- REQUIRE(cpp_widget.the_answer() == 42);
74
- }
75
-
76
- TEST_CASE("Import error handling") {
77
- REQUIRE_NOTHROW(py::module_::import("widget_module"));
78
- REQUIRE_THROWS_WITH(py::module_::import("throw_exception"),
79
- "ImportError: C++ Error");
80
- #if PY_VERSION_HEX >= 0x03030000
81
- REQUIRE_THROWS_WITH(py::module_::import("throw_error_already_set"),
82
- Catch::Contains("ImportError: initialization failed"));
83
-
84
- auto locals = py::dict("is_keyerror"_a=false, "message"_a="not set");
85
- py::exec(R"(
86
- try:
87
- import throw_error_already_set
88
- except ImportError as e:
89
- is_keyerror = type(e.__cause__) == KeyError
90
- message = str(e.__cause__)
91
- )", py::globals(), locals);
92
- REQUIRE(locals["is_keyerror"].cast<bool>() == true);
93
- REQUIRE(locals["message"].cast<std::string>() == "'missing'");
94
- #else
95
- REQUIRE_THROWS_WITH(py::module_::import("throw_error_already_set"),
96
- Catch::Contains("ImportError: KeyError"));
97
- #endif
98
- }
99
-
100
- TEST_CASE("There can be only one interpreter") {
101
- static_assert(std::is_move_constructible<py::scoped_interpreter>::value, "");
102
- static_assert(!std::is_move_assignable<py::scoped_interpreter>::value, "");
103
- static_assert(!std::is_copy_constructible<py::scoped_interpreter>::value, "");
104
- static_assert(!std::is_copy_assignable<py::scoped_interpreter>::value, "");
105
-
106
- REQUIRE_THROWS_WITH(py::initialize_interpreter(), "The interpreter is already running");
107
- REQUIRE_THROWS_WITH(py::scoped_interpreter(), "The interpreter is already running");
108
-
109
- py::finalize_interpreter();
110
- REQUIRE_NOTHROW(py::scoped_interpreter());
111
- {
112
- auto pyi1 = py::scoped_interpreter();
113
- auto pyi2 = std::move(pyi1);
114
- }
115
- py::initialize_interpreter();
116
- }
117
-
118
- bool has_pybind11_internals_builtin() {
119
- auto builtins = py::handle(PyEval_GetBuiltins());
120
- return builtins.contains(PYBIND11_INTERNALS_ID);
121
- };
122
-
123
- bool has_pybind11_internals_static() {
124
- auto **&ipp = py::detail::get_internals_pp();
125
- return (ipp != nullptr) && (*ipp != nullptr);
126
- }
127
-
128
- TEST_CASE("Restart the interpreter") {
129
- // Verify pre-restart state.
130
- REQUIRE(py::module_::import("widget_module").attr("add")(1, 2).cast<int>() == 3);
131
- REQUIRE(has_pybind11_internals_builtin());
132
- REQUIRE(has_pybind11_internals_static());
133
- REQUIRE(py::module_::import("external_module").attr("A")(123).attr("value").cast<int>() == 123);
134
-
135
- // local and foreign module internals should point to the same internals:
136
- REQUIRE(reinterpret_cast<uintptr_t>(*py::detail::get_internals_pp()) ==
137
- py::module_::import("external_module").attr("internals_at")().cast<uintptr_t>());
138
-
139
- // Restart the interpreter.
140
- py::finalize_interpreter();
141
- REQUIRE(Py_IsInitialized() == 0);
142
-
143
- py::initialize_interpreter();
144
- REQUIRE(Py_IsInitialized() == 1);
145
-
146
- // Internals are deleted after a restart.
147
- REQUIRE_FALSE(has_pybind11_internals_builtin());
148
- REQUIRE_FALSE(has_pybind11_internals_static());
149
- pybind11::detail::get_internals();
150
- REQUIRE(has_pybind11_internals_builtin());
151
- REQUIRE(has_pybind11_internals_static());
152
- REQUIRE(reinterpret_cast<uintptr_t>(*py::detail::get_internals_pp()) ==
153
- py::module_::import("external_module").attr("internals_at")().cast<uintptr_t>());
154
-
155
- // Make sure that an interpreter with no get_internals() created until finalize still gets the
156
- // internals destroyed
157
- py::finalize_interpreter();
158
- py::initialize_interpreter();
159
- bool ran = false;
160
- py::module_::import("__main__").attr("internals_destroy_test") =
161
- py::capsule(&ran, [](void *ran) { py::detail::get_internals(); *static_cast<bool *>(ran) = true; });
162
- REQUIRE_FALSE(has_pybind11_internals_builtin());
163
- REQUIRE_FALSE(has_pybind11_internals_static());
164
- REQUIRE_FALSE(ran);
165
- py::finalize_interpreter();
166
- REQUIRE(ran);
167
- py::initialize_interpreter();
168
- REQUIRE_FALSE(has_pybind11_internals_builtin());
169
- REQUIRE_FALSE(has_pybind11_internals_static());
170
-
171
- // C++ modules can be reloaded.
172
- auto cpp_module = py::module_::import("widget_module");
173
- REQUIRE(cpp_module.attr("add")(1, 2).cast<int>() == 3);
174
-
175
- // C++ type information is reloaded and can be used in python modules.
176
- auto py_module = py::module_::import("test_interpreter");
177
- auto py_widget = py_module.attr("DerivedWidget")("Hello after restart");
178
- REQUIRE(py_widget.attr("the_message").cast<std::string>() == "Hello after restart");
179
- }
180
-
181
- TEST_CASE("Subinterpreter") {
182
- // Add tags to the modules in the main interpreter and test the basics.
183
- py::module_::import("__main__").attr("main_tag") = "main interpreter";
184
- {
185
- auto m = py::module_::import("widget_module");
186
- m.attr("extension_module_tag") = "added to module in main interpreter";
187
-
188
- REQUIRE(m.attr("add")(1, 2).cast<int>() == 3);
189
- }
190
- REQUIRE(has_pybind11_internals_builtin());
191
- REQUIRE(has_pybind11_internals_static());
192
-
193
- /// Create and switch to a subinterpreter.
194
- auto main_tstate = PyThreadState_Get();
195
- auto sub_tstate = Py_NewInterpreter();
196
-
197
- // Subinterpreters get their own copy of builtins. detail::get_internals() still
198
- // works by returning from the static variable, i.e. all interpreters share a single
199
- // global pybind11::internals;
200
- REQUIRE_FALSE(has_pybind11_internals_builtin());
201
- REQUIRE(has_pybind11_internals_static());
202
-
203
- // Modules tags should be gone.
204
- REQUIRE_FALSE(py::hasattr(py::module_::import("__main__"), "tag"));
205
- {
206
- auto m = py::module_::import("widget_module");
207
- REQUIRE_FALSE(py::hasattr(m, "extension_module_tag"));
208
-
209
- // Function bindings should still work.
210
- REQUIRE(m.attr("add")(1, 2).cast<int>() == 3);
211
- }
212
-
213
- // Restore main interpreter.
214
- Py_EndInterpreter(sub_tstate);
215
- PyThreadState_Swap(main_tstate);
216
-
217
- REQUIRE(py::hasattr(py::module_::import("__main__"), "main_tag"));
218
- REQUIRE(py::hasattr(py::module_::import("widget_module"), "extension_module_tag"));
219
- }
220
-
221
- TEST_CASE("Execution frame") {
222
- // When the interpreter is embedded, there is no execution frame, but `py::exec`
223
- // should still function by using reasonable globals: `__main__.__dict__`.
224
- py::exec("var = dict(number=42)");
225
- REQUIRE(py::globals()["var"]["number"].cast<int>() == 42);
226
- }
227
-
228
- TEST_CASE("Threads") {
229
- // Restart interpreter to ensure threads are not initialized
230
- py::finalize_interpreter();
231
- py::initialize_interpreter();
232
- REQUIRE_FALSE(has_pybind11_internals_static());
233
-
234
- constexpr auto num_threads = 10;
235
- auto locals = py::dict("count"_a=0);
236
-
237
- {
238
- py::gil_scoped_release gil_release{};
239
- REQUIRE(has_pybind11_internals_static());
240
-
241
- auto threads = std::vector<std::thread>();
242
- for (auto i = 0; i < num_threads; ++i) {
243
- threads.emplace_back([&]() {
244
- py::gil_scoped_acquire gil{};
245
- locals["count"] = locals["count"].cast<int>() + 1;
246
- });
247
- }
248
-
249
- for (auto &thread : threads) {
250
- thread.join();
251
- }
252
- }
253
-
254
- REQUIRE(locals["count"].cast<int>() == num_threads);
255
- }
256
-
257
- // Scope exit utility https://stackoverflow.com/a/36644501/7255855
258
- struct scope_exit {
259
- std::function<void()> f_;
260
- explicit scope_exit(std::function<void()> f) noexcept : f_(std::move(f)) {}
261
- ~scope_exit() { if (f_) f_(); }
262
- };
263
-
264
- TEST_CASE("Reload module from file") {
265
- // Disable generation of cached bytecode (.pyc files) for this test, otherwise
266
- // Python might pick up an old version from the cache instead of the new versions
267
- // of the .py files generated below
268
- auto sys = py::module_::import("sys");
269
- bool dont_write_bytecode = sys.attr("dont_write_bytecode").cast<bool>();
270
- sys.attr("dont_write_bytecode") = true;
271
- // Reset the value at scope exit
272
- scope_exit reset_dont_write_bytecode([&]() {
273
- sys.attr("dont_write_bytecode") = dont_write_bytecode;
274
- });
275
-
276
- std::string module_name = "test_module_reload";
277
- std::string module_file = module_name + ".py";
278
-
279
- // Create the module .py file
280
- std::ofstream test_module(module_file);
281
- test_module << "def test():\n";
282
- test_module << " return 1\n";
283
- test_module.close();
284
- // Delete the file at scope exit
285
- scope_exit delete_module_file([&]() {
286
- std::remove(module_file.c_str());
287
- });
288
-
289
- // Import the module from file
290
- auto module_ = py::module_::import(module_name.c_str());
291
- int result = module_.attr("test")().cast<int>();
292
- REQUIRE(result == 1);
293
-
294
- // Update the module .py file with a small change
295
- test_module.open(module_file);
296
- test_module << "def test():\n";
297
- test_module << " return 2\n";
298
- test_module.close();
299
-
300
- // Reload the module
301
- module_.reload();
302
- result = module_.attr("test")().cast<int>();
303
- REQUIRE(result == 2);
304
- }
305
-
306
- TEST_CASE("sys.argv gets initialized properly") {
307
- py::finalize_interpreter();
308
- {
309
- py::scoped_interpreter default_scope;
310
- auto module = py::module::import("test_interpreter");
311
- auto py_widget = module.attr("DerivedWidget")("The question");
312
- const auto &cpp_widget = py_widget.cast<const Widget &>();
313
- REQUIRE(cpp_widget.argv0().empty());
314
- }
315
-
316
- {
317
- char *argv[] = {strdup("a.out")};
318
- py::scoped_interpreter argv_scope(true, 1, argv);
319
- std::free(argv[0]);
320
- auto module = py::module::import("test_interpreter");
321
- auto py_widget = module.attr("DerivedWidget")("The question");
322
- const auto &cpp_widget = py_widget.cast<const Widget &>();
323
- REQUIRE(cpp_widget.argv0() == "a.out");
324
- }
325
- py::initialize_interpreter();
326
- }
@@ -1,15 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import sys
3
-
4
- from widget_module import Widget
5
-
6
-
7
- class DerivedWidget(Widget):
8
- def __init__(self, message):
9
- super(DerivedWidget, self).__init__(message)
10
-
11
- def the_answer(self):
12
- return 42
13
-
14
- def argv0(self):
15
- return sys.argv[0]
@@ -1,148 +0,0 @@
1
- /*
2
- tests/test_enums.cpp -- enumerations
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
-
12
- TEST_SUBMODULE(enums, m) {
13
- // test_unscoped_enum
14
- enum UnscopedEnum {
15
- EOne = 1,
16
- ETwo,
17
- EThree
18
- };
19
- py::enum_<UnscopedEnum>(m, "UnscopedEnum", py::arithmetic(), "An unscoped enumeration")
20
- .value("EOne", EOne, "Docstring for EOne")
21
- .value("ETwo", ETwo, "Docstring for ETwo")
22
- .value("EThree", EThree, "Docstring for EThree")
23
- .export_values();
24
-
25
- // test_scoped_enum
26
- enum class ScopedEnum {
27
- Two = 2,
28
- Three
29
- };
30
- py::enum_<ScopedEnum>(m, "ScopedEnum", py::arithmetic())
31
- .value("Two", ScopedEnum::Two)
32
- .value("Three", ScopedEnum::Three);
33
-
34
- m.def("test_scoped_enum", [](ScopedEnum z) {
35
- return "ScopedEnum::" + std::string(z == ScopedEnum::Two ? "Two" : "Three");
36
- });
37
-
38
- // test_binary_operators
39
- enum Flags {
40
- Read = 4,
41
- Write = 2,
42
- Execute = 1
43
- };
44
- py::enum_<Flags>(m, "Flags", py::arithmetic())
45
- .value("Read", Flags::Read)
46
- .value("Write", Flags::Write)
47
- .value("Execute", Flags::Execute)
48
- .export_values();
49
-
50
- // test_implicit_conversion
51
- class ClassWithUnscopedEnum {
52
- public:
53
- enum EMode {
54
- EFirstMode = 1,
55
- ESecondMode
56
- };
57
-
58
- static EMode test_function(EMode mode) {
59
- return mode;
60
- }
61
- };
62
- py::class_<ClassWithUnscopedEnum> exenum_class(m, "ClassWithUnscopedEnum");
63
- exenum_class.def_static("test_function", &ClassWithUnscopedEnum::test_function);
64
- py::enum_<ClassWithUnscopedEnum::EMode>(exenum_class, "EMode")
65
- .value("EFirstMode", ClassWithUnscopedEnum::EFirstMode)
66
- .value("ESecondMode", ClassWithUnscopedEnum::ESecondMode)
67
- .export_values();
68
-
69
- // test_enum_to_int
70
- m.def("test_enum_to_int", [](int) { });
71
- m.def("test_enum_to_uint", [](uint32_t) { });
72
- m.def("test_enum_to_long_long", [](long long) { });
73
-
74
- // test_duplicate_enum_name
75
- enum SimpleEnum
76
- {
77
- ONE, TWO, THREE
78
- };
79
-
80
- m.def("register_bad_enum", [m]() {
81
- py::enum_<SimpleEnum>(m, "SimpleEnum")
82
- .value("ONE", SimpleEnum::ONE) //NOTE: all value function calls are called with the same first parameter value
83
- .value("ONE", SimpleEnum::TWO)
84
- .value("ONE", SimpleEnum::THREE)
85
- .export_values();
86
- });
87
-
88
- // test_enum_scalar
89
- enum UnscopedUCharEnum : unsigned char {};
90
- enum class ScopedShortEnum : short {};
91
- enum class ScopedLongEnum : long {};
92
- enum UnscopedUInt64Enum : std::uint64_t {};
93
- static_assert(py::detail::all_of<
94
- std::is_same<py::enum_<UnscopedUCharEnum>::Scalar, unsigned char>,
95
- std::is_same<py::enum_<ScopedShortEnum>::Scalar, short>,
96
- std::is_same<py::enum_<ScopedLongEnum>::Scalar, long>,
97
- std::is_same<py::enum_<UnscopedUInt64Enum>::Scalar, std::uint64_t>
98
- >::value, "Error during the deduction of enum's scalar type with normal integer underlying");
99
-
100
- // test_enum_scalar_with_char_underlying
101
- enum class ScopedCharEnum : char { Zero, Positive };
102
- enum class ScopedWCharEnum : wchar_t { Zero, Positive };
103
- enum class ScopedChar32Enum : char32_t { Zero, Positive };
104
- enum class ScopedChar16Enum : char16_t { Zero, Positive };
105
-
106
- // test the scalar of char type enums according to chapter 'Character types'
107
- // from https://en.cppreference.com/w/cpp/language/types
108
- static_assert(py::detail::any_of<
109
- std::is_same<py::enum_<ScopedCharEnum>::Scalar, signed char>, // e.g. gcc on x86
110
- std::is_same<py::enum_<ScopedCharEnum>::Scalar, unsigned char> // e.g. arm linux
111
- >::value, "char should be cast to either signed char or unsigned char");
112
- static_assert(
113
- sizeof(py::enum_<ScopedWCharEnum>::Scalar) == 2 ||
114
- sizeof(py::enum_<ScopedWCharEnum>::Scalar) == 4
115
- , "wchar_t should be either 16 bits (Windows) or 32 (everywhere else)");
116
- static_assert(py::detail::all_of<
117
- std::is_same<py::enum_<ScopedChar32Enum>::Scalar, std::uint_least32_t>,
118
- std::is_same<py::enum_<ScopedChar16Enum>::Scalar, std::uint_least16_t>
119
- >::value, "char32_t, char16_t (and char8_t)'s size, signedness, and alignment is determined");
120
- #if defined(PYBIND11_HAS_U8STRING)
121
- enum class ScopedChar8Enum : char8_t { Zero, Positive };
122
- static_assert(std::is_same<py::enum_<ScopedChar8Enum>::Scalar, unsigned char>::value);
123
- #endif
124
-
125
- // test_char_underlying_enum
126
- py::enum_<ScopedCharEnum>(m, "ScopedCharEnum")
127
- .value("Zero", ScopedCharEnum::Zero)
128
- .value("Positive", ScopedCharEnum::Positive);
129
- py::enum_<ScopedWCharEnum>(m, "ScopedWCharEnum")
130
- .value("Zero", ScopedWCharEnum::Zero)
131
- .value("Positive", ScopedWCharEnum::Positive);
132
- py::enum_<ScopedChar32Enum>(m, "ScopedChar32Enum")
133
- .value("Zero", ScopedChar32Enum::Zero)
134
- .value("Positive", ScopedChar32Enum::Positive);
135
- py::enum_<ScopedChar16Enum>(m, "ScopedChar16Enum")
136
- .value("Zero", ScopedChar16Enum::Zero)
137
- .value("Positive", ScopedChar16Enum::Positive);
138
-
139
- // test_bool_underlying_enum
140
- enum class ScopedBoolEnum : bool { FALSE, TRUE };
141
-
142
- // bool is unsigned (std::is_signed returns false) and 1-byte long, so represented with u8
143
- static_assert(std::is_same<py::enum_<ScopedBoolEnum>::Scalar, std::uint8_t>::value, "");
144
-
145
- py::enum_<ScopedBoolEnum>(m, "ScopedBoolEnum")
146
- .value("FALSE", ScopedBoolEnum::FALSE)
147
- .value("TRUE", ScopedBoolEnum::TRUE);
148
- }