mirror of https://github.com/m-labs/artiq.git
language: support setting slices of data in mutate_dataset
This commit is contained in:
parent
9dcd43fb0d
commit
77280a75d9
|
@ -291,7 +291,12 @@ class HasEnvironment:
|
||||||
a given position in a NumPy array)
|
a given position in a NumPy array)
|
||||||
|
|
||||||
If the dataset was created in broadcast mode, the modification is
|
If the dataset was created in broadcast mode, the modification is
|
||||||
immediately transmitted."""
|
immediately transmitted.
|
||||||
|
|
||||||
|
If the index is a tuple of integers, it is interpreted as
|
||||||
|
``slice(*index)``.
|
||||||
|
If the index is a tuple of tuples, each sub-tuple is interpreted
|
||||||
|
as ``slice(*sub_tuple)`` (multi-dimensional slicing)."""
|
||||||
if self.__parent is not None:
|
if self.__parent is not None:
|
||||||
self.__parent.mutate_dataset(key, index, value)
|
self.__parent.mutate_dataset(key, index, value)
|
||||||
if self.__dataset_mgr is None:
|
if self.__dataset_mgr is None:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from operator import setitem
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
@ -169,7 +170,13 @@ class DatasetManager:
|
||||||
target = self.broadcast[key][1]
|
target = self.broadcast[key][1]
|
||||||
if target is None:
|
if target is None:
|
||||||
raise KeyError("Cannot mutate non-existing dataset")
|
raise KeyError("Cannot mutate non-existing dataset")
|
||||||
target[index] = value
|
|
||||||
|
if isinstance(index, tuple):
|
||||||
|
if isinstance(index[0], tuple):
|
||||||
|
index = tuple(slice(*e) for e in index)
|
||||||
|
else:
|
||||||
|
index = slice(*index)
|
||||||
|
setitem(target, index, value)
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
if key in self.local:
|
if key in self.local:
|
||||||
|
|
Loading…
Reference in New Issue