def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertIsInstance(system, SystemBase)
     self.assertEqual(
         system.GetSystemType(),
         "drake::systems::Adder<double>")
     system.set_name(name="adder")
     self.assertEqual(system.get_name(), "adder")
     self.assertEqual(system.GetSystemName(), "adder")
     self.assertEqual(system.GetSystemPathname(), "::adder")
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     u1 = system.GetInputPort("u1")
     self.assertEqual(u1.get_name(), "u1")
     self.assertIn("u1", u1.GetFullDescription())
     self.assertEqual(u1.get_index(), 1)
     self.assertEqual(u1.size(), 10)
     self.assertIsNotNone(u1.ticket())
     self.assertIs(u1.get_system(), system)
     y = system.GetOutputPort("sum")
     self.assertEqual(y.get_name(), "sum")
     self.assertEqual(y.get_index(), 0)
     self.assertIsInstance(y.Allocate(), Value[BasicVector])
     self.assertIs(y.get_system(), system)
     y.disable_caching_by_default()
     self.assertEqual(y, system.get_output_port())
示例#2
0
 def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     self.assertEqual(system.GetInputPort("u1").get_index(), 1)
     self.assertEqual(system.GetOutputPort("sum").get_index(), 0)
示例#3
0
 def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     u1 = system.GetInputPort("u1")
     self.assertEqual(u1.get_name(), "u1")
     self.assertIn("u1", u1.GetFullDescription())
     self.assertEqual(u1.get_index(), 1)
     self.assertEqual(u1.size(), 10)
     self.assertIsNotNone(u1.ticket())
     self.assertEqual(system.GetOutputPort("sum").get_index(), 0)
示例#4
0
 def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     u1 = system.GetInputPort("u1")
     self.assertEqual(u1.get_name(), "u1")
     self.assertIn("u1", u1.GetFullDescription())
     self.assertEqual(u1.get_index(), 1)
     self.assertEqual(u1.size(), 10)
     self.assertIsNotNone(u1.ticket())
     self.assertEqual(system.GetOutputPort("sum").get_index(), 0)
示例#5
0
 def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertEqual(
         system.GetSystemType(),
         "drake::systems::Adder<double>")
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     u1 = system.GetInputPort("u1")
     self.assertEqual(u1.get_name(), "u1")
     self.assertIn("u1", u1.GetFullDescription())
     self.assertEqual(u1.get_index(), 1)
     self.assertEqual(u1.size(), 10)
     self.assertIsNotNone(u1.ticket())
     y = system.GetOutputPort("sum")
     self.assertEqual(y.get_index(), 0)
     self.assertIsInstance(y.Allocate(), Value[BasicVector])