xcoll 0.5.11__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +5 -18
- xcoll/beam_elements/__init__.py +1 -0
- xcoll/beam_elements/absorber.py +12 -2
- xcoll/beam_elements/base.py +162 -62
- xcoll/beam_elements/blowup.py +1 -0
- xcoll/beam_elements/elements_src/black_absorber.h +57 -58
- xcoll/beam_elements/elements_src/black_crystal.h +49 -50
- xcoll/beam_elements/elements_src/everest_block.h +21 -11
- xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
- xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
- xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
- xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
- xcoll/beam_elements/everest.py +16 -5
- xcoll/beam_elements/monitor.py +1 -0
- xcoll/beam_elements/transparent.py +83 -0
- xcoll/colldb.py +15 -6
- xcoll/general.py +1 -1
- xcoll/headers/particle_states.py +51 -0
- xcoll/initial_distribution.py +129 -103
- xcoll/interaction_record/interaction_record.py +2 -1
- xcoll/interaction_record/interaction_types.py +2 -2
- xcoll/line_tools.py +163 -74
- xcoll/lossmap.py +519 -127
- xcoll/plot.py +109 -0
- xcoll/rf_sweep.py +6 -0
- xcoll/scattering_routines/engine.py +600 -0
- xcoll/scattering_routines/environment.py +297 -0
- xcoll/scattering_routines/everest/amorphous.h +95 -71
- xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
- xcoll/scattering_routines/everest/constants.h +1 -1
- xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
- xcoll/scattering_routines/everest/everest.h +8 -3
- xcoll/scattering_routines/everest/everest.py +2 -1
- xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
- xcoll/scattering_routines/everest/jaw.h +19 -24
- xcoll/scattering_routines/everest/materials.py +2 -0
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
- xcoll/scattering_routines/everest/properties.h +4 -73
- xcoll/xaux.py +73 -0
- {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/METADATA +5 -5
- xcoll-0.6.0.dist-info/RECORD +135 -0
- xcoll/_manager.py +0 -22
- xcoll/headers/particle_states.h +0 -25
- xcoll/install.py +0 -35
- xcoll/scattering_routines/geant4/collimasim/.git +0 -1
- xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
- xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
- 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 +0 -427
- 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 +0 -427
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
- 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 +0 -279
- 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 +0 -143
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
- xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
- xcoll-0.5.11.dist-info/RECORD +0 -413
- {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/LICENSE +0 -0
- {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/NOTICE +0 -0
- {xcoll-0.5.11.dist-info → xcoll-0.6.0.dist-info}/WHEEL +0 -0
|
@@ -1,536 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
import env
|
|
5
|
-
from pybind11_tests import IncType, UserType
|
|
6
|
-
from pybind11_tests import builtin_casters as m
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_simple_string():
|
|
10
|
-
assert m.string_roundtrip("const char *") == "const char *"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_unicode_conversion():
|
|
14
|
-
"""Tests unicode conversion and error reporting."""
|
|
15
|
-
assert m.good_utf8_string() == u"Say utf8‽ 🎂 𝐀"
|
|
16
|
-
assert m.good_utf16_string() == u"b‽🎂𝐀z"
|
|
17
|
-
assert m.good_utf32_string() == u"a𝐀🎂‽z"
|
|
18
|
-
assert m.good_wchar_string() == u"a⸘𝐀z"
|
|
19
|
-
if hasattr(m, "has_u8string"):
|
|
20
|
-
assert m.good_utf8_u8string() == u"Say utf8‽ 🎂 𝐀"
|
|
21
|
-
|
|
22
|
-
with pytest.raises(UnicodeDecodeError):
|
|
23
|
-
m.bad_utf8_string()
|
|
24
|
-
|
|
25
|
-
with pytest.raises(UnicodeDecodeError):
|
|
26
|
-
m.bad_utf16_string()
|
|
27
|
-
|
|
28
|
-
# These are provided only if they actually fail (they don't when 32-bit and under Python 2.7)
|
|
29
|
-
if hasattr(m, "bad_utf32_string"):
|
|
30
|
-
with pytest.raises(UnicodeDecodeError):
|
|
31
|
-
m.bad_utf32_string()
|
|
32
|
-
if hasattr(m, "bad_wchar_string"):
|
|
33
|
-
with pytest.raises(UnicodeDecodeError):
|
|
34
|
-
m.bad_wchar_string()
|
|
35
|
-
if hasattr(m, "has_u8string"):
|
|
36
|
-
with pytest.raises(UnicodeDecodeError):
|
|
37
|
-
m.bad_utf8_u8string()
|
|
38
|
-
|
|
39
|
-
assert m.u8_Z() == "Z"
|
|
40
|
-
assert m.u8_eacute() == u"é"
|
|
41
|
-
assert m.u16_ibang() == u"‽"
|
|
42
|
-
assert m.u32_mathbfA() == u"𝐀"
|
|
43
|
-
assert m.wchar_heart() == u"♥"
|
|
44
|
-
if hasattr(m, "has_u8string"):
|
|
45
|
-
assert m.u8_char8_Z() == "Z"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_single_char_arguments():
|
|
49
|
-
"""Tests failures for passing invalid inputs to char-accepting functions"""
|
|
50
|
-
|
|
51
|
-
def toobig_message(r):
|
|
52
|
-
return "Character code point not in range({:#x})".format(r)
|
|
53
|
-
|
|
54
|
-
toolong_message = "Expected a character, but multi-character string found"
|
|
55
|
-
|
|
56
|
-
assert m.ord_char(u"a") == 0x61 # simple ASCII
|
|
57
|
-
assert m.ord_char_lv(u"b") == 0x62
|
|
58
|
-
assert (
|
|
59
|
-
m.ord_char(u"é") == 0xE9
|
|
60
|
-
) # requires 2 bytes in utf-8, but can be stuffed in a char
|
|
61
|
-
with pytest.raises(ValueError) as excinfo:
|
|
62
|
-
assert m.ord_char(u"Ā") == 0x100 # requires 2 bytes, doesn't fit in a char
|
|
63
|
-
assert str(excinfo.value) == toobig_message(0x100)
|
|
64
|
-
with pytest.raises(ValueError) as excinfo:
|
|
65
|
-
assert m.ord_char(u"ab")
|
|
66
|
-
assert str(excinfo.value) == toolong_message
|
|
67
|
-
|
|
68
|
-
assert m.ord_char16(u"a") == 0x61
|
|
69
|
-
assert m.ord_char16(u"é") == 0xE9
|
|
70
|
-
assert m.ord_char16_lv(u"ê") == 0xEA
|
|
71
|
-
assert m.ord_char16(u"Ā") == 0x100
|
|
72
|
-
assert m.ord_char16(u"‽") == 0x203D
|
|
73
|
-
assert m.ord_char16(u"♥") == 0x2665
|
|
74
|
-
assert m.ord_char16_lv(u"♡") == 0x2661
|
|
75
|
-
with pytest.raises(ValueError) as excinfo:
|
|
76
|
-
assert m.ord_char16(u"🎂") == 0x1F382 # requires surrogate pair
|
|
77
|
-
assert str(excinfo.value) == toobig_message(0x10000)
|
|
78
|
-
with pytest.raises(ValueError) as excinfo:
|
|
79
|
-
assert m.ord_char16(u"aa")
|
|
80
|
-
assert str(excinfo.value) == toolong_message
|
|
81
|
-
|
|
82
|
-
assert m.ord_char32(u"a") == 0x61
|
|
83
|
-
assert m.ord_char32(u"é") == 0xE9
|
|
84
|
-
assert m.ord_char32(u"Ā") == 0x100
|
|
85
|
-
assert m.ord_char32(u"‽") == 0x203D
|
|
86
|
-
assert m.ord_char32(u"♥") == 0x2665
|
|
87
|
-
assert m.ord_char32(u"🎂") == 0x1F382
|
|
88
|
-
with pytest.raises(ValueError) as excinfo:
|
|
89
|
-
assert m.ord_char32(u"aa")
|
|
90
|
-
assert str(excinfo.value) == toolong_message
|
|
91
|
-
|
|
92
|
-
assert m.ord_wchar(u"a") == 0x61
|
|
93
|
-
assert m.ord_wchar(u"é") == 0xE9
|
|
94
|
-
assert m.ord_wchar(u"Ā") == 0x100
|
|
95
|
-
assert m.ord_wchar(u"‽") == 0x203D
|
|
96
|
-
assert m.ord_wchar(u"♥") == 0x2665
|
|
97
|
-
if m.wchar_size == 2:
|
|
98
|
-
with pytest.raises(ValueError) as excinfo:
|
|
99
|
-
assert m.ord_wchar(u"🎂") == 0x1F382 # requires surrogate pair
|
|
100
|
-
assert str(excinfo.value) == toobig_message(0x10000)
|
|
101
|
-
else:
|
|
102
|
-
assert m.ord_wchar(u"🎂") == 0x1F382
|
|
103
|
-
with pytest.raises(ValueError) as excinfo:
|
|
104
|
-
assert m.ord_wchar(u"aa")
|
|
105
|
-
assert str(excinfo.value) == toolong_message
|
|
106
|
-
|
|
107
|
-
if hasattr(m, "has_u8string"):
|
|
108
|
-
assert m.ord_char8(u"a") == 0x61 # simple ASCII
|
|
109
|
-
assert m.ord_char8_lv(u"b") == 0x62
|
|
110
|
-
assert (
|
|
111
|
-
m.ord_char8(u"é") == 0xE9
|
|
112
|
-
) # requires 2 bytes in utf-8, but can be stuffed in a char
|
|
113
|
-
with pytest.raises(ValueError) as excinfo:
|
|
114
|
-
assert m.ord_char8(u"Ā") == 0x100 # requires 2 bytes, doesn't fit in a char
|
|
115
|
-
assert str(excinfo.value) == toobig_message(0x100)
|
|
116
|
-
with pytest.raises(ValueError) as excinfo:
|
|
117
|
-
assert m.ord_char8(u"ab")
|
|
118
|
-
assert str(excinfo.value) == toolong_message
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def test_bytes_to_string():
|
|
122
|
-
"""Tests the ability to pass bytes to C++ string-accepting functions. Note that this is
|
|
123
|
-
one-way: the only way to return bytes to Python is via the pybind11::bytes class."""
|
|
124
|
-
# Issue #816
|
|
125
|
-
|
|
126
|
-
def to_bytes(s):
|
|
127
|
-
b = s if env.PY2 else s.encode("utf8")
|
|
128
|
-
assert isinstance(b, bytes)
|
|
129
|
-
return b
|
|
130
|
-
|
|
131
|
-
assert m.strlen(to_bytes("hi")) == 2
|
|
132
|
-
assert m.string_length(to_bytes("world")) == 5
|
|
133
|
-
assert m.string_length(to_bytes("a\x00b")) == 3
|
|
134
|
-
assert m.strlen(to_bytes("a\x00b")) == 1 # C-string limitation
|
|
135
|
-
|
|
136
|
-
# passing in a utf8 encoded string should work
|
|
137
|
-
assert m.string_length(u"💩".encode("utf8")) == 4
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@pytest.mark.skipif(not hasattr(m, "has_string_view"), reason="no <string_view>")
|
|
141
|
-
def test_string_view(capture):
|
|
142
|
-
"""Tests support for C++17 string_view arguments and return values"""
|
|
143
|
-
assert m.string_view_chars("Hi") == [72, 105]
|
|
144
|
-
assert m.string_view_chars("Hi 🎂") == [72, 105, 32, 0xF0, 0x9F, 0x8E, 0x82]
|
|
145
|
-
assert m.string_view16_chars(u"Hi 🎂") == [72, 105, 32, 0xD83C, 0xDF82]
|
|
146
|
-
assert m.string_view32_chars(u"Hi 🎂") == [72, 105, 32, 127874]
|
|
147
|
-
if hasattr(m, "has_u8string"):
|
|
148
|
-
assert m.string_view8_chars("Hi") == [72, 105]
|
|
149
|
-
assert m.string_view8_chars(u"Hi 🎂") == [72, 105, 32, 0xF0, 0x9F, 0x8E, 0x82]
|
|
150
|
-
|
|
151
|
-
assert m.string_view_return() == u"utf8 secret 🎂"
|
|
152
|
-
assert m.string_view16_return() == u"utf16 secret 🎂"
|
|
153
|
-
assert m.string_view32_return() == u"utf32 secret 🎂"
|
|
154
|
-
if hasattr(m, "has_u8string"):
|
|
155
|
-
assert m.string_view8_return() == u"utf8 secret 🎂"
|
|
156
|
-
|
|
157
|
-
with capture:
|
|
158
|
-
m.string_view_print("Hi")
|
|
159
|
-
m.string_view_print("utf8 🎂")
|
|
160
|
-
m.string_view16_print(u"utf16 🎂")
|
|
161
|
-
m.string_view32_print(u"utf32 🎂")
|
|
162
|
-
assert (
|
|
163
|
-
capture
|
|
164
|
-
== u"""
|
|
165
|
-
Hi 2
|
|
166
|
-
utf8 🎂 9
|
|
167
|
-
utf16 🎂 8
|
|
168
|
-
utf32 🎂 7
|
|
169
|
-
"""
|
|
170
|
-
)
|
|
171
|
-
if hasattr(m, "has_u8string"):
|
|
172
|
-
with capture:
|
|
173
|
-
m.string_view8_print("Hi")
|
|
174
|
-
m.string_view8_print(u"utf8 🎂")
|
|
175
|
-
assert (
|
|
176
|
-
capture
|
|
177
|
-
== u"""
|
|
178
|
-
Hi 2
|
|
179
|
-
utf8 🎂 9
|
|
180
|
-
"""
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
with capture:
|
|
184
|
-
m.string_view_print("Hi, ascii")
|
|
185
|
-
m.string_view_print("Hi, utf8 🎂")
|
|
186
|
-
m.string_view16_print(u"Hi, utf16 🎂")
|
|
187
|
-
m.string_view32_print(u"Hi, utf32 🎂")
|
|
188
|
-
assert (
|
|
189
|
-
capture
|
|
190
|
-
== u"""
|
|
191
|
-
Hi, ascii 9
|
|
192
|
-
Hi, utf8 🎂 13
|
|
193
|
-
Hi, utf16 🎂 12
|
|
194
|
-
Hi, utf32 🎂 11
|
|
195
|
-
"""
|
|
196
|
-
)
|
|
197
|
-
if hasattr(m, "has_u8string"):
|
|
198
|
-
with capture:
|
|
199
|
-
m.string_view8_print("Hi, ascii")
|
|
200
|
-
m.string_view8_print(u"Hi, utf8 🎂")
|
|
201
|
-
assert (
|
|
202
|
-
capture
|
|
203
|
-
== u"""
|
|
204
|
-
Hi, ascii 9
|
|
205
|
-
Hi, utf8 🎂 13
|
|
206
|
-
"""
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
def test_integer_casting():
|
|
211
|
-
"""Issue #929 - out-of-range integer values shouldn't be accepted"""
|
|
212
|
-
assert m.i32_str(-1) == "-1"
|
|
213
|
-
assert m.i64_str(-1) == "-1"
|
|
214
|
-
assert m.i32_str(2000000000) == "2000000000"
|
|
215
|
-
assert m.u32_str(2000000000) == "2000000000"
|
|
216
|
-
if env.PY2:
|
|
217
|
-
assert m.i32_str(long(-1)) == "-1" # noqa: F821 undefined name 'long'
|
|
218
|
-
assert m.i64_str(long(-1)) == "-1" # noqa: F821 undefined name 'long'
|
|
219
|
-
assert (
|
|
220
|
-
m.i64_str(long(-999999999999)) # noqa: F821 undefined name 'long'
|
|
221
|
-
== "-999999999999"
|
|
222
|
-
)
|
|
223
|
-
assert (
|
|
224
|
-
m.u64_str(long(999999999999)) # noqa: F821 undefined name 'long'
|
|
225
|
-
== "999999999999"
|
|
226
|
-
)
|
|
227
|
-
else:
|
|
228
|
-
assert m.i64_str(-999999999999) == "-999999999999"
|
|
229
|
-
assert m.u64_str(999999999999) == "999999999999"
|
|
230
|
-
|
|
231
|
-
with pytest.raises(TypeError) as excinfo:
|
|
232
|
-
m.u32_str(-1)
|
|
233
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
234
|
-
with pytest.raises(TypeError) as excinfo:
|
|
235
|
-
m.u64_str(-1)
|
|
236
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
237
|
-
with pytest.raises(TypeError) as excinfo:
|
|
238
|
-
m.i32_str(-3000000000)
|
|
239
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
240
|
-
with pytest.raises(TypeError) as excinfo:
|
|
241
|
-
m.i32_str(3000000000)
|
|
242
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
243
|
-
|
|
244
|
-
if env.PY2:
|
|
245
|
-
with pytest.raises(TypeError) as excinfo:
|
|
246
|
-
m.u32_str(long(-1)) # noqa: F821 undefined name 'long'
|
|
247
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
248
|
-
with pytest.raises(TypeError) as excinfo:
|
|
249
|
-
m.u64_str(long(-1)) # noqa: F821 undefined name 'long'
|
|
250
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def test_int_convert():
|
|
254
|
-
class Int(object):
|
|
255
|
-
def __int__(self):
|
|
256
|
-
return 42
|
|
257
|
-
|
|
258
|
-
class NotInt(object):
|
|
259
|
-
pass
|
|
260
|
-
|
|
261
|
-
class Float(object):
|
|
262
|
-
def __float__(self):
|
|
263
|
-
return 41.99999
|
|
264
|
-
|
|
265
|
-
class Index(object):
|
|
266
|
-
def __index__(self):
|
|
267
|
-
return 42
|
|
268
|
-
|
|
269
|
-
class IntAndIndex(object):
|
|
270
|
-
def __int__(self):
|
|
271
|
-
return 42
|
|
272
|
-
|
|
273
|
-
def __index__(self):
|
|
274
|
-
return 0
|
|
275
|
-
|
|
276
|
-
class RaisingTypeErrorOnIndex(object):
|
|
277
|
-
def __index__(self):
|
|
278
|
-
raise TypeError
|
|
279
|
-
|
|
280
|
-
def __int__(self):
|
|
281
|
-
return 42
|
|
282
|
-
|
|
283
|
-
class RaisingValueErrorOnIndex(object):
|
|
284
|
-
def __index__(self):
|
|
285
|
-
raise ValueError
|
|
286
|
-
|
|
287
|
-
def __int__(self):
|
|
288
|
-
return 42
|
|
289
|
-
|
|
290
|
-
convert, noconvert = m.int_passthrough, m.int_passthrough_noconvert
|
|
291
|
-
|
|
292
|
-
def requires_conversion(v):
|
|
293
|
-
pytest.raises(TypeError, noconvert, v)
|
|
294
|
-
|
|
295
|
-
def cant_convert(v):
|
|
296
|
-
pytest.raises(TypeError, convert, v)
|
|
297
|
-
|
|
298
|
-
assert convert(7) == 7
|
|
299
|
-
assert noconvert(7) == 7
|
|
300
|
-
cant_convert(3.14159)
|
|
301
|
-
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
|
|
302
|
-
if (3, 8) <= env.PY < (3, 10):
|
|
303
|
-
with env.deprecated_call():
|
|
304
|
-
assert convert(Int()) == 42
|
|
305
|
-
else:
|
|
306
|
-
assert convert(Int()) == 42
|
|
307
|
-
requires_conversion(Int())
|
|
308
|
-
cant_convert(NotInt())
|
|
309
|
-
cant_convert(Float())
|
|
310
|
-
|
|
311
|
-
# Before Python 3.8, `PyLong_AsLong` does not pick up on `obj.__index__`,
|
|
312
|
-
# but pybind11 "backports" this behavior.
|
|
313
|
-
assert convert(Index()) == 42
|
|
314
|
-
assert noconvert(Index()) == 42
|
|
315
|
-
assert convert(IntAndIndex()) == 0 # Fishy; `int(DoubleThought)` == 42
|
|
316
|
-
assert noconvert(IntAndIndex()) == 0
|
|
317
|
-
assert convert(RaisingTypeErrorOnIndex()) == 42
|
|
318
|
-
requires_conversion(RaisingTypeErrorOnIndex())
|
|
319
|
-
assert convert(RaisingValueErrorOnIndex()) == 42
|
|
320
|
-
requires_conversion(RaisingValueErrorOnIndex())
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
def test_numpy_int_convert():
|
|
324
|
-
np = pytest.importorskip("numpy")
|
|
325
|
-
|
|
326
|
-
convert, noconvert = m.int_passthrough, m.int_passthrough_noconvert
|
|
327
|
-
|
|
328
|
-
def require_implicit(v):
|
|
329
|
-
pytest.raises(TypeError, noconvert, v)
|
|
330
|
-
|
|
331
|
-
# `np.intc` is an alias that corresponds to a C++ `int`
|
|
332
|
-
assert convert(np.intc(42)) == 42
|
|
333
|
-
assert noconvert(np.intc(42)) == 42
|
|
334
|
-
|
|
335
|
-
# The implicit conversion from np.float32 is undesirable but currently accepted.
|
|
336
|
-
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
|
|
337
|
-
if (3, 8) <= env.PY < (3, 10):
|
|
338
|
-
with env.deprecated_call():
|
|
339
|
-
assert convert(np.float32(3.14159)) == 3
|
|
340
|
-
else:
|
|
341
|
-
assert convert(np.float32(3.14159)) == 3
|
|
342
|
-
require_implicit(np.float32(3.14159))
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
def test_tuple(doc):
|
|
346
|
-
"""std::pair <-> tuple & std::tuple <-> tuple"""
|
|
347
|
-
assert m.pair_passthrough((True, "test")) == ("test", True)
|
|
348
|
-
assert m.tuple_passthrough((True, "test", 5)) == (5, "test", True)
|
|
349
|
-
# Any sequence can be cast to a std::pair or std::tuple
|
|
350
|
-
assert m.pair_passthrough([True, "test"]) == ("test", True)
|
|
351
|
-
assert m.tuple_passthrough([True, "test", 5]) == (5, "test", True)
|
|
352
|
-
assert m.empty_tuple() == ()
|
|
353
|
-
|
|
354
|
-
assert (
|
|
355
|
-
doc(m.pair_passthrough)
|
|
356
|
-
== """
|
|
357
|
-
pair_passthrough(arg0: Tuple[bool, str]) -> Tuple[str, bool]
|
|
358
|
-
|
|
359
|
-
Return a pair in reversed order
|
|
360
|
-
"""
|
|
361
|
-
)
|
|
362
|
-
assert (
|
|
363
|
-
doc(m.tuple_passthrough)
|
|
364
|
-
== """
|
|
365
|
-
tuple_passthrough(arg0: Tuple[bool, str, int]) -> Tuple[int, str, bool]
|
|
366
|
-
|
|
367
|
-
Return a triple in reversed order
|
|
368
|
-
"""
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
assert m.rvalue_pair() == ("rvalue", "rvalue")
|
|
372
|
-
assert m.lvalue_pair() == ("lvalue", "lvalue")
|
|
373
|
-
assert m.rvalue_tuple() == ("rvalue", "rvalue", "rvalue")
|
|
374
|
-
assert m.lvalue_tuple() == ("lvalue", "lvalue", "lvalue")
|
|
375
|
-
assert m.rvalue_nested() == ("rvalue", ("rvalue", ("rvalue", "rvalue")))
|
|
376
|
-
assert m.lvalue_nested() == ("lvalue", ("lvalue", ("lvalue", "lvalue")))
|
|
377
|
-
|
|
378
|
-
assert m.int_string_pair() == (2, "items")
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
def test_builtins_cast_return_none():
|
|
382
|
-
"""Casters produced with PYBIND11_TYPE_CASTER() should convert nullptr to None"""
|
|
383
|
-
assert m.return_none_string() is None
|
|
384
|
-
assert m.return_none_char() is None
|
|
385
|
-
assert m.return_none_bool() is None
|
|
386
|
-
assert m.return_none_int() is None
|
|
387
|
-
assert m.return_none_float() is None
|
|
388
|
-
assert m.return_none_pair() is None
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
def test_none_deferred():
|
|
392
|
-
"""None passed as various argument types should defer to other overloads"""
|
|
393
|
-
assert not m.defer_none_cstring("abc")
|
|
394
|
-
assert m.defer_none_cstring(None)
|
|
395
|
-
assert not m.defer_none_custom(UserType())
|
|
396
|
-
assert m.defer_none_custom(None)
|
|
397
|
-
assert m.nodefer_none_void(None)
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
def test_void_caster():
|
|
401
|
-
assert m.load_nullptr_t(None) is None
|
|
402
|
-
assert m.cast_nullptr_t() is None
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
def test_reference_wrapper():
|
|
406
|
-
"""std::reference_wrapper for builtin and user types"""
|
|
407
|
-
assert m.refwrap_builtin(42) == 420
|
|
408
|
-
assert m.refwrap_usertype(UserType(42)) == 42
|
|
409
|
-
assert m.refwrap_usertype_const(UserType(42)) == 42
|
|
410
|
-
|
|
411
|
-
with pytest.raises(TypeError) as excinfo:
|
|
412
|
-
m.refwrap_builtin(None)
|
|
413
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
414
|
-
|
|
415
|
-
with pytest.raises(TypeError) as excinfo:
|
|
416
|
-
m.refwrap_usertype(None)
|
|
417
|
-
assert "incompatible function arguments" in str(excinfo.value)
|
|
418
|
-
|
|
419
|
-
assert m.refwrap_lvalue().value == 1
|
|
420
|
-
assert m.refwrap_lvalue_const().value == 1
|
|
421
|
-
|
|
422
|
-
a1 = m.refwrap_list(copy=True)
|
|
423
|
-
a2 = m.refwrap_list(copy=True)
|
|
424
|
-
assert [x.value for x in a1] == [2, 3]
|
|
425
|
-
assert [x.value for x in a2] == [2, 3]
|
|
426
|
-
assert not a1[0] is a2[0] and not a1[1] is a2[1]
|
|
427
|
-
|
|
428
|
-
b1 = m.refwrap_list(copy=False)
|
|
429
|
-
b2 = m.refwrap_list(copy=False)
|
|
430
|
-
assert [x.value for x in b1] == [1, 2]
|
|
431
|
-
assert [x.value for x in b2] == [1, 2]
|
|
432
|
-
assert b1[0] is b2[0] and b1[1] is b2[1]
|
|
433
|
-
|
|
434
|
-
assert m.refwrap_iiw(IncType(5)) == 5
|
|
435
|
-
assert m.refwrap_call_iiw(IncType(10), m.refwrap_iiw) == [10, 10, 10, 10]
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
def test_complex_cast():
|
|
439
|
-
"""std::complex casts"""
|
|
440
|
-
assert m.complex_cast(1) == "1.0"
|
|
441
|
-
assert m.complex_cast(2j) == "(0.0, 2.0)"
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
def test_bool_caster():
|
|
445
|
-
"""Test bool caster implicit conversions."""
|
|
446
|
-
convert, noconvert = m.bool_passthrough, m.bool_passthrough_noconvert
|
|
447
|
-
|
|
448
|
-
def require_implicit(v):
|
|
449
|
-
pytest.raises(TypeError, noconvert, v)
|
|
450
|
-
|
|
451
|
-
def cant_convert(v):
|
|
452
|
-
pytest.raises(TypeError, convert, v)
|
|
453
|
-
|
|
454
|
-
# straight up bool
|
|
455
|
-
assert convert(True) is True
|
|
456
|
-
assert convert(False) is False
|
|
457
|
-
assert noconvert(True) is True
|
|
458
|
-
assert noconvert(False) is False
|
|
459
|
-
|
|
460
|
-
# None requires implicit conversion
|
|
461
|
-
require_implicit(None)
|
|
462
|
-
assert convert(None) is False
|
|
463
|
-
|
|
464
|
-
class A(object):
|
|
465
|
-
def __init__(self, x):
|
|
466
|
-
self.x = x
|
|
467
|
-
|
|
468
|
-
def __nonzero__(self):
|
|
469
|
-
return self.x
|
|
470
|
-
|
|
471
|
-
def __bool__(self):
|
|
472
|
-
return self.x
|
|
473
|
-
|
|
474
|
-
class B(object):
|
|
475
|
-
pass
|
|
476
|
-
|
|
477
|
-
# Arbitrary objects are not accepted
|
|
478
|
-
cant_convert(object())
|
|
479
|
-
cant_convert(B())
|
|
480
|
-
|
|
481
|
-
# Objects with __nonzero__ / __bool__ defined can be converted
|
|
482
|
-
require_implicit(A(True))
|
|
483
|
-
assert convert(A(True)) is True
|
|
484
|
-
assert convert(A(False)) is False
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
def test_numpy_bool():
|
|
488
|
-
np = pytest.importorskip("numpy")
|
|
489
|
-
|
|
490
|
-
convert, noconvert = m.bool_passthrough, m.bool_passthrough_noconvert
|
|
491
|
-
|
|
492
|
-
def cant_convert(v):
|
|
493
|
-
pytest.raises(TypeError, convert, v)
|
|
494
|
-
|
|
495
|
-
# np.bool_ is not considered implicit
|
|
496
|
-
assert convert(np.bool_(True)) is True
|
|
497
|
-
assert convert(np.bool_(False)) is False
|
|
498
|
-
assert noconvert(np.bool_(True)) is True
|
|
499
|
-
assert noconvert(np.bool_(False)) is False
|
|
500
|
-
cant_convert(np.zeros(2, dtype="int"))
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
def test_int_long():
|
|
504
|
-
"""In Python 2, a C++ int should return a Python int rather than long
|
|
505
|
-
if possible: longs are not always accepted where ints are used (such
|
|
506
|
-
as the argument to sys.exit()). A C++ long long is always a Python
|
|
507
|
-
long."""
|
|
508
|
-
|
|
509
|
-
import sys
|
|
510
|
-
|
|
511
|
-
must_be_long = type(getattr(sys, "maxint", 1) + 1)
|
|
512
|
-
assert isinstance(m.int_cast(), int)
|
|
513
|
-
assert isinstance(m.long_cast(), int)
|
|
514
|
-
assert isinstance(m.longlong_cast(), must_be_long)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
def test_void_caster_2():
|
|
518
|
-
assert m.test_void_caster()
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
def test_const_ref_caster():
|
|
522
|
-
"""Verifies that const-ref is propagated through type_caster cast_op.
|
|
523
|
-
The returned ConstRefCasted type is a minimal type that is constructed to
|
|
524
|
-
reference the casting mode used.
|
|
525
|
-
"""
|
|
526
|
-
x = False
|
|
527
|
-
assert m.takes(x) == 1
|
|
528
|
-
assert m.takes_move(x) == 1
|
|
529
|
-
|
|
530
|
-
assert m.takes_ptr(x) == 3
|
|
531
|
-
assert m.takes_ref(x) == 2
|
|
532
|
-
assert m.takes_ref_wrap(x) == 2
|
|
533
|
-
|
|
534
|
-
assert m.takes_const_ptr(x) == 5
|
|
535
|
-
assert m.takes_const_ref(x) == 4
|
|
536
|
-
assert m.takes_const_ref_wrap(x) == 4
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
tests/test_call_policies.cpp -- keep_alive and call_guard
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
|
|
5
|
-
|
|
6
|
-
All rights reserved. Use of this source code is governed by a
|
|
7
|
-
BSD-style license that can be found in the LICENSE file.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
#include "pybind11_tests.h"
|
|
11
|
-
|
|
12
|
-
struct CustomGuard {
|
|
13
|
-
static bool enabled;
|
|
14
|
-
|
|
15
|
-
CustomGuard() { enabled = true; }
|
|
16
|
-
~CustomGuard() { enabled = false; }
|
|
17
|
-
|
|
18
|
-
static const char *report_status() { return enabled ? "guarded" : "unguarded"; }
|
|
19
|
-
};
|
|
20
|
-
bool CustomGuard::enabled = false;
|
|
21
|
-
|
|
22
|
-
struct DependentGuard {
|
|
23
|
-
static bool enabled;
|
|
24
|
-
|
|
25
|
-
DependentGuard() { enabled = CustomGuard::enabled; }
|
|
26
|
-
~DependentGuard() { enabled = false; }
|
|
27
|
-
|
|
28
|
-
static const char *report_status() { return enabled ? "guarded" : "unguarded"; }
|
|
29
|
-
};
|
|
30
|
-
bool DependentGuard::enabled = false;
|
|
31
|
-
|
|
32
|
-
TEST_SUBMODULE(call_policies, m) {
|
|
33
|
-
// Parent/Child are used in:
|
|
34
|
-
// test_keep_alive_argument, test_keep_alive_return_value, test_alive_gc_derived,
|
|
35
|
-
// test_alive_gc_multi_derived, test_return_none, test_keep_alive_constructor
|
|
36
|
-
class Child {
|
|
37
|
-
public:
|
|
38
|
-
Child() { py::print("Allocating child."); }
|
|
39
|
-
Child(const Child &) = default;
|
|
40
|
-
Child(Child &&) = default;
|
|
41
|
-
~Child() { py::print("Releasing child."); }
|
|
42
|
-
};
|
|
43
|
-
py::class_<Child>(m, "Child")
|
|
44
|
-
.def(py::init<>());
|
|
45
|
-
|
|
46
|
-
class Parent {
|
|
47
|
-
public:
|
|
48
|
-
Parent() { py::print("Allocating parent."); }
|
|
49
|
-
Parent(const Parent& parent) = default;
|
|
50
|
-
~Parent() { py::print("Releasing parent."); }
|
|
51
|
-
void addChild(Child *) { }
|
|
52
|
-
Child *returnChild() { return new Child(); }
|
|
53
|
-
Child *returnNullChild() { return nullptr; }
|
|
54
|
-
static Child *staticFunction(Parent*) { return new Child(); }
|
|
55
|
-
};
|
|
56
|
-
py::class_<Parent>(m, "Parent")
|
|
57
|
-
.def(py::init<>())
|
|
58
|
-
.def(py::init([](Child *) { return new Parent(); }), py::keep_alive<1, 2>())
|
|
59
|
-
.def("addChild", &Parent::addChild)
|
|
60
|
-
.def("addChildKeepAlive", &Parent::addChild, py::keep_alive<1, 2>())
|
|
61
|
-
.def("returnChild", &Parent::returnChild)
|
|
62
|
-
.def("returnChildKeepAlive", &Parent::returnChild, py::keep_alive<1, 0>())
|
|
63
|
-
.def("returnNullChildKeepAliveChild", &Parent::returnNullChild, py::keep_alive<1, 0>())
|
|
64
|
-
.def("returnNullChildKeepAliveParent", &Parent::returnNullChild, py::keep_alive<0, 1>())
|
|
65
|
-
.def_static(
|
|
66
|
-
"staticFunction", &Parent::staticFunction, py::keep_alive<1, 0>());
|
|
67
|
-
|
|
68
|
-
m.def("free_function", [](Parent*, Child*) {}, py::keep_alive<1, 2>());
|
|
69
|
-
m.def("invalid_arg_index", []{}, py::keep_alive<0, 1>());
|
|
70
|
-
|
|
71
|
-
#if !defined(PYPY_VERSION)
|
|
72
|
-
// test_alive_gc
|
|
73
|
-
class ParentGC : public Parent {
|
|
74
|
-
public:
|
|
75
|
-
using Parent::Parent;
|
|
76
|
-
};
|
|
77
|
-
py::class_<ParentGC, Parent>(m, "ParentGC", py::dynamic_attr())
|
|
78
|
-
.def(py::init<>());
|
|
79
|
-
#endif
|
|
80
|
-
|
|
81
|
-
// test_call_guard
|
|
82
|
-
m.def("unguarded_call", &CustomGuard::report_status);
|
|
83
|
-
m.def("guarded_call", &CustomGuard::report_status, py::call_guard<CustomGuard>());
|
|
84
|
-
|
|
85
|
-
m.def("multiple_guards_correct_order", []() {
|
|
86
|
-
return CustomGuard::report_status() + std::string(" & ") + DependentGuard::report_status();
|
|
87
|
-
}, py::call_guard<CustomGuard, DependentGuard>());
|
|
88
|
-
|
|
89
|
-
m.def("multiple_guards_wrong_order", []() {
|
|
90
|
-
return DependentGuard::report_status() + std::string(" & ") + CustomGuard::report_status();
|
|
91
|
-
}, py::call_guard<DependentGuard, CustomGuard>());
|
|
92
|
-
|
|
93
|
-
#if defined(WITH_THREAD) && !defined(PYPY_VERSION)
|
|
94
|
-
// `py::call_guard<py::gil_scoped_release>()` should work in PyPy as well,
|
|
95
|
-
// but it's unclear how to test it without `PyGILState_GetThisThreadState`.
|
|
96
|
-
auto report_gil_status = []() {
|
|
97
|
-
auto is_gil_held = false;
|
|
98
|
-
if (auto tstate = py::detail::get_thread_state_unchecked())
|
|
99
|
-
is_gil_held = (tstate == PyGILState_GetThisThreadState());
|
|
100
|
-
|
|
101
|
-
return is_gil_held ? "GIL held" : "GIL released";
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
m.def("with_gil", report_gil_status);
|
|
105
|
-
m.def("without_gil", report_gil_status, py::call_guard<py::gil_scoped_release>());
|
|
106
|
-
#endif
|
|
107
|
-
}
|