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: ef8b09d9bcdd
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: 05dd11a60d21
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 25, 2015

  1. Copy the full SHA
    5979f85 View commit details
  2. Copy the full SHA
    9fe6576 View commit details
  3. Copy the full SHA
    8bc1dd9 View commit details
  4. Copy the full SHA
    05dd11a View commit details
Showing with 37 additions and 3 deletions.
  1. +2 −0 artiq/gui/console.py
  2. +9 −0 artiq/gui/log.py
  3. +23 −1 artiq/protocols/pyon.py
  4. +3 −2 artiq/test/serialization.py
2 changes: 2 additions & 0 deletions artiq/gui/console.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@


_help = """
This is an interactive Python console.
The following functions are available:
get_parameter(key)
set_parameter(key, value) [asynchronous update]
9 changes: 9 additions & 0 deletions artiq/gui/log.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,15 @@ def __init__(self, parent, init):
ListSyncModel.__init__(self,
["RID", "Message"],
parent, init)
self.fixed_font = QtGui.QFont()
self.fixed_font.setFamily("Monospace")

def data(self, index, role):
if (role == QtCore.Qt.FontRole and index.isValid()
and index.column() == 1):
return self.fixed_font
else:
return ListSyncModel.data(self, index, role)

def convert(self, v, column):
return v[column]
24 changes: 23 additions & 1 deletion artiq/protocols/pyon.py
Original file line number Diff line number Diff line change
@@ -39,6 +39,16 @@
numpy.ndarray: "nparray"
}

_numpy_scalar = {
"int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64",
"float16", "float32", "float64"
}


for _t in _numpy_scalar:
_encode_map[getattr(numpy, _t)] = "npscalar"


class _Encoder:
def __init__(self, pretty):
self.pretty = pretty
@@ -114,6 +124,13 @@ def encode_nparray(self, x):
r += ")"
return r

def encode_npscalar(self, x):
r = "npscalar("
r += "\"" + type(x).__name__ + "\", "
r += encode(base64.b64encode(x).decode())
r += ")"
return r

def encode(self, x):
return getattr(self, "encode_" + _encode_map[type(x)])(x)

@@ -131,6 +148,10 @@ def _nparray(shape, dtype, data):
return a.reshape(shape)


def _npscalar(ty, data):
return numpy.frombuffer(base64.b64decode(data), dtype=ty)[0]


_eval_dict = {
"__builtins__": None,

@@ -139,7 +160,8 @@ def _nparray(shape, dtype, data):
"true": True,

"Fraction": Fraction,
"nparray": _nparray
"nparray": _nparray,
"npscalar": _npscalar
}

def decode(s):
5 changes: 3 additions & 2 deletions artiq/test/serialization.py
Original file line number Diff line number Diff line change
@@ -4,14 +4,15 @@

import numpy as np

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


_pyon_test_object = {
(1, 2): [(3, 4.2), (2, )],
Fraction(3, 4): np.linspace(5, 10, 1),
"frequency": 10*GHz
"a": np.int8(9), "b": np.int16(-98), "c": np.int32(42), "d": np.int64(-5),
"e": np.uint8(8), "f": np.uint16(5), "g": np.uint32(4), "h": np.uint64(9),
"x": np.float16(9.0), "y": np.float32(9.0), "z": np.float64(9.0),
}