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