Skip to content

Commit

Permalink
A few breaking changes for consistency just before the 1.0 release
Browse files Browse the repository at this point in the history
1. Renamed PYTHON_* to PYBIND_* everywhere

2. Renamed pybind::array_dtype<> to pybind::array_t<>
  • Loading branch information
Wenzel Jakob committed Oct 13, 2015
1 parent 19208fe commit b50872a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void init_ex10(py::module &);
void init_ex11(py::module &);
void init_ex12(py::module &);

PYTHON_PLUGIN(example) {
PYBIND_PLUGIN(example) {
py::module m("example", "pybind example plugin");

init_ex1(m);
Expand Down
2 changes: 1 addition & 1 deletion example/example10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void init_ex10(py::module &m) {

// Vectorize a lambda function with a capture object (e.g. to exclude some arguments from the vectorization)
m.def("vectorized_func2",
[](py::array_dtype<int> x, py::array_dtype<float> y, float z) {
[](py::array_t<int> x, py::array_t<float> y, float z) {
return py::vectorize([z](int x, float y) { return my_func(x, y, z); })(x, y);
}
);
Expand Down
14 changes: 7 additions & 7 deletions include/pybind/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#define NAMESPACE_END(name) }
#endif

#if !defined(PYTHON_EXPORT)
#if !defined(PYBIND_EXPORT)
#if defined(WIN32) || defined(_WIN32)
#define PYTHON_EXPORT __declspec(dllexport)
#define PYBIND_EXPORT __declspec(dllexport)
#else
#define PYTHON_EXPORT __attribute__ ((visibility("default")))
#define PYBIND_EXPORT __attribute__ ((visibility("default")))
#endif
#endif

Expand Down Expand Up @@ -61,11 +61,11 @@
#endif

#if PY_MAJOR_VERSION >= 3
#define PYTHON_PLUGIN(name) \
extern "C" PYTHON_EXPORT PyObject *PyInit_##name()
#define PYBIND_PLUGIN(name) \
extern "C" PYBIND_EXPORT PyObject *PyInit_##name()
#else
#define PYTHON_PLUGIN(name) \
extern "C" PYTHON_EXPORT PyObject *init##name()
#define PYBIND_PLUGIN(name) \
extern "C" PYBIND_EXPORT PyObject *init##name()
#endif

NAMESPACE_BEGIN(pybind)
Expand Down
26 changes: 13 additions & 13 deletions include/pybind/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class array : public buffer {
}
};

template <typename T> class array_dtype : public array {
template <typename T> class array_t : public array {
public:
PYBIND_OBJECT_CVT(array_dtype, array, is_non_null, m_ptr = ensure(m_ptr));
array_dtype() : array() { }
PYBIND_OBJECT_CVT(array_t, array, is_non_null, m_ptr = ensure(m_ptr));
array_t() : array() { }
static bool is_non_null(PyObject *ptr) { return ptr != nullptr; }
PyObject *ensure(PyObject *ptr) {
if (ptr == nullptr)
Expand All @@ -151,14 +151,14 @@ DECL_FMT(std::complex<double>, NPY_CDOUBLE);

NAMESPACE_BEGIN(detail)
PYBIND_TYPE_CASTER_PYTYPE(array)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<int8_t>) PYBIND_TYPE_CASTER_PYTYPE(array_dtype<uint8_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<int16_t>) PYBIND_TYPE_CASTER_PYTYPE(array_dtype<uint16_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<int32_t>) PYBIND_TYPE_CASTER_PYTYPE(array_dtype<uint32_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<int64_t>) PYBIND_TYPE_CASTER_PYTYPE(array_dtype<uint64_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<float>) PYBIND_TYPE_CASTER_PYTYPE(array_dtype<double>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<std::complex<float>>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<std::complex<double>>)
PYBIND_TYPE_CASTER_PYTYPE(array_dtype<bool>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<int8_t>) PYBIND_TYPE_CASTER_PYTYPE(array_t<uint8_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<int16_t>) PYBIND_TYPE_CASTER_PYTYPE(array_t<uint16_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<int32_t>) PYBIND_TYPE_CASTER_PYTYPE(array_t<uint32_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<int64_t>) PYBIND_TYPE_CASTER_PYTYPE(array_t<uint64_t>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<float>) PYBIND_TYPE_CASTER_PYTYPE(array_t<double>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<std::complex<float>>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<std::complex<double>>)
PYBIND_TYPE_CASTER_PYTYPE(array_t<bool>)

template <typename Func, typename Return, typename... Args>
struct vectorize_helper {
Expand All @@ -167,11 +167,11 @@ struct vectorize_helper {
template <typename T>
vectorize_helper(T&&f) : f(std::forward<T>(f)) { }

object operator()(array_dtype<Args>... args) {
object operator()(array_t<Args>... args) {
return run(args..., typename make_index_sequence<sizeof...(Args)>::type());
}

template <size_t ... Index> object run(array_dtype<Args>&... args, index_sequence<Index...>) {
template <size_t ... Index> object run(array_t<Args>&... args, index_sequence<Index...>) {
/* Request buffers from all parameters */
const size_t N = sizeof...(Args);
std::array<buffer_info, N> buffers {{ args.request()... }};
Expand Down

0 comments on commit b50872a

Please sign in to comment.