28struct type_caster<xt::xarray<T>> {
30 PYBIND11_TYPE_CASTER(xt::xarray<T>, const_name(
"xarray"));
31 static handle cast(xt::xarray<T> &src, return_value_policy, handle) {
32 auto v = py::array(src.size(), src.data(), py::capsule([]() {}));
33 v.resize(src.shape());
40struct type_caster<E> {
41 using value_type =
typename E::value_type;
42 using array_type = xt::xarray<value_type>;
44 PYBIND11_TYPE_CASTER(array_type, _(
"xexpression"));
45 static handle cast(
const E &expr, return_value_policy, handle) {
46 xt::xarray<value_type> tmp = xt::eval(expr);
47 auto *data_holder =
new xt::xarray<double>(std::move(tmp));
48 py::capsule owner_capsule(data_holder,
49 [](
void *p) {
delete static_cast<xt::xarray<value_type> *
>(p); });
50 py::array result(data_holder->shape(), data_holder->data(), owner_capsule);
51 return result.release();
89class PYBIND11_EXPORT AxesSubPlot {
91 explicit AxesSubPlot(py::object axes) : m_obj(std::move(axes)) {}
93 DEFINE_PY_CLASS_METHOD_AUTO(scatter)
94 DEFINE_PY_CLASS_METHOD_AUTO(triplot)
95 DEFINE_PY_CLASS_METHOD_AUTO(plot)
96 DEFINE_PY_CLASS_METHOD_AUTO(text)
97 DEFINE_PY_CLASS_METHOD_AUTO(set_xlabel)
98 DEFINE_PY_CLASS_METHOD_AUTO(set_ylabel)
99 DEFINE_PY_CLASS_METHOD_AUTO(set_zlabel)
100 DEFINE_PY_CLASS_METHOD_AUTO(set_title)
101 DEFINE_PY_CLASS_METHOD_AUTO(grid)
102 DEFINE_PY_CLASS_METHOD_AUTO(legend)
103 DEFINE_PY_CLASS_METHOD_AUTO(set_xlim)
104 DEFINE_PY_CLASS_METHOD_AUTO(set_ylim)
105 DEFINE_PY_CLASS_METHOD_AUTO(set_zlim)