Skip to content

Commit

Permalink
DNM Currently broken...
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Jan 29, 2019
1 parent f9c57b7 commit 4ef7baf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions bindings/pybind11_ext/numpy_dtypes_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,16 @@ class dtype_user : public object {
}

/// Defines a constructor.
template <typename ... Args>
template <typename ... Args, typename ... Extra>
dtype_user& def(
detail::initimpl::constructor<Args...>&&, const char* doc = "") {
detail::initimpl::constructor<Args...>&&, Extra&&... extra) {
// See notes in `add_init`.
// N.B. Do NOT use `Class*` as the argument, since that may incur recursion.
add_init([](object py_self, Args... args) {
// Old-style. No factories for now.
Class* self = DTypePyObject::load_raw(py_self.ptr());
new (self) Class(std::forward<Args>(args)...);
}, doc);
}, detail::type_pack<Args...>{}, std::forward<Extra>(extra)...);
return *this;
}

Expand Down Expand Up @@ -607,8 +607,8 @@ class dtype_user : public object {
}

// Adds constructor. See comments within for explanation.
template <typename Func>
void add_init(Func&& f, const char* doc) {
template <typename Func, typename... Extra, typename... Args>
void add_init(Func&& f, detail::type_pack<Args...>, Extra&&... extra) {
// Do not construct this with the name `__init__` as `pybind11`s
// constructor implementations via `cpp_function` are rigidly fixed to
// its instance registration system (which we don't want).
Expand All @@ -620,10 +620,10 @@ class dtype_user : public object {
if (!d.contains("__init__")) {
auto init = self().attr("_dtype_init");
auto func = cpp_function(
[init](handle self, args args, kwargs kwargs) {
[init](handle self, Args... args) {
// Dispatch.
init(self, *args, **kwargs);
}, is_method(self()), doc);
init(self, std::forward<Args>(args)...);
}, is_method(self()), std::forward<Extra>(extra)...);
self().attr("__init__") = func;
}
}
Expand Down
7 changes: 4 additions & 3 deletions bindings/pydrake/symbolic_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ PYBIND11_MODULE(symbolic, m) {
var_doc.Type.RANDOM_EXPONENTIAL.doc);

var_cls
.def(py::init<const string&, Variable::Type>(), py::arg("name"),
py::arg("type") = Variable::Type::CONTINUOUS, var_doc.ctor.doc_2args)
.def(py::init<const string&, Variable::Type>(),
py::arg("name"), py::arg("type") = Variable::Type::CONTINUOUS,
var_doc.ctor.doc_2args)
.def("get_id", &Variable::get_id, var_doc.get_id.doc)
.def("get_type", &Variable::get_type, var_doc.get_type.doc)
.def("__str__", &Variable::to_string, var_doc.to_string.doc)
Expand Down Expand Up @@ -209,7 +210,7 @@ PYBIND11_MODULE(symbolic, m) {
expr_cls // BR
.def(py::init<>(), doc.Expression.ctor.doc_0args)
.def(py::init<double>(), doc.Expression.ctor.doc_1args_d)
.def(py::init<const Variable&>(), doc.Expression.ctor.doc_copy)
.def(py::init<const Variable&>(), doc.Expression.ctor.doc_1args_var)
// Casting
.def_loop(py::dtype_method::implicit_conversion<Variable, Expression>())
// Methods
Expand Down

0 comments on commit 4ef7baf

Please sign in to comment.