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,593 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import pytest
3
-
4
- import env # noqa: F401
5
- from pybind11_tests import numpy_array as m
6
-
7
- np = pytest.importorskip("numpy")
8
-
9
-
10
- def test_dtypes():
11
- # See issue #1328.
12
- # - Platform-dependent sizes.
13
- for size_check in m.get_platform_dtype_size_checks():
14
- print(size_check)
15
- assert size_check.size_cpp == size_check.size_numpy, size_check
16
- # - Concrete sizes.
17
- for check in m.get_concrete_dtype_checks():
18
- print(check)
19
- assert check.numpy == check.pybind11, check
20
- if check.numpy.num != check.pybind11.num:
21
- print(
22
- "NOTE: typenum mismatch for {}: {} != {}".format(
23
- check, check.numpy.num, check.pybind11.num
24
- )
25
- )
26
-
27
-
28
- @pytest.fixture(scope="function")
29
- def arr():
30
- return np.array([[1, 2, 3], [4, 5, 6]], "=u2")
31
-
32
-
33
- def test_array_attributes():
34
- a = np.array(0, "f8")
35
- assert m.ndim(a) == 0
36
- assert all(m.shape(a) == [])
37
- assert all(m.strides(a) == [])
38
- with pytest.raises(IndexError) as excinfo:
39
- m.shape(a, 0)
40
- assert str(excinfo.value) == "invalid axis: 0 (ndim = 0)"
41
- with pytest.raises(IndexError) as excinfo:
42
- m.strides(a, 0)
43
- assert str(excinfo.value) == "invalid axis: 0 (ndim = 0)"
44
- assert m.writeable(a)
45
- assert m.size(a) == 1
46
- assert m.itemsize(a) == 8
47
- assert m.nbytes(a) == 8
48
- assert m.owndata(a)
49
-
50
- a = np.array([[1, 2, 3], [4, 5, 6]], "u2").view()
51
- a.flags.writeable = False
52
- assert m.ndim(a) == 2
53
- assert all(m.shape(a) == [2, 3])
54
- assert m.shape(a, 0) == 2
55
- assert m.shape(a, 1) == 3
56
- assert all(m.strides(a) == [6, 2])
57
- assert m.strides(a, 0) == 6
58
- assert m.strides(a, 1) == 2
59
- with pytest.raises(IndexError) as excinfo:
60
- m.shape(a, 2)
61
- assert str(excinfo.value) == "invalid axis: 2 (ndim = 2)"
62
- with pytest.raises(IndexError) as excinfo:
63
- m.strides(a, 2)
64
- assert str(excinfo.value) == "invalid axis: 2 (ndim = 2)"
65
- assert not m.writeable(a)
66
- assert m.size(a) == 6
67
- assert m.itemsize(a) == 2
68
- assert m.nbytes(a) == 12
69
- assert not m.owndata(a)
70
-
71
-
72
- @pytest.mark.parametrize(
73
- "args, ret", [([], 0), ([0], 0), ([1], 3), ([0, 1], 1), ([1, 2], 5)]
74
- )
75
- def test_index_offset(arr, args, ret):
76
- assert m.index_at(arr, *args) == ret
77
- assert m.index_at_t(arr, *args) == ret
78
- assert m.offset_at(arr, *args) == ret * arr.dtype.itemsize
79
- assert m.offset_at_t(arr, *args) == ret * arr.dtype.itemsize
80
-
81
-
82
- def test_dim_check_fail(arr):
83
- for func in (
84
- m.index_at,
85
- m.index_at_t,
86
- m.offset_at,
87
- m.offset_at_t,
88
- m.data,
89
- m.data_t,
90
- m.mutate_data,
91
- m.mutate_data_t,
92
- ):
93
- with pytest.raises(IndexError) as excinfo:
94
- func(arr, 1, 2, 3)
95
- assert str(excinfo.value) == "too many indices for an array: 3 (ndim = 2)"
96
-
97
-
98
- @pytest.mark.parametrize(
99
- "args, ret",
100
- [
101
- ([], [1, 2, 3, 4, 5, 6]),
102
- ([1], [4, 5, 6]),
103
- ([0, 1], [2, 3, 4, 5, 6]),
104
- ([1, 2], [6]),
105
- ],
106
- )
107
- def test_data(arr, args, ret):
108
- from sys import byteorder
109
-
110
- assert all(m.data_t(arr, *args) == ret)
111
- assert all(m.data(arr, *args)[(0 if byteorder == "little" else 1) :: 2] == ret)
112
- assert all(m.data(arr, *args)[(1 if byteorder == "little" else 0) :: 2] == 0)
113
-
114
-
115
- @pytest.mark.parametrize("dim", [0, 1, 3])
116
- def test_at_fail(arr, dim):
117
- for func in m.at_t, m.mutate_at_t:
118
- with pytest.raises(IndexError) as excinfo:
119
- func(arr, *([0] * dim))
120
- assert str(excinfo.value) == "index dimension mismatch: {} (ndim = 2)".format(
121
- dim
122
- )
123
-
124
-
125
- def test_at(arr):
126
- assert m.at_t(arr, 0, 2) == 3
127
- assert m.at_t(arr, 1, 0) == 4
128
-
129
- assert all(m.mutate_at_t(arr, 0, 2).ravel() == [1, 2, 4, 4, 5, 6])
130
- assert all(m.mutate_at_t(arr, 1, 0).ravel() == [1, 2, 4, 5, 5, 6])
131
-
132
-
133
- def test_mutate_readonly(arr):
134
- arr.flags.writeable = False
135
- for func, args in (
136
- (m.mutate_data, ()),
137
- (m.mutate_data_t, ()),
138
- (m.mutate_at_t, (0, 0)),
139
- ):
140
- with pytest.raises(ValueError) as excinfo:
141
- func(arr, *args)
142
- assert str(excinfo.value) == "array is not writeable"
143
-
144
-
145
- def test_mutate_data(arr):
146
- assert all(m.mutate_data(arr).ravel() == [2, 4, 6, 8, 10, 12])
147
- assert all(m.mutate_data(arr).ravel() == [4, 8, 12, 16, 20, 24])
148
- assert all(m.mutate_data(arr, 1).ravel() == [4, 8, 12, 32, 40, 48])
149
- assert all(m.mutate_data(arr, 0, 1).ravel() == [4, 16, 24, 64, 80, 96])
150
- assert all(m.mutate_data(arr, 1, 2).ravel() == [4, 16, 24, 64, 80, 192])
151
-
152
- assert all(m.mutate_data_t(arr).ravel() == [5, 17, 25, 65, 81, 193])
153
- assert all(m.mutate_data_t(arr).ravel() == [6, 18, 26, 66, 82, 194])
154
- assert all(m.mutate_data_t(arr, 1).ravel() == [6, 18, 26, 67, 83, 195])
155
- assert all(m.mutate_data_t(arr, 0, 1).ravel() == [6, 19, 27, 68, 84, 196])
156
- assert all(m.mutate_data_t(arr, 1, 2).ravel() == [6, 19, 27, 68, 84, 197])
157
-
158
-
159
- def test_bounds_check(arr):
160
- for func in (
161
- m.index_at,
162
- m.index_at_t,
163
- m.data,
164
- m.data_t,
165
- m.mutate_data,
166
- m.mutate_data_t,
167
- m.at_t,
168
- m.mutate_at_t,
169
- ):
170
- with pytest.raises(IndexError) as excinfo:
171
- func(arr, 2, 0)
172
- assert str(excinfo.value) == "index 2 is out of bounds for axis 0 with size 2"
173
- with pytest.raises(IndexError) as excinfo:
174
- func(arr, 0, 4)
175
- assert str(excinfo.value) == "index 4 is out of bounds for axis 1 with size 3"
176
-
177
-
178
- def test_make_c_f_array():
179
- assert m.make_c_array().flags.c_contiguous
180
- assert not m.make_c_array().flags.f_contiguous
181
- assert m.make_f_array().flags.f_contiguous
182
- assert not m.make_f_array().flags.c_contiguous
183
-
184
-
185
- def test_make_empty_shaped_array():
186
- m.make_empty_shaped_array()
187
-
188
- # empty shape means numpy scalar, PEP 3118
189
- assert m.scalar_int().ndim == 0
190
- assert m.scalar_int().shape == ()
191
- assert m.scalar_int() == 42
192
-
193
-
194
- def test_wrap():
195
- def assert_references(a, b, base=None):
196
- from distutils.version import LooseVersion
197
-
198
- if base is None:
199
- base = a
200
- assert a is not b
201
- assert a.__array_interface__["data"][0] == b.__array_interface__["data"][0]
202
- assert a.shape == b.shape
203
- assert a.strides == b.strides
204
- assert a.flags.c_contiguous == b.flags.c_contiguous
205
- assert a.flags.f_contiguous == b.flags.f_contiguous
206
- assert a.flags.writeable == b.flags.writeable
207
- assert a.flags.aligned == b.flags.aligned
208
- if LooseVersion(np.__version__) >= LooseVersion("1.14.0"):
209
- assert a.flags.writebackifcopy == b.flags.writebackifcopy
210
- else:
211
- assert a.flags.updateifcopy == b.flags.updateifcopy
212
- assert np.all(a == b)
213
- assert not b.flags.owndata
214
- assert b.base is base
215
- if a.flags.writeable and a.ndim == 2:
216
- a[0, 0] = 1234
217
- assert b[0, 0] == 1234
218
-
219
- a1 = np.array([1, 2], dtype=np.int16)
220
- assert a1.flags.owndata and a1.base is None
221
- a2 = m.wrap(a1)
222
- assert_references(a1, a2)
223
-
224
- a1 = np.array([[1, 2], [3, 4]], dtype=np.float32, order="F")
225
- assert a1.flags.owndata and a1.base is None
226
- a2 = m.wrap(a1)
227
- assert_references(a1, a2)
228
-
229
- a1 = np.array([[1, 2], [3, 4]], dtype=np.float32, order="C")
230
- a1.flags.writeable = False
231
- a2 = m.wrap(a1)
232
- assert_references(a1, a2)
233
-
234
- a1 = np.random.random((4, 4, 4))
235
- a2 = m.wrap(a1)
236
- assert_references(a1, a2)
237
-
238
- a1t = a1.transpose()
239
- a2 = m.wrap(a1t)
240
- assert_references(a1t, a2, a1)
241
-
242
- a1d = a1.diagonal()
243
- a2 = m.wrap(a1d)
244
- assert_references(a1d, a2, a1)
245
-
246
- a1m = a1[::-1, ::-1, ::-1]
247
- a2 = m.wrap(a1m)
248
- assert_references(a1m, a2, a1)
249
-
250
-
251
- def test_numpy_view(capture):
252
- with capture:
253
- ac = m.ArrayClass()
254
- ac_view_1 = ac.numpy_view()
255
- ac_view_2 = ac.numpy_view()
256
- assert np.all(ac_view_1 == np.array([1, 2], dtype=np.int32))
257
- del ac
258
- pytest.gc_collect()
259
- assert (
260
- capture
261
- == """
262
- ArrayClass()
263
- ArrayClass::numpy_view()
264
- ArrayClass::numpy_view()
265
- """
266
- )
267
- ac_view_1[0] = 4
268
- ac_view_1[1] = 3
269
- assert ac_view_2[0] == 4
270
- assert ac_view_2[1] == 3
271
- with capture:
272
- del ac_view_1
273
- del ac_view_2
274
- pytest.gc_collect()
275
- pytest.gc_collect()
276
- assert (
277
- capture
278
- == """
279
- ~ArrayClass()
280
- """
281
- )
282
-
283
-
284
- def test_cast_numpy_int64_to_uint64():
285
- m.function_taking_uint64(123)
286
- m.function_taking_uint64(np.uint64(123))
287
-
288
-
289
- def test_isinstance():
290
- assert m.isinstance_untyped(np.array([1, 2, 3]), "not an array")
291
- assert m.isinstance_typed(np.array([1.0, 2.0, 3.0]))
292
-
293
-
294
- def test_constructors():
295
- defaults = m.default_constructors()
296
- for a in defaults.values():
297
- assert a.size == 0
298
- assert defaults["array"].dtype == np.array([]).dtype
299
- assert defaults["array_t<int32>"].dtype == np.int32
300
- assert defaults["array_t<double>"].dtype == np.float64
301
-
302
- results = m.converting_constructors([1, 2, 3])
303
- for a in results.values():
304
- np.testing.assert_array_equal(a, [1, 2, 3])
305
- assert results["array"].dtype == np.int_
306
- assert results["array_t<int32>"].dtype == np.int32
307
- assert results["array_t<double>"].dtype == np.float64
308
-
309
-
310
- def test_overload_resolution(msg):
311
- # Exact overload matches:
312
- assert m.overloaded(np.array([1], dtype="float64")) == "double"
313
- assert m.overloaded(np.array([1], dtype="float32")) == "float"
314
- assert m.overloaded(np.array([1], dtype="ushort")) == "unsigned short"
315
- assert m.overloaded(np.array([1], dtype="intc")) == "int"
316
- assert m.overloaded(np.array([1], dtype="longlong")) == "long long"
317
- assert m.overloaded(np.array([1], dtype="complex")) == "double complex"
318
- assert m.overloaded(np.array([1], dtype="csingle")) == "float complex"
319
-
320
- # No exact match, should call first convertible version:
321
- assert m.overloaded(np.array([1], dtype="uint8")) == "double"
322
-
323
- with pytest.raises(TypeError) as excinfo:
324
- m.overloaded("not an array")
325
- assert (
326
- msg(excinfo.value)
327
- == """
328
- overloaded(): incompatible function arguments. The following argument types are supported:
329
- 1. (arg0: numpy.ndarray[numpy.float64]) -> str
330
- 2. (arg0: numpy.ndarray[numpy.float32]) -> str
331
- 3. (arg0: numpy.ndarray[numpy.int32]) -> str
332
- 4. (arg0: numpy.ndarray[numpy.uint16]) -> str
333
- 5. (arg0: numpy.ndarray[numpy.int64]) -> str
334
- 6. (arg0: numpy.ndarray[numpy.complex128]) -> str
335
- 7. (arg0: numpy.ndarray[numpy.complex64]) -> str
336
-
337
- Invoked with: 'not an array'
338
- """
339
- )
340
-
341
- assert m.overloaded2(np.array([1], dtype="float64")) == "double"
342
- assert m.overloaded2(np.array([1], dtype="float32")) == "float"
343
- assert m.overloaded2(np.array([1], dtype="complex64")) == "float complex"
344
- assert m.overloaded2(np.array([1], dtype="complex128")) == "double complex"
345
- assert m.overloaded2(np.array([1], dtype="float32")) == "float"
346
-
347
- assert m.overloaded3(np.array([1], dtype="float64")) == "double"
348
- assert m.overloaded3(np.array([1], dtype="intc")) == "int"
349
- expected_exc = """
350
- overloaded3(): incompatible function arguments. The following argument types are supported:
351
- 1. (arg0: numpy.ndarray[numpy.int32]) -> str
352
- 2. (arg0: numpy.ndarray[numpy.float64]) -> str
353
-
354
- Invoked with: """
355
-
356
- with pytest.raises(TypeError) as excinfo:
357
- m.overloaded3(np.array([1], dtype="uintc"))
358
- assert msg(excinfo.value) == expected_exc + repr(np.array([1], dtype="uint32"))
359
- with pytest.raises(TypeError) as excinfo:
360
- m.overloaded3(np.array([1], dtype="float32"))
361
- assert msg(excinfo.value) == expected_exc + repr(np.array([1.0], dtype="float32"))
362
- with pytest.raises(TypeError) as excinfo:
363
- m.overloaded3(np.array([1], dtype="complex"))
364
- assert msg(excinfo.value) == expected_exc + repr(np.array([1.0 + 0.0j]))
365
-
366
- # Exact matches:
367
- assert m.overloaded4(np.array([1], dtype="double")) == "double"
368
- assert m.overloaded4(np.array([1], dtype="longlong")) == "long long"
369
- # Non-exact matches requiring conversion. Since float to integer isn't a
370
- # save conversion, it should go to the double overload, but short can go to
371
- # either (and so should end up on the first-registered, the long long).
372
- assert m.overloaded4(np.array([1], dtype="float32")) == "double"
373
- assert m.overloaded4(np.array([1], dtype="short")) == "long long"
374
-
375
- assert m.overloaded5(np.array([1], dtype="double")) == "double"
376
- assert m.overloaded5(np.array([1], dtype="uintc")) == "unsigned int"
377
- assert m.overloaded5(np.array([1], dtype="float32")) == "unsigned int"
378
-
379
-
380
- def test_greedy_string_overload():
381
- """Tests fix for #685 - ndarray shouldn't go to std::string overload"""
382
-
383
- assert m.issue685("abc") == "string"
384
- assert m.issue685(np.array([97, 98, 99], dtype="b")) == "array"
385
- assert m.issue685(123) == "other"
386
-
387
-
388
- def test_array_unchecked_fixed_dims(msg):
389
- z1 = np.array([[1, 2], [3, 4]], dtype="float64")
390
- m.proxy_add2(z1, 10)
391
- assert np.all(z1 == [[11, 12], [13, 14]])
392
-
393
- with pytest.raises(ValueError) as excinfo:
394
- m.proxy_add2(np.array([1.0, 2, 3]), 5.0)
395
- assert (
396
- msg(excinfo.value) == "array has incorrect number of dimensions: 1; expected 2"
397
- )
398
-
399
- expect_c = np.ndarray(shape=(3, 3, 3), buffer=np.array(range(3, 30)), dtype="int")
400
- assert np.all(m.proxy_init3(3.0) == expect_c)
401
- expect_f = np.transpose(expect_c)
402
- assert np.all(m.proxy_init3F(3.0) == expect_f)
403
-
404
- assert m.proxy_squared_L2_norm(np.array(range(6))) == 55
405
- assert m.proxy_squared_L2_norm(np.array(range(6), dtype="float64")) == 55
406
-
407
- assert m.proxy_auxiliaries2(z1) == [11, 11, True, 2, 8, 2, 2, 4, 32]
408
- assert m.proxy_auxiliaries2(z1) == m.array_auxiliaries2(z1)
409
-
410
- assert m.proxy_auxiliaries1_const_ref(z1[0, :])
411
- assert m.proxy_auxiliaries2_const_ref(z1)
412
-
413
-
414
- def test_array_unchecked_dyn_dims():
415
- z1 = np.array([[1, 2], [3, 4]], dtype="float64")
416
- m.proxy_add2_dyn(z1, 10)
417
- assert np.all(z1 == [[11, 12], [13, 14]])
418
-
419
- expect_c = np.ndarray(shape=(3, 3, 3), buffer=np.array(range(3, 30)), dtype="int")
420
- assert np.all(m.proxy_init3_dyn(3.0) == expect_c)
421
-
422
- assert m.proxy_auxiliaries2_dyn(z1) == [11, 11, True, 2, 8, 2, 2, 4, 32]
423
- assert m.proxy_auxiliaries2_dyn(z1) == m.array_auxiliaries2(z1)
424
-
425
-
426
- def test_array_failure():
427
- with pytest.raises(ValueError) as excinfo:
428
- m.array_fail_test()
429
- assert str(excinfo.value) == "cannot create a pybind11::array from a nullptr"
430
-
431
- with pytest.raises(ValueError) as excinfo:
432
- m.array_t_fail_test()
433
- assert str(excinfo.value) == "cannot create a pybind11::array_t from a nullptr"
434
-
435
- with pytest.raises(ValueError) as excinfo:
436
- m.array_fail_test_negative_size()
437
- assert str(excinfo.value) == "negative dimensions are not allowed"
438
-
439
-
440
- def test_initializer_list():
441
- assert m.array_initializer_list1().shape == (1,)
442
- assert m.array_initializer_list2().shape == (1, 2)
443
- assert m.array_initializer_list3().shape == (1, 2, 3)
444
- assert m.array_initializer_list4().shape == (1, 2, 3, 4)
445
-
446
-
447
- def test_array_resize():
448
- a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype="float64")
449
- m.array_reshape2(a)
450
- assert a.size == 9
451
- assert np.all(a == [[1, 2, 3], [4, 5, 6], [7, 8, 9]])
452
-
453
- # total size change should succced with refcheck off
454
- m.array_resize3(a, 4, False)
455
- assert a.size == 64
456
- # ... and fail with refcheck on
457
- try:
458
- m.array_resize3(a, 3, True)
459
- except ValueError as e:
460
- assert str(e).startswith("cannot resize an array")
461
- # transposed array doesn't own data
462
- b = a.transpose()
463
- try:
464
- m.array_resize3(b, 3, False)
465
- except ValueError as e:
466
- assert str(e).startswith("cannot resize this array: it does not own its data")
467
- # ... but reshape should be fine
468
- m.array_reshape2(b)
469
- assert b.shape == (8, 8)
470
-
471
-
472
- @pytest.mark.xfail("env.PYPY")
473
- def test_array_create_and_resize():
474
- a = m.create_and_resize(2)
475
- assert a.size == 4
476
- assert np.all(a == 42.0)
477
-
478
-
479
- def test_array_view():
480
- a = np.ones(100 * 4).astype("uint8")
481
- a_float_view = m.array_view(a, "float32")
482
- assert a_float_view.shape == (100 * 1,) # 1 / 4 bytes = 8 / 32
483
-
484
- a_int16_view = m.array_view(a, "int16") # 1 / 2 bytes = 16 / 32
485
- assert a_int16_view.shape == (100 * 2,)
486
-
487
-
488
- def test_array_view_invalid():
489
- a = np.ones(100 * 4).astype("uint8")
490
- with pytest.raises(TypeError):
491
- m.array_view(a, "deadly_dtype")
492
-
493
-
494
- def test_reshape_initializer_list():
495
- a = np.arange(2 * 7 * 3) + 1
496
- x = m.reshape_initializer_list(a, 2, 7, 3)
497
- assert x.shape == (2, 7, 3)
498
- assert list(x[1][4]) == [34, 35, 36]
499
- with pytest.raises(ValueError) as excinfo:
500
- m.reshape_initializer_list(a, 1, 7, 3)
501
- assert str(excinfo.value) == "cannot reshape array of size 42 into shape (1,7,3)"
502
-
503
-
504
- def test_reshape_tuple():
505
- a = np.arange(3 * 7 * 2) + 1
506
- x = m.reshape_tuple(a, (3, 7, 2))
507
- assert x.shape == (3, 7, 2)
508
- assert list(x[1][4]) == [23, 24]
509
- y = m.reshape_tuple(x, (x.size,))
510
- assert y.shape == (42,)
511
- with pytest.raises(ValueError) as excinfo:
512
- m.reshape_tuple(a, (3, 7, 1))
513
- assert str(excinfo.value) == "cannot reshape array of size 42 into shape (3,7,1)"
514
- with pytest.raises(ValueError) as excinfo:
515
- m.reshape_tuple(a, ())
516
- assert str(excinfo.value) == "cannot reshape array of size 42 into shape ()"
517
-
518
-
519
- def test_index_using_ellipsis():
520
- a = m.index_using_ellipsis(np.zeros((5, 6, 7)))
521
- assert a.shape == (6,)
522
-
523
-
524
- @pytest.mark.parametrize(
525
- "test_func",
526
- [
527
- m.test_fmt_desc_float,
528
- m.test_fmt_desc_double,
529
- m.test_fmt_desc_const_float,
530
- m.test_fmt_desc_const_double,
531
- ],
532
- )
533
- def test_format_descriptors_for_floating_point_types(test_func):
534
- assert "numpy.ndarray[numpy.float" in test_func.__doc__
535
-
536
-
537
- @pytest.mark.parametrize("forcecast", [False, True])
538
- @pytest.mark.parametrize("contiguity", [None, "C", "F"])
539
- @pytest.mark.parametrize("noconvert", [False, True])
540
- @pytest.mark.filterwarnings(
541
- "ignore:Casting complex values to real discards the imaginary part:numpy.ComplexWarning"
542
- )
543
- def test_argument_conversions(forcecast, contiguity, noconvert):
544
- function_name = "accept_double"
545
- if contiguity == "C":
546
- function_name += "_c_style"
547
- elif contiguity == "F":
548
- function_name += "_f_style"
549
- if forcecast:
550
- function_name += "_forcecast"
551
- if noconvert:
552
- function_name += "_noconvert"
553
- function = getattr(m, function_name)
554
-
555
- for dtype in [np.dtype("float32"), np.dtype("float64"), np.dtype("complex128")]:
556
- for order in ["C", "F"]:
557
- for shape in [(2, 2), (1, 3, 1, 1), (1, 1, 1), (0,)]:
558
- if not noconvert:
559
- # If noconvert is not passed, only complex128 needs to be truncated and
560
- # "cannot be safely obtained". So without `forcecast`, the argument shouldn't
561
- # be accepted.
562
- should_raise = dtype.name == "complex128" and not forcecast
563
- else:
564
- # If noconvert is passed, only float64 and the matching order is accepted.
565
- # If at most one dimension has a size greater than 1, the array is also
566
- # trivially contiguous.
567
- trivially_contiguous = sum(1 for d in shape if d > 1) <= 1
568
- should_raise = dtype.name != "float64" or (
569
- contiguity is not None
570
- and contiguity != order
571
- and not trivially_contiguous
572
- )
573
-
574
- array = np.zeros(shape, dtype=dtype, order=order)
575
- if not should_raise:
576
- function(array)
577
- else:
578
- with pytest.raises(
579
- TypeError, match="incompatible function arguments"
580
- ):
581
- function(array)
582
-
583
-
584
- @pytest.mark.xfail("env.PYPY")
585
- def test_dtype_refcount_leak():
586
- from sys import getrefcount
587
-
588
- dtype = np.dtype(np.float_)
589
- a = np.array([1], dtype=dtype)
590
- before = getrefcount(dtype)
591
- m.ndim(a)
592
- after = getrefcount(dtype)
593
- assert after == before