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,524 +0,0 @@
1
- /*
2
- tests/test_numpy_dtypes.cpp -- Structured and compound NumPy dtypes
3
-
4
- Copyright (c) 2016 Ivan Smirnov
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/numpy.h>
12
-
13
- #ifdef __GNUC__
14
- #define PYBIND11_PACKED(cls) cls __attribute__((__packed__))
15
- #else
16
- #define PYBIND11_PACKED(cls) __pragma(pack(push, 1)) cls __pragma(pack(pop))
17
- #endif
18
-
19
- namespace py = pybind11;
20
-
21
- struct SimpleStruct {
22
- bool bool_;
23
- uint32_t uint_;
24
- float float_;
25
- long double ldbl_;
26
- };
27
-
28
- std::ostream& operator<<(std::ostream& os, const SimpleStruct& v) {
29
- return os << "s:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
30
- }
31
-
32
- struct SimpleStructReordered {
33
- bool bool_;
34
- float float_;
35
- uint32_t uint_;
36
- long double ldbl_;
37
- };
38
-
39
- PYBIND11_PACKED(struct PackedStruct {
40
- bool bool_;
41
- uint32_t uint_;
42
- float float_;
43
- long double ldbl_;
44
- });
45
-
46
- std::ostream& operator<<(std::ostream& os, const PackedStruct& v) {
47
- return os << "p:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
48
- }
49
-
50
- PYBIND11_PACKED(struct NestedStruct {
51
- SimpleStruct a;
52
- PackedStruct b;
53
- });
54
-
55
- std::ostream& operator<<(std::ostream& os, const NestedStruct& v) {
56
- return os << "n:a=" << v.a << ";b=" << v.b;
57
- }
58
-
59
- struct PartialStruct {
60
- bool bool_;
61
- uint32_t uint_;
62
- float float_;
63
- uint64_t dummy2;
64
- long double ldbl_;
65
- };
66
-
67
- struct PartialNestedStruct {
68
- uint64_t dummy1;
69
- PartialStruct a;
70
- uint64_t dummy2;
71
- };
72
-
73
- struct UnboundStruct { };
74
-
75
- struct StringStruct {
76
- char a[3];
77
- std::array<char, 3> b;
78
- };
79
-
80
- struct ComplexStruct {
81
- std::complex<float> cflt;
82
- std::complex<double> cdbl;
83
- };
84
-
85
- std::ostream& operator<<(std::ostream& os, const ComplexStruct& v) {
86
- return os << "c:" << v.cflt << "," << v.cdbl;
87
- }
88
-
89
- struct ArrayStruct {
90
- char a[3][4];
91
- int32_t b[2];
92
- std::array<uint8_t, 3> c;
93
- std::array<float, 2> d[4];
94
- };
95
-
96
- PYBIND11_PACKED(struct StructWithUglyNames {
97
- int8_t __x__;
98
- uint64_t __y__;
99
- });
100
-
101
- enum class E1 : int64_t { A = -1, B = 1 };
102
- enum E2 : uint8_t { X = 1, Y = 2 };
103
-
104
- PYBIND11_PACKED(struct EnumStruct {
105
- E1 e1;
106
- E2 e2;
107
- });
108
-
109
- std::ostream& operator<<(std::ostream& os, const StringStruct& v) {
110
- os << "a='";
111
- for (size_t i = 0; i < 3 && (v.a[i] != 0); i++)
112
- os << v.a[i];
113
- os << "',b='";
114
- for (size_t i = 0; i < 3 && (v.b[i] != 0); i++)
115
- os << v.b[i];
116
- return os << "'";
117
- }
118
-
119
- std::ostream& operator<<(std::ostream& os, const ArrayStruct& v) {
120
- os << "a={";
121
- for (int i = 0; i < 3; i++) {
122
- if (i > 0)
123
- os << ',';
124
- os << '{';
125
- for (int j = 0; j < 3; j++)
126
- os << v.a[i][j] << ',';
127
- os << v.a[i][3] << '}';
128
- }
129
- os << "},b={" << v.b[0] << ',' << v.b[1];
130
- os << "},c={" << int(v.c[0]) << ',' << int(v.c[1]) << ',' << int(v.c[2]);
131
- os << "},d={";
132
- for (int i = 0; i < 4; i++) {
133
- if (i > 0)
134
- os << ',';
135
- os << '{' << v.d[i][0] << ',' << v.d[i][1] << '}';
136
- }
137
- return os << '}';
138
- }
139
-
140
- std::ostream& operator<<(std::ostream& os, const EnumStruct& v) {
141
- return os << "e1=" << (v.e1 == E1::A ? "A" : "B") << ",e2=" << (v.e2 == E2::X ? "X" : "Y");
142
- }
143
-
144
- template <typename T>
145
- py::array mkarray_via_buffer(size_t n) {
146
- return py::array(py::buffer_info(nullptr, sizeof(T),
147
- py::format_descriptor<T>::format(),
148
- 1, { n }, { sizeof(T) }));
149
- }
150
-
151
- #define SET_TEST_VALS(s, i) \
152
- do { \
153
- (s).bool_ = (i) % 2 != 0; \
154
- (s).uint_ = (uint32_t) (i); \
155
- (s).float_ = (float) (i) *1.5f; \
156
- (s).ldbl_ = (long double) (i) * -2.5L; \
157
- } while (0)
158
-
159
- template <typename S>
160
- py::array_t<S, 0> create_recarray(size_t n) {
161
- auto arr = mkarray_via_buffer<S>(n);
162
- auto req = arr.request();
163
- auto ptr = static_cast<S*>(req.ptr);
164
- for (size_t i = 0; i < n; i++) {
165
- SET_TEST_VALS(ptr[i], i);
166
- }
167
- return arr;
168
- }
169
-
170
- template <typename S>
171
- py::list print_recarray(py::array_t<S, 0> arr) {
172
- const auto req = arr.request();
173
- const auto ptr = static_cast<S*>(req.ptr);
174
- auto l = py::list();
175
- for (py::ssize_t i = 0; i < req.size; i++) {
176
- std::stringstream ss;
177
- ss << ptr[i];
178
- l.append(py::str(ss.str()));
179
- }
180
- return l;
181
- }
182
-
183
- py::array_t<int32_t, 0> test_array_ctors(int i) {
184
- using arr_t = py::array_t<int32_t, 0>;
185
-
186
- std::vector<int32_t> data { 1, 2, 3, 4, 5, 6 };
187
- std::vector<py::ssize_t> shape { 3, 2 };
188
- std::vector<py::ssize_t> strides { 8, 4 };
189
-
190
- auto ptr = data.data();
191
- auto vptr = (void *) ptr;
192
- auto dtype = py::dtype("int32");
193
-
194
- py::buffer_info buf_ndim1(vptr, 4, "i", 6);
195
- py::buffer_info buf_ndim1_null(nullptr, 4, "i", 6);
196
- py::buffer_info buf_ndim2(vptr, 4, "i", 2, shape, strides);
197
- py::buffer_info buf_ndim2_null(nullptr, 4, "i", 2, shape, strides);
198
-
199
- auto fill = [](py::array arr) {
200
- auto req = arr.request();
201
- for (int i = 0; i < 6; i++) ((int32_t *) req.ptr)[i] = i + 1;
202
- return arr;
203
- };
204
-
205
- switch (i) {
206
- // shape: (3, 2)
207
- case 10: return arr_t(shape, strides, ptr);
208
- case 11: return py::array(shape, strides, ptr);
209
- case 12: return py::array(dtype, shape, strides, vptr);
210
- case 13: return arr_t(shape, ptr);
211
- case 14: return py::array(shape, ptr);
212
- case 15: return py::array(dtype, shape, vptr);
213
- case 16: return arr_t(buf_ndim2);
214
- case 17: return py::array(buf_ndim2);
215
- // shape: (3, 2) - post-fill
216
- case 20: return fill(arr_t(shape, strides));
217
- case 21: return py::array(shape, strides, ptr); // can't have nullptr due to templated ctor
218
- case 22: return fill(py::array(dtype, shape, strides));
219
- case 23: return fill(arr_t(shape));
220
- case 24: return py::array(shape, ptr); // can't have nullptr due to templated ctor
221
- case 25: return fill(py::array(dtype, shape));
222
- case 26: return fill(arr_t(buf_ndim2_null));
223
- case 27: return fill(py::array(buf_ndim2_null));
224
- // shape: (6, )
225
- case 30: return arr_t(6, ptr);
226
- case 31: return py::array(6, ptr);
227
- case 32: return py::array(dtype, 6, vptr);
228
- case 33: return arr_t(buf_ndim1);
229
- case 34: return py::array(buf_ndim1);
230
- // shape: (6, )
231
- case 40: return fill(arr_t(6));
232
- case 41: return py::array(6, ptr); // can't have nullptr due to templated ctor
233
- case 42: return fill(py::array(dtype, 6));
234
- case 43: return fill(arr_t(buf_ndim1_null));
235
- case 44: return fill(py::array(buf_ndim1_null));
236
- }
237
- return arr_t();
238
- }
239
-
240
- py::list test_dtype_ctors() {
241
- py::list list;
242
- list.append(py::dtype("int32"));
243
- list.append(py::dtype(std::string("float64")));
244
- list.append(py::dtype::from_args(py::str("bool")));
245
- py::list names, offsets, formats;
246
- py::dict dict;
247
- names.append(py::str("a")); names.append(py::str("b")); dict["names"] = names;
248
- offsets.append(py::int_(1)); offsets.append(py::int_(10)); dict["offsets"] = offsets;
249
- formats.append(py::dtype("int32")); formats.append(py::dtype("float64")); dict["formats"] = formats;
250
- dict["itemsize"] = py::int_(20);
251
- list.append(py::dtype::from_args(dict));
252
- list.append(py::dtype(names, formats, offsets, 20));
253
- list.append(py::dtype(py::buffer_info((void *) 0, sizeof(unsigned int), "I", 1)));
254
- list.append(py::dtype(py::buffer_info((void *) 0, 0, "T{i:a:f:b:}", 1)));
255
- return list;
256
- }
257
-
258
- struct A {};
259
- struct B {};
260
-
261
- TEST_SUBMODULE(numpy_dtypes, m) {
262
- try { py::module_::import("numpy"); }
263
- catch (...) { return; }
264
-
265
- // typeinfo may be registered before the dtype descriptor for scalar casts to work...
266
- py::class_<SimpleStruct>(m, "SimpleStruct")
267
- // Explicit construct to ensure zero-valued initialization.
268
- .def(py::init([]() { return SimpleStruct(); }))
269
- .def_readwrite("bool_", &SimpleStruct::bool_)
270
- .def_readwrite("uint_", &SimpleStruct::uint_)
271
- .def_readwrite("float_", &SimpleStruct::float_)
272
- .def_readwrite("ldbl_", &SimpleStruct::ldbl_)
273
- .def("astuple",
274
- [](const SimpleStruct &self) {
275
- return py::make_tuple(self.bool_, self.uint_, self.float_, self.ldbl_);
276
- })
277
- .def_static("fromtuple", [](const py::tuple &tup) {
278
- if (py::len(tup) != 4) {
279
- throw py::cast_error("Invalid size");
280
- }
281
- return SimpleStruct{
282
- tup[0].cast<bool>(),
283
- tup[1].cast<uint32_t>(),
284
- tup[2].cast<float>(),
285
- tup[3].cast<long double>()};
286
- });
287
-
288
- PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_);
289
- PYBIND11_NUMPY_DTYPE(SimpleStructReordered, bool_, uint_, float_, ldbl_);
290
- PYBIND11_NUMPY_DTYPE(PackedStruct, bool_, uint_, float_, ldbl_);
291
- PYBIND11_NUMPY_DTYPE(NestedStruct, a, b);
292
- PYBIND11_NUMPY_DTYPE(PartialStruct, bool_, uint_, float_, ldbl_);
293
- PYBIND11_NUMPY_DTYPE(PartialNestedStruct, a);
294
- PYBIND11_NUMPY_DTYPE(StringStruct, a, b);
295
- PYBIND11_NUMPY_DTYPE(ArrayStruct, a, b, c, d);
296
- PYBIND11_NUMPY_DTYPE(EnumStruct, e1, e2);
297
- PYBIND11_NUMPY_DTYPE(ComplexStruct, cflt, cdbl);
298
-
299
- // ... or after
300
- py::class_<PackedStruct>(m, "PackedStruct");
301
-
302
- PYBIND11_NUMPY_DTYPE_EX(StructWithUglyNames, __x__, "x", __y__, "y");
303
-
304
- // If uncommented, this should produce a static_assert failure telling the user that the struct
305
- // is not a POD type
306
- // struct NotPOD { std::string v; NotPOD() : v("hi") {}; };
307
- // PYBIND11_NUMPY_DTYPE(NotPOD, v);
308
-
309
- // Check that dtypes can be registered programmatically, both from
310
- // initializer lists of field descriptors and from other containers.
311
- py::detail::npy_format_descriptor<A>::register_dtype(
312
- {}
313
- );
314
- py::detail::npy_format_descriptor<B>::register_dtype(
315
- std::vector<py::detail::field_descriptor>{}
316
- );
317
-
318
- // test_recarray, test_scalar_conversion
319
- m.def("create_rec_simple", &create_recarray<SimpleStruct>);
320
- m.def("create_rec_packed", &create_recarray<PackedStruct>);
321
- m.def("create_rec_nested", [](size_t n) { // test_signature
322
- py::array_t<NestedStruct, 0> arr = mkarray_via_buffer<NestedStruct>(n);
323
- auto req = arr.request();
324
- auto ptr = static_cast<NestedStruct*>(req.ptr);
325
- for (size_t i = 0; i < n; i++) {
326
- SET_TEST_VALS(ptr[i].a, i);
327
- SET_TEST_VALS(ptr[i].b, i + 1);
328
- }
329
- return arr;
330
- });
331
- m.def("create_rec_partial", &create_recarray<PartialStruct>);
332
- m.def("create_rec_partial_nested", [](size_t n) {
333
- py::array_t<PartialNestedStruct, 0> arr = mkarray_via_buffer<PartialNestedStruct>(n);
334
- auto req = arr.request();
335
- auto ptr = static_cast<PartialNestedStruct*>(req.ptr);
336
- for (size_t i = 0; i < n; i++) {
337
- SET_TEST_VALS(ptr[i].a, i);
338
- }
339
- return arr;
340
- });
341
- m.def("print_rec_simple", &print_recarray<SimpleStruct>);
342
- m.def("print_rec_packed", &print_recarray<PackedStruct>);
343
- m.def("print_rec_nested", &print_recarray<NestedStruct>);
344
-
345
- // test_format_descriptors
346
- m.def("get_format_unbound", []() { return py::format_descriptor<UnboundStruct>::format(); });
347
- m.def("print_format_descriptors", []() {
348
- py::list l;
349
- for (const auto &fmt : {
350
- py::format_descriptor<SimpleStruct>::format(),
351
- py::format_descriptor<PackedStruct>::format(),
352
- py::format_descriptor<NestedStruct>::format(),
353
- py::format_descriptor<PartialStruct>::format(),
354
- py::format_descriptor<PartialNestedStruct>::format(),
355
- py::format_descriptor<StringStruct>::format(),
356
- py::format_descriptor<ArrayStruct>::format(),
357
- py::format_descriptor<EnumStruct>::format(),
358
- py::format_descriptor<ComplexStruct>::format()
359
- }) {
360
- l.append(py::cast(fmt));
361
- }
362
- return l;
363
- });
364
-
365
- // test_dtype
366
- std::vector<const char *> dtype_names{
367
- "byte", "short", "intc", "int_", "longlong",
368
- "ubyte", "ushort", "uintc", "uint", "ulonglong",
369
- "half", "single", "double", "longdouble",
370
- "csingle", "cdouble", "clongdouble",
371
- "bool_", "datetime64", "timedelta64", "object_"
372
- };
373
-
374
- m.def("print_dtypes", []() {
375
- py::list l;
376
- for (const py::handle &d : {
377
- py::dtype::of<SimpleStruct>(),
378
- py::dtype::of<PackedStruct>(),
379
- py::dtype::of<NestedStruct>(),
380
- py::dtype::of<PartialStruct>(),
381
- py::dtype::of<PartialNestedStruct>(),
382
- py::dtype::of<StringStruct>(),
383
- py::dtype::of<ArrayStruct>(),
384
- py::dtype::of<EnumStruct>(),
385
- py::dtype::of<StructWithUglyNames>(),
386
- py::dtype::of<ComplexStruct>()
387
- })
388
- l.append(py::str(d));
389
- return l;
390
- });
391
- m.def("test_dtype_ctors", &test_dtype_ctors);
392
- m.def("test_dtype_kind", [dtype_names]() {
393
- py::list list;
394
- for (auto& dt_name : dtype_names)
395
- list.append(py::dtype(dt_name).kind());
396
- return list;
397
- });
398
- m.def("test_dtype_char_", [dtype_names]() {
399
- py::list list;
400
- for (auto& dt_name : dtype_names)
401
- list.append(py::dtype(dt_name).char_());
402
- return list;
403
- });
404
- m.def("test_dtype_methods", []() {
405
- py::list list;
406
- auto dt1 = py::dtype::of<int32_t>();
407
- auto dt2 = py::dtype::of<SimpleStruct>();
408
- list.append(dt1); list.append(dt2);
409
- list.append(py::bool_(dt1.has_fields())); list.append(py::bool_(dt2.has_fields()));
410
- list.append(py::int_(dt1.itemsize())); list.append(py::int_(dt2.itemsize()));
411
- return list;
412
- });
413
- struct TrailingPaddingStruct {
414
- int32_t a;
415
- char b;
416
- };
417
- PYBIND11_NUMPY_DTYPE(TrailingPaddingStruct, a, b);
418
- m.def("trailing_padding_dtype", []() { return py::dtype::of<TrailingPaddingStruct>(); });
419
-
420
- // test_string_array
421
- m.def("create_string_array", [](bool non_empty) {
422
- py::array_t<StringStruct, 0> arr = mkarray_via_buffer<StringStruct>(non_empty ? 4 : 0);
423
- if (non_empty) {
424
- auto req = arr.request();
425
- auto ptr = static_cast<StringStruct*>(req.ptr);
426
- for (py::ssize_t i = 0; i < req.size * req.itemsize; i++)
427
- static_cast<char*>(req.ptr)[i] = 0;
428
- ptr[1].a[0] = 'a'; ptr[1].b[0] = 'a';
429
- ptr[2].a[0] = 'a'; ptr[2].b[0] = 'a';
430
- ptr[3].a[0] = 'a'; ptr[3].b[0] = 'a';
431
-
432
- ptr[2].a[1] = 'b'; ptr[2].b[1] = 'b';
433
- ptr[3].a[1] = 'b'; ptr[3].b[1] = 'b';
434
-
435
- ptr[3].a[2] = 'c'; ptr[3].b[2] = 'c';
436
- }
437
- return arr;
438
- });
439
- m.def("print_string_array", &print_recarray<StringStruct>);
440
-
441
- // test_array_array
442
- m.def("create_array_array", [](size_t n) {
443
- py::array_t<ArrayStruct, 0> arr = mkarray_via_buffer<ArrayStruct>(n);
444
- auto ptr = (ArrayStruct *) arr.mutable_data();
445
- for (size_t i = 0; i < n; i++) {
446
- for (size_t j = 0; j < 3; j++)
447
- for (size_t k = 0; k < 4; k++)
448
- ptr[i].a[j][k] = char('A' + (i * 100 + j * 10 + k) % 26);
449
- for (size_t j = 0; j < 2; j++)
450
- ptr[i].b[j] = int32_t(i * 1000 + j);
451
- for (size_t j = 0; j < 3; j++)
452
- ptr[i].c[j] = uint8_t(i * 10 + j);
453
- for (size_t j = 0; j < 4; j++)
454
- for (size_t k = 0; k < 2; k++)
455
- ptr[i].d[j][k] = float(i) * 100.0f + float(j) * 10.0f + float(k);
456
- }
457
- return arr;
458
- });
459
- m.def("print_array_array", &print_recarray<ArrayStruct>);
460
-
461
- // test_enum_array
462
- m.def("create_enum_array", [](size_t n) {
463
- py::array_t<EnumStruct, 0> arr = mkarray_via_buffer<EnumStruct>(n);
464
- auto ptr = (EnumStruct *) arr.mutable_data();
465
- for (size_t i = 0; i < n; i++) {
466
- ptr[i].e1 = static_cast<E1>(-1 + ((int) i % 2) * 2);
467
- ptr[i].e2 = static_cast<E2>(1 + (i % 2));
468
- }
469
- return arr;
470
- });
471
- m.def("print_enum_array", &print_recarray<EnumStruct>);
472
-
473
- // test_complex_array
474
- m.def("create_complex_array", [](size_t n) {
475
- py::array_t<ComplexStruct, 0> arr = mkarray_via_buffer<ComplexStruct>(n);
476
- auto ptr = (ComplexStruct *) arr.mutable_data();
477
- for (size_t i = 0; i < n; i++) {
478
- ptr[i].cflt.real(float(i));
479
- ptr[i].cflt.imag(float(i) + 0.25f);
480
- ptr[i].cdbl.real(double(i) + 0.5);
481
- ptr[i].cdbl.imag(double(i) + 0.75);
482
- }
483
- return arr;
484
- });
485
- m.def("print_complex_array", &print_recarray<ComplexStruct>);
486
-
487
- // test_array_constructors
488
- m.def("test_array_ctors", &test_array_ctors);
489
-
490
- // test_compare_buffer_info
491
- struct CompareStruct {
492
- bool x;
493
- uint32_t y;
494
- float z;
495
- };
496
- PYBIND11_NUMPY_DTYPE(CompareStruct, x, y, z);
497
- m.def("compare_buffer_info", []() {
498
- py::list list;
499
- list.append(py::bool_(py::detail::compare_buffer_info<float>::compare(py::buffer_info(nullptr, sizeof(float), "f", 1))));
500
- list.append(py::bool_(py::detail::compare_buffer_info<unsigned>::compare(py::buffer_info(nullptr, sizeof(int), "I", 1))));
501
- list.append(py::bool_(py::detail::compare_buffer_info<long>::compare(py::buffer_info(nullptr, sizeof(long), "l", 1))));
502
- list.append(py::bool_(py::detail::compare_buffer_info<long>::compare(py::buffer_info(nullptr, sizeof(long), sizeof(long) == sizeof(int) ? "i" : "q", 1))));
503
- list.append(py::bool_(py::detail::compare_buffer_info<CompareStruct>::compare(py::buffer_info(nullptr, sizeof(CompareStruct), "T{?:x:3xI:y:f:z:}", 1))));
504
- return list;
505
- });
506
- m.def("buffer_to_dtype", [](py::buffer& buf) { return py::dtype(buf.request()); });
507
-
508
- // test_scalar_conversion
509
- auto f_simple = [](SimpleStruct s) { return s.uint_ * 10; };
510
- m.def("f_simple", f_simple);
511
- m.def("f_packed", [](PackedStruct s) { return s.uint_ * 10; });
512
- m.def("f_nested", [](NestedStruct s) { return s.a.uint_ * 10; });
513
-
514
- // test_vectorize
515
- m.def("f_simple_vectorized", py::vectorize(f_simple));
516
- auto f_simple_pass_thru = [](SimpleStruct s) { return s; };
517
- m.def("f_simple_pass_thru_vectorized", py::vectorize(f_simple_pass_thru));
518
-
519
- // test_register_dtype
520
- m.def("register_dtype", []() { PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_); });
521
-
522
- // test_str_leak
523
- m.def("dtype_wrapper", [](py::object d) { return py::dtype::from_args(std::move(d)); });
524
- }