Commit Graph

2817 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
e94b98fd76 Merge branch 'master' into smart_holder 2021-11-22 17:03:58 -08:00
Rasmus Munk Larsen
70a58c577e
Replace usage of deprecated Eigen class MappedSparseMatrix. (#3499)
* Replace usage of deprecated Eigen class

Eigen::MappedSparseMatrix has been deprecated since Eigen 3.3 from 2016. Use the equivalent modern syntax Eigen::Map<Eigen::SparseMatrix<...>>.

* Update eigen.h

* Update eigen.h
2021-11-22 17:01:35 -08:00
pre-commit-ci[bot]
fe65693c72
[pre-commit.ci] pre-commit autoupdate (#3500)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v2.29.0 → v2.29.1](https://github.com/asottile/pyupgrade/compare/v2.29.0...v2.29.1)
- [github.com/psf/black: 21.10b0 → 21.11b1](https://github.com/psf/black/compare/21.10b0...21.11b1)
- [github.com/asottile/blacken-docs: v1.11.0 → v1.12.0](https://github.com/asottile/blacken-docs/compare/v1.11.0...v1.12.0)

* Keep blacken-docs and black in sync.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2021-11-22 16:25:35 -05:00
Lishen1
5d067e870a
fix: remove redundant copy operation to fix warning (#3486)
* fix compiler warning: deprecated implicit copy constructor

* take care of the bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747

* add parenthesis for better reading

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update include/pybind11/eigen.h

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2021-11-22 15:27:00 -05:00
Ralf W. Grosse-Kunstleve
98bdbba999 Merge branch 'master' into smart_holder 2021-11-22 01:35:01 -08:00
Ralf W. Grosse-Kunstleve
9281faf429
Fixing stict vs strict typo. (#3493) 2021-11-22 01:33:03 -08:00
Ralf W. Grosse-Kunstleve
7bbc5e3cdd Merge branch 'master' into smart_holder 2021-11-20 16:03:36 -08:00
Jason Rhinelander
673b4be3d7
Fix py::kw_only when used before the first arg of a method (#3488)
* Fix py::kw_only when used before the first arg of a method

The implicit space for the `self` argument isn't added until we hit the
first argument, but this wasn't being done for kw_only or pos_only, and
so a kw_only before the first argument would break.

This fixes it by properly checking whether we need to add the self arg.

(The pos_only issue here was extremely mild -- you didn't get the `/` in
the docstring, but AFAICT it has no other effect since there are no
meaningful arguments before it anyway).

* Style changes

- rename check_have_self_arg -> append_self_arg_if_needed

- move the argument name inline comments before the args instead of
  after
2021-11-20 16:01:57 -08:00
Ralf W. Grosse-Kunstleve
e57afe23f7 Merge branch 'master' into smart_holder 2021-11-20 09:35:40 -08:00
ngc92
56322dafc9
fixed include for filesystem::path (#3482) 2021-11-18 14:06:04 -05:00
Henry Schreiner
15f8d7c12e
fix(build): cleaner CMake printouts & IDE folders (#3479) 2021-11-18 10:01:24 -05:00
Henry Schreiner
ff51fcb773
docs: fix broken link (again) 2021-11-18 08:42:08 -05:00
Henry Schreiner
72282f75a1
ci: support development releases of Python (#3419)
* ci: support development releases of Python

* fix: better PyPy support

* fix: patch over a few more pypy issues

* Try to patch

* Properly follow pep667

* Fix typo

* Whoops, 667 not in yet

* For testing

* More testing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Try to backport

* Try to simplify fix

* Nail down the fix

* Try pypy workaround

* Typo

* one last typo

* Replacing 0x03110000 with 0x030B0000

* Add TODO. Drop PyPy

* Fix typo

* Revert catch upgrade

* fix: minor cleanup, try pypy again

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2021-11-17 09:44:19 -05:00
Guillaume Jacquenot
1eb59963c7
Removed duplicated word in docs/advanced/exceptions.rst (#3476) 2021-11-16 17:32:01 -05:00
Sergiu Deitsch
d2b2131603
cmake: report version type in the version string (#3472) 2021-11-16 10:03:41 -05:00
pre-commit-ci[bot]
9422d98fcc
[pre-commit.ci] pre-commit autoupdate (#3473)
updates:
- [github.com/PyCQA/isort: 5.10.0 → 5.10.1](https://github.com/PyCQA/isort/compare/5.10.0...5.10.1)
- [github.com/shellcheck-py/shellcheck-py: v0.7.2.1 → v0.8.0.1](https://github.com/shellcheck-py/shellcheck-py/compare/v0.7.2.1...v0.8.0.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-15 22:48:39 -05:00
Ralf W. Grosse-Kunstleve
47720eebd9 Tracking ci.yml changes from master. 2021-11-15 15:04:06 -08:00
Ralf W. Grosse-Kunstleve
8a7643f471 Using PYBIND11_SH_DEF for test_override_cache_helper introduced by PR #3465. 2021-11-15 14:59:46 -08:00
Ralf W. Grosse-Kunstleve
f4fab85d87 Merge branch 'master' into sh_merge_master 2021-11-15 14:43:08 -08:00
Trigve
afdc09deda
[master] Wrong caching of overrides (#3465)
* override: Fix wrong caching of the overrides

There was a problem when the python type, which was stored in override
cache for C++ functions, was destroyed and  the record wasn't removed from the
override cache. Therefor, dangling pointer was stored there. Then when the
memory was reused and new type was allocated at the given address and the
method with the same name (as previously stored in the cache) was actually
overridden in python, it would wrongly find it in the override cache for C++
functions and therefor override from python wouldn't be called.
The fix is to erase the type from the override cache when the type is destroyed.

* test: Pass by const ref instead of by value (clang-tidy)

* test: Rename classes and move to different files

Rename the classes and files so they're no too generic. Also, better place to
test the stuff is in test_virtual_functions.cpp/.py as we're basically testing
the virtual functions/trampolines.

* Add TODO for erasure code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-15 13:36:41 -05:00
Henry Schreiner
270b11d502
Revert "style: drop pycln" (#3466)
* Revert "style: drop pycln (#3397)"

This reverts commit 606f81a966.

* Update .pre-commit-config.yaml
2021-11-13 21:32:58 -05:00
Guillaume Jacquenot
e450eb62c2
Removed duplicated word in docs/advanced/cast/eigen.rst (#3458) 2021-11-12 10:53:43 -05:00
Henry Schreiner
aebd21b53c
docs: rework CI a bit, more modern skipping (#3424)
* docs: rework CI a bit, more modern skipping

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-10 12:13:10 -05:00
Antony Lee
b11ff912a6
fix(setup =_helpers): don't add -g0 CFLAGS sets -g (#3436)
On Unix, setuptools prepends $CFLAGS and $CPPFLAGS to the compiler flags
(they always come before extra_compile_args and anything else; see
distutils.sysconfig.customize_compiler).  In practice, the environment
variables are useful e.g. to quickly generate a debug build (e.g. by
setting CFLAGS=-g), but Pybind11Extension currently unconditionally
overwrites this with -g0.

Instead, check the environment variables and only insert -g0 if not
overridden by them.
2021-11-08 16:27:32 -05:00
pre-commit-ci[bot]
b322018e15
[pre-commit.ci] pre-commit autoupdate (#3449)
updates:
- [github.com/PyCQA/isort: 5.9.3 → 5.10.0](https://github.com/PyCQA/isort/compare/5.9.3...5.10.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-08 15:56:20 -05:00
Ralf W. Grosse-Kunstleve
58c7f076bc Merge branch 'master' into sh_merge_master 2021-11-07 16:26:55 -08:00
Boris Rasin
01f938e799
fix: add missing std::forward calls (#3443)
* fix: add missing std::forward calls

Two of the four cpp_function overloads are missing std::forward calls, which seems like a simple oversight.

* add test for https://github.com/pybind/pybind11/pull/3443

* add py tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix test

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-07 18:35:25 -05:00
Henry Schreiner
a61e354e42
docs: touch up manual release suggestion (#3422) 2021-11-05 22:48:27 -04:00
pre-commit-ci[bot]
6de30d3172
[pre-commit.ci] pre-commit autoupdate (#3432)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 21.9b0 → 21.10b0](https://github.com/psf/black/compare/21.9b0...21.10b0)

* Update blacken-docs too

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2021-11-01 17:22:12 -04:00
Chad B. Hovey
dd2d12721c
Correct "which" versus "that" error. (#3430) 2021-11-01 12:01:27 -04:00
Jason Rhinelander
e7c9753f1d
feat: allow kw-only args after a py::args (#3402)
* Simply has_kw_only_args handling

This simplifies tracking the number of kw-only args by instead tracking
the number of positional arguments (which is really what we care about
everywhere this is used).

* Allow keyword-only arguments to follow py::args

This removes the constraint that py::args has to be last (or
second-last, with py::kwargs) and instead makes py::args imply
py::kw_only for any remaining arguments, allowing you to bind a function
that works the same way as a Python function such as:

    def f(a, *args, b):
        return a * b + sum(args)

    f(10, 1, 2, 3, b=20)  # == 206

With this change, you can bind such a function using:

    m.def("f", [](int a, py::args args, int b) { /* ... */ },
        "a"_a, "b"_a);

Or, to be more explicit about the keyword-only arguments:

    m.def("g", [](int a, py::args args, int b) { /* ... */ },
        "a"_a, py::kw_only{}, "b"_a);

(The only difference between the two is that the latter will fail at
binding time if the `kw_only{}` doesn't match the `py::args` position).

This doesn't affect backwards compatibility at all because, currently,
you can't have a py::args anywhere except the end/2nd-last.

* Take args/kwargs by const lvalue ref

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2021-10-28 23:16:55 -04:00
Ralf W. Grosse-Kunstleve
22bf704794 Merge branch 'master' into smart_holder 2021-10-27 16:23:55 -07:00
Ralf W. Grosse-Kunstleve
a80b22374a chore: get back to work after 2.8.1
[skip ci]
2021-10-27 15:15:11 -07:00
Ralf W. Grosse-Kunstleve
acae930123 Merge branch 'master' into stable 2021-10-27 14:59:25 -07:00
Ralf W. Grosse-Kunstleve
f7b499615e
[skip ci] Tweaks in preparation for the 2.8.1 release. (#3421) 2021-10-27 14:35:10 -07:00
Henry Schreiner
f1594cb960
docs: changelog update for 2.8.1 (#3416)
* docs: changelog update for 2.8.1

* chore: add one more entry

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-10-27 15:08:59 -04:00
Henry Schreiner
90707b46f2
fix(build): support conan's multiple includes of all files (#3420) 2021-10-27 15:06:02 -04:00
Ralf W. Grosse-Kunstleve
5d949b703c Separate concurrency groups for ci.yml, ci_sh_def.yml. Also changing name back from CI-SH-AVL to CI because I saw the github.com web UI getting confused if there are different names for the same .yml. 2021-10-27 10:55:24 -07:00
Ralf W. Grosse-Kunstleve
fc5d70da29 return_value_policy_override fix: also enable for type_uses_smart_holder_type_caster 2021-10-27 09:47:01 -07:00
Ralf W. Grosse-Kunstleve
50a4ed2888 Tracking ci.yml changes from master. 2021-10-26 12:13:05 -07:00
Ralf W. Grosse-Kunstleve
4958fd9aa1 Merge branch 'master' into sh_merge_master 2021-10-26 12:10:34 -07:00
Henry Schreiner
e7e2c79f3f
fix: improve support for Python 3.11-dev (#3368)
* ci: support Python 3.11-dev

Also update 3.10 to final, better PyPy usage

* fix: use PyFrame_GetCode on Python 3.9+

* ci: some bitiness of pypy not supported on win

* chore: update CMake support to 3.22rc1 to quiet warning

* fix: use dev version of py to fix Py 3.11

* tests: print proper Eigen version

* ci: include pypy2, not sure why

* ci: avoid running on Python 3.11 for now

* ci: fix runs

* ci: simpler PyPy usage, drop unmaintained scipy + pypy index

* ci: only binary numpy, wait on pypy 3.8

* refactor: address review
2021-10-26 14:50:34 -04:00
Ryan Cahoon
c2d3e220bd
fix: the types for return_value_policy_override in optional_caster (#3376)
* fix: the types for return_value_policy_override in optional_caster

`return_value_policy_override` was not being applied correctly in
`optional_caster` in two ways:
- The `is_lvalue_reference` condition referenced `T`, which was the
`optional<T>` type parameter from the class, when it should have used `T_`,
which was the parameter to the `cast` function. `T_` can potentially be a
reference type, but `T` will never be.
- The type parameter passed to `return_value_policy_override` should be
`T::value_type`, not `T`. This matches the way that the other STL container
type casters work.

The result of these issues was that a method/property definition which used a
`reference` or `reference_internal` return value policy would create a Python
value that's bound by reference to a temporary C++ object, resulting in
undefined behavior. For reasons that I was not able to figure out fully, it
seems like this causes problems when using old versions of `boost::optional`,
but not with recent versions of `boost::optional` or the `libstdc++`
implementation of `std::optional`. The issue (that the override to
`return_value_policy::move` is never being applied) is present for all
implementations, it just seems like that somehow doesn't result in problems for
the some implementation of `optional`. This change includes a regression type
with a custom optional-like type which was able to reproduce the issue.

Part of the issue with using the wrong types may have stemmed from the type
variables `T` and `T_` having very similar names. This also changes the type
variables in `optional_caster` to use slightly more descriptive names, which
also more closely follow the naming convention used by the other STL casters.

Fixes #3330

* Fix clang-tidy complaints

* Add missing NOLINT

* Apply a couple more fixes

* fix: support GCC 4.8

* tests: avoid warning about unknown compiler for compilers missing C++17

* Remove unneeded test module attribute

* Change test enum to have more unique int values

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2021-10-25 19:04:45 -07:00
pre-commit-ci[bot]
d45a88105c
[pre-commit.ci] pre-commit autoupdate (#3409)
updates:
- [github.com/asottile/yesqa: v1.2.3 → v1.3.0](https://github.com/asottile/yesqa/compare/v1.2.3...v1.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-10-25 16:06:13 -04:00
Henry Schreiner
9379b399d9
fix: MSVC 2017 C++17 on Python 3 regression (#3407)
* fix: MSVC 2017 C++17 on Python 3 regression

* ci: add 3.7 job on CI
2021-10-25 16:01:19 -04:00
Aaron Gokaslan
78ee782bd4
feat: Add C++ binding to throw AttributeError (#3387)
* Add C++ bindings to throw AttributeError

* Fix formatting bug
2021-10-23 00:07:22 -04:00
Dmitry Yershov
076c89fc54
tests: test recursive dispatch using visitor pattern (#3365) 2021-10-22 17:09:15 -04:00
Henry Schreiner
606f81a966
style: drop pycln (#3397) 2021-10-22 16:38:40 -04:00
Geoffrey Gunter
2d6014e417
docs: fix minor typo (#3390) 2021-10-21 10:37:54 -04:00
Henry Schreiner
f791dc8648
fix: deprecate make_simple_namespace, fix Python 3.11 (#3374)
* fix: deprecate make_simple_namespace, fix Python 3.11

* docs: update links
2021-10-19 14:39:29 -04:00