Skip to content

Commit

Permalink
Fix ambiguous capsule calls with pybind11 (#1887)
Browse files Browse the repository at this point in the history
* Fix ambiguous capsule calls with pybind11 - nullptr arg errors

I got multiple errors like this:
error: call of overloaded ‘capsule(std::__shared_ptr<tiledb_subarray_t, __gnu_cxx::_S_atomic>::element_type*, const char [9], std::nullptr_t)’ is ambiguous
when building fresh with latest pybind on ubuntu22, m6id.4xlarge ec2 machine.
  • Loading branch information
robertbindar authored Feb 14, 2024
1 parent 2cd7806 commit ca0ccd7
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 22 deletions.
7 changes: 3 additions & 4 deletions tiledb/cc/attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ void init_attribute(py::module &m) {

.def(py::init<const Context &, py::capsule>())

.def("__capsule__",
[](Attribute &attr) {
return py::capsule(attr.ptr().get(), "attr", nullptr);
})
.def(
"__capsule__",
[](Attribute &attr) { return py::capsule(attr.ptr().get(), "attr"); })

.def_property_readonly("_name", &Attribute::name)

Expand Down
10 changes: 3 additions & 7 deletions tiledb/cc/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ void init_context(py::module &m) {
.def(py::init<py::capsule, bool>())

.def("__capsule__",
[](Context &ctx) {
return py::capsule(ctx.ptr().get(), "ctx", nullptr);
})
[](Context &ctx) { return py::capsule(ctx.ptr().get(), "ctx"); })

.def("__capsule__",
[](Context &ctx) {
return py::capsule(ctx.ptr().get(), "ctx", nullptr);
})
[](Context &ctx) { return py::capsule(ctx.ptr().get(), "ctx"); })

.def("config", &Context::config)
.def("set_tag", &Context::set_tag)
Expand All @@ -42,7 +38,7 @@ void init_config(py::module &m) {

.def("__capsule__",
[](Config &config) {
return py::capsule(config.ptr().get(), "config", nullptr);
return py::capsule(config.ptr().get(), "config");
})

.def("set", &Config::set)
Expand Down
2 changes: 1 addition & 1 deletion tiledb/cc/dimension_label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void init_dimension_label(py::module &m) {

.def("__capsule__",
[](DimensionLabel &dim_label) {
return py::capsule(dim_label.ptr().get(), "dim_label", nullptr);
return py::capsule(dim_label.ptr().get(), "dim_label");
})

.def_property_readonly("_label_attr_name",
Expand Down
6 changes: 2 additions & 4 deletions tiledb/cc/domain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ void init_domain(py::module &m) {
.def(py::init<const Context &, py::capsule>())

.def("__capsule__",
[](Domain &dom) {
return py::capsule(dom.ptr().get(), "dom", nullptr);
})
[](Domain &dom) { return py::capsule(dom.ptr().get(), "dom"); })

.def_property_readonly("_ncell",
[](Domain &dom) { return dom.cell_num(); })
Expand All @@ -206,4 +204,4 @@ void init_domain(py::module &m) {
.def("_dump", [](Domain &dom) { dom.dump(); });
}

} // namespace libtiledbcpp
} // namespace libtiledbcpp
4 changes: 2 additions & 2 deletions tiledb/cc/enumeration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void init_enumeration(py::module &m) {

.def("__capsule__",
[](Enumeration &enmr) {
return py::capsule(enmr.ptr().get(), "enmr", nullptr);
return py::capsule(enmr.ptr().get(), "enmr");
})

.def_property_readonly("name", &Enumeration::name)
Expand Down Expand Up @@ -95,4 +95,4 @@ void init_enumeration(py::module &m) {
});
}

} // namespace libtiledbcpp
} // namespace libtiledbcpp
2 changes: 1 addition & 1 deletion tiledb/cc/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void init_filter(py::module &m) {

.def("__capsule__",
[](FilterList &filterlist) {
return py::capsule(filterlist.ptr().get(), "fl", nullptr);
return py::capsule(filterlist.ptr().get(), "fl");
})

.def_property("_chunksize", &FilterList::max_chunk_size,
Expand Down
2 changes: 1 addition & 1 deletion tiledb/cc/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void init_schema(py::module &m) {

.def("__capsule__",
[](ArraySchema &schema) {
return py::capsule(schema.ptr().get(), "schema", nullptr);
return py::capsule(schema.ptr().get(), "schema");
})

.def("_dump", &ArraySchema::dump)
Expand Down
2 changes: 1 addition & 1 deletion tiledb/cc/subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ void init_subarray(py::module &m) {

.def("__capsule__",
[](Subarray &subarray) {
return py::capsule(subarray.ptr().get(), "subarray", nullptr);
return py::capsule(subarray.ptr().get(), "subarray");
})

.def("_add_dim_range",
Expand Down
2 changes: 1 addition & 1 deletion tiledb/query_condition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PyQueryCondition {

shared_ptr<QueryCondition> ptr() { return qc_; }

py::capsule __capsule__() { return py::capsule(&qc_, "qc", nullptr); }
py::capsule __capsule__() { return py::capsule(&qc_, "qc"); }

void set_use_enumeration(bool use_enumeration) {
QueryConditionExperimental::set_use_enumeration(ctx_, *qc_,
Expand Down

0 comments on commit ca0ccd7

Please sign in to comment.