1. 10 Mar, 2017 1 commit
    • Use trusty for travis-ci pypy build (#716) · 303ee29d
      Nightlies for pypy no longer run on Ubuntu 12.04; change the pypy build
      distribution to the travis-ci trusty (i.e. 14.04) beta container.
      
      The pypy build was also installing numpy and scipy for the *system*
      python version, which was pointless; this also adds a guard to the
      eigen/numpy/scipy install code with a !PYPY check.
      Jason Rhinelander committed
  2. 08 Mar, 2017 1 commit
  3. 06 Mar, 2017 1 commit
  4. 04 Mar, 2017 2 commits
  5. 03 Mar, 2017 2 commits
  6. 01 Mar, 2017 1 commit
    • fix python version check (#705) · 11c9f32c
      Commit 11a337f1 added major and minor python version
      checking to cast.h but does not use the macros defined
      via the Python.h inclusion. This may be due to an
      intention to use the variables defined by the cmake
      module FindPythonInterpreter, but nothing in the
      pybind11 repo does anything to convert the cmake
      variables to preprocessor defines.
      eirrgang committed
  7. 28 Feb, 2017 1 commit
  8. 27 Feb, 2017 2 commits
  9. 26 Feb, 2017 7 commits
  10. 24 Feb, 2017 13 commits
    • Move requires_numpy, etc. decorators to globals · 2a757844
      test_eigen.py and test_numpy_*.py have the same
      @pytest.requires_eigen_and_numpy or @pytest.requires_numpy on every
      single test; this changes them to use pytest's global `pytestmark = ...`
      instead to disable the entire module when numpy and/or eigen aren't
      available.
      Jason Rhinelander committed
    • Eigen<->numpy referencing support · 17d0283e
      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.
      Jason Rhinelander committed
    • Add an ability to avoid forcing rvp::move · 546f6fce
      Eigen::Ref objects, when returned, are almost always returned as
      rvalues; what's important is the data they reference, not the outer
      shell, and so we want to be able to use `::copy`,
      `::reference_internal`, etc. to refer to the data the Eigen::Ref
      references (in the following commits), rather than the Eigen::Ref
      instance itself.
      
      This moves the policy override into a struct so that code that wants to
      avoid it (or wants to provide some other Return-type-conditional
      override) can create a specialization of
      return_value_policy_override<Return> in order to override the override.
      
      This lets an Eigen::Ref-returning function be bound with `rvp::copy`,
      for example, to specify that the data should be copied into a new numpy
      array rather than referenced, or `rvp::reference_internal` to indicate
      that it should be referenced, but a keep-alive used (actually, we used
      the array's `base` rather than a py::keep_alive in such a case, but it
      accomplishes the same thing).
      Jason Rhinelander committed
    • Change array's writeable exception to a ValueError · fd751703
      Numpy raises ValueError when attempting to modify an array, while
      py::array is raising a RuntimeError.  This changes the exception to a
      std::domain_error, which gets mapped to the expected ValueError in
      python.
      Jason Rhinelander committed
    • array: fix base handling · f86dddf7
      numpy arrays aren't currently properly setting base: by setting `->base`
      directly, the base doesn't follow what numpy expects and documents (that
      is, following chained array bases to the root array).
      
      This fixes the behaviour by using numpy's PyArray_SetBaseObject to set
      the base instead, and then updates the tests to reflect the fixed
      behaviour.
      Jason Rhinelander committed
    • Change numpy constants to non-deprecated versions · 88fff9d1
      A few of pybind's numpy constants are using the numpy-deprecated names
      (without "ARRAY_" in them); updated our names to be consistent with
      current numpy code.
      Jason Rhinelander committed
    • Make is_template_base_of ignore cv qualification · 7d46c6f6
      `is_template_base_of<T>` fails when `T` is `const` (because its
      implementation relies on being able to convert a `T*` to a `Base<U>*`,
      which won't work when `T` is const).
      
      (This also agrees with std::is_base_of, which ignores cv qualification.)
      Jason Rhinelander committed
    • Eigen: fix partially-fixed matrix conversion · d9d224f2
      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.
      Jason Rhinelander committed
    • Show kwargs in failed method invocation · 231e1678
      With the previous commit, output can be very confusing because you only
      see positional arguments in the "invoked with" line, but you can have a
      failure from kwargs as well (in particular, when a value is invalidly
      specified via both via positional and kwargs).  This commits adds
      kwargs to the output, and updates the associated tests to match.
      Jason Rhinelander committed
    • Make bad kwarg arguments try next overload · caa1379e
      Fixes #688.
      
      My (commented) assumption that such an error is "highly likely to be a
      caller mistake" was proven false by #688.
      Jason Rhinelander committed
    • Independent tests (#665) · 60d0e0db
      * Make tests buildable independently
      
      This makes "tests" buildable as a separate project that uses
      find_package(pybind11 CONFIG) when invoked independently.
      
      This also moves the WERROR option into tests/CMakeLists.txt, as that's
      the only place it is used.
      
      * Use Eigen 3.3.1's cmake target, if available
      
      This changes the eigen finding code to attempt to use Eigen's
      system-installed Eigen3Config first.  In Eigen 3.3.1, it exports a cmake
      Eigen3::Eigen target to get dependencies from (rather than setting the
      include path directly).
      
      If it fails, we fall back to the trying to load allowing modules (i.e.
      allowing our tools/FindEigen3.cmake).  If we either fallback, or the
      eigen version is older than 3.3.1 (or , we still set the include
      directory manually; otherwise, for CONFIG + new Eigen, we get it via
      the target.
      
      This is also needed to allow 'tests' to be built independently, when
      the find_package(Eigen3) is going to find via the system-installed
      Eigen3Config.cmake.
      
      * Add a install-then-build test, using clang on linux
      
      This tests that `make install` to the actual system, followed by a build
      of the tests (without the main pybind11 repository available) works as
      expected.
      
      To also expand the testing variety a bit, it also builds using
      clang-3.9 instead of gcc.
      
      * Don't try loading Eigen3Config in cmake < 3.0
      
      It could FATAL_ERROR as the newer cmake includes a cmake 3.0 required
      line.
      
      If doing an independent, out-of-tree "tests" build, the regular
      find_package(Eigen3) is likely to fail with the same error, but I think
      we can just let that be: if you want a recent Eigen with proper cmake
      loading support *and* want to do an independent tests build, you'll
      need at least cmake 3.0.
      Jason Rhinelander committed
    • Make string conversion stricter (#695) · ee2e5a50
      * Make string conversion stricter
      
      The string conversion logic added in PR #624 for all std::basic_strings
      was derived from the old std::wstring logic, but that was underused and
      turns out to have had a bug in accepting almost anything convertible to
      unicode, while the previous std::string logic was much stricter.  This
      restores the previous std::string logic by only allowing actual unicode
      or string types.
      
      Fixes #685.
      
      * Added missing 'requires numpy' decorator
      
      (I forgot that the change to a global decorator here is in the
      not-yet-merged Eigen PR)
      Jason Rhinelander committed
  11. 23 Feb, 2017 4 commits
    • Enable static properties (py::metaclass) by default · dd01665e
      Now that only one shared metaclass is ever allocated, it's extremely
      cheap to enable it for all pybind11 types.
      
      * Deprecate the default py::metaclass() since it's not needed anymore.
      * Allow users to specify a custom metaclass via py::metaclass(handle).
      Dean Moldovan committed
    • Make all classes with the same instance size derive from a common base · 08cbe8df
      In order to fully satisfy Python's inheritance type layout requirements,
      all types should have a common 'solid' base. A solid base is one which
      has the same instance size as the derived type (not counting the space
      required for the optional `dict_ptr` and `weakrefs_ptr`). Thus, `object`
      does not qualify as a solid base for pybind11 types and this can lead to
      issues with multiple inheritance.
      
      To get around this, new base types are created: one per unique instance
      size. There is going to be very few of these bases. They ensure Python's
      MRO checks will pass when multiple bases are involved.
      Dean Moldovan committed
    • Reimplement static properties by extending PyProperty_Type · c91f8bd6
      Instead of creating a new unique metaclass for each type, the builtin
      `property` type is subclassed to support static properties. The new
      setter/getters always pass types instead of instances in their `self`
      argument. A metaclass is still required to support this behavior, but
      it doesn't store any data anymore, so a new one doesn't need to be
      created for each class. There is now only one common metaclass which
      is shared by all pybind11 types.
      Dean Moldovan committed
    • Minor docs build maintenance (#692) · a3f4a02c
      * Switch breathe to stable releases. It was previously pulling directly
        from master because a required bugfix was not in a stable release yet.
      
      * Force update sphinx and RTD theme. When using conda, readthedocs pins
        sphinx==1.3.5 and sphinx_rtd_theme==0.1.7, which is a bit older than
        the ones used in the RTD regular (non-conda) build. The newer theme
        has nicer sidebar navigation (4-level depth vs. only 2-level on the
        older version). Note that the python==3.5 requirement must stay
        because RTD still installs the older sphinx at one point which isn't
        available with Python 3.6.
      
      [skip ci]
      Dean Moldovan committed
  12. 22 Feb, 2017 1 commit
    • Fixed compilation error when binding function accepting some forms of std::function (#689) · c7fcde7c
      * Fixed compilation error when defining function accepting some forms of std::function.
      
      The compilation error happens only when the functional.h header is
      present, and the build is done in debug mode, with NDEBUG being
      undefined.  In addition, the std::function must accept an abstract
      base class by reference.
      
      The compilation error occurred in cast.h, when trying to construct a
      std::tuple<AbstractBase>, rather than a std::tuple<AbstractBase&>.
      This was caused by functional.h using std::move rather than
      std::forward, changing the signature of the function being used.
      
      This commit contains the fix, along with a test that exhibits the
      issue when compiled in debug mode without the fix applied.
      
      * Moved new std::function tests into test_callbacks, added callback_with_movable test.
      Lunderberg committed
  13. 18 Feb, 2017 1 commit
  14. 17 Feb, 2017 3 commits
    • changed return_value:: to return_value_policy:: (#672) · e72eaa47
      * changed return_value:: to return_value_policy::
      
      * Update functions.rst
      thorink committed
    • Revert noexcept deduction in favour of better SFINAE on lambda functions (#677) · 1d7998e3
      noexcept deduction, added in PR #555, doesn't work with clang's
      -std=c++1z; and while it works with g++, it isn't entirely clear to me
      that it is required to work in C++17.
      
      What should work, however, is that C++17 allows implicit conversion of a
      `noexcept(true)` function pointer to a `noexcept(false)` (i.e.  default,
      noexcept-not-specified) function pointer.  That was breaking in pybind11
      because the cpp_function template used for lambdas provided a better
      match (i.e. without requiring an implicit conversion), but it then
      failed.
      
      This commit takes a different approach of using SFINAE on the lambda
      function to prevent it from matching a non-lambda object, which then
      gets implicit conversion from a `noexcept` function pointer to a
      `noexcept(false)` function pointer.  This much nicer solution also gets
      rid of the C++17 NOEXCEPT macros, and works in both clang and g++.
      Jason Rhinelander committed