├── .gitignore ├── FTReading ├── CMakeLists.txt ├── pybind11-master │ ├── .appveyor.yml │ ├── .github │ │ └── workflows │ │ │ ├── ci.yml │ │ │ ├── configure.yml │ │ │ └── format.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .pre-commit-config.yaml │ ├── .readthedocs.yml │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE.md │ ├── LICENSE │ ├── MANIFEST.in │ ├── README.md │ ├── docs │ │ ├── Doxyfile │ │ ├── _static │ │ │ └── theme_overrides.css │ │ ├── advanced │ │ │ ├── cast │ │ │ │ ├── chrono.rst │ │ │ │ ├── custom.rst │ │ │ │ ├── eigen.rst │ │ │ │ ├── functional.rst │ │ │ │ ├── index.rst │ │ │ │ ├── overview.rst │ │ │ │ ├── stl.rst │ │ │ │ └── strings.rst │ │ │ ├── classes.rst │ │ │ ├── embedding.rst │ │ │ ├── exceptions.rst │ │ │ ├── functions.rst │ │ │ ├── misc.rst │ │ │ ├── pycpp │ │ │ │ ├── index.rst │ │ │ │ ├── numpy.rst │ │ │ │ ├── object.rst │ │ │ │ └── utilities.rst │ │ │ └── smart_ptrs.rst │ │ ├── basics.rst │ │ ├── benchmark.py │ │ ├── benchmark.rst │ │ ├── changelog.rst │ │ ├── classes.rst │ │ ├── compiling.rst │ │ ├── conf.py │ │ ├── faq.rst │ │ ├── index.rst │ │ ├── intro.rst │ │ ├── limitations.rst │ │ ├── pybind11-logo.png │ │ ├── pybind11_vs_boost_python1.png │ │ ├── pybind11_vs_boost_python1.svg │ │ ├── pybind11_vs_boost_python2.png │ │ ├── pybind11_vs_boost_python2.svg │ │ ├── reference.rst │ │ ├── release.rst │ │ ├── requirements.txt │ │ └── upgrade.rst │ ├── include │ │ └── pybind11 │ │ │ ├── attr.h │ │ │ ├── buffer_info.h │ │ │ ├── cast.h │ │ │ ├── chrono.h │ │ │ ├── common.h │ │ │ ├── complex.h │ │ │ ├── detail │ │ │ ├── class.h │ │ │ ├── common.h │ │ │ ├── descr.h │ │ │ ├── init.h │ │ │ ├── internals.h │ │ │ └── typeid.h │ │ │ ├── eigen.h │ │ │ ├── embed.h │ │ │ ├── eval.h │ │ │ ├── functional.h │ │ │ ├── iostream.h │ │ │ ├── numpy.h │ │ │ ├── operators.h │ │ │ ├── options.h │ │ │ ├── pybind11.h │ │ │ ├── pytypes.h │ │ │ ├── stl.h │ │ │ └── stl_bind.h │ ├── pybind11 │ │ ├── __init__.py │ │ ├── __main__.py │ │ └── _version.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── conftest.py │ │ ├── constructor_stats.h │ │ ├── cross_module_gil_utils.cpp │ │ ├── local_bindings.h │ │ ├── object.h │ │ ├── pybind11_cross_module_tests.cpp │ │ ├── pybind11_tests.cpp │ │ ├── pybind11_tests.h │ │ ├── pytest.ini │ │ ├── requirements.txt │ │ ├── test_async.cpp │ │ ├── test_async.py │ │ ├── test_buffers.cpp │ │ ├── test_buffers.py │ │ ├── test_builtin_casters.cpp │ │ ├── test_builtin_casters.py │ │ ├── test_call_policies.cpp │ │ ├── test_call_policies.py │ │ ├── test_callbacks.cpp │ │ ├── test_callbacks.py │ │ ├── test_chrono.cpp │ │ ├── test_chrono.py │ │ ├── test_class.cpp │ │ ├── test_class.py │ │ ├── test_cmake_build │ │ │ ├── CMakeLists.txt │ │ │ ├── embed.cpp │ │ │ ├── installed_embed │ │ │ │ └── CMakeLists.txt │ │ │ ├── installed_function │ │ │ │ └── CMakeLists.txt │ │ │ ├── installed_target │ │ │ │ └── CMakeLists.txt │ │ │ ├── main.cpp │ │ │ ├── subdirectory_embed │ │ │ │ └── CMakeLists.txt │ │ │ ├── subdirectory_function │ │ │ │ └── CMakeLists.txt │ │ │ ├── subdirectory_target │ │ │ │ └── CMakeLists.txt │ │ │ └── test.py │ │ ├── test_constants_and_functions.cpp │ │ ├── test_constants_and_functions.py │ │ ├── test_copy_move.cpp │ │ ├── test_copy_move.py │ │ ├── test_custom_type_casters.cpp │ │ ├── test_custom_type_casters.py │ │ ├── test_docstring_options.cpp │ │ ├── test_docstring_options.py │ │ ├── test_eigen.cpp │ │ ├── test_eigen.py │ │ ├── test_embed │ │ │ ├── CMakeLists.txt │ │ │ ├── catch.cpp │ │ │ ├── external_module.cpp │ │ │ ├── test_interpreter.cpp │ │ │ └── test_interpreter.py │ │ ├── test_enum.cpp │ │ ├── test_enum.py │ │ ├── test_eval.cpp │ │ ├── test_eval.py │ │ ├── test_eval_call.py │ │ ├── test_exceptions.cpp │ │ ├── test_exceptions.py │ │ ├── test_factory_constructors.cpp │ │ ├── test_factory_constructors.py │ │ ├── test_gil_scoped.cpp │ │ ├── test_gil_scoped.py │ │ ├── test_iostream.cpp │ │ ├── test_iostream.py │ │ ├── test_kwargs_and_defaults.cpp │ │ ├── test_kwargs_and_defaults.py │ │ ├── test_local_bindings.cpp │ │ ├── test_local_bindings.py │ │ ├── test_methods_and_attributes.cpp │ │ ├── test_methods_and_attributes.py │ │ ├── test_modules.cpp │ │ ├── test_modules.py │ │ ├── test_multiple_inheritance.cpp │ │ ├── test_multiple_inheritance.py │ │ ├── test_numpy_array.cpp │ │ ├── test_numpy_array.py │ │ ├── test_numpy_dtypes.cpp │ │ ├── test_numpy_dtypes.py │ │ ├── test_numpy_vectorize.cpp │ │ ├── test_numpy_vectorize.py │ │ ├── test_opaque_types.cpp │ │ ├── test_opaque_types.py │ │ ├── test_operator_overloading.cpp │ │ ├── test_operator_overloading.py │ │ ├── test_pickling.cpp │ │ ├── test_pickling.py │ │ ├── test_pytypes.cpp │ │ ├── test_pytypes.py │ │ ├── test_sequences_and_iterators.cpp │ │ ├── test_sequences_and_iterators.py │ │ ├── test_smart_ptr.cpp │ │ ├── test_smart_ptr.py │ │ ├── test_stl.cpp │ │ ├── test_stl.py │ │ ├── test_stl_binders.cpp │ │ ├── test_stl_binders.py │ │ ├── test_tagbased_polymorphic.cpp │ │ ├── test_tagbased_polymorphic.py │ │ ├── test_union.cpp │ │ ├── test_union.py │ │ ├── test_virtual_functions.cpp │ │ └── test_virtual_functions.py │ └── tools │ │ ├── FindCatch.cmake │ │ ├── FindEigen3.cmake │ │ ├── FindPythonLibsNew.cmake │ │ ├── check-style.sh │ │ ├── libsize.py │ │ ├── mkdoc.py │ │ ├── pybind11Config.cmake.in │ │ └── pybind11Tools.cmake └── src │ ├── .vscode │ ├── launch.json │ ├── settings.json │ └── tasks.json │ ├── CMakeLists.txt │ ├── Force.cpp │ ├── Force.h │ ├── main.cpp │ └── pyFT.cpp ├── README.md ├── configs ├── Image_guide1.jpeg ├── Image_guide2.jpeg ├── Image_guide3.jpeg └── UR10e.yaml ├── data ├── FT_data │ ├── .~lock.FT_data_e1.xlsx# │ ├── .~lock.FT_data_ex3.xlsx# │ ├── FT_data0.xlsx │ ├── FT_data_0.xlsx │ ├── FT_data_e0.xlsx │ ├── FT_data_e1.xlsx │ ├── FT_data_e2.xlsx │ ├── FT_data_e3.xlsx │ ├── FT_data_e4.xlsx │ ├── FT_data_e5.xlsx │ ├── FT_data_e6.xlsx │ ├── FT_data_e7.xlsx │ ├── FT_data_e8.xlsx │ ├── FT_data_e9.xlsx │ ├── data_array.xlsx │ └── r.txt └── force │ ├── force_assembly_0 │ ├── 0assembly_dataFx0_success.jpg │ ├── 0assembly_dataFy0_success.jpg │ ├── 0assembly_dataFz0_success.jpg │ ├── 0assembly_dataMx0_success.jpg │ ├── 0assembly_dataMy0_success.jpg │ └── 0assembly_dataMz0_success.jpg │ └── force_touch_0 │ ├── 0touch_dataFx0_success.jpg │ ├── 0touch_dataFy0_success.jpg │ ├── 0touch_dataFz0_success.jpg │ ├── 0touch_dataMx0_success.jpg │ ├── 0touch_dataMy0_success.jpg │ └── 0touch_dataMz0_success.jpg ├── projects ├── Assembly.py ├── Control.py ├── Multiply_assembly.py ├── Read_FT.py └── read_data.py ├── requirements.txt ├── 使用UR机械臂力控轴孔装配.mp4 ├── 使用发那科工业机械臂实现装配代码(不包含示教器部分) └── server.py ├── 使用发那科机械臂力控轴孔装配.mp4 └── 力控项目报告.docx /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | .idea/* 161 | .idea/ 162 | -------------------------------------------------------------------------------- /FTReading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(FTReading) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | set(CMAKE_CONFIGURATION_TYPES "Release") 6 | 7 | find_package(pybind11) 8 | INCLUDE_DIRECTORIES(${pybind11_INCLUDE_DIRS}) 9 | 10 | aux_source_directory(./src SRC_LIST) 11 | pybind11_add_module(FTReading ${SRC_LIST}) 12 | 13 | 14 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: 3 | - Visual Studio 2015 4 | test: off 5 | skip_branch_with_pr: true 6 | build: 7 | parallel: true 8 | platform: 9 | - x86 10 | environment: 11 | matrix: 12 | - PYTHON: 36 13 | CONFIG: Debug 14 | - PYTHON: 27 15 | CONFIG: Debug 16 | install: 17 | - ps: | 18 | $env:CMAKE_GENERATOR = "Visual Studio 14 2015" 19 | if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } 20 | $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" 21 | python -W ignore -m pip install --upgrade pip wheel 22 | python -W ignore -m pip install pytest numpy --no-warn-script-location 23 | - ps: | 24 | Start-FileDownload 'http://bitbucket.org/eigen/eigen/get/3.3.3.zip' 25 | 7z x 3.3.3.zip -y > $null 26 | $env:CMAKE_INCLUDE_PATH = "eigen-eigen-67e894c6cd8f;$env:CMAKE_INCLUDE_PATH" 27 | build_script: 28 | - cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" 29 | -DPYBIND11_CPP_STANDARD=/std:c++14 30 | -DPYBIND11_WERROR=ON 31 | -DDOWNLOAD_CATCH=ON 32 | -DCMAKE_SUPPRESS_REGENERATION=1 33 | . 34 | - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 35 | - cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% 36 | - cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% 37 | on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* 38 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.github/workflows/configure.yml: -------------------------------------------------------------------------------- 1 | name: Configure 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: 8 | - master 9 | - stable 10 | - v* 11 | 12 | jobs: 13 | cmake: 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | python: 18 | - 2.7 19 | - 3.8 20 | 21 | name: CMake ${{ matrix.cmake }} Python ${{ matrix.python }} on ubuntu 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | 27 | - name: Setup Python ${{ matrix.python }} 28 | uses: actions/setup-python@v2 29 | with: 30 | python-version: ${{ matrix.python }} 31 | 32 | - name: Prepare env 33 | run: python -m pip install -r tests/requirements.txt 34 | 35 | - name: Make build directories 36 | run: | 37 | mkdir build2.8 38 | mkdir build3.7 39 | mkdir build3.18 40 | 41 | - name: Setup CMake 2.8 42 | uses: jwlawson/actions-setup-cmake@v1.3 43 | with: 44 | cmake-version: 2.8 45 | 46 | - name: Configure 2.8 47 | working-directory: build2.8 48 | run: > 49 | cmake --version && 50 | cmake .. 51 | -DPYBIND11_WERROR=ON 52 | -DDOWNLOAD_CATCH=ON 53 | -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") 54 | 55 | - name: Setup CMake 3.7 56 | uses: jwlawson/actions-setup-cmake@v1.3 57 | with: 58 | cmake-version: 3.7 59 | 60 | - name: Configure 3.7 61 | working-directory: build3.7 62 | run: > 63 | cmake --version && 64 | cmake .. 65 | -DPYBIND11_WERROR=ON 66 | -DDOWNLOAD_CATCH=ON 67 | -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") 68 | 69 | - name: Setup CMake 3.18 70 | uses: jwlawson/actions-setup-cmake@v1.3 71 | with: 72 | cmake-version: 3.18 73 | 74 | - name: Configure 3.18 75 | working-directory: build3.18 76 | run: > 77 | cmake --version && 78 | cmake .. 79 | -DPYBIND11_WERROR=ON 80 | -DDOWNLOAD_CATCH=ON 81 | -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") 82 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | name: Format 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: 8 | - master 9 | - stable 10 | - "v*" 11 | 12 | jobs: 13 | pre-commit: 14 | name: Format 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | - uses: actions/setup-python@v2 19 | - uses: pre-commit/action@v2.0.0 20 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | .DS_Store 6 | *.so 7 | *.pyd 8 | *.dll 9 | *.sln 10 | *.sdf 11 | *.opensdf 12 | *.vcxproj 13 | *.vcxproj.user 14 | *.filters 15 | example.dir 16 | Win32 17 | x64 18 | Release 19 | Debug 20 | .vs 21 | CTestTestfile.cmake 22 | Testing 23 | autogen 24 | MANIFEST 25 | /.ninja_* 26 | /*.ninja 27 | /docs/.build 28 | *.py[co] 29 | *.egg-info 30 | *~ 31 | .*.swp 32 | .DS_Store 33 | /dist 34 | /build 35 | /cmake/ 36 | .cache/ 37 | sosize-*.txt 38 | pybind11Config*.cmake 39 | pybind11Targets.cmake 40 | /*env* 41 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/clang"] 2 | path = tools/clang 3 | url = ../../wjakob/clang-cindex-python3.git 4 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v3.1.0 4 | hooks: 5 | - id: check-added-large-files 6 | - id: check-case-conflict 7 | - id: check-merge-conflict 8 | - id: check-symlinks 9 | - id: check-yaml 10 | - id: debug-statements 11 | - id: end-of-file-fixer 12 | - id: mixed-line-ending 13 | - id: requirements-txt-fixer 14 | - id: trailing-whitespace 15 | - id: fix-encoding-pragma 16 | 17 | - repo: https://github.com/Lucas-C/pre-commit-hooks 18 | rev: v1.1.9 19 | hooks: 20 | - id: remove-tabs 21 | 22 | - repo: https://gitlab.com/pycqa/flake8 23 | rev: 3.8.3 24 | hooks: 25 | - id: flake8 26 | additional_dependencies: [flake8-bugbear, pep8-naming] 27 | exclude: ^(docs/.*|tools/.*)$ 28 | 29 | - repo: local 30 | hooks: 31 | - id: check-style 32 | name: Classic check-style 33 | language: system 34 | types: 35 | - c++ 36 | entry: ./tools/check-style.sh 37 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | python: 2 | version: 3 3 | requirements_file: docs/requirements.txt 4 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Thank you for your interest in this project! Please refer to the following 2 | sections on how to contribute code and bug reports. 3 | 4 | ### Reporting bugs 5 | 6 | At the moment, this project is run in the spare time of a single person 7 | ([Wenzel Jakob](http://rgl.epfl.ch/people/wjakob)) with very limited resources 8 | for issue tracker tickets. Thus, before submitting a question or bug report, 9 | please take a moment of your time and ensure that your issue isn't already 10 | discussed in the project documentation provided at 11 | [http://pybind11.readthedocs.org/en/latest](http://pybind11.readthedocs.org/en/latest). 12 | 13 | Assuming that you have identified a previously unknown problem or an important 14 | question, it's essential that you submit a self-contained and minimal piece of 15 | code that reproduces the problem. In other words: no external dependencies, 16 | isolate the function(s) that cause breakage, submit matched and complete C++ 17 | and Python snippets that can be easily compiled and run on my end. 18 | 19 | ## Pull requests 20 | Contributions are submitted, reviewed, and accepted using Github pull requests. 21 | Please refer to [this 22 | article](https://help.github.com/articles/using-pull-requests) for details and 23 | adhere to the following rules to make the process as smooth as possible: 24 | 25 | * Make a new branch for every feature you're working on. 26 | * Make small and clean pull requests that are easy to review but make sure they 27 | do add value by themselves. 28 | * Add tests for any new functionality and run the test suite (``make pytest``) 29 | to ensure that no existing features break. 30 | * Please run [``pre-commit``][pre-commit] to check your code matches the 31 | project style. (Note that ``gawk`` is required.) Use `pre-commit run 32 | --all-files` before committing (or use installed-mode, check pre-commit docs) 33 | to verify your code passes before pushing to save time. 34 | * This project has a strong focus on providing general solutions using a 35 | minimal amount of code, thus small pull requests are greatly preferred. 36 | 37 | [pre-commit]: https://pre-commit.com 38 | 39 | ### Licensing of contributions 40 | 41 | pybind11 is provided under a BSD-style license that can be found in the 42 | ``LICENSE`` file. By using, distributing, or contributing to this project, you 43 | agree to the terms and conditions of this license. 44 | 45 | You are under no obligation whatsoever to provide any bug fixes, patches, or 46 | upgrades to the features, functionality or performance of the source code 47 | ("Enhancements") to anyone; however, if you choose to make your Enhancements 48 | available either publicly, or directly to the author of this software, without 49 | imposing a separate written license agreement for such Enhancements, then you 50 | hereby grant the following license: a non-exclusive, royalty-free perpetual 51 | license to install, use, modify, prepare derivative works, incorporate into 52 | other computer software, distribute, and sublicense such enhancements or 53 | derivative works thereof, in binary and source code form. 54 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure you've completed the following steps before submitting your issue -- thank you! 2 | 3 | 1. Check if your question has already been answered in the [FAQ](http://pybind11.readthedocs.io/en/latest/faq.html) section. 4 | 2. Make sure you've read the [documentation](http://pybind11.readthedocs.io/en/latest/). Your issue may be addressed there. 5 | 3. If those resources didn't help and you only have a short question (not a bug report), consider asking in the [Gitter chat room](https://gitter.im/pybind/Lobby). 6 | 4. If you have a genuine bug report or a more complex question which is not answered in the previous items (or not suitable for chat), please fill in the details below. 7 | 5. Include a self-contained and minimal piece of code that reproduces the problem. If that's not possible, try to make the description as clear as possible. 8 | 9 | *After reading, remove this checklist and the template text in parentheses below.* 10 | 11 | ## Issue description 12 | 13 | (Provide a short description, state the expected behavior and what actually happens.) 14 | 15 | ## Reproducible example code 16 | 17 | (The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.) 18 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Wenzel Jakob , All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Please also refer to the file CONTRIBUTING.md, which clarifies licensing of 29 | external contributions to this project including patches, pull requests, etc. 30 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include include/pybind11 *.h 2 | include LICENSE README.md CONTRIBUTING.md 3 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = pybind11 2 | INPUT = ../include/pybind11/ 3 | RECURSIVE = YES 4 | 5 | GENERATE_HTML = NO 6 | GENERATE_LATEX = NO 7 | GENERATE_XML = YES 8 | XML_OUTPUT = .build/doxygenxml 9 | XML_PROGRAMLISTING = YES 10 | 11 | MACRO_EXPANSION = YES 12 | EXPAND_ONLY_PREDEF = YES 13 | EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION 14 | 15 | ALIASES = "rst=\verbatim embed:rst" 16 | ALIASES += "endrst=\endverbatim" 17 | 18 | QUIET = YES 19 | WARNINGS = YES 20 | WARN_IF_UNDOCUMENTED = NO 21 | PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ 22 | PY_MAJOR_VERSION=3 23 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | .wy-table-responsive table td, 2 | .wy-table-responsive table th { 3 | white-space: initial !important; 4 | } 5 | .rst-content table.docutils td { 6 | vertical-align: top !important; 7 | } 8 | div[class^='highlight'] pre { 9 | white-space: pre; 10 | white-space: pre-wrap; 11 | } 12 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/advanced/cast/chrono.rst: -------------------------------------------------------------------------------- 1 | Chrono 2 | ====== 3 | 4 | When including the additional header file :file:`pybind11/chrono.h` conversions 5 | from C++11 chrono datatypes to python datetime objects are automatically enabled. 6 | This header also enables conversions of python floats (often from sources such 7 | as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``) 8 | into durations. 9 | 10 | An overview of clocks in C++11 11 | ------------------------------ 12 | 13 | A point of confusion when using these conversions is the differences between 14 | clocks provided in C++11. There are three clock types defined by the C++11 15 | standard and users can define their own if needed. Each of these clocks have 16 | different properties and when converting to and from python will give different 17 | results. 18 | 19 | The first clock defined by the standard is ``std::chrono::system_clock``. This 20 | clock measures the current date and time. However, this clock changes with to 21 | updates to the operating system time. For example, if your time is synchronised 22 | with a time server this clock will change. This makes this clock a poor choice 23 | for timing purposes but good for measuring the wall time. 24 | 25 | The second clock defined in the standard is ``std::chrono::steady_clock``. 26 | This clock ticks at a steady rate and is never adjusted. This makes it excellent 27 | for timing purposes, however the value in this clock does not correspond to the 28 | current date and time. Often this clock will be the amount of time your system 29 | has been on, although it does not have to be. This clock will never be the same 30 | clock as the system clock as the system clock can change but steady clocks 31 | cannot. 32 | 33 | The third clock defined in the standard is ``std::chrono::high_resolution_clock``. 34 | This clock is the clock that has the highest resolution out of the clocks in the 35 | system. It is normally a typedef to either the system clock or the steady clock 36 | but can be its own independent clock. This is important as when using these 37 | conversions as the types you get in python for this clock might be different 38 | depending on the system. 39 | If it is a typedef of the system clock, python will get datetime objects, but if 40 | it is a different clock they will be timedelta objects. 41 | 42 | Provided conversions 43 | -------------------- 44 | 45 | .. rubric:: C++ to Python 46 | 47 | - ``std::chrono::system_clock::time_point`` → ``datetime.datetime`` 48 | System clock times are converted to python datetime instances. They are 49 | in the local timezone, but do not have any timezone information attached 50 | to them (they are naive datetime objects). 51 | 52 | - ``std::chrono::duration`` → ``datetime.timedelta`` 53 | Durations are converted to timedeltas, any precision in the duration 54 | greater than microseconds is lost by rounding towards zero. 55 | 56 | - ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta`` 57 | Any clock time that is not the system clock is converted to a time delta. 58 | This timedelta measures the time from the clocks epoch to now. 59 | 60 | .. rubric:: Python to C++ 61 | 62 | - ``datetime.datetime`` or ``datetime.date`` or ``datetime.time`` → ``std::chrono::system_clock::time_point`` 63 | Date/time objects are converted into system clock timepoints. Any 64 | timezone information is ignored and the type is treated as a naive 65 | object. 66 | 67 | - ``datetime.timedelta`` → ``std::chrono::duration`` 68 | Time delta are converted into durations with microsecond precision. 69 | 70 | - ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point`` 71 | Time deltas that are converted into clock timepoints are treated as 72 | the amount of time from the start of the clocks epoch. 73 | 74 | - ``float`` → ``std::chrono::duration`` 75 | Floats that are passed to C++ as durations be interpreted as a number of 76 | seconds. These will be converted to the duration using ``duration_cast`` 77 | from the float. 78 | 79 | - ``float`` → ``std::chrono::[other_clocks]::time_point`` 80 | Floats that are passed to C++ as time points will be interpreted as the 81 | number of seconds from the start of the clocks epoch. 82 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/advanced/cast/custom.rst: -------------------------------------------------------------------------------- 1 | Custom type casters 2 | =================== 3 | 4 | In very rare cases, applications may require custom type casters that cannot be 5 | expressed using the abstractions provided by pybind11, thus requiring raw 6 | Python C API calls. This is fairly advanced usage and should only be pursued by 7 | experts who are familiar with the intricacies of Python reference counting. 8 | 9 | The following snippets demonstrate how this works for a very simple ``inty`` 10 | type that that should be convertible from Python types that provide a 11 | ``__int__(self)`` method. 12 | 13 | .. code-block:: cpp 14 | 15 | struct inty { long long_value; }; 16 | 17 | void print(inty s) { 18 | std::cout << s.long_value << std::endl; 19 | } 20 | 21 | The following Python snippet demonstrates the intended usage from the Python side: 22 | 23 | .. code-block:: python 24 | 25 | class A: 26 | def __int__(self): 27 | return 123 28 | 29 | from example import print 30 | print(A()) 31 | 32 | To register the necessary conversion routines, it is necessary to add 33 | a partial overload to the ``pybind11::detail::type_caster`` template. 34 | Although this is an implementation detail, adding partial overloads to this 35 | type is explicitly allowed. 36 | 37 | .. code-block:: cpp 38 | 39 | namespace pybind11 { namespace detail { 40 | template <> struct type_caster { 41 | public: 42 | /** 43 | * This macro establishes the name 'inty' in 44 | * function signatures and declares a local variable 45 | * 'value' of type inty 46 | */ 47 | PYBIND11_TYPE_CASTER(inty, _("inty")); 48 | 49 | /** 50 | * Conversion part 1 (Python->C++): convert a PyObject into a inty 51 | * instance or return false upon failure. The second argument 52 | * indicates whether implicit conversions should be applied. 53 | */ 54 | bool load(handle src, bool) { 55 | /* Extract PyObject from handle */ 56 | PyObject *source = src.ptr(); 57 | /* Try converting into a Python integer value */ 58 | PyObject *tmp = PyNumber_Long(source); 59 | if (!tmp) 60 | return false; 61 | /* Now try to convert into a C++ int */ 62 | value.long_value = PyLong_AsLong(tmp); 63 | Py_DECREF(tmp); 64 | /* Ensure return code was OK (to avoid out-of-range errors etc) */ 65 | return !(value.long_value == -1 && !PyErr_Occurred()); 66 | } 67 | 68 | /** 69 | * Conversion part 2 (C++ -> Python): convert an inty instance into 70 | * a Python object. The second and third arguments are used to 71 | * indicate the return value policy and parent object (for 72 | * ``return_value_policy::reference_internal``) and are generally 73 | * ignored by implicit casters. 74 | */ 75 | static handle cast(inty src, return_value_policy /* policy */, handle /* parent */) { 76 | return PyLong_FromLong(src.long_value); 77 | } 78 | }; 79 | }} // namespace pybind11::detail 80 | 81 | .. note:: 82 | 83 | A ``type_caster`` defined with ``PYBIND11_TYPE_CASTER(T, ...)`` requires 84 | that ``T`` is default-constructible (``value`` is first default constructed 85 | and then ``load()`` assigns to it). 86 | 87 | .. warning:: 88 | 89 | When using custom type casters, it's important to declare them consistently 90 | in every compilation unit of the Python extension module. Otherwise, 91 | undefined behavior can ensue. 92 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/advanced/cast/functional.rst: -------------------------------------------------------------------------------- 1 | Functional 2 | ########## 3 | 4 | The following features must be enabled by including :file:`pybind11/functional.h`. 5 | 6 | 7 | Callbacks and passing anonymous functions 8 | ========================================= 9 | 10 | The C++11 standard brought lambda functions and the generic polymorphic 11 | function wrapper ``std::function<>`` to the C++ programming language, which 12 | enable powerful new ways of working with functions. Lambda functions come in 13 | two flavors: stateless lambda function resemble classic function pointers that 14 | link to an anonymous piece of code, while stateful lambda functions 15 | additionally depend on captured variables that are stored in an anonymous 16 | *lambda closure object*. 17 | 18 | Here is a simple example of a C++ function that takes an arbitrary function 19 | (stateful or stateless) with signature ``int -> int`` as an argument and runs 20 | it with the value 10. 21 | 22 | .. code-block:: cpp 23 | 24 | int func_arg(const std::function &f) { 25 | return f(10); 26 | } 27 | 28 | The example below is more involved: it takes a function of signature ``int -> int`` 29 | and returns another function of the same kind. The return value is a stateful 30 | lambda function, which stores the value ``f`` in the capture object and adds 1 to 31 | its return value upon execution. 32 | 33 | .. code-block:: cpp 34 | 35 | std::function func_ret(const std::function &f) { 36 | return [f](int i) { 37 | return f(i) + 1; 38 | }; 39 | } 40 | 41 | This example demonstrates using python named parameters in C++ callbacks which 42 | requires using ``py::cpp_function`` as a wrapper. Usage is similar to defining 43 | methods of classes: 44 | 45 | .. code-block:: cpp 46 | 47 | py::cpp_function func_cpp() { 48 | return py::cpp_function([](int i) { return i+1; }, 49 | py::arg("number")); 50 | } 51 | 52 | After including the extra header file :file:`pybind11/functional.h`, it is almost 53 | trivial to generate binding code for all of these functions. 54 | 55 | .. code-block:: cpp 56 | 57 | #include 58 | 59 | PYBIND11_MODULE(example, m) { 60 | m.def("func_arg", &func_arg); 61 | m.def("func_ret", &func_ret); 62 | m.def("func_cpp", &func_cpp); 63 | } 64 | 65 | The following interactive session shows how to call them from Python. 66 | 67 | .. code-block:: pycon 68 | 69 | $ python 70 | >>> import example 71 | >>> def square(i): 72 | ... return i * i 73 | ... 74 | >>> example.func_arg(square) 75 | 100L 76 | >>> square_plus_1 = example.func_ret(square) 77 | >>> square_plus_1(4) 78 | 17L 79 | >>> plus_1 = func_cpp() 80 | >>> plus_1(number=43) 81 | 44L 82 | 83 | .. warning:: 84 | 85 | Keep in mind that passing a function from C++ to Python (or vice versa) 86 | will instantiate a piece of wrapper code that translates function 87 | invocations between the two languages. Naturally, this translation 88 | increases the computational cost of each function call somewhat. A 89 | problematic situation can arise when a function is copied back and forth 90 | between Python and C++ many times in a row, in which case the underlying 91 | wrappers will accumulate correspondingly. The resulting long sequence of 92 | C++ -> Python -> C++ -> ... roundtrips can significantly decrease 93 | performance. 94 | 95 | There is one exception: pybind11 detects case where a stateless function 96 | (i.e. a function pointer or a lambda function without captured variables) 97 | is passed as an argument to another C++ function exposed in Python. In this 98 | case, there is no overhead. Pybind11 will extract the underlying C++ 99 | function pointer from the wrapped function to sidestep a potential C++ -> 100 | Python -> C++ roundtrip. This is demonstrated in :file:`tests/test_callbacks.cpp`. 101 | 102 | .. note:: 103 | 104 | This functionality is very useful when generating bindings for callbacks in 105 | C++ libraries (e.g. GUI libraries, asynchronous networking libraries, etc.). 106 | 107 | The file :file:`tests/test_callbacks.cpp` contains a complete example 108 | that demonstrates how to work with callbacks and anonymous functions in 109 | more detail. 110 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/advanced/cast/index.rst: -------------------------------------------------------------------------------- 1 | Type conversions 2 | ################ 3 | 4 | Apart from enabling cross-language function calls, a fundamental problem 5 | that a binding tool like pybind11 must address is to provide access to 6 | native Python types in C++ and vice versa. There are three fundamentally 7 | different ways to do this—which approach is preferable for a particular type 8 | depends on the situation at hand. 9 | 10 | 1. Use a native C++ type everywhere. In this case, the type must be wrapped 11 | using pybind11-generated bindings so that Python can interact with it. 12 | 13 | 2. Use a native Python type everywhere. It will need to be wrapped so that 14 | C++ functions can interact with it. 15 | 16 | 3. Use a native C++ type on the C++ side and a native Python type on the 17 | Python side. pybind11 refers to this as a *type conversion*. 18 | 19 | Type conversions are the most "natural" option in the sense that native 20 | (non-wrapped) types are used everywhere. The main downside is that a copy 21 | of the data must be made on every Python ↔ C++ transition: this is 22 | needed since the C++ and Python versions of the same type generally won't 23 | have the same memory layout. 24 | 25 | pybind11 can perform many kinds of conversions automatically. An overview 26 | is provided in the table ":ref:`conversion_table`". 27 | 28 | The following subsections discuss the differences between these options in more 29 | detail. The main focus in this section is on type conversions, which represent 30 | the last case of the above list. 31 | 32 | .. toctree:: 33 | :maxdepth: 1 34 | 35 | overview 36 | strings 37 | stl 38 | functional 39 | chrono 40 | eigen 41 | custom 42 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/advanced/pycpp/index.rst: -------------------------------------------------------------------------------- 1 | Python C++ interface 2 | #################### 3 | 4 | pybind11 exposes Python types and functions using thin C++ wrappers, which 5 | makes it possible to conveniently call Python code from C++ without resorting 6 | to Python's C API. 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | object 12 | numpy 13 | utilities 14 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/benchmark.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import random 3 | import os 4 | import time 5 | import datetime as dt 6 | 7 | nfns = 4 # Functions per class 8 | nargs = 4 # Arguments per function 9 | 10 | 11 | def generate_dummy_code_pybind11(nclasses=10): 12 | decl = "" 13 | bindings = "" 14 | 15 | for cl in range(nclasses): 16 | decl += "class cl%03i;\n" % cl 17 | decl += '\n' 18 | 19 | for cl in range(nclasses): 20 | decl += "class cl%03i {\n" % cl 21 | decl += "public:\n" 22 | bindings += ' py::class_(m, "cl%03i")\n' % (cl, cl) 23 | for fn in range(nfns): 24 | ret = random.randint(0, nclasses - 1) 25 | params = [random.randint(0, nclasses - 1) for i in range(nargs)] 26 | decl += " cl%03i *fn_%03i(" % (ret, fn) 27 | decl += ", ".join("cl%03i *" % p for p in params) 28 | decl += ");\n" 29 | bindings += ' .def("fn_%03i", &cl%03i::fn_%03i)\n' % \ 30 | (fn, cl, fn) 31 | decl += "};\n\n" 32 | bindings += ' ;\n' 33 | 34 | result = "#include \n\n" 35 | result += "namespace py = pybind11;\n\n" 36 | result += decl + '\n' 37 | result += "PYBIND11_MODULE(example, m) {\n" 38 | result += bindings 39 | result += "}" 40 | return result 41 | 42 | 43 | def generate_dummy_code_boost(nclasses=10): 44 | decl = "" 45 | bindings = "" 46 | 47 | for cl in range(nclasses): 48 | decl += "class cl%03i;\n" % cl 49 | decl += '\n' 50 | 51 | for cl in range(nclasses): 52 | decl += "class cl%03i {\n" % cl 53 | decl += "public:\n" 54 | bindings += ' py::class_("cl%03i")\n' % (cl, cl) 55 | for fn in range(nfns): 56 | ret = random.randint(0, nclasses - 1) 57 | params = [random.randint(0, nclasses - 1) for i in range(nargs)] 58 | decl += " cl%03i *fn_%03i(" % (ret, fn) 59 | decl += ", ".join("cl%03i *" % p for p in params) 60 | decl += ");\n" 61 | bindings += ' .def("fn_%03i", &cl%03i::fn_%03i, py::return_value_policy())\n' % \ 62 | (fn, cl, fn) 63 | decl += "};\n\n" 64 | bindings += ' ;\n' 65 | 66 | result = "#include \n\n" 67 | result += "namespace py = boost::python;\n\n" 68 | result += decl + '\n' 69 | result += "BOOST_PYTHON_MODULE(example) {\n" 70 | result += bindings 71 | result += "}" 72 | return result 73 | 74 | 75 | for codegen in [generate_dummy_code_pybind11, generate_dummy_code_boost]: 76 | print ("{") 77 | for i in range(0, 10): 78 | nclasses = 2 ** i 79 | with open("test.cpp", "w") as f: 80 | f.write(codegen(nclasses)) 81 | n1 = dt.datetime.now() 82 | os.system("g++ -Os -shared -rdynamic -undefined dynamic_lookup " 83 | "-fvisibility=hidden -std=c++14 test.cpp -I include " 84 | "-I /System/Library/Frameworks/Python.framework/Headers -o test.so") 85 | n2 = dt.datetime.now() 86 | elapsed = (n2 - n1).total_seconds() 87 | size = os.stat('test.so').st_size 88 | print(" {%i, %f, %i}," % (nclasses * nfns, elapsed, size)) 89 | print ("}") 90 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/benchmark.rst: -------------------------------------------------------------------------------- 1 | Benchmark 2 | ========= 3 | 4 | The following is the result of a synthetic benchmark comparing both compilation 5 | time and module size of pybind11 against Boost.Python. A detailed report about a 6 | Boost.Python to pybind11 conversion of a real project is available here: [#f1]_. 7 | 8 | .. [#f1] http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf 9 | 10 | Setup 11 | ----- 12 | 13 | A python script (see the ``docs/benchmark.py`` file) was used to generate a set 14 | of files with dummy classes whose count increases for each successive benchmark 15 | (between 1 and 2048 classes in powers of two). Each class has four methods with 16 | a randomly generated signature with a return value and four arguments. (There 17 | was no particular reason for this setup other than the desire to generate many 18 | unique function signatures whose count could be controlled in a simple way.) 19 | 20 | Here is an example of the binding code for one class: 21 | 22 | .. code-block:: cpp 23 | 24 | ... 25 | class cl034 { 26 | public: 27 | cl279 *fn_000(cl084 *, cl057 *, cl065 *, cl042 *); 28 | cl025 *fn_001(cl098 *, cl262 *, cl414 *, cl121 *); 29 | cl085 *fn_002(cl445 *, cl297 *, cl145 *, cl421 *); 30 | cl470 *fn_003(cl200 *, cl323 *, cl332 *, cl492 *); 31 | }; 32 | ... 33 | 34 | PYBIND11_MODULE(example, m) { 35 | ... 36 | py::class_(m, "cl034") 37 | .def("fn_000", &cl034::fn_000) 38 | .def("fn_001", &cl034::fn_001) 39 | .def("fn_002", &cl034::fn_002) 40 | .def("fn_003", &cl034::fn_003) 41 | ... 42 | } 43 | 44 | The Boost.Python version looks almost identical except that a return value 45 | policy had to be specified as an argument to ``def()``. For both libraries, 46 | compilation was done with 47 | 48 | .. code-block:: bash 49 | 50 | Apple LLVM version 7.0.2 (clang-700.1.81) 51 | 52 | and the following compilation flags 53 | 54 | .. code-block:: bash 55 | 56 | g++ -Os -shared -rdynamic -undefined dynamic_lookup -fvisibility=hidden -std=c++14 57 | 58 | Compilation time 59 | ---------------- 60 | 61 | The following log-log plot shows how the compilation time grows for an 62 | increasing number of class and function declarations. pybind11 includes many 63 | fewer headers, which initially leads to shorter compilation times, but the 64 | performance is ultimately fairly similar (pybind11 is 19.8 seconds faster for 65 | the largest largest file with 2048 classes and a total of 8192 methods -- a 66 | modest **1.2x** speedup relative to Boost.Python, which required 116.35 67 | seconds). 68 | 69 | .. only:: not latex 70 | 71 | .. image:: pybind11_vs_boost_python1.svg 72 | 73 | .. only:: latex 74 | 75 | .. image:: pybind11_vs_boost_python1.png 76 | 77 | Module size 78 | ----------- 79 | 80 | Differences between the two libraries become much more pronounced when 81 | considering the file size of the generated Python plugin: for the largest file, 82 | the binary generated by Boost.Python required 16.8 MiB, which was **2.17 83 | times** / **9.1 megabytes** larger than the output generated by pybind11. For 84 | very small inputs, Boost.Python has an edge in the plot below -- however, note 85 | that it stores many definitions in an external library, whose size was not 86 | included here, hence the comparison is slightly shifted in Boost.Python's 87 | favor. 88 | 89 | .. only:: not latex 90 | 91 | .. image:: pybind11_vs_boost_python2.svg 92 | 93 | .. only:: latex 94 | 95 | .. image:: pybind11_vs_boost_python2.png 96 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. only: not latex 2 | 3 | .. image:: pybind11-logo.png 4 | 5 | pybind11 --- Seamless operability between C++11 and Python 6 | ========================================================== 7 | 8 | .. only: not latex 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | intro 16 | changelog 17 | upgrade 18 | 19 | .. toctree:: 20 | :caption: The Basics 21 | :maxdepth: 2 22 | 23 | basics 24 | classes 25 | compiling 26 | 27 | .. toctree:: 28 | :caption: Advanced Topics 29 | :maxdepth: 2 30 | 31 | advanced/functions 32 | advanced/classes 33 | advanced/exceptions 34 | advanced/smart_ptrs 35 | advanced/cast/index 36 | advanced/pycpp/index 37 | advanced/embedding 38 | advanced/misc 39 | 40 | .. toctree:: 41 | :caption: Extra Information 42 | :maxdepth: 1 43 | 44 | faq 45 | benchmark 46 | limitations 47 | reference 48 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/intro.rst: -------------------------------------------------------------------------------- 1 | .. image:: pybind11-logo.png 2 | 3 | About this project 4 | ================== 5 | **pybind11** is a lightweight header-only library that exposes C++ types in Python 6 | and vice versa, mainly to create Python bindings of existing C++ code. Its 7 | goals and syntax are similar to the excellent `Boost.Python`_ library by David 8 | Abrahams: to minimize boilerplate code in traditional extension modules by 9 | inferring type information using compile-time introspection. 10 | 11 | .. _Boost.Python: http://www.boost.org/doc/libs/release/libs/python/doc/index.html 12 | 13 | The main issue with Boost.Python—and the reason for creating such a similar 14 | project—is Boost. Boost is an enormously large and complex suite of utility 15 | libraries that works with almost every C++ compiler in existence. This 16 | compatibility has its cost: arcane template tricks and workarounds are 17 | necessary to support the oldest and buggiest of compiler specimens. Now that 18 | C++11-compatible compilers are widely available, this heavy machinery has 19 | become an excessively large and unnecessary dependency. 20 | Think of this library as a tiny self-contained version of Boost.Python with 21 | everything stripped away that isn't relevant for binding generation. Without 22 | comments, the core header files only require ~4K lines of code and depend on 23 | Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This 24 | compact implementation was possible thanks to some of the new C++11 language 25 | features (specifically: tuples, lambda functions and variadic templates). Since 26 | its creation, this library has grown beyond Boost.Python in many ways, leading 27 | to dramatically simpler binding code in many common situations. 28 | 29 | Core features 30 | ************* 31 | The following core C++ features can be mapped to Python 32 | 33 | - Functions accepting and returning custom data structures per value, reference, or pointer 34 | - Instance methods and static methods 35 | - Overloaded functions 36 | - Instance attributes and static attributes 37 | - Arbitrary exception types 38 | - Enumerations 39 | - Callbacks 40 | - Iterators and ranges 41 | - Custom operators 42 | - Single and multiple inheritance 43 | - STL data structures 44 | - Smart pointers with reference counting like ``std::shared_ptr`` 45 | - Internal references with correct reference counting 46 | - C++ classes with virtual (and pure virtual) methods can be extended in Python 47 | 48 | Goodies 49 | ******* 50 | In addition to the core functionality, pybind11 provides some extra goodies: 51 | 52 | - Python 2.7, 3.x, and PyPy (PyPy2.7 >= 5.7) are supported with an 53 | implementation-agnostic interface. 54 | 55 | - It is possible to bind C++11 lambda functions with captured variables. The 56 | lambda capture data is stored inside the resulting Python function object. 57 | 58 | - pybind11 uses C++11 move constructors and move assignment operators whenever 59 | possible to efficiently transfer custom data types. 60 | 61 | - It's easy to expose the internal storage of custom data types through 62 | Pythons' buffer protocols. This is handy e.g. for fast conversion between 63 | C++ matrix classes like Eigen and NumPy without expensive copy operations. 64 | 65 | - pybind11 can automatically vectorize functions so that they are transparently 66 | applied to all entries of one or more NumPy array arguments. 67 | 68 | - Python's slice-based access and assignment operations can be supported with 69 | just a few lines of code. 70 | 71 | - Everything is contained in just a few header files; there is no need to link 72 | against any additional libraries. 73 | 74 | - Binaries are generally smaller by a factor of at least 2 compared to 75 | equivalent bindings generated by Boost.Python. A recent pybind11 conversion 76 | of `PyRosetta`_, an enormous Boost.Python binding project, reported a binary 77 | size reduction of **5.4x** and compile time reduction by **5.8x**. 78 | 79 | - Function signatures are precomputed at compile time (using ``constexpr``), 80 | leading to smaller binaries. 81 | 82 | - With little extra effort, C++ types can be pickled and unpickled similar to 83 | regular Python objects. 84 | 85 | .. _PyRosetta: http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf 86 | 87 | Supported compilers 88 | ******************* 89 | 90 | 1. Clang/LLVM (any non-ancient version with C++11 support) 91 | 2. GCC 4.8 or newer 92 | 3. Microsoft Visual Studio 2015 or newer 93 | 4. Intel C++ compiler v17 or newer (v16 with pybind11 v2.0 and v15 with pybind11 v2.0 and a `workaround `_ ) 94 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/limitations.rst: -------------------------------------------------------------------------------- 1 | Limitations 2 | ########### 3 | 4 | pybind11 strives to be a general solution to binding generation, but it also has 5 | certain limitations: 6 | 7 | - pybind11 casts away ``const``-ness in function arguments and return values. 8 | This is in line with the Python language, which has no concept of ``const`` 9 | values. This means that some additional care is needed to avoid bugs that 10 | would be caught by the type checker in a traditional C++ program. 11 | 12 | - The NumPy interface ``pybind11::array`` greatly simplifies accessing 13 | numerical data from C++ (and vice versa), but it's not a full-blown array 14 | class like ``Eigen::Array`` or ``boost.multi_array``. 15 | 16 | These features could be implemented but would lead to a significant increase in 17 | complexity. I've decided to draw the line here to keep this project simple and 18 | compact. Users who absolutely require these features are encouraged to fork 19 | pybind11. 20 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/pybind11-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/FTReading/pybind11-master/docs/pybind11-logo.png -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/pybind11_vs_boost_python1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/FTReading/pybind11-master/docs/pybind11_vs_boost_python1.png -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/pybind11_vs_boost_python2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/FTReading/pybind11-master/docs/pybind11_vs_boost_python2.png -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/reference.rst: -------------------------------------------------------------------------------- 1 | .. _reference: 2 | 3 | .. warning:: 4 | 5 | Please be advised that the reference documentation discussing pybind11 6 | internals is currently incomplete. Please refer to the previous sections 7 | and the pybind11 header files for the nitty gritty details. 8 | 9 | Reference 10 | ######### 11 | 12 | .. _macros: 13 | 14 | Macros 15 | ====== 16 | 17 | .. doxygendefine:: PYBIND11_MODULE 18 | 19 | .. _core_types: 20 | 21 | Convenience classes for arbitrary Python types 22 | ============================================== 23 | 24 | Common member functions 25 | ----------------------- 26 | 27 | .. doxygenclass:: object_api 28 | :members: 29 | 30 | Without reference counting 31 | -------------------------- 32 | 33 | .. doxygenclass:: handle 34 | :members: 35 | 36 | With reference counting 37 | ----------------------- 38 | 39 | .. doxygenclass:: object 40 | :members: 41 | 42 | .. doxygenfunction:: reinterpret_borrow 43 | 44 | .. doxygenfunction:: reinterpret_steal 45 | 46 | Convenience classes for specific Python types 47 | ============================================= 48 | 49 | .. doxygenclass:: module 50 | :members: 51 | 52 | .. doxygengroup:: pytypes 53 | :members: 54 | 55 | .. _extras: 56 | 57 | Passing extra arguments to ``def`` or ``class_`` 58 | ================================================ 59 | 60 | .. doxygengroup:: annotations 61 | :members: 62 | 63 | Embedding the interpreter 64 | ========================= 65 | 66 | .. doxygendefine:: PYBIND11_EMBEDDED_MODULE 67 | 68 | .. doxygenfunction:: initialize_interpreter 69 | 70 | .. doxygenfunction:: finalize_interpreter 71 | 72 | .. doxygenclass:: scoped_interpreter 73 | 74 | Redirecting C++ streams 75 | ======================= 76 | 77 | .. doxygenclass:: scoped_ostream_redirect 78 | 79 | .. doxygenclass:: scoped_estream_redirect 80 | 81 | .. doxygenfunction:: add_ostream_redirect 82 | 83 | Python built-in functions 84 | ========================= 85 | 86 | .. doxygengroup:: python_builtins 87 | :members: 88 | 89 | Inheritance 90 | =========== 91 | 92 | See :doc:`/classes` and :doc:`/advanced/classes` for more detail. 93 | 94 | .. doxygendefine:: PYBIND11_OVERLOAD 95 | 96 | .. doxygendefine:: PYBIND11_OVERLOAD_PURE 97 | 98 | .. doxygendefine:: PYBIND11_OVERLOAD_NAME 99 | 100 | .. doxygendefine:: PYBIND11_OVERLOAD_PURE_NAME 101 | 102 | .. doxygenfunction:: get_overload 103 | 104 | Exceptions 105 | ========== 106 | 107 | .. doxygenclass:: error_already_set 108 | :members: 109 | 110 | .. doxygenclass:: builtin_exception 111 | :members: 112 | 113 | 114 | Literals 115 | ======== 116 | 117 | .. doxygennamespace:: literals 118 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/release.rst: -------------------------------------------------------------------------------- 1 | To release a new version of pybind11: 2 | 3 | - Update the version number and push to pypi 4 | - Update ``pybind11/_version.py`` (set release version, remove 'dev'). 5 | - Update ``PYBIND11_VERSION_MAJOR`` etc. in ``include/pybind11/detail/common.h``. 6 | - Ensure that all the information in ``setup.py`` is up-to-date. 7 | - Update version in ``docs/conf.py``. 8 | - Tag release date in ``docs/changelog.rst``. 9 | - ``git add`` and ``git commit``. 10 | - if new minor version: ``git checkout -b vX.Y``, ``git push -u origin vX.Y`` 11 | - ``git tag -a vX.Y.Z -m 'vX.Y.Z release'``. 12 | - ``git push`` 13 | - ``git push --tags``. 14 | - ``python setup.py sdist upload``. 15 | - ``python setup.py bdist_wheel upload``. 16 | - Get back to work 17 | - Update ``_version.py`` (add 'dev' and increment minor). 18 | - Update version in ``docs/conf.py`` 19 | - Update version macros in ``include/pybind11/common.h`` 20 | - ``git add`` and ``git commit``. 21 | ``git push`` 22 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | breathe == 4.5.0 2 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/complex.h: Complex number support 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #pragma once 11 | 12 | #include "pybind11.h" 13 | #include 14 | 15 | /// glibc defines I as a macro which breaks things, e.g., boost template names 16 | #ifdef I 17 | # undef I 18 | #endif 19 | 20 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 21 | 22 | template struct format_descriptor, detail::enable_if_t::value>> { 23 | static constexpr const char c = format_descriptor::c; 24 | static constexpr const char value[3] = { 'Z', c, '\0' }; 25 | static std::string format() { return std::string(value); } 26 | }; 27 | 28 | #ifndef PYBIND11_CPP17 29 | 30 | template constexpr const char format_descriptor< 31 | std::complex, detail::enable_if_t::value>>::value[3]; 32 | 33 | #endif 34 | 35 | PYBIND11_NAMESPACE_BEGIN(detail) 36 | 37 | template struct is_fmt_numeric, detail::enable_if_t::value>> { 38 | static constexpr bool value = true; 39 | static constexpr int index = is_fmt_numeric::index + 3; 40 | }; 41 | 42 | template class type_caster> { 43 | public: 44 | bool load(handle src, bool convert) { 45 | if (!src) 46 | return false; 47 | if (!convert && !PyComplex_Check(src.ptr())) 48 | return false; 49 | Py_complex result = PyComplex_AsCComplex(src.ptr()); 50 | if (result.real == -1.0 && PyErr_Occurred()) { 51 | PyErr_Clear(); 52 | return false; 53 | } 54 | value = std::complex((T) result.real, (T) result.imag); 55 | return true; 56 | } 57 | 58 | static handle cast(const std::complex &src, return_value_policy /* policy */, handle /* parent */) { 59 | return PyComplex_FromDoubles((double) src.real(), (double) src.imag()); 60 | } 61 | 62 | PYBIND11_TYPE_CASTER(std::complex, _("complex")); 63 | }; 64 | PYBIND11_NAMESPACE_END(detail) 65 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 66 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/detail/descr.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/descr.h: Helper type for concatenating type signatures at compile time 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #pragma once 11 | 12 | #include "common.h" 13 | 14 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 15 | PYBIND11_NAMESPACE_BEGIN(detail) 16 | 17 | #if !defined(_MSC_VER) 18 | # define PYBIND11_DESCR_CONSTEXPR static constexpr 19 | #else 20 | # define PYBIND11_DESCR_CONSTEXPR const 21 | #endif 22 | 23 | /* Concatenate type signatures at compile time */ 24 | template 25 | struct descr { 26 | char text[N + 1]; 27 | 28 | constexpr descr() : text{'\0'} { } 29 | constexpr descr(char const (&s)[N+1]) : descr(s, make_index_sequence()) { } 30 | 31 | template 32 | constexpr descr(char const (&s)[N+1], index_sequence) : text{s[Is]..., '\0'} { } 33 | 34 | template 35 | constexpr descr(char c, Chars... cs) : text{c, static_cast(cs)..., '\0'} { } 36 | 37 | static constexpr std::array types() { 38 | return {{&typeid(Ts)..., nullptr}}; 39 | } 40 | }; 41 | 42 | template 43 | constexpr descr plus_impl(const descr &a, const descr &b, 44 | index_sequence, index_sequence) { 45 | return {a.text[Is1]..., b.text[Is2]...}; 46 | } 47 | 48 | template 49 | constexpr descr operator+(const descr &a, const descr &b) { 50 | return plus_impl(a, b, make_index_sequence(), make_index_sequence()); 51 | } 52 | 53 | template 54 | constexpr descr _(char const(&text)[N]) { return descr(text); } 55 | constexpr descr<0> _(char const(&)[1]) { return {}; } 56 | 57 | template struct int_to_str : int_to_str { }; 58 | template struct int_to_str<0, Digits...> { 59 | static constexpr auto digits = descr(('0' + Digits)...); 60 | }; 61 | 62 | // Ternary description (like std::conditional) 63 | template 64 | constexpr enable_if_t> _(char const(&text1)[N1], char const(&)[N2]) { 65 | return _(text1); 66 | } 67 | template 68 | constexpr enable_if_t> _(char const(&)[N1], char const(&text2)[N2]) { 69 | return _(text2); 70 | } 71 | 72 | template 73 | constexpr enable_if_t _(const T1 &d, const T2 &) { return d; } 74 | template 75 | constexpr enable_if_t _(const T1 &, const T2 &d) { return d; } 76 | 77 | template auto constexpr _() -> decltype(int_to_str::digits) { 78 | return int_to_str::digits; 79 | } 80 | 81 | template constexpr descr<1, Type> _() { return {'%'}; } 82 | 83 | constexpr descr<0> concat() { return {}; } 84 | 85 | template 86 | constexpr descr concat(const descr &descr) { return descr; } 87 | 88 | template 89 | constexpr auto concat(const descr &d, const Args &...args) 90 | -> decltype(std::declval>() + concat(args...)) { 91 | return d + _(", ") + concat(args...); 92 | } 93 | 94 | template 95 | constexpr descr type_descr(const descr &descr) { 96 | return _("{") + descr + _("}"); 97 | } 98 | 99 | PYBIND11_NAMESPACE_END(detail) 100 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 101 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/detail/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | #include 17 | #endif 18 | 19 | #include "common.h" 20 | 21 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 22 | PYBIND11_NAMESPACE_BEGIN(detail) 23 | /// Erase all occurrences of a substring 24 | inline void erase_all(std::string &string, const std::string &search) { 25 | for (size_t pos = 0;;) { 26 | pos = string.find(search, pos); 27 | if (pos == std::string::npos) break; 28 | string.erase(pos, search.length()); 29 | } 30 | } 31 | 32 | PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { 33 | #if defined(__GNUG__) 34 | int status = 0; 35 | std::unique_ptr res { 36 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; 37 | if (status == 0) 38 | name = res.get(); 39 | #else 40 | detail::erase_all(name, "class "); 41 | detail::erase_all(name, "struct "); 42 | detail::erase_all(name, "enum "); 43 | #endif 44 | detail::erase_all(name, "pybind11::"); 45 | } 46 | PYBIND11_NAMESPACE_END(detail) 47 | 48 | /// Return a string representation of a C++ type 49 | template static std::string type_id() { 50 | std::string name(typeid(T).name()); 51 | detail::clean_type_id(name); 52 | return name; 53 | } 54 | 55 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 56 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/eval.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/exec.h: Support for evaluating Python expressions and statements 3 | from strings and files 4 | 5 | Copyright (c) 2016 Klemens Morgenstern and 6 | Wenzel Jakob 7 | 8 | All rights reserved. Use of this source code is governed by a 9 | BSD-style license that can be found in the LICENSE file. 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "pybind11.h" 15 | 16 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 17 | 18 | enum eval_mode { 19 | /// Evaluate a string containing an isolated expression 20 | eval_expr, 21 | 22 | /// Evaluate a string containing a single statement. Returns \c none 23 | eval_single_statement, 24 | 25 | /// Evaluate a string containing a sequence of statement. Returns \c none 26 | eval_statements 27 | }; 28 | 29 | template 30 | object eval(str expr, object global = globals(), object local = object()) { 31 | if (!local) 32 | local = global; 33 | 34 | /* PyRun_String does not accept a PyObject / encoding specifier, 35 | this seems to be the only alternative */ 36 | std::string buffer = "# -*- coding: utf-8 -*-\n" + (std::string) expr; 37 | 38 | int start; 39 | switch (mode) { 40 | case eval_expr: start = Py_eval_input; break; 41 | case eval_single_statement: start = Py_single_input; break; 42 | case eval_statements: start = Py_file_input; break; 43 | default: pybind11_fail("invalid evaluation mode"); 44 | } 45 | 46 | PyObject *result = PyRun_String(buffer.c_str(), start, global.ptr(), local.ptr()); 47 | if (!result) 48 | throw error_already_set(); 49 | return reinterpret_steal(result); 50 | } 51 | 52 | template 53 | object eval(const char (&s)[N], object global = globals(), object local = object()) { 54 | /* Support raw string literals by removing common leading whitespace */ 55 | auto expr = (s[0] == '\n') ? str(module::import("textwrap").attr("dedent")(s)) 56 | : str(s); 57 | return eval(expr, global, local); 58 | } 59 | 60 | inline void exec(str expr, object global = globals(), object local = object()) { 61 | eval(expr, global, local); 62 | } 63 | 64 | template 65 | void exec(const char (&s)[N], object global = globals(), object local = object()) { 66 | eval(s, global, local); 67 | } 68 | 69 | #if defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x3000000 70 | template 71 | object eval_file(str, object, object) { 72 | pybind11_fail("eval_file not supported in PyPy3. Use eval"); 73 | } 74 | template 75 | object eval_file(str, object) { 76 | pybind11_fail("eval_file not supported in PyPy3. Use eval"); 77 | } 78 | template 79 | object eval_file(str) { 80 | pybind11_fail("eval_file not supported in PyPy3. Use eval"); 81 | } 82 | #else 83 | template 84 | object eval_file(str fname, object global = globals(), object local = object()) { 85 | if (!local) 86 | local = global; 87 | 88 | int start; 89 | switch (mode) { 90 | case eval_expr: start = Py_eval_input; break; 91 | case eval_single_statement: start = Py_single_input; break; 92 | case eval_statements: start = Py_file_input; break; 93 | default: pybind11_fail("invalid evaluation mode"); 94 | } 95 | 96 | int closeFile = 1; 97 | std::string fname_str = (std::string) fname; 98 | #if PY_VERSION_HEX >= 0x03040000 99 | FILE *f = _Py_fopen_obj(fname.ptr(), "r"); 100 | #elif PY_VERSION_HEX >= 0x03000000 101 | FILE *f = _Py_fopen(fname.ptr(), "r"); 102 | #else 103 | /* No unicode support in open() :( */ 104 | auto fobj = reinterpret_steal(PyFile_FromString( 105 | const_cast(fname_str.c_str()), 106 | const_cast("r"))); 107 | FILE *f = nullptr; 108 | if (fobj) 109 | f = PyFile_AsFile(fobj.ptr()); 110 | closeFile = 0; 111 | #endif 112 | if (!f) { 113 | PyErr_Clear(); 114 | pybind11_fail("File \"" + fname_str + "\" could not be opened!"); 115 | } 116 | 117 | #if PY_VERSION_HEX < 0x03000000 && defined(PYPY_VERSION) 118 | PyObject *result = PyRun_File(f, fname_str.c_str(), start, global.ptr(), 119 | local.ptr()); 120 | (void) closeFile; 121 | #else 122 | PyObject *result = PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(), 123 | local.ptr(), closeFile); 124 | #endif 125 | 126 | if (!result) 127 | throw error_already_set(); 128 | return reinterpret_steal(result); 129 | } 130 | #endif 131 | 132 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 133 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/functional.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/functional.h: std::function<> support 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #pragma once 11 | 12 | #include "pybind11.h" 13 | #include 14 | 15 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 16 | PYBIND11_NAMESPACE_BEGIN(detail) 17 | 18 | template 19 | struct type_caster> { 20 | using type = std::function; 21 | using retval_type = conditional_t::value, void_type, Return>; 22 | using function_type = Return (*) (Args...); 23 | 24 | public: 25 | bool load(handle src, bool convert) { 26 | if (src.is_none()) { 27 | // Defer accepting None to other overloads (if we aren't in convert mode): 28 | if (!convert) return false; 29 | return true; 30 | } 31 | 32 | if (!isinstance(src)) 33 | return false; 34 | 35 | auto func = reinterpret_borrow(src); 36 | 37 | /* 38 | When passing a C++ function as an argument to another C++ 39 | function via Python, every function call would normally involve 40 | a full C++ -> Python -> C++ roundtrip, which can be prohibitive. 41 | Here, we try to at least detect the case where the function is 42 | stateless (i.e. function pointer or lambda function without 43 | captured variables), in which case the roundtrip can be avoided. 44 | */ 45 | if (auto cfunc = func.cpp_function()) { 46 | auto c = reinterpret_borrow(PyCFunction_GET_SELF(cfunc.ptr())); 47 | auto rec = (function_record *) c; 48 | 49 | if (rec && rec->is_stateless && 50 | same_type(typeid(function_type), *reinterpret_cast(rec->data[1]))) { 51 | struct capture { function_type f; }; 52 | value = ((capture *) &rec->data)->f; 53 | return true; 54 | } 55 | } 56 | 57 | // ensure GIL is held during functor destruction 58 | struct func_handle { 59 | function f; 60 | func_handle(function&& f_) : f(std::move(f_)) {} 61 | func_handle(const func_handle&) = default; 62 | ~func_handle() { 63 | gil_scoped_acquire acq; 64 | function kill_f(std::move(f)); 65 | } 66 | }; 67 | 68 | // to emulate 'move initialization capture' in C++11 69 | struct func_wrapper { 70 | func_handle hfunc; 71 | func_wrapper(func_handle&& hf): hfunc(std::move(hf)) {} 72 | Return operator()(Args... args) const { 73 | gil_scoped_acquire acq; 74 | object retval(hfunc.f(std::forward(args)...)); 75 | /* Visual studio 2015 parser issue: need parentheses around this expression */ 76 | return (retval.template cast()); 77 | } 78 | }; 79 | 80 | value = func_wrapper(func_handle(std::move(func))); 81 | return true; 82 | } 83 | 84 | template 85 | static handle cast(Func &&f_, return_value_policy policy, handle /* parent */) { 86 | if (!f_) 87 | return none().inc_ref(); 88 | 89 | auto result = f_.template target(); 90 | if (result) 91 | return cpp_function(*result, policy).release(); 92 | else 93 | return cpp_function(std::forward(f_), policy).release(); 94 | } 95 | 96 | PYBIND11_TYPE_CASTER(type, _("Callable[[") + concat(make_caster::name...) + _("], ") 97 | + make_caster::name + _("]")); 98 | }; 99 | 100 | PYBIND11_NAMESPACE_END(detail) 101 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 102 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/include/pybind11/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/options.h: global settings that are configurable at runtime. 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #pragma once 11 | 12 | #include "detail/common.h" 13 | 14 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 15 | 16 | class options { 17 | public: 18 | 19 | // Default RAII constructor, which leaves settings as they currently are. 20 | options() : previous_state(global_state()) {} 21 | 22 | // Class is non-copyable. 23 | options(const options&) = delete; 24 | options& operator=(const options&) = delete; 25 | 26 | // Destructor, which restores settings that were in effect before. 27 | ~options() { 28 | global_state() = previous_state; 29 | } 30 | 31 | // Setter methods (affect the global state): 32 | 33 | options& disable_user_defined_docstrings() & { global_state().show_user_defined_docstrings = false; return *this; } 34 | 35 | options& enable_user_defined_docstrings() & { global_state().show_user_defined_docstrings = true; return *this; } 36 | 37 | options& disable_function_signatures() & { global_state().show_function_signatures = false; return *this; } 38 | 39 | options& enable_function_signatures() & { global_state().show_function_signatures = true; return *this; } 40 | 41 | // Getter methods (return the global state): 42 | 43 | static bool show_user_defined_docstrings() { return global_state().show_user_defined_docstrings; } 44 | 45 | static bool show_function_signatures() { return global_state().show_function_signatures; } 46 | 47 | // This type is not meant to be allocated on the heap. 48 | void* operator new(size_t) = delete; 49 | 50 | private: 51 | 52 | struct state { 53 | bool show_user_defined_docstrings = true; //< Include user-supplied texts in docstrings. 54 | bool show_function_signatures = true; //< Include auto-generated function signatures in docstrings. 55 | }; 56 | 57 | static state &global_state() { 58 | static state instance; 59 | return instance; 60 | } 61 | 62 | state previous_state; 63 | }; 64 | 65 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 66 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/pybind11/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from ._version import version_info, __version__ # noqa: F401 imported but unused 3 | 4 | 5 | def get_include(user=False): 6 | import os 7 | d = os.path.dirname(__file__) 8 | if os.path.exists(os.path.join(d, "include")): 9 | # Package is installed 10 | return os.path.join(d, "include") 11 | else: 12 | # Package is from a source directory 13 | return os.path.join(os.path.dirname(d), "include") 14 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/pybind11/__main__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import print_function 3 | 4 | import argparse 5 | import sys 6 | import sysconfig 7 | 8 | from . import get_include 9 | 10 | 11 | def print_includes(): 12 | dirs = [sysconfig.get_path('include'), 13 | sysconfig.get_path('platinclude'), 14 | get_include()] 15 | 16 | # Make unique but preserve order 17 | unique_dirs = [] 18 | for d in dirs: 19 | if d not in unique_dirs: 20 | unique_dirs.append(d) 21 | 22 | print(' '.join('-I' + d for d in unique_dirs)) 23 | 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(prog='python -m pybind11') 27 | parser.add_argument('--includes', action='store_true', 28 | help='Include flags for both pybind11 and Python headers.') 29 | args = parser.parse_args() 30 | if not sys.argv[1:]: 31 | parser.print_help() 32 | if args.includes: 33 | print_includes() 34 | 35 | 36 | if __name__ == '__main__': 37 | main() 38 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/pybind11/_version.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | version_info = (2, 5, 'dev1') 3 | __version__ = '.'.join(map(str, version_info)) 4 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | 4 | [flake8] 5 | max-line-length = 99 6 | show_source = True 7 | exclude = .git, __pycache__, build, dist, docs, tools, venv 8 | ignore = 9 | # required for pretty matrix formatting: multiple spaces after `,` and `[` 10 | E201, E241, W504, 11 | # camelcase 'cPickle' imported as lowercase 'pickle' 12 | N813 13 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/cross_module_gil_utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/cross_module_gil_utils.cpp -- tools for acquiring GIL from a different module 3 | 4 | Copyright (c) 2019 Google LLC 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 | #include 10 | #include 11 | 12 | // This file mimics a DSO that makes pybind11 calls but does not define a 13 | // PYBIND11_MODULE. The purpose is to test that such a DSO can create a 14 | // py::gil_scoped_acquire when the running thread is in a GIL-released state. 15 | // 16 | // Note that we define a Python module here for convenience, but in general 17 | // this need not be the case. The typical scenario would be a DSO that implements 18 | // shared logic used internally by multiple pybind11 modules. 19 | 20 | namespace { 21 | 22 | namespace py = pybind11; 23 | void gil_acquire() { py::gil_scoped_acquire gil; } 24 | 25 | constexpr char kModuleName[] = "cross_module_gil_utils"; 26 | 27 | #if PY_MAJOR_VERSION >= 3 28 | struct PyModuleDef moduledef = { 29 | PyModuleDef_HEAD_INIT, 30 | kModuleName, 31 | NULL, 32 | 0, 33 | NULL, 34 | NULL, 35 | NULL, 36 | NULL, 37 | NULL 38 | }; 39 | #else 40 | PyMethodDef module_methods[] = { 41 | {NULL, NULL, 0, NULL} 42 | }; 43 | #endif 44 | 45 | } // namespace 46 | 47 | extern "C" PYBIND11_EXPORT 48 | #if PY_MAJOR_VERSION >= 3 49 | PyObject* PyInit_cross_module_gil_utils() 50 | #else 51 | void initcross_module_gil_utils() 52 | #endif 53 | { 54 | 55 | PyObject* m = 56 | #if PY_MAJOR_VERSION >= 3 57 | PyModule_Create(&moduledef); 58 | #else 59 | Py_InitModule(kModuleName, module_methods); 60 | #endif 61 | 62 | if (m != NULL) { 63 | static_assert( 64 | sizeof(&gil_acquire) == sizeof(void*), 65 | "Function pointer must have the same size as void*"); 66 | PyModule_AddObject(m, "gil_acquire_funcaddr", 67 | PyLong_FromVoidPtr(reinterpret_cast(&gil_acquire))); 68 | } 69 | 70 | #if PY_MAJOR_VERSION >= 3 71 | return m; 72 | #endif 73 | } 74 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/local_bindings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pybind11_tests.h" 3 | 4 | /// Simple class used to test py::local: 5 | template class LocalBase { 6 | public: 7 | LocalBase(int i) : i(i) { } 8 | int i = -1; 9 | }; 10 | 11 | /// Registered with py::module_local in both main and secondary modules: 12 | using LocalType = LocalBase<0>; 13 | /// Registered without py::module_local in both modules: 14 | using NonLocalType = LocalBase<1>; 15 | /// A second non-local type (for stl_bind tests): 16 | using NonLocal2 = LocalBase<2>; 17 | /// Tests within-module, different-compilation-unit local definition conflict: 18 | using LocalExternal = LocalBase<3>; 19 | /// Mixed: registered local first, then global 20 | using MixedLocalGlobal = LocalBase<4>; 21 | /// Mixed: global first, then local 22 | using MixedGlobalLocal = LocalBase<5>; 23 | 24 | /// Registered with py::module_local only in the secondary module: 25 | using ExternalType1 = LocalBase<6>; 26 | using ExternalType2 = LocalBase<7>; 27 | 28 | using LocalVec = std::vector; 29 | using LocalVec2 = std::vector; 30 | using LocalMap = std::unordered_map; 31 | using NonLocalVec = std::vector; 32 | using NonLocalVec2 = std::vector; 33 | using NonLocalMap = std::unordered_map; 34 | using NonLocalMap2 = std::unordered_map; 35 | 36 | PYBIND11_MAKE_OPAQUE(LocalVec); 37 | PYBIND11_MAKE_OPAQUE(LocalVec2); 38 | PYBIND11_MAKE_OPAQUE(LocalMap); 39 | PYBIND11_MAKE_OPAQUE(NonLocalVec); 40 | //PYBIND11_MAKE_OPAQUE(NonLocalVec2); // same type as LocalVec2 41 | PYBIND11_MAKE_OPAQUE(NonLocalMap); 42 | PYBIND11_MAKE_OPAQUE(NonLocalMap2); 43 | 44 | 45 | // Simple bindings (used with the above): 46 | template 47 | py::class_ bind_local(Args && ...args) { 48 | return py::class_(std::forward(args)...) 49 | .def(py::init()) 50 | .def("get", [](T &i) { return i.i + Adjust; }); 51 | }; 52 | 53 | // Simulate a foreign library base class (to match the example in the docs): 54 | namespace pets { 55 | class Pet { 56 | public: 57 | Pet(std::string name) : name_(name) {} 58 | std::string name_; 59 | const std::string &name() { return name_; } 60 | }; 61 | } 62 | 63 | struct MixGL { int i; MixGL(int i) : i{i} {} }; 64 | struct MixGL2 { int i; MixGL2(int i) : i{i} {} }; 65 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/pybind11_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/pybind11_tests.cpp -- pybind example plugin 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #include "constructor_stats.h" 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | For testing purposes, we define a static global variable here in a function that each individual 18 | test .cpp calls with its initialization lambda. It's convenient here because we can just not 19 | compile some test files to disable/ignore some of the test code. 20 | 21 | It is NOT recommended as a way to use pybind11 in practice, however: the initialization order will 22 | be essentially random, which is okay for our test scripts (there are no dependencies between the 23 | individual pybind11 test .cpp files), but most likely not what you want when using pybind11 24 | productively. 25 | 26 | Instead, see the "How can I reduce the build time?" question in the "Frequently asked questions" 27 | section of the documentation for good practice on splitting binding code over multiple files. 28 | */ 29 | std::list> &initializers() { 30 | static std::list> inits; 31 | return inits; 32 | } 33 | 34 | test_initializer::test_initializer(Initializer init) { 35 | initializers().push_back(init); 36 | } 37 | 38 | test_initializer::test_initializer(const char *submodule_name, Initializer init) { 39 | initializers().push_back([=](py::module &parent) { 40 | auto m = parent.def_submodule(submodule_name); 41 | init(m); 42 | }); 43 | } 44 | 45 | void bind_ConstructorStats(py::module &m) { 46 | py::class_(m, "ConstructorStats") 47 | .def("alive", &ConstructorStats::alive) 48 | .def("values", &ConstructorStats::values) 49 | .def_readwrite("default_constructions", &ConstructorStats::default_constructions) 50 | .def_readwrite("copy_assignments", &ConstructorStats::copy_assignments) 51 | .def_readwrite("move_assignments", &ConstructorStats::move_assignments) 52 | .def_readwrite("copy_constructions", &ConstructorStats::copy_constructions) 53 | .def_readwrite("move_constructions", &ConstructorStats::move_constructions) 54 | .def_static("get", (ConstructorStats &(*)(py::object)) &ConstructorStats::get, py::return_value_policy::reference_internal) 55 | 56 | // Not exactly ConstructorStats, but related: expose the internal pybind number of registered instances 57 | // to allow instance cleanup checks (invokes a GC first) 58 | .def_static("detail_reg_inst", []() { 59 | ConstructorStats::gc(); 60 | return py::detail::get_internals().registered_instances.size(); 61 | }) 62 | ; 63 | } 64 | 65 | PYBIND11_MODULE(pybind11_tests, m) { 66 | m.doc() = "pybind11 test module"; 67 | 68 | bind_ConstructorStats(m); 69 | 70 | #if !defined(NDEBUG) 71 | m.attr("debug_enabled") = true; 72 | #else 73 | m.attr("debug_enabled") = false; 74 | #endif 75 | 76 | py::class_(m, "UserType", "A `py::class_` type for testing") 77 | .def(py::init<>()) 78 | .def(py::init()) 79 | .def("get_value", &UserType::value, "Get value using a method") 80 | .def("set_value", &UserType::set, "Set value using a method") 81 | .def_property("value", &UserType::value, &UserType::set, "Get/set value using a property") 82 | .def("__repr__", [](const UserType& u) { return "UserType({})"_s.format(u.value()); }); 83 | 84 | py::class_(m, "IncType") 85 | .def(py::init<>()) 86 | .def(py::init()) 87 | .def("__repr__", [](const IncType& u) { return "IncType({})"_s.format(u.value()); }); 88 | 89 | for (const auto &initializer : initializers()) 90 | initializer(m); 91 | 92 | if (!py::hasattr(m, "have_eigen")) m.attr("have_eigen") = false; 93 | } 94 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/pybind11_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #if defined(_MSC_VER) && _MSC_VER < 1910 5 | // We get some really long type names here which causes MSVC 2015 to emit warnings 6 | # pragma warning(disable: 4503) // warning C4503: decorated name length exceeded, name was truncated 7 | #endif 8 | 9 | namespace py = pybind11; 10 | using namespace pybind11::literals; 11 | 12 | class test_initializer { 13 | using Initializer = void (*)(py::module &); 14 | 15 | public: 16 | test_initializer(Initializer init); 17 | test_initializer(const char *submodule_name, Initializer init); 18 | }; 19 | 20 | #define TEST_SUBMODULE(name, variable) \ 21 | void test_submodule_##name(py::module &); \ 22 | test_initializer name(#name, test_submodule_##name); \ 23 | void test_submodule_##name(py::module &variable) 24 | 25 | 26 | /// Dummy type which is not exported anywhere -- something to trigger a conversion error 27 | struct UnregisteredType { }; 28 | 29 | /// A user-defined type which is exported and can be used by any test 30 | class UserType { 31 | public: 32 | UserType() = default; 33 | UserType(int i) : i(i) { } 34 | 35 | int value() const { return i; } 36 | void set(int set) { i = set; } 37 | 38 | private: 39 | int i = -1; 40 | }; 41 | 42 | /// Like UserType, but increments `value` on copy for quick reference vs. copy tests 43 | class IncType : public UserType { 44 | public: 45 | using UserType::UserType; 46 | IncType() = default; 47 | IncType(const IncType &other) : IncType(other.value() + 1) { } 48 | IncType(IncType &&) = delete; 49 | IncType &operator=(const IncType &) = delete; 50 | IncType &operator=(IncType &&) = delete; 51 | }; 52 | 53 | /// Custom cast-only type that casts to a string "rvalue" or "lvalue" depending on the cast context. 54 | /// Used to test recursive casters (e.g. std::tuple, stl containers). 55 | struct RValueCaster {}; 56 | PYBIND11_NAMESPACE_BEGIN(pybind11) 57 | PYBIND11_NAMESPACE_BEGIN(detail) 58 | template<> class type_caster { 59 | public: 60 | PYBIND11_TYPE_CASTER(RValueCaster, _("RValueCaster")); 61 | static handle cast(RValueCaster &&, return_value_policy, handle) { return py::str("rvalue").release(); } 62 | static handle cast(const RValueCaster &, return_value_policy, handle) { return py::str("lvalue").release(); } 63 | }; 64 | PYBIND11_NAMESPACE_END(detail) 65 | PYBIND11_NAMESPACE_END(pybind11) 66 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | minversion = 3.0 3 | norecursedirs = test_cmake_build test_embed 4 | addopts = 5 | # show summary of skipped tests 6 | -rs 7 | # capture only Python print and C++ py::print, but not C output (low-level Python errors) 8 | --capture=sys 9 | filterwarnings = 10 | # make warnings into errors but ignore certain third-party extension issues 11 | error 12 | # importing scipy submodules on some version of Python 13 | ignore::ImportWarning 14 | # bogus numpy ABI warning (see numpy/#432) 15 | ignore:.*numpy.dtype size changed.*:RuntimeWarning 16 | ignore:.*numpy.ufunc size changed.*:RuntimeWarning 17 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | --extra-index-url https://antocuni.github.io/pypy-wheels/manylinux2010/ 2 | numpy==1.16.6; python_version<"3.6" 3 | numpy==1.18.0; platform_python_implementation=="PyPy" and sys_platform=="darwin" and python_version>="3.6" 4 | numpy==1.19.1; (platform_python_implementation!="PyPy" or sys_platform!="darwin") and python_version>="3.6" 5 | pytest==4.6.9; python_version<"3.5" 6 | pytest==5.4.3; python_version>="3.5" 7 | scipy==1.2.3; (platform_python_implementation!="PyPy" or sys_platform!="darwin") and python_version<"3.6" 8 | scipy==1.5.2; (platform_python_implementation!="PyPy" or sys_platform!="darwin") and python_version>="3.6" and python_version<"3.9" 9 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_async.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_async.cpp -- __await__ support 3 | 4 | Copyright (c) 2019 Google Inc. 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 | TEST_SUBMODULE(async_module, m) { 13 | struct DoesNotSupportAsync {}; 14 | py::class_(m, "DoesNotSupportAsync") 15 | .def(py::init<>()); 16 | struct SupportsAsync {}; 17 | py::class_(m, "SupportsAsync") 18 | .def(py::init<>()) 19 | .def("__await__", [](const SupportsAsync& self) -> py::object { 20 | static_cast(self); 21 | py::object loop = py::module::import("asyncio.events").attr("get_event_loop")(); 22 | py::object f = loop.attr("create_future")(); 23 | f.attr("set_result")(5); 24 | return f.attr("__await__")(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_async.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import asyncio 3 | import pytest 4 | from pybind11_tests import async_module as m 5 | 6 | 7 | @pytest.fixture 8 | def event_loop(): 9 | loop = asyncio.new_event_loop() 10 | yield loop 11 | loop.close() 12 | 13 | 14 | async def get_await_result(x): 15 | return await x 16 | 17 | 18 | def test_await(event_loop): 19 | assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync())) 20 | 21 | 22 | def test_await_missing(event_loop): 23 | with pytest.raises(TypeError): 24 | event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync())) 25 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_buffers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import io 3 | import struct 4 | import sys 5 | 6 | import pytest 7 | 8 | from pybind11_tests import buffers as m 9 | from pybind11_tests import ConstructorStats 10 | 11 | PY3 = sys.version_info[0] >= 3 12 | 13 | pytestmark = pytest.requires_numpy 14 | 15 | with pytest.suppress(ImportError): 16 | import numpy as np 17 | 18 | 19 | def test_from_python(): 20 | with pytest.raises(RuntimeError) as excinfo: 21 | m.Matrix(np.array([1, 2, 3])) # trying to assign a 1D array 22 | assert str(excinfo.value) == "Incompatible buffer format!" 23 | 24 | m3 = np.array([[1, 2, 3], [4, 5, 6]]).astype(np.float32) 25 | m4 = m.Matrix(m3) 26 | 27 | for i in range(m4.rows()): 28 | for j in range(m4.cols()): 29 | assert m3[i, j] == m4[i, j] 30 | 31 | cstats = ConstructorStats.get(m.Matrix) 32 | assert cstats.alive() == 1 33 | del m3, m4 34 | assert cstats.alive() == 0 35 | assert cstats.values() == ["2x3 matrix"] 36 | assert cstats.copy_constructions == 0 37 | # assert cstats.move_constructions >= 0 # Don't invoke any 38 | assert cstats.copy_assignments == 0 39 | assert cstats.move_assignments == 0 40 | 41 | 42 | # PyPy: Memory leak in the "np.array(m, copy=False)" call 43 | # https://bitbucket.org/pypy/pypy/issues/2444 44 | @pytest.unsupported_on_pypy 45 | def test_to_python(): 46 | mat = m.Matrix(5, 4) 47 | assert memoryview(mat).shape == (5, 4) 48 | 49 | assert mat[2, 3] == 0 50 | mat[2, 3] = 4.0 51 | mat[3, 2] = 7.0 52 | assert mat[2, 3] == 4 53 | assert mat[3, 2] == 7 54 | assert struct.unpack_from('f', mat, (3 * 4 + 2) * 4) == (7, ) 55 | assert struct.unpack_from('f', mat, (2 * 4 + 3) * 4) == (4, ) 56 | 57 | mat2 = np.array(mat, copy=False) 58 | assert mat2.shape == (5, 4) 59 | assert abs(mat2).sum() == 11 60 | assert mat2[2, 3] == 4 and mat2[3, 2] == 7 61 | mat2[2, 3] = 5 62 | assert mat2[2, 3] == 5 63 | 64 | cstats = ConstructorStats.get(m.Matrix) 65 | assert cstats.alive() == 1 66 | del mat 67 | pytest.gc_collect() 68 | assert cstats.alive() == 1 69 | del mat2 # holds a mat reference 70 | pytest.gc_collect() 71 | assert cstats.alive() == 0 72 | assert cstats.values() == ["5x4 matrix"] 73 | assert cstats.copy_constructions == 0 74 | # assert cstats.move_constructions >= 0 # Don't invoke any 75 | assert cstats.copy_assignments == 0 76 | assert cstats.move_assignments == 0 77 | 78 | 79 | @pytest.unsupported_on_pypy 80 | def test_inherited_protocol(): 81 | """SquareMatrix is derived from Matrix and inherits the buffer protocol""" 82 | 83 | matrix = m.SquareMatrix(5) 84 | assert memoryview(matrix).shape == (5, 5) 85 | assert np.asarray(matrix).shape == (5, 5) 86 | 87 | 88 | @pytest.unsupported_on_pypy 89 | def test_pointer_to_member_fn(): 90 | for cls in [m.Buffer, m.ConstBuffer, m.DerivedBuffer]: 91 | buf = cls() 92 | buf.value = 0x12345678 93 | value = struct.unpack('i', bytearray(buf))[0] 94 | assert value == 0x12345678 95 | 96 | 97 | @pytest.unsupported_on_pypy 98 | def test_readonly_buffer(): 99 | buf = m.BufferReadOnly(0x64) 100 | view = memoryview(buf) 101 | assert view[0] == 0x64 if PY3 else b'd' 102 | assert view.readonly 103 | 104 | 105 | @pytest.unsupported_on_pypy 106 | def test_selective_readonly_buffer(): 107 | buf = m.BufferReadOnlySelect() 108 | 109 | memoryview(buf)[0] = 0x64 if PY3 else b'd' 110 | assert buf.value == 0x64 111 | 112 | io.BytesIO(b'A').readinto(buf) 113 | assert buf.value == ord(b'A') 114 | 115 | buf.readonly = True 116 | with pytest.raises(TypeError): 117 | memoryview(buf)[0] = 0 if PY3 else b'\0' 118 | with pytest.raises(TypeError): 119 | io.BytesIO(b'1').readinto(buf) 120 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_call_policies.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_call_policies.cpp -- keep_alive and call_guard 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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_(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 | }; 55 | py::class_(m, "Parent") 56 | .def(py::init<>()) 57 | .def(py::init([](Child *) { return new Parent(); }), py::keep_alive<1, 2>()) 58 | .def("addChild", &Parent::addChild) 59 | .def("addChildKeepAlive", &Parent::addChild, py::keep_alive<1, 2>()) 60 | .def("returnChild", &Parent::returnChild) 61 | .def("returnChildKeepAlive", &Parent::returnChild, py::keep_alive<1, 0>()) 62 | .def("returnNullChildKeepAliveChild", &Parent::returnNullChild, py::keep_alive<1, 0>()) 63 | .def("returnNullChildKeepAliveParent", &Parent::returnNullChild, py::keep_alive<0, 1>()); 64 | 65 | #if !defined(PYPY_VERSION) 66 | // test_alive_gc 67 | class ParentGC : public Parent { 68 | public: 69 | using Parent::Parent; 70 | }; 71 | py::class_(m, "ParentGC", py::dynamic_attr()) 72 | .def(py::init<>()); 73 | #endif 74 | 75 | // test_call_guard 76 | m.def("unguarded_call", &CustomGuard::report_status); 77 | m.def("guarded_call", &CustomGuard::report_status, py::call_guard()); 78 | 79 | m.def("multiple_guards_correct_order", []() { 80 | return CustomGuard::report_status() + std::string(" & ") + DependentGuard::report_status(); 81 | }, py::call_guard()); 82 | 83 | m.def("multiple_guards_wrong_order", []() { 84 | return DependentGuard::report_status() + std::string(" & ") + CustomGuard::report_status(); 85 | }, py::call_guard()); 86 | 87 | #if defined(WITH_THREAD) && !defined(PYPY_VERSION) 88 | // `py::call_guard()` should work in PyPy as well, 89 | // but it's unclear how to test it without `PyGILState_GetThisThreadState`. 90 | auto report_gil_status = []() { 91 | auto is_gil_held = false; 92 | if (auto tstate = py::detail::get_thread_state_unchecked()) 93 | is_gil_held = (tstate == PyGILState_GetThisThreadState()); 94 | 95 | return is_gil_held ? "GIL held" : "GIL released"; 96 | }; 97 | 98 | m.def("with_gil", report_gil_status); 99 | m.def("without_gil", report_gil_status, py::call_guard()); 100 | #endif 101 | } 102 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_callbacks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | from pybind11_tests import callbacks as m 4 | from threading import Thread 5 | 6 | 7 | def test_callbacks(): 8 | from functools import partial 9 | 10 | def func1(): 11 | return "func1" 12 | 13 | def func2(a, b, c, d): 14 | return "func2", a, b, c, d 15 | 16 | def func3(a): 17 | return "func3({})".format(a) 18 | 19 | assert m.test_callback1(func1) == "func1" 20 | assert m.test_callback2(func2) == ("func2", "Hello", "x", True, 5) 21 | assert m.test_callback1(partial(func2, 1, 2, 3, 4)) == ("func2", 1, 2, 3, 4) 22 | assert m.test_callback1(partial(func3, "partial")) == "func3(partial)" 23 | assert m.test_callback3(lambda i: i + 1) == "func(43) = 44" 24 | 25 | f = m.test_callback4() 26 | assert f(43) == 44 27 | f = m.test_callback5() 28 | assert f(number=43) == 44 29 | 30 | 31 | def test_bound_method_callback(): 32 | # Bound Python method: 33 | class MyClass: 34 | def double(self, val): 35 | return 2 * val 36 | 37 | z = MyClass() 38 | assert m.test_callback3(z.double) == "func(43) = 86" 39 | 40 | z = m.CppBoundMethodTest() 41 | assert m.test_callback3(z.triple) == "func(43) = 129" 42 | 43 | 44 | def test_keyword_args_and_generalized_unpacking(): 45 | 46 | def f(*args, **kwargs): 47 | return args, kwargs 48 | 49 | assert m.test_tuple_unpacking(f) == (("positional", 1, 2, 3, 4, 5, 6), {}) 50 | assert m.test_dict_unpacking(f) == (("positional", 1), {"key": "value", "a": 1, "b": 2}) 51 | assert m.test_keyword_args(f) == ((), {"x": 10, "y": 20}) 52 | assert m.test_unpacking_and_keywords1(f) == ((1, 2), {"c": 3, "d": 4}) 53 | assert m.test_unpacking_and_keywords2(f) == ( 54 | ("positional", 1, 2, 3, 4, 5), 55 | {"key": "value", "a": 1, "b": 2, "c": 3, "d": 4, "e": 5} 56 | ) 57 | 58 | with pytest.raises(TypeError) as excinfo: 59 | m.test_unpacking_error1(f) 60 | assert "Got multiple values for keyword argument" in str(excinfo.value) 61 | 62 | with pytest.raises(TypeError) as excinfo: 63 | m.test_unpacking_error2(f) 64 | assert "Got multiple values for keyword argument" in str(excinfo.value) 65 | 66 | with pytest.raises(RuntimeError) as excinfo: 67 | m.test_arg_conversion_error1(f) 68 | assert "Unable to convert call argument" in str(excinfo.value) 69 | 70 | with pytest.raises(RuntimeError) as excinfo: 71 | m.test_arg_conversion_error2(f) 72 | assert "Unable to convert call argument" in str(excinfo.value) 73 | 74 | 75 | def test_lambda_closure_cleanup(): 76 | m.test_cleanup() 77 | cstats = m.payload_cstats() 78 | assert cstats.alive() == 0 79 | assert cstats.copy_constructions == 1 80 | assert cstats.move_constructions >= 1 81 | 82 | 83 | def test_cpp_function_roundtrip(): 84 | """Test if passing a function pointer from C++ -> Python -> C++ yields the original pointer""" 85 | 86 | assert m.test_dummy_function(m.dummy_function) == "matches dummy_function: eval(1) = 2" 87 | assert (m.test_dummy_function(m.roundtrip(m.dummy_function)) == 88 | "matches dummy_function: eval(1) = 2") 89 | assert m.roundtrip(None, expect_none=True) is None 90 | assert (m.test_dummy_function(lambda x: x + 2) == 91 | "can't convert to function pointer: eval(1) = 3") 92 | 93 | with pytest.raises(TypeError) as excinfo: 94 | m.test_dummy_function(m.dummy_function2) 95 | assert "incompatible function arguments" in str(excinfo.value) 96 | 97 | with pytest.raises(TypeError) as excinfo: 98 | m.test_dummy_function(lambda x, y: x + y) 99 | assert any(s in str(excinfo.value) for s in ("missing 1 required positional argument", 100 | "takes exactly 2 arguments")) 101 | 102 | 103 | def test_function_signatures(doc): 104 | assert doc(m.test_callback3) == "test_callback3(arg0: Callable[[int], int]) -> str" 105 | assert doc(m.test_callback4) == "test_callback4() -> Callable[[int], int]" 106 | 107 | 108 | def test_movable_object(): 109 | assert m.callback_with_movable(lambda _: None) is True 110 | 111 | 112 | def test_async_callbacks(): 113 | # serves as state for async callback 114 | class Item: 115 | def __init__(self, value): 116 | self.value = value 117 | 118 | res = [] 119 | 120 | # generate stateful lambda that will store result in `res` 121 | def gen_f(): 122 | s = Item(3) 123 | return lambda j: res.append(s.value + j) 124 | 125 | # do some work async 126 | work = [1, 2, 3, 4] 127 | m.test_async_callback(gen_f(), work) 128 | # wait until work is done 129 | from time import sleep 130 | sleep(0.5) 131 | assert sum(res) == sum([x + 3 for x in work]) 132 | 133 | 134 | def test_async_async_callbacks(): 135 | t = Thread(target=test_async_callbacks) 136 | t.start() 137 | t.join() 138 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_chrono.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_chrono.cpp -- test conversions to/from std::chrono types 3 | 4 | Copyright (c) 2016 Trent Houliston and 5 | Wenzel Jakob 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 13 | 14 | TEST_SUBMODULE(chrono, m) { 15 | using system_time = std::chrono::system_clock::time_point; 16 | using steady_time = std::chrono::steady_clock::time_point; 17 | 18 | using timespan = std::chrono::duration; 19 | using timestamp = std::chrono::time_point; 20 | 21 | // test_chrono_system_clock 22 | // Return the current time off the wall clock 23 | m.def("test_chrono1", []() { return std::chrono::system_clock::now(); }); 24 | 25 | // test_chrono_system_clock_roundtrip 26 | // Round trip the passed in system clock time 27 | m.def("test_chrono2", [](system_time t) { return t; }); 28 | 29 | // test_chrono_duration_roundtrip 30 | // Round trip the passed in duration 31 | m.def("test_chrono3", [](std::chrono::system_clock::duration d) { return d; }); 32 | 33 | // test_chrono_duration_subtraction_equivalence 34 | // Difference between two passed in time_points 35 | m.def("test_chrono4", [](system_time a, system_time b) { return a - b; }); 36 | 37 | // test_chrono_steady_clock 38 | // Return the current time off the steady_clock 39 | m.def("test_chrono5", []() { return std::chrono::steady_clock::now(); }); 40 | 41 | // test_chrono_steady_clock_roundtrip 42 | // Round trip a steady clock timepoint 43 | m.def("test_chrono6", [](steady_time t) { return t; }); 44 | 45 | // test_floating_point_duration 46 | // Roundtrip a duration in microseconds from a float argument 47 | m.def("test_chrono7", [](std::chrono::microseconds t) { return t; }); 48 | // Float durations (issue #719) 49 | m.def("test_chrono_float_diff", [](std::chrono::duration a, std::chrono::duration b) { 50 | return a - b; }); 51 | 52 | m.def("test_nano_timepoint", [](timestamp start, timespan delta) -> timestamp { 53 | return start + delta; 54 | }); 55 | } 56 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(test_cmake_build) 2 | 3 | if(CMAKE_VERSION VERSION_LESS 3.1) 4 | # 3.0 needed for interface library for subdirectory_target/installed_target 5 | # 3.1 needed for cmake -E env for testing 6 | return() 7 | endif() 8 | 9 | include(CMakeParseArguments) 10 | function(pybind11_add_build_test name) 11 | cmake_parse_arguments(ARG "INSTALL" "" "" ${ARGN}) 12 | 13 | set(build_options "-DCMAKE_PREFIX_PATH=${PROJECT_BINARY_DIR}/mock_install" 14 | "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" 15 | "-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}" 16 | "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" 17 | "-DPYBIND11_CPP_STANDARD=${PYBIND11_CPP_STANDARD}") 18 | if(NOT ARG_INSTALL) 19 | list(APPEND build_options "-DPYBIND11_PROJECT_DIR=${PROJECT_SOURCE_DIR}") 20 | endif() 21 | 22 | add_custom_target(test_${name} ${CMAKE_CTEST_COMMAND} 23 | --quiet --output-log ${name}.log 24 | --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/${name}" 25 | "${CMAKE_CURRENT_BINARY_DIR}/${name}" 26 | --build-config Release 27 | --build-noclean 28 | --build-generator ${CMAKE_GENERATOR} 29 | $<$:--build-generator-platform> ${CMAKE_GENERATOR_PLATFORM} 30 | --build-makeprogram ${CMAKE_MAKE_PROGRAM} 31 | --build-target check 32 | --build-options ${build_options} 33 | ) 34 | if(ARG_INSTALL) 35 | add_dependencies(test_${name} mock_install) 36 | endif() 37 | add_dependencies(test_cmake_build test_${name}) 38 | endfunction() 39 | 40 | pybind11_add_build_test(subdirectory_function) 41 | pybind11_add_build_test(subdirectory_target) 42 | if(NOT ${PYTHON_MODULE_EXTENSION} MATCHES "pypy") 43 | pybind11_add_build_test(subdirectory_embed) 44 | endif() 45 | 46 | if(PYBIND11_INSTALL) 47 | add_custom_target(mock_install ${CMAKE_COMMAND} 48 | "-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/mock_install" 49 | -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" 50 | ) 51 | 52 | pybind11_add_build_test(installed_function INSTALL) 53 | pybind11_add_build_test(installed_target INSTALL) 54 | if(NOT ${PYTHON_MODULE_EXTENSION} MATCHES "pypy") 55 | pybind11_add_build_test(installed_embed INSTALL) 56 | endif() 57 | endif() 58 | 59 | add_dependencies(check test_cmake_build) 60 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/embed.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_EMBEDDED_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | 8 | int main(int argc, char *argv[]) { 9 | if (argc != 2) 10 | throw std::runtime_error("Expected test.py file as the first argument"); 11 | auto test_py_file = argv[1]; 12 | 13 | py::scoped_interpreter guard{}; 14 | 15 | auto m = py::module::import("test_cmake_build"); 16 | if (m.attr("add")(1, 2).cast() != 3) 17 | throw std::runtime_error("embed.cpp failed"); 18 | 19 | py::module::import("sys").attr("argv") = py::make_tuple("test.py", "embed.cpp"); 20 | py::eval_file(test_py_file, py::globals()); 21 | } 22 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/installed_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_installed_embed CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | find_package(pybind11 CONFIG REQUIRED) 6 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 7 | 8 | add_executable(test_cmake_build ../embed.cpp) 9 | target_link_libraries(test_cmake_build PRIVATE pybind11::embed) 10 | 11 | 12 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::embed). 13 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 14 | set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 15 | 16 | add_custom_target(check $ ${PROJECT_SOURCE_DIR}/../test.py) 17 | 18 | if(CMAKE_CXX_STANDARD AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) 19 | if(CMAKE_CXX_STANDARD LESS 17) 20 | target_compile_options(test_cmake_build PUBLIC -Wno-deprecated-register) 21 | else() 22 | target_compile_options(test_cmake_build PUBLIC -Wno-register) 23 | endif() 24 | endif() 25 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/installed_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(test_installed_module CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | 6 | find_package(pybind11 CONFIG REQUIRED) 7 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 8 | 9 | pybind11_add_module(test_cmake_build SHARED NO_EXTRAS ../main.cpp) 10 | 11 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 12 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 13 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/installed_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_installed_target CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | 6 | find_package(pybind11 CONFIG REQUIRED) 7 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 8 | 9 | add_library(test_cmake_build MODULE ../main.cpp) 10 | 11 | target_link_libraries(test_cmake_build PRIVATE pybind11::module) 12 | 13 | # make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 14 | set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" 15 | SUFFIX "${PYTHON_MODULE_EXTENSION}") 16 | 17 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module). 18 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 19 | set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 20 | 21 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 22 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 23 | 24 | if(CMAKE_CXX_STANDARD AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) 25 | if(CMAKE_CXX_STANDARD LESS 17) 26 | target_compile_options(test_cmake_build PUBLIC -Wno-deprecated-register) 27 | else() 28 | target_compile_options(test_cmake_build PUBLIC -Wno-register) 29 | endif() 30 | endif() 31 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_subdirectory_embed CXX) 3 | 4 | set(PYBIND11_INSTALL ON CACHE BOOL "") 5 | set(PYBIND11_EXPORT_NAME test_export) 6 | 7 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 8 | 9 | # Test basic target functionality 10 | add_executable(test_cmake_build ../embed.cpp) 11 | target_link_libraries(test_cmake_build PRIVATE pybind11::embed) 12 | 13 | add_custom_target(check $ ${PROJECT_SOURCE_DIR}/../test.py) 14 | 15 | # Test custom export group -- PYBIND11_EXPORT_NAME 16 | add_library(test_embed_lib ../embed.cpp) 17 | target_link_libraries(test_embed_lib PRIVATE pybind11::embed) 18 | 19 | install(TARGETS test_embed_lib 20 | EXPORT test_export 21 | ARCHIVE DESTINATION bin 22 | LIBRARY DESTINATION lib 23 | RUNTIME DESTINATION lib) 24 | install(EXPORT test_export 25 | DESTINATION lib/cmake/test_export/test_export-Targets.cmake) 26 | 27 | if(CMAKE_CXX_STANDARD AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) 28 | if(CMAKE_CXX_STANDARD LESS 17) 29 | target_compile_options(test_embed_lib PUBLIC -Wno-deprecated-register) 30 | target_compile_options(test_cmake_build PUBLIC -Wno-deprecated-register) 31 | else() 32 | target_compile_options(test_embed_lib PUBLIC -Wno-register) 33 | target_compile_options(test_cmake_build PUBLIC -Wno-register) 34 | endif() 35 | endif() 36 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/subdirectory_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(test_subdirectory_module CXX) 3 | 4 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 5 | pybind11_add_module(test_cmake_build THIN_LTO ../main.cpp) 6 | 7 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 8 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 9 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/subdirectory_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_subdirectory_target CXX) 3 | 4 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 5 | 6 | add_library(test_cmake_build MODULE ../main.cpp) 7 | 8 | target_link_libraries(test_cmake_build PRIVATE pybind11::module) 9 | 10 | # make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 11 | set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" 12 | SUFFIX "${PYTHON_MODULE_EXTENSION}") 13 | 14 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 15 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 16 | 17 | if(CMAKE_CXX_STANDARD AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) 18 | if(CMAKE_CXX_STANDARD LESS 17) 19 | target_compile_options(test_cmake_build PUBLIC -Wno-deprecated-register) 20 | else() 21 | target_compile_options(test_cmake_build PUBLIC -Wno-register) 22 | endif() 23 | endif() 24 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_cmake_build/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | import test_cmake_build 4 | 5 | assert test_cmake_build.add(1, 2) == 3 6 | print("{} imports, runs, and adds: 1 + 2 = 3".format(sys.argv[1])) 7 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_constants_and_functions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_constants_and_functions.cpp -- global constants and functions, enumerations, raw byte strings 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | enum MyEnum { EFirstEntry = 1, ESecondEntry }; 13 | 14 | std::string test_function1() { 15 | return "test_function()"; 16 | } 17 | 18 | std::string test_function2(MyEnum k) { 19 | return "test_function(enum=" + std::to_string(k) + ")"; 20 | } 21 | 22 | std::string test_function3(int i) { 23 | return "test_function(" + std::to_string(i) + ")"; 24 | } 25 | 26 | py::str test_function4() { return "test_function()"; } 27 | py::str test_function4(char *) { return "test_function(char *)"; } 28 | py::str test_function4(int, float) { return "test_function(int, float)"; } 29 | py::str test_function4(float, int) { return "test_function(float, int)"; } 30 | 31 | py::bytes return_bytes() { 32 | const char *data = "\x01\x00\x02\x00"; 33 | return std::string(data, 4); 34 | } 35 | 36 | std::string print_bytes(py::bytes bytes) { 37 | std::string ret = "bytes["; 38 | const auto value = static_cast(bytes); 39 | for (size_t i = 0; i < value.length(); ++i) { 40 | ret += std::to_string(static_cast(value[i])) + " "; 41 | } 42 | ret.back() = ']'; 43 | return ret; 44 | } 45 | 46 | // Test that we properly handle C++17 exception specifiers (which are part of the function signature 47 | // in C++17). These should all still work before C++17, but don't affect the function signature. 48 | namespace test_exc_sp { 49 | int f1(int x) noexcept { return x+1; } 50 | int f2(int x) noexcept(true) { return x+2; } 51 | int f3(int x) noexcept(false) { return x+3; } 52 | #if defined(__GNUG__) 53 | # pragma GCC diagnostic push 54 | # pragma GCC diagnostic ignored "-Wdeprecated" 55 | #endif 56 | int f4(int x) throw() { return x+4; } // Deprecated equivalent to noexcept(true) 57 | #if defined(__GNUG__) 58 | # pragma GCC diagnostic pop 59 | #endif 60 | struct C { 61 | int m1(int x) noexcept { return x-1; } 62 | int m2(int x) const noexcept { return x-2; } 63 | int m3(int x) noexcept(true) { return x-3; } 64 | int m4(int x) const noexcept(true) { return x-4; } 65 | int m5(int x) noexcept(false) { return x-5; } 66 | int m6(int x) const noexcept(false) { return x-6; } 67 | #if defined(__GNUG__) 68 | # pragma GCC diagnostic push 69 | # pragma GCC diagnostic ignored "-Wdeprecated" 70 | #endif 71 | int m7(int x) throw() { return x-7; } 72 | int m8(int x) const throw() { return x-8; } 73 | #if defined(__GNUG__) 74 | # pragma GCC diagnostic pop 75 | #endif 76 | }; 77 | } 78 | 79 | 80 | TEST_SUBMODULE(constants_and_functions, m) { 81 | // test_constants 82 | m.attr("some_constant") = py::int_(14); 83 | 84 | // test_function_overloading 85 | m.def("test_function", &test_function1); 86 | m.def("test_function", &test_function2); 87 | m.def("test_function", &test_function3); 88 | 89 | #if defined(PYBIND11_OVERLOAD_CAST) 90 | m.def("test_function", py::overload_cast<>(&test_function4)); 91 | m.def("test_function", py::overload_cast(&test_function4)); 92 | m.def("test_function", py::overload_cast(&test_function4)); 93 | m.def("test_function", py::overload_cast(&test_function4)); 94 | #else 95 | m.def("test_function", static_cast(&test_function4)); 96 | m.def("test_function", static_cast(&test_function4)); 97 | m.def("test_function", static_cast(&test_function4)); 98 | m.def("test_function", static_cast(&test_function4)); 99 | #endif 100 | 101 | py::enum_(m, "MyEnum") 102 | .value("EFirstEntry", EFirstEntry) 103 | .value("ESecondEntry", ESecondEntry) 104 | .export_values(); 105 | 106 | // test_bytes 107 | m.def("return_bytes", &return_bytes); 108 | m.def("print_bytes", &print_bytes); 109 | 110 | // test_exception_specifiers 111 | using namespace test_exc_sp; 112 | py::class_(m, "C") 113 | .def(py::init<>()) 114 | .def("m1", &C::m1) 115 | .def("m2", &C::m2) 116 | .def("m3", &C::m3) 117 | .def("m4", &C::m4) 118 | .def("m5", &C::m5) 119 | .def("m6", &C::m6) 120 | .def("m7", &C::m7) 121 | .def("m8", &C::m8) 122 | ; 123 | m.def("f1", f1); 124 | m.def("f2", f2); 125 | m.def("f3", f3); 126 | m.def("f4", f4); 127 | } 128 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_constants_and_functions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import constants_and_functions as m 3 | 4 | 5 | def test_constants(): 6 | assert m.some_constant == 14 7 | 8 | 9 | def test_function_overloading(): 10 | assert m.test_function() == "test_function()" 11 | assert m.test_function(7) == "test_function(7)" 12 | assert m.test_function(m.MyEnum.EFirstEntry) == "test_function(enum=1)" 13 | assert m.test_function(m.MyEnum.ESecondEntry) == "test_function(enum=2)" 14 | 15 | assert m.test_function() == "test_function()" 16 | assert m.test_function("abcd") == "test_function(char *)" 17 | assert m.test_function(1, 1.0) == "test_function(int, float)" 18 | assert m.test_function(1, 1.0) == "test_function(int, float)" 19 | assert m.test_function(2.0, 2) == "test_function(float, int)" 20 | 21 | 22 | def test_bytes(): 23 | assert m.print_bytes(m.return_bytes()) == "bytes[1 0 2 0]" 24 | 25 | 26 | def test_exception_specifiers(): 27 | c = m.C() 28 | assert c.m1(2) == 1 29 | assert c.m2(3) == 1 30 | assert c.m3(5) == 2 31 | assert c.m4(7) == 3 32 | assert c.m5(10) == 5 33 | assert c.m6(14) == 8 34 | assert c.m7(20) == 13 35 | assert c.m8(29) == 21 36 | 37 | assert m.f1(33) == 34 38 | assert m.f2(53) == 55 39 | assert m.f3(86) == 89 40 | assert m.f4(140) == 144 41 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_custom_type_casters.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | from pybind11_tests import custom_type_casters as m 4 | 5 | 6 | def test_noconvert_args(msg): 7 | a = m.ArgInspector() 8 | assert msg(a.f("hi")) == """ 9 | loading ArgInspector1 argument WITH conversion allowed. Argument value = hi 10 | """ 11 | assert msg(a.g("this is a", "this is b")) == """ 12 | loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 13 | loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 14 | 13 15 | loading ArgInspector2 argument WITH conversion allowed. Argument value = (default arg inspector 2) 16 | """ # noqa: E501 line too long 17 | assert msg(a.g("this is a", "this is b", 42)) == """ 18 | loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 19 | loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 20 | 42 21 | loading ArgInspector2 argument WITH conversion allowed. Argument value = (default arg inspector 2) 22 | """ # noqa: E501 line too long 23 | assert msg(a.g("this is a", "this is b", 42, "this is d")) == """ 24 | loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 25 | loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 26 | 42 27 | loading ArgInspector2 argument WITH conversion allowed. Argument value = this is d 28 | """ 29 | assert (a.h("arg 1") == 30 | "loading ArgInspector2 argument WITHOUT conversion allowed. Argument value = arg 1") 31 | assert msg(m.arg_inspect_func("A1", "A2")) == """ 32 | loading ArgInspector2 argument WITH conversion allowed. Argument value = A1 33 | loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = A2 34 | """ 35 | 36 | assert m.floats_preferred(4) == 2.0 37 | assert m.floats_only(4.0) == 2.0 38 | with pytest.raises(TypeError) as excinfo: 39 | m.floats_only(4) 40 | assert msg(excinfo.value) == """ 41 | floats_only(): incompatible function arguments. The following argument types are supported: 42 | 1. (f: float) -> float 43 | 44 | Invoked with: 4 45 | """ 46 | 47 | assert m.ints_preferred(4) == 2 48 | assert m.ints_preferred(True) == 0 49 | with pytest.raises(TypeError) as excinfo: 50 | m.ints_preferred(4.0) 51 | assert msg(excinfo.value) == """ 52 | ints_preferred(): incompatible function arguments. The following argument types are supported: 53 | 1. (i: int) -> int 54 | 55 | Invoked with: 4.0 56 | """ # noqa: E501 line too long 57 | 58 | assert m.ints_only(4) == 2 59 | with pytest.raises(TypeError) as excinfo: 60 | m.ints_only(4.0) 61 | assert msg(excinfo.value) == """ 62 | ints_only(): incompatible function arguments. The following argument types are supported: 63 | 1. (i: int) -> int 64 | 65 | Invoked with: 4.0 66 | """ 67 | 68 | 69 | def test_custom_caster_destruction(): 70 | """Tests that returning a pointer to a type that gets converted with a custom type caster gets 71 | destroyed when the function has py::return_value_policy::take_ownership policy applied.""" 72 | 73 | cstats = m.destruction_tester_cstats() 74 | # This one *doesn't* have take_ownership: the pointer should be used but not destroyed: 75 | z = m.custom_caster_no_destroy() 76 | assert cstats.alive() == 1 and cstats.default_constructions == 1 77 | assert z 78 | 79 | # take_ownership applied: this constructs a new object, casts it, then destroys it: 80 | z = m.custom_caster_destroy() 81 | assert z 82 | assert cstats.default_constructions == 2 83 | 84 | # Same, but with a const pointer return (which should *not* inhibit destruction): 85 | z = m.custom_caster_destroy_const() 86 | assert z 87 | assert cstats.default_constructions == 3 88 | 89 | # Make sure we still only have the original object (from ..._no_destroy()) alive: 90 | assert cstats.alive() == 1 91 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_docstring_options.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_docstring_options.cpp -- generation of docstrings and signatures 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | TEST_SUBMODULE(docstring_options, m) { 13 | // test_docstring_options 14 | { 15 | py::options options; 16 | options.disable_function_signatures(); 17 | 18 | m.def("test_function1", [](int, int) {}, py::arg("a"), py::arg("b")); 19 | m.def("test_function2", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); 20 | 21 | m.def("test_overloaded1", [](int) {}, py::arg("i"), "Overload docstring"); 22 | m.def("test_overloaded1", [](double) {}, py::arg("d")); 23 | 24 | m.def("test_overloaded2", [](int) {}, py::arg("i"), "overload docstring 1"); 25 | m.def("test_overloaded2", [](double) {}, py::arg("d"), "overload docstring 2"); 26 | 27 | m.def("test_overloaded3", [](int) {}, py::arg("i")); 28 | m.def("test_overloaded3", [](double) {}, py::arg("d"), "Overload docstr"); 29 | 30 | options.enable_function_signatures(); 31 | 32 | m.def("test_function3", [](int, int) {}, py::arg("a"), py::arg("b")); 33 | m.def("test_function4", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); 34 | 35 | options.disable_function_signatures().disable_user_defined_docstrings(); 36 | 37 | m.def("test_function5", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); 38 | 39 | { 40 | py::options nested_options; 41 | nested_options.enable_user_defined_docstrings(); 42 | m.def("test_function6", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); 43 | } 44 | } 45 | 46 | m.def("test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); 47 | 48 | { 49 | py::options options; 50 | options.disable_user_defined_docstrings(); 51 | 52 | struct DocstringTestFoo { 53 | int value; 54 | void setValue(int v) { value = v; } 55 | int getValue() const { return value; } 56 | }; 57 | py::class_(m, "DocstringTestFoo", "This is a class docstring") 58 | .def_property("value_prop", &DocstringTestFoo::getValue, &DocstringTestFoo::setValue, "This is a property docstring") 59 | ; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_docstring_options.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import docstring_options as m 3 | 4 | 5 | def test_docstring_options(): 6 | # options.disable_function_signatures() 7 | assert not m.test_function1.__doc__ 8 | 9 | assert m.test_function2.__doc__ == "A custom docstring" 10 | 11 | # docstring specified on just the first overload definition: 12 | assert m.test_overloaded1.__doc__ == "Overload docstring" 13 | 14 | # docstring on both overloads: 15 | assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2" 16 | 17 | # docstring on only second overload: 18 | assert m.test_overloaded3.__doc__ == "Overload docstr" 19 | 20 | # options.enable_function_signatures() 21 | assert m.test_function3.__doc__ .startswith("test_function3(a: int, b: int) -> None") 22 | 23 | assert m.test_function4.__doc__ .startswith("test_function4(a: int, b: int) -> None") 24 | assert m.test_function4.__doc__ .endswith("A custom docstring\n") 25 | 26 | # options.disable_function_signatures() 27 | # options.disable_user_defined_docstrings() 28 | assert not m.test_function5.__doc__ 29 | 30 | # nested options.enable_user_defined_docstrings() 31 | assert m.test_function6.__doc__ == "A custom docstring" 32 | 33 | # RAII destructor 34 | assert m.test_function7.__doc__ .startswith("test_function7(a: int, b: int) -> None") 35 | assert m.test_function7.__doc__ .endswith("A custom docstring\n") 36 | 37 | # Suppression of user-defined docstrings for non-function objects 38 | assert not m.DocstringTestFoo.__doc__ 39 | assert not m.DocstringTestFoo.value_prop.__doc__ 40 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${PYTHON_MODULE_EXTENSION} MATCHES "pypy") 2 | add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported. 3 | set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}") 4 | return() 5 | endif() 6 | 7 | find_package(Catch 2.13.0) 8 | if(CATCH_FOUND) 9 | message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}") 10 | else() 11 | message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers" 12 | " manually or use `cmake -DDOWNLOAD_CATCH=ON` to fetch them automatically.") 13 | return() 14 | endif() 15 | 16 | add_executable(test_embed 17 | catch.cpp 18 | test_interpreter.cpp 19 | ) 20 | target_include_directories(test_embed PRIVATE "${CATCH_INCLUDE_DIR}") 21 | pybind11_enable_warnings(test_embed) 22 | 23 | if(NOT CMAKE_VERSION VERSION_LESS 3.0) 24 | target_link_libraries(test_embed PRIVATE pybind11::embed) 25 | else() 26 | target_include_directories(test_embed PRIVATE "${PYBIND11_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIRS}") 27 | target_compile_options(test_embed PRIVATE "${PYBIND11_CPP_STANDARD}") 28 | target_link_libraries(test_embed PRIVATE "${PYTHON_LIBRARIES}") 29 | endif() 30 | 31 | find_package(Threads REQUIRED) 32 | target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT}) 33 | 34 | add_custom_target(cpptest COMMAND $ 35 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 36 | 37 | pybind11_add_module(external_module THIN_LTO external_module.cpp) 38 | set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 39 | foreach(config ${CMAKE_CONFIGURATION_TYPES}) 40 | string(TOUPPER ${config} config) 41 | set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} "${CMAKE_CURRENT_SOURCE_DIR}") 42 | endforeach() 43 | add_dependencies(cpptest external_module) 44 | 45 | add_dependencies(check cpptest) 46 | 47 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) 48 | if(CMAKE_CXX_STANDARD LESS 17) 49 | target_compile_options(test_embed PUBLIC -Wno-deprecated-register) 50 | target_compile_options(external_module PUBLIC -Wno-deprecated-register) 51 | else() 52 | target_compile_options(test_embed PUBLIC -Wno-register) 53 | target_compile_options(external_module PUBLIC -Wno-register) 54 | endif() 55 | endif() 56 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_embed/catch.cpp: -------------------------------------------------------------------------------- 1 | // The Catch implementation is compiled here. This is a standalone 2 | // translation unit to avoid recompiling it for every test change. 3 | 4 | #include 5 | 6 | #ifdef _MSC_VER 7 | // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch 8 | // 2.0.1; this should be fixed in the next catch release after 2.0.1). 9 | # pragma warning(disable: 4996) 10 | #endif 11 | 12 | #define CATCH_CONFIG_RUNNER 13 | #include 14 | 15 | namespace py = pybind11; 16 | 17 | int main(int argc, char *argv[]) { 18 | py::scoped_interpreter guard{}; 19 | auto result = Catch::Session().run(argc, argv); 20 | 21 | return result < 0xff ? result : 0xff; 22 | } 23 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_embed/external_module.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace py = pybind11; 4 | 5 | /* Simple test module/test class to check that the referenced internals data of external pybind11 6 | * modules aren't preserved over a finalize/initialize. 7 | */ 8 | 9 | PYBIND11_MODULE(external_module, m) { 10 | class A { 11 | public: 12 | A(int value) : v{value} {}; 13 | int v; 14 | }; 15 | 16 | py::class_(m, "A") 17 | .def(py::init()) 18 | .def_readwrite("value", &A::v); 19 | 20 | m.def("internals_at", []() { 21 | return reinterpret_cast(&py::detail::get_internals()); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_embed/test_interpreter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from widget_module import Widget 3 | 4 | 5 | class DerivedWidget(Widget): 6 | def __init__(self, message): 7 | super(DerivedWidget, self).__init__(message) 8 | 9 | def the_answer(self): 10 | return 42 11 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_enum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_enums.cpp -- enumerations 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | TEST_SUBMODULE(enums, m) { 13 | // test_unscoped_enum 14 | enum UnscopedEnum { 15 | EOne = 1, 16 | ETwo, 17 | EThree 18 | }; 19 | py::enum_(m, "UnscopedEnum", py::arithmetic(), "An unscoped enumeration") 20 | .value("EOne", EOne, "Docstring for EOne") 21 | .value("ETwo", ETwo, "Docstring for ETwo") 22 | .value("EThree", EThree, "Docstring for EThree") 23 | .export_values(); 24 | 25 | // test_scoped_enum 26 | enum class ScopedEnum { 27 | Two = 2, 28 | Three 29 | }; 30 | py::enum_(m, "ScopedEnum", py::arithmetic()) 31 | .value("Two", ScopedEnum::Two) 32 | .value("Three", ScopedEnum::Three); 33 | 34 | m.def("test_scoped_enum", [](ScopedEnum z) { 35 | return "ScopedEnum::" + std::string(z == ScopedEnum::Two ? "Two" : "Three"); 36 | }); 37 | 38 | // test_binary_operators 39 | enum Flags { 40 | Read = 4, 41 | Write = 2, 42 | Execute = 1 43 | }; 44 | py::enum_(m, "Flags", py::arithmetic()) 45 | .value("Read", Flags::Read) 46 | .value("Write", Flags::Write) 47 | .value("Execute", Flags::Execute) 48 | .export_values(); 49 | 50 | // test_implicit_conversion 51 | class ClassWithUnscopedEnum { 52 | public: 53 | enum EMode { 54 | EFirstMode = 1, 55 | ESecondMode 56 | }; 57 | 58 | static EMode test_function(EMode mode) { 59 | return mode; 60 | } 61 | }; 62 | py::class_ exenum_class(m, "ClassWithUnscopedEnum"); 63 | exenum_class.def_static("test_function", &ClassWithUnscopedEnum::test_function); 64 | py::enum_(exenum_class, "EMode") 65 | .value("EFirstMode", ClassWithUnscopedEnum::EFirstMode) 66 | .value("ESecondMode", ClassWithUnscopedEnum::ESecondMode) 67 | .export_values(); 68 | 69 | // test_enum_to_int 70 | m.def("test_enum_to_int", [](int) { }); 71 | m.def("test_enum_to_uint", [](uint32_t) { }); 72 | m.def("test_enum_to_long_long", [](long long) { }); 73 | 74 | // test_duplicate_enum_name 75 | enum SimpleEnum 76 | { 77 | ONE, TWO, THREE 78 | }; 79 | 80 | m.def("register_bad_enum", [m]() { 81 | py::enum_(m, "SimpleEnum") 82 | .value("ONE", SimpleEnum::ONE) //NOTE: all value function calls are called with the same first parameter value 83 | .value("ONE", SimpleEnum::TWO) 84 | .value("ONE", SimpleEnum::THREE) 85 | .export_values(); 86 | }); 87 | } 88 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_eval.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_eval.cpp -- Usage of eval() and eval_file() 3 | 4 | Copyright (c) 2016 Klemens D. Morgenstern 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 | 11 | #include 12 | #include "pybind11_tests.h" 13 | 14 | TEST_SUBMODULE(eval_, m) { 15 | // test_evals 16 | 17 | auto global = py::dict(py::module::import("__main__").attr("__dict__")); 18 | 19 | m.def("test_eval_statements", [global]() { 20 | auto local = py::dict(); 21 | local["call_test"] = py::cpp_function([&]() -> int { 22 | return 42; 23 | }); 24 | 25 | // Regular string literal 26 | py::exec( 27 | "message = 'Hello World!'\n" 28 | "x = call_test()", 29 | global, local 30 | ); 31 | 32 | // Multi-line raw string literal 33 | py::exec(R"( 34 | if x == 42: 35 | print(message) 36 | else: 37 | raise RuntimeError 38 | )", global, local 39 | ); 40 | auto x = local["x"].cast(); 41 | 42 | return x == 42; 43 | }); 44 | 45 | m.def("test_eval", [global]() { 46 | auto local = py::dict(); 47 | local["x"] = py::int_(42); 48 | auto x = py::eval("x", global, local); 49 | return x.cast() == 42; 50 | }); 51 | 52 | m.def("test_eval_single_statement", []() { 53 | auto local = py::dict(); 54 | local["call_test"] = py::cpp_function([&]() -> int { 55 | return 42; 56 | }); 57 | 58 | auto result = py::eval("x = call_test()", py::dict(), local); 59 | auto x = local["x"].cast(); 60 | return result.is_none() && x == 42; 61 | }); 62 | 63 | m.def("test_eval_file", [global](py::str filename) { 64 | auto local = py::dict(); 65 | local["y"] = py::int_(43); 66 | 67 | int val_out; 68 | local["call_test2"] = py::cpp_function([&](int value) { val_out = value; }); 69 | 70 | auto result = py::eval_file(filename, global, local); 71 | return val_out == 43 && result.is_none(); 72 | }); 73 | 74 | m.def("test_eval_failure", []() { 75 | try { 76 | py::eval("nonsense code ..."); 77 | } catch (py::error_already_set &) { 78 | return true; 79 | } 80 | return false; 81 | }); 82 | 83 | m.def("test_eval_file_failure", []() { 84 | try { 85 | py::eval_file("non-existing file"); 86 | } catch (std::exception &) { 87 | return true; 88 | } 89 | return false; 90 | }); 91 | } 92 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_eval.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import pytest 4 | from pybind11_tests import eval_ as m 5 | 6 | 7 | def test_evals(capture): 8 | with capture: 9 | assert m.test_eval_statements() 10 | assert capture == "Hello World!" 11 | 12 | assert m.test_eval() 13 | assert m.test_eval_single_statement() 14 | 15 | assert m.test_eval_failure() 16 | 17 | 18 | @pytest.unsupported_on_pypy3 19 | def test_eval_file(): 20 | filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py") 21 | assert m.test_eval_file(filename) 22 | 23 | assert m.test_eval_file_failure() 24 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_eval_call.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is called from 'test_eval.py' 3 | 4 | if 'call_test2' in locals(): 5 | call_test2(y) # noqa: F821 undefined name 6 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_gil_scoped.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_gil_scoped.cpp -- acquire and release gil 3 | 4 | Copyright (c) 2017 Borja Zarco (Google LLC) 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 | #include 12 | 13 | 14 | class VirtClass { 15 | public: 16 | virtual ~VirtClass() = default; 17 | VirtClass() = default; 18 | VirtClass(const VirtClass&) = delete; 19 | virtual void virtual_func() {} 20 | virtual void pure_virtual_func() = 0; 21 | }; 22 | 23 | class PyVirtClass : public VirtClass { 24 | void virtual_func() override { 25 | PYBIND11_OVERLOAD(void, VirtClass, virtual_func,); 26 | } 27 | void pure_virtual_func() override { 28 | PYBIND11_OVERLOAD_PURE(void, VirtClass, pure_virtual_func,); 29 | } 30 | }; 31 | 32 | TEST_SUBMODULE(gil_scoped, m) { 33 | py::class_(m, "VirtClass") 34 | .def(py::init<>()) 35 | .def("virtual_func", &VirtClass::virtual_func) 36 | .def("pure_virtual_func", &VirtClass::pure_virtual_func); 37 | 38 | m.def("test_callback_py_obj", 39 | [](py::object func) { func(); }); 40 | m.def("test_callback_std_func", 41 | [](const std::function &func) { func(); }); 42 | m.def("test_callback_virtual_func", 43 | [](VirtClass &virt) { virt.virtual_func(); }); 44 | m.def("test_callback_pure_virtual_func", 45 | [](VirtClass &virt) { virt.pure_virtual_func(); }); 46 | m.def("test_cross_module_gil", 47 | []() { 48 | auto cm = py::module::import("cross_module_gil_utils"); 49 | auto gil_acquire = reinterpret_cast( 50 | PyLong_AsVoidPtr(cm.attr("gil_acquire_funcaddr").ptr())); 51 | py::gil_scoped_release gil_release; 52 | gil_acquire(); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_gil_scoped.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import multiprocessing 3 | import threading 4 | from pybind11_tests import gil_scoped as m 5 | 6 | 7 | def _run_in_process(target, *args, **kwargs): 8 | """Runs target in process and returns its exitcode after 10s (None if still alive).""" 9 | process = multiprocessing.Process(target=target, args=args, kwargs=kwargs) 10 | process.daemon = True 11 | try: 12 | process.start() 13 | # Do not need to wait much, 10s should be more than enough. 14 | process.join(timeout=10) 15 | return process.exitcode 16 | finally: 17 | if process.is_alive(): 18 | process.terminate() 19 | 20 | 21 | def _python_to_cpp_to_python(): 22 | """Calls different C++ functions that come back to Python.""" 23 | class ExtendedVirtClass(m.VirtClass): 24 | def virtual_func(self): 25 | pass 26 | 27 | def pure_virtual_func(self): 28 | pass 29 | 30 | extended = ExtendedVirtClass() 31 | m.test_callback_py_obj(lambda: None) 32 | m.test_callback_std_func(lambda: None) 33 | m.test_callback_virtual_func(extended) 34 | m.test_callback_pure_virtual_func(extended) 35 | 36 | 37 | def _python_to_cpp_to_python_from_threads(num_threads, parallel=False): 38 | """Calls different C++ functions that come back to Python, from Python threads.""" 39 | threads = [] 40 | for _ in range(num_threads): 41 | thread = threading.Thread(target=_python_to_cpp_to_python) 42 | thread.daemon = True 43 | thread.start() 44 | if parallel: 45 | threads.append(thread) 46 | else: 47 | thread.join() 48 | for thread in threads: 49 | thread.join() 50 | 51 | 52 | def test_python_to_cpp_to_python_from_thread(): 53 | """Makes sure there is no GIL deadlock when running in a thread. 54 | 55 | It runs in a separate process to be able to stop and assert if it deadlocks. 56 | """ 57 | assert _run_in_process(_python_to_cpp_to_python_from_threads, 1) == 0 58 | 59 | 60 | def test_python_to_cpp_to_python_from_thread_multiple_parallel(): 61 | """Makes sure there is no GIL deadlock when running in a thread multiple times in parallel. 62 | 63 | It runs in a separate process to be able to stop and assert if it deadlocks. 64 | """ 65 | assert _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=True) == 0 66 | 67 | 68 | def test_python_to_cpp_to_python_from_thread_multiple_sequential(): 69 | """Makes sure there is no GIL deadlock when running in a thread multiple times sequentially. 70 | 71 | It runs in a separate process to be able to stop and assert if it deadlocks. 72 | """ 73 | assert _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=False) == 0 74 | 75 | 76 | def test_python_to_cpp_to_python_from_process(): 77 | """Makes sure there is no GIL deadlock when using processes. 78 | 79 | This test is for completion, but it was never an issue. 80 | """ 81 | assert _run_in_process(_python_to_cpp_to_python) == 0 82 | 83 | 84 | def test_cross_module_gil(): 85 | """Makes sure that the GIL can be acquired by another module from a GIL-released state.""" 86 | m.test_cross_module_gil() # Should not raise a SIGSEGV 87 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_iostream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_iostream.cpp -- Usage of scoped_output_redirect 3 | 4 | Copyright (c) 2017 Henry F. Schreiner 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 | 11 | #include 12 | #include "pybind11_tests.h" 13 | #include 14 | 15 | 16 | void noisy_function(std::string msg, bool flush) { 17 | 18 | std::cout << msg; 19 | if (flush) 20 | std::cout << std::flush; 21 | } 22 | 23 | void noisy_funct_dual(std::string msg, std::string emsg) { 24 | std::cout << msg; 25 | std::cerr << emsg; 26 | } 27 | 28 | TEST_SUBMODULE(iostream, m) { 29 | 30 | add_ostream_redirect(m); 31 | 32 | // test_evals 33 | 34 | m.def("captured_output_default", [](std::string msg) { 35 | py::scoped_ostream_redirect redir; 36 | std::cout << msg << std::flush; 37 | }); 38 | 39 | m.def("captured_output", [](std::string msg) { 40 | py::scoped_ostream_redirect redir(std::cout, py::module::import("sys").attr("stdout")); 41 | std::cout << msg << std::flush; 42 | }); 43 | 44 | m.def("guard_output", &noisy_function, 45 | py::call_guard(), 46 | py::arg("msg"), py::arg("flush")=true); 47 | 48 | m.def("captured_err", [](std::string msg) { 49 | py::scoped_ostream_redirect redir(std::cerr, py::module::import("sys").attr("stderr")); 50 | std::cerr << msg << std::flush; 51 | }); 52 | 53 | m.def("noisy_function", &noisy_function, py::arg("msg"), py::arg("flush") = true); 54 | 55 | m.def("dual_guard", &noisy_funct_dual, 56 | py::call_guard(), 57 | py::arg("msg"), py::arg("emsg")); 58 | 59 | m.def("raw_output", [](std::string msg) { 60 | std::cout << msg << std::flush; 61 | }); 62 | 63 | m.def("raw_err", [](std::string msg) { 64 | std::cerr << msg << std::flush; 65 | }); 66 | 67 | m.def("captured_dual", [](std::string msg, std::string emsg) { 68 | py::scoped_ostream_redirect redirout(std::cout, py::module::import("sys").attr("stdout")); 69 | py::scoped_ostream_redirect redirerr(std::cerr, py::module::import("sys").attr("stderr")); 70 | std::cout << msg << std::flush; 71 | std::cerr << emsg << std::flush; 72 | }); 73 | } 74 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_local_bindings.cpp: -------------------------------------------------------------------------------- 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 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 | #include 14 | #include 15 | #include 16 | 17 | TEST_SUBMODULE(local_bindings, m) { 18 | // test_load_external 19 | m.def("load_external1", [](ExternalType1 &e) { return e.i; }); 20 | m.def("load_external2", [](ExternalType2 &e) { return e.i; }); 21 | 22 | // test_local_bindings 23 | // Register a class with py::module_local: 24 | bind_local(m, "LocalType", py::module_local()) 25 | .def("get3", [](LocalType &t) { return t.i + 3; }) 26 | ; 27 | 28 | m.def("local_value", [](LocalType &l) { return l.i; }); 29 | 30 | // test_nonlocal_failure 31 | // The main pybind11 test module is loaded first, so this registration will succeed (the second 32 | // one, in pybind11_cross_module_tests.cpp, is designed to fail): 33 | bind_local(m, "NonLocalType") 34 | .def(py::init()) 35 | .def("get", [](LocalType &i) { return i.i; }) 36 | ; 37 | 38 | // test_duplicate_local 39 | // py::module_local declarations should be visible across compilation units that get linked together; 40 | // this tries to register a duplicate local. It depends on a definition in test_class.cpp and 41 | // should raise a runtime error from the duplicate definition attempt. If test_class isn't 42 | // available it *also* throws a runtime error (with "test_class not enabled" as value). 43 | m.def("register_local_external", [m]() { 44 | auto main = py::module::import("pybind11_tests"); 45 | if (py::hasattr(main, "class_")) { 46 | bind_local(m, "LocalExternal", py::module_local()); 47 | } 48 | else throw std::runtime_error("test_class not enabled"); 49 | }); 50 | 51 | // test_stl_bind_local 52 | // stl_bind.h binders defaults to py::module_local if the types are local or converting: 53 | py::bind_vector(m, "LocalVec"); 54 | py::bind_map(m, "LocalMap"); 55 | // and global if the type (or one of the types, for the map) is global: 56 | py::bind_vector(m, "NonLocalVec"); 57 | py::bind_map(m, "NonLocalMap"); 58 | 59 | // test_stl_bind_global 60 | // They can, however, be overridden to global using `py::module_local(false)`: 61 | bind_local(m, "NonLocal2"); 62 | py::bind_vector(m, "LocalVec2", py::module_local()); 63 | py::bind_map(m, "NonLocalMap2", py::module_local(false)); 64 | 65 | // test_mixed_local_global 66 | // We try this both with the global type registered first and vice versa (the order shouldn't 67 | // matter). 68 | m.def("register_mixed_global", [m]() { 69 | bind_local(m, "MixedGlobalLocal", py::module_local(false)); 70 | }); 71 | m.def("register_mixed_local", [m]() { 72 | bind_local(m, "MixedLocalGlobal", py::module_local()); 73 | }); 74 | m.def("get_mixed_gl", [](int i) { return MixedGlobalLocal(i); }); 75 | m.def("get_mixed_lg", [](int i) { return MixedLocalGlobal(i); }); 76 | 77 | // test_internal_locals_differ 78 | m.def("local_cpp_types_addr", []() { return (uintptr_t) &py::detail::registered_local_types_cpp(); }); 79 | 80 | // test_stl_caster_vs_stl_bind 81 | m.def("load_vector_via_caster", [](std::vector v) { 82 | return std::accumulate(v.begin(), v.end(), 0); 83 | }); 84 | 85 | // test_cross_module_calls 86 | m.def("return_self", [](LocalVec *v) { return v; }); 87 | m.def("return_copy", [](const LocalVec &v) { return LocalVec(v); }); 88 | 89 | class Cat : public pets::Pet { public: Cat(std::string name) : Pet(name) {}; }; 90 | py::class_(m, "Pet", py::module_local()) 91 | .def("get_name", &pets::Pet::name); 92 | // Binding for local extending class: 93 | py::class_(m, "Cat") 94 | .def(py::init()); 95 | m.def("pet_name", [](pets::Pet &p) { return p.name(); }); 96 | 97 | py::class_(m, "MixGL").def(py::init()); 98 | m.def("get_gl_value", [](MixGL &o) { return o.i + 10; }); 99 | 100 | py::class_(m, "MixGL2").def(py::init()); 101 | } 102 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_modules.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_modules.cpp -- nested modules, importing modules, and 3 | internal references 4 | 5 | Copyright (c) 2016 Wenzel Jakob 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 "constructor_stats.h" 13 | 14 | TEST_SUBMODULE(modules, m) { 15 | // test_nested_modules 16 | py::module m_sub = m.def_submodule("subsubmodule"); 17 | m_sub.def("submodule_func", []() { return "submodule_func()"; }); 18 | 19 | // test_reference_internal 20 | class A { 21 | public: 22 | A(int v) : v(v) { print_created(this, v); } 23 | ~A() { print_destroyed(this); } 24 | A(const A&) { print_copy_created(this); } 25 | A& operator=(const A ©) { print_copy_assigned(this); v = copy.v; return *this; } 26 | std::string toString() { return "A[" + std::to_string(v) + "]"; } 27 | private: 28 | int v; 29 | }; 30 | py::class_(m_sub, "A") 31 | .def(py::init()) 32 | .def("__repr__", &A::toString); 33 | 34 | class B { 35 | public: 36 | B() { print_default_created(this); } 37 | ~B() { print_destroyed(this); } 38 | B(const B&) { print_copy_created(this); } 39 | B& operator=(const B ©) { print_copy_assigned(this); a1 = copy.a1; a2 = copy.a2; return *this; } 40 | A &get_a1() { return a1; } 41 | A &get_a2() { return a2; } 42 | 43 | A a1{1}; 44 | A a2{2}; 45 | }; 46 | py::class_(m_sub, "B") 47 | .def(py::init<>()) 48 | .def("get_a1", &B::get_a1, "Return the internal A 1", py::return_value_policy::reference_internal) 49 | .def("get_a2", &B::get_a2, "Return the internal A 2", py::return_value_policy::reference_internal) 50 | .def_readwrite("a1", &B::a1) // def_readonly uses an internal reference return policy by default 51 | .def_readwrite("a2", &B::a2); 52 | 53 | m.attr("OD") = py::module::import("collections").attr("OrderedDict"); 54 | 55 | // test_duplicate_registration 56 | // Registering two things with the same name 57 | m.def("duplicate_registration", []() { 58 | class Dupe1 { }; 59 | class Dupe2 { }; 60 | class Dupe3 { }; 61 | class DupeException { }; 62 | 63 | auto dm = py::module("dummy"); 64 | auto failures = py::list(); 65 | 66 | py::class_(dm, "Dupe1"); 67 | py::class_(dm, "Dupe2"); 68 | dm.def("dupe1_factory", []() { return Dupe1(); }); 69 | py::exception(dm, "DupeException"); 70 | 71 | try { 72 | py::class_(dm, "Dupe1"); 73 | failures.append("Dupe1 class"); 74 | } catch (std::runtime_error &) {} 75 | try { 76 | dm.def("Dupe1", []() { return Dupe1(); }); 77 | failures.append("Dupe1 function"); 78 | } catch (std::runtime_error &) {} 79 | try { 80 | py::class_(dm, "dupe1_factory"); 81 | failures.append("dupe1_factory"); 82 | } catch (std::runtime_error &) {} 83 | try { 84 | py::exception(dm, "Dupe2"); 85 | failures.append("Dupe2"); 86 | } catch (std::runtime_error &) {} 87 | try { 88 | dm.def("DupeException", []() { return 30; }); 89 | failures.append("DupeException1"); 90 | } catch (std::runtime_error &) {} 91 | try { 92 | py::class_(dm, "DupeException"); 93 | failures.append("DupeException2"); 94 | } catch (std::runtime_error &) {} 95 | 96 | return failures; 97 | }); 98 | } 99 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_modules.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import modules as m 3 | from pybind11_tests.modules import subsubmodule as ms 4 | from pybind11_tests import ConstructorStats 5 | 6 | 7 | def test_nested_modules(): 8 | import pybind11_tests 9 | assert pybind11_tests.__name__ == "pybind11_tests" 10 | assert pybind11_tests.modules.__name__ == "pybind11_tests.modules" 11 | assert pybind11_tests.modules.subsubmodule.__name__ == "pybind11_tests.modules.subsubmodule" 12 | assert m.__name__ == "pybind11_tests.modules" 13 | assert ms.__name__ == "pybind11_tests.modules.subsubmodule" 14 | 15 | assert ms.submodule_func() == "submodule_func()" 16 | 17 | 18 | def test_reference_internal(): 19 | b = ms.B() 20 | assert str(b.get_a1()) == "A[1]" 21 | assert str(b.a1) == "A[1]" 22 | assert str(b.get_a2()) == "A[2]" 23 | assert str(b.a2) == "A[2]" 24 | 25 | b.a1 = ms.A(42) 26 | b.a2 = ms.A(43) 27 | assert str(b.get_a1()) == "A[42]" 28 | assert str(b.a1) == "A[42]" 29 | assert str(b.get_a2()) == "A[43]" 30 | assert str(b.a2) == "A[43]" 31 | 32 | astats, bstats = ConstructorStats.get(ms.A), ConstructorStats.get(ms.B) 33 | assert astats.alive() == 2 34 | assert bstats.alive() == 1 35 | del b 36 | assert astats.alive() == 0 37 | assert bstats.alive() == 0 38 | assert astats.values() == ['1', '2', '42', '43'] 39 | assert bstats.values() == [] 40 | assert astats.default_constructions == 0 41 | assert bstats.default_constructions == 1 42 | assert astats.copy_constructions == 0 43 | assert bstats.copy_constructions == 0 44 | # assert astats.move_constructions >= 0 # Don't invoke any 45 | # assert bstats.move_constructions >= 0 # Don't invoke any 46 | assert astats.copy_assignments == 2 47 | assert bstats.copy_assignments == 0 48 | assert astats.move_assignments == 0 49 | assert bstats.move_assignments == 0 50 | 51 | 52 | def test_importing(): 53 | from pybind11_tests.modules import OD 54 | from collections import OrderedDict 55 | 56 | assert OD is OrderedDict 57 | assert str(OD([(1, 'a'), (2, 'b')])) == "OrderedDict([(1, 'a'), (2, 'b')])" 58 | 59 | 60 | def test_pydoc(): 61 | """Pydoc needs to be able to provide help() for everything inside a pybind11 module""" 62 | import pybind11_tests 63 | import pydoc 64 | 65 | assert pybind11_tests.__name__ == "pybind11_tests" 66 | assert pybind11_tests.__doc__ == "pybind11 test module" 67 | assert pydoc.text.docmodule(pybind11_tests) 68 | 69 | 70 | def test_duplicate_registration(): 71 | """Registering two things with the same name""" 72 | 73 | assert m.duplicate_registration() == [] 74 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_numpy_vectorize.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_numpy_vectorize.cpp -- auto-vectorize functions over NumPy array 3 | arguments 4 | 5 | Copyright (c) 2016 Wenzel Jakob 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 13 | 14 | double my_func(int x, float y, double z) { 15 | py::print("my_func(x:int={}, y:float={:.0f}, z:float={:.0f})"_s.format(x, y, z)); 16 | return (float) x*y*z; 17 | } 18 | 19 | TEST_SUBMODULE(numpy_vectorize, m) { 20 | try { py::module::import("numpy"); } 21 | catch (...) { return; } 22 | 23 | // test_vectorize, test_docs, test_array_collapse 24 | // Vectorize all arguments of a function (though non-vector arguments are also allowed) 25 | m.def("vectorized_func", py::vectorize(my_func)); 26 | 27 | // Vectorize a lambda function with a capture object (e.g. to exclude some arguments from the vectorization) 28 | m.def("vectorized_func2", 29 | [](py::array_t x, py::array_t y, float z) { 30 | return py::vectorize([z](int x, float y) { return my_func(x, y, z); })(x, y); 31 | } 32 | ); 33 | 34 | // Vectorize a complex-valued function 35 | m.def("vectorized_func3", py::vectorize( 36 | [](std::complex c) { return c * std::complex(2.f); } 37 | )); 38 | 39 | // test_type_selection 40 | // Numpy function which only accepts specific data types 41 | m.def("selective_func", [](py::array_t) { return "Int branch taken."; }); 42 | m.def("selective_func", [](py::array_t) { return "Float branch taken."; }); 43 | m.def("selective_func", [](py::array_t, py::array::c_style>) { return "Complex float branch taken."; }); 44 | 45 | 46 | // test_passthrough_arguments 47 | // Passthrough test: references and non-pod types should be automatically passed through (in the 48 | // function definition below, only `b`, `d`, and `g` are vectorized): 49 | struct NonPODClass { 50 | NonPODClass(int v) : value{v} {} 51 | int value; 52 | }; 53 | py::class_(m, "NonPODClass").def(py::init()); 54 | m.def("vec_passthrough", py::vectorize( 55 | [](double *a, double b, py::array_t c, const int &d, int &e, NonPODClass f, const double g) { 56 | return *a + b + c.at(0) + d + e + f.value + g; 57 | } 58 | )); 59 | 60 | // test_method_vectorization 61 | struct VectorizeTestClass { 62 | VectorizeTestClass(int v) : value{v} {}; 63 | float method(int x, float y) { return y + (float) (x + value); } 64 | int value = 0; 65 | }; 66 | py::class_ vtc(m, "VectorizeTestClass"); 67 | vtc .def(py::init()) 68 | .def_readwrite("value", &VectorizeTestClass::value); 69 | 70 | // Automatic vectorizing of methods 71 | vtc.def("method", py::vectorize(&VectorizeTestClass::method)); 72 | 73 | // test_trivial_broadcasting 74 | // Internal optimization test for whether the input is trivially broadcastable: 75 | py::enum_(m, "trivial") 76 | .value("f_trivial", py::detail::broadcast_trivial::f_trivial) 77 | .value("c_trivial", py::detail::broadcast_trivial::c_trivial) 78 | .value("non_trivial", py::detail::broadcast_trivial::non_trivial); 79 | m.def("vectorized_is_trivial", []( 80 | py::array_t arg1, 81 | py::array_t arg2, 82 | py::array_t arg3 83 | ) { 84 | ssize_t ndim; 85 | std::vector shape; 86 | std::array buffers {{ arg1.request(), arg2.request(), arg3.request() }}; 87 | return py::detail::broadcast(buffers, ndim, shape); 88 | }); 89 | } 90 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_opaque_types.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_opaque_types.cpp -- opaque types, passing void pointers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 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 | #include 12 | #include 13 | 14 | // IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures 15 | // 16 | // This also deliberately doesn't use the below StringList type alias to test 17 | // that MAKE_OPAQUE can handle a type containing a `,`. (The `std::allocator` 18 | // bit is just the default `std::vector` allocator). 19 | PYBIND11_MAKE_OPAQUE(std::vector>); 20 | 21 | using StringList = std::vector>; 22 | 23 | TEST_SUBMODULE(opaque_types, m) { 24 | // test_string_list 25 | py::class_(m, "StringList") 26 | .def(py::init<>()) 27 | .def("pop_back", &StringList::pop_back) 28 | /* There are multiple versions of push_back(), etc. Select the right ones. */ 29 | .def("push_back", (void (StringList::*)(const std::string &)) &StringList::push_back) 30 | .def("back", (std::string &(StringList::*)()) &StringList::back) 31 | .def("__len__", [](const StringList &v) { return v.size(); }) 32 | .def("__iter__", [](StringList &v) { 33 | return py::make_iterator(v.begin(), v.end()); 34 | }, py::keep_alive<0, 1>()); 35 | 36 | class ClassWithSTLVecProperty { 37 | public: 38 | StringList stringList; 39 | }; 40 | py::class_(m, "ClassWithSTLVecProperty") 41 | .def(py::init<>()) 42 | .def_readwrite("stringList", &ClassWithSTLVecProperty::stringList); 43 | 44 | m.def("print_opaque_list", [](const StringList &l) { 45 | std::string ret = "Opaque list: ["; 46 | bool first = true; 47 | for (auto entry : l) { 48 | if (!first) 49 | ret += ", "; 50 | ret += entry; 51 | first = false; 52 | } 53 | return ret + "]"; 54 | }); 55 | 56 | // test_pointers 57 | m.def("return_void_ptr", []() { return (void *) 0x1234; }); 58 | m.def("get_void_ptr_value", [](void *ptr) { return reinterpret_cast(ptr); }); 59 | m.def("return_null_str", []() { return (char *) nullptr; }); 60 | m.def("get_null_str_value", [](char *ptr) { return reinterpret_cast(ptr); }); 61 | 62 | m.def("return_unique_ptr", []() -> std::unique_ptr { 63 | StringList *result = new StringList(); 64 | result->push_back("some value"); 65 | return std::unique_ptr(result); 66 | }); 67 | } 68 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_opaque_types.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | from pybind11_tests import opaque_types as m 4 | from pybind11_tests import ConstructorStats, UserType 5 | 6 | 7 | def test_string_list(): 8 | lst = m.StringList() 9 | lst.push_back("Element 1") 10 | lst.push_back("Element 2") 11 | assert m.print_opaque_list(lst) == "Opaque list: [Element 1, Element 2]" 12 | assert lst.back() == "Element 2" 13 | 14 | for i, k in enumerate(lst, start=1): 15 | assert k == "Element {}".format(i) 16 | lst.pop_back() 17 | assert m.print_opaque_list(lst) == "Opaque list: [Element 1]" 18 | 19 | cvp = m.ClassWithSTLVecProperty() 20 | assert m.print_opaque_list(cvp.stringList) == "Opaque list: []" 21 | 22 | cvp.stringList = lst 23 | cvp.stringList.push_back("Element 3") 24 | assert m.print_opaque_list(cvp.stringList) == "Opaque list: [Element 1, Element 3]" 25 | 26 | 27 | def test_pointers(msg): 28 | living_before = ConstructorStats.get(UserType).alive() 29 | assert m.get_void_ptr_value(m.return_void_ptr()) == 0x1234 30 | assert m.get_void_ptr_value(UserType()) # Should also work for other C++ types 31 | assert ConstructorStats.get(UserType).alive() == living_before 32 | 33 | with pytest.raises(TypeError) as excinfo: 34 | m.get_void_ptr_value([1, 2, 3]) # This should not work 35 | assert msg(excinfo.value) == """ 36 | get_void_ptr_value(): incompatible function arguments. The following argument types are supported: 37 | 1. (arg0: capsule) -> int 38 | 39 | Invoked with: [1, 2, 3] 40 | """ # noqa: E501 line too long 41 | 42 | assert m.return_null_str() is None 43 | assert m.get_null_str_value(m.return_null_str()) is not None 44 | 45 | ptr = m.return_unique_ptr() 46 | assert "StringList" in repr(ptr) 47 | assert m.print_opaque_list(ptr) == "Opaque list: [some value]" 48 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_operator_overloading.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | from pybind11_tests import operators as m 4 | from pybind11_tests import ConstructorStats 5 | 6 | 7 | def test_operator_overloading(): 8 | v1 = m.Vector2(1, 2) 9 | v2 = m.Vector(3, -1) 10 | v3 = m.Vector2(1, 2) # Same value as v1, but different instance. 11 | assert v1 is not v3 12 | 13 | assert str(v1) == "[1.000000, 2.000000]" 14 | assert str(v2) == "[3.000000, -1.000000]" 15 | 16 | assert str(-v2) == "[-3.000000, 1.000000]" 17 | 18 | assert str(v1 + v2) == "[4.000000, 1.000000]" 19 | assert str(v1 - v2) == "[-2.000000, 3.000000]" 20 | assert str(v1 - 8) == "[-7.000000, -6.000000]" 21 | assert str(v1 + 8) == "[9.000000, 10.000000]" 22 | assert str(v1 * 8) == "[8.000000, 16.000000]" 23 | assert str(v1 / 8) == "[0.125000, 0.250000]" 24 | assert str(8 - v1) == "[7.000000, 6.000000]" 25 | assert str(8 + v1) == "[9.000000, 10.000000]" 26 | assert str(8 * v1) == "[8.000000, 16.000000]" 27 | assert str(8 / v1) == "[8.000000, 4.000000]" 28 | assert str(v1 * v2) == "[3.000000, -2.000000]" 29 | assert str(v2 / v1) == "[3.000000, -0.500000]" 30 | 31 | assert v1 == v3 32 | assert v1 != v2 33 | assert hash(v1) == 4 34 | # TODO(eric.cousineau): Make this work. 35 | # assert abs(v1) == "abs(Vector2)" 36 | 37 | v1 += 2 * v2 38 | assert str(v1) == "[7.000000, 0.000000]" 39 | v1 -= v2 40 | assert str(v1) == "[4.000000, 1.000000]" 41 | v1 *= 2 42 | assert str(v1) == "[8.000000, 2.000000]" 43 | v1 /= 16 44 | assert str(v1) == "[0.500000, 0.125000]" 45 | v1 *= v2 46 | assert str(v1) == "[1.500000, -0.125000]" 47 | v2 /= v1 48 | assert str(v2) == "[2.000000, 8.000000]" 49 | 50 | cstats = ConstructorStats.get(m.Vector2) 51 | assert cstats.alive() == 3 52 | del v1 53 | assert cstats.alive() == 2 54 | del v2 55 | assert cstats.alive() == 1 56 | del v3 57 | assert cstats.alive() == 0 58 | assert cstats.values() == [ 59 | '[1.000000, 2.000000]', 60 | '[3.000000, -1.000000]', 61 | '[1.000000, 2.000000]', 62 | '[-3.000000, 1.000000]', 63 | '[4.000000, 1.000000]', 64 | '[-2.000000, 3.000000]', 65 | '[-7.000000, -6.000000]', 66 | '[9.000000, 10.000000]', 67 | '[8.000000, 16.000000]', 68 | '[0.125000, 0.250000]', 69 | '[7.000000, 6.000000]', 70 | '[9.000000, 10.000000]', 71 | '[8.000000, 16.000000]', 72 | '[8.000000, 4.000000]', 73 | '[3.000000, -2.000000]', 74 | '[3.000000, -0.500000]', 75 | '[6.000000, -2.000000]', 76 | ] 77 | assert cstats.default_constructions == 0 78 | assert cstats.copy_constructions == 0 79 | assert cstats.move_constructions >= 10 80 | assert cstats.copy_assignments == 0 81 | assert cstats.move_assignments == 0 82 | 83 | 84 | def test_operators_notimplemented(): 85 | """#393: need to return NotSupported to ensure correct arithmetic operator behavior""" 86 | 87 | c1, c2 = m.C1(), m.C2() 88 | assert c1 + c1 == 11 89 | assert c2 + c2 == 22 90 | assert c2 + c1 == 21 91 | assert c1 + c2 == 12 92 | 93 | 94 | def test_nested(): 95 | """#328: first member in a class can't be used in operators""" 96 | 97 | a = m.NestA() 98 | b = m.NestB() 99 | c = m.NestC() 100 | 101 | a += 10 102 | assert m.get_NestA(a) == 13 103 | b.a += 100 104 | assert m.get_NestA(b.a) == 103 105 | c.b.a += 1000 106 | assert m.get_NestA(c.b.a) == 1003 107 | b -= 1 108 | assert m.get_NestB(b) == 3 109 | c.b -= 3 110 | assert m.get_NestB(c.b) == 1 111 | c *= 7 112 | assert m.get_NestC(c) == 35 113 | 114 | abase = a.as_base() 115 | assert abase.value == -2 116 | a.as_base().value += 44 117 | assert abase.value == 42 118 | assert c.b.a.as_base().value == -2 119 | c.b.a.as_base().value += 44 120 | assert c.b.a.as_base().value == 42 121 | 122 | del c 123 | pytest.gc_collect() 124 | del a # Shouldn't delete while abase is still alive 125 | pytest.gc_collect() 126 | 127 | assert abase.value == 42 128 | del abase, b 129 | pytest.gc_collect() 130 | 131 | 132 | def test_overriding_eq_reset_hash(): 133 | 134 | assert m.Comparable(15) is not m.Comparable(15) 135 | assert m.Comparable(15) == m.Comparable(15) 136 | 137 | with pytest.raises(TypeError): 138 | hash(m.Comparable(15)) # TypeError: unhashable type: 'm.Comparable' 139 | 140 | for hashable in (m.Hashable, m.Hashable2): 141 | assert hashable(15) is not hashable(15) 142 | assert hashable(15) == hashable(15) 143 | 144 | assert hash(hashable(15)) == 15 145 | assert hash(hashable(15)) == hash(hashable(15)) 146 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_pickling.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | from pybind11_tests import pickling as m 4 | 5 | try: 6 | import cPickle as pickle # Use cPickle on Python 2.7 7 | except ImportError: 8 | import pickle 9 | 10 | 11 | @pytest.mark.parametrize("cls_name", ["Pickleable", "PickleableNew"]) 12 | def test_roundtrip(cls_name): 13 | cls = getattr(m, cls_name) 14 | p = cls("test_value") 15 | p.setExtra1(15) 16 | p.setExtra2(48) 17 | 18 | data = pickle.dumps(p, 2) # Must use pickle protocol >= 2 19 | p2 = pickle.loads(data) 20 | assert p2.value() == p.value() 21 | assert p2.extra1() == p.extra1() 22 | assert p2.extra2() == p.extra2() 23 | 24 | 25 | @pytest.unsupported_on_pypy 26 | @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"]) 27 | def test_roundtrip_with_dict(cls_name): 28 | cls = getattr(m, cls_name) 29 | p = cls("test_value") 30 | p.extra = 15 31 | p.dynamic = "Attribute" 32 | 33 | data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL) 34 | p2 = pickle.loads(data) 35 | assert p2.value == p.value 36 | assert p2.extra == p.extra 37 | assert p2.dynamic == p.dynamic 38 | 39 | 40 | def test_enum_pickle(): 41 | from pybind11_tests import enums as e 42 | data = pickle.dumps(e.EOne, 2) 43 | assert e.EOne == pickle.loads(data) 44 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_tagbased_polymorphic.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import tagbased_polymorphic as m 3 | 4 | 5 | def test_downcast(): 6 | zoo = m.create_zoo() 7 | assert [type(animal) for animal in zoo] == [ 8 | m.Labrador, m.Dog, m.Chihuahua, m.Cat, m.Panther 9 | ] 10 | assert [animal.name for animal in zoo] == [ 11 | "Fido", "Ginger", "Hertzl", "Tiger", "Leo" 12 | ] 13 | zoo[1].sound = "woooooo" 14 | assert [dog.bark() for dog in zoo[:3]] == [ 15 | "Labrador Fido goes WOOF!", 16 | "Dog Ginger goes woooooo", 17 | "Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles" 18 | ] 19 | assert [cat.purr() for cat in zoo[3:]] == ["mrowr", "mrrrRRRRRR"] 20 | zoo[0].excitement -= 1000 21 | assert zoo[0].excitement == 14000 22 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_union.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_class.cpp -- test py::class_ definitions and basic functionality 3 | 4 | Copyright (c) 2019 Roland Dreier 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 | TEST_SUBMODULE(union_, m) { 13 | union TestUnion { 14 | int value_int; 15 | unsigned value_uint; 16 | }; 17 | 18 | py::class_(m, "TestUnion") 19 | .def(py::init<>()) 20 | .def_readonly("as_int", &TestUnion::value_int) 21 | .def_readwrite("as_uint", &TestUnion::value_uint); 22 | } 23 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tests/test_union.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import union_ as m 3 | 4 | 5 | def test_union(): 6 | instance = m.TestUnion() 7 | 8 | instance.as_uint = 10 9 | assert instance.as_int == 10 10 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tools/FindCatch.cmake: -------------------------------------------------------------------------------- 1 | # - Find the Catch test framework or download it (single header) 2 | # 3 | # This is a quick module for internal use. It assumes that Catch is 4 | # REQUIRED and that a minimum version is provided (not EXACT). If 5 | # a suitable version isn't found locally, the single header file 6 | # will be downloaded and placed in the build dir: PROJECT_BINARY_DIR. 7 | # 8 | # This code sets the following variables: 9 | # CATCH_INCLUDE_DIR - path to catch.hpp 10 | # CATCH_VERSION - version number 11 | 12 | if(NOT Catch_FIND_VERSION) 13 | message(FATAL_ERROR "A version number must be specified.") 14 | elseif(Catch_FIND_REQUIRED) 15 | message(FATAL_ERROR "This module assumes Catch is not required.") 16 | elseif(Catch_FIND_VERSION_EXACT) 17 | message(FATAL_ERROR "Exact version numbers are not supported, only minimum.") 18 | endif() 19 | 20 | # Extract the version number from catch.hpp 21 | function(_get_catch_version) 22 | file(STRINGS "${CATCH_INCLUDE_DIR}/catch.hpp" version_line REGEX "Catch v.*" LIMIT_COUNT 1) 23 | if(version_line MATCHES "Catch v([0-9]+)\\.([0-9]+)\\.([0-9]+)") 24 | set(CATCH_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" PARENT_SCOPE) 25 | endif() 26 | endfunction() 27 | 28 | # Download the single-header version of Catch 29 | function(_download_catch version destination_dir) 30 | message(STATUS "Downloading catch v${version}...") 31 | set(url https://github.com/philsquared/Catch/releases/download/v${version}/catch.hpp) 32 | file(DOWNLOAD ${url} "${destination_dir}/catch.hpp" STATUS status) 33 | list(GET status 0 error) 34 | if(error) 35 | message(FATAL_ERROR "Could not download ${url}") 36 | endif() 37 | set(CATCH_INCLUDE_DIR "${destination_dir}" CACHE INTERNAL "") 38 | endfunction() 39 | 40 | # Look for catch locally 41 | find_path(CATCH_INCLUDE_DIR NAMES catch.hpp PATH_SUFFIXES catch2) 42 | if(CATCH_INCLUDE_DIR) 43 | _get_catch_version() 44 | endif() 45 | 46 | # Download the header if it wasn't found or if it's outdated 47 | if(NOT CATCH_VERSION OR CATCH_VERSION VERSION_LESS ${Catch_FIND_VERSION}) 48 | if(DOWNLOAD_CATCH) 49 | _download_catch(${Catch_FIND_VERSION} "${PROJECT_BINARY_DIR}/catch/") 50 | _get_catch_version() 51 | else() 52 | set(CATCH_FOUND FALSE) 53 | return() 54 | endif() 55 | endif() 56 | 57 | set(CATCH_FOUND TRUE) 58 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tools/FindEigen3.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Eigen3 lib 2 | # 3 | # This module supports requiring a minimum version, e.g. you can do 4 | # find_package(Eigen3 3.1.2) 5 | # to require version 3.1.2 or newer of Eigen3. 6 | # 7 | # Once done this will define 8 | # 9 | # EIGEN3_FOUND - system has eigen lib with correct version 10 | # EIGEN3_INCLUDE_DIR - the eigen include directory 11 | # EIGEN3_VERSION - eigen version 12 | 13 | # Copyright (c) 2006, 2007 Montel Laurent, 14 | # Copyright (c) 2008, 2009 Gael Guennebaud, 15 | # Copyright (c) 2009 Benoit Jacob 16 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license. 17 | 18 | if(NOT Eigen3_FIND_VERSION) 19 | if(NOT Eigen3_FIND_VERSION_MAJOR) 20 | set(Eigen3_FIND_VERSION_MAJOR 2) 21 | endif(NOT Eigen3_FIND_VERSION_MAJOR) 22 | if(NOT Eigen3_FIND_VERSION_MINOR) 23 | set(Eigen3_FIND_VERSION_MINOR 91) 24 | endif(NOT Eigen3_FIND_VERSION_MINOR) 25 | if(NOT Eigen3_FIND_VERSION_PATCH) 26 | set(Eigen3_FIND_VERSION_PATCH 0) 27 | endif(NOT Eigen3_FIND_VERSION_PATCH) 28 | 29 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") 30 | endif(NOT Eigen3_FIND_VERSION) 31 | 32 | macro(_eigen3_check_version) 33 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) 34 | 35 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") 36 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") 37 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") 38 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") 39 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") 40 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") 41 | 42 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) 43 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 44 | set(EIGEN3_VERSION_OK FALSE) 45 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 46 | set(EIGEN3_VERSION_OK TRUE) 47 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 48 | 49 | if(NOT EIGEN3_VERSION_OK) 50 | 51 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " 52 | "but at least version ${Eigen3_FIND_VERSION} is required") 53 | endif(NOT EIGEN3_VERSION_OK) 54 | endmacro(_eigen3_check_version) 55 | 56 | if (EIGEN3_INCLUDE_DIR) 57 | 58 | # in cache already 59 | _eigen3_check_version() 60 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) 61 | 62 | else (EIGEN3_INCLUDE_DIR) 63 | 64 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library 65 | PATHS 66 | ${CMAKE_INSTALL_PREFIX}/include 67 | ${KDE4_INCLUDE_DIR} 68 | PATH_SUFFIXES eigen3 eigen 69 | ) 70 | 71 | if(EIGEN3_INCLUDE_DIR) 72 | _eigen3_check_version() 73 | endif(EIGEN3_INCLUDE_DIR) 74 | 75 | include(FindPackageHandleStandardArgs) 76 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) 77 | 78 | mark_as_advanced(EIGEN3_INCLUDE_DIR) 79 | 80 | endif(EIGEN3_INCLUDE_DIR) 81 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tools/check-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Script to check include/test code for common pybind11 code style errors. 4 | # 5 | # This script currently checks for 6 | # 7 | # 1. missing space between keyword and parenthesis, e.g.: for(, if(, while( 8 | # 2. Missing space between right parenthesis and brace, e.g. 'for (...){' 9 | # 3. opening brace on its own line. It should always be on the same line as the 10 | # if/while/for/do statement. 11 | # 12 | # Invoke as: tools/check-style.sh 13 | # 14 | 15 | check_style_errors=0 16 | IFS=$'\n' 17 | 18 | 19 | found="$(grep '\<\(if\|for\|while\|catch\)(\|){' $@ -rn --color=always)" 20 | if [ -n "$found" ]; then 21 | echo -e '\033[31;01mError: found the following coding style problems:\033[0m' 22 | check_style_errors=1 23 | echo "$found" | sed -e 's/^/ /' 24 | fi 25 | 26 | found="$(awk ' 27 | function prefix(filename, lineno) { 28 | return " \033[35m" filename "\033[36m:\033[32m" lineno "\033[36m:\033[0m" 29 | } 30 | function mark(pattern, string) { sub(pattern, "\033[01;31m&\033[0m", string); return string } 31 | last && /^\s*{/ { 32 | print prefix(FILENAME, FNR-1) mark("\\)\\s*$", last) 33 | print prefix(FILENAME, FNR) mark("^\\s*{", $0) 34 | last="" 35 | } 36 | { last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" } 37 | ' $(find include -type f) $@)" 38 | if [ -n "$found" ]; then 39 | check_style_errors=1 40 | echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m' 41 | echo "$found" 42 | fi 43 | 44 | exit $check_style_errors 45 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tools/libsize.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import print_function, division 3 | import os 4 | import sys 5 | 6 | # Internal build script for generating debugging test .so size. 7 | # Usage: 8 | # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the 9 | # size in it, then overwrites save.txt with the new size for future runs. 10 | 11 | if len(sys.argv) != 3: 12 | sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt") 13 | 14 | lib = sys.argv[1] 15 | save = sys.argv[2] 16 | 17 | if not os.path.exists(lib): 18 | sys.exit("Error: requested file ({}) does not exist".format(lib)) 19 | 20 | libsize = os.path.getsize(lib) 21 | 22 | print("------", os.path.basename(lib), "file size:", libsize, end='') 23 | 24 | if os.path.exists(save): 25 | with open(save) as sf: 26 | oldsize = int(sf.readline()) 27 | 28 | if oldsize > 0: 29 | change = libsize - oldsize 30 | if change == 0: 31 | print(" (no change)") 32 | else: 33 | print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize)) 34 | else: 35 | print() 36 | 37 | with open(save, 'w') as sf: 38 | sf.write(str(libsize)) 39 | -------------------------------------------------------------------------------- /FTReading/pybind11-master/tools/pybind11Config.cmake.in: -------------------------------------------------------------------------------- 1 | # pybind11Config.cmake 2 | # -------------------- 3 | # 4 | # PYBIND11 cmake module. 5 | # This module sets the following variables in your project:: 6 | # 7 | # pybind11_FOUND - true if pybind11 and all required components found on the system 8 | # pybind11_VERSION - pybind11 version in format Major.Minor.Release 9 | # pybind11_INCLUDE_DIRS - Directories where pybind11 and python headers are located. 10 | # pybind11_INCLUDE_DIR - Directory where pybind11 headers are located. 11 | # pybind11_DEFINITIONS - Definitions necessary to use pybind11, namely USING_pybind11. 12 | # pybind11_LIBRARIES - compile flags and python libraries (as needed) to link against. 13 | # pybind11_LIBRARY - empty. 14 | # CMAKE_MODULE_PATH - appends location of accompanying FindPythonLibsNew.cmake and 15 | # pybind11Tools.cmake modules. 16 | # 17 | # 18 | # Available components: None 19 | # 20 | # 21 | # Exported targets:: 22 | # 23 | # If pybind11 is found, this module defines the following :prop_tgt:`IMPORTED` 24 | # interface library targets:: 25 | # 26 | # pybind11::module - for extension modules 27 | # pybind11::embed - for embedding the Python interpreter 28 | # 29 | # Python headers, libraries (as needed by platform), and the C++ standard 30 | # are attached to the target. Set PythonLibsNew variables to influence 31 | # python detection and CMAKE_CXX_STANDARD (11 or 14) to influence standard 32 | # setting. :: 33 | # 34 | # find_package(pybind11 CONFIG REQUIRED) 35 | # message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 36 | # 37 | # # Create an extension module 38 | # add_library(mylib MODULE main.cpp) 39 | # target_link_libraries(mylib pybind11::module) 40 | # 41 | # # Or embed the Python interpreter into an executable 42 | # add_executable(myexe main.cpp) 43 | # target_link_libraries(myexe pybind11::embed) 44 | # 45 | # Suggested usage:: 46 | # 47 | # find_package with version info is not recommended except for release versions. :: 48 | # 49 | # find_package(pybind11 CONFIG) 50 | # find_package(pybind11 2.0 EXACT CONFIG REQUIRED) 51 | # 52 | # 53 | # The following variables can be set to guide the search for this package:: 54 | # 55 | # pybind11_DIR - CMake variable, set to directory containing this Config file 56 | # CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package 57 | # PATH - environment variable, set to bin directory of this package 58 | # CMAKE_DISABLE_FIND_PACKAGE_pybind11 - CMake variable, disables 59 | # find_package(pybind11) when not REQUIRED, perhaps to force internal build 60 | 61 | @PACKAGE_INIT@ 62 | 63 | set(PN pybind11) 64 | 65 | # location of pybind11/pybind11.h 66 | set(${PN}_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@") 67 | 68 | set(${PN}_LIBRARY "") 69 | set(${PN}_DEFINITIONS USING_${PN}) 70 | 71 | check_required_components(${PN}) 72 | 73 | # make detectable the FindPythonLibsNew.cmake module 74 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) 75 | 76 | include(pybind11Tools) 77 | 78 | if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) 79 | #----------------------------------------------------------------------------- 80 | # Don't include targets if this file is being picked up by another 81 | # project which has already built this as a subproject 82 | #----------------------------------------------------------------------------- 83 | if(NOT TARGET ${PN}::pybind11) 84 | include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake") 85 | 86 | find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED) 87 | set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS}) 88 | set_property(TARGET ${PN}::embed APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES}) 89 | if(WIN32 OR CYGWIN) 90 | set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES}) 91 | endif() 92 | 93 | if(CMAKE_VERSION VERSION_LESS 3.3) 94 | set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}") 95 | else() 96 | set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${PYBIND11_CPP_STANDARD}>) 97 | endif() 98 | 99 | get_property(_iid TARGET ${PN}::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) 100 | get_property(_ill TARGET ${PN}::module PROPERTY INTERFACE_LINK_LIBRARIES) 101 | set(${PN}_INCLUDE_DIRS ${_iid}) 102 | set(${PN}_LIBRARIES ${_ico} ${_ill}) 103 | endif() 104 | endif() 105 | -------------------------------------------------------------------------------- /FTReading/src/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/build/my_cmake_exe", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${fileDirname}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "Enable pretty-printing for gdb", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | } 24 | ], 25 | "preLaunchTask": "Build", 26 | 27 | }, 28 | 29 | { 30 | "name": "clang++ - Build and debug active file", 31 | "type": "cppdbg", 32 | "request": "launch", 33 | "program": "${workspaceFolder}/build/my_cmake_exe", 34 | "args": [], 35 | "stopAtEntry": false, 36 | "cwd": "${workspaceFolder}", 37 | "environment": [], 38 | "externalConsole": false, 39 | "MIMode": "lldb", 40 | "setupCommands": [ 41 | { 42 | "description": "Enable pretty-printing for gdb", 43 | "text": "-enable-pretty-printing", 44 | "ignoreFailures": true 45 | } 46 | ], 47 | "preLaunchTask": "Build", 48 | "miDebuggerPath": "/usr/bin/lldb-mi" 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /FTReading/src/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "iomanip": "cpp", 4 | "vector": "cpp", 5 | "iostream": "cpp", 6 | "cctype": "cpp", 7 | "clocale": "cpp", 8 | "cmath": "cpp", 9 | "csignal": "cpp", 10 | "cstdarg": "cpp", 11 | "cstddef": "cpp", 12 | "cstdio": "cpp", 13 | "cstdlib": "cpp", 14 | "cstring": "cpp", 15 | "ctime": "cpp", 16 | "cwchar": "cpp", 17 | "cwctype": "cpp", 18 | "array": "cpp", 19 | "atomic": "cpp", 20 | "strstream": "cpp", 21 | "*.tcc": "cpp", 22 | "bitset": "cpp", 23 | "chrono": "cpp", 24 | "complex": "cpp", 25 | "cstdint": "cpp", 26 | "deque": "cpp", 27 | "forward_list": "cpp", 28 | "list": "cpp", 29 | "unordered_map": "cpp", 30 | "unordered_set": "cpp", 31 | "exception": "cpp", 32 | "fstream": "cpp", 33 | "functional": "cpp", 34 | "initializer_list": "cpp", 35 | "iosfwd": "cpp", 36 | "istream": "cpp", 37 | "limits": "cpp", 38 | "new": "cpp", 39 | "ostream": "cpp", 40 | "numeric": "cpp", 41 | "ratio": "cpp", 42 | "sstream": "cpp", 43 | "stdexcept": "cpp", 44 | "streambuf": "cpp", 45 | "system_error": "cpp", 46 | "thread": "cpp", 47 | "cfenv": "cpp", 48 | "cinttypes": "cpp", 49 | "tuple": "cpp", 50 | "type_traits": "cpp", 51 | "utility": "cpp", 52 | "typeindex": "cpp", 53 | "typeinfo": "cpp", 54 | "valarray": "cpp", 55 | "algorithm": "cpp", 56 | "iterator": "cpp", 57 | "map": "cpp", 58 | "memory": "cpp", 59 | "memory_resource": "cpp", 60 | "optional": "cpp", 61 | "random": "cpp", 62 | "set": "cpp", 63 | "string": "cpp", 64 | "string_view": "cpp", 65 | "variant": "cpp" 66 | }, 67 | "C_Cpp.errorSquiggles": "Disabled" 68 | } -------------------------------------------------------------------------------- /FTReading/src/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "options": { 4 | "cwd": "${workspaceFolder}/build" 5 | }, 6 | "tasks": [ 7 | { 8 | "type": "shell", 9 | "label": "cmake", 10 | "command": "cmake", 11 | "args": [ 12 | ".." 13 | ] 14 | }, 15 | { 16 | "label": "make", 17 | "group": { 18 | "kind": "build", 19 | "isDefault": true 20 | }, 21 | "command": "make", 22 | "args": [ 23 | 24 | ] 25 | }, 26 | { 27 | "label": "Build", 28 | "dependsOrder": "sequence", // 按列出的顺序执行任务依赖项 29 | "dependsOn":[ 30 | "cmake", 31 | "make" 32 | ] 33 | } 34 | ] 35 | 36 | } -------------------------------------------------------------------------------- /FTReading/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(FTReading) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | set(CMAKE_BUILD_TYPE Debug) 6 | 7 | add_executable(my_cmake_exe main.cpp Force.cpp Force.h) 8 | -------------------------------------------------------------------------------- /FTReading/src/Force.h: -------------------------------------------------------------------------------- 1 | #ifndef CALIBRATION_FORCE_H 2 | #define CALIBRATION_FORCE_H 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef int SOCKET_HANDLE; 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | //#pragma pack(1) 20 | 21 | //#define PORT 49151 /* Port the Ethernet DAQ always uses */ 22 | //#define SAMPLE_COUNT 100 /* 100 incoming samples */ 23 | 24 | #define READFT 0 25 | #define READCALIBRATIONINFO 1 26 | 27 | //! \brief The ForceSensor class 28 | //! Constructor: IP-Address 29 | //! File Name 30 | class ForceSensor 31 | { 32 | 33 | const int DAQ_PORT = 49151; 34 | const int INIT_SAMPLE_COUNT = 10000; 35 | 36 | typedef unsigned int uint32; 37 | typedef int int32; 38 | typedef unsigned short uint16; 39 | typedef short int16; 40 | typedef unsigned char byte; 41 | 42 | typedef struct FTResponseStruct 43 | { 44 | uint16 header; 45 | uint16 status; 46 | int16 ForceX; 47 | int16 ForceY; 48 | int16 ForceZ; 49 | int16 TorqueX; 50 | int16 TorqueY; 51 | int16 TorqueZ; 52 | 53 | FTResponseStruct() : header(0), 54 | status(0), 55 | ForceX(0), 56 | ForceY(0), 57 | ForceZ(0), 58 | TorqueX(0), 59 | TorqueY(0), 60 | TorqueZ(0) 61 | { 62 | } 63 | } FTResponse; 64 | 65 | typedef struct CalibrationResponseStruct 66 | { 67 | uint16 header; 68 | byte forceUnits; 69 | byte torqueUnits; 70 | uint32 countsPerForce; 71 | uint32 countsPerTorque; 72 | uint16 scaleFactors[6]; 73 | } CalibrationResponse; 74 | 75 | typedef struct FTReadCommandStruct 76 | { 77 | byte command; 78 | byte reserved[19]; 79 | } FTReadCommand; 80 | 81 | typedef struct ReadCalibrationCommandStruct 82 | { 83 | byte command; 84 | byte reserved[19]; 85 | } ReadCalibrationCommand; 86 | 87 | public: 88 | ForceSensor(const char *ip_address) : ip_(ip_address), 89 | socketHandle_(), 90 | initftResponse_(), 91 | outputftResponse_(), 92 | ftResponseStack_(), 93 | sequence_(0), 94 | calibrationResponse_() 95 | { 96 | } 97 | 98 | ~ForceSensor() = default; 99 | 100 | //! \brief InitFTResponse 101 | //! Get Calibration Information 102 | void InitFTResponse(); 103 | 104 | //! \brief Read Remote F/T Sensor some times and Take average 105 | //! \param times 106 | void Read(int times); 107 | 108 | //! \brief WriteLogs, Output Formata: Sequence,FX,FY,FZ,TX,TY,TZ 109 | //! \param FileName 110 | void WriteLogs(const char *FileName = "../data/FT.txt"); 111 | 112 | //! TODO 113 | void WriteJson(); 114 | 115 | //! TODO 116 | void Plot(); 117 | 118 | //! \brief MySleep Sleep ms milliseconds 119 | //! \param ms 120 | void MySleep(unsigned long ms); 121 | 122 | //! \brief ShowCalibrationInfo 123 | void ShowCalibrationInfo(); 124 | 125 | int GetSequence() const; 126 | 127 | //! 128 | //! \brief PYRead 129 | //! \param times 130 | //! \return FX,FY,FZ,TX,TY,TZ 131 | std::vector PYRead(int times); 132 | 133 | private: 134 | std::string ip_; // ip_address of remote sensor 135 | 136 | SOCKET_HANDLE socketHandle_; //Handle to UDP socket used to communicate with Ethernet DAQ. 137 | 138 | std::array initftResponse_; 139 | 140 | std::array outputftResponse_; 141 | 142 | std::vector> ftResponseStack_; 143 | 144 | int sequence_; 145 | 146 | CalibrationResponse calibrationResponse_; // class variable to hold calibration info datas 147 | 148 | int SocketConnect(); 149 | 150 | void SocketClose(); 151 | 152 | int GetCalibrationInfo(); 153 | 154 | void SmoothReadings(int times); 155 | 156 | int ReadFT(FTResponse *r); 157 | 158 | void SwapFTResponseBytes(FTResponse *r); 159 | 160 | void AccumulateReadings(FTResponse *r); 161 | 162 | int16 swap_int16(int16 val); 163 | }; 164 | -------------------------------------------------------------------------------- /FTReading/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Force.h" 2 | #include 3 | #include 4 | int main() 5 | { 6 | ForceSensor Ft("192.168.1.11"); 7 | Ft.InitFTResponse(); 8 | while(true) 9 | { 10 | std::vector output; 11 | output = Ft.PYRead(1); 12 | // std::cout<<""< 2 | #include 3 | #include 4 | #include "Force.h" 5 | 6 | // ---------------- 7 | // Python interface 8 | // ---------------- 9 | namespace py = pybind11; 10 | 11 | PYBIND11_MODULE(FTReading, m) 12 | { 13 | py::class_(m, "FTReading") 14 | .def(py::init(), "Constructor with ip") 15 | .def("InitFT", &ForceSensor::InitFTResponse, "Init the Sensor Reading") 16 | .def("GetReading", &ForceSensor::PYRead, "Input Read times for smooth"); 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## **一.简介:** 2 | **参考算法文章:[Autonomous Alignment of Peg and Hole by Force/Torque Measurement for Robotic Assembly](http://wjchen84.github.io/publications/C2016_CASE_PH.pdf)** 3 | 4 | **项目名称:轴孔力控装配** 5 | 6 | **操作系统:Ubuntu18.04** 7 | 8 | **编程语言: Python3** 9 | 10 | **机械臂平台: UR10e&FT-Sensor** 11 | 12 | **概述:本系统使用UR_RTDE接口控制UR10e,实现了力控轴孔装配。可在50mm的轴孔尺寸下,实现0.1mm以内间隙的装配。** 13 | 14 | ## **二.配置文件:** 15 | 16 | cd Peg_in_Hole 17 | 18 | pip install -r requirements.txt 19 | 20 | ## **三.文件描述:** 21 | │ README.md //help 22 | │ requirements.txt //python环境配置 23 | ├─configs 24 | │ UR10e.yaml //参数配置 包括轴径,孔径,轴孔坐标等 25 | ├─data //获取的FT数据 26 | │ ├─force 27 | │ │ ├─force_assembly_0 //装配时期的FT数据图 28 | │ │ │ 29 | │ │ └─force_touch_0 //接触时期的FT数据图 30 | │ │ 0touch_dataFx0_success.jpg 31 | │ │ 0touch_dataFy0_success.jpg 32 | │ │ 0touch_dataFz0_success.jpg 33 | │ │ 0touch_dataMx0_success.jpg 34 | │ │ 0touch_dataMy0_success.jpg 35 | │ │ 0touch_dataMz0_success.jpg 36 | │ │ 37 | │ └─FT_data //全部的FT数据及计算与实际误差结果 38 | │ 39 | └─projects //code 40 | │ Assembly.py //控制轴孔接触与装配,记录FT数据 41 | │ Control.py //初始化机械臂,与机械臂建立连接 42 | │ Multiply_assembly.py //主程序,记录数据 43 | └─ read_data.py //处理数据 44 | 45 | ## **四.演示视频** 46 | [demo video](https://youtu.be/v5WuBuBptk0/) 47 | 48 | ## **五.配置UR示教器:** 49 | 测量末端到机械臂末端的距离。将该距离填入图中z值并点上标签。 50 | 51 |
52 | 53 | 54 | 55 |
56 | 57 | # Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot 58 | -------------------------------------------------------------------------------- /configs/Image_guide1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/configs/Image_guide1.jpeg -------------------------------------------------------------------------------- /configs/Image_guide2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/configs/Image_guide2.jpeg -------------------------------------------------------------------------------- /configs/Image_guide3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/configs/Image_guide3.jpeg -------------------------------------------------------------------------------- /configs/UR10e.yaml: -------------------------------------------------------------------------------- 1 | # the units of the parameters is m, rad, m/s, m/s^2, g, pixel 2 | 3 | #robot ip and port 4 | name: UR10e 5 | ip: 192.168.1.10 6 | port: 30003 7 | FT_ip : 192.168.1.11 8 | 9 | #设置孔内径 R 及 轴径 r 10 | R : 0.0252 11 | r : 0.0252 12 | 13 | #设置抓取轴时机械臂末端在笛卡尔坐标系下的z值 14 | z : 0.095 15 | 16 | #设置装配完成时的z值 17 | z_assembly : 0.0 18 | 19 | #的位置->x,y 20 | Bearing_Point: 21 | # - [ -0.4510, -0.190 ] # y : -196--210 x:445-458 22 | # - [ -0.5670, -0.190 ] 23 | - [ -0.7005, -0.187 ] 24 | # - [ -0.8150, -0.200 ] 25 | # - [ -0.632, 0.092 ] 26 | - 27 | #轴的位置->x,y 28 | Shaft_Point: 29 | # - [ -0.524, 0.346 ] 30 | - [ -0.624, 0.346 ] 31 | # - [ -0.724, 0.346 ] 32 | 33 | #失败区位置 34 | fail_areas: [-0.63, -0.361] 35 | -------------------------------------------------------------------------------- /data/FT_data/.~lock.FT_data_e1.xlsx#: -------------------------------------------------------------------------------- 1 | ,franka,franka-TM1701,07.07.2021 09:43,file:///home/franka/.config/libreoffice/4; -------------------------------------------------------------------------------- /data/FT_data/.~lock.FT_data_ex3.xlsx#: -------------------------------------------------------------------------------- 1 | ,franka,franka-TM1701,07.07.2021 09:49,file:///home/franka/.config/libreoffice/4; -------------------------------------------------------------------------------- /data/FT_data/FT_data0.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data0.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_0.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_0.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e0.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e0.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e1.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e2.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e3.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e3.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e4.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e4.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e5.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e5.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e6.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e6.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e7.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e7.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e8.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e8.xlsx -------------------------------------------------------------------------------- /data/FT_data/FT_data_e9.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/FT_data_e9.xlsx -------------------------------------------------------------------------------- /data/FT_data/data_array.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/FT_data/data_array.xlsx -------------------------------------------------------------------------------- /data/FT_data/r.txt: -------------------------------------------------------------------------------- 1 | x_minus y_minus cal_x cal_y real_x real_y 2 | 0.717780970391213 0.043769346524725 -452.749277998008 -196.389316223126 -453.467058968399 -196.433085569651 3 | x_minus y_minus cal_x cal_y real_x real_y 4 | 0.004248897806425 -0.016374282705872 -452.451881773284 -196.703977112394 -452.45613067109 -196.687602829689 5 | -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataFx0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataFx0_success.jpg -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataFy0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataFy0_success.jpg -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataFz0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataFz0_success.jpg -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataMx0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataMx0_success.jpg -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataMy0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataMy0_success.jpg -------------------------------------------------------------------------------- /data/force/force_assembly_0/0assembly_dataMz0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_assembly_0/0assembly_dataMz0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataFx0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataFx0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataFy0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataFy0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataFz0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataFz0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataMx0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataMx0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataMy0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataMy0_success.jpg -------------------------------------------------------------------------------- /data/force/force_touch_0/0touch_dataMz0_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/data/force/force_touch_0/0touch_dataMz0_success.jpg -------------------------------------------------------------------------------- /projects/Control.py: -------------------------------------------------------------------------------- 1 | # 主要功能是控制机器人进行运动控制。 2 | # 程序中使用了yaml模块读取配置文件,rtde_control控制机器人的移动和姿态控制,rtde_io控制机器人的数字输入输出,rtde_receive接收来自机器人的实时数据。 3 | # FTReading模块用于读取机器人的力矩传感器数据。 4 | # 该程序中定义了URControl类,其中包含机器人的IP地址、连接控制器、接收器、IO接口和力矩传感器读取接口等。get_robot()函数用于返回机器人本身,方便其他程序调用。 5 | # Created by Jie Yu 6 | import yaml 7 | import rtde_control 8 | import rtde_io 9 | import rtde_receive 10 | import FTReading 11 | 12 | 13 | def from_yaml_get_data(label): 14 | file = open('../configs/UR10e.yaml', 'r', encoding='utf-8') 15 | read = file.read() 16 | cfg = yaml.load(read, Loader=yaml.FullLoader) 17 | 18 | return cfg[label] 19 | pass 20 | 21 | 22 | class URControl: 23 | def __init__(self): 24 | IP = from_yaml_get_data('ip') 25 | FT_IP = from_yaml_get_data('FT_ip') 26 | self.control_c = rtde_control.RTDEControlInterface(IP) 27 | self.receive_r = rtde_receive.RTDEReceiveInterface(IP) 28 | self.io_control = rtde_io.RTDEIOInterface(IP) 29 | self.read_FT = FTReading.FTReading(FT_IP) 30 | return 31 | 32 | def get_robot(self): 33 | return self 34 | -------------------------------------------------------------------------------- /projects/Read_FT.py: -------------------------------------------------------------------------------- 1 | # 主要实现的功能是读取某个IP地址对应的传感器的数据,并将其实时显示在一个包含6个子图的大图里面,每个子图展示对应轴向上的力或力矩变化。 2 | # 通过调用FTReading模块中的类,实现传感器的初始化和数据的读取。同时,该程序使用了matplotlib库来绘制实时的力矩变化曲线。 3 | # Created by Jie Yu 4 | import time 5 | import FTReading 6 | import matplotlib.pyplot as plt 7 | 8 | 9 | def get_ft_chart(): 10 | a = FTReading.FTReading('192.168.1.11') 11 | a.InitFT() 12 | FM_num = 6 13 | t_array = [[0], [0], [0], [0], [0], [0]] 14 | t = [0, 0] 15 | t_append = 0 16 | color = ['b', 'g', 'r', 'c', 'm', 'y'] 17 | text = ["Fx", "Fy", "Fz", "Mx", "My", "Mz"] 18 | fig, axs = plt.subplots(2, 3, constrained_layout=False, figsize=(20, 20)) 19 | while True: 20 | tcp_force = a.GetReading(1) 21 | for i in range(FM_num): 22 | t_array[i].append(tcp_force[i]) 23 | axs.flat[i].plot(t, t_array[i], color[i], linewidth=1) 24 | axs.flat[i].set_title(text[i], fontsize=12) 25 | t_append += 1 26 | t.append(t_append) 27 | plt.pause(0.001) 28 | plt.close() 29 | 30 | 31 | if __name__ == '__main__': 32 | get_ft_chart() 33 | -------------------------------------------------------------------------------- /projects/read_data.py: -------------------------------------------------------------------------------- 1 | # 读取Excel数据和绘制力传感器数据图像的函数。 2 | # 其中,“read”函数的主要目的是从Excel文件中提取力传感器数据并绘制图像; 3 | # “array”函数的主要目的是将多个Excel文件中的数据合并到单个xlsx文件中; 4 | # “deal_data”函数的目的是处理数据并输出图像和数组。 5 | # Created by Jie Yu 6 | import time 7 | 8 | import xlrd 9 | import matplotlib.pyplot as plt 10 | import numpy as np 11 | import os 12 | 13 | import xlsxwriter 14 | 15 | 16 | def read(file, which='', combine=0): 17 | excel = xlrd.open_workbook(file) 18 | sheet = excel.sheet_by_index(0) 19 | step1_start = [] 20 | step1_over = [] 21 | step2_start = [] 22 | step2_over = [] 23 | for row in range(sheet.nrows): 24 | if sheet.cell_type(row, 0) is 1: 25 | label = sheet.cell(row, 0).value 26 | if label == 'step1:touch': 27 | step1_start.append(row) 28 | elif label == 'step1 over': 29 | step1_over.append(row) 30 | elif label == 'step2:assembly': 31 | step2_start.append(row) 32 | elif label == 'step2 over': 33 | step2_over.append(row) 34 | success_judge = [] 35 | for row_start in step2_over: 36 | row = row_start + 1 37 | while sheet.cell_type(row, 0) is not 1: 38 | row = row + 1 39 | success_judge.append(sheet.cell(row, 0).value) 40 | 41 | text = ["Fx", "Fy", "Fz", "Mx", "My", "Mz"] 42 | color = ['b', 'g', 'r', 'c', 'm', 'y'] 43 | group = -1 44 | for row_start in step1_start: 45 | group = group + 1 46 | row_over = step1_over[step1_start.index(row_start)] 47 | for col in range(6): 48 | data = [] 49 | data_index = [] 50 | for i in range(row_start + 2, row_over - 1): 51 | data.append(sheet.cell(i, col * 2).value) 52 | data_index.append(sheet.cell(i, 6 * 2).value) 53 | plt.title(text[col]) 54 | plt.xlabel("time") 55 | plt.ylabel(text[col]) 56 | plt.plot(data_index, data, color[col], linestyle="-", linewidth=2) 57 | plt.savefig( 58 | "./../data/force/force_touch_" + which + "/" + str(group) + "touch_data" + text[col] + which + "_" + 59 | success_judge[group] + ".jpg") 60 | if combine != 1: 61 | plt.close() 62 | plt.close() 63 | group = -1 64 | for row_start in step2_start: 65 | group = group + 1 66 | row_over = step2_over[step2_start.index(row_start)] 67 | for col in range(6): 68 | data = [] 69 | data_index = [] 70 | for i in range(row_start + 2, row_over - 1): 71 | data.append(sheet.cell(i, col * 2).value) 72 | data_index.append(sheet.cell(i, 6 * 2).value) 73 | plt.title(text[col]) 74 | plt.xlabel("time") 75 | plt.ylabel(text[col]) 76 | plt.plot(data_index, data, color[col], linestyle="-", linewidth=2) 77 | plt.savefig( 78 | "./../data/force/force_assembly_" + which + "/" + str( 79 | group) + "assembly_data" + text[col] + which + "_" + success_judge[group] + ".jpg") 80 | if combine != 1: 81 | plt.close() 82 | 83 | 84 | def array(): 85 | data_name = ['x_', 'y_', 'cal_x', 'cal_y', 'rel_x', 'rel_y'] 86 | workbook = xlsxwriter.Workbook('./../data/FT_data/' + 'data_array' + '.xlsx') 87 | worksheet_ = workbook.add_worksheet() 88 | for j in range(6): 89 | array_row = 0 90 | worksheet_.write(array_row, j, data_name[j]) 91 | array_row = array_row + 1 92 | for i in range(10): 93 | file = './../data/FT_data/FT_data_e' + str(i) + '.xlsx' 94 | excel = xlrd.open_workbook(file) 95 | sheet = excel.sheet_by_index(1) 96 | row = 3 97 | record = sheet.cell(row, j * 2).value 98 | worksheet_.write(array_row, j, record) 99 | array_row = array_row + 1 100 | workbook.close() 101 | 102 | 103 | def deal_data(): 104 | data = [0] 105 | for i in data: 106 | try: 107 | os.makedirs('./../data/force/force_touch_' + str(i)) 108 | except BaseException or Exception as e: 109 | time.sleep(0) 110 | try: 111 | os.makedirs('./../data/force/force_assembly_' + str(i)) 112 | except BaseException or Exception as e: 113 | time.sleep(0) 114 | read('./../data/FT_data/FT_data_e' + str(i) + '.xlsx', str(i), combine=0) 115 | 116 | 117 | if __name__ == '__main__': 118 | deal_data() 119 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib~=3.3.4 2 | numpy~=1.19.5 3 | pandas==1.2.4 4 | scipy~=1.5.4 5 | sympy~=1.8 6 | threadpoolctl 7 | XlsxWriter~=1.3.8 8 | xlrd~=1.2.0 9 | PyYAML~=5.4.1 10 | ur_rtde 11 | -------------------------------------------------------------------------------- /使用UR机械臂力控轴孔装配.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/使用UR机械臂力控轴孔装配.mp4 -------------------------------------------------------------------------------- /使用发那科机械臂力控轴孔装配.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/使用发那科机械臂力控轴孔装配.mp4 -------------------------------------------------------------------------------- /力控项目报告.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankJIE09/Peg_in_Hole_with_OnRobot_Force_Sensor-UR_Robot/f18f3c67bc53316bad184d3b634734d01f5ea8a0/力控项目报告.docx --------------------------------------------------------------------------------