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,267 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- from pybind11_tests import numpy_vectorize as m
5
-
6
- np = pytest.importorskip("numpy")
7
-
8
-
9
- def test_vectorize(capture):
10
- assert np.isclose(m.vectorized_func3(np.array(3 + 7j)), [6 + 14j])
11
-
12
- for f in [m.vectorized_func, m.vectorized_func2]:
13
- with capture:
14
- assert np.isclose(f(1, 2, 3), 6)
15
- assert capture == "my_func(x:int=1, y:float=2, z:float=3)"
16
- with capture:
17
- assert np.isclose(f(np.array(1), np.array(2), 3), 6)
18
- assert capture == "my_func(x:int=1, y:float=2, z:float=3)"
19
- with capture:
20
- assert np.allclose(f(np.array([1, 3]), np.array([2, 4]), 3), [6, 36])
21
- assert (
22
- capture
23
- == """
24
- my_func(x:int=1, y:float=2, z:float=3)
25
- my_func(x:int=3, y:float=4, z:float=3)
26
- """
27
- )
28
- with capture:
29
- a = np.array([[1, 2], [3, 4]], order="F")
30
- b = np.array([[10, 20], [30, 40]], order="F")
31
- c = 3
32
- result = f(a, b, c)
33
- assert np.allclose(result, a * b * c)
34
- assert result.flags.f_contiguous
35
- # All inputs are F order and full or singletons, so we the result is in col-major order:
36
- assert (
37
- capture
38
- == """
39
- my_func(x:int=1, y:float=10, z:float=3)
40
- my_func(x:int=3, y:float=30, z:float=3)
41
- my_func(x:int=2, y:float=20, z:float=3)
42
- my_func(x:int=4, y:float=40, z:float=3)
43
- """
44
- )
45
- with capture:
46
- a, b, c = (
47
- np.array([[1, 3, 5], [7, 9, 11]]),
48
- np.array([[2, 4, 6], [8, 10, 12]]),
49
- 3,
50
- )
51
- assert np.allclose(f(a, b, c), a * b * c)
52
- assert (
53
- capture
54
- == """
55
- my_func(x:int=1, y:float=2, z:float=3)
56
- my_func(x:int=3, y:float=4, z:float=3)
57
- my_func(x:int=5, y:float=6, z:float=3)
58
- my_func(x:int=7, y:float=8, z:float=3)
59
- my_func(x:int=9, y:float=10, z:float=3)
60
- my_func(x:int=11, y:float=12, z:float=3)
61
- """
62
- )
63
- with capture:
64
- a, b, c = np.array([[1, 2, 3], [4, 5, 6]]), np.array([2, 3, 4]), 2
65
- assert np.allclose(f(a, b, c), a * b * c)
66
- assert (
67
- capture
68
- == """
69
- my_func(x:int=1, y:float=2, z:float=2)
70
- my_func(x:int=2, y:float=3, z:float=2)
71
- my_func(x:int=3, y:float=4, z:float=2)
72
- my_func(x:int=4, y:float=2, z:float=2)
73
- my_func(x:int=5, y:float=3, z:float=2)
74
- my_func(x:int=6, y:float=4, z:float=2)
75
- """
76
- )
77
- with capture:
78
- a, b, c = np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2
79
- assert np.allclose(f(a, b, c), a * b * c)
80
- assert (
81
- capture
82
- == """
83
- my_func(x:int=1, y:float=2, z:float=2)
84
- my_func(x:int=2, y:float=2, z:float=2)
85
- my_func(x:int=3, y:float=2, z:float=2)
86
- my_func(x:int=4, y:float=3, z:float=2)
87
- my_func(x:int=5, y:float=3, z:float=2)
88
- my_func(x:int=6, y:float=3, z:float=2)
89
- """
90
- )
91
- with capture:
92
- a, b, c = (
93
- np.array([[1, 2, 3], [4, 5, 6]], order="F"),
94
- np.array([[2], [3]]),
95
- 2,
96
- )
97
- assert np.allclose(f(a, b, c), a * b * c)
98
- assert (
99
- capture
100
- == """
101
- my_func(x:int=1, y:float=2, z:float=2)
102
- my_func(x:int=2, y:float=2, z:float=2)
103
- my_func(x:int=3, y:float=2, z:float=2)
104
- my_func(x:int=4, y:float=3, z:float=2)
105
- my_func(x:int=5, y:float=3, z:float=2)
106
- my_func(x:int=6, y:float=3, z:float=2)
107
- """
108
- )
109
- with capture:
110
- a, b, c = np.array([[1, 2, 3], [4, 5, 6]])[::, ::2], np.array([[2], [3]]), 2
111
- assert np.allclose(f(a, b, c), a * b * c)
112
- assert (
113
- capture
114
- == """
115
- my_func(x:int=1, y:float=2, z:float=2)
116
- my_func(x:int=3, y:float=2, z:float=2)
117
- my_func(x:int=4, y:float=3, z:float=2)
118
- my_func(x:int=6, y:float=3, z:float=2)
119
- """
120
- )
121
- with capture:
122
- a, b, c = (
123
- np.array([[1, 2, 3], [4, 5, 6]], order="F")[::, ::2],
124
- np.array([[2], [3]]),
125
- 2,
126
- )
127
- assert np.allclose(f(a, b, c), a * b * c)
128
- assert (
129
- capture
130
- == """
131
- my_func(x:int=1, y:float=2, z:float=2)
132
- my_func(x:int=3, y:float=2, z:float=2)
133
- my_func(x:int=4, y:float=3, z:float=2)
134
- my_func(x:int=6, y:float=3, z:float=2)
135
- """
136
- )
137
-
138
-
139
- def test_type_selection():
140
- assert m.selective_func(np.array([1], dtype=np.int32)) == "Int branch taken."
141
- assert m.selective_func(np.array([1.0], dtype=np.float32)) == "Float branch taken."
142
- assert (
143
- m.selective_func(np.array([1.0j], dtype=np.complex64))
144
- == "Complex float branch taken."
145
- )
146
-
147
-
148
- def test_docs(doc):
149
- assert (
150
- doc(m.vectorized_func)
151
- == """
152
- vectorized_func(arg0: numpy.ndarray[numpy.int32], arg1: numpy.ndarray[numpy.float32], arg2: numpy.ndarray[numpy.float64]) -> object
153
- """ # noqa: E501 line too long
154
- )
155
-
156
-
157
- def test_trivial_broadcasting():
158
- trivial, vectorized_is_trivial = m.trivial, m.vectorized_is_trivial
159
-
160
- assert vectorized_is_trivial(1, 2, 3) == trivial.c_trivial
161
- assert vectorized_is_trivial(np.array(1), np.array(2), 3) == trivial.c_trivial
162
- assert (
163
- vectorized_is_trivial(np.array([1, 3]), np.array([2, 4]), 3)
164
- == trivial.c_trivial
165
- )
166
- assert trivial.c_trivial == vectorized_is_trivial(
167
- np.array([[1, 3, 5], [7, 9, 11]]), np.array([[2, 4, 6], [8, 10, 12]]), 3
168
- )
169
- assert (
170
- vectorized_is_trivial(np.array([[1, 2, 3], [4, 5, 6]]), np.array([2, 3, 4]), 2)
171
- == trivial.non_trivial
172
- )
173
- assert (
174
- vectorized_is_trivial(np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2)
175
- == trivial.non_trivial
176
- )
177
- z1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]], dtype="int32")
178
- z2 = np.array(z1, dtype="float32")
179
- z3 = np.array(z1, dtype="float64")
180
- assert vectorized_is_trivial(z1, z2, z3) == trivial.c_trivial
181
- assert vectorized_is_trivial(1, z2, z3) == trivial.c_trivial
182
- assert vectorized_is_trivial(z1, 1, z3) == trivial.c_trivial
183
- assert vectorized_is_trivial(z1, z2, 1) == trivial.c_trivial
184
- assert vectorized_is_trivial(z1[::2, ::2], 1, 1) == trivial.non_trivial
185
- assert vectorized_is_trivial(1, 1, z1[::2, ::2]) == trivial.c_trivial
186
- assert vectorized_is_trivial(1, 1, z3[::2, ::2]) == trivial.non_trivial
187
- assert vectorized_is_trivial(z1, 1, z3[1::4, 1::4]) == trivial.c_trivial
188
-
189
- y1 = np.array(z1, order="F")
190
- y2 = np.array(y1)
191
- y3 = np.array(y1)
192
- assert vectorized_is_trivial(y1, y2, y3) == trivial.f_trivial
193
- assert vectorized_is_trivial(y1, 1, 1) == trivial.f_trivial
194
- assert vectorized_is_trivial(1, y2, 1) == trivial.f_trivial
195
- assert vectorized_is_trivial(1, 1, y3) == trivial.f_trivial
196
- assert vectorized_is_trivial(y1, z2, 1) == trivial.non_trivial
197
- assert vectorized_is_trivial(z1[1::4, 1::4], y2, 1) == trivial.f_trivial
198
- assert vectorized_is_trivial(y1[1::4, 1::4], z2, 1) == trivial.c_trivial
199
-
200
- assert m.vectorized_func(z1, z2, z3).flags.c_contiguous
201
- assert m.vectorized_func(y1, y2, y3).flags.f_contiguous
202
- assert m.vectorized_func(z1, 1, 1).flags.c_contiguous
203
- assert m.vectorized_func(1, y2, 1).flags.f_contiguous
204
- assert m.vectorized_func(z1[1::4, 1::4], y2, 1).flags.f_contiguous
205
- assert m.vectorized_func(y1[1::4, 1::4], z2, 1).flags.c_contiguous
206
-
207
-
208
- def test_passthrough_arguments(doc):
209
- assert doc(m.vec_passthrough) == (
210
- "vec_passthrough("
211
- + ", ".join(
212
- [
213
- "arg0: float",
214
- "arg1: numpy.ndarray[numpy.float64]",
215
- "arg2: numpy.ndarray[numpy.float64]",
216
- "arg3: numpy.ndarray[numpy.int32]",
217
- "arg4: int",
218
- "arg5: m.numpy_vectorize.NonPODClass",
219
- "arg6: numpy.ndarray[numpy.float64]",
220
- ]
221
- )
222
- + ") -> object"
223
- )
224
-
225
- b = np.array([[10, 20, 30]], dtype="float64")
226
- c = np.array([100, 200]) # NOT a vectorized argument
227
- d = np.array([[1000], [2000], [3000]], dtype="int")
228
- g = np.array([[1000000, 2000000, 3000000]], dtype="int") # requires casting
229
- assert np.all(
230
- m.vec_passthrough(1, b, c, d, 10000, m.NonPODClass(100000), g)
231
- == np.array(
232
- [
233
- [1111111, 2111121, 3111131],
234
- [1112111, 2112121, 3112131],
235
- [1113111, 2113121, 3113131],
236
- ]
237
- )
238
- )
239
-
240
-
241
- def test_method_vectorization():
242
- o = m.VectorizeTestClass(3)
243
- x = np.array([1, 2], dtype="int")
244
- y = np.array([[10], [20]], dtype="float32")
245
- assert np.all(o.method(x, y) == [[14, 15], [24, 25]])
246
-
247
-
248
- def test_array_collapse():
249
- assert not isinstance(m.vectorized_func(1, 2, 3), np.ndarray)
250
- assert not isinstance(m.vectorized_func(np.array(1), 2, 3), np.ndarray)
251
- z = m.vectorized_func([1], 2, 3)
252
- assert isinstance(z, np.ndarray)
253
- assert z.shape == (1,)
254
- z = m.vectorized_func(1, [[[2]]], 3)
255
- assert isinstance(z, np.ndarray)
256
- assert z.shape == (1, 1, 1)
257
-
258
-
259
- def test_vectorized_noreturn():
260
- x = m.NonPODClass(0)
261
- assert x.value == 0
262
- m.add_to(x, [1, 2, 3, 4])
263
- assert x.value == 10
264
- m.add_to(x, 1)
265
- assert x.value == 11
266
- m.add_to(x, [[1, 1], [2, 3]])
267
- assert x.value == 18
@@ -1,73 +0,0 @@
1
- /*
2
- tests/test_opaque_types.cpp -- opaque types, passing void pointers
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include <pybind11/stl.h>
12
- #include <vector>
13
-
14
- // IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures
15
- //
16
- // This also deliberately doesn't use the below StringList type alias to test
17
- // that MAKE_OPAQUE can handle a type containing a `,`. (The `std::allocator`
18
- // bit is just the default `std::vector` allocator).
19
- PYBIND11_MAKE_OPAQUE(std::vector<std::string, std::allocator<std::string>>);
20
-
21
- using StringList = std::vector<std::string, std::allocator<std::string>>;
22
-
23
- TEST_SUBMODULE(opaque_types, m) {
24
- // test_string_list
25
- py::class_<StringList>(m, "StringList")
26
- .def(py::init<>())
27
- .def("pop_back", &StringList::pop_back)
28
- /* There are multiple versions of push_back(), etc. Select the right ones. */
29
- .def("push_back", (void (StringList::*)(const std::string &)) &StringList::push_back)
30
- .def("back", (std::string &(StringList::*)()) &StringList::back)
31
- .def("__len__", [](const StringList &v) { return v.size(); })
32
- .def("__iter__", [](StringList &v) {
33
- return py::make_iterator(v.begin(), v.end());
34
- }, py::keep_alive<0, 1>());
35
-
36
- class ClassWithSTLVecProperty {
37
- public:
38
- StringList stringList;
39
- };
40
- py::class_<ClassWithSTLVecProperty>(m, "ClassWithSTLVecProperty")
41
- .def(py::init<>())
42
- .def_readwrite("stringList", &ClassWithSTLVecProperty::stringList);
43
-
44
- m.def("print_opaque_list", [](const StringList &l) {
45
- std::string ret = "Opaque list: [";
46
- bool first = true;
47
- for (const auto &entry : l) {
48
- if (!first)
49
- ret += ", ";
50
- ret += entry;
51
- first = false;
52
- }
53
- return ret + "]";
54
- });
55
-
56
- // test_pointers
57
- m.def("return_void_ptr", []() { return (void *) 0x1234; });
58
- m.def("get_void_ptr_value", [](void *ptr) { return reinterpret_cast<std::intptr_t>(ptr); });
59
- m.def("return_null_str", []() { return (char *) nullptr; });
60
- m.def("get_null_str_value", [](char *ptr) { return reinterpret_cast<std::intptr_t>(ptr); });
61
-
62
- m.def("return_unique_ptr", []() -> std::unique_ptr<StringList> {
63
- auto *result = new StringList();
64
- result->push_back("some value");
65
- return std::unique_ptr<StringList>(result);
66
- });
67
-
68
- // test unions
69
- py::class_<IntFloat>(m, "IntFloat")
70
- .def(py::init<>())
71
- .def_readwrite("i", &IntFloat::i)
72
- .def_readwrite("f", &IntFloat::f);
73
- }
@@ -1,59 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- from pybind11_tests import ConstructorStats, UserType
5
- from pybind11_tests import opaque_types as m
6
-
7
-
8
- def test_string_list():
9
- lst = m.StringList()
10
- lst.push_back("Element 1")
11
- lst.push_back("Element 2")
12
- assert m.print_opaque_list(lst) == "Opaque list: [Element 1, Element 2]"
13
- assert lst.back() == "Element 2"
14
-
15
- for i, k in enumerate(lst, start=1):
16
- assert k == "Element {}".format(i)
17
- lst.pop_back()
18
- assert m.print_opaque_list(lst) == "Opaque list: [Element 1]"
19
-
20
- cvp = m.ClassWithSTLVecProperty()
21
- assert m.print_opaque_list(cvp.stringList) == "Opaque list: []"
22
-
23
- cvp.stringList = lst
24
- cvp.stringList.push_back("Element 3")
25
- assert m.print_opaque_list(cvp.stringList) == "Opaque list: [Element 1, Element 3]"
26
-
27
-
28
- def test_pointers(msg):
29
- living_before = ConstructorStats.get(UserType).alive()
30
- assert m.get_void_ptr_value(m.return_void_ptr()) == 0x1234
31
- assert m.get_void_ptr_value(UserType()) # Should also work for other C++ types
32
- assert ConstructorStats.get(UserType).alive() == living_before
33
-
34
- with pytest.raises(TypeError) as excinfo:
35
- m.get_void_ptr_value([1, 2, 3]) # This should not work
36
- assert (
37
- msg(excinfo.value)
38
- == """
39
- get_void_ptr_value(): incompatible function arguments. The following argument types are supported:
40
- 1. (arg0: capsule) -> int
41
-
42
- Invoked with: [1, 2, 3]
43
- """ # noqa: E501 line too long
44
- )
45
-
46
- assert m.return_null_str() is None
47
- assert m.get_null_str_value(m.return_null_str()) is not None
48
-
49
- ptr = m.return_unique_ptr()
50
- assert "StringList" in repr(ptr)
51
- assert m.print_opaque_list(ptr) == "Opaque list: [some value]"
52
-
53
-
54
- def test_unions():
55
- int_float_union = m.IntFloat()
56
- int_float_union.i = 42
57
- assert int_float_union.i == 42
58
- int_float_union.f = 3.0
59
- assert int_float_union.f == 3.0
@@ -1,235 +0,0 @@
1
- /*
2
- tests/test_operator_overloading.cpp -- operator overloading
3
-
4
- Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
-
6
- All rights reserved. Use of this source code is governed by a
7
- BSD-style license that can be found in the LICENSE file.
8
- */
9
-
10
- #include "pybind11_tests.h"
11
- #include "constructor_stats.h"
12
- #include <pybind11/operators.h>
13
- #include <functional>
14
-
15
- class Vector2 {
16
- public:
17
- Vector2(float x, float y) : x(x), y(y) { print_created(this, toString()); }
18
- Vector2(const Vector2 &v) : x(v.x), y(v.y) { print_copy_created(this); }
19
- Vector2(Vector2 &&v) noexcept : x(v.x), y(v.y) {
20
- print_move_created(this);
21
- v.x = v.y = 0;
22
- }
23
- Vector2 &operator=(const Vector2 &v) { x = v.x; y = v.y; print_copy_assigned(this); return *this; }
24
- Vector2 &operator=(Vector2 &&v) noexcept {
25
- x = v.x;
26
- y = v.y;
27
- v.x = v.y = 0;
28
- print_move_assigned(this);
29
- return *this;
30
- }
31
- ~Vector2() { print_destroyed(this); }
32
-
33
- std::string toString() const { return "[" + std::to_string(x) + ", " + std::to_string(y) + "]"; }
34
-
35
- Vector2 operator-() const { return Vector2(-x, -y); }
36
- Vector2 operator+(const Vector2 &v) const { return Vector2(x + v.x, y + v.y); }
37
- Vector2 operator-(const Vector2 &v) const { return Vector2(x - v.x, y - v.y); }
38
- Vector2 operator-(float value) const { return Vector2(x - value, y - value); }
39
- Vector2 operator+(float value) const { return Vector2(x + value, y + value); }
40
- Vector2 operator*(float value) const { return Vector2(x * value, y * value); }
41
- Vector2 operator/(float value) const { return Vector2(x / value, y / value); }
42
- Vector2 operator*(const Vector2 &v) const { return Vector2(x * v.x, y * v.y); }
43
- Vector2 operator/(const Vector2 &v) const { return Vector2(x / v.x, y / v.y); }
44
- Vector2& operator+=(const Vector2 &v) { x += v.x; y += v.y; return *this; }
45
- Vector2& operator-=(const Vector2 &v) { x -= v.x; y -= v.y; return *this; }
46
- Vector2& operator*=(float v) { x *= v; y *= v; return *this; }
47
- Vector2& operator/=(float v) { x /= v; y /= v; return *this; }
48
- Vector2& operator*=(const Vector2 &v) { x *= v.x; y *= v.y; return *this; }
49
- Vector2& operator/=(const Vector2 &v) { x /= v.x; y /= v.y; return *this; }
50
-
51
- friend Vector2 operator+(float f, const Vector2 &v) { return Vector2(f + v.x, f + v.y); }
52
- friend Vector2 operator-(float f, const Vector2 &v) { return Vector2(f - v.x, f - v.y); }
53
- friend Vector2 operator*(float f, const Vector2 &v) { return Vector2(f * v.x, f * v.y); }
54
- friend Vector2 operator/(float f, const Vector2 &v) { return Vector2(f / v.x, f / v.y); }
55
-
56
- bool operator==(const Vector2 &v) const {
57
- return x == v.x && y == v.y;
58
- }
59
- bool operator!=(const Vector2 &v) const {
60
- return x != v.x || y != v.y;
61
- }
62
- private:
63
- float x, y;
64
- };
65
-
66
- class C1 { };
67
- class C2 { };
68
-
69
- int operator+(const C1 &, const C1 &) { return 11; }
70
- int operator+(const C2 &, const C2 &) { return 22; }
71
- int operator+(const C2 &, const C1 &) { return 21; }
72
- int operator+(const C1 &, const C2 &) { return 12; }
73
-
74
- // Note: Specializing explicit within `namespace std { ... }` is done due to a
75
- // bug in GCC<7. If you are supporting compilers later than this, consider
76
- // specializing `using template<> struct std::hash<...>` in the global
77
- // namespace instead, per this recommendation:
78
- // https://en.cppreference.com/w/cpp/language/extending_std#Adding_template_specializations
79
- namespace std {
80
- template<>
81
- struct hash<Vector2> {
82
- // Not a good hash function, but easy to test
83
- size_t operator()(const Vector2 &) { return 4; }
84
- };
85
- } // namespace std
86
-
87
- // Not a good abs function, but easy to test.
88
- std::string abs(const Vector2&) {
89
- return "abs(Vector2)";
90
- }
91
-
92
- // MSVC & Intel warns about unknown pragmas, and warnings are errors.
93
- #if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
94
- #pragma GCC diagnostic push
95
- // clang 7.0.0 and Apple LLVM 10.0.1 introduce `-Wself-assign-overloaded` to
96
- // `-Wall`, which is used here for overloading (e.g. `py::self += py::self `).
97
- // Here, we suppress the warning using `#pragma diagnostic`.
98
- // Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46
99
- // TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`).
100
- #if defined(__APPLE__) && defined(__clang__)
101
- #if (__clang_major__ >= 10)
102
- #pragma GCC diagnostic ignored "-Wself-assign-overloaded"
103
- #endif
104
- #elif defined(__clang__)
105
- #if (__clang_major__ >= 7)
106
- #pragma GCC diagnostic ignored "-Wself-assign-overloaded"
107
- #endif
108
- #endif
109
- #endif
110
-
111
- TEST_SUBMODULE(operators, m) {
112
-
113
- // test_operator_overloading
114
- py::class_<Vector2>(m, "Vector2")
115
- .def(py::init<float, float>())
116
- .def(py::self + py::self)
117
- .def(py::self + float())
118
- .def(py::self - py::self)
119
- .def(py::self - float())
120
- .def(py::self * float())
121
- .def(py::self / float())
122
- .def(py::self * py::self)
123
- .def(py::self / py::self)
124
- .def(py::self += py::self)
125
- .def(py::self -= py::self)
126
- .def(py::self *= float())
127
- .def(py::self /= float())
128
- .def(py::self *= py::self)
129
- .def(py::self /= py::self)
130
- .def(float() + py::self)
131
- .def(float() - py::self)
132
- .def(float() * py::self)
133
- .def(float() / py::self)
134
- .def(-py::self)
135
- .def("__str__", &Vector2::toString)
136
- .def("__repr__", &Vector2::toString)
137
- .def(py::self == py::self)
138
- .def(py::self != py::self)
139
- .def(py::hash(py::self))
140
- // N.B. See warning about usage of `py::detail::abs(py::self)` in
141
- // `operators.h`.
142
- .def("__abs__", [](const Vector2& v) { return abs(v); })
143
- ;
144
-
145
- m.attr("Vector") = m.attr("Vector2");
146
-
147
- // test_operators_notimplemented
148
- // #393: need to return NotSupported to ensure correct arithmetic operator behavior
149
- py::class_<C1>(m, "C1")
150
- .def(py::init<>())
151
- .def(py::self + py::self);
152
-
153
- py::class_<C2>(m, "C2")
154
- .def(py::init<>())
155
- .def(py::self + py::self)
156
- .def("__add__", [](const C2& c2, const C1& c1) { return c2 + c1; })
157
- .def("__radd__", [](const C2& c2, const C1& c1) { return c1 + c2; });
158
-
159
- // test_nested
160
- // #328: first member in a class can't be used in operators
161
- struct NestABase { int value = -2; };
162
- py::class_<NestABase>(m, "NestABase")
163
- .def(py::init<>())
164
- .def_readwrite("value", &NestABase::value);
165
-
166
- struct NestA : NestABase {
167
- int value = 3;
168
- NestA& operator+=(int i) { value += i; return *this; }
169
- };
170
- py::class_<NestA>(m, "NestA")
171
- .def(py::init<>())
172
- .def(py::self += int())
173
- .def("as_base", [](NestA &a) -> NestABase& {
174
- return (NestABase&) a;
175
- }, py::return_value_policy::reference_internal);
176
- m.def("get_NestA", [](const NestA &a) { return a.value; });
177
-
178
- struct NestB {
179
- NestA a;
180
- int value = 4;
181
- NestB& operator-=(int i) { value -= i; return *this; }
182
- };
183
- py::class_<NestB>(m, "NestB")
184
- .def(py::init<>())
185
- .def(py::self -= int())
186
- .def_readwrite("a", &NestB::a);
187
- m.def("get_NestB", [](const NestB &b) { return b.value; });
188
-
189
- struct NestC {
190
- NestB b;
191
- int value = 5;
192
- NestC& operator*=(int i) { value *= i; return *this; }
193
- };
194
- py::class_<NestC>(m, "NestC")
195
- .def(py::init<>())
196
- .def(py::self *= int())
197
- .def_readwrite("b", &NestC::b);
198
- m.def("get_NestC", [](const NestC &c) { return c.value; });
199
-
200
-
201
- // test_overriding_eq_reset_hash
202
- // #2191 Overriding __eq__ should set __hash__ to None
203
- struct Comparable {
204
- int value;
205
- bool operator==(const Comparable& rhs) const {return value == rhs.value;}
206
- };
207
-
208
- struct Hashable : Comparable {
209
- explicit Hashable(int value): Comparable{value}{};
210
- size_t hash() const { return static_cast<size_t>(value); }
211
- };
212
-
213
- struct Hashable2 : Hashable {
214
- using Hashable::Hashable;
215
- };
216
-
217
- py::class_<Comparable>(m, "Comparable")
218
- .def(py::init<int>())
219
- .def(py::self == py::self);
220
-
221
- py::class_<Hashable>(m, "Hashable")
222
- .def(py::init<int>())
223
- .def(py::self == py::self)
224
- .def("__hash__", &Hashable::hash);
225
-
226
- // define __hash__ before __eq__
227
- py::class_<Hashable2>(m, "Hashable2")
228
- .def("__hash__", &Hashable::hash)
229
- .def(py::init<int>())
230
- .def(py::self == py::self);
231
- }
232
-
233
- #if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
234
- #pragma GCC diagnostic pop
235
- #endif