Skip to content

Commit

Permalink
pydrake: Revert some bindings of State accessors
Browse files Browse the repository at this point in the history
Under Xenial GCC 5.4 + Python2 + --compilation_mode=dbg only, the
//bindings/pydrake/systems:py/custom_test has about 75% failure rate
when pydrake.systems.framework.State has too many methods bound.

We'll need to root cause this further, but for now this repairs CI,
while stopping short of a full revert.
  • Loading branch information
jwnimmer-tri committed May 9, 2019
1 parent 78f9f4b commit 8883716
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 31 deletions.
25 changes: 1 addition & 24 deletions bindings/pydrake/systems/framework_py_semantics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,16 +641,6 @@ void DefineFrameworkPySemantics(py::module m) {
overload_cast_explicit<DiscreteValues<T>&>(
&State<T>::get_mutable_discrete_state),
py_reference_internal, doc.State.get_mutable_discrete_state.doc)
.def("get_discrete_state",
overload_cast_explicit<const BasicVector<T>&, int>(
&State<T>::get_discrete_state),
py::arg("index"), py_reference_internal,
doc.State.get_discrete_state.doc)
.def("get_mutable_discrete_state",
overload_cast_explicit<BasicVector<T>&, int>(
&State<T>::get_mutable_discrete_state),
py::arg("index"), py_reference_internal,
doc.State.get_mutable_discrete_state.doc)
.def("get_abstract_state",
static_cast<const AbstractValues& (State<T>::*)() const>(
&State<T>::get_abstract_state),
Expand All @@ -659,20 +649,7 @@ void DefineFrameworkPySemantics(py::module m) {
[](State<T>* self) -> AbstractValues& {
return self->get_mutable_abstract_state();
},
py_reference_internal, doc.State.get_mutable_abstract_state.doc)
.def("get_abstract_state",
[](const State<T>* self, int index) -> auto& {
return self->get_abstract_state().get_value(index);
},
py::arg("index"), py_reference_internal,
doc.State.get_abstract_state.doc)
.def("get_mutable_abstract_state",
[](State<T>* self, int index) -> AbstractValue& {
return self->get_mutable_abstract_state().get_mutable_value(
index);
},
py::arg("index"), py_reference_internal,
doc.State.get_mutable_abstract_state.doc);
py_reference_internal, doc.State.get_mutable_abstract_state.doc);

// - Constituents.
DefineTemplateClassWithDefault<ContinuousState<T>>(
Expand Down
9 changes: 2 additions & 7 deletions bindings/pydrake/systems/test/general_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,17 @@ def check_abstract_value_zero(context, expected_value):
expected_value)
self.assertEqual(context.get_abstract_state().get_value(
index=0).get_value(), expected_value)
self.assertEqual(context.get_state().get_abstract_state(
index=0).get_value(), expected_value)
self.assertEqual(context.get_state().get_abstract_state()
.get_value(index=0).get_value(), expected_value)

context.SetAbstractState(index=0, value=True)
check_abstract_value_zero(context, True)
context.SetAbstractState(index=0, value=False)
check_abstract_value_zero(context, False)
value = context.get_mutable_state().get_mutable_abstract_state(index=0)
value.set_value(True)
check_abstract_value_zero(context, True)
value = context.get_mutable_state().get_mutable_abstract_state()\
.get_mutable_value(index=0)
value.set_value(False)
check_abstract_value_zero(context, False)
value.set_value(True)
check_abstract_value_zero(context, True)

def test_event_api(self):
# TriggerType - existence check.
Expand Down

0 comments on commit 8883716

Please sign in to comment.