Commit Graph

134 Commits

Author SHA1 Message Date
Dean Moldovan
3ac1275248 Improve CI test coverage: eigen, numpy and C++14 2016-07-30 17:18:33 +02:00
Wenzel Jakob
a975ab2501 minor namespace change in example 2016-07-19 17:35:09 +02:00
Jason Rhinelander
b3f3d79f4c Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.

Specifically, the following renaming is applied:

example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions

* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.

This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.

The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 16:43:18 -04:00
Jason Rhinelander
4e45e1805b Fix #283: don't print first arg of constructor
This changes the exception error message of a bad-arguments error to
suppress the constructor argument when the failure is a constructor.

This changes both the "Invoked with: " output to omit the object
instances, and rewrites the constructor signature to make it look
like a constructor (changing the first argument to the object name, and
removing the ' -> NoneType' return type.
2016-07-17 17:47:05 -04:00
Jason Rhinelander
eae180cd0b Add missing scipy run-time dep to eigen test
scipy is imported in pybind11/eigen.h when it encounters a sparse
matrix, which gets tested in the eigen test.
2016-07-12 14:16:46 -04:00
Wenzel Jakob
3c6ada3a48 Merge pull request #273 from lsst-dm/master
Add support for user defined exception translators
2016-07-11 23:38:21 +02:00
Pim Schellart
5a7d17ff16 Add support for user defined exception translators 2016-07-11 17:33:04 -04:00
Wenzel Jakob
4e27f7bb13 python 2.7 fix for example 5 2016-07-10 11:01:35 +02:00
Wenzel Jakob
954b7932fe avoid C++ -> Python -> C++ overheads when passing around function objects 2016-07-10 10:44:44 +02:00
Jason Rhinelander
7de9f6c72d Tests can skip by exiting with 99; fix eigen test failure
This allows (and changes the current examples) to exit with status 99 to
skip a test instead of outputting a special string ("NumPy missing").

This also fixes the eigen test, which currently fails when eigen
headers are available but NumPy is not, to skip instead of failing when
NumPy isn't available.
2016-07-09 14:33:10 -04:00
Wenzel Jakob
0d3fc3566a complete rewrite of eval/exec patch 2016-07-08 10:52:10 +02:00
Klemens Morgenstern
c6ad2c4993 added exec functions 2016-07-08 10:05:24 +02:00
Wenzel Jakob
22201d08e4 Merge pull request #268 from bennorth/stricter-test
Tighten check() test in eigen.py
2016-07-06 05:45:56 +02:00
Wenzel Jakob
f57133aa2e correction to #266 fix 2016-07-06 05:43:52 +02:00
Ben North
150a0fa786 check(): Stricter check in tests
Previous version would give false 'OK' if, for example, we were supposed
to get [1, 2, 3] but instead got [2, 1, 3].
2016-07-05 21:46:50 +01:00
Ben North
676e29885b Test that check() catches wrong order of elements
Fails --- next commit will tighten test.
2016-07-05 21:46:50 +01:00
Wenzel Jakob
c2f6841c22 Merge pull request #267 from bennorth/non-contiguous-arrays
Non-contiguous arrays
2016-07-05 22:34:36 +02:00
Ben North
7b8d9e0246 Test eigen converts slices of 3d arrays correctly 2016-07-05 21:13:24 +01:00
Ben North
3e0e779322 Tests: Add further '2*' functions for matrices
Add and declare to Python functions

    double_mat_cm() --- compute 2* a column-major matrix
    double_mat_rm() --- compute 2* a row-major matrix

to 'eigen.cpp' tests / example.
2016-07-05 21:13:24 +01:00
Ben North
4a22091d45 Add tests for doubling row- and col-vectors
Passing a non-contiguous one-dimensional numpy array gives incorrect
results, so three of these tests fail.  The only one passing is the
simple case where the numpy array is contiguous and we are building a
column-major vector.  Subsequent commit will fix the three failing
cases.
2016-07-05 21:13:20 +01:00
Ben North
b063e64b19 Eigen tests: '2*' functions for col-, row-vectors 2016-07-05 21:12:25 +01:00
Jason Rhinelander
f23e0b5e95 Fix test diff output under python2.7
PR #220 broke failed test output under python2.7, which doesn't support
the keepends argument to splitlines.
2016-07-05 16:03:43 -04:00
Wenzel Jakob
fb0e2e5dac minor formatting fix 2016-07-01 14:54:24 +02:00
Brad Harmon
835fc06ca4 Add callback examples with named parameters 2016-06-16 13:19:15 -05:00
Jerry Gamache
c6e0cdfa54 Allow pybind11::arg to have 0, false, or "" as default values. 2016-06-15 12:48:15 -04:00
Dean Moldovan
96017dd7cd Add _a literal for named arguments 2016-06-03 23:15:22 +02:00
Dean Moldovan
1fe5901062 Add a more informative diff output for failed tests 2016-06-02 00:06:09 +02:00
Dean Moldovan
4337a5d86a Fix typo which caused the C++ set test to be skipped
It used to pass anyway because the expected output was identical
to the Python set.
2016-06-01 23:48:24 +02:00
Dean Moldovan
f2b36c2ed2 Fix a couple of warnings
- Conversion warning on clang: 'long' to 'size_t'
- Unused variable warning on MSVC
2016-06-01 23:48:23 +02:00
Wenzel Jakob
38d8b8cfe2 don't allow registering a class twice (fixes #218) 2016-05-31 09:53:28 +02:00
Wenzel Jakob
5dd33d880d fix issues with std::vector<bool> overload in STL (fixes #216) 2016-05-30 11:28:21 +02:00
Wenzel Jakob
0a07805ab6 fixed many conversion warnings on clang 2016-05-29 13:40:40 +02:00
Wenzel Jakob
c48da92561 Merge branch 'cygwin' of https://github.com/BorisSchaeling/pybind11 into BorisSchaeling-cygwin 2016-05-29 12:46:21 +02:00
Wenzel Jakob
67a6392987 very minor cmake adjustments 2016-05-29 12:35:16 +02:00
Wenzel Jakob
1503d2fb50 Merge pull request #207 from dean0x7d/cmake
Simplify CMake build using add_subdirectory
2016-05-29 12:29:36 +02:00
Boris Schäling
20ee935203 Use decltype to deduce return type of PyThread_create_key 2016-05-28 12:26:18 +02:00
Dean Moldovan
9fb50c56d0 Add LTO and strip to pybind11_add_module 2016-05-27 21:42:43 +02:00
Wenzel Jakob
86d825f330 Redesigned virtual call mechanism and user-facing syntax (breaking change!)
Sergey Lyskov pointed out that the trampoline mechanism used to override
virtual methods from within Python caused unnecessary overheads when
instantiating the original (i.e. non-extended) class.

This commit removes this inefficiency, but some syntax changes were
needed to achieve this. Projects using this features will need to make a
few changes:

In particular, the example below shows the old syntax to instantiate a
class with a trampoline:

class_<TrampolineClass>("MyClass")
    .alias<MyClass>()
    ....

This is what should be used now:

class_<MyClass, std::unique_ptr<MyClass, TrampolineClass>("MyClass")
    ....

Importantly, the trampoline class is now specified as the *third*
argument to the class_ template, and the alias<..>() call is gone. The
second argument with the unique pointer is simply the default holder
type used by pybind11.
2016-05-26 13:36:24 +02:00
Yung-Yu Chen
114bfeb762 pybind11::args should have been derived from tuple
args was derived from list, but cpp_function::dispatcher sends a tuple to it->impl (line #346 and #392 in pybind11.h).  As a result args::size() and args::operator[] don't work at all.  On my mac args::size() returns -1.  Making args a subclass of tuple fixes it.
2016-05-25 21:09:35 +08:00
Wenzel Jakob
1e3be73a52 PYBIND11_OVERLOAD_NAME and PYBIND11_OVERLOAD_PURE_NAME (fixes #205) 2016-05-24 23:42:14 +02:00
Andreas Bergmeier
2dd215711a Fixed expected test examples for more verbose error output. 2016-05-24 10:15:43 +02:00
Dean Moldovan
8c6b0b8333 Don't build tests when project is used via add_subdirectory 2016-05-23 00:12:37 +02:00
Wenzel Jakob
43b09af3a9 example12 clarifications 2016-05-21 01:11:11 +02:00
Wenzel Jakob
b47a9de035 ability to prevent force casts in numpy arguments 2016-05-19 16:02:09 +02:00
Wenzel Jakob
3f200fab22 don't implicitly convert doubles to ints 2016-05-17 15:35:29 +02:00
Wenzel Jakob
00c7d6ccc7 Merge branch 'stl_bind' 2016-05-16 12:33:20 +02:00
Wenzel Jakob
25c03cecfa stl_bind redesign & cleanup pass 2016-05-16 12:12:58 +02:00
Sergey Lyskov
9ee4f92b06 Refactoring vector_binder so it now a function 2016-05-15 20:46:07 +02:00
Sergey Lyskov
a95bde1ea5 Adding documentation for value_error. Fixing various formatting issues. Removing redundant binding for C++ style methods. Adding bindings for iterator and slicing protocol. Extending examples. 2016-05-15 20:46:07 +02:00
Sergey Lyskov
a315c7a25a Adding Python-style modifiers for vector. Wrapping has_insertion_operator_implementation in _MSC_VER ifdef’s. Adding ‘!=0’ instead of bool cast’s. 2016-05-15 20:46:07 +02:00