xcoll 0.3.3__py3-none-any.whl → 0.3.5__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 (317) hide show
  1. xcoll/beam_elements/__init__.py +5 -0
  2. xcoll/beam_elements/absorber.py +2 -1
  3. xcoll/beam_elements/base.py +32 -17
  4. xcoll/beam_elements/collimators_src/absorber.h +5 -0
  5. xcoll/beam_elements/everest.py +14 -25
  6. xcoll/colldb.py +50 -27
  7. xcoll/general.py +1 -1
  8. xcoll/headers/checks.h +7 -1
  9. xcoll/impacts/impacts.py +2 -1
  10. xcoll/impacts/impacts_src/impacts.h +1 -6
  11. xcoll/manager.py +5 -5
  12. xcoll/rf_sweep.py +90 -19
  13. xcoll/scattering_routines/everest/__init__.py +5 -0
  14. xcoll/scattering_routines/everest/everest.py +1 -1
  15. xcoll/scattering_routines/fluka/build_fluka_input.py +58 -0
  16. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  17. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.so +0 -0
  18. xcoll/scattering_routines/fluka/flukaio/src/Connection.d +68 -48
  19. xcoll/scattering_routines/fluka/flukaio/src/Connection.o +0 -0
  20. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.d +46 -37
  21. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.o +0 -0
  22. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.d +28 -25
  23. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.o +0 -0
  24. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.d +67 -47
  25. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.o +0 -0
  26. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.d +39 -33
  27. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.o +0 -0
  28. xcoll/scattering_routines/fluka/flukaio/src/NetIO.d +66 -47
  29. xcoll/scattering_routines/fluka/flukaio/src/NetIO.o +0 -0
  30. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/METADATA +3 -2
  31. xcoll-0.3.5.dist-info/NOTICE +2 -0
  32. xcoll-0.3.5.dist-info/RECORD +111 -0
  33. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/WHEEL +1 -1
  34. xcoll/beam_elements/collimators_src/base_block.h +0 -14
  35. xcoll/beam_elements/collimators_src/base_collimator.h +0 -14
  36. xcoll/beam_elements/collimators_src/invalid_collimator.h +0 -15
  37. xcoll/install_collimators.py +0 -180
  38. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  39. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  40. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  41. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  42. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  43. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  44. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  45. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  46. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  47. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  48. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  49. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  281. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  282. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  283. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  284. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -662
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -110
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  290. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -475
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -20
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  296. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  297. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  298. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  303. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  304. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  307. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  308. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  309. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  310. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  316. xcoll-0.3.3.dist-info/RECORD +0 -391
  317. {xcoll-0.3.3.dist-info → xcoll-0.3.5.dist-info}/LICENSE +0 -0
@@ -1,318 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- m = pytest.importorskip("pybind11_tests.smart_ptr")
5
- from pybind11_tests import ConstructorStats # noqa: E402
6
-
7
-
8
- def test_smart_ptr(capture):
9
- # Object1
10
- for i, o in enumerate(
11
- [m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
12
- ):
13
- assert o.getRefCount() == 1
14
- with capture:
15
- m.print_object_1(o)
16
- m.print_object_2(o)
17
- m.print_object_3(o)
18
- m.print_object_4(o)
19
- assert capture == "MyObject1[{i}]\n".format(i=i) * 4
20
-
21
- for i, o in enumerate(
22
- [m.make_myobject1_1(), m.make_myobject1_2(), m.MyObject1(6), 7], start=4
23
- ):
24
- print(o)
25
- with capture:
26
- if not isinstance(o, int):
27
- m.print_object_1(o)
28
- m.print_object_2(o)
29
- m.print_object_3(o)
30
- m.print_object_4(o)
31
- m.print_myobject1_1(o)
32
- m.print_myobject1_2(o)
33
- m.print_myobject1_3(o)
34
- m.print_myobject1_4(o)
35
-
36
- times = 4 if isinstance(o, int) else 8
37
- assert capture == "MyObject1[{i}]\n".format(i=i) * times
38
-
39
- cstats = ConstructorStats.get(m.MyObject1)
40
- assert cstats.alive() == 0
41
- expected_values = ["MyObject1[{}]".format(i) for i in range(1, 7)] + [
42
- "MyObject1[7]"
43
- ] * 4
44
- assert cstats.values() == expected_values
45
- assert cstats.default_constructions == 0
46
- assert cstats.copy_constructions == 0
47
- # assert cstats.move_constructions >= 0 # Doesn't invoke any
48
- assert cstats.copy_assignments == 0
49
- assert cstats.move_assignments == 0
50
-
51
- # Object2
52
- for i, o in zip(
53
- [8, 6, 7], [m.MyObject2(8), m.make_myobject2_1(), m.make_myobject2_2()]
54
- ):
55
- print(o)
56
- with capture:
57
- m.print_myobject2_1(o)
58
- m.print_myobject2_2(o)
59
- m.print_myobject2_3(o)
60
- m.print_myobject2_4(o)
61
- assert capture == "MyObject2[{i}]\n".format(i=i) * 4
62
-
63
- cstats = ConstructorStats.get(m.MyObject2)
64
- assert cstats.alive() == 1
65
- o = None
66
- assert cstats.alive() == 0
67
- assert cstats.values() == ["MyObject2[8]", "MyObject2[6]", "MyObject2[7]"]
68
- assert cstats.default_constructions == 0
69
- assert cstats.copy_constructions == 0
70
- # assert cstats.move_constructions >= 0 # Doesn't invoke any
71
- assert cstats.copy_assignments == 0
72
- assert cstats.move_assignments == 0
73
-
74
- # Object3
75
- for i, o in zip(
76
- [9, 8, 9], [m.MyObject3(9), m.make_myobject3_1(), m.make_myobject3_2()]
77
- ):
78
- print(o)
79
- with capture:
80
- m.print_myobject3_1(o)
81
- m.print_myobject3_2(o)
82
- m.print_myobject3_3(o)
83
- m.print_myobject3_4(o)
84
- assert capture == "MyObject3[{i}]\n".format(i=i) * 4
85
-
86
- cstats = ConstructorStats.get(m.MyObject3)
87
- assert cstats.alive() == 1
88
- o = None
89
- assert cstats.alive() == 0
90
- assert cstats.values() == ["MyObject3[9]", "MyObject3[8]", "MyObject3[9]"]
91
- assert cstats.default_constructions == 0
92
- assert cstats.copy_constructions == 0
93
- # assert cstats.move_constructions >= 0 # Doesn't invoke any
94
- assert cstats.copy_assignments == 0
95
- assert cstats.move_assignments == 0
96
-
97
- # Object
98
- cstats = ConstructorStats.get(m.Object)
99
- assert cstats.alive() == 0
100
- assert cstats.values() == []
101
- assert cstats.default_constructions == 10
102
- assert cstats.copy_constructions == 0
103
- # assert cstats.move_constructions >= 0 # Doesn't invoke any
104
- assert cstats.copy_assignments == 0
105
- assert cstats.move_assignments == 0
106
-
107
- # ref<>
108
- cstats = m.cstats_ref()
109
- assert cstats.alive() == 0
110
- assert cstats.values() == ["from pointer"] * 10
111
- assert cstats.default_constructions == 30
112
- assert cstats.copy_constructions == 12
113
- # assert cstats.move_constructions >= 0 # Doesn't invoke any
114
- assert cstats.copy_assignments == 30
115
- assert cstats.move_assignments == 0
116
-
117
-
118
- def test_smart_ptr_refcounting():
119
- assert m.test_object1_refcounting()
120
-
121
-
122
- def test_unique_nodelete():
123
- o = m.MyObject4(23)
124
- assert o.value == 23
125
- cstats = ConstructorStats.get(m.MyObject4)
126
- assert cstats.alive() == 1
127
- del o
128
- assert cstats.alive() == 1
129
- m.MyObject4.cleanup_all_instances()
130
- assert cstats.alive() == 0
131
-
132
-
133
- def test_unique_nodelete4a():
134
- o = m.MyObject4a(23)
135
- assert o.value == 23
136
- cstats = ConstructorStats.get(m.MyObject4a)
137
- assert cstats.alive() == 1
138
- del o
139
- assert cstats.alive() == 1
140
- m.MyObject4a.cleanup_all_instances()
141
- assert cstats.alive() == 0
142
-
143
-
144
- def test_unique_deleter():
145
- m.MyObject4a(0)
146
- o = m.MyObject4b(23)
147
- assert o.value == 23
148
- cstats4a = ConstructorStats.get(m.MyObject4a)
149
- assert cstats4a.alive() == 2
150
- cstats4b = ConstructorStats.get(m.MyObject4b)
151
- assert cstats4b.alive() == 1
152
- del o
153
- assert cstats4a.alive() == 1 # Should now only be one leftover
154
- assert cstats4b.alive() == 0 # Should be deleted
155
- m.MyObject4a.cleanup_all_instances()
156
- assert cstats4a.alive() == 0
157
- assert cstats4b.alive() == 0
158
-
159
-
160
- def test_large_holder():
161
- o = m.MyObject5(5)
162
- assert o.value == 5
163
- cstats = ConstructorStats.get(m.MyObject5)
164
- assert cstats.alive() == 1
165
- del o
166
- assert cstats.alive() == 0
167
-
168
-
169
- def test_shared_ptr_and_references():
170
- s = m.SharedPtrRef()
171
- stats = ConstructorStats.get(m.A)
172
- assert stats.alive() == 2
173
-
174
- ref = s.ref # init_holder_helper(holder_ptr=false, owned=false)
175
- assert stats.alive() == 2
176
- assert s.set_ref(ref)
177
- with pytest.raises(RuntimeError) as excinfo:
178
- assert s.set_holder(ref)
179
- assert "Unable to cast from non-held to held instance" in str(excinfo.value)
180
-
181
- copy = s.copy # init_holder_helper(holder_ptr=false, owned=true)
182
- assert stats.alive() == 3
183
- assert s.set_ref(copy)
184
- assert s.set_holder(copy)
185
-
186
- holder_ref = s.holder_ref # init_holder_helper(holder_ptr=true, owned=false)
187
- assert stats.alive() == 3
188
- assert s.set_ref(holder_ref)
189
- assert s.set_holder(holder_ref)
190
-
191
- holder_copy = s.holder_copy # init_holder_helper(holder_ptr=true, owned=true)
192
- assert stats.alive() == 3
193
- assert s.set_ref(holder_copy)
194
- assert s.set_holder(holder_copy)
195
-
196
- del ref, copy, holder_ref, holder_copy, s
197
- assert stats.alive() == 0
198
-
199
-
200
- def test_shared_ptr_from_this_and_references():
201
- s = m.SharedFromThisRef()
202
- stats = ConstructorStats.get(m.B)
203
- assert stats.alive() == 2
204
-
205
- ref = s.ref # init_holder_helper(holder_ptr=false, owned=false, bad_wp=false)
206
- assert stats.alive() == 2
207
- assert s.set_ref(ref)
208
- assert s.set_holder(
209
- ref
210
- ) # std::enable_shared_from_this can create a holder from a reference
211
-
212
- bad_wp = s.bad_wp # init_holder_helper(holder_ptr=false, owned=false, bad_wp=true)
213
- assert stats.alive() == 2
214
- assert s.set_ref(bad_wp)
215
- with pytest.raises(RuntimeError) as excinfo:
216
- assert s.set_holder(bad_wp)
217
- assert "Unable to cast from non-held to held instance" in str(excinfo.value)
218
-
219
- copy = s.copy # init_holder_helper(holder_ptr=false, owned=true, bad_wp=false)
220
- assert stats.alive() == 3
221
- assert s.set_ref(copy)
222
- assert s.set_holder(copy)
223
-
224
- holder_ref = (
225
- s.holder_ref
226
- ) # init_holder_helper(holder_ptr=true, owned=false, bad_wp=false)
227
- assert stats.alive() == 3
228
- assert s.set_ref(holder_ref)
229
- assert s.set_holder(holder_ref)
230
-
231
- holder_copy = (
232
- s.holder_copy
233
- ) # init_holder_helper(holder_ptr=true, owned=true, bad_wp=false)
234
- assert stats.alive() == 3
235
- assert s.set_ref(holder_copy)
236
- assert s.set_holder(holder_copy)
237
-
238
- del ref, bad_wp, copy, holder_ref, holder_copy, s
239
- assert stats.alive() == 0
240
-
241
- z = m.SharedFromThisVirt.get()
242
- y = m.SharedFromThisVirt.get()
243
- assert y is z
244
-
245
-
246
- def test_move_only_holder():
247
- a = m.TypeWithMoveOnlyHolder.make()
248
- b = m.TypeWithMoveOnlyHolder.make_as_object()
249
- stats = ConstructorStats.get(m.TypeWithMoveOnlyHolder)
250
- assert stats.alive() == 2
251
- del b
252
- assert stats.alive() == 1
253
- del a
254
- assert stats.alive() == 0
255
-
256
-
257
- def test_holder_with_addressof_operator():
258
- # this test must not throw exception from c++
259
- a = m.TypeForHolderWithAddressOf.make()
260
- a.print_object_1()
261
- a.print_object_2()
262
- a.print_object_3()
263
- a.print_object_4()
264
-
265
- stats = ConstructorStats.get(m.TypeForHolderWithAddressOf)
266
- assert stats.alive() == 1
267
-
268
- np = m.TypeForHolderWithAddressOf.make()
269
- assert stats.alive() == 2
270
- del a
271
- assert stats.alive() == 1
272
- del np
273
- assert stats.alive() == 0
274
-
275
- b = m.TypeForHolderWithAddressOf.make()
276
- c = b
277
- assert b.get() is c.get()
278
- assert stats.alive() == 1
279
-
280
- del b
281
- assert stats.alive() == 1
282
-
283
- del c
284
- assert stats.alive() == 0
285
-
286
-
287
- def test_move_only_holder_with_addressof_operator():
288
- a = m.TypeForMoveOnlyHolderWithAddressOf.make()
289
- a.print_object()
290
-
291
- stats = ConstructorStats.get(m.TypeForMoveOnlyHolderWithAddressOf)
292
- assert stats.alive() == 1
293
-
294
- a.value = 42
295
- assert a.value == 42
296
-
297
- del a
298
- assert stats.alive() == 0
299
-
300
-
301
- def test_smart_ptr_from_default():
302
- instance = m.HeldByDefaultHolder()
303
- with pytest.raises(RuntimeError) as excinfo:
304
- m.HeldByDefaultHolder.load_shared_ptr(instance)
305
- assert (
306
- "Unable to load a custom holder type from a "
307
- "default-holder instance" in str(excinfo.value)
308
- )
309
-
310
-
311
- def test_shared_ptr_gc():
312
- """#187: issue involving std::shared_ptr<> return value policy & garbage collection"""
313
- el = m.ElementList()
314
- for i in range(10):
315
- el.add(m.ElementA(i))
316
- pytest.gc_collect()
317
- for i, v in enumerate(el.get()):
318
- assert i == v.value()
@@ -1,342 +0,0 @@
1
- /*
2
- tests/test_stl.cpp -- STL type casters
3
-
4
- Copyright (c) 2017 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include "constructor_stats.h"
12
- #include <pybind11/stl.h>
13
-
14
- #ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
15
- #define PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
16
- #endif
17
- #include <pybind11/stl/filesystem.h>
18
-
19
- #include <vector>
20
- #include <string>
21
-
22
- // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14
23
- #if defined(PYBIND11_HAS_VARIANT)
24
- using std::variant;
25
- #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910)
26
- # include <boost/variant.hpp>
27
- # define PYBIND11_HAS_VARIANT 1
28
- using boost::variant;
29
-
30
- namespace pybind11 { namespace detail {
31
- template <typename... Ts>
32
- struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
33
-
34
- template <>
35
- struct visit_helper<boost::variant> {
36
- template <typename... Args>
37
- static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
38
- return boost::apply_visitor(args...);
39
- }
40
- };
41
- }} // namespace pybind11::detail
42
- #endif
43
-
44
- PYBIND11_MAKE_OPAQUE(std::vector<std::string, std::allocator<std::string>>);
45
-
46
- /// Issue #528: templated constructor
47
- struct TplCtorClass {
48
- template <typename T>
49
- explicit TplCtorClass(const T &) {}
50
- bool operator==(const TplCtorClass &) const { return true; }
51
- };
52
-
53
- namespace std {
54
- template <>
55
- struct hash<TplCtorClass> { size_t operator()(const TplCtorClass &) const { return 0; } };
56
- } // namespace std
57
-
58
-
59
- template <template <typename> class OptionalImpl, typename T>
60
- struct OptionalHolder
61
- {
62
- OptionalHolder() = default;
63
- bool member_initialized() const {
64
- return member && member->initialized;
65
- }
66
- OptionalImpl<T> member = T{};
67
- };
68
-
69
-
70
- TEST_SUBMODULE(stl, m) {
71
- // test_vector
72
- m.def("cast_vector", []() { return std::vector<int>{1}; });
73
- m.def("load_vector", [](const std::vector<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
74
- // `std::vector<bool>` is special because it returns proxy objects instead of references
75
- m.def("cast_bool_vector", []() { return std::vector<bool>{true, false}; });
76
- m.def("load_bool_vector", [](const std::vector<bool> &v) {
77
- return v.at(0) == true && v.at(1) == false;
78
- });
79
- // Unnumbered regression (caused by #936): pointers to stl containers aren't castable
80
- static std::vector<RValueCaster> lvv{2};
81
- m.def("cast_ptr_vector", []() { return &lvv; });
82
-
83
- // test_deque
84
- m.def("cast_deque", []() { return std::deque<int>{1}; });
85
- m.def("load_deque", [](const std::deque<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
86
-
87
- // test_array
88
- m.def("cast_array", []() { return std::array<int, 2> {{1 , 2}}; });
89
- m.def("load_array", [](const std::array<int, 2> &a) { return a[0] == 1 && a[1] == 2; });
90
-
91
- // test_valarray
92
- m.def("cast_valarray", []() { return std::valarray<int>{1, 4, 9}; });
93
- m.def("load_valarray", [](const std::valarray<int>& v) {
94
- return v.size() == 3 && v[0] == 1 && v[1] == 4 && v[2] == 9;
95
- });
96
-
97
- // test_map
98
- m.def("cast_map", []() { return std::map<std::string, std::string>{{"key", "value"}}; });
99
- m.def("load_map", [](const std::map<std::string, std::string> &map) {
100
- return map.at("key") == "value" && map.at("key2") == "value2";
101
- });
102
-
103
- // test_set
104
- m.def("cast_set", []() { return std::set<std::string>{"key1", "key2"}; });
105
- m.def("load_set", [](const std::set<std::string> &set) {
106
- return (set.count("key1") != 0u) && (set.count("key2") != 0u) && (set.count("key3") != 0u);
107
- });
108
-
109
- // test_recursive_casting
110
- m.def("cast_rv_vector", []() { return std::vector<RValueCaster>{2}; });
111
- m.def("cast_rv_array", []() { return std::array<RValueCaster, 3>(); });
112
- // NB: map and set keys are `const`, so while we technically do move them (as `const Type &&`),
113
- // casters don't typically do anything with that, which means they fall to the `const Type &`
114
- // caster.
115
- m.def("cast_rv_map", []() { return std::unordered_map<std::string, RValueCaster>{{"a", RValueCaster{}}}; });
116
- m.def("cast_rv_nested", []() {
117
- std::vector<std::array<std::list<std::unordered_map<std::string, RValueCaster>>, 2>> v;
118
- v.emplace_back(); // add an array
119
- v.back()[0].emplace_back(); // add a map to the array
120
- v.back()[0].back().emplace("b", RValueCaster{});
121
- v.back()[0].back().emplace("c", RValueCaster{});
122
- v.back()[1].emplace_back(); // add a map to the array
123
- v.back()[1].back().emplace("a", RValueCaster{});
124
- return v;
125
- });
126
- static std::array<RValueCaster, 2> lva;
127
- static std::unordered_map<std::string, RValueCaster> lvm{{"a", RValueCaster{}}, {"b", RValueCaster{}}};
128
- static std::unordered_map<std::string, std::vector<std::list<std::array<RValueCaster, 2>>>> lvn;
129
- lvn["a"].emplace_back(); // add a list
130
- lvn["a"].back().emplace_back(); // add an array
131
- lvn["a"].emplace_back(); // another list
132
- lvn["a"].back().emplace_back(); // add an array
133
- lvn["b"].emplace_back(); // add a list
134
- lvn["b"].back().emplace_back(); // add an array
135
- lvn["b"].back().emplace_back(); // add another array
136
- m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
137
- m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
138
- m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });
139
- m.def("cast_lv_nested", []() -> const decltype(lvn) & { return lvn; });
140
- // #853:
141
- m.def("cast_unique_ptr_vector", []() {
142
- std::vector<std::unique_ptr<UserType>> v;
143
- v.emplace_back(new UserType{7});
144
- v.emplace_back(new UserType{42});
145
- return v;
146
- });
147
-
148
- // test_move_out_container
149
- struct MoveOutContainer {
150
- struct Value { int value; };
151
- std::list<Value> move_list() const { return {{0}, {1}, {2}}; }
152
- };
153
- py::class_<MoveOutContainer::Value>(m, "MoveOutContainerValue")
154
- .def_readonly("value", &MoveOutContainer::Value::value);
155
- py::class_<MoveOutContainer>(m, "MoveOutContainer")
156
- .def(py::init<>())
157
- .def_property_readonly("move_list", &MoveOutContainer::move_list);
158
-
159
- // Class that can be move- and copy-constructed, but not assigned
160
- struct NoAssign {
161
- int value;
162
-
163
- explicit NoAssign(int value = 0) : value(value) { }
164
- NoAssign(const NoAssign &) = default;
165
- NoAssign(NoAssign &&) = default;
166
-
167
- NoAssign &operator=(const NoAssign &) = delete;
168
- NoAssign &operator=(NoAssign &&) = delete;
169
- };
170
- py::class_<NoAssign>(m, "NoAssign", "Class with no C++ assignment operators")
171
- .def(py::init<>())
172
- .def(py::init<int>());
173
-
174
-
175
- struct MoveOutDetector
176
- {
177
- MoveOutDetector() = default;
178
- MoveOutDetector(const MoveOutDetector&) = default;
179
- MoveOutDetector(MoveOutDetector&& other) noexcept
180
- : initialized(other.initialized) {
181
- // steal underlying resource
182
- other.initialized = false;
183
- }
184
- bool initialized = true;
185
- };
186
- py::class_<MoveOutDetector>(m, "MoveOutDetector", "Class with move tracking")
187
- .def(py::init<>())
188
- .def_readonly("initialized", &MoveOutDetector::initialized);
189
-
190
-
191
- #ifdef PYBIND11_HAS_OPTIONAL
192
- // test_optional
193
- m.attr("has_optional") = true;
194
-
195
- using opt_int = std::optional<int>;
196
- using opt_no_assign = std::optional<NoAssign>;
197
- m.def("double_or_zero", [](const opt_int& x) -> int {
198
- return x.value_or(0) * 2;
199
- });
200
- m.def("half_or_none", [](int x) -> opt_int { return x != 0 ? opt_int(x / 2) : opt_int(); });
201
- m.def("test_nullopt", [](opt_int x) {
202
- return x.value_or(42);
203
- }, py::arg_v("x", std::nullopt, "None"));
204
- m.def("test_no_assign", [](const opt_no_assign &x) {
205
- return x ? x->value : 42;
206
- }, py::arg_v("x", std::nullopt, "None"));
207
-
208
- m.def("nodefer_none_optional", [](std::optional<int>) { return true; });
209
- m.def("nodefer_none_optional", [](const py::none &) { return false; });
210
-
211
- using opt_holder = OptionalHolder<std::optional, MoveOutDetector>;
212
- py::class_<opt_holder>(m, "OptionalHolder", "Class with optional member")
213
- .def(py::init<>())
214
- .def_readonly("member", &opt_holder::member)
215
- .def("member_initialized", &opt_holder::member_initialized);
216
- #endif
217
-
218
- #ifdef PYBIND11_HAS_EXP_OPTIONAL
219
- // test_exp_optional
220
- m.attr("has_exp_optional") = true;
221
-
222
- using exp_opt_int = std::experimental::optional<int>;
223
- using exp_opt_no_assign = std::experimental::optional<NoAssign>;
224
- m.def("double_or_zero_exp", [](const exp_opt_int& x) -> int {
225
- return x.value_or(0) * 2;
226
- });
227
- m.def("half_or_none_exp", [](int x) -> exp_opt_int {
228
- return x ? exp_opt_int(x / 2) : exp_opt_int();
229
- });
230
- m.def("test_nullopt_exp", [](exp_opt_int x) {
231
- return x.value_or(42);
232
- }, py::arg_v("x", std::experimental::nullopt, "None"));
233
- m.def("test_no_assign_exp", [](const exp_opt_no_assign &x) {
234
- return x ? x->value : 42;
235
- }, py::arg_v("x", std::experimental::nullopt, "None"));
236
-
237
- using opt_exp_holder = OptionalHolder<std::experimental::optional, MoveOutDetector>;
238
- py::class_<opt_exp_holder>(m, "OptionalExpHolder", "Class with optional member")
239
- .def(py::init<>())
240
- .def_readonly("member", &opt_exp_holder::member)
241
- .def("member_initialized", &opt_exp_holder::member_initialized);
242
- #endif
243
-
244
- #ifdef PYBIND11_HAS_FILESYSTEM
245
- // test_fs_path
246
- m.attr("has_filesystem") = true;
247
- m.def("parent_path", [](const std::filesystem::path& p) { return p.parent_path(); });
248
- #endif
249
-
250
- #ifdef PYBIND11_HAS_VARIANT
251
- static_assert(std::is_same<py::detail::variant_caster_visitor::result_type, py::handle>::value,
252
- "visitor::result_type is required by boost::variant in C++11 mode");
253
-
254
- struct visitor {
255
- using result_type = const char *;
256
-
257
- result_type operator()(int) { return "int"; }
258
- result_type operator()(const std::string &) { return "std::string"; }
259
- result_type operator()(double) { return "double"; }
260
- result_type operator()(std::nullptr_t) { return "std::nullptr_t"; }
261
- };
262
-
263
- // test_variant
264
- m.def("load_variant", [](const variant<int, std::string, double, std::nullptr_t> &v) {
265
- return py::detail::visit_helper<variant>::call(visitor(), v);
266
- });
267
- m.def("load_variant_2pass", [](variant<double, int> v) {
268
- return py::detail::visit_helper<variant>::call(visitor(), v);
269
- });
270
- m.def("cast_variant", []() {
271
- using V = variant<int, std::string>;
272
- return py::make_tuple(V(5), V("Hello"));
273
- });
274
- #endif
275
-
276
- // #528: templated constructor
277
- // (no python tests: the test here is that this compiles)
278
- m.def("tpl_ctor_vector", [](std::vector<TplCtorClass> &) {});
279
- m.def("tpl_ctor_map", [](std::unordered_map<TplCtorClass, TplCtorClass> &) {});
280
- m.def("tpl_ctor_set", [](std::unordered_set<TplCtorClass> &) {});
281
- #if defined(PYBIND11_HAS_OPTIONAL)
282
- m.def("tpl_constr_optional", [](std::optional<TplCtorClass> &) {});
283
- #elif defined(PYBIND11_HAS_EXP_OPTIONAL)
284
- m.def("tpl_constr_optional", [](std::experimental::optional<TplCtorClass> &) {});
285
- #endif
286
-
287
- // test_vec_of_reference_wrapper
288
- // #171: Can't return STL structures containing reference wrapper
289
- m.def("return_vec_of_reference_wrapper", [](std::reference_wrapper<UserType> p4) {
290
- static UserType p1{1}, p2{2}, p3{3};
291
- return std::vector<std::reference_wrapper<UserType>> {
292
- std::ref(p1), std::ref(p2), std::ref(p3), p4
293
- };
294
- });
295
-
296
- // test_stl_pass_by_pointer
297
- m.def("stl_pass_by_pointer", [](std::vector<int>* v) { return *v; }, "v"_a=nullptr);
298
-
299
- // #1258: pybind11/stl.h converts string to vector<string>
300
- m.def("func_with_string_or_vector_string_arg_overload",
301
- [](const std::vector<std::string> &) { return 1; });
302
- m.def("func_with_string_or_vector_string_arg_overload",
303
- [](const std::list<std::string> &) { return 2; });
304
- m.def("func_with_string_or_vector_string_arg_overload", [](const std::string &) { return 3; });
305
-
306
- class Placeholder {
307
- public:
308
- Placeholder() { print_created(this); }
309
- Placeholder(const Placeholder &) = delete;
310
- ~Placeholder() { print_destroyed(this); }
311
- };
312
- py::class_<Placeholder>(m, "Placeholder");
313
-
314
- /// test_stl_vector_ownership
315
- m.def("test_stl_ownership",
316
- []() {
317
- std::vector<Placeholder *> result;
318
- result.push_back(new Placeholder());
319
- return result;
320
- },
321
- py::return_value_policy::take_ownership);
322
-
323
- m.def("array_cast_sequence", [](std::array<int, 3> x) { return x; });
324
-
325
- /// test_issue_1561
326
- struct Issue1561Inner { std::string data; };
327
- struct Issue1561Outer { std::vector<Issue1561Inner> list; };
328
-
329
- py::class_<Issue1561Inner>(m, "Issue1561Inner")
330
- .def(py::init<std::string>())
331
- .def_readwrite("data", &Issue1561Inner::data);
332
-
333
- py::class_<Issue1561Outer>(m, "Issue1561Outer")
334
- .def(py::init<>())
335
- .def_readwrite("list", &Issue1561Outer::list);
336
-
337
- m.def(
338
- "return_vector_bool_raw_ptr",
339
- []() { return new std::vector<bool>(4513); },
340
- // Without explicitly specifying `take_ownership`, this function leaks.
341
- py::return_value_policy::take_ownership);
342
- }