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,747 +0,0 @@
1
- /*
2
- pybind11/std_bind.h: Binding generators for STL data types
3
-
4
- Copyright (c) 2016 Sergey Lyskov and Wenzel Jakob
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
- #pragma once
11
-
12
- #include "detail/common.h"
13
- #include "operators.h"
14
-
15
- #include <algorithm>
16
- #include <sstream>
17
-
18
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
19
- PYBIND11_NAMESPACE_BEGIN(detail)
20
-
21
- /* SFINAE helper class used by 'is_comparable */
22
- template <typename T> struct container_traits {
23
- template <typename T2> static std::true_type test_comparable(decltype(std::declval<const T2 &>() == std::declval<const T2 &>())*);
24
- template <typename T2> static std::false_type test_comparable(...);
25
- template <typename T2> static std::true_type test_value(typename T2::value_type *);
26
- template <typename T2> static std::false_type test_value(...);
27
- template <typename T2> static std::true_type test_pair(typename T2::first_type *, typename T2::second_type *);
28
- template <typename T2> static std::false_type test_pair(...);
29
-
30
- static constexpr const bool is_comparable = std::is_same<std::true_type, decltype(test_comparable<T>(nullptr))>::value;
31
- static constexpr const bool is_pair = std::is_same<std::true_type, decltype(test_pair<T>(nullptr, nullptr))>::value;
32
- static constexpr const bool is_vector = std::is_same<std::true_type, decltype(test_value<T>(nullptr))>::value;
33
- static constexpr const bool is_element = !is_pair && !is_vector;
34
- };
35
-
36
- /* Default: is_comparable -> std::false_type */
37
- template <typename T, typename SFINAE = void>
38
- struct is_comparable : std::false_type { };
39
-
40
- /* For non-map data structures, check whether operator== can be instantiated */
41
- template <typename T>
42
- struct is_comparable<
43
- T, enable_if_t<container_traits<T>::is_element &&
44
- container_traits<T>::is_comparable>>
45
- : std::true_type { };
46
-
47
- /* For a vector/map data structure, recursively check the value type (which is std::pair for maps) */
48
- template <typename T>
49
- struct is_comparable<T, enable_if_t<container_traits<T>::is_vector>> {
50
- static constexpr const bool value =
51
- is_comparable<typename T::value_type>::value;
52
- };
53
-
54
- /* For pairs, recursively check the two data types */
55
- template <typename T>
56
- struct is_comparable<T, enable_if_t<container_traits<T>::is_pair>> {
57
- static constexpr const bool value =
58
- is_comparable<typename T::first_type>::value &&
59
- is_comparable<typename T::second_type>::value;
60
- };
61
-
62
- /* Fallback functions */
63
- template <typename, typename, typename... Args> void vector_if_copy_constructible(const Args &...) { }
64
- template <typename, typename, typename... Args> void vector_if_equal_operator(const Args &...) { }
65
- template <typename, typename, typename... Args> void vector_if_insertion_operator(const Args &...) { }
66
- template <typename, typename, typename... Args> void vector_modifiers(const Args &...) { }
67
-
68
- template<typename Vector, typename Class_>
69
- void vector_if_copy_constructible(enable_if_t<is_copy_constructible<Vector>::value, Class_> &cl) {
70
- cl.def(init<const Vector &>(), "Copy constructor");
71
- }
72
-
73
- template<typename Vector, typename Class_>
74
- void vector_if_equal_operator(enable_if_t<is_comparable<Vector>::value, Class_> &cl) {
75
- using T = typename Vector::value_type;
76
-
77
- cl.def(self == self);
78
- cl.def(self != self);
79
-
80
- cl.def("count",
81
- [](const Vector &v, const T &x) {
82
- return std::count(v.begin(), v.end(), x);
83
- },
84
- arg("x"),
85
- "Return the number of times ``x`` appears in the list"
86
- );
87
-
88
- cl.def("remove", [](Vector &v, const T &x) {
89
- auto p = std::find(v.begin(), v.end(), x);
90
- if (p != v.end())
91
- v.erase(p);
92
- else
93
- throw value_error();
94
- },
95
- arg("x"),
96
- "Remove the first item from the list whose value is x. "
97
- "It is an error if there is no such item."
98
- );
99
-
100
- cl.def("__contains__",
101
- [](const Vector &v, const T &x) {
102
- return std::find(v.begin(), v.end(), x) != v.end();
103
- },
104
- arg("x"),
105
- "Return true the container contains ``x``"
106
- );
107
- }
108
-
109
- // Vector modifiers -- requires a copyable vector_type:
110
- // (Technically, some of these (pop and __delitem__) don't actually require copyability, but it seems
111
- // silly to allow deletion but not insertion, so include them here too.)
112
- template <typename Vector, typename Class_>
113
- void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_type>::value, Class_> &cl) {
114
- using T = typename Vector::value_type;
115
- using SizeType = typename Vector::size_type;
116
- using DiffType = typename Vector::difference_type;
117
-
118
- auto wrap_i = [](DiffType i, SizeType n) {
119
- if (i < 0)
120
- i += n;
121
- if (i < 0 || (SizeType)i >= n)
122
- throw index_error();
123
- return i;
124
- };
125
-
126
- cl.def("append",
127
- [](Vector &v, const T &value) { v.push_back(value); },
128
- arg("x"),
129
- "Add an item to the end of the list");
130
-
131
- cl.def(init([](const iterable &it) {
132
- auto v = std::unique_ptr<Vector>(new Vector());
133
- v->reserve(len_hint(it));
134
- for (handle h : it)
135
- v->push_back(h.cast<T>());
136
- return v.release();
137
- }));
138
-
139
- cl.def("clear",
140
- [](Vector &v) {
141
- v.clear();
142
- },
143
- "Clear the contents"
144
- );
145
-
146
- cl.def("extend",
147
- [](Vector &v, const Vector &src) {
148
- v.insert(v.end(), src.begin(), src.end());
149
- },
150
- arg("L"),
151
- "Extend the list by appending all the items in the given list"
152
- );
153
-
154
- cl.def(
155
- "extend",
156
- [](Vector &v, const iterable &it) {
157
- const size_t old_size = v.size();
158
- v.reserve(old_size + len_hint(it));
159
- try {
160
- for (handle h : it) {
161
- v.push_back(h.cast<T>());
162
- }
163
- } catch (const cast_error &) {
164
- v.erase(v.begin() + static_cast<typename Vector::difference_type>(old_size),
165
- v.end());
166
- try {
167
- v.shrink_to_fit();
168
- } catch (const std::exception &) {
169
- // Do nothing
170
- }
171
- throw;
172
- }
173
- },
174
- arg("L"),
175
- "Extend the list by appending all the items in the given list");
176
-
177
- cl.def("insert",
178
- [](Vector &v, DiffType i, const T &x) {
179
- // Can't use wrap_i; i == v.size() is OK
180
- if (i < 0)
181
- i += v.size();
182
- if (i < 0 || (SizeType)i > v.size())
183
- throw index_error();
184
- v.insert(v.begin() + i, x);
185
- },
186
- arg("i") , arg("x"),
187
- "Insert an item at a given position."
188
- );
189
-
190
- cl.def("pop",
191
- [](Vector &v) {
192
- if (v.empty())
193
- throw index_error();
194
- T t = std::move(v.back());
195
- v.pop_back();
196
- return t;
197
- },
198
- "Remove and return the last item"
199
- );
200
-
201
- cl.def("pop",
202
- [wrap_i](Vector &v, DiffType i) {
203
- i = wrap_i(i, v.size());
204
- T t = std::move(v[(SizeType) i]);
205
- v.erase(std::next(v.begin(), i));
206
- return t;
207
- },
208
- arg("i"),
209
- "Remove and return the item at index ``i``"
210
- );
211
-
212
- cl.def("__setitem__",
213
- [wrap_i](Vector &v, DiffType i, const T &t) {
214
- i = wrap_i(i, v.size());
215
- v[(SizeType)i] = t;
216
- }
217
- );
218
-
219
- /// Slicing protocol
220
- cl.def(
221
- "__getitem__",
222
- [](const Vector &v, slice slice) -> Vector * {
223
- size_t start = 0, stop = 0, step = 0, slicelength = 0;
224
-
225
- if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
226
- throw error_already_set();
227
-
228
- auto *seq = new Vector();
229
- seq->reserve((size_t) slicelength);
230
-
231
- for (size_t i=0; i<slicelength; ++i) {
232
- seq->push_back(v[start]);
233
- start += step;
234
- }
235
- return seq;
236
- },
237
- arg("s"),
238
- "Retrieve list elements using a slice object");
239
-
240
- cl.def(
241
- "__setitem__",
242
- [](Vector &v, slice slice, const Vector &value) {
243
- size_t start = 0, stop = 0, step = 0, slicelength = 0;
244
- if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
245
- throw error_already_set();
246
-
247
- if (slicelength != value.size())
248
- throw std::runtime_error("Left and right hand size of slice assignment have different sizes!");
249
-
250
- for (size_t i=0; i<slicelength; ++i) {
251
- v[start] = value[i];
252
- start += step;
253
- }
254
- },
255
- "Assign list elements using a slice object");
256
-
257
- cl.def("__delitem__",
258
- [wrap_i](Vector &v, DiffType i) {
259
- i = wrap_i(i, v.size());
260
- v.erase(v.begin() + i);
261
- },
262
- "Delete the list elements at index ``i``"
263
- );
264
-
265
- cl.def(
266
- "__delitem__",
267
- [](Vector &v, slice slice) {
268
- size_t start = 0, stop = 0, step = 0, slicelength = 0;
269
-
270
- if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
271
- throw error_already_set();
272
-
273
- if (step == 1 && false) {
274
- v.erase(v.begin() + (DiffType) start, v.begin() + DiffType(start + slicelength));
275
- } else {
276
- for (size_t i = 0; i < slicelength; ++i) {
277
- v.erase(v.begin() + DiffType(start));
278
- start += step - 1;
279
- }
280
- }
281
- },
282
- "Delete list elements using a slice object");
283
- }
284
-
285
- // If the type has an operator[] that doesn't return a reference (most notably std::vector<bool>),
286
- // we have to access by copying; otherwise we return by reference.
287
- template <typename Vector> using vector_needs_copy = negation<
288
- std::is_same<decltype(std::declval<Vector>()[typename Vector::size_type()]), typename Vector::value_type &>>;
289
-
290
- // The usual case: access and iterate by reference
291
- template <typename Vector, typename Class_>
292
- void vector_accessor(enable_if_t<!vector_needs_copy<Vector>::value, Class_> &cl) {
293
- using T = typename Vector::value_type;
294
- using SizeType = typename Vector::size_type;
295
- using DiffType = typename Vector::difference_type;
296
- using ItType = typename Vector::iterator;
297
-
298
- auto wrap_i = [](DiffType i, SizeType n) {
299
- if (i < 0)
300
- i += n;
301
- if (i < 0 || (SizeType)i >= n)
302
- throw index_error();
303
- return i;
304
- };
305
-
306
- cl.def("__getitem__",
307
- [wrap_i](Vector &v, DiffType i) -> T & {
308
- i = wrap_i(i, v.size());
309
- return v[(SizeType)i];
310
- },
311
- return_value_policy::reference_internal // ref + keepalive
312
- );
313
-
314
- cl.def("__iter__",
315
- [](Vector &v) {
316
- return make_iterator<
317
- return_value_policy::reference_internal, ItType, ItType, T&>(
318
- v.begin(), v.end());
319
- },
320
- keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
321
- );
322
- }
323
-
324
- // The case for special objects, like std::vector<bool>, that have to be returned-by-copy:
325
- template <typename Vector, typename Class_>
326
- void vector_accessor(enable_if_t<vector_needs_copy<Vector>::value, Class_> &cl) {
327
- using T = typename Vector::value_type;
328
- using SizeType = typename Vector::size_type;
329
- using DiffType = typename Vector::difference_type;
330
- using ItType = typename Vector::iterator;
331
- cl.def("__getitem__",
332
- [](const Vector &v, DiffType i) -> T {
333
- if (i < 0 && (i += v.size()) < 0)
334
- throw index_error();
335
- if ((SizeType)i >= v.size())
336
- throw index_error();
337
- return v[(SizeType)i];
338
- }
339
- );
340
-
341
- cl.def("__iter__",
342
- [](Vector &v) {
343
- return make_iterator<
344
- return_value_policy::copy, ItType, ItType, T>(
345
- v.begin(), v.end());
346
- },
347
- keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
348
- );
349
- }
350
-
351
- template <typename Vector, typename Class_> auto vector_if_insertion_operator(Class_ &cl, std::string const &name)
352
- -> decltype(std::declval<std::ostream&>() << std::declval<typename Vector::value_type>(), void()) {
353
- using size_type = typename Vector::size_type;
354
-
355
- cl.def("__repr__",
356
- [name](Vector &v) {
357
- std::ostringstream s;
358
- s << name << '[';
359
- for (size_type i=0; i < v.size(); ++i) {
360
- s << v[i];
361
- if (i != v.size() - 1)
362
- s << ", ";
363
- }
364
- s << ']';
365
- return s.str();
366
- },
367
- "Return the canonical string representation of this list."
368
- );
369
- }
370
-
371
- // Provide the buffer interface for vectors if we have data() and we have a format for it
372
- // GCC seems to have "void std::vector<bool>::data()" - doing SFINAE on the existence of data() is insufficient, we need to check it returns an appropriate pointer
373
- template <typename Vector, typename = void>
374
- struct vector_has_data_and_format : std::false_type {};
375
- template <typename Vector>
376
- struct vector_has_data_and_format<Vector, enable_if_t<std::is_same<decltype(format_descriptor<typename Vector::value_type>::format(), std::declval<Vector>().data()), typename Vector::value_type*>::value>> : std::true_type {};
377
-
378
- // [workaround(intel)] Separate function required here
379
- // Workaround as the Intel compiler does not compile the enable_if_t part below
380
- // (tested with icc (ICC) 2021.1 Beta 20200827)
381
- template <typename... Args>
382
- constexpr bool args_any_are_buffer() {
383
- return detail::any_of<std::is_same<Args, buffer_protocol>...>::value;
384
- }
385
-
386
- // [workaround(intel)] Separate function required here
387
- // [workaround(msvc)] Can't use constexpr bool in return type
388
-
389
- // Add the buffer interface to a vector
390
- template <typename Vector, typename Class_, typename... Args>
391
- void vector_buffer_impl(Class_& cl, std::true_type) {
392
- using T = typename Vector::value_type;
393
-
394
- static_assert(vector_has_data_and_format<Vector>::value, "There is not an appropriate format descriptor for this vector");
395
-
396
- // numpy.h declares this for arbitrary types, but it may raise an exception and crash hard at runtime if PYBIND11_NUMPY_DTYPE hasn't been called, so check here
397
- format_descriptor<T>::format();
398
-
399
- cl.def_buffer([](Vector& v) -> buffer_info {
400
- return buffer_info(v.data(), static_cast<ssize_t>(sizeof(T)), format_descriptor<T>::format(), 1, {v.size()}, {sizeof(T)});
401
- });
402
-
403
- cl.def(init([](const buffer &buf) {
404
- auto info = buf.request();
405
- if (info.ndim != 1 || info.strides[0] % static_cast<ssize_t>(sizeof(T)))
406
- throw type_error("Only valid 1D buffers can be copied to a vector");
407
- if (!detail::compare_buffer_info<T>::compare(info) || (ssize_t) sizeof(T) != info.itemsize)
408
- throw type_error("Format mismatch (Python: " + info.format + " C++: " + format_descriptor<T>::format() + ")");
409
-
410
- T *p = static_cast<T*>(info.ptr);
411
- ssize_t step = info.strides[0] / static_cast<ssize_t>(sizeof(T));
412
- T *end = p + info.shape[0] * step;
413
- if (step == 1) {
414
- return Vector(p, end);
415
- }
416
- Vector vec;
417
- vec.reserve((size_t) info.shape[0]);
418
- for (; p != end; p += step)
419
- vec.push_back(*p);
420
- return vec;
421
-
422
- }));
423
-
424
- return;
425
- }
426
-
427
- template <typename Vector, typename Class_, typename... Args>
428
- void vector_buffer_impl(Class_&, std::false_type) {}
429
-
430
- template <typename Vector, typename Class_, typename... Args>
431
- void vector_buffer(Class_& cl) {
432
- vector_buffer_impl<Vector, Class_, Args...>(cl, detail::any_of<std::is_same<Args, buffer_protocol>...>{});
433
- }
434
-
435
- PYBIND11_NAMESPACE_END(detail)
436
-
437
- //
438
- // std::vector
439
- //
440
- template <typename Vector, typename holder_type = std::unique_ptr<Vector>, typename... Args>
441
- class_<Vector, holder_type> bind_vector(handle scope, std::string const &name, Args&&... args) {
442
- using Class_ = class_<Vector, holder_type>;
443
-
444
- // If the value_type is unregistered (e.g. a converting type) or is itself registered
445
- // module-local then make the vector binding module-local as well:
446
- using vtype = typename Vector::value_type;
447
- auto vtype_info = detail::get_type_info(typeid(vtype));
448
- bool local = !vtype_info || vtype_info->module_local;
449
-
450
- Class_ cl(scope, name.c_str(), pybind11::module_local(local), std::forward<Args>(args)...);
451
-
452
- // Declare the buffer interface if a buffer_protocol() is passed in
453
- detail::vector_buffer<Vector, Class_, Args...>(cl);
454
-
455
- cl.def(init<>());
456
-
457
- // Register copy constructor (if possible)
458
- detail::vector_if_copy_constructible<Vector, Class_>(cl);
459
-
460
- // Register comparison-related operators and functions (if possible)
461
- detail::vector_if_equal_operator<Vector, Class_>(cl);
462
-
463
- // Register stream insertion operator (if possible)
464
- detail::vector_if_insertion_operator<Vector, Class_>(cl, name);
465
-
466
- // Modifiers require copyable vector value type
467
- detail::vector_modifiers<Vector, Class_>(cl);
468
-
469
- // Accessor and iterator; return by value if copyable, otherwise we return by ref + keep-alive
470
- detail::vector_accessor<Vector, Class_>(cl);
471
-
472
- cl.def("__bool__",
473
- [](const Vector &v) -> bool {
474
- return !v.empty();
475
- },
476
- "Check whether the list is nonempty"
477
- );
478
-
479
- cl.def("__len__", &Vector::size);
480
-
481
-
482
-
483
-
484
- #if 0
485
- // C++ style functions deprecated, leaving it here as an example
486
- cl.def(init<size_type>());
487
-
488
- cl.def("resize",
489
- (void (Vector::*) (size_type count)) & Vector::resize,
490
- "changes the number of elements stored");
491
-
492
- cl.def("erase",
493
- [](Vector &v, SizeType i) {
494
- if (i >= v.size())
495
- throw index_error();
496
- v.erase(v.begin() + i);
497
- }, "erases element at index ``i``");
498
-
499
- cl.def("empty", &Vector::empty, "checks whether the container is empty");
500
- cl.def("size", &Vector::size, "returns the number of elements");
501
- cl.def("push_back", (void (Vector::*)(const T&)) &Vector::push_back, "adds an element to the end");
502
- cl.def("pop_back", &Vector::pop_back, "removes the last element");
503
-
504
- cl.def("max_size", &Vector::max_size, "returns the maximum possible number of elements");
505
- cl.def("reserve", &Vector::reserve, "reserves storage");
506
- cl.def("capacity", &Vector::capacity, "returns the number of elements that can be held in currently allocated storage");
507
- cl.def("shrink_to_fit", &Vector::shrink_to_fit, "reduces memory usage by freeing unused memory");
508
-
509
- cl.def("clear", &Vector::clear, "clears the contents");
510
- cl.def("swap", &Vector::swap, "swaps the contents");
511
-
512
- cl.def("front", [](Vector &v) {
513
- if (v.size()) return v.front();
514
- else throw index_error();
515
- }, "access the first element");
516
-
517
- cl.def("back", [](Vector &v) {
518
- if (v.size()) return v.back();
519
- else throw index_error();
520
- }, "access the last element ");
521
-
522
- #endif
523
-
524
- return cl;
525
- }
526
-
527
-
528
-
529
- //
530
- // std::map, std::unordered_map
531
- //
532
-
533
- PYBIND11_NAMESPACE_BEGIN(detail)
534
-
535
- /* Fallback functions */
536
- template <typename, typename, typename... Args> void map_if_insertion_operator(const Args &...) { }
537
- template <typename, typename, typename... Args> void map_assignment(const Args &...) { }
538
-
539
- // Map assignment when copy-assignable: just copy the value
540
- template <typename Map, typename Class_>
541
- void map_assignment(enable_if_t<is_copy_assignable<typename Map::mapped_type>::value, Class_> &cl) {
542
- using KeyType = typename Map::key_type;
543
- using MappedType = typename Map::mapped_type;
544
-
545
- cl.def("__setitem__",
546
- [](Map &m, const KeyType &k, const MappedType &v) {
547
- auto it = m.find(k);
548
- if (it != m.end()) it->second = v;
549
- else m.emplace(k, v);
550
- }
551
- );
552
- }
553
-
554
- // Not copy-assignable, but still copy-constructible: we can update the value by erasing and reinserting
555
- template<typename Map, typename Class_>
556
- void map_assignment(enable_if_t<
557
- !is_copy_assignable<typename Map::mapped_type>::value &&
558
- is_copy_constructible<typename Map::mapped_type>::value,
559
- Class_> &cl) {
560
- using KeyType = typename Map::key_type;
561
- using MappedType = typename Map::mapped_type;
562
-
563
- cl.def("__setitem__",
564
- [](Map &m, const KeyType &k, const MappedType &v) {
565
- // We can't use m[k] = v; because value type might not be default constructable
566
- auto r = m.emplace(k, v);
567
- if (!r.second) {
568
- // value type is not copy assignable so the only way to insert it is to erase it first...
569
- m.erase(r.first);
570
- m.emplace(k, v);
571
- }
572
- }
573
- );
574
- }
575
-
576
-
577
- template <typename Map, typename Class_> auto map_if_insertion_operator(Class_ &cl, std::string const &name)
578
- -> decltype(std::declval<std::ostream&>() << std::declval<typename Map::key_type>() << std::declval<typename Map::mapped_type>(), void()) {
579
-
580
- cl.def("__repr__",
581
- [name](Map &m) {
582
- std::ostringstream s;
583
- s << name << '{';
584
- bool f = false;
585
- for (auto const &kv : m) {
586
- if (f)
587
- s << ", ";
588
- s << kv.first << ": " << kv.second;
589
- f = true;
590
- }
591
- s << '}';
592
- return s.str();
593
- },
594
- "Return the canonical string representation of this map."
595
- );
596
- }
597
-
598
- template<typename Map>
599
- struct keys_view
600
- {
601
- Map &map;
602
- };
603
-
604
- template<typename Map>
605
- struct values_view
606
- {
607
- Map &map;
608
- };
609
-
610
- template<typename Map>
611
- struct items_view
612
- {
613
- Map &map;
614
- };
615
-
616
- PYBIND11_NAMESPACE_END(detail)
617
-
618
- template <typename Map, typename holder_type = std::unique_ptr<Map>, typename... Args>
619
- class_<Map, holder_type> bind_map(handle scope, const std::string &name, Args&&... args) {
620
- using KeyType = typename Map::key_type;
621
- using MappedType = typename Map::mapped_type;
622
- using KeysView = detail::keys_view<Map>;
623
- using ValuesView = detail::values_view<Map>;
624
- using ItemsView = detail::items_view<Map>;
625
- using Class_ = class_<Map, holder_type>;
626
-
627
- // If either type is a non-module-local bound type then make the map binding non-local as well;
628
- // otherwise (e.g. both types are either module-local or converting) the map will be
629
- // module-local.
630
- auto tinfo = detail::get_type_info(typeid(MappedType));
631
- bool local = !tinfo || tinfo->module_local;
632
- if (local) {
633
- tinfo = detail::get_type_info(typeid(KeyType));
634
- local = !tinfo || tinfo->module_local;
635
- }
636
-
637
- Class_ cl(scope, name.c_str(), pybind11::module_local(local), std::forward<Args>(args)...);
638
- class_<KeysView> keys_view(
639
- scope, ("KeysView[" + name + "]").c_str(), pybind11::module_local(local));
640
- class_<ValuesView> values_view(
641
- scope, ("ValuesView[" + name + "]").c_str(), pybind11::module_local(local));
642
- class_<ItemsView> items_view(
643
- scope, ("ItemsView[" + name + "]").c_str(), pybind11::module_local(local));
644
-
645
- cl.def(init<>());
646
-
647
- // Register stream insertion operator (if possible)
648
- detail::map_if_insertion_operator<Map, Class_>(cl, name);
649
-
650
- cl.def("__bool__",
651
- [](const Map &m) -> bool { return !m.empty(); },
652
- "Check whether the map is nonempty"
653
- );
654
-
655
- cl.def("__iter__",
656
- [](Map &m) { return make_key_iterator(m.begin(), m.end()); },
657
- keep_alive<0, 1>() /* Essential: keep map alive while iterator exists */
658
- );
659
-
660
- cl.def("keys",
661
- [](Map &m) { return KeysView{m}; },
662
- keep_alive<0, 1>() /* Essential: keep map alive while view exists */
663
- );
664
-
665
- cl.def("values",
666
- [](Map &m) { return ValuesView{m}; },
667
- keep_alive<0, 1>() /* Essential: keep map alive while view exists */
668
- );
669
-
670
- cl.def("items",
671
- [](Map &m) { return ItemsView{m}; },
672
- keep_alive<0, 1>() /* Essential: keep map alive while view exists */
673
- );
674
-
675
- cl.def("__getitem__",
676
- [](Map &m, const KeyType &k) -> MappedType & {
677
- auto it = m.find(k);
678
- if (it == m.end())
679
- throw key_error();
680
- return it->second;
681
- },
682
- return_value_policy::reference_internal // ref + keepalive
683
- );
684
-
685
- cl.def("__contains__",
686
- [](Map &m, const KeyType &k) -> bool {
687
- auto it = m.find(k);
688
- if (it == m.end())
689
- return false;
690
- return true;
691
- }
692
- );
693
- // Fallback for when the object is not of the key type
694
- cl.def("__contains__", [](Map &, const object &) -> bool { return false; });
695
-
696
- // Assignment provided only if the type is copyable
697
- detail::map_assignment<Map, Class_>(cl);
698
-
699
- cl.def("__delitem__",
700
- [](Map &m, const KeyType &k) {
701
- auto it = m.find(k);
702
- if (it == m.end())
703
- throw key_error();
704
- m.erase(it);
705
- }
706
- );
707
-
708
- cl.def("__len__", &Map::size);
709
-
710
- keys_view.def("__len__", [](KeysView &view) { return view.map.size(); });
711
- keys_view.def("__iter__",
712
- [](KeysView &view) {
713
- return make_key_iterator(view.map.begin(), view.map.end());
714
- },
715
- keep_alive<0, 1>() /* Essential: keep view alive while iterator exists */
716
- );
717
- keys_view.def("__contains__",
718
- [](KeysView &view, const KeyType &k) -> bool {
719
- auto it = view.map.find(k);
720
- if (it == view.map.end())
721
- return false;
722
- return true;
723
- }
724
- );
725
- // Fallback for when the object is not of the key type
726
- keys_view.def("__contains__", [](KeysView &, const object &) -> bool { return false; });
727
-
728
- values_view.def("__len__", [](ValuesView &view) { return view.map.size(); });
729
- values_view.def("__iter__",
730
- [](ValuesView &view) {
731
- return make_value_iterator(view.map.begin(), view.map.end());
732
- },
733
- keep_alive<0, 1>() /* Essential: keep view alive while iterator exists */
734
- );
735
-
736
- items_view.def("__len__", [](ItemsView &view) { return view.map.size(); });
737
- items_view.def("__iter__",
738
- [](ItemsView &view) {
739
- return make_iterator(view.map.begin(), view.map.end());
740
- },
741
- keep_alive<0, 1>() /* Essential: keep view alive while iterator exists */
742
- );
743
-
744
- return cl;
745
- }
746
-
747
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)