xcoll 0.5.12__py3-none-any.whl → 0.6.1__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 (336) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/__init__.py.orig +26 -0
  3. xcoll/beam_elements/__init__.py +1 -0
  4. xcoll/beam_elements/absorber.py +12 -2
  5. xcoll/beam_elements/base.py +162 -62
  6. xcoll/beam_elements/blowup.py +1 -0
  7. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  8. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  9. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  10. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  11. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  12. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  13. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  14. xcoll/beam_elements/everest.py +16 -5
  15. xcoll/beam_elements/monitor.py +1 -0
  16. xcoll/beam_elements/transparent.py +83 -0
  17. xcoll/colldb.py +15 -6
  18. xcoll/general.py +1 -1
  19. xcoll/general.py.orig +20 -0
  20. xcoll/headers/particle_states.py +51 -0
  21. xcoll/initial_distribution.py +121 -91
  22. xcoll/initial_distribution.py.orig +256 -0
  23. xcoll/interaction_record/interaction_record.py +2 -1
  24. xcoll/interaction_record/interaction_types.py +2 -2
  25. xcoll/line_tools.py +163 -73
  26. xcoll/lossmap.py +519 -127
  27. xcoll/plot.py +109 -0
  28. xcoll/rf_sweep.py +6 -0
  29. xcoll/scattering_routines/engine.py +414 -217
  30. xcoll/scattering_routines/environment.py +297 -0
  31. xcoll/scattering_routines/everest/amorphous.h +95 -71
  32. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  33. xcoll/scattering_routines/everest/constants.h +1 -1
  34. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  35. xcoll/scattering_routines/everest/everest.h +8 -3
  36. xcoll/scattering_routines/everest/everest.py +2 -1
  37. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  38. xcoll/scattering_routines/everest/jaw.h +19 -24
  39. xcoll/scattering_routines/everest/materials.py +2 -0
  40. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  41. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  42. xcoll/scattering_routines/everest/properties.h +3 -72
  43. xcoll/xaux.py +65 -109
  44. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/METADATA +5 -5
  45. xcoll-0.6.1.dist-info/RECORD +138 -0
  46. xcoll/_manager.py +0 -22
  47. xcoll/headers/particle_states.h +0 -25
  48. xcoll/install.py +0 -35
  49. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  50. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  51. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  52. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  53. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  54. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  55. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  56. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  57. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  58. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  289. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  290. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  291. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  292. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  293. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  304. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  305. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  306. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  307. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  317. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  318. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  319. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  330. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  331. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  332. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  333. xcoll-0.5.12.dist-info/RECORD +0 -415
  334. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/LICENSE +0 -0
  335. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/NOTICE +0 -0
  336. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/WHEEL +0 -0
@@ -1,143 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import os
3
- import subprocess
4
- import sys
5
- from textwrap import dedent
6
-
7
- import pytest
8
-
9
- DIR = os.path.abspath(os.path.dirname(__file__))
10
- MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
11
-
12
-
13
- @pytest.mark.parametrize("parallel", [False, True])
14
- @pytest.mark.parametrize("std", [11, 0])
15
- def test_simple_setup_py(monkeypatch, tmpdir, parallel, std):
16
- monkeypatch.chdir(tmpdir)
17
- monkeypatch.syspath_prepend(MAIN_DIR)
18
-
19
- (tmpdir / "setup.py").write_text(
20
- dedent(
21
- u"""\
22
- import sys
23
- sys.path.append({MAIN_DIR!r})
24
-
25
- from setuptools import setup, Extension
26
- from pybind11.setup_helpers import build_ext, Pybind11Extension
27
-
28
- std = {std}
29
-
30
- ext_modules = [
31
- Pybind11Extension(
32
- "simple_setup",
33
- sorted(["main.cpp"]),
34
- cxx_std=std,
35
- ),
36
- ]
37
-
38
- cmdclass = dict()
39
- if std == 0:
40
- cmdclass["build_ext"] = build_ext
41
-
42
-
43
- parallel = {parallel}
44
- if parallel:
45
- from pybind11.setup_helpers import ParallelCompile
46
- ParallelCompile().install()
47
-
48
- setup(
49
- name="simple_setup_package",
50
- cmdclass=cmdclass,
51
- ext_modules=ext_modules,
52
- )
53
- """
54
- ).format(MAIN_DIR=MAIN_DIR, std=std, parallel=parallel),
55
- encoding="ascii",
56
- )
57
-
58
- (tmpdir / "main.cpp").write_text(
59
- dedent(
60
- u"""\
61
- #include <pybind11/pybind11.h>
62
-
63
- int f(int x) {
64
- return x * 3;
65
- }
66
- PYBIND11_MODULE(simple_setup, m) {
67
- m.def("f", &f);
68
- }
69
- """
70
- ),
71
- encoding="ascii",
72
- )
73
-
74
- subprocess.check_call(
75
- [sys.executable, "setup.py", "build_ext", "--inplace"],
76
- stdout=sys.stdout,
77
- stderr=sys.stderr,
78
- )
79
-
80
- # Debug helper printout, normally hidden
81
- for item in tmpdir.listdir():
82
- print(item.basename)
83
-
84
- assert (
85
- len([f for f in tmpdir.listdir() if f.basename.startswith("simple_setup")]) == 1
86
- )
87
- assert len(list(tmpdir.listdir())) == 4 # two files + output + build_dir
88
-
89
- (tmpdir / "test.py").write_text(
90
- dedent(
91
- u"""\
92
- import simple_setup
93
- assert simple_setup.f(3) == 9
94
- """
95
- ),
96
- encoding="ascii",
97
- )
98
-
99
- subprocess.check_call(
100
- [sys.executable, "test.py"], stdout=sys.stdout, stderr=sys.stderr
101
- )
102
-
103
-
104
- def test_intree_extensions(monkeypatch, tmpdir):
105
- monkeypatch.syspath_prepend(MAIN_DIR)
106
-
107
- from pybind11.setup_helpers import intree_extensions
108
-
109
- monkeypatch.chdir(tmpdir)
110
- root = tmpdir
111
- root.ensure_dir()
112
- subdir = root / "dir"
113
- subdir.ensure_dir()
114
- src = subdir / "ext.cpp"
115
- src.ensure()
116
- (ext,) = intree_extensions([src.relto(tmpdir)])
117
- assert ext.name == "ext"
118
- subdir.ensure("__init__.py")
119
- (ext,) = intree_extensions([src.relto(tmpdir)])
120
- assert ext.name == "dir.ext"
121
-
122
-
123
- def test_intree_extensions_package_dir(monkeypatch, tmpdir):
124
- monkeypatch.syspath_prepend(MAIN_DIR)
125
-
126
- from pybind11.setup_helpers import intree_extensions
127
-
128
- monkeypatch.chdir(tmpdir)
129
- root = tmpdir / "src"
130
- root.ensure_dir()
131
- subdir = root / "dir"
132
- subdir.ensure_dir()
133
- src = subdir / "ext.cpp"
134
- src.ensure()
135
- (ext,) = intree_extensions([src.relto(tmpdir)], package_dir={"": "src"})
136
- assert ext.name == "dir.ext"
137
- (ext,) = intree_extensions([src.relto(tmpdir)], package_dir={"foo": "src"})
138
- assert ext.name == "foo.dir.ext"
139
- subdir.ensure("__init__.py")
140
- (ext,) = intree_extensions([src.relto(tmpdir)], package_dir={"": "src"})
141
- assert ext.name == "dir.ext"
142
- (ext,) = intree_extensions([src.relto(tmpdir)], package_dir={"foo": "src"})
143
- assert ext.name == "foo.dir.ext"
@@ -1,85 +0,0 @@
1
- #pragma once
2
- #include <utility>
3
-
4
- #include "pybind11_tests.h"
5
-
6
- /// Simple class used to test py::local:
7
- template <int> class LocalBase {
8
- public:
9
- explicit LocalBase(int i) : i(i) { }
10
- int i = -1;
11
- };
12
-
13
- /// Registered with py::module_local in both main and secondary modules:
14
- using LocalType = LocalBase<0>;
15
- /// Registered without py::module_local in both modules:
16
- using NonLocalType = LocalBase<1>;
17
- /// A second non-local type (for stl_bind tests):
18
- using NonLocal2 = LocalBase<2>;
19
- /// Tests within-module, different-compilation-unit local definition conflict:
20
- using LocalExternal = LocalBase<3>;
21
- /// Mixed: registered local first, then global
22
- using MixedLocalGlobal = LocalBase<4>;
23
- /// Mixed: global first, then local
24
- using MixedGlobalLocal = LocalBase<5>;
25
-
26
- /// Registered with py::module_local only in the secondary module:
27
- using ExternalType1 = LocalBase<6>;
28
- using ExternalType2 = LocalBase<7>;
29
-
30
- using LocalVec = std::vector<LocalType>;
31
- using LocalVec2 = std::vector<NonLocal2>;
32
- using LocalMap = std::unordered_map<std::string, LocalType>;
33
- using NonLocalVec = std::vector<NonLocalType>;
34
- using NonLocalVec2 = std::vector<NonLocal2>;
35
- using NonLocalMap = std::unordered_map<std::string, NonLocalType>;
36
- using NonLocalMap2 = std::unordered_map<std::string, uint8_t>;
37
-
38
-
39
- // Exception that will be caught via the module local translator.
40
- class LocalException : public std::exception {
41
- public:
42
- explicit LocalException(const char * m) : message{m} {}
43
- const char * what() const noexcept override {return message.c_str();}
44
- private:
45
- std::string message = "";
46
- };
47
-
48
- // Exception that will be registered with register_local_exception_translator
49
- class LocalSimpleException : public std::exception {
50
- public:
51
- explicit LocalSimpleException(const char * m) : message{m} {}
52
- const char * what() const noexcept override {return message.c_str();}
53
- private:
54
- std::string message = "";
55
- };
56
-
57
- PYBIND11_MAKE_OPAQUE(LocalVec);
58
- PYBIND11_MAKE_OPAQUE(LocalVec2);
59
- PYBIND11_MAKE_OPAQUE(LocalMap);
60
- PYBIND11_MAKE_OPAQUE(NonLocalVec);
61
- //PYBIND11_MAKE_OPAQUE(NonLocalVec2); // same type as LocalVec2
62
- PYBIND11_MAKE_OPAQUE(NonLocalMap);
63
- PYBIND11_MAKE_OPAQUE(NonLocalMap2);
64
-
65
-
66
- // Simple bindings (used with the above):
67
- template <typename T, int Adjust = 0, typename... Args>
68
- py::class_<T> bind_local(Args && ...args) {
69
- return py::class_<T>(std::forward<Args>(args)...)
70
- .def(py::init<int>())
71
- .def("get", [](T &i) { return i.i + Adjust; });
72
- };
73
-
74
- // Simulate a foreign library base class (to match the example in the docs):
75
- namespace pets {
76
- class Pet {
77
- public:
78
- explicit Pet(std::string name) : name_(std::move(name)) {}
79
- std::string name_;
80
- const std::string &name() const { return name_; }
81
- };
82
- } // namespace pets
83
-
84
- struct MixGL { int i; explicit MixGL(int i) : i{i} {} };
85
- struct MixGL2 { int i; explicit MixGL2(int i) : i{i} {} };
@@ -1,179 +0,0 @@
1
- #if !defined(__OBJECT_H)
2
- #define __OBJECT_H
3
-
4
- #include <atomic>
5
- #include "constructor_stats.h"
6
-
7
- /// Reference counted object base class
8
- class Object {
9
- public:
10
- /// Default constructor
11
- Object() { print_default_created(this); }
12
-
13
- /// Copy constructor
14
- Object(const Object &) : m_refCount(0) { print_copy_created(this); }
15
-
16
- /// Return the current reference count
17
- int getRefCount() const { return m_refCount; };
18
-
19
- /// Increase the object's reference count by one
20
- void incRef() const { ++m_refCount; }
21
-
22
- /** \brief Decrease the reference count of
23
- * the object and possibly deallocate it.
24
- *
25
- * The object will automatically be deallocated once
26
- * the reference count reaches zero.
27
- */
28
- void decRef(bool dealloc = true) const {
29
- --m_refCount;
30
- if (m_refCount == 0 && dealloc)
31
- delete this;
32
- else if (m_refCount < 0)
33
- throw std::runtime_error("Internal error: reference count < 0!");
34
- }
35
-
36
- virtual std::string toString() const = 0;
37
- protected:
38
- /** \brief Virtual protected deconstructor.
39
- * (Will only be called by \ref ref)
40
- */
41
- virtual ~Object() { print_destroyed(this); }
42
- private:
43
- mutable std::atomic<int> m_refCount { 0 };
44
- };
45
-
46
- // Tag class used to track constructions of ref objects. When we track constructors, below, we
47
- // track and print out the actual class (e.g. ref<MyObject>), and *also* add a fake tracker for
48
- // ref_tag. This lets us check that the total number of ref<Anything> constructors/destructors is
49
- // correct without having to check each individual ref<Whatever> type individually.
50
- class ref_tag {};
51
-
52
- /**
53
- * \brief Reference counting helper
54
- *
55
- * The \a ref refeference template is a simple wrapper to store a
56
- * pointer to an object. It takes care of increasing and decreasing
57
- * the reference count of the object. When the last reference goes
58
- * out of scope, the associated object will be deallocated.
59
- *
60
- * \ingroup libcore
61
- */
62
- template <typename T> class ref {
63
- public:
64
- /// Create a nullptr reference
65
- ref() : m_ptr(nullptr) { print_default_created(this); track_default_created((ref_tag*) this); }
66
-
67
- /// Construct a reference from a pointer
68
- explicit ref(T *ptr) : m_ptr(ptr) {
69
- if (m_ptr) ((Object *) m_ptr)->incRef();
70
-
71
- print_created(this, "from pointer", m_ptr); track_created((ref_tag*) this, "from pointer");
72
-
73
- }
74
-
75
- /// Copy constructor
76
- ref(const ref &r) : m_ptr(r.m_ptr) {
77
- if (m_ptr)
78
- ((Object *) m_ptr)->incRef();
79
-
80
- print_copy_created(this, "with pointer", m_ptr); track_copy_created((ref_tag*) this);
81
- }
82
-
83
- /// Move constructor
84
- ref(ref &&r) noexcept : m_ptr(r.m_ptr) {
85
- r.m_ptr = nullptr;
86
-
87
- print_move_created(this, "with pointer", m_ptr); track_move_created((ref_tag*) this);
88
- }
89
-
90
- /// Destroy this reference
91
- ~ref() {
92
- if (m_ptr)
93
- ((Object *) m_ptr)->decRef();
94
-
95
- print_destroyed(this); track_destroyed((ref_tag*) this);
96
- }
97
-
98
- /// Move another reference into the current one
99
- ref &operator=(ref &&r) noexcept {
100
- print_move_assigned(this, "pointer", r.m_ptr); track_move_assigned((ref_tag*) this);
101
-
102
- if (*this == r)
103
- return *this;
104
- if (m_ptr)
105
- ((Object *) m_ptr)->decRef();
106
- m_ptr = r.m_ptr;
107
- r.m_ptr = nullptr;
108
- return *this;
109
- }
110
-
111
- /// Overwrite this reference with another reference
112
- ref& operator=(const ref& r) {
113
- if (this == &r) {
114
- return *this;
115
- }
116
- print_copy_assigned(this, "pointer", r.m_ptr);
117
- track_copy_assigned((ref_tag *) this);
118
-
119
- if (m_ptr == r.m_ptr)
120
- return *this;
121
- if (m_ptr)
122
- ((Object *) m_ptr)->decRef();
123
- m_ptr = r.m_ptr;
124
- if (m_ptr)
125
- ((Object *) m_ptr)->incRef();
126
- return *this;
127
- }
128
-
129
- /// Overwrite this reference with a pointer to another object
130
- ref& operator=(T *ptr) {
131
- print_values(this, "assigned pointer"); track_values((ref_tag*) this, "assigned pointer");
132
-
133
- if (m_ptr == ptr)
134
- return *this;
135
- if (m_ptr)
136
- ((Object *) m_ptr)->decRef();
137
- m_ptr = ptr;
138
- if (m_ptr)
139
- ((Object *) m_ptr)->incRef();
140
- return *this;
141
- }
142
-
143
- /// Compare this reference with another reference
144
- bool operator==(const ref &r) const { return m_ptr == r.m_ptr; }
145
-
146
- /// Compare this reference with another reference
147
- bool operator!=(const ref &r) const { return m_ptr != r.m_ptr; }
148
-
149
- /// Compare this reference with a pointer
150
- bool operator==(const T* ptr) const { return m_ptr == ptr; }
151
-
152
- /// Compare this reference with a pointer
153
- bool operator!=(const T* ptr) const { return m_ptr != ptr; }
154
-
155
- /// Access the object referenced by this reference
156
- T* operator->() { return m_ptr; }
157
-
158
- /// Access the object referenced by this reference
159
- const T* operator->() const { return m_ptr; }
160
-
161
- /// Return a C++ reference to the referenced object
162
- T& operator*() { return *m_ptr; }
163
-
164
- /// Return a const C++ reference to the referenced object
165
- const T& operator*() const { return *m_ptr; }
166
-
167
- /// Return a pointer to the referenced object
168
- explicit operator T* () { return m_ptr; }
169
-
170
- /// Return a const pointer to the referenced object
171
- T* get_ptr() { return m_ptr; }
172
-
173
- /// Return a pointer to the referenced object
174
- const T* get_ptr() const { return m_ptr; }
175
- private:
176
- T *m_ptr;
177
- };
178
-
179
- #endif /* __OBJECT_H */
@@ -1,151 +0,0 @@
1
- /*
2
- tests/pybind11_cross_module_tests.cpp -- contains tests that require multiple modules
3
-
4
- Copyright (c) 2017 Jason Rhinelander <jason@imaginary.ca>
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 "local_bindings.h"
12
- #include "test_exceptions.h"
13
-
14
- #include <pybind11/stl_bind.h>
15
-
16
- #include <numeric>
17
- #include <utility>
18
-
19
- PYBIND11_MODULE(pybind11_cross_module_tests, m) {
20
- m.doc() = "pybind11 cross-module test module";
21
-
22
- // test_local_bindings.py tests:
23
- //
24
- // Definitions here are tested by importing both this module and the
25
- // relevant pybind11_tests submodule from a test_whatever.py
26
-
27
- // test_load_external
28
- bind_local<ExternalType1>(m, "ExternalType1", py::module_local());
29
- bind_local<ExternalType2>(m, "ExternalType2", py::module_local());
30
-
31
- // test_exceptions.py
32
- py::register_local_exception<LocalSimpleException>(m, "LocalSimpleException");
33
- m.def("raise_runtime_error", []() { PyErr_SetString(PyExc_RuntimeError, "My runtime error"); throw py::error_already_set(); });
34
- m.def("raise_value_error", []() { PyErr_SetString(PyExc_ValueError, "My value error"); throw py::error_already_set(); });
35
- m.def("throw_pybind_value_error", []() { throw py::value_error("pybind11 value error"); });
36
- m.def("throw_pybind_type_error", []() { throw py::type_error("pybind11 type error"); });
37
- m.def("throw_stop_iteration", []() { throw py::stop_iteration(); });
38
- m.def("throw_local_error", []() { throw LocalException("just local"); });
39
- m.def("throw_local_simple_error", []() { throw LocalSimpleException("external mod"); });
40
- py::register_exception_translator([](std::exception_ptr p) {
41
- try {
42
- if (p) std::rethrow_exception(p);
43
- } catch (const shared_exception &e) {
44
- PyErr_SetString(PyExc_KeyError, e.what());
45
- }
46
- });
47
-
48
- // translate the local exception into a key error but only in this module
49
- py::register_local_exception_translator([](std::exception_ptr p) {
50
- try {
51
- if (p) {
52
- std::rethrow_exception(p);
53
- }
54
- } catch (const LocalException &e) {
55
- PyErr_SetString(PyExc_KeyError, e.what());
56
- }
57
- });
58
-
59
- // test_local_bindings.py
60
- // Local to both:
61
- bind_local<LocalType, 1>(m, "LocalType", py::module_local())
62
- .def("get2", [](LocalType &t) { return t.i + 2; })
63
- ;
64
-
65
- // Can only be called with our python type:
66
- m.def("local_value", [](LocalType &l) { return l.i; });
67
-
68
- // test_nonlocal_failure
69
- // This registration will fail (global registration when LocalFail is already registered
70
- // globally in the main test module):
71
- m.def("register_nonlocal", [m]() {
72
- bind_local<NonLocalType, 0>(m, "NonLocalType");
73
- });
74
-
75
- // test_stl_bind_local
76
- // stl_bind.h binders defaults to py::module_local if the types are local or converting:
77
- py::bind_vector<LocalVec>(m, "LocalVec");
78
- py::bind_map<LocalMap>(m, "LocalMap");
79
-
80
- // test_stl_bind_global
81
- // and global if the type (or one of the types, for the map) is global (so these will fail,
82
- // assuming pybind11_tests is already loaded):
83
- m.def("register_nonlocal_vec", [m]() {
84
- py::bind_vector<NonLocalVec>(m, "NonLocalVec");
85
- });
86
- m.def("register_nonlocal_map", [m]() {
87
- py::bind_map<NonLocalMap>(m, "NonLocalMap");
88
- });
89
- // The default can, however, be overridden to global using `py::module_local()` or
90
- // `py::module_local(false)`.
91
- // Explicitly made local:
92
- py::bind_vector<NonLocalVec2>(m, "NonLocalVec2", py::module_local());
93
- // Explicitly made global (and so will fail to bind):
94
- m.def("register_nonlocal_map2", [m]() {
95
- py::bind_map<NonLocalMap2>(m, "NonLocalMap2", py::module_local(false));
96
- });
97
-
98
- // test_mixed_local_global
99
- // We try this both with the global type registered first and vice versa (the order shouldn't
100
- // matter).
101
- m.def("register_mixed_global_local", [m]() {
102
- bind_local<MixedGlobalLocal, 200>(m, "MixedGlobalLocal", py::module_local());
103
- });
104
- m.def("register_mixed_local_global", [m]() {
105
- bind_local<MixedLocalGlobal, 2000>(m, "MixedLocalGlobal", py::module_local(false));
106
- });
107
- m.def("get_mixed_gl", [](int i) { return MixedGlobalLocal(i); });
108
- m.def("get_mixed_lg", [](int i) { return MixedLocalGlobal(i); });
109
-
110
- // test_internal_locals_differ
111
- m.def("local_cpp_types_addr", []() { return (uintptr_t) &py::detail::get_local_internals().registered_types_cpp; });
112
-
113
- // test_stl_caster_vs_stl_bind
114
- py::bind_vector<std::vector<int>>(m, "VectorInt");
115
-
116
- m.def("load_vector_via_binding", [](std::vector<int> &v) {
117
- return std::accumulate(v.begin(), v.end(), 0);
118
- });
119
-
120
- // test_cross_module_calls
121
- m.def("return_self", [](LocalVec *v) { return v; });
122
- m.def("return_copy", [](const LocalVec &v) { return LocalVec(v); });
123
-
124
- class Dog : public pets::Pet {
125
- public:
126
- explicit Dog(std::string name) : Pet(std::move(name)) {}
127
- };
128
- py::class_<pets::Pet>(m, "Pet", py::module_local())
129
- .def("name", &pets::Pet::name);
130
- // Binding for local extending class:
131
- py::class_<Dog, pets::Pet>(m, "Dog")
132
- .def(py::init<std::string>());
133
- m.def("pet_name", [](pets::Pet &p) { return p.name(); });
134
-
135
- py::class_<MixGL>(m, "MixGL", py::module_local()).def(py::init<int>());
136
- m.def("get_gl_value", [](MixGL &o) { return o.i + 100; });
137
-
138
- py::class_<MixGL2>(m, "MixGL2", py::module_local()).def(py::init<int>());
139
-
140
- // test_vector_bool
141
- // We can't test both stl.h and stl_bind.h conversions of `std::vector<bool>` within
142
- // the same module (it would be an ODR violation). Therefore `bind_vector` of `bool`
143
- // is defined here and tested in `test_stl_binders.py`.
144
- py::bind_vector<std::vector<bool>>(m, "VectorBool");
145
-
146
- // test_missing_header_message
147
- // The main module already includes stl.h, but we need to test the error message
148
- // which appears when this header is missing.
149
- m.def("missing_header_arg", [](const std::vector<float> &) {});
150
- m.def("missing_header_return", []() { return std::vector<float>(); });
151
- }
@@ -1,91 +0,0 @@
1
- /*
2
- tests/pybind11_tests.cpp -- pybind example plugin
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include "constructor_stats.h"
12
-
13
- #include <functional>
14
- #include <list>
15
-
16
- /*
17
- For testing purposes, we define a static global variable here in a function that each individual
18
- test .cpp calls with its initialization lambda. It's convenient here because we can just not
19
- compile some test files to disable/ignore some of the test code.
20
-
21
- It is NOT recommended as a way to use pybind11 in practice, however: the initialization order will
22
- be essentially random, which is okay for our test scripts (there are no dependencies between the
23
- individual pybind11 test .cpp files), but most likely not what you want when using pybind11
24
- productively.
25
-
26
- Instead, see the "How can I reduce the build time?" question in the "Frequently asked questions"
27
- section of the documentation for good practice on splitting binding code over multiple files.
28
- */
29
- std::list<std::function<void(py::module_ &)>> &initializers() {
30
- static std::list<std::function<void(py::module_ &)>> inits;
31
- return inits;
32
- }
33
-
34
- test_initializer::test_initializer(Initializer init) {
35
- initializers().emplace_back(init);
36
- }
37
-
38
- test_initializer::test_initializer(const char *submodule_name, Initializer init) {
39
- initializers().emplace_back([=](py::module_ &parent) {
40
- auto m = parent.def_submodule(submodule_name);
41
- init(m);
42
- });
43
- }
44
-
45
- void bind_ConstructorStats(py::module_ &m) {
46
- py::class_<ConstructorStats>(m, "ConstructorStats")
47
- .def("alive", &ConstructorStats::alive)
48
- .def("values", &ConstructorStats::values)
49
- .def_readwrite("default_constructions", &ConstructorStats::default_constructions)
50
- .def_readwrite("copy_assignments", &ConstructorStats::copy_assignments)
51
- .def_readwrite("move_assignments", &ConstructorStats::move_assignments)
52
- .def_readwrite("copy_constructions", &ConstructorStats::copy_constructions)
53
- .def_readwrite("move_constructions", &ConstructorStats::move_constructions)
54
- .def_static("get", (ConstructorStats &(*)(py::object)) &ConstructorStats::get, py::return_value_policy::reference_internal)
55
-
56
- // Not exactly ConstructorStats, but related: expose the internal pybind number of registered instances
57
- // to allow instance cleanup checks (invokes a GC first)
58
- .def_static("detail_reg_inst", []() {
59
- ConstructorStats::gc();
60
- return py::detail::get_internals().registered_instances.size();
61
- })
62
- ;
63
- }
64
-
65
- PYBIND11_MODULE(pybind11_tests, m) {
66
- m.doc() = "pybind11 test module";
67
-
68
- bind_ConstructorStats(m);
69
-
70
- #if !defined(NDEBUG)
71
- m.attr("debug_enabled") = true;
72
- #else
73
- m.attr("debug_enabled") = false;
74
- #endif
75
-
76
- py::class_<UserType>(m, "UserType", "A `py::class_` type for testing")
77
- .def(py::init<>())
78
- .def(py::init<int>())
79
- .def("get_value", &UserType::value, "Get value using a method")
80
- .def("set_value", &UserType::set, "Set value using a method")
81
- .def_property("value", &UserType::value, &UserType::set, "Get/set value using a property")
82
- .def("__repr__", [](const UserType& u) { return "UserType({})"_s.format(u.value()); });
83
-
84
- py::class_<IncType, UserType>(m, "IncType")
85
- .def(py::init<>())
86
- .def(py::init<int>())
87
- .def("__repr__", [](const IncType& u) { return "IncType({})"_s.format(u.value()); });
88
-
89
- for (const auto &initializer : initializers())
90
- initializer(m);
91
- }