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: a120a09d792a
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: 0faa2d56b4a1
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on May 28, 2016

  1. Copy the full SHA
    7851391 View commit details
  2. Copy the full SHA
    8b556ef View commit details
  3. Copy the full SHA
    0faa2d5 View commit details
Showing with 62 additions and 15 deletions.
  1. +2 −0 RELEASE_NOTES.rst
  2. +2 −2 artiq/examples/master/repository/arguments_demo.py
  3. +4 −2 artiq/frontend/artiq_compile.py
  4. +27 −6 artiq/language/environment.py
  5. +27 −5 artiq/language/scan.py
2 changes: 2 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ unreleased [2.x]
has been replaced. Pass the parent as first argument instead.
* In the dashboard's experiment windows, partial or full argument recomputation
takes into account the repository revision field.
* By default, ``NumberValue`` and ``Scannable`` infer the scale from the unit
for common units.


1.1 (unreleased)
4 changes: 2 additions & 2 deletions artiq/examples/master/repository/arguments_demo.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ class SubComponent1(HasEnvironment):
def build(self):
self.setattr_argument("sc1_scan",
Scannable(default=[NoScan(3250), RandomScan(10, 20, 6)],
scale=1e3, unit="kHz"),
unit="kHz"),
"Flux capacitor")
self.setattr_argument("sc1_enum", EnumerationValue(["1", "2", "3"]),
"Flux capacitor")
@@ -43,7 +43,7 @@ def build(self):
self.setattr_argument("pyon_value",
PYONValue(self.get_dataset("foo", default=42)))
self.setattr_argument("number", NumberValue(42e-6,
unit="us", scale=1e-6,
unit="us",
ndecimals=4))
self.setattr_argument("integer", NumberValue(42,
step=1, ndecimals=0))
6 changes: 4 additions & 2 deletions artiq/frontend/artiq_compile.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

from artiq.master.databases import DeviceDB, DatasetDB
from artiq.master.worker_db import DeviceManager, DatasetManager
from artiq.language.environment import ProcessArgumentManager
from artiq.coredevice.core import CompileError
from artiq.tools import *

@@ -44,14 +45,15 @@ def main():
module = file_import(args.file, prefix="artiq_run_")
exp = get_experiment(module, args.experiment)
arguments = parse_arguments(args.arguments)
exp_inst = exp(device_mgr, dataset_mgr, **arguments)
argument_mgr = ProcessArgumentManager(arguments)
exp_inst = exp((device_mgr, dataset_mgr, argument_mgr))

if not hasattr(exp.run, "artiq_embedded"):
raise ValueError("Experiment entry point must be a kernel")
core_name = exp.run.artiq_embedded.core_name
core = getattr(exp_inst, core_name)

object_map, kernel_library, symbolizer = \
object_map, kernel_library, _, _ = \
core.compile(exp.run, [exp_inst], {},
with_attr_writeback=False)
except CompileError as error:
33 changes: 27 additions & 6 deletions artiq/language/environment.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
from inspect import isclass

from artiq.protocols import pyon
from artiq.language import units


__all__ = ["NoDefault",
@@ -79,7 +80,6 @@ def describe(self):
d["choices"] = self.choices
return d


class NumberValue(_SimpleArgProcessor):
"""An argument that can take a numerical value.
@@ -88,18 +88,39 @@ class NumberValue(_SimpleArgProcessor):
The simplest way to represent an integer argument is
``NumberValue(step=1, ndecimals=0)``.
:param unit: A string representing the unit of the value, for user
interface (UI) purposes.
:param scale: The scale of value for UI purposes. The displayed value is
divided by the scale.
When ``scale`` is not specified, and the unit is a common one (i.e.
defined in ``artiq.language.units``), then the scale is obtained from
the unit using a simple string match. For example, milliseconds (``"ms"``)
units set the scale to 0.001. No unit (default) corresponds to a scale of
1.0.
For arguments with uncommon or complex units, use both the unit parameter
(a string for display) and the scale parameter (a numerical scale for
experiments).
For example, ``NumberValue(1, unit="xyz", scale=0.001)`` will display as
1 xyz in the GUI window because of the unit setting, and appear as the
numerical value 0.001 in the code because of the scale setting.
:param unit: A string representing the unit of the value.
:param scale: A numerical scaling factor by which the displayed value is
multiplied when referenced in the experiment.
:param step: The step with which the value should be modified by up/down
buttons in a UI. The default is the scale divided by 10.
:param min: The minimum value of the argument.
:param max: The maximum value of the argument.
:param ndecimals: The number of decimals a UI should use.
"""
def __init__(self, default=NoDefault, unit="", scale=1.0,
def __init__(self, default=NoDefault, unit="", scale=None,
step=None, min=None, max=None, ndecimals=2):
if scale is None:
if unit == "":
scale = 1.0
else:
try:
scale = getattr(units, unit)
except AttributeError:
raise KeyError("Unit {} is unknown, you must specify "
"the scale manually".format(unit))
if step is None:
step = scale/10.0
if default is not NoDefault:
32 changes: 27 additions & 5 deletions artiq/language/scan.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@

from artiq.language.core import *
from artiq.language.environment import NoDefault, DefaultMissing
from artiq.language import units


__all__ = ["ScanObject",
@@ -143,6 +144,19 @@ class Scannable:
"""An argument (as defined in :class:`artiq.language.environment`) that
takes a scan object.
When ``scale`` is not specified, and the unit is a common one (i.e.
defined in ``artiq.language.units``), then the scale is obtained from
the unit using a simple string match. For example, milliseconds (``"ms"``)
units set the scale to 0.001. No unit (default) corresponds to a scale of
1.0.
For arguments with uncommon or complex units, use both the unit parameter
(a string for display) and the scale parameter (a numerical scale for
experiments).
For example, a scan shown between 1 xyz and 10 xyz in the GUI with
``scale=0.001`` and ``unit="xyz"`` results in values between 0.001 and
0.01 being scanned.
:param default: The default scan object. This parameter can be a list of
scan objects, in which case the first one is used as default and the
others are used to configure the default values of scan types that are
@@ -154,15 +168,23 @@ class Scannable:
:param global_step: The step with which the value should be modified by
up/down buttons in a user interface. The default is the scale divided
by 10.
:param unit: A string representing the unit of the scanned variable, for
user interface (UI) purposes.
:param scale: The scale of value for UI purposes. The displayed value is
divided by the scale.
:param unit: A string representing the unit of the scanned variable.
:param scale: A numerical scaling factor by which the displayed values
are multiplied when referenced in the experiment.
:param ndecimals: The number of decimals a UI should use.
"""
def __init__(self, default=NoDefault, unit="", scale=1.0,
def __init__(self, default=NoDefault, unit="", scale=None,
global_step=None, global_min=None, global_max=None,
ndecimals=2):
if scale is None:
if unit == "":
scale = 1.0
else:
try:
scale = getattr(units, unit)
except AttributeError:
raise KeyError("Unit {} is unknown, you must specify "
"the scale manually".format(unit))
if global_step is None:
global_step = scale/10.0
if default is not NoDefault: