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

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

Potentially problematic release.


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

Files changed (333) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/beam_elements/__init__.py +1 -0
  3. xcoll/beam_elements/absorber.py +12 -2
  4. xcoll/beam_elements/base.py +162 -62
  5. xcoll/beam_elements/blowup.py +1 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  7. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  8. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  9. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  10. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  11. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  12. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  13. xcoll/beam_elements/everest.py +16 -5
  14. xcoll/beam_elements/monitor.py +1 -0
  15. xcoll/beam_elements/transparent.py +83 -0
  16. xcoll/colldb.py +15 -6
  17. xcoll/general.py +1 -1
  18. xcoll/headers/particle_states.py +51 -0
  19. xcoll/initial_distribution.py +121 -91
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -73
  23. xcoll/lossmap.py +519 -127
  24. xcoll/plot.py +109 -0
  25. xcoll/rf_sweep.py +6 -0
  26. xcoll/scattering_routines/engine.py +414 -217
  27. xcoll/scattering_routines/environment.py +297 -0
  28. xcoll/scattering_routines/everest/amorphous.h +95 -71
  29. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  30. xcoll/scattering_routines/everest/constants.h +1 -1
  31. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  32. xcoll/scattering_routines/everest/everest.h +8 -3
  33. xcoll/scattering_routines/everest/everest.py +2 -1
  34. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  35. xcoll/scattering_routines/everest/jaw.h +19 -24
  36. xcoll/scattering_routines/everest/materials.py +2 -0
  37. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  38. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  39. xcoll/scattering_routines/everest/properties.h +3 -72
  40. xcoll/xaux.py +65 -109
  41. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
  42. xcoll-0.6.0.dist-info/RECORD +135 -0
  43. xcoll/_manager.py +0 -22
  44. xcoll/headers/particle_states.h +0 -25
  45. xcoll/install.py +0 -35
  46. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  47. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  48. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  49. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  50. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  51. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  52. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  53. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  54. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  55. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  289. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  290. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  304. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  330. xcoll-0.5.12.dist-info/RECORD +0 -415
  331. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.12.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,284 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- import env # noqa: F401
5
- from pybind11_tests import kwargs_and_defaults as m
6
-
7
-
8
- def test_function_signatures(doc):
9
- assert doc(m.kw_func0) == "kw_func0(arg0: int, arg1: int) -> str"
10
- assert doc(m.kw_func1) == "kw_func1(x: int, y: int) -> str"
11
- assert doc(m.kw_func2) == "kw_func2(x: int = 100, y: int = 200) -> str"
12
- assert doc(m.kw_func3) == "kw_func3(data: str = 'Hello world!') -> None"
13
- assert doc(m.kw_func4) == "kw_func4(myList: List[int] = [13, 17]) -> str"
14
- assert doc(m.kw_func_udl) == "kw_func_udl(x: int, y: int = 300) -> str"
15
- assert doc(m.kw_func_udl_z) == "kw_func_udl_z(x: int, y: int = 0) -> str"
16
- assert doc(m.args_function) == "args_function(*args) -> tuple"
17
- assert (
18
- doc(m.args_kwargs_function) == "args_kwargs_function(*args, **kwargs) -> tuple"
19
- )
20
- assert (
21
- doc(m.KWClass.foo0)
22
- == "foo0(self: m.kwargs_and_defaults.KWClass, arg0: int, arg1: float) -> None"
23
- )
24
- assert (
25
- doc(m.KWClass.foo1)
26
- == "foo1(self: m.kwargs_and_defaults.KWClass, x: int, y: float) -> None"
27
- )
28
-
29
-
30
- def test_named_arguments(msg):
31
- assert m.kw_func0(5, 10) == "x=5, y=10"
32
-
33
- assert m.kw_func1(5, 10) == "x=5, y=10"
34
- assert m.kw_func1(5, y=10) == "x=5, y=10"
35
- assert m.kw_func1(y=10, x=5) == "x=5, y=10"
36
-
37
- assert m.kw_func2() == "x=100, y=200"
38
- assert m.kw_func2(5) == "x=5, y=200"
39
- assert m.kw_func2(x=5) == "x=5, y=200"
40
- assert m.kw_func2(y=10) == "x=100, y=10"
41
- assert m.kw_func2(5, 10) == "x=5, y=10"
42
- assert m.kw_func2(x=5, y=10) == "x=5, y=10"
43
-
44
- with pytest.raises(TypeError) as excinfo:
45
- # noinspection PyArgumentList
46
- m.kw_func2(x=5, y=10, z=12)
47
- assert excinfo.match(
48
- r"(?s)^kw_func2\(\): incompatible.*Invoked with: kwargs: ((x=5|y=10|z=12)(, |$))"
49
- + "{3}$"
50
- )
51
-
52
- assert m.kw_func4() == "{13 17}"
53
- assert m.kw_func4(myList=[1, 2, 3]) == "{1 2 3}"
54
-
55
- assert m.kw_func_udl(x=5, y=10) == "x=5, y=10"
56
- assert m.kw_func_udl_z(x=5) == "x=5, y=0"
57
-
58
-
59
- def test_arg_and_kwargs():
60
- args = "arg1_value", "arg2_value", 3
61
- assert m.args_function(*args) == args
62
-
63
- args = "a1", "a2"
64
- kwargs = dict(arg3="a3", arg4=4)
65
- assert m.args_kwargs_function(*args, **kwargs) == (args, kwargs)
66
-
67
-
68
- def test_mixed_args_and_kwargs(msg):
69
- mpa = m.mixed_plus_args
70
- mpk = m.mixed_plus_kwargs
71
- mpak = m.mixed_plus_args_kwargs
72
- mpakd = m.mixed_plus_args_kwargs_defaults
73
-
74
- assert mpa(1, 2.5, 4, 99.5, None) == (1, 2.5, (4, 99.5, None))
75
- assert mpa(1, 2.5) == (1, 2.5, ())
76
- with pytest.raises(TypeError) as excinfo:
77
- assert mpa(1)
78
- assert (
79
- msg(excinfo.value)
80
- == """
81
- mixed_plus_args(): incompatible function arguments. The following argument types are supported:
82
- 1. (arg0: int, arg1: float, *args) -> tuple
83
-
84
- Invoked with: 1
85
- """ # noqa: E501 line too long
86
- )
87
- with pytest.raises(TypeError) as excinfo:
88
- assert mpa()
89
- assert (
90
- msg(excinfo.value)
91
- == """
92
- mixed_plus_args(): incompatible function arguments. The following argument types are supported:
93
- 1. (arg0: int, arg1: float, *args) -> tuple
94
-
95
- Invoked with:
96
- """ # noqa: E501 line too long
97
- )
98
-
99
- assert mpk(-2, 3.5, pi=3.14159, e=2.71828) == (
100
- -2,
101
- 3.5,
102
- {"e": 2.71828, "pi": 3.14159},
103
- )
104
- assert mpak(7, 7.7, 7.77, 7.777, 7.7777, minusseven=-7) == (
105
- 7,
106
- 7.7,
107
- (7.77, 7.777, 7.7777),
108
- {"minusseven": -7},
109
- )
110
- assert mpakd() == (1, 3.14159, (), {})
111
- assert mpakd(3) == (3, 3.14159, (), {})
112
- assert mpakd(j=2.71828) == (1, 2.71828, (), {})
113
- assert mpakd(k=42) == (1, 3.14159, (), {"k": 42})
114
- assert mpakd(1, 1, 2, 3, 5, 8, then=13, followedby=21) == (
115
- 1,
116
- 1,
117
- (2, 3, 5, 8),
118
- {"then": 13, "followedby": 21},
119
- )
120
- # Arguments specified both positionally and via kwargs should fail:
121
- with pytest.raises(TypeError) as excinfo:
122
- assert mpakd(1, i=1)
123
- assert (
124
- msg(excinfo.value)
125
- == """
126
- mixed_plus_args_kwargs_defaults(): incompatible function arguments. The following argument types are supported:
127
- 1. (i: int = 1, j: float = 3.14159, *args, **kwargs) -> tuple
128
-
129
- Invoked with: 1; kwargs: i=1
130
- """ # noqa: E501 line too long
131
- )
132
- with pytest.raises(TypeError) as excinfo:
133
- assert mpakd(1, 2, j=1)
134
- assert (
135
- msg(excinfo.value)
136
- == """
137
- mixed_plus_args_kwargs_defaults(): incompatible function arguments. The following argument types are supported:
138
- 1. (i: int = 1, j: float = 3.14159, *args, **kwargs) -> tuple
139
-
140
- Invoked with: 1, 2; kwargs: j=1
141
- """ # noqa: E501 line too long
142
- )
143
-
144
-
145
- def test_keyword_only_args(msg):
146
- assert m.kw_only_all(i=1, j=2) == (1, 2)
147
- assert m.kw_only_all(j=1, i=2) == (2, 1)
148
-
149
- with pytest.raises(TypeError) as excinfo:
150
- assert m.kw_only_all(i=1) == (1,)
151
- assert "incompatible function arguments" in str(excinfo.value)
152
-
153
- with pytest.raises(TypeError) as excinfo:
154
- assert m.kw_only_all(1, 2) == (1, 2)
155
- assert "incompatible function arguments" in str(excinfo.value)
156
-
157
- assert m.kw_only_some(1, k=3, j=2) == (1, 2, 3)
158
-
159
- assert m.kw_only_with_defaults(z=8) == (3, 4, 5, 8)
160
- assert m.kw_only_with_defaults(2, z=8) == (2, 4, 5, 8)
161
- assert m.kw_only_with_defaults(2, j=7, k=8, z=9) == (2, 7, 8, 9)
162
- assert m.kw_only_with_defaults(2, 7, z=9, k=8) == (2, 7, 8, 9)
163
-
164
- assert m.kw_only_mixed(1, j=2) == (1, 2)
165
- assert m.kw_only_mixed(j=2, i=3) == (3, 2)
166
- assert m.kw_only_mixed(i=2, j=3) == (2, 3)
167
-
168
- assert m.kw_only_plus_more(4, 5, k=6, extra=7) == (4, 5, 6, {"extra": 7})
169
- assert m.kw_only_plus_more(3, k=5, j=4, extra=6) == (3, 4, 5, {"extra": 6})
170
- assert m.kw_only_plus_more(2, k=3, extra=4) == (2, -1, 3, {"extra": 4})
171
-
172
- with pytest.raises(TypeError) as excinfo:
173
- assert m.kw_only_mixed(i=1) == (1,)
174
- assert "incompatible function arguments" in str(excinfo.value)
175
-
176
- with pytest.raises(RuntimeError) as excinfo:
177
- m.register_invalid_kw_only(m)
178
- assert (
179
- msg(excinfo.value)
180
- == """
181
- arg(): cannot specify an unnamed argument after an kw_only() annotation
182
- """
183
- )
184
-
185
-
186
- def test_positional_only_args(msg):
187
- assert m.pos_only_all(1, 2) == (1, 2)
188
- assert m.pos_only_all(2, 1) == (2, 1)
189
-
190
- with pytest.raises(TypeError) as excinfo:
191
- m.pos_only_all(i=1, j=2)
192
- assert "incompatible function arguments" in str(excinfo.value)
193
-
194
- assert m.pos_only_mix(1, 2) == (1, 2)
195
- assert m.pos_only_mix(2, j=1) == (2, 1)
196
-
197
- with pytest.raises(TypeError) as excinfo:
198
- m.pos_only_mix(i=1, j=2)
199
- assert "incompatible function arguments" in str(excinfo.value)
200
-
201
- assert m.pos_kw_only_mix(1, 2, k=3) == (1, 2, 3)
202
- assert m.pos_kw_only_mix(1, j=2, k=3) == (1, 2, 3)
203
-
204
- with pytest.raises(TypeError) as excinfo:
205
- m.pos_kw_only_mix(i=1, j=2, k=3)
206
- assert "incompatible function arguments" in str(excinfo.value)
207
-
208
- with pytest.raises(TypeError) as excinfo:
209
- m.pos_kw_only_mix(1, 2, 3)
210
- assert "incompatible function arguments" in str(excinfo.value)
211
-
212
- with pytest.raises(TypeError) as excinfo:
213
- m.pos_only_def_mix()
214
- assert "incompatible function arguments" in str(excinfo.value)
215
-
216
- assert m.pos_only_def_mix(1) == (1, 2, 3)
217
- assert m.pos_only_def_mix(1, 4) == (1, 4, 3)
218
- assert m.pos_only_def_mix(1, 4, 7) == (1, 4, 7)
219
- assert m.pos_only_def_mix(1, 4, k=7) == (1, 4, 7)
220
-
221
- with pytest.raises(TypeError) as excinfo:
222
- m.pos_only_def_mix(1, j=4)
223
- assert "incompatible function arguments" in str(excinfo.value)
224
-
225
-
226
- def test_signatures():
227
- assert "kw_only_all(*, i: int, j: int) -> tuple\n" == m.kw_only_all.__doc__
228
- assert "kw_only_mixed(i: int, *, j: int) -> tuple\n" == m.kw_only_mixed.__doc__
229
- assert "pos_only_all(i: int, j: int, /) -> tuple\n" == m.pos_only_all.__doc__
230
- assert "pos_only_mix(i: int, /, j: int) -> tuple\n" == m.pos_only_mix.__doc__
231
- assert (
232
- "pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple\n"
233
- == m.pos_kw_only_mix.__doc__
234
- )
235
-
236
-
237
- @pytest.mark.xfail("env.PYPY and env.PY2", reason="PyPy2 doesn't double count")
238
- def test_args_refcount():
239
- """Issue/PR #1216 - py::args elements get double-inc_ref()ed when combined with regular
240
- arguments"""
241
- refcount = m.arg_refcount_h
242
-
243
- myval = 54321
244
- expected = refcount(myval)
245
- assert m.arg_refcount_h(myval) == expected
246
- assert m.arg_refcount_o(myval) == expected + 1
247
- assert m.arg_refcount_h(myval) == expected
248
- assert refcount(myval) == expected
249
-
250
- assert m.mixed_plus_args(1, 2.0, "a", myval) == (1, 2.0, ("a", myval))
251
- assert refcount(myval) == expected
252
-
253
- assert m.mixed_plus_kwargs(3, 4.0, a=1, b=myval) == (3, 4.0, {"a": 1, "b": myval})
254
- assert refcount(myval) == expected
255
-
256
- assert m.args_function(-1, myval) == (-1, myval)
257
- assert refcount(myval) == expected
258
-
259
- assert m.mixed_plus_args_kwargs(5, 6.0, myval, a=myval) == (
260
- 5,
261
- 6.0,
262
- (myval,),
263
- {"a": myval},
264
- )
265
- assert refcount(myval) == expected
266
-
267
- assert m.args_kwargs_function(7, 8, myval, a=1, b=myval) == (
268
- (7, 8, myval),
269
- {"a": 1, "b": myval},
270
- )
271
- assert refcount(myval) == expected
272
-
273
- exp3 = refcount(myval, myval, myval)
274
- assert m.args_refcount(myval, myval, myval) == (exp3, exp3, exp3)
275
- assert refcount(myval) == expected
276
-
277
- # This function takes the first arg as a `py::object` and the rest as a `py::args`. Unlike the
278
- # previous case, when we have both positional and `py::args` we need to construct a new tuple
279
- # for the `py::args`; in the previous case, we could simply inc_ref and pass on Python's input
280
- # tuple without having to inc_ref the individual elements, but here we can't, hence the extra
281
- # refs.
282
- assert m.mixed_args_refcount(myval, myval, myval) == (exp3 + 3, exp3 + 3, exp3 + 3)
283
-
284
- assert m.class_default_argument() == "<class 'decimal.Decimal'>"
@@ -1,107 +0,0 @@
1
- /*
2
- tests/test_local_bindings.cpp -- tests the py::module_local class feature which makes a class
3
- binding local to the module in which it is defined.
4
-
5
- Copyright (c) 2017 Jason Rhinelander <jason@imaginary.ca>
6
-
7
- All rights reserved. Use of this source code is governed by a
8
- BSD-style license that can be found in the LICENSE file.
9
- */
10
-
11
- #include "pybind11_tests.h"
12
- #include "local_bindings.h"
13
-
14
- #include <pybind11/stl.h>
15
- #include <pybind11/stl_bind.h>
16
-
17
- #include <numeric>
18
- #include <utility>
19
-
20
- TEST_SUBMODULE(local_bindings, m) {
21
- // test_load_external
22
- m.def("load_external1", [](ExternalType1 &e) { return e.i; });
23
- m.def("load_external2", [](ExternalType2 &e) { return e.i; });
24
-
25
- // test_local_bindings
26
- // Register a class with py::module_local:
27
- bind_local<LocalType, -1>(m, "LocalType", py::module_local())
28
- .def("get3", [](LocalType &t) { return t.i + 3; })
29
- ;
30
-
31
- m.def("local_value", [](LocalType &l) { return l.i; });
32
-
33
- // test_nonlocal_failure
34
- // The main pybind11 test module is loaded first, so this registration will succeed (the second
35
- // one, in pybind11_cross_module_tests.cpp, is designed to fail):
36
- bind_local<NonLocalType, 0>(m, "NonLocalType")
37
- .def(py::init<int>())
38
- .def("get", [](LocalType &i) { return i.i; })
39
- ;
40
-
41
- // test_duplicate_local
42
- // py::module_local declarations should be visible across compilation units that get linked together;
43
- // this tries to register a duplicate local. It depends on a definition in test_class.cpp and
44
- // should raise a runtime error from the duplicate definition attempt. If test_class isn't
45
- // available it *also* throws a runtime error (with "test_class not enabled" as value).
46
- m.def("register_local_external", [m]() {
47
- auto main = py::module_::import("pybind11_tests");
48
- if (py::hasattr(main, "class_")) {
49
- bind_local<LocalExternal, 7>(m, "LocalExternal", py::module_local());
50
- }
51
- else throw std::runtime_error("test_class not enabled");
52
- });
53
-
54
- // test_stl_bind_local
55
- // stl_bind.h binders defaults to py::module_local if the types are local or converting:
56
- py::bind_vector<LocalVec>(m, "LocalVec");
57
- py::bind_map<LocalMap>(m, "LocalMap");
58
- // and global if the type (or one of the types, for the map) is global:
59
- py::bind_vector<NonLocalVec>(m, "NonLocalVec");
60
- py::bind_map<NonLocalMap>(m, "NonLocalMap");
61
-
62
- // test_stl_bind_global
63
- // They can, however, be overridden to global using `py::module_local(false)`:
64
- bind_local<NonLocal2, 10>(m, "NonLocal2");
65
- py::bind_vector<LocalVec2>(m, "LocalVec2", py::module_local());
66
- py::bind_map<NonLocalMap2>(m, "NonLocalMap2", py::module_local(false));
67
-
68
- // test_mixed_local_global
69
- // We try this both with the global type registered first and vice versa (the order shouldn't
70
- // matter).
71
- m.def("register_mixed_global", [m]() {
72
- bind_local<MixedGlobalLocal, 100>(m, "MixedGlobalLocal", py::module_local(false));
73
- });
74
- m.def("register_mixed_local", [m]() {
75
- bind_local<MixedLocalGlobal, 1000>(m, "MixedLocalGlobal", py::module_local());
76
- });
77
- m.def("get_mixed_gl", [](int i) { return MixedGlobalLocal(i); });
78
- m.def("get_mixed_lg", [](int i) { return MixedLocalGlobal(i); });
79
-
80
- // test_internal_locals_differ
81
- m.def("local_cpp_types_addr", []() { return (uintptr_t) &py::detail::get_local_internals().registered_types_cpp; });
82
-
83
- // test_stl_caster_vs_stl_bind
84
- m.def("load_vector_via_caster", [](std::vector<int> v) {
85
- return std::accumulate(v.begin(), v.end(), 0);
86
- });
87
-
88
- // test_cross_module_calls
89
- m.def("return_self", [](LocalVec *v) { return v; });
90
- m.def("return_copy", [](const LocalVec &v) { return LocalVec(v); });
91
-
92
- class Cat : public pets::Pet {
93
- public:
94
- explicit Cat(std::string name) : Pet(std::move(name)) {}
95
- };
96
- py::class_<pets::Pet>(m, "Pet", py::module_local())
97
- .def("get_name", &pets::Pet::name);
98
- // Binding for local extending class:
99
- py::class_<Cat, pets::Pet>(m, "Cat")
100
- .def(py::init<std::string>());
101
- m.def("pet_name", [](pets::Pet &p) { return p.name(); });
102
-
103
- py::class_<MixGL>(m, "MixGL").def(py::init<int>());
104
- m.def("get_gl_value", [](MixGL &o) { return o.i + 10; });
105
-
106
- py::class_<MixGL2>(m, "MixGL2").def(py::init<int>());
107
- }
@@ -1,257 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- import env # noqa: F401
5
- from pybind11_tests import local_bindings as m
6
-
7
-
8
- def test_load_external():
9
- """Load a `py::module_local` type that's only registered in an external module"""
10
- import pybind11_cross_module_tests as cm
11
-
12
- assert m.load_external1(cm.ExternalType1(11)) == 11
13
- assert m.load_external2(cm.ExternalType2(22)) == 22
14
-
15
- with pytest.raises(TypeError) as excinfo:
16
- assert m.load_external2(cm.ExternalType1(21)) == 21
17
- assert "incompatible function arguments" in str(excinfo.value)
18
-
19
- with pytest.raises(TypeError) as excinfo:
20
- assert m.load_external1(cm.ExternalType2(12)) == 12
21
- assert "incompatible function arguments" in str(excinfo.value)
22
-
23
-
24
- def test_local_bindings():
25
- """Tests that duplicate `py::module_local` class bindings work across modules"""
26
-
27
- # Make sure we can load the second module with the conflicting (but local) definition:
28
- import pybind11_cross_module_tests as cm
29
-
30
- i1 = m.LocalType(5)
31
- assert i1.get() == 4
32
- assert i1.get3() == 8
33
-
34
- i2 = cm.LocalType(10)
35
- assert i2.get() == 11
36
- assert i2.get2() == 12
37
-
38
- assert not hasattr(i1, "get2")
39
- assert not hasattr(i2, "get3")
40
-
41
- # Loading within the local module
42
- assert m.local_value(i1) == 5
43
- assert cm.local_value(i2) == 10
44
-
45
- # Cross-module loading works as well (on failure, the type loader looks for
46
- # external module-local converters):
47
- assert m.local_value(i2) == 10
48
- assert cm.local_value(i1) == 5
49
-
50
-
51
- def test_nonlocal_failure():
52
- """Tests that attempting to register a non-local type in multiple modules fails"""
53
- import pybind11_cross_module_tests as cm
54
-
55
- with pytest.raises(RuntimeError) as excinfo:
56
- cm.register_nonlocal()
57
- assert (
58
- str(excinfo.value) == 'generic_type: type "NonLocalType" is already registered!'
59
- )
60
-
61
-
62
- def test_duplicate_local():
63
- """Tests expected failure when registering a class twice with py::local in the same module"""
64
- with pytest.raises(RuntimeError) as excinfo:
65
- m.register_local_external()
66
- import pybind11_tests
67
-
68
- assert str(excinfo.value) == (
69
- 'generic_type: type "LocalExternal" is already registered!'
70
- if hasattr(pybind11_tests, "class_")
71
- else "test_class not enabled"
72
- )
73
-
74
-
75
- def test_stl_bind_local():
76
- import pybind11_cross_module_tests as cm
77
-
78
- v1, v2 = m.LocalVec(), cm.LocalVec()
79
- v1.append(m.LocalType(1))
80
- v1.append(m.LocalType(2))
81
- v2.append(cm.LocalType(1))
82
- v2.append(cm.LocalType(2))
83
-
84
- # Cross module value loading:
85
- v1.append(cm.LocalType(3))
86
- v2.append(m.LocalType(3))
87
-
88
- assert [i.get() for i in v1] == [0, 1, 2]
89
- assert [i.get() for i in v2] == [2, 3, 4]
90
-
91
- v3, v4 = m.NonLocalVec(), cm.NonLocalVec2()
92
- v3.append(m.NonLocalType(1))
93
- v3.append(m.NonLocalType(2))
94
- v4.append(m.NonLocal2(3))
95
- v4.append(m.NonLocal2(4))
96
-
97
- assert [i.get() for i in v3] == [1, 2]
98
- assert [i.get() for i in v4] == [13, 14]
99
-
100
- d1, d2 = m.LocalMap(), cm.LocalMap()
101
- d1["a"] = v1[0]
102
- d1["b"] = v1[1]
103
- d2["c"] = v2[0]
104
- d2["d"] = v2[1]
105
- assert {i: d1[i].get() for i in d1} == {"a": 0, "b": 1}
106
- assert {i: d2[i].get() for i in d2} == {"c": 2, "d": 3}
107
-
108
-
109
- def test_stl_bind_global():
110
- import pybind11_cross_module_tests as cm
111
-
112
- with pytest.raises(RuntimeError) as excinfo:
113
- cm.register_nonlocal_map()
114
- assert (
115
- str(excinfo.value) == 'generic_type: type "NonLocalMap" is already registered!'
116
- )
117
-
118
- with pytest.raises(RuntimeError) as excinfo:
119
- cm.register_nonlocal_vec()
120
- assert (
121
- str(excinfo.value) == 'generic_type: type "NonLocalVec" is already registered!'
122
- )
123
-
124
- with pytest.raises(RuntimeError) as excinfo:
125
- cm.register_nonlocal_map2()
126
- assert (
127
- str(excinfo.value) == 'generic_type: type "NonLocalMap2" is already registered!'
128
- )
129
-
130
-
131
- def test_mixed_local_global():
132
- """Local types take precedence over globally registered types: a module with a `module_local`
133
- type can be registered even if the type is already registered globally. With the module,
134
- casting will go to the local type; outside the module casting goes to the global type."""
135
- import pybind11_cross_module_tests as cm
136
-
137
- m.register_mixed_global()
138
- m.register_mixed_local()
139
-
140
- a = []
141
- a.append(m.MixedGlobalLocal(1))
142
- a.append(m.MixedLocalGlobal(2))
143
- a.append(m.get_mixed_gl(3))
144
- a.append(m.get_mixed_lg(4))
145
-
146
- assert [x.get() for x in a] == [101, 1002, 103, 1004]
147
-
148
- cm.register_mixed_global_local()
149
- cm.register_mixed_local_global()
150
- a.append(m.MixedGlobalLocal(5))
151
- a.append(m.MixedLocalGlobal(6))
152
- a.append(cm.MixedGlobalLocal(7))
153
- a.append(cm.MixedLocalGlobal(8))
154
- a.append(m.get_mixed_gl(9))
155
- a.append(m.get_mixed_lg(10))
156
- a.append(cm.get_mixed_gl(11))
157
- a.append(cm.get_mixed_lg(12))
158
-
159
- assert [x.get() for x in a] == [
160
- 101,
161
- 1002,
162
- 103,
163
- 1004,
164
- 105,
165
- 1006,
166
- 207,
167
- 2008,
168
- 109,
169
- 1010,
170
- 211,
171
- 2012,
172
- ]
173
-
174
-
175
- def test_internal_locals_differ():
176
- """Makes sure the internal local type map differs across the two modules"""
177
- import pybind11_cross_module_tests as cm
178
-
179
- assert m.local_cpp_types_addr() != cm.local_cpp_types_addr()
180
-
181
-
182
- @pytest.mark.xfail("env.PYPY and sys.pypy_version_info < (7, 3, 2)")
183
- def test_stl_caster_vs_stl_bind(msg):
184
- """One module uses a generic vector caster from `<pybind11/stl.h>` while the other
185
- exports `std::vector<int>` via `py:bind_vector` and `py::module_local`"""
186
- import pybind11_cross_module_tests as cm
187
-
188
- v1 = cm.VectorInt([1, 2, 3])
189
- assert m.load_vector_via_caster(v1) == 6
190
- assert cm.load_vector_via_binding(v1) == 6
191
-
192
- v2 = [1, 2, 3]
193
- assert m.load_vector_via_caster(v2) == 6
194
- with pytest.raises(TypeError) as excinfo:
195
- cm.load_vector_via_binding(v2)
196
- assert (
197
- msg(excinfo.value)
198
- == """
199
- load_vector_via_binding(): incompatible function arguments. The following argument types are supported:
200
- 1. (arg0: pybind11_cross_module_tests.VectorInt) -> int
201
-
202
- Invoked with: [1, 2, 3]
203
- """ # noqa: E501 line too long
204
- )
205
-
206
-
207
- def test_cross_module_calls():
208
- import pybind11_cross_module_tests as cm
209
-
210
- v1 = m.LocalVec()
211
- v1.append(m.LocalType(1))
212
- v2 = cm.LocalVec()
213
- v2.append(cm.LocalType(2))
214
-
215
- # Returning the self pointer should get picked up as returning an existing
216
- # instance (even when that instance is of a foreign, non-local type).
217
- assert m.return_self(v1) is v1
218
- assert cm.return_self(v2) is v2
219
- assert m.return_self(v2) is v2
220
- assert cm.return_self(v1) is v1
221
-
222
- assert m.LocalVec is not cm.LocalVec
223
- # Returning a copy, on the other hand, always goes to the local type,
224
- # regardless of where the source type came from.
225
- assert type(m.return_copy(v1)) is m.LocalVec
226
- assert type(m.return_copy(v2)) is m.LocalVec
227
- assert type(cm.return_copy(v1)) is cm.LocalVec
228
- assert type(cm.return_copy(v2)) is cm.LocalVec
229
-
230
- # Test the example given in the documentation (which also tests inheritance casting):
231
- mycat = m.Cat("Fluffy")
232
- mydog = cm.Dog("Rover")
233
- assert mycat.get_name() == "Fluffy"
234
- assert mydog.name() == "Rover"
235
- assert m.Cat.__base__.__name__ == "Pet"
236
- assert cm.Dog.__base__.__name__ == "Pet"
237
- assert m.Cat.__base__ is not cm.Dog.__base__
238
- assert m.pet_name(mycat) == "Fluffy"
239
- assert m.pet_name(mydog) == "Rover"
240
- assert cm.pet_name(mycat) == "Fluffy"
241
- assert cm.pet_name(mydog) == "Rover"
242
-
243
- assert m.MixGL is not cm.MixGL
244
- a = m.MixGL(1)
245
- b = cm.MixGL(2)
246
- assert m.get_gl_value(a) == 11
247
- assert m.get_gl_value(b) == 12
248
- assert cm.get_gl_value(a) == 101
249
- assert cm.get_gl_value(b) == 102
250
-
251
- c, d = m.MixGL2(3), cm.MixGL2(4)
252
- with pytest.raises(TypeError) as excinfo:
253
- m.get_gl_value(c)
254
- assert "incompatible function arguments" in str(excinfo.value)
255
- with pytest.raises(TypeError) as excinfo:
256
- m.get_gl_value(d)
257
- assert "incompatible function arguments" in str(excinfo.value)