xcoll 0.3.6__py3-none-any.whl → 0.5.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.
- xcoll/__init__.py +13 -4
- xcoll/beam_elements/__init__.py +14 -6
- xcoll/beam_elements/absorber.py +41 -7
- xcoll/beam_elements/base.py +1202 -247
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/elements_src/black_absorber.h +136 -0
- xcoll/beam_elements/elements_src/black_crystal.h +129 -0
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
- xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
- xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
- xcoll/beam_elements/everest.py +65 -119
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +276 -747
- xcoll/general.py +5 -5
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +2 -2
- xcoll/initial_distribution.py +207 -0
- xcoll/install.py +179 -0
- xcoll/interaction_record/__init__.py +1 -0
- xcoll/interaction_record/interaction_record.py +298 -0
- xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
- xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
- xcoll/line_tools.py +82 -0
- xcoll/lossmap.py +219 -0
- xcoll/manager.py +2 -937
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +232 -0
- xcoll/scattering_routines/everest/channeling.h +240 -0
- xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
- xcoll/scattering_routines/everest/everest.h +11 -30
- xcoll/scattering_routines/everest/everest.py +13 -10
- xcoll/scattering_routines/everest/jaw.h +28 -197
- xcoll/scattering_routines/everest/materials.py +37 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
- xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/__init__.py +6 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
- xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
- xcoll/scattering_routines/geometry/geometry.py +26 -0
- xcoll/scattering_routines/geometry/get_s.h +92 -0
- xcoll/scattering_routines/geometry/methods.h +111 -0
- xcoll/scattering_routines/geometry/objects.h +154 -0
- xcoll/scattering_routines/geometry/rotation.h +23 -0
- xcoll/scattering_routines/geometry/segments.h +226 -0
- xcoll/scattering_routines/geometry/sort.h +184 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/beam_elements/collimators_src/absorber.h +0 -141
- xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
- xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
- xcoll/collimator_settings.py +0 -457
- xcoll/impacts/__init__.py +0 -1
- xcoll/impacts/impacts.py +0 -102
- xcoll/impacts/impacts_src/impacts.h +0 -99
- xcoll/scattering_routines/everest/crystal.h +0 -1302
- xcoll/scattering_routines/everest/scatter.h +0 -169
- xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.3.6.dist-info/RECORD +0 -111
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,593 @@
|
|
|
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
|