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

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

Potentially problematic release.


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

Files changed (333) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/beam_elements/__init__.py +1 -0
  3. xcoll/beam_elements/absorber.py +12 -2
  4. xcoll/beam_elements/base.py +162 -62
  5. xcoll/beam_elements/blowup.py +1 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  7. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  8. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  9. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  10. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  11. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  12. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  13. xcoll/beam_elements/everest.py +16 -5
  14. xcoll/beam_elements/monitor.py +1 -0
  15. xcoll/beam_elements/transparent.py +83 -0
  16. xcoll/colldb.py +15 -6
  17. xcoll/general.py +1 -1
  18. xcoll/headers/particle_states.py +51 -0
  19. xcoll/initial_distribution.py +129 -103
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -74
  23. xcoll/lossmap.py +519 -127
  24. xcoll/plot.py +109 -0
  25. xcoll/rf_sweep.py +6 -0
  26. xcoll/scattering_routines/engine.py +600 -0
  27. xcoll/scattering_routines/environment.py +297 -0
  28. xcoll/scattering_routines/everest/amorphous.h +95 -71
  29. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  30. xcoll/scattering_routines/everest/constants.h +1 -1
  31. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  32. xcoll/scattering_routines/everest/everest.h +8 -3
  33. xcoll/scattering_routines/everest/everest.py +2 -1
  34. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  35. xcoll/scattering_routines/everest/jaw.h +19 -24
  36. xcoll/scattering_routines/everest/materials.py +2 -0
  37. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  38. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  39. xcoll/scattering_routines/everest/properties.h +4 -73
  40. xcoll/xaux.py +73 -0
  41. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
  42. xcoll-0.6.0.dist-info/RECORD +135 -0
  43. xcoll/_manager.py +0 -22
  44. xcoll/headers/particle_states.h +0 -25
  45. xcoll/install.py +0 -35
  46. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  47. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  48. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  49. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  50. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  51. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  52. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  53. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  54. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  55. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  289. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  290. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  304. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  330. xcoll-0.5.11.dist-info/RECORD +0 -413
  331. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,550 +0,0 @@
1
- /*
2
- tests/test_class.cpp -- test py::class_ definitions and basic functionality
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
- #if defined(__INTEL_COMPILER) && __cplusplus >= 201703L
11
- // Intel compiler requires a separate header file to support aligned new operators
12
- // and does not set the __cpp_aligned_new feature macro.
13
- // This header needs to be included before pybind11.
14
- #include <aligned_new>
15
- #endif
16
-
17
- #include "pybind11_tests.h"
18
- #include "constructor_stats.h"
19
- #include "local_bindings.h"
20
- #include <pybind11/stl.h>
21
-
22
- #include <utility>
23
-
24
- #if defined(_MSC_VER)
25
- # pragma warning(disable: 4324) // warning C4324: structure was padded due to alignment specifier
26
- #endif
27
-
28
- // test_brace_initialization
29
- struct NoBraceInitialization {
30
- explicit NoBraceInitialization(std::vector<int> v) : vec{std::move(v)} {}
31
- template <typename T>
32
- NoBraceInitialization(std::initializer_list<T> l) : vec(l) {}
33
-
34
- std::vector<int> vec;
35
- };
36
-
37
- TEST_SUBMODULE(class_, m) {
38
- // test_instance
39
- struct NoConstructor {
40
- NoConstructor() = default;
41
- NoConstructor(const NoConstructor &) = default;
42
- NoConstructor(NoConstructor &&) = default;
43
- static NoConstructor *new_instance() {
44
- auto *ptr = new NoConstructor();
45
- print_created(ptr, "via new_instance");
46
- return ptr;
47
- }
48
- ~NoConstructor() { print_destroyed(this); }
49
- };
50
- struct NoConstructorNew {
51
- NoConstructorNew() = default;
52
- NoConstructorNew(const NoConstructorNew &) = default;
53
- NoConstructorNew(NoConstructorNew &&) = default;
54
- static NoConstructorNew *new_instance() {
55
- auto *ptr = new NoConstructorNew();
56
- print_created(ptr, "via new_instance");
57
- return ptr;
58
- }
59
- ~NoConstructorNew() { print_destroyed(this); }
60
- };
61
-
62
- py::class_<NoConstructor>(m, "NoConstructor")
63
- .def_static("new_instance", &NoConstructor::new_instance, "Return an instance");
64
-
65
- py::class_<NoConstructorNew>(m, "NoConstructorNew")
66
- .def(py::init([](const NoConstructorNew &self) { return self; })) // Need a NOOP __init__
67
- .def_static("__new__",
68
- [](const py::object &) { return NoConstructorNew::new_instance(); });
69
-
70
- // test_inheritance
71
- class Pet {
72
- public:
73
- Pet(const std::string &name, const std::string &species)
74
- : m_name(name), m_species(species) {}
75
- std::string name() const { return m_name; }
76
- std::string species() const { return m_species; }
77
- private:
78
- std::string m_name;
79
- std::string m_species;
80
- };
81
-
82
- class Dog : public Pet {
83
- public:
84
- explicit Dog(const std::string &name) : Pet(name, "dog") {}
85
- std::string bark() const { return "Woof!"; }
86
- };
87
-
88
- class Rabbit : public Pet {
89
- public:
90
- explicit Rabbit(const std::string &name) : Pet(name, "parrot") {}
91
- };
92
-
93
- class Hamster : public Pet {
94
- public:
95
- explicit Hamster(const std::string &name) : Pet(name, "rodent") {}
96
- };
97
-
98
- class Chimera : public Pet {
99
- Chimera() : Pet("Kimmy", "chimera") {}
100
- };
101
-
102
- py::class_<Pet> pet_class(m, "Pet");
103
- pet_class
104
- .def(py::init<std::string, std::string>())
105
- .def("name", &Pet::name)
106
- .def("species", &Pet::species);
107
-
108
- /* One way of declaring a subclass relationship: reference parent's class_ object */
109
- py::class_<Dog>(m, "Dog", pet_class)
110
- .def(py::init<std::string>());
111
-
112
- /* Another way of declaring a subclass relationship: reference parent's C++ type */
113
- py::class_<Rabbit, Pet>(m, "Rabbit")
114
- .def(py::init<std::string>());
115
-
116
- /* And another: list parent in class template arguments */
117
- py::class_<Hamster, Pet>(m, "Hamster")
118
- .def(py::init<std::string>());
119
-
120
- /* Constructors are not inherited by default */
121
- py::class_<Chimera, Pet>(m, "Chimera");
122
-
123
- m.def("pet_name_species", [](const Pet &pet) { return pet.name() + " is a " + pet.species(); });
124
- m.def("dog_bark", [](const Dog &dog) { return dog.bark(); });
125
-
126
- // test_automatic_upcasting
127
- struct BaseClass {
128
- BaseClass() = default;
129
- BaseClass(const BaseClass &) = default;
130
- BaseClass(BaseClass &&) = default;
131
- virtual ~BaseClass() = default;
132
- };
133
- struct DerivedClass1 : BaseClass { };
134
- struct DerivedClass2 : BaseClass { };
135
-
136
- py::class_<BaseClass>(m, "BaseClass").def(py::init<>());
137
- py::class_<DerivedClass1>(m, "DerivedClass1").def(py::init<>());
138
- py::class_<DerivedClass2>(m, "DerivedClass2").def(py::init<>());
139
-
140
- m.def("return_class_1", []() -> BaseClass* { return new DerivedClass1(); });
141
- m.def("return_class_2", []() -> BaseClass* { return new DerivedClass2(); });
142
- m.def("return_class_n", [](int n) -> BaseClass* {
143
- if (n == 1) return new DerivedClass1();
144
- if (n == 2) return new DerivedClass2();
145
- return new BaseClass();
146
- });
147
- m.def("return_none", []() -> BaseClass* { return nullptr; });
148
-
149
- // test_isinstance
150
- m.def("check_instances", [](const py::list &l) {
151
- return py::make_tuple(
152
- py::isinstance<py::tuple>(l[0]),
153
- py::isinstance<py::dict>(l[1]),
154
- py::isinstance<Pet>(l[2]),
155
- py::isinstance<Pet>(l[3]),
156
- py::isinstance<Dog>(l[4]),
157
- py::isinstance<Rabbit>(l[5]),
158
- py::isinstance<UnregisteredType>(l[6])
159
- );
160
- });
161
-
162
- struct Invalid {};
163
-
164
- // test_type
165
- m.def("check_type", [](int category) {
166
- // Currently not supported (via a fail at compile time)
167
- // See https://github.com/pybind/pybind11/issues/2486
168
- // if (category == 2)
169
- // return py::type::of<int>();
170
- if (category == 1)
171
- return py::type::of<DerivedClass1>();
172
- return py::type::of<Invalid>();
173
- });
174
-
175
- m.def("get_type_of", [](py::object ob) { return py::type::of(std::move(ob)); });
176
-
177
- m.def("get_type_classic", [](py::handle h) {
178
- return h.get_type();
179
- });
180
-
181
- m.def("as_type", [](const py::object &ob) { return py::type(ob); });
182
-
183
- // test_mismatched_holder
184
- struct MismatchBase1 { };
185
- struct MismatchDerived1 : MismatchBase1 { };
186
-
187
- struct MismatchBase2 { };
188
- struct MismatchDerived2 : MismatchBase2 { };
189
-
190
- m.def("mismatched_holder_1", []() {
191
- auto mod = py::module_::import("__main__");
192
- py::class_<MismatchBase1, std::shared_ptr<MismatchBase1>>(mod, "MismatchBase1");
193
- py::class_<MismatchDerived1, MismatchBase1>(mod, "MismatchDerived1");
194
- });
195
- m.def("mismatched_holder_2", []() {
196
- auto mod = py::module_::import("__main__");
197
- py::class_<MismatchBase2>(mod, "MismatchBase2");
198
- py::class_<MismatchDerived2, std::shared_ptr<MismatchDerived2>,
199
- MismatchBase2>(mod, "MismatchDerived2");
200
- });
201
-
202
- // test_override_static
203
- // #511: problem with inheritance + overwritten def_static
204
- struct MyBase {
205
- static std::unique_ptr<MyBase> make() {
206
- return std::unique_ptr<MyBase>(new MyBase());
207
- }
208
- };
209
-
210
- struct MyDerived : MyBase {
211
- static std::unique_ptr<MyDerived> make() {
212
- return std::unique_ptr<MyDerived>(new MyDerived());
213
- }
214
- };
215
-
216
- py::class_<MyBase>(m, "MyBase")
217
- .def_static("make", &MyBase::make);
218
-
219
- py::class_<MyDerived, MyBase>(m, "MyDerived")
220
- .def_static("make", &MyDerived::make)
221
- .def_static("make2", &MyDerived::make);
222
-
223
- // test_implicit_conversion_life_support
224
- struct ConvertibleFromUserType {
225
- int i;
226
-
227
- explicit ConvertibleFromUserType(UserType u) : i(u.value()) {}
228
- };
229
-
230
- py::class_<ConvertibleFromUserType>(m, "AcceptsUserType")
231
- .def(py::init<UserType>());
232
- py::implicitly_convertible<UserType, ConvertibleFromUserType>();
233
-
234
- m.def("implicitly_convert_argument", [](const ConvertibleFromUserType &r) { return r.i; });
235
- m.def("implicitly_convert_variable", [](const py::object &o) {
236
- // `o` is `UserType` and `r` is a reference to a temporary created by implicit
237
- // conversion. This is valid when called inside a bound function because the temp
238
- // object is attached to the same life support system as the arguments.
239
- const auto &r = o.cast<const ConvertibleFromUserType &>();
240
- return r.i;
241
- });
242
- m.add_object("implicitly_convert_variable_fail", [&] {
243
- auto f = [](PyObject *, PyObject *args) -> PyObject * {
244
- auto o = py::reinterpret_borrow<py::tuple>(args)[0];
245
- try { // It should fail here because there is no life support.
246
- o.cast<const ConvertibleFromUserType &>();
247
- } catch (const py::cast_error &e) {
248
- return py::str(e.what()).release().ptr();
249
- }
250
- return py::str().release().ptr();
251
- };
252
-
253
- auto def = new PyMethodDef{"f", f, METH_VARARGS, nullptr};
254
- py::capsule def_capsule(def, [](void *ptr) { delete reinterpret_cast<PyMethodDef *>(ptr); });
255
- return py::reinterpret_steal<py::object>(PyCFunction_NewEx(def, def_capsule.ptr(), m.ptr()));
256
- }());
257
-
258
- // test_operator_new_delete
259
- struct HasOpNewDel {
260
- std::uint64_t i;
261
- static void *operator new(size_t s) { py::print("A new", s); return ::operator new(s); }
262
- static void *operator new(size_t s, void *ptr) { py::print("A placement-new", s); return ptr; }
263
- static void operator delete(void *p) { py::print("A delete"); return ::operator delete(p); }
264
- };
265
- struct HasOpNewDelSize {
266
- std::uint32_t i;
267
- static void *operator new(size_t s) { py::print("B new", s); return ::operator new(s); }
268
- static void *operator new(size_t s, void *ptr) { py::print("B placement-new", s); return ptr; }
269
- static void operator delete(void *p, size_t s) { py::print("B delete", s); return ::operator delete(p); }
270
- };
271
- struct AliasedHasOpNewDelSize {
272
- std::uint64_t i;
273
- static void *operator new(size_t s) { py::print("C new", s); return ::operator new(s); }
274
- static void *operator new(size_t s, void *ptr) { py::print("C placement-new", s); return ptr; }
275
- static void operator delete(void *p, size_t s) { py::print("C delete", s); return ::operator delete(p); }
276
- virtual ~AliasedHasOpNewDelSize() = default;
277
- AliasedHasOpNewDelSize() = default;
278
- AliasedHasOpNewDelSize(const AliasedHasOpNewDelSize&) = delete;
279
- };
280
- struct PyAliasedHasOpNewDelSize : AliasedHasOpNewDelSize {
281
- PyAliasedHasOpNewDelSize() = default;
282
- explicit PyAliasedHasOpNewDelSize(int) {}
283
- std::uint64_t j;
284
- };
285
- struct HasOpNewDelBoth {
286
- std::uint32_t i[8];
287
- static void *operator new(size_t s) { py::print("D new", s); return ::operator new(s); }
288
- static void *operator new(size_t s, void *ptr) { py::print("D placement-new", s); return ptr; }
289
- static void operator delete(void *p) { py::print("D delete"); return ::operator delete(p); }
290
- static void operator delete(void *p, size_t s) { py::print("D wrong delete", s); return ::operator delete(p); }
291
- };
292
- py::class_<HasOpNewDel>(m, "HasOpNewDel").def(py::init<>());
293
- py::class_<HasOpNewDelSize>(m, "HasOpNewDelSize").def(py::init<>());
294
- py::class_<HasOpNewDelBoth>(m, "HasOpNewDelBoth").def(py::init<>());
295
- py::class_<AliasedHasOpNewDelSize, PyAliasedHasOpNewDelSize> aliased(m, "AliasedHasOpNewDelSize");
296
- aliased.def(py::init<>());
297
- aliased.attr("size_noalias") = py::int_(sizeof(AliasedHasOpNewDelSize));
298
- aliased.attr("size_alias") = py::int_(sizeof(PyAliasedHasOpNewDelSize));
299
-
300
- // This test is actually part of test_local_bindings (test_duplicate_local), but we need a
301
- // definition in a different compilation unit within the same module:
302
- bind_local<LocalExternal, 17>(m, "LocalExternal", py::module_local());
303
-
304
- // test_bind_protected_functions
305
- class ProtectedA {
306
- protected:
307
- int foo() const { return value; }
308
-
309
- private:
310
- int value = 42;
311
- };
312
-
313
- class PublicistA : public ProtectedA {
314
- public:
315
- using ProtectedA::foo;
316
- };
317
-
318
- py::class_<ProtectedA>(m, "ProtectedA")
319
- .def(py::init<>())
320
- #if !defined(_MSC_VER) || _MSC_VER >= 1910
321
- .def("foo", &PublicistA::foo);
322
- #else
323
- .def("foo", static_cast<int (ProtectedA::*)() const>(&PublicistA::foo));
324
- #endif
325
-
326
- class ProtectedB {
327
- public:
328
- virtual ~ProtectedB() = default;
329
- ProtectedB() = default;
330
- ProtectedB(const ProtectedB &) = delete;
331
-
332
- protected:
333
- virtual int foo() const { return value; }
334
-
335
- private:
336
- int value = 42;
337
- };
338
-
339
- class TrampolineB : public ProtectedB {
340
- public:
341
- int foo() const override { PYBIND11_OVERRIDE(int, ProtectedB, foo, ); }
342
- };
343
-
344
- class PublicistB : public ProtectedB {
345
- public:
346
- // [workaround(intel)] = default does not work here
347
- // Removing or defaulting this destructor results in linking errors with the Intel compiler
348
- // (in Debug builds only, tested with icpc (ICC) 2021.1 Beta 20200827)
349
- ~PublicistB() override {}; // NOLINT(modernize-use-equals-default)
350
- using ProtectedB::foo;
351
- };
352
-
353
- py::class_<ProtectedB, TrampolineB>(m, "ProtectedB")
354
- .def(py::init<>())
355
- #if !defined(_MSC_VER) || _MSC_VER >= 1910
356
- .def("foo", &PublicistB::foo);
357
- #else
358
- .def("foo", static_cast<int (ProtectedB::*)() const>(&PublicistB::foo));
359
- #endif
360
-
361
- // test_brace_initialization
362
- struct BraceInitialization {
363
- int field1;
364
- std::string field2;
365
- };
366
-
367
- py::class_<BraceInitialization>(m, "BraceInitialization")
368
- .def(py::init<int, const std::string &>())
369
- .def_readwrite("field1", &BraceInitialization::field1)
370
- .def_readwrite("field2", &BraceInitialization::field2);
371
- // We *don't* want to construct using braces when the given constructor argument maps to a
372
- // constructor, because brace initialization could go to the wrong place (in particular when
373
- // there is also an `initializer_list<T>`-accept constructor):
374
- py::class_<NoBraceInitialization>(m, "NoBraceInitialization")
375
- .def(py::init<std::vector<int>>())
376
- .def_readonly("vec", &NoBraceInitialization::vec);
377
-
378
- // test_reentrant_implicit_conversion_failure
379
- // #1035: issue with runaway reentrant implicit conversion
380
- struct BogusImplicitConversion {
381
- BogusImplicitConversion(const BogusImplicitConversion &) = default;
382
- };
383
-
384
- py::class_<BogusImplicitConversion>(m, "BogusImplicitConversion")
385
- .def(py::init<const BogusImplicitConversion &>());
386
-
387
- py::implicitly_convertible<int, BogusImplicitConversion>();
388
-
389
- // test_qualname
390
- // #1166: nested class docstring doesn't show nested name
391
- // Also related: tests that __qualname__ is set properly
392
- struct NestBase {};
393
- struct Nested {};
394
- py::class_<NestBase> base(m, "NestBase");
395
- base.def(py::init<>());
396
- py::class_<Nested>(base, "Nested")
397
- .def(py::init<>())
398
- .def("fn", [](Nested &, int, NestBase &, Nested &) {})
399
- .def("fa", [](Nested &, int, NestBase &, Nested &) {},
400
- "a"_a, "b"_a, "c"_a);
401
- base.def("g", [](NestBase &, Nested &) {});
402
- base.def("h", []() { return NestBase(); });
403
-
404
- // test_error_after_conversion
405
- // The second-pass path through dispatcher() previously didn't
406
- // remember which overload was used, and would crash trying to
407
- // generate a useful error message
408
-
409
- struct NotRegistered {};
410
- struct StringWrapper { std::string str; };
411
- m.def("test_error_after_conversions", [](int) {});
412
- m.def("test_error_after_conversions",
413
- [](const StringWrapper &) -> NotRegistered { return {}; });
414
- py::class_<StringWrapper>(m, "StringWrapper").def(py::init<std::string>());
415
- py::implicitly_convertible<std::string, StringWrapper>();
416
-
417
- #if defined(PYBIND11_CPP17)
418
- struct alignas(1024) Aligned {
419
- std::uintptr_t ptr() const { return (uintptr_t) this; }
420
- };
421
- py::class_<Aligned>(m, "Aligned")
422
- .def(py::init<>())
423
- .def("ptr", &Aligned::ptr);
424
- #endif
425
-
426
- // test_final
427
- struct IsFinal final {};
428
- py::class_<IsFinal>(m, "IsFinal", py::is_final());
429
-
430
- // test_non_final_final
431
- struct IsNonFinalFinal {};
432
- py::class_<IsNonFinalFinal>(m, "IsNonFinalFinal", py::is_final());
433
-
434
- // test_exception_rvalue_abort
435
- struct PyPrintDestructor {
436
- PyPrintDestructor() = default;
437
- ~PyPrintDestructor() {
438
- py::print("Print from destructor");
439
- }
440
- void throw_something() { throw std::runtime_error("error"); }
441
- };
442
- py::class_<PyPrintDestructor>(m, "PyPrintDestructor")
443
- .def(py::init<>())
444
- .def("throw_something", &PyPrintDestructor::throw_something);
445
-
446
- // test_multiple_instances_with_same_pointer
447
- struct SamePointer {};
448
- static SamePointer samePointer;
449
- py::class_<SamePointer, std::unique_ptr<SamePointer, py::nodelete>>(m, "SamePointer")
450
- .def(py::init([]() { return &samePointer; }));
451
-
452
- struct Empty {};
453
- py::class_<Empty>(m, "Empty")
454
- .def(py::init<>());
455
-
456
- // test_base_and_derived_nested_scope
457
- struct BaseWithNested {
458
- struct Nested {};
459
- };
460
-
461
- struct DerivedWithNested : BaseWithNested {
462
- struct Nested {};
463
- };
464
-
465
- py::class_<BaseWithNested> baseWithNested_class(m, "BaseWithNested");
466
- py::class_<DerivedWithNested, BaseWithNested> derivedWithNested_class(m, "DerivedWithNested");
467
- py::class_<BaseWithNested::Nested>(baseWithNested_class, "Nested")
468
- .def_static("get_name", []() { return "BaseWithNested::Nested"; });
469
- py::class_<DerivedWithNested::Nested>(derivedWithNested_class, "Nested")
470
- .def_static("get_name", []() { return "DerivedWithNested::Nested"; });
471
-
472
- // test_register_duplicate_class
473
- struct Duplicate {};
474
- struct OtherDuplicate {};
475
- struct DuplicateNested {};
476
- struct OtherDuplicateNested {};
477
-
478
- m.def("register_duplicate_class_name", [](const py::module_ &m) {
479
- py::class_<Duplicate>(m, "Duplicate");
480
- py::class_<OtherDuplicate>(m, "Duplicate");
481
- });
482
- m.def("register_duplicate_class_type", [](const py::module_ &m) {
483
- py::class_<OtherDuplicate>(m, "OtherDuplicate");
484
- py::class_<OtherDuplicate>(m, "YetAnotherDuplicate");
485
- });
486
- m.def("register_duplicate_nested_class_name", [](const py::object &gt) {
487
- py::class_<DuplicateNested>(gt, "DuplicateNested");
488
- py::class_<OtherDuplicateNested>(gt, "DuplicateNested");
489
- });
490
- m.def("register_duplicate_nested_class_type", [](const py::object &gt) {
491
- py::class_<OtherDuplicateNested>(gt, "OtherDuplicateNested");
492
- py::class_<OtherDuplicateNested>(gt, "YetAnotherDuplicateNested");
493
- });
494
- }
495
-
496
- template <int N> class BreaksBase { public:
497
- virtual ~BreaksBase() = default;
498
- BreaksBase() = default;
499
- BreaksBase(const BreaksBase&) = delete;
500
- };
501
- template <int N> class BreaksTramp : public BreaksBase<N> {};
502
- // These should all compile just fine:
503
- using DoesntBreak1 = py::class_<BreaksBase<1>, std::unique_ptr<BreaksBase<1>>, BreaksTramp<1>>;
504
- using DoesntBreak2 = py::class_<BreaksBase<2>, BreaksTramp<2>, std::unique_ptr<BreaksBase<2>>>;
505
- using DoesntBreak3 = py::class_<BreaksBase<3>, std::unique_ptr<BreaksBase<3>>>;
506
- using DoesntBreak4 = py::class_<BreaksBase<4>, BreaksTramp<4>>;
507
- using DoesntBreak5 = py::class_<BreaksBase<5>>;
508
- using DoesntBreak6 = py::class_<BreaksBase<6>, std::shared_ptr<BreaksBase<6>>, BreaksTramp<6>>;
509
- using DoesntBreak7 = py::class_<BreaksBase<7>, BreaksTramp<7>, std::shared_ptr<BreaksBase<7>>>;
510
- using DoesntBreak8 = py::class_<BreaksBase<8>, std::shared_ptr<BreaksBase<8>>>;
511
- #define CHECK_BASE(N) static_assert(std::is_same<typename DoesntBreak##N::type, BreaksBase<(N)>>::value, \
512
- "DoesntBreak" #N " has wrong type!")
513
- CHECK_BASE(1); CHECK_BASE(2); CHECK_BASE(3); CHECK_BASE(4); CHECK_BASE(5); CHECK_BASE(6); CHECK_BASE(7); CHECK_BASE(8);
514
- #define CHECK_ALIAS(N) static_assert(DoesntBreak##N::has_alias && std::is_same<typename DoesntBreak##N::type_alias, BreaksTramp<(N)>>::value, \
515
- "DoesntBreak" #N " has wrong type_alias!")
516
- #define CHECK_NOALIAS(N) static_assert(!DoesntBreak##N::has_alias && std::is_void<typename DoesntBreak##N::type_alias>::value, \
517
- "DoesntBreak" #N " has type alias, but shouldn't!")
518
- CHECK_ALIAS(1); CHECK_ALIAS(2); CHECK_NOALIAS(3); CHECK_ALIAS(4); CHECK_NOALIAS(5); CHECK_ALIAS(6); CHECK_ALIAS(7); CHECK_NOALIAS(8);
519
- #define CHECK_HOLDER(N, TYPE) static_assert(std::is_same<typename DoesntBreak##N::holder_type, std::TYPE##_ptr<BreaksBase<(N)>>>::value, \
520
- "DoesntBreak" #N " has wrong holder_type!")
521
- CHECK_HOLDER(1, unique); CHECK_HOLDER(2, unique); CHECK_HOLDER(3, unique); CHECK_HOLDER(4, unique); CHECK_HOLDER(5, unique);
522
- CHECK_HOLDER(6, shared); CHECK_HOLDER(7, shared); CHECK_HOLDER(8, shared);
523
-
524
- // There's no nice way to test that these fail because they fail to compile; leave them here,
525
- // though, so that they can be manually tested by uncommenting them (and seeing that compilation
526
- // failures occurs).
527
-
528
- // We have to actually look into the type: the typedef alone isn't enough to instantiate the type:
529
- #define CHECK_BROKEN(N) static_assert(std::is_same<typename Breaks##N::type, BreaksBase<-(N)>>::value, \
530
- "Breaks1 has wrong type!");
531
-
532
- //// Two holder classes:
533
- //typedef py::class_<BreaksBase<-1>, std::unique_ptr<BreaksBase<-1>>, std::unique_ptr<BreaksBase<-1>>> Breaks1;
534
- //CHECK_BROKEN(1);
535
- //// Two aliases:
536
- //typedef py::class_<BreaksBase<-2>, BreaksTramp<-2>, BreaksTramp<-2>> Breaks2;
537
- //CHECK_BROKEN(2);
538
- //// Holder + 2 aliases
539
- //typedef py::class_<BreaksBase<-3>, std::unique_ptr<BreaksBase<-3>>, BreaksTramp<-3>, BreaksTramp<-3>> Breaks3;
540
- //CHECK_BROKEN(3);
541
- //// Alias + 2 holders
542
- //typedef py::class_<BreaksBase<-4>, std::unique_ptr<BreaksBase<-4>>, BreaksTramp<-4>, std::shared_ptr<BreaksBase<-4>>> Breaks4;
543
- //CHECK_BROKEN(4);
544
- //// Invalid option (not a subclass or holder)
545
- //typedef py::class_<BreaksBase<-5>, BreaksTramp<-4>> Breaks5;
546
- //CHECK_BROKEN(5);
547
- //// Invalid option: multiple inheritance not supported:
548
- //template <> struct BreaksBase<-8> : BreaksBase<-6>, BreaksBase<-7> {};
549
- //typedef py::class_<BreaksBase<-8>, BreaksBase<-6>, BreaksBase<-7>> Breaks8;
550
- //CHECK_BROKEN(8);