1. 28 Nov, 2022 1 commit
  2. 18 Oct, 2022 1 commit
    • Lalaland's avatar
      First draft of Eigen::Tensor support (#4201) · fab1eebe
      Lalaland authored
      * First draft of Eigen::Tensor support
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Fix build errors
      
      * Weird allocator stuff?
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Remove unused + additional allocator junk
      
      * Disable warning
      
      * Use constexpr
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * clang tidy fixes
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Resolve comments
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Remove auto constexpr function
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Try again for older C++
      
      * Oops forgot constexpr
      
      * Move to new files as suggested
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Fix weird tests
      
      * Fix nits
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Oops, forgot import
      
      * Fix clang 3.6 bug
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * More comprehensive test suite
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Refactor allocators to make things more clear
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Switch to std::copy
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Switch to DSizes instead of array
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Address feedback
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Fix python + dummy c++ change to trigger build
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Alignment
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      
      
      * Add include guard
      
      * Forgot inline
      
      * Fix compiler warning
      
      * Remove bad test
      
      * Better type signatures
      
      * Add guards to make compiler requirements more explicit
      
      * style: pre-commit fixes
      
      * Force rerun of tests due to flake
      
      * style: pre-commit fixes
      
      * Keep pragmas & all related comments together, add PLEASE KEEP IN SYNC
      
      * Move headers out of detail
      
      * style: pre-commit fixes
      
      * Fix cmake
      
      * Improve casting
      
      * style: pre-commit fixes
      
      * Add a ton more tests + refactor
      
      * Improve names
      
      * style: pre-commit fixes
      
      * Update include/pybind11/eigen/tensor.h
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      
      * Fix tests
      
      * style: pre-commit fixes
      
      * Update
      
      * Add a test to verify that strange numpy arrays work
      
      * Fix dumb compiler warning
      
      * Better tests
      
      * Better tests
      
      * Fix tests
      
      * style: pre-commit fixes
      
      * More test fixes
      
      * style: pre-commit fixes
      
      * A ton more test coverage
      
      * Fix tests
      
      * style: pre-commit fixes
      
      * style: pre-commit fixes
      
      * Add back constexpr
      
      * Another test
      
      * style: pre-commit fixes
      
      * Improve tests
      
      * Whoops
      
      * Less magic numbers
      
      * Update tests/test_eigen_tensor.py
      Co-authored-by: default avatarSergiu Deitsch <sergiud@users.noreply.github.com>
      
      * Update tests/test_eigen_tensor.py
      Co-authored-by: default avatarSergiu Deitsch <sergiud@users.noreply.github.com>
      
      * style: pre-commit fixes
      
      * Fix tests
      
      * style: pre-commit fixes
      
      * Fix memory leak
      
      * style: pre-commit fixes
      
      * Fix order
      
      * style: pre-commit fixes
      
      * Add test to make sure unsafe casts fail
      
      * Minor bug fix to work on 32 bit machines
      
      * Implement convert flag
      
      * style: pre-commit fixes
      
      * Switch to correct TensorMap const use
      
      * style: pre-commit fixes
      
      * Support older versions of eigen
      
      * Weird c++ compilers
      
      * Fix Eigen bug
      
      * Fix another eigen bug
      
      * Yet another eigen bug
      
      * Potential flakes?
      
      * style: pre-commit fixes
      
      * Rerun tests with dummy exception to find out what is going on
      
      * Another dummy test run
      
      * Ablate more
      
      * Found the broken test?
      
      * One step closer
      
      * one step further
      
      * Double check
      
      * one thing at a time
      
      * Give up and disable the test
      
      * Clang lies about being gcc
      
      * Oops, fix matrix test
      
      * style: pre-commit fixes
      
      * Add tests to verify scalar conversions
      
      * style: pre-commit fixes
      
      * Fix nits
      
      * Support no_array
      
      * Fix tests
      
      * style: pre-commit fixes
      
      * Silence compiler warning
      
      * Improve build system for ancient compilers
      
      * Make clang happy
      
      * Make gcc happy
      
      * Implement Skylion's suggestions
      
      * Fix warning
      
      * Inline const pointer check
      
      * Implement suggestions
      
      * style: pre-commit fixes
      
      * Improve tests
      
      * Typo
      
      * style: pre-commit fixes
      
      * Support Google's build environment
      
      * style: pre-commit fixes
      
      * Update include/pybind11/eigen/tensor.h
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      
      * style: pre-commit fixes
      
      * Test cleanup per Skylion
      
      * Switch to remvove_cv_t
      
      * Cleaner test
      
      * style: pre-commit fixes
      
      * Remove tensor from eigen.h, update tests
      
      * style: pre-commit fixes
      Co-authored-by: default avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
      Co-authored-by: default avatarRalf W. Grosse-Kunstleve <rwgk@google.com>
      Co-authored-by: default avatarAaron Gokaslan <aaronGokaslan@gmail.com>
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      Co-authored-by: default avatarSergiu Deitsch <sergiud@users.noreply.github.com>
      fab1eebe
  3. 07 Oct, 2022 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      test_eigen.py test_nonunit_stride_to_python bug fix (ASAN failure) (#4217) · 4a421562
      Ralf W. Grosse-Kunstleve authored
      * Disable test triggering ASAN failure (to pin-point where the problem is).
      
      * Fix unsafe "block" implementation in test_eigen.cpp
      
      * Undo changes (i.e. revert back to master).
      
      * Detect "type_caster for Eigen::Ref made a copy."
      
      This is achieved without
      * reaching into internals,
      * making test_eigen.cpp depend on pybind11/numpy.h.
      
      * Add comment pointing to PR, for easy reference.
      4a421562
  4. 29 Jun, 2022 1 commit
    • Matthew Woehlke's avatar
      Fix arrays with zero-size dimensions (#4038) · 479e9a50
      Matthew Woehlke authored
      When converting an array to an Eigen matrix, ignore the strides if any
      dimension size is 0. If the array is empty, the strides aren't relevant,
      and especially numpy ≥ 1.23 explicitly sets the strides to 0 in this
      case. (See numpy commit dd5ab7b11520.)
      
      Update tests to verify that this works, and continues to work.
      479e9a50
  5. 14 Feb, 2022 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      Dropping MSVC 2015 (#3722) · a97e9d8c
      Ralf W. Grosse-Kunstleve authored
      * Changing `_MSC_VER` guard to `< 1910` (dropping MSVC 2015).
      
      * Removing MSVC 2015 from ci.yml, and .appveyor.yml entirely.
      
      * Bringing back .appveyor.yml from master.
      
      * appveyor Visual Studio 2017
      
      * 1st manual pass, builds & tests with unix_clang, before pre-commit.
      
      * After clang-format (via pre-commit).
      
      * Manual pass looking for "2015", builds & tests with unix_clang, before pre-commit.
      
      * Backtracking for include/pybind11 changes in previous commit.
      
      git checkout d07865846c7d31dd61111e6df801864327b65070 include/pybind11/attr.h include/pybind11/detail/common.h include/pybind11/functional.h
      
      --------------------
      
      CI #4160 errors observed:
      
      https://github.com/pybind/pybind11/pull/3722/commits/2a26873727214c5f1e159cba98f5c625b908381a
      https://github.com/pybind/pybind11/runs/5168332130?check_suite_focus=true
      
      $ grep ' error C' *.txt | sed 's/2022-02-12[^ ]*//' | sed 's/^[0-9][0-9]*//' | sed 's/^.*\.txt: //' | sort | uniqD:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      
      d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\cross_module_gil_utils.vcxproj]
      d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_cross_module_tests.vcxproj]
      d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\test_embed\external_module.vcxproj]
      D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      
      $ grep ': error C2737' *.txt | sed 's/^.*MSVC//' | sed 's/___.*//' | sort | uniq
      
      _2017
      
      $ grep ': error C2752' *.txt
      
      3______3.8_____MSVC_2019_____x86_-DCMAKE_CXX_STANDARD=17.txt:2022-02-12T16:12:45.9921122Z D:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      
      $ grep ': fatal error C1001:' *.txt
      
      10______pypy-3.8-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:12:56.3163683Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      1______3.6_____MSVC_2019_____x86.txt:2022-02-12T16:12:47.6774625Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      16______3.6_____windows-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:2022-02-12T16:12:27.0556151Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      17______3.9_____windows-2019_____x64.txt:2022-02-12T16:12:30.3822566Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      2______3.7_____MSVC_2019_____x86.txt:2022-02-12T16:12:38.7018911Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
      6______3.6_____windows-2022_____x64.txt:2022-02-12T16:12:00.4513642Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      7______3.9_____windows-2022_____x64.txt:2022-02-12T16:11:43.6306160Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      8______3.10_____windows-2022_____x64.txt:2022-02-12T16:11:49.9589644Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      9______pypy-3.7-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:11:53.7912112Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
      
      * common.h: is_template_base_of
      
      * Re-applying 4 changes from 2a26873727214c5f1e159cba98f5c625b908381a that work universally.
      
      * `overload_cast = {};` only for MSVC 2017 and Clang 5
      
      * Refining condition for using is_template_base_of workaround.
      
      * Undoing MSVC 2015 workaround in test_constants_and_functions.cpp
      
      * CentOS7: silence_unused_warnings
      
      * Tweaks in response to reviews.
      
      * Adding windows-2022 C++20
      
      * Trying another way of adding windows-2022 C++20
      a97e9d8c
  6. 10 Feb, 2022 1 commit
  7. 08 Feb, 2022 1 commit
  8. 11 Oct, 2021 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      Correct options on Eigen::MappedSparseMatrix & adding MSVC C4127 suppression... · 7c580586
      Ralf W. Grosse-Kunstleve authored
      Correct options on Eigen::MappedSparseMatrix & adding MSVC C4127 suppression around Eigen includes. (#3352)
      
      * Adding MSVC C4127 suppression around Eigen includes.
      
      * For MSVC 2015 only: also adding the C4127 suppression to test_eigen.cpp
      
      * Copying original change from PR #3343, with extra line breaks to not run past 99 columns (our desired but currently not enforced limit).
      7c580586
  9. 10 Sep, 2021 1 commit
  10. 14 Jul, 2021 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      * Removing stray semicolons (discovered by running clang-format v12 followed... · aca6c3ba
      Ralf W. Grosse-Kunstleve authored
      * Removing stray semicolons (discovered by running clang-format v12 followed by tools/check-style.sh). (#3087)
      
      * Manually moving `// NOLINT` comments so that clang-format does not move them to the wrong places.
      
      * Manually reformatting comments related to `static_assert`s so that clang-format does not need two passes.
      
      * Empty lines between #includes, to prevent clang-format from shuffling the order and thereby confusing MSVC 2015.
      
      * git diff -U0 --no-color HEAD^ | python3 $HOME/clone/llvm-project/clang/tools/clang-format/clang-format-diff.py -p1 -style=file -i
      aca6c3ba
  11. 12 Jul, 2021 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      NOLINT reduction (#3096) · 2d468697
      Ralf W. Grosse-Kunstleve authored
      * Copying from prework_no_rst branch (PR #3087): test_numpy_array.cpp, test_stl.cpp
      
      * Manual changes reducing NOLINTs.
      
      * clang-format-diff.py
      
      * Minor adjustment to avoid MSVC warning C4702: unreachable code
      2d468697
  12. 22 Jun, 2021 1 commit
    • Aaron Gokaslan's avatar
      fix(clang-tidy): performance fixes applied in tests and CI (#3051) · dac74ebd
      Aaron Gokaslan authored
      * Initial fixes
      
      * Whoops
      
      * Finish clang-tidy manual fixes
      
      * Add two missing fixes
      
      * Revert
      
      * Update clang-tidy
      
      * Try to fix unreachable code error
      
      * Move nolint comment
      
      * Apply missing fix
      
      * Don't override clang-tidy config
      
      * Does this fix clang-tidy?
      
      * Make all clang-tidy errors visible
      
      * Add comments about NOLINTs and remove a few
      
      * Fix typo
      dac74ebd
  13. 15 Jan, 2021 1 commit
    • Axel Huebl's avatar
      ci: Intel icc/icpc via oneAPI (#2573) · 0b3df7f9
      Axel Huebl authored
      
      
      * CI: Intel icc/icpc via oneAPI
      
      Add testing for Intel icc/icpc via the oneAPI images.
      Intel oneAPI is in a late beta stage, currently shipping
      oneAPI beta09 with ICC 20.2.
      
      * CI: Skip Interpreter Tests for Intel
      
      Cannot find how to add this, neiter the package `libc6-dev` nor
      `intel-oneapi-mkl-devel` help when installed to solve this:
      ```
      -- Looking for C++ include pthread.h
      -- Looking for C++ include pthread.h - not found
      CMake Error at /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
        Could NOT find Threads (missing: Threads_FOUND)
      Call Stack (most recent call first):
        /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
        /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
        tests/test_embed/CMakeLists.txt:17 (find_package)
      ```
      
      * CI: libc6-dev from GCC for ICC
      
      * CI: Run bare metal for oneAPI
      
      * CI: Ubuntu 18.04 for oneAPI
      
      * CI: Intel +Catch -Eigen
      
      * CI: CMake from Apt (ICC tests)
      
      * CI: Replace Intel Py with GCC Py
      
      * CI: Intel w/o GCC's Eigen
      
      * CI: ICC with verbose make
      
      * [Debug] Find core dump
      
      * tests: use arg{} instead of arg() for Intel
      
      * tests: adding a few more missing {}
      
      * fix: sync with @tobiasleibner's branch
      
      * fix: try ubuntu 20-04
      
      * fix: drop exit 1
      
      * style: clang tidy fix
      
      * style: fix missing NOLINT
      
      * ICC: Update Compiler Name
      
      Changed upstream with the last oneAPI release.
      
      * ICC CI: Downgrade pytest
      
      pytest 6 does not capture the `discard_as_unraisable` stderr and
      just writes a warning with its content instead.
      
      * Use new test pinning requirements.txt
      
      * tests: add notes about intel, cleanup
      Co-authored-by: default avatarHenry Schreiner <henryschreineriii@gmail.com>
      0b3df7f9
  14. 09 Nov, 2020 1 commit
  15. 03 Oct, 2020 1 commit
  16. 16 Aug, 2020 1 commit
    • Henry Schreiner's avatar
      tests: cleanup and ci hardening (#2397) · 4d9024ec
      Henry Schreiner authored
      * tests: refactor and cleanup
      
      * refactor: more consistent
      
      * tests: vendor six
      
      * tests: more xfails, nicer system
      
      * tests: simplify to info
      
      * tests: suggestions from @YannickJadoul and @bstaletic
      
      * tests: restore some pypy tests that now pass
      
      * tests: rename info to env
      
      * tests: strict False/True
      
      * tests: drop explicit strict=True again
      
      * tests: reduce minimum PyTest to 3.1
      4d9024ec
  17. 28 Feb, 2018 1 commit
    • luz.paz's avatar
      Typo · 13c08072
      luz.paz authored
      13c08072
  18. 23 Dec, 2017 1 commit
    • Jason Rhinelander's avatar
      Silence new MSVC C++17 deprecation warnings · 3be401f2
      Jason Rhinelander authored
      In the latest MSVC in C++17 mode including Eigen causes warnings:
      
          warning C4996: 'std::unary_negate<_Fn>': warning STL4008: std::not1(),
          std::not2(), std::unary_negate, and std::binary_negate are deprecated in
          C++17. They are superseded by std::not_fn(). You can define
          _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING or
          _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have
          received this warning.
      
      This disables 4996 for the Eigen includes.
      
      Catch generates a similar warning for std::uncaught_exception, so
      disable the warning there, too.
      
      In both cases this is temporary; we can (and should) remove the warnings
      disabling once new upstream versions of Eigen and Catch are available
      that address the warning. (The Catch one, in particular, looks to be
      fixed in upstream master, so will probably be fixed in the next (2.0.2)
      release).
      3be401f2
  19. 12 Oct, 2017 1 commit
    • Jason Rhinelander's avatar
      Fix 2D Nx1/1xN inputs to eigen dense vector args · 6a81dbbb
      Jason Rhinelander authored
      This fixes a bug introduced in b68959e8
      when passing in a two-dimensional, but conformable, array as the value
      for a compile-time Eigen vector (such as VectorXd or RowVectorXd).  The
      commit switched to using numpy to copy into the eigen data, but this
      broke the described case because numpy refuses to broadcast a (N,1)
      into a (N).
      
      This commit fixes it by squeezing the input array whenever the output
      array is 1-dimensional, which will let the problematic case through.
      (This shouldn't squeeze inappropriately as dimension compatibility is
      already checked for conformability before getting to the copy code).
      6a81dbbb
  20. 05 Aug, 2017 1 commit
    • Jason Rhinelander's avatar
      Update all remaining tests to new test styles · 391c7544
      Jason Rhinelander authored
      This udpates all the remaining tests to the new test suite code and
      comment styles started in #898.  For the most part, the test coverage
      here is unchanged, with a few minor exceptions as noted below.
      
      - test_constants_and_functions: this adds more overload tests with
        overloads with different number of arguments for more comprehensive
        overload_cast testing.  The test style conversion broke the overload
        tests under MSVC 2015, prompting the additional tests while looking
        for a workaround.
      
      - test_eigen: this dropped the unused functions `get_cm_corners` and
        `get_cm_corners_const`--these same tests were duplicates of the same
        things provided (and used) via ReturnTester methods.
      
      - test_opaque_types: this test had a hidden dependence on ExampleMandA
        which is now fixed by using the global UserType which suffices for the
        relevant test.
      
      - test_methods_and_attributes: this required some additions to UserType
        to make it usable as a replacement for the test's previous SimpleType:
        UserType gained a value mutator, and the `value` property is not
        mutable (it was previously readonly).  Some overload tests were also
        added to better test overload_cast (as described above).
      
      - test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
        the templated versions with an empty parameter pack expand to the same
        thing.
      
      - test_stl: this was already mostly in the new style; this just tweaks
        things a bit, localizing a class, and adding some missing
        `// test_whatever` comments.
      
      - test_virtual_functions: like `test_stl`, this was mostly in the new
        test style already, but needed some `// test_whatever` comments.
        This commit also moves the inherited virtual example code to the end
        of the file, after the main set of tests (since it is less important
        than the other tests, and rather length); it also got renamed to
        `test_inherited_virtuals` (from `test_inheriting_repeat`) because it
        tests both inherited virtual approaches, not just the repeat approach.
      391c7544
  21. 29 Jun, 2017 1 commit
  22. 09 Apr, 2017 1 commit
    • Jason Rhinelander's avatar
      Fix Eigen argument doc strings · e9e17746
      Jason Rhinelander authored
      Many of the Eigen type casters' name() methods weren't wrapping the type
      description in a `type_descr` object, which thus wasn't adding the
      "{...}" annotation used to identify an argument which broke the help
      output by skipping eigen arguments.
      
      The test code I had added even had some (unnoticed) broken output (with
      the "arg0: " showing up in the return value).
      
      This commit also adds test code to ensure that named eigen arguments
      actually work properly, despite the invalid help output.  (The added
      tests pass without the rest of this commit).
      e9e17746
  23. 22 Mar, 2017 1 commit
  24. 17 Mar, 2017 1 commit
    • Jason Rhinelander's avatar
      Eigen: don't require conformability on length-1 dimensions · efa8726f
      Jason Rhinelander authored
      Fixes #738
      
      The current check for conformability fails when given a 2D, 1xN or Nx1
      input to a row-major or column-major, respectively, Eigen::Ref, leading
      to a copy-required state in the type_caster, but this later failed
      because the copy was also non-conformable because it had the same shape
      and strides (because a 1xN or Nx1 is both F and C contiguous).
      
      In such cases we can safely ignore the stride on the "1" dimension since
      it'll never be used: only the "N" dimension stride needs to match the
      Eigen::Ref stride, which both fixes the non-conformable copy problem,
      but also avoids a copy entirely as long as the "N" dimension has a
      compatible stride.
      efa8726f
  25. 28 Feb, 2017 1 commit
  26. 24 Feb, 2017 2 commits
    • Jason Rhinelander's avatar
      Eigen<->numpy referencing support · 17d0283e
      Jason Rhinelander authored
      This commit largely rewrites the Eigen dense matrix support to avoid
      copying in many cases: Eigen arguments can now reference numpy data, and
      numpy objects can now reference Eigen data (given compatible types).
      
      Eigen::Ref<...> arguments now also make use of the new `convert`
      argument use (added in PR #634) to avoid conversion, allowing
      `py::arg().noconvert()` to be used when binding a function to prohibit
      copying when invoking the function.  Respecting `convert` also means
      Eigen overloads that avoid copying will be preferred during overload
      resolution to ones that require copying.
      
      This commit also rewrites the Eigen documentation and test suite to
      explain and test the new capabilities.
      17d0283e
    • Jason Rhinelander's avatar
      Eigen: fix partially-fixed matrix conversion · d9d224f2
      Jason Rhinelander authored
      Currently when we do a conversion between a numpy array and an Eigen
      Vector, we allow the conversion only if the Eigen type is a
      compile-time vector (i.e. at least one dimension is fixed at 1 at
      compile time), or if the type is dynamic on *both* dimensions.
      
      This means we can run into cases where MatrixXd allow things that
      conforming, compile-time sizes does not: for example,
      `Matrix<double,4,Dynamic>` is currently not allowed, even when assigning
      from a 4-element vector, but it *is* allowed for a
      `Matrix<double,Dynamic,Dynamic>`.
      
      This commit also reverts the current behaviour of using the matrix's
      storage order to determine the structure when the Matrix is fully
      dynamic (i.e. in both dimensions).  Currently we assign to an eigen row
      if the storage order is row-major, and column otherwise: this seems
      wrong (the storage order has nothing to do with the shape!).  While
      numpy doesn't distinguish between a row/column vector, Eigen does, but
      it makes more sense to consistently choose one than to produce
      something with a different shape based on the intended storage layout.
      d9d224f2
  27. 12 Dec, 2016 1 commit
    • Jason Rhinelander's avatar
      Adds automatic casting on assignment of non-pyobject types (#551) · 3f1ff3f4
      Jason Rhinelander authored
      This adds automatic casting when assigning to python types like dict,
      list, and attributes.  Instead of:
      
          dict["key"] = py::cast(val);
          m.attr("foo") = py::cast(true);
          list.append(py::cast(42));
      
      you can now simply write:
      
          dict["key"] = val;
          m.attr("foo") = true;
          list.append(42);
      
      Casts needing extra parameters (e.g. for a non-default rvp) still
      require the py::cast() call. set::add() is also supported.
      
      All usage is channeled through a SFINAE implementation which either just returns or casts. 
      
      Combined non-converting handle and autocasting template methods via a
      helper method that either just returns (handle) or casts (C++ type).
      3f1ff3f4
  28. 06 Sep, 2016 1 commit
  29. 03 Sep, 2016 1 commit
    • Jason Rhinelander's avatar
      Make test initialization self-registering · 52f4be89
      Jason Rhinelander authored
      Adding or removing tests is a little bit cumbersome currently: the test
      needs to be added to CMakeLists.txt, the init function needs to be
      predeclared in pybind11_tests.cpp, then called in the plugin
      initialization.  While this isn't a big deal for tests that are being
      committed, it's more of a hassle when working on some new feature or
      test code for which I temporarily only care about building and linking
      the test being worked on rather than the entire test suite.
      
      This commit changes tests to self-register their initialization by
      having each test initialize a local object (which stores the
      initialization function in a static variable).  This makes changing the
      set of tests being build easy: one only needs to add or comment out
      test names in tests/CMakeLists.txt.
      
      A couple other minor changes that go along with this:
      
      - test_eigen.cpp is now included in the test list, then removed if eigen
        isn't available.  This lets you disable the eigen tests by commenting
        it out, just like all the other tests, but keeps the build working
        without eigen eigen isn't available.  (Also, if it's commented out, we
        don't even bother looking for and reporting the building with/without
        eigen status message).
      
      - pytest is now invoked with all the built test names (with .cpp changed
        to .py) so that it doesn't try to run tests that weren't built.
      52f4be89
  30. 19 Aug, 2016 1 commit
    • Dean Moldovan's avatar
      Port tests to pytest · a0c1ccf0
      Dean Moldovan authored
      Use simple asserts and pytest's powerful introspection to make testing
      simpler. This merges the old .py/.ref file pairs into simple .py files
      where the expected values are right next to the code being tested.
      
      This commit does not touch the C++ part of the code and replicates the
      Python tests exactly like the old .ref-file-based approach.
      a0c1ccf0
  31. 04 Aug, 2016 2 commits
    • Jason Rhinelander's avatar
      Eigen support for special matrix objects · 9ffb3dda
      Jason Rhinelander authored
      Functions returning specialized Eigen matrices like Eigen::DiagonalMatrix and
      Eigen::SelfAdjointView--which inherit from EigenBase but not
      DenseBase--isn't currently allowed; such classes are explicitly copyable
      into a Matrix (by definition), and so we can support functions that
      return them by copying the value into a Matrix then casting that
      resulting dense Matrix into a numpy.ndarray.  This commit does exactly
      that.
      9ffb3dda
    • Jason Rhinelander's avatar
      Fix eigen copying of non-standard stride values · 8657f308
      Jason Rhinelander authored
      Some Eigen objects, such as those returned by matrix.diagonal() and
      matrix.block() have non-standard stride values because they are
      basically just maps onto the underlying matrix without copying it (for
      example, the primary diagonal of a 3x3 matrix is a vector-like object
      with .src equal to the full matrix data, but with stride 4).  Returning
      such an object from a pybind11 method breaks, however, because pybind11
      assumes vectors have stride 1, and that matrices have strides equal to
      the number of rows/columns or 1 (depending on whether the matrix is
      stored column-major or row-major).
      
      This commit fixes the issue by making pybind11 use Eigen's stride
      methods when copying the data.
      8657f308
  32. 03 Aug, 2016 1 commit
    • Jason Rhinelander's avatar
      Add support for Eigen::Ref<...> function arguments · 5fd5074a
      Jason Rhinelander authored
      Eigen::Ref is a common way to pass eigen dense types without needing a
      template, e.g. the single definition `void
      func(Eigen::Ref<Eigen::MatrixXd> x)` can be called with any double
      matrix-like object.
      
      The current pybind11 eigen support fails with internal errors if
      attempting to bind a function with an Eigen::Ref<...> argument because
      Eigen::Ref<...> satisfies the "is_eigen_dense" requirement, but can't
      compile if actually used: Eigen::Ref<...> itself is not default
      constructible, and so the argument std::tuple containing an
      Eigen::Ref<...> isn't constructible, which results in compilation
      failure.
      
      This commit adds support for Eigen::Ref<...> by giving it its own
      type_caster implementation which consists of an internal type_caster of
      the referenced type, load/cast methods that dispatch to the internal
      type_caster, and a unique_ptr to an Eigen::Ref<> instance that gets
      set during load().
      
      There is, of course, no performance advantage for pybind11-using code of
      using Eigen::Ref<...>--we are allocating a matrix of the derived type
      when loading it--but this has the advantage of allowing pybind11 to bind
      transparently to C++ methods taking Eigen::Refs.
      5fd5074a
  33. 05 Jul, 2016 2 commits
  34. 05 May, 2016 1 commit