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

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

Potentially problematic release.


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

Files changed (333) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/beam_elements/__init__.py +1 -0
  3. xcoll/beam_elements/absorber.py +12 -2
  4. xcoll/beam_elements/base.py +162 -62
  5. xcoll/beam_elements/blowup.py +1 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  7. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  8. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  9. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  10. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  11. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  12. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  13. xcoll/beam_elements/everest.py +16 -5
  14. xcoll/beam_elements/monitor.py +1 -0
  15. xcoll/beam_elements/transparent.py +83 -0
  16. xcoll/colldb.py +15 -6
  17. xcoll/general.py +1 -1
  18. xcoll/headers/particle_states.py +51 -0
  19. xcoll/initial_distribution.py +129 -103
  20. xcoll/interaction_record/interaction_record.py +2 -1
  21. xcoll/interaction_record/interaction_types.py +2 -2
  22. xcoll/line_tools.py +163 -74
  23. xcoll/lossmap.py +519 -127
  24. xcoll/plot.py +109 -0
  25. xcoll/rf_sweep.py +6 -0
  26. xcoll/scattering_routines/engine.py +600 -0
  27. xcoll/scattering_routines/environment.py +297 -0
  28. xcoll/scattering_routines/everest/amorphous.h +95 -71
  29. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  30. xcoll/scattering_routines/everest/constants.h +1 -1
  31. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  32. xcoll/scattering_routines/everest/everest.h +8 -3
  33. xcoll/scattering_routines/everest/everest.py +2 -1
  34. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  35. xcoll/scattering_routines/everest/jaw.h +19 -24
  36. xcoll/scattering_routines/everest/materials.py +2 -0
  37. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  38. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  39. xcoll/scattering_routines/everest/properties.h +4 -73
  40. xcoll/xaux.py +73 -0
  41. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
  42. xcoll-0.6.0.dist-info/RECORD +135 -0
  43. xcoll/_manager.py +0 -22
  44. xcoll/headers/particle_states.h +0 -25
  45. xcoll/install.py +0 -35
  46. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  47. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  48. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  49. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  50. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  51. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  52. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  53. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  54. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  55. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  289. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  290. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  304. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  330. xcoll-0.5.11.dist-info/RECORD +0 -413
  331. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
  332. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
  333. {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
@@ -1,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