Skip to content

Commit

Permalink
pyon: support slices
Browse files Browse the repository at this point in the history
sbourdeauducq committed Jun 15, 2016
1 parent 46b75db commit e56c50a
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions artiq/protocols/pyon.py
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
list: "list",
set: "set",
dict: "dict",
slice: "slice",
wrapping_int: "number",
Fraction: "fraction",
OrderedDict: "ordereddict",
@@ -127,6 +128,9 @@ def encode_dict(self, x):
r += "}"
return r

def encode_slice(self, x):
return repr(x)

def encode_fraction(self, x):
return "Fraction({}, {})".format(self.encode(x.numerator),
self.encode(x.denominator))
@@ -178,6 +182,7 @@ def _npscalar(ty, data):
"null": None,
"false": False,
"true": True,
"slice": slice,

"int": wrapping_int,
"Fraction": Fraction,
1 change: 1 addition & 0 deletions artiq/test/test_serialization.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@

_pyon_test_object = {
(1, 2): [(3, 4.2), (2, )],
"slice": slice(3),
Fraction(3, 4): np.linspace(5, 10, 1),
"set": {"testing", "sets"},
"a": np.int8(9), "b": np.int16(-98), "c": np.int32(42), "d": np.int64(-5),
1 change: 1 addition & 0 deletions artiq/test/test_sync_struct.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ def write_test_data(test_dict):
test_dict[key] = value
test_dict[1.5] = 1.5
test_dict["list"] = []
test_dict["list"][:] = [34, 31]
test_dict["list"].append(42)
test_dict["list"].insert(1, 1)
test_dict[100] = 0

0 comments on commit e56c50a

Please sign in to comment.