1. 08 Dec, 2020 1 commit
  2. 15 Oct, 2020 1 commit
  3. 03 Oct, 2020 1 commit
  4. 14 Sep, 2020 1 commit
  5. 09 Sep, 2020 1 commit
  6. 04 Sep, 2020 1 commit
  7. 23 Aug, 2020 1 commit
  8. 22 Aug, 2020 1 commit
    • jbarlow83's avatar
      Improve documentation of Python and C++ exceptions (#2408) · b8863698
      jbarlow83 authored
      The main change is to treat error_already_set as a separate category
      of exception that arises in different circumstances and needs to be
      handled differently. The asymmetry between Python and C++ exceptions
      is further emphasized.
      b8863698
  9. 20 Aug, 2020 1 commit
  10. 04 Aug, 2020 1 commit
  11. 23 Jul, 2020 1 commit
  12. 20 Jul, 2020 1 commit
  13. 15 Jul, 2020 1 commit
    • Kota Yamaguchi's avatar
      Fix undefined memoryview format (#2223) · e2488698
      Kota Yamaguchi authored
      * Fix undefined memoryview format
      
      * Add missing <algorithm> header
      
      * Add workaround for py27 array compatibility
      
      * Workaround py27 memoryview behavior
      
      * Fix memoryview constructor from buffer_info
      
      * Workaround PyMemoryView_FromMemory availability in py27
      
      * Fix up memoryview tests
      
      * Update memoryview test from buffer to check signedness
      
      * Use static factory method to create memoryview
      
      * Remove ndim arg from memoryview::frombuffer and add tests
      
      * Allow ndim=0 memoryview and documentation fixup
      
      * Use void* to align to frombuffer method signature
      
      * Add const variants of frombuffer and frommemory
      
      * Add memory view section in doc
      
      * Fix docs
      
      * Add test for null buffer
      
      * Workaround py27 nullptr behavior in test
      
      * Rename frombuffer to from_buffer
      e2488698
  14. 30 Jun, 2020 1 commit
  15. 28 Aug, 2018 1 commit
  16. 24 Jun, 2018 1 commit
  17. 21 Sep, 2017 1 commit
    • Ansgar Burchardt's avatar
      correct stride in matrix example and test · a22dd2d1
      Ansgar Burchardt authored
      This also matches the Eigen example for the row-major case.
      
      This also enhances one of the tests to trigger a failure (and fixes it in the PR).  (This isn't really a flaw in pybind itself, but rather fixes wrong code in the test code and docs).
      a22dd2d1
  18. 13 Sep, 2017 1 commit
  19. 25 Aug, 2017 1 commit
  20. 27 Jun, 2017 1 commit
  21. 29 May, 2017 1 commit
    • Dean Moldovan's avatar
      Replace PYBIND11_PLUGIN with PYBIND11_MODULE · 443ab594
      Dean Moldovan authored
      This commit also adds `doc()` to `object_api` as a shortcut for the
      `attr("__doc__")` accessor.
      
      The module macro changes from:
      ```c++
      PYBIND11_PLUGIN(example) {
          pybind11::module m("example", "pybind11 example plugin");
          m.def("add", [](int a, int b) { return a + b; });
          return m.ptr();
      }
      ```
      
      to:
      
      ```c++
      PYBIND11_MODULE(example, m) {
          m.doc() = "pybind11 example plugin";
          m.def("add", [](int a, int b) { return a + b; });
      }
      ```
      
      Using the old macro results in a deprecation warning. The warning
      actually points to the `pybind11_init` function (since attributes
      don't bind to macros), but the message should be quite clear:
      "PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE".
      443ab594
  22. 28 May, 2017 1 commit
  23. 27 May, 2017 1 commit
  24. 25 May, 2017 1 commit
    • Jason Rhinelander's avatar
      vectorize: pass-through of non-vectorizable args · f3ce00ea
      Jason Rhinelander authored
      This extends py::vectorize to automatically pass through
      non-vectorizable arguments.  This removes the need for the documented
      "explicitly exclude an argument" workaround.
      
      Vectorization now applies to arithmetic, std::complex, and POD types,
      passed as plain value or by const lvalue reference (previously only
      pass-by-value types were supported).  Non-const lvalue references and
      any other types are passed through as-is.
      
      Functions with rvalue reference arguments (whether vectorizable or not)
      are explicitly prohibited: an rvalue reference is inherently not
      something that can be passed multiple times and is thus unsuitable to
      being in a vectorized function.
      
      The vectorize returned value is also now more sensitive to inputs:
      previously it would return by value when all inputs are of size 1; this
      is now amended to having all inputs of size 1 *and* 0 dimensions.  Thus
      if you pass in, for example, [[1]], you get back a 1x1, 2D array, while
      previously you got back just the resulting single value.
      
      Vectorization of member function specializations is now also supported
      via `py::vectorize(&Class::method)`; this required passthrough support
      for the initial object pointer on the wrapping function pointer.
      f3ce00ea
  25. 10 May, 2017 2 commits
    • Bruce Merry's avatar
      Allow std::complex field with PYBIND11_NUMPY_DTYPE (#831) · b82c0f0a
      Bruce Merry authored
      This exposed a few underlying issues:
      
      1. is_pod_struct was too strict to allow this. I've relaxed it to
      require only trivially copyable and standard layout, rather than POD
      (which additionally requires a trivial constructor, which std::complex
      violates).
      
      2. format_descriptor<std::complex<T>>::format() returned numpy format
      strings instead of PEP3118 format strings, but register_dtype
      feeds format codes of its fields to _dtype_from_pep3118. I've changed it
      to return PEP3118 format codes. format_descriptor is a public type, so
      this may be considered an incompatible change.
      
      3. register_structured_dtype tried to be smart about whether to mark
      fields as unaligned (with ^). However, it's examining the C++ alignment,
      rather than what numpy (or possibly PEP3118) thinks the alignment should
      be. For complex values those are different. I've made it mark all fields
      as ^ unconditionally, which should always be safe even if they are
      aligned, because we explicitly mark the padding.
      b82c0f0a
    • Bruce Merry's avatar
      Support arrays inside PYBIND11_NUMPY_DTYPE (#832) · 8e0d832c
      Bruce Merry authored
      Resolves #800.
      
      Both C++ arrays and std::array are supported, including mixtures like
      std::array<int, 2>[4]. In a multi-dimensional array of char, the last
      dimension is used to construct a numpy string type.
      8e0d832c
  26. 08 May, 2017 1 commit
  27. 07 May, 2017 3 commits
    • Cris Luengo's avatar
    • Jason Rhinelander's avatar
      Use numpy rather than Eigen for copying · b68959e8
      Jason Rhinelander authored
      We're current copy by creating an Eigen::Map into the input numpy
      array, then assigning that to the basic eigen type, effectively having
      Eigen do the copy.  That doesn't work for negative strides, though:
      Eigen doesn't allow them.
      
      This commit makes numpy do the copying instead by allocating the eigen
      type, then having numpy copy from the input array into a numpy reference
      into the eigen object's data.  This also saves a copy when type
      conversion is required: numpy can do the conversion on-the-fly as part
      of the copy.
      
      Finally this commit also makes non-reference parameters respect the
      convert flag, declining the load when called in a noconvert pass with a
      convertible, but non-array input or an array with the wrong dtype.
      b68959e8
    • Cris Luengo's avatar
      d400f60c
  28. 28 Mar, 2017 1 commit
  29. 22 Mar, 2017 2 commits
    • Jason Rhinelander's avatar
      array-unchecked: add runtime dimension support and array-compatible methods · 773339f1
      Jason Rhinelander authored
      The extends the previous unchecked support with the ability to
      determine the dimensions at runtime.  This incurs a small performance
      hit when used (versus the compile-time fixed alternative), but is still considerably
      faster than the full checks on every call that happen with
      `.at()`/`.mutable_at()`.
      773339f1
    • Jason Rhinelander's avatar
      array: add unchecked access via proxy object · 423a49b8
      Jason Rhinelander authored
      This adds bounds-unchecked access to arrays through a `a.unchecked<Type,
      Dimensions>()` method.  (For `array_t<T>`, the `Type` template parameter
      is omitted).  The mutable version (which requires the array have the
      `writeable` flag) is available as `a.mutable_unchecked<...>()`.
      
      Specifying the Dimensions as a template parameter allows storage of an
      std::array; having the strides and sizes stored that way (as opposed to
      storing a copy of the array's strides/shape pointers) allows the
      compiler to make significant optimizations of the shape() method that it
      can't make with a pointer; testing with nested loops of the form:
      
          for (size_t i0 = 0; i0 < r.shape(0); i0++)
              for (size_t i1 = 0; i1 < r.shape(1); i1++)
                  ...
                      r(i0, i1, ...) += 1;
      
      over a 10 million element array gives around a 25% speedup (versus using
      a pointer) for the 1D case, 33% for 2D, and runs more than twice as fast
      with a 5D array.
      423a49b8
  30. 31 Jan, 2017 3 commits
    • Jason Rhinelander's avatar
      Minor fixes (#613) · 12494525
      Jason Rhinelander authored
      * Minor doc syntax fix
      
      The numpy documentation had a bad :file: reference (was using double
      backticks instead of single backticks).
      
      * Changed long-outdated "example" -> "tests" wording
      
      The ConstructorStats internal docs still had "from example import", and
      the main testing cpp file still used "example" in the module
      description.
      12494525
    • Jason Rhinelander's avatar
      Numpy: better compilation errors, long double support (#619) · f7f5bc8e
      Jason Rhinelander authored
      * Clarify PYBIND11_NUMPY_DTYPE documentation
      
      The current documentation and example reads as though
      PYBIND11_NUMPY_DTYPE is a declarative macro along the same lines as
      PYBIND11_DECLARE_HOLDER_TYPE, but it isn't.  The changes the
      documentation and docs example to make it clear that you need to "call"
      the macro.
      
      * Add satisfies_{all,any,none}_of<T, Preds>
      
      `satisfies_all_of<T, Pred1, Pred2, Pred3>` is a nice legibility-enhanced
      shortcut for `is_all<Pred1<T>, Pred2<T>, Pred3<T>>`.
      
      * Give better error message for non-POD dtype attempts
      
      If you try to use a non-POD data type, you get difficult-to-interpret
      compilation errors (about ::name() not being a member of an internal
      pybind11 struct, among others), for which isn't at all obvious what the
      problem is.
      
      This adds a static_assert for such cases.
      
      It also changes the base case from an empty struct to the is_pod_struct
      case by no longer using `enable_if<is_pod_struct>` but instead using a
      static_assert: thus specializations avoid the base class, POD types
      work, and non-POD types (and unimplemented POD types like std::array)
      get a more informative static_assert failure.
      
      * Prefix macros with PYBIND11_
      
      numpy.h uses unprefixed macros, which seems undesirable.  This prefixes
      them with PYBIND11_ to match all the other macros in numpy.h (and
      elsewhere).
      
      * Add long double support
      
      This adds long double and std::complex<long double> support for numpy
      arrays.
      
      This allows some simplification of the code used to generate format
      descriptors; the new code uses fewer macros, instead putting the code as
      different templated options; the template conditions end up simpler with
      this because we are now supporting all basic C++ arithmetic types (and
      so can use is_arithmetic instead of is_integral + multiple
      different specializations).
      
      In addition to testing that it is indeed working in the test script, it
      also adds various offset and size calculations there, which
      fixes the test failures under x86 compilations.
      f7f5bc8e
    • Dean Moldovan's avatar
      Automate generation of reference docs with doxygen and breathe (#598) · 57a9bbc6
      Dean Moldovan authored
      * Make 'any' the default markup role for Sphinx docs
      
      * Automate generation of reference docs with doxygen and breathe
      
      * Improve reference docs coverage
      57a9bbc6
  31. 13 Jan, 2017 1 commit
  32. 16 Dec, 2016 1 commit
    • Wenzel Jakob's avatar
      WIP: PyPy support (#527) · 1d1f81b2
      Wenzel Jakob authored
      This commit includes modifications that are needed to get pybind11 to work with PyPy. The full test suite compiles and runs except for a last few functions that are commented out (due to problems in PyPy that were reported on the PyPy bugtracker).
      
      Two somewhat intrusive changes were needed to make it possible: two new tags ``py::buffer_protocol()`` and ``py::metaclass()`` must now be specified to the ``class_`` constructor if the class uses the buffer protocol and/or requires a metaclass (e.g. for static properties).
      
      Note that this is only for the PyPy version based on Python 2.7 for now. When the PyPy 3.x has caught up in terms of cpyext compliance, a PyPy 3.x patch will follow.
      1d1f81b2
  33. 20 Oct, 2016 1 commit