mirror of https://github.com/m-labs/artiq.git
use short exception raise syntax in kernels
This commit is contained in:
parent
205b08a343
commit
e292233186
|
@ -111,7 +111,7 @@ class Fastino:
|
||||||
:param addr: Address to read from.
|
:param addr: Address to read from.
|
||||||
:return: The data read.
|
:return: The data read.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
# rtio_output(self.channel | addr | 0x80)
|
# rtio_output(self.channel | addr | 0x80)
|
||||||
# return rtio_input_data(self.channel >> 8)
|
# return rtio_input_data(self.channel >> 8)
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,12 @@ class Grabber:
|
||||||
if timestamp == int64(-1):
|
if timestamp == int64(-1):
|
||||||
raise GrabberTimeoutException("Timeout before Grabber frame available")
|
raise GrabberTimeoutException("Timeout before Grabber frame available")
|
||||||
if sentinel != self.sentinel:
|
if sentinel != self.sentinel:
|
||||||
raise OutOfSyncException()
|
raise OutOfSyncException
|
||||||
|
|
||||||
for i in range(len(data)):
|
for i in range(len(data)):
|
||||||
timestamp, roi_output = rtio_input_timestamped_data(timeout_mu, channel)
|
timestamp, roi_output = rtio_input_timestamped_data(timeout_mu, channel)
|
||||||
if roi_output == self.sentinel:
|
if roi_output == self.sentinel:
|
||||||
raise OutOfSyncException()
|
raise OutOfSyncException
|
||||||
if timestamp == int64(-1):
|
if timestamp == int64(-1):
|
||||||
raise GrabberTimeoutException(
|
raise GrabberTimeoutException(
|
||||||
"Timeout retrieving ROIs (attempting to read more ROIs than enabled?)")
|
"Timeout retrieving ROIs (attempting to read more ROIs than enabled?)")
|
||||||
|
|
|
@ -81,6 +81,6 @@ class TDR(EnvExperiment):
|
||||||
for i in range(len(self.t)):
|
for i in range(len(self.t)):
|
||||||
ti = self.ttl3.timestamp_mu(now_mu())
|
ti = self.ttl3.timestamp_mu(now_mu())
|
||||||
if ti <= int64(0):
|
if ti <= int64(0):
|
||||||
raise PulseNotReceivedError()
|
raise PulseNotReceivedError
|
||||||
self.t[i] = int32(int64(self.t[i]) + ti - t0)
|
self.t[i] = int32(int64(self.t[i]) + ti - t0)
|
||||||
self.ttl3.count(now_mu()) # flush
|
self.ttl3.count(now_mu()) # flush
|
||||||
|
|
|
@ -689,7 +689,7 @@ class SinaraTester(EnvExperiment):
|
||||||
window=0x000, profiles=[1 for _ in range(len(osc))])
|
window=0x000, profiles=[1 for _ in range(len(osc))])
|
||||||
self.core.delay(1.*ms)
|
self.core.delay(1.*ms)
|
||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def phaser_led_wave(self, phasers: list[Phaser]):
|
def phaser_led_wave(self, phasers: list[Phaser]):
|
||||||
|
|
|
@ -138,7 +138,7 @@ class Option(Generic[T]):
|
||||||
|
|
||||||
def unwrap(self):
|
def unwrap(self):
|
||||||
if self.is_none():
|
if self.is_none():
|
||||||
raise UnwrapNoneError()
|
raise UnwrapNoneError
|
||||||
return self._nac3_option
|
return self._nac3_option
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
|
|
@ -140,7 +140,7 @@ class _NestedFinally(EnvExperiment):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
raise IndexError()
|
raise IndexError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._trace(0)
|
self._trace(0)
|
||||||
except:
|
except:
|
||||||
|
@ -166,7 +166,7 @@ class _NestedExceptions(EnvExperiment):
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
raise IndexError()
|
raise IndexError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._trace(1)
|
self._trace(1)
|
||||||
raise
|
raise
|
||||||
|
@ -212,7 +212,7 @@ class _Exceptions(EnvExperiment):
|
||||||
if i == 1:
|
if i == 1:
|
||||||
raise _MyException()
|
raise _MyException()
|
||||||
elif i == 2:
|
elif i == 2:
|
||||||
raise IndexError()
|
raise IndexError
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self._trace(101)
|
self._trace(101)
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -72,7 +72,7 @@ class RTT(EnvExperiment):
|
||||||
self.ttl_inout.pulse(1*us)
|
self.ttl_inout.pulse(1*us)
|
||||||
t1 = self.ttl_inout.timestamp_mu(now_mu())
|
t1 = self.ttl_inout.timestamp_mu(now_mu())
|
||||||
if t1 < 0:
|
if t1 < 0:
|
||||||
raise PulseNotReceived()
|
raise PulseNotReceived
|
||||||
self.set_dataset("rtt", self.core.mu_to_seconds(t1 - t0))
|
self.set_dataset("rtt", self.core.mu_to_seconds(t1 - t0))
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class Loopback(EnvExperiment):
|
||||||
self.loop_out.pulse(1*us)
|
self.loop_out.pulse(1*us)
|
||||||
t1 = self.loop_in.timestamp_mu(now_mu())
|
t1 = self.loop_in.timestamp_mu(now_mu())
|
||||||
if t1 < 0:
|
if t1 < 0:
|
||||||
raise PulseNotReceived()
|
raise PulseNotReceived
|
||||||
self.set_dataset("rtt", self.core.mu_to_seconds(t1 - t0))
|
self.set_dataset("rtt", self.core.mu_to_seconds(t1 - t0))
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ class LoopbackGateTiming(EnvExperiment):
|
||||||
in_mu = self.loop_in.timestamp_mu(gate_end_mu)
|
in_mu = self.loop_in.timestamp_mu(gate_end_mu)
|
||||||
print("timings: ", gate_start_mu, in_mu - lat_offset, gate_end_mu)
|
print("timings: ", gate_start_mu, in_mu - lat_offset, gate_end_mu)
|
||||||
if in_mu < 0:
|
if in_mu < 0:
|
||||||
raise PulseNotReceived()
|
raise PulseNotReceived
|
||||||
if not (gate_start_mu <= (in_mu - lat_offset) <= gate_end_mu):
|
if not (gate_start_mu <= (in_mu - lat_offset) <= gate_end_mu):
|
||||||
raise IncorrectPulseTiming("Input event should occur during gate")
|
raise IncorrectPulseTiming("Input event should occur during gate")
|
||||||
if not (-2 < (in_mu - out_mu - loop_delay_mu) < 2):
|
if not (-2 < (in_mu - out_mu - loop_delay_mu) < 2):
|
||||||
|
@ -433,7 +433,7 @@ class HandoverException(EnvExperiment):
|
||||||
def k(self, var):
|
def k(self, var):
|
||||||
self.set_dataset(var, now_mu())
|
self.set_dataset(var, now_mu())
|
||||||
delay_mu(1234)
|
delay_mu(1234)
|
||||||
raise DummyException()
|
raise DummyException
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue