xcoll 0.4.0__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +2 -1
- xcoll/beam_elements/__init__.py +9 -2
- xcoll/beam_elements/absorber.py +2 -2
- xcoll/beam_elements/base.py +105 -67
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
- xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
- 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 +19 -2
- xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
- xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
- xcoll/beam_elements/everest.py +5 -6
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +103 -74
- xcoll/general.py +4 -4
- xcoll/initial_distribution.py +18 -6
- xcoll/install.py +3 -1
- xcoll/interaction_record/interaction_record.py +127 -81
- xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
- xcoll/line_tools.py +8 -9
- xcoll/lossmap.py +48 -38
- xcoll/scattering_routines/everest/amorphous.h +4 -11
- xcoll/scattering_routines/everest/channeling.h +3 -8
- xcoll/scattering_routines/everest/everest.h +4 -1
- xcoll/scattering_routines/everest/jaw.h +4 -3
- xcoll/scattering_routines/everest/materials.py +35 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
- 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/collimator_geometry.h +9 -10
- xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/METADATA +1 -1
- xcoll-0.5.1.dist-info/RECORD +413 -0
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.4.0.dist-info/RECORD +0 -126
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/LICENSE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/NOTICE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
import env # noqa: F401
|
|
5
|
+
from pybind11_tests import kwargs_and_defaults as m
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_function_signatures(doc):
|
|
9
|
+
assert doc(m.kw_func0) == "kw_func0(arg0: int, arg1: int) -> str"
|
|
10
|
+
assert doc(m.kw_func1) == "kw_func1(x: int, y: int) -> str"
|
|
11
|
+
assert doc(m.kw_func2) == "kw_func2(x: int = 100, y: int = 200) -> str"
|
|
12
|
+
assert doc(m.kw_func3) == "kw_func3(data: str = 'Hello world!') -> None"
|
|
13
|
+
assert doc(m.kw_func4) == "kw_func4(myList: List[int] = [13, 17]) -> str"
|
|
14
|
+
assert doc(m.kw_func_udl) == "kw_func_udl(x: int, y: int = 300) -> str"
|
|
15
|
+
assert doc(m.kw_func_udl_z) == "kw_func_udl_z(x: int, y: int = 0) -> str"
|
|
16
|
+
assert doc(m.args_function) == "args_function(*args) -> tuple"
|
|
17
|
+
assert (
|
|
18
|
+
doc(m.args_kwargs_function) == "args_kwargs_function(*args, **kwargs) -> tuple"
|
|
19
|
+
)
|
|
20
|
+
assert (
|
|
21
|
+
doc(m.KWClass.foo0)
|
|
22
|
+
== "foo0(self: m.kwargs_and_defaults.KWClass, arg0: int, arg1: float) -> None"
|
|
23
|
+
)
|
|
24
|
+
assert (
|
|
25
|
+
doc(m.KWClass.foo1)
|
|
26
|
+
== "foo1(self: m.kwargs_and_defaults.KWClass, x: int, y: float) -> None"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_named_arguments(msg):
|
|
31
|
+
assert m.kw_func0(5, 10) == "x=5, y=10"
|
|
32
|
+
|
|
33
|
+
assert m.kw_func1(5, 10) == "x=5, y=10"
|
|
34
|
+
assert m.kw_func1(5, y=10) == "x=5, y=10"
|
|
35
|
+
assert m.kw_func1(y=10, x=5) == "x=5, y=10"
|
|
36
|
+
|
|
37
|
+
assert m.kw_func2() == "x=100, y=200"
|
|
38
|
+
assert m.kw_func2(5) == "x=5, y=200"
|
|
39
|
+
assert m.kw_func2(x=5) == "x=5, y=200"
|
|
40
|
+
assert m.kw_func2(y=10) == "x=100, y=10"
|
|
41
|
+
assert m.kw_func2(5, 10) == "x=5, y=10"
|
|
42
|
+
assert m.kw_func2(x=5, y=10) == "x=5, y=10"
|
|
43
|
+
|
|
44
|
+
with pytest.raises(TypeError) as excinfo:
|
|
45
|
+
# noinspection PyArgumentList
|
|
46
|
+
m.kw_func2(x=5, y=10, z=12)
|
|
47
|
+
assert excinfo.match(
|
|
48
|
+
r"(?s)^kw_func2\(\): incompatible.*Invoked with: kwargs: ((x=5|y=10|z=12)(, |$))"
|
|
49
|
+
+ "{3}$"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
assert m.kw_func4() == "{13 17}"
|
|
53
|
+
assert m.kw_func4(myList=[1, 2, 3]) == "{1 2 3}"
|
|
54
|
+
|
|
55
|
+
assert m.kw_func_udl(x=5, y=10) == "x=5, y=10"
|
|
56
|
+
assert m.kw_func_udl_z(x=5) == "x=5, y=0"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_arg_and_kwargs():
|
|
60
|
+
args = "arg1_value", "arg2_value", 3
|
|
61
|
+
assert m.args_function(*args) == args
|
|
62
|
+
|
|
63
|
+
args = "a1", "a2"
|
|
64
|
+
kwargs = dict(arg3="a3", arg4=4)
|
|
65
|
+
assert m.args_kwargs_function(*args, **kwargs) == (args, kwargs)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_mixed_args_and_kwargs(msg):
|
|
69
|
+
mpa = m.mixed_plus_args
|
|
70
|
+
mpk = m.mixed_plus_kwargs
|
|
71
|
+
mpak = m.mixed_plus_args_kwargs
|
|
72
|
+
mpakd = m.mixed_plus_args_kwargs_defaults
|
|
73
|
+
|
|
74
|
+
assert mpa(1, 2.5, 4, 99.5, None) == (1, 2.5, (4, 99.5, None))
|
|
75
|
+
assert mpa(1, 2.5) == (1, 2.5, ())
|
|
76
|
+
with pytest.raises(TypeError) as excinfo:
|
|
77
|
+
assert mpa(1)
|
|
78
|
+
assert (
|
|
79
|
+
msg(excinfo.value)
|
|
80
|
+
== """
|
|
81
|
+
mixed_plus_args(): incompatible function arguments. The following argument types are supported:
|
|
82
|
+
1. (arg0: int, arg1: float, *args) -> tuple
|
|
83
|
+
|
|
84
|
+
Invoked with: 1
|
|
85
|
+
""" # noqa: E501 line too long
|
|
86
|
+
)
|
|
87
|
+
with pytest.raises(TypeError) as excinfo:
|
|
88
|
+
assert mpa()
|
|
89
|
+
assert (
|
|
90
|
+
msg(excinfo.value)
|
|
91
|
+
== """
|
|
92
|
+
mixed_plus_args(): incompatible function arguments. The following argument types are supported:
|
|
93
|
+
1. (arg0: int, arg1: float, *args) -> tuple
|
|
94
|
+
|
|
95
|
+
Invoked with:
|
|
96
|
+
""" # noqa: E501 line too long
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
assert mpk(-2, 3.5, pi=3.14159, e=2.71828) == (
|
|
100
|
+
-2,
|
|
101
|
+
3.5,
|
|
102
|
+
{"e": 2.71828, "pi": 3.14159},
|
|
103
|
+
)
|
|
104
|
+
assert mpak(7, 7.7, 7.77, 7.777, 7.7777, minusseven=-7) == (
|
|
105
|
+
7,
|
|
106
|
+
7.7,
|
|
107
|
+
(7.77, 7.777, 7.7777),
|
|
108
|
+
{"minusseven": -7},
|
|
109
|
+
)
|
|
110
|
+
assert mpakd() == (1, 3.14159, (), {})
|
|
111
|
+
assert mpakd(3) == (3, 3.14159, (), {})
|
|
112
|
+
assert mpakd(j=2.71828) == (1, 2.71828, (), {})
|
|
113
|
+
assert mpakd(k=42) == (1, 3.14159, (), {"k": 42})
|
|
114
|
+
assert mpakd(1, 1, 2, 3, 5, 8, then=13, followedby=21) == (
|
|
115
|
+
1,
|
|
116
|
+
1,
|
|
117
|
+
(2, 3, 5, 8),
|
|
118
|
+
{"then": 13, "followedby": 21},
|
|
119
|
+
)
|
|
120
|
+
# Arguments specified both positionally and via kwargs should fail:
|
|
121
|
+
with pytest.raises(TypeError) as excinfo:
|
|
122
|
+
assert mpakd(1, i=1)
|
|
123
|
+
assert (
|
|
124
|
+
msg(excinfo.value)
|
|
125
|
+
== """
|
|
126
|
+
mixed_plus_args_kwargs_defaults(): incompatible function arguments. The following argument types are supported:
|
|
127
|
+
1. (i: int = 1, j: float = 3.14159, *args, **kwargs) -> tuple
|
|
128
|
+
|
|
129
|
+
Invoked with: 1; kwargs: i=1
|
|
130
|
+
""" # noqa: E501 line too long
|
|
131
|
+
)
|
|
132
|
+
with pytest.raises(TypeError) as excinfo:
|
|
133
|
+
assert mpakd(1, 2, j=1)
|
|
134
|
+
assert (
|
|
135
|
+
msg(excinfo.value)
|
|
136
|
+
== """
|
|
137
|
+
mixed_plus_args_kwargs_defaults(): incompatible function arguments. The following argument types are supported:
|
|
138
|
+
1. (i: int = 1, j: float = 3.14159, *args, **kwargs) -> tuple
|
|
139
|
+
|
|
140
|
+
Invoked with: 1, 2; kwargs: j=1
|
|
141
|
+
""" # noqa: E501 line too long
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_keyword_only_args(msg):
|
|
146
|
+
assert m.kw_only_all(i=1, j=2) == (1, 2)
|
|
147
|
+
assert m.kw_only_all(j=1, i=2) == (2, 1)
|
|
148
|
+
|
|
149
|
+
with pytest.raises(TypeError) as excinfo:
|
|
150
|
+
assert m.kw_only_all(i=1) == (1,)
|
|
151
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
152
|
+
|
|
153
|
+
with pytest.raises(TypeError) as excinfo:
|
|
154
|
+
assert m.kw_only_all(1, 2) == (1, 2)
|
|
155
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
156
|
+
|
|
157
|
+
assert m.kw_only_some(1, k=3, j=2) == (1, 2, 3)
|
|
158
|
+
|
|
159
|
+
assert m.kw_only_with_defaults(z=8) == (3, 4, 5, 8)
|
|
160
|
+
assert m.kw_only_with_defaults(2, z=8) == (2, 4, 5, 8)
|
|
161
|
+
assert m.kw_only_with_defaults(2, j=7, k=8, z=9) == (2, 7, 8, 9)
|
|
162
|
+
assert m.kw_only_with_defaults(2, 7, z=9, k=8) == (2, 7, 8, 9)
|
|
163
|
+
|
|
164
|
+
assert m.kw_only_mixed(1, j=2) == (1, 2)
|
|
165
|
+
assert m.kw_only_mixed(j=2, i=3) == (3, 2)
|
|
166
|
+
assert m.kw_only_mixed(i=2, j=3) == (2, 3)
|
|
167
|
+
|
|
168
|
+
assert m.kw_only_plus_more(4, 5, k=6, extra=7) == (4, 5, 6, {"extra": 7})
|
|
169
|
+
assert m.kw_only_plus_more(3, k=5, j=4, extra=6) == (3, 4, 5, {"extra": 6})
|
|
170
|
+
assert m.kw_only_plus_more(2, k=3, extra=4) == (2, -1, 3, {"extra": 4})
|
|
171
|
+
|
|
172
|
+
with pytest.raises(TypeError) as excinfo:
|
|
173
|
+
assert m.kw_only_mixed(i=1) == (1,)
|
|
174
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
175
|
+
|
|
176
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
177
|
+
m.register_invalid_kw_only(m)
|
|
178
|
+
assert (
|
|
179
|
+
msg(excinfo.value)
|
|
180
|
+
== """
|
|
181
|
+
arg(): cannot specify an unnamed argument after an kw_only() annotation
|
|
182
|
+
"""
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_positional_only_args(msg):
|
|
187
|
+
assert m.pos_only_all(1, 2) == (1, 2)
|
|
188
|
+
assert m.pos_only_all(2, 1) == (2, 1)
|
|
189
|
+
|
|
190
|
+
with pytest.raises(TypeError) as excinfo:
|
|
191
|
+
m.pos_only_all(i=1, j=2)
|
|
192
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
193
|
+
|
|
194
|
+
assert m.pos_only_mix(1, 2) == (1, 2)
|
|
195
|
+
assert m.pos_only_mix(2, j=1) == (2, 1)
|
|
196
|
+
|
|
197
|
+
with pytest.raises(TypeError) as excinfo:
|
|
198
|
+
m.pos_only_mix(i=1, j=2)
|
|
199
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
200
|
+
|
|
201
|
+
assert m.pos_kw_only_mix(1, 2, k=3) == (1, 2, 3)
|
|
202
|
+
assert m.pos_kw_only_mix(1, j=2, k=3) == (1, 2, 3)
|
|
203
|
+
|
|
204
|
+
with pytest.raises(TypeError) as excinfo:
|
|
205
|
+
m.pos_kw_only_mix(i=1, j=2, k=3)
|
|
206
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
207
|
+
|
|
208
|
+
with pytest.raises(TypeError) as excinfo:
|
|
209
|
+
m.pos_kw_only_mix(1, 2, 3)
|
|
210
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
211
|
+
|
|
212
|
+
with pytest.raises(TypeError) as excinfo:
|
|
213
|
+
m.pos_only_def_mix()
|
|
214
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
215
|
+
|
|
216
|
+
assert m.pos_only_def_mix(1) == (1, 2, 3)
|
|
217
|
+
assert m.pos_only_def_mix(1, 4) == (1, 4, 3)
|
|
218
|
+
assert m.pos_only_def_mix(1, 4, 7) == (1, 4, 7)
|
|
219
|
+
assert m.pos_only_def_mix(1, 4, k=7) == (1, 4, 7)
|
|
220
|
+
|
|
221
|
+
with pytest.raises(TypeError) as excinfo:
|
|
222
|
+
m.pos_only_def_mix(1, j=4)
|
|
223
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def test_signatures():
|
|
227
|
+
assert "kw_only_all(*, i: int, j: int) -> tuple\n" == m.kw_only_all.__doc__
|
|
228
|
+
assert "kw_only_mixed(i: int, *, j: int) -> tuple\n" == m.kw_only_mixed.__doc__
|
|
229
|
+
assert "pos_only_all(i: int, j: int, /) -> tuple\n" == m.pos_only_all.__doc__
|
|
230
|
+
assert "pos_only_mix(i: int, /, j: int) -> tuple\n" == m.pos_only_mix.__doc__
|
|
231
|
+
assert (
|
|
232
|
+
"pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple\n"
|
|
233
|
+
== m.pos_kw_only_mix.__doc__
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@pytest.mark.xfail("env.PYPY and env.PY2", reason="PyPy2 doesn't double count")
|
|
238
|
+
def test_args_refcount():
|
|
239
|
+
"""Issue/PR #1216 - py::args elements get double-inc_ref()ed when combined with regular
|
|
240
|
+
arguments"""
|
|
241
|
+
refcount = m.arg_refcount_h
|
|
242
|
+
|
|
243
|
+
myval = 54321
|
|
244
|
+
expected = refcount(myval)
|
|
245
|
+
assert m.arg_refcount_h(myval) == expected
|
|
246
|
+
assert m.arg_refcount_o(myval) == expected + 1
|
|
247
|
+
assert m.arg_refcount_h(myval) == expected
|
|
248
|
+
assert refcount(myval) == expected
|
|
249
|
+
|
|
250
|
+
assert m.mixed_plus_args(1, 2.0, "a", myval) == (1, 2.0, ("a", myval))
|
|
251
|
+
assert refcount(myval) == expected
|
|
252
|
+
|
|
253
|
+
assert m.mixed_plus_kwargs(3, 4.0, a=1, b=myval) == (3, 4.0, {"a": 1, "b": myval})
|
|
254
|
+
assert refcount(myval) == expected
|
|
255
|
+
|
|
256
|
+
assert m.args_function(-1, myval) == (-1, myval)
|
|
257
|
+
assert refcount(myval) == expected
|
|
258
|
+
|
|
259
|
+
assert m.mixed_plus_args_kwargs(5, 6.0, myval, a=myval) == (
|
|
260
|
+
5,
|
|
261
|
+
6.0,
|
|
262
|
+
(myval,),
|
|
263
|
+
{"a": myval},
|
|
264
|
+
)
|
|
265
|
+
assert refcount(myval) == expected
|
|
266
|
+
|
|
267
|
+
assert m.args_kwargs_function(7, 8, myval, a=1, b=myval) == (
|
|
268
|
+
(7, 8, myval),
|
|
269
|
+
{"a": 1, "b": myval},
|
|
270
|
+
)
|
|
271
|
+
assert refcount(myval) == expected
|
|
272
|
+
|
|
273
|
+
exp3 = refcount(myval, myval, myval)
|
|
274
|
+
assert m.args_refcount(myval, myval, myval) == (exp3, exp3, exp3)
|
|
275
|
+
assert refcount(myval) == expected
|
|
276
|
+
|
|
277
|
+
# This function takes the first arg as a `py::object` and the rest as a `py::args`. Unlike the
|
|
278
|
+
# previous case, when we have both positional and `py::args` we need to construct a new tuple
|
|
279
|
+
# for the `py::args`; in the previous case, we could simply inc_ref and pass on Python's input
|
|
280
|
+
# tuple without having to inc_ref the individual elements, but here we can't, hence the extra
|
|
281
|
+
# refs.
|
|
282
|
+
assert m.mixed_args_refcount(myval, myval, myval) == (exp3 + 3, exp3 + 3, exp3 + 3)
|
|
283
|
+
|
|
284
|
+
assert m.class_default_argument() == "<class 'decimal.Decimal'>"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
tests/test_local_bindings.cpp -- tests the py::module_local class feature which makes a class
|
|
3
|
+
binding local to the module in which it is defined.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2017 Jason Rhinelander <jason@imaginary.ca>
|
|
6
|
+
|
|
7
|
+
All rights reserved. Use of this source code is governed by a
|
|
8
|
+
BSD-style license that can be found in the LICENSE file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "pybind11_tests.h"
|
|
12
|
+
#include "local_bindings.h"
|
|
13
|
+
|
|
14
|
+
#include <pybind11/stl.h>
|
|
15
|
+
#include <pybind11/stl_bind.h>
|
|
16
|
+
|
|
17
|
+
#include <numeric>
|
|
18
|
+
#include <utility>
|
|
19
|
+
|
|
20
|
+
TEST_SUBMODULE(local_bindings, m) {
|
|
21
|
+
// test_load_external
|
|
22
|
+
m.def("load_external1", [](ExternalType1 &e) { return e.i; });
|
|
23
|
+
m.def("load_external2", [](ExternalType2 &e) { return e.i; });
|
|
24
|
+
|
|
25
|
+
// test_local_bindings
|
|
26
|
+
// Register a class with py::module_local:
|
|
27
|
+
bind_local<LocalType, -1>(m, "LocalType", py::module_local())
|
|
28
|
+
.def("get3", [](LocalType &t) { return t.i + 3; })
|
|
29
|
+
;
|
|
30
|
+
|
|
31
|
+
m.def("local_value", [](LocalType &l) { return l.i; });
|
|
32
|
+
|
|
33
|
+
// test_nonlocal_failure
|
|
34
|
+
// The main pybind11 test module is loaded first, so this registration will succeed (the second
|
|
35
|
+
// one, in pybind11_cross_module_tests.cpp, is designed to fail):
|
|
36
|
+
bind_local<NonLocalType, 0>(m, "NonLocalType")
|
|
37
|
+
.def(py::init<int>())
|
|
38
|
+
.def("get", [](LocalType &i) { return i.i; })
|
|
39
|
+
;
|
|
40
|
+
|
|
41
|
+
// test_duplicate_local
|
|
42
|
+
// py::module_local declarations should be visible across compilation units that get linked together;
|
|
43
|
+
// this tries to register a duplicate local. It depends on a definition in test_class.cpp and
|
|
44
|
+
// should raise a runtime error from the duplicate definition attempt. If test_class isn't
|
|
45
|
+
// available it *also* throws a runtime error (with "test_class not enabled" as value).
|
|
46
|
+
m.def("register_local_external", [m]() {
|
|
47
|
+
auto main = py::module_::import("pybind11_tests");
|
|
48
|
+
if (py::hasattr(main, "class_")) {
|
|
49
|
+
bind_local<LocalExternal, 7>(m, "LocalExternal", py::module_local());
|
|
50
|
+
}
|
|
51
|
+
else throw std::runtime_error("test_class not enabled");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// test_stl_bind_local
|
|
55
|
+
// stl_bind.h binders defaults to py::module_local if the types are local or converting:
|
|
56
|
+
py::bind_vector<LocalVec>(m, "LocalVec");
|
|
57
|
+
py::bind_map<LocalMap>(m, "LocalMap");
|
|
58
|
+
// and global if the type (or one of the types, for the map) is global:
|
|
59
|
+
py::bind_vector<NonLocalVec>(m, "NonLocalVec");
|
|
60
|
+
py::bind_map<NonLocalMap>(m, "NonLocalMap");
|
|
61
|
+
|
|
62
|
+
// test_stl_bind_global
|
|
63
|
+
// They can, however, be overridden to global using `py::module_local(false)`:
|
|
64
|
+
bind_local<NonLocal2, 10>(m, "NonLocal2");
|
|
65
|
+
py::bind_vector<LocalVec2>(m, "LocalVec2", py::module_local());
|
|
66
|
+
py::bind_map<NonLocalMap2>(m, "NonLocalMap2", py::module_local(false));
|
|
67
|
+
|
|
68
|
+
// test_mixed_local_global
|
|
69
|
+
// We try this both with the global type registered first and vice versa (the order shouldn't
|
|
70
|
+
// matter).
|
|
71
|
+
m.def("register_mixed_global", [m]() {
|
|
72
|
+
bind_local<MixedGlobalLocal, 100>(m, "MixedGlobalLocal", py::module_local(false));
|
|
73
|
+
});
|
|
74
|
+
m.def("register_mixed_local", [m]() {
|
|
75
|
+
bind_local<MixedLocalGlobal, 1000>(m, "MixedLocalGlobal", py::module_local());
|
|
76
|
+
});
|
|
77
|
+
m.def("get_mixed_gl", [](int i) { return MixedGlobalLocal(i); });
|
|
78
|
+
m.def("get_mixed_lg", [](int i) { return MixedLocalGlobal(i); });
|
|
79
|
+
|
|
80
|
+
// test_internal_locals_differ
|
|
81
|
+
m.def("local_cpp_types_addr", []() { return (uintptr_t) &py::detail::get_local_internals().registered_types_cpp; });
|
|
82
|
+
|
|
83
|
+
// test_stl_caster_vs_stl_bind
|
|
84
|
+
m.def("load_vector_via_caster", [](std::vector<int> v) {
|
|
85
|
+
return std::accumulate(v.begin(), v.end(), 0);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// test_cross_module_calls
|
|
89
|
+
m.def("return_self", [](LocalVec *v) { return v; });
|
|
90
|
+
m.def("return_copy", [](const LocalVec &v) { return LocalVec(v); });
|
|
91
|
+
|
|
92
|
+
class Cat : public pets::Pet {
|
|
93
|
+
public:
|
|
94
|
+
explicit Cat(std::string name) : Pet(std::move(name)) {}
|
|
95
|
+
};
|
|
96
|
+
py::class_<pets::Pet>(m, "Pet", py::module_local())
|
|
97
|
+
.def("get_name", &pets::Pet::name);
|
|
98
|
+
// Binding for local extending class:
|
|
99
|
+
py::class_<Cat, pets::Pet>(m, "Cat")
|
|
100
|
+
.def(py::init<std::string>());
|
|
101
|
+
m.def("pet_name", [](pets::Pet &p) { return p.name(); });
|
|
102
|
+
|
|
103
|
+
py::class_<MixGL>(m, "MixGL").def(py::init<int>());
|
|
104
|
+
m.def("get_gl_value", [](MixGL &o) { return o.i + 10; });
|
|
105
|
+
|
|
106
|
+
py::class_<MixGL2>(m, "MixGL2").def(py::init<int>());
|
|
107
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
import env # noqa: F401
|
|
5
|
+
from pybind11_tests import local_bindings as m
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_load_external():
|
|
9
|
+
"""Load a `py::module_local` type that's only registered in an external module"""
|
|
10
|
+
import pybind11_cross_module_tests as cm
|
|
11
|
+
|
|
12
|
+
assert m.load_external1(cm.ExternalType1(11)) == 11
|
|
13
|
+
assert m.load_external2(cm.ExternalType2(22)) == 22
|
|
14
|
+
|
|
15
|
+
with pytest.raises(TypeError) as excinfo:
|
|
16
|
+
assert m.load_external2(cm.ExternalType1(21)) == 21
|
|
17
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
18
|
+
|
|
19
|
+
with pytest.raises(TypeError) as excinfo:
|
|
20
|
+
assert m.load_external1(cm.ExternalType2(12)) == 12
|
|
21
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_local_bindings():
|
|
25
|
+
"""Tests that duplicate `py::module_local` class bindings work across modules"""
|
|
26
|
+
|
|
27
|
+
# Make sure we can load the second module with the conflicting (but local) definition:
|
|
28
|
+
import pybind11_cross_module_tests as cm
|
|
29
|
+
|
|
30
|
+
i1 = m.LocalType(5)
|
|
31
|
+
assert i1.get() == 4
|
|
32
|
+
assert i1.get3() == 8
|
|
33
|
+
|
|
34
|
+
i2 = cm.LocalType(10)
|
|
35
|
+
assert i2.get() == 11
|
|
36
|
+
assert i2.get2() == 12
|
|
37
|
+
|
|
38
|
+
assert not hasattr(i1, "get2")
|
|
39
|
+
assert not hasattr(i2, "get3")
|
|
40
|
+
|
|
41
|
+
# Loading within the local module
|
|
42
|
+
assert m.local_value(i1) == 5
|
|
43
|
+
assert cm.local_value(i2) == 10
|
|
44
|
+
|
|
45
|
+
# Cross-module loading works as well (on failure, the type loader looks for
|
|
46
|
+
# external module-local converters):
|
|
47
|
+
assert m.local_value(i2) == 10
|
|
48
|
+
assert cm.local_value(i1) == 5
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_nonlocal_failure():
|
|
52
|
+
"""Tests that attempting to register a non-local type in multiple modules fails"""
|
|
53
|
+
import pybind11_cross_module_tests as cm
|
|
54
|
+
|
|
55
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
56
|
+
cm.register_nonlocal()
|
|
57
|
+
assert (
|
|
58
|
+
str(excinfo.value) == 'generic_type: type "NonLocalType" is already registered!'
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_duplicate_local():
|
|
63
|
+
"""Tests expected failure when registering a class twice with py::local in the same module"""
|
|
64
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
65
|
+
m.register_local_external()
|
|
66
|
+
import pybind11_tests
|
|
67
|
+
|
|
68
|
+
assert str(excinfo.value) == (
|
|
69
|
+
'generic_type: type "LocalExternal" is already registered!'
|
|
70
|
+
if hasattr(pybind11_tests, "class_")
|
|
71
|
+
else "test_class not enabled"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_stl_bind_local():
|
|
76
|
+
import pybind11_cross_module_tests as cm
|
|
77
|
+
|
|
78
|
+
v1, v2 = m.LocalVec(), cm.LocalVec()
|
|
79
|
+
v1.append(m.LocalType(1))
|
|
80
|
+
v1.append(m.LocalType(2))
|
|
81
|
+
v2.append(cm.LocalType(1))
|
|
82
|
+
v2.append(cm.LocalType(2))
|
|
83
|
+
|
|
84
|
+
# Cross module value loading:
|
|
85
|
+
v1.append(cm.LocalType(3))
|
|
86
|
+
v2.append(m.LocalType(3))
|
|
87
|
+
|
|
88
|
+
assert [i.get() for i in v1] == [0, 1, 2]
|
|
89
|
+
assert [i.get() for i in v2] == [2, 3, 4]
|
|
90
|
+
|
|
91
|
+
v3, v4 = m.NonLocalVec(), cm.NonLocalVec2()
|
|
92
|
+
v3.append(m.NonLocalType(1))
|
|
93
|
+
v3.append(m.NonLocalType(2))
|
|
94
|
+
v4.append(m.NonLocal2(3))
|
|
95
|
+
v4.append(m.NonLocal2(4))
|
|
96
|
+
|
|
97
|
+
assert [i.get() for i in v3] == [1, 2]
|
|
98
|
+
assert [i.get() for i in v4] == [13, 14]
|
|
99
|
+
|
|
100
|
+
d1, d2 = m.LocalMap(), cm.LocalMap()
|
|
101
|
+
d1["a"] = v1[0]
|
|
102
|
+
d1["b"] = v1[1]
|
|
103
|
+
d2["c"] = v2[0]
|
|
104
|
+
d2["d"] = v2[1]
|
|
105
|
+
assert {i: d1[i].get() for i in d1} == {"a": 0, "b": 1}
|
|
106
|
+
assert {i: d2[i].get() for i in d2} == {"c": 2, "d": 3}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_stl_bind_global():
|
|
110
|
+
import pybind11_cross_module_tests as cm
|
|
111
|
+
|
|
112
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
113
|
+
cm.register_nonlocal_map()
|
|
114
|
+
assert (
|
|
115
|
+
str(excinfo.value) == 'generic_type: type "NonLocalMap" is already registered!'
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
119
|
+
cm.register_nonlocal_vec()
|
|
120
|
+
assert (
|
|
121
|
+
str(excinfo.value) == 'generic_type: type "NonLocalVec" is already registered!'
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
with pytest.raises(RuntimeError) as excinfo:
|
|
125
|
+
cm.register_nonlocal_map2()
|
|
126
|
+
assert (
|
|
127
|
+
str(excinfo.value) == 'generic_type: type "NonLocalMap2" is already registered!'
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_mixed_local_global():
|
|
132
|
+
"""Local types take precedence over globally registered types: a module with a `module_local`
|
|
133
|
+
type can be registered even if the type is already registered globally. With the module,
|
|
134
|
+
casting will go to the local type; outside the module casting goes to the global type."""
|
|
135
|
+
import pybind11_cross_module_tests as cm
|
|
136
|
+
|
|
137
|
+
m.register_mixed_global()
|
|
138
|
+
m.register_mixed_local()
|
|
139
|
+
|
|
140
|
+
a = []
|
|
141
|
+
a.append(m.MixedGlobalLocal(1))
|
|
142
|
+
a.append(m.MixedLocalGlobal(2))
|
|
143
|
+
a.append(m.get_mixed_gl(3))
|
|
144
|
+
a.append(m.get_mixed_lg(4))
|
|
145
|
+
|
|
146
|
+
assert [x.get() for x in a] == [101, 1002, 103, 1004]
|
|
147
|
+
|
|
148
|
+
cm.register_mixed_global_local()
|
|
149
|
+
cm.register_mixed_local_global()
|
|
150
|
+
a.append(m.MixedGlobalLocal(5))
|
|
151
|
+
a.append(m.MixedLocalGlobal(6))
|
|
152
|
+
a.append(cm.MixedGlobalLocal(7))
|
|
153
|
+
a.append(cm.MixedLocalGlobal(8))
|
|
154
|
+
a.append(m.get_mixed_gl(9))
|
|
155
|
+
a.append(m.get_mixed_lg(10))
|
|
156
|
+
a.append(cm.get_mixed_gl(11))
|
|
157
|
+
a.append(cm.get_mixed_lg(12))
|
|
158
|
+
|
|
159
|
+
assert [x.get() for x in a] == [
|
|
160
|
+
101,
|
|
161
|
+
1002,
|
|
162
|
+
103,
|
|
163
|
+
1004,
|
|
164
|
+
105,
|
|
165
|
+
1006,
|
|
166
|
+
207,
|
|
167
|
+
2008,
|
|
168
|
+
109,
|
|
169
|
+
1010,
|
|
170
|
+
211,
|
|
171
|
+
2012,
|
|
172
|
+
]
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_internal_locals_differ():
|
|
176
|
+
"""Makes sure the internal local type map differs across the two modules"""
|
|
177
|
+
import pybind11_cross_module_tests as cm
|
|
178
|
+
|
|
179
|
+
assert m.local_cpp_types_addr() != cm.local_cpp_types_addr()
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@pytest.mark.xfail("env.PYPY and sys.pypy_version_info < (7, 3, 2)")
|
|
183
|
+
def test_stl_caster_vs_stl_bind(msg):
|
|
184
|
+
"""One module uses a generic vector caster from `<pybind11/stl.h>` while the other
|
|
185
|
+
exports `std::vector<int>` via `py:bind_vector` and `py::module_local`"""
|
|
186
|
+
import pybind11_cross_module_tests as cm
|
|
187
|
+
|
|
188
|
+
v1 = cm.VectorInt([1, 2, 3])
|
|
189
|
+
assert m.load_vector_via_caster(v1) == 6
|
|
190
|
+
assert cm.load_vector_via_binding(v1) == 6
|
|
191
|
+
|
|
192
|
+
v2 = [1, 2, 3]
|
|
193
|
+
assert m.load_vector_via_caster(v2) == 6
|
|
194
|
+
with pytest.raises(TypeError) as excinfo:
|
|
195
|
+
cm.load_vector_via_binding(v2)
|
|
196
|
+
assert (
|
|
197
|
+
msg(excinfo.value)
|
|
198
|
+
== """
|
|
199
|
+
load_vector_via_binding(): incompatible function arguments. The following argument types are supported:
|
|
200
|
+
1. (arg0: pybind11_cross_module_tests.VectorInt) -> int
|
|
201
|
+
|
|
202
|
+
Invoked with: [1, 2, 3]
|
|
203
|
+
""" # noqa: E501 line too long
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def test_cross_module_calls():
|
|
208
|
+
import pybind11_cross_module_tests as cm
|
|
209
|
+
|
|
210
|
+
v1 = m.LocalVec()
|
|
211
|
+
v1.append(m.LocalType(1))
|
|
212
|
+
v2 = cm.LocalVec()
|
|
213
|
+
v2.append(cm.LocalType(2))
|
|
214
|
+
|
|
215
|
+
# Returning the self pointer should get picked up as returning an existing
|
|
216
|
+
# instance (even when that instance is of a foreign, non-local type).
|
|
217
|
+
assert m.return_self(v1) is v1
|
|
218
|
+
assert cm.return_self(v2) is v2
|
|
219
|
+
assert m.return_self(v2) is v2
|
|
220
|
+
assert cm.return_self(v1) is v1
|
|
221
|
+
|
|
222
|
+
assert m.LocalVec is not cm.LocalVec
|
|
223
|
+
# Returning a copy, on the other hand, always goes to the local type,
|
|
224
|
+
# regardless of where the source type came from.
|
|
225
|
+
assert type(m.return_copy(v1)) is m.LocalVec
|
|
226
|
+
assert type(m.return_copy(v2)) is m.LocalVec
|
|
227
|
+
assert type(cm.return_copy(v1)) is cm.LocalVec
|
|
228
|
+
assert type(cm.return_copy(v2)) is cm.LocalVec
|
|
229
|
+
|
|
230
|
+
# Test the example given in the documentation (which also tests inheritance casting):
|
|
231
|
+
mycat = m.Cat("Fluffy")
|
|
232
|
+
mydog = cm.Dog("Rover")
|
|
233
|
+
assert mycat.get_name() == "Fluffy"
|
|
234
|
+
assert mydog.name() == "Rover"
|
|
235
|
+
assert m.Cat.__base__.__name__ == "Pet"
|
|
236
|
+
assert cm.Dog.__base__.__name__ == "Pet"
|
|
237
|
+
assert m.Cat.__base__ is not cm.Dog.__base__
|
|
238
|
+
assert m.pet_name(mycat) == "Fluffy"
|
|
239
|
+
assert m.pet_name(mydog) == "Rover"
|
|
240
|
+
assert cm.pet_name(mycat) == "Fluffy"
|
|
241
|
+
assert cm.pet_name(mydog) == "Rover"
|
|
242
|
+
|
|
243
|
+
assert m.MixGL is not cm.MixGL
|
|
244
|
+
a = m.MixGL(1)
|
|
245
|
+
b = cm.MixGL(2)
|
|
246
|
+
assert m.get_gl_value(a) == 11
|
|
247
|
+
assert m.get_gl_value(b) == 12
|
|
248
|
+
assert cm.get_gl_value(a) == 101
|
|
249
|
+
assert cm.get_gl_value(b) == 102
|
|
250
|
+
|
|
251
|
+
c, d = m.MixGL2(3), cm.MixGL2(4)
|
|
252
|
+
with pytest.raises(TypeError) as excinfo:
|
|
253
|
+
m.get_gl_value(c)
|
|
254
|
+
assert "incompatible function arguments" in str(excinfo.value)
|
|
255
|
+
with pytest.raises(TypeError) as excinfo:
|
|
256
|
+
m.get_gl_value(d)
|
|
257
|
+
assert "incompatible function arguments" in str(excinfo.value)
|