Example #1
0
 def test_optimize(self):
     dmgr = dict()
     dmgr["comm"] = comm_dummy.Comm(dmgr)
     coredev = core.Core(dmgr, ref_period=1*ns)
     func_def = ast.parse(optimize_in).body[0]
     coredev.transform_stack(func_def, dict(), dict())
     self.assertEqual(unparse(func_def), optimize_out)
Example #2
0
def _run_on_device(k_class, **parameters):
    comm = comm_serial.Comm()
    try:
        coredev = core.Core(comm=comm)
        k_inst = k_class(core=coredev, **parameters)
        k_inst.run()
    finally:
        comm.close()
Example #3
0
 def test_sequence_error(self):
     comm = comm_serial.Comm()
     try:
         coredev = core.Core(comm=comm)
         uut = _RTIOSequenceError(core=coredev,
                                  o=rtio.RTIOOut(core=coredev, channel=2))
         with self.assertRaises(runtime_exceptions.RTIOSequenceError):
             uut.run()
     finally:
         comm.close()
Example #4
0
 def test_underflow(self):
     comm = comm_serial.Comm()
     try:
         coredev = core.Core(comm=comm)
         uut = _RTIOUnderflow(core=coredev,
                              o=rtio.RTIOOut(core=coredev, channel=2))
         with self.assertRaises(runtime_exceptions.RTIOUnderflow):
             uut.run()
     finally:
         comm.close()
Example #5
0
 def test_rpc_exceptions(self):
     comm = comm_serial.Comm()
     try:
         uut = _RPCExceptions(core=core.Core(comm=comm))
         with self.assertRaises(_MyException):
             uut.do_not_catch()
         uut.catch()
         self.assertTrue(uut.success)
     finally:
         comm.close()
Example #6
0
 def test_loopback(self):
     npulses = 4
     comm = comm_serial.Comm()
     try:
         coredev = core.Core(comm=comm)
         uut = _RTIOLoopback(core=coredev,
                             i=rtio.RTIOIn(core=coredev, channel=0),
                             o=rtio.RTIOOut(core=coredev, channel=2),
                             npulses=npulses)
         uut.run()
         self.assertEqual(uut.result, npulses)
     finally:
         comm.close()
Example #7
0
 def test_misc(self):
     comm = comm_serial.Comm()
     try:
         coredev = core.Core(comm=comm)
         uut = _Misc(core=coredev)
         uut.run()
         self.assertEqual(uut.half_input, 42)
         self.assertEqual(uut.decimal_fraction, Fraction("1.2"))
         self.assertEqual(uut.inhomogeneous_units, [1000 * Hz, 10 * s])
         self.assertEqual(uut.acc, sum(uut.al))
         self.assertEqual(uut.list_copy_in, uut.list_copy_out)
         self.assertEqual(uut.unit_comp, [1 * MHz for _ in range(3)])
         with self.assertRaises(DimensionError):
             uut.dimension_error1()
         with self.assertRaises(DimensionError):
             uut.dimension_error2()
         with self.assertRaises(DimensionError):
             uut.dimension_error3()
         with self.assertRaises(DimensionError):
             uut.dimension_error4()
     finally:
         comm.close()
Example #8
0
 def test_optimize(self):
     coredev = core.Core(comm=comm_dummy.Comm())
     func_def = ast.parse(optimize_in).body[0]
     coredev.transform_stack(func_def, dict(), dict())
     self.assertEqual(unparse(func_def), optimize_out)