Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py systems: Bind OutputPort.Allocate(), DiagramBuilder.empty(), .GetMutableSystems() #13270

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bindings/pydrake/systems/framework_py_semantics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ void DefineFrameworkPySemantics(py::module m) {
"as a BasicVector. Most users should call Eval() instead. "
"This method is only needed when the result will be passed "
"into some other API that only accepts a BasicVector.",
py_reference_internal);
py_reference_internal)
.def("Allocate", &OutputPort<T>::Allocate, doc.OutputPort.Allocate.doc);

auto system_output = DefineTemplateClassWithDefault<SystemOutput<T>>(
m, "SystemOutput", GetPyParam<T>(), doc.SystemOutput.doc);
Expand Down
4 changes: 3 additions & 1 deletion bindings/pydrake/systems/test/general_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def test_system_base_api(self):
self.assertEqual(u1.get_index(), 1)
self.assertEqual(u1.size(), 10)
self.assertIsNotNone(u1.ticket())
self.assertEqual(system.GetOutputPort("sum").get_index(), 0)
y = system.GetOutputPort("sum")
self.assertEqual(y.get_index(), 0)
self.assertIsInstance(y.Allocate(), Value[BasicVector])
# TODO(eric.cousineau): Consolidate the main API tests for `System`
# to this test point.

Expand Down