xcoll 0.5.12__py3-none-any.whl → 0.6.1__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 (336) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/__init__.py.orig +26 -0
  3. xcoll/beam_elements/__init__.py +1 -0
  4. xcoll/beam_elements/absorber.py +12 -2
  5. xcoll/beam_elements/base.py +162 -62
  6. xcoll/beam_elements/blowup.py +1 -0
  7. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  8. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  9. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  10. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  11. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  12. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  13. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  14. xcoll/beam_elements/everest.py +16 -5
  15. xcoll/beam_elements/monitor.py +1 -0
  16. xcoll/beam_elements/transparent.py +83 -0
  17. xcoll/colldb.py +15 -6
  18. xcoll/general.py +1 -1
  19. xcoll/general.py.orig +20 -0
  20. xcoll/headers/particle_states.py +51 -0
  21. xcoll/initial_distribution.py +121 -91
  22. xcoll/initial_distribution.py.orig +256 -0
  23. xcoll/interaction_record/interaction_record.py +2 -1
  24. xcoll/interaction_record/interaction_types.py +2 -2
  25. xcoll/line_tools.py +163 -73
  26. xcoll/lossmap.py +519 -127
  27. xcoll/plot.py +109 -0
  28. xcoll/rf_sweep.py +6 -0
  29. xcoll/scattering_routines/engine.py +414 -217
  30. xcoll/scattering_routines/environment.py +297 -0
  31. xcoll/scattering_routines/everest/amorphous.h +95 -71
  32. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  33. xcoll/scattering_routines/everest/constants.h +1 -1
  34. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  35. xcoll/scattering_routines/everest/everest.h +8 -3
  36. xcoll/scattering_routines/everest/everest.py +2 -1
  37. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  38. xcoll/scattering_routines/everest/jaw.h +19 -24
  39. xcoll/scattering_routines/everest/materials.py +2 -0
  40. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  41. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  42. xcoll/scattering_routines/everest/properties.h +3 -72
  43. xcoll/xaux.py +65 -109
  44. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/METADATA +5 -5
  45. xcoll-0.6.1.dist-info/RECORD +138 -0
  46. xcoll/_manager.py +0 -22
  47. xcoll/headers/particle_states.h +0 -25
  48. xcoll/install.py +0 -35
  49. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  50. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  51. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  52. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  53. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  54. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  55. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  56. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  57. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  58. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  289. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  290. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  291. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  292. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  293. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  304. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  305. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  306. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  307. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  317. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  318. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  319. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  330. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  331. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  332. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  333. xcoll-0.5.12.dist-info/RECORD +0 -415
  334. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/LICENSE +0 -0
  335. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/NOTICE +0 -0
  336. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/WHEEL +0 -0
@@ -1,55 +0,0 @@
1
- /*
2
- pybind11/detail/typeid.h: Compiler-independent access to type identifiers
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
- #pragma once
11
-
12
- #include <cstdio>
13
- #include <cstdlib>
14
-
15
- #if defined(__GNUG__)
16
- #include <cxxabi.h>
17
- #endif
18
-
19
- #include "common.h"
20
-
21
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
22
- PYBIND11_NAMESPACE_BEGIN(detail)
23
- /// Erase all occurrences of a substring
24
- inline void erase_all(std::string &string, const std::string &search) {
25
- for (size_t pos = 0;;) {
26
- pos = string.find(search, pos);
27
- if (pos == std::string::npos) break;
28
- string.erase(pos, search.length());
29
- }
30
- }
31
-
32
- PYBIND11_NOINLINE void clean_type_id(std::string &name) {
33
- #if defined(__GNUG__)
34
- int status = 0;
35
- std::unique_ptr<char, void (*)(void *)> res {
36
- abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free };
37
- if (status == 0)
38
- name = res.get();
39
- #else
40
- detail::erase_all(name, "class ");
41
- detail::erase_all(name, "struct ");
42
- detail::erase_all(name, "enum ");
43
- #endif
44
- detail::erase_all(name, "pybind11::");
45
- }
46
- PYBIND11_NAMESPACE_END(detail)
47
-
48
- /// Return a string representation of a C++ type
49
- template <typename T> static std::string type_id() {
50
- std::string name(typeid(T).name());
51
- detail::clean_type_id(name);
52
- return name;
53
- }
54
-
55
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -1,606 +0,0 @@
1
- /*
2
- pybind11/eigen.h: Transparent conversion for dense and sparse Eigen matrices
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
- #pragma once
11
-
12
- /* HINT: To suppress warnings originating from the Eigen headers, use -isystem.
13
- See also:
14
- https://stackoverflow.com/questions/2579576/i-dir-vs-isystem-dir
15
- https://stackoverflow.com/questions/1741816/isystem-for-ms-visual-studio-c-compiler
16
- */
17
-
18
- #include "numpy.h"
19
-
20
- // The C4127 suppression was introduced for Eigen 3.4.0. In theory we could
21
- // make it version specific, or even remove it later, but considering that
22
- // 1. C4127 is generally far more distracting than useful for modern template code, and
23
- // 2. we definitely want to ignore any MSVC warnings originating from Eigen code,
24
- // it is probably best to keep this around indefinitely.
25
- #if defined(_MSC_VER)
26
- # pragma warning(push)
27
- # pragma warning(disable: 4127) // C4127: conditional expression is constant
28
- #endif
29
-
30
- #include <Eigen/Core>
31
- #include <Eigen/SparseCore>
32
-
33
- #if defined(_MSC_VER)
34
- # pragma warning(pop)
35
- #endif
36
-
37
- // Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit
38
- // move constructors that break things. We could detect this an explicitly copy, but an extra copy
39
- // of matrices seems highly undesirable.
40
- static_assert(EIGEN_VERSION_AT_LEAST(3,2,7), "Eigen support in pybind11 requires Eigen >= 3.2.7");
41
-
42
- PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
43
-
44
- // Provide a convenience alias for easier pass-by-ref usage with fully dynamic strides:
45
- using EigenDStride = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
46
- template <typename MatrixType> using EigenDRef = Eigen::Ref<MatrixType, 0, EigenDStride>;
47
- template <typename MatrixType> using EigenDMap = Eigen::Map<MatrixType, 0, EigenDStride>;
48
-
49
- PYBIND11_NAMESPACE_BEGIN(detail)
50
-
51
- #if EIGEN_VERSION_AT_LEAST(3,3,0)
52
- using EigenIndex = Eigen::Index;
53
- #else
54
- using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
55
- #endif
56
-
57
- // Matches Eigen::Map, Eigen::Ref, blocks, etc:
58
- template <typename T> using is_eigen_dense_map = all_of<is_template_base_of<Eigen::DenseBase, T>, std::is_base_of<Eigen::MapBase<T, Eigen::ReadOnlyAccessors>, T>>;
59
- template <typename T> using is_eigen_mutable_map = std::is_base_of<Eigen::MapBase<T, Eigen::WriteAccessors>, T>;
60
- template <typename T> using is_eigen_dense_plain = all_of<negation<is_eigen_dense_map<T>>, is_template_base_of<Eigen::PlainObjectBase, T>>;
61
- template <typename T> using is_eigen_sparse = is_template_base_of<Eigen::SparseMatrixBase, T>;
62
- // Test for objects inheriting from EigenBase<Derived> that aren't captured by the above. This
63
- // basically covers anything that can be assigned to a dense matrix but that don't have a typical
64
- // matrix data layout that can be copied from their .data(). For example, DiagonalMatrix and
65
- // SelfAdjointView fall into this category.
66
- template <typename T> using is_eigen_other = all_of<
67
- is_template_base_of<Eigen::EigenBase, T>,
68
- negation<any_of<is_eigen_dense_map<T>, is_eigen_dense_plain<T>, is_eigen_sparse<T>>>
69
- >;
70
-
71
- // Captures numpy/eigen conformability status (returned by EigenProps::conformable()):
72
- template <bool EigenRowMajor> struct EigenConformable {
73
- bool conformable = false;
74
- EigenIndex rows = 0, cols = 0;
75
- EigenDStride stride{0, 0}; // Only valid if negativestrides is false!
76
- bool negativestrides = false; // If true, do not use stride!
77
-
78
- // NOLINTNEXTLINE(google-explicit-constructor)
79
- EigenConformable(bool fits = false) : conformable{fits} {}
80
- // Matrix type:
81
- EigenConformable(EigenIndex r, EigenIndex c,
82
- EigenIndex rstride, EigenIndex cstride) :
83
- conformable{true}, rows{r}, cols{c} {
84
- // TODO: when Eigen bug #747 is fixed, remove the tests for non-negativity. http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747
85
- if (rstride < 0 || cstride < 0) {
86
- negativestrides = true;
87
- } else {
88
- stride = {EigenRowMajor ? rstride : cstride /* outer stride */,
89
- EigenRowMajor ? cstride : rstride /* inner stride */ };
90
- }
91
- }
92
- // Vector type:
93
- EigenConformable(EigenIndex r, EigenIndex c, EigenIndex stride)
94
- : EigenConformable(r, c, r == 1 ? c*stride : stride, c == 1 ? r : r*stride) {}
95
-
96
- template <typename props> bool stride_compatible() const {
97
- // To have compatible strides, we need (on both dimensions) one of fully dynamic strides,
98
- // matching strides, or a dimension size of 1 (in which case the stride value is irrelevant)
99
- return
100
- !negativestrides &&
101
- (props::inner_stride == Eigen::Dynamic || props::inner_stride == stride.inner() ||
102
- (EigenRowMajor ? cols : rows) == 1) &&
103
- (props::outer_stride == Eigen::Dynamic || props::outer_stride == stride.outer() ||
104
- (EigenRowMajor ? rows : cols) == 1);
105
- }
106
- // NOLINTNEXTLINE(google-explicit-constructor)
107
- operator bool() const { return conformable; }
108
- };
109
-
110
- template <typename Type> struct eigen_extract_stride { using type = Type; };
111
- template <typename PlainObjectType, int MapOptions, typename StrideType>
112
- struct eigen_extract_stride<Eigen::Map<PlainObjectType, MapOptions, StrideType>> { using type = StrideType; };
113
- template <typename PlainObjectType, int Options, typename StrideType>
114
- struct eigen_extract_stride<Eigen::Ref<PlainObjectType, Options, StrideType>> { using type = StrideType; };
115
-
116
- // Helper struct for extracting information from an Eigen type
117
- template <typename Type_> struct EigenProps {
118
- using Type = Type_;
119
- using Scalar = typename Type::Scalar;
120
- using StrideType = typename eigen_extract_stride<Type>::type;
121
- static constexpr EigenIndex
122
- rows = Type::RowsAtCompileTime,
123
- cols = Type::ColsAtCompileTime,
124
- size = Type::SizeAtCompileTime;
125
- static constexpr bool
126
- row_major = Type::IsRowMajor,
127
- vector = Type::IsVectorAtCompileTime, // At least one dimension has fixed size 1
128
- fixed_rows = rows != Eigen::Dynamic,
129
- fixed_cols = cols != Eigen::Dynamic,
130
- fixed = size != Eigen::Dynamic, // Fully-fixed size
131
- dynamic = !fixed_rows && !fixed_cols; // Fully-dynamic size
132
-
133
- template <EigenIndex i, EigenIndex ifzero> using if_zero = std::integral_constant<EigenIndex, i == 0 ? ifzero : i>;
134
- static constexpr EigenIndex inner_stride = if_zero<StrideType::InnerStrideAtCompileTime, 1>::value,
135
- outer_stride = if_zero<StrideType::OuterStrideAtCompileTime,
136
- vector ? size : row_major ? cols : rows>::value;
137
- static constexpr bool dynamic_stride = inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic;
138
- static constexpr bool requires_row_major = !dynamic_stride && !vector && (row_major ? inner_stride : outer_stride) == 1;
139
- static constexpr bool requires_col_major = !dynamic_stride && !vector && (row_major ? outer_stride : inner_stride) == 1;
140
-
141
- // Takes an input array and determines whether we can make it fit into the Eigen type. If
142
- // the array is a vector, we attempt to fit it into either an Eigen 1xN or Nx1 vector
143
- // (preferring the latter if it will fit in either, i.e. for a fully dynamic matrix type).
144
- static EigenConformable<row_major> conformable(const array &a) {
145
- const auto dims = a.ndim();
146
- if (dims < 1 || dims > 2)
147
- return false;
148
-
149
- if (dims == 2) { // Matrix type: require exact match (or dynamic)
150
-
151
- EigenIndex
152
- np_rows = a.shape(0),
153
- np_cols = a.shape(1),
154
- np_rstride = a.strides(0) / static_cast<ssize_t>(sizeof(Scalar)),
155
- np_cstride = a.strides(1) / static_cast<ssize_t>(sizeof(Scalar));
156
- if ((PYBIND11_SILENCE_MSVC_C4127(fixed_rows) && np_rows != rows) ||
157
- (PYBIND11_SILENCE_MSVC_C4127(fixed_cols) && np_cols != cols))
158
- return false;
159
-
160
- return {np_rows, np_cols, np_rstride, np_cstride};
161
- }
162
-
163
- // Otherwise we're storing an n-vector. Only one of the strides will be used, but whichever
164
- // is used, we want the (single) numpy stride value.
165
- const EigenIndex n = a.shape(0),
166
- stride = a.strides(0) / static_cast<ssize_t>(sizeof(Scalar));
167
-
168
- if (vector) { // Eigen type is a compile-time vector
169
- if (PYBIND11_SILENCE_MSVC_C4127(fixed) && size != n)
170
- return false; // Vector size mismatch
171
- return {rows == 1 ? 1 : n, cols == 1 ? 1 : n, stride};
172
- }
173
- if (fixed) {
174
- // The type has a fixed size, but is not a vector: abort
175
- return false;
176
- }
177
- if (fixed_cols) {
178
- // Since this isn't a vector, cols must be != 1. We allow this only if it exactly
179
- // equals the number of elements (rows is Dynamic, and so 1 row is allowed).
180
- if (cols != n) return false;
181
- return {1, n, stride};
182
- } // Otherwise it's either fully dynamic, or column dynamic; both become a column vector
183
- if (PYBIND11_SILENCE_MSVC_C4127(fixed_rows) && rows != n) return false;
184
- return {n, 1, stride};
185
- }
186
-
187
- static constexpr bool show_writeable = is_eigen_dense_map<Type>::value && is_eigen_mutable_map<Type>::value;
188
- static constexpr bool show_order = is_eigen_dense_map<Type>::value;
189
- static constexpr bool show_c_contiguous = show_order && requires_row_major;
190
- static constexpr bool show_f_contiguous = !show_c_contiguous && show_order && requires_col_major;
191
-
192
- static constexpr auto descriptor =
193
- _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name +
194
- _("[") + _<fixed_rows>(_<(size_t) rows>(), _("m")) +
195
- _(", ") + _<fixed_cols>(_<(size_t) cols>(), _("n")) +
196
- _("]") +
197
- // For a reference type (e.g. Ref<MatrixXd>) we have other constraints that might need to be
198
- // satisfied: writeable=True (for a mutable reference), and, depending on the map's stride
199
- // options, possibly f_contiguous or c_contiguous. We include them in the descriptor output
200
- // to provide some hint as to why a TypeError is occurring (otherwise it can be confusing to
201
- // see that a function accepts a 'numpy.ndarray[float64[3,2]]' and an error message that you
202
- // *gave* a numpy.ndarray of the right type and dimensions.
203
- _<show_writeable>(", flags.writeable", "") +
204
- _<show_c_contiguous>(", flags.c_contiguous", "") +
205
- _<show_f_contiguous>(", flags.f_contiguous", "") +
206
- _("]");
207
- };
208
-
209
- // Casts an Eigen type to numpy array. If given a base, the numpy array references the src data,
210
- // otherwise it'll make a copy. writeable lets you turn off the writeable flag for the array.
211
- template <typename props> handle eigen_array_cast(typename props::Type const &src, handle base = handle(), bool writeable = true) {
212
- constexpr ssize_t elem_size = sizeof(typename props::Scalar);
213
- array a;
214
- if (props::vector)
215
- a = array({ src.size() }, { elem_size * src.innerStride() }, src.data(), base);
216
- else
217
- a = array({ src.rows(), src.cols() }, { elem_size * src.rowStride(), elem_size * src.colStride() },
218
- src.data(), base);
219
-
220
- if (!writeable)
221
- array_proxy(a.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
222
-
223
- return a.release();
224
- }
225
-
226
- // Takes an lvalue ref to some Eigen type and a (python) base object, creating a numpy array that
227
- // reference the Eigen object's data with `base` as the python-registered base class (if omitted,
228
- // the base will be set to None, and lifetime management is up to the caller). The numpy array is
229
- // non-writeable if the given type is const.
230
- template <typename props, typename Type>
231
- handle eigen_ref_array(Type &src, handle parent = none()) {
232
- // none here is to get past array's should-we-copy detection, which currently always
233
- // copies when there is no base. Setting the base to None should be harmless.
234
- return eigen_array_cast<props>(src, parent, !std::is_const<Type>::value);
235
- }
236
-
237
- // Takes a pointer to some dense, plain Eigen type, builds a capsule around it, then returns a numpy
238
- // array that references the encapsulated data with a python-side reference to the capsule to tie
239
- // its destruction to that of any dependent python objects. Const-ness is determined by whether or
240
- // not the Type of the pointer given is const.
241
- template <typename props, typename Type, typename = enable_if_t<is_eigen_dense_plain<Type>::value>>
242
- handle eigen_encapsulate(Type *src) {
243
- capsule base(src, [](void *o) { delete static_cast<Type *>(o); });
244
- return eigen_ref_array<props>(*src, base);
245
- }
246
-
247
- // Type caster for regular, dense matrix types (e.g. MatrixXd), but not maps/refs/etc. of dense
248
- // types.
249
- template<typename Type>
250
- struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::value>> {
251
- using Scalar = typename Type::Scalar;
252
- using props = EigenProps<Type>;
253
-
254
- bool load(handle src, bool convert) {
255
- // If we're in no-convert mode, only load if given an array of the correct type
256
- if (!convert && !isinstance<array_t<Scalar>>(src))
257
- return false;
258
-
259
- // Coerce into an array, but don't do type conversion yet; the copy below handles it.
260
- auto buf = array::ensure(src);
261
-
262
- if (!buf)
263
- return false;
264
-
265
- auto dims = buf.ndim();
266
- if (dims < 1 || dims > 2)
267
- return false;
268
-
269
- auto fits = props::conformable(buf);
270
- if (!fits)
271
- return false;
272
-
273
- // Allocate the new type, then build a numpy reference into it
274
- value = Type(fits.rows, fits.cols);
275
- auto ref = reinterpret_steal<array>(eigen_ref_array<props>(value));
276
- if (dims == 1) ref = ref.squeeze();
277
- else if (ref.ndim() == 1) buf = buf.squeeze();
278
-
279
- int result = detail::npy_api::get().PyArray_CopyInto_(ref.ptr(), buf.ptr());
280
-
281
- if (result < 0) { // Copy failed!
282
- PyErr_Clear();
283
- return false;
284
- }
285
-
286
- return true;
287
- }
288
-
289
- private:
290
-
291
- // Cast implementation
292
- template <typename CType>
293
- static handle cast_impl(CType *src, return_value_policy policy, handle parent) {
294
- switch (policy) {
295
- case return_value_policy::take_ownership:
296
- case return_value_policy::automatic:
297
- return eigen_encapsulate<props>(src);
298
- case return_value_policy::move:
299
- return eigen_encapsulate<props>(new CType(std::move(*src)));
300
- case return_value_policy::copy:
301
- return eigen_array_cast<props>(*src);
302
- case return_value_policy::reference:
303
- case return_value_policy::automatic_reference:
304
- return eigen_ref_array<props>(*src);
305
- case return_value_policy::reference_internal:
306
- return eigen_ref_array<props>(*src, parent);
307
- default:
308
- throw cast_error("unhandled return_value_policy: should not happen!");
309
- };
310
- }
311
-
312
- public:
313
-
314
- // Normal returned non-reference, non-const value:
315
- static handle cast(Type &&src, return_value_policy /* policy */, handle parent) {
316
- return cast_impl(&src, return_value_policy::move, parent);
317
- }
318
- // If you return a non-reference const, we mark the numpy array readonly:
319
- static handle cast(const Type &&src, return_value_policy /* policy */, handle parent) {
320
- return cast_impl(&src, return_value_policy::move, parent);
321
- }
322
- // lvalue reference return; default (automatic) becomes copy
323
- static handle cast(Type &src, return_value_policy policy, handle parent) {
324
- if (policy == return_value_policy::automatic || policy == return_value_policy::automatic_reference)
325
- policy = return_value_policy::copy;
326
- return cast_impl(&src, policy, parent);
327
- }
328
- // const lvalue reference return; default (automatic) becomes copy
329
- static handle cast(const Type &src, return_value_policy policy, handle parent) {
330
- if (policy == return_value_policy::automatic || policy == return_value_policy::automatic_reference)
331
- policy = return_value_policy::copy;
332
- return cast(&src, policy, parent);
333
- }
334
- // non-const pointer return
335
- static handle cast(Type *src, return_value_policy policy, handle parent) {
336
- return cast_impl(src, policy, parent);
337
- }
338
- // const pointer return
339
- static handle cast(const Type *src, return_value_policy policy, handle parent) {
340
- return cast_impl(src, policy, parent);
341
- }
342
-
343
- static constexpr auto name = props::descriptor;
344
-
345
- // NOLINTNEXTLINE(google-explicit-constructor)
346
- operator Type*() { return &value; }
347
- // NOLINTNEXTLINE(google-explicit-constructor)
348
- operator Type&() { return value; }
349
- // NOLINTNEXTLINE(google-explicit-constructor)
350
- operator Type&&() && { return std::move(value); }
351
- template <typename T> using cast_op_type = movable_cast_op_type<T>;
352
-
353
- private:
354
- Type value;
355
- };
356
-
357
- // Base class for casting reference/map/block/etc. objects back to python.
358
- template <typename MapType> struct eigen_map_caster {
359
- private:
360
- using props = EigenProps<MapType>;
361
-
362
- public:
363
-
364
- // Directly referencing a ref/map's data is a bit dangerous (whatever the map/ref points to has
365
- // to stay around), but we'll allow it under the assumption that you know what you're doing (and
366
- // have an appropriate keep_alive in place). We return a numpy array pointing directly at the
367
- // ref's data (The numpy array ends up read-only if the ref was to a const matrix type.) Note
368
- // that this means you need to ensure you don't destroy the object in some other way (e.g. with
369
- // an appropriate keep_alive, or with a reference to a statically allocated matrix).
370
- static handle cast(const MapType &src, return_value_policy policy, handle parent) {
371
- switch (policy) {
372
- case return_value_policy::copy:
373
- return eigen_array_cast<props>(src);
374
- case return_value_policy::reference_internal:
375
- return eigen_array_cast<props>(src, parent, is_eigen_mutable_map<MapType>::value);
376
- case return_value_policy::reference:
377
- case return_value_policy::automatic:
378
- case return_value_policy::automatic_reference:
379
- return eigen_array_cast<props>(src, none(), is_eigen_mutable_map<MapType>::value);
380
- default:
381
- // move, take_ownership don't make any sense for a ref/map:
382
- pybind11_fail("Invalid return_value_policy for Eigen Map/Ref/Block type");
383
- }
384
- }
385
-
386
- static constexpr auto name = props::descriptor;
387
-
388
- // Explicitly delete these: support python -> C++ conversion on these (i.e. these can be return
389
- // types but not bound arguments). We still provide them (with an explicitly delete) so that
390
- // you end up here if you try anyway.
391
- bool load(handle, bool) = delete;
392
- operator MapType() = delete;
393
- template <typename> using cast_op_type = MapType;
394
- };
395
-
396
- // We can return any map-like object (but can only load Refs, specialized next):
397
- template <typename Type> struct type_caster<Type, enable_if_t<is_eigen_dense_map<Type>::value>>
398
- : eigen_map_caster<Type> {};
399
-
400
- // Loader for Ref<...> arguments. See the documentation for info on how to make this work without
401
- // copying (it requires some extra effort in many cases).
402
- template <typename PlainObjectType, typename StrideType>
403
- struct type_caster<
404
- Eigen::Ref<PlainObjectType, 0, StrideType>,
405
- enable_if_t<is_eigen_dense_map<Eigen::Ref<PlainObjectType, 0, StrideType>>::value>
406
- > : public eigen_map_caster<Eigen::Ref<PlainObjectType, 0, StrideType>> {
407
- private:
408
- using Type = Eigen::Ref<PlainObjectType, 0, StrideType>;
409
- using props = EigenProps<Type>;
410
- using Scalar = typename props::Scalar;
411
- using MapType = Eigen::Map<PlainObjectType, 0, StrideType>;
412
- using Array = array_t<Scalar, array::forcecast |
413
- ((props::row_major ? props::inner_stride : props::outer_stride) == 1 ? array::c_style :
414
- (props::row_major ? props::outer_stride : props::inner_stride) == 1 ? array::f_style : 0)>;
415
- static constexpr bool need_writeable = is_eigen_mutable_map<Type>::value;
416
- // Delay construction (these have no default constructor)
417
- std::unique_ptr<MapType> map;
418
- std::unique_ptr<Type> ref;
419
- // Our array. When possible, this is just a numpy array pointing to the source data, but
420
- // sometimes we can't avoid copying (e.g. input is not a numpy array at all, has an incompatible
421
- // layout, or is an array of a type that needs to be converted). Using a numpy temporary
422
- // (rather than an Eigen temporary) saves an extra copy when we need both type conversion and
423
- // storage order conversion. (Note that we refuse to use this temporary copy when loading an
424
- // argument for a Ref<M> with M non-const, i.e. a read-write reference).
425
- Array copy_or_ref;
426
- public:
427
- bool load(handle src, bool convert) {
428
- // First check whether what we have is already an array of the right type. If not, we can't
429
- // avoid a copy (because the copy is also going to do type conversion).
430
- bool need_copy = !isinstance<Array>(src);
431
-
432
- EigenConformable<props::row_major> fits;
433
- if (!need_copy) {
434
- // We don't need a converting copy, but we also need to check whether the strides are
435
- // compatible with the Ref's stride requirements
436
- auto aref = reinterpret_borrow<Array>(src);
437
-
438
- if (aref && (!need_writeable || aref.writeable())) {
439
- fits = props::conformable(aref);
440
- if (!fits) return false; // Incompatible dimensions
441
- if (!fits.template stride_compatible<props>())
442
- need_copy = true;
443
- else
444
- copy_or_ref = std::move(aref);
445
- }
446
- else {
447
- need_copy = true;
448
- }
449
- }
450
-
451
- if (need_copy) {
452
- // We need to copy: If we need a mutable reference, or we're not supposed to convert
453
- // (either because we're in the no-convert overload pass, or because we're explicitly
454
- // instructed not to copy (via `py::arg().noconvert()`) we have to fail loading.
455
- if (!convert || need_writeable) return false;
456
-
457
- Array copy = Array::ensure(src);
458
- if (!copy) return false;
459
- fits = props::conformable(copy);
460
- if (!fits || !fits.template stride_compatible<props>())
461
- return false;
462
- copy_or_ref = std::move(copy);
463
- loader_life_support::add_patient(copy_or_ref);
464
- }
465
-
466
- ref.reset();
467
- map.reset(new MapType(data(copy_or_ref), fits.rows, fits.cols, make_stride(fits.stride.outer(), fits.stride.inner())));
468
- ref.reset(new Type(*map));
469
-
470
- return true;
471
- }
472
-
473
- // NOLINTNEXTLINE(google-explicit-constructor)
474
- operator Type*() { return ref.get(); }
475
- // NOLINTNEXTLINE(google-explicit-constructor)
476
- operator Type&() { return *ref; }
477
- template <typename _T> using cast_op_type = pybind11::detail::cast_op_type<_T>;
478
-
479
- private:
480
- template <typename T = Type, enable_if_t<is_eigen_mutable_map<T>::value, int> = 0>
481
- Scalar *data(Array &a) { return a.mutable_data(); }
482
-
483
- template <typename T = Type, enable_if_t<!is_eigen_mutable_map<T>::value, int> = 0>
484
- const Scalar *data(Array &a) { return a.data(); }
485
-
486
- // Attempt to figure out a constructor of `Stride` that will work.
487
- // If both strides are fixed, use a default constructor:
488
- template <typename S> using stride_ctor_default = bool_constant<
489
- S::InnerStrideAtCompileTime != Eigen::Dynamic && S::OuterStrideAtCompileTime != Eigen::Dynamic &&
490
- std::is_default_constructible<S>::value>;
491
- // Otherwise, if there is a two-index constructor, assume it is (outer,inner) like
492
- // Eigen::Stride, and use it:
493
- template <typename S> using stride_ctor_dual = bool_constant<
494
- !stride_ctor_default<S>::value && std::is_constructible<S, EigenIndex, EigenIndex>::value>;
495
- // Otherwise, if there is a one-index constructor, and just one of the strides is dynamic, use
496
- // it (passing whichever stride is dynamic).
497
- template <typename S> using stride_ctor_outer = bool_constant<
498
- !any_of<stride_ctor_default<S>, stride_ctor_dual<S>>::value &&
499
- S::OuterStrideAtCompileTime == Eigen::Dynamic && S::InnerStrideAtCompileTime != Eigen::Dynamic &&
500
- std::is_constructible<S, EigenIndex>::value>;
501
- template <typename S> using stride_ctor_inner = bool_constant<
502
- !any_of<stride_ctor_default<S>, stride_ctor_dual<S>>::value &&
503
- S::InnerStrideAtCompileTime == Eigen::Dynamic && S::OuterStrideAtCompileTime != Eigen::Dynamic &&
504
- std::is_constructible<S, EigenIndex>::value>;
505
-
506
- template <typename S = StrideType, enable_if_t<stride_ctor_default<S>::value, int> = 0>
507
- static S make_stride(EigenIndex, EigenIndex) { return S(); }
508
- template <typename S = StrideType, enable_if_t<stride_ctor_dual<S>::value, int> = 0>
509
- static S make_stride(EigenIndex outer, EigenIndex inner) { return S(outer, inner); }
510
- template <typename S = StrideType, enable_if_t<stride_ctor_outer<S>::value, int> = 0>
511
- static S make_stride(EigenIndex outer, EigenIndex) { return S(outer); }
512
- template <typename S = StrideType, enable_if_t<stride_ctor_inner<S>::value, int> = 0>
513
- static S make_stride(EigenIndex, EigenIndex inner) { return S(inner); }
514
-
515
- };
516
-
517
- // type_caster for special matrix types (e.g. DiagonalMatrix), which are EigenBase, but not
518
- // EigenDense (i.e. they don't have a data(), at least not with the usual matrix layout).
519
- // load() is not supported, but we can cast them into the python domain by first copying to a
520
- // regular Eigen::Matrix, then casting that.
521
- template <typename Type>
522
- struct type_caster<Type, enable_if_t<is_eigen_other<Type>::value>> {
523
- protected:
524
- using Matrix = Eigen::Matrix<typename Type::Scalar, Type::RowsAtCompileTime, Type::ColsAtCompileTime>;
525
- using props = EigenProps<Matrix>;
526
- public:
527
- static handle cast(const Type &src, return_value_policy /* policy */, handle /* parent */) {
528
- handle h = eigen_encapsulate<props>(new Matrix(src));
529
- return h;
530
- }
531
- static handle cast(const Type *src, return_value_policy policy, handle parent) { return cast(*src, policy, parent); }
532
-
533
- static constexpr auto name = props::descriptor;
534
-
535
- // Explicitly delete these: support python -> C++ conversion on these (i.e. these can be return
536
- // types but not bound arguments). We still provide them (with an explicitly delete) so that
537
- // you end up here if you try anyway.
538
- bool load(handle, bool) = delete;
539
- operator Type() = delete;
540
- template <typename> using cast_op_type = Type;
541
- };
542
-
543
- template<typename Type>
544
- struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
545
- using Scalar = typename Type::Scalar;
546
- using StorageIndex = remove_reference_t<decltype(*std::declval<Type>().outerIndexPtr())>;
547
- using Index = typename Type::Index;
548
- static constexpr bool rowMajor = Type::IsRowMajor;
549
-
550
- bool load(handle src, bool) {
551
- if (!src)
552
- return false;
553
-
554
- auto obj = reinterpret_borrow<object>(src);
555
- object sparse_module = module_::import("scipy.sparse");
556
- object matrix_type = sparse_module.attr(
557
- rowMajor ? "csr_matrix" : "csc_matrix");
558
-
559
- if (!type::handle_of(obj).is(matrix_type)) {
560
- try {
561
- obj = matrix_type(obj);
562
- } catch (const error_already_set &) {
563
- return false;
564
- }
565
- }
566
-
567
- auto values = array_t<Scalar>((object) obj.attr("data"));
568
- auto innerIndices = array_t<StorageIndex>((object) obj.attr("indices"));
569
- auto outerIndices = array_t<StorageIndex>((object) obj.attr("indptr"));
570
- auto shape = pybind11::tuple((pybind11::object) obj.attr("shape"));
571
- auto nnz = obj.attr("nnz").cast<Index>();
572
-
573
- if (!values || !innerIndices || !outerIndices)
574
- return false;
575
-
576
- value = Eigen::MappedSparseMatrix<Scalar,
577
- Type::Flags & (Eigen::RowMajor | Eigen::ColMajor),
578
- StorageIndex>(
579
- shape[0].cast<Index>(), shape[1].cast<Index>(), nnz,
580
- outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());
581
-
582
- return true;
583
- }
584
-
585
- static handle cast(const Type &src, return_value_policy /* policy */, handle /* parent */) {
586
- const_cast<Type&>(src).makeCompressed();
587
-
588
- object matrix_type = module_::import("scipy.sparse").attr(
589
- rowMajor ? "csr_matrix" : "csc_matrix");
590
-
591
- array data(src.nonZeros(), src.valuePtr());
592
- array outerIndices((rowMajor ? src.rows() : src.cols()) + 1, src.outerIndexPtr());
593
- array innerIndices(src.nonZeros(), src.innerIndexPtr());
594
-
595
- return matrix_type(
596
- std::make_tuple(data, innerIndices, outerIndices),
597
- std::make_pair(src.rows(), src.cols())
598
- ).release();
599
- }
600
-
601
- PYBIND11_TYPE_CASTER(Type, _<(Type::IsRowMajor) != 0>("scipy.sparse.csr_matrix[", "scipy.sparse.csc_matrix[")
602
- + npy_format_descriptor<Scalar>::name + _("]"));
603
- };
604
-
605
- PYBIND11_NAMESPACE_END(detail)
606
- PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)