def test_state_output_port_declarations(self): """Checks that DeclareStateOutputPort is bound.""" dut = LeafSystem() xc_index = dut.DeclareContinuousState(2) xc_port = dut.DeclareStateOutputPort(name="xc", state_index=xc_index) self.assertEqual(xc_port.size(), 2) xd_index = dut.DeclareDiscreteState(3) xd_port = dut.DeclareStateOutputPort(name="xd", state_index=xd_index) self.assertEqual(xd_port.size(), 3) xa_index = dut.DeclareAbstractState(AbstractValue.Make(1)) xa_port = dut.DeclareStateOutputPort(name="xa", state_index=xa_index) self.assertEqual(xa_port.get_name(), "xa")
def test_leaf_system_per_item_tickets(self): dut = LeafSystem() dut.DeclareAbstractParameter(AbstractValue.Make(1)) dut.DeclareAbstractState(AbstractValue.Make(1)) dut.DeclareDiscreteState(1) dut.DeclareVectorInputPort("u0", BasicVector(1)) dut.DeclareNumericParameter(BasicVector(1)) for func, arg in [ (dut.abstract_parameter_ticket, AbstractParameterIndex(0)), (dut.abstract_state_ticket, AbstractStateIndex(0)), (dut.cache_entry_ticket, CacheIndex(0)), (dut.discrete_state_ticket, DiscreteStateIndex(0)), (dut.input_port_ticket, InputPortIndex(0)), (dut.numeric_parameter_ticket, NumericParameterIndex(0)), ]: self.assertIsInstance(func(arg), DependencyTicket, func)