- 17 Nov, 2016 4 commits
-
-
Dean Moldovan authored
* `array_t(const object &)` now throws on error * `array_t::ensure()` is intended for casters —- old constructor is deprecated * `array` and `array_t` get default constructors (empty array) * `array` gets a converting constructor * `py::isinstance<array_T<T>>()` checks the type (but not flags) There is only one special thing which must remain: `array_t` gets its own `type_caster` specialization which uses `ensure` instead of a simple check.
-
Dean Moldovan authored
The pytype converting constructors are convenient and safe for user code, but for library internals the additional type checks and possible conversions are sometimes not desired. `reinterpret_borrow<T>()` and `reinterpret_steal<T>()` serve as the low-level unsafe counterparts of `cast<T>()`. This deprecates the `object(handle, bool)` constructor. Renamed `borrowed` parameter to `is_borrowed` to avoid shadowing warnings on MSVC.
-
Dean Moldovan authored
* Deprecate the `py::object::str()` member function since `py::str(obj)` is now equivalent and preferred * Make `py::repr()` a free function * Make sure obj.cast<T>() works as expected when T is a Python type `obj.cast<T>()` should be the same as `T(obj)`, i.e. it should convert the given object to a different Python type. However, `obj.cast<T>()` usually calls `type_caster::load()` which only checks the type without doing any actual conversion. That causes a very unexpected `cast_error`. This commit makes it so that `obj.cast<T>()` and `T(obj)` are the same when T is a Python type. * Simplify pytypes converting constructor implementation It's not necessary to maintain a full set of converting constructors and assignment operators + const& and &&. A single converting const& constructor will work and there is no impact on binary size. On the other hand, the conversion functions can be significantly simplified.
-
Dean Moldovan authored
Allows checking the Python types before creating an object instead of after. For example: ```c++ auto l = list(ptr, true); if (l.check()) // ... ``` The above is replaced with: ```c++ if (isinstance<list>(ptr)) { auto l = reinterpret_borrow(ptr); // ... } ``` This deprecates `py::object::check()`. `py::isinstance()` covers the same use case, but it can also check for user-defined types: ```c++ class Pet { ... }; py::class_<Pet>(...); m.def("is_pet", [](py::object obj) { return py::isinstance<Pet>(obj); // works as expected }); ```
-
- 16 Nov, 2016 1 commit
-
-
Sylvain Corlay authored
* Also added unsafe version without checks
-
- 08 Nov, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 03 Nov, 2016 3 commits
-
-
Ivan Smirnov authored
(avoid code bloat if possible)
-
Ivan Smirnov authored
NumPy internals are stored under "_numpy_internals" key.
-
Ivan Smirnov authored
-
- 01 Nov, 2016 1 commit
-
-
Ivan Smirnov authored
PYBIND11_NUMPY_DTYPE_EX(Type, F1, "N1", F2, "N2", ...)
-
- 23 Oct, 2016 1 commit
-
-
Ivan Smirnov authored
This avoid a hashmap lookup since the pointer to the list of direct converters is now cached in the typeinfo.
-
- 22 Oct, 2016 4 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
- 20 Oct, 2016 4 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
- 16 Oct, 2016 1 commit
-
-
Jason Rhinelander authored
We have various classes that have non-explicit constructors that accept a single argument, which is implicitly making them implicitly convertible from the argument. In a few cases, this is desirable (e.g. implicit conversion of std::string to py::str, or conversion of double to py::float_); in many others, however, it is unintended (e.g. implicit conversion of size_t to some pre-declared py::array_t<T> type). This disables most of the unwanted implicit conversions by marking them `explicit`, and comments the ones that are deliberately left implicit.
-
- 13 Oct, 2016 2 commits
-
-
Wenzel Jakob authored
This convenience function ensures that a py::object is either a py::array, or the implementation will try to convert it into one. Layout requirements (such as c_style or f_style) can be also be provided.
-
Wenzel Jakob authored
-
- 12 Oct, 2016 1 commit
-
-
Wenzel Jakob authored
This patch adds an extra base handle parameter to most ``py::array`` and ``py::array_t<>`` constructors. If specified along with a pointer to data, the base object will be registered within NumPy, which increases the base's reference count. This feature is useful to create shallow copies of C++ or Python arrays while ensuring that the owners of the underlying can't be garbage collected while referenced by NumPy. The commit also adds a simple test function involving a ``wrap()`` function that creates shallow copies of various N-D arrays.
-
- 07 Oct, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 23 Sep, 2016 1 commit
-
-
Dean Moldovan authored
-
- 22 Sep, 2016 2 commits
-
-
Dean Moldovan authored
This also adds the `hasattr` and `getattr` functions which are needed with the new attribute behavior. The new functions behave exactly like their Python counterparts. Similarly `object` gets a `contains` method which calls `__contains__`, i.e. it's the same as the `in` keyword in Python.
-
Dzhelil Rufat authored
-
- 19 Sep, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 10 Sep, 2016 2 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
- 27 Aug, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 25 Aug, 2016 2 commits
-
-
Ivan Smirnov authored
-
Wenzel Jakob authored
-
- 24 Aug, 2016 1 commit
-
-
Ivan Smirnov authored
If operators.h is included, int_ function in the `detail` namespace will shadow pybind11::int_ type, so the fully qualified name has to be used.
-
- 15 Aug, 2016 2 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
- 14 Aug, 2016 1 commit
-
-
Ivan Smirnov authored
This is required since format descriptors for string types that were using PYBIND11_DESCR were causing problems on C++14 on Linux. Although this is technically a breaking change, it shouldn't cause problems since the only use of format strings is passing them to buffer_info constructor which expects std::string. Note: for non-structured types, the const char * value is still accessible via ::value for compatibility purpose.
-
- 13 Aug, 2016 3 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-