Skip to content

From Boost.Python to PYBIND11 #5

Closed
@sgwoodjr

Description

@sgwoodjr

Hi,
First off, great job on the library. It looks very promising.

Now to my question. I have a set of functions where each one returns a custom container class called vec. Below is an example wrapper using boost.python with num_util by Phil Austin. Basically num_util takes an iterator and returns a numpy array.

How would I achieve the same results using pybind11?

namespace nbpl = num_util;
namespace bp = boost::python;

bpn::array mybartlett(int L)
{
    // This is a call to my custom function that returns a custom vector
    vec w = bartlett(L);

    // This copies the data in w into the numpy array out
    bpn::array out = nbpl::makeNum(w.begin(), w.size());

    return out;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions