|
4 | 4 | from fractions import Fraction
|
5 | 5 |
|
6 | 6 | from artiq import *
|
7 |
| -from artiq.language.units import * |
| 7 | +from artiq.language.units import DimensionError |
8 | 8 | from artiq.coredevice import comm_serial, core, runtime_exceptions, rtio
|
9 | 9 | from artiq.sim import devices as sim_devices
|
10 | 10 |
|
@@ -51,18 +51,19 @@ def build(self):
|
51 | 51 | self.input = 84
|
52 | 52 | self.inhomogeneous_units = []
|
53 | 53 | self.al = [1, 2, 3, 4, 5]
|
| 54 | + self.list_copy_in = [2*Hz, 10*MHz] |
54 | 55 |
|
55 | 56 | @kernel
|
56 | 57 | def run(self):
|
57 | 58 | self.half_input = self.input//2
|
58 |
| - decimal_fraction = Fraction("1.2") |
59 |
| - self.decimal_fraction_n = int(decimal_fraction.numerator) |
60 |
| - self.decimal_fraction_d = int(decimal_fraction.denominator) |
61 |
| - self.inhomogeneous_units.append(Quantity(1000, "Hz")) |
62 |
| - self.inhomogeneous_units.append(Quantity(10, "s")) |
| 59 | + self.decimal_fraction = Fraction("1.2") |
| 60 | + self.inhomogeneous_units.append(1000*Hz) |
| 61 | + self.inhomogeneous_units.append(10*s) |
63 | 62 | self.acc = 0
|
64 | 63 | for i in range(len(self.al)):
|
65 | 64 | self.acc += self.al[i]
|
| 65 | + self.list_copy_out = self.list_copy_in |
| 66 | + self.unit_comp = [1*MHz for _ in range(3)] |
66 | 67 |
|
67 | 68 | @kernel
|
68 | 69 | def dimension_error1(self):
|
@@ -184,12 +185,11 @@ def test_misc(self):
|
184 | 185 | uut = _Misc(core=coredev)
|
185 | 186 | uut.run()
|
186 | 187 | self.assertEqual(uut.half_input, 42)
|
187 |
| - self.assertEqual(Fraction(uut.decimal_fraction_n, |
188 |
| - uut.decimal_fraction_d), |
189 |
| - Fraction("1.2")) |
190 |
| - self.assertEqual(uut.inhomogeneous_units, [ |
191 |
| - Quantity(1000, "Hz"), Quantity(10, "s")]) |
| 188 | + self.assertEqual(uut.decimal_fraction, Fraction("1.2")) |
| 189 | + self.assertEqual(uut.inhomogeneous_units, [1000*Hz, 10*s]) |
192 | 190 | self.assertEqual(uut.acc, sum(uut.al))
|
| 191 | + self.assertEqual(uut.list_copy_in, uut.list_copy_out) |
| 192 | + self.assertEqual(uut.unit_comp, [1*MHz for _ in range(3)]) |
193 | 193 | with self.assertRaises(DimensionError):
|
194 | 194 | uut.dimension_error1()
|
195 | 195 | with self.assertRaises(DimensionError):
|
|
0 commit comments