forked from M-Labs/artiq
1
0
Fork 0

use short exception raise syntax in kernels

This commit is contained in:
Sebastien Bourdeauducq 2024-07-12 13:06:09 +02:00
parent 205b08a343
commit e292233186
7 changed files with 13 additions and 13 deletions

View File

@ -111,7 +111,7 @@ class Fastino:
:param addr: Address to read from.
:return: The data read.
"""
raise NotImplementedError()
raise NotImplementedError
# rtio_output(self.channel | addr | 0x80)
# return rtio_input_data(self.channel >> 8)

View File

@ -118,12 +118,12 @@ class Grabber:
if timestamp == int64(-1):
raise GrabberTimeoutException("Timeout before Grabber frame available")
if sentinel != self.sentinel:
raise OutOfSyncException()
raise OutOfSyncException
for i in range(len(data)):
timestamp, roi_output = rtio_input_timestamped_data(timeout_mu, channel)
if roi_output == self.sentinel:
raise OutOfSyncException()
raise OutOfSyncException
if timestamp == int64(-1):
raise GrabberTimeoutException(
"Timeout retrieving ROIs (attempting to read more ROIs than enabled?)")

View File

@ -81,6 +81,6 @@ class TDR(EnvExperiment):
for i in range(len(self.t)):
ti = self.ttl3.timestamp_mu(now_mu())
if ti <= int64(0):
raise PulseNotReceivedError()
raise PulseNotReceivedError
self.t[i] = int32(int64(self.t[i]) + ti - t0)
self.ttl3.count(now_mu()) # flush

View File

@ -689,7 +689,7 @@ class SinaraTester(EnvExperiment):
window=0x000, profiles=[1 for _ in range(len(osc))])
self.core.delay(1.*ms)
else:
raise ValueError()
raise ValueError
@kernel
def phaser_led_wave(self, phasers: list[Phaser]):

View File

@ -138,7 +138,7 @@ class Option(Generic[T]):
def unwrap(self):
if self.is_none():
raise UnwrapNoneError()
raise UnwrapNoneError
return self._nac3_option
def __repr__(self) -> str:

View File

@ -140,7 +140,7 @@ class _NestedFinally(EnvExperiment):
raise ValueError
finally:
try:
raise IndexError()
raise IndexError
except ValueError:
self._trace(0)
except:
@ -166,7 +166,7 @@ class _NestedExceptions(EnvExperiment):
raise
finally:
try:
raise IndexError()
raise IndexError
except ValueError:
self._trace(1)
raise
@ -212,7 +212,7 @@ class _Exceptions(EnvExperiment):
if i == 1:
raise _MyException()
elif i == 2:
raise IndexError()
raise IndexError
except IndexError:
self._trace(101)
raise

View File

@ -72,7 +72,7 @@ class RTT(EnvExperiment):
self.ttl_inout.pulse(1*us)
t1 = self.ttl_inout.timestamp_mu(now_mu())
if t1 < 0:
raise PulseNotReceived()
raise PulseNotReceived
self.set_dataset("rtt", self.core.mu_to_seconds(t1 - t0))
@ -96,7 +96,7 @@ class Loopback(EnvExperiment):
self.loop_out.pulse(1*us)
t1 = self.loop_in.timestamp_mu(now_mu())
if t1 < 0:
raise PulseNotReceived()
raise PulseNotReceived
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)
print("timings: ", gate_start_mu, in_mu - lat_offset, gate_end_mu)
if in_mu < 0:
raise PulseNotReceived()
raise PulseNotReceived
if not (gate_start_mu <= (in_mu - lat_offset) <= gate_end_mu):
raise IncorrectPulseTiming("Input event should occur during gate")
if not (-2 < (in_mu - out_mu - loop_delay_mu) < 2):
@ -433,7 +433,7 @@ class HandoverException(EnvExperiment):
def k(self, var):
self.set_dataset(var, now_mu())
delay_mu(1234)
raise DummyException()
raise DummyException
def run(self):
try: