Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f85583481051
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0abd41a04a1d
Choose a head ref
  • 5 commits
  • 8 files changed
  • 1 contributor

Commits on Feb 27, 2015

  1. benchmarks: fix imports

    sbourdeauducq committed Feb 27, 2015
    Copy the full SHA
    14e481d View commit details
  2. Copy the full SHA
    ee9d616 View commit details
  3. Copy the full SHA
    61f33a9 View commit details
  4. Copy the full SHA
    3e46a36 View commit details
  5. Copy the full SHA
    0abd41a View commit details
3 changes: 1 addition & 2 deletions artiq/devices/lda/driver.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def get_attenuation(self):
return self._attenuation

def set_attenuation(self, attenuation):
"""Stores the new attenuation value and prints it to console.
"""Stores the new attenuation value.
:param attenuation: The attenuation value in dB.
"""
@@ -60,7 +60,6 @@ def set_attenuation(self, attenuation):
raise ValueError("Cannot set attenuation {} < 0".format(att))
else:
att = round(att.amount*4)/4. * dB
print("setting attenuation to {}".format(att))
self._attenuation = att

def ping(self):
10 changes: 5 additions & 5 deletions artiq/frontend/artiq_client.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
from artiq.protocols.pc_rpc import Client
from artiq.protocols.sync_struct import Subscriber
from artiq.protocols import pyon
from artiq.tools import format_run_arguments
from artiq.tools import format_arguments


def clear_screen():
@@ -151,8 +151,8 @@ def _show_queue(queue):
for rid, run_params in queue:
row = [rid, run_params["file"]]
for x in run_params["unit"], run_params["timeout"]:
row.append("-" if x is None else x)
row.append(format_run_arguments(run_params["arguments"]))
row.append("" if x is None else x)
row.append(format_arguments(run_params["arguments"]))
table.add_row(row)
print(table)
else:
@@ -169,8 +169,8 @@ def _show_timed(timed):
row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)),
trid, run_params["file"]]
for x in run_params["unit"], run_params["timeout"]:
row.append("-" if x is None else x)
row.append(format_run_arguments(run_params["arguments"]))
row.append("" if x is None else x)
row.append(format_arguments(run_params["arguments"]))
table.add_row(row)
print(table)
else:
10 changes: 5 additions & 5 deletions artiq/gui/scheduler.py
Original file line number Diff line number Diff line change
@@ -5,16 +5,16 @@

from artiq.gui.tools import Window, ListSyncer, DictSyncer
from artiq.protocols.sync_struct import Subscriber
from artiq.tools import format_run_arguments
from artiq.tools import format_arguments


class _QueueStoreSyncer(ListSyncer):
def convert(self, x):
rid, run_params = x
row = [rid, run_params["file"]]
for e in run_params["unit"], run_params["timeout"]:
row.append("-" if e is None else str(e))
row.append(format_run_arguments(run_params["arguments"]))
row.append("" if e is None else str(e))
row.append(format_arguments(run_params["arguments"]))
return row


@@ -28,8 +28,8 @@ def convert(self, trid, x):
row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)),
trid, run_params["file"]]
for e in run_params["unit"], run_params["timeout"]:
row.append("-" if e is None else str(e))
row.append(format_run_arguments(run_params["arguments"]))
row.append("" if e is None else str(e))
row.append(format_arguments(run_params["arguments"]))
return row


23 changes: 23 additions & 0 deletions artiq/language/units.py
Original file line number Diff line number Diff line change
@@ -239,3 +239,26 @@ def check_unit(value, unit):
else:
if not isinstance(value, Quantity) or value.unit != unit:
raise DimensionError

def strip_unit(value, unit):
"""Check that the value has the specified unit and returns its amount.
Raises ``DimensionError`` if the units does not match.
If the passed value is not a ``Quantity``, it is assumed to be in the
specified unit and is returned unchanged.
If ``unit`` is ``None``, passing a ``Quantity`` as value raises
``DimensionError``.
"""
if unit is None:
if isinstance(value, Quantity):
raise DimensionError
else:
return value
else:
if isinstance(value, Quantity):
if value.unit != unit:
raise DimensionError
else:
return value.amount
18 changes: 18 additions & 0 deletions artiq/protocols/pc_rpc.py
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@

from artiq.protocols import pyon
from artiq.protocols.asyncio_server import AsyncioServer as _AsyncioServer
from artiq.tools import format_arguments


logger = logging.getLogger(__name__)
@@ -373,6 +374,22 @@ def proxy(*args, **kwargs):
return proxy


class _PrettyPrintCall:
def __init__(self, obj):
self.obj = obj

def __str__(self):
r = self.obj["name"] + "("
args = ", ".join([repr(a) for a in self.obj["args"]])
r += args
kwargs = format_arguments(self.obj["kwargs"])
if args and kwargs:
r += ", "
r += kwargs
r += ")"
return r


class Server(_AsyncioServer):
"""This class creates a TCP server that handles requests coming from
``Client`` objects.
@@ -435,6 +452,7 @@ def _handle_connection_cr(self, reader, writer):
inspect.getdoc(method))
obj = {"status": "ok", "ret": methods}
elif obj["action"] == "call":
logger.debug("calling %s", _PrettyPrintCall(obj))
method = getattr(target, obj["name"])
ret = method(*obj["args"], **obj["kwargs"])
obj = {"status": "ok", "ret": ret}
8 changes: 4 additions & 4 deletions artiq/tools.py
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@
import os.path


def format_run_arguments(arguments):
def format_arguments(arguments):
fmtargs = []
for k, v in sorted(arguments.items(), key=itemgetter(0)):
fmtargs.append(k + "=" + str(v))
fmtargs.append(k + "=" + repr(v))
if fmtargs:
return " ".join(fmtargs)
return ", ".join(fmtargs)
else:
return "-"
return ""


def file_import(filename):
3 changes: 0 additions & 3 deletions benchmarks/all.py
Original file line number Diff line number Diff line change
@@ -2,9 +2,6 @@

import pulse_rate, rtio_skew, rpc_timing

from pulse_rate import PulseRate
from rtio_skew import RTIOSkew

_units = [pulse_rate.PulseRate, rtio_skew.RTIOSkew, rpc_timing.RPCTiming]

class AllBenchmarks(AutoDB):
File renamed without changes.